airaknit 1.1.2-rc.9
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.
- package/LICENSE +84 -0
- package/README.md +202 -0
- package/bin/airaknit +9 -0
- package/bin/airaknit-project +14 -0
- package/bin/kanna +9 -0
- package/dist/client/assets/CompactSummaryMessage-Yw0BDWEJ.js +1 -0
- package/dist/client/assets/ExitPlanModeMessage-DIdkQ4uF.js +1 -0
- package/dist/client/assets/LocalFilePreviewDialog-DQx2eiCc.js +3 -0
- package/dist/client/assets/LocalProjectsSection-C4xlWkgS.js +1 -0
- package/dist/client/assets/TextMessage-B5G39DEJ.js +1 -0
- package/dist/client/assets/UserMessage-CIkWk-0L.js +1 -0
- package/dist/client/assets/_basePickBy-CVrAFfnZ.js +1 -0
- package/dist/client/assets/_baseUniq-JL-aaF4P.js +1 -0
- package/dist/client/assets/arc-B07zg7ol.js +1 -0
- package/dist/client/assets/architecture-YZFGNWBL-PSLVJL3p.js +1 -0
- package/dist/client/assets/architectureDiagram-Q4EWVU46-DfWIF1G_.js +36 -0
- package/dist/client/assets/array-BGFCBI0e.js +1 -0
- package/dist/client/assets/blockDiagram-DXYQGD6D-CzwIeo_B.js +132 -0
- package/dist/client/assets/bundle-mjs-BDE2gWbQ.js +1 -0
- package/dist/client/assets/button-DO50qOGv.js +1 -0
- package/dist/client/assets/c4Diagram-AHTNJAMY-CR8DCQRE.js +10 -0
- package/dist/client/assets/channel-Dj-UUfaF.js +1 -0
- package/dist/client/assets/chunk-2KRD3SAO-dznP-cn8.js +1 -0
- package/dist/client/assets/chunk-336JU56O-Dqss5Vu6.js +2 -0
- package/dist/client/assets/chunk-426QAEUC-CEKis_0_.js +1 -0
- package/dist/client/assets/chunk-4BX2VUAB-BYOv0Gm1.js +1 -0
- package/dist/client/assets/chunk-4TB4RGXK-BxzubH5S.js +206 -0
- package/dist/client/assets/chunk-55IACEB6-BSlTj03a.js +1 -0
- package/dist/client/assets/chunk-5FUZZQ4R-9Au93Bi1.js +62 -0
- package/dist/client/assets/chunk-5PVQY5BW-BhksHFEZ.js +2 -0
- package/dist/client/assets/chunk-67CJDMHE-BFwhz-8t.js +1 -0
- package/dist/client/assets/chunk-7N4EOEYR-BDUPds87.js +1 -0
- package/dist/client/assets/chunk-AA7GKIK3-CEWTdyXO.js +1 -0
- package/dist/client/assets/chunk-BO2N2NFS-D0LvxnhU.js +103 -0
- package/dist/client/assets/chunk-BSJP7CBP-BNJnK6sq.js +1 -0
- package/dist/client/assets/chunk-Bj-mKKzh.js +1 -0
- package/dist/client/assets/chunk-CIAEETIT-CYhfoCeN.js +1 -0
- package/dist/client/assets/chunk-EDXVE4YY-C5ovJLc0.js +1 -0
- package/dist/client/assets/chunk-ENJZ2VHE-HOhYaeGr.js +10 -0
- package/dist/client/assets/chunk-FMBD7UC4-BLCiKcAQ.js +15 -0
- package/dist/client/assets/chunk-FOC6F5B3-B6GtY2ek.js +1 -0
- package/dist/client/assets/chunk-ICPOFSXX-DPoIZoC5.js +122 -0
- package/dist/client/assets/chunk-K5T4RW27-BsKN63rv.js +94 -0
- package/dist/client/assets/chunk-KGLVRYIC-BUGn9uuY.js +1 -0
- package/dist/client/assets/chunk-LIHQZDEY-DhaZyo03.js +1 -0
- package/dist/client/assets/chunk-ORNJ4GCN-DlpeeJyi.js +1 -0
- package/dist/client/assets/chunk-OYMX7WX6-Dc9q7aYA.js +231 -0
- package/dist/client/assets/chunk-QZHKN3VN-BEdrPoSb.js +1 -0
- package/dist/client/assets/chunk-U2HBQHQK-CIB3Bjjd.js +70 -0
- package/dist/client/assets/chunk-X2U36JSP-CtB-o8Yp.js +1 -0
- package/dist/client/assets/chunk-XPW4576I-C6iHhX_8.js +32 -0
- package/dist/client/assets/chunk-YZCP3GAM-CTmKr6ZH.js +1 -0
- package/dist/client/assets/chunk-ZZ45TVLE-BgU8A2RF.js +1 -0
- package/dist/client/assets/classDiagram-6PBFFD2Q-Bqk5e679.js +1 -0
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-6pSaZOkC.js +1 -0
- package/dist/client/assets/client-BrKWI4CM.js +1 -0
- package/dist/client/assets/client-CGgNRU9w.js +1 -0
- package/dist/client/assets/client-DMSLRzg9.js +6 -0
- package/dist/client/assets/clone-DWcL7whJ.js +1 -0
- package/dist/client/assets/cose-bilkent-S5V4N54A-CrV5wsV_.js +1 -0
- package/dist/client/assets/cytoscape.esm--aLzKuep.js +321 -0
- package/dist/client/assets/dagre-CuRxWcrj.js +1 -0
- package/dist/client/assets/dagre-KV5264BT-BIDiVnkA.js +4 -0
- package/dist/client/assets/defaultLocale-CRZydyG6.js +1 -0
- package/dist/client/assets/diagram-5BDNPKRD-i1kjKRCB.js +10 -0
- package/dist/client/assets/diagram-G4DWMVQ6-9ZSLuhbl.js +24 -0
- package/dist/client/assets/diagram-MMDJMWI5-B4_CUjgv.js +43 -0
- package/dist/client/assets/diagram-TYMM5635-Ct5eTGS8.js +24 -0
- package/dist/client/assets/dist-CuB4kiSK.js +1 -0
- package/dist/client/assets/erDiagram-SMLLAGMA-Cy38ercc.js +85 -0
- package/dist/client/assets/flowDiagram-DWJPFMVM-CZKuYl0V.js +162 -0
- package/dist/client/assets/ganttDiagram-T4ZO3ILL-DLPjCh7a.js +292 -0
- package/dist/client/assets/gitGraph-7Q5UKJZL-DqbrtEp9.js +1 -0
- package/dist/client/assets/gitGraphDiagram-UUTBAWPF-BoRBkDhQ.js +106 -0
- package/dist/client/assets/graphlib-BcQ6qlQh.js +1 -0
- package/dist/client/assets/highlighted-body-OFNGDK62-BEpBVDTX.js +1 -0
- package/dist/client/assets/index-CetCiuqP.js +105 -0
- package/dist/client/assets/index-N29Mip7A.css +1 -0
- package/dist/client/assets/info-OMHHGYJF-D98DRBJX.js +1 -0
- package/dist/client/assets/infoDiagram-42DDH7IO-BAcdTWbt.js +2 -0
- package/dist/client/assets/init-B8gtcn7T.js +1 -0
- package/dist/client/assets/isArrayLikeObject-D8SJFmkN.js +1 -0
- package/dist/client/assets/isEmpty-BF3YX5Jk.js +1 -0
- package/dist/client/assets/ishikawaDiagram-UXIWVN3A-Ynu2VKdC.js +70 -0
- package/dist/client/assets/journeyDiagram-VCZTEJTY-BjfhQaN3.js +139 -0
- package/dist/client/assets/jsx-runtime-CyI9ICYU.js +1 -0
- package/dist/client/assets/kanban-definition-6JOO6SKY-JLXH9zUJ.js +89 -0
- package/dist/client/assets/katex-B94qP8b6.js +265 -0
- package/dist/client/assets/lib--QVjyxmL.js +29 -0
- package/dist/client/assets/lib-B6rgJiZ9.js +1 -0
- package/dist/client/assets/line-DCrYfLBn.js +1 -0
- package/dist/client/assets/linear-_4upLmeo.js +1 -0
- package/dist/client/assets/mermaid-GHXKKRXX-rwJHYUmW.js +1 -0
- package/dist/client/assets/mermaid-parser.core-KZinfW8o.js +4 -0
- package/dist/client/assets/mermaid.core-QqY9gSNe.js +11 -0
- package/dist/client/assets/mindmap-definition-QFDTVHPH-TWgHDAzp.js +96 -0
- package/dist/client/assets/ordinal-CCj7PWgZ.js +1 -0
- package/dist/client/assets/packet-4T2RLAQJ-DEvfkn3F.js +1 -0
- package/dist/client/assets/path-DZF-JdEe.js +1 -0
- package/dist/client/assets/pie-ZZUOXDRM-72e6WVjb.js +1 -0
- package/dist/client/assets/pieDiagram-DEJITSTG-Cl8PCsoj.js +30 -0
- package/dist/client/assets/preload-helper-rov5CBGT.js +1 -0
- package/dist/client/assets/pty-client-DZ27IS00.js +1 -0
- package/dist/client/assets/ptyInstancesStore-D9ag7SYd.js +1 -0
- package/dist/client/assets/quadrantDiagram-34T5L4WZ-CHyVGp9E.js +7 -0
- package/dist/client/assets/radar-PYXPWWZC-Cp7xd_EY.js +1 -0
- package/dist/client/assets/react-CClhXMB2.js +1 -0
- package/dist/client/assets/react-Dd6D81m0.js +1 -0
- package/dist/client/assets/react-dom--G6_6fQ_.js +1 -0
- package/dist/client/assets/requirementDiagram-MS252O5E-DaanG2iM.js +84 -0
- package/dist/client/assets/rough.esm-BsmKo2S5.js +1 -0
- package/dist/client/assets/sankeyDiagram-XADWPNL6-B_fhLY36.js +10 -0
- package/dist/client/assets/sequenceDiagram-FGHM5R23-C5FNrveI.js +157 -0
- package/dist/client/assets/src-DeTlMJAU.js +1 -0
- package/dist/client/assets/stateDiagram-FHFEXIEX-nTTcdjjQ.js +1 -0
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-Dw0632j_.js +1 -0
- package/dist/client/assets/timeline-definition-GMOUNBTQ-DkQV1yP8.js +120 -0
- package/dist/client/assets/treeView-SZITEDCU-ZLIgC7_K.js +1 -0
- package/dist/client/assets/treemap-W4RFUUIX-BqaMbB6N.js +1 -0
- package/dist/client/assets/uiIdentityOverlay-Ba7GNj7m.js +1 -0
- package/dist/client/assets/vennDiagram-DHZGUBPP-DbZ2xgs6.js +34 -0
- package/dist/client/assets/wardley-RL74JXVD-DXQS8zf4.js +1 -0
- package/dist/client/assets/wardleyDiagram-NUSXRM2D-BzCJ6MAu.js +20 -0
- package/dist/client/assets/xychartDiagram-5P7HB3ND-BSlFecop.js +7 -0
- package/dist/client/favicon.png +0 -0
- package/dist/client/favicon.svg +15 -0
- package/dist/client/fonts/body-medium.woff2 +0 -0
- package/dist/client/fonts/body-regular-italic.woff2 +0 -0
- package/dist/client/fonts/body-regular.woff2 +0 -0
- package/dist/client/fonts/body-semibold.woff2 +0 -0
- package/dist/client/index.html +31 -0
- package/dist/client/manifest.webmanifest +12 -0
- package/dist/client/sw.js +32 -0
- package/package.json +122 -0
- package/src/nats/auth-callout/callout-config.test.ts +93 -0
- package/src/nats/auth-callout/callout-config.ts +109 -0
- package/src/nats/auth-callout/callout.integration.test.ts +332 -0
- package/src/nats/auth-callout/keys.ts +103 -0
- package/src/nats/auth-callout/responder.ts +241 -0
- package/src/nats/auth-callout/scope-policy.test.ts +159 -0
- package/src/nats/auth-callout/scope-policy.ts +210 -0
- package/src/nats/auth-callout/token.test.ts +163 -0
- package/src/nats/auth-callout/token.ts +157 -0
- package/src/nats/nats-daemon-callout.ts +194 -0
- package/src/nats/nats-daemon.test.ts +77 -0
- package/src/nats/nats-daemon.ts +50 -0
- package/src/nats/nats-token.test.ts +61 -0
- package/src/nats/nats-token.ts +59 -0
- package/src/runner/coordination-mcp-integration.test.ts +134 -0
- package/src/runner/nats-coordination-client.test.ts +49 -0
- package/src/runner/nats-coordination-client.ts +94 -0
- package/src/runner/runner-agent.test.ts +469 -0
- package/src/runner/runner-agent.ts +453 -0
- package/src/runner/runner-credential.test.ts +93 -0
- package/src/runner/runner-credential.ts +82 -0
- package/src/runner/runner-nats.test.ts +495 -0
- package/src/runner/runner-nats.ts +323 -0
- package/src/runner/runner-pair.test.ts +107 -0
- package/src/runner/runner-pair.ts +81 -0
- package/src/runner/runner.test.ts +135 -0
- package/src/runner/runner.ts +212 -0
- package/src/runner/turn-factories.test.ts +97 -0
- package/src/runner/turn-factories.ts +475 -0
- package/src/server/agent-config-journey.test.ts +106 -0
- package/src/server/agent.ts +8 -0
- package/src/server/auto-continue/auth-error-detector.ts +66 -0
- package/src/server/auto-continue/limit-detector.ts +194 -0
- package/src/server/bm25.test.ts +92 -0
- package/src/server/bm25.ts +101 -0
- package/src/server/chat-events-jetstream.test.ts +135 -0
- package/src/server/claude-harness.ts +360 -0
- package/src/server/claude-pty/agent-normalizers.ts +309 -0
- package/src/server/claude-pty/auth.test.ts +38 -0
- package/src/server/claude-pty/auth.ts +32 -0
- package/src/server/claude-pty/claude-session-registry.adapter.ts +81 -0
- package/src/server/claude-pty/claude-session-registry.test.ts +149 -0
- package/src/server/claude-pty/driver.test.ts +902 -0
- package/src/server/claude-pty/driver.ts +807 -0
- package/src/server/claude-pty/jsonl-path.adapter.ts +57 -0
- package/src/server/claude-pty/jsonl-path.test.ts +114 -0
- package/src/server/claude-pty/jsonl-to-event.test.ts +241 -0
- package/src/server/claude-pty/jsonl-to-event.ts +174 -0
- package/src/server/claude-pty/output-ring.test.ts +35 -0
- package/src/server/claude-pty/output-ring.ts +25 -0
- package/src/server/claude-pty/parity-matrix.test.ts +227 -0
- package/src/server/claude-pty/pid-registry.adapter.ts +135 -0
- package/src/server/claude-pty/pid-registry.test.ts +122 -0
- package/src/server/claude-pty/preflight/binary-fingerprint.adapter.ts +20 -0
- package/src/server/claude-pty/preflight/binary-fingerprint.test.ts +32 -0
- package/src/server/claude-pty/pty-instance-registry.test.ts +177 -0
- package/src/server/claude-pty/pty-instance-registry.ts +166 -0
- package/src/server/claude-pty/pty-memory-sampler.adapter.test.ts +103 -0
- package/src/server/claude-pty/pty-memory-sampler.adapter.ts +85 -0
- package/src/server/claude-pty/pty-process.adapter.ts +66 -0
- package/src/server/claude-pty/pty-process.test.ts +49 -0
- package/src/server/claude-pty/resolve-binary.adapter.ts +106 -0
- package/src/server/claude-pty/resolve-binary.test.ts +118 -0
- package/src/server/claude-pty/runtime-dir.adapter.ts +19 -0
- package/src/server/claude-pty/settings-writer.adapter.ts +27 -0
- package/src/server/claude-pty/settings-writer.test.ts +22 -0
- package/src/server/claude-pty/smoke-test-io.adapter.ts +28 -0
- package/src/server/claude-pty/smoke-test.test.ts +191 -0
- package/src/server/claude-pty/smoke-test.ts +185 -0
- package/src/server/claude-pty/subagent-orchestrator.ts +887 -0
- package/src/server/claude-pty/tool-callback.ts +274 -0
- package/src/server/claude-pty/tui-control.test.ts +272 -0
- package/src/server/claude-pty/tui-control.ts +182 -0
- package/src/server/claude-pty/tui-source.adapter.test.ts +360 -0
- package/src/server/claude-pty/tui-source.adapter.ts +343 -0
- package/src/server/claude-pty/tunnel-gateway.ts +12 -0
- package/src/server/claude-pty-mcp/canonical-args.ts +15 -0
- package/src/server/claude-pty-mcp/fs-stat.adapter.ts +8 -0
- package/src/server/claude-pty-mcp/history-primer.ts +90 -0
- package/src/server/claude-pty-mcp/http-server.adapter.ts +33 -0
- package/src/server/claude-pty-mcp/mcp-http.ts +177 -0
- package/src/server/claude-pty-mcp/mcp.ts +412 -0
- package/src/server/claude-pty-mcp/mention-parser.ts +25 -0
- package/src/server/claude-pty-mcp/paths.ts +24 -0
- package/src/server/claude-pty-mcp/permission-gate.ts +243 -0
- package/src/server/claude-pty-mcp/terminal-pid-registry.adapter.ts +107 -0
- package/src/server/claude-pty-mcp/tools/ask-user-question.test.ts +119 -0
- package/src/server/claude-pty-mcp/tools/ask-user-question.ts +61 -0
- package/src/server/claude-pty-mcp/tools/bash.adapter.ts +76 -0
- package/src/server/claude-pty-mcp/tools/bash.test.ts +56 -0
- package/src/server/claude-pty-mcp/tools/delegate-subagent.test.ts +155 -0
- package/src/server/claude-pty-mcp/tools/delegate-subagent.ts +111 -0
- package/src/server/claude-pty-mcp/tools/edit.adapter.ts +95 -0
- package/src/server/claude-pty-mcp/tools/edit.test.ts +93 -0
- package/src/server/claude-pty-mcp/tools/exit-plan-mode.test.ts +61 -0
- package/src/server/claude-pty-mcp/tools/exit-plan-mode.ts +50 -0
- package/src/server/claude-pty-mcp/tools/glob.adapter.ts +86 -0
- package/src/server/claude-pty-mcp/tools/glob.test.ts +61 -0
- package/src/server/claude-pty-mcp/tools/grep.adapter.ts +126 -0
- package/src/server/claude-pty-mcp/tools/grep.test.ts +62 -0
- package/src/server/claude-pty-mcp/tools/read.adapter.ts +58 -0
- package/src/server/claude-pty-mcp/tools/read.test.ts +62 -0
- package/src/server/claude-pty-mcp/tools/tool-callback-shim.ts +42 -0
- package/src/server/claude-pty-mcp/tools/webfetch.test.ts +81 -0
- package/src/server/claude-pty-mcp/tools/webfetch.ts +82 -0
- package/src/server/claude-pty-mcp/tools/websearch.test.ts +40 -0
- package/src/server/claude-pty-mcp/tools/websearch.ts +42 -0
- package/src/server/claude-pty-mcp/tools/write.adapter.ts +60 -0
- package/src/server/claude-pty-mcp/tools/write.test.ts +52 -0
- package/src/server/claude-pty-mcp/uploads.adapter.ts +98 -0
- package/src/server/claude-pty-mcp/uploads.ts +38 -0
- package/src/server/claude-turn.test.ts +176 -0
- package/src/server/cli-runtime.test.ts +456 -0
- package/src/server/cli-runtime.ts +374 -0
- package/src/server/cli-supervisor.ts +81 -0
- package/src/server/cli.ts +78 -0
- package/src/server/client-log-forwarder.test.ts +74 -0
- package/src/server/client-log-forwarder.ts +75 -0
- package/src/server/codex-app-server-protocol.ts +449 -0
- package/src/server/codex-app-server.test.ts +2990 -0
- package/src/server/codex-app-server.ts +1713 -0
- package/src/server/coordination-integration.test.ts +63 -0
- package/src/server/coordination-mcp.test.ts +149 -0
- package/src/server/coordination-mcp.ts +197 -0
- package/src/server/delegation-coordinator.test.ts +675 -0
- package/src/server/delegation-coordinator.ts +454 -0
- package/src/server/discovery.test.ts +211 -0
- package/src/server/discovery.ts +301 -0
- package/src/server/event-store-agent-config.test.ts +124 -0
- package/src/server/event-store-coordination.test.ts +149 -0
- package/src/server/event-store-profile.test.ts +132 -0
- package/src/server/event-store-repo.test.ts +154 -0
- package/src/server/event-store-runner-team.test.ts +104 -0
- package/src/server/event-store.test.ts +342 -0
- package/src/server/event-store.ts +2208 -0
- package/src/server/events.ts +379 -0
- package/src/server/extension-router.test.ts +183 -0
- package/src/server/extension-router.ts +114 -0
- package/src/server/extensions/agents/server.test.ts +191 -0
- package/src/server/extensions/agents/server.ts +108 -0
- package/src/server/extensions/c3/server.test.ts +284 -0
- package/src/server/extensions/c3/server.ts +212 -0
- package/src/server/extensions/code/server.test.ts +200 -0
- package/src/server/extensions/code/server.ts +150 -0
- package/src/server/extensions.config.ts +10 -0
- package/src/server/external-open.ts +69 -0
- package/src/server/generate-fork-context.ts +58 -0
- package/src/server/generate-merge-context.test.ts +290 -0
- package/src/server/generate-merge-context.ts +141 -0
- package/src/server/generate-title.ts +36 -0
- package/src/server/git-clone-policy.test.ts +138 -0
- package/src/server/git-clone-policy.ts +27 -0
- package/src/server/harness-types.ts +1 -0
- package/src/server/journey-verification.test.ts +640 -0
- package/src/server/journey-verification.ts +195 -0
- package/src/server/machine-name.ts +22 -0
- package/src/server/nats-auth.test.ts +92 -0
- package/src/server/nats-auth.ts +6 -0
- package/src/server/nats-bind-guard.test.ts +71 -0
- package/src/server/nats-bind-guard.ts +42 -0
- package/src/server/nats-bridge.test.ts +141 -0
- package/src/server/nats-bridge.ts +111 -0
- package/src/server/nats-connector.test.ts +56 -0
- package/src/server/nats-connector.ts +71 -0
- package/src/server/nats-daemon-manager.test.ts +76 -0
- package/src/server/nats-daemon-manager.ts +174 -0
- package/src/server/nats-publisher.test.ts +356 -0
- package/src/server/nats-publisher.ts +271 -0
- package/src/server/nats-responders.test.ts +1018 -0
- package/src/server/nats-responders.ts +925 -0
- package/src/server/nats-streams.test.ts +112 -0
- package/src/server/nats-streams.ts +129 -0
- package/src/server/oauth-pool/oauth-responders.ts +185 -0
- package/src/server/oauth-pool/oauth-settings-store.ts +173 -0
- package/src/server/oauth-pool/oauth-token-pool.ts +303 -0
- package/src/server/orchestration.test.ts +1063 -0
- package/src/server/orchestration.ts +716 -0
- package/src/server/pairing-endpoints.test.ts +171 -0
- package/src/server/pairing-store.test.ts +154 -0
- package/src/server/pairing-store.ts +124 -0
- package/src/server/paths.ts +27 -0
- package/src/server/pr3-liveness.test.ts +252 -0
- package/src/server/process-utils.ts +10 -0
- package/src/server/project-cli.ts +180 -0
- package/src/server/provider-catalog.test.ts +177 -0
- package/src/server/provider-catalog.ts +146 -0
- package/src/server/pty-responders.ts +345 -0
- package/src/server/push-notifications.test.ts +234 -0
- package/src/server/push-notifications.ts +188 -0
- package/src/server/quick-response.test.ts +196 -0
- package/src/server/quick-response.ts +154 -0
- package/src/server/read-models-agent-config.test.ts +59 -0
- package/src/server/read-models-coordination.test.ts +69 -0
- package/src/server/read-models.test.ts +332 -0
- package/src/server/read-models.ts +258 -0
- package/src/server/repo-journey.test.ts +96 -0
- package/src/server/repo-manager.test.ts +118 -0
- package/src/server/repo-manager.ts +97 -0
- package/src/server/repo-status.test.ts +54 -0
- package/src/server/repo-status.ts +82 -0
- package/src/server/restart.test.ts +27 -0
- package/src/server/restart.ts +30 -0
- package/src/server/runner-incompatible-gate.test.ts +383 -0
- package/src/server/runner-manager.test.ts +72 -0
- package/src/server/runner-manager.ts +312 -0
- package/src/server/runner-pairing-urls.test.ts +59 -0
- package/src/server/runner-pairing-urls.ts +67 -0
- package/src/server/runner-proxy.test.ts +456 -0
- package/src/server/runner-proxy.ts +494 -0
- package/src/server/runner-router.test.ts +429 -0
- package/src/server/runner-router.ts +212 -0
- package/src/server/runner-routing.test.ts +584 -0
- package/src/server/runtime-registry.test.ts +436 -0
- package/src/server/runtime-registry.ts +307 -0
- package/src/server/sandbox-health.test.ts +127 -0
- package/src/server/sandbox-health.ts +94 -0
- package/src/server/sandbox-journey.test.ts +232 -0
- package/src/server/sandbox-manager.test.ts +146 -0
- package/src/server/sandbox-manager.ts +159 -0
- package/src/server/server.test.ts +287 -0
- package/src/server/server.ts +1108 -0
- package/src/server/session-discovery.test.ts +129 -0
- package/src/server/session-discovery.ts +475 -0
- package/src/server/session-index.test.ts +362 -0
- package/src/server/session-index.ts +119 -0
- package/src/server/session-seed.ts +288 -0
- package/src/server/share.test.ts +108 -0
- package/src/server/share.ts +113 -0
- package/src/server/skill-discovery.test.ts +201 -0
- package/src/server/skill-discovery.ts +77 -0
- package/src/server/storage/test-helpers.ts +67 -0
- package/src/server/terminal-manager.test.ts +309 -0
- package/src/server/terminal-manager.ts +354 -0
- package/src/server/transcript-consumer.test.ts +339 -0
- package/src/server/transcript-consumer.ts +162 -0
- package/src/server/transcript-search.test.ts +193 -0
- package/src/server/transcript-search.ts +83 -0
- package/src/server/transcript-utils.ts +52 -0
- package/src/server/update-manager.test.ts +107 -0
- package/src/server/update-manager.ts +230 -0
- package/src/server/workflow-engine.test.ts +251 -0
- package/src/server/workflow-engine.ts +169 -0
- package/src/server/workflow-mcp.ts +49 -0
- package/src/server/workflow-store.test.ts +155 -0
- package/src/server/workflow-store.ts +139 -0
- package/src/server/workspace-agent-integration.test.ts +167 -0
- package/src/server/workspace-agent-routes.test.ts +127 -0
- package/src/server/workspace-agent-routes.ts +89 -0
- package/src/server/workspace-agent.test.ts +103 -0
- package/src/server/workspace-agent.ts +102 -0
- package/src/server/workspace-cli.test.ts +79 -0
- package/src/server/workspace-config-manager.test.ts +109 -0
- package/src/server/workspace-config-manager.ts +83 -0
- package/src/server/workspace-directory-policy.test.ts +109 -0
- package/src/server/workspace-directory-policy.ts +56 -0
- package/src/shared/agent-config-types.ts +25 -0
- package/src/shared/branding.test.ts +42 -0
- package/src/shared/branding.ts +54 -0
- package/src/shared/compression.test.ts +85 -0
- package/src/shared/compression.ts +42 -0
- package/src/shared/coordination-store.test.ts +24 -0
- package/src/shared/coordination-store.ts +26 -0
- package/src/shared/dev-ports.test.ts +84 -0
- package/src/shared/dev-ports.ts +100 -0
- package/src/shared/extension-types.ts +45 -0
- package/src/shared/fork-presets.ts +54 -0
- package/src/shared/harness-types.test.ts +15 -0
- package/src/shared/harness-types.ts +21 -0
- package/src/shared/log-sink.test.ts +112 -0
- package/src/shared/log-sink.ts +185 -0
- package/src/shared/mention-pattern.ts +7 -0
- package/src/shared/merge-presets.ts +41 -0
- package/src/shared/nats-subjects.test.ts +61 -0
- package/src/shared/nats-subjects.ts +131 -0
- package/src/shared/permission-policy.ts +136 -0
- package/src/shared/ports.ts +3 -0
- package/src/shared/preset-types.ts +15 -0
- package/src/shared/profile-types.ts +49 -0
- package/src/shared/projectFileUrl.ts +36 -0
- package/src/shared/protocol.ts +153 -0
- package/src/shared/pty-instance.ts +43 -0
- package/src/shared/puggy/diagnostics/result.ts +18 -0
- package/src/shared/puggy/expressions/evaluate.ts +292 -0
- package/src/shared/puggy/index.test.ts +101 -0
- package/src/shared/puggy/index.ts +69 -0
- package/src/shared/puggy/parser/ast.ts +110 -0
- package/src/shared/puggy/parser/parser.ts +624 -0
- package/src/shared/puggy/renderer/html.ts +447 -0
- package/src/shared/runner-protocol.test.ts +277 -0
- package/src/shared/runner-protocol.ts +210 -0
- package/src/shared/runner-team-types.ts +73 -0
- package/src/shared/runtime-types.ts +48 -0
- package/src/shared/sandbox-types.ts +53 -0
- package/src/shared/tailwind-build.test.ts +12 -0
- package/src/shared/tinkaria-system-prompt.ts +101 -0
- package/src/shared/tools.test.ts +335 -0
- package/src/shared/tools.ts +397 -0
- package/src/shared/transcript-entries.ts +27 -0
- package/src/shared/transcript-render.test.ts +225 -0
- package/src/shared/transcript-render.ts +467 -0
- package/src/shared/types.ts +1031 -0
- package/src/shared/vite-config.test.ts +47 -0
- package/src/shared/web-context.test.ts +110 -0
- package/src/shared/web-context.ts +76 -0
- package/src/shared/workflow-types.ts +51 -0
- package/src/shared/workspace-types.ts +100 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/client-DMSLRzg9.js","assets/chunk-Bj-mKKzh.js","assets/lib--QVjyxmL.js","assets/button-DO50qOGv.js","assets/bundle-mjs-BDE2gWbQ.js","assets/jsx-runtime-CyI9ICYU.js","assets/react-CClhXMB2.js","assets/uiIdentityOverlay-Ba7GNj7m.js","assets/lib-B6rgJiZ9.js","assets/client-CGgNRU9w.js","assets/client-BrKWI4CM.js","assets/mermaid.core-QqY9gSNe.js","assets/preload-helper-rov5CBGT.js","assets/chunk-U2HBQHQK-CIB3Bjjd.js","assets/src-DeTlMJAU.js","assets/chunk-5PVQY5BW-BhksHFEZ.js","assets/dist-CuB4kiSK.js","assets/chunk-ICPOFSXX-DPoIZoC5.js","assets/isArrayLikeObject-D8SJFmkN.js","assets/isEmpty-BF3YX5Jk.js","assets/chunk-336JU56O-Dqss5Vu6.js","assets/chunk-5FUZZQ4R-9Au93Bi1.js","assets/chunk-X2U36JSP-CtB-o8Yp.js","assets/chunk-ZZ45TVLE-BgU8A2RF.js","assets/rough.esm-BsmKo2S5.js","assets/chunk-ENJZ2VHE-HOhYaeGr.js","assets/line-DCrYfLBn.js","assets/path-DZF-JdEe.js","assets/array-BGFCBI0e.js","assets/chunk-BSJP7CBP-BNJnK6sq.js","assets/chunk-426QAEUC-CEKis_0_.js","assets/chunk-XPW4576I-C6iHhX_8.js","assets/TextMessage-B5G39DEJ.js","assets/chunk-BO2N2NFS-D0LvxnhU.js","assets/react-dom--G6_6fQ_.js","assets/UserMessage-CIkWk-0L.js","assets/ExitPlanModeMessage-DIdkQ4uF.js","assets/CompactSummaryMessage-Yw0BDWEJ.js","assets/LocalFilePreviewDialog-DQx2eiCc.js","assets/LocalProjectsSection-C4xlWkgS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,r as t,s as n,t as r}from"./chunk-Bj-mKKzh.js";import{t as i}from"./react-CClhXMB2.js";import{t as a}from"./react-dom--G6_6fQ_.js";import{t as o}from"./preload-helper-rov5CBGT.js";import{a as s,c,d as l,f as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./uiIdentityOverlay-Ba7GNj7m.js";import{i as y,n as b,r as x,t as S}from"./button-DO50qOGv.js";import{t as C}from"./jsx-runtime-CyI9ICYU.js";import{t as w}from"./react-Dd6D81m0.js";import{s as T}from"./lib--QVjyxmL.js";import{r as E}from"./chunk-BO2N2NFS-D0LvxnhU.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),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 D=r((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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(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`):w=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(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),O=r(((e,t)=>{t.exports=D()})),k=r((e=>{var t=O(),n=i(),r=a();function o(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 s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(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 l(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 u(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 d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x: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 E:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R={pending:!1,data:null,method:null,action:null},z=[],B=-1;function V(e){return{current:e}}function H(e){0>B||(e.current=z[B],z[B]=null,B--)}function U(e,t){B++,z[B]=e.current,e.current=t}var W=V(null),G=V(null),K=V(null),q=V(null);function J(e,t){switch(U(K,t),U(G,e),U(W,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}H(W),U(W,e)}function ee(){H(W),H(G),H(K)}function Y(e){e.memoizedState!==null&&U(q,e);var t=W.current,n=Hd(t,e.type);t!==n&&(U(G,e),U(W,n))}function te(e){G.current===e&&(H(W),H(G)),q.current===e&&(H(q),Qf._currentValue=R)}var ne,re;function ie(e){if(ne===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ne=t&&t[1]||``,re=-1<e.stack.indexOf(`
|
|
3
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
+
`+ne+e+re}var ae=!1;function oe(e,t){if(!e||ae)return``;ae=!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{ae=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ie(n):``}function se(e,t){switch(e.tag){case 26:case 27:case 5:return ie(e.type);case 16:return ie(`Lazy`);case 13:return e.child!==t&&t!==null?ie(`Suspense Fallback`):ie(`Suspense`);case 19:return ie(`SuspenseList`);case 0:case 15:return oe(e.type,!1);case 11:return oe(e.type.render,!1);case 1:return oe(e.type,!0);case 31:return ie(`Activity`);default:return``}}function ce(e){try{var t=``,n=null;do t+=se(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
+
Error generating stack: `+e.message+`
|
|
9
|
+
`+e.stack}}var le=Object.prototype.hasOwnProperty,ue=t.unstable_scheduleCallback,de=t.unstable_cancelCallback,fe=t.unstable_shouldYield,pe=t.unstable_requestPaint,me=t.unstable_now,he=t.unstable_getCurrentPriorityLevel,ge=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,ye=t.unstable_LowPriority,be=t.unstable_IdlePriority,X=t.log,xe=t.unstable_setDisableYieldValue,Se=null,Ce=null;function we(e){if(typeof X==`function`&&xe(e),Ce&&typeof Ce.setStrictMode==`function`)try{Ce.setStrictMode(Se,e)}catch{}}var Te=Math.clz32?Math.clz32:Oe,Ee=Math.log,De=Math.LN2;function Oe(e){return e>>>=0,e===0?32:31-(Ee(e)/De|0)|0}var ke=256,Ae=262144,je=4194304;function Me(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 Ne(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=Me(n))):i=Me(o):i=Me(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Me(n))):i=Me(o)):i=Me(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 Pe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Fe(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 Ie(){var e=je;return je<<=1,!(je&62914560)&&(je=4194304),e}function Le(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Re(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ze(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-Te(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&&Be(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Be(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Te(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ve(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Te(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function He(e,t){var n=t&-t;return n=n&42?1:Ue(n),(n&(e.suspendedLanes|t))===0?n:0}function Ue(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 We(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ge(){var e=L.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function Ke(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var qe=Math.random().toString(36).slice(2),Je=`__reactFiber$`+qe,Ye=`__reactProps$`+qe,Xe=`__reactContainer$`+qe,Ze=`__reactEvents$`+qe,Qe=`__reactListeners$`+qe,$e=`__reactHandles$`+qe,et=`__reactResources$`+qe,tt=`__reactMarker$`+qe;function nt(e){delete e[Je],delete e[Ye],delete e[Ze],delete e[Qe],delete e[$e]}function rt(e){var t=e[Je];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xe]||n[Je]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[Je])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function it(e){if(e=e[Je]||e[Xe]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function at(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ot(e){var t=e[et];return t||=e[et]={hoistableStyles:new Map,hoistableScripts:new Map},t}function st(e){e[tt]=!0}var ct=new Set,lt={};function ut(e,t){dt(e,t),dt(e+`Capture`,t)}function dt(e,t){for(lt[e]=t,e=0;e<t.length;e++)ct.add(t[e])}var ft=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={},mt={};function ht(e){return le.call(mt,e)?!0:le.call(pt,e)?!1:ft.test(e)?mt[e]=!0:(pt[e]=!0,!1)}function gt(e,t,n){if(ht(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 _t(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 vt(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 yt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function bt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function xt(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 St(e){if(!e._valueTracker){var t=bt(e)?`checked`:`value`;e._valueTracker=xt(e,t,``+e[t])}}function Ct(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=bt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function wt(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 Tt=/[\n"\\]/g;function Et(e){return e.replace(Tt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Dt(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=``+yt(t)):e.value!==``+yt(t)&&(e.value=``+yt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):kt(e,o,yt(n)):kt(e,o,yt(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=``+yt(s):e.removeAttribute(`name`)}function Ot(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)){St(e);return}n=n==null?``:``+yt(n),t=t==null?n:``+yt(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),St(e)}function kt(e,t,n){t===`number`&&wt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function At(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=``+yt(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 jt(e,t,n){if(t!=null&&(t=``+yt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+yt(n)}function Mt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(F(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=yt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),St(e)}function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pt=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 Ft(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||Pt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function It(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(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 i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&Ft(e,i,r)}else for(var a in t)t.hasOwnProperty(a)&&Ft(e,a,t[a])}function Lt(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 Rt=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`]]),zt=/^[\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 Bt(e){return zt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Vt(){}var Ht=null;function Ut(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wt=null,Gt=null;function Kt(e){var t=it(e);if(t&&(e=t.stateNode)){var n=e[Ye]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Dt(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="`+Et(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[Ye]||null;if(!i)throw Error(o(90));Dt(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ct(r)}break a;case`textarea`:jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&At(e,!!n.multiple,t,!1)}}}var qt=!1;function Jt(e,t,n){if(qt)return e(t,n);qt=!0;try{return e(t)}finally{if(qt=!1,(Wt!==null||Gt!==null)&&(_u(),Wt&&(t=Wt,e=Gt,Gt=Wt=null,Kt(t),e)))for(t=0;t<e.length;t++)Kt(e[t])}}function Yt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Ye]||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(o(231,t,typeof n));return n}var Xt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Zt=!1;if(Xt)try{var Qt={};Object.defineProperty(Qt,`passive`,{get:function(){Zt=!0}}),window.addEventListener(`test`,Qt,Qt),window.removeEventListener(`test`,Qt,Qt)}catch{Zt=!1}var $t=null,en=null,tn=null;function nn(){if(tn)return tn;var e,t=en,n=t.length,r,i=`value`in $t?$t.value:$t.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 tn=i.slice(e,1<r?1-r:void 0)}function rn(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 an(){return!0}function on(){return!1}function sn(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)?an:on,this.isPropagationStopped=on,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=an)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=an)},persist:function(){},isPersistent:an}),t}var cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ln=sn(cn),un=m({},cn,{view:0,detail:0}),dn=sn(un),fn,pn,mn,hn=m({},un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:En,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!==mn&&(mn&&e.type===`mousemove`?(fn=e.screenX-mn.screenX,pn=e.screenY-mn.screenY):pn=fn=0,mn=e),fn)},movementY:function(e){return`movementY`in e?e.movementY:pn}}),gn=sn(hn),_n=sn(m({},hn,{dataTransfer:0})),vn=sn(m({},un,{relatedTarget:0})),yn=sn(m({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=sn(m({},cn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),xn=sn(m({},cn,{data:0})),Sn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Cn={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 Tn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=wn[e])?!!t[e]:!1}function En(){return Tn}var Dn=sn(m({},un,{key:function(e){if(e.key){var t=Sn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=rn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Cn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:En,charCode:function(e){return e.type===`keypress`?rn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?rn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),On=sn(m({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),kn=sn(m({},un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:En})),An=sn(m({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),jn=sn(m({},hn,{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})),Mn=sn(m({},cn,{newState:0,oldState:0})),Nn=[9,13,27,32],Pn=Xt&&`CompositionEvent`in window,Fn=null;Xt&&`documentMode`in document&&(Fn=document.documentMode);var In=Xt&&`TextEvent`in window&&!Fn,Ln=Xt&&(!Pn||Fn&&8<Fn&&11>=Fn),Rn=` `,zn=!1;function Bn(e,t){switch(e){case`keyup`:return Nn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Vn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Hn=!1;function Un(e,t){switch(e){case`compositionend`:return Vn(t);case`keypress`:return t.which===32?(zn=!0,Rn):null;case`textInput`:return e=t.data,e===Rn&&zn?null:e;default:return null}}function Wn(e,t){if(Hn)return e===`compositionend`||!Pn&&Bn(e,t)?(e=nn(),tn=en=$t=null,Hn=!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 Ln&&t.locale!==`ko`?null:t.data;default:return null}}var Gn={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 Kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Gn[e.type]:t===`textarea`}function qn(e,t,n,r){Wt?Gt?Gt.push(r):Gt=[r]:Wt=r,t=Td(t,`onChange`),0<t.length&&(n=new ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Jn=null,Yn=null;function Xn(e){_d(e,0)}function Zn(e){if(Ct(at(e)))return e}function Qn(e,t){if(e===`change`)return t}var $n=!1;if(Xt){var er;if(Xt){var tr=`oninput`in document;if(!tr){var nr=document.createElement(`div`);nr.setAttribute(`oninput`,`return;`),tr=typeof nr.oninput==`function`}er=tr}else er=!1;$n=er&&(!document.documentMode||9<document.documentMode)}function rr(){Jn&&(Jn.detachEvent(`onpropertychange`,ir),Yn=Jn=null)}function ir(e){if(e.propertyName===`value`&&Zn(Yn)){var t=[];qn(t,Yn,e,Ut(e)),Jt(Xn,t)}}function ar(e,t,n){e===`focusin`?(rr(),Jn=t,Yn=n,Jn.attachEvent(`onpropertychange`,ir)):e===`focusout`&&rr()}function or(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Zn(Yn)}function sr(e,t){if(e===`click`)return Zn(t)}function cr(e,t){if(e===`input`||e===`change`)return Zn(t)}function lr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var ur=typeof Object.is==`function`?Object.is:lr;function dr(e,t){if(ur(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(!le.call(t,i)||!ur(e[i],t[i]))return!1}return!0}function fr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pr(e,t){var n=fr(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=fr(n)}}function mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function hr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=wt(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=wt(e.document)}return t}function gr(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 _r=Xt&&`documentMode`in document&&11>=document.documentMode,vr=null,yr=null,br=null,xr=!1;function Sr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xr||vr==null||vr!==wt(r)||(r=vr,`selectionStart`in r&&gr(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&&dr(br,r)||(br=r,r=Td(yr,`onSelect`),0<r.length&&(t=new ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=vr)))}function Cr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var wr={animationend:Cr(`Animation`,`AnimationEnd`),animationiteration:Cr(`Animation`,`AnimationIteration`),animationstart:Cr(`Animation`,`AnimationStart`),transitionrun:Cr(`Transition`,`TransitionRun`),transitionstart:Cr(`Transition`,`TransitionStart`),transitioncancel:Cr(`Transition`,`TransitionCancel`),transitionend:Cr(`Transition`,`TransitionEnd`)},Tr={},Er={};Xt&&(Er=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 Dr(e){if(Tr[e])return Tr[e];if(!wr[e])return e;var t=wr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Er)return Tr[e]=t[n];return e}var Or=Dr(`animationend`),kr=Dr(`animationiteration`),Ar=Dr(`animationstart`),jr=Dr(`transitionrun`),Mr=Dr(`transitionstart`),Nr=Dr(`transitioncancel`),Pr=Dr(`transitionend`),Fr=new Map,Ir=`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(` `);Ir.push(`scrollEnd`);function Lr(e,t){Fr.set(e,t),ut(t,[e])}var Rr=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)},zr=[],Br=0,Vr=0;function Hr(){for(var e=Br,t=Vr=Br=0;t<e;){var n=zr[t];zr[t++]=null;var r=zr[t];zr[t++]=null;var i=zr[t];zr[t++]=null;var a=zr[t];if(zr[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&&Kr(n,i,a)}}function Ur(e,t,n,r){zr[Br++]=e,zr[Br++]=t,zr[Br++]=n,zr[Br++]=r,Vr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Wr(e,t,n,r){return Ur(e,t,n,r),qr(e)}function Gr(e,t){return Ur(e,null,null,t),qr(e)}function Kr(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-Te(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function qr(e){if(50<cu)throw cu=0,lu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Jr={};function Yr(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 Xr(e,t,n,r){return new Yr(e,t,n,r)}function Zr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qr(e,t){var n=e.alternate;return n===null?(n=Xr(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 $r(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 ei(e,t,n,r,i,a){var s=0;if(r=e,typeof e==`function`)Zr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,W.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=Xr(31,n,t,i),e.elementType=k,e.lanes=a,e;case v:return ti(n.children,i,a,t);case y:s=8,i|=24;break;case b:return e=Xr(12,n,t,i|2),e.elementType=b,e.lanes=a,e;case w:return e=Xr(13,n,t,i),e.elementType=w,e.lanes=a,e;case T:return e=Xr(19,n,t,i),e.elementType=T,e.lanes=a,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case S:s=10;break a;case x:s=9;break a;case C:s=11;break a;case E:s=14;break a;case D:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=Xr(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function ti(e,t,n,r){return e=Xr(7,e,r,t),e.lanes=n,e}function ni(e,t,n){return e=Xr(6,e,null,t),e.lanes=n,e}function ri(e){var t=Xr(18,null,null,0);return t.stateNode=e,t}function ii(e,t,n){return t=Xr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ai=new WeakMap;function oi(e,t){if(typeof e==`object`&&e){var n=ai.get(e);return n===void 0?(t={value:e,source:t,stack:ce(t)},ai.set(e,t),t):n}return{value:e,source:t,stack:ce(t)}}var si=[],ci=0,li=null,ui=0,di=[],fi=0,pi=null,mi=1,hi=``;function gi(e,t){si[ci++]=ui,si[ci++]=li,li=e,ui=t}function _i(e,t,n){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,pi=e;var r=mi;e=hi;var i=32-Te(r)-1;r&=~(1<<i),n+=1;var a=32-Te(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,mi=1<<32-Te(t)+i|n<<i|r,hi=a+e}else mi=1<<a|n<<i|r,hi=e}function vi(e){e.return!==null&&(gi(e,1),_i(e,1,0))}function yi(e){for(;e===li;)li=si[--ci],si[ci]=null,ui=si[--ci],si[ci]=null;for(;e===pi;)pi=di[--fi],di[fi]=null,hi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null}function bi(e,t){di[fi++]=mi,di[fi++]=hi,di[fi++]=pi,mi=t.id,hi=t.overflow,pi=e}var xi=null,Si=null,Ci=!1,wi=null,Ti=!1,Ei=Error(o(519));function Di(e){throw Mi(oi(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ei}function Oi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Je]=e,t[Ye]=r,n){case`dialog`:vd(`cancel`,t),vd(`close`,t);break;case`iframe`:case`object`:case`embed`:vd(`load`,t);break;case`video`:case`audio`:for(n=0;n<hd.length;n++)vd(hd[n],t);break;case`source`:vd(`error`,t);break;case`img`:case`image`:case`link`:vd(`error`,t),vd(`load`,t);break;case`details`:vd(`toggle`,t);break;case`input`:vd(`invalid`,t),Ot(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:vd(`invalid`,t);break;case`textarea`:vd(`invalid`,t),Mt(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||jd(t.textContent,n)?(r.popover!=null&&(vd(`beforetoggle`,t),vd(`toggle`,t)),r.onScroll!=null&&vd(`scroll`,t),r.onScrollEnd!=null&&vd(`scrollend`,t),r.onClick!=null&&(t.onclick=Vt),t=!0):t=!1,t||Di(e,!0)}function ki(e){for(xi=e.return;xi;)switch(xi.tag){case 5:case 31:case 13:Ti=!1;return;case 27:case 3:Ti=!0;return;default:xi=xi.return}}function Z(e){if(e!==xi)return!1;if(!Ci)return ki(e),Ci=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&Si&&Di(e),ki(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));Si=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));Si=uf(e)}else t===27?(t=Si,Zd(e.type)?(e=lf,lf=null,Si=e):Si=t):Si=xi?cf(e.stateNode.nextSibling):null;return!0}function Ai(){Si=xi=null,Ci=!1}function ji(){var e=wi;return e!==null&&(Jl===null?Jl=e:Jl.push.apply(Jl,e),wi=null),e}function Mi(e){wi===null?wi=[e]:wi.push(e)}var Q=V(null),Ni=null,Pi=null;function Fi(e,t,n){U(Q,t._currentValue),t._currentValue=n}function Ii(e){e._currentValue=Q.current,H(Q)}function Li(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 Ri(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),Li(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Li(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function zi(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;ur(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===q.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}i=i.return}e!==null&&Ri(t,e,n,r),t.flags|=262144}function Bi(e){for(e=e.firstContext;e!==null;){if(!ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Vi(e){Ni=e,Pi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Hi(e){return Wi(Ni,e)}function Ui(e,t){return Ni===null&&Vi(e),Wi(e,t)}function Wi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Pi===null){if(e===null)throw Error(o(308));Pi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Pi=Pi.next=t;return n}var Gi=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()})}},Ki=t.unstable_scheduleCallback,qi=t.unstable_NormalPriority,Ji={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Yi(){return{controller:new Gi,data:new Map,refCount:0}}function Xi(e){e.refCount--,e.refCount===0&&Ki(qi,function(){e.controller.abort()})}var Zi=null,Qi=0,$i=0,ea=null;function ta(e,t){if(Zi===null){var n=Zi=[];Qi=0,$i=ld(),ea={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Qi++,t.then(na,na),t}function na(){if(--Qi===0&&Zi!==null){ea!==null&&(ea.status=`fulfilled`);var e=Zi;Zi=null,$i=0,ea=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ra(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 ia=I.S;I.S=function(e,t){Zl=me(),typeof t==`object`&&t&&typeof t.then==`function`&&ta(e,t),ia!==null&&ia(e,t)};var aa=V(null);function oa(){var e=aa.current;return e===null?Ml.pooledCache:e}function sa(e,t){t===null?U(aa,aa.current):U(aa,t.pool)}function ca(){var e=oa();return e===null?null:{parent:Ji._currentValue,pool:e}}var la=Error(o(460)),ua=Error(o(474)),da=Error(o(542)),fa={then:function(){}};function pa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ma(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Vt,Vt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,va(e),e;default:if(typeof t.status==`string`)t.then(Vt,Vt);else{if(e=Ml,e!==null&&100<e.shellSuspendCounter)throw Error(o(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,va(e),e}throw ga=t,la}}function ha(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ga=e,la):e}}var ga=null;function _a(){if(ga===null)throw Error(o(459));var e=ga;return ga=null,e}function va(e){if(e===la||e===da)throw Error(o(483))}var ya=null,ba=0;function xa(e){var t=ba;return ba+=1,ya===null&&(ya=[]),ma(ya,e,t)}function Sa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ca(e,t){throw t.$$typeof===h?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function wa(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 i(e,t){return e=Qr(e,t),e.index=0,e.sibling=null,e}function a(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=ni(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===v?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===D&&ha(a)===t.type)?(t=i(t,n.props),Sa(t,n),t.return=e,t):(t=ei(n.type,n.key,n.props,null,e.mode,r),Sa(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=ii(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=ti(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ni(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=ei(t.type,t.key,t.props,null,e.mode,n),Sa(n,t),n.return=e,n;case _:return t=ii(t,e.mode,n),t.return=e,t;case D:return t=ha(t),f(e,t,n)}if(F(t)||M(t))return t=ti(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,xa(t),n);if(t.$$typeof===S)return f(e,Ui(e,t),n);Ca(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 g:return n.key===i?l(e,t,n,r):null;case _:return n.key===i?u(e,t,n,r):null;case D:return n=ha(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,xa(n),r);if(n.$$typeof===S)return p(e,t,Ui(e,n),r);Ca(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 g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case _:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case D:return r=ha(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,xa(r),i);if(r.$$typeof===S)return m(e,t,n,Ui(t,r),i);Ca(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=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),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ci&&gi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return Ci&&gi(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),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ci&&gi(i,h),l}function y(i,s,c,l){if(c==null)throw Error(o(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(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),Ci&&gi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ci&&gi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),Ci&&gi(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===v&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case g:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===v){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===D&&ha(l)===r.type){n(e,r.sibling),c=i(r,a.props),Sa(c,a),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}a.type===v?(c=ti(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=ei(a.type,a.key,a.props,null,e.mode,c),Sa(c,a),c.return=e,e=c)}return s(e);case _:a:{for(l=a.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ii(a,e.mode,c),c.return=e,e=c}return s(e);case D:return a=ha(a),b(e,r,a,c)}if(F(a))return h(e,r,a,c);if(M(a)){if(l=M(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),y(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,xa(a),c);if(a.$$typeof===S)return b(e,r,Ui(e,a),c);Ca(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=ni(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ba=0;var i=b(e,t,n,r);return ya=null,i}catch(t){if(t===la||t===da)throw t;var a=Xr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ta=wa(!0),Ea=wa(!1),Da=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ka(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 Aa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ja(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,jl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=qr(e),Kr(e,null,n),t}return Ur(e,r,t,n),qr(e)}function Ma(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,Ve(e,n)}}function Na(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 Pa=!1;function Fa(){if(Pa){var e=ea;if(e!==null)throw e}}function Ia(e,t,n,r){Pa=!1;var i=e.updateQueue;Da=!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?(Pl&f)===f:(r&f)===f){f!==0&&f===$i&&(Pa=!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:Da=!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),Hl|=o,e.lanes=o,e.memoizedState=d}}function La(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function Ra(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)La(n[e],t)}var za=V(null),Ba=V(0);function Va(e,t){e=Bl,U(Ba,e),U(za,t),Bl=e|t.baseLanes}function Ha(){U(Ba,Bl),U(za,za.current)}function Ua(){Bl=Ba.current,H(za),H(Ba)}var Wa=V(null),Ga=null;function Ka(e){var t=e.alternate;U(Za,Za.current&1),U(Wa,e),Ga===null&&(t===null||za.current!==null||t.memoizedState!==null)&&(Ga=e)}function qa(e){U(Za,Za.current),U(Wa,e),Ga===null&&(Ga=e)}function Ja(e){e.tag===22?(U(Za,Za.current),U(Wa,e),Ga===null&&(Ga=e)):Ya(e)}function Ya(){U(Za,Za.current),U(Wa,Wa.current)}function Xa(e){H(Wa),Ga===e&&(Ga=null),H(Za)}var Za=V(0);function Qa(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(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 $a=0,$=null,eo=null,to=null,no=!1,ro=!1,io=!1,ao=0,oo=0,so=null,co=0;function lo(){throw Error(o(321))}function uo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ur(e[n],t[n]))return!1;return!0}function fo(e,t,n,r,i,a){return $a=a,$=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?ks:As,io=!1,a=n(r,i),io=!1,ro&&(a=mo(t,n,r,i)),po(e),a}function po(e){I.H=Os;var t=eo!==null&&eo.next!==null;if($a=0,to=eo=$=null,no=!1,oo=0,so=null,t)throw Error(o(300));e===null||qs||(e=e.dependencies,e!==null&&Bi(e)&&(qs=!0))}function mo(e,t,n,r){$=e;var i=0;do{if(ro&&(so=null),oo=0,ro=!1,25<=i)throw Error(o(301));if(i+=1,to=eo=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}I.H=js,a=t(n,r)}while(ro);return a}function ho(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?So(t):t,e=e.useState()[0],(eo===null?null:eo.memoizedState)!==e&&($.flags|=1024),t}function go(){var e=ao!==0;return ao=0,e}function _o(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function vo(e){if(no){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}no=!1}$a=0,to=eo=$=null,ro=!1,oo=ao=0,so=null}function yo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return to===null?$.memoizedState=to=e:to=to.next=e,to}function bo(){if(eo===null){var e=$.alternate;e=e===null?null:e.memoizedState}else e=eo.next;var t=to===null?$.memoizedState:to.next;if(t!==null)to=t,eo=e;else{if(e===null)throw $.alternate===null?Error(o(467)):Error(o(310));eo=e,e={memoizedState:eo.memoizedState,baseState:eo.baseState,baseQueue:eo.baseQueue,queue:eo.queue,next:null},to===null?$.memoizedState=to=e:to=to.next=e}return to}function xo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function So(e){var t=oo;return oo+=1,so===null&&(so=[]),e=ma(so,e,t),t=$,(to===null?t.memoizedState:to.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?ks:As),e}function Co(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return So(e);if(e.$$typeof===S)return Hi(e)}throw Error(o(438,String(e)))}function wo(e){var t=null,n=$.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=$.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=xo(),$.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]=A;return t.index++,n}function To(e,t){return typeof t==`function`?t(e):t}function Eo(e){return Do(bo(),eo,e)}function Do(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?($a&f)===f:(Pl&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===$i&&(d=!0);else if(($a&p)===p){u=u.next,p===$i&&(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=a):l=l.next=f,$.lanes|=p,Hl|=p;f=u.action,io&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,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=a):l=l.next=p,$.lanes|=f,Hl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!ur(a,e.memoizedState)&&(qs=!0,d&&(n=ea,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Oo(e){var t=bo(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);ur(a,t.memoizedState)||(qs=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function ko(e,t,n){var r=$,i=bo(),a=Ci;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!ur((eo||i).memoizedState,n);if(s&&(i.memoizedState=n,qs=!0),i=i.queue,es(Mo.bind(null,r,i,e),[e]),i.getSnapshot!==t||s||to!==null&&to.memoizedState.tag&1){if(r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,i,n,t),null),Ml===null)throw Error(o(349));a||$a&127||Ao(r,t,n)}return n}function Ao(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=$.updateQueue,t===null?(t=xo(),$.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function jo(e,t,n,r){t.value=n,t.getSnapshot=r,No(t)&&Po(e)}function Mo(e,t,n){return n(function(){No(t)&&Po(e)})}function No(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ur(e,n)}catch{return!0}}function Po(e){var t=Gr(e,2);t!==null&&fu(t,e,2)}function Fo(e){var t=yo();if(typeof e==`function`){var n=e;if(e=n(),io){we(!0);try{n()}finally{we(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:e},t}function Io(e,t,n,r){return e.baseState=n,Do(e,eo,typeof r==`function`?r:To)}function Lo(e,t,n,r,i){if(Ts(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};I.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,Ro(t,a)):(a.next=n.next,t.pending=n.next=a)}}function Ro(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),zo(e,t,s)}catch(n){Vo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),zo(e,t,a)}catch(n){Vo(e,t,n)}}function zo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Bo(e,t,n)},function(n){return Vo(e,t,n)}):Bo(e,t,n)}function Bo(e,t,n){t.status=`fulfilled`,t.value=n,Ho(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ro(e,n)))}function Vo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ho(t),t=t.next;while(t!==r)}e.action=null}function Ho(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Uo(e,t){return t}function Wo(e,t){if(Ci){var n=Ml.formState;if(n!==null){a:{var r=$;if(Ci){if(Si){b:{for(var i=Si,a=Ti;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Si=cf(i.nextSibling),r=i.data===`F!`;break a}}Di(r)}r=!1}r&&(t=n[0])}}return n=yo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:t},n.queue=r,n=Ss.bind(null,$,r),r.dispatch=n,r=Fo(!1),a=ws.bind(null,$,!1,r.queue),r=yo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Lo.bind(null,$,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Go(e){return Ko(bo(),eo,e)}function Ko(e,t,n){if(t=Do(e,t,Uo)[0],e=Eo(To)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=So(t)}catch(e){throw e===la?da:e}else r=t;t=bo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&($.flags|=2048,Yo(9,{destroy:void 0},qo.bind(null,i,n),null)),[r,a,e]}function qo(e,t){e.action=t}function Jo(e){var t=bo(),n=eo;if(n!==null)return Ko(t,n,e);bo(),t=t.memoizedState,n=bo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Yo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=$.updateQueue,t===null&&(t=xo(),$.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 Xo(){return bo().memoizedState}function Zo(e,t,n,r){var i=yo();$.flags|=e,i.memoizedState=Yo(1|t,{destroy:void 0},n,r===void 0?null:r)}function Qo(e,t,n,r){var i=bo();r=r===void 0?null:r;var a=i.memoizedState.inst;eo!==null&&r!==null&&uo(r,eo.memoizedState.deps)?i.memoizedState=Yo(t,a,n,r):($.flags|=e,i.memoizedState=Yo(1|t,a,n,r))}function $o(e,t){Zo(8390656,8,e,t)}function es(e,t){Qo(2048,8,e,t)}function ts(e){$.flags|=4;var t=$.updateQueue;if(t===null)t=xo(),$.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ns(e){var t=bo().memoizedState;return ts({ref:t,nextImpl:e}),function(){if(jl&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function rs(e,t){return Qo(4,2,e,t)}function is(e,t){return Qo(4,4,e,t)}function as(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 os(e,t,n){n=n==null?null:n.concat([e]),Qo(4,4,as.bind(null,t,e),n)}function ss(){}function cs(e,t){var n=bo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&uo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ls(e,t){var n=bo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&uo(t,r[1]))return r[0];if(r=e(),io){we(!0);try{e()}finally{we(!1)}}return n.memoizedState=[r,t],r}function us(e,t,n){return n===void 0||$a&1073741824&&!(Pl&261930)?e.memoizedState=t:(e.memoizedState=n,e=du(),$.lanes|=e,Hl|=e,n)}function ds(e,t,n,r){return ur(n,t)?n:za.current===null?!($a&42)||$a&1073741824&&!(Pl&261930)?(qs=!0,e.memoizedState=n):(e=du(),$.lanes|=e,Hl|=e,t):(e=us(e,n,r),ur(e,t)||(qs=!0),e)}function fs(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,ws(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Cs(e,t,ra(c,r),uu(e)):Cs(e,t,r,uu(e))}catch(n){Cs(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function ps(){}function ms(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=hs(e).queue;fs(e,i,t,R,n===null?ps:function(){return gs(e),n(r)})}function hs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:R},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function gs(e){var t=hs(e);t.next===null&&(t=e.alternate.memoizedState),Cs(e,t.next.queue,{},uu())}function _s(){return Hi(Qf)}function vs(){return bo().memoizedState}function ys(){return bo().memoizedState}function bs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=Aa(n);var r=ja(t,e,n);r!==null&&(fu(r,t,n),Ma(r,t,n)),t={cache:Yi()},e.payload=t;return}t=t.return}}function xs(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ts(e)?Es(t,n):(n=Wr(e,t,n,r),n!==null&&(fu(n,e,r),Ds(n,t,r)))}function Ss(e,t,n){Cs(e,t,n,uu())}function Cs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ts(e))Es(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,ur(s,o))return Ur(e,t,i,0),Ml===null&&Hr(),!1}catch{}if(n=Wr(e,t,i,r),n!==null)return fu(n,e,r),Ds(n,t,r),!0}return!1}function ws(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ts(e)){if(t)throw Error(o(479))}else t=Wr(e,n,r,2),t!==null&&fu(t,e,2)}function Ts(e){var t=e.alternate;return e===$||t!==null&&t===$}function Es(e,t){ro=no=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ds(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ve(e,n)}}var Os={readContext:Hi,use:Co,useCallback:lo,useContext:lo,useEffect:lo,useImperativeHandle:lo,useLayoutEffect:lo,useInsertionEffect:lo,useMemo:lo,useReducer:lo,useRef:lo,useState:lo,useDebugValue:lo,useDeferredValue:lo,useTransition:lo,useSyncExternalStore:lo,useId:lo,useHostTransitionStatus:lo,useFormState:lo,useActionState:lo,useOptimistic:lo,useMemoCache:lo,useCacheRefresh:lo};Os.useEffectEvent=lo;var ks={readContext:Hi,use:Co,useCallback:function(e,t){return yo().memoizedState=[e,t===void 0?null:t],e},useContext:Hi,useEffect:$o,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Zo(4194308,4,as.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){Zo(4,2,e,t)},useMemo:function(e,t){var n=yo();t=t===void 0?null:t;var r=e();if(io){we(!0);try{e()}finally{we(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=yo();if(n!==void 0){var i=n(t);if(io){we(!0);try{n(t)}finally{we(!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=xs.bind(null,$,e),[r.memoizedState,e]},useRef:function(e){var t=yo();return e={current:e},t.memoizedState=e},useState:function(e){e=Fo(e);var t=e.queue,n=Ss.bind(null,$,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ss,useDeferredValue:function(e,t){return us(yo(),e,t)},useTransition:function(){var e=Fo(!1);return e=fs.bind(null,$,e.queue,!0,!1),yo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=$,i=yo();if(Ci){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Ml===null)throw Error(o(349));Pl&127||Ao(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,$o(Mo.bind(null,r,a,e),[e]),r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,a,n,t),null),n},useId:function(){var e=yo(),t=Ml.identifierPrefix;if(Ci){var n=hi,r=mi;n=(r&~(1<<32-Te(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ao++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=co++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:_s,useFormState:Wo,useActionState:Wo,useOptimistic:function(e){var t=yo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ws.bind(null,$,!0,n),n.dispatch=t,[e,t]},useMemoCache:wo,useCacheRefresh:function(){return yo().memoizedState=bs.bind(null,$)},useEffectEvent:function(e){var t=yo(),n={impl:e};return t.memoizedState=n,function(){if(jl&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},As={readContext:Hi,use:Co,useCallback:cs,useContext:Hi,useEffect:es,useImperativeHandle:os,useInsertionEffect:rs,useLayoutEffect:is,useMemo:ls,useReducer:Eo,useRef:Xo,useState:function(){return Eo(To)},useDebugValue:ss,useDeferredValue:function(e,t){return ds(bo(),eo.memoizedState,e,t)},useTransition:function(){var e=Eo(To)[0],t=bo().memoizedState;return[typeof e==`boolean`?e:So(e),t]},useSyncExternalStore:ko,useId:vs,useHostTransitionStatus:_s,useFormState:Go,useActionState:Go,useOptimistic:function(e,t){return Io(bo(),eo,e,t)},useMemoCache:wo,useCacheRefresh:ys};As.useEffectEvent=ns;var js={readContext:Hi,use:Co,useCallback:cs,useContext:Hi,useEffect:es,useImperativeHandle:os,useInsertionEffect:rs,useLayoutEffect:is,useMemo:ls,useReducer:Oo,useRef:Xo,useState:function(){return Oo(To)},useDebugValue:ss,useDeferredValue:function(e,t){var n=bo();return eo===null?us(n,e,t):ds(n,eo.memoizedState,e,t)},useTransition:function(){var e=Oo(To)[0],t=bo().memoizedState;return[typeof e==`boolean`?e:So(e),t]},useSyncExternalStore:ko,useId:vs,useHostTransitionStatus:_s,useFormState:Jo,useActionState:Jo,useOptimistic:function(e,t){var n=bo();return eo===null?(n.baseState=e,[e,n.queue.dispatch]):Io(n,eo,e,t)},useMemoCache:wo,useCacheRefresh:ys};js.useEffectEvent=ns;function Ms(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 Ns={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=uu(),i=Aa(r);i.payload=t,n!=null&&(i.callback=n),t=ja(e,i,r),t!==null&&(fu(t,e,r),Ma(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=uu(),i=Aa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ja(e,i,r),t!==null&&(fu(t,e,r),Ma(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=uu(),r=Aa(n);r.tag=2,t!=null&&(r.callback=t),t=ja(e,r,n),t!==null&&(fu(t,e,n),Ma(t,e,n))}};function Ps(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?!dr(n,r)||!dr(i,a):!0}function Fs(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&&Ns.enqueueReplaceState(t,t.state,null)}function Is(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 Ls(e){Rr(e)}function Rs(e){console.error(e)}function zs(e){Rr(e)}function Bs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Vs(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 Hs(e,t,n){return n=Aa(n),n.tag=3,n.payload={element:null},n.callback=function(){Bs(e,t)},n}function Us(e){return e=Aa(e),e.tag=3,e}function Ws(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(){Vs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Vs(t,n,r),typeof i!=`function`&&(eu===null?eu=new Set([this]):eu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Gs(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&zi(t,n,i,!0),n=Wa.current,n!==null){switch(n.tag){case 31:case 13:return Ga===null?wu():n.alternate===null&&Vl===0&&(Vl=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===fa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Uu(e,r,i)),!1;case 22:return n.flags|=65536,r===fa?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)),Uu(e,r,i)),!1}throw Error(o(435,n.tag))}return Uu(e,r,i),wu(),!1}if(Ci)return t=Wa.current,t===null?(r!==Ei&&(t=Error(o(423),{cause:r}),Mi(oi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=oi(r,n),i=Hs(e.stateNode,r,i),Na(e,i),Vl!==4&&(Vl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==Ei&&(e=Error(o(422),{cause:r}),Mi(oi(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=oi(a,n),ql===null?ql=[a]:ql.push(a),Vl!==4&&(Vl=2),t===null)return!0;r=oi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Hs(n.stateNode,r,e),Na(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(eu===null||!eu.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Us(i),Ws(i,e,n,r),Na(n,i),!1}n=n.return}while(n!==null);return!1}var Ks=Error(o(461)),qs=!1;function Js(e,t,n,r){t.child=e===null?Ea(t,null,n,r):Ta(t,e.child,n,r)}function Ys(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 Vi(t),r=fo(e,t,n,o,a,i),s=go(),e!==null&&!qs?(_o(e,t,i),yc(e,t,i)):(Ci&&s&&vi(t),t.flags|=1,Js(e,t,r,i),t.child)}function Xs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Zr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Zs(e,t,a,r,i)):(e=ei(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!bc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?dr:n,n(o,r)&&e.ref===t.ref)return yc(e,t,i)}return t.flags|=1,e=Qr(a,r),e.ref=t.ref,e.return=t,t.child=e}function Zs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(dr(a,r)&&e.ref===t.ref)if(qs=!1,t.pendingProps=r=a,bc(e,i))e.flags&131072&&(qs=!0);else return t.lanes=e.lanes,yc(e,t,i)}return ac(e,t,n,r,i)}function Qs(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 ec(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&sa(t,a===null?null:a.cachePool),a===null?Ha():Va(t,a),Ja(t);else return r=t.lanes=536870912,ec(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&sa(t,null),Ha(),Ya(t)):(sa(t,a.cachePool),Va(t,a),Ya(t),t.memoizedState=null);return Js(e,t,i,n),t.child}function $s(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function ec(e,t,n,r,i){var a=oa();return a=a===null?null:{parent:Ji._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&sa(t,null),Ha(),Ja(t),e!==null&&zi(e,t,r,!0),t.childLanes=i,null}function tc(e,t){return t=mc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function nc(e,t,n){return Ta(t,e.child,null,n),e=tc(t,t.pendingProps),e.flags|=2,Xa(t),t.memoizedState=null,e}function rc(e,t,n){var r=t.pendingProps,i=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ci){if(r.mode===`hidden`)return e=tc(t,r),t.lanes=536870912,$s(null,e);if(qa(t),(e=Si)?(e=rf(e,Ti),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Di(t);return t.lanes=536870912,null}return tc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if(qa(t),i)if(t.flags&256)t.flags&=-257,t=nc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(qs||zi(e,t,n,!1),i=(n&e.childLanes)!==0,qs||i){if(r=Ml,r!==null&&(s=He(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,Gr(e,s),fu(r,e,s),Ks;wu(),t=nc(e,t,n)}else e=a.treeContext,Si=cf(s.nextSibling),xi=t,Ci=!0,wi=null,Ti=!1,e!==null&&bi(t,e),t=tc(t,r),t.flags|=4096;return t}return e=Qr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ic(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(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function ac(e,t,n,r,i){return Vi(t),n=fo(e,t,n,r,void 0,i),r=go(),e!==null&&!qs?(_o(e,t,i),yc(e,t,i)):(Ci&&r&&vi(t),t.flags|=1,Js(e,t,n,i),t.child)}function oc(e,t,n,r,i,a){return Vi(t),t.updateQueue=null,n=mo(t,r,n,i),po(e),r=go(),e!==null&&!qs?(_o(e,t,a),yc(e,t,a)):(Ci&&r&&vi(t),t.flags|=1,Js(e,t,n,a),t.child)}function sc(e,t,n,r,i){if(Vi(t),t.stateNode===null){var a=Jr,o=n.contextType;typeof o==`object`&&o&&(a=Hi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ns,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Oa(t),o=n.contextType,a.context=typeof o==`object`&&o?Hi(o):Jr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ms(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&&Ns.enqueueReplaceState(a,a.state,null),Ia(t,r,a,i),Fa(),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=Is(n,s);a.props=c;var l=a.context,u=n.contextType;o=Jr,typeof u==`object`&&u&&(o=Hi(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)&&Fs(t,a,r,o),Da=!1;var f=t.memoizedState;a.state=f,Ia(t,r,a,i),Fa(),l=t.memoizedState,s||f!==l||Da?(typeof d==`function`&&(Ms(t,n,d,r),l=t.memoizedState),(c=Da||Ps(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,ka(e,t),o=t.memoizedProps,u=Is(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Jr,typeof l==`object`&&l&&(c=Hi(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)&&Fs(t,a,r,c),Da=!1,f=t.memoizedState,a.state=f,Ia(t,r,a,i),Fa();var p=t.memoizedState;o!==d||f!==p||Da||e!==null&&e.dependencies!==null&&Bi(e.dependencies)?(typeof s==`function`&&(Ms(t,n,s,r),p=t.memoizedState),(u=Da||Ps(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Bi(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,ic(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=Ta(t,e.child,null,i),t.child=Ta(t,null,n,i)):Js(e,t,n,i),t.memoizedState=a.state,e=t.child):e=yc(e,t,i),e}function cc(e,t,n,r){return Ai(),t.flags|=256,Js(e,t,n,r),t.child}var lc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function uc(e){return{baseLanes:e,cachePool:ca()}}function dc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Gl),e}function fc(e,t,n){var r=t.pendingProps,i=!1,a=(t.flags&128)!=0,s;if((s=a)||(s=e!==null&&e.memoizedState===null?!1:(Za.current&2)!=0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ci){if(i?Ka(t):Ya(t),(e=Si)?(e=rf(e,Ti),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pi===null?null:{id:mi,overflow:hi},retryLane:536870912,hydrationErrors:null},n=ri(e),n.return=t,t.child=n,xi=t,Si=null)):e=null,e===null)throw Di(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,i?(Ya(t),i=t.mode,c=mc({mode:`hidden`,children:c},i),r=ti(r,i,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=uc(n),r.childLanes=dc(e,s,n),t.memoizedState=lc,$s(null,r)):(Ka(t),pc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(a)t.flags&256?(Ka(t),t.flags&=-257,t=hc(e,t,n)):t.memoizedState===null?(Ya(t),c=r.fallback,i=t.mode,r=mc({mode:`visible`,children:r.children},i),c=ti(c,i,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ta(t,e.child,null,n),r=t.child,r.memoizedState=uc(n),r.childLanes=dc(e,s,n),t.memoizedState=lc,t=$s(null,r)):(Ya(t),t.child=e.child,t.flags|=128,t=null);else if(Ka(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(o(419)),r.stack=``,r.digest=s,Mi({value:r,source:null,stack:null}),t=hc(e,t,n)}else if(qs||zi(e,t,n,!1),s=(n&e.childLanes)!==0,qs||s){if(s=Ml,s!==null&&(r=He(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Gr(e,r),fu(s,e,r),Ks;af(c)||wu(),t=hc(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Si=cf(c.nextSibling),xi=t,Ci=!0,wi=null,Ti=!1,e!==null&&bi(t,e),t=pc(t,r.children),t.flags|=4096);return t}return i?(Ya(t),c=r.fallback,i=t.mode,l=e.child,u=l.sibling,r=Qr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ti(c,i,n,null),c.flags|=2):c=Qr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,$s(null,r),r=t.child,c=e.child.memoizedState,c===null?c=uc(n):(i=c.cachePool,i===null?i=ca():(l=Ji._currentValue,i=i.parent===l?i:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:i}),r.memoizedState=c,r.childLanes=dc(e,s,n),t.memoizedState=lc,$s(e.child,r)):(Ka(t),n=e.child,e=n.sibling,n=Qr(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 pc(e,t){return t=mc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function mc(e,t){return e=Xr(22,e,null,t),e.lanes=0,e}function hc(e,t,n){return Ta(t,e.child,null,n),e=pc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function gc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Li(e.return,t,n)}function _c(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=Za.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,U(Za,o),Js(e,t,r,n),r=Ci?ui:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&gc(e,n,t);else if(e.tag===19)gc(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&&Qa(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),_c(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&&Qa(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}_c(t,!0,n,null,a,r);break;case`together`:_c(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function yc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Hl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(zi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Qr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function bc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Bi(e))):!0}function xc(e,t,n){switch(t.tag){case 3:J(t,t.stateNode.containerInfo),Fi(t,Ji,e.memoizedState.cache),Ai();break;case 27:case 5:Y(t);break;case 4:J(t,t.stateNode.containerInfo);break;case 10:Fi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,qa(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ka(t),e=yc(e,t,n),e===null?null:e.sibling):fc(e,t,n):(Ka(t),t.flags|=128,null);Ka(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(zi(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),U(Za,Za.current),r)break;return null;case 22:return t.lanes=0,Qs(e,t,n,t.pendingProps);case 24:Fi(t,Ji,e.memoizedState.cache)}return yc(e,t,n)}function Sc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)qs=!0;else{if(!bc(e,n)&&!(t.flags&128))return qs=!1,xc(e,t,n);qs=!!(e.flags&131072)}else qs=!1,Ci&&t.flags&1048576&&_i(t,ui,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ha(t.elementType),t.type=e,typeof e==`function`)Zr(e)?(r=Is(e,r),t.tag=1,t=sc(null,t,e,r,n)):(t.tag=0,t=ac(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===C){t.tag=11,t=Ys(null,t,e,r,n);break a}else if(i===E){t.tag=14,t=Xs(null,t,e,r,n);break a}}throw t=P(e)||e,Error(o(306,t,``))}}return t;case 0:return ac(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=Is(r,t.pendingProps),sc(e,t,r,i,n);case 3:a:{if(J(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,ka(e,t),Ia(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Fi(t,Ji,r),r!==a.cache&&Ri(t,[Ji],n,!0),Fa(),r=s.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=cc(e,t,r,n);break a}else if(r!==i){i=oi(Error(o(424)),t),Mi(i),t=cc(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(Si=cf(e.firstChild),xi=t,Ci=!0,wi=null,Ti=!0,n=Ea(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ai(),r===i){t=yc(e,t,n);break a}Js(e,t,r,n)}t=t.child}return t;case 26:return ic(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ci||(n=t.type,e=t.pendingProps,r=Bd(K.current).createElement(n),r[Je]=t,r[Ye]=e,Pd(r,n,e),st(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Y(t),e===null&&Ci&&(r=t.stateNode=ff(t.type,t.pendingProps,K.current),xi=t,Ti=!0,i=Si,Zd(t.type)?(lf=i,Si=cf(r.firstChild)):Si=i),Js(e,t,t.pendingProps.children,n),ic(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ci&&((i=r=Si)&&(r=tf(r,t.type,t.pendingProps,Ti),r===null?i=!1:(t.stateNode=r,xi=t,Si=cf(r.firstChild),Ti=!1,i=!0)),i||Di(t)),Y(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,Ud(i,a)?r=null:s!==null&&Ud(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=fo(e,t,ho,null,null,n),Qf._currentValue=i),ic(e,t),Js(e,t,r,n),t.child;case 6:return e===null&&Ci&&((e=n=Si)&&(n=nf(n,t.pendingProps,Ti),n===null?e=!1:(t.stateNode=n,xi=t,Si=null,e=!0)),e||Di(t)),null;case 13:return fc(e,t,n);case 4:return J(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ta(t,null,r,n):Js(e,t,r,n),t.child;case 11:return Ys(e,t,t.type,t.pendingProps,n);case 7:return Js(e,t,t.pendingProps,n),t.child;case 8:return Js(e,t,t.pendingProps.children,n),t.child;case 12:return Js(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Fi(t,t.type,r.value),Js(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,Vi(t),i=Hi(i),r=r(i),t.flags|=1,Js(e,t,r,n),t.child;case 14:return Xs(e,t,t.type,t.pendingProps,n);case 15:return Zs(e,t,t.type,t.pendingProps,n);case 19:return vc(e,t,n);case 31:return rc(e,t,n);case 22:return Qs(e,t,n,t.pendingProps);case 24:return Vi(t),r=Hi(Ji),e===null?(i=oa(),i===null&&(i=Ml,a=Yi(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},Oa(t),Fi(t,Ji,i)):((e.lanes&n)!==0&&(ka(e,t),Ia(t,null,null,n),Fa()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,Fi(t,Ji,r),r!==i.cache&&Ri(t,[Ji],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Fi(t,Ji,r))),Js(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Cc(e){e.flags|=4}function wc(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(xu())e.flags|=8192;else throw ga=fa,ua}else e.flags&=-16777217}function Tc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(xu())e.flags|=8192;else throw ga=fa,ua}function Ec(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ie(),e.lanes|=t,Kl|=t)}function Dc(e,t){if(!Ci)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 Oc(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 kc(e,t,n){var r=t.pendingProps;switch(yi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Oc(t),null;case 1:return Oc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ii(Ji),ee(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Z(t)?Cc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ji())),Oc(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(Cc(t),a===null?(Oc(t),wc(t,i,null,r,n)):(Oc(t),Tc(t,a))):a?a===e.memoizedState?(Oc(t),t.flags&=-16777217):(Cc(t),Oc(t),Tc(t,a)):(e=e.memoizedProps,e!==r&&Cc(t),Oc(t),wc(t,i,e,r,n)),null;case 27:if(te(t),n=K.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Oc(t),null}e=W.current,Z(t)?Oi(t,e):(e=ff(i,r,n),t.stateNode=e,Cc(t))}return Oc(t),null;case 5:if(te(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Oc(t),null}if(a=W.current,Z(t))Oi(t,a);else{var s=Bd(K.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[Je]=t,a[Ye]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.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=a;a:switch(Pd(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Cc(t)}}return Oc(t),wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=K.current,Z(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=xi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[Je]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Di(t,!0)}else e=Bd(e).createTextNode(r),e[Je]=t,t.stateNode=e}return Oc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Z(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[Je]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),e=!1}else n=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Xa(t),t):(Xa(t),null);if(t.flags&128)throw Error(o(558))}return Oc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Z(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[Je]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),i=!1}else i=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Xa(t),t):(Xa(t),null)}return Xa(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ec(t,t.updateQueue),Oc(t),null);case 4:return ee(),e===null&&xd(t.stateNode.containerInfo),Oc(t),null;case 10:return Ii(t.type),Oc(t),null;case 19:if(H(Za),r=t.memoizedState,r===null)return Oc(t),null;if(i=(t.flags&128)!=0,a=r.rendering,a===null)if(i)Dc(r,!1);else{if(Vl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Qa(e),a!==null){for(t.flags|=128,Dc(r,!1),e=a.updateQueue,t.updateQueue=e,Ec(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)$r(n,e),n=n.sibling;return U(Za,Za.current&1|2),Ci&&gi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&me()>Ql&&(t.flags|=128,i=!0,Dc(r,!1),t.lanes=4194304)}else{if(!i)if(e=Qa(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Ec(t,e),Dc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!Ci)return Oc(t),null}else 2*me()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,i=!0,Dc(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(Oc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=me(),e.sibling=null,n=Za.current,U(Za,i?n&1|2:n&1),Ci&&gi(t,r.treeForkCount),e);case 22:case 23:return Xa(t),Ua(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Oc(t),t.subtreeFlags&6&&(t.flags|=8192)):Oc(t),n=t.updateQueue,n!==null&&Ec(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&&H(aa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ii(Ji),Oc(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Ac(e,t){switch(yi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ii(Ji),ee(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return te(t),null;case 31:if(t.memoizedState!==null){if(Xa(t),t.alternate===null)throw Error(o(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Xa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(Za),null;case 4:return ee(),null;case 10:return Ii(t.type),null;case 22:case 23:return Xa(t),Ua(),e!==null&&H(aa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ii(Ji),null;case 25:return null;default:return null}}function jc(e,t){switch(yi(t),t.tag){case 3:Ii(Ji),ee();break;case 26:case 27:case 5:te(t);break;case 4:ee();break;case 31:t.memoizedState!==null&&Xa(t);break;case 13:Xa(t);break;case 19:H(Za);break;case 10:Ii(t.type);break;case 22:case 23:Xa(t),Ua(),e!==null&&H(aa);break;case 24:Ii(Ji)}}function Mc(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){Hu(t,t.return,e)}}function Nc(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){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Pc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ra(t,n)}catch(t){Hu(e,e.return,t)}}}function Fc(e,t,n){n.props=Is(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Ic(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){Hu(e,t,n)}}function Lc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Hu(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){Hu(e,t,n)}else n.current=null}function Rc(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){Hu(e,e.return,t)}}function zc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[Ye]=t}catch(t){Hu(e,e.return,t)}}function Bc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Vc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Bc(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&&Zd(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 Hc(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=Vt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Hc(e,t,n),e=e.sibling;e!==null;)Hc(e,t,n),e=e.sibling}function Uc(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&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Je]=e,t[Ye]=n}catch(t){Hu(e,e.return,t)}}var Gc=!1,Kc=!1,qc=!1,Jc=typeof WeakSet==`function`?WeakSet:Set,Yc=null;function Xc(e,t){if(e=e.containerInfo,Rd=sp,e=hr(e),gr(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 i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.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||i!==0&&f.nodeType!==3||(c=s+i),f!==a||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===i&&(c=s),p===a&&++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(zd={focusedElem:e,selectionRange:n},sp=!1,Yc=t;Yc!==null;)if(t=Yc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Yc=e;else for(;Yc!==null;){switch(t=Yc,a=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++)i=e[n],i.ref.impl=i.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&a!==null){e=void 0,n=t,i=a.memoizedProps,a=a.memoizedState,r=n.stateNode;try{var h=Is(n.type,i);e=r.getSnapshotBeforeUpdate(h,a),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Hu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(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(o(163))}if(e=t.sibling,e!==null){e.return=t.return,Yc=e;break}Yc=t.return}}function Zc(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:fl(e,n),r&4&&Mc(5,n);break;case 1:if(fl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Hu(n,n.return,e)}else{var i=Is(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Hu(n,n.return,e)}}r&64&&Pc(n),r&512&&Ic(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{Ra(e,t)}catch(e){Hu(n,n.return,e)}}break;case 27:t===null&&r&4&&Wc(n);case 26:case 5:fl(e,n),t===null&&r&4&&Rc(n),r&512&&Ic(n,n.return);break;case 12:fl(e,n);break;case 31:fl(e,n),r&4&&rl(e,n);break;case 13:fl(e,n),r&4&&il(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ku.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||Gc,!r){t=t!==null&&t.memoizedState!==null||Kc,i=Gc;var a=Kc;Gc=r,(Kc=t)&&!a?ml(e,n,(n.subtreeFlags&8772)!=0):fl(e,n),Gc=i,Kc=a}break;case 30:break;default:fl(e,n)}}function Qc(e){var t=e.alternate;t!==null&&(e.alternate=null,Qc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&nt(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 $c=null,el=!1;function tl(e,t,n){for(n=n.child;n!==null;)nl(e,t,n),n=n.sibling}function nl(e,t,n){if(Ce&&typeof Ce.onCommitFiberUnmount==`function`)try{Ce.onCommitFiberUnmount(Se,n)}catch{}switch(n.tag){case 26:Kc||Lc(n,t),tl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Kc||Lc(n,t);var r=$c,i=el;Zd(n.type)&&($c=n.stateNode,el=!1),tl(e,t,n),pf(n.stateNode),$c=r,el=i;break;case 5:Kc||Lc(n,t);case 6:if(r=$c,i=el,$c=null,tl(e,t,n),$c=r,el=i,$c!==null)if(el)try{($c.nodeType===9?$c.body:$c.nodeName===`HTML`?$c.ownerDocument.body:$c).removeChild(n.stateNode)}catch(e){Hu(n,t,e)}else try{$c.removeChild(n.stateNode)}catch(e){Hu(n,t,e)}break;case 18:$c!==null&&(el?(e=$c,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd($c,n.stateNode));break;case 4:r=$c,i=el,$c=n.stateNode.containerInfo,el=!0,tl(e,t,n),$c=r,el=i;break;case 0:case 11:case 14:case 15:Nc(2,n,t),Kc||Nc(4,n,t),tl(e,t,n);break;case 1:Kc||(Lc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Fc(n,t,r)),tl(e,t,n);break;case 21:tl(e,t,n);break;case 22:Kc=(r=Kc)||n.memoizedState!==null,tl(e,t,n),Kc=r;break;default:tl(e,t,n)}}function rl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Hu(t,t.return,e)}}}function il(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Hu(t,t.return,e)}}function al(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Jc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Jc),t;default:throw Error(o(435,e.tag))}}function ol(e,t){var n=al(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=qu.bind(null,e,t);t.then(r,r)}})}function sl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],a=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){$c=c.stateNode,el=!1;break a}break;case 5:$c=c.stateNode,el=!1;break a;case 3:case 4:$c=c.stateNode.containerInfo,el=!0;break a}c=c.return}if($c===null)throw Error(o(160));nl(a,s,i),$c=null,el=!1,a=i.alternate,a!==null&&(a.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ll(t,e),t=t.sibling}var cl=null;function ll(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:sl(t,e),ul(e),r&4&&(Nc(3,e,e.return),Mc(3,e),Nc(5,e,e.return));break;case 1:sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),r&64&&Gc&&(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 i=cl;if(sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),r&4){var a=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,i=i.ownerDocument||i;b:switch(r){case`title`:a=i.getElementsByTagName(`title`)[0],(!a||a[tt]||a[Je]||a.namespaceURI===`http://www.w3.org/2000/svg`||a.hasAttribute(`itemprop`))&&(a=i.createElement(r),i.head.insertBefore(a,i.querySelector(`head > title`))),Pd(a,r,n),a[Je]=e,st(a),r=a;break a;case`link`:var s=Vf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&a.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&a.getAttribute(`title`)===(n.title==null?null:n.title)&&a.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}a=i.createElement(r),Pd(a,r,n),i.head.appendChild(a);break;case`meta`:if(s=Vf(`meta`,`content`,i).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`content`)===(n.content==null?null:``+n.content)&&a.getAttribute(`name`)===(n.name==null?null:n.name)&&a.getAttribute(`property`)===(n.property==null?null:n.property)&&a.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&a.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}a=i.createElement(r),Pd(a,r,n),i.head.appendChild(a);break;default:throw Error(o(468,r))}a[Je]=e,st(a),r=a}e.stateNode=r}else Hf(i,e.type,e.stateNode);else e.stateNode=If(i,r,e.memoizedProps);else a===r?r===null&&e.stateNode!==null&&zc(e,e.memoizedProps,n.memoizedProps):(a===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):a.count--,r===null?Hf(i,e.type,e.stateNode):If(i,r,e.memoizedProps))}break;case 27:sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),n!==null&&r&4&&zc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),e.flags&32){i=e.stateNode;try{Nt(i,``)}catch(t){Hu(e,e.return,t)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,zc(e,i,n===null?i:n.memoizedProps)),r&1024&&(qc=!0);break;case 6:if(sl(t,e),ul(e),r&4){if(e.stateNode===null)throw Error(o(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Hu(e,e.return,t)}}break;case 3:if(Bf=null,i=cl,cl=gf(t.containerInfo),sl(t,e),cl=i,ul(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Hu(e,e.return,t)}qc&&(qc=!1,dl(e));break;case 4:r=cl,cl=gf(e.stateNode.containerInfo),sl(t,e),ul(e),cl=r;break;case 12:sl(t,e),ul(e);break;case 31:sl(t,e),ul(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 13:sl(t,e),ul(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Xl=me()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 22:i=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Gc,d=Kc;if(Gc=u||i,Kc=d||l,sl(t,e),Kc=d,Gc=u,ul(e),r&8192)a:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||l||Gc||Kc||pl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(a=l.stateNode,i)s=a.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){Hu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=i?``:l.memoizedProps}catch(e){Hu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;i?$d(m,!0):$d(l.stateNode,!1)}catch(e){Hu(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,ol(e,n))));break;case 19:sl(t,e),ul(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 30:break;case 21:break;default:sl(t,e),ul(e)}}function ul(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Bc(r)){n=r;break}r=r.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var i=n.stateNode;Uc(e,Vc(e),i);break;case 5:var a=n.stateNode;n.flags&32&&(Nt(a,``),n.flags&=-33),Uc(e,Vc(e),a);break;case 3:case 4:var s=n.stateNode.containerInfo;Hc(e,Vc(e),s);break;default:throw Error(o(161))}}catch(t){Hu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function dl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;dl(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;)Zc(e,t.alternate,t),t=t.sibling}function pl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Nc(4,t,t.return),pl(t);break;case 1:Lc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Fc(t,t.return,n),pl(t);break;case 27:pf(t.stateNode);case 26:case 5:Lc(t,t.return),pl(t);break;case 22:t.memoizedState===null&&pl(t);break;case 30:pl(t);break;default:pl(t)}e=e.sibling}}function ml(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:ml(i,a,n),Mc(4,a);break;case 1:if(ml(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Hu(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++)La(c[i],s)}catch(e){Hu(r,r.return,e)}}n&&o&64&&Pc(a),Ic(a,a.return);break;case 27:Wc(a);case 26:case 5:ml(i,a,n),n&&r===null&&o&4&&Rc(a),Ic(a,a.return);break;case 12:ml(i,a,n);break;case 31:ml(i,a,n),n&&o&4&&rl(i,a);break;case 13:ml(i,a,n),n&&o&4&&il(i,a);break;case 22:a.memoizedState===null&&ml(i,a,n),Ic(a,a.return);break;case 30:break;default:ml(i,a,n)}t=t.sibling}}function hl(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&&Xi(n))}function gl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Xi(e))}function _l(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:_l(e,t,n,r),i&2048&&Mc(9,t);break;case 1:_l(e,t,n,r);break;case 3:_l(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&&Xi(e)));break;case 12:if(i&2048){_l(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){Hu(t,t.return,e)}}else _l(e,t,n,r);break;case 31:_l(e,t,n,r);break;case 13:_l(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?_l(e,t,n,r):(a._visibility|=2,yl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?_l(e,t,n,r):bl(e,t),i&2048&&hl(o,t);break;case 24:_l(e,t,n,r),i&2048&&gl(t.alternate,t);break;default:_l(e,t,n,r)}}function yl(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:yl(a,o,s,c,i),Mc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,yl(a,o,s,c,i)):u._visibility&2?yl(a,o,s,c,i):bl(a,o),i&&l&2048&&hl(o.alternate,o);break;case 24:yl(a,o,s,c,i),i&&l&2048&&gl(o.alternate,o);break;default:yl(a,o,s,c,i)}t=t.sibling}}function bl(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:bl(n,r),i&2048&&hl(r.alternate,r);break;case 24:bl(n,r),i&2048&&gl(r.alternate,r);break;default:bl(n,r)}t=t.sibling}}var xl=8192;function Sl(e,t,n){if(e.subtreeFlags&xl)for(e=e.child;e!==null;)Cl(e,t,n),e=e.sibling}function Cl(e,t,n){switch(e.tag){case 26:Sl(e,t,n),e.flags&xl&&e.memoizedState!==null&&Gf(n,cl,e.memoizedState,e.memoizedProps);break;case 5:Sl(e,t,n);break;case 3:case 4:var r=cl;cl=gf(e.stateNode.containerInfo),Sl(e,t,n),cl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=xl,xl=16777216,Sl(e,t,n),xl=r):Sl(e,t,n));break;default:Sl(e,t,n)}}function wl(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 Tl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Yc=r,Ol(r,e)}wl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)El(e),e=e.sibling}function El(e){switch(e.tag){case 0:case 11:case 15:Tl(e),e.flags&2048&&Nc(9,e,e.return);break;case 3:Tl(e);break;case 12:Tl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Dl(e)):Tl(e);break;default:Tl(e)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Yc=r,Ol(r,e)}wl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Nc(8,t,t.return),Dl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Dl(t));break;default:Dl(t)}e=e.sibling}}function Ol(e,t){for(;Yc!==null;){var n=Yc;switch(n.tag){case 0:case 11:case 15:Nc(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:Xi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Yc=r;else a:for(n=e;Yc!==null;){r=Yc;var i=r.sibling,a=r.return;if(Qc(r),r===n){Yc=null;break a}if(i!==null){i.return=a,Yc=i;break a}Yc=a}}}var kl={getCacheForType:function(e){var t=Hi(Ji),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Hi(Ji).controller.signal}},Al=typeof WeakMap==`function`?WeakMap:Map,jl=0,Ml=null,Nl=null,Pl=0,Fl=0,Il=null,Ll=!1,Rl=!1,zl=!1,Bl=0,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=null,Jl=null,Yl=!1,Xl=0,Zl=0,Ql=1/0,$l=null,eu=null,tu=0,nu=null,ru=null,iu=0,au=0,ou=null,su=null,cu=0,lu=null;function uu(){return jl&2&&Pl!==0?Pl&-Pl:I.T===null?Ge():ld()}function du(){if(Gl===0)if(!(Pl&536870912)||Ci){var e=Ae;Ae<<=1,!(Ae&3932160)&&(Ae=262144),Gl=e}else Gl=536870912;return e=Wa.current,e!==null&&(e.flags|=32),Gl}function fu(e,t,n){(e===Ml&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)&&(yu(e,0),gu(e,Pl,Gl,!1)),Re(e,n),(!(jl&2)||e!==Ml)&&(e===Ml&&(!(jl&2)&&(Ul|=n),Vl===4&&gu(e,Pl,Gl,!1)),td(e))}function pu(e,t,n){if(jl&6)throw Error(o(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Pe(e,t),i=r?Du(e,t):Tu(e,t,!0),a=r;do{if(i===0){Rl&&!r&&gu(e,t,0,!1);break}else{if(n=e.current.alternate,a&&!hu(n)){i=Tu(e,t,!1),a=!1;continue}if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)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;i=ql;var l=c.current.memoizedState.isDehydrated;if(l&&(yu(c,s).flags|=256),s=Tu(c,s,!1),s!==2){if(zl&&!l){c.errorRecoveryDisabledLanes|=a,Ul|=a,i=4;break a}a=Jl,Jl=i,a!==null&&(Jl===null?Jl=a:Jl.push.apply(Jl,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){yu(e,0),gu(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:gu(r,t,Gl,!Ll);break a;case 2:Jl=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=Xl+300-me(),10<i)){if(gu(r,t,Gl,!Ll),Ne(r,0,!0)!==0)break a;iu=t,r.timeoutHandle=Kd(mu.bind(null,r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,a,`Throttled`,-0,0),i);break a}mu(r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,a,null,-0,0)}}break}while(1);td(e)}function mu(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:Vt},Cl(t,a,d);var m=(a&62914560)===a?Xl-me():(a&4194048)===a?Zl-me():0;if(m=qf(d,m),m!==null){iu=a,e.cancelPendingCommit=m(Pu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),gu(e,a,o,!l);return}}Pu(e,t,a,n,r,i,o,s,c)}function hu(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(!ur(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 gu(e,t,n,r){t&=~Wl,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Te(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Be(e,n,t)}function _u(){return jl&6?!0:(nd(0,!1),!1)}function vu(){if(Nl!==null){if(Fl===0)var e=Nl.return;else e=Nl,Pi=Ni=null,vo(e),ya=null,ba=0,e=Nl;for(;e!==null;)jc(e.alternate,e),e=e.return;Nl=null}}function yu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),iu=0,vu(),Ml=e,Nl=n=Qr(e.current,null),Pl=t,Fl=0,Il=null,Ll=!1,Rl=Pe(e,t),zl=!1,Kl=Gl=Wl=Ul=Hl=Vl=0,Jl=ql=null,Yl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Te(r),a=1<<i;t|=e[i],r&=~a}return Bl=t,Hr(),n}function bu(e,t){$=null,I.H=Os,t===la||t===da?(t=_a(),Fl=3):t===ua?(t=_a(),Fl=4):Fl=t===Ks?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Il=t,Nl===null&&(Vl=1,Bs(e,oi(t,e.current)))}function xu(){var e=Wa.current;return e===null?!0:(Pl&4194048)===Pl?Ga===null:(Pl&62914560)===Pl||Pl&536870912?e===Ga:!1}function Su(){var e=I.H;return I.H=Os,e===null?Os:e}function Cu(){var e=I.A;return I.A=kl,e}function wu(){Vl=4,Ll||(Pl&4194048)!==Pl&&Wa.current!==null||(Rl=!0),!(Hl&134217727)&&!(Ul&134217727)||Ml===null||gu(Ml,Pl,Gl,!1)}function Tu(e,t,n){var r=jl;jl|=2;var i=Su(),a=Cu();(Ml!==e||Pl!==t)&&($l=null,yu(e,t)),t=!1;var o=Vl;a:do try{if(Fl!==0&&Nl!==null){var s=Nl,c=Il;switch(Fl){case 8:vu(),o=6;break a;case 3:case 2:case 9:case 6:Wa.current===null&&(t=!0);var l=Fl;if(Fl=0,Il=null,ju(e,s,c,l),n&&Rl){o=0;break a}break;default:l=Fl,Fl=0,Il=null,ju(e,s,c,l)}}Eu(),o=Vl;break}catch(t){bu(e,t)}while(1);return t&&e.shellSuspendCounter++,Pi=Ni=null,jl=r,I.H=i,I.A=a,Nl===null&&(Ml=null,Pl=0,Hr()),o}function Eu(){for(;Nl!==null;)ku(Nl)}function Du(e,t){var n=jl;jl|=2;var r=Su(),i=Cu();Ml!==e||Pl!==t?($l=null,Ql=me()+500,yu(e,t)):Rl=Pe(e,t);a:do try{if(Fl!==0&&Nl!==null){t=Nl;var a=Il;b:switch(Fl){case 1:Fl=0,Il=null,ju(e,t,a,1);break;case 2:case 9:if(pa(a)){Fl=0,Il=null,Au(t);break}t=function(){Fl!==2&&Fl!==9||Ml!==e||(Fl=7),td(e)},a.then(t,t);break a;case 3:Fl=7;break a;case 4:Fl=5;break a;case 7:pa(a)?(Fl=0,Il=null,Au(t)):(Fl=0,Il=null,ju(e,t,a,7));break;case 5:var s=null;switch(Nl.tag){case 26:s=Nl.memoizedState;case 5:case 27:var c=Nl;if(s?Wf(s):c.stateNode.complete){Fl=0,Il=null;var l=c.sibling;if(l!==null)Nl=l;else{var u=c.return;u===null?Nl=null:(Nl=u,Mu(u))}break b}}Fl=0,Il=null,ju(e,t,a,5);break;case 6:Fl=0,Il=null,ju(e,t,a,6);break;case 8:vu(),Vl=6;break a;default:throw Error(o(462))}}Ou();break}catch(t){bu(e,t)}while(1);return Pi=Ni=null,I.H=r,I.A=i,jl=n,Nl===null?(Ml=null,Pl=0,Hr(),Vl):0}function Ou(){for(;Nl!==null&&!fe();)ku(Nl)}function ku(e){var t=Sc(e.alternate,e,Bl);e.memoizedProps=e.pendingProps,t===null?Mu(e):Nl=t}function Au(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=oc(n,t,t.pendingProps,t.type,void 0,Pl);break;case 11:t=oc(n,t,t.pendingProps,t.type.render,t.ref,Pl);break;case 5:vo(t);default:jc(n,t),t=Nl=$r(t,Bl),t=Sc(n,t,Bl)}e.memoizedProps=e.pendingProps,t===null?Mu(e):Nl=t}function ju(e,t,n,r){Pi=Ni=null,vo(t),ya=null,ba=0;var i=t.return;try{if(Gs(e,i,t,n,Pl)){Vl=1,Bs(e,oi(n,e.current)),Nl=null;return}}catch(t){if(i!==null)throw Nl=i,t;Vl=1,Bs(e,oi(n,e.current)),Nl=null;return}t.flags&32768?(Ci||r===1?e=!0:Rl||Pl&536870912?e=!1:(Ll=e=!0,(r===2||r===9||r===3||r===6)&&(r=Wa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Nu(t,e)):Mu(t)}function Mu(e){var t=e;do{if(t.flags&32768){Nu(t,Ll);return}e=t.return;var n=kc(t.alternate,t,Bl);if(n!==null){Nl=n;return}if(t=t.sibling,t!==null){Nl=t;return}Nl=t=e}while(t!==null);Vl===0&&(Vl=5)}function Nu(e,t){do{var n=Ac(e.alternate,e);if(n!==null){n.flags&=32767,Nl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Nl=e;return}Nl=e=n}while(e!==null);Vl=6,Nl=null}function Pu(e,t,n,r,i,a,s,c,l){e.cancelPendingCommit=null;do zu();while(tu!==0);if(jl&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(a=t.lanes|t.childLanes,a|=Vr,ze(e,n,a,s,c,l),e===Ml&&(Nl=Ml=null,Pl=0),ru=t,nu=e,iu=n,au=a,ou=i,su=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Ju(ve,function(){return Bu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=I.T,I.T=null,i=L.p,L.p=2,s=jl,jl|=4;try{Xc(e,t,n)}finally{jl=s,L.p=i,I.T=r}}tu=1,Fu(),Iu(),Lu()}}function Fu(){if(tu===1){tu=0;var e=nu,t=ru,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=jl;jl|=4;try{ll(t,e);var a=zd,o=hr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&mr(s.ownerDocument.documentElement,s)){if(c!==null&&gr(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 _=pr(s,h),v=pr(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}}sp=!!Rd,zd=Rd=null}finally{jl=i,L.p=r,I.T=n}}e.current=t,tu=2}}function Iu(){if(tu===2){tu=0;var e=nu,t=ru,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=jl;jl|=4;try{Zc(e,t.alternate,t)}finally{jl=i,L.p=r,I.T=n}}tu=3}}function Lu(){if(tu===4||tu===3){tu=0,pe();var e=nu,t=ru,n=iu,r=su;t.subtreeFlags&10256||t.flags&10256?tu=5:(tu=0,ru=nu=null,Ru(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(eu=null),We(n),t=t.stateNode,Ce&&typeof Ce.onCommitFiberRoot==`function`)try{Ce.onCommitFiberRoot(Se,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.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{I.T=t,L.p=i}}iu&3&&zu(),td(e),i=e.pendingLanes,n&261930&&i&42?e===lu?cu++:(cu=0,lu=e):cu=0,nd(0,!1)}}function Ru(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Xi(t)))}function zu(){return Fu(),Iu(),Lu(),Bu()}function Bu(){if(tu!==5)return!1;var e=nu,t=au;au=0;var n=We(iu),r=I.T,i=L.p;try{L.p=32>n?32:n,I.T=null,n=ou,ou=null;var a=nu,s=iu;if(tu=0,ru=nu=null,iu=0,jl&6)throw Error(o(331));var c=jl;if(jl|=4,El(a.current),vl(a,a.current,s,n),jl=c,nd(0,!1),Ce&&typeof Ce.onPostCommitFiberRoot==`function`)try{Ce.onPostCommitFiberRoot(Se,a)}catch{}return!0}finally{L.p=i,I.T=r,Ru(e,t)}}function Vu(e,t,n){t=oi(n,t),t=Hs(e.stateNode,t,2),e=ja(e,t,2),e!==null&&(Re(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=oi(n,e),n=Us(2),r=ja(t,n,2),r!==null&&(Ws(n,r,t,e),Re(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Al;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)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ml===e&&(Pl&n)===n&&(Vl===4||Vl===3&&(Pl&62914560)===Pl&&300>me()-Xl?!(jl&2)&&yu(e,0):Wl|=n,Kl===Pl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=Ie()),e=Gr(e,t),e!==null&&(Re(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return ue(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;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-Te(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Pl,a=Ne(r,r===Ml?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Pe(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=me(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Te(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Fe(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ml,n=Pl,n=Ne(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&de(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Pe(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&de(r),We(n)){case 2:case 8:n=_e;break;case 32:n=ve;break;case 268435456:n=be;break;default:n=ve}return r=od.bind(null,e),n=ue(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&de(r),e.callbackPriority=2,e.callbackNode=null,2}function od(e,t){if(tu!==0&&tu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(zu()&&e.callbackNode!==n)return null;var r=Pl;return r=Ne(e,e===Ml?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(pu(e,r,t),ad(e,me()),e.callbackNode!=null&&e.callbackNode===n?od.bind(null,e):null)}function sd(e,t){if(zu())return null;pu(e,t,!0)}function cd(){Yd(function(){jl&6?ue(ge,rd):id()})}function ld(){if(ed===0){var e=$i;e===0&&(e=ke,ke<<=1,!(ke&261888)&&(ke=256)),ed=e}return ed}function ud(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Bt(``+e)}function dd(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 fd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=ud((i[Ye]||null).action),o=r.submitter;o&&(t=(t=o[Ye]||null)?ud(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ed!==0){var e=o?dd(i,o):new FormData(i);ms(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?dd(i,o):new FormData(i),ms(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var pd=0;pd<Ir.length;pd++){var md=Ir[pd];Lr(md.toLowerCase(),`on`+(md[0].toUpperCase()+md.slice(1)))}Lr(Or,`onAnimationEnd`),Lr(kr,`onAnimationIteration`),Lr(Ar,`onAnimationStart`),Lr(`dblclick`,`onDoubleClick`),Lr(`focusin`,`onFocus`),Lr(`focusout`,`onBlur`),Lr(jr,`onTransitionRun`),Lr(Mr,`onTransitionStart`),Lr(Nr,`onTransitionCancel`),Lr(Pr,`onTransitionEnd`),dt(`onMouseEnter`,[`mouseout`,`mouseover`]),dt(`onMouseLeave`,[`mouseout`,`mouseover`]),dt(`onPointerEnter`,[`pointerout`,`pointerover`]),dt(`onPointerLeave`,[`pointerout`,`pointerover`]),ut(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ut(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ut(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ut(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var hd=`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(` `),gd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(hd));function _d(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){Rr(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){Rr(e)}i.currentTarget=null,a=c}}}}function vd(e,t){var n=t[Ze];n===void 0&&(n=t[Ze]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,ct.forEach(function(t){t!==`selectionchange`&&(gd.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!Zt||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 Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=rt(s),o===null)return;if(l=o.tag,l===5||l===6||l===26||l===27){r=a=o;continue a}s=s.parentNode}}r=r.return}Jt(function(){var r=a,i=Ut(n),o=[];a:{var s=Fr.get(e);if(s!==void 0){var l=ln,u=e;switch(e){case`keypress`:if(rn(n)===0)break a;case`keydown`:case`keyup`:l=Dn;break;case`focusin`:u=`focus`,l=vn;break;case`focusout`:u=`blur`,l=vn;break;case`beforeblur`:case`afterblur`:l=vn;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=gn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=_n;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=kn;break;case Or:case kr:case Ar:l=yn;break;case Pr:l=An;break;case`scroll`:case`scrollend`:l=dn;break;case`wheel`:l=jn;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=On;break;case`toggle`:case`beforetoggle`:l=Mn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;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=Yt(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(s=new l(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,s&&n!==Ht&&(u=n.relatedTarget||n.fromElement)&&(rt(u)||u[Xe]))break a;if((l||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?rt(u):null,u!==null&&(f=c(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=gn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=On,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?s:at(l),h=u==null?s:at(u),s=new d(g,m+`leave`,l,n,i),s.target=f,s.relatedTarget=h,g=null,rt(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=Ed,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&&Dd(o,s,l,d,!1),u!==null&&f!==null&&Dd(o,f,u,d,!0)}}a:{if(s=r?at(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var v=Qn;else if(Kn(s))if($n)v=cr;else{v=or;var y=ar}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Lt(r.elementType)&&(v=Qn):v=sr;if(v&&=v(e,r)){qn(o,v,n,i);break a}y&&y(e,s,r),e===`focusout`&&r&&s.type===`number`&&r.memoizedProps.value!=null&&kt(s,`number`,s.value)}switch(y=r?at(r):window,e){case`focusin`:(Kn(y)||y.contentEditable===`true`)&&(vr=y,yr=r,br=null);break;case`focusout`:br=yr=vr=null;break;case`mousedown`:xr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:xr=!1,Sr(o,n,i);break;case`selectionchange`:if(_r)break;case`keydown`:case`keyup`:Sr(o,n,i)}var b;if(Pn)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 Hn?Bn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Ln&&n.locale!==`ko`&&(Hn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Hn&&(b=nn()):($t=i,en=`value`in $t?$t.value:$t.textContent,Hn=!0)),y=Td(r,x),0<y.length&&(x=new xn(x,e,null,n,i),o.push({event:x,listeners:y}),b?x.data=b:(b=Vn(n),b!==null&&(x.data=b)))),(b=In?Un(e,n):Wn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new xn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:y,listeners:x}),y.data=b)),fd(o,e,r,n,i)}_d(o,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(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=Yt(e,n),i!=null&&r.unshift(wd(e,i,a)),i=Yt(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(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=Yt(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=Yt(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
|
|
10
|
+
`).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,i,a){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Nt(e,``+r);break;case`className`:_t(e,`class`,r);break;case`tabIndex`:_t(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:_t(e,n,r);break;case`style`:It(e,r,a);break;case`data`:if(t!==`object`){_t(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=Bt(``+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 a==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,i.name,i,null),Md(e,t,`formEncType`,i.formEncType,i,null),Md(e,t,`formMethod`,i.formMethod,i,null),Md(e,t,`formTarget`,i.formTarget,i,null)):(Md(e,t,`encType`,i.encType,i,null),Md(e,t,`method`,i.method,i,null),Md(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(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=Bt(``+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`:vd(`beforetoggle`,e),vd(`toggle`,e),gt(e,`popover`,r);break;case`xlinkActuate`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:gt(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=Rt.get(n)||n,gt(e,n,r))}}function Nd(e,t,n,r,i,a){switch(n){case`style`:It(e,r,a);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Nt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),a=e[Ye]||null,a=a==null?null:a[n],typeof a==`function`&&e.removeEventListener(t,a,i),typeof r==`function`)){typeof a!=`function`&&a!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):gt(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Md(e,t,a,s,n,null)}}i&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:Md(e,t,r,d,n,null)}}Ot(e,a,c,l,u,s,i,!1);return;case`select`:for(i in vd(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&At(e,!!r,n,!0):At(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:Md(e,t,s,c,n,null)}Mt(e,r,i,a);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:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`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(o(137,t));default:Md(e,t,u,r,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(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 i=null,a=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)||Md(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`:a=m;break;case`name`:i=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(o(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}Dt(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||Md(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:p=a;break;case`defaultValue`:c=a;break;case`multiple`:s=a;default:a!==l&&Md(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?At(e,!!n,n?[]:``,!1):At(e,!!n,t,!0)):At(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&Md(e,t,s,i,r,a)}jt(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:Md(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:Md(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)&&Md(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(o(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(Lt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(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||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(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||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){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&&Id(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&&Id(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 Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(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 Hd(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 Ud(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 Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(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),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[tt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(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 ef(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`:ef(n),nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(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[tt])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=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(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 cf(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 lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(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 ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);nt(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=L.d;L.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=it(e);t!==null&&t.tag===5&&t.type===`form`?gs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Et(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Et(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Et(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Et(n.imageSizes)+`"]`)):i+=`[href="`+Et(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(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(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Et(r)+`"][href="`+Et(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(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(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),st(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=ot(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);st(c),Pd(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,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=ot(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),st(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=ot(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),st(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=K.current)?gf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=ot(i).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=Af(n.href);var a=ot(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(jf(e)))&&!a._p&&(s.instance=a,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),a||Nf(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=ot(i).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(o(444,e))}}function Af(e){return`href="`+Et(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(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}),Pd(t,`link`,n),st(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Et(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Et(n.href)+`"]`);if(r)return t.instance=r,st(r),r;var i=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),st(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var a=e.querySelector(jf(i));if(a)return t.state.loading|=4,t.instance=a,st(a),a;r=Mf(n),(i=mf.get(i))&&Rf(r,i),a=(e.ownerDocument||e).createElement(`link`),st(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(a,`link`,r),t.state.loading|=4,Lf(a,n.precedence,e),t.instance=a;case`script`:return a=Pf(n.src),(i=e.querySelector(Ff(a)))?(t.instance=i,st(i),i):(r=n,(i=mf.get(a))&&(r=m({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),st(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(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 Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,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[tt]||a[Je]||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 Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(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 Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(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=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,st(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),st(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(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=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.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=Jf.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 Qf={$$typeof:S,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function $f(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=Le(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Le(0),this.hiddenUpdates=Le(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 ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Xr(3,null,null,t),e.current=a,a.stateNode=e,t=Yi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Oa(a),e}function tp(e){return e?(e=Jr,e):Jr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Aa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=ja(e,r,t),n!==null&&(fu(n,e,t),Ma(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Gr(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=Ue(t);var n=Gr(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,up(e,t,n,r)}finally{L.p=a,I.T=i}}function lp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,up(e,t,n,r)}finally{L.p=a,I.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=it(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Me(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Te(o);s.entanglements[1]|=c,o&=~c}td(a),!(jl&6)&&(Ql=me()+500,nd(0,!1))}}break;case 31:case 13:s=Gr(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Ut(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=rt(e),e!==null){var t=c(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=l(t),e!==null)return e;e=null}else if(n===31){if(e=u(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 fp=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(he()){case ge:return 2;case _e:return 8;case ve:case ye:return 32;case be:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`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 Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(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=it(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=rt(e.target);if(t!==null){var n=c(t);if(n!==null){if(t=n.tag,t===13){if(t=l(n),t!==null){e.blockedOn=t,Ke(e.priority,function(){op(n)});return}}else if(t===31){if(t=u(n),t!==null){e.blockedOn=t,Ke(e.priority,function(){op(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 Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ht=r,n.target.dispatchEvent(r),Ht=null}else return t=it(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=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(pp(r||n)===null)continue;break}var a=it(n);a!==null&&(e.splice(t,3),t-=3,ms(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.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[Ye]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Ye]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){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 Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[Xe]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ge();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.4`)throw Error(o(527,Lp,`19.2.4`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=f(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{Se=zp.inject(Rp),Ce=zp}catch{}}e.createRoot=function(e,t){if(!s(e))throw Error(o(299));var n=!1,r=``,i=Ls,a=Rs,c=zs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,i,a,c,Pp),e[Xe]=t.current,xd(e),new Fp(t)}})),A=r(((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=k()})),j=n(i(),1),M=`popstate`;function N(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function P(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return z(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:B(t)}return H(t,n,null,e)}function F(e,t){if(e===!1||e==null)throw Error(t)}function I(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function L(){return Math.random().toString(36).substring(2,10)}function R(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function z(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?V(t):t,state:n,key:t&&t.key||r||L(),unstable_mask:i}}function B({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function V(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function H(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=N(e)?e:z(h.location,e,t);n&&n(r,e),l=u()+1;let d=R(r,l),f=h.createHref(r.unstable_mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=N(e)?e:z(h.location,e,t);n&&n(r,e),l=u();let i=R(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return U(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(M,d),c=e,()=>{i.removeEventListener(M,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function U(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),F(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:B(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function W(e,t,n=`/`){return G(e,t,n,!1)}function G(e,t,n,r){let i=pe((typeof t==`string`?V(t):t).pathname||`/`,n);if(i==null)return null;let a=q(e);ee(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=fe(i);o=le(a[e],t,r)}return o}function K(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function q(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;F(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=X([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(F(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),q(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:se(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of J(e.path))a(e,t,!0,n)}),t}function J(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=J(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ee(e){e.sort((e,t)=>e.score===t.score?ce(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Y=/^:[\w-]+$/,te=3,ne=2,re=1,ie=10,ae=-2,oe=e=>e===`*`;function se(e,t){let n=e.split(`/`),r=n.length;return n.some(oe)&&(r+=ae),t&&(r+=ne),n.filter(e=>!oe(e)).reduce((e,t)=>e+(Y.test(t)?te:t===``?re:ie),r)}function ce(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function le(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=ue({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=ue({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:X([a,u.pathname]),pathnameBase:xe(X([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=X([a,u.pathnameBase]))}return o}function ue(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=de(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function de(e,t=!1,n=!0){I(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function fe(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return I(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function pe(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var me=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function he(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?V(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?ge(n.substring(1),`/`):ge(n,t)):a=t,{pathname:a,search:Se(r),hash:Ce(i)}}function ge(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function _e(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ve(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function ye(e){let t=ve(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function be(e,t,n,r=!1){let i;typeof e==`string`?i=V(e):(i={...e},F(!i.pathname||!i.pathname.includes(`?`),_e(`?`,`pathname`,`search`,i)),F(!i.pathname||!i.pathname.includes(`#`),_e(`#`,`pathname`,`hash`,i)),F(!i.search||!i.search.includes(`#`),_e(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=he(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var X=e=>e.join(`/`).replace(/\/\/+/g,`/`),xe=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Se=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ce=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,we=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Te(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ee(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var De=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Oe(e,t){let n=e;if(typeof n!=`string`||!me.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(De)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=pe(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{I(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var ke=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(ke);var Ae=[`GET`,...ke];new Set(Ae);var je=j.createContext(null);je.displayName=`DataRouter`;var Me=j.createContext(null);Me.displayName=`DataRouterState`;var Ne=j.createContext(!1);function Pe(){return j.useContext(Ne)}var Fe=j.createContext({isTransitioning:!1});Fe.displayName=`ViewTransition`;var Ie=j.createContext(new Map);Ie.displayName=`Fetchers`;var Le=j.createContext(null);Le.displayName=`Await`;var Re=j.createContext(null);Re.displayName=`Navigation`;var ze=j.createContext(null);ze.displayName=`Location`;var Be=j.createContext({outlet:null,matches:[],isDataRoute:!1});Be.displayName=`Route`;var Ve=j.createContext(null);Ve.displayName=`RouteError`;var He=`REACT_ROUTER_ERROR`,Ue=`REDIRECT`,We=`ROUTE_ERROR_RESPONSE`;function Ge(e){if(e.startsWith(`${He}:${Ue}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Ke(e){if(e.startsWith(`${He}:${We}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new we(t.status,t.statusText,t.data)}catch{}}function qe(e,{relative:t}={}){F(Je(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=j.useContext(Re),{hash:i,pathname:a,search:o}=it(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:X([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Je(){return j.useContext(ze)!=null}function Ye(){return F(Je(),`useLocation() may be used only in the context of a <Router> component.`),j.useContext(ze).location}var Xe=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Ze(e){j.useContext(Re).static||j.useLayoutEffect(e)}function Qe(){let{isDataRoute:e}=j.useContext(Be);return e?Ct():$e()}function $e(){F(Je(),`useNavigate() may be used only in the context of a <Router> component.`);let e=j.useContext(je),{basename:t,navigator:n}=j.useContext(Re),{matches:r}=j.useContext(Be),{pathname:i}=Ye(),a=JSON.stringify(ye(r)),o=j.useRef(!1);return Ze(()=>{o.current=!0}),j.useCallback((r,s={})=>{if(I(o.current,Xe),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=be(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:X([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var et=j.createContext(null);function tt(){return j.useContext(et)}function nt(e){let t=j.useContext(Be).outlet;return j.useMemo(()=>t&&j.createElement(et.Provider,{value:e},t),[t,e])}function rt(){let{matches:e}=j.useContext(Be),t=e[e.length-1];return t?t.params:{}}function it(e,{relative:t}={}){let{matches:n}=j.useContext(Be),{pathname:r}=Ye(),i=JSON.stringify(ye(n));return j.useMemo(()=>be(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function at(e,t){return ot(e,t)}function ot(e,t,n){F(Je(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=j.useContext(Re),{matches:i}=j.useContext(Be),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;Tt(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
11
|
+
|
|
12
|
+
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=Ye(),d;if(t){let e=typeof t==`string`?V(t):t;F(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=W(e,{pathname:p});I(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),I(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=pt(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:X([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:X([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?j.createElement(ze.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},h):h}function st(){let e=St(),t=Te(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=j.createElement(j.Fragment,null,j.createElement(`p`,null,`💿 Hey developer 👋`),j.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,j.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,j.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),j.createElement(j.Fragment,null,j.createElement(`h2`,null,`Unexpected Application Error!`),j.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?j.createElement(`pre`,{style:i},n):null,o)}var ct=j.createElement(st,null),lt=class extends j.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Ke(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:j.createElement(Be.Provider,{value:this.props.routeContext},j.createElement(Ve.Provider,{value:e,children:this.props.component}));return this.context?j.createElement(dt,{error:e},t):t}};lt.contextType=Ne;var ut=new WeakMap;function dt({children:e,error:t}){let{basename:n}=j.useContext(Re);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Ge(t.digest);if(e){let r=ut.get(t);if(r)throw r;let i=Oe(e.location,n);if(De&&!ut.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw ut.set(t,n),n}return j.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function ft({routeContext:e,match:t,children:n}){let r=j.useContext(je);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),j.createElement(Be.Provider,{value:e},n)}function pt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);F(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:Ee(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||ct,o&&(s<0&&c===0?(Tt(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?j.createElement(n.route.Component,null):n.route.element?n.route.element:e,j.createElement(ft,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?j.createElement(lt,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function mt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ht(e){let t=j.useContext(je);return F(t,mt(e)),t}function gt(e){let t=j.useContext(Me);return F(t,mt(e)),t}function _t(e){let t=j.useContext(Be);return F(t,mt(e)),t}function vt(e){let t=_t(e),n=t.matches[t.matches.length-1];return F(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function yt(){return vt(`useRouteId`)}function bt(){return gt(`useNavigation`).navigation}function xt(){let{matches:e,loaderData:t}=gt(`useMatches`);return j.useMemo(()=>e.map(e=>K(e,t)),[e,t])}function St(){let e=j.useContext(Ve),t=gt(`useRouteError`),n=vt(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Ct(){let{router:e}=ht(`useNavigate`),t=vt(`useNavigate`),n=j.useRef(!1);return Ze(()=>{n.current=!0}),j.useCallback(async(r,i={})=>{I(n.current,Xe),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var wt={};function Tt(e,t,n){!t&&!wt[e]&&(wt[e]=!0,I(!1,n))}j.useOptimistic,j.memo(Et);function Et({routes:e,future:t,state:n,isStatic:r,onError:i}){return ot(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function Dt({to:e,replace:t,state:n,relative:r}){F(Je(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=j.useContext(Re);I(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=j.useContext(Be),{pathname:o}=Ye(),s=Qe(),c=be(e,ye(a),o,r===`path`),l=JSON.stringify(c);return j.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Ot(e){return nt(e.context)}function kt(e){F(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function At({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){F(!Je(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=j.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=V(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,unstable_mask:m}=n,h=j.useMemo(()=>{let e=pe(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,unstable_mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return I(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:j.createElement(Re.Provider,{value:c},j.createElement(ze.Provider,{children:t,value:h}))}function jt({children:e,location:t}){return at(Mt(e),t)}j.Component;function Mt(e,t=[]){let n=[];return j.Children.forEach(e,(e,r)=>{if(!j.isValidElement(e))return;let i=[...t,r];if(e.type===j.Fragment){n.push.apply(n,Mt(e.props.children,i));return}F(e.type===kt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),F(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Mt(e.props.children,i)),n.push(a)}),n}var Nt=`get`,Pt=`application/x-www-form-urlencoded`;function Ft(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function It(e){return Ft(e)&&e.tagName.toLowerCase()===`button`}function Lt(e){return Ft(e)&&e.tagName.toLowerCase()===`form`}function Rt(e){return Ft(e)&&e.tagName.toLowerCase()===`input`}function zt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Bt(e,t){return e.button===0&&(!t||t===`_self`)&&!zt(e)}function Vt(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Ht(e,t){let n=Vt(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Ut=null;function Wt(){if(Ut===null)try{new FormData(document.createElement(`form`),0),Ut=!1}catch{Ut=!0}return Ut}var Gt=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Kt(e){return e!=null&&!Gt.has(e)?(I(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Pt}"`),null):e}function qt(e,t){let n,r,i,a,o;if(Lt(e)){let o=e.getAttribute(`action`);r=o?pe(o,t):null,n=e.getAttribute(`method`)||Nt,i=Kt(e.getAttribute(`enctype`))||Pt,a=new FormData(e)}else if(It(e)||Rt(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?pe(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Nt,i=Kt(e.getAttribute(`formenctype`))||Kt(o.getAttribute(`enctype`))||Pt,a=new FormData(o,e),!Wt()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Ft(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Nt,r=null,i=Pt,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Jt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Yt=/[&><\u2028\u2029]/g;function Xt(e){return e.replace(Yt,e=>Jt[e])}function Zt(e,t){if(e===!1||e==null)throw Error(t)}function Qt(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&pe(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function $t(e,t){if(e.id in t)return t[e.id];try{let n=await o(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function en(e){return e!=null&&typeof e.page==`string`}function tn(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function nn(e,t,n){return cn((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await $t(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(tn).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function rn(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function an(e,t,{includeHydrateFallback:n}={}){return on(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function on(e){return[...new Set(e)]}function sn(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function cn(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!en(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(sn(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function ln(){let e=j.useContext(je);return Zt(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function un(){let e=j.useContext(Me);return Zt(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var dn=j.createContext(void 0);dn.displayName=`FrameworkContext`;function fn(){let e=j.useContext(dn);return Zt(e,`You must render this element inside a <HydratedRouter> element`),e}function pn(e,t){let n=j.useContext(dn),[r,i]=j.useState(!1),[a,o]=j.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=j.useRef(null);j.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),j.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:mn(s,p),onBlur:mn(c,m),onMouseEnter:mn(l,p),onMouseLeave:mn(u,m),onTouchStart:mn(d,p)}]:[a,f,{}]:[!1,f,{}]}function mn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function hn({page:e,...t}){let n=Pe(),{router:r}=ln(),i=j.useMemo(()=>W(r.routes,e,r.basename),[r.routes,e,r.basename]);return i?n?j.createElement(_n,{page:e,matches:i,...t}):j.createElement(vn,{page:e,matches:i,...t}):null}function gn(e){let{manifest:t,routeModules:n}=fn(),[r,i]=j.useState([]);return j.useEffect(()=>{let r=!1;return nn(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function _n({page:e,matches:t,...n}){let r=Ye(),{future:i}=fn(),{basename:a}=ln(),o=j.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=Qt(e,a,i.unstable_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.unstable_trailingSlashAwareDataRequests,e,r,t]);return j.createElement(j.Fragment,null,o.map(e=>j.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function vn({page:e,matches:t,...n}){let r=Ye(),{future:i,manifest:a,routeModules:o}=fn(),{basename:s}=ln(),{loaderData:c,matches:l}=un(),u=j.useMemo(()=>rn(e,t,l,a,r,`data`),[e,t,l,a,r]),d=j.useMemo(()=>rn(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=j.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=Qt(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=j.useMemo(()=>an(d,a),[d,a]),m=gn(d);return j.createElement(j.Fragment,null,f.map(e=>j.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>j.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>j.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function yn(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}j.Component;var bn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{bn&&(window.__reactRouterVersion=`7.14.0`)}catch{}function xn({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=j.useRef();i.current??=P({window:r,v5Compat:!0});let a=i.current,[o,s]=j.useState({action:a.action,location:a.location}),c=j.useCallback(e=>{n===!1?s(e):j.startTransition(()=>s(e))},[n]);return j.useLayoutEffect(()=>a.listen(c),[a,c]),j.createElement(At,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Sn({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=j.useState({action:n.action,location:n.location}),o=j.useCallback(e=>{r===!1?a(e):j.startTransition(()=>a(e))},[r]);return j.useLayoutEffect(()=>n.listen(o),[n,o]),j.createElement(At,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Sn.displayName=`unstable_HistoryRouter`;var Cn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wn=j.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,unstable_useTransitions:_}=j.useContext(Re),v=typeof l==`string`&&Cn.test(l),y=Oe(l,h);l=y.to;let b=qe(l,{relative:r}),x=Ye(),S=null;if(o){let e=be(o,[],x.unstable_mask?x.unstable_mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:X([h,e.pathname])),S=g.createHref(e)}let[C,w,T]=pn(n,p),E=jn(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:_});function D(t){e&&e(t),t.defaultPrevented||E(t)}let O=!(y.isExternal||i),k=j.createElement(`a`,{...p,...T,href:(O?S:void 0)||y.absoluteURL||b,onClick:O?D:e,ref:yn(m,w),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return C&&!v?j.createElement(j.Fragment,null,k,j.createElement(hn,{page:b})):k});wn.displayName=`Link`;var Tn=j.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=it(a,{relative:c.relative}),d=Ye(),f=j.useContext(Me),{navigator:p,basename:m}=j.useContext(Re),h=f!=null&&Hn(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=pe(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,w;w=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(S):i;return j.createElement(wn,{...c,"aria-current":C,className:w,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(S):s)});Tn.displayName=`NavLink`;var En=j.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Nt,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=j.useContext(Re),g=Fn(),_=In(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Cn.test(s);return j.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?j.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});En.displayName=`Form`;function Dn({getKey:e,storageKey:t,...n}){let r=j.useContext(dn),{basename:i}=j.useContext(Re),a=Ye(),o=xt();Bn({getKey:e,storageKey:t});let s=j.useMemo(()=>{if(!r||!e)return null;let t=zn(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return j.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Xt(JSON.stringify(t||Ln))}, ${Xt(JSON.stringify(s))})`}})}Dn.displayName=`ScrollRestoration`;function On(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kn(e){let t=j.useContext(je);return F(t,On(e)),t}function An(e){let t=j.useContext(Me);return F(t,On(e)),t}function jn(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=Qe(),d=Ye(),f=it(e,{relative:o});return j.useCallback(p=>{if(Bt(p,t)){p.preventDefault();let t=n===void 0?B(d)===B(f):n,m=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?j.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function Mn(e){I(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=j.useRef(Vt(e)),n=j.useRef(!1),r=Ye(),i=j.useMemo(()=>Ht(r.search,n.current?null:t.current),[r.search]),a=Qe();return[i,j.useCallback((e,t)=>{let r=Vt(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Nn=0,Pn=()=>`__${String(++Nn)}__`;function Fn(){let{router:e}=kn(`useSubmit`),{basename:t}=j.useContext(Re),n=yt(),r=e.fetch,i=e.navigate;return j.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=qt(e,t);a.navigate===!1?await r(a.fetcherKey||Pn(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function In(e,{relative:t}={}){let{basename:n}=j.useContext(Re),r=j.useContext(Be);F(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...it(e||`.`,{relative:t})},o=Ye();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:X([n,a.pathname])),B(a)}var Ln=`react-router-scroll-positions`,Rn={};function zn(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:pe(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Bn({getKey:e,storageKey:t}={}){let{router:n}=kn(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=An(`useScrollRestoration`),{basename:a}=j.useContext(Re),o=Ye(),s=xt(),c=bt();j.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Vn(j.useCallback(()=>{if(c.state===`idle`){let t=zn(o,s,a,e);Rn[t]=window.scrollY}try{sessionStorage.setItem(t||Ln,JSON.stringify(Rn))}catch(e){I(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(j.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Ln);e&&(Rn=JSON.parse(e))}catch{}},[t]),j.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Rn,()=>window.scrollY,e?(t,n)=>zn(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),j.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{I(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Vn(e,t){let{capture:n}=t||{};j.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Hn(e,{relative:t}={}){let n=j.useContext(Fe);F(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=kn(`useViewTransitionState`),i=it(e,{relative:t});if(!n.isTransitioning)return!1;let a=pe(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=pe(n.nextLocation.pathname,r)||n.nextLocation.pathname;return ue(i.pathname,o)!=null||ue(i.pathname,a)!=null}var Un=u(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Wn=u(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),Gn=u(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),Kn=u(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),qn=u(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Jn=u(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Yn=u(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Xn=u(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Zn=u(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Qn=u(`badge-plus`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`16`,key:`10p56q`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),$n=u(`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`}]]),er=u(`box`,[[`path`,{d:`M21 8a2 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.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),tr=u(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),nr=u(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),rr=u(`building-2`,[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]]),ir=u(`check-line`,[[`path`,{d:`M20 4L9 15`,key:`1qkx8z`}],[`path`,{d:`M21 19L3 19`,key:`100sma`}],[`path`,{d:`M9 15L4 10`,key:`9zxff7`}]]),ar=u(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),or=u(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),sr=u(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),cr=u(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),lr=u(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ur=u(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),dr=u(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),fr=u(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),pr=u(`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`}]]),mr=u(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),hr=u(`clock-plus`,[[`path`,{d:`M12 6v6l3.644 1.822`,key:`1jmett`}],[`path`,{d:`M16 19h6`,key:`xwg31i`}],[`path`,{d:`M19 16v6`,key:`tddt3s`}],[`path`,{d:`M21.92 13.267a10 10 0 1 0-8.653 8.653`,key:`1u0osk`}]]),gr=u(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),_r=u(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),vr=u(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),yr=u(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),br=u(`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`}]]),xr=u(`crosshair`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]),Sr=u(`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`}]]),Cr=u(`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`}]]),wr=u(`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`}]]),Tr=u(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),Er=u(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 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 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Dr=u(`file-plus`,[[`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:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),Or=u(`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`}]]),kr=u(`file`,[[`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`}]]),Ar=u(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 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.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),jr=u(`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`}]]),Mr=u(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Nr=u(`git-branch-plus`,[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Pr=u(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Fr=u(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Ir=u(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),Lr=u(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Rr=u(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),zr=u(`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`}]]),Br=u(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Vr=u(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Hr=u(`list-checks`,[[`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`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),Ur=u(`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`}]]),Wr=u(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Gr=u(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Kr=u(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),qr=u(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),Jr=u(`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`}]]),Yr=u(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Xr=u(`merge`,[[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}],[`path`,{d:`M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22`,key:`1hyw0i`}],[`path`,{d:`m20 22-5-5`,key:`1m27yz`}]]),Zr=u(`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`}]]),Qr=u(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),$r=u(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),ei=u(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ti=u(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ni=u(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),ri=u(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`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`}]]),ii=u(`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`}]]),ai=u(`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`}]]),oi=u(`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`}]]),si=u(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ci=u(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),li=u(`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`}]]),ui=u(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),di=u(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),fi=u(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),pi=u(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),mi=u(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),hi=u(`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`}]]),gi=u(`square-menu`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 8h10`,key:`1jw688`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]]),_i=u(`square-minus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),vi=u(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),yi=u(`square-x`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),bi=u(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),xi=u(`toy-brick`,[[`rect`,{width:`18`,height:`12`,x:`3`,y:`8`,rx:`1`,key:`158fvp`}],[`path`,{d:`M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3`,key:`s0042v`}],[`path`,{d:`M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3`,key:`9wmeh2`}]]),Si=u(`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`}]]),Ci=u(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),wi=u(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),Ti=u(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ei=u(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Di=u(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Oi=u(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),ki=A();typeof window<`u`&&window.document&&window.document.createElement;function Z(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Ai(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function ji(...e){return t=>{let n=!1,r=e.map(e=>{let r=Ai(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():Ai(e[t],null)}}}}function Mi(...e){return j.useCallback(ji(...e),e)}var Q=C();function Ni(e,t){let n=j.createContext(t),r=e=>{let{children:t,...r}=e,i=j.useMemo(()=>r,Object.values(r));return(0,Q.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=j.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function Pi(e,t=[]){let n=[];function r(t,r){let i=j.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=j.useMemo(()=>o,Object.values(o));return(0,Q.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=j.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=>j.createContext(e));return function(n){let r=n?.[e]||t;return j.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Fi(i,...t)]}function Fi(...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 j.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Ii=n(a(),1);function Li(e){let t=Ri(e),n=j.forwardRef((e,n)=>{let{children:r,...i}=e,a=j.Children.toArray(r),o=a.find(Vi);if(o){let e=o.props.children,r=a.map(t=>t===o?j.Children.count(e)>1?j.Children.only(null):j.isValidElement(e)?e.props.children:null:t);return(0,Q.jsx)(t,{...i,ref:n,children:j.isValidElement(e)?j.cloneElement(e,void 0,r):null})}return(0,Q.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ri(e){let t=j.forwardRef((e,t)=>{let{children:n,...r}=e;if(j.isValidElement(n)){let e=Ui(n),i=Hi(r,n.props);return n.type!==j.Fragment&&(i.ref=t?ji(t,e):e),j.cloneElement(n,i)}return j.Children.count(n)>1?j.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var zi=Symbol(`radix.slottable`);function Bi(e){let t=({children:e})=>(0,Q.jsx)(Q.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=zi,t}function Vi(e){return j.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===zi}function Hi(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 Ui(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 Wi=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Li(`Primitive.${t}`),r=j.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Q.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Gi(e,t){e&&Ii.flushSync(()=>e.dispatchEvent(t))}function Ki(e){let t=j.useRef(e);return j.useEffect(()=>{t.current=e}),j.useMemo(()=>(...e)=>t.current?.(...e),[])}function qi(e,t=globalThis?.document){let n=Ki(e);j.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 Ji=`DismissableLayer`,Yi=`dismissableLayer.update`,Xi=`dismissableLayer.pointerDownOutside`,Zi=`dismissableLayer.focusOutside`,Qi,$i=j.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ea=j.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=j.useContext($i),[u,d]=j.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=j.useState({}),m=Mi(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=ra(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=ia(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return qi(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),j.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Qi=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),aa(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Qi)}},[u,f,n,l]),j.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),aa())},[u,l]),j.useEffect(()=>{let e=()=>p({});return document.addEventListener(Yi,e),()=>document.removeEventListener(Yi,e)},[]),(0,Q.jsx)(Wi.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:Z(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Z(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Z(e.onPointerDownCapture,x.onPointerDownCapture)})});ea.displayName=Ji;var ta=`DismissableLayerBranch`,na=j.forwardRef((e,t)=>{let n=j.useContext($i),r=j.useRef(null),i=Mi(t,r);return j.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,Q.jsx)(Wi.div,{...e,ref:i})});na.displayName=ta;function ra(e,t=globalThis?.document){let n=Ki(e),r=j.useRef(!1),i=j.useRef(()=>{});return j.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){oa(Xi,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 ia(e,t=globalThis?.document){let n=Ki(e),r=j.useRef(!1);return j.useEffect(()=>{let e=e=>{e.target&&!r.current&&oa(Zi,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 aa(){let e=new CustomEvent(Yi);document.dispatchEvent(e)}function oa(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?Gi(i,a):i.dispatchEvent(a)}var sa=globalThis?.document?j.useLayoutEffect:()=>{},ca=j.useId||(()=>void 0),la=0;function ua(e){let[t,n]=j.useState(ca());return sa(()=>{e||n(e=>e??String(la++))},[e]),e||(t?`radix-${t}`:``)}var da=[`top`,`right`,`bottom`,`left`],fa=Math.min,pa=Math.max,ma=Math.round,ha=Math.floor,ga=e=>({x:e,y:e}),_a={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function va(e,t,n){return pa(e,fa(t,n))}function ya(e,t){return typeof e==`function`?e(t):e}function ba(e){return e.split(`-`)[0]}function xa(e){return e.split(`-`)[1]}function Sa(e){return e===`x`?`y`:`x`}function Ca(e){return e===`y`?`height`:`width`}function wa(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ta(e){return Sa(wa(e))}function Ea(e,t,n){n===void 0&&(n=!1);let r=xa(e),i=Ta(e),a=Ca(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Fa(o)),[o,Fa(o)]}function Da(e){let t=Fa(e);return[Oa(e),t,Oa(t)]}function Oa(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ka=[`left`,`right`],Aa=[`right`,`left`],ja=[`top`,`bottom`],Ma=[`bottom`,`top`];function Na(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Aa:ka:t?ka:Aa;case`left`:case`right`:return t?ja:Ma;default:return[]}}function Pa(e,t,n,r){let i=xa(e),a=Na(ba(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Oa)))),a}function Fa(e){let t=ba(e);return _a[t]+e.slice(t.length)}function Ia(e){return{top:0,right:0,bottom:0,left:0,...e}}function La(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ia(e)}function Ra(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function za(e,t,n){let{reference:r,floating:i}=e,a=wa(t),o=Ta(t),s=Ca(o),c=ba(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(xa(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function Ba(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ya(t,e),p=La(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Ra(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Ra(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Va=50,Ha=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ba},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=za(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Va&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=za(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ua=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ya(e,t)||{};if(l==null)return{};let d=La(u),f={x:n,y:r},p=Ta(i),m=Ca(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=fa(d[_],T),D=fa(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=va(O,A,k),M=!c.arrow&&xa(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Wa=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ya(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=ba(r),_=wa(o),v=ba(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Fa(o)]:Da(o)),x=p!==`none`;!d&&x&&b.push(...Pa(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Ea(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==wa(t))||T.every(e=>wa(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=wa(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Ga(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ka(e){return da.some(t=>e[t]>=0)}var qa=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=ya(e,t);switch(i){case`referenceHidden`:{let e=Ga(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ka(e)}}}case`escaped`:{let e=Ga(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ka(e)}}}default:return{}}}}},Ja=new Set([`left`,`top`]);async function Ya(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ba(n),s=xa(n),c=wa(n)===`y`,l=Ja.has(o)?-1:1,u=a&&c?-1:1,d=ya(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Xa=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ya(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Za=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ya(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=wa(ba(i)),p=Sa(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=va(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=va(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Qa=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ya(e,t),u={x:n,y:r},d=wa(i),f=Sa(d),p=u[f],m=u[d],h=ya(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ja.has(ba(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},$a=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=ya(e,t),u=await o.detectOverflow(t,l),d=ba(i),f=xa(i),p=wa(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=fa(h-u[g],v),x=fa(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=pa(u.left,0),t=pa(u.right,0),n=pa(u.top,0),r=pa(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:pa(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:pa(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function $(){return typeof window<`u`}function eo(e){return ro(e)?(e.nodeName||``).toLowerCase():`#document`}function to(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function no(e){return((ro(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ro(e){return $()?e instanceof Node||e instanceof to(e).Node:!1}function io(e){return $()?e instanceof Element||e instanceof to(e).Element:!1}function ao(e){return $()?e instanceof HTMLElement||e instanceof to(e).HTMLElement:!1}function oo(e){return!$()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof to(e).ShadowRoot}function so(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=yo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function co(e){return/^(table|td|th)$/.test(eo(e))}function lo(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var uo=/transform|translate|scale|rotate|perspective|filter/,fo=/paint|layout|strict|content/,po=e=>!!e&&e!==`none`,mo;function ho(e){let t=io(e)?yo(e):e;return po(t.transform)||po(t.translate)||po(t.scale)||po(t.rotate)||po(t.perspective)||!_o()&&(po(t.backdropFilter)||po(t.filter))||uo.test(t.willChange||``)||fo.test(t.contain||``)}function go(e){let t=xo(e);for(;ao(t)&&!vo(t);){if(ho(t))return t;if(lo(t))return null;t=xo(t)}return null}function _o(){return mo??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),mo}function vo(e){return/^(html|body|#document)$/.test(eo(e))}function yo(e){return to(e).getComputedStyle(e)}function bo(e){return io(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function xo(e){if(eo(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||oo(e)&&e.host||no(e);return oo(t)?t.host:t}function So(e){let t=xo(e);return vo(t)?e.ownerDocument?e.ownerDocument.body:e.body:ao(t)&&so(t)?t:So(t)}function Co(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=So(e),i=r===e.ownerDocument?.body,a=to(r);if(i){let e=wo(a);return t.concat(a,a.visualViewport||[],so(r)?r:[],e&&n?Co(e):[])}else return t.concat(r,Co(r,[],n))}function wo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function To(e){let t=yo(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ao(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ma(n)!==a||ma(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Eo(e){return io(e)?e:e.contextElement}function Do(e){let t=Eo(e);if(!ao(t))return ga(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=To(t),o=(a?ma(n.width):n.width)/r,s=(a?ma(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Oo=ga(0);function ko(e){let t=to(e);return!_o()||!t.visualViewport?Oo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ao(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==to(e)?!1:t}function jo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Eo(e),o=ga(1);t&&(r?io(r)&&(o=Do(r)):o=Do(e));let s=Ao(a,n,r)?ko(a):ga(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=to(a),t=r&&io(r)?to(r):r,n=e,i=wo(n);for(;i&&r&&t!==n;){let e=Do(i),t=i.getBoundingClientRect(),r=yo(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=to(i),i=wo(n)}}return Ra({width:u,height:d,x:c,y:l})}function Mo(e,t){let n=bo(e).scrollLeft;return t?t.left+n:jo(no(e)).left+n}function No(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Mo(e,n),y:n.top+t.scrollTop}}function Po(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=no(r),s=t?lo(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ga(1),u=ga(0),d=ao(r);if((d||!d&&!a)&&((eo(r)!==`body`||so(o))&&(c=bo(r)),d)){let e=jo(r);l=Do(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?No(o,c):ga(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Fo(e){return Array.from(e.getClientRects())}function Io(e){let t=no(e),n=bo(e),r=e.ownerDocument.body,i=pa(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=pa(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Mo(e),s=-n.scrollTop;return yo(r).direction===`rtl`&&(o+=pa(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Lo=25;function Ro(e,t){let n=to(e),r=no(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=_o();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Mo(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Lo&&(a-=o)}else l<=Lo&&(a+=l);return{width:a,height:o,x:s,y:c}}function zo(e,t){let n=jo(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ao(e)?Do(e):ga(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Bo(e,t,n){let r;if(t===`viewport`)r=Ro(e,n);else if(t===`document`)r=Io(no(e));else if(io(t))r=zo(t,n);else{let n=ko(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ra(r)}function Vo(e,t){let n=xo(e);return n===t||!io(n)||vo(n)?!1:yo(n).position===`fixed`||Vo(n,t)}function Ho(e,t){let n=t.get(e);if(n)return n;let r=Co(e,[],!1).filter(e=>io(e)&&eo(e)!==`body`),i=null,a=yo(e).position===`fixed`,o=a?xo(e):e;for(;io(o)&&!vo(o);){let t=yo(o),n=ho(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||so(o)&&!n&&Vo(e,o))?r=r.filter(e=>e!==o):i=t,o=xo(o)}return t.set(e,r),r}function Uo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?lo(t)?[]:Ho(t,this._c):[].concat(n),r],o=Bo(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Bo(t,a[e],i);s=pa(n.top,s),c=fa(n.right,c),l=fa(n.bottom,l),u=pa(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Wo(e){let{width:t,height:n}=To(e);return{width:t,height:n}}function Go(e,t,n){let r=ao(t),i=no(t),a=n===`fixed`,o=jo(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ga(0);function l(){c.x=Mo(i)}if(r||!r&&!a)if((eo(t)!==`body`||so(i))&&(s=bo(t)),r){let e=jo(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?No(i,s):ga(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ko(e){return yo(e).position===`static`}function qo(e,t){if(!ao(e)||yo(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return no(e)===n&&(n=n.ownerDocument.body),n}function Jo(e,t){let n=to(e);if(lo(e))return n;if(!ao(e)){let t=xo(e);for(;t&&!vo(t);){if(io(t)&&!Ko(t))return t;t=xo(t)}return n}let r=qo(e,t);for(;r&&co(r)&&Ko(r);)r=qo(r,t);return r&&vo(r)&&Ko(r)&&!ho(r)?n:r||go(e)||n}var Yo=async function(e){let t=this.getOffsetParent||Jo,n=this.getDimensions,r=await n(e.floating);return{reference:Go(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xo(e){return yo(e).direction===`rtl`}var Zo={convertOffsetParentRelativeRectToViewportRelativeRect:Po,getDocumentElement:no,getClippingRect:Uo,getOffsetParent:Jo,getElementRects:Yo,getClientRects:Fo,getDimensions:Wo,getScale:Do,isElement:io,isRTL:Xo};function Qo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $o(e,t){let n=null,r,i=no(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=ha(d),h=ha(i.clientWidth-(u+f)),g=ha(i.clientHeight-(d+p)),_=ha(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:pa(0,fa(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Qo(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function es(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Eo(e),u=i||a?[...l?Co(l):[],...t?Co(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?$o(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?jo(e):null;c&&g();function g(){let t=jo(e);h&&!Qo(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ts=Xa,ns=Za,rs=Wa,is=$a,as=qa,os=Ua,ss=Qa,cs=(e,t,n)=>{let r=new Map,i={platform:Zo,...n},a={...i.platform,_c:r};return Ha(e,t,{...i,platform:a})},ls=typeof document<`u`?j.useLayoutEffect:function(){};function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!us(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ds(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fs(e,t){let n=ds(e);return Math.round(t*n)/n}function ps(e){let t=j.useRef(e);return ls(()=>{t.current=e}),t}function ms(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=j.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=j.useState(r);us(f,r)||p(r);let[m,h]=j.useState(null),[g,_]=j.useState(null),v=j.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=j.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=j.useRef(null),C=j.useRef(null),w=j.useRef(u),T=c!=null,E=ps(c),D=ps(i),O=ps(l),k=j.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),cs(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!us(w.current,t)&&(w.current=t,Ii.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);ls(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=j.useRef(!1);ls(()=>(A.current=!0,()=>{A.current=!1}),[]),ls(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let M=j.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=j.useMemo(()=>({reference:b,floating:x}),[b,x]),P=j.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=fs(N.floating,u.x),r=fs(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ds(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return j.useMemo(()=>({...u,update:k,refs:M,elements:N,floatingStyles:P}),[u,k,M,N,P])}var hs=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:os({element:r.current,padding:i}).fn(n):r?os({element:r,padding:i}).fn(n):{}}}},gs=(e,t)=>{let n=ts(e);return{name:n.name,fn:n.fn,options:[e,t]}},_s=(e,t)=>{let n=ns(e);return{name:n.name,fn:n.fn,options:[e,t]}},vs=(e,t)=>({fn:ss(e).fn,options:[e,t]}),ys=(e,t)=>{let n=rs(e);return{name:n.name,fn:n.fn,options:[e,t]}},bs=(e,t)=>{let n=is(e);return{name:n.name,fn:n.fn,options:[e,t]}},xs=(e,t)=>{let n=as(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ss=(e,t)=>{let n=hs(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cs=`Arrow`,ws=j.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,Q.jsx)(Wi.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Q.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});ws.displayName=Cs;var Ts=ws;function Es(e){let[t,n]=j.useState(void 0);return sa(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Ds=`Popper`,[Os,ks]=Pi(Ds),[As,js]=Os(Ds),Ms=e=>{let{__scopePopper:t,children:n}=e,[r,i]=j.useState(null);return(0,Q.jsx)(As,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ms.displayName=Ds;var Ns=`PopperAnchor`,Ps=j.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=js(Ns,n),o=j.useRef(null),s=Mi(t,o),c=j.useRef(null);return j.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,Q.jsx)(Wi.div,{...i,ref:s})});Ps.displayName=Ns;var Fs=`PopperContent`,[Is,Ls]=Os(Fs),Rs=j.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=js(Fs,n),[_,v]=j.useState(null),y=Mi(t,e=>v(e)),[b,x]=j.useState(null),S=Es(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(Hs),altBoundary:O},{refs:A,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=ms({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>es(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[gs({mainAxis:i+w,alignmentAxis:o}),c&&_s({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?vs():void 0,...k}),c&&ys({...k}),bs({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&Ss({element:b,padding:s}),Us({arrowWidth:C,arrowHeight:w}),f&&xs({strategy:`referenceHidden`,...k})]}),[I,L]=Ws(N),R=Ki(m);sa(()=>{P&&R?.()},[P,R]);let z=F.arrow?.x,B=F.arrow?.y,V=F.arrow?.centerOffset!==0,[H,U]=j.useState();return sa(()=>{_&&U(window.getComputedStyle(_).zIndex)},[_]),(0,Q.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:H,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Q.jsx)(Is,{scope:n,placedSide:I,onArrowChange:x,arrowX:z,arrowY:B,shouldHideArrow:V,children:(0,Q.jsx)(Wi.div,{"data-side":I,"data-align":L,...h,ref:y,style:{...h.style,animation:P?void 0:`none`}})})})});Rs.displayName=Fs;var zs=`PopperArrow`,Bs={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Vs=j.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ls(zs,n),a=Bs[i.placedSide];return(0,Q.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Q.jsx)(Ts,{...r,ref:t,style:{...r.style,display:`block`}})})});Vs.displayName=zs;function Hs(e){return e!==null}var Us=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ws(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Ws(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Gs=Ms,Ks=Ps,qs=Rs,Js=Vs,Ys=`Portal`,Xs=j.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=j.useState(!1);sa(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Ii.createPortal((0,Q.jsx)(Wi.div,{...r,ref:t}),o):null});Xs.displayName=Ys;function Zs(e,t){return j.useReducer((e,n)=>t[e][n]??e,e)}var Qs=e=>{let{present:t,children:n}=e,r=$s(t),i=typeof n==`function`?n({present:r.isPresent}):j.Children.only(n),a=Mi(r.ref,tc(i));return typeof n==`function`||r.isPresent?j.cloneElement(i,{ref:a}):null};Qs.displayName=`Presence`;function $s(e){let[t,n]=j.useState(),r=j.useRef(null),i=j.useRef(e),a=j.useRef(`none`),[o,s]=Zs(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return j.useEffect(()=>{let e=ec(r.current);a.current=o===`mounted`?e:`none`},[o]),sa(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ec(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),sa(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ec(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=ec(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:j.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function ec(e){return e?.animationName||`none`}function tc(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 nc=j.useInsertionEffect||sa;function rc({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=ic({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=j.useRef(e!==void 0);j.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,j.useCallback(t=>{if(s){let n=ac(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function ic({defaultProp:e,onChange:t}){let[n,r]=j.useState(e),i=j.useRef(n),a=j.useRef(t);return nc(()=>{a.current=t},[t]),j.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function ac(e){return typeof e==`function`}var oc=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),sc=`VisuallyHidden`,cc=j.forwardRef((e,t)=>(0,Q.jsx)(Wi.span,{...e,ref:t,style:{...oc,...e.style}}));cc.displayName=sc;var lc=cc,[uc,dc]=Pi(`Tooltip`,[ks]),fc=ks(),pc=`TooltipProvider`,mc=700,hc=`tooltip.open`,[gc,_c]=uc(pc),vc=e=>{let{__scopeTooltip:t,delayDuration:n=mc,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=j.useRef(!0),s=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Q.jsx)(gc,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:j.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};vc.displayName=pc;var yc=`Tooltip`,[bc,xc]=uc(yc),Sc=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=_c(yc,e.__scopeTooltip),l=fc(t),[u,d]=j.useState(null),f=ua(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=rc({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(hc))):c.onClose(),a?.(e)},caller:yc}),y=j.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return j.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Q.jsx)(Gs,{...l,children:(0,Q.jsx)(bc,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:j.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Sc.displayName=yc;var Cc=`TooltipTrigger`,wc=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=xc(Cc,n),a=_c(Cc,n),o=fc(n),s=Mi(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Q.jsx)(Ks,{asChild:!0,...o,children:(0,Q.jsx)(Wi.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Z(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Z(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Z(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Z(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Z(e.onBlur,i.onClose),onClick:Z(e.onClick,i.onClose)})})});wc.displayName=Cc;var Tc=`TooltipPortal`,[Ec,Dc]=uc(Tc,{forceMount:void 0}),Oc=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=xc(Tc,t);return(0,Q.jsx)(Ec,{scope:t,forceMount:n,children:(0,Q.jsx)(Qs,{present:n||a.open,children:(0,Q.jsx)(Xs,{asChild:!0,container:i,children:r})})})};Oc.displayName=Tc;var kc=`TooltipContent`,Ac=j.forwardRef((e,t)=>{let n=Dc(kc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=xc(kc,e.__scopeTooltip);return(0,Q.jsx)(Qs,{present:r||o.open,children:o.disableHoverableContent?(0,Q.jsx)(Fc,{side:i,...a,ref:t}):(0,Q.jsx)(jc,{side:i,...a,ref:t})})}),jc=j.forwardRef((e,t)=>{let n=xc(kc,e.__scopeTooltip),r=_c(kc,e.__scopeTooltip),i=j.useRef(null),a=Mi(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=zc(r,Rc(r,n.getBoundingClientRect())),a=Bc(t.getBoundingClientRect());s(Hc([...i,...a])),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Vc(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Q.jsx)(Fc,{...e,ref:a})}),[Mc,Nc]=uc(yc,{isInside:!1}),Pc=Bi(`TooltipContent`),Fc=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=xc(kc,n),l=fc(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(hc,u),()=>document.removeEventListener(hc,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Q.jsx)(ea,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Q.jsxs)(qs,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Q.jsx)(Pc,{children:r}),(0,Q.jsx)(Mc,{scope:n,isInside:!0,children:(0,Q.jsx)(lc,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Ac.displayName=kc;var Ic=`TooltipArrow`,Lc=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=fc(n);return Nc(Ic,n).isInside?null:(0,Q.jsx)(Js,{...i,...r,ref:t})});Lc.displayName=Ic;function Rc(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function zc(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Bc(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Vc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Hc(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Uc(t)}function Uc(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Wc=vc,Gc=Sc,Kc=wc,qc=Oc,Jc=Ac;function Yc({className:e,...t}){return(0,Q.jsx)(`kbd`,{className:b(`pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none`,e),...t})}function Xc({className:e,...t}){return(0,Q.jsx)(`span`,{className:b(`inline-flex items-center gap-0.5`,e),...t})}var Zc=`z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,Qc=Wc,$c=Gc,el=Kc,tl=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Q.jsx)(qc,{children:(0,Q.jsx)(Jc,{ref:r,sideOffset:t,className:b(`z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tl.displayName=Jc.displayName;function nl(e){return e.toUpperCase()}function rl(e){return(0,Q.jsx)(Xc,{children:e.split(`+`).map((e,t)=>(0,Q.jsx)(Yc,{children:nl(e)},`${e}-${t}`))})}var il=j.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},a)=>{let o=r===void 0?null:Array.isArray(r)?r[0]??null:r;return(0,Q.jsx)(qc,{children:(0,Q.jsx)(Jc,{ref:a,sideOffset:t,className:b(Zc,e),...i,children:o?rl(o):(0,Q.jsx)(`span`,{children:typeof n==`string`?nl(n):n})})})});il.displayName=`HotkeyTooltipContent`;var al={sm:`text-sm px-2.5 py-1`,md:`text-sm px-3 py-1.5`};function ol({value:e,onValueChange:t,options:n,size:r=`md`,className:i,optionClassName:a,alwaysShowLabels:o=!1}){return(0,Q.jsx)(`div`,{className:b(`inline-flex items-center rounded-lg border border-border p-[3px] `,i),children:n.map(n=>{let i=n.value===e,s=n.icon,c=s?(0,j.isValidElement)(s)?s:(0,Q.jsx)(s,{className:r===`sm`?`h-3.5 w-3.5`:`h-4 w-4`}):null,l=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.value),disabled:n.disabled,"aria-pressed":i,className:b(`rounded-[4px] border transition-colors`,s?`grid grid-cols-[auto_auto] items-center gap-2`:`inline-flex items-center gap-1.5`,al[r],i?`bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 `:`border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground`,n.disabled&&`opacity-50 pointer-events-none`,a),children:[c,(0,Q.jsx)(`span`,{className:s&&!o?`hidden md:inline`:void 0,children:n.label})]},n.value);return n.tooltip?(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:l}),(0,Q.jsx)(tl,{children:n.tooltip})]},n.value):l})})}function sl(e){let[t,n]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(e)return e.subscribe({type:`runtime-status`},n)},[e]),t}function cl({status:e}){return(0,Q.jsx)(`span`,{className:b(`inline-block h-2 w-2 rounded-full shrink-0`,{"bg-green-500":e===`healthy`,"bg-yellow-500":e===`degraded`,"bg-red-500":e===`unavailable`})})}function ll({source:e}){return(0,Q.jsx)(`span`,{className:b(`text-xs px-1.5 py-0.5 rounded font-medium`,e===`managed`?`bg-blue-500/15 text-blue-400`:`bg-muted text-muted-foreground`),children:e})}function ul({runtime:e,onHealthCheck:t,onRemove:n,onDetect:r}){let{health:i}=e;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(er,{className:`size-4 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-sm text-foreground`,children:e.provider}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:[`v`,e.version]}),(0,Q.jsx)(ll,{source:e.source})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono mt-0.5 truncate`,children:e.binaryPath})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:r,children:(0,Q.jsx)(li,{className:`size-3`})})}),(0,Q.jsx)(tl,{children:`Scan system`})]}),(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:t,children:(0,Q.jsx)(Un,{className:`size-3`})})}),(0,Q.jsx)(tl,{children:`Health check`})]}),e.source===`managed`&&(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:n,children:(0,Q.jsx)(Si,{className:`size-3`})})}),(0,Q.jsx)(tl,{children:`Remove runtime`})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(cl,{status:i.status}),(0,Q.jsx)(`span`,{className:`capitalize`,children:i.status}),i.latencyMs>0&&(0,Q.jsxs)(`span`,{children:[i.latencyMs,`ms`]}),i.error&&(0,Q.jsx)(`span`,{className:`text-red-400 truncate`,children:i.error})]})]})}function dl({state:e}){let t=sl(e.socket);function n(t){e.socket.command({type:`runtime.detect`,provider:t})}function r(t,n){e.socket.command({type:`runtime.health`,provider:t,version:n})}function i(t,n){e.socket.command({type:`runtime.remove`,provider:t,version:n})}return(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage runtime binaries for Claude and Codex.`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>n(`claude`),children:[(0,Q.jsx)(li,{className:`size-3.5 mr-1.5`}),`Scan Claude`]}),(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>n(`codex`),children:[(0,Q.jsx)(li,{className:`size-3.5 mr-1.5`}),`Scan Codex`]})]}),!t||t.runtimes.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center border border-dashed border-border rounded-lg`,children:[(0,Q.jsx)(er,{className:`size-8 text-muted-foreground/50 mb-3`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runtimes detected`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:`Use Scan above to detect installed CLIs`})]}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:t.runtimes.map(e=>(0,Q.jsx)(ul,{runtime:e,onDetect:()=>n(e.provider),onHealthCheck:()=>r(e.provider,e.version),onRemove:()=>i(e.provider,e.version)},`${e.provider}-${e.version}`))})]})}function fl(e){let[t,n]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(e)return e.subscribe({type:`profiles`},n)},[e]),t}var pl={default:`rounded-lg px-3 py-2 bg-background outline-none`,sm:`rounded-md px-2 py-1 bg-transparent focus:ring-1 focus:ring-ring`},ml=j.forwardRef(({className:e,type:t,size:n=`default`,...r},i)=>(0,Q.jsx)(`input`,{ref:i,type:t,className:b(`flex w-full border border-border text-sm text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,pl[n],e),...r}));ml.displayName=`Input`;var hl={default:`rounded-lg px-2.5 py-2 bg-background`,sm:`rounded-md px-2 py-1 bg-transparent focus:ring-1 focus:ring-ring resize-none`},gl=j.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,Q.jsx)(`textarea`,{"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,"data-1p-ignore":!0,autoComplete:`off`,className:b(`flex w-full border border-border text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,hl[t],e),ref:r,...n}));gl.displayName=`Textarea`;var _l=`focusScope.autoFocusOnMount`,vl=`focusScope.autoFocusOnUnmount`,yl={bubbles:!1,cancelable:!0},bl=`FocusScope`,xl=j.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=j.useState(null),l=Ki(i),u=Ki(a),d=j.useRef(null),f=Mi(t,e=>c(e)),p=j.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;j.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Ol(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Ol(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Ol(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]),j.useEffect(()=>{if(s){kl.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(_l,yl);s.addEventListener(_l,l),s.dispatchEvent(t),t.defaultPrevented||(Sl(Ml(wl(s)),{select:!0}),document.activeElement===e&&Ol(s))}return()=>{s.removeEventListener(_l,l),setTimeout(()=>{let t=new CustomEvent(vl,yl);s.addEventListener(vl,u),s.dispatchEvent(t),t.defaultPrevented||Ol(e??document.body,{select:!0}),s.removeEventListener(vl,u),kl.remove(p)},0)}}},[s,l,u,p]);let m=j.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]=Cl(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Ol(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Ol(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,Q.jsx)(Wi.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});xl.displayName=bl;function Sl(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Ol(r,{select:t}),document.activeElement!==n)return}function Cl(e){let t=wl(e);return[Tl(t,e),Tl(t.reverse(),e)]}function wl(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 Tl(e,t){for(let n of e)if(!El(n,{upTo:t}))return n}function El(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 Dl(e){return e instanceof HTMLInputElement&&`select`in e}function Ol(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dl(e)&&t&&e.select()}}var kl=Al();function Al(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=jl(e,t),e.unshift(t)},remove(t){e=jl(e,t),e[0]?.resume()}}}function jl(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ml(e){return e.filter(e=>e.tagName!==`A`)}var Nl=0;function Pl(){j.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Fl()),document.body.insertAdjacentElement(`beforeend`,e[1]??Fl()),Nl++,()=>{Nl===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Nl--}},[])}function Fl(){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 Il=function(){return Il=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},Il.apply(this,arguments)};function Ll(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 Rl(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var zl=`right-scroll-bar-position`,Bl=`width-before-scroll-bar`,Vl=`with-scroll-bars-hidden`,Hl=`--removed-body-scroll-bar-size`;function Ul(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Wl(e,t){var n=(0,j.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 Gl=typeof window<`u`?j.useLayoutEffect:j.useEffect,Kl=new WeakMap;function ql(e,t){var n=Wl(t||null,function(t){return e.forEach(function(e){return Ul(e,t)})});return Gl(function(){var t=Kl.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Ul(e,null)}),i.forEach(function(e){r.has(e)||Ul(e,a)})}Kl.set(n,e)},[e]),n}function Jl(e){return e}function Yl(e,t){t===void 0&&(t=Jl);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 Xl(e){e===void 0&&(e={});var t=Yl(null);return t.options=Il({async:!0,ssr:!1},e),t}var Zl=function(e){var t=e.sideCar,n=Ll(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 j.createElement(r,Il({},n))};Zl.isSideCarExport=!0;function Ql(e,t){return e.useMedium(t),Zl}var $l=Xl(),eu=function(){},tu=j.forwardRef(function(e,t){var n=j.useRef(null),r=j.useState({onScrollCapture:eu,onWheelCapture:eu,onTouchMoveCapture:eu}),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,v=_===void 0?`div`:_,y=e.gapMode,b=Ll(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=ql([n,t]),C=Il(Il({},b),i);return j.createElement(j.Fragment,null,u&&j.createElement(x,{sideCar:$l,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?j.cloneElement(j.Children.only(s),Il(Il({},C),{ref:S})):j.createElement(v,Il({},C,{className:c,ref:S}),s))});tu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},tu.classNames={fullWidth:Bl,zeroRight:zl};var nu,ru=function(){if(nu)return nu;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function iu(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=ru();return t&&e.setAttribute(`nonce`,t),e}function au(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ou(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var su=function(){var e=0,t=null;return{add:function(n){e==0&&(t=iu())&&(au(t,n),ou(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cu=function(){var e=su();return function(t,n){j.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},lu=function(){var e=cu();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},uu={left:0,top:0,right:0,gap:0},du=function(e){return parseInt(e||``,10)||0},fu=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[du(n),du(r),du(i)]},pu=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return uu;var t=fu(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])}},mu=lu(),hu=`data-scroll-locked`,gu=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
13
|
+
.${Vl} {
|
|
14
|
+
overflow: hidden ${r};
|
|
15
|
+
padding-right: ${s}px ${r};
|
|
16
|
+
}
|
|
17
|
+
body[${hu}] {
|
|
18
|
+
overflow: hidden ${r};
|
|
19
|
+
overscroll-behavior: contain;
|
|
20
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
21
|
+
padding-left: ${i}px;
|
|
22
|
+
padding-top: ${a}px;
|
|
23
|
+
padding-right: ${o}px;
|
|
24
|
+
margin-left:0;
|
|
25
|
+
margin-top:0;
|
|
26
|
+
margin-right: ${s}px ${r};
|
|
27
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.${zl} {
|
|
31
|
+
right: ${s}px ${r};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.${Bl} {
|
|
35
|
+
margin-right: ${s}px ${r};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.${zl} .${zl} {
|
|
39
|
+
right: 0 ${r};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.${Bl} .${Bl} {
|
|
43
|
+
margin-right: 0 ${r};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
body[${hu}] {
|
|
47
|
+
${Hl}: ${s}px;
|
|
48
|
+
}
|
|
49
|
+
`},_u=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},vu=function(){j.useEffect(function(){return document.body.setAttribute(hu,(_u()+1).toString()),function(){var e=_u()-1;e<=0?document.body.removeAttribute(hu):document.body.setAttribute(hu,e.toString())}},[])},yu=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;vu();var a=j.useMemo(function(){return pu(i)},[i]);return j.createElement(mu,{styles:gu(a,!t,i,n?``:`!important`)})},bu=!1;if(typeof window<`u`)try{var xu=Object.defineProperty({},`passive`,{get:function(){return bu=!0,!0}});window.addEventListener(`test`,xu,xu),window.removeEventListener(`test`,xu,xu)}catch{bu=!1}var Su=bu?{passive:!1}:!1,Cu=function(e){return e.tagName===`TEXTAREA`},wu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Cu(e)&&n[t]===`visible`)},Tu=function(e){return wu(e,`overflowY`)},Eu=function(e){return wu(e,`overflowX`)},Du=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Au(e,r)){var i=ju(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ou=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},ku=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Au=function(e,t){return e===`v`?Tu(t):Eu(t)},ju=function(e,t){return e===`v`?Ou(t):ku(t)},Mu=function(e,t){return e===`h`&&t===`rtl`?-1:1},Nu=function(e,t,n,r,i){var a=Mu(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=ju(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Au(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},Pu=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Fu=function(e){return[e.deltaX,e.deltaY]},Iu=function(e){return e&&`current`in e?e.current:e},Lu=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ru=function(e){return`
|
|
50
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
51
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
52
|
+
`},zu=0,Bu=[];function Vu(e){var t=j.useRef([]),n=j.useRef([0,0]),r=j.useRef(),i=j.useState(zu++)[0],a=j.useState(lu)[0],o=j.useRef(e);j.useEffect(function(){o.current=e},[e]),j.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Rl([e.lockRef.current],(e.shards||[]).map(Iu),!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=j.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Pu(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=Du(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Du(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 Nu(h,t,e,h===`h`?s:c,!0)},[]),c=j.useCallback(function(e){var n=e;if(!(!Bu.length||Bu[Bu.length-1]!==a)){var r=`deltaY`in n?Fu(n):Pu(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Lu(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Iu).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=j.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Hu(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=j.useCallback(function(e){n.current=Pu(e),r.current=void 0},[]),d=j.useCallback(function(t){l(t.type,Fu(t),t.target,s(t,e.lockRef.current))},[]),f=j.useCallback(function(t){l(t.type,Pu(t),t.target,s(t,e.lockRef.current))},[]);j.useEffect(function(){return Bu.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Su),document.addEventListener(`touchmove`,c,Su),document.addEventListener(`touchstart`,u,Su),function(){Bu=Bu.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Su),document.removeEventListener(`touchmove`,c,Su),document.removeEventListener(`touchstart`,u,Su)}},[]);var p=e.removeScrollBar,m=e.inert;return j.createElement(j.Fragment,null,m?j.createElement(a,{styles:Ru(i)}):null,p?j.createElement(yu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Hu(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Uu=Ql($l,Vu),Wu=j.forwardRef(function(e,t){return j.createElement(tu,Il({},e,{ref:t,sideCar:Uu}))});Wu.classNames=tu.classNames;var Gu=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Ku=new WeakMap,qu=new WeakMap,Ju={},Yu=0,Xu=function(e){return e&&(e.host||Xu(e.parentNode))},Zu=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Xu(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})},Qu=function(e,t,n,r){var i=Zu(t,Array.isArray(e)?e:[e]);Ju[n]||(Ju[n]=new WeakMap);var a=Ju[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=(Ku.get(e)||0)+1,l=(a.get(e)||0)+1;Ku.set(e,c),a.set(e,l),o.push(e),c===1&&i&&qu.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(),Yu++,function(){o.forEach(function(e){var t=Ku.get(e)-1,i=a.get(e)-1;Ku.set(e,t),a.set(e,i),t||(qu.has(e)||e.removeAttribute(r),qu.delete(e)),i||e.removeAttribute(n)}),Yu--,Yu||(Ku=new WeakMap,Ku=new WeakMap,qu=new WeakMap,Ju={})}},$u=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Gu(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Qu(r,i,n,`aria-hidden`)):function(){return null}},ed=`Dialog`,[td,nd]=Pi(ed),[rd,id]=td(ed),ad=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=j.useRef(null),c=j.useRef(null),[l,u]=rc({prop:r,defaultProp:i??!1,onChange:a,caller:ed});return(0,Q.jsx)(rd,{scope:t,triggerRef:s,contentRef:c,contentId:ua(),titleId:ua(),descriptionId:ua(),open:l,onOpenChange:u,onOpenToggle:j.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};ad.displayName=ed;var od=`DialogTrigger`,sd=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=id(od,n),a=Mi(t,i.triggerRef);return(0,Q.jsx)(Wi.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Dd(i.open),...r,ref:a,onClick:Z(e.onClick,i.onOpenToggle)})});sd.displayName=od;var cd=`DialogPortal`,[ld,ud]=td(cd,{forceMount:void 0}),dd=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=id(cd,t);return(0,Q.jsx)(ld,{scope:t,forceMount:n,children:j.Children.map(r,e=>(0,Q.jsx)(Qs,{present:n||a.open,children:(0,Q.jsx)(Xs,{asChild:!0,container:i,children:e})}))})};dd.displayName=cd;var fd=`DialogOverlay`,pd=j.forwardRef((e,t)=>{let n=ud(fd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=id(fd,e.__scopeDialog);return a.modal?(0,Q.jsx)(Qs,{present:r||a.open,children:(0,Q.jsx)(hd,{...i,ref:t})}):null});pd.displayName=fd;var md=Li(`DialogOverlay.RemoveScroll`),hd=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=id(fd,n);return(0,Q.jsx)(Wu,{as:md,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Q.jsx)(Wi.div,{"data-state":Dd(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),gd=`DialogContent`,_d=j.forwardRef((e,t)=>{let n=ud(gd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=id(gd,e.__scopeDialog);return(0,Q.jsx)(Qs,{present:r||a.open,children:a.modal?(0,Q.jsx)(vd,{...i,ref:t}):(0,Q.jsx)(yd,{...i,ref:t})})});_d.displayName=gd;var vd=j.forwardRef((e,t)=>{let n=id(gd,e.__scopeDialog),r=j.useRef(null),i=Mi(t,n.contentRef,r);return j.useEffect(()=>{let e=r.current;if(e)return $u(e)},[]),(0,Q.jsx)(bd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Z(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Z(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Z(e.onFocusOutside,e=>e.preventDefault())})}),yd=j.forwardRef((e,t)=>{let n=id(gd,e.__scopeDialog),r=j.useRef(!1),i=j.useRef(!1);return(0,Q.jsx)(bd,{...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()}})}),bd=j.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=id(gd,n),c=j.useRef(null),l=Mi(t,c);return Pl(),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Q.jsx)(ea,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Dd(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jd,{titleId:s.titleId}),(0,Q.jsx)(Nd,{contentRef:c,descriptionId:s.descriptionId})]})]})}),xd=`DialogTitle`,Sd=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=id(xd,n);return(0,Q.jsx)(Wi.h2,{id:i.titleId,...r,ref:t})});Sd.displayName=xd;var Cd=`DialogDescription`,wd=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=id(Cd,n);return(0,Q.jsx)(Wi.p,{id:i.descriptionId,...r,ref:t})});wd.displayName=Cd;var Td=`DialogClose`,Ed=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=id(Td,n);return(0,Q.jsx)(Wi.button,{type:`button`,...r,ref:t,onClick:Z(e.onClick,()=>i.onOpenChange(!1))})});Ed.displayName=Td;function Dd(e){return e?`open`:`closed`}var Od=`DialogTitleWarning`,[kd,Ad]=Ni(Od,{contentName:gd,titleName:xd,docsSlug:`dialog`}),jd=({titleId:e})=>{let t=Ad(Od),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
53
|
+
|
|
54
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
55
|
+
|
|
56
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Md=`DialogDescriptionWarning`,Nd=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ad(Md).contentName}}.`;return j.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Pd=ad,Fd=sd,Id=dd,Ld=pd,Rd=_d,zd=Sd,Bd=wd,Vd=Ed,Hd=`AlertDialog`,[Ud,Wd]=Pi(Hd,[nd]),Gd=nd(),Kd=e=>{let{__scopeAlertDialog:t,...n}=e,r=Gd(t);return(0,Q.jsx)(Pd,{...r,...n,modal:!0})};Kd.displayName=Hd;var qd=`AlertDialogTrigger`,Jd=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Gd(n);return(0,Q.jsx)(Fd,{...i,...r,ref:t})});Jd.displayName=qd;var Yd=`AlertDialogPortal`,Xd=e=>{let{__scopeAlertDialog:t,...n}=e,r=Gd(t);return(0,Q.jsx)(Id,{...r,...n})};Xd.displayName=Yd;var Zd=`AlertDialogOverlay`,Qd=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Gd(n);return(0,Q.jsx)(Ld,{...i,...r,ref:t})});Qd.displayName=Zd;var $d=`AlertDialogContent`,[ef,tf]=Ud($d),nf=Bi(`AlertDialogContent`),rf=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=Gd(n),o=j.useRef(null),s=Mi(t,o),c=j.useRef(null);return(0,Q.jsx)(kd,{contentName:$d,titleName:af,docsSlug:`alert-dialog`,children:(0,Q.jsx)(ef,{scope:n,cancelRef:c,children:(0,Q.jsxs)(Rd,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:Z(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,Q.jsx)(nf,{children:r}),(0,Q.jsx)(pf,{contentRef:o})]})})})});rf.displayName=$d;var af=`AlertDialogTitle`,of=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Gd(n);return(0,Q.jsx)(zd,{...i,...r,ref:t})});of.displayName=af;var sf=`AlertDialogDescription`,cf=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Gd(n);return(0,Q.jsx)(Bd,{...i,...r,ref:t})});cf.displayName=sf;var lf=`AlertDialogAction`,uf=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Gd(n);return(0,Q.jsx)(Vd,{...i,...r,ref:t})});uf.displayName=lf;var df=`AlertDialogCancel`,ff=j.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=tf(df,n),a=Gd(n),o=Mi(t,i);return(0,Q.jsx)(Vd,{...a,...r,ref:o})});ff.displayName=df;var pf=({contentRef:e})=>{let t=`\`${$d}\` requires a description for the component to be accessible for screen reader users.
|
|
57
|
+
|
|
58
|
+
You can add a description to the \`${$d}\` by passing a \`${sf}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
59
|
+
|
|
60
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${$d}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
61
|
+
|
|
62
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{document.getElementById(e.current?.getAttribute(`aria-describedby`))||console.warn(t)},[t,e]),null},mf=Kd,hf=Jd,gf=Xd,_f=Qd,vf=rf,yf=uf,bf=ff,xf=of,Sf=cf,Cf=mf,wf=hf,Tf=gf,Ef=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(_f,{ref:n,className:b(`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}));Ef.displayName=_f.displayName;var Df=j.forwardRef(({className:e,...t},n)=>(0,Q.jsxs)(Tf,{children:[(0,Q.jsx)(Ef,{}),(0,Q.jsx)(vf,{ref:n,className:b(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-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),...t})]}));Df.displayName=vf.displayName;function Of({className:e,...t}){return(0,Q.jsx)(`div`,{className:b(`flex flex-col space-y-2 text-center sm:text-left`,e),...t})}function kf({className:e,...t}){return(0,Q.jsx)(`div`,{className:b(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t})}var Af=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(xf,{ref:n,className:b(`text-lg font-semibold`,e),...t}));Af.displayName=xf.displayName;var jf=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Sf,{ref:n,className:b(`text-sm text-muted-foreground`,e),...t}));jf.displayName=Sf.displayName;var Mf=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(yf,{ref:n,className:b(`inline-flex h-10 items-center justify-center rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground ring-offset-background transition-colors hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,e),...t}));Mf.displayName=yf.displayName;var Nf=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(bf,{ref:n,className:b(`inline-flex h-10 items-center justify-center rounded-md border border-border bg-background px-4 py-2 text-sm font-medium ring-offset-background transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 mt-2 sm:mt-0`,e),...t}));Nf.displayName=bf.displayName;function Pf(){return`profile-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Ff={id:``,name:``,provider:`claude`,model:``,runtime:`system`,apiKeyRef:``,systemPrompt:``};function If({initial:e,onSubmit:t,onCancel:n,isEdit:r}){let[i,a]=(0,j.useState)(e);function o(){!i.name.trim()||!i.model.trim()||t({...i,id:r?i.id:Pf(),apiKeyRef:i.apiKeyRef?.trim()||void 0,systemPrompt:i.systemPrompt?.trim()||void 0})}return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[r&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono`,children:i.id}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Name *`,value:i.name,onChange:e=>a({...i,name:e.target.value}),autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsxs)(`select`,{className:b(`flex h-8 w-full rounded-md border border-input bg-transparent px-2 py-1 text-sm shadow-sm`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`),value:i.provider,onChange:e=>a({...i,provider:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,Q.jsx)(`option`,{value:`codex`,children:`Codex`})]}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Model *`,value:i.model,onChange:e=>a({...i,model:e.target.value})})]}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`API key ref (e.g. env:ANTHROPIC_API_KEY)`,value:i.apiKeyRef??``,onChange:e=>a({...i,apiKeyRef:e.target.value})}),(0,Q.jsx)(gl,{size:`sm`,placeholder:`System prompt`,rows:3,value:i.systemPrompt??``,onChange:e=>a({...i,systemPrompt:e.target.value})}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(S,{variant:`default`,size:`sm`,onClick:o,children:r?`Save`:`Create`}),(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`})]})]})}function Lf({record:e,onEdit:t,onRemove:n}){let{profile:r}=e;return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2.5 rounded-lg border border-border hover:bg-accent/30 transition-colors`,children:[r.provider===`claude`?(0,Q.jsx)($n,{className:`size-4 mt-0.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(Ti,{className:`size-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:r.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[r.provider,`/`,r.model]}),r.apiKeyRef&&(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground/70`,children:r.apiKeyRef})]}),r.systemPrompt&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:r.systemPrompt})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:t,"aria-label":`Edit profile`,children:(0,Q.jsx)(ri,{className:`size-3`})})}),(0,Q.jsx)(tl,{children:`Edit profile`})]}),(0,Q.jsxs)(Cf,{children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(wf,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove profile`,children:(0,Q.jsx)(Si,{className:`size-3`})})})}),(0,Q.jsx)(tl,{children:`Remove profile`})]}),(0,Q.jsxs)(Df,{children:[(0,Q.jsxs)(Of,{children:[(0,Q.jsx)(Af,{children:`Remove profile?`}),(0,Q.jsxs)(jf,{children:[`"`,r.name,`" will be permanently removed.`]})]}),(0,Q.jsxs)(kf,{children:[(0,Q.jsx)(Nf,{children:`Cancel`}),(0,Q.jsx)(Mf,{onClick:n,children:`Remove`})]})]})]})]})]})}function Rf({state:e}){let t=fl(e.socket),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(null);function o(t){e.socket.command({type:`profile.save`,profile:t}),r(!1)}function s(t){e.socket.command({type:`profile.save`,profile:t}),a(null)}function c(t){e.socket.command({type:`profile.remove`,profileId:t})}let l=t?.profiles??[];return(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Saved provider configurations for quick reuse.`}),(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,className:`shrink-0`,onClick:()=>r(!n),children:[(0,Q.jsx)(si,{className:`size-3.5 mr-1.5`}),`New`]})]}),n&&(0,Q.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4`,children:(0,Q.jsx)(If,{initial:Ff,onSubmit:o,onCancel:()=>r(!1),isEdit:!1})}),l.length===0&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center border border-dashed border-border rounded-lg`,children:[(0,Q.jsx)(Ti,{className:`size-8 text-muted-foreground/50 mb-3`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No profiles yet`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:`Create a profile to save provider settings`}),(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,className:`mt-4`,onClick:()=>r(!0),children:[(0,Q.jsx)(si,{className:`size-3.5 mr-1.5`}),`New profile`]})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>i===e.id?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4`,children:(0,Q.jsx)(If,{initial:e.profile,onSubmit:s,onCancel:()=>a(null),isEdit:!0})},e.id):(0,Q.jsx)(Lf,{record:e,onEdit:()=>a(e.id),onRemove:()=>c(e.id)},e.id))})]})}function zf(e){let[t,n]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(e)return e.subscribe({type:`extension-preferences`},n)},[e]),t}var Bf=[{id:`c3`,name:`Architecture`,icon:`building-2`,detectPatterns:[`.c3/`],component:(0,j.lazy)(()=>o(()=>import(`./client-DMSLRzg9.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])))},{id:`agents`,name:`Agents`,icon:`bot`,detectPatterns:[`CLAUDE.md`,`.claude/`],component:(0,j.lazy)(()=>o(()=>import(`./client-CGgNRU9w.js`),__vite__mapDeps([9,1,3,4,5,6,7])))},{id:`code`,name:`Code`,icon:`code`,detectPatterns:[`package.json`,`Cargo.toml`,`go.mod`,`pyproject.toml`],component:(0,j.lazy)(()=>o(()=>import(`./client-BrKWI4CM.js`),__vite__mapDeps([10,1,7,6,5])))}],Vf={"building-2":rr,bot:$n,code:vr};function Hf({name:e,icon:t,detectPatterns:n,enabled:r,onToggle:i}){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`size-8 rounded-md bg-accent/50 flex items-center justify-center shrink-0`,children:(0,Q.jsx)(Vf[t]??ci,{className:`size-4 text-foreground`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-sm text-foreground`,children:e}),n.length>0&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 mt-1 flex-wrap`,children:n.map(e=>(0,Q.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:e},e))})]})]}),(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":r,onClick:i,className:b(`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,r?`bg-primary`:`bg-muted`),children:(0,Q.jsx)(`span`,{className:b(`pointer-events-none inline-block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform`,r?`translate-x-4`:`translate-x-0`)})})]})})}function Uf({state:e}){let t=zf(e.socket);function n(t,n){e.socket.command({type:`extension.preference.set`,extensionId:t,enabled:!n})}return(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enable or disable extensions for project detection and tools.`}),Bf.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center border border-dashed border-border rounded-lg`,children:[(0,Q.jsx)(ci,{className:`size-8 text-muted-foreground/50 mb-3`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No extensions available`})]}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:Bf.map(e=>{let r=t?.preferences.find(t=>t.extensionId===e.id)?.enabled!==!1;return(0,Q.jsx)(Hf,{name:e.name,icon:e.icon,detectPatterns:e.detectPatterns,enabled:r,onToggle:()=>n(e.id,r)},e.id)})})]})}function Wf(e,[t,n]){return Math.min(n,Math.max(t,e))}function Gf(e){let t=e+`CollectionProvider`,[n,r]=Pi(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=j.useRef(null),a=j.useRef(new Map).current;return(0,Q.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Li(s),l=j.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,Q.jsx)(c,{ref:Mi(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Li(u),p=j.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=j.useRef(null),s=Mi(t,o),c=a(u,n);return j.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,Q.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return j.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Kf=j.createContext(void 0);function qf(e){let t=j.useContext(Kf);return e||t||`ltr`}function Jf(e){let t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Yf=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Xf=[` `,`Enter`],Zf=`Select`,[Qf,$f,ep]=Gf(Zf),[tp,np]=Pi(Zf,[ep,ks]),rp=ks(),[ip,ap]=tp(Zf),[op,sp]=tp(Zf),cp=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=rp(t),[g,_]=j.useState(null),[v,y]=j.useState(null),[b,x]=j.useState(!1),S=qf(l),[C,w]=rc({prop:r,defaultProp:i??!1,onChange:a,caller:Zf}),[T,E]=rc({prop:o,defaultProp:s,onChange:c,caller:Zf}),D=j.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=j.useState(new Set),M=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Q.jsx)(Gs,{...h,children:(0,Q.jsxs)(ip,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:ua(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Q.jsx)(Qf.Provider,{scope:t,children:(0,Q.jsx)(op,{scope:e.__scopeSelect,onNativeOptionAdd:j.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:j.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Q.jsxs)(rm,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,Q.jsx)(`option`,{value:``}):null,Array.from(k)]},M):null]})})};cp.displayName=Zf;var lp=`SelectTrigger`,up=j.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=rp(n),o=ap(lp,n),s=o.disabled||r,c=Mi(t,o.onTriggerChange),l=$f(n),u=j.useRef(`touch`),[d,f,p]=am(e=>{let t=l().filter(e=>!e.disabled),n=om(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Q.jsx)(Ks,{asChild:!0,...a,children:(0,Q.jsx)(Wi.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":im(o.value)?``:void 0,...i,ref:c,onClick:Z(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Z(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Z(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Yf.includes(e.key)&&(m(),e.preventDefault())})})})});up.displayName=lp;var dp=`SelectValue`,fp=j.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=ap(dp,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Mi(t,c.onValueNodeChange);return sa(()=>{l(u)},[l,u]),(0,Q.jsx)(Wi.span,{...s,ref:d,style:{pointerEvents:`none`},children:im(c.value)?(0,Q.jsx)(Q.Fragment,{children:o}):a})});fp.displayName=dp;var pp=`SelectIcon`,mp=j.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Q.jsx)(Wi.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});mp.displayName=pp;var hp=`SelectPortal`,gp=e=>(0,Q.jsx)(Xs,{asChild:!0,...e});gp.displayName=hp;var _p=`SelectContent`,vp=j.forwardRef((e,t)=>{let n=ap(_p,e.__scopeSelect),[r,i]=j.useState();if(sa(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Ii.createPortal((0,Q.jsx)(bp,{scope:e.__scopeSelect,children:(0,Q.jsx)(Qf.Slot,{scope:e.__scopeSelect,children:(0,Q.jsx)(`div`,{children:e.children})})}),t):null}return(0,Q.jsx)(wp,{...e,ref:t})});vp.displayName=_p;var yp=10,[bp,xp]=tp(_p),Sp=`SelectContentImpl`,Cp=Li(`SelectContent.RemoveScroll`),wp=j.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=ap(_p,n),[y,b]=j.useState(null),[x,S]=j.useState(null),C=Mi(t,e=>b(e)),[w,T]=j.useState(null),[E,D]=j.useState(null),O=$f(n),[k,A]=j.useState(!1),M=j.useRef(!1);j.useEffect(()=>{if(y)return $u(y)},[y]),Pl();let N=j.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),P=j.useCallback(()=>N([w,y]),[N,w,y]);j.useEffect(()=>{k&&P()},[k,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;j.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,I]),j.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,R]=am(e=>{let t=O().filter(e=>!e.disabled),n=om(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),z=j.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(M.current=!0))},[v.value]),B=j.useCallback(()=>y?.focus(),[y]),V=j.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),H=r===`popper`?Op:Ep,U=H===Op?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Q.jsx)(bp,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:z,selectedItem:w,onItemLeave:B,itemTextRefCallback:V,focusSelectedItem:P,selectedItemText:E,position:r,isPositioned:k,searchRef:L,children:(0,Q.jsx)(Wu,{as:Cp,allowPinchZoom:!0,children:(0,Q.jsx)(xl,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Z(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Q.jsx)(ea,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Q.jsx)(H,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...U,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Z(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&R(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});wp.displayName=Sp;var Tp=`SelectItemAlignedPosition`,Ep=j.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=ap(_p,n),o=xp(_p,n),[s,c]=j.useState(null),[l,u]=j.useState(null),d=Mi(t,e=>u(e)),f=$f(n),p=j.useRef(!1),m=j.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=j.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-yp,d=Wf(a,[yp,Math.max(yp,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-yp,d=Wf(a,[yp,Math.max(yp,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-yp*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-yp,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${yp}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);sa(()=>y(),[y]);let[b,x]=j.useState();return sa(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Q.jsx)(kp,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:j.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Q.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Q.jsx)(Wi.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Ep.displayName=Tp;var Dp=`SelectPopperPosition`,Op=j.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=yp,...a}=e,o=rp(n);return(0,Q.jsx)(qs,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Op.displayName=Dp;var[kp,Ap]=tp(_p,{}),jp=`SelectViewport`,Mp=j.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=xp(jp,n),o=Ap(jp,n),s=Mi(t,a.onViewportChange),c=j.useRef(0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,Q.jsx)(Qf.Slot,{scope:n,children:(0,Q.jsx)(Wi.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Z(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-yp*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Mp.displayName=jp;var Np=`SelectGroup`,[Pp,Fp]=tp(Np),Ip=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ua();return(0,Q.jsx)(Pp,{scope:n,id:i,children:(0,Q.jsx)(Wi.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Ip.displayName=Np;var Lp=`SelectLabel`,Rp=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Fp(Lp,n);return(0,Q.jsx)(Wi.div,{id:i.id,...r,ref:t})});Rp.displayName=Lp;var zp=`SelectItem`,[Bp,Vp]=tp(zp),Hp=j.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=ap(zp,n),c=xp(zp,n),l=s.value===r,[u,d]=j.useState(a??``),[f,p]=j.useState(!1),m=Mi(t,e=>c.itemRefCallback?.(e,r,i)),h=ua(),g=j.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,Q.jsx)(Bp,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:j.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Q.jsx)(Qf.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Q.jsx)(Wi.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Z(o.onFocus,()=>p(!0)),onBlur:Z(o.onBlur,()=>p(!1)),onClick:Z(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Z(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Z(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Z(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Z(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Z(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Xf.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Hp.displayName=zp;var Up=`SelectItemText`,Wp=j.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=ap(Up,n),s=xp(Up,n),c=Vp(Up,n),l=sp(Up,n),[u,d]=j.useState(null),f=Mi(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=j.useMemo(()=>(0,Q.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return sa(()=>(h(m),()=>g(m)),[h,g,m]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wi.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Ii.createPortal(a.children,o.valueNode):null]})});Wp.displayName=Up;var Gp=`SelectItemIndicator`,Kp=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Vp(Gp,n).isSelected?(0,Q.jsx)(Wi.span,{"aria-hidden":!0,...r,ref:t}):null});Kp.displayName=Gp;var qp=`SelectScrollUpButton`,Jp=j.forwardRef((e,t)=>{let n=xp(qp,e.__scopeSelect),r=Ap(qp,e.__scopeSelect),[i,a]=j.useState(!1),o=Mi(t,r.onScrollButtonChange);return sa(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Q.jsx)(Zp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Jp.displayName=qp;var Yp=`SelectScrollDownButton`,Xp=j.forwardRef((e,t)=>{let n=xp(Yp,e.__scopeSelect),r=Ap(Yp,e.__scopeSelect),[i,a]=j.useState(!1),o=Mi(t,r.onScrollButtonChange);return sa(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Q.jsx)(Zp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Xp.displayName=Yp;var Zp=j.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=xp(`SelectScrollButton`,n),o=j.useRef(null),s=$f(n),c=j.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return j.useEffect(()=>()=>c(),[c]),sa(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Q.jsx)(Wi.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Z(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Z(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Z(i.onPointerLeave,()=>{c()})})}),Qp=`SelectSeparator`,$p=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Q.jsx)(Wi.div,{"aria-hidden":!0,...r,ref:t})});$p.displayName=Qp;var em=`SelectArrow`,tm=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=rp(n),a=ap(em,n),o=xp(em,n);return a.open&&o.position===`popper`?(0,Q.jsx)(Js,{...i,...r,ref:t}):null});tm.displayName=em;var nm=`SelectBubbleInput`,rm=j.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=j.useRef(null),a=Mi(r,i),o=Jf(t);return j.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,Q.jsx)(Wi.select,{...n,style:{...oc,...n.style},ref:a,defaultValue:t})});rm.displayName=nm;function im(e){return e===``||e===void 0}function am(e){let t=Ki(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function om(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=sm(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function sm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cm=cp,lm=up,um=fp,dm=mp,fm=gp,pm=vp,mm=Mp,hm=Rp,gm=Hp,_m=Wp,vm=Kp,ym=Jp,bm=Xp,xm=$p,Sm=cm,Cm=um,wm=j.forwardRef(({className:e,children:t,...n},r)=>(0,Q.jsxs)(lm,{ref:r,className:b(`flex h-9 w-full items-center justify-between gap-2 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors`,`placeholder:text-muted-foreground`,`focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-50`,`[&>span]:line-clamp-1`,e),...n,children:[t,(0,Q.jsx)(dm,{asChild:!0,children:(0,Q.jsx)(or,{className:`h-4 w-4 shrink-0 opacity-50`})})]}));wm.displayName=lm.displayName;var Tm=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(ym,{ref:n,className:b(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(lr,{className:`h-4 w-4`})}));Tm.displayName=ym.displayName;var Em=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(bm,{ref:n,className:b(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(or,{className:`h-4 w-4`})}));Em.displayName=bm.displayName;var Dm=j.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,Q.jsx)(fm,{children:(0,Q.jsxs)(pm,{ref:i,className:b(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border border-border bg-background text-foreground shadow-md`,`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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,Q.jsx)(Tm,{}),(0,Q.jsx)(mm,{className:b(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,Q.jsx)(Em,{})]})}));Dm.displayName=pm.displayName;var Om=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(hm,{ref:n,className:b(`px-2 py-1.5 text-sm font-semibold`,e),...t}));Om.displayName=hm.displayName;var km=j.forwardRef(({className:e,children:t,...n},r)=>(0,Q.jsxs)(gm,{ref:r,className:b(`relative flex w-full cursor-default select-none items-center rounded-md py-1.5 pl-2 pr-8 text-sm outline-none`,`focus:bg-accent focus:text-accent-foreground`,`data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Q.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(vm,{children:(0,Q.jsx)(ar,{className:`h-4 w-4`})})}),(0,Q.jsx)(_m,{children:t})]}));km.displayName=gm.displayName;var Am=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(xm,{ref:n,className:b(`-mx-1 my-1 h-px bg-border`,e),...t}));Am.displayName=xm.displayName;function jm(e){return e.filter(e=>!e.incompatible&&e.state!==`offline`).sort((e,t)=>e.state===t.state?e.runnerId.localeCompare(t.runnerId):e.state===`online`?-1:1)}function Mm(e,t){let n=new Set;for(let r of t)e.has(r.runnerId)||n.add(r.runnerId);return n}function Nm(e){let[t,n]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(e)return e.subscribe({type:`runner-teams`},n)},[e]),t}function Pm(e,t){let n=(Array.isArray(t)?t.find(t=>t.runnerId===e):t.get(e))?.name?.trim();if(n)return n;let r=e.split(`-`);return r.length>1?r.slice(-2).join(`-`):e}function Fm(e,t,n){let r=Array.isArray(t)?t.find(t=>t.runnerId===e):t.get(e);if(!r?.memberId)return null;let i=r.memberId;return Array.isArray(n)?n.find(e=>e.id===i)??null:n.get(i)??null}var Im=`__none__`,Lm=2e3;function Rm({code:e,onCopied:t}){let[n,r]=(0,j.useState)(!1);async function i(){await navigator.clipboard.writeText(e),r(!0),t?.(),setTimeout(()=>r(!1),2e3)}return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-muted px-3 py-2 font-mono text-sm`,children:[(0,Q.jsx)(`span`,{className:`flex-1 select-all tracking-wider break-all`,children:e}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:i,title:`Copy code`,children:n?(0,Q.jsx)(ar,{className:`size-3.5 text-green-500`}):(0,Q.jsx)(br,{className:`size-3.5`})})]})}function zm(e){let t=e-Date.now();return t<=0?`expired`:`expires in ${Math.ceil(t/6e4)} min`}function Bm(){let[e,t]=(0,j.useState)([]),[n,r]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let e=!1;async function n(){try{let n=await(await fetch(`/health`)).json();if(e)return;t(jm(n.runners??[])),r(null)}catch(t){if(e)return;r(t instanceof Error?t.message:String(t))}}n();let i=setInterval(n,Lm);return()=>{e=!0,clearInterval(i)}},[]),{runners:e,error:n}}function Vm({runner:e,justConnected:t,labels:n,members:r,onRename:i,onAssign:a}){let o=e.capabilities?.providers.join(`, `)||`all providers`,s=e.state===`online`?`bg-green-500`:`bg-yellow-500`,c=Pm(e.runnerId,n),l=n.find(t=>t.runnerId===e.runnerId),u=l?.name??``,d=l?.memberId??null,[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(u);function g(){let t=m.trim();i(e.runnerId,t===``?null:t),p(!1)}return(0,Q.jsxs)(`div`,{className:b(`flex items-start gap-3 rounded-lg border px-4 py-3 transition-colors`,t?`border-green-500/50 bg-green-500/10 ring-1 ring-green-500/30`:`border-border bg-muted/30`),children:[(0,Q.jsx)(fi,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:b(`size-2 shrink-0 rounded-full`,s)}),f?(0,Q.jsx)(ml,{size:`sm`,autoFocus:!0,value:m,onChange:e=>h(e.target.value),onBlur:g,onKeyDown:e=>{e.key===`Enter`&&g(),e.key===`Escape`&&(h(u),p(!1))},placeholder:e.runnerId.split(`-`).slice(-2).join(`-`),className:`h-6 max-w-[14rem] text-sm`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:c}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`size-5 shrink-0 text-muted-foreground`,title:`Rename runner`,onClick:()=>{h(u),p(!0)},children:(0,Q.jsx)(ii,{className:`size-3`})})]}),e.isShared&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:`shared`}),t&&(0,Q.jsx)(`span`,{className:`rounded-full bg-green-500/20 px-1.5 py-0.5 text-[10px] font-medium text-green-400`,children:`connected`}),(0,Q.jsxs)(Sm,{value:d??Im,onValueChange:t=>a(e.runnerId,t===Im?null:t),children:[(0,Q.jsx)(wm,{className:`ml-auto h-7 w-36 text-xs`,children:(0,Q.jsx)(Cm,{placeholder:`Unassigned`})}),(0,Q.jsxs)(Dm,{children:[(0,Q.jsx)(km,{value:Im,children:`Unassigned`}),r.map(e=>(0,Q.jsx)(km,{value:e.id,children:e.name},e.id))]})]}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs capitalize text-muted-foreground`,children:e.state})]}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:o})]})]})}function Hm({state:e}){let[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(null),s=(0,j.useRef)(null),{runners:c,error:l}=Bm(),u=Nm(e.socket),d=u?.runners??[],f=u?.members??[];function p(t,n){e.socket.command({type:`runner.label.set`,runnerId:t,name:n,memberId:d.find(e=>e.runnerId===t)?.memberId??null})}function m(t,n){e.socket.command({type:`runner.label.set`,runnerId:t,name:d.find(e=>e.runnerId===t)?.name??null,memberId:n})}let h=s.current?Mm(s.current,c):new Set,g=r!==null&&h.size===0;async function _(){n(!0),o(null),i(null);try{let e=await fetch(`/api/pairing/code`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();s.current=new Set(c.map(e=>e.runnerId)),i(t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{n(!1)}}let v=r?`bun run src/runner/runner.ts pair --server ${window.location.origin} --code ${r.code}`:null;return(0,Q.jsxs)(`div`,{className:`space-y-6 max-w-2xl`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add a runner on a remote machine. Generate a one-time pairing code, then run the command below on the runner machine to connect it.`}),(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:_,disabled:t,children:[(0,Q.jsx)(si,{className:`size-3.5 mr-1.5`}),t?`Generating…`:`Generate pairing code`]}),a&&(0,Q.jsx)(`div`,{className:`rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400`,children:a}),r&&(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(fi,{className:`size-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:zm(r.expiresAt)})]}),(0,Q.jsx)(Rm,{code:r.code}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`On the runner machine, run:`}),(0,Q.jsx)(Rm,{code:v}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`The code is single-use and valid for ~10 minutes. The runner will appear below once it connects.`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Connected runners`}),l&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground/70`,children:[`Couldn’t reach the server: `,l]}),c.map(e=>(0,Q.jsx)(Vm,{runner:e,justConnected:h.has(e.runnerId),labels:d,members:f,onRename:p,onAssign:m},e.runnerId)),g&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`size-2 shrink-0 animate-pulse rounded-full bg-muted-foreground/60`}),`Waiting for a runner to connect…`]}),c.length===0&&!g&&!l&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runners connected. Generate a pairing code to add one.`})]})]})}function Um({state:e}){let t=Nm(e.socket)?.members??[],[n,r]=(0,j.useState)(``);function i(){let t=n.trim();t&&(e.socket.command({type:`team.member.save`,member:{id:crypto.randomUUID(),name:t}}),r(``))}function a(t,n){let r=n.trim();r&&e.socket.command({type:`team.member.save`,member:{id:t,name:r}})}function o(t){e.socket.command({type:`team.member.remove`,memberId:t})}return(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Members`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`People you assign runners to. Labels only — no login or permissions. Assign runners on the Runners tab.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ml,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},placeholder:`Add a member (e.g. Alice)`,className:`max-w-xs`}),(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:i,disabled:!n.trim(),children:[(0,Q.jsx)(si,{className:`size-3.5 mr-1.5`}),`Add`]})]}),t.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No members yet.`}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(Ti,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(ml,{size:`sm`,defaultValue:e.name,onBlur:t=>{t.target.value.trim()&&t.target.value.trim()!==e.name&&a(e.id,t.target.value)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`h-7 max-w-xs text-sm`}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`ml-auto size-7 text-muted-foreground hover:text-destructive`,title:`Remove member`,onClick:()=>o(e.id),children:(0,Q.jsx)(Si,{className:`size-3.5`})})]},e.id))})]})}var Wm=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium`},{id:`high`,label:`High`},{id:`max`,label:`Max`}],Gm=[{id:`minimal`,label:`Minimal`},{id:`low`,label:`Low`},{id:`medium`,label:`Medium`},{id:`high`,label:`High`},{id:`xhigh`,label:`XHigh`}],Km={reasoningEffort:`high`,contextWindow:`200k`},qm={reasoningEffort:`high`,fastMode:!1},Jm={reasoningEffort:`high`,contextWindow:`200k`};function Ym(e){return Wm.some(t=>t.id===e)}function Xm(e){return Gm.some(t=>t.id===e)}var Zm=[{id:`200k`,label:`200k`},{id:`1m`,label:`1M`}],Qm=[{id:`claude`,label:`Claude`,defaultModel:`opus`,defaultEffort:`high`,supportsPlanMode:!0,models:[{id:`opus`,label:`Opus`,supportsEffort:!0,contextWindowOptions:[...Zm]},{id:`sonnet`,label:`Sonnet`,supportsEffort:!0,contextWindowOptions:[...Zm]},{id:`haiku`,label:`Haiku`,supportsEffort:!0}],efforts:[...Wm]},{id:`codex`,label:`Codex`,defaultModel:`gpt-5.4`,supportsPlanMode:!0,models:[{id:`gpt-5.4`,label:`GPT-5.4`,supportsEffort:!1},{id:`gpt-5.3-codex`,label:`GPT-5.3 Codex`,supportsEffort:!1},{id:`gpt-5.3-codex-spark`,label:`GPT-5.3 Codex Spark`,supportsEffort:!1}],efforts:[]},{id:`claude-pty`,label:`Claude (PTY)`,defaultModel:`opus`,defaultEffort:`high`,supportsPlanMode:!0,models:[{id:`opus`,label:`Opus`,supportsEffort:!0,contextWindowOptions:[...Zm]},{id:`sonnet`,label:`Sonnet`,supportsEffort:!0,contextWindowOptions:[...Zm]},{id:`haiku`,label:`Haiku`,supportsEffort:!0}],efforts:[...Wm]}];function $m(e){let t=Qm.find(t=>t.id===e);if(!t)throw Error(`Unknown provider: ${e}`);return t}function eh(e){return $m(`claude`).models.find(t=>t.id===e)}function th(e){return eh(e)?.contextWindowOptions??[]}function nh(e,t){let n=th(e);return n.length===0?Km.contextWindow:n.some(e=>e.id===t)?t:Km.contextWindow}function rh(e,t){return t===`1m`?`${e}[1m]`:e}function ih(e){return typeof e==`object`&&!!e&&`images`in e&&Array.isArray(e.images)}var ah=`runtime`,oh=`${ah}.snap.`;function sh(e){switch(e.type){case`chat`:return`chat.${e.chatId}`;case`terminal`:return`terminal.${e.terminalId}`;case`orchestration`:return`orchestration.${e.chatId}`;case`workspace`:return`workspace.${e.workspaceId}`;case`agent-config`:return`agent-config.${e.workspaceId}`;case`repos`:return`repos.${e.workspaceId}`;case`workflow-runs`:return`workflow-runs.${e.workspaceId}`;case`sandbox-status`:return`sandbox-status.${e.workspaceId}`;default:return e.type}}function ch(e){return`${oh}${sh(e)}`}function lh(e){return`${ah}.evt.terminal.${e}`}function uh(e){return`${ah}.evt.chat.${e}`}function dh(e){return`${ah}.cmd.${e}`}`${oh}`,`${ah}`,`${ah}`,`${ah}`;var fh=`KANNA_CHAT_MESSAGE_EVENTS`;`${ah}`,`${ah}`,`${ah}`;function ph(e){return`${ah}.cmd.${e}`}function mh(){return`${ah}.evt.pty.delta`}`${ah}`,`${ah}`;function hh(e){return`${ah}.cmd.${e}`}function gh(){return`${ah}.evt.oauth.changed`}`${ah}`,`${ah}`;async function _h(e,t,n){let r=await e.rawRequest(hh(t),n);if(!r.ok)throw Error(r.error);return r}async function vh(e){let t=await _h(e,`oauth.list`,{});if(!t.settings)throw Error(`oauth.list missing settings`);return t.settings}async function yh(e,t){let n=await _h(e,`oauth.add`,t);if(!n.entry)throw Error(`oauth.add missing entry`);return n.entry}async function bh(e,t){return!!(await _h(e,`oauth.remove`,{id:t})).removed}async function xh(e,t,n){let r=await _h(e,`oauth.update`,{id:t,...n});if(!r.entry)throw Error(`oauth.update missing entry`);return r.entry}async function Sh(e,t){await _h(e,`oauth.setConcurrencyDefault`,{value:t})}function Ch(e,t){return e.rawSubscribe(gh(),e=>{e?.settings&&t(e.settings)})}var wh=`tinkaria.claude-pty.settings`;function Th(){try{let e=localStorage.getItem(wh);if(e){let t=JSON.parse(e);if(t&&typeof t==`object`)return{enabled:!!t.enabled,binaryPath:typeof t.binaryPath==`string`?t.binaryPath:``}}}catch{}return{enabled:!1,binaryPath:``}}function Eh(e){try{localStorage.setItem(wh,JSON.stringify(e))}catch{}}function Dh(e){return e.length<=12?`•`.repeat(e.length):`${e.slice(0,6)}…${e.slice(-4)}`}function Oh(e){if(!e)return`never`;try{return new Date(e).toLocaleString()}catch{return String(e)}}function kh(e){switch(e){case`active`:return`text-green-600 dark:text-green-400`;case`limited`:return`text-amber-600 dark:text-amber-400`;case`error`:return`text-red-600 dark:text-red-400`;case`disabled`:return`text-muted-foreground`}}function Ah({state:e}){let[t,n]=(0,j.useState)(()=>Th()),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(``),h=(0,j.useCallback)(async()=>{o(!0),c(null);try{i(await vh(e.socket))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.socket]);(0,j.useEffect)(()=>(h(),Ch(e.socket,e=>i(e))),[e.socket,h]);let g=e=>{let r={...t,...e};n(r),Eh(r)},_=async()=>{let t=l.trim();if(!t||!d){c(`Label and token are required.`);return}c(null);try{let n=p?Number(p):void 0;await yh(e.socket,{label:t,token:d,...n===void 0?{}:{maxConcurrent:n}}),u(``),f(``),m(``)}catch(e){c(e instanceof Error?e.message:String(e))}},v=async t=>{c(null);try{await bh(e.socket,t)}catch(e){c(e instanceof Error?e.message:String(e))}},y=async(t,n)=>{c(null);try{if(n.trim()===``)await xh(e.socket,t,{maxConcurrent:null});else{let r=Number(n);await xh(e.socket,t,{maxConcurrent:r})}}catch(e){c(e instanceof Error?e.message:String(e))}},b=async t=>{c(null);try{let n=Number(t);Number.isFinite(n)&&await Sh(e.socket,n)}catch(e){c(e instanceof Error?e.message:String(e))}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6 max-w-3xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(bi,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Claude PTY`}),(0,Q.jsx)(`span`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:`preview — no sandbox`})]}),(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Run the local `,(0,Q.jsx)(`code`,{className:`font-mono`,children:`claude`}),` CLI inside a PTY, billed against an OAuth-pool token. Add at least one OAuth token below; new chats with the Claude (PTY) provider will pick from the pool automatically.`]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-4`,checked:t.enabled,onChange:e=>g({enabled:e.target.checked})}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Enable Claude PTY provider`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`label`,{className:`text-sm font-medium`,children:[`Binary path`,(0,Q.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground font-normal`,children:`(blank = resolve from PATH)`})]}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded border bg-background px-3 py-2 text-sm font-mono`,placeholder:`/usr/local/bin/claude`,value:t.binaryPath,onChange:e=>g({binaryPath:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 border-t pt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`OAuth pool tokens`}),a?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`loading…`}):null]}),s?(0,Q.jsx)(`div`,{className:`rounded border border-red-400/50 bg-red-50 dark:bg-red-950/30 px-3 py-2 text-xs text-red-700 dark:text-red-300`,children:s}):null,r&&r.tokens.length>0?(0,Q.jsxs)(`table`,{className:`text-xs`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b`,children:[(0,Q.jsx)(`th`,{className:`text-left py-2 px-2 font-medium`,children:`Label`}),(0,Q.jsx)(`th`,{className:`text-left py-2 px-2 font-medium`,children:`Token`}),(0,Q.jsx)(`th`,{className:`text-left py-2 px-2 font-medium`,children:`Status`}),(0,Q.jsx)(`th`,{className:`text-left py-2 px-2 font-medium`,children:`Concurrency`}),(0,Q.jsx)(`th`,{className:`text-left py-2 px-2 font-medium`,children:`Last used`}),(0,Q.jsx)(`th`,{})]})}),(0,Q.jsx)(`tbody`,{children:r.tokens.map(e=>(0,Q.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,Q.jsx)(`td`,{className:`py-2 px-2`,children:e.label}),(0,Q.jsx)(`td`,{className:`py-2 px-2 font-mono`,children:Dh(e.token)}),(0,Q.jsxs)(`td`,{className:`py-2 px-2 font-medium ${kh(e.status)}`,children:[e.status,e.status===`error`&&e.lastErrorMessage?(0,Q.jsxs)(`span`,{className:`ml-1 text-muted-foreground font-normal`,children:[`(`,e.lastErrorMessage.slice(0,40),`)`]}):null]}),(0,Q.jsx)(`td`,{className:`py-2 px-2`,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:5,className:`w-16 rounded border bg-background px-2 py-1 text-xs`,placeholder:String(r.concurrencyDefault),defaultValue:e.maxConcurrent??``,onBlur:t=>y(e.id,t.target.value)})}),(0,Q.jsx)(`td`,{className:`py-2 px-2 text-muted-foreground`,children:Oh(e.lastUsedAt)}),(0,Q.jsx)(`td`,{className:`py-2 px-2 text-right`,children:(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>v(e.id),title:`Remove token`,children:(0,Q.jsx)(Si,{className:`size-3.5 text-red-600`})})})]},e.id))})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`No tokens configured.`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 border-t pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Add new token`}),(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,maxLength:64,placeholder:`Label (e.g. Personal)`,className:`rounded border bg-background px-3 py-2 text-sm flex-1`,value:l,onChange:e=>u(e.target.value)}),(0,Q.jsx)(`input`,{type:`password`,placeholder:`OAuth token`,className:`rounded border bg-background px-3 py-2 text-sm font-mono flex-1`,value:d,onChange:e=>f(e.target.value)}),(0,Q.jsx)(`input`,{type:`number`,min:1,max:5,placeholder:`concurrency`,className:`rounded border bg-background px-3 py-2 text-sm w-28`,value:p,onChange:e=>m(e.target.value)}),(0,Q.jsx)(S,{type:`button`,size:`sm`,onClick:_,disabled:!l.trim()||!d,children:`Add token`})]})]}),r?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-t pt-3 text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Default concurrency cap`}),(0,Q.jsx)(`input`,{type:`number`,min:1,max:5,defaultValue:r.concurrencyDefault,className:`w-16 rounded border bg-background px-2 py-1 text-xs`,onBlur:e=>b(e.target.value)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`applied to tokens without an explicit override`})]}):null]})]})}var jh=[{value:`providers`,label:`Providers`,icon:er,tooltip:`Providers`},{value:`profiles`,label:`Profiles`,icon:Ti,tooltip:`Profiles`},{value:`extensions`,label:`Extensions`,icon:ci,tooltip:`Extensions`},{value:`runners`,label:`Runners`,icon:fi,tooltip:`Runners`},{value:`team`,label:`Team`,icon:Ei,tooltip:`Team`},{value:`claude-pty`,label:`Claude PTY`,icon:bi,tooltip:`Claude PTY`}];function Mh(e){return e===`profiles`||e===`extensions`||e===`runners`||e===`team`||e===`claude-pty`?e:`providers`}function Nh({state:e,initialTab:t=`providers`}){let[n,r]=(0,j.useState)(t);return(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(ol,{value:n,onValueChange:r,options:jh,size:`sm`,className:`w-full md:w-auto`,optionClassName:`flex-1 md:flex-initial justify-center`,alwaysShowLabels:!0})}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[n===`providers`&&(0,Q.jsx)(dl,{state:e}),n===`profiles`&&(0,Q.jsx)(Rf,{state:e}),n===`extensions`&&(0,Q.jsx)(Uf,{state:e}),n===`runners`&&(0,Q.jsx)(Hm,{state:e}),n===`team`&&(0,Q.jsx)(Um,{state:e}),n===`claude-pty`&&(0,Q.jsx)(Ah,{state:e})]})]})}function Ph(){let e=tt(),t=Qe();return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 relative`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3 pb-2 md:pt-4 md:pb-3`,children:[(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>t(`/`),className:`size-7 border-0 md:hidden`,children:(0,Q.jsx)(Jn,{className:`size-4`})}),(0,Q.jsx)(pi,{className:`size-4 text-muted-foreground hidden md:block`}),(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-foreground md:text-lg`,children:`Tinkaria`})]}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 px-4 pb-4 overflow-y-auto`,children:(0,Q.jsx)(Nh,{state:e})})]})}var Fh=`ui-identity-fab-position`,Ih=`data-ui-identity-fab`,Lh={right:12,bottom:12};function Rh(e=window.matchMedia){return e(`(pointer: coarse)`).matches}function zh(e){return e.getAttribute(`data-ui-id`)?e:e.closest(`[${_}]`)}function Bh(e){return e.closest(`[data-ui-identity-overlay-root="true"]`)||e.closest(`[data-ui-identity-fab="true"]`)?!1:e.closest(`[${_}]`)!==null}function Vh(e=localStorage){try{let t=e.getItem(Fh);if(!t)return null;let n=JSON.parse(t);return typeof n==`object`&&n&&`right`in n&&`bottom`in n&&typeof n.right==`number`&&typeof n.bottom==`number`?n:null}catch{return null}}function Hh(e,t=localStorage){t.setItem(Fh,JSON.stringify(e))}var Uh=119;function Wh(e){return{position:`fixed`,right:e.right,bottom:e.bottom,width:36,height:36,zIndex:Uh}}function Gh(e){let[t,n]=(0,j.useState)(()=>(typeof localStorage<`u`?Vh():null)??Lh),r=(0,j.useRef)(null),i=(0,j.useCallback)(e=>{e.currentTarget.setPointerCapture(e.pointerId),r.current={startX:e.clientX,startY:e.clientY,startRight:t.right,startBottom:t.bottom}},[t]),a=(0,j.useCallback)(e=>{let t=r.current;if(!t)return;let i=e.clientX-t.startX,a=e.clientY-t.startY;n({right:Math.max(0,t.startRight-i),bottom:Math.max(0,t.startBottom-a)})},[]),o=(0,j.useCallback)(n=>{let i=r.current;i&&(r.current=null,Math.abs(n.clientX-i.startX)+Math.abs(n.clientY-i.startY)<5?e.onToggle():Hh(t))},[t,e.onToggle]),s=(0,Q.jsx)(`button`,{type:`button`,[Ih]:`true`,"aria-label":e.active?`Deactivate UI inspector`:`Activate UI inspector`,className:`flex items-center justify-center rounded-full border border-border shadow-lg backdrop-blur-sm transition-colors`,style:{...Wh(t),opacity:e.active?1:.4,backgroundColor:e.active?`rgb(14 165 233)`:`rgb(var(--background))`,touchAction:`none`},onPointerDown:i,onPointerMove:a,onPointerUp:o,children:(0,Q.jsx)(xr,{size:18,className:e.active?`text-white`:`text-muted-foreground`})});return typeof document>`u`||!document.body?s:(0,Ii.createPortal)(s,document.body)}var Kh=`data-focus-fallback-ignore`,qh=`data-allow-focus-retain`,Jh=`tinkaria:restore-chat-input-focus`,Yh=`data-chat-input`,Xh=`data-chat-selection-zone`;function Zh(e,t){return!!e?.closest(`[${t}]`)}function Qh(e){let t=e;return t?.matches?t.matches(`input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select`)||t.isContentEditable||t.getAttribute?.(`role`)===`textbox`?!0:Zh(e,qh):!1}function $h(e){let t=e;return t?.matches?Qh(e)||(t.tabIndex??-1)>=0||t.matches(`button, a[href], summary`)?!0:Zh(e,qh):!1}function eg(e){return!!e.querySelector(`[${Kh}][data-state='open']`)}function tg(e,t){if(!e)return!1;let n=Array.from(t.querySelectorAll(`textarea[${Yh}]`)).filter(e=>!e.disabled);if(n.length===0)return!1;let r=n.indexOf(e),i=n[r>=0?(r+1)%n.length:0];return i?(i.focus({preventScroll:!0}),!0):!1}function ng(e){let{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return`none`;if(e.trigger===`escape`)return e.defaultPrevented||Zh(t,`data-chat-input`)||e.canCancel?`none`:`escape-focus`;let{pointerStartTarget:i,pointerEndTarget:a,root:o}=e,s=a??i;return!o||!s||!o.contains(s)||Zh(s,`data-focus-fallback-ignore`)||Zh(t,`data-focus-fallback-ignore`)||Zh(i,`data-chat-selection-zone`)||Zh(s,`data-chat-selection-zone`)||Qh(t)?`none`:t&&t===s?`restore`:$h(t)?`none`:`restore`}var rg=Pd,ig=Vd,ag=Id,og=`px-4 pb-4 pt-3.5`,sg=`flex-1 min-h-0 overflow-y-auto ${og}`,cg=`max-md:inset-0 max-md:left-0 max-md:top-0 max-md:max-w-none max-md:max-h-none max-md:h-[100dvh] max-md:rounded-none max-md:border-0 max-md:translate-x-0 max-md:translate-y-0 max-md:shadow-none`,lg=`max-md:pt-[max(1rem,env(safe-area-inset-top))]`,ug=`max-md:rounded-none max-md:pb-[max(0.5rem,env(safe-area-inset-bottom))]`,dg=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Ld,{ref:n,className:b(`fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));dg.displayName=Ld.displayName;var fg={sm:`max-w-sm`,md:`max-w-md`,lg:`max-w-lg`,xl:`max-w-4xl`,fullscreen:`inset-0 max-w-none max-h-none rounded-none border-0 translate-x-0 translate-y-0 left-0 top-0 shadow-none`},pg=j.forwardRef(({className:e,children:t,size:n=`md`,...r},i)=>(0,Q.jsxs)(ag,{children:[(0,Q.jsx)(dg,{}),(0,Q.jsxs)(Rd,{ref:i,[Kh]:``,onCloseAutoFocus:e=>{e.preventDefault(),window.dispatchEvent(new Event(Jh)),r.onCloseAutoFocus?.(e)},className:b(`fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl 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%]`,`max-h-[85vh] flex flex-col`,fg[n],e),...r,children:[t,(0,Q.jsxs)(Vd,{className:b(`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`,n===`fullscreen`&&`hidden`),children:[(0,Q.jsx)(Di,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));pg.displayName=Rd.displayName;function mg({className:e,...t}){return(0,Q.jsx)(`div`,{className:b(`shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border`,e),...t})}function hg({className:e,...t}){return(0,Q.jsx)(zd,{className:b(`text-lg font-medium leading-none tracking-tight`,e),...t})}function gg({className:e,...t}){return(0,Q.jsx)(Bd,{className:b(`text-sm text-muted-foreground`,e),...t})}function _g({className:e,...t}){return(0,Q.jsx)(`div`,{className:b(sg,e),...t})}function vg({className:e,...t}){return(0,Q.jsx)(`div`,{className:b(`shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl`,e),...t})}function yg({className:e,...t}){return(0,Q.jsx)(`button`,{className:b(`touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors`,`rounded-full h-9 px-4`,`bg-primary text-primary-foreground hover:bg-primary/90`,`disabled:pointer-events-none disabled:bg-primary/20 disabled:text-primary/60`,e),...t})}function bg({className:e,...t}){return(0,Q.jsx)(`button`,{className:b(`touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors`,`rounded-full h-9 px-4`,`hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground`,`disabled:pointer-events-none disabled:text-muted-foreground/50`,e),...t})}var xg=(0,j.createContext)(null);function Sg({children:e}){let[t,n]=(0,j.useState)(null),r=(0,j.useRef)(null);(0,j.useEffect)(()=>{t?.kind===`prompt`&&(r.current?.focus(),r.current?.select())},[t]);let i=(0,j.useCallback)(()=>{n(null)},[]),a=(0,j.useCallback)(()=>{t&&(t.kind===`confirm`?t.resolve(!1):t.kind===`prompt`?t.resolve(null):t.resolve(),i())},[i,t]),o=(0,j.useCallback)(()=>{t&&(t.kind===`confirm`?t.resolve(!0):t.kind===`prompt`?t.resolve(t.inputValue.trim()||null):t.resolve(),i())},[i,t]),s=(0,j.useCallback)(e=>new Promise(t=>{n({kind:`confirm`,options:e,resolve:t})}),[]),c=(0,j.useCallback)(e=>new Promise(t=>{n({kind:`prompt`,options:e,inputValue:e.initialValue??``,resolve:t})}),[]),l=(0,j.useCallback)(e=>new Promise(t=>{n({kind:`alert`,options:e,resolve:t})}),[]),u=(0,j.useMemo)(()=>({confirm:s,prompt:c,alert:l}),[l,s,c]);return(0,Q.jsxs)(xg.Provider,{value:u,children:[e,(0,Q.jsx)(rg,{open:t!==null,onOpenChange:e=>{e||!t||a()},children:(0,Q.jsx)(pg,{size:`sm`,className:cg,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||!t||t.kind!==`confirm`||(e.preventDefault(),o())},children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(_g,{className:`space-y-4`,children:[(0,Q.jsx)(hg,{children:t.options.title}),t.options.description?(0,Q.jsx)(gg,{children:t.options.description}):null,t.kind===`prompt`?(0,Q.jsx)(ml,{ref:r,autoFocus:!0,type:`text`,value:t.inputValue,onFocus:e=>e.currentTarget.select(),onChange:e=>n(t=>t?.kind===`prompt`?{...t,inputValue:e.target.value}:t),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())},placeholder:t.options.placeholder}):null]}),(0,Q.jsxs)(vg,{className:ug,children:[(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:a,className:t.kind===`alert`?`hidden`:void 0,children:`cancelLabel`in t.options?t.options.cancelLabel??`Cancel`:`Cancel`}),(0,Q.jsx)(S,{variant:t.kind===`confirm`?t.options.confirmVariant??`default`:`secondary`,size:`sm`,onClick:o,disabled:t.kind===`prompt`&&!t.inputValue.trim(),children:t.kind===`alert`?t.options.closeLabel??`OK`:`confirmLabel`in t.options?t.options.confirmLabel??`Confirm`:`Confirm`})]})]}):null})})]})}function Cg(){let e=(0,j.useContext)(xg);if(!e)throw Error(`useAppDialog must be used within AppDialogProvider`);return e}var wg=224,Tg=34,Eg=16,Dg=12,Og=10;function kg(e,t){return t===e?`Copied`:`Copy`}function Ag(e){let t=Math.max(1,e.rowCount)*Tg+Eg,n=wg,r=e.anchorRect.bottom+Og,i=Math.max(Dg,e.viewport.height-t-Dg),a=e.anchorRect.top-t-Og,o=r<=i?r:Math.max(Dg,a),s=e.anchorRect.left+Og,c=Math.max(Dg,e.viewport.width-n-Dg),l=e.anchorRect.left-n-Og;return{top:o,left:s+n<=e.viewport.width-Dg?s:l>=Dg?l:Math.max(Dg,Math.min(s,c))}}function jg(e){let t=new Set;return e.map(e=>f(e)).filter(e=>e!==null).filter(e=>{let n=g(e);return t.has(n)?!1:(t.add(n),!0)})}function Mg(e){let t=jg(e.stack);if(!e.active||!e.anchorRect||t.length===0)return null;let n=typeof window>`u`?{width:1280,height:800}:{width:window.innerWidth,height:window.innerHeight},r=Ag({anchorRect:e.anchorRect,rowCount:t.length,viewport:n});return(0,Q.jsxs)(`div`,{[p]:`true`,className:`pointer-events-none fixed inset-0 z-[120] select-none`,children:[e.highlightRect?(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute rounded-xl border-2 border-sky-500/90 bg-sky-500/10`,style:{top:e.highlightRect.top,left:e.highlightRect.left,width:e.highlightRect.width,height:e.highlightRect.height,boxShadow:`0 0 0 1px rgba(255,255,255,0.65)`}}):null,(0,Q.jsx)(`div`,{className:`pointer-events-auto absolute flex min-w-56 flex-col gap-1 rounded-xl border border-border bg-background/95 p-2 shadow-xl backdrop-blur-sm`,style:{top:r.top,left:r.left},children:t.map(t=>(0,Q.jsxs)(`button`,{type:`button`,className:b(`pointer-events-auto flex items-center justify-between gap-3 rounded-lg px-2 py-1.5 text-left text-xs`,e.highlightedId===t.id?`bg-accent text-foreground`:`text-muted-foreground`),onMouseEnter:()=>e.onHighlight(t.id),onFocus:()=>e.onHighlight(t.id),onClick:()=>e.onCopy(t),title:g(t),children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium`,children:t.id}),t.c3ComponentId?(0,Q.jsx)(`span`,{className:`block truncate text-[10px] text-muted-foreground/80`,children:t.c3ComponentLabel?`${t.c3ComponentId} · ${t.c3ComponentLabel}`:t.c3ComponentId}):null]}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px]`,children:kg(t.id,e.copiedId)})]},t.id))})]})}function Ng(e){let t=Mg(e);return t?typeof document>`u`||!document.body?t:(0,Ii.createPortal)(t,document.body):null}function Pg(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Fg=e=>{switch(e){case`success`:return Rg;case`info`:return Bg;case`warning`:return zg;case`error`:return Vg;default:return null}},Ig=Array(12).fill(0),Lg=({visible:e,className:t})=>j.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},j.createElement(`div`,{className:`sonner-spinner`},Ig.map((e,t)=>j.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Rg=j.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},j.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),zg=j.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},j.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),Bg=j.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},j.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),Vg=j.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},j.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),Hg=j.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},j.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),j.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),Ug=()=>{let[e,t]=j.useState(document.hidden);return j.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},Wg=1,Gg=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:Wg++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],j.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(qg(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!j.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!j.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!j.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!j.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||Wg++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Kg=(e,t)=>{let n=t?.id||Wg++;return Gg.addToast({title:e,...t,id:n}),n},qg=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,Jg=Object.assign(Kg,{success:Gg.success,info:Gg.info,warning:Gg.warning,error:Gg.error,custom:Gg.custom,message:Gg.message,promise:Gg.promise,dismiss:Gg.dismiss,loading:Gg.loading},{getHistory:()=>Gg.toasts,getToasts:()=>Gg.getActiveToasts()});Pg(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function Yg(e){return e.label!==void 0}var Xg=3,Zg=`24px`,Qg=`16px`,$g=4e3,e_=356,t_=14,n_=45,r_=200;function i_(...e){return e.filter(Boolean).join(` `)}function a_(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var o_=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=j.useState(null),[O,k]=j.useState(null),[A,M]=j.useState(!1),[N,P]=j.useState(!1),[F,I]=j.useState(!1),[L,R]=j.useState(!1),[z,B]=j.useState(!1),[V,H]=j.useState(0),[U,W]=j.useState(0),G=j.useRef(n.duration||y||$g),K=j.useRef(null),q=j.useRef(null),J=c===0,ee=c+1<=o,Y=n.type,te=n.dismissible!==!1,ne=n.className||``,re=n.descriptionClassName||``,ie=j.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ae=j.useMemo(()=>n.closeButton??p,[n.closeButton,p]),oe=j.useMemo(()=>n.duration||y||$g,[n.duration,y]),se=j.useRef(0),ce=j.useRef(0),le=j.useRef(0),ue=j.useRef(null),[de,fe]=b.split(`-`),pe=j.useMemo(()=>s.reduce((e,t,n)=>n>=ie?e:e+t.height,0),[s,ie]),me=Ug(),he=n.invert||t,ge=Y===`loading`;ce.current=j.useMemo(()=>ie*x+pe,[ie,pe]),j.useEffect(()=>{G.current=oe},[oe]),j.useEffect(()=>{M(!0)},[]),j.useEffect(()=>{let e=q.current;if(e){let t=e.getBoundingClientRect().height;return W(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),j.useLayoutEffect(()=>{if(!A)return;let e=q.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,W(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let _e=j.useCallback(()=>{P(!0),H(ce.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},r_)},[n,d,a,ce]);j.useEffect(()=>{if(n.promise&&Y===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||me?(()=>{if(le.current<se.current){let e=new Date().getTime()-se.current;G.current-=e}le.current=new Date().getTime()})():G.current!==1/0&&(se.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),_e()},G.current)),()=>clearTimeout(e)},[u,i,n,Y,me,_e]),j.useEffect(()=>{n.delete&&(_e(),n.onDismiss==null||n.onDismiss.call(n,n))},[_e,n.delete]);function ve(){return w?.loading?j.createElement(`div`,{className:i_(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":Y===`loading`},w.loading):j.createElement(Lg,{className:i_(C?.loader,n?.classNames?.loader),visible:Y===`loading`})}let ye=n.icon||w?.[Y]||Fg(Y);return j.createElement(`li`,{tabIndex:0,ref:q,className:i_(_,ne,C?.toast,n?.classNames?.toast,C?.default,C?.[Y],n?.classNames?.[Y]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":z,"data-removed":N,"data-visible":ee,"data-y-position":de,"data-x-position":fe,"data-index":c,"data-front":J,"data-swiping":F,"data-dismissible":te,"data-type":Y,"data-invert":he,"data-swipe-out":L,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?V:ce.current}px`,"--initial-height":S?`auto`:`${U}px`,...m,...n.style},onDragEnd:()=>{I(!1),D(null),ue.current=null},onPointerDown:e=>{e.button!==2&&(ge||!te||(K.current=new Date,H(ce.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),ue.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!te)return;ue.current=null;let e=Number(q.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(q.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-K.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=n_||a>.11){H(ce.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),_e(),R(!0);return}else{var o,s;(o=q.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=q.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}B(!1),I(!1),D(null)},onPointerMove:t=>{var n,r;if(!ue.current||!te||window.getSelection()?.toString().length>0)return;let i=t.clientY-ue.current.y,a=t.clientX-ue.current.x,o=e.swipeDirections??a_(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&B(!0),(n=q.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=q.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ae&&!n.jsx&&Y!==`loading`?j.createElement(`button`,{"aria-label":T,"data-disabled":ge,"data-close-button":!0,onClick:ge||!te?()=>{}:()=>{_e(),n.onDismiss==null||n.onDismiss.call(n,n)},className:i_(C?.closeButton,n?.classNames?.closeButton)},w?.close??Hg):null,(Y||n.icon||n.promise)&&n.icon!==null&&(w?.[Y]!==null||n.icon)?j.createElement(`div`,{"data-icon":``,className:i_(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||ve():null,n.type===`loading`?null:ye):null,j.createElement(`div`,{"data-content":``,className:i_(C?.content,n?.classNames?.content)},j.createElement(`div`,{"data-title":``,className:i_(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?j.createElement(`div`,{"data-description":``,className:i_(v,re,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),j.isValidElement(n.cancel)?n.cancel:n.cancel&&Yg(n.cancel)?j.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{Yg(n.cancel)&&te&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),_e())},className:i_(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,j.isValidElement(n.action)?n.action:n.action&&Yg(n.action)?j.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{Yg(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&_e())},className:i_(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function s_(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function c_(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?Qg:Zg;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var l_=j.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=Xg,toastOptions:g,dir:_=s_(),gap:v=t_,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=j.useState([]),C=j.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=j.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=j.useState([]),[D,O]=j.useState(!1),[k,A]=j.useState(!1),[M,N]=j.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=j.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=j.useRef(null),L=j.useRef(!1),R=j.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||Gg.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return j.useEffect(()=>Gg.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Ii.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),j.useEffect(()=>{if(d!==`system`){N(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?N(`dark`):N(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{N(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{N(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),j.useEffect(()=>{x.length<=1&&O(!1)},[x]),j.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=P.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===P.current||P.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),j.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),j.createElement(`section`,{ref:t,"aria-label":`${b} ${F}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?j.createElement(`ol`,{key:t,dir:_===`auto`?s_():_,tabIndex:-1,ref:P,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${e_}px`,"--gap":`${v}px`,...m,...c_(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>j.createElement(o_,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:R,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),u_={name:`airaknit`,type:`module`,version:`1.1.2-rc.9`,description:`A playful web workbench for Claude Code and Codex`,license:`MIT`,keywords:[`claude`,`claude-code`,`ai`,`chat`,`ui`,`agent`,`anthropic`,`bun`,`react`],repository:{type:`git`,url:`git+https://github.com/lagz0ne/tinkaria.git`},bin:{airaknit:`bin/airaknit`,"airaknit-project":`bin/airaknit-project`},packageManager:`bun@1.3.11`,files:[`bin/`,`src/nats/`,`src/runner/`,`src/server/`,`src/shared/`,`dist/client/`],engines:{bun:`>=1.3.5`},scripts:{build:`vite build`,check:`bunx @typescript/native-preview --noEmit -p tsconfig.json && vite build`,"lint:rules":`bash .git/hooks/pre-commit --all`,dev:`bun run ./scripts/dev.ts`,"dev:client":`vite --host 0.0.0.0 --port 5174`,"dev:server":`bun run ./scripts/dev-server.ts --no-open --port 5175`,"install:dev":`bun install && bun run build && bun install -g .`,start:`bun run ./src/server/cli.ts`,test:`bun test`,"verify:journey":`bun run ./scripts/verify-journey.ts`,"copy:legacy-transcripts":`bun run ./scripts/copy-legacy-transcripts.ts`,prepublishOnly:`vite build`},dependencies:{"@anthropic-ai/claude-agent-sdk":`^0.2.91`,"@chenglou/pretext":`^0.0.4`,"@lagz0ne/nats-embedded":`^0.3.1`,"@modelcontextprotocol/sdk":`^1.29.0`,"@nats-io/jetstream":`^3.3.1`,"@nats-io/jwt":`^0.0.10-5`,"@nats-io/kv":`^3.3.1`,"@nats-io/nats-core":`^3.3.1`,"@nats-io/transport-node":`^3.3.1`,"@radix-ui/react-alert-dialog":`^1.1.15`,"@radix-ui/react-context-menu":`^2.2.16`,"@radix-ui/react-dropdown-menu":`^2.1.16`,"@radix-ui/react-select":`^2.2.6`,"@tanstack/react-virtual":`^3.13.23`,"@xterm/addon-fit":`^0.11.0`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/addon-web-links":`^0.12.0`,"@xterm/headless":`^6.0.0`,"@xterm/xterm":`^6.0.0`,cloudflared:`^0.7.1`,"default-shell":`^2.2.0`,diff:`^8.0.4`,"file-type":`^22.0.1`,"js-yaml":`^4.1.1`,mermaid:`^11.14.0`,minimatch:`^10.2.5`,qrcode:`^1.5.4`,"react-resizable-panels":`^4.9.0`,"shell-quote":`^1.8.4`,sonner:`^2.0.7`,"sugar-high":`^1.0.0`,"web-push":`^3.6.7`,zod:`^4.3.6`},devDependencies:{"@radix-ui/react-dialog":`^1.1.15`,"@radix-ui/react-popover":`^1.1.15`,"@radix-ui/react-tooltip":`^1.2.8`,"@resvg/resvg-js":`^2.6.2`,"@tailwindcss/postcss":`^4.2.2`,"@tailwindcss/typography":`^0.5.19`,"@types/bun":`^1.3.11`,"@types/diff":`^8.0.0`,"@types/js-yaml":`^4.0.9`,"@types/node":`^25.5.0`,"@types/qrcode":`^1.5.6`,"@types/react":`19.2.14`,"@types/react-dom":`19.2.3`,"@types/shell-quote":`^1.7.5`,"@types/web-push":`^3.6.4`,"@vitejs/plugin-react":`6.0.1`,autoprefixer:`^10.4.27`,"class-variance-authority":`^0.7.1`,clsx:`^2.1.1`,"lucide-react":`^1.7.0`,"png-to-ico":`^3.0.1`,react:`19.2.4`,"react-dom":`19.2.4`,"react-markdown":`^10.1.0`,"react-router-dom":`^7.14.0`,"remark-gfm":`^4.0.1`,sharp:`^0.34.5`,streamdown:`^2.5.0`,"tailwind-merge":`^3.5.0`,tailwindcss:`^4.2.2`,typescript:`6.0.2`,vite:`^8.0.3`,zustand:`^5.0.12`}},d_=`Tinkaria`,f_=`tinkaria`,p_=`tinkaria/${u_.version}`,m_=`[tinkaria]`,h_=`~/${d_}`;function g_(e){return e?`${f_} ${e}`:f_}var __=`data:image/svg+xml,%3csvg%20width='256'%20height='256'%20viewBox='0%200%20256%20256'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='256'%20height='256'%20rx='64'%20fill='%23FFF8EE'/%3e%3cg%20transform='translate(128%20128)'%20stroke='%2317322C'%20stroke-width='6.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3e%3cpath%20d='M0%20-74V-48'/%3e%3cpath%20d='M0%2048V74'/%3e%3cpath%20d='M-74%200H-48'/%3e%3cpath%20d='M48%200H74'/%3e%3cpath%20d='M-52.3%20-52.3L-34%20-34'/%3e%3cpath%20d='M34%2034L52.3%2052.3'/%3e%3cpath%20d='M52.3%20-52.3L34%20-34'/%3e%3cpath%20d='M-34%2034L-52.3%2052.3'/%3e%3ccircle%20r='30'/%3e%3c/g%3e%3ccircle%20cx='128'%20cy='128'%20r='6.5'%20fill='%23FF8A5B'/%3e%3c/svg%3e`;function v_({className:e,imageClassName:t}){return(0,Q.jsx)(`span`,{className:b(`inline-flex items-center justify-center rounded-[8px] border border-slate-300/70 bg-white/70 p-0.5 shadow-[0_0_0_0.5px_rgba(255,255,255,0.35)] dark:border-white/12 dark:bg-white/[0.03] dark:shadow-none`,e),children:(0,Q.jsx)(`img`,{src:__,alt:``,"aria-hidden":`true`,className:b(`size-5`,t)})})}var y_=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>(0,Q.jsx)(`span`,{style:{"--shiny-width":`${Math.min(n,100)}px`},className:b(`mx-auto max-w-md text-foreground/50`,r?[`animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]`,`bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80`]:[`text-neutral`],t),...i,children:e});function b_(e){return e.split(/[\s_-]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}var x_=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function S_(e){let t=e.trim();for(let e of x_){let n=t.match(e);if(!n)continue;let r=(n[2]??n[1]??``).trim();if(r)return r}return t}function C_(e){return e.split(`/`).pop()||e}function w_(e,t=Date.now()){let n=t-e,r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function T_(e,t){if(e===void 0)return null;let n=Math.max(0,t-e),r=6e4,i=60*r,a=24*i,o=7*a;return n<r?`now`:n<i?`${Math.floor(n/r)}m`:n<a?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/a)}d`:`${Math.floor(n/o)}w`}var E_=`(max-width: 767px)`;function D_(){return typeof window>`u`||typeof window.matchMedia!=`function`?null:window.matchMedia.bind(window)}function O_(){let e=D_();return e?e(E_).matches:!1}function k_(){let[e,t]=(0,j.useState)(O_);return(0,j.useEffect)(()=>{let e=D_();if(!e)return;let n=e(E_),r=e=>t(e.matches);return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[]),e}function A_({className:e,...t}){return(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:b(`shrink-0`,e),...t,children:(0,Q.jsx)(`path`,{d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`})})}function j_({className:e,...t}){return(0,Q.jsx)(`svg`,{viewBox:`0 0 158.7128 157.296`,fill:`currentColor`,"aria-hidden":`true`,className:b(`shrink-0`,e),...t,children:(0,Q.jsx)(`path`,{d:`M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z`})})}var M_={claude:A_,codex:j_,"claude-pty":A_};function N_(e){let t=e.toLowerCase();return/sonnet|opus|haiku|claude/.test(t)?`claude`:/gpt|o1|o3|o4|codex/.test(t)?`codex`:null}var P_=`Popover`,[F_,I_]=Pi(P_,[ks]),L_=ks(),[R_,z_]=F_(P_),B_=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=L_(t),c=j.useRef(null),[l,u]=j.useState(!1),[d,f]=rc({prop:r,defaultProp:i??!1,onChange:a,caller:P_});return(0,Q.jsx)(Gs,{...s,children:(0,Q.jsx)(R_,{scope:t,contentId:ua(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:j.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:j.useCallback(()=>u(!0),[]),onCustomAnchorRemove:j.useCallback(()=>u(!1),[]),modal:o,children:n})})};B_.displayName=P_;var V_=`PopoverAnchor`,H_=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z_(V_,n),a=L_(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return j.useEffect(()=>(o(),()=>s()),[o,s]),(0,Q.jsx)(Ks,{...a,...r,ref:t})});H_.displayName=V_;var U_=`PopoverTrigger`,W_=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z_(U_,n),a=L_(n),o=Mi(t,i.triggerRef),s=(0,Q.jsx)(Wi.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":av(i.open),...r,ref:o,onClick:Z(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Q.jsx)(Ks,{asChild:!0,...a,children:s})});W_.displayName=U_;var G_=`PopoverPortal`,[K_,q_]=F_(G_,{forceMount:void 0}),J_=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=z_(G_,t);return(0,Q.jsx)(K_,{scope:t,forceMount:n,children:(0,Q.jsx)(Qs,{present:n||a.open,children:(0,Q.jsx)(Xs,{asChild:!0,container:i,children:r})})})};J_.displayName=G_;var Y_=`PopoverContent`,X_=j.forwardRef((e,t)=>{let n=q_(Y_,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=z_(Y_,e.__scopePopover);return(0,Q.jsx)(Qs,{present:r||a.open,children:a.modal?(0,Q.jsx)(Q_,{...i,ref:t}):(0,Q.jsx)($_,{...i,ref:t})})});X_.displayName=Y_;var Z_=Li(`PopoverContent.RemoveScroll`),Q_=j.forwardRef((e,t)=>{let n=z_(Y_,e.__scopePopover),r=j.useRef(null),i=Mi(t,r),a=j.useRef(!1);return j.useEffect(()=>{let e=r.current;if(e)return $u(e)},[]),(0,Q.jsx)(Wu,{as:Z_,allowPinchZoom:!0,children:(0,Q.jsx)(ev,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Z(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Z(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:Z(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),$_=j.forwardRef((e,t)=>{let n=z_(Y_,e.__scopePopover),r=j.useRef(!1),i=j.useRef(!1);return(0,Q.jsx)(ev,{...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()}})}),ev=j.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=z_(Y_,n),p=L_(n);return Pl(),(0,Q.jsx)(xl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Q.jsx)(ea,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,Q.jsx)(qs,{"data-state":av(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),tv=`PopoverClose`,nv=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z_(tv,n);return(0,Q.jsx)(Wi.button,{type:`button`,...r,ref:t,onClick:Z(e.onClick,()=>i.onOpenChange(!1))})});nv.displayName=tv;var rv=`PopoverArrow`,iv=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=L_(n);return(0,Q.jsx)(Js,{...i,...r,ref:t})});iv.displayName=rv;function av(e){return e?`open`:`closed`}var ov=B_,sv=W_,cv=J_,lv=X_,uv=ov,dv=sv,fv=j.forwardRef(({className:e,align:t=`center`,sideOffset:n=4,...r},i)=>(0,Q.jsx)(cv,{children:(0,Q.jsx)(lv,{ref:i,align:t,sideOffset:n,[Kh]:``,onCloseAutoFocus:e=>{e.preventDefault(),window.dispatchEvent(new Event(Jh)),r.onCloseAutoFocus?.(e)},className:b(`z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));fv.displayName=lv.displayName;function pv({onClick:e,selected:t,icon:n,label:r,description:i,disabled:a,trailing:o}){return(0,Q.jsxs)(S,{variant:`ghost`,onClick:e,disabled:a,className:b(`w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left h-auto justify-start transition-opacity`,t?`bg-muted border-border`:`hover:opacity-60`,a&&`opacity-40 cursor-not-allowed`),children:[n,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium`,children:r}),i?(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i}):null]}),o?(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground`,children:o}):null]})}function mv({trigger:e,triggerClassName:t,disabled:n=!1,triggerUiId:r,contentUiId:i,onDoubleTap:a,children:o}){let[s,l]=(0,j.useState)(!1);return n?(0,Q.jsx)(S,{variant:`ghost`,...r?c(r):{},disabled:!0,className:b(`flex items-center gap-1.5 px-2 py-1 text-sm text-muted-foreground [&>svg]:shrink-0 opacity-70 [&>span]:whitespace-nowrap h-auto`,t),children:e}):(0,Q.jsxs)(uv,{open:s,onOpenChange:l,children:[(0,Q.jsx)(dv,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,...r?c(r):{},onDoubleClick:a?e=>{e.preventDefault(),l(!1),a()}:void 0,className:b(`flex items-center gap-1.5 px-2 py-1 text-sm text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap h-auto`,t),children:e})}),(0,Q.jsx)(fv,{...i?c(i):{},align:`center`,className:`w-64 p-1`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:typeof o==`function`?o(()=>l(!1)):o})})]})}var hv=(0,j.memo)(function({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,providerLocked:r=!1,model:i,modelOptions:a,onProviderChange:o,onModelChange:l,onModelDoubleTap:u,onModelOptionChange:d,planMode:f=!1,onPlanModeChange:p,includePlanMode:h=!0,showSkillsToggle:g=!1,skillsVisible:_=!1,onSkillsToggle:v,className:y}){let x=e.find(e=>e.id===t)??e[0],C=M_[t],w=er,T=h&&x?.supportsPlanMode&&p,E=t===`claude`?a:null,D=t===`codex`?a:null,O=x.models.find(e=>e.id===i)?.contextWindowOptions??[],k=E?.contextWindow??Zm[0].id,A=k===`1m`?gi:_i,M=k_(),[N,P]=(0,j.useState)(!1),[F,I]=(0,j.useState)(null),L=m({id:s(`chat.composer.provider`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),R=m({id:s(`chat.composer.provider`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),z=m({id:s(`chat.composer.model`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),B=m({id:s(`chat.composer.model`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),V=m({id:s(`chat.composer.reasoning`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),H=m({id:s(`chat.composer.reasoning`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),U=m({id:s(`chat.composer.context-window`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),W=m({id:s(`chat.composer.context-window`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),G=m({id:s(`chat.composer.fast-mode`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),K=m({id:s(`chat.composer.fast-mode`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),q=m({id:s(`chat.composer.plan-mode`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),J=m({id:s(`chat.composer.plan-mode`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),ee=m({id:s(`chat.composer.skills.toggle`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),Y=m({id:s(`chat.composer.menu`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),te=m({id:s(`chat.composer.menu`,`popover`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`});if(M){let s=x.models.find(e=>e.id===i)?.label??i,u=t===`claude`?Wm.find(e=>e.id===a.reasoningEffort)?.label??a.reasoningEffort:Gm.find(e=>e.id===a.reasoningEffort)?.label??a.reasoningEffort,m=()=>{P(!1),I(null)},h=[];n&&h.push({key:`provider`,icon:(0,Q.jsx)(C,{className:`h-4 w-4 text-muted-foreground`}),label:`Provider`,value:x?.label??t,disabled:r||!o,renderOptions:()=>e.map(e=>{let n=M_[e.id];return(0,Q.jsx)(pv,{onClick:()=>{o?.(e.id),m()},selected:t===e.id,icon:(0,Q.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)})}),h.push({key:`model`,icon:(0,Q.jsx)(w,{className:`h-4 w-4 text-muted-foreground`}),label:`Model`,value:s,renderOptions:()=>x.models.map(e=>(0,Q.jsx)(pv,{onClick:()=>{l(t,e.id),m()},selected:i===e.id,icon:(0,Q.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,description:e.description},e.id))}),h.push({key:`reasoning`,icon:(0,Q.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),label:`Reasoning`,value:u,renderOptions:()=>t===`claude`?Wm.map(e=>(0,Q.jsx)(pv,{onClick:()=>{d({type:`claudeReasoningEffort`,effort:e.id}),m()},selected:a.reasoningEffort===e.id,icon:(0,Q.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,disabled:e.id===`max`&&i!==`opus`},e.id)):Gm.map(e=>(0,Q.jsx)(pv,{onClick:()=>{d({type:`codexReasoningEffort`,effort:e.id}),m()},selected:a.reasoningEffort===e.id,icon:(0,Q.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id))}),t===`claude`&&O.length>1&&h.push({key:`context`,icon:(0,Q.jsx)(A,{className:`h-4 w-4 text-muted-foreground`}),label:`Context`,value:O.find(e=>e.id===k)?.label??k,renderOptions:()=>O.map(e=>(0,Q.jsx)(pv,{onClick:()=>{d({type:`contextWindow`,contextWindow:e.id}),m()},selected:k===e.id,icon:e.id===`1m`?(0,Q.jsx)(gi,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(_i,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,description:e.id===`1m`?`Expanded context window`:`Standard context window`},e.id))}),t===`codex`&&h.push({key:`fastMode`,icon:(0,Q.jsx)(Mr,{className:b(`h-4 w-4 text-muted-foreground`,!D?.fastMode&&`-scale-x-100`)}),label:`Speed`,value:D?.fastMode?`Fast Mode`:`Standard`,renderOptions:()=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pv,{onClick:()=>{d({type:`fastMode`,fastMode:!1}),m()},selected:!D?.fastMode,icon:(0,Q.jsx)(Mr,{className:`h-4 w-4 text-muted-foreground -scale-x-100`}),label:`Standard`}),(0,Q.jsx)(pv,{onClick:()=>{d({type:`fastMode`,fastMode:!0}),m()},selected:!!D?.fastMode,icon:(0,Q.jsx)(Mr,{className:`h-4 w-4 text-muted-foreground`}),label:`Fast Mode`})]})}),T&&h.push({key:`mode`,icon:f?(0,Q.jsx)(Ur,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(Kr,{className:`h-4 w-4 text-muted-foreground`}),label:`Mode`,value:f?`Plan Mode`:`Full Access`,renderOptions:()=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pv,{onClick:()=>{p(!1),m()},selected:!f,icon:(0,Q.jsx)(Kr,{className:`h-4 w-4 text-muted-foreground`}),label:`Full Access`,description:`Execution without approval`}),(0,Q.jsx)(pv,{onClick:()=>{p(!0),m()},selected:f,icon:(0,Q.jsx)(Ur,{className:`h-4 w-4 text-muted-foreground`}),label:`Plan Mode`,description:`Review a plan before execution`})]})});let y=F?h.find(e=>e.key===F)??null:null,E=f?Ur:w,j=f?`text-blue-400 dark:text-blue-300`:t===`codex`&&D?.fastMode?`text-emerald-500 dark:text-emerald-400`:void 0;return(0,Q.jsx)(`div`,{className:`flex items-center`,children:(0,Q.jsxs)(uv,{open:N,onOpenChange:e=>{P(e),e||I(null)},children:[(0,Q.jsx)(dv,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,"aria-label":`Composer settings — ${s}`,...c(Y),className:b(`shrink-0 rounded-full h-9 w-9 text-muted-foreground [&>svg]:shrink-0`,j),children:(0,Q.jsx)(E,{className:`h-5 w-5`})})}),(0,Q.jsx)(fv,{...c(te),align:`center`,className:`w-64 p-1`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>I(null),className:`w-full flex items-center gap-2 p-2 text-sm font-medium text-muted-foreground hover:opacity-60 transition-opacity`,children:[(0,Q.jsx)(Jn,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:y.label})]}),y.renderOptions()]}):(0,Q.jsxs)(Q.Fragment,{children:[h.map(e=>(0,Q.jsx)(pv,{onClick:()=>{e.disabled||I(e.key)},disabled:e.disabled,selected:!1,icon:e.icon,label:e.label,description:e.value,trailing:e.disabled?void 0:(0,Q.jsx)(cr,{className:`h-4 w-4`})},e.key)),g?(0,Q.jsx)(pv,{onClick:()=>{v?.(),m()},selected:!!_,icon:(0,Q.jsx)(hi,{className:b(`h-4 w-4 text-muted-foreground`,_&&`text-amber-600 dark:text-amber-400`)}),label:`Skills`,description:_?`Shown`:`Hidden`}):null]})})})]})})}return(0,Q.jsxs)(`div`,{className:b(`flex md:justify-center items-center gap-0.5`,y),children:[n?(0,Q.jsx)(mv,{disabled:r||!o,triggerUiId:L,contentUiId:R,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(C,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:x?.label??t})]}),children:n=>e.map(e=>{let r=M_[e.id];return(0,Q.jsx)(pv,{onClick:()=>{o?.(e.id),n()},selected:t===e.id,icon:(0,Q.jsx)(r,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)})}):null,(0,Q.jsx)(mv,{triggerUiId:z,contentUiId:B,onDoubleTap:u,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(w,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:x.models.find(e=>e.id===i)?.label??i})]}),children:e=>x.models.map(n=>{let r=er;return(0,Q.jsx)(pv,{onClick:()=>{l(t,n.id),e()},selected:i===n.id,icon:(0,Q.jsx)(r,{className:`h-4 w-4 text-muted-foreground`}),label:n.label,description:n.description},n.id)})}),g?(0,Q.jsxs)(`button`,{type:`button`,onClick:v,className:b(`shrink-0 flex items-center gap-1 px-2 py-1 text-sm rounded-md transition-colors`,`text-muted-foreground hover:bg-muted/50 [&>span]:whitespace-nowrap`,_&&`text-amber-600 dark:text-amber-400`),...c(ee),children:[(0,Q.jsx)(hi,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:`Skills`}),(0,Q.jsx)(cr,{className:b(`h-3.5 w-3.5 transition-transform duration-200`,_&&`rotate-90`)})]}):null,(0,Q.jsx)(mv,{triggerUiId:V,contentUiId:H,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nr,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:t===`claude`?Wm.find(e=>e.id===a.reasoningEffort)?.label??a.reasoningEffort:Gm.find(e=>e.id===a.reasoningEffort)?.label??a.reasoningEffort})]}),children:e=>t===`claude`?Wm.map(t=>(0,Q.jsx)(pv,{onClick:()=>{d({type:`claudeReasoningEffort`,effort:t.id}),e()},selected:a.reasoningEffort===t.id,icon:(0,Q.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,disabled:t.id===`max`&&i!==`opus`},t.id)):Gm.map(t=>(0,Q.jsx)(pv,{onClick:()=>{d({type:`codexReasoningEffort`,effort:t.id}),e()},selected:a.reasoningEffort===t.id,icon:(0,Q.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id))}),t===`claude`&&O.length>1?(0,Q.jsx)(mv,{triggerUiId:U,contentUiId:W,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:O.find(e=>e.id===k)?.label??k})]}),children:e=>O.map(t=>(0,Q.jsx)(pv,{onClick:()=>{d({type:`contextWindow`,contextWindow:t.id}),e()},selected:k===t.id,icon:t.id===`1m`?(0,Q.jsx)(gi,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(_i,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.id===`1m`?`Expanded context window`:`Standard context window`},t.id))}):null,t===`codex`?(0,Q.jsx)(mv,{triggerUiId:G,contentUiId:K,trigger:(0,Q.jsxs)(Q.Fragment,{children:[D?.fastMode?(0,Q.jsx)(Mr,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Mr,{className:`h-3.5 w-3.5 -scale-x-100`}),(0,Q.jsx)(`span`,{children:D?.fastMode?`Fast Mode`:`Standard`})]}),triggerClassName:D?.fastMode?`text-emerald-500 dark:text-emerald-400`:void 0,children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pv,{onClick:()=>{d({type:`fastMode`,fastMode:!1}),e()},selected:!D?.fastMode,icon:(0,Q.jsx)(Mr,{className:`h-4 w-4 text-muted-foreground -scale-x-100`}),label:`Standard`}),(0,Q.jsx)(pv,{onClick:()=>{d({type:`fastMode`,fastMode:!0}),e()},selected:!!D?.fastMode,icon:(0,Q.jsx)(Mr,{className:`h-4 w-4 text-muted-foreground`}),label:`Fast Mode`})]})}):null,T?(0,Q.jsx)(mv,{triggerUiId:q,contentUiId:J,trigger:(0,Q.jsxs)(Q.Fragment,{children:[f?(0,Q.jsx)(Ur,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Kr,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:f?`Plan Mode`:`Full Access`})]}),triggerClassName:f?`text-blue-400 dark:text-blue-300`:void 0,children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pv,{onClick:()=>{p(!1),e()},selected:!f,icon:(0,Q.jsx)(Kr,{className:`h-4 w-4 text-muted-foreground`}),label:`Full Access`,description:`Execution without approval`}),(0,Q.jsx)(pv,{onClick:()=>{p(!0),e()},selected:f,icon:(0,Q.jsx)(Ur,{className:`h-4 w-4 text-muted-foreground`}),label:`Plan Mode`,description:`Review a plan before execution`})]})}):null]})}),gv=`rovingFocusGroup.onEntryFocus`,_v={bubbles:!1,cancelable:!0},vv=`RovingFocusGroup`,[yv,bv,xv]=Gf(vv),[Sv,Cv]=Pi(vv,[xv]),[wv,Tv]=Sv(vv),Ev=j.forwardRef((e,t)=>(0,Q.jsx)(yv.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Q.jsx)(yv.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Q.jsx)(Dv,{...e,ref:t})})}));Ev.displayName=vv;var Dv=j.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=j.useRef(null),p=Mi(t,f),m=qf(a),[h,g]=rc({prop:o,defaultProp:s??null,onChange:c,caller:vv}),[_,v]=j.useState(!1),y=Ki(l),b=bv(n),x=j.useRef(!1),[S,C]=j.useState(0);return j.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(gv,y),()=>e.removeEventListener(gv,y)},[y]),(0,Q.jsx)(wv,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:j.useCallback(e=>g(e),[g]),onItemShiftTab:j.useCallback(()=>v(!0),[]),onFocusableItemAdd:j.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:j.useCallback(()=>C(e=>e-1),[]),children:(0,Q.jsx)(Wi.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Z(e.onMouseDown,()=>{x.current=!0}),onFocus:Z(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(gv,_v);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Nv([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:Z(e.onBlur,()=>v(!1))})})}),Ov=`RovingFocusGroupItem`,kv=j.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=ua(),l=a||c,u=Tv(Ov,n),d=u.currentTabStopId===l,f=bv(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return j.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,Q.jsx)(yv.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Q.jsx)(Wi.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Z(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Z(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Z(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Mv(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Pv(n,r+1):n.slice(r+1)}setTimeout(()=>Nv(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});kv.displayName=Ov;var Av={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function jv(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Mv(e,t,n){let r=jv(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Av[r]}function Nv(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Pv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Fv=Ev,Iv=kv,Lv=[`Enter`,` `],Rv=[`ArrowDown`,`PageUp`,`Home`],zv=[`ArrowUp`,`PageDown`,`End`],Bv=[...Rv,...zv],Vv={ltr:[...Lv,`ArrowRight`],rtl:[...Lv,`ArrowLeft`]},Hv={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Uv=`Menu`,[Wv,Gv,Kv]=Gf(Uv),[qv,Jv]=Pi(Uv,[Kv,ks,Cv]),Yv=ks(),Xv=Cv(),[Zv,Qv]=qv(Uv),[$v,ey]=qv(Uv),ty=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Yv(t),[c,l]=j.useState(null),u=j.useRef(!1),d=Ki(a),f=qf(i);return j.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,Q.jsx)(Gs,{...s,children:(0,Q.jsx)(Zv,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,Q.jsx)($v,{scope:t,onClose:j.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};ty.displayName=Uv;var ny=`MenuAnchor`,ry=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Yv(n);return(0,Q.jsx)(Ks,{...i,...r,ref:t})});ry.displayName=ny;var iy=`MenuPortal`,[ay,oy]=qv(iy,{forceMount:void 0}),sy=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Qv(iy,t);return(0,Q.jsx)(ay,{scope:t,forceMount:n,children:(0,Q.jsx)(Qs,{present:n||a.open,children:(0,Q.jsx)(Xs,{asChild:!0,container:i,children:r})})})};sy.displayName=iy;var cy=`MenuContent`,[ly,uy]=qv(cy),dy=j.forwardRef((e,t)=>{let n=oy(cy,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Qv(cy,e.__scopeMenu),o=ey(cy,e.__scopeMenu);return(0,Q.jsx)(Wv.Provider,{scope:e.__scopeMenu,children:(0,Q.jsx)(Qs,{present:r||a.open,children:(0,Q.jsx)(Wv.Slot,{scope:e.__scopeMenu,children:o.modal?(0,Q.jsx)(fy,{...i,ref:t}):(0,Q.jsx)(py,{...i,ref:t})})})})}),fy=j.forwardRef((e,t)=>{let n=Qv(cy,e.__scopeMenu),r=j.useRef(null),i=Mi(t,r);return j.useEffect(()=>{let e=r.current;if(e)return $u(e)},[]),(0,Q.jsx)(hy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Z(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),py=j.forwardRef((e,t)=>{let n=Qv(cy,e.__scopeMenu);return(0,Q.jsx)(hy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),my=Li(`MenuContent.ScrollLock`),hy=j.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Qv(cy,n),_=ey(cy,n),v=Yv(n),y=Xv(n),b=Gv(n),[x,S]=j.useState(null),C=j.useRef(null),w=Mi(t,C,g.onContentChange),T=j.useRef(0),E=j.useRef(``),D=j.useRef(0),O=j.useRef(null),k=j.useRef(`right`),A=j.useRef(0),M=m?Wu:j.Fragment,N=m?{as:my,allowPinchZoom:!0}:void 0,P=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=$y(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};j.useEffect(()=>()=>window.clearTimeout(T.current),[]),Pl();let F=j.useCallback(e=>k.current===O.current?.side&&tb(e,O.current?.area),[]);return(0,Q.jsx)(ly,{scope:n,searchRef:E,onItemEnter:j.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:j.useCallback(e=>{F(e)||(C.current?.focus(),S(null))},[F]),onTriggerLeave:j.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:D,onPointerGraceIntentChange:j.useCallback(e=>{O.current=e},[]),children:(0,Q.jsx)(M,{...N,children:(0,Q.jsx)(xl,{asChild:!0,trapped:i,onMountAutoFocus:Z(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Q.jsx)(ea,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,Q.jsx)(Fv,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Z(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Q.jsx)(qs,{role:`menu`,"aria-orientation":`vertical`,"data-state":Jy(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:Z(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=C.current;if(e.target!==i||!Bv.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);zv.includes(e.key)&&a.reverse(),Zy(a)}),onBlur:Z(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:Z(e.onPointerMove,nb(e=>{let t=e.target,n=A.current!==e.clientX;e.currentTarget.contains(t)&&n&&(k.current=e.clientX>A.current?`right`:`left`,A.current=e.clientX)}))})})})})})})});dy.displayName=cy;var gy=`MenuGroup`,_y=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,Q.jsx)(Wi.div,{role:`group`,...r,ref:t})});_y.displayName=gy;var vy=`MenuLabel`,yy=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,Q.jsx)(Wi.div,{...r,ref:t})});yy.displayName=vy;var by=`MenuItem`,xy=`menu.itemSelect`,Sy=j.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=j.useRef(null),o=ey(by,e.__scopeMenu),s=uy(by,e.__scopeMenu),c=Mi(t,a),l=j.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(xy,{bubbles:!0,cancelable:!0});e.addEventListener(xy,e=>r?.(e),{once:!0}),Gi(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,Q.jsx)(Cy,{...i,ref:c,disabled:n,onClick:Z(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Z(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Z(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Lv.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Sy.displayName=by;var Cy=j.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=uy(by,n),s=Xv(n),c=j.useRef(null),l=Mi(t,c),[u,d]=j.useState(!1),[f,p]=j.useState(``);return j.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,Q.jsx)(Wv.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,Q.jsx)(Iv,{asChild:!0,...s,focusable:!r,children:(0,Q.jsx)(Wi.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Z(e.onPointerMove,nb(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Z(e.onPointerLeave,nb(e=>o.onItemLeave(e))),onFocus:Z(e.onFocus,()=>d(!0)),onBlur:Z(e.onBlur,()=>d(!1))})})})}),wy=`MenuCheckboxItem`,Ty=j.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,Q.jsx)(Ny,{scope:e.__scopeMenu,checked:n,children:(0,Q.jsx)(Sy,{role:`menuitemcheckbox`,"aria-checked":Yy(n)?`mixed`:n,...i,ref:t,"data-state":Xy(n),onSelect:Z(i.onSelect,()=>r?.(Yy(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ty.displayName=wy;var Ey=`MenuRadioGroup`,[Dy,Oy]=qv(Ey,{value:void 0,onValueChange:()=>{}}),ky=j.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Ki(r);return(0,Q.jsx)(Dy,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,Q.jsx)(_y,{...i,ref:t})})});ky.displayName=Ey;var Ay=`MenuRadioItem`,jy=j.forwardRef((e,t)=>{let{value:n,...r}=e,i=Oy(Ay,e.__scopeMenu),a=n===i.value;return(0,Q.jsx)(Ny,{scope:e.__scopeMenu,checked:a,children:(0,Q.jsx)(Sy,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Xy(a),onSelect:Z(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});jy.displayName=Ay;var My=`MenuItemIndicator`,[Ny,Py]=qv(My,{checked:!1}),Fy=j.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Py(My,n);return(0,Q.jsx)(Qs,{present:r||Yy(a.checked)||a.checked===!0,children:(0,Q.jsx)(Wi.span,{...i,ref:t,"data-state":Xy(a.checked)})})});Fy.displayName=My;var Iy=`MenuSeparator`,Ly=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,Q.jsx)(Wi.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Ly.displayName=Iy;var Ry=`MenuArrow`,zy=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Yv(n);return(0,Q.jsx)(Js,{...i,...r,ref:t})});zy.displayName=Ry;var By=`MenuSub`,[Vy,Hy]=qv(By),Uy=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Qv(By,t),o=Yv(t),[s,c]=j.useState(null),[l,u]=j.useState(null),d=Ki(i);return j.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,Q.jsx)(Gs,{...o,children:(0,Q.jsx)(Zv,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,Q.jsx)(Vy,{scope:t,contentId:ua(),triggerId:ua(),trigger:s,onTriggerChange:c,children:n})})})};Uy.displayName=By;var Wy=`MenuSubTrigger`,Gy=j.forwardRef((e,t)=>{let n=Qv(Wy,e.__scopeMenu),r=ey(Wy,e.__scopeMenu),i=Hy(Wy,e.__scopeMenu),a=uy(Wy,e.__scopeMenu),o=j.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=j.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return j.useEffect(()=>u,[u]),j.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,Q.jsx)(ry,{asChild:!0,...l,children:(0,Q.jsx)(Cy,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Jy(n.open),...e,ref:ji(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Z(e.onPointerMove,nb(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Z(e.onPointerLeave,nb(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Z(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Vv[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Gy.displayName=Wy;var Ky=`MenuSubContent`,qy=j.forwardRef((e,t)=>{let n=oy(cy,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Qv(cy,e.__scopeMenu),o=ey(cy,e.__scopeMenu),s=Hy(Ky,e.__scopeMenu),c=j.useRef(null),l=Mi(t,c);return(0,Q.jsx)(Wv.Provider,{scope:e.__scopeMenu,children:(0,Q.jsx)(Qs,{present:r||a.open,children:(0,Q.jsx)(Wv.Slot,{scope:e.__scopeMenu,children:(0,Q.jsx)(hy,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Z(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Z(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:Z(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Hv[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});qy.displayName=Ky;function Jy(e){return e?`open`:`closed`}function Yy(e){return e===`indeterminate`}function Xy(e){return Yy(e)?`indeterminate`:e?`checked`:`unchecked`}function Zy(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Qy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function $y(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Qy(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function eb(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function tb(e,t){return t?eb({x:e.clientX,y:e.clientY},t):!1}function nb(e){return t=>t.pointerType===`mouse`?e(t):void 0}var rb=ty,ib=ry,ab=sy,ob=dy,sb=_y,cb=yy,lb=Sy,ub=Ty,db=ky,fb=jy,pb=Fy,mb=Ly,hb=zy,gb=Uy,_b=Gy,vb=qy,yb=`ContextMenu`,[bb,xb]=Pi(yb,[Jv]),Sb=Jv(),[Cb,wb]=bb(yb),Tb=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=j.useState(!1),c=Sb(t),l=Ki(r),u=j.useCallback(e=>{s(e),l(e)},[l]);return(0,Q.jsx)(Cb,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,Q.jsx)(rb,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};Tb.displayName=yb;var Eb=`ContextMenuTrigger`,Db=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=wb(Eb,n),o=Sb(n),s=j.useRef({x:0,y:0}),c=j.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=j.useRef(0),u=j.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return j.useEffect(()=>u,[u]),j.useEffect(()=>void(r&&u()),[r,u]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ib,{...o,virtualRef:c}),(0,Q.jsx)(Wi.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:Z(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:Z(e.onPointerDown,nx(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:Z(e.onPointerMove,nx(u)),onPointerCancel:r?e.onPointerCancel:Z(e.onPointerCancel,nx(u)),onPointerUp:r?e.onPointerUp:Z(e.onPointerUp,nx(u))})]})});Db.displayName=Eb;var Ob=`ContextMenuPortal`,kb=e=>{let{__scopeContextMenu:t,...n}=e,r=Sb(t);return(0,Q.jsx)(ab,{...r,...n})};kb.displayName=Ob;var Ab=`ContextMenuContent`,jb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=wb(Ab,n),a=Sb(n),o=j.useRef(!1);return(0,Q.jsx)(ob,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});jb.displayName=Ab;var Mb=`ContextMenuGroup`,Nb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(sb,{...i,...r,ref:t})});Nb.displayName=Mb;var Pb=`ContextMenuLabel`,Fb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(cb,{...i,...r,ref:t})});Fb.displayName=Pb;var Ib=`ContextMenuItem`,Lb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(lb,{...i,...r,ref:t})});Lb.displayName=Ib;var Rb=`ContextMenuCheckboxItem`,zb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(ub,{...i,...r,ref:t})});zb.displayName=Rb;var Bb=`ContextMenuRadioGroup`,Vb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(db,{...i,...r,ref:t})});Vb.displayName=Bb;var Hb=`ContextMenuRadioItem`,Ub=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(fb,{...i,...r,ref:t})});Ub.displayName=Hb;var Wb=`ContextMenuItemIndicator`,Gb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(pb,{...i,...r,ref:t})});Gb.displayName=Wb;var Kb=`ContextMenuSeparator`,qb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(mb,{...i,...r,ref:t})});qb.displayName=Kb;var Jb=`ContextMenuArrow`,Yb=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(hb,{...i,...r,ref:t})});Yb.displayName=Jb;var Xb=`ContextMenuSub`,Zb=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=Sb(t),[s,c]=rc({prop:i,defaultProp:a??!1,onChange:r,caller:Xb});return(0,Q.jsx)(gb,{...o,open:s,onOpenChange:c,children:n})};Zb.displayName=Xb;var Qb=`ContextMenuSubTrigger`,$b=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(_b,{...i,...r,ref:t})});$b.displayName=Qb;var ex=`ContextMenuSubContent`,tx=j.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Sb(n);return(0,Q.jsx)(vb,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});tx.displayName=ex;function nx(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var rx=Tb,ix=Db,ax=kb,ox=jb,sx=Lb,cx=rx,lx=ix;function ux(e){return e?c(e):{}}var dx=j.forwardRef(({className:e,uiId:t,...n},r)=>(0,Q.jsx)(ax,{children:(0,Q.jsx)(ox,{ref:r,...ux(t),className:b(`z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...n})}));dx.displayName=ox.displayName;var fx=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(sx,{ref:n,className:b(`relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...t}));fx.displayName=sx.displayName;var px=`sidebar.project-group.menu`,mx=`sidebar.chat-row.menu`,hx=m({id:px,c3ComponentId:`c3-113`,c3ComponentLabel:`sidebar`}),gx=m({id:mx,c3ComponentId:`c3-113`,c3ComponentLabel:`sidebar`});function _x({onMergeSession:e,mergeDisabled:t=!1,onOpenCoordination:n,onOpenProject:r,onNewChat:i,newChatDisabled:a=!1,onRemove:o,children:s}){return(0,Q.jsxs)(cx,{children:[(0,Q.jsx)(lx,{asChild:!0,children:s}),(0,Q.jsxs)(dx,{uiId:hx,children:[e?(0,Q.jsxs)(fx,{disabled:t,onSelect:t=>{t.stopPropagation(),e()},children:[(0,Q.jsx)(Xr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Merge sessions`})]}):null,n?(0,Q.jsxs)(fx,{onSelect:e=>{e.stopPropagation(),n()},children:[(0,Q.jsx)(Vr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Coordination board`})]}):null,r?(0,Q.jsxs)(fx,{onSelect:e=>{e.stopPropagation(),r()},children:[(0,Q.jsx)(Br,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Project view`})]}):null,i?(0,Q.jsxs)(fx,{disabled:a,onSelect:e=>{e.stopPropagation(),i()},children:[(0,Q.jsx)(vi,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`New chat`})]}):null,o?(0,Q.jsxs)(fx,{onSelect:e=>{e.stopPropagation(),o()},className:`text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20`,children:[(0,Q.jsx)(Si,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Remove`})]}):null]})]})}function vx({onFork:e,onMergeWith:t,onRename:n,onDelete:r,children:i}){return(0,Q.jsxs)(cx,{children:[(0,Q.jsx)(lx,{asChild:!0,children:i}),(0,Q.jsxs)(dx,{uiId:gx,children:[e?(0,Q.jsxs)(fx,{onSelect:t=>{t.stopPropagation(),e()},children:[(0,Q.jsx)(Nr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Fork`})]}):null,t?(0,Q.jsxs)(fx,{onSelect:e=>{e.stopPropagation(),t()},children:[(0,Q.jsx)(Xr,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Merge with`})]}):null,(0,Q.jsxs)(fx,{onSelect:e=>{e.stopPropagation(),n()},children:[(0,Q.jsx)(ii,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Rename`})]}),(0,Q.jsxs)(fx,{onSelect:e=>{e.stopPropagation(),r()},className:`text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20`,children:[(0,Q.jsx)(Si,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Delete`})]})]})]})}function yx(e){let t=(0,j.useRef)(e);return(0,j.useLayoutEffect)(()=>{t.current=e}),(0,j.useCallback)((...e)=>t.current(...e),[])}var bx=new Set([`starting`,`running`]),xx=m({id:`sidebar.chat-row`,c3ComponentId:`c3-113`,c3ComponentLabel:`sidebar`}),Sx={claude:`Claude`,codex:`Codex`,"claude-pty":`Claude (PTY)`};function Cx(e,t){let n=y(e.chat.chatId),r=y(t.chat.chatId),i=e.activeChatId===n,a=t.activeChatId===r;return e.nowMs===t.nowMs&&i===a&&e.chat._id===t.chat._id&&e.chat._creationTime===t.chat._creationTime&&e.chat.chatId===t.chat.chatId&&e.chat.title===t.chat.title&&e.chat.status===t.chat.status&&e.chat.unread===t.chat.unread&&e.chat.localPath===t.chat.localPath&&e.chat.provider===t.chat.provider&&e.chat.model===t.chat.model&&e.chat.lastMessageAt===t.chat.lastMessageAt&&e.chat.hasAutomation===t.chat.hasAutomation}function wx({chat:e,activeChatId:t,nowMs:n,onSelectChat:r,onForkChat:i,onMergeWithChat:a,onDeleteChat:o,onRenameChat:s}){let l=y(e.chatId),u=t===l,d=T_(e.lastMessageAt,n),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(e.title),g=(0,j.useRef)(null),_=e.provider?M_[e.provider]:null,v=e.provider?Sx[e.provider]:null,x=typeof e.model==`string`&&e.model.trim()?e.model.trim():null,S=yx(()=>{f||r(e.chatId)}),C=yx(()=>{o(e.chatId)}),w=yx(t=>{s(e.chatId,t)}),T=yx(()=>{i?.(e.chatId)}),E=yx(()=>{a?.(e.chatId)});(0,j.useEffect)(()=>{f&&(g.current?.focus(),g.current?.select())},[f]);function D(){let t=m.trim();p(!1),t&&t!==e.title?w(t):h(e.title)}function O(){h(e.title),p(!0)}return(0,Q.jsx)(vx,{onFork:T,onMergeWith:E,onRename:O,onDelete:C,children:(0,Q.jsxs)(`div`,{"data-chat-id":l,...c(xx),className:b(`group flex min-h-8 items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border hover:bg-muted/20 active:scale-[0.985] transition-all`,u?`bg-primary/[0.07] hover:bg-primary/[0.1] border-primary/20 dark:bg-primary/[0.12] dark:hover:bg-primary/[0.16] dark:border-primary/15`:`border-border/0 hover:border-border dark:hover:border-slate-400/10`),onClick:S,children:[bx.has(e.status)?(0,Q.jsx)(Gr,{className:`size-3.5 flex-shrink-0 animate-spin text-muted-foreground`}):e.status===`waiting_for_user`?(0,Q.jsx)(`div`,{className:`relative `,children:(0,Q.jsxs)(`div`,{className:` rounded-full z-0 size-3.5 flex items-center justify-center `,children:[(0,Q.jsx)(`div`,{className:`absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping`}),(0,Q.jsx)(`div`,{className:` rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50`})]})}):e.status===`awaiting_agents`?(0,Q.jsx)(`div`,{className:`relative `,children:(0,Q.jsxs)(`div`,{className:` rounded-full z-0 size-3.5 flex items-center justify-center `,children:[(0,Q.jsx)(`div`,{className:`absolute rounded-full z-0 size-2.5 bg-blue-500/80 animate-ping`}),(0,Q.jsx)(`div`,{className:` rounded-full z-0 size-2.5 bg-blue-500 ring-2 ring-muted/20 dark:ring-muted/50`})]})}):e.unread?(0,Q.jsx)(`div`,{className:`relative`,children:(0,Q.jsxs)(`div`,{className:`rounded-full z-0 size-3.5 flex items-center justify-center`,children:[(0,Q.jsx)(`div`,{className:`absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping`}),(0,Q.jsx)(`div`,{className:`rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50`})]})}):null,f?(0,Q.jsx)(ml,{ref:g,size:`sm`,className:`flex-1 translate-y-[-0.5px]`,value:m,onChange:e=>h(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),D()):t.key===`Escape`&&(t.preventDefault(),h(e.title),p(!1))},onBlur:D,onClick:e=>e.stopPropagation()}):(0,Q.jsx)(`span`,{className:b(`text-sm truncate flex-1 translate-y-[-0.5px]`,u&&`font-medium`),onDoubleClick:e=>{e.stopPropagation(),O()},children:e.status!==`idle`&&e.status!==`waiting_for_user`&&e.status!==`awaiting_agents`?(0,Q.jsx)(y_,{animate:e.status===`running`,shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),(0,Q.jsxs)(`div`,{className:`mr-[2px] flex shrink-0 items-center gap-0.5`,children:[x?(0,Q.jsx)(`span`,{className:b(`max-w-24 truncate rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground/70 transition-colors`,u?`bg-primary/[0.08] text-foreground/70 dark:bg-primary/[0.14]`:`bg-muted/60 group-hover:bg-muted group-hover:text-muted-foreground`),title:x,"aria-label":x,children:x}):null,_&&v?(0,Q.jsx)(`span`,{className:b(`flex h-7 w-4 items-center justify-center text-muted-foreground/55 transition-colors`,u?`text-foreground/60`:`group-hover:text-muted-foreground/80`),title:v,"aria-label":v,children:(0,Q.jsx)(_,{className:`h-2.5 w-2.5`})}):null,d?(0,Q.jsx)(`span`,{className:`hidden md:flex h-7 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50`,children:d}):null]})]})})}var Tx=(0,j.memo)(wx,Cx);function Ex({onCreate:e}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Workspaces`}),(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`h-5.5 w-5.5 !rounded`,onClick:e,children:(0,Q.jsx)(si,{className:`size-3.5 text-slate-500 dark:text-slate-400`})})}),(0,Q.jsx)(tl,{side:`right`,sideOffset:4,children:`New workspace`})]})]})}function Dx({workspaces:e,onSelect:t,onCreate:n,activeWorkspaceId:r,onRename:i,onTogglePin:a,onReorder:o,onDelete:s}){let[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(``);function f(e){l(e.id),d(e.name)}function p(){if(c){let e=u.trim();e&&i?.(c,e)}l(null)}function m(t,n){let r=t+n;if(r<0||r>=e.length)return;let i=e.map(e=>e.id);[i[t],i[r]]=[i[r],i[t]],o?.(i)}return e.length===0?(0,Q.jsx)(`div`,{className:`p-[10px]`,children:(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsx)(Ex,{onCreate:n})})}):(0,Q.jsxs)(`div`,{className:`mb-1`,children:[(0,Q.jsx)(`div`,{className:`sticky top-0 bg-background dark:bg-card z-10 p-[10px] flex items-center justify-between`,children:(0,Q.jsx)(Ex,{onCreate:n})}),(0,Q.jsx)(`div`,{className:`space-y-[2px]`,children:e.map((n,h)=>(0,Q.jsxs)(cx,{children:[(0,Q.jsx)(lx,{asChild:!0,children:c===n.id?(0,Q.jsxs)(`div`,{className:b(`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg text-left text-sm`,r===n.id&&`bg-muted`),children:[(0,Q.jsx)(tr,{className:`size-3.5 shrink-0 text-slate-400 dark:text-slate-500`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),onBlur:p,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),l(null))},className:`min-w-0 flex-1 bg-transparent text-foreground outline-none border-b border-border`})]}):(0,Q.jsxs)(`button`,{className:b(`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg text-left text-sm transition-colors`,`hover:bg-muted/50`,r===n.id&&`bg-muted`),onClick:()=>t(n.id),children:[n.pinned?(0,Q.jsx)(oi,{className:`size-3.5 shrink-0 text-slate-400 dark:text-slate-500`}):(0,Q.jsx)(tr,{className:`size-3.5 shrink-0 text-slate-400 dark:text-slate-500`}),(0,Q.jsx)(`span`,{className:`truncate text-foreground`,children:n.name})]})}),(0,Q.jsxs)(dx,{children:[i?(0,Q.jsxs)(fx,{onSelect:e=>{e.preventDefault(),f(n)},children:[(0,Q.jsx)(ii,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Rename`})]}):null,a?(0,Q.jsxs)(fx,{onSelect:()=>a(n.id,!n.pinned),children:[n.pinned?(0,Q.jsx)(ai,{className:`h-4 w-4`}):(0,Q.jsx)(oi,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:n.pinned?`Unpin`:`Pin`})]}):null,o?(0,Q.jsxs)(fx,{disabled:h===0,onSelect:()=>m(h,-1),children:[(0,Q.jsx)(Zn,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Move up`})]}):null,o?(0,Q.jsxs)(fx,{disabled:h===e.length-1,onSelect:()=>m(h,1),children:[(0,Q.jsx)(qn,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Move down`})]}):null,s?(0,Q.jsxs)(fx,{onSelect:()=>s(n.id),className:`text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20`,children:[(0,Q.jsx)(Si,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Delete`})]}):null]})]},n.id))})]})}function Ox(e){return e.reduce((e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=e.at(-1),r=t[0];return n&&n.toLowerCase()===r.toLowerCase()?`${e}${t.slice(1)}`:`${e}${t}`},``)}function kx(e){let t=e.literal??Ox(e.parts??[]);return e.frame.replace(`%`,t)}function Ax(e){let t=2166136261;for(let n of e)t^=n.charCodeAt(0),t=Math.imul(t,16777619);return t>>>0}function jx(e,t){return e[Ax(t)%e.length]}function Mx(e,t,n){let r=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return e[(Ax(t)+r)%e.length]}var Nx=[{frame:`What are we %?`,parts:[`tink`,`ar`,`ing`]},{frame:`What are we % up?`,parts:[`scrom`,`m`,`ing`]},{frame:`What are we % today?`,parts:[`sketch`,`l`,`ing`]},{frame:`What are we % together?`,parts:[`patch`,`l`,`ing`]},{frame:`What are we %?`,parts:[`mash`,`craft`,`ing`]},{frame:`What are we % on?`,parts:[`spark`,`er`,`ing`]},{frame:`What are we % into shape?`,parts:[`rigg`,`l`,`ing`]},{frame:`What are we % loose?`,parts:[`puzz`,`l`,`ing`]},{frame:`What are we % together?`,parts:[`clack`,`l`,`ing`]},{frame:`What are we % here?`,parts:[`sprout`,`ing`]}],Px=[{frame:`%...`,parts:[`tink`,`ar`,`ing`]},{frame:`% something up...`,parts:[`scrom`,`m`,`ing`]},{frame:`% time...`,parts:[`sketch`,`l`,`ing`]},{frame:`% a plan...`,parts:[`patch`,`l`,`e`]},{frame:`% a prompt...`,parts:[`mash`,`craft`]},{frame:`% up a weird little build...`,parts:[`spark`]},{frame:`% something into place...`,parts:[`rigg`,`l`,`e`]},{frame:`% a thought into motion...`,parts:[`nudg`,`e`]},{frame:`% a scrappy idea...`,parts:[`spin`]},{frame:`%`,literal:`Make a tiny glorious mess...`}],Fx=Nx.map(kx),Ix=Px.map(kx);function Lx(e){return jx(Fx,`${e??`default`}:empty-state`)}function Rx(e){return jx(Ix,`${e??`default`}:composer-placeholder`)}function zx(e,t){return Mx(Ix,`${e??`default`}:composer-placeholder`,t)}function Bx(){return typeof window>`u`||typeof window.matchMedia!=`function`?null:window.matchMedia(`(display-mode: standalone)`)}function Vx(){let[e,t]=(0,j.useState)(()=>{if(typeof window>`u`)return!1;let e=navigator.standalone===!0,t=Bx()?.matches===!0;return e||t});return(0,j.useEffect)(()=>{let e=Bx();if(!e){t(navigator.standalone===!0);return}let n=e=>{t(e.matches||navigator.standalone===!0)};return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function Hx(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var Ux=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return Ux(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return Ux(t)(e)}}}},Wx=(e,t)=>(n,r,i)=>{let a={storage:Hx(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return Ux(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},Gx=10080*60*1e3,Kx=2e4;function qx(e,t=Date.now()){return e?Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{if(!n||typeof n.text!=`string`||typeof n.updatedAt!=`number`)return[];let r=n.text.trim();return!r||t-n.updatedAt>Gx?[]:[[e,{...n,text:r.length>Kx?r.slice(-Kx):r}]]})):{}}var Jx=w()(Wx((e,t)=>({drafts:{},queuedDrafts:{},setDraft:(t,n)=>e(e=>{if(!n){let{[t]:n,...r}=e.drafts;return{drafts:r}}return{drafts:{...e.drafts,[t]:n}}}),clearDraft:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),getDraft:e=>t().drafts[e]??``,setQueuedDraft:(t,n)=>e(e=>({queuedDrafts:qx({...e.queuedDrafts,[t]:n})})),clearQueuedDraft:t=>e(e=>{let{[t]:n,...r}=e.queuedDrafts;return{queuedDrafts:r}}),getQueuedDraft:e=>t().queuedDrafts[e]??null,syncQueuedDrafts:t=>e(()=>({queuedDrafts:qx(t)})),reconcileQueuedDrafts:t=>e(e=>({queuedDrafts:Object.fromEntries(Object.entries(e.queuedDrafts).filter(([e])=>t.includes(e)))}))}),{name:`chat-input-drafts`,merge:(e,t)=>{let n=e??{};return{...t,...n,queuedDrafts:qx(n.queuedDrafts)}}}));function Yx(e){return e===`gpt-5-codex`?`gpt-5.3-codex`:e??`gpt-5.4`}function Xx(e){return e===`claude`||e===`codex`||e===`claude-pty`?e:`last_used`}function Zx(e){let t=e?.modelOptions?.reasoningEffort,n=Ym(t)?t:Ym(e?.effort)?e.effort:Km.reasoningEffort,r=e?.model??`opus`,i=nh(r,e?.modelOptions?.contextWindow);return{model:r,modelOptions:{reasoningEffort:r!==`opus`&&n===`max`?`high`:n,contextWindow:i},planMode:!!e?.planMode}}function Qx(e){let t=e?.modelOptions?.reasoningEffort;return{model:Yx(e?.model),modelOptions:{reasoningEffort:Xm(t)?t:Xm(e?.effort)?e.effort:qm.reasoningEffort,fastMode:typeof e?.modelOptions?.fastMode==`boolean`?e.modelOptions.fastMode:qm.fastMode},planMode:!!e?.planMode}}function $x(e){let t=e?.modelOptions?.reasoningEffort,n=Ym(t)?t:Ym(e?.effort)?e.effort:Jm.reasoningEffort,r=e?.model??`opus`,i=nh(r,e?.modelOptions?.contextWindow);return{model:r,modelOptions:{reasoningEffort:r!==`opus`&&n===`max`?`high`:n,contextWindow:i},planMode:!!e?.planMode}}function eS(){return{claude:{model:`opus`,modelOptions:{...Km},planMode:!1},codex:{model:`gpt-5.4`,modelOptions:{...qm},planMode:!1},"claude-pty":{model:`opus`,modelOptions:{...Jm},planMode:!1}}}function tS(e){return{claude:Zx(e?.claude),codex:Qx(e?.codex),"claude-pty":$x(e?.[`claude-pty`])}}function nS(e,t){if(t===void 0){console.info(`[chat-preferences] ${e}`);return}console.info(`[chat-preferences] ${e}`,t)}function rS(e,t){if(e===`claude`){let e=t.claude;return{provider:`claude`,model:e.model,modelOptions:{...e.modelOptions},planMode:e.planMode}}if(e===`claude-pty`){let e=t[`claude-pty`];return{provider:`claude-pty`,model:e.model,modelOptions:{...e.modelOptions},planMode:e.planMode}}let n=t.codex;return{provider:`codex`,model:n.model,modelOptions:{...n.modelOptions},planMode:n.planMode}}function iS(e,t,n,r){if(e?.provider===`claude`){let t=Zx(e);return{provider:`claude`,model:t.model,modelOptions:t.modelOptions,planMode:t.planMode}}if(e?.provider===`codex`){let t=Qx(e);return{provider:`codex`,model:t.model,modelOptions:t.modelOptions,planMode:t.planMode}}if(e?.provider===`claude-pty`){let t=$x(e);return{provider:`claude-pty`,model:t.model,modelOptions:t.modelOptions,planMode:t.planMode}}if(n===`claude`){let e=Zx(r?.claude);return{provider:`claude`,model:e.model,modelOptions:e.modelOptions,planMode:e.planMode}}if(n===`codex`){let e=Qx(r?.codex);return{provider:`codex`,model:e.model,modelOptions:e.modelOptions,planMode:e.planMode}}return rS(`claude`,t)}function aS(e){let t=tS(e?.providerDefaults);return{defaultProvider:Xx(e?.defaultProvider),providerDefaults:t,composerState:iS(e?.composerState,t,e?.liveProvider,e?.livePreferences)}}var oS=w()(Wx(e=>({defaultProvider:`last_used`,providerDefaults:eS(),composerState:{provider:`claude`,model:`opus`,modelOptions:{...Km},planMode:!1},setDefaultProvider:t=>e({defaultProvider:t}),setProviderDefaultModel:(t,n)=>e(e=>({providerDefaults:{...e.providerDefaults,[t]:t===`claude`?Zx({...e.providerDefaults.claude,model:n}):Qx({...e.providerDefaults.codex,model:n})}})),setProviderDefaultModelOptions:(t,n)=>e(e=>({providerDefaults:{...e.providerDefaults,[t]:t===`claude`?Zx({...e.providerDefaults.claude,modelOptions:{...e.providerDefaults.claude.modelOptions,...n}}):Qx({...e.providerDefaults.codex,modelOptions:{...e.providerDefaults.codex.modelOptions,...n}})}})),setProviderDefaultPlanMode:(t,n)=>e(e=>({providerDefaults:{...e.providerDefaults,[t]:{...e.providerDefaults[t],planMode:n}}})),setComposerProvider:t=>e(e=>({composerState:{...e.composerState,provider:t}})),setComposerModel:t=>e(e=>e.composerState.provider===`claude`?{composerState:{provider:`claude`,model:t,modelOptions:Zx({...e.composerState,model:t}).modelOptions,planMode:e.composerState.planMode}}:e.composerState.provider===`claude-pty`?{composerState:{provider:`claude-pty`,model:t,modelOptions:$x({...e.composerState,model:t}).modelOptions,planMode:e.composerState.planMode}}:{composerState:{provider:`codex`,model:t,modelOptions:Qx({...e.composerState,model:t}).modelOptions,planMode:e.composerState.planMode}}),setComposerModelOptions:t=>e(e=>e.composerState.provider===`claude`?{composerState:{provider:`claude`,model:e.composerState.model,modelOptions:Zx({...e.composerState,modelOptions:{...e.composerState.modelOptions,...t}}).modelOptions,planMode:e.composerState.planMode}}:e.composerState.provider===`claude-pty`?{composerState:{provider:`claude-pty`,model:e.composerState.model,modelOptions:$x({...e.composerState,modelOptions:{...e.composerState.modelOptions,...t}}).modelOptions,planMode:e.composerState.planMode}}:{composerState:{provider:`codex`,model:e.composerState.model,modelOptions:Qx({...e.composerState,modelOptions:{...e.composerState.modelOptions,...t}}).modelOptions,planMode:e.composerState.planMode}}),setComposerPlanMode:t=>e(e=>({composerState:{...e.composerState,planMode:t}})),resetComposerFromProvider:t=>e(e=>({composerState:rS(t,e.providerDefaults)})),initializeComposerForNewChat:()=>e(e=>{if(e.defaultProvider===`last_used`)return nS(`initializeComposerForNewChat:last_used`,{defaultProvider:e.defaultProvider,composerState:e.composerState,providerDefaults:e.providerDefaults}),{composerState:{...e.composerState}};let t=rS(e.defaultProvider,e.providerDefaults);return nS(`initializeComposerForNewChat:explicit_default`,{defaultProvider:e.defaultProvider,composerState:t,providerDefaults:e.providerDefaults}),{composerState:t}})}),{name:`chat-preferences`,version:4,migrate:e=>aS(e)})),sS=w()(Wx(e=>({usageCounts:{},ribbonVisible:!0,recordUsage:t=>{t.length!==0&&e(e=>{let n={...e.usageCounts};for(let e of t)n[e]=(n[e]??0)+1;return{usageCounts:n}})},toggleRibbon:()=>e(e=>({ribbonVisible:!e.ribbonVisible}))}),{name:`skill-composition`})),cS=/^\[Skills: (\/[^\]]+)\](?:\n\n?)?/;function lS(e){let t=e.match(cS);return t?{skills:t[1].split(`, `).map(e=>e.replace(/^\//,``)),content:e.slice(t[0].length)}:{skills:null,content:e}}function uS(e,t){return[...e].sort((e,n)=>(t[n]??0)-(t[e]??0))}function dS(e){return e===`codex`?`$`:`/`}function fS(e,t){return`${dS(t)}${e}`}function pS(e,t,n,r){let i=e.substring(0,t),a=e.substring(n),o=i.length>0&&!i.endsWith(` `)&&!i.endsWith(`
|
|
63
|
+
`),s=a.length===0||!a.startsWith(` `)&&!a.startsWith(`
|
|
64
|
+
`),c=o?` `:``,l=s?` `:``;return{value:i+c+r+l+a,cursorPosition:t+c.length+r.length+l.length}}var mS={ribbon:m({id:`chat.composer.skills.ribbon`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),toggle:m({id:s(`chat.composer.skills.toggle`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),skillButton:m({id:s(`chat.composer.skills.insert`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`})},hS=(0,j.memo)(function({skills:e,provider:t,visible:n,onToggle:r,onInsert:i,showToggle:a=!0,showContent:o=!0,className:s,contentClassName:l}){let u=sS(e=>e.usageCounts),d=(0,j.useMemo)(()=>uS(e,u),[e,u]);return e.length===0||!a&&!o?null:(0,Q.jsxs)(`div`,{className:b(`flex items-center min-h-[32px]`,s),...c(mS.ribbon),children:[a?(0,Q.jsxs)(`button`,{type:`button`,onClick:r,className:b(`shrink-0 flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded-md transition-colors`,`hover:bg-muted/60`,n?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`),...c(mS.toggle),children:[(0,Q.jsx)(hi,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:`Skills`}),(0,Q.jsx)(cr,{className:b(`h-3 w-3 transition-transform duration-200`,n&&`rotate-90`)})]}):null,n&&o?(0,Q.jsx)(`div`,{className:b(`flex-1 flex items-center gap-1 pr-2 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,l),children:d.map(e=>(0,Q.jsx)(S,{variant:`secondary`,size:`sm`,onClick:()=>i(e),...c(mS.skillButton),className:b(`shrink-0 font-mono`),children:fS(e,t)},e))}):null]})}),gS=1200,_S=4e3;function vS(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.id!==i.id||r.label!==i.label||r.supportsPlanMode!==i.supportsPlanMode||r.models.length!==i.models.length)return!1;for(let e=0;e<r.models.length;e+=1){let t=r.models[e],n=i.models[e];if(t.id!==n.id||t.label!==n.label||t.contextWindowOptions?.join(`,`)!==n.contextWindowOptions?.join(`,`))return!1}}return!0}function yS(e,t){let n=e??[],r=t??[];if(n.length!==r.length)return!1;for(let e=0;e<n.length;e+=1)if(n[e]!==r[e])return!1;return!0}function bS(e,t){return e.queuedText===t.queuedText&&e.disabled===t.disabled&&e.canCancel===t.canCancel&&e.chatId===t.chatId&&e.connectionStatus===t.connectionStatus&&e.activeProvider===t.activeProvider&&e.runtimeModel===t.runtimeModel&&vS(e.availableProviders,t.availableProviders)&&yS(e.availableSkills,t.availableSkills)}function xS(e,t){return e.provider===`claude`?{...e,model:t,modelOptions:{...e.modelOptions,contextWindow:nh(t,e.modelOptions.contextWindow)}}:{...e,model:t}}function SS(e,t){if(t===void 0){console.info(`[ChatInput] ${e}`);return}console.info(`[ChatInput] ${e}`,t)}function CS(e,t,n,r){return e===`claude`?t.provider===`claude`?{provider:`claude`,model:r??t.model,modelOptions:{...t.modelOptions},planMode:t.planMode}:{provider:`claude`,model:r??n.claude.model,modelOptions:{...n.claude.modelOptions},planMode:n.claude.planMode}:t.provider===`codex`?{provider:`codex`,model:r??t.model,modelOptions:{...t.modelOptions},planMode:t.planMode}:{provider:`codex`,model:r??n.codex.model,modelOptions:{...n.codex.modelOptions},planMode:n.codex.planMode}}function wS(e){if(!e.providerLocked)return{composerPlanMode:e.planMode,lockedComposerState:e.lockedComposerState};let t=e.lockedComposerState??CS(e.selectedProvider,e.composerState,e.providerDefaults);return{composerPlanMode:e.composerState.planMode,lockedComposerState:{...t,planMode:e.planMode}}}function TS(e){return e.trim().length>0}function ES(e){return e}function DS(e){return e.trim().length>0}function OS(e){return e.disabled||!DS(e.value)}function kS(e){return e.disabled||e.reconnectVisualState!==`idle`}function AS(e){return e.key!==`Enter`||e.shiftKey||!e.canCancel?!1:e.metaKey||e.ctrlKey||!e.isTouchDevice}function jS(e,t){return e===`pointerdown`?(t.current=!0,!0):t.current?(t.current=!1,!1):!0}function MS(e,t){return DS(e)?null:DS(t)?t:null}function NS(e){return e===`queued`||e===`sent`}function PS(e,t){return`${e??`__new__`}:${t??`unlocked`}`}function FS(e){let t=e.activeProvider!==null,n=e.activeProvider??e.composerState.provider,r=e.activeProvider?CS(e.activeProvider,e.composerState,e.providerDefaults,e.runtimeModel):null;return{providerLocked:t,selectedProvider:n,lockedBaseState:r,providerPrefs:t?e.lockedOverrides??r??e.composerState:e.composerState,showPlanMode:(Qm.find(e=>e.id===n)??Qm[0])?.supportsPlanMode??!1}}var IS=(0,j.memo)((0,j.forwardRef)(function({activeProvider:e,runtimeModel:t,composerState:n,providerDefaults:r,availableProviders:i,availableSkills:a,ribbonVisible:o,toggleRibbon:s,setComposerModel:c,setComposerModelOptions:l,setComposerPlanMode:u,resetComposerFromProvider:d},f){let[p,m]=(0,j.useState)(null),h=FS({activeProvider:e,composerState:n,providerDefaults:r,lockedOverrides:p,runtimeModel:t}),g=(i.find(e=>e.id===h.selectedProvider)??i[0])?.supportsPlanMode??!1,_=(0,j.useCallback)(e=>{h.providerLocked||d(e)},[h.providerLocked,d]),v=(0,j.useCallback)((e,t)=>{if(h.providerLocked){m(e=>xS(e??h.lockedBaseState??CS(h.selectedProvider,n,r),t));return}c(t)},[h.providerLocked,h.lockedBaseState,h.selectedProvider,n,r,c]),y=(0,j.useCallback)(e=>{let t=(e,t)=>{if(h.providerLocked){m(t=>e(t??h.lockedBaseState??CS(h.selectedProvider,n,r)));return}t()};switch(e.type){case`claudeReasoningEffort`:case`codexReasoningEffort`:t(t=>({...t,modelOptions:{...t.modelOptions,reasoningEffort:e.effort}}),()=>l({reasoningEffort:e.effort}));break;case`contextWindow`:t(t=>t.provider===`claude`?xS({...t,modelOptions:{...t.modelOptions,contextWindow:e.contextWindow}},t.model):t,()=>l({contextWindow:e.contextWindow}));break;case`fastMode`:t(t=>t.provider===`codex`?{...t,modelOptions:{...t.modelOptions,fastMode:e.fastMode}}:t,()=>l({fastMode:e.fastMode}));break}},[h.providerLocked,h.lockedBaseState,h.selectedProvider,n,r,l]),b=(0,j.useCallback)(e=>{let t=wS({providerLocked:h.providerLocked,planMode:e,selectedProvider:h.selectedProvider,composerState:n,providerDefaults:r,lockedComposerState:p});if(h.providerLocked){m(t.lockedComposerState);return}t.composerPlanMode!==n.planMode&&u(t.composerPlanMode)},[h.providerLocked,h.selectedProvider,n,r,p,u]);(0,j.useImperativeHandle)(f,()=>({getSnapshot:()=>({selectedProvider:h.selectedProvider,providerPrefs:h.providerPrefs,showPlanMode:g}),setPlanMode:b}),[h.selectedProvider,h.providerPrefs,g,b]);let x=(0,j.useCallback)(()=>{let e=h.selectedProvider,t=Qm.find(t=>t.id===e);if(!t)return;let n=t.models;v(e,n[(n.findIndex(e=>e.id===h.providerPrefs.model)+1)%n.length].id)},[h.selectedProvider,h.providerPrefs.model,v]);return(0,Q.jsx)(hv,{availableProviders:i,selectedProvider:h.selectedProvider,providerLocked:h.providerLocked,model:h.providerPrefs.model,modelOptions:h.providerPrefs.modelOptions,onProviderChange:_,onModelChange:v,onModelDoubleTap:x,onModelOptionChange:y,planMode:h.providerPrefs.planMode,onPlanModeChange:b,includePlanMode:g,showSkillsToggle:a.length>0,skillsVisible:o,onSkillsToggle:s,className:`max-w-[840px] mx-auto`})})),LS=(0,j.forwardRef)(function({onSubmit:e,onCancel:t,queuedText:n=``,onClearQueuedText:r,onRestoreQueuedText:i,disabled:a,canCancel:o,chatId:l,connectionStatus:u,activeProvider:d,runtimeModel:f,availableProviders:p,availableSkills:h=[]},g){let _=Jx(e=>e.getDraft),v=Jx(e=>e.setDraft),y=Jx(e=>e.clearDraft),x=oS(e=>e.composerState),C=oS(e=>e.providerDefaults),w=oS(e=>e.setComposerModel),T=oS(e=>e.setComposerModelOptions),E=oS(e=>e.setComposerPlanMode),D=oS(e=>e.resetComposerFromProvider),O=sS(e=>e.ribbonVisible),k=sS(e=>e.toggleRibbon),A=sS(e=>e.recordUsage),M=l?_(l):``,N=(0,j.useRef)(M),[P,F]=(0,j.useState)(()=>DS(M)),[I,L]=(0,j.useState)(0),R=(0,j.useRef)(null),z=(0,j.useRef)(null),B=Vx(),V=k_(),H=typeof window<`u`&&(`ontouchstart`in window||navigator.maxTouchPoints>0),U=o?zx(l,I):Rx(l),W=PS(l,d),G=s(`chat.composer`,`area`),K=s(`chat.composer.submit`,`action`),q=s(`chat.composer.cancel`,`action`),J=s(`chat.composer.queue`,`action`),ee=m({id:G,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),Y=m({id:K,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),te=m({id:q,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),ne=m({id:J,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),re=m({id:s(`chat.composer.connection`,`section`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),[ie,ae]=(0,j.useState)(()=>u===`connected`?`idle`:`reconnecting`),oe=(0,j.useRef)(u===`connected`),se=(0,j.useRef)(!1);function ce(){return z.current?.getSnapshot()??FS({activeProvider:d,composerState:x,providerDefaults:C,lockedOverrides:null,runtimeModel:f})}function le(e){z.current?.setPlanMode(e)}let ue=(0,j.useCallback)(()=>{let e=R.current;if(e){if(e.value.length===0){e.style.height=``;return}e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}},[]),de=(0,j.useCallback)(e=>{N.current=e;let t=DS(e);F(e=>e===t?e:t),l&&v(l,e)},[l,v]),fe=(0,j.useCallback)(e=>{let t=R.current;t&&t.value!==e&&(t.value=e),de(e),ue()},[ue,de]),pe=(0,j.useCallback)(e=>{if(R.current=e,g){if(typeof g==`function`){g(e);return}g.current=e}},[g]);(0,j.useEffect)(()=>(window.addEventListener(`resize`,ue),()=>window.removeEventListener(`resize`,ue)),[ue]),(0,j.useEffect)(()=>{H||R.current?.focus()},[l,H]),(0,j.useEffect)(()=>{if(!o){L(0);return}L(0);let e=window.setInterval(()=>{L(e=>e+1)},_S);return()=>{window.clearInterval(e)}},[o,l]),(0,j.useEffect)(()=>{if(u!==`connected`){ae(`reconnecting`);return}if(!oe.current){oe.current=!0,ae(`idle`);return}if(ie!==`reconnecting`){ae(`idle`);return}ae(`reconnected`);let e=window.setTimeout(()=>{ae(`idle`)},gS);return()=>{window.clearTimeout(e)}},[u,ie]);let me=d??x.provider;function he(e){let t=R.current;if(!t)return;let n=fS(e,me),{value:r,cursorPosition:i}=pS(N.current,t.selectionStart,t.selectionEnd,n);fe(r),A([e]),requestAnimationFrame(()=>{t.focus(),t.selectionStart=i,t.selectionEnd=i})}async function ge(){let t=N.current;if(!DS(t))return;let n=ce(),r;r=n.providerPrefs.provider===`claude`?{claude:{...n.providerPrefs.modelOptions}}:n.providerPrefs.provider===`claude-pty`?{"claude-pty":{...n.providerPrefs.modelOptions}}:{codex:{...n.providerPrefs.modelOptions}};let i={provider:n.selectedProvider,model:n.providerPrefs.model,modelOptions:r,planMode:n.showPlanMode?n.providerPrefs.planMode:!1};SS(`submit settings`,{chatId:l??null,activeProvider:d,composerProvider:n.providerPrefs.provider,submitOptions:i}),fe(``);try{NS(await e(t,i))&&l&&y(l)}catch(e){console.error(`[ChatInput] Submit failed:`,e),fe(t)}}function _e(){let e=N.current,t=i?.(),n=e||t;n&&(fe(n),requestAnimationFrame(()=>{R.current?.focus()}))}function ve(){r?.(),l&&y(l)}function ye(){OS({disabled:a,value:N.current})||ge()}function be(e){if(e.key===`ArrowUp`&&MS(N.current,n)){e.preventDefault(),_e();return}if(e.key===`Tab`&&!e.shiftKey){e.preventDefault(),tg(R.current,document);return}if(e.key===`Tab`&&e.shiftKey){let t=ce();if(t.showPlanMode){e.preventDefault(),le(!t.providerPrefs.planMode);return}}if(e.key===`Escape`&&o){e.preventDefault(),t?.();return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!o){e.preventDefault(),ge();return}let r=`ontouchstart`in window||navigator.maxTouchPoints>0;if(AS({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,canCancel:o,isTouchDevice:r})){e.preventDefault(),ye();return}e.key===`Enter`&&!e.shiftKey&&!o&&!r&&(e.preventDefault(),ge())}let X=ES(!!o),xe=kS({disabled:a||u!==`connected`,reconnectVisualState:ie}),Se=ie!==`idle`||u!==`connected`,Ce=xe||!P,we=xe||!P,Te=ie===`reconnected`,Ee=(0,Q.jsx)(IS,{ref:z,activeProvider:d,runtimeModel:f,composerState:x,providerDefaults:C,availableProviders:p,availableSkills:h,ribbonVisible:O,toggleRibbon:k,setComposerModel:w,setComposerModelOptions:T,setComposerPlanMode:E,resetComposerFromProvider:D},W);return(0,Q.jsxs)(`div`,{children:[TS(n)?(0,Q.jsx)(`div`,{className:b(`px-3 pb-2`,B&&`px-5`),children:(0,Q.jsxs)(`div`,{className:`max-w-[840px] mx-auto rounded-[26px] border border-dashed border-amber-400/50 bg-amber-50/80 px-4 py-3 text-sm whitespace-pre-wrap shadow-sm dark:border-amber-300/30 dark:bg-amber-500/10`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium uppercase tracking-[0.18em] text-amber-700 dark:text-amber-200`,children:[(0,Q.jsx)(hr,{className:`h-3.5 w-3.5`}),`Queued`]}),(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`sm`,onClick:ve,children:`Clear`})]}),(0,Q.jsx)(`div`,{children:n})]})}):null,h.length>0&&O?(0,Q.jsx)(`div`,{className:b(`px-3`,V&&`pb-2`,B&&`px-5`),children:(0,Q.jsx)(`div`,{className:`max-w-[840px] mx-auto`,children:(0,Q.jsx)(hS,{skills:h,provider:me,visible:O,onToggle:k,onInsert:he,showToggle:!1,contentClassName:`pr-0`})})}):null,(0,Q.jsx)(`div`,{className:b(`px-3 pt-0`,V&&`pb-3`,B&&`px-5`),children:(0,Q.jsx)(`div`,{...c(ee),className:b(`max-w-[840px] mx-auto rounded-[29px] border pr-1.5 dark:bg-card/40 backdrop-blur-lg transition-[border-color,box-shadow] duration-300`,ie===`reconnecting`&&`border-amber-400/30`,ie===`reconnected`&&`border-emerald-400/30`,ie===`idle`&&!o&&`border-border`,ie===`idle`&&o&&`animate-composer-running`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Te?(0,Q.jsx)(`div`,{className:`flex justify-end pt-1.5 pr-3`,children:(0,Q.jsx)(`div`,{...c(re),className:`inline-flex items-center transition-opacity duration-300 text-emerald-600 dark:text-emerald-300/60 opacity-60`,children:(0,Q.jsx)(ar,{className:`h-3 w-3`})})}):null,(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2`,children:[V?(0,Q.jsx)(`div`,{className:`mb-1 shrink-0`,children:Ee}):null,(0,Q.jsx)(gl,{ref:pe,placeholder:U,defaultValue:M,autoFocus:!H,[Yh]:``,rows:1,onChange:e=>{de(e.target.value),ue()},onKeyDown:be,disabled:a,className:b(`tinkaria-composer-placeholder min-w-0 flex-1 text-base p-3 md:p-4 pl-4.5 md:pl-6 resize-none max-h-[200px] outline-none bg-transparent border-0 shadow-none`,o&&`tinkaria-composer-placeholder-rotating`)}),X?(0,Q.jsxs)(`div`,{className:`flex-shrink-0 mb-1 -mr-0.5 flex items-center gap-1.5 md:gap-2 md:mr-0 md:mb-1.5`,children:[(0,Q.jsx)(S,{...c(te),type:`button`,"aria-label":`Stop`,onPointerDown:e=>{e.preventDefault(),jS(`pointerdown`,se)&&t?.()},onClick:e=>{e.preventDefault(),jS(`click`,se)&&t?.()},disabled:Se,size:`icon`,className:b(`flex-shrink-0 rounded-full h-10 w-10 md:h-11 md:w-11 touch-manipulation transition-colors`,`bg-slate-600 text-white dark:bg-white dark:text-slate-900`,ie===`reconnecting`&&`disabled:opacity-60`),children:(0,Q.jsx)(`div`,{className:`w-3 h-3 md:w-4 md:h-4 rounded-xs bg-current`})}),(0,Q.jsx)(S,{...c(ne),type:`button`,"aria-label":`Queue`,title:`Queue`,onPointerDown:e=>{e.preventDefault(),ye()},disabled:Ce,size:`icon`,className:b(`flex-shrink-0 h-10 w-10 rounded-full md:h-11 md:w-11 transition-colors`,ie===`reconnecting`&&`disabled:opacity-60`),children:(0,Q.jsx)(hr,{className:`h-4 w-4`})})]}):(0,Q.jsx)(S,{...c(Y),type:`button`,onPointerDown:e=>{e.preventDefault(),!we&&DS(N.current)&&ge()},disabled:we,size:`icon`,className:b(`flex-shrink-0 rounded-full h-10 w-10 md:h-11 md:w-11 mb-1 -mr-0.5 md:mr-0 md:mb-1.5 touch-manipulation transition-colors`,`bg-slate-600 text-white dark:bg-white dark:text-slate-900 disabled:bg-white/60 disabled:text-slate-700`,ie===`reconnecting`&&`disabled:opacity-60`),children:ie===`reconnecting`?(0,Q.jsx)(Gr,{className:`h-5 w-5 animate-spin md:h-6 md:w-6`}):ie===`reconnected`?(0,Q.jsx)(ar,{className:`h-5 w-5 md:h-6 md:w-6`}):(0,Q.jsx)(Zn,{className:`h-5 w-5 md:h-6 md:w-6`})})]})]})})}),V?null:(0,Q.jsxs)(`div`,{className:b(`overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden py-3 flex flex-row`,B&&`p-5 pt-3`),children:[(0,Q.jsx)(`div`,{className:`min-w-3`}),Ee,(0,Q.jsx)(`div`,{className:`min-w-3`})]})]})}),RS=(0,j.memo)(LS,bS);function zS(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
65
|
+
font-size: .6rem;
|
|
66
|
+
font-weight: bold;
|
|
67
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function BS(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var VS=(e,t)=>Math.abs(e-t)<1.01,HS=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},US=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},WS=e=>e,GS=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},KS=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(US(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(US(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},qS={passive:!0},JS=typeof window>`u`?!0:`onscrollend`in window,YS=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&JS?()=>void 0:HS(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,qS);let l=e.options.useScrollendEvent&&JS;return l&&n.addEventListener(`scrollend`,c,qS),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},XS=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ZS=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},QS=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:WS,rangeExtractor:GS,onChange:()=>{},measureElement:XS,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=zS(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=zS(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=zS(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=zS(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?eC({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=zS(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=zS(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return BS(t[$S(0,t.length-1,e=>BS(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&VS(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},$S=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function eC({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=$S(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var tC=typeof document<`u`?j.useLayoutEffect:j.useEffect;function nC({useFlushSync:e=!0,...t}){let n=j.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Ii.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=j.useState(()=>new QS(r));return i.setOptions(r),tC(()=>i._didMount(),[]),tC(()=>i._willUpdate()),i}function rC(e){return nC({observeElementRect:KS,observeElementOffset:YS,scrollToFn:ZS,...e})}var iC=`BN.BN.BN.BN.BN.BN.BN.BN.BN.S.B.S.WS.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.B.B.B.S.WS.ON.ON.ET.ET.ET.ON.ON.ON.ON.ON.ON.CS.ON.CS.ON.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.ON.ON.ON.ON.ON.ON.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.ON.ON.ON.ON.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.ON.ON.ON.BN.BN.BN.BN.BN.BN.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.CS.ON.ET.ET.ET.ET.ON.ON.ON.ON.L.ON.ON.ON.ON.ON.ET.ET.EN.EN.ON.L.ON.ON.ON.EN.L.ON.ON.ON.ON.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.L.L.L.L.L.L.L.L`.split(`.`),aC=`AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.CS.AL.ON.ON.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.AL.AL.AL.AL.AL.AN.AN.AN.AN.AN.AN.AN.AN.AN.AN.ET.AN.AN.AL.AL.AL.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.ON.NSM.NSM.NSM.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL`.split(`.`);function oC(e){return e<=255?iC[e]:1424<=e&&e<=1524?`R`:1536<=e&&e<=1791?aC[e&255]:1792<=e&&e<=2220?`AL`:`L`}function sC(e){let t=e.length;if(t===0)return null;let n=Array(t),r=0;for(let i=0;i<t;i++){let t=oC(e.charCodeAt(i));(t===`R`||t===`AL`||t===`AN`)&&r++,n[i]=t}if(r===0)return null;let i=t/r<.3?0:1,a=new Int8Array(t);for(let e=0;e<t;e++)a[e]=i;let o=i&1?`R`:`L`,s=o,c=s;for(let e=0;e<t;e++)n[e]===`NSM`?n[e]=c:c=n[e];c=s;for(let e=0;e<t;e++){let t=n[e];t===`EN`?n[e]=c===`AL`?`AN`:`EN`:(t===`R`||t===`L`||t===`AL`)&&(c=t)}for(let e=0;e<t;e++)n[e]===`AL`&&(n[e]=`R`);for(let e=1;e<t-1;e++)n[e]===`ES`&&n[e-1]===`EN`&&n[e+1]===`EN`&&(n[e]=`EN`),n[e]===`CS`&&(n[e-1]===`EN`||n[e-1]===`AN`)&&n[e+1]===n[e-1]&&(n[e]=n[e-1]);for(let e=0;e<t;e++){if(n[e]!==`EN`)continue;let r;for(r=e-1;r>=0&&n[r]===`ET`;r--)n[r]=`EN`;for(r=e+1;r<t&&n[r]===`ET`;r++)n[r]=`EN`}for(let e=0;e<t;e++){let t=n[e];(t===`WS`||t===`ES`||t===`ET`||t===`CS`)&&(n[e]=`ON`)}c=s;for(let e=0;e<t;e++){let t=n[e];t===`EN`?n[e]=c===`L`?`L`:`EN`:(t===`R`||t===`L`)&&(c=t)}for(let e=0;e<t;e++){if(n[e]!==`ON`)continue;let r=e+1;for(;r<t&&n[r]===`ON`;)r++;let i=e>0?n[e-1]:s,a=r<t?n[r]:s,o=i===`L`?`L`:`R`;if(o===(a===`L`?`L`:`R`))for(let t=e;t<r;t++)n[t]=o;e=r-1}for(let e=0;e<t;e++)n[e]===`ON`&&(n[e]=o);for(let e=0;e<t;e++){let t=n[e];a[e]&1?(t===`L`||t===`AN`||t===`EN`)&&a[e]++:t===`R`?a[e]++:(t===`AN`||t===`EN`)&&(a[e]+=2)}return a}function cC(e,t){let n=sC(e);if(n===null)return null;let r=new Int8Array(t.length);for(let e=0;e<t.length;e++)r[e]=n[t[e]];return r}var lC=/[ \t\n\r\f]+/g,uC=/[\t\n\r\f]| {2,}|^ | $/;function dC(e){let t=e??`normal`;return t===`pre-wrap`?{mode:t,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:t,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function fC(e){if(!uC.test(e))return e;let t=e.replace(lC,` `);return t.charCodeAt(0)===32&&(t=t.slice(1)),t.length>0&&t.charCodeAt(t.length-1)===32&&(t=t.slice(0,-1)),t}function pC(e){return/[\r\f]/.test(e)?e.replace(/\r\n/g,`
|
|
68
|
+
`).replace(/[\r\f]/g,`
|
|
69
|
+
`):e.replace(/\r\n/g,`
|
|
70
|
+
`)}var mC=null,hC;function gC(){return mC===null&&(mC=new Intl.Segmenter(hC,{granularity:`word`})),mC}var _C=/\p{Script=Arabic}/u,vC=/\p{M}/u,yC=/\p{Nd}/u;function bC(e){return _C.test(e)}function xC(e){for(let t of e){let e=t.codePointAt(0);if(e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=196608&&e<=201551||e>=63744&&e<=64255||e>=194560&&e<=195103||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519)return!0}return!1}var SC=new Set(`,...!.:.;.?.、.。.・.).〕.〉.》.」.』.】.〗.〙.〛.ー.々.〻.ゝ.ゞ.ヽ.ヾ`.split(`.`)),CC=new Set([`"`,`(`,`[`,`{`,`“`,`‘`,`«`,`‹`,`(`,`〔`,`〈`,`《`,`「`,`『`,`【`,`〖`,`〘`,`〚`]),wC=new Set([`'`,`’`]),TC=new Set(`.(,(!(?(:(;(،(؛(؟(।(॥(၊(။(၌(၍(၏()(](}(%("(”(’(»(›(…`.split(`(`)),EC=new Set([`:`,`.`,`،`,`؛`]),DC=new Set([`၏`]),OC=new Set([`”`,`’`,`»`,`›`,`」`,`』`,`】`,`》`,`〉`,`〕`,`)`]);function kC(e){if(MC(e))return!0;let t=!1;for(let n of e){if(TC.has(n)){t=!0;continue}if(!(t&&vC.test(n)))return!1}return t}function AC(e){for(let t of e)if(!SC.has(t)&&!TC.has(t))return!1;return e.length>0}function jC(e){if(MC(e))return!0;for(let t of e)if(!CC.has(t)&&!wC.has(t)&&!vC.test(t))return!1;return e.length>0}function MC(e){let t=!1;for(let n of e)if(!(n===`\\`||vC.test(n))){if(CC.has(n)||TC.has(n)||wC.has(n)){t=!0;continue}return!1}return t}function NC(e){let t=Array.from(e),n=t.length;for(;n>0;){let e=t[n-1];if(vC.test(e)){n--;continue}if(CC.has(e)||wC.has(e)){n--;continue}break}return n<=0||n===t.length?null:{head:t.slice(0,n).join(``),tail:t.slice(n).join(``)}}function PC(e,t){if(e.length===0)return!1;for(let n of e)if(n!==t)return!1;return!0}function FC(e){return!bC(e)||e.length===0?!1:EC.has(e[e.length-1])}function IC(e){return e.length===0?!1:DC.has(e[e.length-1])}function LC(e){if(e.length<2||e[0]!==` `)return null;let t=e.slice(1);return/^\p{M}+$/u.test(t)?{space:` `,marks:t}:null}function RC(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(OC.has(n))return!0;if(!TC.has(n))return!1}return!1}function zC(e,t){if(t.preserveOrdinarySpaces||t.preserveHardBreaks){if(e===` `)return`preserved-space`;if(e===` `)return`tab`;if(t.preserveHardBreaks&&e===`
|
|
71
|
+
`)return`hard-break`}return e===` `?`space`:e===`\xA0`||e===` `||e===``||e===``?`glue`:e===``?`zero-width-break`:e===``?`soft-hyphen`:`text`}function BC(e){return e.length===1?e[0]:e.join(``)}function VC(e,t,n,r){let i=[],a=null,o=[],s=n,c=!1,l=0;for(let u of e){let e=zC(u,r),d=e===`text`&&t;if(a!==null&&e===a&&d===c){o.push(u),l+=u.length;continue}a!==null&&i.push({text:BC(o),isWordLike:c,kind:a,start:s}),a=e,o=[u],s=n+l,c=d,l+=u.length}return a!==null&&i.push({text:BC(o),isWordLike:c,kind:a,start:s}),i}function HC(e){return e===`space`||e===`preserved-space`||e===`zero-width-break`||e===`hard-break`}var UC=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function WC(e,t){let n=e.texts[t];return n.startsWith(`www.`)?!0:UC.test(n)&&t+1<e.len&&e.kinds[t+1]===`text`&&e.texts[t+1]===`//`}function GC(e){return e.includes(`?`)&&(e.includes(`://`)||e.startsWith(`www.`))}function KC(e){let t=e.texts.slice(),n=e.isWordLike.slice(),r=e.kinds.slice(),i=e.starts.slice();for(let i=0;i<e.len;i++){if(r[i]!==`text`||!WC(e,i))continue;let a=[t[i]],o=i+1;for(;o<e.len&&!HC(r[o]);){a.push(t[o]),n[i]=!0;let e=t[o].includes(`?`);if(r[o]=`text`,t[o]=``,o++,e)break}t[i]=BC(a)}let a=0;for(let e=0;e<t.length;e++){let o=t[e];o.length!==0&&(a!==e&&(t[a]=o,n[a]=n[e],r[a]=r[e],i[a]=i[e]),a++)}return t.length=a,n.length=a,r.length=a,i.length=a,{len:a,texts:t,isWordLike:n,kinds:r,starts:i}}function qC(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a];if(t.push(o),n.push(e.isWordLike[a]),r.push(e.kinds[a]),i.push(e.starts[a]),!GC(o))continue;let s=a+1;if(s>=e.len||HC(e.kinds[s]))continue;let c=[],l=e.starts[s],u=s;for(;u<e.len&&!HC(e.kinds[u]);)c.push(e.texts[u]),u++;c.length>0&&(t.push(BC(c)),n.push(!0),r.push(`text`),i.push(l),a=u-1)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}var JC=new Set([`:`,`-`,`/`,`×`,`,`,`.`,`+`,`–`,`—`]),YC=/^[A-Za-z0-9_]+[,:;]*$/,XC=/[,:;]+$/;function ZC(e){for(let t of e)if(yC.test(t))return!0;return!1}function QC(e){if(e.length===0)return!1;for(let t of e)if(!(yC.test(t)||JC.has(t)))return!1;return!0}function $C(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a],s=e.kinds[a];if(s===`text`&&QC(o)&&ZC(o)){let s=[o],c=a+1;for(;c<e.len&&e.kinds[c]===`text`&&QC(e.texts[c]);)s.push(e.texts[c]),c++;t.push(BC(s)),n.push(!0),r.push(`text`),i.push(e.starts[a]),a=c-1;continue}t.push(o),n.push(e.isWordLike[a]),r.push(s),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function ew(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a],s=e.kinds[a],c=e.isWordLike[a];if(s===`text`&&c&&YC.test(o)){let s=[o],c=XC.test(o),l=a+1;for(;c&&l<e.len&&e.kinds[l]===`text`&&e.isWordLike[l]&&YC.test(e.texts[l]);){let t=e.texts[l];s.push(t),c=XC.test(t),l++}t.push(BC(s)),n.push(!0),r.push(`text`),i.push(e.starts[a]),a=l-1;continue}t.push(o),n.push(c),r.push(s),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function tw(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a];if(e.kinds[a]===`text`&&o.includes(`-`)){let s=o.split(`-`),c=s.length>1;for(let e=0;e<s.length;e++){let t=s[e];if(!c)break;(t.length===0||!ZC(t)||!QC(t))&&(c=!1)}if(c){let o=0;for(let c=0;c<s.length;c++){let l=s[c],u=c<s.length-1?`${l}-`:l;t.push(u),n.push(!0),r.push(`text`),i.push(e.starts[a]+o),o+=u.length}continue}}t.push(o),n.push(e.isWordLike[a]),r.push(e.kinds[a]),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function nw(e){let t=[],n=[],r=[],i=[],a=0;for(;a<e.len;){let o=[e.texts[a]],s=e.isWordLike[a],c=e.kinds[a],l=e.starts[a];if(c===`glue`){let u=[o[0]],d=l;for(a++;a<e.len&&e.kinds[a]===`glue`;)u.push(e.texts[a]),a++;let f=BC(u);if(a<e.len&&e.kinds[a]===`text`)o[0]=f,o.push(e.texts[a]),s=e.isWordLike[a],c=`text`,l=d,a++;else{t.push(f),n.push(!1),r.push(`glue`),i.push(d);continue}}else a++;if(c===`text`)for(;a<e.len&&e.kinds[a]===`glue`;){let t=[];for(;a<e.len&&e.kinds[a]===`glue`;)t.push(e.texts[a]),a++;let n=BC(t);if(a<e.len&&e.kinds[a]===`text`){o.push(n,e.texts[a]),s||=e.isWordLike[a],a++;continue}o.push(n)}t.push(BC(o)),n.push(s),r.push(c),i.push(l)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function rw(e){let t=e.texts.slice(),n=e.isWordLike.slice(),r=e.kinds.slice(),i=e.starts.slice();for(let e=0;e<t.length-1;e++){if(r[e]!==`text`||r[e+1]!==`text`||!xC(t[e])||!xC(t[e+1]))continue;let n=NC(t[e]);n!==null&&(t[e]=n.head,t[e+1]=n.tail+t[e+1],i[e+1]=i[e]+n.head.length)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function iw(e,t,n){let r=gC(),i=0,a=[],o=[],s=[],c=[];for(let l of r.segment(e))for(let e of VC(l.segment,l.isWordLike??!1,l.index,n)){let n=e.kind===`text`;t.carryCJKAfterClosingQuote&&n&&i>0&&s[i-1]===`text`&&xC(e.text)&&xC(a[i-1])&&RC(a[i-1])||n&&i>0&&s[i-1]===`text`&&AC(e.text)&&xC(a[i-1])||n&&i>0&&s[i-1]===`text`&&IC(a[i-1])?(a[i-1]+=e.text,o[i-1]=o[i-1]||e.isWordLike):n&&i>0&&s[i-1]===`text`&&e.isWordLike&&bC(e.text)&&FC(a[i-1])?(a[i-1]+=e.text,o[i-1]=!0):n&&!e.isWordLike&&i>0&&s[i-1]===`text`&&e.text.length===1&&e.text!==`-`&&e.text!==`—`&&PC(a[i-1],e.text)||n&&!e.isWordLike&&i>0&&s[i-1]===`text`&&(kC(e.text)||e.text===`-`&&o[i-1])?a[i-1]+=e.text:(a[i]=e.text,o[i]=e.isWordLike,s[i]=e.kind,c[i]=e.start,i++)}for(let e=1;e<i;e++)s[e]===`text`&&!o[e]&&MC(a[e])&&s[e-1]===`text`&&(a[e-1]+=a[e],o[e-1]=o[e-1]||o[e],a[e]=``);for(let e=i-2;e>=0;e--)if(s[e]===`text`&&!o[e]&&jC(a[e])){let t=e+1;for(;t<i&&a[t]===``;)t++;t<i&&s[t]===`text`&&(a[t]=a[e]+a[t],c[t]=c[e],a[e]=``)}let l=0;for(let e=0;e<i;e++){let t=a[e];t.length!==0&&(l!==e&&(a[l]=t,o[l]=o[e],s[l]=s[e],c[l]=c[e]),l++)}a.length=l,o.length=l,s.length=l,c.length=l;let u=rw(ew(tw($C(qC(KC(nw({len:l,texts:a,isWordLike:o,kinds:s,starts:c})))))));for(let e=0;e<u.len-1;e++){let t=LC(u.texts[e]);t!==null&&(u.kinds[e]!==`space`&&u.kinds[e]!==`preserved-space`||u.kinds[e+1]!==`text`||!bC(u.texts[e+1])||(u.texts[e]=t.space,u.isWordLike[e]=!1,u.kinds[e]=u.kinds[e]===`preserved-space`?`preserved-space`:`space`,u.texts[e+1]=t.marks+u.texts[e+1],u.starts[e+1]=u.starts[e]+t.space.length))}return u}function aw(e,t){if(e.len===0)return[];if(!t.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}];let n=[],r=0;for(let t=0;t<e.len;t++)e.kinds[t]===`hard-break`&&(n.push({startSegmentIndex:r,endSegmentIndex:t,consumedEndSegmentIndex:t+1}),r=t+1);return r<e.len&&n.push({startSegmentIndex:r,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}),n}function ow(e,t,n=`normal`){let r=dC(n),i=r.mode===`pre-wrap`?pC(e):fC(e);if(i.length===0)return{normalized:i,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let a=iw(i,t,r);return{normalized:i,chunks:aw(a,r),...a}}var sw=null,cw=new Map,lw=null,uw=/\p{Emoji_Presentation}/u,dw=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,fw=null,pw=new Map;function mw(){if(sw!==null)return sw;if(typeof OffscreenCanvas<`u`)return sw=new OffscreenCanvas(1,1).getContext(`2d`),sw;if(typeof document<`u`)return sw=document.createElement(`canvas`).getContext(`2d`),sw;throw Error(`Text measurement requires OffscreenCanvas or a DOM canvas context.`)}function hw(e){let t=cw.get(e);return t||(t=new Map,cw.set(e,t)),t}function gw(e,t){let n=t.get(e);return n===void 0&&(n={width:mw().measureText(e).width,containsCJK:xC(e)},t.set(e,n)),n}function _w(){if(lw!==null)return lw;if(typeof navigator>`u`)return lw={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},lw;let e=navigator.userAgent,t=navigator.vendor===`Apple Computer, Inc.`&&e.includes(`Safari/`)&&!e.includes(`Chrome/`)&&!e.includes(`Chromium/`)&&!e.includes(`CriOS/`)&&!e.includes(`FxiOS/`)&&!e.includes(`EdgiOS/`),n=e.includes(`Chrome/`)||e.includes(`Chromium/`)||e.includes(`CriOS/`)||e.includes(`Edg/`);return lw={lineFitEpsilon:t?1/64:.005,carryCJKAfterClosingQuote:n,preferPrefixWidthsForBreakableRuns:t,preferEarlySoftHyphenBreak:t},lw}function vw(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/);return t?parseFloat(t[1]):16}function yw(){return fw===null&&(fw=new Intl.Segmenter(void 0,{granularity:`grapheme`})),fw}function bw(e){return uw.test(e)||e.includes(`️`)}function xw(e){return dw.test(e)}function Sw(e,t){let n=pw.get(e);if(n!==void 0)return n;let r=mw();r.font=e;let i=r.measureText(`😀`).width;if(n=0,i>t+.5&&typeof document<`u`&&document.body!==null){let t=document.createElement(`span`);t.style.font=e,t.style.display=`inline-block`,t.style.visibility=`hidden`,t.style.position=`absolute`,t.textContent=`😀`,document.body.appendChild(t);let r=t.getBoundingClientRect().width;document.body.removeChild(t),i-r>.5&&(n=i-r)}return pw.set(e,n),n}function Cw(e){let t=0,n=yw();for(let r of n.segment(e))bw(r.segment)&&t++;return t}function ww(e,t){return t.emojiCount===void 0&&(t.emojiCount=Cw(e)),t.emojiCount}function Tw(e,t,n){return n===0?t.width:t.width-ww(e,t)*n}function Ew(e,t,n,r){if(t.graphemeWidths!==void 0)return t.graphemeWidths;let i=[],a=yw();for(let t of a.segment(e)){let e=gw(t.segment,n);i.push(Tw(t.segment,e,r))}return t.graphemeWidths=i.length>1?i:null,t.graphemeWidths}function Dw(e,t,n,r){if(t.graphemePrefixWidths!==void 0)return t.graphemePrefixWidths;let i=[],a=yw(),o=``;for(let t of a.segment(e)){o+=t.segment;let e=gw(o,n);i.push(Tw(o,e,r))}return t.graphemePrefixWidths=i.length>1?i:null,t.graphemePrefixWidths}function Ow(e,t){let n=mw();n.font=e;let r=hw(e),i=vw(e);return{cache:r,fontSize:i,emojiCorrection:t?Sw(e,i):0}}function kw(e){return e===`space`||e===`preserved-space`||e===`tab`||e===`zero-width-break`||e===`soft-hyphen`}function Aw(e,t){for(;t<e.widths.length;){let n=e.kinds[t];if(n!==`space`&&n!==`zero-width-break`&&n!==`soft-hyphen`)break;t++}return t}function jw(e,t){if(t<=0)return 0;let n=e%t;return Math.abs(n)<=1e-6?t:t-n}function Mw(e,t,n,r){return!r||t===null?e[n]:t[n]-(n>0?t[n-1]:0)}function Nw(e,t,n,r,i,a){let o=0,s=t;for(;o<e.length;){let c=a?t+e[o]:s+e[o];if((o+1<e.length?c+i:c)>n+r)break;s=c,o++}return{fitCount:o,fittedWidth:s}}function Pw(e,t){return e.simpleLineWalkFastPath?Fw(e,t):Lw(e,t)}function Fw(e,t){return Iw(e,t)}function Iw(e,t,n){let{widths:r,kinds:i,breakableWidths:a,breakablePrefixWidths:o}=e;if(r.length===0)return 0;let s=_w(),c=s.lineFitEpsilon,l=0,u=0,d=!1,f=0,p=0,m=0,h=0,g=-1,_=0;function v(){g=-1,_=0}function y(e=m,t=h,r=u){l++,n?.({startSegmentIndex:f,startGraphemeIndex:p,endSegmentIndex:e,endGraphemeIndex:t,width:r}),u=0,d=!1,v()}function b(e,t){d=!0,f=e,p=0,m=e+1,h=0,u=t}function x(e,t,n){d=!0,f=e,p=t,m=e,h=t+1,u=n}function S(e,t){if(!d){b(e,t);return}u+=t,m=e+1,h=0}function C(e,t){kw(i[e])&&(g=e+1,_=u-t)}function w(e){T(e,0)}function T(e,n){let r=a[e],i=o[e]??null;for(let a=n;a<r.length;a++){let n=Mw(r,i,a,s.preferPrefixWidthsForBreakableRuns);if(!d){x(e,a,n);continue}u+n>t+c?(y(),x(e,a,n)):(u+=n,m=e,h=a+1)}d&&m===e&&h===r.length&&(m=e+1,h=0)}let E=0;for(;E<r.length&&!(!d&&(E=Aw(e,E),E>=r.length));){let e=r[E],n=i[E];if(!d){e>t&&a[E]!==null?w(E):b(E,e),C(E,e),E++;continue}if(u+e>t+c){if(kw(n)){S(E,e),y(E+1,0,u-e),E++;continue}if(g>=0){if(m>g||m===g&&h>0){y();continue}y(g,0,_);continue}if(e>t&&a[E]!==null){y(),w(E),E++;continue}y();continue}S(E,e),C(E,e),E++}return d&&y(),l}function Lw(e,t,n){if(e.simpleLineWalkFastPath)return Iw(e,t,n);let{widths:r,lineEndFitAdvances:i,lineEndPaintAdvances:a,kinds:o,breakableWidths:s,breakablePrefixWidths:c,discretionaryHyphenWidth:l,tabStopAdvance:u,chunks:d}=e;if(r.length===0||d.length===0)return 0;let f=_w(),p=f.lineFitEpsilon,m=0,h=0,g=!1,_=0,v=0,y=0,b=0,x=-1,S=0,C=0,w=null;function T(){x=-1,S=0,C=0,w=null}function E(e=y,t=b,r=h){m++,n?.({startSegmentIndex:_,startGraphemeIndex:v,endSegmentIndex:e,endGraphemeIndex:t,width:r}),h=0,g=!1,T()}function D(e,t){g=!0,_=e,v=0,y=e+1,b=0,h=t}function O(e,t,n){g=!0,_=e,v=t,y=e,b=t+1,h=n}function k(e,t){if(!g){D(e,t);return}h+=t,y=e+1,b=0}function A(e,t){if(!kw(o[e]))return;let n=o[e]===`tab`?0:i[e],r=o[e]===`tab`?t:a[e];x=e+1,S=h-t+n,C=h-t+r,w=o[e]}function j(e){M(e,0)}function M(e,n){let r=s[e],i=c[e]??null;for(let a=n;a<r.length;a++){let n=Mw(r,i,a,f.preferPrefixWidthsForBreakableRuns);if(!g){O(e,a,n);continue}h+n>t+p?(E(),O(e,a,n)):(h+=n,y=e,b=a+1)}g&&y===e&&b===r.length&&(y=e+1,b=0)}function N(e){if(w!==`soft-hyphen`)return!1;let n=s[e];if(n===null)return!1;let r=f.preferPrefixWidthsForBreakableRuns?c[e]??n:n,{fitCount:i,fittedWidth:a}=Nw(r,h,t,p,l,r!==n);return i===0?!1:(h=a,y=e,b=i,T(),i===n.length?(y=e+1,b=0,!0):(E(e,i,a+l),M(e,i),!0))}function P(e){m++,n?.({startSegmentIndex:e.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:e.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),T()}for(let e=0;e<d.length;e++){let n=d[e];if(n.startSegmentIndex===n.endSegmentIndex){P(n);continue}g=!1,h=0,_=n.startSegmentIndex,v=0,y=n.startSegmentIndex,b=0,T();let c=n.startSegmentIndex;for(;c<n.endSegmentIndex;){let e=o[c],n=e===`tab`?jw(h,u):r[c];if(e===`soft-hyphen`){g&&(y=c+1,b=0,x=c+1,S=h+l,C=h+l,w=e),c++;continue}if(!g){n>t&&s[c]!==null?j(c):D(c,n),A(c,n),c++;continue}if(h+n>t+p){let r=h+(e===`tab`?0:i[c]),o=h+(e===`tab`?n:a[c]);if(w===`soft-hyphen`&&f.preferEarlySoftHyphenBreak&&S<=t+p){E(x,0,C);continue}if(w===`soft-hyphen`&&N(c)){c++;continue}if(kw(e)&&r<=t+p){k(c,n),E(c+1,0,o),c++;continue}if(x>=0&&S<=t+p){if(y>x||y===x&&b>0){E();continue}let e=x;E(e,0,C),c=e;continue}if(n>t&&s[c]!==null){E(),j(c),c++;continue}E();continue}k(c,n),A(c,n),c++}if(g){let e=x===n.consumedEndSegmentIndex?C:h;E(n.consumedEndSegmentIndex,0,e)}}return m}var Rw=null;function zw(){return Rw===null&&(Rw=new Intl.Segmenter(void 0,{granularity:`grapheme`})),Rw}function Bw(e){return e?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function Vw(e,t,n){let r=zw(),i=_w(),{cache:a,emojiCorrection:o}=Ow(t,xw(e.normalized)),s=Tw(`-`,gw(`-`,a),o),c=Tw(` `,gw(` `,a),o)*8;if(e.len===0)return Bw(n);let l=[],u=[],d=[],f=[],p=e.chunks.length<=1,m=n?[]:null,h=[],g=[],_=n?[]:null,v=Array.from({length:e.len}),y=Array.from({length:e.len});function b(e,t,n,r,i,a,o,s){i!==`text`&&i!==`space`&&i!==`zero-width-break`&&(p=!1),l.push(t),u.push(n),d.push(r),f.push(i),m?.push(a),h.push(o),g.push(s),_!==null&&_.push(e)}for(let t=0;t<e.len;t++){v[t]=l.length;let n=e.texts[t],c=e.isWordLike[t],u=e.kinds[t],d=e.starts[t];if(u===`soft-hyphen`){b(n,0,s,s,u,d,null,null),y[t]=l.length;continue}if(u===`hard-break`){b(n,0,0,0,u,d,null,null),y[t]=l.length;continue}if(u===`tab`){b(n,0,0,0,u,d,null,null),y[t]=l.length;continue}let f=gw(n,a);if(u===`text`&&f.containsCJK){let e=``,s=0;for(let t of r.segment(n)){let n=t.segment;if(e.length===0){e=n,s=t.index;continue}if(CC.has(e)||SC.has(n)||TC.has(n)||i.carryCJKAfterClosingQuote&&xC(n)&&RC(e)){e+=n;continue}let r=gw(e,a),c=Tw(e,r,o);b(e,c,c,c,`text`,d+s,null,null),e=n,s=t.index}if(e.length>0){let t=gw(e,a),n=Tw(e,t,o);b(e,n,n,n,`text`,d+s,null,null)}y[t]=l.length;continue}let p=Tw(n,f,o),m=u===`space`||u===`preserved-space`||u===`zero-width-break`?0:p,h=u===`space`||u===`zero-width-break`?0:p;c&&n.length>1?b(n,p,m,h,u,d,Ew(n,f,a,o),i.preferPrefixWidthsForBreakableRuns?Dw(n,f,a,o):null):b(n,p,m,h,u,d,null,null),y[t]=l.length}let x=Hw(e.chunks,v,y),S=m===null?null:cC(e.normalized,m);return _===null?{widths:l,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:p,segLevels:S,breakableWidths:h,breakablePrefixWidths:g,discretionaryHyphenWidth:s,tabStopAdvance:c,chunks:x}:{widths:l,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:p,segLevels:S,breakableWidths:h,breakablePrefixWidths:g,discretionaryHyphenWidth:s,tabStopAdvance:c,chunks:x,segments:_}}function Hw(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a.startSegmentIndex<t.length?t[a.startSegmentIndex]:n[n.length-1]??0,s=a.endSegmentIndex<t.length?t[a.endSegmentIndex]:n[n.length-1]??0,c=a.consumedEndSegmentIndex<t.length?t[a.consumedEndSegmentIndex]:n[n.length-1]??0;r.push({startSegmentIndex:o,endSegmentIndex:s,consumedEndSegmentIndex:c})}return r}function Uw(e,t,n,r){return Vw(ow(e,_w(),r?.whiteSpace),t,n)}function Ww(e,t,n){return Uw(e,t,!1,n)}function Gw(e){return e}function Kw(e,t,n){let r=Pw(Gw(e),t);return{lineCount:r,height:r*n}}var qw=`14px Body`,Jw=24,Yw=20,Xw=12,Zw=28,Qw=.8,$w=16,eT=80,tT={system_init:48,account_info:0,result:40,status:32,compact_boundary:40,context_cleared:40,compact_summary:56,interrupted:32,tool:56,unknown:80},nT=64,rT=72,iT=500,aT=new Map;function oT(e,t,n,r){let i=aT.get(t);if(i)return aT.delete(t),aT.set(t,i),i;let a=Ww(e,n,r);if(aT.set(t,a),aT.size>iT){let e=aT.keys().next().value;e!==void 0&&aT.delete(e)}return a}function sT(e){let t=0,n=0;for(;n<e.length;)if(e[n]===`
|
|
72
|
+
`&&n+1<e.length&&e[n+1]===`
|
|
73
|
+
`)for(t++,n+=2;n<e.length&&e[n]===`
|
|
74
|
+
`;)n++;else n++;return t}function cT(e,t,n){if(!n)return eT;if(e.kind===`assistant_text`){let n=Kw(oT(e.text,e.id,qw),t,Jw),r=sT(e.text);return n.height+r*$w+Yw}if(e.kind===`user_prompt`){let n=t*Qw-Zw;return Kw(oT(e.content,e.id,qw,{whiteSpace:`pre-wrap`}),n,Jw).height+Xw+Yw}return tT[e.kind]??eT}function lT(e,t,n){return e.kind===`tool_group`?nT:e.kind===`wip_block`?rT:e.kind===`standalone_tool`?cT(e.tool,t,n):e.kind===`artifact`?cT(e.artifact,t,n):cT(e.message,t,n)}var uT=!1,dT=null;function fT(){return uT?Promise.resolve(!0):dT||(dT=document.fonts.ready.then(()=>(uT=document.fonts.check(`14px Body`),uT)),dT)}function pT(e,t){let[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(800),o=(0,j.useRef)(e);return o.current=e,(0,j.useEffect)(()=>{let e=!0;return fT().then(t=>{e&&r(t)}),()=>{e=!1}},[]),(0,j.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let t=e.clientWidth;t>0&&a(Math.min(t,800))},r=new ResizeObserver(n);return r.observe(e),n(),()=>r.disconnect()},[t]),{estimateSize:(0,j.useCallback)(e=>{let t=o.current[e];return t?lT(t,i,n):80},[i,n])}}var mT=(0,j.memo)(function({json:e}){return(0,Q.jsx)(`div`,{className:`flex gap-3 justify-start`,children:(0,Q.jsx)(`div`,{className:`flex-1 max-w-[90%]`,children:(0,Q.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words bg-muted rounded-lg p-3 overflow-auto max-h-96`,children:e})})})});function hT(e){if(!e)return;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function gT(e){if(!e)return null;let t=e.trim();if(!t||/^(https?:|mailto:|ftp:|file:)/i.test(t)||!t.startsWith(`/`))return null;let n=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(t);return n?.groups?.path?{path:n.groups.path,line:hT(n.groups.line),column:hT(n.groups.column)}:{path:t}}function _T(e,t){if(!e)return``;if(t){let n=t.endsWith(`/`)?t:`${t}/`;if(e.startsWith(n))return e.slice(n.length);if(e===t)return``}return e.replace(/^\/home\/user\/workspace\//,``)}var vT=.25,yT=.25,bT=5;function xT(e){return Number.isFinite(e)?Math.min(bT,Math.max(yT,e)):1}function ST(e,t){switch(e.type){case`code`:return t.type===`TOGGLE_LINE_NUMBERS`?{...e,lineNumbers:!e.lineNumbers}:e;case`diff`:return t.type===`SET_VIEW_MODE`?{...e,viewMode:t.payload}:e;case`embed`:switch(t.type){case`SET_RENDER_MODE`:return{...e,renderMode:t.payload};case`SET_ZOOM`:return{...e,zoom:xT(t.payload)};case`ZOOM_IN`:return{...e,zoom:xT(e.zoom+vT)};case`ZOOM_OUT`:return{...e,zoom:xT(e.zoom-vT)};case`ZOOM_RESET`:return{...e,zoom:1};default:return e}case`markdown`:switch(t.type){case`TOGGLE_TOC`:return{...e,tocOpen:!e.tocOpen};case`REGISTER_HEADINGS`:return{...e,headings:t.payload};default:return e}}}function CT(e){switch(e){case`code`:return{type:`code`,lineNumbers:!1};case`diff`:return{type:`diff`,viewMode:`unified`};case`embed`:return{type:`embed`,renderMode:`render`,zoom:1};case`markdown`:return{type:`markdown`,tocOpen:!1,headings:[]}}}var wT=(0,j.createContext)(null);function TT(){return(0,j.useContext)(wT)}function ET({ariaLabel:e,onClick:t,active:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":n,onClick:t,className:b(`flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,n&&`bg-accent text-foreground`),children:r})}var DT=(0,j.memo)(function({state:e,dispatch:t,showCodeLineNumbers:n=!0}){switch(e.type){case`code`:return n?(0,Q.jsx)(ET,{ariaLabel:`Toggle line numbers`,active:e.lineNumbers,onClick:()=>t({type:`TOGGLE_LINE_NUMBERS`}),children:(0,Q.jsx)(Rr,{className:`h-3.5 w-3.5`})}):null;case`diff`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ET,{ariaLabel:`Unified view`,active:e.viewMode===`unified`,onClick:()=>t({type:`SET_VIEW_MODE`,payload:`unified`}),children:(0,Q.jsx)(ui,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(ET,{ariaLabel:`Split view`,active:e.viewMode===`split`,onClick:()=>t({type:`SET_VIEW_MODE`,payload:`split`}),children:(0,Q.jsx)(yr,{className:`h-3.5 w-3.5`})})]});case`embed`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ET,{ariaLabel:`Show rendered`,active:e.renderMode===`render`,onClick:()=>t({type:`SET_RENDER_MODE`,payload:`render`}),children:(0,Q.jsx)(wr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(ET,{ariaLabel:`Show source`,active:e.renderMode===`source`,onClick:()=>t({type:`SET_RENDER_MODE`,payload:`source`}),children:(0,Q.jsx)(vr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:`mx-0.5 h-3 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(ET,{ariaLabel:`Zoom out`,onClick:()=>t({type:`ZOOM_OUT`}),children:(0,Q.jsx)(ei,{className:`h-3 w-3`})}),(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Reset zoom`,onClick:()=>t({type:`ZOOM_RESET`}),className:`flex h-6 min-w-[2.25rem] items-center justify-center rounded px-1 text-[10px] tabular-nums text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[Math.round(e.zoom*100),`%`]}),(0,Q.jsx)(ET,{ariaLabel:`Zoom in`,onClick:()=>t({type:`ZOOM_IN`}),children:(0,Q.jsx)(si,{className:`h-3 w-3`})})]});case`markdown`:return(0,Q.jsx)(ET,{ariaLabel:`Table of contents`,active:e.tocOpen,onClick:()=>t({type:`TOGGLE_TOC`}),children:(0,Q.jsx)(Wr,{className:`h-3.5 w-3.5`})})}}),OT={nav:m({id:`rich-content.toc.area`,c3ComponentId:`c3-107`,c3ComponentLabel:`rich-content`}),item:m({id:`rich-content.toc.item`,c3ComponentId:`c3-107`,c3ComponentLabel:`rich-content`})},kT={1:``,2:`pl-3`,3:`pl-6`},AT=(0,j.memo)(function({headings:e,onSelect:t}){return e.length===0?null:(0,Q.jsx)(`nav`,{"aria-label":`Table of contents`,className:`border-b border-border bg-muted/20 px-3 py-2`,...c(OT.nav),children:(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),...c(OT.item),className:b(`w-full truncate rounded px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,kT[e.level]??`pl-6`),children:e.text})},e.id))})})}),jT={code:vr,markdown:Or,embed:zr,diff:Ir},MT=`mx-auto w-full max-w-[96rem]`,NT=`h-[100dvh] max-h-none`,PT=`${og} pt-4`,FT=`space-y-0 px-3 py-2`,IT=m({id:`rich-content.viewer.area`,c3ComponentId:`c3-107`,c3ComponentLabel:`rich-content`}),LT=`fullscreen`;function RT(e=IT){return c(e)}function zT({open:e,onOpenChange:t,title:n,type:r,children:i,rawContent:a,rootUiId:o}){let[s,c]=(0,j.useState)(!1),l=k_(),[u,d]=(0,j.useReducer)(ST,r,CT),f=(0,j.useRef)(null),p=jT[r],m=(0,j.useCallback)(async()=>{if(a)try{await navigator.clipboard.writeText(a),c(!0),setTimeout(()=>c(!1),2e3)}catch(e){console.warn(`[tinkaria] clipboard write failed:`,e instanceof Error?e.message:String(e))}},[a]),h=(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,"data-controls":`true`,children:[(0,Q.jsx)(DT,{state:u,dispatch:d,showCodeLineNumbers:!1}),a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mx-0.5 h-3 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(ET,{ariaLabel:s?`Copied`:`Copy content`,onClick:m,children:s?(0,Q.jsx)(ar,{className:`h-3.5 w-3.5 text-green-400`}):(0,Q.jsx)(br,{className:`h-3.5 w-3.5`})})]}):null]});return(0,Q.jsx)(rg,{open:e,onOpenChange:t,children:(0,Q.jsx)(pg,{size:LT,className:b(NT,l&&`h-[100dvh] data-[state=open]:slide-in-from-bottom data-[state=open]:duration-300 data-[state=closed]:slide-out-to-bottom data-[state=closed]:duration-200 data-[state=open]:zoom-in-100 data-[state=closed]:zoom-out-100`),...RT(o),children:(0,Q.jsxs)(wT.Provider,{value:{state:u,dispatch:d},children:[(0,Q.jsx)(mg,{className:b(FT,l&&`max-md:pt-[max(1rem,env(safe-area-inset-top))]`),children:(0,Q.jsxs)(`div`,{className:b(`flex w-full items-center gap-2`,MT),children:[l?(0,Q.jsx)(ig,{asChild:!0,children:(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`-ml-2 h-11 w-11 rounded-lg text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(Jn,{className:`h-5 w-5`})})}):(0,Q.jsx)(p,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(hg,{className:`truncate text-sm`,children:n??r}),l?null:(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[h,(0,Q.jsx)(ig,{asChild:!0,children:(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`h-8 w-8 rounded text-muted-foreground`,children:(0,Q.jsx)(Di,{className:`h-4 w-4`})})})]})]})}),l&&u.type===`markdown`&&u.tocOpen?(0,Q.jsx)(AT,{headings:u.headings,onSelect:e=>{let t=f.current?.querySelector(`#${CSS.escape(e)}`);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}}):null,(0,Q.jsx)(_g,{className:`p-0`,children:(0,Q.jsx)(`div`,{ref:f,className:b(PT,MT),children:i})}),l?(0,Q.jsx)(`div`,{className:`flex items-center justify-end px-2.5 py-1.5 bg-muted/50 border-t border-border pb-[env(safe-area-inset-bottom)]`,children:(0,Q.jsx)(`div`,{className:MT,children:h})}):null]},r)})})}var BT={code:vr,markdown:Or,embed:zr,diff:Ir},VT=`max-h-24`,HT=`px-4 pb-4 pt-3.5`,UT=d({id:`rich-content.block`,c3ComponentId:`c3-107`,c3ComponentLabel:`rich-content`}),WT=(0,j.createContext)({chrome:`card`,controlsVisibility:`always`});function GT({children:e,chrome:t,controlsVisibility:n=`always`}){return(0,Q.jsx)(WT.Provider,{value:(0,j.useMemo)(()=>({chrome:t,controlsVisibility:n}),[t,n]),children:e})}var KT=(0,j.memo)(function({type:e,title:t,defaultExpanded:n=!1,children:r,rawContent:i,chrome:a,controlsVisibility:o,bodyClassName:s}){let l=(0,j.useContext)(WT),u=a??l.chrome,d=o??l.controlsVisibility,[f,p]=(0,j.useState)(n),[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(!1),[v,y]=(0,j.useReducer)(ST,e,CT),x=k_(),S=BT[e],C=t??e,w=(0,j.useRef)(null),T=(0,j.useCallback)(e=>{d!==`hover-or-touch`||e.pointerType!==`touch`||w.current?.focus()},[d]),E=(0,j.useCallback)(async()=>{if(i)try{await navigator.clipboard.writeText(i),_(!0),setTimeout(()=>_(!1),2e3)}catch(e){console.warn(`[tinkaria] clipboard write failed:`,e instanceof Error?e.message:String(e))}},[i]),D=v.type===`embed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(DT,{state:v,dispatch:y}),(0,Q.jsx)(`div`,{className:`mx-0.5 h-3 w-px bg-border`,"aria-hidden":`true`})]}):null,O=i?(0,Q.jsx)(ET,{ariaLabel:g?`Copied`:`Copy content`,onClick:E,children:g?(0,Q.jsx)(ar,{className:`h-3.5 w-3.5 text-green-400`}):(0,Q.jsx)(br,{className:`h-3.5 w-3.5`})}):null,k=(0,Q.jsx)(ET,{ariaLabel:f?`Collapse content`:`Expand content`,onClick:()=>p(e=>!e),children:(0,Q.jsx)(cr,{className:b(`h-3.5 w-3.5 transition-transform duration-200`,f&&`rotate-90`)})}),A=(0,Q.jsx)(ET,{ariaLabel:`Open in overlay`,onClick:()=>h(!0),children:(0,Q.jsx)(Jr,{className:`h-3.5 w-3.5`})}),M=(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,"data-controls":`true`,children:[D,O,k,A]}),N=(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,"data-controls":`true`,children:[D,O,A]}),P=(0,Q.jsx)(`div`,{className:`flex items-center gap-0.5`,"data-controls":`true`,children:k}),F=(0,Q.jsxs)(`div`,{className:b(`relative transition-[max-height] duration-200 ease-in-out`,!f&&`${VT} overflow-hidden`),children:[(0,Q.jsx)(`div`,{className:b(HT,s),children:r}),f?null:(0,Q.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background to-transparent pointer-events-none`,"aria-hidden":`true`})]});return(0,Q.jsx)(wT.Provider,{value:(0,j.useMemo)(()=>({state:v,dispatch:y}),[v,y]),children:(0,Q.jsxs)(`div`,{ref:w,className:b(`group/rich-content min-w-0`,u===`card`?`rounded-lg border border-border overflow-hidden`:`relative w-full`),onPointerDownCapture:T,tabIndex:d===`hover-or-touch`?-1:void 0,...c(UT),children:[u===`card`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:b(`flex items-center gap-1.5 px-2.5 py-1.5 bg-muted/50 border-b border-border text-xs`,x&&`py-1`),children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate font-medium text-muted-foreground`,children:C}),(0,Q.jsx)(`div`,{className:`ml-auto`,children:x?N:M})]}),F,x?(0,Q.jsx)(`div`,{className:`flex items-center justify-end px-2.5 py-1.5 bg-muted/50 border-t border-border`,children:P}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:b(`absolute right-0 top-0 z-10`,d===`hover-or-touch`&&`opacity-0 pointer-events-none transition-opacity duration-150 group-hover/rich-content:opacity-100 group-hover/rich-content:pointer-events-auto group-focus-within/rich-content:opacity-100 group-focus-within/rich-content:pointer-events-auto`),children:(0,Q.jsx)(`div`,{className:`inline-flex items-center gap-0.5 rounded-full border border-border/70 bg-background/85 px-1 py-0.5 shadow-sm backdrop-blur-sm`,children:M})}),F]}),(0,Q.jsx)(zT,{open:m,onOpenChange:h,title:C,type:e,rawContent:i,children:r})]})})});function qT(e,t,n,r){return{code:e,message:t,line:n,column:r}}function JT(e){return{ok:!1,html:``,diagnostics:e}}var YT=new Set(`process.globalThis.window.document.Math.Date.Intl.JSON.Object.Array.String.Number.Boolean.RegExp.Promise.Reflect.Proxy.Symbol.Map.Set.WeakMap.WeakSet.Function.eval.constructor.__proto__.prototype.import.require.fetch.XMLHttpRequest.WebSocket.localStorage.sessionStorage`.split(`.`));function XT(e,t,n,r,i=void 0){let a=e.trim(),o=/^"([\s\S]*)"$/.exec(a)??/^'([\s\S]*)'$/.exec(a);if(o)return{ok:!0,value:o[1].replace(/\\"/g,`"`).replace(/\\'/g,`'`)};let s=eE(a);if(s)return{ok:!1,diagnostic:qT(`PUGGY_HOST_ACCESS_DENIED`,`Host and global access are not allowed in expressions.`,n,r+s.index)};let c=$T(a);if(c){let e=ZT(i);if(!e.allowCalls)return{ok:!1,diagnostic:qT(`PUGGY_UNSUPPORTED_EXPRESSION`,`Unsupported expression.`,n,r)};let a=nE(e.capabilities,c.callee);if(typeof a!=`function`)return{ok:!1,diagnostic:qT(`PUGGY_HOST_ACCESS_DENIED`,`Host and global access are not allowed in expressions.`,n,r)};let o=[];for(let e of rE(c.args)){if(e.trim()===``)continue;let a=XT(e,t,n,r,i);if(!a.ok)return a;o.push(a.value)}return{ok:!0,value:a(...o)}}return a===`true`?{ok:!0,value:!0}:a===`false`?{ok:!0,value:!1}:/^-?\d+(?:\.\d+)?$/.test(a)?{ok:!0,value:Number(a)}:/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(a)?{ok:!0,value:tE(t,a)}:{ok:!1,diagnostic:qT(`PUGGY_UNSUPPORTED_EXPRESSION`,`Unsupported expression.`,n,r)}}function ZT(e){let t=typeof e==`string`?{profile:e}:e??{},n=t.profile??`data-only`,r={...n===`ui-safe`?QT():{},...t.capabilities??{}};return{allowCalls:t.allowCalls??(n===`ui-safe`||t.capabilities!==void 0),capabilities:r}}function QT(){return{math:{abs(e){return Math.abs(Number(e))},ceil(e){return Math.ceil(Number(e))},floor(e){return Math.floor(Number(e))},max(...e){return Math.max(...e.map(Number))},min(...e){return Math.min(...e.map(Number))},round(e){return Math.round(Number(e))},trunc(e){return Math.trunc(Number(e))}},text:{lower(e){return String(e).toLowerCase()},upper(e){return String(e).toUpperCase()}}}}function $T(e){let t=/^([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\(([\s\S]*)\)$/.exec(e);return t?{callee:t[1],args:t[2]}:null}function eE(e){for(let t of e.matchAll(/[A-Za-z_$][\w$]*/g)){let e=t[0];if(YT.has(e))return{index:t.index??0}}return null}function tE(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;let t=Object.getOwnPropertyDescriptor(n,e);if(!t||!(`value`in t))return;n=t.value}return n}function nE(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;let t=Object.getOwnPropertyDescriptor(n,e);if(!t||!(`value`in t))return;n=t.value}return n}function rE(e){let t=[],n=``,r=null,i=0;for(let a=0;a<e.length;a+=1){let o=e[a];if(r){n+=o,o===r&&e[a-1]!==`\\`&&(r=null);continue}if(o===`"`||o===`'`){r=o,n+=o;continue}if(o===`(`){i+=1,n+=o;continue}if(o===`)`){--i,n+=o;continue}if(o===`,`&&i===0){t.push(n.trim()),n=``;continue}n+=o}return n.trim()!==``&&t.push(n.trim()),t}var iE=new Set([`switch`,`case`,`while`,`for`,`unless`,`extends:`]),aE=new Set([`if`,`else`,`each`,`include`,`extends`,`block`,`mixin`]),oE=/^[A-Za-z_:][A-Za-z0-9_:-]*$/;function sE(e){let t=e.replace(/\r\n?/g,`
|
|
75
|
+
`).split(`
|
|
76
|
+
`).map((e,t)=>{if(e.trim()===``)return null;let n=e.match(/^ */)?.[0].length??0;return{raw:e,text:e.slice(n),line:t+1,indent:n,column:n+1}}).filter(e=>e!==null),n=[],r=[{indent:-2,children:n}],i=0,a=!0;for(let e of t){for(;r.length>1&&e.indent<=r[r.length-1].indent;)r.pop();let t=r[r.length-1];if(t.node?.kind===`element`&&t.node.rawText&&e.indent>t.indent){t.children.push({kind:`text`,value:e.raw.slice(Math.min(e.raw.length,t.indent+2)),line:e.line,column:t.indent+3}),i=e.indent,a=!0;continue}if(e.indent%2!=0||e.indent>i+2||e.indent>i&&!a)return{ok:!1,diagnostics:[qT(`PUGGY_BAD_INDENT`,`Invalid indentation level.`,e.line,e.column)]};let n=cE(e);if(!n.ok)return n;let o=r[r.length-1];if(n.node.kind===`else`){let t=o.children[o.children.length-1];if(t?.kind!==`if`)return{ok:!1,diagnostics:[qT(`PUGGY_UNKNOWN_DIRECTIVE`,`Unknown directive: else.`,e.line,e.column)]};r.push({indent:e.indent,children:t.alternate,node:t}),i=e.indent,a=!0;continue}o.children.push(n.node);let s=fE(n.node);s&&r.push({indent:e.indent,children:s,node:n.node}),i=e.indent,a=s!==null}return{ok:!0,nodes:n}}function cE(e){let[t]=e.text.split(/\s+/,1);if(e.text.startsWith(`//-`)||/^doctype(?:\s+|$)/.test(e.text))return{ok:!0,node:{kind:`omit`,children:[],line:e.line,column:e.column}};let n=/^\|\s?(.*)$/.exec(e.text);if(n)return{ok:!0,node:{kind:`text`,value:n[1]??``,line:e.line,column:e.column+2}};let r=/^=\s?(.*)$/.exec(e.text);if(r)return{ok:!0,node:{kind:`expr`,expression:r[1]??``,line:e.line,column:e.column+1}};if(t&&iE.has(t))return{ok:!1,diagnostics:[qT(`PUGGY_UNKNOWN_DIRECTIVE`,`Unknown directive: ${t}.`,e.line,e.column)]};if(e.text===`else`)return{ok:!0,node:{kind:`else`}};let i=/^if\s+(.+)$/.exec(e.text);if(i)return{ok:!0,node:{kind:`if`,expression:i[1].trim(),consequent:[],alternate:[],line:e.line,column:e.column}};let a=/^each\s+([A-Za-z_$][\w$]*)\s+in\s+(.+)$/.exec(e.text);if(a)return{ok:!0,node:{kind:`each`,itemName:a[1],listExpression:a[2].trim(),children:[],line:e.line,column:e.column}};let o=/^include\s+([A-Za-z0-9_$./-]+)$/.exec(e.text);if(o)return{ok:!0,node:{kind:`include`,name:o[1],line:e.line,column:e.column}};let s=/^extends\s+([A-Za-z0-9_$./-]+)$/.exec(e.text);if(s)return{ok:!0,node:{kind:`extends`,name:s[1],line:e.line,column:e.column}};let c=/^block\s+([A-Za-z_$][\w$-]*)$/.exec(e.text);if(c)return{ok:!0,node:{kind:`block`,name:c[1],children:[],line:e.line,column:e.column}};let l=/^mixin\s+([A-Za-z_$][\w$]*)\(([^)]*)\)$/.exec(e.text);if(l){let t=_E(l[2]).map(e=>e.trim()).filter(Boolean);return{ok:!0,node:{kind:`mixin`,name:l[1],params:t,children:[],line:e.line,column:e.column}}}let u=/^\+([A-Za-z_$][\w$]*)\((.*)\)$/.exec(e.text);return u?{ok:!0,node:{kind:`mixin-call`,name:u[1],args:_E(u[2]),line:e.line,column:e.column}}:t&&aE.has(t)?{ok:!1,diagnostics:[qT(`PUGGY_UNKNOWN_DIRECTIVE`,`Unknown directive: ${t}.`,e.line,e.column)]}:uE(lE(e))}function lE(e){let t=/^([A-Za-z][\w.#-]*(?:\([^)]*\))?):\s+[A-Za-z][\w.#-]*(?:\([^)]*\))?\s+(.+)$/.exec(e.text);return t?{...e,text:`${t[1]} ${t[2]}`}:e}function uE(e){let t=yE(e.text),n=dE(t.head),r=n>=0?vE(t.head,n):-1;if(n>=0&&r<0)return{ok:!1,diagnostics:[qT(`PUGGY_UNCLOSED_ATTRS`,`Unclosed attribute list.`,e.line,e.column+t.head.length)]};let i=t.head.trimEnd(),a=n<0&&i.endsWith(`.`),o=a?i.slice(0,-1):i,s=n>=0?o.slice(0,n):o,c=n>=0&&r>=0?i.slice(n+1,r):``,l=pE(s||`div`);if(!l.ok)return{ok:!1,diagnostics:[qT(l.code,l.message,e.line,e.column)]};let u=gE(c,e,n);return u.ok?{ok:!0,node:{kind:`element`,tag:l.tag,classes:l.classes,...l.id?{id:l.id}:{},attrs:u.attrs,children:[],line:e.line,column:e.column,...a?{rawText:a}:{},...t.kind===`expr`?{expr:t.inline,exprColumn:e.column+t.inlineColumn-1}:t.inline?{text:t.inline,textColumn:e.column+t.inlineColumn-1}:{}}}:{ok:!1,diagnostics:u.diagnostics}}function dE(e){let t=0,n=null;for(let r=0;r<e.length;r+=1){let i=e[r];if(n){i===n&&e[r-1]!==`\\`&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`[`){t+=1;continue}if(i===`]`){--t;continue}if(t===0&&i===`(`)return r}return-1}function fE(e){switch(e.kind){case`element`:case`omit`:case`each`:case`block`:case`mixin`:return e.children;case`if`:return e.consequent;default:return null}}function pE(e){let t=/^[A-Za-z][\w-]*/.exec(e),n=t?.[0]??`div`,r=t?.[0].length??0,i=[],a;for(;r<e.length;){let t=e[r];if(t===`.`){let t=mE(e,r+1);if(!t)return{ok:!1,code:`PUGGY_UNSUPPORTED_SELECTOR`,message:`Unsupported selector syntax.`};i.push(t.value),r=t.end;continue}if(t!==`#`)return{ok:!1,code:`PUGGY_UNSUPPORTED_SELECTOR`,message:`Unsupported selector syntax.`};let n=/^#([A-Za-z0-9_-]+)/.exec(e.slice(r));if(!n)return{ok:!1,code:`PUGGY_UNSUPPORTED_SELECTOR`,message:`Unsupported selector syntax.`};if(a!==void 0)return{ok:!1,code:`PUGGY_DUPLICATE_ID`,message:`Duplicate id selector.`};a=n[1],r+=n[0].length}return{ok:!0,tag:n,classes:i,...a?{id:a}:{}}}function mE(e,t){let n=t,r=0,i=null;for(;n<e.length;){let t=e[n];if(i){t===i&&e[n-1]!==`\\`&&(i=null),n+=1;continue}if(t===`"`||t===`'`){i=t,n+=1;continue}if(t===`[`){r+=1,n+=1;continue}if(t===`]`){if(--r,r<0)return null;n+=1;continue}if(r===0&&(t===`.`||t===`#`))break;if(/\s/.test(t))return null;n+=1}if(i||r!==0||n===t)return null;let a=e.slice(t,n);return hE(a)?{value:a,end:n}:null}function hE(e){return/^[A-Za-z0-9_!:[\]#@%/>&=$*~|'"().,+-]+$/.test(e)}function gE(e,t,n){if(e.trim()===``)return{ok:!0,attrs:[]};let r=[];for(let i of _E(e)){let e=i.indexOf(`=`),a=(e<0?i:i.slice(0,e)).trim(),o=t.column+n+1;if(!oE.test(a))return{ok:!1,diagnostics:[qT(`PUGGY_INVALID_ATTR`,`Invalid attribute name.`,t.line,o)]};if(e<0){r.push({name:a,value:null,expression:!1,column:o});continue}let s=i.slice(e+1).trim(),c=/^"([\s\S]*)"$/.exec(s)??/^'([\s\S]*)'$/.exec(s);r.push({name:a,value:c?c[1]:s,expression:!c,column:o})}return{ok:!0,attrs:r}}function _E(e){let t=[],n=``,r=null;for(let i=0;i<e.length;i+=1){let a=e[i];if(r){n+=a,a===r&&e[i-1]!==`\\`&&(r=null);continue}if(a===`"`||a===`'`){r=a,n+=a;continue}if((a===`,`||/\s/.test(a))&&n.trim()!==``){t.push(n.trim()),n=``;continue}a===`,`||/\s/.test(a)||(n+=a)}return n.trim()!==``&&t.push(n.trim()),t}function vE(e,t){let n=null;for(let r=t+1;r<e.length;r+=1){let t=e[r];if(n){t===n&&e[r-1]!==`\\`&&(n=null);continue}if(t===`"`||t===`'`){n=t;continue}if(t===`)`)return r}return-1}function yE(e){let t=0,n=0,r=null;for(let i=0;i<e.length;i+=1){let a=e[i];if(r){a===r&&e[i-1]!==`\\`&&(r=null);continue}if(a===`"`||a===`'`){r=a;continue}if(a===`(`){t+=1;continue}if(a===`)`){--t;continue}if(a===`[`){n+=1;continue}if(a===`]`){--n;continue}if(t===0&&n===0&&a===`=`)return{head:e.slice(0,i),inline:e.slice(i+1).trimStart(),inlineColumn:i+2+bE(e.slice(i+1)),kind:`expr`};if(t===0&&n===0&&/\s/.test(a))return{head:e.slice(0,i),inline:e.slice(i+1),inlineColumn:i+2,kind:`text`}}return{head:e,inline:``,inlineColumn:e.length+1,kind:`text`}}function bE(e){return e.match(/^ */)?.[0].length??0}var xE=new Set([`script`,`iframe`,`object`,`embed`,`base`,`link`,`meta`,`svg`,`math`,`template`,`plaintext`,`xmp`,`noscript`]),SE=new Set([`meta`]),CE=new Set([`href`,`src`,`action`,`formaction`]);function wE(e,t,n){let r=sE(e);if(!r.ok)return JT(r.diagnostics);let i={data:t,options:n,mixins:new Map,blocks:FE(r.nodes),includeStack:[],mixinStack:[]},a=NE(r.nodes,i);if(!a.ok)return a;let o=TE(a.nodes,i);return o.ok?{ok:!0,html:o.html,diagnostics:[]}:o}function TE(e,t){let n=``;for(let r of e){let e=EE(r,t);if(!e.ok)return e;n+=e.html}return{ok:!0,html:n}}function EE(e,t){switch(e.kind){case`element`:return DE(e,t);case`text`:{let n=IE(e.value,t,e.line,e.column);return n.ok?{ok:!0,html:zE(n.value)}:JT([n.diagnostic])}case`expr`:{let n=XT(e.expression,t.data,e.line,e.column,t.options.expressions);return n.ok?{ok:!0,html:zE(RE(n.value))}:JT([n.diagnostic])}case`omit`:return{ok:!0,html:``};case`if`:{let n=XT(e.expression,t.data,e.line,e.column+3,t.options.expressions);return n.ok?TE(n.value?e.consequent:e.alternate,t):JT([n.diagnostic])}case`each`:{let n=XT(e.listExpression,t.data,e.line,e.column,t.options.expressions);if(!n.ok)return JT([n.diagnostic]);if(!Array.isArray(n.value))return{ok:!0,html:``};let r=``;for(let i of n.value){let n={...t,data:{...t.data,[e.itemName]:i}},a=TE(e.children,n);if(!a.ok)return a;r+=a.html}return{ok:!0,html:r}}case`include`:{if(t.includeStack.includes(e.name))return JT([{code:`PUGGY_INCLUDE_CYCLE`,message:`Recursive include is not allowed.`,line:e.line,column:e.column}]);let n=t.options.modules?.[e.name];if(n===void 0)return JT([{code:`PUGGY_MISSING_MODULE`,message:`Missing virtual module: ${e.name}.`,line:e.line,column:e.column}]);let r=sE(n);return r.ok?TE(r.nodes,{...t,includeStack:[...t.includeStack,e.name]}):JT(r.diagnostics)}case`block`:return TE(e.children,t);case`mixin`:return t.mixins.set(e.name,e),{ok:!0,html:``};case`mixin-call`:{let n=t.mixins.get(e.name);if(!n)return JT([{code:`PUGGY_UNKNOWN_MIXIN`,message:`Unknown mixin: ${e.name}.`,line:e.line,column:e.column}]);if(t.mixinStack.includes(e.name))return JT([{code:`PUGGY_MIXIN_CYCLE`,message:`Recursive mixin call is not allowed.`,line:e.line,column:e.column}]);let r={...t.data};for(let i=0;i<n.params.length;i+=1){let a=XT(e.args[i]??``,t.data,e.line,e.column+1,t.options.expressions);if(!a.ok)return JT([a.diagnostic]);r[n.params[i]]=a.value}return TE(n.children,{...t,data:r,mixinStack:[...t.mixinStack,e.name]})}case`extends`:return{ok:!0,html:``};default:return{ok:!0,html:``}}}function DE(e,t){if(xE.has(e.tag.toLowerCase()))return SE.has(e.tag.toLowerCase())?{ok:!0,html:``}:JT([{code:`PUGGY_UNSAFE_TAG`,message:`Unsafe tag is not allowed.`,line:e.line,column:e.column}]);let n=[];e.classes.length>0&&n.push(`class="${zE(e.classes.join(` `))}"`),e.id&&n.push(`id="${zE(e.id)}"`);for(let r of e.attrs){if(OE(r.name)&&r.name.toLowerCase()!==`style`)return JT([{code:`PUGGY_UNSAFE_ATTR`,message:`Unsafe attribute is not allowed.`,line:e.line,column:r.column}]);if(r.value===null){n.push(r.name);continue}let i=r.expression?XT(r.value,t.data,e.line,e.column,t.options.expressions):{ok:!0,value:r.value};if(!i.ok)return JT([i.diagnostic]);let a=RE(i.value);if(jE(r.name)&&ME(a))return JT([{code:`PUGGY_UNSAFE_URL`,message:`Unsafe URL protocol is not allowed.`,line:e.line,column:r.column}]);n.push(`${r.name}="${zE(a)}"`)}let r=n.length>0?` ${n.join(` `)}`:``;if(e.tag.toLowerCase()===`style`){let t=kE(e);return{ok:!0,html:`<${e.tag}${r}>${t}</${e.tag}>`}}if(e.rawText)return{ok:!0,html:`<${e.tag}${r}>${zE(AE(e))}</${e.tag}>`};let i=``;if(e.text){let n=IE(e.text,t,e.line,e.textColumn??e.column);if(!n.ok)return JT([n.diagnostic]);i+=zE(n.value)}if(e.expr){let n=XT(e.expr,t.data,e.line,e.exprColumn??e.column,t.options.expressions);if(!n.ok)return JT([n.diagnostic]);i+=zE(RE(n.value))}let a=TE(e.children,t);return a.ok?(i+=a.html,{ok:!0,html:`<${e.tag}${r}>${i}</${e.tag}>`}):a}function OE(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`srcdoc`||t===`style`}function kE(e){return AE(e).replace(/<\/style/gi,`<\\/style`)}function AE(e){let t=[];e.text&&t.push(LE(e.text));for(let n of e.children)n.kind===`text`&&t.push(n.value);return t.join(`
|
|
77
|
+
`)}function jE(e){let t=e.toLowerCase();return CE.has(t)||t.endsWith(`:href`)||t.endsWith(`:src`)}function ME(e){return/^\s*(?:javascript|vbscript|data):/i.test(e)}function NE(e,t){let n=e.find(e=>e.kind!==`block`);if(n?.kind!==`extends`)return{ok:!0,nodes:e};let r=t.options.modules?.[n.name];if(r===void 0)return JT([{code:`PUGGY_MISSING_MODULE`,message:`Missing virtual module: ${n.name}.`,line:n.line,column:n.column}]);let i=sE(r);return i.ok?{ok:!0,nodes:PE(i.nodes,t.blocks)}:JT(i.diagnostics)}function PE(e,t){return e.map(e=>e.kind===`block`?t.get(e.name)??e:`children`in e?{...e,children:PE(e.children,t)}:e.kind===`if`?{...e,consequent:PE(e.consequent,t),alternate:PE(e.alternate,t)}:e)}function FE(e){let t=new Map;for(let n of e)n.kind===`block`&&t.set(n.name,n);return t}function IE(e,t,n,r){let i=``,a=0;for(let o of e.matchAll(/#\{([^}]*)\}/g)){i+=e.slice(a,o.index);let s=XT(o[1]??``,t.data,n,r+(o.index??0)+2,t.options.expressions);if(!s.ok)return{ok:!1,diagnostic:s.diagnostic};i+=RE(s.value),a=(o.index??0)+o[0].length}return i+=e.slice(a),{ok:!0,value:LE(i)}}function LE(e){return e.replace(/#\[[A-Za-z][\w-]*(?:[.#][\w-]+)*\s+([^\]]*)\]/g,`$1`)}function RE(e){return e==null||typeof e==`object`||typeof e==`function`||typeof e==`symbol`?``:String(e)}function zE(e){return e.replace(/[&<>"]/g,e=>{switch(e){case`&`:return`&`;case`<`:return`<`;case`>`:return`>`;default:return`"`}})}function BE(e,t={},n={}){return wE(e,t,n)}var VE=new Set([`mermaid`,`d2`,`svg`,`iframe`,`diashort`,`html`,`pug`]),HE=`https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4`,UE=`:where(html),:where(body){margin:0;min-height:100%;}:where(body){background:transparent;padding:1rem;font-family:Inter,ui-sans-serif,system-ui,sans-serif;}`;function WE(e){return e!==null&&VE.has(e)}var GE=(0,j.memo)(function({format:e,source:t,fillHeight:n=!1}){return e===`mermaid`?(0,Q.jsx)(lD,{source:t}):e===`html`?(0,Q.jsx)(QE,{source:t,fillHeight:n}):e===`pug`?(0,Q.jsx)($E,{source:t,fillHeight:n}):e===`svg`?(0,Q.jsx)(cD,{source:t}):e===`iframe`||e===`diashort`?(0,Q.jsx)(eD,{format:e,source:t}):(0,Q.jsxs)(`div`,{className:`text-xs font-mono`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 text-muted-foreground text-[10px] uppercase tracking-wider`,children:[e,` diagram (source)`]}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-foreground`,children:t})]})});function KE(e){let t=e.trim();if(!t)return{ok:!1,message:`SVG render error`};let n=[],r=0,i=-1,a=-1;for(;r<t.length;){if(t[r]!==`<`){let e=t.indexOf(`<`,r),i=t.slice(r,e===-1?t.length:e);if(!(n.length>0)&&i.trim())return{ok:!1,message:`SVG render error`};r=e===-1?t.length:e;continue}if(t.startsWith(`<!--`,r)){let e=t.indexOf(`-->`,r+4);if(e===-1)return{ok:!1,message:`SVG render error`};r=e+3;continue}if(t.startsWith(`<![CDATA[`,r)){let e=t.indexOf(`]]>`,r+9);if(e===-1||n.length===0)return{ok:!1,message:`SVG render error`};r=e+3;continue}if(t.startsWith(`<?`,r)){let e=t.indexOf(`?>`,r+2);if(e===-1||i!==-1)return{ok:!1,message:`SVG render error`};r=e+2;continue}if(t.slice(r,r+9).toUpperCase()===`<!DOCTYPE`){let e=tD(t,r+9);if(e===-1||i!==-1)return{ok:!1,message:`SVG render error`};r=e+1;continue}let e=nD(t,r);if(!e)return{ok:!1,message:`SVG render error`};let{name:o,closing:s,selfClosing:c,end:l}=e;if(s){if(n.pop()!==o)return{ok:!1,message:`SVG render error`};o===`svg`&&n.length===0&&(a=l),r=l;continue}if(i===-1){if(o!==`svg`||c)return{ok:!1,message:`SVG render error`};i=r}else if(a!==-1)return{ok:!1,message:`SVG render error`};c||n.push(o),r=l}return i===-1||a===-1||n.length!==0?{ok:!1,message:`SVG render error`}:{ok:!0,markup:t.slice(i,a)}}function qE(e){return!e.ctrlKey&&!e.metaKey?null:e.deltaY<0?`in`:e.deltaY>0?`out`:null}function JE(e,t){try{let n=new URL(t);if(n.protocol!==`https:`&&n.protocol!==`http:`)return null;if(e===`diashort`||n.hostname===`diashort.apps.quickable.co`){let e=n.pathname.match(/^\/(?:d|e)\/([^/?#]+)/);if(!e)return null;let t=new URL(`/d/${e[1]}`,n.origin);for(let[e,r]of n.searchParams.entries())t.searchParams.set(e,r);return t.toString()}return n.toString()}catch{return null}}function YE(){let e=TT(),[t]=(0,j.useState)(`render`),[n,r]=(0,j.useState)(1),i=e!==null&&e.state.type===`embed`?e.state:null,a=e!==null&&e.state.type===`embed`?e.dispatch:null;return{mode:i?i.renderMode:t,zoom:i?i.zoom:n,adjustZoom:e=>{if(e===`in`){a?a({type:`ZOOM_IN`}):r(e=>xT(e+.25));return}e===`out`&&(a?a({type:`ZOOM_OUT`}):r(e=>xT(e-.25)))}}}function XE(e){return e===1?void 0:{transform:`scale(${e})`,transformOrigin:`top left`}}function ZE({zoom:e,adjustZoom:t,children:n,className:r}){return(0,Q.jsx)(`div`,{onWheel:e=>{let n=qE(e);n&&(e.preventDefault(),t(n))},"data-embed-zoomable":`true`,className:`overflow-auto overscroll-contain touch-pan-x touch-pan-y rounded-md border border-border/60 bg-background ${r??``}`,children:(0,Q.jsx)(`div`,{"data-embed-zoom-content":`true`,style:XE(e),className:`min-w-full origin-top-left`,children:n})})}function QE({source:e,fillHeight:t=!1}){let{mode:n,zoom:r,adjustZoom:i}=YE(),a=rD(e);return(0,Q.jsx)(Q.Fragment,{children:n===`render`?(0,Q.jsx)(ZE,{zoom:r,adjustZoom:i,children:(0,Q.jsx)(`iframe`,{"data-html-embed":`true`,srcDoc:a,title:`HTML content`,sandbox:`allow-scripts`,className:b(`block w-full border-0 bg-background`,t?`h-[calc(100dvh-8rem)]`:`h-[420px]`)})}):(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono text-foreground`,children:e})})}function $E({source:e,fillHeight:t=!1}){let{mode:n}=YE();if(n===`source`)return(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono text-foreground`,children:e});let r=BE(e);return r.ok?(0,Q.jsx)(QE,{source:r.html,fillHeight:t}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-destructive`,children:`Pug render error`}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono text-destructive`,children:r.diagnostics.map(e=>`${e.code} at ${e.line}:${e.column} ${e.message}`).join(`
|
|
78
|
+
`)}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono text-foreground`,children:e})]})}function eD({format:e,source:t}){let{mode:n,zoom:r,adjustZoom:i}=YE(),a=JE(e,t);return(0,Q.jsx)(Q.Fragment,{children:n===`render`&&a?(0,Q.jsx)(ZE,{zoom:r,adjustZoom:i,children:(0,Q.jsx)(`iframe`,{"data-remote-embed":`true`,"data-remote-embed-url":a,src:a,title:`Embedded content`,sandbox:`allow-scripts allow-same-origin`,referrerPolicy:`no-referrer`,className:`block h-[420px] w-full min-w-[720px] border-0 bg-background sm:min-w-0`})}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[a?null:(0,Q.jsx)(`div`,{className:`text-xs text-destructive`,children:`Embed URL is invalid or unsupported`}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono text-foreground`,children:a??t})]})})}function tD(e,t){let n=null;for(let r=t;r<e.length;r+=1){let t=e[r];if(n){t===n?n=null:t===`\\`&&(r+=1);continue}if(t===`"`||t===`'`){n=t;continue}if(t===`>`)return r}return-1}function nD(e,t){let n=tD(e,t+1);if(n===-1)return null;let r=e.slice(t+1,n).trim();if(!r)return null;let i=r.startsWith(`/`),a=i?r.slice(1).trim():r,o=a.match(/^([A-Za-z][\w:-]*)\b/);return o?{name:o[1],closing:i,selfClosing:!i&&/\/\s*$/.test(a),end:n+1}:null}function rD(e){let t=e.trim();return t?oD(t)?sD(t):iD(t):iD(``)}function iD(e){return`<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />${aD()}<style>${UE}</style></head><body>${e}</body></html>`}function aD(){return`<script src="${HE}"><\/script>`}function oD(e){return/<!doctype html/i.test(e)||/<html[\s>]/i.test(e)||/<head[\s>]/i.test(e)}function sD(e){let t=/<head[\s>]/i.test(e)?e:e.replace(/<html([^>]*)>/i,`<html$1><head></head>`),n=t.includes(HE)?t:t.replace(/<\/head>/i,`${aD()}</head>`);return/<style[^>]*data-tinkaria-embed-base/i.test(n)?n:n.replace(/<\/head>/i,`<style data-tinkaria-embed-base>${UE}</style></head>`)}function cD({source:e}){let{mode:t,zoom:n,adjustZoom:r}=YE(),i=KE(e),a=i.ok?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i.markup)}`:null;return(0,Q.jsx)(Q.Fragment,{children:t===`render`&&i.ok?(0,Q.jsxs)(ZE,{zoom:n,adjustZoom:r,className:`border-0 bg-transparent`,children:[(0,Q.jsx)(`img`,{"data-svg-render":`true`,alt:``,src:a??void 0,className:`block h-auto max-h-[320px] max-w-none rounded-md border border-border/60 bg-background p-3 w-auto`}),(0,Q.jsx)(`script`,{type:`text/plain`,"data-svg-source":`true`,children:e})]}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[i.ok?null:(0,Q.jsx)(`div`,{className:`text-xs text-destructive`,children:i.message}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono text-foreground`,children:e})]})})}function lD({source:e}){let t=(0,j.useRef)(null),[n,r]=(0,j.useState)(null),{mode:i,zoom:a,adjustZoom:s}=YE();return(0,j.useEffect)(()=>{let n=!1;if(i!==`render`)return()=>{n=!0};async function a(){let i=t.current;if(i)try{r(null);let t=await o(()=>import(`./mermaid.core-QqY9gSNe.js`),__vite__mapDeps([11,12,13,14,1,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]));t.default.initialize({startOnLoad:!1,theme:`default`,securityLevel:`strict`});let a=`mermaid-${x().slice(0,8)}`,{svg:s}=await t.default.render(a,e);n||(i.innerHTML=s)}catch(e){n||r(e instanceof Error?e.message:String(e))}}return a(),()=>{n=!0}},[i,e]),n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs text-destructive`,children:`Diagram render error`}),(0,Q.jsx)(`pre`,{className:`text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all`,children:e})]}):i===`source`?(0,Q.jsx)(`pre`,{className:`text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all`,children:e}):(0,Q.jsx)(ZE,{zoom:a,adjustZoom:s,className:`border-0 bg-transparent`,children:(0,Q.jsx)(`div`,{ref:t,"data-mermaid-source":e,className:`inline-flex min-h-[60px] min-w-full items-center justify-center [&_svg]:h-auto [&_svg]:max-w-none`})})}var uD=new Set([`<`,`>`,`{`,`}`,`[`,`]`]),dD=new Set(`for.do.while.if.else.return.function.var.let.const.true.false.undefined.this.new.delete.typeof.in.instanceof.void.break.continue.switch.case.default.throw.try.catch.finally.debugger.with.yield.async.await.class.extends.super.import.export.from.static`.split(`.`)),fD=new Set([...dD,`type`,`interface`,`enum`,`implements`,`readonly`,`abstract`,`declare`,`namespace`,`module`,`private`,`protected`,`public`,`override`,`keyof`,`infer`,`is`,`asserts`,`satisfies`,`as`,`unknown`,`never`,`any`]),pD=new Set([`+`,`-`,`*`,`/`,`%`,`=`,`!`,`&`,`|`,`^`,`~`,`!`,`?`,`:`,`.`,`,`,`;`,`'`,`"`,`.`,`(`,`)`,`[`,`]`,`#`,`@`,`\\`,...uD]),mD={keywords:dD,onCommentStart:VD,onCommentEnd:HD};function hD(e){let t=0;return/\binterface\s+[A-Za-z_$][\w$]*/.test(e)&&(t+=2),/\btype\s+[A-Za-z_$][\w$]*\s*=/.test(e)&&(t+=2),/\benum\s+[A-Za-z_$][\w$]*/.test(e)&&(t+=2),/\b(?:implements|readonly|declare|namespace|satisfies|infer|keyof|asserts)\b/.test(e)&&(t+=2),/:\s*[A-Za-z_$][\w$]*(?:<[^>\n]+>)?(?:\[\])?(?=\s*[,)=;{])/m.test(e)&&(t+=1),/\b(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*:\s*/.test(e)&&(t+=1),/\)\s*:\s*[A-Za-z_$][\w$]*(?:<[^>\n]+>)?(?:\[\])?\s*(?:=>|\{)/.test(e)&&(t+=1),t>=2}function gD(e,t){if(e[t]!==`<`)return!1;let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`<`){n++;continue}if(t===`>`){if(n--,n===0){let t=i+1;for(;t<e.length&&/\s/.test(e[t]);)t++;if(!(r&&e[t]===`(`))return!1;let n=e.slice(t,t+320);return/\)\s*(?::[\s\S]{0,120}?)?=>/.test(n)}continue}if(n!==0){if(/[$A-Za-z_]/.test(t)){r=!0;continue}if(!/[\s,\.\=\?\:\|\&\[\]]/.test(t))return!1}}return!1}var _D=[`identifier`,`keyword`,`string`,`class`,`property`,`entity`,`jsxliterals`,`sign`,`comment`,`break`,`space`],[vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD]=_D.map((e,t)=>t);function kD(e){return/^[^\S\r\n]+$/g.test(e)}function AD(e){return pD.has(e)}function jD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function MD(e){return/^[\w_]+$/.test(e)||PD(e)}function ND(e){let t=e[0];return MD(t)&&t===t.toUpperCase()||e===`null`}function PD(e){return/[^\u0000-\u007f]/.test(e)}function FD(e){return/^[a-zA-Z]$/.test(e)}function ID(e){return FD(e)||PD(e)}function LD(e){return ID(e[0])&&(e.length===1||MD(e.slice(1)))}function RD(e){return e==="`"}function zD(e){return e===`"`||e===`'`}function BD(e){return zD(e)||RD(e)}function VD(e,t){let n=e+t;return n===`/*`?2:n===`//`?1:0}function HD(e,t){return e+t===`*/`?2:t===`
|
|
79
|
+
`?1:0}function UD(e){return e[0]===`/`&&!VD(e[0],e[1])}function WD(e,t){let n={...mD,...t},r=!!(t&&t.keywords instanceof Set),i=hD(e),a=r?n.keywords:i?fD:dD,{onCommentStart:o,onCommentEnd:s}=n,c=``,l=-1,u=[-1,``],d=[-2,``],f=[],p=!1,m=0,h=!1,g=0,_=()=>p&&!h&&!m,v=()=>m&&!_(),y=()=>!m&&_()&&!h&&g>0,b=null,x=!1,S=0,C=0,w=()=>b!==null,T=()=>x,E=()=>C>S,D=()=>C>0&&C===S,O=()=>w()||E();function k(e){let t=e===`
|
|
80
|
+
`;if(v()){if(w())return bD;let[,t]=u;if(LD(e)&&(t===`<`||t===`</`))return CD}if(y())return wD;if(w()||E())return bD;if(a.has(e))return u[1]===`.`?vD:yD;if(t)return DD;if(kD(e))return OD;if(e.split(``).every(AD))return TD;if(ND(e))return v()?vD:xD;if(LD(e)){let e=u[1]===`.`&&LD(d[1]);if(!O()&&!e)return vD;if(e)return SD}return bD}let A=(e,t)=>{if(t&&(c=t),c){l=typeof e==`number`?e:k(c);let t=[l,c];l!==OD&&l!==DD&&(d=u,u=t),f.push(t)}c=``};for(let t=0;t<e.length;t++){let r=e[t],i=e[t-1],l=e[t+1],d=i+r,f=r+l;if(typeof n.onQuote==`function`&&r===`'`&&!w()&&!y()&&!E()){let i=n.onQuote(r,t,e);if(typeof i==`number`&&i>=1&&!Number.isNaN(i)){let n=Math.min(i,e.length-t),r=t+n;A(),c=e.slice(t,r),A(vD),t=r-1;continue}}if(zD(r)&&!y()&&!E()){A(),i!==`\\`&&(b&&r===b?b=null:b||=r),A(bD,r);continue}if(!E()&&i!==`\\n`&&RD(r)){A(),A(bD,r),C++;continue}if(E()){if(i!==`\\n`&&RD(r)&&C>0){A(),C--,A(bD,r);continue}if(f==="${"){S++,A(bD),A(TD,f),t++;continue}}if(D()&&r===`}`){A(),S--,A(TD,r);continue}if(_()&&r===`{`){A(),A(TD,r),h=!0;continue}if(p){if(!m&&r===`<`){A(),l===`/`?(m=2,c=f,t++):(m=1,c=r),A(TD);continue}if(m){if(r===`>`&&!`/=`.includes(i)){A(),m===1?(m=0,g++):(m=0,p=!1),A(TD,r);continue}if(f===`/>`||f===`</`){c!==`<`&&c!==`/`&&A(),f===`/>`?m=0:g--,g||(p=!1),c=f,t++,A(TD);continue}if(r===`<`){A(),c=r,A(TD);continue}if(l===`-`&&!O()&&!y()&&c){A(SD,c+r+l),t++;continue}if(l===`=`&&!O()&&!kD(r)){kD(c)&&A();let e=c+r;if(LD(e)){A(SD,e);continue}}}}if(!m&&(r===`<`&&ID(l)||f===`</`)){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;let i=n>=0?e[n]:``,[o,s]=u,d=!1,f=!1;if(c&&!kD(c)){let e=c;ND(e)||e===`true`||e===`false`?d=!0:a.has(e)&&LD(e)?f=!0:LD(e)&&(d=!0)}let h=r===`<`&&/[$\w\]\)]/.test(i)&&(d||!f&&(o===vD||o===xD||o===TD&&(s===`)`||s===`]`))),g=r===`<`&&gD(e,t);!h&&!g&&(m=l===`/`?2:1),r===`<`&&(l===`/`||FD(l))&&!h&&!g&&!O()&&!y()&&!T()&&(p=!0)}let v=BD(r),k=E(),j=!p&&UD(f),M=y();if(v||k||zD(b))c+=r;else if(j){A();let[n,i]=u;if(j&&n!==-1&&!(n===TD&&i!==`)`||n===ED)){c=r,A();continue}x=!0;let a=t++,o=()=>t>=e.length,s=()=>o()||e[t]===`
|
|
81
|
+
`,l=!1;for(;!s();t++)if(e[t]===`/`&&e[t-1]!==`\\`){for(l=!0;a!==t&&/^[a-z]$/.test(e[t+1])&&!s();)t++;break}x=!1,a!==t&&l?(c=e.slice(a,t+1),A(bD)):(c=r,A(),t=a)}else if(o(r,l)){A();let n=t,i=o(r,l);if(i)for(;t<e.length&&s(e[t-1],e[t])!=i;t++);c=e.slice(n,t+1),A(ED)}else r===` `||r===`
|
|
82
|
+
`?r===` `&&(kD(c)||!c||M)?(c+=r,l===`<`&&A()):(A(),c=r,A()):h&&r===`}`?(A(),c=r,A(),h=!1):M&&!uD.has(r)||E()||(MD(r)===MD(c[c.length-1])||_())&&!pD.has(r)?c+=r:(d===`</`&&(c=d),A(),d!==`</`&&(c=r),f===`</`||f===`/>`?(c=f,A(),t++):uD.has(r)&&A())}return A(),f}function GD(e){let t=[],n=e=>({type:`element`,tagName:`span`,children:e,properties:{className:`sh__line`}});function r(e){let r=e.map(([e,t])=>{let n=_D[e];return{type:`element`,tagName:`span`,children:[{type:`text`,value:t}],properties:{className:`sh__token--${n}`,style:{color:`var(--sh-${n})`}}}});t.push(n(r))}let i=[],a=!1;for(let t=0;t<e.length;t++){let n=e[t],[o,s]=n,c=t===e.length-1;if(o!==DD){if(s.includes(`
|
|
83
|
+
`)){let e=s.split(`
|
|
84
|
+
`);for(let t=0;t<e.length;t++)i.push([o,e[t]]),t<e.length-1&&(r(i),i.length=0)}else i.push(n);a=!1}else a?r([]):(r(i),i.length=0),c&&r([]),a=!0}return i.length&&r(i),t}var KD=e=>{let t=`class="${e.className}"`;if(e.style){let n=Object.entries(e.style).map(([e,t])=>`${e}:${t}`).join(`;`);t+=` style="${n}"`}return t};function qD(e){return e.map(e=>{let{tagName:t}=e,n=e.children.map(e=>{let{tagName:t,children:n,properties:r}=e;return`<${t} ${KD(r)}>${jD(n[0].value)}</${t}>`}).join(``);return`<${t} class="${e.properties.className}">${n}</${t}>`}).join(`
|
|
85
|
+
`)}function JD(e,t){return qD(GD(WD(e,t)))}new Map(_D.map((e,t)=>[e,t]));var YD=t({keywords:()=>XD,onCommentEnd:()=>QD,onCommentStart:()=>ZD}),XD=new Set([`@media`,`@import`,`@keyframes`,`@font-face`,`@supports`,`@page`,`@counter-style`,`@font-feature-values`,`@viewport`,`@counter-style`,`@font-feature-values`,`@document`]),ZD=(e,t)=>e+t===`/*`?1:0,QD=(e,t)=>e+t===`*/`?1:0,$D=t({keywords:()=>eO,onQuote:()=>tO}),eO=new Set(`as.break.const.continue.crate.else.enum.extern.false.fn.for.if.impl.in.let.loop.match.mod.move.mut.pub.ref.return.self.Self.static.struct.super.trait.true.type.unsafe.use.where.while.async.await.dyn.abstract.become.box.do.final.macro.override.priv.typeof.unsized.virtual.yield.try`.split(`.`));function tO(e,t,n){if(e!==`'`||t+1>=n.length)return 1;let r=n[t+1];if(r===`\\`){let e=t+2;for(;e<n.length;){if(n[e]===`\\`){e+=2;continue}if(n[e]===`'`)return e-t+1;e++}return n.length-t}if(r===`_`)return 2;if(/[a-zA-Z]/.test(r)){let e=t+2;for(;e<n.length&&/[a-zA-Z0-9_]/.test(n[e]);)e++;return e<n.length&&n[e]===`'`?e-t+1:e-t}return 1}var nO=t({keywords:()=>rO,onCommentEnd:()=>aO,onCommentStart:()=>iO}),rO=new Set(`and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield`.split(`.`)),iO=(e,t)=>e===`#`?1:0,aO=(e,t)=>t===`
|
|
86
|
+
`?1:0;function oO(e){return e===`#`?1:0}function sO(e,t){return e===`-`&&t===`-`?1:e===`/`&&t===`*`?2:0}function cO(e,t){return e===`/`&&t===`/`?1:e===`/`&&t===`*`?2:e===`#`?1:0}function lO(e,t){return e===`*`&&t===`/`?2:0}var uO={keywords:new Set(`break.case.chan.const.continue.default.defer.else.fallthrough.for.func.go.goto.if.import.interface.map.package.range.return.select.struct.switch.type.var.nil.true.false.iota.append.cap.close.copy.delete.len.make.new.panic.print.println.recover.error.string.int.int8.int16.int32.int64.uint.uint8.uint16.uint32.uint64.float32.float64.bool.byte.rune.complex64.complex128.any`.split(`.`))},dO={keywords:new Set(`abstract.assert.boolean.break.byte.case.catch.char.class.const.continue.default.do.double.else.enum.extends.final.finally.float.for.goto.if.implements.import.instanceof.int.interface.long.native.new.package.private.protected.public.return.short.static.strictfp.super.switch.synchronized.this.throw.throws.transient.try.void.volatile.while.true.false.null.var.record.sealed.permits.yield`.split(`.`))},fO={keywords:new Set(`if.then.else.elif.fi.for.while.until.do.done.case.esac.in.function.return.local.declare.export.readonly.unset.shift.break.continue.exit.trap.source.eval.exec.set.true.false.echo.printf.read.test.cd.pwd.mkdir.rm.cp.mv.ls.cat.grep.sed.awk.find.xargs.sort.uniq.wc.head.tail.cut.tr.chmod.chown.curl.wget`.split(`.`)),onCommentStart:oO},pO={keywords:new Set(`alias.and.begin.break.case.class.def.defined.do.else.elsif.end.ensure.false.for.if.in.module.next.nil.not.or.redo.rescue.retry.return.self.super.then.true.undef.unless.until.when.while.yield.require.include.extend.attr_reader.attr_writer.attr_accessor.private.protected.public.raise.puts.print.lambda.proc.block_given`.split(`.`)),onCommentStart:oO},mO={keywords:new Set(`select.from.where.and.or.not.insert.into.values.update.set.delete.create.table.drop.alter.add.column.index.view.as.join.inner.left.right.outer.full.on.group.by.order.asc.desc.having.limit.offset.union.all.distinct.between.like.in.is.null.true.false.exists.case.when.then.else.end.cast.primary.key.foreign.references.constraint.unique.default.check.grant.revoke.begin.commit.rollback.transaction.if.declare.cursor.fetch.open.close.integer.varchar.text.boolean.date.timestamp.float.decimal.serial.bigint.smallint.char.with.recursive.returning.conflict.do.nothing.coalesce.count.sum.avg.min.max.explain.analyze.using.cascade.SELECT.FROM.WHERE.AND.OR.NOT.INSERT.INTO.VALUES.UPDATE.SET.DELETE.CREATE.TABLE.DROP.ALTER.ADD.COLUMN.INDEX.VIEW.AS.JOIN.INNER.LEFT.RIGHT.OUTER.FULL.ON.GROUP.BY.ORDER.ASC.DESC.HAVING.LIMIT.OFFSET.UNION.ALL.DISTINCT.BETWEEN.LIKE.IN.IS.NULL.TRUE.FALSE.EXISTS.CASE.WHEN.THEN.ELSE.END.CAST.PRIMARY.KEY.FOREIGN.REFERENCES.CONSTRAINT.UNIQUE.DEFAULT.CHECK.BEGIN.COMMIT.ROLLBACK.RETURNING.WITH.INTEGER.VARCHAR.TEXT.BOOLEAN.DATE.TIMESTAMP.FLOAT.DECIMAL.SERIAL.BIGINT.SMALLINT.CHAR.COUNT.SUM.AVG.MIN.MAX.EXPLAIN.ANALYZE.USING.CASCADE`.split(`.`)),onCommentStart:sO,onCommentEnd:lO},hO={keywords:new Set(`auto.break.case.char.const.continue.default.do.double.else.enum.extern.float.for.goto.if.inline.int.long.register.restrict.return.short.signed.sizeof.static.struct.switch.typedef.union.unsigned.void.volatile.while.NULL.true.false.bool.size_t.int8_t.int16_t.int32_t.int64_t.uint8_t.uint16_t.uint32_t.uint64_t.include.define.ifdef.ifndef.endif.pragma.elif`.split(`.`))},gO={keywords:new Set([...hO.keywords,`alignas`,`alignof`,`and_eq`,`asm`,`bitand`,`bitor`,`catch`,`class`,`co_await`,`co_return`,`co_yield`,`compl`,`concept`,`consteval`,`constexpr`,`constinit`,`decltype`,`delete`,`dynamic_cast`,`explicit`,`export`,`final`,`friend`,`mutable`,`namespace`,`new`,`noexcept`,`not_eq`,`nullptr`,`operator`,`or_eq`,`override`,`private`,`protected`,`public`,`reinterpret_cast`,`requires`,`static_assert`,`static_cast`,`template`,`this`,`thread_local`,`throw`,`try`,`typeid`,`typename`,`using`,`virtual`,`xor_eq`,`string`,`vector`,`map`,`set`,`pair`,`shared_ptr`,`unique_ptr`,`optional`,`variant`,`array`,`cout`,`cin`,`endl`,`std`])},_O={keywords:new Set(`abstract.actual.annotation.as.break.by.catch.class.companion.const.constructor.continue.crossinline.data.do.else.enum.expect.external.false.final.finally.for.fun.get.if.import.in.infix.init.inline.inner.interface.internal.is.lateinit.noinline.null.object.open.operator.out.override.package.private.protected.public.reified.return.sealed.set.super.suspend.this.throw.true.try.typealias.val.var.vararg.when.where.while`.split(`.`))},vO={keywords:new Set(`actor.as.associatedtype.async.await.break.case.catch.class.continue.default.defer.deinit.do.else.enum.extension.fallthrough.false.fileprivate.for.func.guard.if.import.in.init.inout.internal.is.lazy.let.nil.open.operator.override.private.protocol.public.repeat.required.rethrows.return.self.some.static.struct.subscript.super.switch.throw.throws.true.try.typealias.var.weak.where.while.String.Int.Double.Float.Bool.Array.Dictionary.Optional.Set.Any.AnyObject.Self.Type`.split(`.`))},yO={keywords:new Set(`abstract.and.array.as.break.callable.case.catch.class.clone.const.continue.declare.default.do.echo.else.elseif.empty.enddeclare.endfor.endforeach.endif.endswitch.endwhile.enum.extends.false.final.finally.fn.for.foreach.function.global.goto.if.implements.include.instanceof.interface.isset.list.match.namespace.new.null.or.print.private.protected.public.readonly.require.return.static.switch.this.throw.trait.true.try.unset.use.var.while.xor.yield`.split(`.`)),onCommentStart:cO,onCommentEnd:lO},bO={keywords:new Set(`and.break.do.else.elseif.end.false.for.function.goto.if.in.local.nil.not.or.repeat.return.then.true.until.while.require.print.pairs.ipairs.type.tostring.tonumber.error.pcall.xpcall.select.next.rawget.rawset.setmetatable.getmetatable.self.table.string.math.io.os.coroutine`.split(`.`)),onCommentStart:sO},xO={keywords:new Set([`true`,`false`,`null`,`yes`,`no`,`on`,`off`,`True`,`False`,`Null`,`Yes`,`No`,`On`,`Off`,`TRUE`,`FALSE`,`NULL`,`YES`,`NO`,`ON`,`OFF`]),onCommentStart:oO},SO={keywords:new Set([`true`,`false`]),onCommentStart:oO},CO={keywords:new Set(`FROM.RUN.CMD.LABEL.MAINTAINER.EXPOSE.ENV.ADD.COPY.ENTRYPOINT.VOLUME.USER.WORKDIR.ARG.ONBUILD.STOPSIGNAL.HEALTHCHECK.SHELL.AS.from.run.cmd.label.expose.env.add.copy.entrypoint.volume.user.workdir.arg.as`.split(`.`)),onCommentStart:oO},wO={keywords:new Set(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.false.finally.fixed.float.for.foreach.goto.if.implicit.in.int.interface.internal.is.lock.long.namespace.new.null.object.operator.out.override.params.private.protected.public.readonly.record.ref.return.sbyte.sealed.short.sizeof.stackalloc.static.string.struct.switch.this.throw.true.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.where.while.yield.get.set.init.value.required`.split(`.`))},TO={keywords:new Set(`ifeq,ifneq,ifdef,ifndef,else,endif,define,endef,include,override,export,unexport,vpath,PHONY,FORCE,SUFFIXES,DEFAULT,PRECIOUS,INTERMEDIATE,SECONDARY,IGNORE,SILENT,EXPORT_ALL_VARIABLES,NOTPARALLEL,ONESHELL,.PHONY,.FORCE,.DEFAULT`.split(`,`)),onCommentStart:oO},EO={python:nO,py:nO,rust:$D,rs:$D,css:YD,scss:YD,go:uO,golang:uO,java:dO,bash:fO,sh:fO,shell:fO,zsh:fO,sql:mO,postgresql:mO,postgres:mO,mysql:mO,sqlite:mO,ruby:pO,rb:pO,c:hO,cpp:gO,"c++":gO,cxx:gO,kotlin:_O,kt:_O,swift:vO,php:yO,lua:bO,yaml:xO,yml:xO,toml:SO,dockerfile:CO,docker:CO,csharp:wO,cs:wO,makefile:TO,make:TO};function DO(e){return EO[e.toLowerCase()]}var OO=()=>{},kO=()=>!1,AO=(0,j.createContext)(OO),jO=(0,j.createContext)(kO);function MO({children:e,onOpenLocalLink:t,onOpenExternalLink:n}){return(0,Q.jsx)(jO.Provider,{value:n??kO,children:(0,Q.jsx)(AO.Provider,{value:t??OO,children:e})})}function NO(){return(0,j.useContext)(AO)}var PO={Task:Ur,TaskOutput:Ur,Bash:bi,Glob:di,Grep:di,ExitPlanMode:qr,Read:kr,Edit:Tr,Write:Er,NotebookEdit:ii,WebFetch:Kn,TodoWrite:ir,WebSearch:di,KillShell:yi,AskUserQuestion:Zr,Skill:hi,EnterPlanMode:qr},FO=xi;function IO(e){return PO[e]?PO[e]:FO}function LO(e,t){if(e.toolKind===`skill`)return e.input.skill;if(e.toolKind===`glob`)return`Search files ${e.input.pattern===`**/*`?`in all directories`:`matching ${e.input.pattern}`}`;if(e.toolKind===`grep`){let t=e.input.pattern,n=e.input.outputMode;return n===`count`?`Count \`${t}\` occurrences`:n===`content`?`Find \`${t}\` in text`:`Find \`${t}\` in files`}return e.toolKind===`bash`?e.input.description||(e.input.command?S_(e.input.command):`Bash`):e.toolKind===`web_search`?e.input.query||`Web Search`:e.toolKind===`read_file`?`Read ${_T(e.input.filePath,t)}`:e.toolKind===`write_file`?`Write ${_T(e.input.filePath,t)}`:e.toolKind===`edit_file`?`Edit ${_T(e.input.filePath,t)}`:e.toolKind===`mcp_generic`?`${b_(e.input.tool)} from ${b_(e.input.server)}`:e.toolKind===`subagent_task`&&e.input.subagentType||e.toolName}function RO({children:e,className:t}){return(0,Q.jsx)(`div`,{className:b(`flex gap-3 justify-start items-center`,t),children:e})}function zO({children:e,className:t}){return(0,Q.jsx)(`div`,{className:b(`flex items-center gap-1.5 text-xs`,t),children:e})}function BO({children:e,className:t}){return(0,Q.jsx)(`span`,{className:b(`font-medium text-foreground/80`,t),children:e})}function VO({children:e}){return(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e})}function HO({children:e,expandedContent:t,defaultExpanded:n=!1,headerAction:r}){let[i,a]=(0,j.useState)(n);return(0,Q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsxs)(`button`,{onClick:()=>a(!i),className:`group/expandable-row min-w-0 flex-1 cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${i?``:`hover:opacity-60 transition-opacity`}`,children:[(0,Q.jsx)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:e}),(0,Q.jsx)(cr,{className:`h-4.5 w-4.5 text-muted-icon translate-y-[0.5px] transition-all duration-200 opacity-0 group-hover/expandable-row:opacity-100 ${i?`rotate-90 opacity-100`:``}`})]}),r?(0,Q.jsx)(`div`,{className:`shrink-0`,children:r}):null]}),i&&t]})}function UO({label:e,children:t,copyText:n}){let[r,i]=(0,j.useState)(!1),a=n??KO(t),o=(0,j.useCallback)(async()=>{try{await navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),2e3)}catch(e){console.warn(`[tinkaria] clipboard write failed:`,e instanceof Error?e.message:String(e))}},[a]);return(0,Q.jsxs)(`div`,{className:`group/codeblock`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e}),(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":r?`Copied`:`Copy content`,onClick:o,className:b(`ml-auto text-muted-foreground opacity-0 group-hover/codeblock:opacity-100 transition-opacity`,r&&`pointer-events-none`),children:r?(0,Q.jsx)(ar,{className:`h-3.5 w-3.5 text-green-400`}):(0,Q.jsx)(br,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`pre`,{className:`text-xs font-mono whitespace-no-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto w-full`,children:t})]})}function WO({children:e,icon:t,className:n}){return(0,Q.jsxs)(`span`,{className:b(`inline-flex items-center gap-1 px-2 py-1 bg-muted border border-border rounded-full`,n),children:[t&&(0,Q.jsx)(t,{className:`h-3 w-3 text-muted-foreground`}),e]})}function GO({children:e,className:t}){return(0,Q.jsxs)(`div`,{className:b(`grid grid-cols-[auto_1fr] gap-2 min-w-0`,t),children:[(0,Q.jsx)(`div`,{className:` min-w-5 flex flex-col relative items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`min-h-full w-[1px] bg-muted-foreground/20`})}),(0,Q.jsx)(`div`,{className:`-ml-[1px] min-w-0 overflow-hidden`,children:e})]})}function KO(e){if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(KO).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return KO(t.children)}return``}function qO(e){if(!(0,j.isValidElement)(e))return null;let t=e.props.className;if(typeof t!=`string`)return null;let n=t.match(/language-(\S+)/);return n?n[1]:null}function JO(e,t){return(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{className:b(e.props.className,t)}):e}var YO={h1:({children:e})=>(0,Q.jsx)(`h1`,{className:`text-[20px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0`,children:e}),h2:({children:e})=>(0,Q.jsx)(`h2`,{className:`text-[18px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0`,children:e}),h3:({children:e})=>(0,Q.jsx)(`h3`,{className:`text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0`,children:e}),h4:({children:e})=>(0,Q.jsx)(`h4`,{className:`text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0`,children:e}),h5:({children:e})=>(0,Q.jsx)(`h5`,{className:`text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0`,children:e}),h6:({children:e})=>(0,Q.jsx)(`h6`,{className:`text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0`,children:e}),pre:({children:e,...t})=>{let n=KO(e),r=qO(e),i=WE(r),a=t[`data-auto-expand`]===`true`;return(0,Q.jsx)(KT,{type:i?`embed`:`code`,title:r??`Code`,rawContent:n,defaultExpanded:a,children:i&&r?(0,Q.jsx)(GE,{format:r,source:n}):(0,Q.jsx)(`div`,{className:`relative overflow-x-auto max-w-full min-w-0 no-code-highlight group/pre`,children:(0,Q.jsx)(`pre`,{className:`min-w-0 rounded-none py-2.5 px-3.5 [.no-pre-highlight_&]:bg-background`,...t,children:e})})})},code:({children:e,className:t,...n})=>{let r=KO(e);if(!t&&!r.includes(`
|
|
87
|
+
`))return(0,Q.jsx)(`code`,{className:`break-normal [overflow-wrap:anywhere] px-1 bg-border/60 dark:[.no-pre-highlight_&]:bg-background dark:[.text-pretty_&]:bg-neutral [.no-code-highlight_&]:!bg-transparent py-0.5 rounded text-sm whitespace-normal`,...n,children:e});let i=typeof t==`string`?t.match(/language-(\S+)/)?.[1]??null:null,a=JD(r,i?DO(i):void 0);return(0,Q.jsx)(`code`,{className:`block text-xs whitespace-pre`,...n,dangerouslySetInnerHTML:{__html:a}})},table:({children:e,...t})=>(0,Q.jsx)(`div`,{className:`border border-border rounded-xl overflow-x-auto`,children:(0,Q.jsx)(`table`,{className:`table-auto min-w-full divide-y divide-border bg-background`,...t,children:e})}),tbody:({children:e,...t})=>(0,Q.jsx)(`tbody`,{className:`divide-y divide-border`,...t,children:e}),th:({children:e,...t})=>(0,Q.jsx)(`th`,{className:`text-left text-xs uppercase text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold`,...t,children:e}),td:({children:e,...t})=>(0,Q.jsx)(`td`,{className:`text-left p-2 pl-0 first:pl-3 [&_*]:font-normal `,...t,children:e}),p:({children:e,...t})=>(0,Q.jsx)(`p`,{className:`break-words mt-5 mb-3 first:mt-0 last:mb-0`,...t,children:e}),blockquote:({children:e,...t})=>(()=>{let n=j.Children.toArray(e),r=n[0];r!==void 0&&(n[0]=JO(r,`mt-0`));let i=n.length-1,a=n[i];return a!==void 0&&(n[i]=JO(a,`mb-0`)),(0,Q.jsx)(`blockquote`,{className:`my-2 mt-5 mb-3 first:mt-0 last:mb-0 border-l-2 border-border/80 pl-2 text-muted-foreground`,...t,children:n})})(),a:({children:e,...t})=>(0,Q.jsx)(`a`,{className:`transition-all underline decoration-2 text-logo decoration-logo/50 hover:text-logo/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40 `,target:`_blank`,rel:`noopener noreferrer`,...t,children:e})};function XO(e){let t=e?.renderRichContentBlocks??!0;return{...YO,pre:({children:e,...n})=>{if(t)return(0,Q.jsx)(`div`,{children:YO.pre({children:e,...n})});let r=KO(e),i=qO(e);return WE(i)&&i?(0,Q.jsx)(`div`,{className:`my-2 overflow-x-auto max-w-full min-w-0`,children:(0,Q.jsx)(GE,{format:i,source:r})}):(0,Q.jsx)(`div`,{className:`relative overflow-x-auto max-w-full min-w-0 no-code-highlight group/pre my-2`,children:(0,Q.jsx)(`pre`,{className:`min-w-0 rounded-xl border border-border bg-muted/30 py-2.5 px-3.5 [.no-pre-highlight_&]:bg-background`,...n,children:e})})},a:({children:t,href:n,onClick:r,...i})=>{let a=e?.onOpenLocalLink??(0,j.useContext)(AO),o=e?.onOpenExternalLink??(0,j.useContext)(jO),s=gT(n);return(0,Q.jsx)(`a`,{...i,className:`transition-all underline decoration-2 text-logo decoration-logo/50 hover:text-logo/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40 `,href:n,target:s?void 0:`_blank`,rel:s?void 0:`noopener noreferrer`,onClick:e=>{if(r?.(e),!e.defaultPrevented){if(s){if(a===OO)return;e.preventDefault(),a(s);return}!n||o===kO||o(n)&&e.preventDefault()}},children:t})}}}({...YO});function ZO({title:e,count:t,children:n,badge:r}){let[i,a]=(0,j.useState)(!1);return t===0?null:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity`,children:[(0,Q.jsx)(cr,{className:b(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,i&&`rotate-90`)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:e}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/60`,children:t}),r]}),i&&(0,Q.jsx)(`div`,{className:`ml-5`,children:n})]})}function QO({title:e,items:t,icon:n,getIcon:r}){return t.length===0?null:(0,Q.jsx)(ZO,{title:e,count:t.length,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,Q.jsx)(WO,{icon:r?r(e):n,children:e},e))})})}function $O(e){let t=e.match(/^mcp__([^_]+)__(.+)$/);return t?{server:t[1],tool:t[2]}:null}function ek({status:e}){return(0,Q.jsx)(`span`,{className:b(`inline-block h-2 w-2 rounded-full shrink-0`,e===`connected`?`bg-emerald-500`:e===`pending`?`bg-yellow-500`:`bg-red-500`)})}function tk(e){switch(e){case`connected`:return`Connected`;case`failed`:return`Connection failed`;case`needs-auth`:return`Needs authentication`;case`pending`:return`Connecting...`;case`disabled`:return`Disabled`;default:return e}}function nk(e){switch(e){case`failed`:return`Check the MCP server process.`;case`needs-auth`:return`Re-authenticate to reconnect.`;default:return null}}function rk({server:e}){let[t,n]=(0,j.useState)(!1),r=e.status===`connected`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`button`,{onClick:()=>r&&e.tools.length>0&&n(!t),className:b(`flex items-center gap-1.5`,r&&e.tools.length>0&&`cursor-pointer hover:opacity-60 transition-opacity`),children:[r&&e.tools.length>0&&(0,Q.jsx)(cr,{className:b(`h-3 w-3 text-muted-foreground transition-transform duration-200`,t&&`rotate-90`)}),(0,Q.jsx)(ek,{status:e.status}),(0,Q.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:b_(e.name)}),r?(0,Q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[e.tools.length,` tools`]}):(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:tk(e.status)})]}),!r&&e.error&&(0,Q.jsx)(`span`,{className:`text-destructive ml-5`,children:e.error}),!r&&!e.error&&(()=>{let t=nk(e.status);return t?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/60 ml-5`,children:t}):null})(),t&&e.tools.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 ml-5`,children:e.tools.map(t=>(0,Q.jsx)(WO,{icon:IO(`mcp__${e.name}__${t}`),children:t},t))})]})}function ik({servers:e}){if(e.length===0)return null;let t=e.filter(e=>e.status===`connected`),n=e.filter(e=>e.status!==`connected`),r=n.length>0?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 ml-1`,children:[(0,Q.jsx)(ek,{status:`failed`}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n.length,` disconnected`]})]}):null;return(0,Q.jsx)(ZO,{title:`MCP Servers`,count:e.length,badge:r,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t.map(e=>(0,Q.jsx)(rk,{server:e},e.name)),n.map(e=>(0,Q.jsx)(rk,{server:e},e.name))]})})}function ak({rawJson:e}){let[t,n]=(0,j.useState)(!1);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity`,children:[(0,Q.jsx)(cr,{className:b(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,t&&`rotate-90`)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Raw Message`})]}),t&&(0,Q.jsx)(`pre`,{className:`ml-5 text-xs whitespace-pre-wrap break-all border border-border rounded-md p-3 overflow-x-auto max-h-96 overflow-y-auto`,children:e})]})}var ok=(0,j.memo)(function({message:e,rawJson:t}){let[n,r]=(0,j.useState)(!1),i=(0,j.useCallback)(()=>r(e=>!e),[]),{coreTools:a,mcpServersWithTools:o}=(0,j.useMemo)(()=>{let t=new Map,n=[];for(let r of e.tools){let e=$O(r);if(e){let n=t.get(e.server)||[];n.push(e.tool),t.set(e.server,n)}else n.push(r)}return{coreTools:n,mcpServersWithTools:e.mcpServers.map(e=>({name:e.name,status:e.status,error:e.error,tools:t.get(e.name)||[]}))}},[e.tools,e.mcpServers]);return(0,Q.jsx)(RO,{className:`w-full`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,Q.jsx)(`button`,{onClick:i,className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${n?``:`hover:opacity-60 transition-opacity`}`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:[(0,Q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,Q.jsx)(cr,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${n?`rotate-90`:``}`})}),(0,Q.jsx)(BO,{className:`text-left`,children:`Session Started`})]})}),n&&(0,Q.jsx)(GO,{className:`my-2 text-xs`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(VO,{children:e.model}),(0,Q.jsx)(QO,{title:`Tools`,items:a,getIcon:e=>PO[e]??FO}),(0,Q.jsx)(QO,{title:`Agents`,items:e.agents,icon:wi}),(0,Q.jsx)(QO,{title:`Commands`,items:e.slashCommands,icon:mi}),(0,Q.jsx)(ik,{servers:o}),t&&(0,Q.jsx)(ak,{rawJson:t})]})})]})})}),sk=(0,j.memo)(function({message:e}){return(0,Q.jsx)(RO,{className:`hidden`,children:(0,Q.jsxs)(HO,{expandedContent:(0,Q.jsx)(GO,{className:`my-4 text-xs`,children:(0,Q.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto`,children:JSON.stringify(e.accountInfo,null,2)})}),children:[(0,Q.jsx)(`div`,{className:`size-5 flex justify-center items-center `,children:(0,Q.jsx)(wi,{className:`h-4 w-4 text-muted-foreground`})}),(0,Q.jsx)(BO,{children:`Account`})]})})}),ck=m({id:`message.ask-user.area`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),lk=m({id:`message.ask-user.option.action`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),uk=m({id:`message.ask-user.custom-input.item`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),dk=m({id:`message.ask-user.submit.action`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),fk=m({id:`message.ask-user.next.action`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`});function pk({question:e,currentIndex:t,totalQuestions:n,onBack:r,children:i}){return(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsxs)(`h3`,{className:`font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border text-foreground flex flex-row items-center gap-2 min-w-0`,children:[r&&t>0?(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:r,className:`text-muted-foreground`,children:(0,Q.jsx)(sr,{className:`h-4 w-4 -ml-0.5`,strokeWidth:3})}):n>1?(0,Q.jsxs)(`span`,{className:`font-bold text-muted-foreground whitespace-nowrap`,children:[t+1,` of `,n]}):null,(0,Q.jsx)(`span`,{className:`text-pretty`,children:e})]}),n>1&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-border`,children:(0,Q.jsx)(`div`,{className:`h-full bg-muted-foreground/40 transition-all duration-300`,style:{width:`${t/n*100}%`}})})]}),i]})}function mk({label:e,description:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`block text-sm text-foreground whitespace-normal break-words`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground whitespace-normal break-words`,children:t})]})}function hk({selected:e,multiSelect:t,onClick:n}){return(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:b(`flex-shrink-0 w-5 h-5 border-1 flex items-center justify-center`,t?`rounded`:`rounded-full`,e?`border-slate-500/0 bg-foreground`:`border-muted-foreground bg-background`,n&&e&&`cursor-pointer`),children:e&&(0,Q.jsx)(ar,{strokeWidth:3,className:`translate-y-[0.5px] h-3 w-3 text-white dark:text-background`})})}function gk({option:e,selected:t,multiSelect:n,onClick:r,isLast:i}){let a=`w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background`,o=i?``:`border-b border-border`;return r?(0,Q.jsx)(S,{variant:`ghost`,onClick:r,className:b(a,o,`transition-all cursor-pointer h-auto w-full justify-start rounded-none border-x-0 border-t-0`),...c(lk),children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(hk,{selected:t,multiSelect:n}),(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsx)(mk,{label:e.label,description:e.description})})]})}):(0,Q.jsx)(`div`,{className:b(a,o),children:(0,Q.jsx)(mk,{label:e.label,description:e.description})})}function _k(e){return e?.answers}function vk(e){return e.id||e.question}var yk=(0,j.memo)(function({message:e,onSubmit:t,isLatest:n}){let r=e.input.questions,i=!!e.result,a=_k(e.result),o=e.result?.discarded===!0,[s,l]=(0,j.useState)(0),[u,d]=(0,j.useState)({}),[f,p]=(0,j.useState)({}),[m,h]=(0,j.useState)(a??null),[g,_]=(0,j.useState)(i),v=(e,t)=>{let n=f[e]?.trim(),i=u[e]||``;if((t||r.find(t=>vk(t)===e))?.multiSelect)return[i,n].filter(Boolean).flatMap(e=>e.split(`, `).filter(Boolean));let a=n||i;return a?[a]:[]},y=e=>{let t=u[vk(e)]||``;return e.multiSelect?t.split(`, `).filter(Boolean):[t]},x=(e,t)=>{let n=vk(e);if(e.multiSelect){let e=u[n]?u[n].split(`, `).filter(Boolean):[],r=e.includes(t)?e.filter(e=>e!==t):[...e,t];d({...u,[n]:r.join(`, `)})}else d({...u,[n]:t}),p({...f,[n]:``}),s<r.length-1&&setTimeout(()=>l(s+1),150)},C=(e,t)=>{let n=vk(e);p({...f,[n]:t}),t&&!e.multiSelect&&d({...u,[n]:``})},w=e=>{let t=vk(e);e.multiSelect&&f[t]&&p({...f,[t]:``})},T=r.every(e=>v(vk(e),e).length>0),E=r[s],D=s===r.length-1,O=E&&v(vk(E),E).length>0,k=()=>{s<r.length-1&&l(s+1)},A=()=>{s>0&&l(s-1)},M=()=>{if(!T)return;let n={};for(let e of r){let t=vk(e);n[t]=v(t,e)}h(n),_(!0),t(e.toolId,r,n)},N=e=>{if(e.key===`Enter`&&!(!E||!O)){if(e.preventDefault(),D){M();return}k()}};if(g||i){let e=m||a||{};return(0,Q.jsx)(`div`,{className:`w-full`,...c(ck),children:(0,Q.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden bg-card`,children:(0,Q.jsx)(`dl`,{className:`divide-y divide-border`,children:r.map(t=>{let n=e[vk(t)]||e[t.question]||[];return(0,Q.jsxs)(`div`,{className:`space-y-3 bg-background p-3 sm:p-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`dt`,{className:`text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Question`}),(0,Q.jsx)(`p`,{className:`text-sm text-foreground text-pretty`,children:t.question})]}),n.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`dt`,{className:`text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:o?`Status`:`Answer`}),(0,Q.jsx)(`dd`,{className:`text-sm font-medium text-foreground`,children:n.join(`, `)})]}),n.length===0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`dt`,{className:`text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:o?`Status`:`Answer`}),(0,Q.jsx)(`dd`,{className:`text-sm font-medium italic text-muted-foreground`,children:o?`Discarded`:`No Response`})]})]},vk(t))})})})})}if(!n)return(0,Q.jsx)(`div`,{className:`w-full py-2`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Zr,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Questions pending (newer question active)`})]})});if(!E)return null;let P=y(E),F=f[vk(E)]||``;return(0,Q.jsxs)(`div`,{className:`w-full space-y-3`,...c(ck),children:[(0,Q.jsxs)(pk,{question:E.question,currentIndex:s,totalQuestions:r.length,onBack:s>0?A:void 0,children:[E.options?.map(e=>(0,Q.jsx)(gk,{option:e,selected:P.includes(e.label),multiSelect:E.multiSelect,onClick:()=>x(E,e.label)},e.label)),(0,Q.jsx)(`div`,{className:`transition-all bg-background`,children:(0,Q.jsxs)(`div`,{className:`flex min-h-[55px] items-center gap-3 pl-4 pr-5`,children:[(0,Q.jsx)(hk,{selected:!!F,multiSelect:E.multiSelect,onClick:E.multiSelect&&F?()=>w(E):void 0}),(0,Q.jsx)(ml,{type:`text`,value:F,onChange:e=>C(E,e.target.value),onKeyDown:N,placeholder:`Other...`,className:`min-w-0 flex-1 rounded-none border-0 bg-transparent px-0 !py-1 text-sm text-foreground outline-none ring-0 placeholder:text-muted-foreground focus-visible:ring-0`,...c(uk)})]})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 mx-2`,children:[!D&&O&&(E.multiSelect||!!F)&&(0,Q.jsx)(S,{size:`sm`,onClick:k,...c(fk),children:`Next`}),D&&(0,Q.jsx)(S,{size:`sm`,onClick:M,disabled:!T,className:b(!T&&`opacity-50 cursor-not-allowed`,`rounded-full`),...c(dk),children:`Submit`})]})]})}),bk=/<!--\s*richcontent:\s*autoExpand\s*-->/;function xk(){return function(e){let t=[];for(let n=0;n<e.children.length;n++){let r=e.children[n];if(r.type!==`html`)continue;let i=r;if(!bk.test(i.value))continue;let a=n+1;if(a<e.children.length){let t=e.children[a];t.data=t.data??{},t.data.hProperties=t.data.hProperties??{},t.data.hProperties[`data-auto-expand`]=`true`}t.push(n)}for(let n=t.length-1;n>=0;n--)e.children.splice(t[n],1)}}function Sk(e){return`error`in e}function Ck(e){return e.result&&!Sk(e.result)?e.result:{accepted:!0,title:e.input.title,kind:e.input.kind,format:e.input.format,source:e.input.source,summary:e.input.summary,collapsed:e.input.collapsed}}function wk({source:e}){return(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert px-0.5 w-full max-w-full space-y-4`,children:(0,Q.jsx)(E,{components:XO(),linkSafety:{enabled:!1},remarkPlugins:[T,xk],children:e})})}function Tk({source:e}){return(0,Q.jsx)(`pre`,{className:`overflow-x-auto rounded-md border border-border/60 bg-muted/30 p-3 text-xs font-mono whitespace-pre-wrap break-all text-foreground`,children:e})}function Ek({summary:e}){return e?(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:e}):null}function Dk(e){let t=e.title||`Content`,n=e.collapsed!==!0,r=(0,Q.jsx)(Ek,{summary:e.summary});return e.format===`markdown`||e.kind===`markdown`?(0,Q.jsx)(KT,{type:`markdown`,title:t,defaultExpanded:n,rawContent:e.source,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,Q.jsx)(wk,{source:e.source})]})}):WE(e.format)?(0,Q.jsx)(KT,{type:`embed`,title:t,defaultExpanded:n,rawContent:e.source,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,Q.jsx)(GE,{format:e.format,source:e.source})]})}):(0,Q.jsx)(KT,{type:`code`,title:t,defaultExpanded:n,rawContent:e.source,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,Q.jsx)(Tk,{source:e.source})]})})}function Ok(e){if(!e.result||!Sk(e.result))return null;let t=e.result.error,n=JSON.stringify(t,null,2);return(0,Q.jsx)(KT,{type:`code`,title:e.input.title||`Content`,defaultExpanded:!0,rawContent:n,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/10 p-3 text-xs text-destructive`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:`Present content validation failed`}),(0,Q.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`source: `,(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:t.source}),`, schema:`,` `,(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:t.schema})]})]}),(0,Q.jsx)(`pre`,{className:`overflow-x-auto rounded-md border border-border/60 bg-muted/30 p-3 text-xs font-mono whitespace-pre-wrap break-all text-foreground`,children:n})]})})}var kk=(0,j.memo)(function({message:e}){return(0,Q.jsx)(`div`,{...c(m({id:`message.present_content.item`,c3ComponentId:`c3-106`,c3ComponentLabel:`present-content`})),children:e.result&&Sk(e.result)?Ok(e):Dk(Ck(e))})}),Ak=m({id:`message.todo.area`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),jk={completed:{Icon:ar,iconClass:`text-emerald-500`,textClass:`text-muted-foreground`},in_progress:{Icon:Gr,iconClass:`text-foreground animate-spin`,textClass:`text-foreground font-medium`},pending:{Icon:mr,iconClass:`text-muted-foreground`,textClass:`text-muted-foreground`}},Mk=(0,j.memo)(function({message:e}){let t=e.input.todos;return t.length?(0,Q.jsx)(`div`,{className:`w-full`,...c(Ak),children:(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,Q.jsxs)(`h3`,{className:`font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2`,children:[(0,Q.jsx)(Hr,{className:`h-4 w-4 text-muted-foreground`}),`Progress`]}),(0,Q.jsx)(`div`,{children:t.map((e,n)=>{let r=n===t.length-1,{Icon:i,iconClass:a,textClass:o}=jk[e.status];return(0,Q.jsxs)(`div`,{className:b(`flex items-center gap-3 px-4 py-2.5 bg-background`,!r&&`border-b border-border`),children:[(0,Q.jsx)(i,{className:b(`h-4 w-4 flex-shrink-0`,a)}),(0,Q.jsx)(`span`,{className:b(`text-sm`,o),children:e.status===`in_progress`?e.activeForm:e.content})]},n)})})]})}):null}),Nk=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Nk{};function Pk(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Fk(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Ik(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Lk(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Rk(e,t){return Ik(e,t,``)}function zk(e,t){return Lk(e,t,``)}function Bk(e,t){return t.slice(0,Vk(e,t))}function Vk(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Hk(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Uk(e,t){if(t)return Gk(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Wk(e,t){if(t)return Gk(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Gk(e,t){if(!t)return[Wk(e),Uk(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Hk(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var Kk=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,qk=RegExp(`[${Kk}]+|\\s+|[^${Kk}]`,`ug`);new class extends Nk{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Hk(e,r)}else n=e.match(qk)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Jk(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Jk(n,i,r,null,t.intlSegmenter),e}};function Jk(e,t,n,r,i){if(t&&n){let[a,o]=Gk(t.value,i),[s,c]=Gk(n.value,i);if(e){let r=Pk(a,s);e.value=Lk(e.value,s,r),t.value=Rk(t.value,r),n.value=Rk(n.value,r)}if(r){let e=Fk(o,c);r.value=Ik(r.value,c,e),t.value=zk(t.value,e),n.value=zk(n.value,e)}}else if(n){if(e){let e=Wk(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Wk(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Wk(r.value,i),[a,o]=Gk(t.value,i),s=Pk(n,a);t.value=Rk(t.value,s);let c=Fk(Rk(n,s),o);t.value=zk(t.value,c),r.value=Ik(r.value,n,c),e.value=Lk(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Wk(r.value,i),n=Bk(Uk(t.value,i),e);t.value=zk(t.value,n)}else if(e){let n=Bk(Uk(e.value,i),Wk(t.value,i));t.value=Rk(t.value,n)}}new class extends Nk{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Kk}]+|[^\\S\\n\\r]+|[^${Kk}]`,`ug`);return e.match(t)||[]}};var Yk=new class extends Nk{constructor(){super(...arguments),this.tokenize=Zk}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
88
|
+
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
89
|
+
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
90
|
+
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
91
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function Xk(e,t,n){return Yk.diff(e,t,n)}function Zk(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
92
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Qk(e){return e==`.`||e==`!`||e==`?`}new class extends Nk{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Qk(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends Nk{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends Nk{constructor(){super(...arguments),this.tokenize=Zk}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify($k(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function $k(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=$k(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=$k(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends Nk{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function eA(e){let t=e.split(`
|
|
93
|
+
`),n=/^\s*(\d+)→(.*)$/;return t.map(e=>{let t=e.match(n);return t?{lineNumber:parseInt(t[1],10),content:t[2]}:{lineNumber:null,content:e}})}function tA(e){return e.replace(/<[^>]+>/g,``)}function nA(e,t){if(e===``&&t===``)return[];let n=Xk(e,t),r=[];for(let e of n){let t=e.added?`added`:e.removed?`removed`:`context`,n=e.added?`+`:e.removed?`-`:` `,i=e.value.endsWith(`
|
|
94
|
+
`)?e.value.slice(0,-1).split(`
|
|
95
|
+
`):e.value.split(`
|
|
96
|
+
`);for(let e of i)r.push({type:t,content:`${n}${e}`})}return r}var rA=(0,j.memo)(function({content:e,isDiff:t=!1,oldString:n,newString:r,filePath:i,chrome:a=!0}){let o=(0,j.useMemo)(()=>t&&n!==void 0&&r!==void 0?nA(n,r):[],[t,n,r]),s=(0,j.useMemo)(()=>t?[]:eA(e),[e,t]),c=(0,j.useMemo)(()=>s.some(e=>e.lineNumber!==null),[s]),l=(0,Q.jsx)(`div`,{className:`my-1 overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,Q.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,Q.jsx)(`tbody`,{children:o.map((e,t)=>{let n=e.type===`removed`?`bg-red-500/10 dark:bg-red-500/15`:e.type===`added`?`bg-green-500/10 dark:bg-green-500/15`:``,r=e.type===`removed`?`text-red-700 dark:text-red-400`:e.type===`added`?`text-green-700 dark:text-green-400`:`text-foreground`;return(0,Q.jsxs)(`tr`,{className:n,children:[(0,Q.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${e.type===`removed`?`text-red-500/50`:e.type===`added`?`text-green-500/50`:`text-muted-foreground/50`}`,children:e.type===`removed`?`-`:e.type===`added`?`+`:` `}),(0,Q.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all ${r}`,children:e.content.slice(1)})]},t)})})})})});if(t&&o.length>0)return a?(0,Q.jsx)(KT,{type:`diff`,title:i??`Diff`,defaultExpanded:!0,children:l}):l;let u=(0,Q.jsx)(`div`,{className:`my-1 overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,Q.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,Q.jsx)(`tbody`,{children:s.map((e,t)=>(0,Q.jsxs)(`tr`,{children:[c&&(0,Q.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right`,children:e.lineNumber===null?``:e.lineNumber}),(0,Q.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all text-foreground`,children:tA(e.content)})]},t))})})})});return a?(0,Q.jsx)(KT,{type:`code`,title:i??`File`,defaultExpanded:!0,children:u}):u}),iA=(0,j.memo)(function({images:e,text:t,title:n}){return(0,Q.jsx)(KT,{type:`embed`,title:n??`Image`,defaultExpanded:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[e.map((e,t)=>(0,Q.jsx)(`img`,{src:`data:${e.mediaType};base64,${e.data}`,alt:n?`Content of ${n}`:`Image ${t+1}`,className:`block max-w-full max-h-[50vh] rounded-md border border-border/60 bg-background object-contain`},t)),t?(0,Q.jsx)(`pre`,{className:`text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all`,children:t}):null]})})}),aA=[`no files found`,`no matches`,`no results`,`exit code 1`,`not found`,`no such file`];function oA(e){let t=typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return aA.some(e=>n.includes(e))}var sA=[{pattern:`permission denied`,hint:`The tool couldn't access a file. Check file permissions.`},{pattern:`command not found`,hint:`The command isn't installed or isn't in PATH.`},{pattern:`timed out`,hint:`The operation took too long.`},{pattern:`timeout`,hint:`The operation took too long.`},{pattern:`enoent`,hint:`A referenced file or directory doesn't exist.`},{pattern:`no such file`,hint:`A referenced file or directory doesn't exist.`}];function cA(e){if(!e)return null;let t=e.toLowerCase();for(let{pattern:e,hint:n}of sA)if(t.includes(e))return n;return null}var lA=m({id:`message.tool-call.item`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),uA=(0,j.memo)(function({message:e,isLoading:t=!1,localPath:n}){let r=e.result!==void 0,i=!r&&t,a=(0,j.useMemo)(()=>LO(e,n),[e.input,e.toolName,n]),o=(0,j.useMemo)(()=>e.toolKind===`subagent_task`,[e.toolKind]),s=(0,j.useMemo)(()=>{if(e.toolKind===`skill`)return e.input.skill},[e.input,e.toolKind]),l=e.toolKind===`bash`,u=e.toolKind===`write_file`,d=e.toolKind===`edit_file`,f=e.toolKind===`read_file`,p=NO(),m=(0,j.useMemo)(()=>e.toolKind===`write_file`||e.toolKind===`edit_file`?e.input.filePath:null,[e]),h=(0,j.useMemo)(()=>{if(typeof e.result==`string`)return e.result;if(!e.result)return``;if(ih(e.result))return e.result.text??``;if(typeof e.result==`object`&&e.result!==null&&`content`in e.result){let t=e.result.content;if(typeof t==`string`)return t}return JSON.stringify(e.result,null,2)},[e.result]),g=(0,j.useMemo)(()=>{switch(e.toolKind){case`bash`:return e.input.command;case`write_file`:return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]),_=ih(e.result)?e.result:null,v=r&&!f&&!(!e.isError&&(u||d));return(0,Q.jsx)(`div`,{...c(lA),children:(0,Q.jsx)(RO,{className:`w-full`,children:(0,Q.jsxs)(HO,{headerAction:m&&!e.isError?(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5 text-xs`,onClick:()=>p({path:m}),children:[(0,Q.jsx)(wr,{className:`size-3.5`}),`Open preview`]}):null,expandedContent:(0,Q.jsx)(GO,{className:`my-4 text-sm`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d?(0,Q.jsx)(rA,{content:``,isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):!f&&!u&&(0,Q.jsx)(UO,{label:l?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(`span`,{children:`Command`}),!!e.input.timeoutMs&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`timeout: `,String(e.input.timeoutMs),`ms`]}),!!e.input.runInBackground&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`background`})]}):`Input`,copyText:g,children:g}),r&&f&&!e.isError&&(_?(0,Q.jsx)(iA,{images:_.images,text:_.text,title:e.input.filePath}):(0,Q.jsx)(rA,{content:h})),u&&!e.isError&&(0,Q.jsx)(rA,{content:e.input.content}),v&&(_?(0,Q.jsx)(iA,{images:_.images,text:_.text}):(0,Q.jsxs)(Q.Fragment,{children:[e.isError&&!oA(e.result)&&(()=>{let e=cA(h);return e?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e}):null})(),(0,Q.jsx)(UO,{label:e.isError?`Error`:`Result`,copyText:h,children:h})]}))]})}),children:[(0,Q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:e.isError?oA(e.result)?(0,Q.jsx)(ur,{className:`size-3.5 text-muted-foreground/50`}):(0,Q.jsx)(Di,{className:`size-4 text-destructive`}):i?o?(0,Q.jsx)(wi,{className:`size-4 text-[var(--logo)] animate-pulse`}):(0,Q.jsx)(IO(e.toolName),{className:`size-4 text-[var(--logo)] animate-pulse`}):r?(0,Q.jsx)(ar,{className:`size-3.5 text-muted-foreground/40`}):o?(0,Q.jsx)(wi,{className:`size-4 text-muted-icon`}):(0,Q.jsx)(IO(e.toolName),{className:`size-4 text-muted-icon`})}),(0,Q.jsx)(BO,{className:`text-left transition-opacity duration-200 truncate ${r&&!i?`text-muted-foreground`:``}`,children:(0,Q.jsx)(y_,{animate:i,shimmerWidth:Math.max(20,((s||a)?.length??33)*3),children:s||a})})]})})})}),dA=(0,j.createContext)(null);function fA(){return(0,j.useContext)(dA)}function pA(e){if(!e)return`This usually means the CLI process crashed or was killed.`;let t=e.toLowerCase();return t.includes(`signal`)?`The process was interrupted by a system signal.`:t.includes(`oom`)||t.includes(`out of memory`)?`The process ran out of memory.`:`This usually means the CLI process crashed or was killed.`}var mA=`Session ended unexpectedly`,hA=`This usually means the CLI process crashed or was killed.`;function gA(e){if(!e)return``;let t=e.split(/\r?\n/);for(;t.length>0&&t[0]?.trim()===``;)t.shift();return t[0]?.trim()===mA&&t.shift(),t[0]?.trim()===hA&&t.shift(),t.join(`
|
|
97
|
+
`).trim()}var _A=(0,j.memo)(function({message:e}){let t=fA(),n=gA(e.result);return e.cancelled?(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 text-sm text-muted-foreground my-3`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4 ml-1.5`}),(0,Q.jsx)(`em`,{children:`Interrupted`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/60 pr-1`,children:`Send a new message to continue this conversation.`})]}):e.success?(0,Q.jsxs)(RO,{className:`px-0.5 text-xs tracking-wide ${e.durationMs>6e4?``:`hidden`}`,children:[(0,Q.jsx)(`div`,{className:`w-full h-[1px] bg-border`}),(0,Q.jsxs)(BO,{className:`whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0`,children:[`Worked for `,(e=>{if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h${r>0?` ${r}m`:``}`:r>0?`${r}m${i>0?` ${i}s`:``}`:`${i}s`})(e.durationMs)]}),(0,Q.jsx)(`div`,{className:`w-full h-[1px] bg-border`})]}):(0,Q.jsx)(`div`,{className:`px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-sm`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(ur,{className:`size-4.5 text-destructive mt-0.5 flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-destructive`,children:mA}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:pA(e.result)}),n&&(0,Q.jsx)(`code`,{className:`text-xs text-muted-foreground/70 font-mono mt-0.5`,children:n}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mt-1.5`,children:[(0,Q.jsx)(S,{variant:`default`,size:`sm`,onClick:t?.onNewChat,children:`Start new chat`}),t?.onResumeSession&&(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:t.onResumeSession,children:`Resume session`})]})]})]})})}),vA=(0,j.memo)(function({message:e}){return(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 text-sm text-muted-foreground my-3`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4 ml-1.5`}),(0,Q.jsx)(`em`,{children:`Interrupted`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/60 pr-1`,children:`Send a new message to continue this conversation.`})]})});function yA({size:e=4}){return(0,Q.jsxs)(`svg`,{className:`flex-1`,viewBox:`0 0 100 ${e}`,preserveAspectRatio:`none`,style:{height:`${e}px`},children:[(0,Q.jsx)(`pattern`,{id:`zigzag`,width:e,height:e,patternUnits:`userSpaceOnUse`,children:(0,Q.jsx)(`path`,{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:`none`,stroke:`currentColor`,strokeWidth:`0.5`,className:`text-muted-foreground/30`,style:{stroke:`currentColor`}})}),(0,Q.jsx)(`rect`,{width:`100%`,height:e,fill:`url(#zigzag)`,className:`text-muted-foreground/30`})]})}var bA=(0,j.memo)(function(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(yA,{}),(0,Q.jsx)(`span`,{className:`text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0`,children:`Compacted`}),(0,Q.jsx)(yA,{})]})}),xA=(0,j.memo)(function(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(yA,{}),(0,Q.jsx)(`span`,{className:`text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0`,children:`Context Cleared`}),(0,Q.jsx)(yA,{})]})}),SA={compacting:`Compacting...`},CA=(0,j.memo)(function({message:e}){let t=SA[e.status]||e.status;return(0,Q.jsxs)(RO,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,Q.jsx)($r,{className:`h-4.5 w-4.5 text-muted-foreground`})}),(0,Q.jsx)(BO,{className:`text-left transition-opacity duration-200 truncate`,children:t})]})});function wA(e,t){try{return new Date(e*1e3).toLocaleString(void 0,{timeZone:t,hour:`2-digit`,minute:`2-digit`})}catch{return new Date(e*1e3).toLocaleString()}}function TA(e=3e4){let[t,n]=(0,j.useState)(()=>Date.now());return(0,j.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function EA({message:e}){let t=TA(),n=e.rateLimit.resetAt*1e3,r=Math.max(0,n-t),i=Math.ceil(r/6e4),a=r>0?`Rate limit reached — resumes in ${i} min (~${wA(e.rateLimit.resetAt,e.rateLimit.tz)})`:`Rate limit cleared (was reset at ${wA(e.rateLimit.resetAt,e.rateLimit.tz)})`;return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning-foreground`,children:[(0,Q.jsx)(Ci,{className:`size-3.5 mt-0.5 shrink-0 text-warning`}),(0,Q.jsx)(`span`,{children:a})]})}var DA=m({id:`message.tool-group.area`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),OA=m({id:`message.tool-group.expand.action`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),kA={read_file:{key:`read`,singular:`read`,plural:`reads`},edit_file:{key:`edit`,singular:`edit`,plural:`edits`},write_file:{key:`write`,singular:`write`,plural:`writes`},bash:{key:`bash`,singular:`command`,plural:`commands`},grep:{key:`grep`,singular:`search`,plural:`searches`},glob:{key:`glob`,singular:`glob`,plural:`globs`},subagent_task:{key:`task`,singular:`agent`,plural:`agents`},web_search:{key:`websearch`,singular:`web search`,plural:`web searches`},skill:{key:`skill`,singular:`skill`,plural:`skills`},todo_write:{key:`todo`,singular:`todo update`,plural:`todo updates`}},AA={key:`other`,singular:`tool call`,plural:`tool calls`};function jA(e){return kA[e]??AA}function MA(e){let t=new Map,n=[];for(let r of e){let e=r.toolKind,i=jA(e),a=t.get(i.key);a?a.count++:(t.set(i.key,{category:i,count:1}),n.push(i.key))}return n.map(e=>{let{category:n,count:r}=t.get(e);return`${r} ${r===1?n.singular:n.plural}`}).join(`, `)}var NA=(0,j.memo)(function({messages:e,isLoading:t,localPath:n}){let[r,i]=(0,j.useState)(!1),a=(0,j.useMemo)(()=>MA(e),[e]),o=(0,j.useMemo)(()=>e.some(e=>e.result===void 0),[e]),s=(0,j.useCallback)(()=>i(e=>!e),[]),l=(0,j.useCallback)(()=>i(!1),[]),u=o&&t;return(0,Q.jsx)(`div`,{...c(DA),children:(0,Q.jsx)(RO,{className:`w-full`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,Q.jsx)(`button`,{onClick:s,className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!r&&!u?`hover:opacity-60 transition-opacity`:``}`,...c(OA),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:[(0,Q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,Q.jsx)(cr,{className:`h-4.5 w-4.5 transition-all duration-200 ${u?`text-[var(--logo)] animate-pulse`:`text-muted-icon`} ${r?`rotate-90`:``}`})}),(0,Q.jsx)(BO,{className:`text-left ${u?``:`text-muted-foreground`}`,children:(0,Q.jsx)(y_,{animate:u,children:a})})]})}),r&&(0,Q.jsxs)(`div`,{className:`my-4 flex flex-col gap-3`,children:[e.map(e=>(0,Q.jsx)(uA,{message:e,isLoading:t,localPath:n},e.id)),e.length>5&&(0,Q.jsx)(`button`,{onClick:l,className:`cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:[(0,Q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,Q.jsx)(cr,{className:`h-4.5 w-4.5 text-muted-icon -rotate-90`})}),(0,Q.jsx)(BO,{className:`text-left`,children:`Collapse`})]})})]})]})})})}),PA=m({id:`message.wip-block.area`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`});function FA(e,t,n){return`${e} ${e===1?t:n}`}function IA(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===`assistant_text`&&n.text.trim()){let e=n.text.trim();return e.length>120?`${e.slice(0,120)}…`:e}}return`Thinking`}var LA=(0,j.memo)(function({steps:e,isLoading:t,localPath:n}){let[r,i]=(0,j.useState)(!1),a=(0,j.useCallback)(()=>i(e=>!e),[]),{stepCount:o,goal:s,toolSteps:l}=(0,j.useMemo)(()=>{let t=[];for(let n of e)n.kind===`tool`&&t.push(n);return{stepCount:t.length,goal:IA(e),toolSteps:t}},[e]);return(0,Q.jsx)(`div`,{...c(PA),children:(0,Q.jsx)(RO,{className:`w-full`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,Q.jsx)(`button`,{onClick:a,className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!r&&!t?`hover:opacity-60 transition-opacity`:``}`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:(0,Q.jsx)(cr,{className:`h-4.5 w-4.5 transition-all duration-200 ${t?`text-[var(--logo)] animate-pulse`:`text-muted-icon`} ${r?`rotate-90`:``}`})}),(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,Q.jsx)(BO,{className:`text-left truncate min-w-0 ${t?``:`text-muted-foreground`}`,children:(0,Q.jsx)(y_,{animate:t,shimmerWidth:60,children:s})}),o>0?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/50 flex-shrink-0 tabular-nums`,children:FA(o,`step`,`steps`)}):null]})]})}),r&&l.length>0?(0,Q.jsx)(`div`,{className:`my-4 flex flex-col gap-3`,children:l.map(e=>(0,Q.jsx)(uA,{message:e,isLoading:t,localPath:n},e.id))}):null]})})})}),RA=50;function zA(e){return e.kind===`wip_block`||e.kind===`tool_group`?e.id:e.kind===`standalone_tool`?`msg-${e.tool.id}`:e.kind===`artifact`?`msg-${e.artifact.id}`:`msg-${e.message.id}`}function BA(e,t){let n=e.split(/\r?\n/)[0];return n.length<=t?n:n.slice(0,t-1)+`…`}function VA(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r.kind===`user_prompt`&&t.push({renderIndex:n,domId:zA(r),label:BA(r.message.content,RA)})}return t}var HA=50;function UA(e,t,n){if(e.length===0)return-1;let r=-1;for(let i=0;i<e.length;i++){let a=n(e[i]);if(a!==null)if(a<=t+HA)r=i;else break}return r}var WA=(0,j.lazy)(()=>o(()=>import(`./TextMessage-B5G39DEJ.js`).then(e=>({default:e.TextMessage})),__vite__mapDeps([32,1,2,33,12,4,34,6,5,7]))),GA=(0,j.lazy)(()=>o(()=>import(`./UserMessage-CIkWk-0L.js`).then(e=>({default:e.UserMessage})),__vite__mapDeps([35,1,2,3,4,5,6,7,8]))),KA=(0,j.lazy)(()=>o(()=>import(`./ExitPlanModeMessage-DIdkQ4uF.js`).then(e=>({default:e.ExitPlanModeMessage})),__vite__mapDeps([36,1,2,3,4,5,6,7,8]))),qA=(0,j.lazy)(()=>o(()=>import(`./CompactSummaryMessage-Yw0BDWEJ.js`).then(e=>({default:e.CompactSummaryMessage})),__vite__mapDeps([37,1,2,8,5,6])));function JA({messages:e,scrollRef:t,isLoading:n,localPath:r,latestToolIds:i,onOpenLocalLink:a,onOpenExternalLink:o,onAskUserQuestionSubmit:s,onExitPlanModeConfirm:c,richContentChrome:l=`card`,virtualizerRef:u}){let d=e,{estimateSize:f}=pT(d,t),p=rC({count:d.length,getScrollElement:()=>t.current,estimateSize:f,overscan:5,getItemKey:e=>d[e]?.id??e});u&&(u.current=p);function m(e){if(e.kind===`user_prompt`)return(0,Q.jsx)(GA,{content:e.content},e.id);switch(e.kind){case`unknown`:return(0,Q.jsx)(mT,{json:e.json},e.id);case`system_init`:return(0,Q.jsx)(ok,{message:e,rawJson:e.debugRaw},e.id);case`account_info`:return(0,Q.jsx)(sk,{message:e},e.id);case`assistant_text`:return(0,Q.jsx)(WA,{message:e},e.id);case`tool`:return e.toolKind===`ask_user_question`?(0,Q.jsx)(yk,{message:e,onSubmit:s,isLatest:e.id===i.AskUserQuestion},e.id):e.toolKind===`exit_plan_mode`?(0,Q.jsx)(KA,{message:e,onConfirm:c,isLatest:e.id===i.ExitPlanMode},e.id):e.toolKind===`todo_write`?(0,Q.jsx)(Mk,{message:e},e.id):e.toolKind===`present_content`?(0,Q.jsx)(kk,{message:e},e.id):(0,Q.jsx)(uA,{message:e,isLoading:n,localPath:r},e.id);case`result`:return(0,Q.jsx)(_A,{message:e},e.id);case`interrupted`:return(0,Q.jsx)(vA,{message:e},e.id);case`compact_boundary`:return(0,Q.jsx)(bA,{},e.id);case`context_cleared`:return(0,Q.jsx)(xA,{},e.id);case`compact_summary`:return(0,Q.jsx)(qA,{message:e},e.id);case`status`:return(0,Q.jsx)(CA,{message:e},e.id);case`rate_limit`:return(0,Q.jsx)(EA,{message:e},e.id)}}function h(e){switch(e.kind){case`wip_block`:return(0,Q.jsx)(LA,{steps:e.steps,isLoading:n,localPath:r});case`tool_group`:return(0,Q.jsx)(NA,{messages:e.tools,isLoading:n,localPath:r});case`standalone_tool`:return m(e.tool);case`artifact`:return(0,Q.jsx)(kk,{message:e.artifact},e.artifact.id);case`assistant_response`:case`user_prompt`:case`system_init`:case`account_info`:case`status`:case`result`:case`compact_boundary`:case`compact_summary`:case`context_cleared`:case`interrupted`:case`unknown`:case`rate_limit`:return m(e.message);default:return e}}let g=p.getVirtualItems();return(0,Q.jsx)(MO,{onOpenLocalLink:a,onOpenExternalLink:o,children:(0,Q.jsx)(GT,{chrome:l,controlsVisibility:l===`inline`?`hover-or-touch`:`always`,children:(0,Q.jsx)(j.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`min-h-[24px]`}),children:(0,Q.jsx)(`div`,{style:{height:p.getTotalSize(),width:`100%`,position:`relative`},children:g.map(e=>{let t=d[e.index];if(t.kind===`tool_group`||t.kind===`wip_block`)return(0,Q.jsx)(`div`,{ref:p.measureElement,"data-index":e.index,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,Q.jsx)(`div`,{className:`group relative pb-5`,[Xh]:``,children:h(t)})},e.key);let n=h(t);return(0,Q.jsx)(`div`,{ref:p.measureElement,"data-index":e.index,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:n?(0,Q.jsx)(`div`,{id:zA(t),className:`group relative pb-5`,[Xh]:``,children:n}):null},e.key)})})})})})}var YA={label:`Dismiss`,variant:`ghost`,action:`dismiss`};function XA(e){let t=e.toLowerCase().trim();return t===`not connected`?{message:`Can't reach the server`,hint:`Make sure ${d_} is running on this machine.`,actions:[YA]}:t.includes(`connection closed`)||t.includes(`socket closed`)?{message:`Connection dropped`,hint:`Reconnecting automatically...`,actions:[YA]}:e.includes(`Unknown command type: system.readLocalFilePreview`)?{message:`Client is newer than server`,hint:`Restart ${d_} to enable in-app file previews.`,actions:[YA]}:{message:e.trim(),actions:[YA]}}var ZA=180,QA=[`continue this work`,`fork this into`,`continue with`];function $A(e){return e.replace(/\s+/g,` `).trim()}function ej(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}\u2026`}function tj(e,t=ZA){let n=$A(e);return n?ej(n.match(/^(.+?[.!?])(?:\s|$)/)?.[1]??n,t):``}function nj(e){let t=e?$A(e):``;return t.length>0?t:null}function rj(e){let t=tj(e.intent,72),n=nj(e.sourceTitle),r=t.toLowerCase();return n&&QA.some(e=>r.startsWith(e))?`Fork: ${n}`:t||(n?`Fork: ${n}`:`Forked session`)}function ij(e){let t=tj(e.intent,72);if(t)return t;let n=e.sourceLabels.map(e=>$A(e)).filter(Boolean);return n.length===1?`Merge: ${n[0]}`:n.length===2?`Merge: ${n[0]} + ${n[1]}`:n.length>2?`Merge ${n.length} sessions`:`Merged session`}function aj(e,t,n){return e?.chatId===t?{...e,phase:`error`,errorMessage:n}:e}function oj(e,t){return e?.chatId===t?e.phase===`error`?e:null:e}var sj=15e3,cj=5e3;async function lj(e){return await e.socket.command({type:`chat.getRenderUnits`,chatId:e.chatId,offset:e.offset,limit:e.limit,isLoading:e.isLoading},e.timeoutMs?{timeoutMs:e.timeoutMs}:void 0)}async function uj(e){return await e.socket.command({type:`chat.getExternalSessionMessages`,parentChatId:e.parentChatId,sessionId:e.sessionId},e.timeoutMs?{timeoutMs:e.timeoutMs}:void 0)}function dj(e,t){let n=e.workspaceGroups.map(e=>{let n=e.chats.filter(e=>e.chatId!==t);return n.length===e.chats.length?e:{...e,chats:n}}).filter(e=>e.chats.length>0);return n.length===e.workspaceGroups.length&&n.every((t,n)=>t===e.workspaceGroups[n])?e:{workspaceGroups:n,independentWorkspaces:e.independentWorkspaces}}function fj(e,t){if(t.size===0)return e;let n=e.workspaceGroups.map(e=>{let n=e.chats.filter(e=>!t.has(e.chatId));return n.length===e.chats.length?e:{...e,chats:n}}).filter(e=>e.chats.length>0);return n.length===e.workspaceGroups.length&&n.every((t,n)=>t===e.workspaceGroups[n])?e:{workspaceGroups:n,independentWorkspaces:e.independentWorkspaces}}function pj(e,t){let n=e.find(e=>e.chats.some(e=>e.chatId===t));return n?n.chats.find(e=>e.chatId!==t)?.chatId??null:null}function mj(e,t){if(!t)return null;for(let n of e){let e=n.chats.find(e=>e.chatId===t);if(e)return e}return null}function hj(e,t){return t.map(t=>mj(e,t)?.title?.trim()||t)}function gj(e,t=0){return e<Math.max(97,t*.12)}function _j(e,t){return e===`awaiting_disconnect`&&t===`disconnected`?`awaiting_reconnect`:e===`awaiting_reconnect`&&t===`connected`?`navigate_home`:`none`}function vj(e){return e.isStandalone?e.connectionStatus===`connected`?e.hiddenAt===null?!1:Math.max(0,e.resumedAt-e.hiddenAt)>=sj:!0:!1}function yj(e){let t=e instanceof Error?e.message:String(e);return t.includes(`Unknown command type: system.readLocalFilePreview`)?`This ${d_} browser client is newer than the running server. Restart ${d_} to enable in-app file previews.`:t}function bj(e){let t=(e instanceof Error?e.message:String(e)).trim(),n=t.toLowerCase();return n===`not connected`?`Can't reach your local ${d_} server yet. Wait a moment, or start ${d_} in a terminal on this machine and try again.`:n.includes(`connection closed`)||n.includes(`socket closed`)?`The connection to your local ${d_} server dropped. ${d_} will keep trying to reconnect.`:t}function xj(e,t){let n=bj(t),r=n.toLowerCase();return r.includes(`timeout`)||r.includes(`timed out`)?e===`fork`?`Preparing the fork brief took too long. Try again with a tighter focus or a smaller source context.`:`Preparing the merged session brief took too long. Try again with fewer sessions or a tighter goal.`:r.includes(`busy`)||r.includes(`already running`)?`The target session is currently busy. Wait for it to finish or pick a different session.`:n}function Sj(e){let t=e.selectedProjectId??e.sidebarProjectId??null;return t?{kind:`project_id`,workspaceId:t}:e.fallbackLocalProjectPath?{kind:`local_path`,localPath:e.fallbackLocalProjectPath}:null}function Cj(e,t){return!e||!t?null:e.runtime.chatId===t?e:(console.info(`[useAppState] stale snapshot masked`,{routeChatId:t,snapshotChatId:e.runtime.chatId,snapshotProvider:e.runtime.provider}),null)}function wj(e,t){let n=e.trim(),r=t.trim();return n?r?`${n}\n\n${r}`:n:r}function Tj(e){return!e.cancelled&&!e.initialFetchDone&&!e.fetchTriggered}function Ej(e,t){return e||t.trim().length>0}function Dj(e){return e.hasExistingMessages&&!e.restoredFromCache&&e.currentMessagesChatId!==null&&e.currentMessagesChatId===e.nextChatId}var Oj=new Set([`AskUserQuestion`,`ExitPlanMode`,`TodoWrite`]),kj=new Set([`TodoWrite`]);function Aj(e){return e.kind===`standalone_tool`?[e.tool]:e.kind===`artifact`?[e.artifact]:e.kind===`tool_group`?e.tools:e.kind===`wip_block`?e.steps.filter(e=>e.kind===`tool`):[]}function jj(e,t){for(let n=e.length-1;n>=0;--n){let r=Aj(e[n]);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n.toolName===t&&!n.result)return n.id}}return null}function Mj(e,t){for(let n=e.length-1;n>=0;--n){let r=Aj(e[n]);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n.toolName===t)return n.id}}return null}function Nj(e){let t={};for(let n of Oj)t[n]=kj.has(n)?Mj(e,n):jj(e,n);return t}function Pj(e){return e===`starting`||e===`running`||e===`waiting_for_user`||e===`awaiting_agents`}function Fj(e){return e===`starting`||e===`running`||e===`waiting_for_user`||e===`awaiting_agents`}function Ij(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function Lj(e){return e===`markdown`||e===`code`||e===`diagram`}function Rj(e){return!!e&&typeof e==`object`&&Array.isArray(e.path)&&(e.path?.every(e=>typeof e==`string`)??!1)&&typeof e.code==`string`&&typeof e.message==`string`}function zj(e){return!!e&&typeof e==`object`&&e.source===`schema_validation`&&e.schema===`present_content`&&Array.isArray(e.issues)&&(e.issues?.every(Rj)??!1)}var Bj=10*1024*1024,Vj=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`]);function Hj(e){if(!Array.isArray(e))return null;let t=[],n;for(let r of e){let e=Ij(r);if(e){if(e.type===`image`){let n=Ij(e.source);n&&n.type===`base64`&&typeof n.media_type==`string`&&Vj.has(n.media_type)&&typeof n.data==`string`&&n.data.length<=Bj&&t.push({mediaType:n.media_type,data:n.data})}e.type===`text`&&typeof e.text==`string`&&(n=n?`${n}\n${e.text}`:e.text)}}return t.length===0?null:{images:t,text:n}}function Uj(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function Wj(e,t){let n=Uj(t);switch(e.toolKind){case`ask_user_question`:{let e=Ij(n),t=Ij(e?.answers)??(e||{});return{answers:Object.fromEntries(Object.entries(t).map(([e,t])=>Array.isArray(t)?[e,t.map(e=>String(e))]:t&&typeof t==`object`&&Array.isArray(t.answers)?[e,t.answers.map(e=>String(e))]:t==null||t===``?[e,[]]:[e,[String(t)]])),...e?.discarded===!0?{discarded:!0}:{}}}case`exit_plan_mode`:{let e=Ij(n);return{confirmed:typeof e?.confirmed==`boolean`?e.confirmed:void 0,clearContext:typeof e?.clearContext==`boolean`?e.clearContext:void 0,message:typeof e?.message==`string`?e.message:void 0,...e?.discarded===!0?{discarded:!0}:{}}}case`read_file`:{if(typeof n==`string`)return n;let e=Hj(n);if(e)return e;let t=Ij(n);return{content:typeof t?.content==`string`?t.content:JSON.stringify(n,null,2)}}case`present_content`:{let t=Ij(n);return zj(t?.error)?{error:t.error}:typeof t?.error==`string`?{error:{source:`schema_validation`,schema:`present_content`,issues:[{path:[],code:`custom`,message:t.error}]}}:{accepted:!0,title:typeof t?.title==`string`?t.title:e.input.title,kind:Lj(t?.kind)?t.kind:e.input.kind,format:typeof t?.format==`string`?t.format:e.input.format,source:typeof t?.source==`string`?t.source:e.input.source,summary:typeof t?.summary==`string`?t.summary:e.input.summary,collapsed:typeof t?.collapsed==`boolean`?t.collapsed:e.input.collapsed}}default:return Hj(n)||n}}var Gj=new Set([`ask_user_question`,`exit_plan_mode`,`todo_write`,`present_content`]);function Kj(e){return new Date(e).toISOString()}function qj(e){return{id:e._id,messageId:e.messageId,timestamp:Kj(e.createdAt),hidden:e.hidden}}function Jj(e){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:`tool`,toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:e.tool.input,timestamp:Kj(e.createdAt)}}function Yj(e){if(e.debugRaw)try{return JSON.parse(e.debugRaw).tool_use_result}catch{return}}function Xj(e){let t=new Map,n=[];for(let r of e)switch(r.kind){case`user_prompt`:n.push({message:{...qj(r),kind:`user_prompt`,content:r.content},sourceEntryIds:[r._id]});break;case`system_init`:n.push({message:{...qj(r),kind:`system_init`,provider:r.provider,model:r.model,tools:r.tools,agents:r.agents,slashCommands:r.slashCommands,mcpServers:r.mcpServers,debugRaw:r.debugRaw},sourceEntryIds:[r._id]});break;case`account_info`:n.push({message:{...qj(r),kind:`account_info`,accountInfo:r.accountInfo},sourceEntryIds:[r._id]});break;case`assistant_text`:n.push({message:{...qj(r),kind:`assistant_text`,text:r.text},sourceEntryIds:[r._id]});break;case`tool_call`:{let e=Jj(r),i={hydrated:e,normalized:r.tool,sourceEntryIds:[r._id]};t.set(r.tool.toolId,i),n.push({message:e,sourceEntryIds:i.sourceEntryIds});break}case`tool_result`:{let e=t.get(r.toolId);if(e){let t=e.normalized.toolKind===`ask_user_question`||e.normalized.toolKind===`exit_plan_mode`;if(!(t&&e.hydrated.result!=null)){let n=t?Yj(r)??r.content:r.content;e.hydrated.result=Wj(e.normalized,n),e.hydrated.rawResult=n,e.hydrated.isError=r.isError}e.sourceEntryIds.push(r._id)}break}case`result`:n.push({message:{...qj(r),kind:`result`,success:!r.isError,cancelled:r.subtype===`cancelled`,result:r.result,durationMs:r.durationMs,costUsd:r.costUsd},sourceEntryIds:[r._id]});break;case`status`:n.push({message:{...qj(r),kind:`status`,status:r.status},sourceEntryIds:[r._id]});break;case`compact_boundary`:n.push({message:{...qj(r),kind:`compact_boundary`},sourceEntryIds:[r._id]});break;case`compact_summary`:n.push({message:{...qj(r),kind:`compact_summary`,summary:r.summary},sourceEntryIds:[r._id]});break;case`context_cleared`:n.push({message:{...qj(r),kind:`context_cleared`},sourceEntryIds:[r._id]});break;case`interrupted`:n.push({message:{...qj(r),kind:`interrupted`},sourceEntryIds:[r._id]});break;case`context_usage`:break;case`context_window_updated`:break;case`rate_limit`:n.push({message:{...qj(r),kind:`rate_limit`,rateLimit:r.rateLimit},sourceEntryIds:[r._id]});break;case`agent_result`:n.push({message:{...qj(r),kind:`unknown`,json:JSON.stringify(r,null,2)},sourceEntryIds:[r._id]});break;default:}return n}function Zj(e,t){let n=t[0]??`empty`,r=t[t.length-1]??n;return e===`wip_block`?`wip:${n}:${r}`:e===`tool_group`?`tools:${n}:${r}`:e===`artifact`?`artifact:${n}`:e===`unknown`?`unknown:${n}`:`${e}:${n}`}function Qj(e){return e.kind===`tool`}function $j(e){return!Qj(e)||e.isError||e.toolKind===`unknown_tool`?!1:!Gj.has(e.toolKind)}function eM(e){return Qj(e)?!$j(e):!1}function tM(e){return!(!eM(e)||e.toolKind===`todo_write`)}function nM(e){return e.kind===`assistant_text`||$j(e)}function rM(e,t){for(let n=e.length-1;n>=0;--n){if(e[n].message.kind!==`assistant_text`)continue;if(!t)return n;let r=!1;for(let t=n+1;t<e.length;t+=1)if(e[t].message.kind===`tool`){r=!0;break}if(r)break;if(n===e.length-1){let t=!1,r=!1;for(let i=0;i<n;i+=1)e[i].message.kind===`tool`&&(r=!0),e[i].message.kind===`assistant_text`&&(t=!0);if(r)return n;if(t)return-1}return n}return-1}function iM(e){return e.flatMap(e=>e.sourceEntryIds)}function aM(e,t){let n=Zj(t,e.sourceEntryIds);switch(t){case`user_prompt`:case`system_init`:case`account_info`:case`status`:case`result`:case`compact_boundary`:case`compact_summary`:case`context_cleared`:case`interrupted`:case`unknown`:case`rate_limit`:return{kind:t,id:n,sourceEntryIds:e.sourceEntryIds,message:e.message};case`assistant_response`:return{kind:t,id:n,sourceEntryIds:e.sourceEntryIds,message:e.message};case`standalone_tool`:return{kind:t,id:n,sourceEntryIds:e.sourceEntryIds,tool:e.message};case`artifact`:return{kind:t,id:n,sourceEntryIds:e.sourceEntryIds,artifact:e.message}}}function oM(e){let t=-1,n=-1;for(let r=0;r<e.length;r+=1){let i=e[r].message;i.kind===`status`&&(t=r),i.kind===`tool`&&i.toolKind===`todo_write`&&(n=r)}return{latestStatusIndex:t,latestTodoWriteIndex:n}}function sM(e,t,n){let r=e[t].message;return r.kind===`status`?t!==n.latestStatusIndex:r.kind===`account_info`?e.findIndex(e=>e.message.kind===`account_info`)!==t:r.kind===`system_init`?e.findIndex(e=>e.message.kind===`system_init`)!==t:r.kind===`result`?e[t-1]?.message.kind===`context_cleared`||e[t+1]?.message.kind===`context_cleared`:r.kind===`tool`&&r.toolKind===`todo_write`?t!==n.latestTodoWriteIndex:!1}function cM(e){switch(e.kind){case`user_prompt`:return`user_prompt`;case`system_init`:return`system_init`;case`account_info`:return`account_info`;case`assistant_text`:return`assistant_response`;case`tool`:return e.toolKind===`present_content`?`artifact`:`standalone_tool`;case`result`:return`result`;case`status`:return`status`;case`compact_boundary`:return`compact_boundary`;case`compact_summary`:return`compact_summary`;case`context_cleared`:return`context_cleared`;case`interrupted`:return`interrupted`;case`unknown`:return`unknown`;case`rate_limit`:return`rate_limit`;default:return e}}function lM(e,t={}){let n=Xj(e),r=[],i=rM(n,t.isLoading===!0),a=oM(n),o=0,s=null;for(;o<n.length;){let e=n[o],c=e.message;if(sM(n,o,a)){o+=1;continue}if(c.kind===`status`){s=aM(e,`status`),o+=1;continue}if(c.kind===`assistant_text`&&o!==i){let s=[e];for(o+=1;o<n.length&&o!==i&&!sM(n,o,a)&&nM(n[o].message);)s.push(n[o]),o+=1;let c=[];if(o<n.length&&tM(n[o].message))for(;s.length>0&&s[s.length-1].message.kind===`assistant_text`;)c.unshift(s.pop());if(s.length>=2||t.isLoading===!0&&s.length>=1){let e=iM(s);r.push({kind:`wip_block`,id:Zj(`wip_block`,e),sourceEntryIds:e,steps:s.map(e=>e.message)})}else s.length===1&&r.push(aM(s[0],cM(s[0].message)));for(let e of c)r.push(aM(e,`assistant_response`));continue}if($j(c)){let t=[e];for(o+=1;o<n.length&&!sM(n,o,a)&&$j(n[o].message);)t.push(n[o]),o+=1;if(t.length>=2){let e=iM(t);r.push({kind:`tool_group`,id:Zj(`tool_group`,e),sourceEntryIds:e,tools:t.map(e=>e.message)})}else r.push(aM(t[0],`standalone_tool`));continue}r.push(aM(e,cM(c))),o+=1}return s&&r.push(s),r}var uM={spawning:{dot:`bg-amber-400`,label:`Spawning`,pulse:!0},running:{dot:`bg-emerald-400`,label:`Running`,pulse:!0},waiting:{dot:`bg-sky-400`,label:`Waiting`,pulse:!0},completed:{dot:`bg-neutral-400 dark:bg-neutral-500`,label:`Done`,pulse:!1},failed:{dot:`bg-red-400`,label:`Failed`,pulse:!1},closed:{dot:`bg-neutral-300 dark:bg-neutral-600`,label:`Closed`,pulse:!1}},dM={root:m({id:`chat.composer.subagents.indicator`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),toggle:m({id:`chat.composer.subagents.toggle`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),dialog:m({id:`chat.composer.subagents.dialog`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),list:m({id:`chat.composer.subagents.list`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),transcript:m({id:`chat.composer.subagents.transcript`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`})},fM={content:b(cg,`h-[min(85vh,48rem)] max-w-5xl p-0`),body:`min-h-0 overflow-hidden p-0`,shell:`flex h-full min-h-0 flex-1 flex-col md:grid md:min-h-0 md:grid-cols-[18rem_minmax(0,1fr)]`,list:`flex shrink-0 gap-2 overflow-x-auto border-b border-border/70 p-3 md:min-h-0 md:shrink md:flex-col md:overflow-y-auto md:border-b-0 md:border-r`,transcriptPanel:`flex min-h-0 flex-1 flex-col overflow-hidden`,transcriptSlot:`flex min-h-0 flex-1 overflow-hidden`},pM=`inline`;function mM(e){return e===`spawning`||e===`running`||e===`waiting`}function hM(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return`${n}m${r>0?`${r}s`:``}`;let i=Math.floor(n/60),a=n%60;return`${i}h${a>0?`${a}m`:``}`}function gM(e){let t=0,n=0,r=0;for(let i of e){t+=1,mM(i.status)&&(n+=1),i.status===`failed`&&(r+=1);let e=gM(i.children);t+=e.total,n+=e.active,r+=e.failed}return{total:t,active:n,failed:r}}function _M(e){return e.every(e=>!mM(e.status)&&_M(e.children))}function vM(e,t=0){let n=[];for(let r of e)n.push({...r,depth:t}),n.push(...vM(r.children,t+1));return n}function yM(e){return e instanceof Error&&e.message.trim().length>0?e.message:`Unable to load the subagent transcript.`}function bM(e,t){return t&&e.some(e=>e.chatId===t)?t:e.find(e=>mM(e.status))?.chatId??e[0]?.chatId??null}function xM(e,t){return t?.runtime.title?.trim()||e?.instruction.trim()||(e?.chatId??`Subagent session`)}function SM({status:e,size:t=`sm`}){let n=uM[e],r=t===`sm`?`h-2 w-2`:`h-1.5 w-1.5`;return(0,Q.jsxs)(`span`,{className:`relative inline-flex items-center justify-center`,children:[n.pulse?(0,Q.jsx)(`span`,{className:b(`absolute inline-flex rounded-full opacity-60 animate-ping`,n.dot,r)}):null,(0,Q.jsx)(`span`,{className:b(`relative inline-flex rounded-full`,n.dot,r)})]})}function CM({node:e,nowMs:t,isSelected:n,onSelect:r}){let i=uM[e.status],a=hM(Math.max(0,t-e.spawnedAt)),o=!mM(e.status);return(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>r(e.chatId),className:b(`flex min-w-[14rem] items-center gap-2 rounded-xl border px-3 py-2 text-left transition-colors md:min-w-0 h-auto`,n?`border-primary/30 bg-primary/10`:`border-border/70 bg-background/70 hover:bg-muted/70`),style:{paddingLeft:`${e.depth*14+12}px`},children:[(0,Q.jsx)(SM,{status:e.status,size:`xs`}),(0,Q.jsxs)(`div`,{className:b(`min-w-0 flex-1 text-xs`,o&&`opacity-60`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-foreground/80`,title:e.instruction,children:e.instruction}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:a})]}),(0,Q.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,children:e.chatId}),(0,Q.jsx)(`span`,{className:b(`shrink-0 text-[10px] font-medium uppercase tracking-wide`,e.status===`failed`?`text-red-400`:`text-muted-foreground`),children:i.label})]})]})]})}function wM({session:e,scrollRef:t,localPath:n,onOpenLocalLink:r,onOpenExternalLink:i}){return e.isLoading?(0,Q.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-1 items-center justify-center bg-muted/20 px-4 text-sm text-muted-foreground`,children:`Loading full transcript…`}):e.error?(0,Q.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-1 items-center justify-center bg-destructive/5 px-4 text-sm text-destructive`,children:e.error}):e.messages.length===0?(0,Q.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-1 items-center justify-center bg-muted/20 px-4 text-sm text-muted-foreground`,children:`This session has no transcript yet.`}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col rounded-2xl border border-border/70 bg-background/90`,children:(0,Q.jsx)(`div`,{ref:t,className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,Q.jsx)(JA,{messages:e.messages,scrollRef:t,isLoading:!1,localPath:n,latestToolIds:Nj(e.messages),onOpenLocalLink:r,onOpenExternalLink:i,onAskUserQuestionSubmit:()=>{},onExitPlanModeConfirm:()=>{},richContentChrome:pM})})})}var TM=(0,j.memo)(function({parentChatId:e,hierarchy:t,socket:n,localPath:r,knownChatIds:i,onOpenLocalLink:a,onOpenExternalLink:o,className:s}){let[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(()=>Date.now()),[p,m]=(0,j.useState)(null),[h,g]=(0,j.useState)({snapshot:null,messages:[],isLoading:!1,error:null}),_=(0,j.useRef)(null),v=(0,j.useMemo)(()=>!t||t.children.length===0?null:gM(t.children),[t]),y=(0,j.useMemo)(()=>t?.children.map(e=>e.status)??[],[t]),x=(0,j.useMemo)(()=>vM(t?.children??[]),[t]),C=(0,j.useMemo)(()=>x.find(e=>e.chatId===p)??null,[x,p]);(0,j.useEffect)(()=>{let e=bM(x,p);e!==p&&m(e)},[x,p]),(0,j.useEffect)(()=>{if(!l)return;f(Date.now());let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[l]);let w=(0,j.useCallback)(()=>{if(!l||!p)return()=>{};let t=p;if(g({snapshot:null,messages:[],isLoading:!0,error:null}),C?.externalSessionId){let t=!1;return uj({socket:n,parentChatId:e??``,sessionId:C.externalSessionId,timeoutMs:12e4}).then(e=>{t||g({snapshot:null,messages:lM(e),isLoading:!1,error:null})}).catch(e=>{t||g({snapshot:null,messages:[],isLoading:!1,error:yM(e)})}),()=>{t=!0}}let r=!1,i=!1,a=!1,o=null,s=null,c=!1;async function u(e){if(!a){a=!0;try{let a=await lj({socket:n,chatId:t,offset:0,limit:Math.max(e??1,1),isLoading:c,timeoutMs:12e4});if(r)return;i=!0,g(e=>({...e,messages:a,isLoading:!1,error:null}))}catch(e){if(r)return;a=!1,g(t=>({...t,messages:[],isLoading:!1,error:yM(e)}))}}}let d=n.subscribe({type:`chat`,chatId:t},e=>{r||(s=e?.messageCount??s,c=e?.runtime.status===`starting`||e?.runtime.status===`running`||e?.runtime.status===`waiting_for_user`||e?.runtime.status===`awaiting_agents`,g(t=>({...t,snapshot:e})),!i&&!a&&u(s))},e=>{if(!(r||e.chatId!==t)){if(s=(s??0)+1,!i&&!a){u(s);return}o===null&&(o=requestAnimationFrame(()=>{o=null,!(r||!i)&&lj({socket:n,chatId:t,offset:0,limit:Math.max(s??1,1),isLoading:c,timeoutMs:12e4}).then(e=>{r||g(t=>({...t,messages:e}))}).catch(e=>{r||g(t=>({...t,error:yM(e)}))})}))}});return()=>{r=!0,o!==null&&cancelAnimationFrame(o),d()}},[l,e,p,C?.externalSessionId,n]);if((0,j.useEffect)(()=>w(),[w]),!v||!t)return null;let T=_M(t.children),E=C?i?.has(C.chatId)??!1:!1;return(0,Q.jsxs)(rg,{open:l,onOpenChange:u,children:[(0,Q.jsx)(`div`,{...c(dM.root),className:b(`transition-all duration-300 ease-out`,T&&!l&&`opacity-40 hover:opacity-80`,s),children:(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>u(!0),...c(dM.toggle),className:b(`group flex min-h-9 items-center gap-2 rounded-full border border-border/70 bg-background/85 px-3 py-1.5 text-xs text-foreground/80 shadow-sm transition-colors hover:bg-muted/60 h-auto`,`max-md:max-w-full max-md:justify-between`),children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(cr,{className:`h-3 w-3 text-muted-icon`}),(0,Q.jsx)(`span`,{className:`flex items-center gap-0.5`,children:y.map((e,t)=>(0,Q.jsx)(SM,{status:e,size:`sm`},t))}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:v.active>0?`${v.active} running`:`${v.total} agent${v.total===1?``:`s`}`})]}),v.failed>0?(0,Q.jsxs)(`span`,{className:`text-red-400`,children:[v.failed,` failed`]}):null]})}),(0,Q.jsxs)(pg,{...c(dM.dialog),className:fM.content,children:[(0,Q.jsxs)(mg,{className:b(lg,`gap-1`),children:[(0,Q.jsx)(hg,{children:`Subagent Sessions`}),(0,Q.jsx)(gg,{children:`Pick a spawned session to inspect its full transcript without leaving the current chat.`})]}),(0,Q.jsx)(_g,{className:fM.body,children:(0,Q.jsxs)(`div`,{className:fM.shell,children:[(0,Q.jsx)(`div`,{...c(dM.list),className:fM.list,children:x.map(e=>(0,Q.jsx)(CM,{node:e,nowMs:d,isSelected:e.chatId===p,onSelect:m},e.chatId))}),(0,Q.jsxs)(`div`,{className:fM.transcriptPanel,...c(dM.transcript),children:[(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-3`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:xM(C,h.snapshot)}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:C?.chatId??`No session selected`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>{w()},children:[(0,Q.jsx)(li,{className:`h-3.5 w-3.5`}),`Refresh`]}),E&&C?(0,Q.jsxs)(`a`,{href:`/chat/${C.chatId}`,className:`inline-flex h-8 items-center gap-1 rounded-full border border-border px-3 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,Q.jsx)(Cr,{className:`h-3.5 w-3.5`}),`Open chat`]}):null]})]})}),(0,Q.jsx)(`div`,{className:fM.transcriptSlot,children:(0,Q.jsx)(wM,{session:h,scrollRef:_,localPath:r,onOpenLocalLink:a,onOpenExternalLink:o})})]})]})}),(0,Q.jsx)(vg,{className:ug,children:(0,Q.jsx)(bg,{type:`button`,onClick:()=>u(!1),children:`Close`})})]})]})}),EM=Object.freeze([]);function DM(e){return e.startsWith(`smoke-spawn`)}function OM(e){return e.phase!==`exited`}function kM(){return w()(e=>({instances:EM,popoverOpen:!1,applySnapshot:t=>{let n=t.filter(OM).filter(e=>!DM(e.chatId));e({instances:n.length===0?EM:n})},applyDiff:t=>e(e=>{let n=e.instances;if(t.op===`added`)return!OM(t.instance)||DM(t.instance.chatId)||n.some(e=>e.chatId===t.instance.chatId)?e:{instances:[...n,t.instance]};if(t.op===`updated`){if(!OM(t.instance)){let r=n.filter(e=>e.chatId!==t.instance.chatId);return r.length===n.length?e:{instances:r.length===0?EM:r}}return n.some(e=>e.chatId===t.instance.chatId)?{instances:n.map(e=>e.chatId===t.instance.chatId?t.instance:e)}:{instances:[...n,t.instance]}}let r=n.filter(e=>e.chatId!==t.chatId);return r.length===n.length?e:{instances:r.length===0?EM:r}}),openPopover:()=>e({popoverOpen:!0}),closePopover:()=>e({popoverOpen:!1}),togglePopover:()=>e(e=>({popoverOpen:!e.popoverOpen}))}))}var AM=kM();function jM(){return AM(e=>e.instances)}function MM(){return AM(e=>e.instances.length)}function NM(){return AM(e=>e.popoverOpen)}function PM(e){if(!e.ok)throw Error(e.error??`pty request failed`);return e}async function FM(e,t){return PM(await e.rawRequest(ph(`pty.spawn`),t))}async function IM(e,t,n){PM(await e.rawRequest(ph(`pty.input`),{chatId:t,data:n}))}async function LM(e,t,n,r){PM(await e.rawRequest(ph(`pty.resize`),{chatId:t,cols:n,rows:r}))}async function RM(e,t){PM(await e.rawRequest(ph(`pty.cancel`),{chatId:t}))}async function zM(e,t){PM(await e.rawRequest(ph(`pty.exit`),{chatId:t}))}async function BM(e){let t=await e.rawRequest(ph(`pty.snapshot`),{});return PM(t),t.instances??[]}var VM={spawning:`var(--warning)`,"trust-dialog":`var(--warning)`,ready:`var(--success, oklch(0.72 0.16 145))`,streaming:`var(--primary)`,cancelling:`var(--warning)`,exited:`var(--muted-foreground)`},HM={spawning:`spawning`,"trust-dialog":`trust`,ready:`ready`,streaming:`streaming`,cancelling:`cancelling`,exited:`exited`};function UM(e){return e.length<=40?e:`…${e.slice(-39)}`}function WM(e){return e.length>8?e.slice(0,8):e}function GM(e,t){let n=Math.max(0,(t??Date.now())-e),r=Math.floor(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60);return i<60?`${i}m ${r%60}s`:`${Math.floor(i/60)}h ${i%60}m`}function KM(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t.toFixed(0)} KB`;let n=t/1024;return n<1024?`${n.toFixed(0)} MB`:`${(n/1024).toFixed(1)} GB`}function qM(e){return e>=100?`${e.toFixed(0)}%`:`${e.toFixed(1)}%`}function JM({phase:e}){return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-[10px] font-mono uppercase tracking-wide tabular-nums`,style:{background:`color-mix(in oklch, var(--muted) 60%, transparent)`},children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block w-[6px] h-[6px] rounded-full`,style:{backgroundColor:VM[e]}}),(0,Q.jsx)(`span`,{style:{color:VM[e]},children:HM[e]})]})}function YM({instance:e,onOpenChat:t,onCancel:n,onKill:r}){let[i,a]=(0,j.useState)(!1),o=(0,j.useCallback)(()=>{i?(r(e.chatId),a(!1)):a(!0)},[i,e.chatId,r]);return(0,Q.jsxs)(`div`,{className:`group border border-border/60 rounded-lg p-3 flex flex-col gap-2 hover:border-border transition-colors`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.chatId),className:`text-xs font-mono font-medium text-foreground hover:text-primary transition-colors text-left truncate flex-1 min-w-0`,children:WM(e.chatId)}),(0,Q.jsx)(JM,{phase:e.phase})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px] text-muted-foreground font-mono tabular-nums`,children:[(0,Q.jsxs)(`div`,{className:`truncate`,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`cwd`}),` `,UM(e.cwd)]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`pid`}),` `,e.pid??`—`]}),(0,Q.jsxs)(`div`,{className:`truncate`,title:e.model,children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`model`}),` `,e.model||`—`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`up`}),` `,GM(e.startedAt,e.exitedAt)]}),e.accountLabel?(0,Q.jsxs)(`div`,{className:`truncate col-span-2`,title:e.accountLabel,children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`acct`}),` `,e.accountLabel,e.oauthMasked?(0,Q.jsxs)(`span`,{className:`text-foreground/30`,children:[` · `,e.oauthMasked]}):null]}):null,e.planMode===null?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`plan`}),` `,e.planMode?`on`:`off`]}),e.smokeTest?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`smoke`}),` `,(0,Q.jsx)(`span`,{style:{color:e.smokeTest===`pass`?VM.ready:VM.exited},children:e.smokeTest})]}):null,e.rssBytes===null?null:(0,Q.jsxs)(`div`,{className:`truncate col-span-2`,title:`Resident memory (current · peak across session)`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`mem`}),` `,KM(e.rssBytes),e.rssPeakBytes!==null&&e.rssPeakBytes>e.rssBytes?(0,Q.jsxs)(`span`,{className:`text-foreground/30`,children:[` · peak `,KM(e.rssPeakBytes)]}):null]}),e.cpuPercent===null?null:(0,Q.jsxs)(`div`,{className:`truncate col-span-2`,title:`CPU usage % across process tree (current · peak; >100% = multi-core)`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`cpu`}),` `,qM(e.cpuPercent),e.cpuPeakPercent!==null&&e.cpuPeakPercent>e.cpuPercent?(0,Q.jsxs)(`span`,{className:`text-foreground/30`,children:[` · peak `,qM(e.cpuPeakPercent)]}):null]})]}),e.phase===`exited`?(0,Q.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground pt-1`,children:[`exited`,e.exitCode===null?``:` · code ${e.exitCode}`]}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.chatId),className:`text-[10px] font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors`,children:`open`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n(e.chatId),className:`text-[10px] font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors`,children:`cancel`}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,onBlur:()=>a(!1),className:`text-[10px] font-mono px-2 py-1 rounded-md border transition-colors ml-auto`,style:{borderColor:i?`var(--destructive)`:`var(--border)`,color:i?`var(--destructive)`:void 0},"aria-label":i?`Confirm kill`:`Kill PTY process`,children:i?`confirm kill?`:`kill`})]})]})}function XM({instances:e,liveCount:t,open:n,onOpenChange:r,onOpenChat:i,onCancel:a,onKill:o}){let s=t>0,c=s?`${t} claude PTY instance${t===1?``:`s`}`:`No live PTY instances`;return(0,Q.jsxs)(uv,{open:n,onOpenChange:r,children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(dv,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":c,className:`inline-flex items-center gap-1.5 px-1.5 h-9 rounded-md hover:bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block w-[7px] h-[7px] rounded-full flex-shrink-0`,style:{backgroundColor:s?VM.ready:`var(--muted-foreground)`}}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono font-medium tabular-nums leading-none`,style:{color:s?VM.ready:`var(--muted-foreground)`},children:[`pty `,t]})]})})}),(0,Q.jsx)(tl,{side:`bottom`,children:c})]}),(0,Q.jsxs)(fv,{align:`end`,sideOffset:8,className:`w-[420px] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-mono uppercase tracking-wider text-foreground/60`,children:`claude pty instances`}),(0,Q.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground tabular-nums`,children:[t,` live`]})]}),e.length===0?(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-6 font-mono`,children:`no instances yet`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 max-h-[60vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsx)(YM,{instance:e,onOpenChat:i,onCancel:a,onKill:o},e.chatId))})]})]})}function ZM({socket:e,onOpenChat:t}){let n=jM(),r=MM(),i=NM(),a=(0,j.useCallback)(e=>{let t=AM.getState();e?t.openPopover():t.closePopover()},[]),o=(0,j.useCallback)(e=>{AM.getState().closePopover(),t?.(e)},[t]),s=(0,j.useCallback)(t=>{e&&RM(e,t).catch(()=>{})},[e]),c=(0,j.useCallback)(t=>{e&&zM(e,t).catch(()=>{})},[e]);return(0,Q.jsx)(XM,{instances:(0,j.useMemo)(()=>n,[n]),liveCount:r,open:i,onOpenChange:a,onOpenChat:o,onCancel:s,onKill:c})}function QM(e,t){let n=t?.localPath??e;if(!n)return null;let r=n.split(`/`).filter(Boolean);return r.length>0?r[r.length-1]:n}function $M(e,t){if(!e)return null;let n=[e];if(t?.branch){let e=t.branch;t.ahead>0&&(e+=` +${t.ahead}`),t.behind>0&&(e+=` -${t.behind}`),n.push(e)}return n.join(` · `)}function eN(e){return e>=90?`bg-red-500 dark:bg-red-400`:e>=75?`bg-orange-500 dark:bg-orange-400`:e>=50?`bg-amber-500 dark:bg-amber-400`:`bg-emerald-500 dark:bg-emerald-400`}function tN({percent:e,testId:t}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,"data-testid":t,children:[(0,Q.jsxs)(`span`,{className:b(`text-xs font-medium leading-none tabular-nums`,nN(e)),children:[e,`%`]}),(0,Q.jsx)(`div`,{className:`w-12 h-1.5 rounded-full bg-muted/60 overflow-hidden`,children:(0,Q.jsx)(`div`,{className:b(`h-full rounded-full transition-all duration-500`,eN(e)),style:{width:`${Math.min(100,Math.max(0,e))}%`}})})]})}function nN(e){return e>=90?`text-red-600 dark:text-red-400`:e>=75?`text-orange-600 dark:text-orange-400`:e>=50?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function rN({localPath:e,repoStatus:t,compactLabel:n}){let[r,i]=(0,j.useState)(!1),a=t?.localPath??e;if(!(a||t?.branch||t?.isRepo))return(0,Q.jsx)(`span`,{className:`truncate text-xs leading-none text-muted-foreground`,title:n,children:n});let o=(t?.stagedCount??0)+(t?.unstagedCount??0)+(t?.untrackedCount??0);return(0,Q.jsxs)(uv,{open:r,onOpenChange:i,children:[(0,Q.jsx)(dv,{asChild:!0,children:(0,Q.jsx)(`button`,{className:`truncate text-xs leading-none text-muted-foreground hover:text-foreground transition-colors cursor-default`,onPointerEnter:()=>i(!0),onPointerLeave:()=>i(!1),children:n})}),(0,Q.jsx)(fv,{side:`bottom`,align:`end`,sideOffset:8,className:`w-auto min-w-48 max-w-72 p-2.5`,onPointerEnter:()=>i(!0),onPointerLeave:()=>i(!1),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Q.jsxs)(`div`,{className:`space-y-1.5 text-xs leading-relaxed`,children:[a?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Path`}),(0,Q.jsx)(`span`,{className:`text-foreground font-medium truncate`,children:a})]}):null,t?.branch?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Branch`}),(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:t.branch})]}):null,(t?.ahead??0)>0||(t?.behind??0)>0?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Sync`}),(0,Q.jsxs)(`span`,{className:`text-foreground font-medium`,children:[t.ahead>0?`+${t.ahead} ahead`:null,t.ahead>0&&t.behind>0?`, `:null,t.behind>0?`-${t.behind} behind`:null]})]}):null,o>0?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Changes`}),(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:[t.stagedCount>0?`${t.stagedCount} staged`:null,t.unstagedCount>0?`${t.unstagedCount} modified`:null,t.untrackedCount>0?`${t.untrackedCount} untracked`:null].filter(Boolean).join(`, `)})]}):null]})})]})}function iN(e){switch(e){case`running`:case`starting`:return`bg-emerald-500 animate-pulse`;case`waiting_for_user`:return`bg-amber-500`;case`awaiting_agents`:return`bg-blue-500 animate-pulse`;case`failed`:return`bg-red-500`;default:return`bg-muted-foreground/40`}}var aN={root:d({id:`chat.navbar`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),area:d({id:s(`chat.navbar`,`area`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),forkSessionAction:d({id:s(`chat.navbar.fork-session`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),mergeSessionAction:d({id:s(`chat.navbar.merge-session`,`action`),c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`})};v(aN);function oN({sidebarCollapsed:e,onOpenSidebar:t,onCollapseSidebar:n,onExpandSidebar:r,onForkSession:i,onMergeSession:a,localPath:o,currentSessionRuntime:s,currentRepoStatus:l,chatTitle:u,chatStatus:d,runtimeModel:f,runtimeProvider:p,socket:m,onOpenPtyChat:h}){let g=$M(QM(o,l),l),_=s?.tokenUsage?.estimatedContextPercent,v=s?.model??f??void 0,y=v?N_(v):p??null,x=y?M_[y]:null,C=!!(g||_!==void 0);return(0,Q.jsxs)(`div`,{...c(aN.root),className:`flex flex-col px-2 py-1.5 border-b border-border/40 bg-background flex-shrink-0`,children:[(0,Q.jsxs)(`div`,{...c(aN.area),className:`flex items-center gap-1.5 w-full min-w-0`,children:[(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`md:hidden size-7`,onClick:t,title:`Open sidebar`,children:(0,Q.jsx)(ni,{className:`size-4`})}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`hidden md:inline-flex size-7`,onClick:e?r:n,title:e?`Expand sidebar`:`Collapse sidebar`,children:(0,Q.jsx)(ni,{className:`size-4`})}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`md:hidden size-7`,onClick:r,"data-testid":`mobile-navbar-toggle`,title:`Expand sidebar`,children:(0,Q.jsx)(ni,{className:`size-4`})}),(0,Q.jsx)(S,{...c(aN.forkSessionAction),variant:`ghost`,size:`icon`,className:`hidden md:inline-flex size-7`,onClick:i,title:`Fork session`,children:(0,Q.jsx)(Lr,{className:`size-3.5`})}),(0,Q.jsx)(S,{...c(aN.mergeSessionAction),variant:`ghost`,size:`icon`,className:`hidden md:inline-flex size-7`,onClick:a,title:`Merge sessions`,children:(0,Q.jsx)(Xr,{className:`size-3.5`})}),x&&v?(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center size-7 text-muted-foreground`,"data-testid":`model-indicator`,children:(0,Q.jsx)(x,{className:`size-3.5`})})}),(0,Q.jsx)(tl,{side:`bottom`,sideOffset:8,children:v})]}):null,(0,Q.jsx)(ZM,{socket:m,onOpenChat:h}),u?(0,Q.jsx)(`div`,{className:`w-px h-3.5 bg-border/60 shrink-0`}):null,u?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,"data-testid":`session-summary`,"data-status":d??`idle`,children:[(0,Q.jsx)(`span`,{className:b(`size-2 shrink-0 rounded-full`,iN(d))}),(0,Q.jsx)(`span`,{className:`truncate text-xs leading-none text-muted-foreground`,title:u,children:u})]}):(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`div`,{className:`hidden md:flex items-center gap-1.5`,children:[g?(0,Q.jsx)(rN,{localPath:o,repoStatus:l,compactLabel:g}):null,_===void 0?null:(0,Q.jsx)(tN,{percent:_,testId:`context-bar`})]})]}),u||C?(0,Q.jsxs)(`div`,{className:b(`md:hidden flex items-center gap-2 w-full min-w-0 px-1 py-0.5 mt-0.5 rounded-full`,`transition-all duration-200`,`bg-transparent`,`active:bg-background`,`border border-transparent`),"data-testid":`mobile-info-strip`,children:[x&&v?(0,Q.jsx)(`div`,{className:`shrink-0 text-muted-foreground`,"data-testid":`mobile-provider-icon`,children:(0,Q.jsx)(x,{className:`size-3.5`})}):null,u?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,"data-testid":`mobile-title-row`,children:[(0,Q.jsx)(`span`,{className:b(`size-2 shrink-0 rounded-full`,iN(d))}),(0,Q.jsx)(`span`,{className:`truncate text-xs leading-none text-muted-foreground`,title:u,children:u})]}):(0,Q.jsx)(`div`,{className:`flex-1`}),g?(0,Q.jsx)(`span`,{className:`shrink-0 truncate text-xs leading-none text-muted-foreground`,"data-testid":`mobile-repo-label`,children:g}):null,_===void 0?null:(0,Q.jsx)(tN,{percent:_})]}):null]})}function sN(e,t){return t?e.find(e=>e.id===t)??null:null}var cN=[{id:`implementation_branch`,label:`Implementation branch`,description:`Continue toward a concrete feature or code change.`,defaultIntent:`Continue this work as an implementation branch. Carry forward the essential technical context, note the main constraints, and focus the new session on the next concrete coding steps.`,generatorHint:`Bias toward an execution-ready brief with concrete next implementation steps.`},{id:`alternative_approach`,label:`Alternative approach`,description:`Explore a different design or implementation path.`,defaultIntent:`Fork this into an alternative approach. Preserve only the key constraints and decisions from the current chat, then frame the new session around a distinctly different implementation strategy.`,generatorHint:`Emphasize the constraints and assumptions that still apply, but optimize for exploring a different solution path.`},{id:`bug_investigation`,label:`Bug investigation`,description:`Turn the current state into a focused debugging branch.`,defaultIntent:`Fork this into a bug investigation. Extract the symptoms, likely causes, relevant files, and the strongest reproduction or verification steps so the new session can debug efficiently.`,generatorHint:`Prioritize symptoms, repro steps, affected surfaces, and likely fault boundaries.`},{id:`cleanup_refactor`,label:`Cleanup / refactor`,description:`Narrow the work to code quality and simplification.`,defaultIntent:`Fork this into a cleanup and refactor pass. Keep the important behavioral constraints, identify the code areas most worth simplifying, and focus the new session on safer structural improvement.`,generatorHint:`Prioritize invariants, areas of complexity, and low-risk refactor opportunities.`},{id:`tests`,label:`Write tests`,description:`Build a testing-focused branch from the current work.`,defaultIntent:`Fork this into a test-writing pass. Capture the intended behavior, risky edges, missing verification, and the best targets for regression or integration tests.`,generatorHint:`Emphasize expected behavior, regressions to guard against, and concrete verification targets.`},{id:`docs_spec`,label:`Docs / spec`,description:`Extract the current work into a clearer brief or spec.`,defaultIntent:`Fork this into a docs or spec-writing session. Distill the relevant decisions, architecture, constraints, and open questions into a cleaner written brief for follow-up work.`,generatorHint:`Bias toward structured explanation, decisions, constraints, and unresolved questions.`}],lN=cN[0].id;function uN(e){return sN(cN,e)}var dN={dialog:d({id:`chat.fork-session.dialog`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),contextInput:d({id:`chat.fork-session.context.input`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),submitAction:d({id:s(`chat.fork-session.submit`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),cancelAction:d({id:s(`chat.fork-session.cancel`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),providerAction:d({id:s(`chat.fork-session.provider`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),providerPopover:d({id:s(`chat.fork-session.provider`,`popover`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),modelAction:d({id:s(`chat.fork-session.model`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),modelPopover:d({id:s(`chat.fork-session.model`,`popover`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),presetAction:d({id:s(`chat.fork-session.preset`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),presetPopover:d({id:s(`chat.fork-session.preset`,`popover`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`})};v(dN);function fN({open:e,onOpenChange:t,sourceTitle:n,defaultProvider:r,defaultModel:i,availableProviders:a,onFork:o}){let[s,l]=(0,j.useState)(0);function u(n){n&&!e&&l(e=>e+1),t(n)}return(0,Q.jsx)(rg,{open:e,onOpenChange:u,children:(0,Q.jsx)(pg,{size:`sm`,className:cg,...c(dN.dialog),children:e?(0,Q.jsx)(pN,{sourceTitle:n,defaultProvider:r,defaultModel:i,availableProviders:a,onFork:o,onClose:()=>u(!1)},s):null})})}function pN({sourceTitle:e,defaultProvider:t,defaultModel:n,availableProviders:r,onFork:i,onClose:a}){let[o,s]=(0,j.useState)(lN),[l,u]=(0,j.useState)(()=>uN(lN)?.defaultIntent??``),[d,f]=(0,j.useState)(t),[p,m]=(0,j.useState)(n),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(null),y=r.find(e=>e.id===d)??r[0],b=uN(o)??cN[0],x=M_[d];function S(e){f(e);let t=r.find(t=>t.id===e);t&&m(t.models[0]?.id??n)}function C(e){s(e),u(uN(e)?.defaultIntent??``)}async function w(){if(!(!l.trim()||h)){g(!0),v(null);try{await i(l.trim(),d,p,o),a()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(mg,{children:(0,Q.jsx)(hg,{children:`Fork session`})}),(0,Q.jsxs)(`div`,{className:`px-4 pb-4 pt-3.5 space-y-3 flex flex-col flex-1 min-h-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?.trim()?`Start a parallel session from “${e.trim()}”. Edit the focus below and Tinkaria will turn it into the opening brief.`:`Start a parallel session from the current chat. Edit the focus below and Tinkaria will turn it into the opening brief.`}),(0,Q.jsx)(mv,{triggerUiId:dN.presetAction,contentUiId:dN.presetPopover,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hi,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:b?.label??`Preset`})]}),children:e=>cN.map(t=>(0,Q.jsx)(pv,{onClick:()=>{C(t.id),e()},selected:t.id===o,icon:(0,Q.jsx)(hi,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.description},t.id))}),(0,Q.jsx)(gl,{...c(dN.contextInput),placeholder:e?.trim()?`What should the fork from “${e.trim()}” focus on?`:`What should this fork focus on?`,value:l,onChange:e=>u(e.target.value),autoFocus:!0,rows:4,className:`resize-none text-sm flex-1 min-h-[4lh]`,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&l.trim()&&!h&&(e.preventDefault(),w())}}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(mv,{triggerUiId:dN.providerAction,contentUiId:dN.providerPopover,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(x,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:y?.label??d})]}),children:e=>r.map(t=>{let n=M_[t.id];return(0,Q.jsx)(pv,{onClick:()=>{S(t.id),e()},selected:d===t.id,icon:(0,Q.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id)})}),(0,Q.jsx)(mv,{triggerUiId:dN.modelAction,contentUiId:dN.modelPopover,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(er,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:y?.models.find(e=>e.id===p)?.label??p})]}),children:e=>(y?.models??[]).map(t=>(0,Q.jsx)(pv,{onClick:()=>{m(t.id),e()},selected:p===t.id,icon:(0,Q.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.description},t.id))})]}),_?(0,Q.jsx)(`div`,{className:`text-sm text-destructive`,children:_}):null]}),(0,Q.jsxs)(vg,{className:ug,children:[(0,Q.jsx)(bg,{onClick:a,disabled:h,...c(dN.cancelAction),children:`Cancel`}),(0,Q.jsx)(yg,{onClick:()=>void w(),disabled:!l.trim()||h,...c(dN.submitAction),children:h?`Creating...`:`Create Session`})]})]})}var mN=[{id:`synthesis`,label:`Synthesis`,description:`Combine findings and decisions into a unified understanding.`,defaultIntent:`Synthesize these sessions into a unified understanding. Extract the key findings, decisions, and constraints from each, resolve any contradictions, and frame the merged context as a single coherent brief for the next step.`,generatorHint:`Bias toward a cohesive narrative that resolves contradictions and surfaces the strongest decisions from each source session.`},{id:`compare_decide`,label:`Compare & decide`,description:`Compare approaches explored in different sessions and surface trade-offs.`,defaultIntent:`Compare the approaches explored across these sessions. Surface the trade-offs, identify which constraints each approach satisfies or violates, and frame the merged context to support a clear decision.`,generatorHint:`Emphasize trade-offs, differences in assumptions, and decision criteria. Present approaches side-by-side.`},{id:`consolidate_progress`,label:`Consolidate progress`,description:`Merge partial work from several sessions into a single next-step brief.`,defaultIntent:`Consolidate the progress from these sessions into a single next-step brief. Identify what was completed, what remains, and any blockers or dependencies across the sessions.`,generatorHint:`Prioritize what was accomplished, what's left to do, and any cross-session dependencies or blockers.`},{id:`knowledge_base`,label:`Knowledge base`,description:`Extract and unify learned patterns, constraints, and decisions.`,defaultIntent:`Extract and unify the learned patterns, constraints, and key decisions from these sessions. Organize them as a reference brief that can guide future work without re-reading the originals.`,generatorHint:`Bias toward structured reference content: patterns, constraints, conventions, and decisions. Avoid execution steps.`}],hN=mN[0].id;function gN(e){return sN(mN,e)}var _N={dialog:d({id:`chat.merge-session.dialog`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),sessionsList:d({id:`chat.merge-session.sessions.list`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),sessionsSearchInput:d({id:`chat.merge-session.sessions.search.input`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),contextInput:d({id:`chat.merge-session.context.input`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),submitAction:d({id:s(`chat.merge-session.submit`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),cancelAction:d({id:s(`chat.merge-session.cancel`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),providerAction:d({id:s(`chat.merge-session.provider`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),providerPopover:d({id:s(`chat.merge-session.provider`,`popover`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),modelAction:d({id:s(`chat.merge-session.model`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),modelPopover:d({id:s(`chat.merge-session.model`,`popover`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),presetAction:d({id:s(`chat.merge-session.preset`,`action`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),presetPopover:d({id:s(`chat.merge-session.preset`,`popover`),c3ComponentId:`c3-110`,c3ComponentLabel:`chat`})};v(_N);var vN={running:`bg-emerald-500`,starting:`bg-yellow-500`,waiting_for_user:`bg-amber-500`,awaiting_agents:`bg-blue-500`,idle:`bg-muted-foreground/40`,failed:`bg-destructive`};function yN({open:e,onOpenChange:t,defaultProvider:n,defaultModel:r,availableProviders:i,availableChats:a,minSessions:o=1,onMerge:s}){let[l,u]=(0,j.useState)(0);function d(n){n&&!e&&u(e=>e+1),t(n)}return(0,Q.jsx)(rg,{open:e,onOpenChange:d,children:(0,Q.jsx)(pg,{size:`md`,className:cg,...c(_N.dialog),children:e?(0,Q.jsx)(bN,{defaultProvider:n,defaultModel:r,availableProviders:i,availableChats:a,minSessions:o,onMerge:s,onClose:()=>d(!1)},l):null})})}function bN({defaultProvider:e,defaultModel:t,availableProviders:n,availableChats:r,minSessions:i=1,onMerge:a,onClose:o}){let[s,l]=(0,j.useState)(new Set),[u,d]=(0,j.useState)(``),[f,p]=(0,j.useState)(hN),[m,h]=(0,j.useState)(()=>gN(hN)?.defaultIntent??``),[g,_]=(0,j.useState)(e),[v,y]=(0,j.useState)(t),[x,C]=(0,j.useState)(!1),[w,T]=(0,j.useState)(null),[E,D]=(0,j.useState)(!1),O=n.find(e=>e.id===g)??n[0],k=gN(f)??mN[0],A=M_[g],M=u.toLowerCase(),N=u?r.filter(e=>(e.title||e.chatId).toLowerCase().includes(M)):r;function P(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.size<5&&n.add(e),n})}function F(e){_(e);let r=n.find(t=>t.id===e);r&&y(r.models[0]?.id??t)}function I(e){p(e),h(gN(e)?.defaultIntent??``)}async function L(){if(!(s.size<i||!m.trim()||x)){C(!0),T(null);try{await a([...s],m.trim(),g,v,f,E),o()}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}}}let R=s.size>=i&&m.trim().length>0&&!x;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(mg,{children:(0,Q.jsx)(hg,{children:`Merge sessions`})}),(0,Q.jsxs)(`div`,{className:`px-4 pb-4 pt-3.5 space-y-3 flex flex-col flex-1 min-h-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select sessions to merge and describe the target outcome. Tinkaria will compact each selected session, then start a dedicated session with the merged brief.`}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(di,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground pointer-events-none`}),(0,Q.jsx)(ml,{...c(_N.sessionsSearchInput),type:`text`,size:`sm`,placeholder:`Search sessions...`,value:u,onChange:e=>d(e.target.value),className:`pl-6`})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-0.5`,children:(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s.size,` of `,5,` max selected`]})}),(0,Q.jsx)(`div`,{...c(_N.sessionsList),className:`max-h-[200px] overflow-y-auto [scrollbar-width:thin] border border-border rounded-lg`,children:N.length===0?(0,Q.jsx)(`div`,{className:`text-center text-xs text-muted-foreground py-6`,children:`No sessions found`}):(0,Q.jsx)(`div`,{className:`flex flex-col`,children:N.map(e=>{let t=s.has(e.chatId),n=s.size>=5&&!t;return(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>P(e.chatId),disabled:n,className:b(`flex items-center gap-2.5 px-3 py-2 text-left h-auto w-full justify-start rounded-none border-0 border-b border-border last:border-b-0`,t?`bg-primary/10`:`hover:bg-muted/50`,n&&`opacity-40 cursor-not-allowed`),children:[(0,Q.jsx)(`div`,{className:b(`h-3.5 w-3.5 shrink-0 rounded border transition-colors flex items-center justify-center`,t?`bg-primary border-primary text-primary-foreground`:`border-muted-foreground/40`),children:t?(0,Q.jsx)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,Q.jsx)(`path`,{d:`M2 6l3 3 5-5`})}):null}),(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.title||e.chatId}),(0,Q.jsx)(`span`,{className:b(`h-1.5 w-1.5 rounded-full shrink-0`,vN[e.status]??vN.idle)}),e.provider?(0,Q.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground shrink-0 leading-none`,children:e.provider}):null]})}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:w_(e.lastMessageAt??e._creationTime)})]},e.chatId)})})})]}),(0,Q.jsx)(mv,{triggerUiId:_N.presetAction,contentUiId:_N.presetPopover,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hi,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:k?.label??`Preset`})]}),children:e=>mN.map(t=>(0,Q.jsx)(pv,{onClick:()=>{I(t.id),e()},selected:t.id===f,icon:(0,Q.jsx)(hi,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.description},t.id))}),(0,Q.jsx)(gl,{...c(_N.contextInput),placeholder:`Describe how these sessions should be merged...`,value:m,onChange:e=>h(e.target.value),autoFocus:!0,rows:4,className:`resize-none text-sm flex-1 min-h-[4lh]`,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&R&&(e.preventDefault(),L())}}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(mv,{triggerUiId:_N.providerAction,contentUiId:_N.providerPopover,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:O?.label??g})]}),children:e=>n.map(t=>{let n=M_[t.id];return(0,Q.jsx)(pv,{onClick:()=>{F(t.id),e()},selected:g===t.id,icon:(0,Q.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id)})}),(0,Q.jsx)(mv,{triggerUiId:_N.modelAction,contentUiId:_N.modelPopover,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(er,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:O?.models.find(e=>e.id===v)?.label??v})]}),children:e=>(O?.models??[]).map(t=>(0,Q.jsx)(pv,{onClick:()=>{y(t.id),e()},selected:v===t.id,icon:(0,Q.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.description},t.id))})]}),w?(0,Q.jsx)(`div`,{className:`text-sm text-destructive`,children:w}):null,(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-muted-foreground cursor-pointer select-none`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`rounded border-border accent-primary`}),`Close source sessions after merge`]})]}),(0,Q.jsxs)(vg,{className:ug,children:[(0,Q.jsx)(bg,{onClick:o,disabled:x,...c(_N.cancelAction),children:`Cancel`}),(0,Q.jsx)(yg,{onClick:()=>void L(),disabled:!R,...c(_N.submitAction),children:x?`Creating...`:`Create Session`})]})]})}var xN=j.forwardRef(({className:e,children:t,...n},r)=>(0,Q.jsx)(`div`,{ref:r,className:b(`relative overflow-y-auto overscroll-contain touch-pan-y scrollbar-hide`,e),style:{WebkitOverflowScrolling:`touch`},...n,children:t}));xN.displayName=`ScrollArea`;function SN({onClose:e,touchedFiles:t,workspacePath:n,onOpenFile:r}){return(0,Q.jsx)(`div`,{...c(m({id:`chat.right-sidebar`,c3ComponentId:`c3-115`,c3ComponentLabel:`right-sidebar`})),className:`h-full min-h-0 border-l border-border bg-background md:min-w-[300px]`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:[`Touched files`,t.length>0?` (${t.length})`:``]}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close right sidebar`,onClick:e,children:(0,Q.jsx)(Di,{className:`h-4 w-4`})})]}),t.length===0?(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No files touched yet`})}):(0,Q.jsx)(xN,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(`ul`,{className:`flex flex-col py-1`,children:t.map(e=>{let t=_T(e.path,n),i=e.change===`created`?Dr:Tr;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),title:`${e.change===`created`?`Created`:`Edited`} — ${t}`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm hover:bg-muted/60`,children:[(0,Q.jsx)(i,{className:`size-3.5 shrink-0 ${e.change===`created`?`text-emerald-500`:`text-amber-500`}`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t})]})},e.path)})})})]})})}var CN={connecting:`Connecting...`,acquiring_sandbox:`Booting...`,initializing:`Initializing...`,starting:`Starting...`,running:`Running...`,waiting_for_user:`Waiting...`,awaiting_agents:`Awaiting agents...`,failed:`Failed`};function wN({status:e}){let t=fA(),n=(e?CN[e]:void 0)||`Processing...`;return e===`failed`?(0,Q.jsx)(`div`,{className:`px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-sm`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(ur,{className:`size-4.5 text-destructive mt-0.5 flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-destructive`,children:`Session failed to start`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`The CLI process exited before it could respond.`}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mt-1.5`,children:[(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:t?.onRetryChat,children:`Try again`}),(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:t?.onDismissError,children:`Dismiss`})]})]})]})}):(0,Q.jsx)(RO,{className:`ml-[1px]`,children:(0,Q.jsxs)(zO,{children:[(0,Q.jsx)(Gr,{className:`size-4.5 animate-spin text-muted-icon`}),(0,Q.jsx)(y_,{className:`ml-[1px] text-sm`,shimmerWidth:44,children:n})]})})}var TN=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:b(`bg-card text-card-foreground`,e),...t}));TN.displayName=`Card`;var EN=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:b(`flex flex-col space-y-1.5 p-2`,e),...t}));EN.displayName=`CardHeader`;var DN=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`h3`,{ref:n,className:b(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));DN.displayName=`CardTitle`;var ON=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`p`,{ref:n,className:b(`text-sm text-muted-foreground`,e),...t}));ON.displayName=`CardDescription`;var kN=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:b(`p-6 pt-0`,e),...t}));kN.displayName=`CardContent`;var AN=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:b(`flex items-center p-6 pt-0`,e),...t}));AN.displayName=`CardFooter`;function jN(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function MN(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function NN(e){return e/100*window.innerHeight}function PN(e){return e/100*window.innerWidth}function FN(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function IN({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=FN(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=MN(t,i);break;case`em`:r=jN(t,i);break;case`vh`:r=NN(i);break;case`vw`:r=PN(i);break}return r}function LN(e){return parseFloat(e.toFixed(3))}function RN({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function zN(e){let{panels:t}=e,n=RN({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=LN(IN({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=LN(IN({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=LN(IN({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=LN(IN({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function BN(e,t=`Assertion error`){if(!e)throw Error(t)}function VN(e,t){return Array.from(t).sort(e===`horizontal`?HN:UN)}function HN(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function UN(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function WN(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function GN(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function KN({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=GN(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return BN(i,`No rect found`),i}var qN;function JN(){return qN===void 0&&(qN=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),qN}function YN(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=VN(n,Array.from(t.children).filter(WN).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,KN({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=JN()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:RN({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var XN=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},ZN=new Map,QN=new XN;function $N(e){ZN=new Map(ZN),ZN.delete(e)}function eP(e,t){for(let[t]of ZN)if(t.id===e)return t}function tP(e,t){for(let[t,n]of ZN)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function nP(){return ZN}function rP(e,t){return QN.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function iP(e,t){let n=ZN.get(e);ZN=new Map(ZN),ZN.set(e,t),QN.emit(`groupChange`,{group:e,prev:n,next:t})}function aP(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=GN(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function oP(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function sP(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:pP(e),b:pP(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();BN(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:fP(dP(n.a)),b:fP(dP(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var cP=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lP(e){let t=getComputedStyle(mP(e)??e).display;return t===`flex`||t===`inline-flex`}function uP(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||lP(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||cP.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function dP(e){let t=e.length;for(;t--;){let n=e[t];if(BN(n,`Missing node`),uP(n))return n}return null}function fP(e){return e&&Number(getComputedStyle(e).zIndex)||0}function pP(e){let t=[];for(;e;)t.push(e),e=mP(e);return t}function mP(e){let{parentNode:t}=e;return oP(t)?t.host:t}function hP(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function gP({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!WN(n)||n.contains(e)||e.contains(n))return!0;if(sP(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(hP(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function _P(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=YN(r),a=aP(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&gP({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function vP(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function yP(e,t,n=0){return Math.abs(LN(e)-LN(t))<=n}function bP(e,t){return yP(e,t)?0:e>t?1:-1}function xP({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(bP(r,c)<0)if(a){let e=(i+c)/2;r=bP(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=LN(r),r}function SP({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(yP(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;BN(u!=null,`Invalid first pivot index`),BN(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];BN(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(BN(n!=null,`Previous layout not found for panel index ${t}`),yP(n,i)){let t=o-n;bP(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];BN(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(BN(n!=null,`Previous layout not found for panel index ${t}`),yP(n,o)){let t=n-i;bP(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];BN(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&bP(i,c)<0)if(e>0){let t=c-o,n=t/2;bP(i+e,c)<0&&(e=bP(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;bP(i-e,c)<0&&(e=bP(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];BN(e!=null,`Previous layout not found for panel index ${r}`);let a=xP({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];BN(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=xP({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!yP(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(vP(c,l))return i;{let t=e<0?d:u,r=s[t];BN(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=xP({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!yP(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];BN(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=xP({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(yP(i,s)||(t-=s-i,l[r]=s),yP(t,0))break;e>0?r--:r++}}}if(!yP(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function CP(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||bP(e[n],t[n])!==0)return!1;return!0}function wP({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!yP(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];BN(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];BN(i!=null,`No layout data found for index ${e}`);let o=r[e];BN(o!=null,`No layout data found for index ${e}`);let s=xP({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!yP(a,0))for(let e=0;e<t.length;e++){let n=r[e];BN(n!=null,`No layout data found for index ${e}`);let i=n+a,o=xP({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,yP(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function TP({groupId:e,panelId:t}){let n=()=>{let t=nP();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=wP({layout:SP({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});CP(l,p)||iP(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&yP(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=RN({group:t});o(LN(IN({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function EP(e){e.defaultPrevented||_P(e,nP()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=TP({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function DP(e){let t=nP();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function OP({groupId:e}){let t=()=>{let t=nP();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=wP({layout:e,panelConstraints:r});return n?o:(CP(o,c)||iP(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function kP(e,t){let n=DP(e),r=tP(n.id,!0),i=n.separators.find(t=>t.element===e);BN(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);BN(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=OP({groupId:n.id}).getLayout(),c=wP({layout:SP({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});CP(s,c)||iP(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function AP(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=DP(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&kP(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&kP(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&kP(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&kP(t,-5);break;case`End`:e.preventDefault(),kP(t,100);break;case`Enter`:{e.preventDefault();let n=DP(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=tP(n.id,!0),o=n.separators.find(e=>e.element===t);BN(o,`Matching separator not found`);let s=a.get(o);BN(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(BN(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];kP(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=DP(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);BN(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),kP(t,-100);break}}var jP={cursorFlags:0,state:`inactive`},MP=new XN;function NP(){return jP}function PP(e){return MP.addListener(`change`,e)}function FP(e){let t=jP,n={...jP};n.cursorFlags=e,jP=n,MP.emit(`change`,{prev:t,next:n})}function IP(e){let t=jP;jP=e,MP.emit(`change`,{prev:t,next:e})}function LP(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=nP(),n=_P(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),IP({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var RP=e=>e,zP=()=>{},BP=1,VP=2,HP=4,UP=8,WP=3,GP=12,KP;function qP(){return KP===void 0&&(KP=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(KP=!0)),KP}function JP({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&qP()){let t=(e&BP)!==0,n=(e&VP)!==0,r=(e&HP)!==0,i=(e&UP)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return qP()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var YP=new WeakMap;function XP(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=YP.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=NP();switch(r.state){case`active`:case`hover`:{let e=JP({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}YP.set(e,{prevStyle:t,styleSheet:n})}function ZP({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=SP({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(CP(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?BP:VP;break;case`vertical`:s|=d<0?HP:UP;break}}else iP(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&WP:c|=s&WP,t.movementY===0?c|=o&GP:c|=s&GP,FP(c),XP(e)}function QP(e){let t=nP(),n=NP();switch(n.state){case`active`:ZP({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function $P(e){if(e.defaultPrevented)return;let t=NP(),n=nP();switch(t.state){case`active`:if(e.buttons===0){IP({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=tP(e.group.id,!0);iP(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}ZP({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=_P(e,n);r.length===0?t.state!==`inactive`&&IP({cursorFlags:0,state:`inactive`}):IP({cursorFlags:0,hitRegions:r,state:`hover`}),XP(e.currentTarget);break}}}function eF(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(NP().state){case`hover`:IP({cursorFlags:0,state:`inactive`})}}function tF(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=NP();switch(t.state){case`active`:IP({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(XP(e.currentTarget),t.hitRegions.forEach(e=>{let t=tP(e.group.id,!0);iP(e.group,t)}),e.preventDefault())}}function nF(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=LN(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=LN((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function rF(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=RN({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:LN(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function iF(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function aF({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=LN(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=LN((r[e]??0)/a*l);else{let e=LN(l/c.length);for(let t of c)u[t]=e}return u}function oF(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var sF=new Map;function cF(e){let t=!0;BN(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=RN({group:e});if(t===0)return;let n=tP(e.id);if(!n)return;let r=zN(e),i=n.defaultLayoutDeferred?nF(r):n.layout,a=wP({layout:aF({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&CP(n.layout,a)&&iF(n.derivedPanelConstraints,r)&&n.groupSize===t)return;iP(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else rF(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{BN(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=RN({group:e}),s=zN(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(oF(e.panels,l)||(l=void 0));let u=wP({layout:e.mutableState.layouts[c]??l??nF(s),panelConstraints:s}),d=e.element.ownerDocument;sF.set(d,(sF.get(d)??0)+1);let f=new Map;return YN(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),iP(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{BN(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,AP)}),sF.get(d)===1&&(d.addEventListener(`dblclick`,EP,!0),d.addEventListener(`pointerdown`,LP,!0),d.addEventListener(`pointerleave`,QP),d.addEventListener(`pointermove`,$P),d.addEventListener(`pointerout`,eF),d.addEventListener(`pointerup`,tF,!0)),function(){t=!1,sF.set(d,Math.max(0,(sF.get(d)??0)-1)),$N(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,AP)}),sF.get(d)||(d.removeEventListener(`dblclick`,EP,!0),d.removeEventListener(`pointerdown`,LP,!0),d.removeEventListener(`pointerleave`,QP),d.removeEventListener(`pointermove`,$P),d.removeEventListener(`pointerout`,eF),d.removeEventListener(`pointerup`,tF,!0)),a.disconnect()}}function lF(){let[e,t]=(0,j.useState)({});return[e,(0,j.useCallback)(()=>t({}),[])]}function uF(e){let t=(0,j.useId)();return`${e??t}`}var dF=typeof window<`u`?j.useLayoutEffect:j.useEffect;function fF(e){let t=(0,j.useRef)(e);return dF(()=>{t.current=e},[e]),(0,j.useCallback)((...e)=>t.current?.(...e),[t])}function pF(...e){return fF(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function mF(e){let t=(0,j.useRef)({...e});return dF(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var hF=(0,j.createContext)(null);function gF(e,t){let n=(0,j.useRef)({getLayout:()=>({}),setLayout:RP});(0,j.useImperativeHandle)(t,()=>n.current,[]),dF(()=>{Object.assign(n.current,OP({groupId:e}))})}function _F({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,j.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=fF(e=>{CP(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=fF(e=>{CP(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=uF(s),v=(0,j.useRef)(null),[y,b]=lF(),x=(0,j.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=pF(v,a);gF(_,o);let C=fF((e,t)=>{let r=NP(),i=eP(e),a=tP(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=mF({defaultLayout:n,disableCursor:r}),T=(0,j.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=VN(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=VN(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=eP(_),i=tP(_);r&&i&&iP(r,{...i,derivedPanelConstraints:zN(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,j.useRef)(null);return dF(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=cF(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=tP(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=rP(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=yP(t.collapsedSize,i[t.panelId]),a=yP(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=NP().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,j.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,Q.jsx)(hF.Provider,{value:T,children:(0,Q.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}_F.displayName=`Group`;function vF(){let e=(0,j.useContext)(hF);return BN(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function yF(e,t){let{id:n}=vF(),r=(0,j.useRef)({collapse:zP,expand:zP,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:zP});(0,j.useImperativeHandle)(t,()=>r.current,[]),dF(()=>{Object.assign(r.current,TP({groupId:n,panelId:e}))})}function bF({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=uF(c),_=mF({disabled:a}),v=(0,j.useRef)(null),y=pF(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=vF(),T=d!==null,E=fF((e,t,n)=>{d?.(e,c,n)});dF(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,j.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),yF(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,j.useSyncExternalStore)(e=>rP(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,Q.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...xF,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,Q.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}bF.displayName=`Panel`;var xF={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function SF({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=wP({layout:SP({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=wP({layout:SP({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function CF({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=uF(a),l=mF({disabled:n,disableDoubleClick:r}),[u,d]=(0,j.useState)({}),[f,p]=(0,j.useState)(`inactive`),m=(0,j.useRef)(null),h=pF(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=vF(),x=v===`horizontal`?`vertical`:`horizontal`;dF(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=PP(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=rP(_,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(SF({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[_,c,y,l]),(0,j.useEffect)(()=>{b(c,{disabled:n,disableDoubleClick:r})},[n,r,c,b]);let S;return n&&!g&&(S=`not-allowed`),(0,Q.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":x,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":n?`disabled`:f,"data-testid":c,id:c,ref:h,role:`separator`,style:{flexBasis:`auto`,cursor:S,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}CF.displayName=`Separator`;var wF=({className:e,...t})=>(0,Q.jsx)(_F,{className:b(`flex h-full w-full`,e),...t}),TF=e=>(0,Q.jsx)(bF,{...e}),EF=({withHandle:e,orientation:t,disabled:n,className:r,...i})=>(0,Q.jsx)(CF,{disabled:n,className:b(`relative flex items-center justify-center bg-transparent focus-visible:outline-none`,t===`vertical`?`h-2 w-full -my-1 cursor-row-resize before:absolute before:inset-x-0 before:top-1/2 before:h-0.5 before:-translate-y-1/2 before:bg-border`:`h-full w-2 -mx-1 cursor-col-resize before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border`,r),...i,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:t===`vertical`?`Resize rows`:`Resize columns`})});function DF(e){return e===`write_file`?`created`:e===`edit_file`?`edited`:null}function OF(e){return e.kind===`standalone_tool`?[e.tool]:e.kind===`tool_group`?e.tools:e.kind===`wip_block`?e.steps.filter(e=>e.kind===`tool`):[]}function kF(e){let t=new Map,n=0;for(let r of e)for(let e of OF(r)){let r=DF(e.toolKind);if(r===null)continue;let i=e.input.filePath;typeof i!=`string`||i.trim()===``||(t.set(i,{change:r,seq:n}),n+=1)}return Array.from(t.entries()).sort((e,t)=>t[1].seq-e[1].seq).map(([e,{change:t}])=>({path:e,change:t}))}function AF(e){return Number.isFinite(e)?Math.min(50,Math.max(20,e)):30}function jF(){return{isVisible:!1,size:20}}function MF(e,t){return e[t]??jF()}function NF(e){if(!e||typeof e!=`object`)return{workspaces:{}};let t=e;return{workspaces:Object.fromEntries(Object.entries(t.workspaces??t.projects??{}).map(([e,t])=>[e,{isVisible:!1,size:AF(t.size??30)}]))}}var PF=w()(Wx(e=>({workspaces:{},toggleVisibility:t=>e(e=>({workspaces:{...e.workspaces,[t]:{...MF(e.workspaces,t),isVisible:!MF(e.workspaces,t).isVisible}}})),setSize:(t,n)=>e(e=>({workspaces:{...e.workspaces,[t]:{...MF(e.workspaces,t),size:AF(n)}}})),clearProject:t=>e(e=>{let{[t]:n,...r}=e.workspaces;return{workspaces:r}})}),{name:`right-sidebar-layouts`,version:2,migrate:NF})),FF={isVisible:!1,size:20},IF=[.4,0,.2,1],LF=8,RF=1e-6;function zF(e,t,n){let r=1-e;return 3*r*r*e*t+3*r*e*e*n+e*e*e}function BF(e,t,n){let r=1-e;return 3*r*r*e*t+3*r*e*e*n+e*e*e}function VF(e,t,n){let r=1-e;return 3*r*r*t+6*r*e*(n-t)+3*e*e*(1-n)}function HF(e,t,n){let r=e;for(let i=0;i<LF;i+=1){let i=zF(r,t,n)-e;if(Math.abs(i)<RF)return r;let a=VF(r,t,n);if(Math.abs(a)<RF)break;r-=i/a}return r}function UF(e){if(e<=0)return 0;if(e>=1)return 1;let[t,n,r,i]=IF;return BF(HF(e,t,r),n,i)}function WF(e,t,n){let r=UF(n);return[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r]}function GF({workspaceId:e,shouldRenderRightSidebarLayout:t,showRightSidebar:n,rightSidebarSize:r}){let i=(0,j.useRef)(null),a=(0,j.useRef)(null),o=(0,j.useRef)(null),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(!1),f=(0,j.useRef)(!1);return(0,j.useEffect)(()=>()=>{s.current!==null&&window.cancelAnimationFrame(s.current),c.current!==null&&window.clearTimeout(c.current)},[]),(0,j.useLayoutEffect)(()=>{if(!t){s.current!==null&&(window.cancelAnimationFrame(s.current),s.current=null),c.current!==null&&(window.clearTimeout(c.current),c.current=null),l.current=!1;return}let p=i.current;if(!p)return;s.current!==null&&(window.cancelAnimationFrame(s.current),s.current=null),c.current!==null&&(window.clearTimeout(c.current),c.current=null);let m=u.current,h=m!==null&&m!==e,g=n&&!f.current,_=!d.current,v=n?[100-r,r]:[100,0],y=h||_&&n,b=g||_?[100,0]:[p.getLayout().workspace??v[0],p.getLayout().rightSidebar??v[1]];if(u.current=e,d.current=t,f.current=n,y||Math.abs(b[0]-v[0])<.1&&Math.abs(b[1]-v[1])<.1){p.setLayout({workspace:v[0],rightSidebar:v[1]}),a.current?.setAttribute(`data-right-sidebar-open`,n?`true`:`false`),o.current?.setAttribute(`data-right-sidebar-open`,n?`true`:`false`),o.current?.setAttribute(`data-right-sidebar-animated`,`false`);return}l.current=!0,a.current?.setAttribute(`data-right-sidebar-open`,n?`true`:`false`),o.current?.setAttribute(`data-right-sidebar-open`,n?`true`:`false`),o.current?.setAttribute(`data-right-sidebar-animated`,`true`),p.setLayout({workspace:b[0],rightSidebar:b[1]});let x=performance.now(),S=e=>{let t=Math.min(1,(e-x)/350),n=WF(b,v,t);if(p.setLayout({workspace:n[0],rightSidebar:n[1]}),t<1){s.current=window.requestAnimationFrame(S);return}p.setLayout({workspace:v[0],rightSidebar:v[1]}),s.current=null,c.current=window.setTimeout(()=>{l.current=!1,c.current=null},0)};s.current=window.requestAnimationFrame(S)},[e,r,t,n]),(0,j.useEffect)(()=>{t||(d.current=!1,f.current=!1)},[t]),{isAnimating:l,panelGroupRef:i,sidebarPanelRef:a,sidebarVisualRef:o}}function KF({rootRef:e,fallbackRef:t,enabled:n,canCancel:r}){(0,j.useEffect)(()=>{if(!n)return;let i=0,a=null,o=n=>{let r=n instanceof Element?n:null,i=e.current,o=t.current;if(ng({trigger:`pointer`,activeElement:document.activeElement,pointerStartTarget:a,pointerEndTarget:r,root:i,fallback:o,hasActiveOverlay:eg(document)})!==`restore`){a=null;return}o?.focus({preventScroll:!0}),a=null},s=e=>{cancelAnimationFrame(i),a=e.target instanceof Element?e.target:null},c=e=>{cancelAnimationFrame(i),i=window.requestAnimationFrame(()=>{o(e.target)})},l=()=>{a=null;let e=t.current;!e||e.disabled||e.focus({preventScroll:!0})},u=e=>{if(e.key!==`Escape`)return;let n=t.current;ng({trigger:`escape`,activeElement:document.activeElement,fallback:n,hasActiveOverlay:eg(document),canCancel:r,defaultPrevented:e.defaultPrevented})===`escape-focus`&&(e.preventDefault(),n?.focus({preventScroll:!0}))};return window.addEventListener(`pointerdown`,s,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`keydown`,u,!0),window.addEventListener(Jh,l),()=>{cancelAnimationFrame(i),window.removeEventListener(`pointerdown`,s,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(Jh,l)}},[r,n,t,e])}function qF({nav:e,onScrollToBottom:t}){let{currentIndex:n,totalCount:r,currentLabel:i,goNext:a,goPrev:o}=e;if(r===0)return t?(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,onClick:t,className:`rounded-full border border-border bg-white dark:bg-slate-700 dark:text-slate-100 dark:border-slate-600 dark:hover:bg-slate-600`,children:(0,Q.jsx)(qn,{className:`h-5 w-5`})}):null;let s=Math.max(0,n)+1;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-full border border-border bg-white dark:bg-slate-700 dark:border-slate-600 shadow-sm px-1 py-0.5`,children:[(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,onClick:o,className:`h-7 w-7 rounded-full dark:text-slate-100 dark:hover:bg-slate-600`,children:(0,Q.jsx)(sr,{className:`h-4 w-4`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 text-xs text-muted-foreground min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`font-medium shrink-0 tabular-nums`,children:[s,`/`,r]}),(0,Q.jsx)(`span`,{className:`truncate max-w-[180px]`,children:i})]}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,onClick:a,className:`h-7 w-7 rounded-full dark:text-slate-100 dark:hover:bg-slate-600`,children:(0,Q.jsx)(cr,{className:`h-4 w-4`})})]})}function JF(e,t){return t.type===`chat-changed`?`anchoring`:e===`anchoring`?t.type===`initial-scroll-done`?t.anchor===`tail`?`following`:`detached`:t.type===`intersection-change`&&!t.isProgrammatic&&!t.isIntersecting?`detached`:`anchoring`:t.type===`scroll-to-bottom`?`following`:t.type===`intersection-change`?t.isProgrammatic?e:t.isIntersecting?`following`:`detached`:e}function YF(e,t){return e===`detached`&&t>0}function XF(e){return e===`following`}function ZF(e){let t=!1,n=new IntersectionObserver(n=>{if(t)return;let r=n[0];r&&e.onIntersectionChange(r.isIntersecting)},{root:e.scrollEl,threshold:0,rootMargin:`0px 0px 20px 0px`});return n.observe(e.sentinelEl),{reobserve(){n.unobserve(e.sentinelEl),n.observe(e.sentinelEl)},destroy(){t=!0,n.disconnect()}}}var QF=.02;function $F(e,t){return e<=Math.max(2,t*QF)}function eI(e,t){let n=`anchoring`,r=0,i=null,a=!1,o=null;function s(e){let t=n;n=JF(t,e),n!==t&&i?.()}function c(){a&&(a=!1,o!==null&&(clearTimeout(o),o=null),r=Math.max(0,r-1))}let l=ZF({scrollEl:e,sentinelEl:t,onIntersectionChange(e){e&&a&&c(),s({type:`intersection-change`,isIntersecting:e,isProgrammatic:r>0})}});return{getSnapshot:()=>n,subscribe(e){return i=e,()=>{i=null}},handleInitialScrollDone(e){s({type:`initial-scroll-done`,anchor:e}),l.reobserve()},handleScrollToBottom(){s({type:`scroll-to-bottom`})},handleChatChanged(){s({type:`chat-changed`})},scrollToBottom(t){r++,s({type:`scroll-to-bottom`}),e.scrollTo({top:e.scrollHeight,behavior:t}),t===`auto`?r=Math.max(0,r-1):(a=!0,o=setTimeout(()=>{c()},500))},beginProgrammaticScroll(){r++},endProgrammaticScroll(){r=Math.max(0,r-1)},destroy(){o!==null&&clearTimeout(o),l.destroy(),i=null}}}var tI=1800;function nI(e,t){e.scrollToIndex(t,{align:`start`}),requestAnimationFrame(()=>e.scrollToIndex(t,{align:`start`}))}function rI({messages:e,scrollRef:t,virtualizerRef:n,scrollToBottom:r,beginProgrammaticScroll:i,endProgrammaticScroll:a}){let o=(0,j.useMemo)(()=>VA(e),[e]),s=(0,j.useRef)(o);s.current=o;let[c,l]=(0,j.useState)(-1),u=(0,j.useRef)(c);u.current=c;let[d,f]=(0,j.useState)(!1),p=(0,j.useRef)(null),m=(0,j.useRef)(!1);function h(){if(m.current)return;let e=t.current,r=n.current;if(!e||!r)return;let i=new Map;for(let e of r.getVirtualItems())i.set(e.index,e.start);let a=UA(s.current,e.scrollTop,e=>i.has(e.renderIndex)?i.get(e.renderIndex):null);a!==-1&&a!==u.current&&l(a)}let g=(0,j.useCallback)(()=>{f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>f(!1),tI)},[]);(0,j.useEffect)(()=>{let e=null,n=!1,r=0;function i(){g(),!n&&(n=!0,r=requestAnimationFrame(()=>{n=!1,h()}))}function a(){let n=t.current;n!==e&&(e&&e.removeEventListener(`scroll`,i),e=n,n&&(n.addEventListener(`scroll`,i,{passive:!0}),h()))}a();let o=setInterval(a,250);return()=>{clearInterval(o),cancelAnimationFrame(r),e&&e.removeEventListener(`scroll`,i),p.current&&clearTimeout(p.current)}},[t,n,g]),(0,j.useEffect)(()=>{h()},[o]);function _(e){m.current=!0,i(),e(),requestAnimationFrame(()=>{setTimeout(()=>{a(),m.current=!1,h()},500)})}let v=(0,j.useCallback)(()=>{let e=n.current,t=s.current;if(!e||t.length===0)return;let i=u.current+1;if(i>=t.length){l(t.length-1),r();return}l(i),_(()=>nI(e,t[i].renderIndex))},[n,r,i,a]),y=(0,j.useCallback)(()=>{let e=t.current,r=n.current,i=s.current;if(!e||!r||i.length===0)return;let a=u.current-1;if(a<0){l(0),_(()=>e.scrollTo({top:0,behavior:`smooth`}));return}l(a),_(()=>nI(r,i[a].renderIndex))},[t,n,i,a]),b=c>=0&&c<o.length?o[c].label:o.length>0?o[0].label:``;return{currentIndex:c,totalCount:o.length,currentLabel:b,visible:d,goNext:v,goPrev:y}}function iI(e){return e===`online`?{text:`online`,className:`text-green-400`}:e===`degraded`?{text:`degraded`,className:`text-yellow-400`}:{text:`offline`,className:`text-muted-foreground`}}function aI({request:e,onClose:t,onPicked:n,socket:r}){let[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(null),u=Nm(r??null),d=u?.runners??[],f=u?.members??[];(0,j.useEffect)(()=>{a(null),l(null),s(!1)},[e]);let p=e?.candidates??[];async function m(){if(!(!e||!i)){s(!0),l(null);try{await e.retry(i),n?.(i),t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}}}let h=e?.reason===`sticky_offline`?`Your runner is offline`:`Choose a runner`,g=e?.reason===`sticky_offline`?`The runner this session was using is offline. Pick another to continue.`:`Multiple runners are available. Choose one for this session.`;return(0,Q.jsx)(rg,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(pg,{className:cg,children:[(0,Q.jsxs)(mg,{children:[(0,Q.jsx)(hg,{children:h}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:g})]}),(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:p.map(e=>{let{text:t,className:n}=iI(e.state),r=i===e.runnerId,o=e.capabilities?.providers.join(`, `)||`all providers`;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.runnerId),className:b(`w-full rounded-lg border px-4 py-3 text-left transition-colors`,`flex items-start gap-3`,r?`border-primary/60 bg-primary/5 ring-1 ring-primary/30`:`border-border bg-muted/30 hover:bg-muted/60`),children:[(0,Q.jsx)(fi,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:Pm(e.runnerId,d)}),Fm(e.runnerId,d,f)&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:Fm(e.runnerId,d,f).name}),e.isShared&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:`shared`}),(0,Q.jsx)(`span`,{className:b(`ml-auto shrink-0 text-xs`,n),children:t})]}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:o})]})]},e.runnerId)})}),c&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:c}),(0,Q.jsxs)(vg,{className:ug,children:[(0,Q.jsx)(bg,{onClick:t,disabled:o,children:`Cancel`}),(0,Q.jsx)(yg,{onClick:m,disabled:!i||o,children:o?`Connecting…`:`Use this runner`})]})]})})}var oI=(0,j.lazy)(()=>o(()=>import(`./LocalFilePreviewDialog-DQx2eiCc.js`).then(e=>({default:e.LocalFilePreviewDialog})),__vite__mapDeps([38,2,1,7,6,8,5]))),sI=120,cI=52,lI=1/3,uI=72,dI=56,fI={page:d({id:`chat.page`,c3ComponentId:`c3-110`,c3ComponentLabel:`chat`}),transcript:d({id:`transcript.message-list`,c3ComponentId:`c3-111`,c3ComponentLabel:`messages`}),composer:d({id:`chat.composer`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`}),navbar:d({id:`chat.navbar`,c3ComponentId:`c3-112`,c3ComponentLabel:`chat-input`})};v(fI);var pI=[`a`,`button`,`input`,`label`,`select`,`textarea`,`[contenteditable='true']`,`[data-no-sidebar-swipe]`,`[role='button']`,`[role='link']`,`[role='menuitem']`,`[role='option']`,`[role='switch']`,`[role='textbox']`].join(`,`);function mI(e){return e===`fork`||e===`merge`}function hI(e){if(!e||typeof e!=`object`)return null;let t=e.sidebarDialog;return mI(t)?t:null}function gI({hasMessages:e,sentinelRef:t}){return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:t,className:`h-px`,"aria-hidden":`true`}),(0,Q.jsx)(`div`,{style:{height:250},"aria-hidden":`true`})]}):(0,Q.jsx)(`div`,{ref:t,className:`h-px`,"aria-hidden":`true`})}function _I(e){if(!e)return null;try{let t=JSON.parse(e);if(!Array.isArray(t.skills))return null;let n=[],r=new Set;for(let e of t.skills){if(typeof e!=`string`)continue;let t=e.trim();!t||r.has(t)||(r.add(t),n.push(t))}return n.length>0?n:null}catch{return null}}function vI(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===`system_init`)return _I(n.message.debugRaw)??n.message.slashCommands}return[]}function yI(e){return e.pendingSessionBootstrap?.phase===`compacting`?e.pendingSessionBootstrap.kind===`fork`?`Preparing the opening brief from the current chat...`:`Preparing the combined opening brief...`:e.pendingSessionBootstrap?.phase===`starting`?e.pendingSessionBootstrap.kind===`fork`?`Starting the forked session...`:`Starting the merged session...`:``}function bI(e){return e.hasAvailableSkills&&e.skillsRibbonVisible?sI+cI:sI}function xI(e){if(!e.isTouchDevice||e.layoutViewportHeight===null||e.visualViewportHeight===null||e.visualViewportOffsetTop===null)return 0;let t=e.layoutViewportHeight-(e.visualViewportHeight+e.visualViewportOffsetTop);return t>0?Math.round(t):0}function SI(e){if(typeof e!=`object`||!e||!(`closest`in e))return!1;let t=e;return typeof t.closest==`function`&&t.closest(pI)!==null}function CI(e){if(!e.isMobileViewport||e.isSidebarOpen||SI(e.target)||e.startX>e.viewportWidth*lI)return!1;let t=e.currentX-e.startX,n=Math.abs(e.currentY-e.startY);return t<uI||n>dI?!1:t>n}function wI(e){if(!e.isMobileViewport||!e.isSidebarOpen||SI(e.target))return!1;let t=e.startX-e.currentX,n=Math.abs(e.currentY-e.startY);return t<uI||n>dI?!1:t>n}function TI(e){return e.messageCount>0?`transcript`:e.chatHasKnownMessages?`loading`:`empty`}function EI(e,t,n){return n&&e===0&&t>0}function DI(e){if(!e.commandError)return!1;if(e.connectionStatus===`connected`)return!0;let t=e.commandError.toLowerCase();return!(t.includes(`can't reach your local`)||t.includes(`will keep trying to reconnect`))}function OI(){return(0,Q.jsx)(v_,{className:`size-8 border-slate-300/60 bg-white/55 p-[3px] text-muted-foreground tinkaria-empty-state-flower dark:border-white/10 dark:bg-white/[0.02]`,imageClassName:`size-full`})}function kI(){let e=tt(),t=Ye(),n=Qe(),r=(0,j.useRef)(null),i=(0,j.useRef)(null),a=(0,j.useRef)(null),o=(0,j.useRef)(e.messages.length),s=e.runtime?.workspaceId??null,l=PF(e=>s?e.workspaces[s]:void 0)??FF,u=PF(e=>e.toggleVisibility),d=PF(e=>e.setSize),f=sS(e=>e.ribbonVisible),p=(0,j.useRef)(null),m=rI({messages:e.messages,scrollRef:e.scrollRef,virtualizerRef:p,scrollToBottom:e.scrollToBottom,beginProgrammaticScroll:e.beginProgrammaticScroll,endProgrammaticScroll:e.endProgrammaticScroll}),h=(0,j.useMemo)(()=>{let t=vI(e.messages);return t.length>0?t:e.chatSnapshot?.availableSkills??[]},[e.messages,e.chatSnapshot?.availableSkills]),g=bI({hasAvailableSkills:h.length>0,skillsRibbonVisible:f}),_=yx(e.handleSubmitFromComposer),v=yx(()=>{e.handleCancel()}),y=yx(()=>{e.clearQueuedText()}),x=yx(()=>e.restoreQueuedText()),C=!!(s&&l.isVisible),[w,T]=(0,j.useState)(!1),[E,D]=(0,j.useState)(!1),[O,k]=(0,j.useState)(0),[A,M]=(0,j.useState)(null),N=hI(t.state),P=e.pendingMergeProjectId??s,F=(0,j.useMemo)(()=>{if(!P)return[];let t=e.sidebarData.workspaceGroups.find(e=>e.groupKey===P);return t?t.chats.filter(t=>t.chatId!==e.activeChatId):[]},[P,e.sidebarData.workspaceGroups,e.activeChatId]),I=(0,j.useMemo)(()=>new Set(e.sidebarData.workspaceGroups.flatMap(e=>e.chats.map(e=>e.chatId))),[e.sidebarData.workspaceGroups]),L=TI({messageCount:e.messages.length,chatHasKnownMessages:e.chatHasKnownMessages}),R=Lx(e.activeChatId),z=(0,j.useMemo)(()=>{let t=()=>e.sidebarData.workspaceGroups.find(t=>t.chats.some(t=>t.chatId===e.activeChatId));return{onRetryChat:()=>{let n=t();n&&e.handleCreateChat(n.groupKey)},onNewChat:()=>{let n=t();n&&e.handleCreateChat(n.groupKey)},onResumeSession:null,onDismissError:()=>{e.clearCommandError()},onRetryBootstrap:null}},[e.sidebarData.workspaceGroups,e.activeChatId,e.handleCreateChat,e.clearCommandError]);(0,j.useEffect)(()=>{e.pendingMergeProjectId&&D(!0)},[e.pendingMergeProjectId]),(0,j.useEffect)(()=>{N&&(N===`fork`?T(!0):D(!0),n(t.pathname,{replace:!0,state:null}))},[N,n,t.pathname]);let B=!!s,{isAnimating:V,panelGroupRef:H,sidebarPanelRef:U,sidebarVisualRef:W}=GF({workspaceId:s,shouldRenderRightSidebarLayout:B,showRightSidebar:C,rightSidebarSize:l.size});KF({rootRef:r,fallbackRef:i,enabled:e.hasSelectedProject&&e.runtime?.status!==`waiting_for_user`&&!e.sidebarOpen,canCancel:e.canCancel});let G=e=>{if(e.pointerType!==`touch`){a.current=null;return}a.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,target:e.target}},K=t=>{let n=a.current;if(!n||n.pointerId!==t.pointerId)return;let r=window.matchMedia(`(max-width: 767px)`).matches;CI({startX:n.startX,startY:n.startY,currentX:t.clientX,currentY:t.clientY,viewportWidth:window.innerWidth,isMobileViewport:r,isSidebarOpen:e.sidebarOpen,target:n.target})&&(a.current=null,e.openSidebar())},q=e=>{a.current?.pointerId===e.pointerId&&(a.current=null)};(0,j.useEffect)(()=>{function t(t){if(!s)return;let n=t.metaKey||t.ctrlKey;if(n&&t.key===`b`){t.preventDefault(),u(s);return}n&&t.altKey&&t.key===`f`&&(t.preventDefault(),e.handleOpenExternal(`open_finder`))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[s,e,u]),(0,j.useEffect)(()=>{if(typeof window>`u`){k(0);return}let e=`ontouchstart`in window||navigator.maxTouchPoints>0,t=window.visualViewport;if(!e||!t){k(0);return}let n=()=>{k(xI({layoutViewportHeight:window.innerHeight,visualViewportHeight:t.height,visualViewportOffsetTop:t.offsetTop,isTouchDevice:e}))};return n(),t.addEventListener(`resize`,n),t.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),()=>{t.removeEventListener(`resize`,n),t.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n)}},[]),(0,j.useEffect)(()=>{let t=o.current;if(o.current=e.messages.length,!EI(t,e.messages.length,navigator.maxTouchPoints>0))return;let n=document.activeElement;n instanceof HTMLElement&&n.blur()},[e.messages.length]);let J=e.transcriptPaddingBottom+O,ee=g+O,Y=e=>Number.isFinite(e)?Math.min(50,Math.max(20,e)):l.size,te=(0,j.useMemo)(()=>kF(e.messages),[e.messages]),ne=(0,Q.jsxs)(TN,{ref:r,className:`bg-background h-full flex flex-col overflow-hidden border-0 rounded-none relative`,children:[(0,Q.jsxs)(kN,{className:`flex flex-1 min-h-0 flex-col p-0 overflow-hidden relative`,children:[(0,Q.jsx)(j.Suspense,{fallback:null,children:(0,Q.jsx)(oI,{preview:e.localFilePreview,workspacePath:e.navbarLocalPath,onClose:e.closeLocalFilePreview,onOpenLocalLink:t=>{e.handleOpenLocalLink(t)}})}),(0,Q.jsx)(oN,{sidebarCollapsed:e.sidebarCollapsed,onOpenSidebar:e.openSidebar,onCollapseSidebar:e.collapseSidebar,onExpandSidebar:e.expandSidebar,onForkSession:()=>T(!0),onMergeSession:()=>D(!0),localPath:e.navbarLocalPath,currentSessionRuntime:e.currentSessionRuntime,currentRepoStatus:e.currentRepoStatus,chatTitle:e.runtime?.title,chatStatus:e.runtime?.status,runtimeModel:e.runtime?.model,runtimeProvider:e.runtime?.provider,socket:e.socket,onOpenPtyChat:e=>n(`/chat/${e}`)}),(0,Q.jsx)(fN,{open:w,onOpenChange:T,sourceTitle:e.runtime?.title??null,defaultProvider:e.runtime?.provider??`claude`,defaultModel:e.availableProviders.find(t=>t.id===(e.runtime?.provider??`claude`))?.models[0]?.id??`opus`,availableProviders:e.availableProviders,onFork:e.handleForkSession}),(0,Q.jsx)(yN,{open:E,onOpenChange:t=>{D(t),t||e.clearMergeRequest()},defaultProvider:e.runtime?.provider??`claude`,defaultModel:e.availableProviders.find(t=>t.id===(e.runtime?.provider??`claude`))?.models[0]?.id??`opus`,availableProviders:e.availableProviders,availableChats:F,minSessions:e.pendingMergeProjectId?2:1,onMerge:e.handleMergeSession}),(0,Q.jsx)(aI,{request:e.needsPickRequest,onClose:e.clearNeedsPickRequest,onPicked:e=>M(e.slice(-8)),socket:e.socket}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,...c(fI.transcript),children:[(0,Q.jsxs)(xN,{ref:e.scrollRef,className:`h-full px-4`,children:[L===`transcript`?null:(0,Q.jsx)(`div`,{style:{height:J},"aria-hidden":`true`}),L===`transcript`?(0,Q.jsxs)(dA.Provider,{value:z,children:[(0,Q.jsxs)(`div`,{className:`animate-fade-in space-y-5 pt-4 max-w-[800px] mx-auto`,children:[(0,Q.jsx)(JA,{messages:e.messages,scrollRef:e.scrollRef,isLoading:e.isProcessing,localPath:e.runtime?.localPath,latestToolIds:e.latestToolIds,onOpenLocalLink:e.handleOpenLocalLink,onOpenExternalLink:e.handleOpenExternalLink,onAskUserQuestionSubmit:e.handleAskUserQuestion,onExitPlanModeConfirm:e.handleExitPlanMode,virtualizerRef:p}),e.isProcessing?(0,Q.jsx)(wN,{status:e.runtime?.status}):null,DI({commandError:e.commandError,connectionStatus:e.connectionStatus})?(()=>{let t=XA(e.commandError);return(0,Q.jsxs)(`div`,{className:`text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t.message}),t.hint?(0,Q.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t.hint}):null]}),(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,className:`shrink-0 -mt-1 -mr-2 text-destructive/70 hover:text-destructive`,onClick:e.clearCommandError,children:`Dismiss`})]})})():null]}),(0,Q.jsx)(gI,{hasMessages:!0,sentinelRef:e.sentinelRef})]}):null,L===`transcript`?null:(0,Q.jsx)(gI,{hasMessages:!1,sentinelRef:e.sentinelRef})]}),L===`loading`?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 px-4`,style:{bottom:J},children:(0,Q.jsx)(`div`,{className:`mx-auto flex h-full max-w-[800px] items-center justify-center`,children:(0,Q.jsx)(Gr,{className:`h-8 w-8 animate-spin text-muted-foreground/40`})})}):null,L===`empty`?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 px-4`,style:{bottom:J},children:(0,Q.jsx)(`div`,{className:`mx-auto flex h-full max-w-[800px] items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground gap-4 opacity-70`,children:e.pendingSessionBootstrap?.chatId===e.activeChatId?e.pendingSessionBootstrap.phase===`error`?(0,Q.jsxs)(`div`,{className:`pointer-events-auto flex flex-col items-center gap-3`,children:[(0,Q.jsx)(ur,{className:`h-8 w-8 text-destructive/60`}),(0,Q.jsxs)(`span`,{className:`text-sm font-medium text-destructive`,children:[e.pendingSessionBootstrap.kind===`fork`?`Fork`:`Merge`,` failed`]}),e.pendingSessionBootstrap.errorMessage?(0,Q.jsx)(`span`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:e.pendingSessionBootstrap.errorMessage}):null,(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>e.dismissBootstrapError(),children:`Dismiss`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gr,{className:`h-8 w-8 animate-spin text-muted-foreground/50`}),(0,Q.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-xl flex-col gap-3 rounded-[24px] border border-border/70 bg-background/92 p-4 text-left shadow-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground/80`,children:e.pendingSessionBootstrap.kind===`fork`?`Fork draft`:`Merge draft`}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground/70`,children:e.pendingSessionBootstrap.phase===`compacting`?`Preparing`:`Starting`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.pendingSessionBootstrap.previewTitle}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:e.pendingSessionBootstrap.previewIntent})]})]}),(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:yI(e)}),e.pendingSessionBootstrap.phase===`compacting`?(0,Q.jsx)(`div`,{className:`flex max-w-md flex-wrap items-center justify-center gap-2`,children:e.pendingSessionBootstrap.sourceLabels.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full border border-border bg-background/70 px-2.5 py-1 text-xs text-muted-foreground`,children:e},e))}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(OI,{}),(0,Q.jsx)(`div`,{className:`text-base font-normal text-muted-foreground text-center max-w-xs flex items-center tinkaria-empty-state-text`,"aria-label":R,children:(0,Q.jsx)(`span`,{className:`whitespace-pre`,children:R})})]})})})}):null]}),(0,Q.jsx)(`div`,{style:{bottom:ee},className:b(`absolute left-1/2 -translate-x-1/2 z-30 transition-all`,m.visible?`scale-100 duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]`:`scale-60 duration-300 ease-out pointer-events-none blur-sm opacity-0`),children:(0,Q.jsx)(qF,{nav:m,onScrollToBottom:e.scrollToBottom})})]}),(0,Q.jsx)(`div`,{style:{bottom:O},className:`absolute bottom-0 left-0 right-0 z-20 pointer-events-none`,...c(fI.composer),children:(0,Q.jsxs)(`div`,{className:`bg-gradient-to-t from-background via-background pointer-events-auto`,ref:e.inputRef,children:[(0,Q.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Q.jsxs)(`div`,{className:`max-w-[840px] mx-auto flex justify-end items-center gap-2`,children:[A?(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70 select-none`,title:`Pinned runner for this session`,children:[`runner: `,A]}):null,(0,Q.jsx)(TM,{parentChatId:e.activeChatId,hierarchy:e.orchestrationHierarchy,socket:e.socket,localPath:e.runtime?.localPath??void 0,knownChatIds:I,onOpenLocalLink:t=>{e.handleOpenLocalLink(t)},onOpenExternalLink:e.handleOpenExternalLink})]})}),(0,Q.jsx)(RS,{ref:i,onSubmit:_,onCancel:v,queuedText:e.queuedText,onClearQueuedText:y,onRestoreQueuedText:x,disabled:!e.hasSelectedProject||e.runtime?.status===`waiting_for_user`||e.pendingSessionBootstrap?.chatId===e.activeChatId,canCancel:e.canCancel,chatId:e.activeChatId,connectionStatus:e.connectionStatus,activeProvider:e.runtime?.provider??null,runtimeModel:e.runtime?.model,availableProviders:e.availableProviders,availableSkills:h},e.activeChatId??`new-chat`)]})})]});return(0,Q.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 relative`,onPointerDown:G,onPointerMove:K,onPointerUp:q,onPointerCancel:q,...c(fI.page),children:B&&s?(0,Q.jsxs)(wF,{groupRef:H,orientation:`horizontal`,className:`flex-1 min-h-0`,onLayoutChange:e=>{if(!C||V.current)return;let t=Y(e.rightSidebar);Math.abs(t-e.rightSidebar)<.1||H.current?.setLayout({workspace:100-t,rightSidebar:t})},onLayoutChanged:e=>{!C||V.current||d(s,Y(e.rightSidebar))},children:[(0,Q.jsx)(TF,{id:`workspace`,defaultSize:`${100-l.size}%`,minSize:`50%`,className:`min-h-0 min-w-0`,children:ne}),(0,Q.jsx)(EF,{withHandle:!0,orientation:`horizontal`,disabled:!C,className:b(!C&&`pointer-events-none opacity-0`)}),(0,Q.jsx)(TF,{id:`rightSidebar`,defaultSize:`${l.size}%`,maxSize:`50%`,className:`min-h-0 min-w-0`,elementRef:U,children:(0,Q.jsx)(`div`,{ref:W,className:`h-full min-h-0 overflow-hidden`,"data-right-sidebar-open":C?`true`:`false`,"data-right-sidebar-animated":`false`,"data-right-sidebar-visual":!0,children:(0,Q.jsx)(SN,{onClose:()=>u(s),touchedFiles:te,workspacePath:e.navbarLocalPath,onOpenFile:t=>{e.handleOpenLocalLink({path:t})}})})})]},`${s}-right-sidebar`):ne})}var AI=(0,j.lazy)(()=>o(()=>import(`./LocalProjectsSection-C4xlWkgS.js`).then(e=>({default:e.LocalProjectsSection})),__vite__mapDeps([39,3,1,4,5,6,7])));function jI(e,t){return e.data===t.data&&e.activeChatId===t.activeChatId&&e.connectionStatus===t.connectionStatus&&e.ready===t.ready&&e.open===t.open&&e.collapsed===t.collapsed&&e.showMobileOpenButton===t.showMobileOpenButton&&e.updateSnapshot===t.updateSnapshot}var MI=d({id:`chat.sidebar`,c3ComponentId:`c3-113`,c3ComponentLabel:`sidebar`});function NI(e,t){return e===`connected`&&t?`connected`:e===`disconnected`?`disconnected`:`connecting`}var PI={connected:`Connected`,connecting:`Connecting`,disconnected:`Disconnected`},FI={connected:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.16)]`,connecting:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.18)]`,disconnected:`bg-rose-500 shadow-[0_0_0_3px_rgba(244,63,94,0.16)]`};function II({data:e,activeChatId:t,connectionStatus:n,ready:r,open:i,collapsed:a,showMobileOpenButton:o,onOpen:s,onClose:l,onCollapse:u,onExpand:d,onCreateChat:f,onDeleteChat:p,onRenameChat:m,onRemoveProject:h,updateSnapshot:g,onInstallUpdate:_,onMergeSession:v,onCreateWorkspace:y,onRenameWorkspace:x,onTogglePinWorkspace:C,onReorderWorkspaces:w,onDeleteWorkspace:T}){let E=Ye(),D=Qe(),O=(0,j.useRef)(null),[k,A]=(0,j.useState)(new Set),[M,N]=(0,j.useState)(()=>Date.now()),P=(0,j.useRef)(null),F=(0,j.useCallback)(e=>{if(e.pointerType!==`touch`){P.current=null;return}P.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,target:e.target}},[]),I=(0,j.useCallback)(e=>{let t=P.current;if(!t||t.pointerId!==e.pointerId)return;let n=window.matchMedia(`(max-width: 767px)`).matches;wI({startX:t.startX,startY:t.startY,currentX:e.clientX,currentY:e.clientY,viewportWidth:window.innerWidth,isMobileViewport:n,isSidebarOpen:i,target:t.target})&&(P.current=null,l())},[i,l]),L=(0,j.useCallback)(e=>{P.current?.pointerId===e.pointerId&&(P.current=null)},[]),R=e.workspaceGroups,z=(0,j.useMemo)(()=>new Map(e.workspaceGroups.map(e=>[e.localPath,e.groupKey])),[e.workspaceGroups]),B=(0,j.useMemo)(()=>e.workspaceGroups.reduce((e,t)=>e+t.chats.length,0),[e.workspaceGroups]),V=(0,j.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),H=(0,j.useCallback)(e=>(0,Q.jsx)(Tx,{chat:e,activeChatId:t,nowMs:M,onSelectChat:e=>{D(`/chat/${e}`),l()},onForkChat:e=>{D(`/chat/${e}`,{state:{sidebarDialog:`fork`}}),l()},onMergeWithChat:e=>{D(`/chat/${e}`,{state:{sidebarDialog:`merge`}}),l()},onDeleteChat:()=>p(e),onRenameChat:m},e._id),[t,D,M,l,p,m]);(0,j.useEffect)(()=>{let e=window.setInterval(()=>{N(Date.now())},3e4);return()=>window.clearInterval(e)},[]),(0,j.useEffect)(()=>{!t||!O.current||requestAnimationFrame(()=>{let e=O.current,n=e?.querySelector(`[data-chat-id="${t}"]`);if(!n||!e)return;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.top<i.top+38){let t=r.top-i.top+e.scrollTop;e.scrollTo({top:t-38,behavior:`smooth`})}else if(r.bottom>i.bottom){let t=r.top+r.height/2-i.top+e.scrollTop,n=e.clientHeight/2;e.scrollTo({top:t-n,behavior:`smooth`})}})},[t,B]);let U=B>0,W=E.pathname===`/`,G=n===`connecting`||!r,K=NI(n,r),q=PI[K],J=g?.updateAvailable===!0,ee=g?g.latestVersion===`${g.currentVersion}-dev`:!1,Y=g?.status===`updating`||g?.status===`restart_pending`;return(0,Q.jsxs)(Q.Fragment,{children:[!i&&o&&(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`fixed top-3 left-3 z-50 md:hidden`,onClick:s,children:(0,Q.jsx)(Yr,{className:`h-5 w-5`})}),a&&W&&(0,Q.jsx)(`div`,{className:`hidden md:flex fixed left-0 top-0 h-full z-40 items-start pt-4 pl-5 border-l border-border/0`,children:(0,Q.jsx)(`div`,{className:`group/desktop-collapsed-shell flex items-center gap-1 rounded-full bg-background/80 pr-1 backdrop-blur-sm`,children:(0,Q.jsxs)(`div`,{className:`relative flex h-9 w-9 shrink-0 items-center justify-center`,children:[(0,Q.jsx)(v_,{className:`absolute inset-0 size-full`,imageClassName:`size-6`}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,onClick:d,title:`Expand sidebar`,className:`absolute inset-0 size-8 rounded-full opacity-0 pointer-events-none transition-all duration-200 ease-out scale-90 group-hover/desktop-collapsed-shell:pointer-events-auto group-hover/desktop-collapsed-shell:opacity-100 group-hover/desktop-collapsed-shell:scale-100`,children:(0,Q.jsx)(ni,{className:`h-4 w-4 text-slate-500/85 dark:text-slate-300/85`})})]})})}),(0,Q.jsxs)(`div`,{...c(MI),"data-sidebar":`open`,className:b(`fixed inset-0 z-50 bg-background dark:bg-card flex flex-col h-[100dvh] select-none`,`transition-transform duration-300 ease-out`,`md:relative md:inset-auto md:w-[275px] md:mr-0 md:h-[calc(100dvh-16px)] md:my-2 md:ml-2 md:border md:border-border md:rounded-2xl md:transition-none`,i?`translate-x-0`:`-translate-x-full md:translate-x-0`,!i&&`pointer-events-none md:pointer-events-auto`,a&&`md:hidden`),onPointerDown:F,onPointerMove:I,onPointerUp:L,onPointerCancel:L,children:[(0,Q.jsxs)(`div`,{className:`pl-2 pr-[7px] h-[64px] max-h-[64px] md:h-[55px] md:max-h-[55px] border-b flex items-center justify-between`,children:[(0,Q.jsxs)(S,{variant:`ghost`,className:`group/sidebar-shell flex min-w-0 items-center gap-2 px-2 rounded-lg text-left transition-colors hover:text-foreground`,onClick:()=>{D(`/`),l()},title:`Home`,"aria-label":`Go to homepage`,children:[(0,Q.jsx)(`div`,{className:`relative hidden md:flex h-9 w-9 shrink-0 items-center justify-center`,children:(0,Q.jsx)(v_,{className:`absolute inset-0 size-full`,imageClassName:`h-6 w-6`})}),(0,Q.jsx)(v_,{className:`h-6 w-6 sm:h-7 sm:w-7 md:hidden`,imageClassName:`h-5 w-5 sm:h-5.5 sm:w-5.5`}),(0,Q.jsx)(`span`,{className:`font-logo text-base uppercase sm:text-md text-slate-600 dark:text-slate-100`,children:d_})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ee?(0,Q.jsx)(`span`,{className:`mr-1 inline-flex items-center rounded-full border border-border bg-muted px-2 py-0.5 text-[11px] font-bold tracking-wider text-muted-foreground`,title:`Development build`,children:`DEV`}):J?(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,className:`rounded-full !h-auto mr-1 py-0.5 px-2 bg-logo/20 hover:bg-logo text-logo border-logo/20 hover:text-foreground hover:border-logo/20 text-[11px] font-bold tracking-wider`,onClick:_,disabled:Y,title:g?.latestVersion?`Update to ${g.latestVersion}`:`Update ${d_}`,children:[Y?(0,Q.jsx)(Gr,{className:`mr-1.5 h-3 w-3 animate-spin`}):null,`UPDATE`]}):null,(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:l,children:(0,Q.jsx)(Di,{className:`h-5 w-5`})})]})]}),(0,Q.jsx)(`div`,{ref:O,className:`flex-1 min-h-0 overflow-y-auto scrollbar-hide`,style:{WebkitOverflowScrolling:`touch`,touchAction:`pan-y`},children:(0,Q.jsxs)(`div`,{className:`p-[7px]`,children:[!U&&G?(0,Q.jsx)(`div`,{className:`space-y-5 px-1 pt-3`,children:[0,1,2].map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2 animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-4 w-28 rounded bg-muted`}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:[0,1,2].map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`h-3.5 w-3.5 rounded-full bg-muted`}),(0,Q.jsx)(`div`,{className:b(`h-3.5 rounded bg-muted`,e===0?`w-32`:e===1?`w-40`:`w-28`)})]},e))})]},e))}):null,!U&&!G&&e.workspaceGroups.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-slate-400 p-2 mt-6 text-center`,children:`No conversations yet`}):null,(0,Q.jsx)(Dx,{workspaces:e.independentWorkspaces,onSelect:e=>{D(`/workspace/${e}`),l()},onCreate:()=>y?.(),onRename:x,onTogglePin:C,onReorder:w,onDelete:T,activeWorkspaceId:E.pathname.startsWith(`/workspace/`)?E.pathname.split(`/`)[2]:null}),(0,Q.jsx)(j.Suspense,{fallback:null,children:(0,Q.jsx)(AI,{workspaceGroups:R,expandedGroups:k,onToggleExpandedGroup:V,renderChatRow:H,chatsPerProject:10,onNewLocalChat:e=>{let t=z.get(e);t&&f(t)},onRemoveProject:h,isConnected:n===`connected`,onMergeSession:v,onOpenProject:e=>{D(`/project/${e}`),l()}})})]})}),(0,Q.jsx)(`div`,{"data-sidebar-footer":`true`,className:`border-t border-border p-2`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`a`,{href:`/?tab=settings`,onClick:e=>{e.preventDefault(),D(`/?tab=settings`),l()},className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-muted-foreground hover:text-foreground hover:bg-accent/50`,children:[(0,Q.jsx)(pi,{className:`h-4 w-4`}),`Tinkaria`]}),(0,Q.jsx)(`span`,{"data-sidebar-connection-indicator":K,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/60`,"aria-label":`Connection status: ${q}`,title:`Connection status: ${q}`,children:(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:b(`size-1.5 rounded-full`,FI[K])})})]})})]}),(0,Q.jsx)(`div`,{className:b(`fixed inset-0 z-40 md:hidden transition-opacity duration-300`,i?`bg-black/40 opacity-100`:`opacity-0 pointer-events-none`),onClick:l})]})}var LI=(0,j.memo)(II,jI);function RI({open:e,onOpenChange:t,onConfirm:n}){let[r,i]=(0,j.useState)(``);function a(){let e=r.trim();e&&(n(e),i(``),t(!1))}function o(e){e||i(``),t(e)}return(0,Q.jsx)(rg,{open:e,onOpenChange:o,children:(0,Q.jsxs)(pg,{size:`sm`,className:cg,children:[(0,Q.jsxs)(_g,{children:[(0,Q.jsx)(hg,{children:`Create Workspace`}),(0,Q.jsx)(`div`,{className:`mt-4 space-y-3`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`workspace-name`,className:`text-sm font-medium text-foreground`,children:`Workspace name`}),(0,Q.jsx)(ml,{id:`workspace-name`,value:r,onChange:e=>i(e.target.value),placeholder:`My workspace`,className:`mt-1.5`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&a()}})]})})]}),(0,Q.jsxs)(vg,{className:ug,children:[(0,Q.jsx)(S,{variant:`outline`,onClick:()=>o(!1),children:`Cancel`}),(0,Q.jsx)(S,{onClick:a,disabled:!r.trim(),children:`Create`})]})]})})}function zI({narrow:e=!1,title:t,subtitle:n,icon:r=ti,uiId:i}){return(0,Q.jsxs)(`div`,{className:b(`w-full`,e?`max-w-2xl px-6 pt-16 mx-auto`:`px-6 pt-16 mb-10`),...i?c(i):{},children:[(0,Q.jsxs)(`div`,{className:b(`flex items-center gap-1 mb-2`,e&&`justify-center`),children:[(0,Q.jsx)(`div`,{className:`p-2 pl-0 rounded-lg`,children:(0,Q.jsx)(r,{className:`h-6 w-6 text-muted-foreground`})}),(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold text-foreground`,children:t})]}),n&&(0,Q.jsx)(`p`,{className:b(`text-muted-foreground`,e&&`mb-10 text-center`),children:n})]})}var BI=`lever-theme`,VI=(0,j.createContext)(void 0),HI=e=>e===`light`||e===`dark`||e===`system`,UI=()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,WI=e=>{if(typeof document>`u`)return;let t=e===`system`?UI():e;document.documentElement.classList.toggle(`dark`,t===`dark`)},GI=()=>{if(typeof window>`u`)return`system`;let e=window.localStorage.getItem(BI);return HI(e)?e:`system`};function KI({children:e}){let[t,n]=(0,j.useState)(GI);(0,j.useEffect)(()=>{WI(t),typeof window<`u`&&window.localStorage.setItem(BI,t)},[t]),(0,j.useEffect)(()=>{if(t!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>WI(`system`);return e.addEventListener?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n))},[t]);let r=(0,j.useMemo)(()=>({theme:t,resolvedTheme:t===`system`?UI():t,setTheme:n}),[t]);return(0,Q.jsx)(VI.Provider,{value:r,children:e})}function qI(){let e=(0,j.useContext)(VI);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function JI(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var YI=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;function XI(){let[e,t]=(0,j.useState)(YI?Notification.permission:`denied`),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(null),c=(0,j.useRef)(!1);return YI&&!c.current&&(c.current=!0,navigator.serviceWorker.ready.then(e=>e.pushManager.getSubscription()).then(e=>{e&&r(!0)}).catch(()=>{})),{supported:YI,permission:e,subscribed:n,subscribe:(0,j.useCallback)(async()=>{if(YI){a(!0),s(null);try{let e=await Notification.requestPermission();if(t(e),e!==`granted`)return;let n=await navigator.serviceWorker.ready;if(await n.pushManager.getSubscription()){r(!0);return}let i=await fetch(`/api/push/vapid-key`);if(!i.ok){s(`Push notifications not available on this server`);return}let{publicKey:a}=await i.json(),o=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:JI(a)});await fetch(`/api/push/subscribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)}),r(!0)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}},[]),unsubscribe:(0,j.useCallback)(async()=>{if(YI){a(!0),s(null);try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!e){r(!1);return}await e.unsubscribe(),await fetch(`/api/push/subscribe`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({endpoint:e.endpoint})}),r(!1)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}},[]),loading:i,error:o}}function ZI(){let{supported:e,subscribed:t,subscribe:n,unsubscribe:r,loading:i}=XI();return e?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-muted-foreground/60`,children:`Notifications`}),(0,Q.jsx)(`button`,{className:b(`rounded-md px-2 py-0.5 capitalize transition-colors`,t?`bg-muted text-foreground`:`hover:bg-muted/50 hover:text-foreground`),onClick:t?r:n,disabled:i,children:t?`on`:`off`})]}):null}var QI=d({id:`home.preferences`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),$I=[`light`,`dark`,`system`],eL=[`last_used`,`claude`,`codex`,`claude-pty`],tL={last_used:`Last used`,claude:`Claude`,codex:`Codex`,"claude-pty":`Claude (PTY)`};function nL({label:e,options:t,value:n,onChange:r,formatLabel:i}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-muted-foreground/60`,children:e}),t.map(e=>(0,Q.jsx)(`button`,{onClick:()=>r(e),className:b(`rounded-md px-2 py-0.5 capitalize transition-colors`,n===e?`bg-muted text-foreground`:`hover:bg-muted/50 hover:text-foreground`),children:i?i(e):e},e))]})}function rL(){let{theme:e,setTheme:t}=qI(),n=oS(e=>e.defaultProvider),r=oS(e=>e.setDefaultProvider);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs text-muted-foreground`,...c(QI),children:[(0,Q.jsx)(nL,{label:`Theme`,options:$I,value:e,onChange:t}),(0,Q.jsx)(nL,{label:`Default provider`,options:eL,value:n,onChange:r,formatLabel:e=>tL[e]}),(0,Q.jsx)(ZI,{})]})}function iL(e){return e.toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function aL({open:e,onOpenChange:t,onConfirm:n,rootUiId:r}){let[i,a]=(0,j.useState)(0);function o(n){n&&!e&&a(e=>e+1),t(n)}return(0,Q.jsx)(rg,{open:e,onOpenChange:o,children:(0,Q.jsx)(pg,{size:`sm`,className:cg,...r?c(r):{},children:e?(0,Q.jsx)(oL,{onClose:()=>o(!1),onConfirm:n},i):null})})}function oL({onClose:e,onConfirm:t}){let[n,r]=(0,j.useState)(`new`),[i,a]=(0,j.useState)(``),[o,s]=(0,j.useState)(``),c=iL(i),l=c?`${h_}/${c}`:``,u=o.trim(),d=n===`new`?c.length>0:u.length>0;function f(){d&&(t(n===`new`?{mode:`new`,localPath:l,title:i.trim()}:{mode:`existing`,localPath:u,title:u.split(`/`).pop()||u}),e())}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(_g,{className:`space-y-4`,children:[(0,Q.jsx)(hg,{children:`Add Project`}),(0,Q.jsx)(ol,{value:n,onValueChange:r,options:[{value:`new`,label:`New Folder`},{value:`existing`,label:`Existing Path`}],className:`w-full mb-2`,optionClassName:`flex-1 justify-center`}),n===`new`?(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(ml,{autoFocus:!0,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&e()},placeholder:`Project name`}),l?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono`,children:l}):null]}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(ml,{autoFocus:!0,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&e()},placeholder:`~/Projects/my-app`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The folder will be created if it doesn't exist.`})]})]}),(0,Q.jsxs)(vg,{className:ug,children:[(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:e,children:`Cancel`}),(0,Q.jsx)(S,{variant:`secondary`,size:`sm`,onClick:f,disabled:!d,children:`Create`})]})]})}var sL=`DropdownMenu`,[cL,lL]=Pi(sL,[Jv]),uL=Jv(),[dL,fL]=cL(sL),pL=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=uL(t),l=j.useRef(null),[u,d]=rc({prop:i,defaultProp:a??!1,onChange:o,caller:sL});return(0,Q.jsx)(dL,{scope:t,triggerId:ua(),triggerRef:l,contentId:ua(),open:u,onOpenChange:d,onOpenToggle:j.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,Q.jsx)(rb,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};pL.displayName=sL;var mL=`DropdownMenuTrigger`,hL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=fL(mL,n),o=uL(n);return(0,Q.jsx)(ib,{asChild:!0,...o,children:(0,Q.jsx)(Wi.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:ji(t,a.triggerRef),onPointerDown:Z(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Z(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});hL.displayName=mL;var gL=`DropdownMenuPortal`,_L=e=>{let{__scopeDropdownMenu:t,...n}=e,r=uL(t);return(0,Q.jsx)(ab,{...r,...n})};_L.displayName=gL;var vL=`DropdownMenuContent`,yL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=fL(vL,n),a=uL(n),o=j.useRef(!1);return(0,Q.jsx)(ob,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Z(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Z(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});yL.displayName=vL;var bL=`DropdownMenuGroup`,xL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(sb,{...i,...r,ref:t})});xL.displayName=bL;var SL=`DropdownMenuLabel`,CL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(cb,{...i,...r,ref:t})});CL.displayName=SL;var wL=`DropdownMenuItem`,TL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(lb,{...i,...r,ref:t})});TL.displayName=wL;var EL=`DropdownMenuCheckboxItem`,DL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(ub,{...i,...r,ref:t})});DL.displayName=EL;var OL=`DropdownMenuRadioGroup`,kL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(db,{...i,...r,ref:t})});kL.displayName=OL;var AL=`DropdownMenuRadioItem`,jL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(fb,{...i,...r,ref:t})});jL.displayName=AL;var ML=`DropdownMenuItemIndicator`,NL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(pb,{...i,...r,ref:t})});NL.displayName=ML;var PL=`DropdownMenuSeparator`,FL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(mb,{...i,...r,ref:t})});FL.displayName=PL;var IL=`DropdownMenuArrow`,LL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(hb,{...i,...r,ref:t})});LL.displayName=IL;var RL=`DropdownMenuSubTrigger`,zL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(_b,{...i,...r,ref:t})});zL.displayName=RL;var BL=`DropdownMenuSubContent`,VL=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=uL(n);return(0,Q.jsx)(vb,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});VL.displayName=BL;var HL=pL,UL=hL,WL=_L,GL=yL,KL=TL,qL=HL,JL=UL;function YL(e){return e?c(e):{}}var XL=j.forwardRef(({className:e,sideOffset:t=4,uiId:n,...r},i)=>(0,Q.jsx)(WL,{children:(0,Q.jsx)(GL,{ref:i,sideOffset:t,...YL(n),className:b(`z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r})}));XL.displayName=GL.displayName;var ZL=j.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(KL,{ref:n,className:b(`relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...t}));ZL.displayName=KL.displayName;var QL={page:d({id:`home.page`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),header:d({id:`home.header`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),tabs:d({id:`home.tabs`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),status:d({id:`home.status`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),setup:d({id:`home.setup`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),workspaceGrid:d({id:`home.workspace-grid`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),addProjectAction:d({id:`home.add-project.action`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),projectOverview:d({id:`home.project-overview`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),projectCard:d({id:`home.project-card`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),projectPrimaryAction:d({id:`home.project-primary.action`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),projectSecondaryAction:d({id:`home.project-secondary.action`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),newProjectDialog:d({id:`home.add-project.dialog`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),settingsPanel:d({id:`home.settings.panel`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),preferences:d({id:`home.preferences`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`})};v(QL);var $L=[{value:`projects`,label:`Projects`,icon:jr},{value:`workspaces`,label:`Workspaces`,icon:_r},{value:`settings`,label:`Settings`,icon:pi}],eR=new Set([`starting`,`running`,`waiting_for_user`,`awaiting_agents`]),tR={idle:`Idle`,starting:`Starting`,running:`Running`,waiting_for_user:`Waiting`,awaiting_agents:`Awaiting agents`,failed:`Failed`};function nR(e){return e.title||C_(e.localPath)}function rR(){return`Open Project`}function iR(){return`Start First Task`}function aR(e){let t=nR(e);return e.source===`saved`?`${t} — pinned workspace.`:`${t} — discovered from recent activity.`}function oR(e){return[...e?.workspaces??[]].sort((e,t)=>{let n=e.lastOpenedAt??0,r=t.lastOpenedAt??0;return n===r?e.title.localeCompare(t.title):r-n})}function sR(e){let t=e.lastMessageAt??e._creationTime;return(eR.has(e.status)?1e9:0)+t}function cR(e){return[...e?.chats??[]].filter(e=>eR.has(e.status)).sort((e,t)=>sR(t)-sR(e)).slice(0,2)}function lR(e){return Math.max(0,...e.chats.map(e=>e.lastMessageAt??e._creationTime))}function uR({href:e,disabled:t,onNavigate:n,onFallbackOpen:r,children:i,className:a}){return e?(0,Q.jsx)(`a`,{href:e,"aria-disabled":t,className:b(`touch-manipulation inline-flex h-9 flex-1 cursor-pointer items-center justify-center whitespace-nowrap rounded-full bg-primary px-3 text-sm font-medium text-primary-foreground ring-offset-background transition-all hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,t&&`pointer-events-none bg-primary/50 text-primary-foreground/90`,a),onClick:e=>{if(e.stopPropagation(),t){e.preventDefault();return}n&&(e.preventDefault(),n())},...c(QL.projectPrimaryAction),children:i}):(0,Q.jsx)(S,{size:`sm`,className:b(`flex-1`,a),disabled:t,onClick:e=>{e.stopPropagation(),r?.()},...c(QL.projectPrimaryAction),children:i})}function dR({sessions:e}){return e.length===0?null:(0,Q.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase text-muted-foreground/70`,children:[(0,Q.jsx)(Qr,{className:`h-3 w-3`}),`Running sessions`]}),e.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 rounded-md border border-border/70 bg-background/50 px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-foreground/85`,children:e.title}),(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:tR[e.status]??e.status})]},e.chatId))]})}function fR({text:e}){let[t,n]=(0,j.useState)(!1);async function r(){await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}return(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-foreground`,onClick:()=>void r(),children:t?(0,Q.jsx)(ar,{className:`h-4 w-4 text-green-400`}):(0,Q.jsx)(br,{className:`h-4 w-4`})})}function pR({children:e}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm`,children:[(0,Q.jsx)(`pre`,{className:`overflow-x-auto`,children:(0,Q.jsx)(`code`,{children:e})}),(0,Q.jsx)(fR,{text:e})]})}function mR({children:e}){return(0,Q.jsx)(`div`,{className:`bg-card border border-border rounded-2xl p-4`,children:e})}function hR({children:e}){return(0,Q.jsx)(`h2`,{className:`text-[13px] font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:e})}function gR({icon:e,title:t,description:n,action:r}){return(0,Q.jsx)(mR,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-xl border border-border bg-background p-2`,children:(0,Q.jsx)(e,{className:`h-4 w-4 text-muted-foreground`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-foreground`,children:t}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:n})]})]}),r]})})}function _R({isConnecting:e,commandError:t}){return(0,Q.jsx)(mR,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:b(`rounded-xl border p-2`,e?`border-border bg-background`:`border-amber-500/20 bg-amber-500/5 text-amber-700 dark:text-amber-300`),children:(0,Q.jsx)(Gr,{className:b(`h-4 w-4`,e&&`animate-spin text-muted-foreground`)})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-foreground`,children:e?`Connecting to your local ${d_} server`:`Local ${d_} server not reachable`}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e?`Loading workspaces from this machine.`:`This browser tab can't reach the local ${d_} server yet. Start it on this machine and the page will reconnect automatically.`})]})]}),t?(0,Q.jsx)(`div`,{className:`rounded-xl border border-amber-500/20 bg-amber-500/5 px-3 py-2 text-sm text-amber-800 dark:text-amber-200`,children:t}):null]})})}function vR({workspace:e,onClick:t,index:n,onRename:r,onTogglePin:i,onMoveUp:a,onMoveDown:o,onDelete:s}){let[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(e.name),f=!!(r||i||a||o||s);function p(){let t=u.trim();t&&t!==e.name&&r?.(e.id,t),l(!1)}return(0,Q.jsx)(`div`,{role:`button`,tabIndex:0,style:{animationDelay:`${n*40}ms`},className:`animate-homepage-enter rounded-xl p-4 text-left transition-colors duration-200 bg-card ring-1 ring-border hover:ring-[color:var(--color-logo)]/15 group cursor-pointer`,onClick:()=>{c||t()},onKeyDown:e=>{!c&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c?(0,Q.jsx)(`input`,{autoFocus:!0,value:u,onClick:e=>e.stopPropagation(),onChange:e=>d(e.target.value),onBlur:p,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),l(!1))},className:`w-full bg-transparent font-medium text-foreground outline-none border-b border-border`}):(0,Q.jsxs)(`div`,{className:`font-medium text-foreground truncate flex items-center gap-1.5`,children:[e.pinned?(0,Q.jsx)(oi,{className:`size-3.5 shrink-0 text-muted-foreground`}):null,(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,Q.jsxs)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[`Created `,w_(e.createdAt)]})]}),f?(0,Q.jsxs)(qL,{children:[(0,Q.jsx)(JL,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,"aria-label":`Workspace actions`,className:`h-7 w-7 shrink-0 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Sr,{className:`h-4 w-4`})})}),(0,Q.jsxs)(XL,{align:`end`,onClick:e=>e.stopPropagation(),children:[r?(0,Q.jsxs)(ZL,{onSelect:t=>{t.preventDefault(),d(e.name),l(!0)},children:[(0,Q.jsx)(ii,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Rename`})]}):null,i?(0,Q.jsxs)(ZL,{onSelect:()=>i(e.id,!e.pinned),children:[e.pinned?(0,Q.jsx)(ai,{className:`h-4 w-4`}):(0,Q.jsx)(oi,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:e.pinned?`Unpin`:`Pin`})]}):null,a?(0,Q.jsxs)(ZL,{onSelect:()=>a(),children:[(0,Q.jsx)(Zn,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Move up`})]}):null,o?(0,Q.jsxs)(ZL,{onSelect:()=>o(),children:[(0,Q.jsx)(qn,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Move down`})]}):null,s?(0,Q.jsxs)(ZL,{onSelect:()=>s(e.id),className:`text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20`,children:[(0,Q.jsx)(Si,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Delete`})]}):null]})]}):(0,Q.jsx)(Yn,{className:`h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0 mt-0.5`})]})})}function yR({projectTitle:e,localPath:t,chatCount:n,projectHref:r,previewSessions:i,loading:a,selected:o,onSelect:s,onOpenProjectPage:l,onStartTask:u,index:d}){let f=iR();return(0,Q.jsxs)(`div`,{...c(QL.projectCard),style:{animationDelay:`${d*40}ms`},className:b(`group animate-homepage-enter rounded-xl p-4 text-left transition-colors duration-200 cursor-pointer`,o?`bg-card ring-1 ring-[color:var(--color-logo)]/20`:`bg-card ring-1 ring-border hover:ring-[color:var(--color-logo)]/15`,a&&`opacity-50 cursor-not-allowed`),onClick:()=>{a||s()},children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-foreground truncate`,children:e}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:t})]}),a?(0,Q.jsx)(Gr,{className:`h-4 w-4 text-muted-foreground animate-spin flex-shrink-0`}):null]}),(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:`${n} ${n===1?`chat`:`chats`}`}),(0,Q.jsx)(dR,{sessions:i}),(0,Q.jsxs)(`div`,{className:b(`mt-3 flex gap-2 transition-opacity duration-150`,o?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[(0,Q.jsxs)(uR,{href:r,disabled:a,onNavigate:l,onFallbackOpen:u,children:[(0,Q.jsx)(Yn,{className:`mr-1.5 h-3.5 w-3.5`}),rR()]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,disabled:a,onClick:e=>{e.stopPropagation(),u()},...c(QL.projectSecondaryAction),children:[(0,Q.jsx)(si,{className:`mr-1 h-3.5 w-3.5`}),f]})]})]})}function bR({project:e,projectHref:t,previewSessions:n,loading:r,onOpenProjectPage:i,onStartTask:a}){let o=nR(e),s=iR(),l=aR(e);return(0,Q.jsx)(`div`,{className:`animate-homepage-enter overflow-hidden rounded-2xl bg-card ring-1 ring-logo/12`,...c(QL.projectOverview),children:(0,Q.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold leading-tight text-foreground`,children:o}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:(0,Q.jsxs)(`span`,{className:`rounded-full bg-muted px-2.5 py-1`,children:[e.chatCount,` `,e.chatCount===1?`chat`:`chats`]})}),(0,Q.jsx)(dR,{sessions:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:[(0,Q.jsxs)(uR,{href:t,disabled:r,onNavigate:i,onFallbackOpen:a,className:`min-w-[10rem]`,children:[(0,Q.jsx)(Yn,{className:`mr-1.5 h-4 w-4`}),rR()]}),(0,Q.jsxs)(S,{variant:`outline`,className:`flex-1 min-w-[10rem]`,disabled:r,onClick:()=>{a()},...c(QL.projectSecondaryAction),children:[(0,Q.jsx)(Qn,{className:`mr-1.5 h-4 w-4`}),s]})]})]})})}function xR({connectionStatus:e,ready:t,snapshot:n,startingLocalPath:r,commandError:i,onOpenProject:a,onCreateProject:o,independentWorkspaces:s,onCreateWorkspace:l,onOpenWorkspace:u,onRenameWorkspace:d,onTogglePinWorkspace:f,onReorderWorkspaces:p,onDeleteWorkspace:m,projectGroups:h,onOpenProjectPage:g,activeTab:_,onActiveTabChange:v,settingsPanel:y}){let[b,x]=(0,j.useState)(!1),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(!1),[D,O]=(0,j.useState)(`projects`),k=(0,j.useMemo)(()=>new Map((h??[]).map(e=>[e.localPath,e])),[h]),A=(0,j.useMemo)(()=>{let e=new Map(oR(n).map(e=>[e.localPath,e]));for(let t of h??[])e.has(t.localPath)||e.set(t.localPath,{localPath:t.localPath,title:C_(t.localPath),source:`saved`,chatCount:t.chats.length,lastOpenedAt:lR(t)});return[...e.values()].sort((e,t)=>{let n=k.has(e.localPath)?1:0,r=k.has(t.localPath)?1:0;if(n!==r)return r-n;let i=e.lastOpenedAt??0,a=t.lastOpenedAt??0;return i===a?e.title.localeCompare(t.title):a-i})},[k,h,n]),M=A.find(e=>e.localPath===C)??A[0]??null,N=e===`connecting`||e===`connected`&&!t,P=e===`connected`&&t,F=_??D;function I(e){v?v(e):O(e)}return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-background overflow-y-auto`,...c(QL.page),children:[P?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`px-4 pt-3 pb-2 md:pt-4 md:pb-3`,...c(QL.header),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(jr,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold text-foreground md:text-lg`,children:n?.machine.displayName??`Local Projects`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage projects, workspaces, sessions, and Tinkaria settings.`})]}),(0,Q.jsx)(`div`,{className:`px-4 mb-3`,...c(QL.tabs),children:(0,Q.jsx)(ol,{value:F,onValueChange:I,options:$L,size:`sm`,className:`w-full md:w-auto`,optionClassName:`flex-1 md:flex-initial justify-center`,alwaysShowLabels:!0})}),(0,Q.jsxs)(`div`,{className:`w-full px-4 pb-10`,children:[F===`workspaces`&&((s?.length??0)>0||l)?(0,Q.jsxs)(`div`,{className:`mb-6`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-4`,children:[(0,Q.jsx)(hR,{children:`Workspaces`}),l?(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,onClick:l,children:[(0,Q.jsx)(si,{className:`h-4 w-4 mr-1.5`}),`New Workspace`]}):null]}),s&&s.length>0?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:s.map((e,t)=>{let n=e=>{let n=s.map(e=>e.id);[n[t],n[e]]=[n[e],n[t]],p?.(n)};return(0,Q.jsx)(vR,{workspace:e,index:t,onClick:()=>u?.(e.id),onRename:d,onTogglePin:f,onMoveUp:t>0&&p?()=>n(t-1):void 0,onMoveDown:t<s.length-1&&p?()=>n(t+1):void 0,onDelete:m},e.id)})}):(0,Q.jsx)(mR,{children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No workspaces yet. Create one to organize agents, repos, and workflows.`})})]}):null,F===`settings`?(0,Q.jsxs)(`div`,{className:`space-y-4`,...c(QL.settingsPanel),children:[(0,Q.jsx)(`div`,{className:`flex items-baseline justify-between gap-4`,children:(0,Q.jsx)(hR,{children:`Home settings`})}),(0,Q.jsx)(mR,{children:(0,Q.jsx)(rL,{})}),y??null]}):null,F===`projects`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-4`,children:[(0,Q.jsx)(hR,{children:`Projects`}),(0,Q.jsxs)(S,{variant:`default`,size:`sm`,onClick:()=>x(!0),...c(QL.addProjectAction),children:[(0,Q.jsx)(si,{className:`h-4 w-4 mr-1.5`}),`Add Project`]})]}),A.length>0?(0,Q.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1.35fr)_minmax(20rem,0.9fr)] lg:items-start`,children:[(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 xl:grid-cols-2`,...c(QL.workspaceGrid),children:(T?A:A.slice(0,6)).map((e,t)=>{let n=nR(e),i=k.get(e.localPath)??null;return(0,Q.jsx)(yR,{index:t,projectTitle:n,localPath:e.localPath,chatCount:e.chatCount,projectHref:i?`/project/${i.groupKey}`:null,previewSessions:cR(i),loading:r===e.localPath,selected:M?.localPath===e.localPath,onSelect:()=>{w(e.localPath)},onOpenProjectPage:i?()=>g?.(i.groupKey):void 0,onStartTask:()=>{a(e.localPath)}},e.localPath)})}),A.length>6?(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,className:`mt-2 justify-start text-xs text-muted-foreground hover:text-foreground lg:col-span-2`,onClick:()=>E(!T),children:T?`Show less`:`Show all ${A.length} projects`}):null,M?(()=>{let e=k.get(M.localPath)??null;return(0,Q.jsx)(bR,{project:M,projectHref:e?`/project/${e.groupKey}`:null,previewSessions:cR(e),loading:r===M.localPath,onOpenProjectPage:e?()=>g?.(e.groupKey):void 0,onStartTask:()=>{a(M.localPath)}})})():null]}):(0,Q.jsx)(mR,{children:(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No local projects yet. Add a workspace here or start `,d_,` inside a project directory to seed one automatically.`]})}),i?(0,Q.jsx)(`div`,{className:`text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4`,children:i}):null]}):null]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(zI,{narrow:!0,icon:_r,uiId:QL.header,title:N?`Connecting ${d_}`:`Connect ${d_}`,subtitle:N?`${d_} is starting up and loading your local projects.`:`Run ${d_} on this machine to unlock local files, saved projects, and chat history.`}),(0,Q.jsxs)(`div`,{className:`max-w-2xl w-full mx-auto pb-12 px-6`,children:[(0,Q.jsx)(hR,{children:`Status`}),(0,Q.jsx)(`div`,{className:`mb-8`,...c(QL.status),children:(0,Q.jsx)(_R,{isConnecting:N,commandError:i})}),N?null:(0,Q.jsxs)(`div`,{className:`mb-10`,...c(QL.setup),children:[(0,Q.jsx)(hR,{children:`Get Connected`}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(gR,{icon:hi,title:`Start ${d_} locally`,description:`Open a terminal on this machine and run the local server. This page reconnects automatically as soon as it comes online.`,action:(0,Q.jsx)(pR,{children:g_()})}),(0,Q.jsx)(gR,{icon:jr,title:`Already running?`,description:`If you expected this page to be connected already, double-check that the server is running on this same machine and keep this tab open for a few seconds.`,action:(0,Q.jsxs)(`div`,{className:`space-y-3 text-sm text-muted-foreground`,children:[(0,Q.jsxs)(`ul`,{className:`list-disc pl-5 space-y-1`,children:[(0,Q.jsx)(`li`,{children:`Wait a moment after startup: project and session snapshots arrive after the socket connects.`}),(0,Q.jsx)(`li`,{children:`Run the command in a terminal on this machine, not on a different host.`}),(0,Q.jsx)(`li`,{children:`If you want to start in the current directory or skip opening a browser tab, use the variants below.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-foreground`,children:`Start in the current directory`}),(0,Q.jsx)(pR,{children:g_(``).trim()})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-foreground`,children:`Start without opening the browser`}),(0,Q.jsx)(pR,{children:g_(`--no-open`)})]})]})})]})]})]})]}),(0,Q.jsx)(aL,{open:b,onOpenChange:x,rootUiId:QL.newProjectDialog,onConfirm:e=>{o(e)}}),(0,Q.jsx)(`div`,{className:`py-4 text-center`,children:(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/50`,children:[`v`,p_.split(`/`)[1]]})})]})}function SR(e){return e===`workspaces`||e===`settings`?e:`projects`}function CR(){let e=tt(),t=Qe(),[n,r]=Mn(),[i,a]=(0,j.useState)(!1),o=SR(n.get(`tab`)),s=Mh(n.get(`settingsTab`)??n.get(`tab`));function c(e){r(e===`projects`?{}:{tab:e})}return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 relative`,children:[(0,Q.jsx)(xR,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject,independentWorkspaces:e.sidebarData.independentWorkspaces,onCreateWorkspace:()=>a(!0),onOpenWorkspace:e=>t(`/workspace/${e}`),onRenameWorkspace:(t,n)=>void e.handleRenameWorkspace(t,n),onTogglePinWorkspace:(t,n)=>void e.handleTogglePinWorkspace(t,n),onReorderWorkspaces:t=>void e.handleReorderWorkspaces(t),onDeleteWorkspace:t=>void e.handleDeleteWorkspace(t),projectGroups:e.sidebarData.workspaceGroups,onOpenProjectPage:e=>t(`/project/${e}`),activeTab:o,onActiveTabChange:c,settingsPanel:(0,Q.jsx)(Nh,{state:e,initialTab:s})}),(0,Q.jsx)(RI,{open:i,onOpenChange:a,onConfirm:t=>{e.handleCreateWorkspace(t)}})]})}function wR(e,t){let[n,r]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(r(null),t)return e.subscribe({type:`agent-config`,workspaceId:t},e=>r(e))},[e,t]),n}function TR(e,t){let[n,r]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(r(null),t)return e.subscribe({type:`repos`,workspaceId:t},e=>r(e))},[e,t]),n}function ER(e,t){let[n,r]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(r(null),t)return e.subscribe({type:`workflow-runs`,workspaceId:t},e=>r(e))},[e,t]),n}function DR(e,t){let[n,r]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(r(null),t)return e.subscribe({type:`sandbox-status`,workspaceId:t},e=>r(e))},[e,t]),n}function OR(e){let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function kR({title:e,count:t,countLabel:n,onAdd:r,addLabel:i,children:a}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold text-foreground`,children:[e,t!==void 0&&t>0&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:[`(`,n||t,`)`]})]}),(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:r,"aria-label":i,children:(0,Q.jsx)(si,{className:`h-4 w-4`})})]}),a]})}function AR({show:e,children:t}){return e?(0,Q.jsx)(`div`,{className:`px-3 py-2 border-b border-border space-y-2`,children:t}):null}function jR({children:e}){return(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:e})}function MR({message:e,description:t,actionLabel:n,onAction:r}){return(0,Q.jsxs)(`div`,{className:`px-3 py-6 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),t&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:t}),n&&r&&(0,Q.jsx)(S,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:r,children:n})]})}function NR({children:e,className:t}){return(0,Q.jsx)(`div`,{className:b(`px-3 py-2 border-b border-border/50 hover:bg-muted/30 transition-colors`,t),children:e})}function PR({children:e}){return(0,Q.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-muted-foreground border-b border-border`,children:e})}function FR({label:e,count:t,children:n}){let[r,i]=(0,j.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(PR,{children:(0,Q.jsxs)(`button`,{type:`button`,className:`w-full text-left flex items-center gap-1`,onClick:()=>i(!r),children:[(0,Q.jsx)(cr,{className:b(`h-3 w-3 transition-transform`,r&&`rotate-90`)}),e,` (`,t,`)`]})}),r&&n]})}function IR(){return`agent-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var LR={id:``,name:``,description:``,provider:`claude`,model:``,systemPrompt:``,tools:[],temperature:.7};function RR({initial:e,onSubmit:t,onCancel:n,isEdit:r}){let[i,a]=(0,j.useState)(e),[o,s]=(0,j.useState)((e.tools??[]).join(`, `));function c(){if(!i.name.trim()||!i.provider.trim()||!i.model.trim())return;let e=o.split(`,`).map(e=>e.trim()).filter(Boolean);t({...i,id:r?i.id:IR(),tools:e.length>0?e:void 0,temperature:i.temperature??void 0,systemPrompt:i.systemPrompt?.trim()||void 0})}return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[r&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono`,children:i.id}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Name *`,value:i.name,onChange:e=>a({...i,name:e.target.value}),autoFocus:!0}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Description`,value:i.description,onChange:e=>a({...i,description:e.target.value})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsx)(ml,{size:`sm`,placeholder:`Provider *`,value:i.provider,onChange:e=>a({...i,provider:e.target.value})}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Model *`,value:i.model,onChange:e=>a({...i,model:e.target.value})})]}),(0,Q.jsx)(gl,{size:`sm`,placeholder:`System prompt`,rows:3,value:i.systemPrompt??``,onChange:e=>a({...i,systemPrompt:e.target.value})}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Tools (comma-separated)`,value:o,onChange:e=>s(e.target.value)}),(0,Q.jsx)(ml,{size:`sm`,type:`number`,placeholder:`Temperature (0-1)`,min:0,max:1,step:.1,value:i.temperature??``,onChange:e=>a({...i,temperature:e.target.value===``?void 0:Number(e.target.value)})}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(S,{variant:`default`,size:`sm`,onClick:c,children:r?`Save`:`Create`}),(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`})]})]})}function zR({configs:e,onSave:t,onRemove:n}){let[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null);function s(e){t(e),i(!1)}function c(e){t(e),o(null)}return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(kR,{title:`Agents`,count:e.length,onAdd:()=>i(!r),addLabel:`Add agent config`}),(0,Q.jsx)(AR,{show:r,children:(0,Q.jsx)(RR,{initial:LR,onSubmit:s,onCancel:()=>i(!1),isEdit:!1})}),(0,Q.jsxs)(jR,{children:[e.length===0&&(0,Q.jsx)(MR,{message:`No agent configs`,description:`Define agent configurations for your workspace`,actionLabel:`Add agent`,onAction:()=>i(!0)}),e.map(e=>a===e.id?(0,Q.jsx)(NR,{children:(0,Q.jsx)(RR,{initial:e.config,onSubmit:c,onCancel:()=>o(null),isEdit:!0})},e.id):(0,Q.jsx)(NR,{children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)($n,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.config.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.config.provider,`/`,e.config.model]})]}),e.config.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.config.description}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:OR(new Date(e.updatedAt).toISOString())}),e.lastCommitHash&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-muted-foreground font-mono`,children:[(0,Q.jsx)(Fr,{className:`h-3 w-3`}),e.lastCommitHash.slice(0,7)]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(e.id),"aria-label":`Edit agent`,children:(0,Q.jsx)(ri,{className:`h-3 w-3`})})}),(0,Q.jsx)(tl,{children:`Edit agent`})]}),(0,Q.jsxs)(Cf,{children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(wf,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove agent`,children:(0,Q.jsx)(Si,{className:`h-3 w-3`})})})}),(0,Q.jsx)(tl,{children:`Remove agent`})]}),(0,Q.jsxs)(Df,{children:[(0,Q.jsxs)(Of,{children:[(0,Q.jsx)(Af,{children:`Remove agent config?`}),(0,Q.jsxs)(jf,{children:[`"`,e.config.name,`" will be permanently removed from the workspace.`]})]}),(0,Q.jsxs)(kf,{children:[(0,Q.jsx)(Nf,{children:`Cancel`}),(0,Q.jsx)(Mf,{onClick:()=>n(e.id),children:`Remove`})]})]})]})]})]})},e.id))]})]})}function BR({status:e}){return(0,Q.jsx)(`span`,{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium ${{cloned:`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`,pending:`bg-yellow-500/15 text-yellow-600 dark:text-yellow-400`,error:`bg-red-500/15 text-red-600 dark:text-red-400`}[e]}`,children:{cloned:`cloned`,pending:`cloning...`,error:`error`}[e]})}function VR(e){return e.split(`/`).filter(Boolean).pop()??e}function HR(e,t=40){return e.length<=t?e:`...${e.slice(-(t-3))}`}function UR({onSubmit:e,onCancel:t}){let[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(``);function o(){n.trim()&&(e(n.trim(),i.trim()||void 0),r(``),a(``))}return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(ml,{size:`sm`,placeholder:`Local path *`,value:n,onChange:e=>r(e.target.value),autoFocus:!0}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Label (optional)`,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(S,{variant:`default`,size:`sm`,onClick:o,children:`Add`}),(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`})]})]})}function WR({onSubmit:e,onCancel:t}){let[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(``),[o,s]=(0,j.useState)(``);function c(){!n.trim()||!i.trim()||(e(n.trim(),i.trim(),o.trim()||void 0),r(``),a(``),s(``))}return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(ml,{size:`sm`,placeholder:`Origin URL *`,value:n,onChange:e=>r(e.target.value),autoFocus:!0}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Target path *`,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(ml,{size:`sm`,placeholder:`Label (optional)`,value:o,onChange:e=>s(e.target.value)}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(S,{variant:`default`,size:`sm`,onClick:c,children:`Clone`}),(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`})]})]})}function GR({repos:e,onAddRepo:t,onCloneRepo:n,onRemoveRepo:r,onPullRepo:i,onPushRepo:a}){let[o,s]=(0,j.useState)(null);function c(){s(e=>e===null?`local`:null)}function l(e,n){t(e,n),s(null)}function u(e,t,r){n(e,t,r),s(null)}return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(kR,{title:`Repos`,count:e.length,onAdd:c,addLabel:`Add repository`}),(0,Q.jsxs)(AR,{show:o!==null,children:[(0,Q.jsxs)(`div`,{className:`flex gap-1 mb-2`,children:[(0,Q.jsx)(S,{variant:o===`local`?`default`:`outline`,size:`sm`,onClick:()=>s(`local`),children:`Add Local`}),(0,Q.jsx)(S,{variant:o===`clone`?`default`:`outline`,size:`sm`,onClick:()=>s(`clone`),children:`Clone`})]}),o===`local`&&(0,Q.jsx)(UR,{onSubmit:l,onCancel:()=>s(null)}),o===`clone`&&(0,Q.jsx)(WR,{onSubmit:u,onCancel:()=>s(null)})]}),(0,Q.jsxs)(jR,{children:[e.length===0&&(0,Q.jsx)(MR,{message:`No repositories`,description:`Add local repos or clone from a remote origin`,actionLabel:`Add repo`,onAction:()=>s(`local`)}),e.map(e=>(0,Q.jsx)(NR,{children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(Ar,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.label??VR(e.localPath)}),(0,Q.jsx)(BR,{status:e.status})]}),e.origin&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,title:e.origin,children:HR(e.origin)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate`,title:e.localPath,children:VR(e.localPath)}),e.branch&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-muted-foreground font-mono`,children:[(0,Q.jsx)(Pr,{className:`h-3 w-3`}),e.branch]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:()=>i(e.id),"aria-label":`Pull`,children:(0,Q.jsx)(Kn,{className:`h-3 w-3`})})}),(0,Q.jsx)(tl,{children:`Pull`})]}),(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,onClick:()=>a(e.id),"aria-label":`Push`,children:(0,Q.jsx)(Xn,{className:`h-3 w-3`})})}),(0,Q.jsx)(tl,{children:`Push`})]}),(0,Q.jsxs)(Cf,{children:[(0,Q.jsxs)($c,{children:[(0,Q.jsx)(el,{asChild:!0,children:(0,Q.jsx)(wf,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove repo`,children:(0,Q.jsx)(Si,{className:`h-3 w-3`})})})}),(0,Q.jsx)(tl,{children:`Remove repo`})]}),(0,Q.jsxs)(Df,{children:[(0,Q.jsxs)(Of,{children:[(0,Q.jsx)(Af,{children:`Remove repository?`}),(0,Q.jsxs)(jf,{children:[`"`,e.label??VR(e.localPath),`" will be removed from the workspace. The files on disk will not be deleted.`]})]}),(0,Q.jsxs)(kf,{children:[(0,Q.jsx)(Nf,{children:`Cancel`}),(0,Q.jsx)(Mf,{onClick:()=>r(e.id),children:`Remove`})]})]})]})]})]})},e.id))]})]})}function KR({status:e}){return(0,Q.jsx)(`span`,{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium ${{running:`bg-blue-500/15 text-blue-600 dark:text-blue-400`,completed:`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`,failed:`bg-red-500/15 text-red-600 dark:text-red-400`,cancelled:`bg-yellow-500/15 text-yellow-600 dark:text-yellow-400`}[e]}`,children:e})}function qR({status:e}){switch(e){case`completed`:return(0,Q.jsx)(dr,{className:`h-3 w-3 text-emerald-500`});case`failed`:return(0,Q.jsx)(ur,{className:`h-3 w-3 text-red-500`});case`running`:return(0,Q.jsx)(Gr,{className:`h-3 w-3 text-blue-500 animate-spin`});case`skipped`:return(0,Q.jsx)(gr,{className:`h-3 w-3 text-muted-foreground`});default:return(0,Q.jsx)(gr,{className:`h-3 w-3 text-muted-foreground opacity-50`})}}function JR(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function YR({run:e,isActive:t,onCancel:n}){return(0,Q.jsx)(NR,{children:(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.workflowId}),(0,Q.jsx)(KR,{status:e.status}),t&&(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`h-5 w-5 ml-auto`,onClick:n,children:(0,Q.jsx)(pr,{className:`h-3.5 w-3.5 text-muted-foreground hover:text-destructive`})})]}),(0,Q.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:[JR(e.startedAt),` · `,e.triggeredBy,e.error&&(0,Q.jsxs)(`span`,{className:`text-red-500 ml-1`,children:[`— `,e.error]})]}),e.steps.length>0&&(0,Q.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:e.steps.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px]`,children:[(0,Q.jsx)(qR,{status:e.status}),(0,Q.jsxs)(`span`,{className:`truncate text-muted-foreground`,children:[e.label??e.mcp_tool,e.repoId&&(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[` (`,e.repoId.slice(0,8),`)`]})]})]},`${e.stepIndex}-${e.repoId??``}`))})]})})}function XR({runs:e,activeRunIds:t,onCancelRun:n}){let r=new Set(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold text-foreground`,children:[`Workflows`,e.length>0&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,Q.jsx)(jR,{children:e.length===0?(0,Q.jsx)(MR,{message:`No workflow runs yet`}):e.map(e=>(0,Q.jsx)(YR,{run:e,isActive:r.has(e.runId),onCancel:()=>n(e.runId)},e.runId))})]})}var ZR={creating:`text-yellow-500`,running:`text-green-500`,stopped:`text-gray-500`,error:`text-red-500`};function QR({snapshot:e,onCommand:t,workspaceId:n}){let r=e?.sandbox;return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold text-foreground`,children:[`Sandbox`,r&&(0,Q.jsx)(`span`,{className:`ml-1.5 text-xs font-normal ${ZR[r.status]??`text-muted-foreground`}`,children:r.status})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[!r&&(0,Q.jsx)(S,{variant:`default`,size:`sm`,onClick:()=>t({type:`workspace.sandbox.create`,workspaceId:n}),children:`Create`}),r?.status===`stopped`&&(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>t({type:`workspace.sandbox.start`,workspaceId:n}),children:`Start`}),r?.status===`running`&&(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>t({type:`workspace.sandbox.stop`,workspaceId:n}),children:`Stop`}),r&&(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,className:`text-destructive hover:bg-destructive/10`,onClick:()=>t({type:`workspace.sandbox.destroy`,workspaceId:n}),children:`Destroy`})]})]}),(0,Q.jsx)(jR,{children:r?(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-1 text-xs`,children:[r.containerId&&(0,Q.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Container`}),(0,Q.jsx)(`span`,{className:`font-mono`,children:r.containerId.slice(0,12)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsxs)(`span`,{children:[r.resourceLimits.memoryMb,`MB`]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`CPU Shares`}),(0,Q.jsx)(`span`,{children:r.resourceLimits.cpuShares})]})]}):(0,Q.jsx)(MR,{message:`No sandbox configured`,description:`Create a sandbox environment for this workspace`,actionLabel:`Create sandbox`,onAction:()=>t({type:`workspace.sandbox.create`,workspaceId:n})})})]})}function $R(e){Jg.success(e)}function ez(e){Jg.error(e)}function tz(e){ez(e instanceof Error?e.message:String(e))}function nz(e,t){e.then(()=>$R(t)).catch(tz)}var rz=[{value:`agents`,label:`Agents`,icon:$n,tooltip:`Agents`},{value:`repos`,label:`Repos`,icon:Ar,tooltip:`Repos`},{value:`workflows`,label:`Workflows`,icon:Oi,tooltip:`Workflows`},{value:`sandbox`,label:`Sandbox`,icon:er,tooltip:`Sandbox`}];function iz(){let{id:e}=rt(),t=tt(),n=wR(t.socket,e??null),r=TR(t.socket,e??null),i=ER(t.socket,e??null),a=DR(t.socket,e??null),o=(0,j.useMemo)(()=>e?t.sidebarData.independentWorkspaces.find(t=>t.id===e)?.name??e:null,[e,t.sidebarData.independentWorkspaces]),s=(0,j.useCallback)(n=>{e&&nz(t.socket.command({type:`workspace.agent.save`,workspaceId:e,config:n}),`Agent config saved`)},[e,t.socket]),c=(0,j.useCallback)(n=>{e&&nz(t.socket.command({type:`workspace.agent.remove`,workspaceId:e,agentId:n}),`Agent config removed`)},[e,t.socket]),l=(0,j.useCallback)((n,r)=>{e&&nz(t.socket.command({type:`workspace.repo.add`,workspaceId:e,localPath:n,label:r}),`Repo added`)},[e,t.socket]),u=(0,j.useCallback)((n,r,i)=>{e&&nz(t.socket.command({type:`workspace.repo.clone`,workspaceId:e,origin:n,targetPath:r,label:i}),`Repo clone started`)},[e,t.socket]),d=(0,j.useCallback)(n=>{e&&nz(t.socket.command({type:`workspace.repo.remove`,workspaceId:e,repoId:n}),`Repo removed`)},[e,t.socket]),f=(0,j.useCallback)(e=>{nz(t.socket.command({type:`workspace.repo.pull`,repoId:e}),`Pull started`)},[t.socket]),p=(0,j.useCallback)(n=>{e&&nz(t.socket.command({type:`workspace.workflow.cancel`,workspaceId:e,runId:n}),`Workflow cancelled`)},[e,t.socket]),m=(0,j.useCallback)(e=>{nz(t.socket.command({type:`workspace.repo.push`,repoId:e}),`Push started`)},[t.socket]);if(!e)return(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No workspace selected`})});let[h,g]=(0,j.useState)(`agents`),_=Qe();return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 relative`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3 pb-2 md:pt-4 md:pb-3`,children:[(0,Q.jsx)(`button`,{onClick:()=>_(`/`),className:`size-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/50 md:hidden`,children:(0,Q.jsx)(Jn,{className:`size-4`})}),(0,Q.jsx)(tr,{className:`size-4 text-muted-foreground hidden md:block`}),(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-foreground md:text-lg truncate`,children:o??`Workspace`})]}),(0,Q.jsx)(`div`,{className:`px-4 mb-3`,children:(0,Q.jsx)(ol,{value:h,onValueChange:g,options:rz,size:`sm`,className:`w-full md:w-auto`,optionClassName:`flex-1 md:flex-initial justify-center`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 mx-4 mb-4 rounded-lg overflow-hidden border border-border bg-background`,children:[h===`agents`&&(0,Q.jsx)(zR,{configs:n?.configs??[],onSave:s,onRemove:c}),h===`repos`&&(0,Q.jsx)(GR,{repos:r?.repos??[],onAddRepo:l,onCloneRepo:u,onRemoveRepo:d,onPullRepo:f,onPushRepo:m}),h===`workflows`&&(0,Q.jsx)(XR,{runs:i?.runs??[],activeRunIds:i?.activeRunIds??[],onCancelRun:p}),h===`sandbox`&&(0,Q.jsx)(QR,{snapshot:a,onCommand:e=>{t.socket.command(e)},workspaceId:e})]})]})}var az=w()(Wx(e=>({archivedIds:[],archive:t=>e(e=>({archivedIds:e.archivedIds.includes(t)?e.archivedIds:[...e.archivedIds,t]})),unarchive:t=>e(e=>({archivedIds:e.archivedIds.filter(e=>e!==t)}))}),{name:`archived-sessions`,version:1}));function oz(e,t){return e.includes(t)}var sz={panel:d({id:`project.sessions.panel`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),list:d({id:`project.sessions.list`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),item:d({id:`project.sessions.item`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),archived:d({id:`project.sessions.archived`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),newChatAction:d({id:`project.sessions.new-chat.action`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),emptyState:d({id:`project.sessions.empty-state`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`})};v(sz);var cz={idle:`bg-zinc-400`,starting:`bg-amber-400`,running:`bg-emerald-400`,waiting_for_user:`bg-blue-400`,awaiting_agents:`bg-blue-400`,failed:`bg-red-400`},lz={idle:`Idle`,starting:`Starting`,running:`Running`,waiting_for_user:`Waiting`,awaiting_agents:`Awaiting agents`,failed:`Failed`},uz=new Set([`starting`,`running`]);function dz({groupKey:e,chats:t,onCreateChat:n,onDeleteChat:r,onRenameChat:i,onForkChat:a,onMergeSession:o}){let s=Qe(),l=az(e=>e.archivedIds),u=az(e=>e.archive),d=az(e=>e.unarchive),f=t.filter(e=>!oz(l,e.chatId)),p=t.filter(e=>oz(l,e.chatId));return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,...c(sz.panel),children:[(0,Q.jsx)(kR,{title:`Sessions`,count:f.length,onAdd:()=>n(e),addLabel:`New chat`}),(0,Q.jsxs)(jR,{children:[f.length===0?(0,Q.jsx)(MR,{message:`No active sessions`,description:`Start a new chat to begin working on this project.`,actionLabel:`New chat`,onAction:()=>n(e)}):(0,Q.jsx)(`div`,{...c(sz.list),children:f.map(t=>(0,Q.jsx)(fz,{chat:t,onSelect:()=>s(`/chat/${t.chatId}`),onFork:()=>a(t.chatId),onMerge:()=>o(e),onRename:e=>i(t.chatId,e),onArchive:()=>u(t.chatId),onDelete:()=>r(t)},t.chatId))}),p.length>0&&(0,Q.jsx)(`div`,{...c(sz.archived),children:(0,Q.jsx)(FR,{label:`Archived`,count:p.length,children:p.map(e=>(0,Q.jsx)(fz,{chat:e,archived:!0,onSelect:()=>s(`/chat/${e.chatId}`),onUnarchive:()=>d(e.chatId),onDelete:()=>r(e)},e.chatId))})})]})]})}function fz({chat:e,archived:t,onSelect:n,onFork:r,onMerge:i,onRename:a,onArchive:o,onUnarchive:s,onDelete:l}){let[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(e.title),m=(0,j.useRef)(null),h=e.provider?M_[e.provider]:null,g=cz[e.status]??cz.idle,_=lz[e.status]??e.status,v=uz.has(e.status);function y(){let t=f.trim();d(!1),t&&t!==e.title&&a?a(t):p(e.title)}function x(){p(e.title),d(!0),requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})}return(0,Q.jsx)(NR,{className:`group/row cursor-pointer`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:n,...c(sz.item),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:b(`size-2 rounded-full shrink-0`,g,v&&`animate-pulse`),title:_}),u?(0,Q.jsx)(ml,{ref:m,size:`sm`,className:`flex-1 h-6 text-sm`,value:f,onChange:e=>p(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),y()):t.key===`Escape`&&(t.preventDefault(),p(e.title),d(!1))},onBlur:y,onClick:e=>e.stopPropagation()}):(0,Q.jsx)(`span`,{className:`text-sm truncate flex-1`,onDoubleClick:e=>{e.stopPropagation(),x()},children:v?(0,Q.jsx)(y_,{animate:!0,shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e.model?(0,Q.jsx)(`span`,{className:`max-w-20 truncate rounded-full bg-muted/60 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground/70`,children:e.model}):null,h?(0,Q.jsx)(`span`,{className:`flex size-5 items-center justify-center text-muted-foreground/55`,children:(0,Q.jsx)(h,{className:`size-2.5`})}):null,e.lastMessageAt?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground/50 w-10 text-right`,children:w_(e.lastMessageAt)}):null,(0,Q.jsx)(pz,{archived:t,onFork:r,onMerge:i,onRename:a?x:void 0,onArchive:o,onUnarchive:s,onDelete:l})]})]})})}function pz({archived:e,onFork:t,onMerge:n,onRename:r,onArchive:i,onUnarchive:a,onDelete:o}){return(0,Q.jsxs)(qL,{children:[(0,Q.jsx)(JL,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`size-6 opacity-0 group-hover/row:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Sr,{className:`size-3.5`})})}),(0,Q.jsxs)(XL,{align:`end`,className:`w-40`,children:[t&&(0,Q.jsxs)(ZL,{onClick:e=>{e.stopPropagation(),t()},children:[(0,Q.jsx)(Nr,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Fork`})]}),n&&(0,Q.jsxs)(ZL,{onClick:e=>{e.stopPropagation(),n()},children:[(0,Q.jsx)(Xr,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Merge sessions`})]}),r&&(0,Q.jsxs)(ZL,{onClick:e=>{e.stopPropagation(),r()},children:[(0,Q.jsx)(ii,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Rename`})]}),i&&!e&&(0,Q.jsxs)(ZL,{onClick:e=>{e.stopPropagation(),i()},children:[(0,Q.jsx)(Gn,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Archive`})]}),a&&e&&(0,Q.jsxs)(ZL,{onClick:e=>{e.stopPropagation(),a()},children:[(0,Q.jsx)(Wn,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Unarchive`})]}),(0,Q.jsxs)(ZL,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10`,children:[(0,Q.jsx)(Si,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Delete`})]})]})]})}var mz={page:d({id:`project.page`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),header:d({id:`project.page.header`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),backAction:d({id:`project.page.back.action`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),tabs:d({id:`project.page.tabs`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),content:d({id:`project.page.content`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),emptyState:d({id:`project.page.empty-state`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),loadingState:d({id:`project.page.loading-state`,c3ComponentId:`c3-117`,c3ComponentLabel:`projects`}),extensionsTabs:d({id:`project.extensions.tabs`,c3ComponentId:`c3-120`,c3ComponentLabel:`extensions`}),extensionsContent:d({id:`project.extensions.content`,c3ComponentId:`c3-120`,c3ComponentLabel:`extensions`})};v(mz);var hz={"building-2":rr,bot:$n,code:vr},gz=[{value:`sessions`,label:`Sessions`,icon:Qr},{value:`extensions`,label:`Extensions`,icon:ci}];function _z({localPath:e,onBack:t}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3 pb-2 md:pt-4 md:pb-3`,...c(mz.header),children:[(0,Q.jsx)(S,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:t,className:`size-7 border-0 md:hidden`,...c(mz.backAction),children:(0,Q.jsx)(Jn,{className:`size-4`})}),(0,Q.jsx)(jr,{className:`size-4 text-muted-foreground hidden md:block`}),(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-foreground md:text-lg truncate`,children:C_(e)})]})}function vz(){let{groupKey:e}=rt(),t=tt(),n=Qe(),[r,i]=(0,j.useState)(`sessions`),a=zf(t.socket),[o,s]=(0,j.useState)(null),[l,u]=(0,j.useState)(!1),d=(0,j.useMemo)(()=>e?t.sidebarData.workspaceGroups.find(t=>t.groupKey===e)??null:null,[e,t.sidebarData.workspaceGroups]),f=d?.localPath??null,p=d?.chats??[];(0,j.useEffect)(()=>{f&&(s(null),u(!1),fetch(`/api/ext/detect?projectPath=${encodeURIComponent(f)}`).then(e=>{if(!e.ok)throw Error(`Detection failed: ${e.status}`);return e.json()}).then(e=>{s(e.filter(e=>e.detected).map(e=>e.extensionId))}).catch(e=>{console.warn(`[ProjectPage] Extension detection failed:`,e instanceof Error?e.message:String(e)),u(!0)}))},[f]);let m=(0,j.useMemo)(()=>o?Bf.filter(e=>o.includes(e.id)?a?.preferences.find(t=>t.extensionId===e.id)?.enabled!==!1:!1):[],[o,a]),h=(0,j.useMemo)(()=>m.map(e=>({value:e.id,label:e.name,icon:hz[e.icon],tooltip:e.name})),[m]),[g,_]=(0,j.useState)(null);(0,j.useEffect)(()=>{m.length>0&&g===null&&_(m[0].id)},[m,g]);let v=(0,j.useMemo)(()=>g?m.find(e=>e.id===g)?.component??null:null,[g,m]);return!e||!f?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,...c(mz.page),children:(0,Q.jsx)(`p`,{className:`text-muted-foreground`,...c(mz.emptyState),children:`Project not found`})}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 relative`,...c(mz.page),children:[(0,Q.jsx)(_z,{localPath:f,onBack:()=>n(`/`)}),(0,Q.jsx)(`div`,{className:`px-4 mb-3`,...c(mz.tabs),children:(0,Q.jsx)(ol,{value:r,onValueChange:i,options:gz,size:`sm`,className:`w-full md:w-auto`,optionClassName:`flex-1 md:flex-initial justify-center`,alwaysShowLabels:!0})}),r===`sessions`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 mx-4 mb-4 rounded-lg overflow-hidden border border-border bg-background`,...c(mz.content),children:(0,Q.jsx)(dz,{groupKey:e,chats:p,onCreateChat:e=>void t.handleCreateChat(e),onDeleteChat:e=>void t.handleDeleteChat(e),onRenameChat:(e,n)=>void t.handleRenameChat(e,n),onForkChat:e=>n(`/chat/${e}`),onMergeSession:e=>t.requestMerge(e)})}),r===`extensions`&&(0,Q.jsx)(Q.Fragment,{children:o===null&&!l?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,...c(mz.loadingState),children:(0,Q.jsx)(Gr,{className:`size-5 animate-spin text-muted-foreground`})}):l||m.length===0?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,...c(mz.emptyState),children:(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No extensions available`})}):(0,Q.jsxs)(Q.Fragment,{children:[h.length>1&&g!==null&&(0,Q.jsx)(`div`,{className:`px-4 mb-3`,...c(mz.extensionsTabs),children:(0,Q.jsx)(ol,{value:g,onValueChange:_,options:h,size:`sm`,className:`w-full md:w-auto`,optionClassName:`flex-1 md:flex-initial justify-center`,alwaysShowLabels:!0})}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 mx-4 mb-4 rounded-lg overflow-hidden border border-border bg-background`,...c(mz.extensionsContent),children:(0,Q.jsx)(j.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,...c(mz.loadingState),children:(0,Q.jsx)(Gr,{className:`size-5 animate-spin text-muted-foreground`})}),children:v&&f&&(0,Q.jsx)(v,{localPath:f,groupKey:e})})})]})})]})}var yz=(0,j.createContext)(null);function bz(e){let{socket:t,activeChatId:n,sessionProvider:r,sessionToken:i,isProcessing:a,resumeRefreshNonce:o}=e,[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(!n||!r||!i){c(null);return}let e=n,o=!1;async function s(){try{let n=await t.command({type:`chat.getSessionRuntime`,chatId:e});o||c(n.runtime)}catch{o||c(null)}}if(s(),!a)return()=>{o=!0};let l=window.setInterval(()=>{s()},5e3);return()=>{o=!0,window.clearInterval(l)}},[n,r,i,a,o,t]),(0,j.useEffect)(()=>{if(!n){u(null);return}let e=n,r=!1;async function i(){try{let n=await t.command({type:`chat.getRepoStatus`,chatId:e});r||u(n.repoStatus)}catch{r||u(null)}}if(i(),!a)return()=>{r=!0};let o=window.setInterval(()=>{i()},5e3);return()=>{r=!0,window.clearInterval(o)}},[n,a,o,t]),{currentSessionRuntime:s,currentRepoStatus:l}}var xz=new Map;function Sz(e){return xz.get(e)??null}function Cz(e,t){if(xz.delete(e),xz.set(e,t),xz.size>10){let e=xz.keys().next().value;e!==void 0&&xz.delete(e)}}function wz(e){xz.delete(e)}function Tz(){xz.clear()}function Ez(e){let t=new Map(e.map(e=>[e.chatId,e]));for(let[e,n]of xz){if(n.stale)continue;let r=t.get(e);!r||r.lastMessageAt===void 0||n.lastMessageAt===void 0||r.lastMessageAt>n.lastMessageAt&&Cz(e,{...n,stale:!0})}}function Dz(){return{explicitProjectId:null,fallbackProjectId:null,activeChatProjectId:null}}function Oz(e,t){switch(t.type){case`sidebar.loaded`:return{...e,fallbackProjectId:t.firstProjectId};case`project.explicitly_selected`:return{...e,explicitProjectId:t.workspaceId};case`chat.snapshot_received`:return{...e,activeChatProjectId:t.workspaceId};case`chat.cleared`:return{...e,activeChatProjectId:null}}}function kz(e){return e.activeChatProjectId?{source:`chat_owned`,workspaceId:e.activeChatProjectId}:e.explicitProjectId?{source:`explicit`,workspaceId:e.explicitProjectId}:e.fallbackProjectId?{source:`fallback`,workspaceId:e.fallbackProjectId}:{source:`none`,workspaceId:null}}function Az(e){return{queuedTextByChat:e?.queuedTextByChat??{},blockedFlushKeyByChat:e?.blockedFlushKeyByChat??{},awaitingBusyByChat:e?.awaitingBusyByChat??{},inFlightTextByChat:e?.inFlightTextByChat??{},optionsByChat:e?.optionsByChat??{}}}function jz(e,t){let n=t.trim();return e===null||!n?null:`${e}:${n}`}function Mz(e,t){return t?e.queuedTextByChat[t]??``:``}function Nz(e,t){let n=wj(Mz(e,t.chatId),t.content);return{...e,queuedTextByChat:n?{...e.queuedTextByChat,[t.chatId]:n}:e.queuedTextByChat,optionsByChat:{...e.optionsByChat,[t.chatId]:t.options},blockedFlushKeyByChat:{...e.blockedFlushKeyByChat,[t.chatId]:null}}}function Pz(e,t){if(e.inFlightTextByChat[t]!==void 0)return`flushing`;if(e.awaitingBusyByChat[t]===!0)return`awaiting_busy_ack`;let n=Mz(e,t),r=jz(t,n);return r!==null&&e.blockedFlushKeyByChat[t]===r?`blocked`:n.trim()?`queued`:`idle`}function Fz(e,t){return{...e,awaitingBusyByChat:{...e.awaitingBusyByChat,[t]:!1}}}function Iz(e,t){return{...e,awaitingBusyByChat:{...e.awaitingBusyByChat,[t.chatId]:!1},inFlightTextByChat:{...e.inFlightTextByChat,[t.chatId]:t.content.trim()}}}function Lz(e,t){let n={...e.inFlightTextByChat};return delete n[t],{...e,awaitingBusyByChat:{...e.awaitingBusyByChat,[t]:!0},inFlightTextByChat:n}}function Rz(e,t){let n={...e.inFlightTextByChat};return delete n[t],{...e,awaitingBusyByChat:{...e.awaitingBusyByChat,[t]:!1},inFlightTextByChat:n}}function zz(e,t){let n={...e.queuedTextByChat};delete n[t];let r={...e.optionsByChat};return delete r[t],{...e,queuedTextByChat:n,optionsByChat:r,awaitingBusyByChat:{...e.awaitingBusyByChat,[t]:!1},blockedFlushKeyByChat:{...e.blockedFlushKeyByChat,[t]:null}}}function Bz(e,t){let n=t.content?.trim()??``;return n?{...e,queuedTextByChat:{...e.queuedTextByChat,[t.chatId]:n},optionsByChat:{...e.optionsByChat,[t.chatId]:t.options},blockedFlushKeyByChat:{...e.blockedFlushKeyByChat,[t.chatId]:null}}:zz(e,t.chatId)}function Vz(e){let{activeChatId:t}=e,n=(0,j.useRef)(Az({queuedTextByChat:Object.fromEntries(Object.entries(Jx.getState().queuedDrafts).map(([e,t])=>[e,t.text])),optionsByChat:Object.fromEntries(Object.entries(Jx.getState().queuedDrafts).map(([e,t])=>[e,t.options]))})),[r,i]=(0,j.useState)(n.current),a=Mz(r,t);function o(e){let t=e(n.current);return n.current=t,i(t),Jx.getState().syncQueuedDrafts(Object.fromEntries(Object.entries(t.queuedTextByChat).flatMap(([e,n])=>{let r=n.trim();return r?[[e,{text:r,updatedAt:Date.now(),options:t.optionsByChat[e]}]]:[]}))),t}function s(){t&&o(e=>zz(e,t))}function c(){let e=a;return t&&o(e=>zz(e,t)),e}return{submitPipelineRef:n,submitPipeline:r,activeQueuedText:a,updateSubmitPipeline:o,clearQueuedText:s,restoreQueuedText:c}}var Hz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.TD=e.TE=e.Empty=void 0,e.encode=n,e.decode=r,e.Empty=new Uint8Array,e.TE=new TextEncoder,e.TD=new TextDecoder;function t(...e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].length;return n}function n(...n){let r=[];for(let t=0;t<n.length;t++)r.push(e.TE.encode(n[t]));return r.length===0?e.Empty:r.length===1?r[0]:t(...r)}function r(t){return!t||t.length===0?``:e.TD.decode(t)}})),Uz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.errors=e.PermissionViolationError=e.NoRespondersError=e.TimeoutError=e.RequestError=e.ProtocolError=e.ConnectionError=e.DrainingConnectionError=e.ClosedConnectionError=e.AuthorizationError=e.UserAuthenticationExpiredError=e.InvalidOperationError=e.InvalidArgumentError=e.InvalidSubjectError=void 0;var t=class extends Error{constructor(e,t){super(`illegal subject: '${e}'`,t),this.name=`InvalidSubjectError`}};e.InvalidSubjectError=t;var n=class e extends Error{constructor(e,t){super(e,t),this.name=`InvalidArgumentError`}static format(t,n,r){return Array.isArray(n)&&n.length>1&&(n=n[0]),Array.isArray(t)?(t=t.map(e=>`'${e}'`),t=t.join(`,`)):t=`'${t}'`,new e(`${t} ${n}`,r)}};e.InvalidArgumentError=n;var r=class extends Error{constructor(e,t){super(e,t),this.name=`InvalidOperationError`}};e.InvalidOperationError=r;var i=class e extends Error{constructor(e,t){super(e,t),this.name=`UserAuthenticationExpiredError`}static parse(t){return t.toLowerCase().indexOf(`user authentication expired`)===-1?null:new e(t)}};e.UserAuthenticationExpiredError=i;var a=class e extends Error{constructor(e,t){super(e,t),this.name=`AuthorizationError`}static parse(t){let n=[`authorization violation`,`account authentication expired`,`authentication timeout`],r=t.toLowerCase();for(let i=0;i<n.length;i++)if(r.indexOf(n[i])!==-1)return new e(t);return null}};e.AuthorizationError=a;var o=class extends Error{constructor(){super(`closed connection`),this.name=`ClosedConnectionError`}};e.ClosedConnectionError=o;var s=class extends Error{constructor(){super(`connection draining`),this.name=`DrainingConnectionError`}};e.DrainingConnectionError=s;var c=class extends Error{constructor(e,t){super(e,t),this.name=`ConnectionError`}};e.ConnectionError=c;var l=class extends Error{constructor(e,t){super(e,t),this.name=`ProtocolError`}};e.ProtocolError=l;var u=class extends Error{constructor(e=``,t){super(e,t),this.name=`RequestError`}isNoResponders(){return this.cause instanceof f}};e.RequestError=u;var d=class extends Error{constructor(e){super(`timeout`,e),this.name=`TimeoutError`}};e.TimeoutError=d;var f=class extends Error{subject;constructor(e,t){super(`no responders: '${e}'`,t),this.subject=e,this.name=`NoResponders`}};e.NoRespondersError=f;var p=class e extends Error{operation;subject;queue;constructor(e,t,n,r,i){super(e,i),this.name=`PermissionViolationError`,this.operation=t,this.subject=n,this.queue=r}static parse(t){if((t?t.toLowerCase():``).indexOf(`permissions violation`)===-1)return null;let n=`publish`,r=``,i,a=t.match(/(Publish|Subscription) to "(\S+)"/);if(a&&(n=a[1].toLowerCase(),r=a[2],n===`subscription`)){let e=t.match(/using queue "(\S+)"/);e&&(i=e[1])}return new e(t,n,r,i)}};e.PermissionViolationError=p,e.errors={AuthorizationError:a,ClosedConnectionError:o,ConnectionError:c,DrainingConnectionError:s,InvalidArgumentError:n,InvalidOperationError:r,InvalidSubjectError:t,NoRespondersError:f,PermissionViolationError:p,ProtocolError:l,RequestError:u,TimeoutError:d,UserAuthenticationExpiredError:i}})),Wz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SimpleMutex=e.Perf=void 0,e.extend=r,e.render=i,e.timeout=a,e.delay=o,e.deadline=s,e.deferred=c,e.debugDeferred=l,e.shuffle=u,e.collect=d,e.jitter=f,e.backoff=p,e.nanos=m,e.millis=h;var t=Hz(),n=Uz();function r(e,...t){for(let n=0;n<t.length;n++){let r=t[n];Object.keys(r).forEach(function(t){e[t]=r[t]})}return e}function i(e){return t.TD.decode(e).replace(/\n/g,`␊`).replace(/\r/g,`␍`)}function a(e,t=!0){let r=t?new n.TimeoutError:null,i,a,o=new Promise((t,o)=>{i={cancel:()=>{a&&clearTimeout(a)}},a=setTimeout(()=>{o(r===null?new n.TimeoutError:r)},e)});return Object.assign(o,i)}function o(e=0){let t,n=new Promise(n=>{let r=setTimeout(()=>{n()},e);t={cancel:()=>{r&&(clearTimeout(r),n())}}});return Object.assign(n,t)}async function s(e,t=1e3){let r=c(),i=setTimeout(()=>{r.reject(new n.TimeoutError)},t);try{return await Promise.race([e,r])}finally{clearTimeout(i)}}function c(){let e={},t=new Promise((t,n)=>{e={resolve:t,reject:n}});return Object.assign(t,e)}function l(){let e={},t=new Promise((t,n)=>{e={resolve:e=>{console.trace(`resolve`,e),t(e)},reject:e=>{console.trace(`reject`),n(e)}}});return Object.assign(t,e)}function u(e){for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}async function d(e){let t=[];for await(let n of e)t.push(n);return t}e.Perf=class{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark(e){this.timers.set(e,performance.now())}measure(e,t,n){let r=this.timers.get(t);if(r===void 0)throw Error(`${t} is not defined`);let i=this.timers.get(n);if(i===void 0)throw Error(`${n} is not defined`);this.measures.set(e,i-r)}getEntries(){let e=[];return this.measures.forEach((t,n)=>{e.push({name:n,duration:t})}),e}},e.SimpleMutex=class{max;current;waiting;constructor(e=1){this.max=e,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let e=c();return this.waiting.push(e),e}unlock(){this.current--,this.waiting.pop()?.resolve()}};function f(e){return e===0?0:Math.floor(e/2+Math.random()*e)}function p(e=[0,250,250,500,500,3e3,5e3]){Array.isArray(e)||(e=[0,250,250,500,500,3e3,5e3]);let t=e.length-1;return{backoff(n){return f(n>t?e[t]:e[n])}}}function m(e){return e*1e6}function h(e){return Math.floor(e/1e6)}})),Gz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.nuid=e.Nuid=void 0;var t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ`,n=36,r=12,i=10,a=0xcfd41b9100000,o=33,s=333,c=r+i;function l(e){for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*255)}function u(e){globalThis?.crypto?.getRandomValues?globalThis.crypto.getRandomValues(e):l(e)}var d=class{buf;seq;inc;inited;constructor(){this.buf=new Uint8Array(c),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*a),this.inc=Math.floor(Math.random()*(s-o)+o)}setPre(){let e=new Uint8Array(r);u(e);for(let i=0;i<r;i++){let r=e[i]%n;this.buf[i]=t.charCodeAt(r)}}fillSeq(){let e=this.seq;for(let i=c-1;i>=r;i--)this.buf[i]=t.charCodeAt(e%n),e=Math.floor(e/n)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>a&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}};e.Nuid=d,e.nuid=new d})),Kz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.nuid=e.Nuid=void 0;var t=Gz();Object.defineProperty(e,`Nuid`,{enumerable:!0,get:function(){return t.Nuid}}),Object.defineProperty(e,`nuid`,{enumerable:!0,get:function(){return t.nuid}})})),qz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_HOST=e.DEFAULT_PORT=e.Match=void 0,e.syncIterator=r,e.createInbox=i;var t=Kz(),n=Uz();e.Match={Exact:`exact`,CanonicalMIME:`canonical`,IgnoreCase:`insensitive`};function r(e){let t=e[Symbol.asyncIterator]();return{async next(){let e=await t.next();return e.done?Promise.resolve(null):Promise.resolve(e.value)}}}function i(e=``){if(e||=`_INBOX`,typeof e!=`string`)throw TypeError(`prefix must be a string`);return e.split(`.`).forEach(t=>{if(t===`*`||t===`>`)throw n.InvalidArgumentError.format(`prefix`,`cannot have wildcards ('${e}')`)}),`${e}.${t.nuid.next()}`}e.DEFAULT_PORT=4222,e.DEFAULT_HOST=`127.0.0.1`})),Jz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DataBuffer=void 0;var t=Hz();e.DataBuffer=class{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].length;return n}static fromAscii(e){return e||=``,t.TE.encode(e)}static toAscii(e){return t.TD.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let e=new Uint8Array(this.byteLength),t=0;for(let n=0;n<this.buffers.length;n++)e.set(this.buffers[n],t),t+=this.buffers[n].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){let e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array}drain(e){if(this.buffers.length){this.pack();let t=this.buffers.pop();if(t){let n=this.byteLength;(e===void 0||e>n)&&(e=n);let r=t.subarray(0,e);return n>e&&this.buffers.push(t.subarray(e)),this.byteLength=n-e,r}}return new Uint8Array}fill(e,...t){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let e=0;e<t.length;e++)t[e]&&t[e].length&&(this.buffers.push(t[e]),this.byteLength+=t[e].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array}size(){return this.byteLength}length(){return this.buffers.length}}})),Yz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.LF=e.CR=e.CRLF=e.CR_LF_LEN=e.CR_LF=void 0,e.setTransportFactory=a,e.defaultPort=o,e.getUrlParseFn=s,e.newTransport=c,e.getResolveFn=l,e.protoLen=u,e.extractProtocolMessage=d;var t=Hz(),n=qz(),r=Jz(),i;function a(e){i=e}function o(){return i!==void 0&&i.defaultPort!==void 0?i.defaultPort:n.DEFAULT_PORT}function s(){return i!==void 0&&i.urlParseFn?i.urlParseFn:void 0}function c(){if(!i||typeof i.factory!=`function`)throw Error(`transport fn is not set`);return i.factory()}function l(){return i!==void 0&&i.dnsResolveFn?i.dnsResolveFn:void 0}e.CR_LF=`\r
|
|
98
|
+
`,e.CR_LF_LEN=e.CR_LF.length,e.CRLF=r.DataBuffer.fromAscii(e.CR_LF),e.CR=new Uint8Array(e.CRLF)[0],e.LF=new Uint8Array(e.CRLF)[1];function u(t){for(let n=0;n<t.length;n++){let r=n+1;if(t.byteLength>r&&t[n]===e.CR&&t[r]===e.LF)return r+1}return 0}function d(e){let n=u(e);if(n>0){let r=new Uint8Array(e).slice(0,n);return t.TD.decode(r)}return``}})),Xz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ipV4=u,e.isIP=d,e.parseIP=f;var t=4,n=16,r=48,i=57,a=65,o=70,s=97,c=102,l=16777215;function u(e,t,r,i){let a=new Uint8Array(n);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((e,t)=>{a[t]=e}),a[12]=e,a[13]=t,a[14]=r,a[15]=i,a}function d(e){return f(e)!==void 0}function f(e){for(let t=0;t<e.length;t++)switch(e[t]){case`.`:return p(e);case`:`:return m(e)}}function p(e){let n=new Uint8Array(t);for(let r=0;r<t;r++){if(e.length===0)return;if(r>0){if(e[0]!==`.`)return;e=e.substring(1)}let{n:t,c:i,ok:a}=h(e);if(!a||t>255)return;e=e.substring(i),n[r]=t}return u(n[0],n[1],n[2],n[3])}function m(e){let r=new Uint8Array(n),i=-1;if(e.length>=2&&e[0]===`:`&&e[1]===`:`&&(i=0,e=e.substring(2),e.length===0))return r;let a=0;for(;a<n;){let{n:o,c:s,ok:c}=g(e);if(!c||o>65535)return;if(s<e.length&&e[s]===`.`){if(i<0&&a!=n-t||a+t>n)return;let o=p(e);if(o===void 0)return;r[a]=o[12],r[a+1]=o[13],r[a+2]=o[14],r[a+3]=o[15],e=``,a+=t;break}if(r[a]=o>>8,r[a+1]=o,a+=2,e=e.substring(s),e.length===0)break;if(e[0]!==`:`||e.length==1)return;if(e=e.substring(1),e[0]===`:`){if(i>=0)return;if(i=a,e=e.substring(1),e.length===0)break}}if(e.length===0){if(a<n){if(i<0)return;let e=n-a;for(let t=a-1;t>=i;t--)r[t+e]=r[t];for(let t=i+e-1;t>=i;t--)r[t]=0}else if(i>=0)return;return r}}function h(e){let t=0,n=0;for(t=0;t<e.length&&r<=e.charCodeAt(t)&&e.charCodeAt(t)<=i;t++)if(n=n*10+(e.charCodeAt(t)-r),n>=l)return{n:l,c:t,ok:!1};return t===0?{n:0,c:0,ok:!1}:{n,c:t,ok:!0}}function g(e){let t=0,n=0;for(n=0;n<e.length;n++){if(r<=e.charCodeAt(n)&&e.charCodeAt(n)<=i)t*=16,t+=e.charCodeAt(n)-r;else if(s<=e.charCodeAt(n)&&e.charCodeAt(n)<=c)t*=16,t+=e.charCodeAt(n)-s+10;else if(a<=e.charCodeAt(n)&&e.charCodeAt(n)<=o)t*=16,t+=e.charCodeAt(n)-a+10;else break;if(t>=l)return{n:0,c:n,ok:!1}}return n===0?{n:0,c:n,ok:!1}:{n:t,c:n,ok:!0}}})),Zz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Servers=e.ServerImpl=void 0,e.isIPV4OrHostname=a,e.hostPort=c;var t=Yz(),n=Wz(),r=Xz(),i=qz();function a(e){return e.indexOf(`[`)!==-1||e.indexOf(`::`)!==-1?!1:e.indexOf(`.`)!==-1||e.split(`:`).length<=2}function o(e){return!a(e)}function s(e){let t=e.toUpperCase().indexOf(`::FFFF:`);if(t!==-1&&e.indexOf(`.`)!==-1){let n=e.substring(t+7);return n=n.replace(`[`,``),n.replace(`]`,``)}return e}function c(e){e=e.trim(),e.match(/^(.*:\/\/)(.*)/m)&&(e=e.replace(/^(.*:\/\/)(.*)/gm,`$2`)),e=s(e),o(e)&&e.indexOf(`[`)===-1&&(e=`[${e}]`);let t=o(e)?e.match(/(]:)(\d+)/):e.match(/(:)(\d+)/),n=t&&t.length===3&&t[1]&&t[2]?parseInt(t[2]):i.DEFAULT_PORT,r=new URL(`${n===80?`https`:`http`}://${e}`);r.port=`${n}`;let a=r.hostname;return a.charAt(0)===`[`&&(a=a.substring(1,a.length-1)),{listen:r.host,hostname:a,port:n}}var l=class e{src;listen;hostname;port;didConnect;reconnects;lastConnect;gossiped;tlsName;resolves;constructor(e,t=!1){this.src=e,this.tlsName=``;let n=c(e);this.listen=n.listen,this.hostname=n.hostname,this.port=n.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=t}toString(){return this.listen}async resolve(t){if(!t.fn||t.resolve===!1)return[this];let i=[];if((0,r.isIP)(this.hostname))return[this];{let n=await t.fn(this.hostname);t.debug&&console.log(`resolve ${this.hostname} = ${n.join(`,`)}`);for(let t of n){let n=this.port===80?`https`:`http`,r=new URL(`${n}://${o(t)?`[`+t+`]`:t}`);r.port=`${this.port}`;let a=new e(r.host,!1);a.tlsName=this.hostname,i.push(a)}}return t.randomize&&(0,n.shuffle)(i),this.resolves=i,i}};e.ServerImpl=l,e.Servers=class{firstSelect;servers;currentServer;tlsName;randomize;constructor(e=[],r={}){this.firstSelect=!0,this.servers=[],this.tlsName=``,this.randomize=r.randomize||!1;let a=(0,t.getUrlParseFn)();e&&(e.forEach(e=>{e=a?a(e):e,this.servers.push(new l(e))}),this.randomize&&(this.servers=(0,n.shuffle)(this.servers))),this.servers.length===0&&this.addServer(`${i.DEFAULT_HOST}:${(0,t.defaultPort)()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){let e=this.getCurrentServer();(0,r.isIP)(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(e=>{e.gossiped&&(e.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,n=!1){let i=(0,t.getUrlParseFn)();e=i?i(e):e;let a=new l(e,n);(0,r.isIP)(a.hostname)&&(a.tlsName=this.tlsName),this.servers.push(a)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;let e=this.servers.shift();return e&&(this.servers.push(e),this.currentServer=e),e}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(e){if(e){let t=this.servers.indexOf(e);this.servers.splice(t,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(e,n){let r=[],i=[],a=(0,t.getUrlParseFn)(),o=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(e=>{e=a?a(e,n):e;let t=new l(e,!0);o.set(e,t)});let s=[];return this.servers.forEach((e,t)=>{let n=e.listen;e.gossiped&&this.currentServer.listen!==n&&o.get(n)===void 0&&s.push(t),o.delete(n)}),s.reverse(),s.forEach(e=>{let t=this.servers.splice(e,1);i=i.concat(t[0].listen)}),o.forEach((e,t)=>{this.servers.push(e),r.push(t)}),{added:r,deleted:i}}}})),Qz=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.QueuedIteratorImpl=void 0;var t=Wz(),n=Uz();e.QueuedIteratorImpl=class{inflight;processed;received;noIterator;iterClosed;done;signal;yields;filtered;pendingFiltered;ctx;_data;err;time;profile;yielding;didBreak;constructor(){this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=(0,t.deferred)(),this.yields=[],this.iterClosed=(0,t.deferred)(),this.time=0,this.yielding=!1,this.didBreak=!1,this.profile=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(!this.done){if(this.didBreak){if(typeof e==`function`){let t=e;try{t()}catch{}}return}typeof e==`function`&&this.pendingFiltered++,this.yields.push(e),this.signal.resolve()}}async*iterate(){if(this.noIterator)throw new n.InvalidOperationError(`iterator cannot be used when a callback is registered`);if(this.yielding)throw new n.InvalidOperationError(`iterator is already yielding`);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;let e=this.yields;this.inflight=e.length,this.yields=[];for(let t=0;t<e.length;t++){if(typeof e[t]==`function`){this.pendingFiltered--;let n=e[t];try{n()}catch(e){throw e}if(this.err)throw this.err;continue}this.processed++,this.inflight--;let n=this.profile?Date.now():0;yield e[t],this.time=this.profile?Date.now()-n:0}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=(0,t.deferred)())}}finally{this.didBreak=!0,this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(e))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}})),$z=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MuxSubscription=void 0;var t=qz(),n=Uz();e.MuxSubscription=class{baseInbox;reqs;constructor(){this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${(0,t.createInbox)(e)}.`,this.baseInbox}add(e){isNaN(e.received)||(e.received=0),this.reqs.set(e.token,e)}get(e){return this.reqs.get(e)}cancel(e){this.reqs.delete(e.token)}getToken(e){let t=e.subject||``;return t.indexOf(this.baseInbox)===0?t.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,t){if(e)return this.all().forEach(e=>{e.resolver(t,{})}),!0;if(t.operation===`publish`){let e=this.all().find(e=>e.requestSubject===t.subject);if(e)return e.resolver(t,{}),!0}return!1}dispatcher(){return(e,t)=>{let r=this.getToken(t);if(r){let i=this.get(r);i&&(e===null&&(e=t?.data?.length===0&&t.headers?.code===503?new n.NoRespondersError(i.requestSubject):null),i.resolver(e,t))}}}close(){let e=new n.RequestError(`connection closed`);this.reqs.forEach(t=>{t.resolver(e,{})})}}})),eB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Heartbeat=void 0;var t=Wz();e.Heartbeat=class{ph;interval;maxOut;timer;pendings;constructor(e,t,n){this.ph=e,this.interval=t,this.maxOut=n,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&=(clearTimeout(this.timer),void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:`ping`,pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}let e=(0,t.deferred)();this.ph.flush(e).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(e),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(e=>(e.resolve(),!1))}}})),tB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DenoBuffer=e.MAX_SIZE=e.AssertionError=void 0,e.assert=r,e.concat=o,e.append=s,e.readAll=l,e.writeAll=u;var t=Hz(),n=class extends Error{constructor(e){super(e),this.name=`AssertionError`}};e.AssertionError=n;function r(e,t=`Assertion failed.`){if(!e)throw new n(t)}var i=32*1024;e.MAX_SIZE=2**32-2;function a(e,t,n=0){let r=t.byteLength-n;return e.byteLength>r&&(e=e.subarray(0,r)),t.set(e,n),e.byteLength}function o(e,t){if(e===void 0&&t===void 0)return new Uint8Array;if(e===void 0)return t;if(t===void 0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function s(e,t){return o(e,Uint8Array.of(t))}var c=class{_buf;_off;constructor(e){if(this._off=0,e==null){this._buf=new Uint8Array;return}this._buf=new Uint8Array(e)}bytes(e={copy:!0}){return e.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(e){if(e===0){this.reset();return}if(e<0||e>this.length)throw Error(`bytes.Buffer: truncation out of range`);this._reslice(this._off+e)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(e){let t=this._buf.byteLength;return e<=this.capacity-t?(this._reslice(t+e),t):-1}_reslice(e){r(e<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,e)}readByte(){let e=new Uint8Array(1);return this.read(e)?e[0]:null}read(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;let t=a(this._buf.subarray(this._off),e);return this._off+=t,t}writeByte(e){return this.write(Uint8Array.of(e))}writeString(e){return this.write(t.TE.encode(e))}write(e){let t=this._grow(e.byteLength);return a(e,this._buf,t)}_grow(t){let n=this.length;n===0&&this._off!==0&&this.reset();let r=this._tryGrowByReslice(t);if(r>=0)return r;let i=this.capacity;if(t<=Math.floor(i/2)-n)a(this._buf.subarray(this._off),this._buf);else if(i+t>e.MAX_SIZE)throw Error(`The buffer cannot be grown beyond the maximum size.`);else{let n=new Uint8Array(Math.min(2*i+t,e.MAX_SIZE));a(this._buf.subarray(this._off),n),this._buf=n}return this._off=0,this._reslice(Math.min(n+t,e.MAX_SIZE)),n}grow(e){if(e<0)throw Error(`Buffer._grow: negative count`);let t=this._grow(e);this._reslice(t)}readFrom(e){let t=0,n=new Uint8Array(i);for(;;){let r=this.capacity-this.length<i,a=r?n:new Uint8Array(this._buf.buffer,this.length),o=e.read(a);if(o===null)return t;r?this.write(a.subarray(0,o)):this._reslice(this.length+o),t+=o}}};e.DenoBuffer=c;function l(e){let t=new c;return t.readFrom(e),t.bytes()}function u(e,t){let n=0;for(;n<t.length;)n+=e.write(t.subarray(n))}})),nB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.cc=e.State=e.Parser=e.Kind=void 0,e.describe=r;var t=tB(),n=Hz();e.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function r(t){let r,i=``;switch(t.kind){case e.Kind.MSG:r=`MSG`;break;case e.Kind.OK:r=`OK`;break;case e.Kind.ERR:r=`ERR`,i=n.TD.decode(t.data);break;case e.Kind.PING:r=`PING`;break;case e.Kind.PONG:r=`PONG`;break;case e.Kind.INFO:r=`INFO`,i=n.TD.decode(t.data)}return`${r}: ${i}`}function i(){let e={};return e.sid=-1,e.hdr=-1,e.size=-1,e}var a=48,o=57;e.Parser=class{dispatcher;state;as;drop;hdr;ma;argBuf;msgBuf;constructor(t){this.dispatcher=t,this.state=e.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(n){let r;for(r=0;r<n.length;r++){let t=n[r];switch(this.state){case e.State.OP_START:switch(t){case e.cc.M:case e.cc.m:this.state=e.State.OP_M,this.hdr=-1,this.ma=i();break;case e.cc.H:case e.cc.h:this.state=e.State.OP_H,this.hdr=0,this.ma=i();break;case e.cc.P:case e.cc.p:this.state=e.State.OP_P;break;case e.cc.PLUS:this.state=e.State.OP_PLUS;break;case e.cc.MINUS:this.state=e.State.OP_MINUS;break;case e.cc.I:case e.cc.i:this.state=e.State.OP_I;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_H:switch(t){case e.cc.M:case e.cc.m:this.state=e.State.OP_M;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_M:switch(t){case e.cc.S:case e.cc.s:this.state=e.State.OP_MS;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MS:switch(t){case e.cc.G:case e.cc.g:this.state=e.State.OP_MSG;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MSG:switch(t){case e.cc.SPACE:case e.cc.TAB:this.state=e.State.OP_MSG_SPC;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MSG_SPC:switch(t){case e.cc.SPACE:case e.cc.TAB:continue;default:this.state=e.State.MSG_ARG,this.as=r}break;case e.State.MSG_ARG:switch(t){case e.cc.CR:this.drop=1;break;case e.cc.NL:{let t=this.argBuf?this.argBuf.bytes():n.subarray(this.as,r-this.drop);this.processMsgArgs(t),this.drop=0,this.as=r+1,this.state=e.State.MSG_PAYLOAD,r=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(t)}break;case e.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){let t=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:e.Kind.MSG,msg:this.ma,data:t}),this.argBuf=void 0,this.msgBuf=void 0,this.state=e.State.MSG_END}else{let e=this.ma.size-this.msgBuf.length,i=n.length-r;i<e&&(e=i),e>0?(this.msgBuf.write(n.subarray(r,r+e)),r=r+e-1):this.msgBuf.writeByte(t)}else r-this.as>=this.ma.size&&(this.dispatcher.push({kind:e.Kind.MSG,msg:this.ma,data:n.subarray(this.as,r)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=e.State.MSG_END);break;case e.State.MSG_END:switch(t){case e.cc.NL:this.drop=0,this.as=r+1,this.state=e.State.OP_START;break;default:continue}break;case e.State.OP_PLUS:switch(t){case e.cc.O:case e.cc.o:this.state=e.State.OP_PLUS_O;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PLUS_O:switch(t){case e.cc.K:case e.cc.k:this.state=e.State.OP_PLUS_OK;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PLUS_OK:switch(t){case e.cc.NL:this.dispatcher.push({kind:e.Kind.OK}),this.drop=0,this.state=e.State.OP_START;break}break;case e.State.OP_MINUS:switch(t){case e.cc.E:case e.cc.e:this.state=e.State.OP_MINUS_E;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MINUS_E:switch(t){case e.cc.R:case e.cc.r:this.state=e.State.OP_MINUS_ER;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MINUS_ER:switch(t){case e.cc.R:case e.cc.r:this.state=e.State.OP_MINUS_ERR;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MINUS_ERR:switch(t){case e.cc.SPACE:case e.cc.TAB:this.state=e.State.OP_MINUS_ERR_SPC;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_MINUS_ERR_SPC:switch(t){case e.cc.SPACE:case e.cc.TAB:continue;default:this.state=e.State.MINUS_ERR_ARG,this.as=r}break;case e.State.MINUS_ERR_ARG:switch(t){case e.cc.CR:this.drop=1;break;case e.cc.NL:{let t;this.argBuf?(t=this.argBuf.bytes(),this.argBuf=void 0):t=n.subarray(this.as,r-this.drop),this.dispatcher.push({kind:e.Kind.ERR,data:t}),this.drop=0,this.as=r+1,this.state=e.State.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(t))}break;case e.State.OP_P:switch(t){case e.cc.I:case e.cc.i:this.state=e.State.OP_PI;break;case e.cc.O:case e.cc.o:this.state=e.State.OP_PO;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PO:switch(t){case e.cc.N:case e.cc.n:this.state=e.State.OP_PON;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PON:switch(t){case e.cc.G:case e.cc.g:this.state=e.State.OP_PONG;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PONG:switch(t){case e.cc.NL:this.dispatcher.push({kind:e.Kind.PONG}),this.drop=0,this.state=e.State.OP_START;break}break;case e.State.OP_PI:switch(t){case e.cc.N:case e.cc.n:this.state=e.State.OP_PIN;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PIN:switch(t){case e.cc.G:case e.cc.g:this.state=e.State.OP_PING;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_PING:switch(t){case e.cc.NL:this.dispatcher.push({kind:e.Kind.PING}),this.drop=0,this.state=e.State.OP_START;break}break;case e.State.OP_I:switch(t){case e.cc.N:case e.cc.n:this.state=e.State.OP_IN;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_IN:switch(t){case e.cc.F:case e.cc.f:this.state=e.State.OP_INF;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_INF:switch(t){case e.cc.O:case e.cc.o:this.state=e.State.OP_INFO;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_INFO:switch(t){case e.cc.SPACE:case e.cc.TAB:this.state=e.State.OP_INFO_SPC;break;default:throw this.fail(n.subarray(r))}break;case e.State.OP_INFO_SPC:switch(t){case e.cc.SPACE:case e.cc.TAB:continue;default:this.state=e.State.INFO_ARG,this.as=r}break;case e.State.INFO_ARG:switch(t){case e.cc.CR:this.drop=1;break;case e.cc.NL:{let t;this.argBuf?(t=this.argBuf.bytes(),this.argBuf=void 0):t=n.subarray(this.as,r-this.drop),this.dispatcher.push({kind:e.Kind.INFO,data:t}),this.drop=0,this.as=r+1,this.state=e.State.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(t)}break;default:throw this.fail(n.subarray(r))}}(this.state===e.State.MSG_ARG||this.state===e.State.MINUS_ERR_ARG||this.state===e.State.INFO_ARG)&&!this.argBuf&&(this.argBuf=new t.DenoBuffer(n.subarray(this.as,r-this.drop))),this.state===e.State.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new t.DenoBuffer(n.subarray(this.as)))}cloneMsgArg(){let e=this.ma.subject.length,n=this.ma.reply?this.ma.reply.length:0,r=new Uint8Array(e+n);r.set(this.ma.subject),this.ma.reply&&r.set(this.ma.reply,e),this.argBuf=new t.DenoBuffer(r),this.ma.subject=r.subarray(0,e),this.ma.reply&&(this.ma.reply=r.subarray(e))}processMsgArgs(t){if(this.hdr>=0)return this.processHeaderMsgArgs(t);let n=[],r=-1;for(let i=0;i<t.length;i++)switch(t[i]){case e.cc.SPACE:case e.cc.TAB:case e.cc.CR:case e.cc.NL:r>=0&&(n.push(t.subarray(r,i)),r=-1);break;default:r<0&&(r=i)}switch(r>=0&&n.push(t.subarray(r)),n.length){case 3:this.ma.subject=n[0],this.ma.sid=this.protoParseInt(n[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(n[2]);break;case 4:this.ma.subject=n[0],this.ma.sid=this.protoParseInt(n[1]),this.ma.reply=n[2],this.ma.size=this.protoParseInt(n[3]);break;default:throw this.fail(t,`processMsgArgs Parse Error`)}if(this.ma.sid<0)throw this.fail(t,`processMsgArgs Bad or Missing Sid Error`);if(this.ma.size<0)throw this.fail(t,`processMsgArgs Bad or Missing Size Error`)}fail(e,t=``){return t=t?`${t} [${this.state}]`:`parse error [${this.state}]`,Error(`${t}: ${n.TD.decode(e)}`)}processHeaderMsgArgs(t){let n=[],r=-1;for(let i=0;i<t.length;i++)switch(t[i]){case e.cc.SPACE:case e.cc.TAB:case e.cc.CR:case e.cc.NL:r>=0&&(n.push(t.subarray(r,i)),r=-1);break;default:r<0&&(r=i)}switch(r>=0&&n.push(t.subarray(r)),n.length){case 4:this.ma.subject=n[0],this.ma.sid=this.protoParseInt(n[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(n[2]),this.ma.size=this.protoParseInt(n[3]);break;case 5:this.ma.subject=n[0],this.ma.sid=this.protoParseInt(n[1]),this.ma.reply=n[2],this.ma.hdr=this.protoParseInt(n[3]),this.ma.size=this.protoParseInt(n[4]);break;default:throw this.fail(t,`processHeaderMsgArgs Parse Error`)}if(this.ma.sid<0)throw this.fail(t,`processHeaderMsgArgs Bad or Missing Sid Error`);if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(t,`processHeaderMsgArgs Bad or Missing Header Size Error`);if(this.ma.size<0)throw this.fail(t,`processHeaderMsgArgs Bad or Missing Size Error`)}protoParseInt(e){if(e.length===0)return-1;let t=0;for(let n=0;n<e.length;n++){if(e[n]<a||e[n]>o)return-1;t=t*10+(e[n]-a)}return t}},e.State={OP_START:0,OP_PLUS:1,OP_PLUS_O:2,OP_PLUS_OK:3,OP_MINUS:4,OP_MINUS_E:5,OP_MINUS_ER:6,OP_MINUS_ERR:7,OP_MINUS_ERR_SPC:8,MINUS_ERR_ARG:9,OP_M:10,OP_MS:11,OP_MSG:12,OP_MSG_SPC:13,MSG_ARG:14,MSG_PAYLOAD:15,MSG_END:16,OP_H:17,OP_P:18,OP_PI:19,OP_PIN:20,OP_PING:21,OP_PO:22,OP_PON:23,OP_PONG:24,OP_I:25,OP_IN:26,OP_INF:27,OP_INFO:28,OP_INFO_SPC:29,INFO_ARG:30},e.cc={CR:13,E:69,e:101,F:70,f:102,G:71,g:103,H:72,h:104,I:73,i:105,K:75,k:107,M:77,m:109,MINUS:45,N:78,n:110,NL:10,O:79,o:111,P:80,p:112,PLUS:43,R:82,r:114,S:83,s:115,SPACE:32,TAB:9}})),rB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MsgHdrsImpl=void 0,e.canonicalMIMEHeaderKey=i,e.headers=a;var t=Hz(),n=qz(),r=Uz();function i(e){let t=!0,n=Array(e.length);for(let i=0;i<e.length;i++){let a=e.charCodeAt(i);if(a===58||a<33||a>126)throw r.InvalidArgumentError.format(`header`,`'${e[i]}' is not a valid character in a header name`);t&&97<=a&&a<=122?a-=32:!t&&65<=a&&a<=90&&(a+=32),n[i]=a,t=a==45}return String.fromCharCode(...n)}function a(e=0,t=``){if(e===0&&t!==``)throw r.InvalidArgumentError.format(`code`,`is required`);if(e>0&&t===``)throw r.InvalidArgumentError.format(`description`,`is required`);return new s(e,t)}var o=`NATS/1.0`,s=class e{_code;headers;_description;constructor(e=0,t=``){this._code=e,this._description=t,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(let[t,n]of this.headers){let r=e.values(t);if(n.length!==r.length)return!1;let i=[...n].sort(),a=[...r].sort();for(let e=0;e<i.length;e++)if(i[e]!==a[e])return!1}return!0}return!1}static decode(n){let r=new e,i=t.TD.decode(n).split(`\r
|
|
99
|
+
`),a=i[0];if(a!==o){let e=a.replace(o,``).trim();if(e.length>0){r._code=parseInt(e,10),isNaN(r._code)&&(r._code=0);let t=r._code.toString();e=e.replace(t,``),r._description=e.trim()}}return i.length>=1&&i.slice(1).map(e=>{if(e){let t=e.indexOf(`:`);if(t>-1){let n=e.slice(0,t),i=e.slice(t+1).trim();r.append(n,i)}}}),r}toString(){if(this.headers.size===0&&this._code===0)return``;let e=o;this._code>0&&this._description!==``&&(e+=` ${this._code} ${this._description}`);for(let[t,n]of this.headers)for(let r=0;r<n.length;r++)e=`${e}\r\n${t}: ${n[r]}`;return`${e}\r\n\r\n`}encode(){return t.TE.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw r.InvalidArgumentError.format(`header`,`values cannot contain \\r or \\n`);return e.trim()}keys(){let e=[];for(let t of this.headers.keys())e.push(t);return e}findKeys(e,t=n.Match.Exact){let r=this.keys();switch(t){case n.Match.Exact:return r.filter(t=>t===e);case n.Match.CanonicalMIME:return e=i(e),r.filter(t=>t===e);default:{let t=e.toLowerCase();return r.filter(e=>t===e.toLowerCase())}}}get(e,t=n.Match.Exact){let r=this.findKeys(e,t);if(r.length){let e=this.headers.get(r[0]);if(e)return Array.isArray(e)?e[0]:e}return``}last(e,t=n.Match.Exact){let r=this.findKeys(e,t);if(r.length){let e=this.headers.get(r[0]);if(e)return Array.isArray(e)?e[e.length-1]:e}return``}has(e,t=n.Match.Exact){return this.findKeys(e,t).length>0}set(e,t,r=n.Match.Exact){this.delete(e,r),this.append(e,t,r)}append(t,r,a=n.Match.Exact){let o=i(t);a===n.Match.CanonicalMIME&&(t=o);let s=this.findKeys(t,a);t=s.length>0?s[0]:t;let c=e.validHeaderValue(r),l=this.headers.get(t);l||(l=[],this.headers.set(t,l)),l.push(c)}values(e,t=n.Match.Exact){let r=[];return this.findKeys(e,t).forEach(e=>{let t=this.headers.get(e);t&&r.push(...t)}),r}delete(e,t=n.Match.Exact){this.findKeys(e,t).forEach(e=>{this.headers.delete(e)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){let e={};return this.keys().forEach(t=>{e[t]=this.values(t)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(t){let n=new e;for(let e in t){let r=t[e];n.headers.set(e,Array.isArray(r)?r:[`${r}`])}return n}};e.MsgHdrsImpl=s})),iB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MsgImpl=void 0;var t=rB(),n=Hz();e.MsgImpl=class{_headers;_msg;_rdata;_reply;_subject;publisher;constructor(e,t,n){this._msg=e,this._rdata=t,this.publisher=n}get subject(){return this._subject||=n.TD.decode(this._msg.subject),this._subject}get reply(){return this._reply||=n.TD.decode(this._msg.reply),this._reply}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){let e=this._rdata.subarray(0,this._msg.hdr);this._headers=t.MsgHdrsImpl.decode(e)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array}respond(e=n.Empty,t){return this.reply?(this.publisher.publish(this.reply,e,t),!0):!1}size(){let e=this._msg.subject.length,t=this._msg.reply?.length||0,n=this._msg.size===-1?0:this._msg.size;return e+t+n}json(e){return JSON.parse(this.string(),e)}string(){return n.TD.decode(this.data)}requestInfo(){let e=this.headers?.get(`Nats-Request-Info`);return e?JSON.parse(e,function(e,t){return(e===`start`||e===`stop`)&&t!==``?new Date(Date.parse(t)):t}):null}}})),aB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Features=e.Feature=void 0,e.parseSemVer=t,e.compare=n;function t(e=``){let t=e.match(/(\d+).(\d+).(\d+)/);if(t)return{major:parseInt(t[1]),minor:parseInt(t[2]),micro:parseInt(t[3])};throw Error(`'${e}' is not a semver value`)}function n(e,t){return e.major<t.major?-1:e.major>t.major?1:e.minor<t.minor?-1:e.minor>t.minor?1:e.micro<t.micro?-1:e.micro>t.micro?1:0}e.Feature={JS_KV:`js_kv`,JS_OBJECTSTORE:`js_objectstore`,JS_PULL_MAX_BYTES:`js_pull_max_bytes`,JS_NEW_CONSUMER_CREATE_API:`js_new_consumer_create`,JS_ALLOW_DIRECT:`js_allow_direct`,JS_MULTIPLE_CONSUMER_FILTER:`js_multiple_consumer_filter`,JS_SIMPLIFICATION:`js_simplification`,JS_STREAM_CONSUMER_METADATA:`js_stream_consumer_metadata`,JS_CONSUMER_FILTER_SUBJECTS:`js_consumer_filter_subjects`,JS_STREAM_FIRST_SEQ:`js_stream_first_seq`,JS_STREAM_SUBJECT_TRANSFORM:`js_stream_subject_transform`,JS_STREAM_SOURCE_SUBJECT_TRANSFORM:`js_stream_source_subject_transform`,JS_STREAM_COMPRESSION:`js_stream_compression`,JS_DEFAULT_CONSUMER_LIMITS:`js_default_consumer_limits`,JS_BATCH_DIRECT_GET:`js_batch_direct_get`,JS_PRIORITY_GROUPS:`js_priority_groups`},e.Features=class{server;features;disabled;constructor(e){this.features=new Map,this.disabled=[],this.update(e)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(e){this.disabled.push(e),this.update(this.server)}isDisabled(e){return this.disabled.indexOf(e)!==-1}update(n){typeof n==`string`&&(n=t(n)),this.server=n,this.set(e.Feature.JS_KV,`2.6.2`),this.set(e.Feature.JS_OBJECTSTORE,`2.6.3`),this.set(e.Feature.JS_PULL_MAX_BYTES,`2.8.3`),this.set(e.Feature.JS_NEW_CONSUMER_CREATE_API,`2.9.0`),this.set(e.Feature.JS_ALLOW_DIRECT,`2.9.0`),this.set(e.Feature.JS_MULTIPLE_CONSUMER_FILTER,`2.10.0`),this.set(e.Feature.JS_SIMPLIFICATION,`2.9.4`),this.set(e.Feature.JS_STREAM_CONSUMER_METADATA,`2.10.0`),this.set(e.Feature.JS_CONSUMER_FILTER_SUBJECTS,`2.10.0`),this.set(e.Feature.JS_STREAM_FIRST_SEQ,`2.10.0`),this.set(e.Feature.JS_STREAM_SUBJECT_TRANSFORM,`2.10.0`),this.set(e.Feature.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,`2.10.0`),this.set(e.Feature.JS_STREAM_COMPRESSION,`2.10.0`),this.set(e.Feature.JS_DEFAULT_CONSUMER_LIMITS,`2.10.0`),this.set(e.Feature.JS_BATCH_DIRECT_GET,`2.11.0`),this.set(e.Feature.JS_PRIORITY_GROUPS,`2.11.0`),this.disabled.forEach(e=>{this.features.delete(e)})}set(e,r){this.features.set(e,{min:r,ok:n(this.server,t(r))>=0})}get(e){return this.features.get(e)||{min:`unknown`,ok:!1}}supports(e){return this.get(e)?.ok||!1}require(e){return typeof e==`string`&&(e=t(e)),n(this.server,e)>=0}}})),oB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.crc16=void 0;var t=new Uint16Array([0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920]);e.crc16=class e{static checksum(e){let n=0;for(let r=0;r<e.byteLength;r++){let i=e[r];n=n<<8&65535^t[(n>>8^i)&255]}return n}static validate(t,n){return e.checksum(t)==n}}})),sB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.base32=void 0;var t=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`;e.base32=class{static encode(e){let n=0,r=0,i=new Uint8Array(e),a=new Uint8Array(e.byteLength*2),o=0;for(let e=0;e<i.byteLength;e++)for(r=r<<8|i[e],n+=8;n>=5;){let e=r>>>n-5&31;a[o++]=t.charAt(e).charCodeAt(0),n-=5}if(n>0){let e=r<<5-n&31;a[o++]=t.charAt(e).charCodeAt(0)}return a.slice(0,o)}static decode(e){let n=0,r=0,i=0,a=new Uint8Array(e),o=new Uint8Array(a.byteLength*5/8|0);for(let e=0;e<a.byteLength;e++){let s=String.fromCharCode(a[e]),c=t.indexOf(s);if(c===-1)throw Error(`Illegal Base32 character: `+a[e]);r=r<<5|c,n+=5,n>=8&&(o[i++]=r>>>n-8&255,n-=8)}return o.slice(0,i)}}})),cB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Codec=void 0;var t=oB(),n=hB(),r=sB();e.Codec=class e{static encode(t,r){if(!r||!(r instanceof Uint8Array))throw new n.NKeysError(n.NKeysErrorCode.SerializationError);if(!n.Prefixes.isValidPrefix(t))throw new n.NKeysError(n.NKeysErrorCode.InvalidPrefixByte);return e._encode(!1,t,r)}static encodeSeed(t,r){if(!r)throw new n.NKeysError(n.NKeysErrorCode.ApiError);if(!n.Prefixes.isValidPublicPrefix(t))throw new n.NKeysError(n.NKeysErrorCode.InvalidPrefixByte);if(r.byteLength!==32)throw new n.NKeysError(n.NKeysErrorCode.InvalidSeedLen);return e._encode(!0,t,r)}static decode(t,r){if(!n.Prefixes.isValidPrefix(t))throw new n.NKeysError(n.NKeysErrorCode.InvalidPrefixByte);let i=e._decode(r);if(i[0]!==t)throw new n.NKeysError(n.NKeysErrorCode.InvalidPrefixByte);return i.slice(1)}static decodeSeed(t){let r=e._decode(t),i=e._decodePrefix(r);if(i[0]!=n.Prefix.Seed)throw new n.NKeysError(n.NKeysErrorCode.InvalidSeed);if(!n.Prefixes.isValidPublicPrefix(i[1]))throw new n.NKeysError(n.NKeysErrorCode.InvalidPrefixByte);return{buf:r.slice(2),prefix:i[1]}}static _encode(i,a,o){let s=i?2:1,c=o.byteLength,l=s+c+2,u=s+c,d=new Uint8Array(l);if(i){let t=e._encodePrefix(n.Prefix.Seed,a);d.set(t)}else d[0]=a;d.set(o,s);let f=t.crc16.checksum(d.slice(0,u));return new DataView(d.buffer).setUint16(u,f,!0),r.base32.encode(d)}static _decode(e){if(e.byteLength<4)throw new n.NKeysError(n.NKeysErrorCode.InvalidEncoding);let i;try{i=r.base32.decode(e)}catch(e){throw new n.NKeysError(n.NKeysErrorCode.InvalidEncoding,{cause:e})}let a=i.byteLength-2,o=new DataView(i.buffer).getUint16(a,!0),s=i.slice(0,a);if(!t.crc16.validate(s,o))throw new n.NKeysError(n.NKeysErrorCode.InvalidChecksum);return s}static _encodePrefix(e,t){let n=e|t>>5,r=(t&31)<<3;return new Uint8Array([n,r])}static _decodePrefix(e){let t=e[0]&248,n=(e[0]&7)<<5|(e[1]&248)>>3;return new Uint8Array([t,n])}}})),lB=r(((e,t)=>{t.exports={}})),uB=r(((t,n)=>{(function(t){var n=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},r=function(){throw Error(`no PRNG`)},i=new Uint8Array(16),a=new Uint8Array(32);a[0]=9;var o=n(),s=n([1]),c=n([56129,1]),l=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),f=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=n&255,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=r&255}function h(e,t,n,r,i){var a,o=0;for(a=0;a<i;a++)o|=e[t+a]^n[r+a];return(1&o-1>>>8)-1}function g(e,t,n,r){return h(e,t,n,r,16)}function _(e,t,n,r){return h(e,t,n,r,32)}function v(e,t,n,r){for(var i=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,a=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,o=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,s=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,c=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,l=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,u=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,d=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,f=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,p=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,m=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,h=n[16]&255|(n[17]&255)<<8|(n[18]&255)<<16|(n[19]&255)<<24,g=n[20]&255|(n[21]&255)<<8|(n[22]&255)<<16|(n[23]&255)<<24,_=n[24]&255|(n[25]&255)<<8|(n[26]&255)<<16|(n[27]&255)<<24,v=n[28]&255|(n[29]&255)<<8|(n[30]&255)<<16|(n[31]&255)<<24,y=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,b=i,x=a,S=o,C=s,w=c,T=l,E=u,D=d,O=f,k=p,A=m,j=h,M=g,N=_,P=v,F=y,I,L=0;L<20;L+=2)I=b+M|0,w^=I<<7|I>>>25,I=w+b|0,O^=I<<9|I>>>23,I=O+w|0,M^=I<<13|I>>>19,I=M+O|0,b^=I<<18|I>>>14,I=T+x|0,k^=I<<7|I>>>25,I=k+T|0,N^=I<<9|I>>>23,I=N+k|0,x^=I<<13|I>>>19,I=x+N|0,T^=I<<18|I>>>14,I=A+E|0,P^=I<<7|I>>>25,I=P+A|0,S^=I<<9|I>>>23,I=S+P|0,E^=I<<13|I>>>19,I=E+S|0,A^=I<<18|I>>>14,I=F+j|0,C^=I<<7|I>>>25,I=C+F|0,D^=I<<9|I>>>23,I=D+C|0,j^=I<<13|I>>>19,I=j+D|0,F^=I<<18|I>>>14,I=b+C|0,x^=I<<7|I>>>25,I=x+b|0,S^=I<<9|I>>>23,I=S+x|0,C^=I<<13|I>>>19,I=C+S|0,b^=I<<18|I>>>14,I=T+w|0,E^=I<<7|I>>>25,I=E+T|0,D^=I<<9|I>>>23,I=D+E|0,w^=I<<13|I>>>19,I=w+D|0,T^=I<<18|I>>>14,I=A+k|0,j^=I<<7|I>>>25,I=j+A|0,O^=I<<9|I>>>23,I=O+j|0,k^=I<<13|I>>>19,I=k+O|0,A^=I<<18|I>>>14,I=F+P|0,M^=I<<7|I>>>25,I=M+F|0,N^=I<<9|I>>>23,I=N+M|0,P^=I<<13|I>>>19,I=P+N|0,F^=I<<18|I>>>14;b=b+i|0,x=x+a|0,S=S+o|0,C=C+s|0,w=w+c|0,T=T+l|0,E=E+u|0,D=D+d|0,O=O+f|0,k=k+p|0,A=A+m|0,j=j+h|0,M=M+g|0,N=N+_|0,P=P+v|0,F=F+y|0,e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=x>>>0&255,e[5]=x>>>8&255,e[6]=x>>>16&255,e[7]=x>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=C>>>0&255,e[13]=C>>>8&255,e[14]=C>>>16&255,e[15]=C>>>24&255,e[16]=w>>>0&255,e[17]=w>>>8&255,e[18]=w>>>16&255,e[19]=w>>>24&255,e[20]=T>>>0&255,e[21]=T>>>8&255,e[22]=T>>>16&255,e[23]=T>>>24&255,e[24]=E>>>0&255,e[25]=E>>>8&255,e[26]=E>>>16&255,e[27]=E>>>24&255,e[28]=D>>>0&255,e[29]=D>>>8&255,e[30]=D>>>16&255,e[31]=D>>>24&255,e[32]=O>>>0&255,e[33]=O>>>8&255,e[34]=O>>>16&255,e[35]=O>>>24&255,e[36]=k>>>0&255,e[37]=k>>>8&255,e[38]=k>>>16&255,e[39]=k>>>24&255,e[40]=A>>>0&255,e[41]=A>>>8&255,e[42]=A>>>16&255,e[43]=A>>>24&255,e[44]=j>>>0&255,e[45]=j>>>8&255,e[46]=j>>>16&255,e[47]=j>>>24&255,e[48]=M>>>0&255,e[49]=M>>>8&255,e[50]=M>>>16&255,e[51]=M>>>24&255,e[52]=N>>>0&255,e[53]=N>>>8&255,e[54]=N>>>16&255,e[55]=N>>>24&255,e[56]=P>>>0&255,e[57]=P>>>8&255,e[58]=P>>>16&255,e[59]=P>>>24&255,e[60]=F>>>0&255,e[61]=F>>>8&255,e[62]=F>>>16&255,e[63]=F>>>24&255}function y(e,t,n,r){for(var i=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,a=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,o=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,s=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,c=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,l=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,u=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,d=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,f=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,p=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,m=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,h=n[16]&255|(n[17]&255)<<8|(n[18]&255)<<16|(n[19]&255)<<24,g=n[20]&255|(n[21]&255)<<8|(n[22]&255)<<16|(n[23]&255)<<24,_=n[24]&255|(n[25]&255)<<8|(n[26]&255)<<16|(n[27]&255)<<24,v=n[28]&255|(n[29]&255)<<8|(n[30]&255)<<16|(n[31]&255)<<24,y=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,b=i,x=a,S=o,C=s,w=c,T=l,E=u,D=d,O=f,k=p,A=m,j=h,M=g,N=_,P=v,F=y,I,L=0;L<20;L+=2)I=b+M|0,w^=I<<7|I>>>25,I=w+b|0,O^=I<<9|I>>>23,I=O+w|0,M^=I<<13|I>>>19,I=M+O|0,b^=I<<18|I>>>14,I=T+x|0,k^=I<<7|I>>>25,I=k+T|0,N^=I<<9|I>>>23,I=N+k|0,x^=I<<13|I>>>19,I=x+N|0,T^=I<<18|I>>>14,I=A+E|0,P^=I<<7|I>>>25,I=P+A|0,S^=I<<9|I>>>23,I=S+P|0,E^=I<<13|I>>>19,I=E+S|0,A^=I<<18|I>>>14,I=F+j|0,C^=I<<7|I>>>25,I=C+F|0,D^=I<<9|I>>>23,I=D+C|0,j^=I<<13|I>>>19,I=j+D|0,F^=I<<18|I>>>14,I=b+C|0,x^=I<<7|I>>>25,I=x+b|0,S^=I<<9|I>>>23,I=S+x|0,C^=I<<13|I>>>19,I=C+S|0,b^=I<<18|I>>>14,I=T+w|0,E^=I<<7|I>>>25,I=E+T|0,D^=I<<9|I>>>23,I=D+E|0,w^=I<<13|I>>>19,I=w+D|0,T^=I<<18|I>>>14,I=A+k|0,j^=I<<7|I>>>25,I=j+A|0,O^=I<<9|I>>>23,I=O+j|0,k^=I<<13|I>>>19,I=k+O|0,A^=I<<18|I>>>14,I=F+P|0,M^=I<<7|I>>>25,I=M+F|0,N^=I<<9|I>>>23,I=N+M|0,P^=I<<13|I>>>19,I=P+N|0,F^=I<<18|I>>>14;e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=T>>>0&255,e[5]=T>>>8&255,e[6]=T>>>16&255,e[7]=T>>>24&255,e[8]=A>>>0&255,e[9]=A>>>8&255,e[10]=A>>>16&255,e[11]=A>>>24&255,e[12]=F>>>0&255,e[13]=F>>>8&255,e[14]=F>>>16&255,e[15]=F>>>24&255,e[16]=E>>>0&255,e[17]=E>>>8&255,e[18]=E>>>16&255,e[19]=E>>>24&255,e[20]=D>>>0&255,e[21]=D>>>8&255,e[22]=D>>>16&255,e[23]=D>>>24&255,e[24]=O>>>0&255,e[25]=O>>>8&255,e[26]=O>>>16&255,e[27]=O>>>24&255,e[28]=k>>>0&255,e[29]=k>>>8&255,e[30]=k>>>16&255,e[31]=k>>>24&255}function b(e,t,n,r){v(e,t,n,r)}function x(e,t,n,r){y(e,t,n,r)}var S=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function C(e,t,n,r,i,a,o){var s=new Uint8Array(16),c=new Uint8Array(64),l,u;for(u=0;u<16;u++)s[u]=0;for(u=0;u<8;u++)s[u]=a[u];for(;i>=64;){for(b(c,s,o,S),u=0;u<64;u++)e[t+u]=n[r+u]^c[u];for(l=1,u=8;u<16;u++)l=l+(s[u]&255)|0,s[u]=l&255,l>>>=8;i-=64,t+=64,r+=64}if(i>0)for(b(c,s,o,S),u=0;u<i;u++)e[t+u]=n[r+u]^c[u];return 0}function w(e,t,n,r,i){var a=new Uint8Array(16),o=new Uint8Array(64),s,c;for(c=0;c<16;c++)a[c]=0;for(c=0;c<8;c++)a[c]=r[c];for(;n>=64;){for(b(o,a,i,S),c=0;c<64;c++)e[t+c]=o[c];for(s=1,c=8;c<16;c++)s=s+(a[c]&255)|0,a[c]=s&255,s>>>=8;n-=64,t+=64}if(n>0)for(b(o,a,i,S),c=0;c<n;c++)e[t+c]=o[c];return 0}function T(e,t,n,r,i){var a=new Uint8Array(32);x(a,r,i,S);for(var o=new Uint8Array(8),s=0;s<8;s++)o[s]=r[s+16];return w(e,t,n,o,a)}function E(e,t,n,r,i,a,o){var s=new Uint8Array(32);x(s,a,o,S);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=a[l+16];return C(e,t,n,r,i,c,s)}var D=function(e){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var t=e[0]&255|(e[1]&255)<<8,n,r,i,a,o,s,c;this.r[0]=t&8191,n=e[2]&255|(e[3]&255)<<8,this.r[1]=(t>>>13|n<<3)&8191,r=e[4]&255|(e[5]&255)<<8,this.r[2]=(n>>>10|r<<6)&7939,i=e[6]&255|(e[7]&255)<<8,this.r[3]=(r>>>7|i<<9)&8191,a=e[8]&255|(e[9]&255)<<8,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,o=e[10]&255|(e[11]&255)<<8,this.r[6]=(a>>>14|o<<2)&8191,s=e[12]&255|(e[13]&255)<<8,this.r[7]=(o>>>11|s<<5)&8065,c=e[14]&255|(e[15]&255)<<8,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127,this.pad[0]=e[16]&255|(e[17]&255)<<8,this.pad[1]=e[18]&255|(e[19]&255)<<8,this.pad[2]=e[20]&255|(e[21]&255)<<8,this.pad[3]=e[22]&255|(e[23]&255)<<8,this.pad[4]=e[24]&255|(e[25]&255)<<8,this.pad[5]=e[26]&255|(e[27]&255)<<8,this.pad[6]=e[28]&255|(e[29]&255)<<8,this.pad[7]=e[30]&255|(e[31]&255)<<8};D.prototype.blocks=function(e,t,n){for(var r=this.fin?0:2048,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C=this.h[0],w=this.h[1],T=this.h[2],E=this.h[3],D=this.h[4],O=this.h[5],k=this.h[6],A=this.h[7],j=this.h[8],M=this.h[9],N=this.r[0],P=this.r[1],F=this.r[2],I=this.r[3],L=this.r[4],R=this.r[5],z=this.r[6],B=this.r[7],V=this.r[8],H=this.r[9];n>=16;)i=e[t+0]&255|(e[t+1]&255)<<8,C+=i&8191,a=e[t+2]&255|(e[t+3]&255)<<8,w+=(i>>>13|a<<3)&8191,o=e[t+4]&255|(e[t+5]&255)<<8,T+=(a>>>10|o<<6)&8191,s=e[t+6]&255|(e[t+7]&255)<<8,E+=(o>>>7|s<<9)&8191,c=e[t+8]&255|(e[t+9]&255)<<8,D+=(s>>>4|c<<12)&8191,O+=c>>>1&8191,l=e[t+10]&255|(e[t+11]&255)<<8,k+=(c>>>14|l<<2)&8191,u=e[t+12]&255|(e[t+13]&255)<<8,A+=(l>>>11|u<<5)&8191,d=e[t+14]&255|(e[t+15]&255)<<8,j+=(u>>>8|d<<8)&8191,M+=d>>>5|r,f=0,p=f,p+=C*N,p+=5*H*w,p+=5*V*T,p+=5*B*E,p+=5*z*D,f=p>>>13,p&=8191,p+=5*R*O,p+=5*L*k,p+=5*I*A,p+=5*F*j,p+=5*P*M,f+=p>>>13,p&=8191,m=f,m+=C*P,m+=w*N,m+=5*H*T,m+=5*V*E,m+=5*B*D,f=m>>>13,m&=8191,m+=5*z*O,m+=5*R*k,m+=5*L*A,m+=5*I*j,m+=5*F*M,f+=m>>>13,m&=8191,h=f,h+=C*F,h+=w*P,h+=T*N,h+=5*H*E,h+=5*V*D,f=h>>>13,h&=8191,h+=5*B*O,h+=5*z*k,h+=5*R*A,h+=5*L*j,h+=5*I*M,f+=h>>>13,h&=8191,g=f,g+=C*I,g+=w*F,g+=T*P,g+=E*N,g+=5*H*D,f=g>>>13,g&=8191,g+=5*V*O,g+=5*B*k,g+=5*z*A,g+=5*R*j,g+=5*L*M,f+=g>>>13,g&=8191,_=f,_+=C*L,_+=w*I,_+=T*F,_+=E*P,_+=D*N,f=_>>>13,_&=8191,_+=5*H*O,_+=5*V*k,_+=5*B*A,_+=5*z*j,_+=5*R*M,f+=_>>>13,_&=8191,v=f,v+=C*R,v+=w*L,v+=T*I,v+=E*F,v+=D*P,f=v>>>13,v&=8191,v+=O*N,v+=5*H*k,v+=5*V*A,v+=5*B*j,v+=5*z*M,f+=v>>>13,v&=8191,y=f,y+=C*z,y+=w*R,y+=T*L,y+=E*I,y+=D*F,f=y>>>13,y&=8191,y+=O*P,y+=k*N,y+=5*H*A,y+=5*V*j,y+=5*B*M,f+=y>>>13,y&=8191,b=f,b+=C*B,b+=w*z,b+=T*R,b+=E*L,b+=D*I,f=b>>>13,b&=8191,b+=O*F,b+=k*P,b+=A*N,b+=5*H*j,b+=5*V*M,f+=b>>>13,b&=8191,x=f,x+=C*V,x+=w*B,x+=T*z,x+=E*R,x+=D*L,f=x>>>13,x&=8191,x+=O*I,x+=k*F,x+=A*P,x+=j*N,x+=5*H*M,f+=x>>>13,x&=8191,S=f,S+=C*H,S+=w*V,S+=T*B,S+=E*z,S+=D*R,f=S>>>13,S&=8191,S+=O*L,S+=k*I,S+=A*F,S+=j*P,S+=M*N,f+=S>>>13,S&=8191,f=(f<<2)+f|0,f=f+p|0,p=f&8191,f>>>=13,m+=f,C=p,w=m,T=h,E=g,D=_,O=v,k=y,A=b,j=x,M=S,t+=16,n-=16;this.h[0]=C,this.h[1]=w,this.h[2]=T,this.h[3]=E,this.h[4]=D,this.h[5]=O,this.h[6]=k,this.h[7]=A,this.h[8]=j,this.h[9]=M},D.prototype.finish=function(e,t){var n=new Uint16Array(10),r,i,a,o;if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=r*5,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,n[0]=this.h[0]+5,r=n[0]>>>13,n[0]&=8191,o=1;o<10;o++)n[o]=this.h[o]+r,r=n[o]>>>13,n[o]&=8191;for(n[9]-=8192,i=(r^1)-1,o=0;o<10;o++)n[o]&=i;for(i=~i,o=0;o<10;o++)this.h[o]=this.h[o]&i|n[o];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,a=this.h[0]+this.pad[0],this.h[0]=a&65535,o=1;o<8;o++)a=(this.h[o]+this.pad[o]|0)+(a>>>16)|0,this.h[o]=a&65535;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},D.prototype.update=function(e,t,n){var r,i;if(this.leftover){for(i=16-this.leftover,i>n&&(i=n),r=0;r<i;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(i=n-n%16,this.blocks(e,t,i),t+=i,n-=i),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};function O(e,t,n,r,i,a){var o=new D(a);return o.update(n,r,i),o.finish(e,t),0}function k(e,t,n,r,i,a){var o=new Uint8Array(16);return O(o,0,n,r,i,a),g(e,t,o,0)}function A(e,t,n,r,i){var a;if(n<32)return-1;for(E(e,0,t,0,n,r,i),O(e,16,e,32,n-32,e),a=0;a<16;a++)e[a]=0;return 0}function j(e,t,n,r,i){var a,o=new Uint8Array(32);if(n<32||(T(o,0,32,r,i),k(t,16,t,32,n-32,o)!==0))return-1;for(E(e,0,t,0,n,r,i),a=0;a<32;a++)e[a]=0;return 0}function M(e,t){var n;for(n=0;n<16;n++)e[n]=t[n]|0}function N(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-r*65536;e[0]+=r-1+37*(r-1)}function P(e,t,n){for(var r,i=~(n-1),a=0;a<16;a++)r=i&(e[a]^t[a]),e[a]^=r,t[a]^=r}function F(e,t){var r,i,a,o=n(),s=n();for(r=0;r<16;r++)s[r]=t[r];for(N(s),N(s),N(s),i=0;i<2;i++){for(o[0]=s[0]-65517,r=1;r<15;r++)o[r]=s[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=s[15]-32767-(o[14]>>16&1),a=o[15]>>16&1,o[14]&=65535,P(s,o,1-a)}for(r=0;r<16;r++)e[2*r]=s[r]&255,e[2*r+1]=s[r]>>8}function I(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return F(n,e),F(r,t),_(n,0,r,0)}function L(e){var t=new Uint8Array(32);return F(t,e),t[0]&1}function R(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function z(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function B(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function V(e,t,n){var r,i,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=0,M=0,N=0,P=0,F=0,I=n[0],L=n[1],R=n[2],z=n[3],B=n[4],V=n[5],H=n[6],U=n[7],W=n[8],G=n[9],K=n[10],q=n[11],J=n[12],ee=n[13],Y=n[14],te=n[15];r=t[0],a+=r*I,o+=r*L,s+=r*R,c+=r*z,l+=r*B,u+=r*V,d+=r*H,f+=r*U,p+=r*W,m+=r*G,h+=r*K,g+=r*q,_+=r*J,v+=r*ee,y+=r*Y,b+=r*te,r=t[1],o+=r*I,s+=r*L,c+=r*R,l+=r*z,u+=r*B,d+=r*V,f+=r*H,p+=r*U,m+=r*W,h+=r*G,g+=r*K,_+=r*q,v+=r*J,y+=r*ee,b+=r*Y,x+=r*te,r=t[2],s+=r*I,c+=r*L,l+=r*R,u+=r*z,d+=r*B,f+=r*V,p+=r*H,m+=r*U,h+=r*W,g+=r*G,_+=r*K,v+=r*q,y+=r*J,b+=r*ee,x+=r*Y,S+=r*te,r=t[3],c+=r*I,l+=r*L,u+=r*R,d+=r*z,f+=r*B,p+=r*V,m+=r*H,h+=r*U,g+=r*W,_+=r*G,v+=r*K,y+=r*q,b+=r*J,x+=r*ee,S+=r*Y,C+=r*te,r=t[4],l+=r*I,u+=r*L,d+=r*R,f+=r*z,p+=r*B,m+=r*V,h+=r*H,g+=r*U,_+=r*W,v+=r*G,y+=r*K,b+=r*q,x+=r*J,S+=r*ee,C+=r*Y,w+=r*te,r=t[5],u+=r*I,d+=r*L,f+=r*R,p+=r*z,m+=r*B,h+=r*V,g+=r*H,_+=r*U,v+=r*W,y+=r*G,b+=r*K,x+=r*q,S+=r*J,C+=r*ee,w+=r*Y,T+=r*te,r=t[6],d+=r*I,f+=r*L,p+=r*R,m+=r*z,h+=r*B,g+=r*V,_+=r*H,v+=r*U,y+=r*W,b+=r*G,x+=r*K,S+=r*q,C+=r*J,w+=r*ee,T+=r*Y,E+=r*te,r=t[7],f+=r*I,p+=r*L,m+=r*R,h+=r*z,g+=r*B,_+=r*V,v+=r*H,y+=r*U,b+=r*W,x+=r*G,S+=r*K,C+=r*q,w+=r*J,T+=r*ee,E+=r*Y,D+=r*te,r=t[8],p+=r*I,m+=r*L,h+=r*R,g+=r*z,_+=r*B,v+=r*V,y+=r*H,b+=r*U,x+=r*W,S+=r*G,C+=r*K,w+=r*q,T+=r*J,E+=r*ee,D+=r*Y,O+=r*te,r=t[9],m+=r*I,h+=r*L,g+=r*R,_+=r*z,v+=r*B,y+=r*V,b+=r*H,x+=r*U,S+=r*W,C+=r*G,w+=r*K,T+=r*q,E+=r*J,D+=r*ee,O+=r*Y,k+=r*te,r=t[10],h+=r*I,g+=r*L,_+=r*R,v+=r*z,y+=r*B,b+=r*V,x+=r*H,S+=r*U,C+=r*W,w+=r*G,T+=r*K,E+=r*q,D+=r*J,O+=r*ee,k+=r*Y,A+=r*te,r=t[11],g+=r*I,_+=r*L,v+=r*R,y+=r*z,b+=r*B,x+=r*V,S+=r*H,C+=r*U,w+=r*W,T+=r*G,E+=r*K,D+=r*q,O+=r*J,k+=r*ee,A+=r*Y,j+=r*te,r=t[12],_+=r*I,v+=r*L,y+=r*R,b+=r*z,x+=r*B,S+=r*V,C+=r*H,w+=r*U,T+=r*W,E+=r*G,D+=r*K,O+=r*q,k+=r*J,A+=r*ee,j+=r*Y,M+=r*te,r=t[13],v+=r*I,y+=r*L,b+=r*R,x+=r*z,S+=r*B,C+=r*V,w+=r*H,T+=r*U,E+=r*W,D+=r*G,O+=r*K,k+=r*q,A+=r*J,j+=r*ee,M+=r*Y,N+=r*te,r=t[14],y+=r*I,b+=r*L,x+=r*R,S+=r*z,C+=r*B,w+=r*V,T+=r*H,E+=r*U,D+=r*W,O+=r*G,k+=r*K,A+=r*q,j+=r*J,M+=r*ee,N+=r*Y,P+=r*te,r=t[15],b+=r*I,x+=r*L,S+=r*R,C+=r*z,w+=r*B,T+=r*V,E+=r*H,D+=r*U,O+=r*W,k+=r*G,A+=r*K,j+=r*q,M+=r*J,N+=r*ee,P+=r*Y,F+=r*te,a+=38*x,o+=38*S,s+=38*C,c+=38*w,l+=38*T,u+=38*E,d+=38*D,f+=38*O,p+=38*k,m+=38*A,h+=38*j,g+=38*M,_+=38*N,v+=38*P,y+=38*F,i=1,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=o+i+65535,i=Math.floor(r/65536),o=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=m+i+65535,i=Math.floor(r/65536),m=r-i*65536,r=h+i+65535,i=Math.floor(r/65536),h=r-i*65536,r=g+i+65535,i=Math.floor(r/65536),g=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=v+i+65535,i=Math.floor(r/65536),v=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=b+i+65535,i=Math.floor(r/65536),b=r-i*65536,a+=i-1+37*(i-1),i=1,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=o+i+65535,i=Math.floor(r/65536),o=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=m+i+65535,i=Math.floor(r/65536),m=r-i*65536,r=h+i+65535,i=Math.floor(r/65536),h=r-i*65536,r=g+i+65535,i=Math.floor(r/65536),g=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=v+i+65535,i=Math.floor(r/65536),v=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=b+i+65535,i=Math.floor(r/65536),b=r-i*65536,a+=i-1+37*(i-1),e[0]=a,e[1]=o,e[2]=s,e[3]=c,e[4]=l,e[5]=u,e[6]=d,e[7]=f,e[8]=p,e[9]=m,e[10]=h,e[11]=g,e[12]=_,e[13]=v,e[14]=y,e[15]=b}function H(e,t){V(e,t,t)}function U(e,t){var r=n(),i;for(i=0;i<16;i++)r[i]=t[i];for(i=253;i>=0;i--)H(r,r),i!==2&&i!==4&&V(r,r,t);for(i=0;i<16;i++)e[i]=r[i]}function W(e,t){var r=n(),i;for(i=0;i<16;i++)r[i]=t[i];for(i=250;i>=0;i--)H(r,r),i!==1&&V(r,r,t);for(i=0;i<16;i++)e[i]=r[i]}function G(e,t,r){var i=new Uint8Array(32),a=new Float64Array(80),o,s,l=n(),u=n(),d=n(),f=n(),p=n(),m=n();for(s=0;s<31;s++)i[s]=t[s];for(i[31]=t[31]&127|64,i[0]&=248,R(a,r),s=0;s<16;s++)u[s]=a[s],f[s]=l[s]=d[s]=0;for(l[0]=f[0]=1,s=254;s>=0;--s)o=i[s>>>3]>>>(s&7)&1,P(l,u,o),P(d,f,o),z(p,l,d),B(l,l,d),z(d,u,f),B(u,u,f),H(f,p),H(m,l),V(l,d,l),V(d,u,p),z(p,l,d),B(l,l,d),H(u,l),B(d,f,m),V(l,d,c),z(l,l,f),V(d,d,l),V(l,f,m),V(f,u,a),H(u,p),P(l,u,o),P(d,f,o);for(s=0;s<16;s++)a[s+16]=l[s],a[s+32]=d[s],a[s+48]=u[s],a[s+64]=f[s];var h=a.subarray(32),g=a.subarray(16);return U(h,h),V(g,g,h),F(e,g),0}function K(e,t){return G(e,t,a)}function q(e,t){return r(t,32),K(e,t)}function J(e,t,n){var r=new Uint8Array(32);return G(r,n,t),x(e,i,r,S)}var ee=A,Y=j;function te(e,t,n,r,i,a){var o=new Uint8Array(32);return J(o,i,a),ee(e,t,n,r,o)}function ne(e,t,n,r,i,a){var o=new Uint8Array(32);return J(o,i,a),Y(e,t,n,r,o)}var re=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ie(e,t,n,r){for(var i=new Int32Array(16),a=new Int32Array(16),o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=e[0],N=e[1],P=e[2],F=e[3],I=e[4],L=e[5],R=e[6],z=e[7],B=t[0],V=t[1],H=t[2],U=t[3],W=t[4],G=t[5],K=t[6],q=t[7],J=0;r>=128;){for(w=0;w<16;w++)T=8*w+J,i[w]=n[T+0]<<24|n[T+1]<<16|n[T+2]<<8|n[T+3],a[w]=n[T+4]<<24|n[T+5]<<16|n[T+6]<<8|n[T+7];for(w=0;w<80;w++)if(o=M,s=N,c=P,l=F,u=I,d=L,f=R,p=z,m=B,h=V,g=H,_=U,v=W,y=G,b=K,x=q,E=z,D=q,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=(I>>>14|W<<18)^(I>>>18|W<<14)^(W>>>9|I<<23),D=(W>>>14|I<<18)^(W>>>18|I<<14)^(I>>>9|W<<23),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=I&L^~I&R,D=W&G^~W&K,O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=re[w*2],D=re[w*2+1],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=i[w%16],D=a[w%16],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,S=A&65535|j<<16,C=O&65535|k<<16,E=S,D=C,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=(M>>>28|B<<4)^(B>>>2|M<<30)^(B>>>7|M<<25),D=(B>>>28|M<<4)^(M>>>2|B<<30)^(M>>>7|B<<25),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=M&N^M&P^N&P,D=B&V^B&H^V&H,O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,p=A&65535|j<<16,x=O&65535|k<<16,E=l,D=_,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=S,D=C,O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,l=A&65535|j<<16,_=O&65535|k<<16,N=o,P=s,F=c,I=l,L=u,R=d,z=f,M=p,V=m,H=h,U=g,W=_,G=v,K=y,q=b,B=x,w%16==15)for(T=0;T<16;T++)E=i[T],D=a[T],O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=i[(T+9)%16],D=a[(T+9)%16],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,S=i[(T+1)%16],C=a[(T+1)%16],E=(S>>>1|C<<31)^(S>>>8|C<<24)^S>>>7,D=(C>>>1|S<<31)^(C>>>8|S<<24)^(C>>>7|S<<25),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,S=i[(T+14)%16],C=a[(T+14)%16],E=(S>>>19|C<<13)^(C>>>29|S<<3)^S>>>6,D=(C>>>19|S<<13)^(S>>>29|C<<3)^(C>>>6|S<<26),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,i[T]=A&65535|j<<16,a[T]=O&65535|k<<16;E=M,D=B,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[0],D=t[0],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[0]=M=A&65535|j<<16,t[0]=B=O&65535|k<<16,E=N,D=V,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[1],D=t[1],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[1]=N=A&65535|j<<16,t[1]=V=O&65535|k<<16,E=P,D=H,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[2],D=t[2],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[2]=P=A&65535|j<<16,t[2]=H=O&65535|k<<16,E=F,D=U,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[3],D=t[3],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[3]=F=A&65535|j<<16,t[3]=U=O&65535|k<<16,E=I,D=W,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[4],D=t[4],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[4]=I=A&65535|j<<16,t[4]=W=O&65535|k<<16,E=L,D=G,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[5],D=t[5],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[5]=L=A&65535|j<<16,t[5]=G=O&65535|k<<16,E=R,D=K,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[6],D=t[6],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[6]=R=A&65535|j<<16,t[6]=K=O&65535|k<<16,E=z,D=q,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[7],D=t[7],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[7]=z=A&65535|j<<16,t[7]=q=O&65535|k<<16,J+=128,r-=128}return r}function ae(e,t,n){var r=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),o,s=n;for(r[0]=1779033703,r[1]=3144134277,r[2]=1013904242,r[3]=2773480762,r[4]=1359893119,r[5]=2600822924,r[6]=528734635,r[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,ie(r,i,t,n),n%=128,o=0;o<n;o++)a[o]=t[s-n+o];for(a[n]=128,n=256-128*(n<112?1:0),a[n-9]=0,m(a,n-8,s/536870912|0,s<<3),ie(r,i,a,n),o=0;o<8;o++)m(e,8*o,r[o],i[o]);return 0}function oe(e,t){var r=n(),i=n(),a=n(),o=n(),s=n(),c=n(),l=n(),d=n(),f=n();B(r,e[1],e[0]),B(f,t[1],t[0]),V(r,r,f),z(i,e[0],e[1]),z(f,t[0],t[1]),V(i,i,f),V(a,e[3],t[3]),V(a,a,u),V(o,e[2],t[2]),z(o,o,o),B(s,i,r),B(c,o,a),z(l,o,a),z(d,i,r),V(e[0],s,c),V(e[1],d,l),V(e[2],l,c),V(e[3],s,d)}function se(e,t,n){var r;for(r=0;r<4;r++)P(e[r],t[r],n)}function ce(e,t){var r=n(),i=n(),a=n();U(a,t[2]),V(r,t[0],a),V(i,t[1],a),F(e,i),e[31]^=L(r)<<7}function le(e,t,n){var r,i;for(M(e[0],o),M(e[1],s),M(e[2],s),M(e[3],o),i=255;i>=0;--i)r=n[i/8|0]>>(i&7)&1,se(e,t,r),oe(t,e),oe(e,e),se(e,t,r)}function ue(e,t){var r=[n(),n(),n(),n()];M(r[0],d),M(r[1],f),M(r[2],s),V(r[3],d,f),le(e,r,t)}function de(e,t,i){var a=new Uint8Array(64),o=[n(),n(),n(),n()],s;for(i||r(t,32),ae(a,t,32),a[0]&=248,a[31]&=127,a[31]|=64,ue(o,a),ce(e,o),s=0;s<32;s++)t[s+32]=e[s];return 0}var fe=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function pe(e,t){var n,r,i,a;for(r=63;r>=32;--r){for(n=0,i=r-32,a=r-12;i<a;++i)t[i]+=n-16*t[r]*fe[i-(r-32)],n=Math.floor((t[i]+128)/256),t[i]-=n*256;t[i]+=n,t[r]=0}for(n=0,i=0;i<32;i++)t[i]+=n-(t[31]>>4)*fe[i],n=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=n*fe[i];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function me(e){var t=new Float64Array(64),n;for(n=0;n<64;n++)t[n]=e[n];for(n=0;n<64;n++)e[n]=0;pe(e,t)}function he(e,t,r,i){var a=new Uint8Array(64),o=new Uint8Array(64),s=new Uint8Array(64),c,l,u=new Float64Array(64),d=[n(),n(),n(),n()];ae(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=r+64;for(c=0;c<r;c++)e[64+c]=t[c];for(c=0;c<32;c++)e[32+c]=a[32+c];for(ae(s,e.subarray(32),r+32),me(s),ue(d,s),ce(e,d),c=32;c<64;c++)e[c]=i[c];for(ae(o,e,r+64),me(o),c=0;c<64;c++)u[c]=0;for(c=0;c<32;c++)u[c]=s[c];for(c=0;c<32;c++)for(l=0;l<32;l++)u[c+l]+=o[c]*a[l];return pe(e.subarray(32),u),f}function ge(e,t){var r=n(),i=n(),a=n(),c=n(),u=n(),d=n(),f=n();return M(e[2],s),R(e[1],t),H(a,e[1]),V(c,a,l),B(a,a,e[2]),z(c,e[2],c),H(u,c),H(d,u),V(f,d,u),V(r,f,a),V(r,r,c),W(r,r),V(r,r,a),V(r,r,c),V(r,r,c),V(e[0],r,c),H(i,e[0]),V(i,i,c),I(i,a)&&V(e[0],e[0],p),H(i,e[0]),V(i,i,c),I(i,a)?-1:(L(e[0])===t[31]>>7&&B(e[0],o,e[0]),V(e[3],e[0],e[1]),0)}function _e(e,t,r,i){var a,o=new Uint8Array(32),s=new Uint8Array(64),c=[n(),n(),n(),n()],l=[n(),n(),n(),n()];if(r<64||ge(l,i))return-1;for(a=0;a<r;a++)e[a]=t[a];for(a=0;a<32;a++)e[a+32]=i[a];if(ae(s,e,r),me(s),le(c,l,s),ue(l,t.subarray(32)),oe(c,l),ce(o,c),r-=64,_(t,0,o,0)){for(a=0;a<r;a++)e[a]=0;return-1}for(a=0;a<r;a++)e[a]=t[a+64];return r}var ve=32,ye=24,be=32,X=16,xe=32,Se=32,Ce=32,we=32,Te=32,Ee=ye,De=be,Oe=X,ke=64,Ae=32,je=64,Me=32,Ne=64;t.lowlevel={crypto_core_hsalsa20:x,crypto_stream_xor:E,crypto_stream:T,crypto_stream_salsa20_xor:C,crypto_stream_salsa20:w,crypto_onetimeauth:O,crypto_onetimeauth_verify:k,crypto_verify_16:g,crypto_verify_32:_,crypto_secretbox:A,crypto_secretbox_open:j,crypto_scalarmult:G,crypto_scalarmult_base:K,crypto_box_beforenm:J,crypto_box_afternm:ee,crypto_box:te,crypto_box_open:ne,crypto_box_keypair:q,crypto_hash:ae,crypto_sign:he,crypto_sign_keypair:de,crypto_sign_open:_e,crypto_secretbox_KEYBYTES:ve,crypto_secretbox_NONCEBYTES:ye,crypto_secretbox_ZEROBYTES:be,crypto_secretbox_BOXZEROBYTES:X,crypto_scalarmult_BYTES:xe,crypto_scalarmult_SCALARBYTES:Se,crypto_box_PUBLICKEYBYTES:Ce,crypto_box_SECRETKEYBYTES:we,crypto_box_BEFORENMBYTES:Te,crypto_box_NONCEBYTES:Ee,crypto_box_ZEROBYTES:De,crypto_box_BOXZEROBYTES:Oe,crypto_sign_BYTES:ke,crypto_sign_PUBLICKEYBYTES:Ae,crypto_sign_SECRETKEYBYTES:je,crypto_sign_SEEDBYTES:Me,crypto_hash_BYTES:Ne,gf:n,D:l,L:fe,pack25519:F,unpack25519:R,M:V,A:z,S:H,Z:B,pow2523:W,add:oe,set25519:M,modL:pe,scalarmult:le,scalarbase:ue};function Pe(e,t){if(e.length!==ve)throw Error(`bad key size`);if(t.length!==ye)throw Error(`bad nonce size`)}function Fe(e,t){if(e.length!==Ce)throw Error(`bad public key size`);if(t.length!==we)throw Error(`bad secret key size`)}function Ie(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw TypeError(`unexpected type, use Uint8Array`)}function Le(e){for(var t=0;t<e.length;t++)e[t]=0}t.randomBytes=function(e){var t=new Uint8Array(e);return r(t,e),t},t.secretbox=function(e,t,n){Ie(e,t,n),Pe(n,t);for(var r=new Uint8Array(be+e.length),i=new Uint8Array(r.length),a=0;a<e.length;a++)r[a+be]=e[a];return A(i,r,r.length,t,n),i.subarray(X)},t.secretbox.open=function(e,t,n){Ie(e,t,n),Pe(n,t);for(var r=new Uint8Array(X+e.length),i=new Uint8Array(r.length),a=0;a<e.length;a++)r[a+X]=e[a];return r.length<32||j(i,r,r.length,t,n)!==0?null:i.subarray(be)},t.secretbox.keyLength=ve,t.secretbox.nonceLength=ye,t.secretbox.overheadLength=X,t.scalarMult=function(e,t){if(Ie(e,t),e.length!==Se)throw Error(`bad n size`);if(t.length!==xe)throw Error(`bad p size`);var n=new Uint8Array(xe);return G(n,e,t),n},t.scalarMult.base=function(e){if(Ie(e),e.length!==Se)throw Error(`bad n size`);var t=new Uint8Array(xe);return K(t,e),t},t.scalarMult.scalarLength=Se,t.scalarMult.groupElementLength=xe,t.box=function(e,n,r,i){var a=t.box.before(r,i);return t.secretbox(e,n,a)},t.box.before=function(e,t){Ie(e,t),Fe(e,t);var n=new Uint8Array(Te);return J(n,e,t),n},t.box.after=t.secretbox,t.box.open=function(e,n,r,i){var a=t.box.before(r,i);return t.secretbox.open(e,n,a)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var e=new Uint8Array(Ce),t=new Uint8Array(we);return q(e,t),{publicKey:e,secretKey:t}},t.box.keyPair.fromSecretKey=function(e){if(Ie(e),e.length!==we)throw Error(`bad secret key size`);var t=new Uint8Array(Ce);return K(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},t.box.publicKeyLength=Ce,t.box.secretKeyLength=we,t.box.sharedKeyLength=Te,t.box.nonceLength=Ee,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(e,t){if(Ie(e,t),t.length!==je)throw Error(`bad secret key size`);var n=new Uint8Array(ke+e.length);return he(n,e,e.length,t),n},t.sign.open=function(e,t){if(Ie(e,t),t.length!==Ae)throw Error(`bad public key size`);var n=new Uint8Array(e.length),r=_e(n,e,e.length,t);if(r<0)return null;for(var i=new Uint8Array(r),a=0;a<i.length;a++)i[a]=n[a];return i},t.sign.detached=function(e,n){for(var r=t.sign(e,n),i=new Uint8Array(ke),a=0;a<i.length;a++)i[a]=r[a];return i},t.sign.detached.verify=function(e,t,n){if(Ie(e,t,n),t.length!==ke)throw Error(`bad signature size`);if(n.length!==Ae)throw Error(`bad public key size`);var r=new Uint8Array(ke+e.length),i=new Uint8Array(ke+e.length),a;for(a=0;a<ke;a++)r[a]=t[a];for(a=0;a<e.length;a++)r[a+ke]=e[a];return _e(i,r,r.length,n)>=0},t.sign.keyPair=function(){var e=new Uint8Array(Ae),t=new Uint8Array(je);return de(e,t),{publicKey:e,secretKey:t}},t.sign.keyPair.fromSecretKey=function(e){if(Ie(e),e.length!==je)throw Error(`bad secret key size`);for(var t=new Uint8Array(Ae),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},t.sign.keyPair.fromSeed=function(e){if(Ie(e),e.length!==Me)throw Error(`bad seed size`);for(var t=new Uint8Array(Ae),n=new Uint8Array(je),r=0;r<32;r++)n[r]=e[r];return de(t,n,!0),{publicKey:t,secretKey:n}},t.sign.publicKeyLength=Ae,t.sign.secretKeyLength=je,t.sign.seedLength=Me,t.sign.signatureLength=ke,t.hash=function(e){Ie(e);var t=new Uint8Array(Ne);return ae(t,e,e.length),t},t.hash.hashLength=Ne,t.verify=function(e,t){return Ie(e,t),e.length===0||t.length===0||e.length!==t.length?!1:h(e,0,t,0,e.length)===0},t.setPRNG=function(e){r=e},(function(){var n=typeof self<`u`?self.crypto||self.msCrypto:null;if(n&&n.getRandomValues){var r=65536;t.setPRNG(function(e,t){var i,a=new Uint8Array(t);for(i=0;i<t;i+=r)n.getRandomValues(a.subarray(i,i+Math.min(t-i,r)));for(i=0;i<t;i++)e[i]=a[i];Le(a)})}else e!==void 0&&(n=lB(),n&&n.randomBytes&&t.setPRNG(function(e,t){var r,i=n.randomBytes(t);for(r=0;r<t;r++)e[r]=i[r];Le(i)}))})()})(n!==void 0&&n.exports?n.exports:self.nacl=self.nacl||{})})),dB=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=t(uB()).default})),fB=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.KP=void 0;var n=cB(),r=hB(),i=t(dB());e.KP=class{seed;constructor(e){this.seed=e}getRawSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return n.Codec.decodeSeed(this.seed).buf}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return this.seed}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);let e=n.Codec.decodeSeed(this.seed),t=i.default.sign.keyPair.fromSeed(this.getRawSeed()),a=n.Codec.encode(e.prefix,t.publicKey);return new TextDecoder().decode(a)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);let e=i.default.sign.keyPair.fromSeed(this.getRawSeed());return n.Codec.encode(r.Prefix.Private,e.secretKey)}sign(e){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);let t=i.default.sign.keyPair.fromSeed(this.getRawSeed());return i.default.sign.detached(e,t.secretKey)}verify(e,t){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);let n=i.default.sign.keyPair.fromSeed(this.getRawSeed());return i.default.sign.detached.verify(e,t,n.publicKey)}clear(){this.seed&&=(this.seed.fill(0),void 0)}seal(e,t,n){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(e,t){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}})),pB=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.PublicKey=void 0;var n=cB(),r=hB(),i=t(dB());e.PublicKey=class{publicKey;constructor(e){this.publicKey=e}getPublicKey(){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return new TextDecoder().decode(this.publicKey)}getPrivateKey(){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.PublicKeyOnly):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}getSeed(){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.PublicKeyOnly):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}sign(e){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.CannotSign):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}verify(e,t){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);let a=n.Codec._decode(this.publicKey);return i.default.sign.detached.verify(e,t,a.slice(1))}clear(){this.publicKey&&=(this.publicKey.fill(0),void 0)}seal(e,t,n){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(e,t){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}})),mB=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.CurveKP=e.curveNonceLen=e.curveKeyLen=void 0;var n=hB(),r=t(dB()),i=cB(),a=hB(),o=sB(),s=oB();e.curveKeyLen=32;var c=35;e.curveNonceLen=24;var l=[120,107,118,49];e.CurveKP=class{seed;constructor(e){this.seed=e}clear(){this.seed&&=(this.seed.fill(0),void 0)}getPrivateKey(){if(!this.seed)throw new n.NKeysError(n.NKeysErrorCode.ClearedPair);return i.Codec.encode(a.Prefix.Private,this.seed)}getPublicKey(){if(!this.seed)throw new n.NKeysError(n.NKeysErrorCode.ClearedPair);let e=r.default.scalarMult.base(this.seed),t=i.Codec.encode(a.Prefix.Curve,e);return new TextDecoder().decode(t)}getSeed(){if(!this.seed)throw new n.NKeysError(n.NKeysErrorCode.ClearedPair);return i.Codec.encodeSeed(a.Prefix.Curve,this.seed)}sign(){throw new n.NKeysError(n.NKeysErrorCode.InvalidCurveOperation)}verify(){throw new n.NKeysError(n.NKeysErrorCode.InvalidCurveOperation)}decodePubCurveKey(e){try{let t=o.base32.decode(new TextEncoder().encode(e));if(t.byteLength!==c)throw new n.NKeysError(n.NKeysErrorCode.InvalidCurveKey);if(t[0]!==a.Prefix.Curve)throw new n.NKeysError(n.NKeysErrorCode.InvalidPublicKey);let r=t.byteLength-2,i=new DataView(t.buffer).getUint16(r,!0),l=t.slice(0,r);if(!s.crc16.validate(l,i))throw new n.NKeysError(n.NKeysErrorCode.InvalidChecksum);return l.slice(1)}catch(e){throw new n.NKeysError(n.NKeysErrorCode.InvalidRecipient,{cause:e})}}seal(t,i,a){if(!this.seed)throw new n.NKeysError(n.NKeysErrorCode.ClearedPair);a||=r.default.randomBytes(e.curveNonceLen);let o=this.decodePubCurveKey(i),s=new Uint8Array(l.length+e.curveNonceLen);s.set(l,0),s.set(a,l.length);let c=r.default.box(t,a,o,this.seed),u=new Uint8Array(s.length+c.length);return u.set(s),u.set(c,s.length),u}open(t,i){if(!this.seed)throw new n.NKeysError(n.NKeysErrorCode.ClearedPair);if(t.length<=e.curveNonceLen+l.length)throw new n.NKeysError(n.NKeysErrorCode.InvalidEncrypted);for(let e=0;e<l.length;e++)if(t[e]!==l[e])throw new n.NKeysError(n.NKeysErrorCode.InvalidEncrypted);let a=this.decodePubCurveKey(i);t=t.slice(l.length);let o=t.slice(0,e.curveNonceLen);return t=t.slice(e.curveNonceLen),r.default.box.open(t,o,a,this.seed)}}})),hB=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.NKeysError=e.NKeysErrorCode=e.Prefixes=e.Prefix=void 0,e.createPair=s,e.createOperator=c,e.createAccount=l,e.createUser=u,e.createCluster=d,e.createServer=f,e.createCurve=p,e.fromPublic=m,e.fromCurveSeed=h,e.fromSeed=g;var n=fB(),r=pB(),i=cB(),a=mB(),o=t(dB());function s(e){let t=e===_.Curve?a.curveKeyLen:32,r=o.default.randomBytes(t),s=i.Codec.encodeSeed(e,new Uint8Array(r));return e===_.Curve?new a.CurveKP(new Uint8Array(r)):new n.KP(s)}function c(){return s(_.Operator)}function l(){return s(_.Account)}function u(){return s(_.User)}function d(){return s(_.Cluster)}function f(){return s(_.Server)}function p(){return s(_.Curve)}function m(e){let t=new TextEncoder().encode(e),n=i.Codec._decode(t),a=v.parsePrefix(n[0]);if(v.isValidPublicPrefix(a))return new r.PublicKey(t);throw new b(y.InvalidPublicKey)}function h(e){let t=i.Codec.decodeSeed(e);if(t.prefix!==_.Curve)throw new b(y.InvalidCurveSeed);if(t.buf.byteLength!==a.curveKeyLen)throw new b(y.InvalidSeedLen);return new a.CurveKP(t.buf)}function g(e){return i.Codec.decodeSeed(e).prefix===_.Curve?h(e):new n.KP(e)}var _;(function(e){e[e.Unknown=-1]=`Unknown`,e[e.Seed=144]=`Seed`,e[e.Private=120]=`Private`,e[e.Operator=112]=`Operator`,e[e.Server=104]=`Server`,e[e.Cluster=16]=`Cluster`,e[e.Account=0]=`Account`,e[e.User=160]=`User`,e[e.Curve=184]=`Curve`})(_||(e.Prefix=_={}));var v=class{static isValidPublicPrefix(e){return e==_.Server||e==_.Operator||e==_.Cluster||e==_.Account||e==_.User||e==_.Curve}static startsWithValidPrefix(e){let t=e[0];return t==`S`||t==`P`||t==`O`||t==`N`||t==`C`||t==`A`||t==`U`||t==`X`}static isValidPrefix(e){return this.parsePrefix(e)!==_.Unknown}static parsePrefix(e){switch(e){case _.Seed:return _.Seed;case _.Private:return _.Private;case _.Operator:return _.Operator;case _.Server:return _.Server;case _.Cluster:return _.Cluster;case _.Account:return _.Account;case _.User:return _.User;case _.Curve:return _.Curve;default:return _.Unknown}}};e.Prefixes=v;var y;(function(e){e.InvalidPrefixByte=`nkeys: invalid prefix byte`,e.InvalidKey=`nkeys: invalid key`,e.InvalidPublicKey=`nkeys: invalid public key`,e.InvalidSeedLen=`nkeys: invalid seed length`,e.InvalidSeed=`nkeys: invalid seed`,e.InvalidCurveSeed=`nkeys: invalid curve seed`,e.InvalidCurveKey=`nkeys: not a valid curve key`,e.InvalidCurveOperation=`nkeys: curve key is not valid for sign/verify`,e.InvalidNKeyOperation=`keys: only curve key can seal/open`,e.InvalidEncoding=`nkeys: invalid encoded key`,e.InvalidRecipient=`nkeys: not a valid recipient public curve key`,e.InvalidEncrypted=`nkeys: encrypted input is not valid`,e.CannotSign=`nkeys: cannot sign, no private key available`,e.PublicKeyOnly=`nkeys: no seed or private key available`,e.InvalidChecksum=`nkeys: invalid checksum`,e.SerializationError=`nkeys: serialization error`,e.ApiError=`nkeys: api error`,e.ClearedPair=`nkeys: pair is cleared`})(y||(e.NKeysErrorCode=y={}));var b=class extends Error{code;constructor(e,t){super(e,t),this.code=e}};e.NKeysError=b})),gB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.encode=t,e.decode=n,e.dump=r;function t(e){return btoa(String.fromCharCode(...e))}function n(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function r(e,t){t&&console.log(t);let n=[];for(let t=0;t<e.byteLength;t++){t%8==0&&n.push(`
|
|
100
|
+
`);let r=e[t].toString(16);r.length===1&&(r=`0`+r),n.push(r)}console.log(n.join(` `))}})),_B=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.version=void 0,e.version=`2.0.3`})),vB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.version=e.encode=e.decode=e.Prefixes=e.Prefix=e.NKeysErrorCode=e.NKeysError=e.fromSeed=e.fromPublic=e.fromCurveSeed=e.createUser=e.createServer=e.createPair=e.createOperator=e.createCurve=e.createCluster=e.createAccount=void 0;var t=hB();Object.defineProperty(e,`createAccount`,{enumerable:!0,get:function(){return t.createAccount}}),Object.defineProperty(e,`createCluster`,{enumerable:!0,get:function(){return t.createCluster}}),Object.defineProperty(e,`createCurve`,{enumerable:!0,get:function(){return t.createCurve}}),Object.defineProperty(e,`createOperator`,{enumerable:!0,get:function(){return t.createOperator}}),Object.defineProperty(e,`createPair`,{enumerable:!0,get:function(){return t.createPair}}),Object.defineProperty(e,`createServer`,{enumerable:!0,get:function(){return t.createServer}}),Object.defineProperty(e,`createUser`,{enumerable:!0,get:function(){return t.createUser}}),Object.defineProperty(e,`fromCurveSeed`,{enumerable:!0,get:function(){return t.fromCurveSeed}}),Object.defineProperty(e,`fromPublic`,{enumerable:!0,get:function(){return t.fromPublic}}),Object.defineProperty(e,`fromSeed`,{enumerable:!0,get:function(){return t.fromSeed}}),Object.defineProperty(e,`NKeysError`,{enumerable:!0,get:function(){return t.NKeysError}}),Object.defineProperty(e,`NKeysErrorCode`,{enumerable:!0,get:function(){return t.NKeysErrorCode}}),Object.defineProperty(e,`Prefix`,{enumerable:!0,get:function(){return t.Prefix}}),Object.defineProperty(e,`Prefixes`,{enumerable:!0,get:function(){return t.Prefixes}});var n=gB();Object.defineProperty(e,`decode`,{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,`encode`,{enumerable:!0,get:function(){return n.encode}});var r=_B();Object.defineProperty(e,`version`,{enumerable:!0,get:function(){return r.version}})})),yB=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!==`default`&&t(i,r,a[o]);return n(i,r),i}})();Object.defineProperty(e,`__esModule`,{value:!0}),e.nkeys=void 0,e.nkeys=r(vB())})),bB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.multiAuthenticator=r,e.noAuthFn=i,e.usernamePasswordAuthenticator=a,e.tokenAuthenticator=o,e.nkeyAuthenticator=s,e.jwtAuthenticator=c,e.credsAuthenticator=l;var t=yB(),n=Hz();function r(e){return t=>{let n={};return e.forEach(e=>{let r=e(t)||{};n=Object.assign(n,r)}),n}}function i(){return()=>{}}function a(e,t){return()=>({user:typeof e==`function`?e():e,pass:typeof t==`function`?t():t})}function o(e){return()=>({auth_token:typeof e==`function`?e():e})}function s(e){return r=>{let i=typeof e==`function`?e():e,a=i?t.nkeys.fromSeed(i):void 0,o=a?a.getPublicKey():``,s=n.TE.encode(r||``),c=a!==void 0&&r?a.sign(s):void 0;return{nkey:o,sig:c?t.nkeys.encode(c):``}}}function c(e,t){return n=>{let r=typeof e==`function`?e():e,{nkey:i,sig:a}=s(t)(n);return{jwt:r,nkey:i,sig:a}}}function l(e){let t=typeof e==`function`?e:()=>e,r=()=>{let e=/\s*(?:(?:[-]{3,}[^\n]*[-]{3,}\n)(.+)(?:\n\s*[-]{3,}[^\n]*[-]{3,}\n))/gi,r=n.TD.decode(t()),i=e.exec(r);if(!i)throw Error(`unable to parse credentials`);let a=i[1].trim();if(i=e.exec(r),!i)throw Error(`unable to parse credentials`);return{jwt:a,seed:n.TE.encode(i[1].trim())}};return c(()=>{let{jwt:e}=r();return e},()=>{let{seed:e}=r();return e})}})),xB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_RECONNECT_TIME_WAIT=e.DEFAULT_MAX_PING_OUT=e.DEFAULT_PING_INTERVAL=e.DEFAULT_JITTER_TLS=e.DEFAULT_JITTER=e.DEFAULT_MAX_RECONNECT_ATTEMPTS=void 0,e.defaultOptions=o,e.hasWsProtocol=s,e.buildAuthenticator=c,e.parseOptions=l,e.checkOptions=u,e.checkUnsupportedOption=d;var t=Wz(),n=Yz(),r=qz(),i=bB(),a=Uz();e.DEFAULT_MAX_RECONNECT_ATTEMPTS=10,e.DEFAULT_JITTER=100,e.DEFAULT_JITTER_TLS=1e3,e.DEFAULT_PING_INTERVAL=120*1e3,e.DEFAULT_MAX_PING_OUT=2,e.DEFAULT_RECONNECT_TIME_WAIT=2*1e3;function o(){return{maxPingOut:e.DEFAULT_MAX_PING_OUT,maxReconnectAttempts:e.DEFAULT_MAX_RECONNECT_ATTEMPTS,noRandomize:!1,pedantic:!1,pingInterval:e.DEFAULT_PING_INTERVAL,reconnect:!0,reconnectJitter:e.DEFAULT_JITTER,reconnectJitterTLS:e.DEFAULT_JITTER_TLS,reconnectTimeWait:e.DEFAULT_RECONNECT_TIME_WAIT,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function s(e){if(e){let{servers:t}=e;if(typeof t==`string`&&(t=[t]),t)for(let e=0;e<t.length;e++){let n=t[e].toLowerCase();if(n.startsWith(`ws://`)||n.startsWith(`wss://`))return!0}}return!1}function c(e){let t=[];return typeof e.authenticator==`function`&&t.push(e.authenticator),Array.isArray(e.authenticator)&&t.push(...e.authenticator),e.token&&t.push((0,i.tokenAuthenticator)(e.token)),e.user&&t.push((0,i.usernamePasswordAuthenticator)(e.user,e.pass)),t.length===0?(0,i.noAuthFn)():(0,i.multiAuthenticator)(t)}function l(e){let i=`${r.DEFAULT_HOST}:${(0,n.defaultPort)()}`;if(e||={servers:[i]},e.servers=e.servers||[],typeof e.servers==`string`&&(e.servers=[e.servers]),e.servers.length>0&&e.port)throw a.InvalidArgumentError.format([`servers`,`port`],`are mutually exclusive`);e.servers.length===0&&e.port&&(e.servers=[`${r.DEFAULT_HOST}:${e.port}`]),e.servers&&e.servers.length===0&&(e.servers=[i]);let s=(0,t.extend)(o(),e);if(s.authenticator=c(s),[`reconnectDelayHandler`,`authenticator`].forEach(e=>{if(s[e]&&typeof s[e]!=`function`)throw TypeError(`'${e}' must be a function`)}),s.reconnectDelayHandler||=()=>{let e=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return e&&=(e++,Math.floor(Math.random()*e)),s.reconnectTimeWait+e},s.inboxPrefix&&(0,r.createInbox)(s.inboxPrefix),s.resolve===void 0&&(s.resolve=typeof(0,n.getResolveFn)()==`function`),s.resolve&&typeof(0,n.getResolveFn)()!=`function`)throw a.InvalidArgumentError.format(`resolve`,`is not supported in the current runtime`);return s}function u(e,t){let{proto:n,tls_required:r,tls_available:i}=e;if((n===void 0||n<1)&&t.noEcho)throw new a.errors.ConnectionError(`server does not support 'noEcho'`);let o=r||i||!1;if(t.tls&&!o)throw new a.errors.ConnectionError(`server does not support 'tls'`)}function d(e,t){if(t)throw a.InvalidArgumentError.format(e,`is not supported`)}})),SB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ProtocolHandler=e.Subscriptions=e.SubscriptionImpl=e.Connect=e.INFO=void 0;var t=Hz(),n=Yz(),r=Wz(),i=Jz(),a=Zz(),o=Qz(),s=$z(),c=eB(),l=nB(),u=iB(),d=aB(),f=xB(),p=Uz(),m=1024*32;e.INFO=/^INFO\s+([^\r\n]+)\r\n/i;var h=(0,t.encode)(`PONG\r
|
|
101
|
+
`),g=(0,t.encode)(`PING\r
|
|
102
|
+
`),_=class{echo;no_responders;protocol;verbose;pedantic;jwt;nkey;sig;user;pass;auth_token;tls_required;name;lang;version;headers;constructor(e,t,n){this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=t.noEcho?!1:void 0,this.verbose=t.verbose,this.pedantic=t.pedantic,this.tls_required=t.tls?!0:void 0,this.name=t.name;let i=(t&&typeof t.authenticator==`function`?t.authenticator(n):{})||{};(0,r.extend)(this,i)}};e.Connect=_;var v=class{slow;cb;notified;constructor(e,t){this.slow=e,this.cb=t,this.notified=!1}maybeNotify(e){e<=this.slow?this.notified=!1:this.notified||=(this.cb(e),!0)}},y=class extends o.QueuedIteratorImpl{sid;queue;draining;max;subject;drained;protocol;timer;info;cleanupFn;closed;requestSubject;slow;constructor(e,t,n={}){super(),(0,r.extend)(this,n),this.protocol=e,this.subject=t,this.draining=!1,this.noIterator=typeof n.callback==`function`,this.closed=(0,r.deferred)();let i=!e.options?.noAsyncTraces;n.timeout&&(this.timer=(0,r.timeout)(n.timeout,i),this.timer.then(()=>{this.timer=void 0}).catch(e=>{this.stop(e),this.noIterator&&this.callback(e,{})})),this.noIterator||this.iterClosed.then(e=>{this.closed.resolve(e),this.unsubscribe()})}setSlowNotificationFn(e,t){if(this.slow=void 0,t){if(this.noIterator)throw Error(`callbacks don't support slow notifications`);this.slow=new v(e,t)}}callback(e,t){this.cancelTimeout(),e?this.stop(e):this.push(t),!e&&this.slow&&this.slow.maybeNotify(this.getPending())}close(e){if(!this.isClosed()){this.cancelTimeout();let t=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve(e)};this.noIterator?t():this.push(t)}}unsubscribe(e){this.protocol.unsubscribe(this,e)}cancelTimeout(){this.timer&&=(this.timer.cancel(),void 0)}drain(){return this.protocol.isClosed()?Promise.reject(new p.errors.ClosedConnectionError):this.isClosed()?Promise.reject(new p.errors.InvalidOperationError(`subscription is already closed`)):(this.drained||=(this.draining=!0,this.protocol.unsub(this),this.protocol.flush((0,r.deferred)()).then(()=>{this.protocol.subscriptions.cancel(this)}).catch(()=>{this.protocol.subscriptions.cancel(this)})),this.drained)}isDraining(){return this.draining}isClosed(){return this.done}getSubject(){return this.subject}getMax(){return this.max}getID(){return this.sid}};e.SubscriptionImpl=y;var b=class{mux;subs;sidCounter;constructor(){this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(e){return this.sidCounter++,e.sid=this.sidCounter,this.subs.set(e.sid,e),e}setMux(e){return this.mux=e,e}getMux(){return this.mux}get(e){return this.subs.get(e)}resub(e){return this.sidCounter++,this.subs.delete(e.sid),e.sid=this.sidCounter,this.subs.set(e.sid,e),e}all(){return Array.from(this.subs.values())}cancel(e){e&&(e.close(),this.subs.delete(e.sid))}handleError(e){let t=this.all(),n;return e.operation===`subscription`?n=t.find(t=>t.subject===e.subject&&t.queue===e.queue):e.operation===`publish`&&(n=t.find(t=>t.requestSubject===e.subject)),n?(n.callback(e,{}),n.close(e),this.subs.delete(n.sid),n!==this.mux):!1}close(){this.subs.forEach(e=>{e.close()})}};e.Subscriptions=b,e.ProtocolHandler=class e{connected;connectedOnce;infoReceived;info;muxSubscriptions;options;outbound;pongs;subscriptions;transport;noMorePublishing;connectError;publisher;_closed;closed;listeners;heartbeats;parser;outMsgs;inMsgs;outBytes;inBytes;pendingLimit;lastError;abortReconnect;whyClosed;servers;server;features;connectPromise;dialDelay;raceTimer;constructor(e,t){this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=m,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=t,this.subscriptions=new b,this.muxSubscriptions=new s.MuxSubscription,this.outbound=new i.DataBuffer,this.pongs=[],this.whyClosed=``,this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new d.Features({major:0,minor:0,micro:0}),this.connectPromise=null,this.dialDelay=null;let n=typeof e.servers==`string`?[e.servers]:e.servers;this.servers=new a.Servers(n,{randomize:!e.noRandomize}),this.closed=(0,r.deferred)(),this.parser=new l.Parser(this),this.heartbeats=new c.Heartbeat(this,this.options.pingInterval||f.DEFAULT_PING_INTERVAL,this.options.maxPingOut||f.DEFAULT_MAX_PING_OUT)}resetOutbound(){this.outbound.reset();let e=this.pongs;this.pongs=[];let t=new p.errors.RequestError(`connection disconnected`);t.stack=``,e.forEach(e=>{e.reject(t)}),this.parser=new l.Parser(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(t=>{t.push(e)})}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();let e=(0,r.deferred)();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=t=>{e.reject(t)},this.transport=(0,n.newTransport)(),this.transport.closed().then(async e=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),e}disconnect(){this.dispatchStatus({type:`staleConnection`}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:`forceReconnect`}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:`disconnect`,server:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{this.dispatchStatus({type:`reconnect`,server:this.servers.getCurrentServer().toString()}),this.lastError instanceof p.errors.UserAuthenticationExpiredError&&(this.lastError=void 0)}).catch(e=>{this.close(e).catch()}):await this.close(e).catch()}async dial(e){let t=this.prepare();try{this.raceTimer=(0,r.timeout)(this.options.timeout||2e4);let t=this.transport.connect(e,this.options);await Promise.race([t,this.raceTimer]),(async()=>{try{for await(let e of this.transport)this.parser.parse(e)}catch(e){console.log(`reader closed`,e)}})().then()}catch(e){t.reject(e)}try{await Promise.race([this.raceTimer,t]),this.raceTimer?.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(e){throw this.raceTimer?.cancel(),await this.transport.close(e),e}}async _doDial(e){let{resolve:t}=this.options,r=await e.resolve({fn:(0,n.getResolveFn)(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:t}),i=null;for(let e of r)try{i=null,this.dispatchStatus({type:`reconnecting`}),await this.dial(e);return}catch(e){i=e}throw i}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let e;for(;;){this._closed&&this.servers.clear();let t=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():f.DEFAULT_RECONNECT_TIME_WAIT,n=t,i=this.selectServer();if(!i||this.abortReconnect)throw e||(this.lastError?this.lastError:new p.errors.ConnectionError(`connection refused`));let a=Date.now();if(i.lastConnect===0||i.lastConnect+t<=a){i.lastConnect=Date.now();try{await this._doDial(i);break}catch(t){if(e=t,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}i.reconnects++;let n=this.options.maxReconnectAttempts||0;n!==-1&&i.reconnects>=n&&this.servers.removeCurrentServer()}}else n=Math.min(n,i.lastConnect+t-a),this.dialDelay=(0,r.delay)(n),await this.dialDelay}}static async connect(t,n){let r=new e(t,n);return await r.dialLoop(),r}static toError(e){let t=p.errors.PermissionViolationError.parse(e);return t||(t=p.errors.UserAuthenticationExpiredError.parse(e),t)||(t=p.errors.AuthorizationError.parse(e),t)?t:new p.errors.ProtocolError(e)}processMsg(e,t){if(this.inMsgs++,this.inBytes+=t.length,!this.subscriptions.sidCounter)return;let n=this.subscriptions.get(e.sid);n&&(n.received+=1,n.callback&&n.callback(null,new u.MsgImpl(e,t,this)),n.max!==void 0&&n.received>=n.max&&n.unsubscribe())}processError(n){let r=(0,t.decode)(n);r.startsWith(`'`)&&r.endsWith(`'`)&&(r=r.slice(1,r.length-1));let i=e.toError(r);switch(i.constructor){case p.errors.PermissionViolationError:{let e=i,t=this.subscriptions.getMux(),n=t?e.subject===t.subject:!1;this.subscriptions.handleError(e),this.muxSubscriptions.handleError(n,e),n&&this.subscriptions.setMux(null)}}this.dispatchStatus({type:`error`,error:i}),this.handleError(i)}handleError(e){(e instanceof p.errors.UserAuthenticationExpiredError||e instanceof p.errors.AuthorizationError)&&this.handleAuthError(e),e instanceof p.errors.PermissionViolationError||(this.lastError=e)}handleAuthError(e){(this.lastError instanceof p.errors.UserAuthenticationExpiredError||this.lastError instanceof p.errors.AuthorizationError)&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(h)}processPong(){let e=this.pongs.shift();e&&e.resolve()}processInfo(e){let r=JSON.parse((0,t.decode)(e));this.info=r;let i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(r,this.transport.isEncrypted());if(!this.infoReceived){this.features.update((0,d.parseSemVer)(r.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();let{version:e,lang:i}=this.transport;try{let a=new _({version:e,lang:i},this.options,r.nonce);r.headers&&(a.headers=!0,a.no_responders=!0);let o=JSON.stringify(a);this.transport.send((0,t.encode)(`CONNECT ${o}${n.CR_LF}`)),this.transport.send(g)}catch(e){this.close(e).catch()}}if(i){let{added:e,deleted:t}=i;this.dispatchStatus({type:`update`,added:e,deleted:t})}r.ldm!==void 0&&r.ldm&&this.dispatchStatus({type:`ldm`,server:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case l.Kind.MSG:{let{msg:t,data:n}=e;this.processMsg(t,n);break}case l.Kind.OK:break;case l.Kind.ERR:this.processError(e.data);break;case l.Kind.PING:this.processPing();break;case l.Kind.PONG:this.processPong();break;case l.Kind.INFO:this.processInfo(e.data);break}}sendCommand(e,...n){let r=this.outbound.length(),i;i=typeof e==`string`?(0,t.encode)(e):e,this.outbound.fill(i,...n),r===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,r=t.Empty,i){let a;if(r instanceof Uint8Array)a=r;else if(typeof r==`string`)a=t.TE.encode(r);else throw TypeError(`payload types can be strings or Uint8Array`);let o=a.length;i||={},i.reply=i.reply||``;let s=t.Empty,c=0;if(i.headers&&(this.info&&!this.info.headers&&p.InvalidArgumentError.format(`headers`,`are not available on this server`),s=i.headers.encode(),c=s.length,o=a.length+c),this.info&&o>this.info.max_payload)throw p.InvalidArgumentError.format(`payload`,`max_payload size exceeded`);this.outBytes+=o,this.outMsgs++;let l;i.headers?(l=i.reply?`HPUB ${e} ${i.reply} ${c} ${o}\r\n`:`HPUB ${e} ${c} ${o}\r\n`,this.sendCommand(l,s,a,n.CRLF)):(l=i.reply?`PUB ${e} ${i.reply} ${o}\r\n`:`PUB ${e} ${o}\r\n`,this.sendCommand(l,a,n.CRLF))}request(e){return this.initMux(),this.muxSubscriptions.add(e),e}subscribe(e){return this.subscriptions.add(e),this._subunsub(e),e}_sub(e){e.queue?this.sendCommand(`SUB ${e.subject} ${e.queue} ${e.sid}\r\n`):this.sendCommand(`SUB ${e.subject} ${e.sid}\r\n`)}_subunsub(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}unsubscribe(e,t){this.unsub(e,t),(e.max===void 0||e.received>=e.max)&&this.subscriptions.cancel(e)}unsub(e,t){!e||this.isClosed()||(t?this.sendCommand(`UNSUB ${e.sid} ${t}\r\n`):this.sendCommand(`UNSUB ${e.sid}\r\n`),e.max=t)}resub(e,t){!e||this.isClosed()||(this.unsub(e),e.subject=t,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||=(0,r.deferred)(),this.pongs.push(e),this.outbound.fill(g),this.flushPending(),e}sendSubscriptions(){let e=[];this.subscriptions.all().forEach(t=>{let r=t;r.queue?e.push(`SUB ${r.subject} ${r.queue} ${r.sid}${n.CR_LF}`):e.push(`SUB ${r.subject} ${r.sid}${n.CR_LF}`)}),e.length&&this.transport.send((0,t.encode)(e.join(``)))}async close(e){if(this._closed)return;this.whyClosed=Error(`close trace`).stack||``,this.heartbeats.cancel(),this.connectError&&=(this.connectError(e),void 0),this.muxSubscriptions.close(),this.subscriptions.close();let t=[];for(let e=0;e<this.listeners.length;e++){let n=this.listeners[e];n&&(n.push({type:`close`}),n.stop(),t.push(n.iterClosed))}t.length&&await Promise.all(t),this._closed=!0,await this.transport.close(e),this.raceTimer?.cancel(),this.dialDelay?.cancel(),this.closed.resolve(e)}isClosed(){return this._closed}async drain(){let e=this.subscriptions.all(),t=[];e.forEach(e=>{t.push(e.drain())});try{await Promise.allSettled(t)}catch{}finally{this.noMorePublishing=!0,await this.flush()}return this.close()}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){let e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){let e=this.muxSubscriptions.init(this.options.inboxPrefix),t=new y(this,`${e}*`);t.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(t),this.subscribe(t)}}selectServer(){let e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}})),CB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RequestOne=e.RequestMany=e.BaseRequest=void 0;var t=Wz(),n=Kz(),r=Uz(),i=class{token;received;ctx;requestSubject;mux;constructor(e,t,i=!0){this.mux=e,this.requestSubject=t,this.received=0,this.token=n.nuid.next(),i&&(this.ctx=new r.RequestError)}};e.BaseRequest=i,e.RequestMany=class extends i{callback;done;timer;max;opts;constructor(e,n,r={maxWait:1e3}){if(super(e,n),this.opts=r,typeof this.opts.callback!=`function`)throw TypeError(`callback must be a function`);this.callback=this.opts.callback,this.max=typeof r.maxMessages==`number`&&r.maxMessages>0?r.maxMessages:-1,this.done=(0,t.deferred)(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},r.maxWait)}cancel(e){e&&this.callback(e,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(e,t){e?(this.ctx&&(e.stack+=`\n\n${this.ctx.stack}`),this.cancel(e)):(this.callback(null,t),this.opts.strategy===`count`&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===`stall`&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.stall||300)),this.opts.strategy===`sentinel`&&t&&t.data.length===0&&this.cancel())}},e.RequestOne=class extends i{deferred;timer;constructor(e,n,r={timeout:1e3},i=!0){super(e,n,i),this.deferred=(0,t.deferred)(),this.timer=(0,t.timeout)(r.timeout,i)}resolver(e,t){this.timer&&this.timer.cancel(),e?(e instanceof r.TimeoutError||(this.ctx?(this.ctx.message=e.message,this.ctx.cause=e,e=this.ctx):e=new r.errors.RequestError(e.message,{cause:e})),this.deferred.reject(e)):this.deferred.resolve(t),this.cancel()}cancel(e){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(e||new r.RequestError(`cancelled`))}}})),wB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NatsConnectionImpl=void 0;var t=Wz(),n=SB(),r=Hz(),i=rB(),a=aB(),o=xB(),s=Qz(),c=CB(),l=qz(),u=Uz(),d=/[ \n\r\t]/;e.NatsConnectionImpl=class e{options;protocol;draining;closeListeners;constructor(e){this.draining=!1,this.options=(0,o.parseOptions)(e)}static connect(t={}){return new Promise((r,i)=>{let a=new e(t);n.ProtocolHandler.connect(a.options,a).then(e=>{a.protocol=e,r(a)}).catch(e=>{i(e)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,t,n){if(this.isClosed())throw new u.errors.ClosedConnectionError;if(t&&this.isDraining()||n&&this.protocol.noMorePublishing)throw new u.errors.DrainingConnectionError;if(e||=``,e.length===0||d.test(e))throw new u.errors.InvalidSubjectError(e)}publish(e,t,n){if(this._check(e,!1,!0),n?.reply&&this._check(n.reply,!1,!0),typeof n?.traceOnly==`boolean`){let e=n.headers||(0,i.headers)();e.set(`Nats-Trace-Only`,`true`),n.headers=e}if(typeof n?.traceDestination==`string`){let e=n.headers||(0,i.headers)();e.set(`Nats-Trace-Dest`,n.traceDestination),n.headers=e}this.protocol.publish(e,t,n)}publishMessage(e){return this.publish(e.subject,e.data,{reply:e.reply,headers:e.headers})}respondMessage(e){return e.reply?(this.publish(e.reply,e.data,{reply:e.reply,headers:e.headers}),!0):!1}subscribe(e,t={}){this._check(e,!0,!1);let r=new n.SubscriptionImpl(this.protocol,e,t);return typeof t.callback!=`function`&&typeof t.slow==`number`&&r.setSlowNotificationFn(t.slow,e=>{this.protocol.dispatchStatus({type:`slowConsumer`,sub:r,pending:e})}),this.protocol.subscribe(r),r}_resub(e,t,n){this._check(t,!0,!1);let r=e;r.max=n,n&&(r.max=n+r.received),this.protocol.resub(r,t)}requestMany(e,t=r.Empty,n={maxWait:1e3,maxMessages:-1}){let i=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(e){return Promise.reject(e)}if(n.strategy=n.strategy||`timer`,n.maxWait=n.maxWait||1e3,n.maxWait<1)return Promise.reject(u.InvalidArgumentError.format(`timeout`,`must be greater than 0`));let a=new s.QueuedIteratorImpl;function o(e){a.push(()=>{a.stop(e)})}function d(e,t){e||t===null?o(e===null?void 0:e):a.push(t)}if(n.noMux){let r=i?Error().stack:null,s=typeof n.maxMessages==`number`&&n.maxMessages>0?n.maxMessages:-1,c=this.subscribe((0,l.createInbox)(this.options.inboxPrefix),{callback:(t,i)=>{if(i?.data?.length===0&&i?.headers?.status===`503`&&(t=new u.errors.NoRespondersError(e)),t){r&&(t.stack+=`\n\n${r}`),f(t);return}d(null,i),n.strategy===`count`&&(s--,s===0&&f()),n.strategy===`stall`&&(_(),g=setTimeout(()=>{f()},300)),n.strategy===`sentinel`&&i&&i.data.length===0&&f()}});c.requestSubject=e,c.closed.then(()=>{o()}).catch(e=>{a.stop(e)});let f=e=>{e&&a.push(()=>{throw e}),_(),c.drain().then(()=>{o()}).catch(e=>{o()})};a.iterClosed.then(()=>{_(),c?.unsubscribe()}).catch(e=>{_(),c?.unsubscribe()});let{headers:p,traceDestination:m,traceOnly:h}=n;try{this.publish(e,t,{reply:c.getSubject(),headers:p,traceDestination:m,traceOnly:h})}catch(e){f(e)}let g=setTimeout(()=>{f()},n.maxWait),_=()=>{g&&clearTimeout(g)}}else{let r=n;r.callback=d,a.iterClosed.then(()=>{i.cancel()}).catch(e=>{i.cancel(e)});let i=new c.RequestMany(this.protocol.muxSubscriptions,e,r);this.protocol.request(i);let{headers:o,traceDestination:s,traceOnly:l}=n;try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${i.token}`,headers:o,traceDestination:s,traceOnly:l})}catch(e){i.cancel(e)}}return Promise.resolve(a)}request(e,n,r={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(e){return Promise.reject(e)}let i=!this.protocol.options.noAsyncTraces;if(r.timeout=r.timeout||1e3,r.timeout<1)return Promise.reject(u.InvalidArgumentError.format(`timeout`,`must be greater than 0`));if(!r.noMux&&r.reply)return Promise.reject(u.InvalidArgumentError.format([`reply`,`noMux`],`are mutually exclusive`));if(r.noMux){let a=r.reply?r.reply:(0,l.createInbox)(this.options.inboxPrefix),o=(0,t.deferred)(),s=i?new u.errors.RequestError(``):null,c=this.subscribe(a,{max:1,timeout:r.timeout,callback:(t,n)=>{n&&n.data?.length===0&&n.headers?.code===503&&(t=new u.errors.NoRespondersError(e)),t?(t instanceof u.TimeoutError||(s?(s.message=t.message,s.cause=t,t=s):t=new u.errors.RequestError(t.message,{cause:t})),o.reject(t),c.unsubscribe()):o.resolve(n)}});return c.requestSubject=e,this.protocol.publish(e,n,{reply:a,headers:r.headers}),o}else{let t=new c.RequestOne(this.protocol.muxSubscriptions,e,r,i);this.protocol.request(t);let{headers:a,traceDestination:o,traceOnly:s}=r;try{this.publish(e,n,{reply:`${this.protocol.muxSubscriptions.baseInbox}${t.token}`,headers:a,traceDestination:o,traceOnly:s})}catch(e){t.cancel(e)}let l=Promise.race([t.timer,t.deferred]);return l.catch(()=>{t.cancel()}),l}}flush(){return this.isClosed()?Promise.reject(new u.errors.ClosedConnectionError):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(new u.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new u.errors.DrainingConnectionError):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){let e=this.protocol.getServer();return e?e.listen:``}status(){let e=new s.QueuedIteratorImpl;return e.iterClosed.then(()=>{let t=this.protocol.listeners.indexOf(e);t>-1&&this.protocol.listeners.splice(t,1)}),this.protocol.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request(`$SYS.REQ.USER.INFO`)).json((e,t)=>e===`time`?new Date(Date.parse(t)):t)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}getServerVersion(){let e=this.info;return e?(0,a.parseSemVer)(e.version):void 0}async rtt(){if(this.isClosed())throw new u.errors.ClosedConnectionError;if(!this.protocol.connected)throw new u.errors.RequestError(`connection disconnected`);let e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}reconnect(){return this.isClosed()?Promise.reject(new u.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new u.errors.DrainingConnectionError):this.protocol.reconnect()}addCloseListener(e){this.closeListeners===void 0&&(this.closeListeners=new f(this.closed())),this.closeListeners.add(e)}removeCloseListener(e){this.closeListeners&&this.closeListeners.remove(e)}};var f=class{listeners;constructor(e){this.listeners=[],e.then(e=>{this.notify(e)})}add(e){this.listeners.push(e)}remove(e){this.listeners=this.listeners.filter(t=>t!==e)}notify(e){this.listeners.forEach(t=>{if(typeof t.connectionClosedCallback==`function`)try{t.connectionClosedCallback(e)}catch{}}),this.listeners=[]}}})),TB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Empty=void 0;var t=Hz();Object.defineProperty(e,`Empty`,{enumerable:!0,get:function(){return t.Empty}})})),EB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Bench=e.Metric=void 0,e.throughput=a,e.msgThroughput=o,e.humanizeBytes=s;var t=TB(),n=Kz(),r=Wz(),i=class{name;duration;date;payload;msgs;lang;version;bytes;asyncRequests;min;max;constructor(e,t){this.name=e,this.duration=t,this.date=Date.now(),this.payload=0,this.msgs=0,this.bytes=0}toString(){let e=this.duration/1e3,t=Math.round(this.msgs/e),n=this.asyncRequests?`asyncRequests`:``,r=``;return this.max&&(r=`${this.min}/${this.max}`),`${this.name}${n?` [asyncRequests]`:``} ${c(t)} msgs/sec - [${e.toFixed(2)} secs] ~ ${a(this.bytes,e)} ${r}`}toCsv(){return`"${this.name}",${new Date(this.date).toISOString()},${this.lang},${this.version},${this.msgs},${this.payload},${this.bytes},${this.duration},${this.asyncRequests?this.asyncRequests:!1}\n`}static header(){return`Test,Date,Lang,Version,Count,MsgPayload,Bytes,Millis,Async
|
|
103
|
+
`}};e.Metric=i,e.Bench=class{nc;callbacks;msgs;size;subject;asyncRequests;pub;sub;req;rep;perf;payload;constructor(e,i={msgs:1e5,size:128,subject:``,asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){if(this.nc=e,this.callbacks=i.callbacks||!1,this.msgs=i.msgs||0,this.size=i.size||0,this.subject=i.subject||n.nuid.next(),this.asyncRequests=i.asyncRequests||!1,this.pub=i.pub||!1,this.sub=i.sub||!1,this.req=i.req||!1,this.rep=i.rep||!1,this.perf=new r.Perf,this.payload=this.size?new Uint8Array(this.size):t.Empty,!this.pub&&!this.sub&&!this.req&&!this.rep)throw Error(`no options selected`)}async run(){return this.nc.closed().then(e=>{if(e)throw e}),this.callbacks?await this.runCallbacks():await this.runAsync(),this.processMetrics()}processMetrics(){let{lang:e,version:t}=this.nc.protocol.transport;this.pub&&this.sub&&this.perf.measure(`pubsub`,`pubStart`,`subStop`),this.req&&this.rep&&this.perf.measure(`reqrep`,`reqStart`,`reqStop`);let n=this.perf.getEntries(),r=n.find(e=>e.name===`pubsub`),a=n.find(e=>e.name===`reqrep`),o=n.find(e=>e.name===`req`),s=n.find(e=>e.name===`rep`),c=n.find(e=>e.name===`pub`),l=n.find(e=>e.name===`sub`),u=this.nc.stats(),d=[];if(r){let{name:n,duration:a}=r,o=new i(n,a);o.msgs=this.msgs*2,o.bytes=u.inBytes+u.outBytes,o.lang=e,o.version=t,o.payload=this.payload.length,d.push(o)}if(a){let{name:n,duration:r}=a,o=new i(n,r);o.msgs=this.msgs*2,o.bytes=u.inBytes+u.outBytes,o.lang=e,o.version=t,o.payload=this.payload.length,d.push(o)}if(c){let{name:n,duration:r}=c,a=new i(n,r);a.msgs=this.msgs,a.bytes=u.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,d.push(a)}if(l){let{name:n,duration:r}=l,a=new i(n,r);a.msgs=this.msgs,a.bytes=u.inBytes,a.lang=e,a.version=t,a.payload=this.payload.length,d.push(a)}if(s){let{name:n,duration:r}=s,a=new i(n,r);a.msgs=this.msgs,a.bytes=u.inBytes+u.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,d.push(a)}if(o){let{name:n,duration:r}=o,a=new i(n,r);a.msgs=this.msgs,a.bytes=u.inBytes+u.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,d.push(a)}return d}async runCallbacks(){let e=[];if(this.sub){let t=(0,r.deferred)();e.push(t);let n=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{n++,n===1&&this.perf.mark(`subStart`),n===this.msgs&&(this.perf.mark(`subStop`),this.perf.measure(`sub`,`subStart`,`subStop`),t.resolve())}})}if(this.rep){let t=(0,r.deferred)();e.push(t);let n=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(e,r)=>{r.respond(this.payload),n++,n===1&&this.perf.mark(`repStart`),n===this.msgs&&(this.perf.mark(`repStop`),this.perf.measure(`rep`,`repStart`,`repStop`),t.resolve())}})}if(this.pub){let t=(async()=>{this.perf.mark(`pubStart`);for(let e=0;e<this.msgs;e++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark(`pubStop`),this.perf.measure(`pub`,`pubStart`,`pubStop`)})();e.push(t)}if(this.req){let t=(async()=>{if(this.asyncRequests){this.perf.mark(`reqStart`);let e=[];for(let t=0;t<this.msgs;t++)e.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(e),this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}else{this.perf.mark(`reqStart`);for(let e=0;e<this.msgs;e++)await this.nc.request(this.subject);this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}})();e.push(t)}await Promise.all(e)}async runAsync(){let e=[];if(this.rep){let t=!1,n=this.nc.subscribe(this.subject,{max:this.msgs}),r=(async()=>{for await(let e of n)t||=(this.perf.mark(`repStart`),!0),e.respond(this.payload);await this.nc.flush(),this.perf.mark(`repStop`),this.perf.measure(`rep`,`repStart`,`repStop`)})();e.push(r)}if(this.sub){let t=!1,n=this.nc.subscribe(this.subject,{max:this.msgs}),r=(async()=>{for await(let e of n)t||=(this.perf.mark(`subStart`),!0);this.perf.mark(`subStop`),this.perf.measure(`sub`,`subStart`,`subStop`)})();e.push(r)}if(this.pub){let t=(async()=>{this.perf.mark(`pubStart`);for(let e=0;e<this.msgs;e++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark(`pubStop`),this.perf.measure(`pub`,`pubStart`,`pubStop`)})();e.push(t)}if(this.req){let t=(async()=>{if(this.asyncRequests){this.perf.mark(`reqStart`);let e=[];for(let t=0;t<this.msgs;t++)e.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(e),this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}else{this.perf.mark(`reqStart`);for(let e=0;e<this.msgs;e++)await this.nc.request(this.subject);this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}})();e.push(t)}await Promise.all(e)}};function a(e,t){return`${s(e/t)}/sec`}function o(e,t){return`${Math.floor(e/t)} msgs/sec`}function s(e,t=!1){let n=t?1e3:1024,r=t?[`k`,`M`,`G`,`T`,`P`,`E`]:[`K`,`M`,`G`,`T`,`P`,`E`],i=t?`iB`:`B`;if(e<n)return`${e.toFixed(2)} ${i}`;let a=parseInt(Math.log(e)/Math.log(n)+``),o=parseInt(a-1+``);return`${(e/n**+a).toFixed(2)} ${r[o]}${i}`}function c(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}})),DB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IdleHeartbeatMonitor=void 0,e.IdleHeartbeatMonitor=class{interval;maxOut;cancelAfter;timer;autoCancelTimer;last;missed;count;callback;constructor(e,t,n={maxOut:2}){this.interval=e,this.maxOut=n?.maxOut||2,this.cancelAfter=n?.cancelAfter||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=t,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,t=0,n=2){this.interval=e,this.maxOut=n,this.cancelAfter=t,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}})),OB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.version=void 0,e.version=`3.3.1`})),kB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.WsTransport=void 0,e.wsUrlParseFn=f,e.wsconnect=p;var t=Wz(),n=Yz(),r=xB(),i=Jz(),a=SB(),o=wB(),s=OB(),c=Uz(),l=s.version,u=`nats.ws`,d=class{version;lang;closeError;connected;done;socket;options;socketClosed;encrypted;peeked;yields;signal;closedNotification;constructor(){this.version=l,this.lang=u,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=(0,t.deferred)(),this.closedNotification=(0,t.deferred)()}async connect(e,o){let s=(0,t.deferred)();this.options=o;let l=e.src;if(o.wsFactory){let{socket:t,encrypted:n}=await o.wsFactory(e.src,o);this.socket=t,this.encrypted=n}else this.encrypted=l.indexOf(`wss://`)===0,this.socket=new WebSocket(l);return this.socket.binaryType=`arraybuffer`,this.socket.onopen=()=>{this.done&&this._closed(Error(`aborted`))},this.socket.onmessage=e=>{if(this.done)return;if(this.yields.push(new Uint8Array(e.data)),this.peeked){this.signal.resolve();return}let c=i.DataBuffer.concat(...this.yields),l=(0,n.extractProtocolMessage)(c);if(l!==``){let e=a.INFO.exec(l);if(!e){o.debug&&console.error(`!!!`,(0,t.render)(c)),s.reject(Error(`unexpected response from server`));return}try{let t=JSON.parse(e[1]);(0,r.checkOptions)(t,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),s.resolve()}catch(e){s.reject(e);return}}},this.socket.onclose=e=>{let t;!e.wasClean&&e.reason!==``&&(t=Error(e.reason)),this._closed(t),this._cleanup()},this.socket.onerror=e=>{if(this.done)return;let t=e,n=new c.errors.ConnectionError(t.message);s.reject(n),this._cleanup()},s}_cleanup(){this.socketClosed===!1&&(this.socketClosed=!0,this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.closedNotification.resolve(this.closeError))}disconnect(){this._closed(void 0,!0)}async _closed(e,n=!0){if(this.done){try{this.socket.close()}catch{}return}if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await(0,t.delay)(100);this.done=!0;try{this.socket.close()}catch{}return this.closedNotification}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.done)return;this.yields.length===0&&await this.signal;let e=this.yields;this.yields=[];for(let n=0;n<e.length;n++)this.options.debug&&console.info(`> ${(0,t.render)(e[n])}`),yield e[n];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=(0,t.deferred)())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.done)try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${(0,t.render)(e)}`);return}catch(n){this.options.debug&&console.error(`!!! ${(0,t.render)(e)}: ${n}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}discard(){this.socket?.close()}};e.WsTransport=d;function f(e,t){/^(.*:\/\/)(.*)/.test(e)||(e=typeof t==`boolean`?`${t===!0?`https`:`http`}://${e}`:`https://${e}`);let n=new URL(e),r=n.protocol.toLowerCase();r===`ws:`&&(t=!1),r===`wss:`&&(t=!0),r!==`https:`&&r!==`http`&&(e=e.replace(/^(.*:\/\/)(.*)/gm,`$2`),n=new URL(`http://${e}`));let i,a,o=n.hostname,s=n.pathname,c=n.search||``;switch(r){case`http:`:case`ws:`:case`nats:`:a=n.port||`80`,i=`ws:`;break;case`https:`:case`wss:`:case`tls:`:a=n.port||`443`,i=`wss:`;break;default:a=n.port||t===!0?`443`:`80`,i=t===!0?`wss:`:`ws:`;break}return`${i}//${o}:${a}${s}${c}`}function p(e={}){return(0,n.setTransportFactory)({defaultPort:443,urlParseFn:f,factory:()=>{if(e.tls)throw c.InvalidArgumentError.format(`tls`,`is not configurable on w3c websocket connections`);return new d}}),o.NatsConnectionImpl.connect(e)}})),AB=r((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.Metric=e.Bench=e.writeAll=e.readAll=e.MAX_SIZE=e.DenoBuffer=e.State=e.Parser=e.Kind=e.describe=e.QueuedIteratorImpl=e.usernamePasswordAuthenticator=e.tokenAuthenticator=e.nkeyAuthenticator=e.jwtAuthenticator=e.credsAuthenticator=e.RequestOne=e.parseOptions=e.hasWsProtocol=e.defaultOptions=e.DEFAULT_MAX_RECONNECT_ATTEMPTS=e.checkUnsupportedOption=e.checkOptions=e.buildAuthenticator=e.DataBuffer=e.MuxSubscription=e.Heartbeat=e.MsgHdrsImpl=e.headers=e.canonicalMIMEHeaderKey=e.timeout=e.SimpleMutex=e.render=e.nanos=e.millis=e.extend=e.delay=e.deferred=e.deadline=e.collect=e.backoff=e.ProtocolHandler=e.INFO=e.Connect=e.setTransportFactory=e.getResolveFn=e.MsgImpl=e.nuid=e.Nuid=e.NatsConnectionImpl=void 0,e.UserAuthenticationExpiredError=e.TimeoutError=e.RequestError=e.ProtocolError=e.PermissionViolationError=e.NoRespondersError=e.InvalidSubjectError=e.InvalidOperationError=e.InvalidArgumentError=e.errors=e.DrainingConnectionError=e.ConnectionError=e.ClosedConnectionError=e.AuthorizationError=e.wsUrlParseFn=e.wsconnect=e.Servers=e.isIPV4OrHostname=e.IdleHeartbeatMonitor=e.Subscriptions=e.SubscriptionImpl=e.syncIterator=e.Match=e.createInbox=e.protoLen=e.extractProtocolMessage=e.Empty=e.parseSemVer=e.Features=e.Feature=e.compare=e.parseIP=e.isIP=e.ipV4=e.TE=e.TD=void 0;var r=wB();Object.defineProperty(e,`NatsConnectionImpl`,{enumerable:!0,get:function(){return r.NatsConnectionImpl}});var i=Kz();Object.defineProperty(e,`Nuid`,{enumerable:!0,get:function(){return i.Nuid}}),Object.defineProperty(e,`nuid`,{enumerable:!0,get:function(){return i.nuid}});var a=iB();Object.defineProperty(e,`MsgImpl`,{enumerable:!0,get:function(){return a.MsgImpl}});var o=Yz();Object.defineProperty(e,`getResolveFn`,{enumerable:!0,get:function(){return o.getResolveFn}}),Object.defineProperty(e,`setTransportFactory`,{enumerable:!0,get:function(){return o.setTransportFactory}});var s=SB();Object.defineProperty(e,`Connect`,{enumerable:!0,get:function(){return s.Connect}}),Object.defineProperty(e,`INFO`,{enumerable:!0,get:function(){return s.INFO}}),Object.defineProperty(e,`ProtocolHandler`,{enumerable:!0,get:function(){return s.ProtocolHandler}});var c=Wz();Object.defineProperty(e,`backoff`,{enumerable:!0,get:function(){return c.backoff}}),Object.defineProperty(e,`collect`,{enumerable:!0,get:function(){return c.collect}}),Object.defineProperty(e,`deadline`,{enumerable:!0,get:function(){return c.deadline}}),Object.defineProperty(e,`deferred`,{enumerable:!0,get:function(){return c.deferred}}),Object.defineProperty(e,`delay`,{enumerable:!0,get:function(){return c.delay}}),Object.defineProperty(e,`extend`,{enumerable:!0,get:function(){return c.extend}}),Object.defineProperty(e,`millis`,{enumerable:!0,get:function(){return c.millis}}),Object.defineProperty(e,`nanos`,{enumerable:!0,get:function(){return c.nanos}}),Object.defineProperty(e,`render`,{enumerable:!0,get:function(){return c.render}}),Object.defineProperty(e,`SimpleMutex`,{enumerable:!0,get:function(){return c.SimpleMutex}}),Object.defineProperty(e,`timeout`,{enumerable:!0,get:function(){return c.timeout}});var l=rB();Object.defineProperty(e,`canonicalMIMEHeaderKey`,{enumerable:!0,get:function(){return l.canonicalMIMEHeaderKey}}),Object.defineProperty(e,`headers`,{enumerable:!0,get:function(){return l.headers}}),Object.defineProperty(e,`MsgHdrsImpl`,{enumerable:!0,get:function(){return l.MsgHdrsImpl}});var u=eB();Object.defineProperty(e,`Heartbeat`,{enumerable:!0,get:function(){return u.Heartbeat}});var d=$z();Object.defineProperty(e,`MuxSubscription`,{enumerable:!0,get:function(){return d.MuxSubscription}});var f=Jz();Object.defineProperty(e,`DataBuffer`,{enumerable:!0,get:function(){return f.DataBuffer}});var p=xB();Object.defineProperty(e,`buildAuthenticator`,{enumerable:!0,get:function(){return p.buildAuthenticator}}),Object.defineProperty(e,`checkOptions`,{enumerable:!0,get:function(){return p.checkOptions}}),Object.defineProperty(e,`checkUnsupportedOption`,{enumerable:!0,get:function(){return p.checkUnsupportedOption}}),Object.defineProperty(e,`DEFAULT_MAX_RECONNECT_ATTEMPTS`,{enumerable:!0,get:function(){return p.DEFAULT_MAX_RECONNECT_ATTEMPTS}}),Object.defineProperty(e,`defaultOptions`,{enumerable:!0,get:function(){return p.defaultOptions}}),Object.defineProperty(e,`hasWsProtocol`,{enumerable:!0,get:function(){return p.hasWsProtocol}}),Object.defineProperty(e,`parseOptions`,{enumerable:!0,get:function(){return p.parseOptions}});var m=CB();Object.defineProperty(e,`RequestOne`,{enumerable:!0,get:function(){return m.RequestOne}});var h=bB();Object.defineProperty(e,`credsAuthenticator`,{enumerable:!0,get:function(){return h.credsAuthenticator}}),Object.defineProperty(e,`jwtAuthenticator`,{enumerable:!0,get:function(){return h.jwtAuthenticator}}),Object.defineProperty(e,`nkeyAuthenticator`,{enumerable:!0,get:function(){return h.nkeyAuthenticator}}),Object.defineProperty(e,`tokenAuthenticator`,{enumerable:!0,get:function(){return h.tokenAuthenticator}}),Object.defineProperty(e,`usernamePasswordAuthenticator`,{enumerable:!0,get:function(){return h.usernamePasswordAuthenticator}}),n(yB(),e);var g=Qz();Object.defineProperty(e,`QueuedIteratorImpl`,{enumerable:!0,get:function(){return g.QueuedIteratorImpl}});var _=nB();Object.defineProperty(e,`describe`,{enumerable:!0,get:function(){return _.describe}}),Object.defineProperty(e,`Kind`,{enumerable:!0,get:function(){return _.Kind}}),Object.defineProperty(e,`Parser`,{enumerable:!0,get:function(){return _.Parser}}),Object.defineProperty(e,`State`,{enumerable:!0,get:function(){return _.State}});var v=tB();Object.defineProperty(e,`DenoBuffer`,{enumerable:!0,get:function(){return v.DenoBuffer}}),Object.defineProperty(e,`MAX_SIZE`,{enumerable:!0,get:function(){return v.MAX_SIZE}}),Object.defineProperty(e,`readAll`,{enumerable:!0,get:function(){return v.readAll}}),Object.defineProperty(e,`writeAll`,{enumerable:!0,get:function(){return v.writeAll}});var y=EB();Object.defineProperty(e,`Bench`,{enumerable:!0,get:function(){return y.Bench}}),Object.defineProperty(e,`Metric`,{enumerable:!0,get:function(){return y.Metric}});var b=Hz();Object.defineProperty(e,`TD`,{enumerable:!0,get:function(){return b.TD}}),Object.defineProperty(e,`TE`,{enumerable:!0,get:function(){return b.TE}});var x=Xz();Object.defineProperty(e,`ipV4`,{enumerable:!0,get:function(){return x.ipV4}}),Object.defineProperty(e,`isIP`,{enumerable:!0,get:function(){return x.isIP}}),Object.defineProperty(e,`parseIP`,{enumerable:!0,get:function(){return x.parseIP}});var S=aB();Object.defineProperty(e,`compare`,{enumerable:!0,get:function(){return S.compare}}),Object.defineProperty(e,`Feature`,{enumerable:!0,get:function(){return S.Feature}}),Object.defineProperty(e,`Features`,{enumerable:!0,get:function(){return S.Features}}),Object.defineProperty(e,`parseSemVer`,{enumerable:!0,get:function(){return S.parseSemVer}});var C=TB();Object.defineProperty(e,`Empty`,{enumerable:!0,get:function(){return C.Empty}});var w=Yz();Object.defineProperty(e,`extractProtocolMessage`,{enumerable:!0,get:function(){return w.extractProtocolMessage}}),Object.defineProperty(e,`protoLen`,{enumerable:!0,get:function(){return w.protoLen}});var T=qz();Object.defineProperty(e,`createInbox`,{enumerable:!0,get:function(){return T.createInbox}}),Object.defineProperty(e,`Match`,{enumerable:!0,get:function(){return T.Match}}),Object.defineProperty(e,`syncIterator`,{enumerable:!0,get:function(){return T.syncIterator}});var E=SB();Object.defineProperty(e,`SubscriptionImpl`,{enumerable:!0,get:function(){return E.SubscriptionImpl}}),Object.defineProperty(e,`Subscriptions`,{enumerable:!0,get:function(){return E.Subscriptions}});var D=DB();Object.defineProperty(e,`IdleHeartbeatMonitor`,{enumerable:!0,get:function(){return D.IdleHeartbeatMonitor}});var O=Zz();Object.defineProperty(e,`isIPV4OrHostname`,{enumerable:!0,get:function(){return O.isIPV4OrHostname}}),Object.defineProperty(e,`Servers`,{enumerable:!0,get:function(){return O.Servers}});var k=kB();Object.defineProperty(e,`wsconnect`,{enumerable:!0,get:function(){return k.wsconnect}}),Object.defineProperty(e,`wsUrlParseFn`,{enumerable:!0,get:function(){return k.wsUrlParseFn}});var A=Uz();Object.defineProperty(e,`AuthorizationError`,{enumerable:!0,get:function(){return A.AuthorizationError}}),Object.defineProperty(e,`ClosedConnectionError`,{enumerable:!0,get:function(){return A.ClosedConnectionError}}),Object.defineProperty(e,`ConnectionError`,{enumerable:!0,get:function(){return A.ConnectionError}}),Object.defineProperty(e,`DrainingConnectionError`,{enumerable:!0,get:function(){return A.DrainingConnectionError}}),Object.defineProperty(e,`errors`,{enumerable:!0,get:function(){return A.errors}}),Object.defineProperty(e,`InvalidArgumentError`,{enumerable:!0,get:function(){return A.InvalidArgumentError}}),Object.defineProperty(e,`InvalidOperationError`,{enumerable:!0,get:function(){return A.InvalidOperationError}}),Object.defineProperty(e,`InvalidSubjectError`,{enumerable:!0,get:function(){return A.InvalidSubjectError}}),Object.defineProperty(e,`NoRespondersError`,{enumerable:!0,get:function(){return A.NoRespondersError}}),Object.defineProperty(e,`PermissionViolationError`,{enumerable:!0,get:function(){return A.PermissionViolationError}}),Object.defineProperty(e,`ProtocolError`,{enumerable:!0,get:function(){return A.ProtocolError}}),Object.defineProperty(e,`RequestError`,{enumerable:!0,get:function(){return A.RequestError}}),Object.defineProperty(e,`TimeoutError`,{enumerable:!0,get:function(){return A.TimeoutError}}),Object.defineProperty(e,`UserAuthenticationExpiredError`,{enumerable:!0,get:function(){return A.UserAuthenticationExpiredError}})})),jB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.wsconnect=e.usernamePasswordAuthenticator=e.UserAuthenticationExpiredError=e.tokenAuthenticator=e.TimeoutError=e.syncIterator=e.RequestError=e.ProtocolError=e.PermissionViolationError=e.nuid=e.Nuid=e.NoRespondersError=e.nkeys=e.nkeyAuthenticator=e.nanos=e.MsgHdrsImpl=e.millis=e.Metric=e.Match=e.jwtAuthenticator=e.InvalidSubjectError=e.InvalidOperationError=e.InvalidArgumentError=e.headers=e.hasWsProtocol=e.errors=e.Empty=e.DrainingConnectionError=e.delay=e.deferred=e.deadline=e.credsAuthenticator=e.createInbox=e.ConnectionError=e.ClosedConnectionError=e.canonicalMIMEHeaderKey=e.buildAuthenticator=e.Bench=e.backoff=e.AuthorizationError=void 0;var t=AB();Object.defineProperty(e,`AuthorizationError`,{enumerable:!0,get:function(){return t.AuthorizationError}}),Object.defineProperty(e,`backoff`,{enumerable:!0,get:function(){return t.backoff}}),Object.defineProperty(e,`Bench`,{enumerable:!0,get:function(){return t.Bench}}),Object.defineProperty(e,`buildAuthenticator`,{enumerable:!0,get:function(){return t.buildAuthenticator}}),Object.defineProperty(e,`canonicalMIMEHeaderKey`,{enumerable:!0,get:function(){return t.canonicalMIMEHeaderKey}}),Object.defineProperty(e,`ClosedConnectionError`,{enumerable:!0,get:function(){return t.ClosedConnectionError}}),Object.defineProperty(e,`ConnectionError`,{enumerable:!0,get:function(){return t.ConnectionError}}),Object.defineProperty(e,`createInbox`,{enumerable:!0,get:function(){return t.createInbox}}),Object.defineProperty(e,`credsAuthenticator`,{enumerable:!0,get:function(){return t.credsAuthenticator}}),Object.defineProperty(e,`deadline`,{enumerable:!0,get:function(){return t.deadline}}),Object.defineProperty(e,`deferred`,{enumerable:!0,get:function(){return t.deferred}}),Object.defineProperty(e,`delay`,{enumerable:!0,get:function(){return t.delay}}),Object.defineProperty(e,`DrainingConnectionError`,{enumerable:!0,get:function(){return t.DrainingConnectionError}}),Object.defineProperty(e,`Empty`,{enumerable:!0,get:function(){return t.Empty}}),Object.defineProperty(e,`errors`,{enumerable:!0,get:function(){return t.errors}}),Object.defineProperty(e,`hasWsProtocol`,{enumerable:!0,get:function(){return t.hasWsProtocol}}),Object.defineProperty(e,`headers`,{enumerable:!0,get:function(){return t.headers}}),Object.defineProperty(e,`InvalidArgumentError`,{enumerable:!0,get:function(){return t.InvalidArgumentError}}),Object.defineProperty(e,`InvalidOperationError`,{enumerable:!0,get:function(){return t.InvalidOperationError}}),Object.defineProperty(e,`InvalidSubjectError`,{enumerable:!0,get:function(){return t.InvalidSubjectError}}),Object.defineProperty(e,`jwtAuthenticator`,{enumerable:!0,get:function(){return t.jwtAuthenticator}}),Object.defineProperty(e,`Match`,{enumerable:!0,get:function(){return t.Match}}),Object.defineProperty(e,`Metric`,{enumerable:!0,get:function(){return t.Metric}}),Object.defineProperty(e,`millis`,{enumerable:!0,get:function(){return t.millis}}),Object.defineProperty(e,`MsgHdrsImpl`,{enumerable:!0,get:function(){return t.MsgHdrsImpl}}),Object.defineProperty(e,`nanos`,{enumerable:!0,get:function(){return t.nanos}}),Object.defineProperty(e,`nkeyAuthenticator`,{enumerable:!0,get:function(){return t.nkeyAuthenticator}}),Object.defineProperty(e,`nkeys`,{enumerable:!0,get:function(){return t.nkeys}}),Object.defineProperty(e,`NoRespondersError`,{enumerable:!0,get:function(){return t.NoRespondersError}}),Object.defineProperty(e,`Nuid`,{enumerable:!0,get:function(){return t.Nuid}}),Object.defineProperty(e,`nuid`,{enumerable:!0,get:function(){return t.nuid}}),Object.defineProperty(e,`PermissionViolationError`,{enumerable:!0,get:function(){return t.PermissionViolationError}}),Object.defineProperty(e,`ProtocolError`,{enumerable:!0,get:function(){return t.ProtocolError}}),Object.defineProperty(e,`RequestError`,{enumerable:!0,get:function(){return t.RequestError}}),Object.defineProperty(e,`syncIterator`,{enumerable:!0,get:function(){return t.syncIterator}}),Object.defineProperty(e,`TimeoutError`,{enumerable:!0,get:function(){return t.TimeoutError}}),Object.defineProperty(e,`tokenAuthenticator`,{enumerable:!0,get:function(){return t.tokenAuthenticator}}),Object.defineProperty(e,`UserAuthenticationExpiredError`,{enumerable:!0,get:function(){return t.UserAuthenticationExpiredError}}),Object.defineProperty(e,`usernamePasswordAuthenticator`,{enumerable:!0,get:function(){return t.usernamePasswordAuthenticator}}),Object.defineProperty(e,`wsconnect`,{enumerable:!0,get:function(){return t.wsconnect}})})),MB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RepublishHeaders=e.DirectMsgHeaders=e.JsHeaders=e.AdvisoryKind=void 0,e.isOrderedPushConsumerOptions=t,e.isPullConsumer=n,e.isPushConsumer=r,e.isBoundPushConsumerOptions=i;function t(e){return e&&typeof e==`object`?`name_prefix`in e||`deliver_subject_prefix`in e||`filter_subjects`in e||`filter_subject`in e||`deliver_policy`in e||`opt_start_seq`in e||`opt_start_time`in e||`replay_policy`in e||`inactive_threshold`in e||`headers_only`in e||`deliver_prefix`in e:!1}function n(e){return e.isPullConsumer()}function r(e){return e.isPushConsumer()}function i(e){return e&&typeof e==`object`?`deliver_subject`in e||`deliver_group`in e||`idle_heartbeat`in e:!1}e.AdvisoryKind={API:`api_audit`,StreamAction:`stream_action`,ConsumerAction:`consumer_action`,SnapshotCreate:`snapshot_create`,SnapshotComplete:`snapshot_complete`,RestoreCreate:`restore_create`,RestoreComplete:`restore_complete`,MaxDeliver:`max_deliver`,Terminated:`terminated`,Ack:`consumer_ack`,StreamLeaderElected:`stream_leader_elected`,StreamQuorumLost:`stream_quorum_lost`,ConsumerLeaderElected:`consumer_leader_elected`,ConsumerQuorumLost:`consumer_quorum_lost`},e.JsHeaders={StreamSourceHdr:`Nats-Stream-Source`,LastConsumerSeqHdr:`Nats-Last-Consumer`,LastStreamSeqHdr:`Nats-Last-Stream`,ConsumerStalledHdr:`Nats-Consumer-Stalled`,MessageSizeHdr:`Nats-Msg-Size`,RollupHdr:`Nats-Rollup`,RollupValueSubject:`sub`,RollupValueAll:`all`,PendingMessagesHdr:`Nats-Pending-Messages`,PendingBytesHdr:`Nats-Pending-Bytes`},e.DirectMsgHeaders={Stream:`Nats-Stream`,Sequence:`Nats-Sequence`,TimeStamp:`Nats-Time-Stamp`,Subject:`Nats-Subject`,LastSequence:`Nats-Last-Sequence`,NumPending:`Nats-Num-Pending`},e.RepublishHeaders={Stream:`Nats-Stream`,Subject:`Nats-Subject`,Sequence:`Nats-Sequence`,LastSequence:`Nats-Last-Sequence`,Size:`Nats-Msg-Size`}})),NB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.jserrors=e.StreamNotFoundError=e.ConsumerNotFoundError=e.JetStreamApiError=e.InvalidNameError=e.JetStreamApiCodes=e.JetStreamStatus=e.JetStreamStatusError=e.JetStreamError=e.JetStreamNotEnabled=void 0,e.isMessageNotFound=a;var t=MB(),n=class extends Error{constructor(e,t){super(e,t),this.name=`JetStreamNotEnabled`}};e.JetStreamNotEnabled=n;var r=class extends Error{constructor(e,t){super(e,t),this.name=`JetStreamError`}};e.JetStreamError=r;var i=class extends r{code;constructor(e,t,n){super(e,n),this.code=t,this.name=`JetStreamStatusError`}};e.JetStreamStatusError=i,e.JetStreamStatus=class e{msg;_description;constructor(e){this.msg=e,this._description=``}static maybeParseStatus(t){let n=new e(t);return n.code===0?null:n}toError(){return new i(this.description,this.code)}debug(){console.log({subject:this.msg.subject,reply:this.msg.reply,description:this.description,status:this.code,headers:this.msg.headers})}get code(){return this.msg.headers?.code||0}get description(){return this._description===``&&(this._description=this.msg.headers?.description?.toLowerCase()||``,this._description===``&&(this._description=this.code===503?`no responders`:`unknown`)),this._description}isIdleHeartbeat(){return this.code===100&&this.description===`idle heartbeat`}isFlowControlRequest(){return this.code===100&&this.description===`flowcontrol request`}parseHeartbeat(){return this.isIdleHeartbeat()?{type:`heartbeat`,lastConsumerSequence:parseInt(this.msg.headers?.get(`Nats-Last-Consumer`)||`0`),lastStreamSequence:parseInt(this.msg.headers?.get(`Nats-Last-Stream`)||`0`)}:null}isRequestTimeout(){return this.code===408&&this.description===`request timeout`}parseDiscard(){let e={msgsLeft:0,bytesLeft:0},n=this.msg.headers?.get(t.JsHeaders.PendingMessagesHdr);n&&(e.msgsLeft=parseInt(n));let r=this.msg.headers?.get(t.JsHeaders.PendingBytesHdr);return r&&(e.bytesLeft=parseInt(r)),e}isBadRequest(){return this.code===400}isConsumerDeleted(){return this.code===409&&this.description===`consumer deleted`}isStreamDeleted(){return this.code===409&&this.description===`stream deleted`}isIdleHeartbeatMissed(){return this.code===409&&this.description===`idle heartbeats missed`}isMaxWaitingExceeded(){return this.code===409&&this.description===`exceeded maxwaiting`}isConsumerIsPushBased(){return this.code===409&&this.description===`consumer is push based`}isExceededMaxWaiting(){return this.code===409&&this.description.includes(`exceeded maxwaiting`)}isExceededMaxRequestBatch(){return this.code===409&&this.description.includes(`exceeded maxrequestbatch`)}isExceededMaxExpires(){return this.code===409&&this.description.includes(`exceeded maxrequestexpires`)}isExceededLimit(){return this.isExceededMaxExpires()||this.isExceededMaxWaiting()||this.isExceededMaxRequestBatch()||this.isMessageSizeExceedsMaxBytes()}isMessageNotFound(){return this.code===404&&this.description===`message not found`}isNoResults(){return this.code===404&&this.description===`no results`}isMessageSizeExceedsMaxBytes(){return this.code===409&&this.description===`message size exceeds maxbytes`}isEndOfBatch(){return this.code===204&&this.description===`eob`}},e.JetStreamApiCodes={ConsumerNotFound:10014,StreamNotFound:10059,JetStreamNotEnabledForAccount:10039,StreamWrongLastSequence:10071,StreamWrongLastSequenceUnknown:10164,NoMessageFound:10037};function a(t){return t instanceof s&&t.code===e.JetStreamApiCodes.NoMessageFound}var o=class extends Error{constructor(e=``,t){super(e,t),this.name=`InvalidNameError`}};e.InvalidNameError=o;var s=class extends Error{#e;constructor(e,t){super(e.description,t),this.#e=e,this.name=`JetStreamApiError`}get code(){return this.#e.err_code}get status(){return this.#e.code}apiError(){return Object.assign({},this.#e)}};e.JetStreamApiError=s;var c=class extends s{constructor(e,t){super(e,t),this.name=`ConsumerNotFoundError`}};e.ConsumerNotFoundError=c;var l=class t extends s{constructor(e,t){super(e,t),this.name=`StreamNotFoundError`}static fromMessage(n){return new t({err_code:e.JetStreamApiCodes.StreamNotFound,description:n,code:404})}};e.StreamNotFoundError=l,e.jserrors={InvalidNameError:o,ConsumerNotFoundError:c,StreamNotFoundError:l,JetStreamError:r,JetStreamApiError:s,JetStreamNotEnabled:n}})),PB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BaseApiClientImpl=void 0,e.defaultJsOptions=a;var t=AB(),n=NB(),r=`$JS.API`,i=5e3;function a(e){return e||={},e.domain&&(e.apiPrefix=`$JS.${e.domain}.API`,delete e.domain),(0,t.extend)({apiPrefix:r,timeout:i},e)}e.BaseApiClientImpl=class{nc;opts;prefix;timeout;constructor(e,t){this.nc=e,t||={},t.watcherPrefix=t.watcherPrefix||this.nc.options.inboxPrefix,this.opts=a(t),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let e=this.opts.apiPrefix;if(!e||e.length===0)throw t.errors.InvalidArgumentError.format(`prefix`,`cannot be empty`);e[e.length-1]===`.`&&(e=e.substr(0,e.length-1)),this.opts.apiPrefix=e,(0,t.createInbox)(this.opts.watcherPrefix)}async _request(e,r=null,i){i||={},i.timeout=this.timeout;let a=t.Empty;r&&(a=new TextEncoder().encode(JSON.stringify(r)));let{retries:o}=i;o||=1,o=o===-1?2**53-1:o;let s=(0,t.backoff)();for(let r=0;r<o;r++)try{let t=await this.nc.request(e,a,i);return this.parseJsResponse(t)}catch(e){let i=e instanceof t.RequestError?e:null;if((e instanceof t.errors.TimeoutError||i?.isNoResponders())&&r+1<o)await(0,t.delay)(s.backoff(r));else throw i?.isNoResponders()?new n.JetStreamNotEnabled(`jetstream is not enabled`,{cause:e}):e}}async findStream(e){let t={subject:e},r=await this._request(`${this.prefix}.STREAM.NAMES`,t);if(!r.streams||r.streams.length!==1)throw n.StreamNotFoundError.fromMessage(`no stream matches subject`);return r.streams[0]}getConnection(){return this.nc}parseJsResponse(e){let t=JSON.parse(new TextDecoder().decode(e.data)),r=t;if(r.error)switch(r.error.err_code){case n.JetStreamApiCodes.ConsumerNotFound:throw new n.ConsumerNotFoundError(r.error);case n.JetStreamApiCodes.StreamNotFound:throw new n.StreamNotFoundError(r.error);case n.JetStreamApiCodes.JetStreamNotEnabledForAccount:{let e=new n.JetStreamApiError(r.error);throw new n.JetStreamNotEnabled(e.message,{cause:e})}default:throw new n.JetStreamApiError(r.error)}return t}}})),FB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ListerImpl=void 0;var t=AB();e.ListerImpl=class{err;offset;pageInfo;subject;jsm;filter;payload;constructor(e,n,r,i){if(!e)throw t.errors.InvalidArgumentError.format(`subject`,`is required`);this.subject=e,this.jsm=r,this.offset=0,this.pageInfo={},this.filter=n,this.payload=i||{}}async next(){if(this.err||this.pageInfo&&this.offset>=this.pageInfo.total)return[];let e={offset:this.offset};this.payload&&Object.assign(e,this.payload);try{let t=await this.jsm._request(this.subject,e,{timeout:this.jsm.timeout});this.pageInfo=t;let n=this.countResponse(t);return n===0?[]:(this.offset+=n,this.filter(t))}catch(e){throw this.err=e,e}}countResponse(e){switch(e?.type){case`io.nats.jetstream.api.v1.stream_names_response`:case`io.nats.jetstream.api.v1.stream_list_response`:return e.streams?.length||0;case`io.nats.jetstream.api.v1.consumer_list_response`:return e.consumers?.length||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${e?.type}`),e.streams?.length||0}}async*[Symbol.asyncIterator](){let e=await this.next();for(;e.length>0;){for(let t of e)yield t;e=await this.next()}}}})),IB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateDurableName=n,e.validateStreamName=r,e.minValidation=i,e.validateName=a,e.validName=o;var t=NB();function n(e){return i(`durable`,e)}function r(e){return i(`stream`,e)}function i(e,n=``){if(n===``)throw Error(`${e} name required`);return[`.`,`*`,`>`,`/`,`\\`,` `,` `,`
|
|
104
|
+
`,`\r`].forEach(r=>{if(n.indexOf(r)!==-1){switch(r){case`
|
|
105
|
+
`:r=`\\n`;break;case`\r`:r=`\\r`;break;case` `:r=`\\t`;break;default:}throw new t.InvalidNameError(`${e} name ('${n}') cannot contain '${r}'`)}}),``}function a(e,t=``){if(t===``)throw Error(`${e} name required`);let n=o(t);if(n.length)throw Error(`invalid ${e} name - ${e} name ${n}`)}function o(e=``){if(e===``)throw Error(`name required`);let t=/^[-\w]+$/g;if(e.match(t)===null){for(let n of e.split(``))if(n.match(t)===null)return`cannot contain '${n}'`}return``}})),LB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PubHeaders=e.PriorityPolicy=e.ConsumerApiAction=e.PersistMode=e.StoreCompression=e.ReplayPolicy=e.AckPolicy=e.DeliverPolicy=e.StorageType=e.DiscardPolicy=e.RetentionPolicy=void 0,e.defaultConsumer=n;var t=jB();e.RetentionPolicy={Limits:`limits`,Interest:`interest`,Workqueue:`workqueue`},e.DiscardPolicy={Old:`old`,New:`new`},e.StorageType={File:`file`,Memory:`memory`},e.DeliverPolicy={All:`all`,Last:`last`,New:`new`,StartSequence:`by_start_sequence`,StartTime:`by_start_time`,LastPerSubject:`last_per_subject`},e.AckPolicy={None:`none`,All:`all`,Explicit:`explicit`,NotSet:``},e.ReplayPolicy={Instant:`instant`,Original:`original`},e.StoreCompression={None:`none`,S2:`s2`},e.PersistMode={Default:`default`,Async:`async`},e.ConsumerApiAction={CreateOrUpdate:``,Update:`update`,Create:`create`},e.PriorityPolicy={None:`none`,Overflow:`overflow`,PinnedClient:`pinned_client`,Prioritized:`prioritized`};function n(n,r={}){return Object.assign({name:n,deliver_policy:e.DeliverPolicy.All,ack_policy:e.AckPolicy.Explicit,ack_wait:(0,t.nanos)(30*1e3),replay_policy:e.ReplayPolicy.Instant},r)}e.PubHeaders={MsgIdHdr:`Nats-Msg-Id`,ExpectedStreamHdr:`Nats-Expected-Stream`,ExpectedLastSeqHdr:`Nats-Expected-Last-Sequence`,ExpectedLastMsgIdHdr:`Nats-Expected-Last-Msg-Id`,ExpectedLastSubjectSequenceHdr:`Nats-Expected-Last-Subject-Sequence`,ExpectedLastSubjectSequenceSubjectHdr:`Nats-Expected-Last-Subject-Sequence-Subject`,MessageTTL:`Nats-TTL`,Schedule:`Nats-Schedule`,ScheduleTarget:`Nats-Schedule-Target`,ScheduleSource:`Nats-Schedule-Source`,ScheduleTTL:`Nats-Schedule-TTL`}})),RB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ConsumerAPIImpl=void 0;var t=PB(),n=FB(),r=IB(),i=AB(),a=LB();e.ConsumerAPIImpl=class extends t.BaseApiClientImpl{constructor(e,t){super(e,t)}async addUpdate(e,t,n){if((0,r.validateStreamName)(e),n||={},t.deliver_group&&t.flow_control)throw i.InvalidArgumentError.format([`flow_control`,`deliver_group`],`are mutually exclusive`);if(t.deliver_group&&t.idle_heartbeat)throw i.InvalidArgumentError.format([`idle_heartbeat`,`deliver_group`],`are mutually exclusive`);if(o(t)){let{min:e,ok:n}=this.nc.features.get(i.Feature.JS_PRIORITY_GROUPS);if(!n)throw Error(`priority_groups require server ${e}`);if(t.deliver_subject)throw i.InvalidArgumentError.format(`deliver_subject`,`cannot be set when using priority groups`);s(t)}let c={};c.config=t,c.stream_name=e,c.action=n.action||a.ConsumerApiAction.Create,c.pedantic=n.pedantic||!1,c.config.durable_name&&(0,r.validateDurableName)(c.config.durable_name);let l=this.nc,{min:u,ok:d}=l.features.get(i.Feature.JS_NEW_CONSUMER_CREATE_API),f=t.name===``?void 0:t.name;if(f&&!d)throw i.InvalidArgumentError.format(`name`,`requires server ${u}`);if(f)try{(0,r.minValidation)(`name`,f)}catch(e){let t=e.message,n=t.indexOf(`cannot contain`);throw n===-1?e:Error(`consumer 'name' ${t.substring(n)}`)}let p,m=``;if(Array.isArray(t.filter_subjects)){let{min:e,ok:t}=l.features.get(i.Feature.JS_MULTIPLE_CONSUMER_FILTER);if(!t)throw i.InvalidArgumentError.format(`filter_subjects`,`requires server ${e}`);d=!1}if(t.metadata){let{min:e,ok:t}=l.features.get(i.Feature.JS_STREAM_CONSUMER_METADATA);if(!t)throw i.InvalidArgumentError.format(`metadata`,`requires server ${e}`)}if(d&&(m=t.name??t.durable_name??``),m!==``){let n=t.filter_subject??void 0;n===`>`&&(n=void 0),p=n===void 0?`${this.prefix}.CONSUMER.CREATE.${e}.${m}`:`${this.prefix}.CONSUMER.CREATE.${e}.${m}.${n}`}else p=t.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${e}.${t.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${e}`;return await this._request(p,c)}add(e,t,n){n||={};let r=a.ConsumerApiAction.Create;typeof n==`string`&&(r=n,n={});let i=Object.assign({},{action:r},n);return this.addUpdate(e,t,i)}async update(e,t,n){let r=await this.info(e,t),i=n;return this.addUpdate(e,Object.assign(r.config,i),{action:a.ConsumerApiAction.Update})}async info(e,t){return(0,r.validateStreamName)(e),(0,r.validateDurableName)(t),await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${t}`)}async delete(e,t){return(0,r.validateStreamName)(e),(0,r.validateDurableName)(t),(await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${t}`)).success}list(e){(0,r.validateStreamName)(e);let t=e=>e.consumers,i=`${this.prefix}.CONSUMER.LIST.${e}`;return new n.ListerImpl(i,t,this)}pause(e,t,n){let r=`${this.prefix}.CONSUMER.PAUSE.${e}.${t}`,i={pause_until:n.toISOString()};return this._request(r,i)}resume(e,t){return this.pause(e,t,new Date(0))}unpin(e,t,n){let r=`${this.prefix}.CONSUMER.UNPIN.${e}.${t}`;return this._request(r,{group:n})}};function o(e){let t=e;return t&&t.priority_groups!==void 0||t.priority_policy!==void 0}function s(e){if(o(e)){if(!Array.isArray(e.priority_groups))throw i.InvalidArgumentError.format([`priority_groups`],`must be an array`);if(e.priority_groups.length===0)throw i.InvalidArgumentError.format([`priority_groups`],`must have at least one group`);if(e.priority_groups.forEach(e=>{if((0,r.minValidation)(`priority_group`,e),e.length>16)throw i.errors.InvalidArgumentError.format(`group`,`must be 16 characters or less`)}),e.priority_policy!==a.PriorityPolicy.None&&e.priority_policy!==a.PriorityPolicy.Overflow&&e.priority_policy!==a.PriorityPolicy.PinnedClient&&e.priority_policy!==a.PriorityPolicy.Prioritized)throw i.InvalidArgumentError.format([`priority_policy`],`must be 'none', 'prioritized', 'overflow', or 'pinned_client'`)}}})),zB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.JsMsgImpl=e.ACK=void 0,e.toJsMsg=s,e.parseInfo=c;var t=AB();e.ACK=Uint8Array.of(43,65,67,75);var n=Uint8Array.of(45,78,65,75),r=Uint8Array.of(43,87,80,73),i=Uint8Array.of(43,78,88,84),a=Uint8Array.of(43,84,69,82,77),o=Uint8Array.of(32);function s(e,t=5e3){return new u(e,t)}function c(e){let t=e.split(`.`);if(t.length===9&&t.splice(2,0,`_`,``),t.length<11||t[0]!==`$JS`||t[1]!==`ACK`)throw Error(`unable to parse delivery info - not a jetstream message`);let n={};return n.domain=t[2]===`_`?``:t[2],n.account_hash=t[3],n.stream=t[4],n.consumer=t[5],n.deliveryCount=parseInt(t[6],10),n.redelivered=n.deliveryCount>1,n.streamSequence=parseInt(t[7],10),n.deliverySequence=parseInt(t[8],10),n.timestampNanos=parseInt(t[9],10),n.pending=parseInt(t[10],10),n}function l(e){let t=e.split(`.`);if(t.length===9&&t.splice(2,0,`_`,``),t.length<11||t[0]!==`$JS`||t[1]!==`ACK`)throw Error(`unable to parse delivery info - not a jetstream message`);return BigInt(t[9])}var u=class{msg;di;didAck;timeout;constructor(e,t){this.msg=e,this.didAck=!1,this.timeout=t}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||=c(this.reply),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||``}get seq(){return this.info.streamSequence}get time(){let e=(0,t.millis)(this.info.timestampNanos);return new Date(e)}get timestamp(){return this.time.toISOString()}get timestampNanos(){return l(this.reply)}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]&&e[3]===r[3]}async ackAck(n){let r=(0,t.deferred)();if(this.didAck)r.resolve(!1);else if(this.didAck=!0,this.msg.reply){n||={},n.timeout=n.timeout||this.timeout;let i=this.msg.publisher,a=!i.options?.noAsyncTraces,o=new t.RequestOne(i.muxSubscriptions,this.msg.reply,{timeout:n.timeout},a);i.request(o);try{i.publish(this.msg.reply,e.ACK,{reply:`${i.muxSubscriptions.baseInbox}${o.token}`})}catch(e){o.cancel(e)}try{await Promise.race([o.timer,o.deferred]),r.resolve(!0)}catch(e){o.cancel(e),r.reject(e)}}else r.resolve(!1);return r}ack(){this.doAck(e.ACK)}nak(e){let r=n;e&&(r=new TextEncoder().encode(`-NAK ${JSON.stringify({delay:(0,t.nanos)(e)})}`)),this.doAck(r)}working(){this.doAck(r)}next(e,n={batch:1}){let r={};r.batch=n.batch||1,r.no_wait=n.no_wait||!1,n.expires&&n.expires>0&&(r.expires=(0,t.nanos)(n.expires));let a=new TextEncoder().encode(JSON.stringify(r)),s=t.DataBuffer.concat(i,o,a),c=e?{reply:e}:void 0;this.msg.respond(s,c)}term(e=``){let t=a;e?.length>0&&(t=new TextEncoder().encode(`+TERM ${e}`)),this.doAck(t)}json(){return this.msg.json()}string(){return this.msg.string()}};e.JsMsgImpl=u})),BB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PullConsumerImpl=e.PullConsumerMessagesImpl=e.PullConsumerType=void 0,e.isOverflowOptions=o,e.isPrioritizedOptions=s,e.validateOverflowPullOptions=l,e.validatePrioritizedPullOptions=u;var t=AB(),n=zB(),r=LB(),i=NB(),a=IB();e.PullConsumerType={Unset:``,Consume:`consume`,Fetch:`fetch`};function o(e){let t=e;return t&&typeof t.group==`string`||typeof t.min_pending==`number`||typeof t.min_ack_pending==`number`}function s(e){let t=e;return t&&typeof t.group==`string`&&typeof t.priority==`number`}var c=class extends t.QueuedIteratorImpl{consumer;opts;sub;monitor;pending;isConsume;callback;listeners;statusIterator;abortOnMissingResource;bind;inboxPrefix;inbox;cancelables;inReset;closeListener;isPinned;isPriority;natsPinId;constructor(e,n,r=!1){if(super(),this.consumer=e,this.isConsume=r,this.cancelables=[],this.inboxPrefix=(0,t.createInbox)(this.consumer.api.nc.options.inboxPrefix),this.inbox=`${this.inboxPrefix}.${this.consumer.serial}`,this.inReset=!1,this.isPinned=!1,this.isPriority=!1,this.natsPinId=``,this.consumer.ordered){if(o(n))throw t.errors.InvalidArgumentError.format([`group`,`min_pending`,`min_ack_pending`],`cannot be specified for ordered consumers`);if(this.consumer.orderedConsumerState===void 0){let n={},r=e.opts;n.namePrefix=r.name_prefix??`oc_${t.nuid.next()}`,n.opts=r,n.cursor={stream_seq:1,deliver_seq:0};let i=e._info.config.opt_start_seq||0;n.cursor.stream_seq=i>0?i-1:0,n.createFails=0,this.consumer.orderedConsumerState=n}}let i=n;if(this.opts=this.parseOptions(n,this.isConsume),this.callback=i.callback||null,this.noIterator=typeof this.callback==`function`,this.monitor=null,this.pending={msgs:0,bytes:0,requests:0},this.listeners=[],this.abortOnMissingResource=i.abort_on_missing_resource===!0,this.bind=i.bind===!0,i.group){let{min_pending:e,min_ack_pending:t}=i;this.isPinned=e===void 0&&t===void 0;let{priority:n}=i;this.isPriority=typeof n==`number`}this.closeListener={connectionClosedCallback:()=>{this._push(()=>{this.stop()})}},this.consumer.api.nc.addCloseListener(this.closeListener),this.start()}start(){let{max_messages:e,max_bytes:r,idle_heartbeat:a,threshold_bytes:o,threshold_messages:s}=this.opts;this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(t,a)=>{if(t){this.stop(t);return}if(this.monitor?.work(),this.consumer.ordered?a.subject.indexOf(this?.inboxPrefix)===0:a.subject===this.inbox){if(a.subject!==this.sub.getSubject())return;let e=new i.JetStreamStatus(a),t=e.parseHeartbeat();if(t){this.notify(t);return}let n=e.code,r=e.description,{msgsLeft:o,bytesLeft:s}=e.parseDiscard();switch((o&&o>0||s&&s>0)&&(this.pending.msgs-=o,this.pending.bytes-=s,this.pending.requests--,this.notify({type:`discard`,messagesLeft:o,bytesLeft:s})),n){case 400:this.stop(e.toError());return;case 409:{let t=this.handle409(e);if(t){this.stop(t);return}if(e.isMessageSizeExceedsMaxBytes()&&this.yields.length>0)break;return}case 423:this.natsPinId=``,this.notify({type:`consumer_unpinned`});break;case 503:if(this.notify({type:`no_responders`,code:n}),this.consumer.ordered){let e=this.consumer.orderedConsumerState;e.needsReset=!0}if(!this.isConsume){this.stop(e.toError());return}break;default:this.notify({type:`debug`,code:n,description:r})}}else{let e=(0,n.toJsMsg)(a,this.consumer.api.timeout);if(this.isPinned){let t=e?.headers?.get(`Nats-Pin-Id`);t&&this.natsPinId===``&&(this.natsPinId=t,this.notify({type:`consumer_pinned`,id:t}))}if(this.consumer.ordered){let t=this.consumer.orderedConsumerState.cursor,n=e.info.deliverySequence,r=e.info.streamSequence;if(n!==t.deliver_seq+1){this.reset();return}t.deliver_seq=n,t.stream_seq=r}this._push(e),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=a.size())}if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.isConsume){if(e&&this.pending.msgs<=s||r&&this.pending.bytes<=o){let e=this.pullOptions();this.pull(e)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),a&&(this.monitor=new t.IdleHeartbeatMonitor(a,e=>(this.notify({type:`heartbeats_missed`,count:e}),!this.isConsume&&!this.consumer.ordered?(this.stop(new i.JetStreamError(`heartbeats missed`)),!0):(this.resetPending().then(()=>{}).catch(()=>{}),!1)),{maxOut:2})),(async()=>{let e=this.consumer.api.nc.status();this.statusIterator=e;for await(let t of e)switch(t.type){case`disconnect`:this.monitor?.cancel();break;case`reconnect`:this.resetPending().then(e=>{e&&this.monitor?.restart()}).catch(()=>{});break;default:}})(),this.sub.closed.then(()=>{this.sub.isDraining()&&this._push(()=>{this.stop()})}),this.pull(this.pullOptions())}handle409(e){let{code:t,description:n}=e;return e.isConsumerDeleted()?this.notify({type:`consumer_deleted`,code:t,description:n}):e.isExceededLimit()&&this.notify({type:`exceeded_limits`,code:t,description:n}),!this.isConsume||e.isConsumerDeleted()&&this.abortOnMissingResource?e.toError():null}reset(){this.monitor?.cancel();let e=this.consumer.orderedConsumerState,{name:n}=this.consumer._info?.config;n&&(this.notify({type:`reset`,name:n}),this.consumer.api.delete(this.consumer.stream,n).catch(()=>{}));let r=this.consumer.getConsumerOpts();this.inbox=`${this.inboxPrefix}.${this.consumer.serial}`,e.cursor.deliver_seq=0,this.consumer.name=r.name,this.consumer.api.nc._resub(this.sub,this.inbox),this.consumer.api.add(this.consumer.stream,r).then(t=>{e.createFails=0,this.consumer._info=t,this.notify({type:`ordered_consumer_recreated`,name:t.name}),this.monitor?.restart(),this.pull(this.pullOptions())}).catch(n=>{if(e.createFails++,n.message===`stream not found`&&(this.notify({type:`stream_not_found`,consumerCreateFails:e.createFails,name:this.consumer.stream}),this.abortOnMissingResource)){this.stop(n);return}e.createFails>=30&&this.received===0&&this.stop(n);let r=(0,t.backoff)(),i=(0,t.delay)(r.backoff(e.createFails));i.then(()=>{let e=this.cancelables.indexOf(i);e!==-1&&(this.cancelables=this.cancelables.splice(e,e)),this.done||this.reset()}).catch(e=>{}),this.cancelables.push(i)})}_push(e){if(!this.callback)super.push(e);else{let t=typeof e==`function`?e:null;try{if(t)t();else{let t=e;this.callback(t)}}catch(e){this.stop(e)}}}notify(e){this.listeners.length>0&&this.listeners.forEach(t=>{let n=t;n.done||n.push(e)})}async resetPending(){if(this.inReset)return Promise.resolve(!0);this.inReset=!0;let e=await(this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo());return this.inReset=!1,e}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){let e=0,n=0,r=(0,t.backoff)([this.opts.expires||3e4]),i=0;for(;;){if(this.done||this.consumer.api.nc.isClosed())return!1;try{return await this.consumer.info(),e=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(a){if(a instanceof t.errors.ClosedConnectionError)return this.stop(a),!1;if(a.message===`stream not found`){if(n++,this.notify({type:`stream_not_found`,name:this.consumer.stream}),!this.isConsume||this.abortOnMissingResource)return this.stop(a),!1}else if(a.message===`consumer not found`){if(e++,this.notify({type:`consumer_not_found`,name:this.consumer.name,stream:this.consumer.stream,count:e}),!this.isConsume||this.abortOnMissingResource){if(this.consumer.ordered){let e=this.consumer.orderedConsumerState;e.needsReset=!0}return this.stop(a),!1}if(this.consumer.ordered)return this.reset(),!1}else e=0,n=0;let o=r.backoff(i),s=(0,t.delay)(o);await Promise.race([s,this.consumer.api.nc.closed()]),s.cancel(),i++}}}pull(e){this.pending.bytes+=e.max_bytes??0,this.pending.msgs+=e.batch??0,this.pending.requests++;let t=this.consumer.api.nc,n=`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer._info.name}`;this._push(()=>{t.publish(n,JSON.stringify(e),{reply:this.inbox}),this.notify({type:`next`,options:e})})}pullOptions(){let e={batch:this.opts.max_messages-this.pending.msgs,max_bytes:this.opts.max_bytes-this.pending.bytes,idle_heartbeat:(0,t.nanos)(this.opts.idle_heartbeat),expires:(0,t.nanos)(this.opts.expires)};return this.isPinned&&this.natsPinId!==``&&(e.id=this.natsPinId),o(this.opts)&&(e.group=this.opts.group,this.opts.min_pending&&(e.min_pending=this.opts.min_pending),this.opts.min_ack_pending&&(e.min_ack_pending=this.opts.min_ack_pending)),s(this.opts)&&(e.group=this.opts.group,e.priority=this.opts.priority),e}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){this.monitor?.cancel(),this.monitor=null}stop(e){this.done||(this.consumer.api.nc.removeCloseListener(this.closeListener),this.sub?.unsubscribe(),this.clearTimers(),this.statusIterator?.stop(),this._push(()=>{super.stop(e),this.listeners.forEach(e=>{e.stop()})}))}parseOptions(e,n=!1){let r=e||{};if(r.max_messages=r.max_messages||0,r.max_bytes=r.max_bytes||0,r.max_messages!==0&&r.max_bytes!==0)throw t.errors.InvalidArgumentError.format([`max_messages`,`max_bytes`],`are mutually exclusive`);if(r.max_messages===0&&(r.max_messages=100),r.expires=r.expires||3e4,r.expires<1e3)throw t.errors.InvalidArgumentError.format(`expires`,`must be at least 1000ms`);if(r.idle_heartbeat=r.idle_heartbeat||r.expires/2,r.idle_heartbeat=r.idle_heartbeat>3e4?3e4:r.idle_heartbeat,r.idle_heartbeat<500&&(r.idle_heartbeat=500),n){let e=Math.round(r.max_messages*.75)||1;r.threshold_messages=r.threshold_messages||e;let t=Math.round(r.max_bytes*.75)||1;r.threshold_bytes=r.threshold_bytes||t}if(o(e)){let{min:n,ok:i}=this.consumer.api.nc.features.get(t.Feature.JS_PRIORITY_GROUPS);if(!i)throw Error(`priority_groups require server ${n}`);l(e),e.group&&(r.group=e.group),e.min_ack_pending&&(r.min_ack_pending=e.min_ack_pending),e.min_pending&&(r.min_pending=e.min_pending)}else s(e)&&(u(e),e.group&&(r.group=e.group),typeof e.priority==`number`&&(r.priority=e.priority));return r}status(){let e=new t.QueuedIteratorImpl;return this.listeners.push(e),e}};e.PullConsumerMessagesImpl=c,e.PullConsumerImpl=class{api;_info;stream;name;opts;type;messages;ordered;serial;orderedConsumerState;constructor(t,n,r=null){this.api=t,this._info=n,this.name=n.name,this.stream=n.stream_name,this.ordered=r!==null,this.opts=r||{},this.serial=1,this.type=e.PullConsumerType.Unset}debug(){console.log({serial:this.serial,cursor:this.orderedConsumerState?.cursor})}isPullConsumer(){return!0}isPushConsumer(){return!1}consume(n={max_messages:100,expires:3e4}){if(n={...n},this.ordered){if(n.bind)return Promise.reject(t.errors.InvalidArgumentError.format(`bind`,`is not supported`));if(this.type===e.PullConsumerType.Fetch)return Promise.reject(new t.errors.InvalidOperationError(`ordered consumer initialized as fetch`));if(this.type===e.PullConsumerType.Consume)return Promise.reject(new t.errors.InvalidOperationError(`ordered consumer doesn't support concurrent consume`));this.type=e.PullConsumerType.Consume}return Promise.resolve(new c(this,n,!0))}async fetch(n={max_messages:100,expires:3e4}){if(n={...n},this.ordered){if(n.group)return Promise.reject(t.errors.InvalidArgumentError.format(`group`,`ordered consumers don't support priority groups`));if(n.bind)return Promise.reject(t.errors.InvalidArgumentError.format(`bind`,`is not supported`));if(this.type===e.PullConsumerType.Consume)return Promise.reject(new t.errors.InvalidOperationError(`ordered consumer already initialized as consume`));if(this.messages?.done===!1)return Promise.reject(new t.errors.InvalidOperationError(`ordered consumer doesn't support concurrent fetch`));this.ordered&&(this.orderedConsumerState?.cursor?.deliver_seq&&(this._info.config.opt_start_seq=this.orderedConsumerState?.cursor.stream_seq+1),this.orderedConsumerState?.needsReset===!0&&await this._reset()),this.type=e.PullConsumerType.Fetch}let r=new c(this,n);return this.ordered&&(this.messages=r),Promise.resolve(r)}async next(e={expires:3e4}){e={...e};let t=e;t.max_messages=1;let n=await this.fetch(t);try{for await(let e of n)return e}catch(e){return Promise.reject(e)}return null}delete(){let{stream_name:e,name:t}=this._info;return this.api.delete(e,t)}getConsumerOpts(){let e=this.orderedConsumerState;this.serial++,this.name=`${e.namePrefix}_${this.serial}`;let n=Object.assign({},this._info.config,{name:this.name,deliver_policy:r.DeliverPolicy.StartSequence,opt_start_seq:e.cursor.stream_seq+1,ack_policy:r.AckPolicy.None,inactive_threshold:(0,t.nanos)(300*1e3),num_replicas:1});return delete n.metadata,n}async _reset(){if(this.messages===void 0)throw Error(`not possible to reset`);this.delete().catch(()=>{});let e=this.getConsumerOpts(),t=await this.api.add(this.stream,e);return this._info=t,t}async info(e=!1){if(e)return Promise.resolve(this._info);let{stream_name:t,name:n}=this._info;return this._info=await this.api.info(t,n),this._info}};function l(e){if(o(e)){if((0,a.minValidation)(`group`,e.group),e.group.length>16)throw t.errors.InvalidArgumentError.format(`group`,`must be 16 characters or less`);let{min_pending:n,min_ack_pending:r}=e;if(n&&typeof n!=`number`)throw t.errors.InvalidArgumentError.format([`min_pending`],`must be a number`);if(r&&typeof r!=`number`)throw t.errors.InvalidArgumentError.format([`min_ack_pending`],`must be a number`)}}function u(e){if(s(e)){if((0,a.minValidation)(`group`,e.group),e.group.length>16)throw t.errors.InvalidArgumentError.format(`group`,`must be 16 characters or less`);let{priority:n}=e;if(n&&typeof n!=`number`)throw t.errors.InvalidArgumentError.format([`priority`],`must be a number`)}}})),VB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PushConsumerImpl=e.PushConsumerMessagesImpl=void 0;var t=zB(),n=LB(),r=AB(),i=NB(),a=class extends r.QueuedIteratorImpl{consumer;sub;monitor;listeners;abortOnMissingResource;callback;ordered;cursor;namePrefix;deliverPrefix;serial;createFails;statusIterator;cancelables;constructor(e,t={},n={}){if(super(),this.consumer=e,this.monitor=null,this.listeners=[],this.cancelables=[],this.abortOnMissingResource=t.abort_on_missing_resource===!0,this.callback=t.callback||null,this.noIterator=this.callback!==null,this.namePrefix=null,this.deliverPrefix=null,this.ordered=n.ordered===!0,this.serial=1,this.ordered){this.namePrefix=n.name_prefix??`oc_${r.nuid.next()}`,this.deliverPrefix=n.deliver_prefix??(0,r.createInbox)(this.consumer.api.nc.options.inboxPrefix),this.cursor={stream_seq:1,deliver_seq:0};let t=e._info.config.opt_start_seq||0;this.cursor.stream_seq=t>0?t-1:0,this.createFails=0}this.start()}reset(){let{name:e}=this.consumer._info?.config;e&&this.consumer.api.delete(this.consumer.stream,e).catch(()=>{});let t=this.getConsumerOpts();this.cursor.deliver_seq=0,this.consumer.name=t.name,this.consumer.serial=this.serial,this.consumer.api.nc._resub(this.sub,t.deliver_subject),this.consumer.api.add(this.consumer.stream,t).then(e=>{this.createFails=0,this.consumer._info=e,this.notify({type:`ordered_consumer_recreated`,name:e.name})}).catch(e=>{if(this.createFails++,e.message===`stream not found`&&(this.notify({type:`stream_not_found`,name:this.consumer.stream,consumerCreateFails:this.createFails}),this.abortOnMissingResource)){this.stop(e);return}this.createFails>=30&&this.received===0&&this.stop(e);let t=(0,r.backoff)(),n=(0,r.delay)(t.backoff(this.createFails));n.then(()=>{this.done||this.reset()}).catch(()=>{}).finally(()=>{let e=this.cancelables.indexOf(n);e!==-1&&(this.cancelables=this.cancelables.splice(e,e))}),this.cancelables.push(n)})}getConsumerOpts(){let e=Object.assign({},this.consumer._info.config);this.serial++;let t=`${this.namePrefix}_${this.serial}`;return Object.assign(e,{name:t,deliver_policy:n.DeliverPolicy.StartSequence,opt_start_seq:this.cursor.stream_seq+1,ack_policy:n.AckPolicy.None,inactive_threshold:(0,r.nanos)(300*1e3),num_replicas:1,flow_control:!0,idle_heartbeat:(0,r.nanos)(30*1e3),deliver_subject:`${this.deliverPrefix}.${this.serial}`})}closed(){return this.iterClosed}close(){return this.stop(),this.iterClosed}stop(e){this.done||(this.statusIterator?.stop(),this.monitor?.cancel(),this.monitor=null,this.cancelables.forEach(e=>{e.cancel()}),Promise.all(this.cancelables).then(()=>{this.cancelables=[]}).catch(()=>{}).finally(()=>{this._push(()=>{super.stop(e),this.listeners.forEach(e=>{e.stop()})})}))}_push(e){if(!this.callback)super.push(e);else{let t=typeof e==`function`?e:null;try{if(t)t();else{let t=e;this.received++,this.callback(t),this.processed++}}catch(e){this.stop(e)}}}status(){let e=new r.QueuedIteratorImpl;return this.listeners.push(e),e}start(){let{deliver_subject:e,deliver_group:n,idle_heartbeat:a}=this.consumer._info.config;if(!e)throw Error(`bad consumer info`);if(a){let e=(0,r.millis)(a);this.monitor=new r.IdleHeartbeatMonitor(e,e=>(this.notify({type:`heartbeats_missed`,count:e}),this.ordered&&this.reset(),!1),{maxOut:2}),(async()=>{this.statusIterator=this.consumer.api.nc.status();for await(let e of this.statusIterator)switch(e.type){case`disconnect`:this.monitor?.cancel();break;case`reconnect`:this.monitor?.restart();break;default:}})()}this.sub=this.consumer.api.nc.subscribe(e,{queue:n,callback:(n,r)=>{if(n){this.stop(n);return}if(this.monitor?.work(),this.ordered?r.subject.indexOf(this?.deliverPrefix)===0:r.subject===e){if(r.subject!==this.sub.getSubject())return;let e=new i.JetStreamStatus(r);if(e.isFlowControlRequest()){this._push(()=>{r.respond(),this.notify({type:`flow_control`})});return}if(e.isIdleHeartbeat()){let e=parseInt(r.headers?.get(`Nats-Last-Consumer`)||`0`),t=parseInt(r.headers?.get(`Nats-Last-Stream`)??`0`);this.notify({type:`heartbeat`,lastStreamSequence:t,lastConsumerSequence:e});return}let t=e.code,n=e.description;if(e.isConsumerDeleted()&&this.notify({type:`consumer_deleted`,code:t,description:n}),this.abortOnMissingResource){this._push(()=>{this.stop(e.toError())});return}}else{let e=(0,t.toJsMsg)(r);if(this.ordered){let t=e.info.deliverySequence;if(t!==this.cursor.deliver_seq+1){this.reset();return}this.cursor.deliver_seq=t,this.cursor.stream_seq=e.info.streamSequence}this._push(e)}}}),this.sub.closed.then(()=>{this._push(()=>{this.stop()})}),this.closed().then(()=>{this.sub?.unsubscribe()})}notify(e){this.listeners.length>0&&this.listeners.forEach(t=>{let n=t;n.done||n.push(e)})}};e.PushConsumerMessagesImpl=a,e.PushConsumerImpl=class{api;_info;stream;name;bound;ordered;started;serial;opts;constructor(e,t,n={}){this.api=e,this._info=t,this.stream=t.stream_name,this.name=t.name,this.bound=n.bound===!0,this.started=!1,this.opts=n,this.serial=0,this.ordered=n.ordered||!1,this.ordered&&(this.serial=1)}consume(e={}){if(e={...e},this.started)return Promise.reject(new r.errors.InvalidOperationError(`consumer already started`));if(!this._info.config.deliver_subject)return Promise.reject(Error(`deliver_subject is not set, not a push consumer`));if(!this._info.config.deliver_group&&this._info.push_bound)return Promise.reject(new r.errors.InvalidOperationError(`consumer is already bound`));let t=new a(this,e,this.opts);return this.started=!0,t.closed().then(()=>{this.started=!1}),Promise.resolve(t)}delete(){if(this.bound)return Promise.reject(new r.errors.InvalidOperationError(`bound consumers cannot delete`));let{stream_name:e,name:t}=this._info;return this.api.delete(e,t)}async info(e){if(this.bound)return Promise.reject(new r.errors.InvalidOperationError(`bound consumers cannot info`));if(e)return Promise.resolve(this._info);let t=await this.api.info(this.stream,this.name);return this._info=t,t}isPullConsumer(){return!1}isPushConsumer(){return!0}}})),HB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.StreamsImpl=e.StoredMsgImpl=e.StreamAPIImpl=e.StreamImpl=e.ConsumersImpl=void 0,e.convertStreamSourceDomain=d;var t=AB(),n=PB(),r=FB(),i=IB(),a=MB(),o=LB(),s=BB(),c=RB(),l=VB(),u=NB();function d(e){if(e===void 0)return;let{domain:n}=e;if(n===void 0)return e;let r=Object.assign({},e);if(delete r.domain,n===``)return r;if(r.external)throw t.InvalidArgumentError.format([`domain`,`external`],`are mutually exclusive`);return r.external={api:`$JS.${n}.API`},r}var f=class{api;notified;constructor(e){this.api=e,this.notified=!1}checkVersion(){let e=this.api.nc.features.get(t.Feature.JS_SIMPLIFICATION);return e.ok?Promise.resolve():Promise.reject(Error(`consumers framework is only supported on servers ${e.min} or better`))}async getPushConsumer(e,t){if(await this.checkVersion(),(0,i.minValidation)(`stream`,e),typeof t==`string`){(0,i.minValidation)(`name`,t);let n=await this.api.info(e,t);return typeof n.config.deliver_subject==`string`?new l.PushConsumerImpl(this.api,n):Promise.reject(Error(`not a push consumer`))}else if(t===void 0)return this.getOrderedPushConsumer(e);else if((0,a.isOrderedPushConsumerOptions)(t)){let n=t;return this.getOrderedPushConsumer(e,n)}return Promise.reject(Error(`unsupported push consumer type`))}async getOrderedPushConsumer(e,n={}){n=Object.assign({},n);let{name_prefix:r,deliver_prefix:a,filter_subjects:s}=n;delete n.deliver_prefix,delete n.name_prefix,delete n.filter_subjects,typeof n.opt_start_seq==`number`&&(n.deliver_policy=o.DeliverPolicy.StartSequence),typeof n.opt_start_time==`string`&&(n.deliver_policy=o.DeliverPolicy.StartTime),r||=`oc_${t.nuid.next()}`,(0,i.minValidation)(`name_prefix`,r),a||=(0,t.createInbox)(this.api.getOptions().watcherPrefix);let c=Object.assign({},n);c.ack_policy=o.AckPolicy.None,c.inactive_threshold=(0,t.nanos)(300*1e3),c.num_replicas=1,c.max_deliver=1,c.flow_control=!0,c.idle_heartbeat=(0,t.nanos)(3e4),Array.isArray(s)&&(c.filter_subjects=s),typeof s==`string`&&(c.filter_subject=s),c.filter_subjects===void 0&&c.filter_subject===void 0&&(c.filter_subject=`>`),c.name=`${r}_1`,c.deliver_subject=`${a}.1`;let u=await this.api.add(e,c),d={name_prefix:r,deliver_prefix:a,ordered:!0};return new l.PushConsumerImpl(this.api,u,d)}getBoundPushConsumer(e){if((0,a.isBoundPushConsumerOptions)(e)){let t={config:e};return Promise.resolve(new l.PushConsumerImpl(this.api,t,{bound:!0}))}else return Promise.reject(t.errors.InvalidArgumentError.format(`deliver_subject`,`is required`))}async get(e,t){if(await this.checkVersion(),typeof t==`string`){let n=await this.api.info(e,t);return typeof n.config.deliver_subject==`string`?Promise.reject(Error(`not a pull consumer`)):new s.PullConsumerImpl(this.api,n)}else return this.ordered(e,t)}getConsumerFromInfo(e){if(typeof e.config.deliver_subject==`string`)throw Error(`not a pull consumer`);return new s.PullConsumerImpl(this.api,e)}async ordered(e,n={}){await this.checkVersion();let r=this.api;await new m(r.nc,r.opts).info(e),typeof n.name_prefix==`string`&&(0,i.minValidation)(`name_prefix`,n.name_prefix),n.name_prefix=n.name_prefix||t.nuid.next();let a={name:`${n.name_prefix}_1`,deliver_policy:o.DeliverPolicy.StartSequence,opt_start_seq:n.opt_start_seq||1,ack_policy:o.AckPolicy.None,inactive_threshold:(0,t.nanos)(300*1e3),num_replicas:1,max_deliver:1,mem_storage:!0};n.headers_only===!0&&(a.headers_only=!0),Array.isArray(n.filter_subjects)&&(a.filter_subjects=n.filter_subjects),typeof n.filter_subjects==`string`&&(a.filter_subject=n.filter_subjects),n.replay_policy&&(a.replay_policy=n.replay_policy),a.deliver_policy=n.deliver_policy||o.DeliverPolicy.StartSequence,(n.deliver_policy===o.DeliverPolicy.All||n.deliver_policy===o.DeliverPolicy.LastPerSubject||n.deliver_policy===o.DeliverPolicy.New||n.deliver_policy===o.DeliverPolicy.Last)&&(delete a.opt_start_seq,a.deliver_policy=n.deliver_policy),a.deliver_policy===o.DeliverPolicy.LastPerSubject&&a.filter_subjects===void 0&&a.filter_subject===void 0&&(a.filter_subject=`>`),n.opt_start_time&&(delete a.opt_start_seq,a.deliver_policy=o.DeliverPolicy.StartTime,a.opt_start_time=n.opt_start_time),n.inactive_threshold&&(a.inactive_threshold=(0,t.nanos)(n.inactive_threshold));let c=await this.api.add(e,a);return Promise.resolve(new s.PullConsumerImpl(this.api,c,n))}};e.ConsumersImpl=f;var p=class e{api;_info;constructor(e,t){this.api=e,this._info=t}get name(){return this._info.config.name}alternates(){return this.info().then(e=>e.alternates?e.alternates:[])}async best(){if(await this.info(),this._info.alternates){let t=await this.api.info(this._info.alternates[0].name);return new e(this.api,t)}else return this}info(e=!1,t){return e?Promise.resolve(this._info):this.api.info(this.name,t).then(e=>(this._info=e,this._info))}getConsumer(e){return new f(new c.ConsumerAPIImpl(this.api.nc,this.api.opts)).get(this.name,e)}getPushConsumer(e){return new f(new c.ConsumerAPIImpl(this.api.nc,this.api.opts)).getPushConsumer(this.name,e)}getMessage(e){return this.api.getMessage(this.name,e)}deleteMessage(e,t=!0){return this.api.deleteMessage(this.name,e,t)}};e.StreamImpl=p;var m=class extends n.BaseApiClientImpl{constructor(e,t){super(e,t)}checkStreamConfigVersions(e){let n=this.nc;if(e.metadata){let{min:e,ok:r}=n.features.get(t.Feature.JS_STREAM_CONSUMER_METADATA);if(!r)throw Error(`stream 'metadata' requires server ${e}`)}if(e.first_seq){let{min:e,ok:r}=n.features.get(t.Feature.JS_STREAM_FIRST_SEQ);if(!r)throw Error(`stream 'first_seq' requires server ${e}`)}if(e.subject_transform){let{min:e,ok:r}=n.features.get(t.Feature.JS_STREAM_SUBJECT_TRANSFORM);if(!r)throw Error(`stream 'subject_transform' requires server ${e}`)}if(e.compression){let{min:e,ok:r}=n.features.get(t.Feature.JS_STREAM_COMPRESSION);if(!r)throw Error(`stream 'compression' requires server ${e}`)}if(e.consumer_limits){let{min:e,ok:r}=n.features.get(t.Feature.JS_DEFAULT_CONSUMER_LIMITS);if(!r)throw Error(`stream 'consumer_limits' requires server ${e}`)}function r(e,r){if((r?.subject_transforms?.length||0)>0){let{min:r,ok:i}=n.features.get(t.Feature.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!i)throw Error(`${e} 'subject_transforms' requires server ${r}`)}}e.sources&&e.sources.forEach(e=>{r(`stream sources`,e)}),e.mirror&&r(`stream mirror`,e.mirror)}async add(e){this.checkStreamConfigVersions(e),(0,i.validateStreamName)(e.name),e.mirror=d(e.mirror),e.sources=e.sources?.map(d);let t=await this._request(`${this.prefix}.STREAM.CREATE.${e.name}`,e);return this._fixInfo(t),t}async delete(e){return(0,i.validateStreamName)(e),(await this._request(`${this.prefix}.STREAM.DELETE.${e}`)).success}async update(e,t={}){if(typeof e==`object`){let n=e;e=n.name,t=n,console.trace(`\x1B[33m >> streams.update(config: StreamConfig) api changed to streams.update(name: string, config: StreamUpdateConfig) - this shim will be removed - update your code. \x1B[0m`)}this.checkStreamConfigVersions(t),(0,i.validateStreamName)(e);let n=await this.info(e),r=Object.assign(n.config,t);r.mirror=d(r.mirror),r.sources=r.sources?.map(d);let a=await this._request(`${this.prefix}.STREAM.UPDATE.${e}`,r);return this._fixInfo(a),a}async info(e,t){(0,i.validateStreamName)(e);let n=`${this.prefix}.STREAM.INFO.${e}`,r=await this._request(n,t),{total:a,limit:o}=r,s=r.state.subjects?Object.getOwnPropertyNames(r.state.subjects).length:1;if(a&&a>s){let e=[r],i=t||{},c=0;for(;a>s;){c++,i.offset=o*c;let t=await this._request(n,i);a=t.total,e.push(t);let r=Object.getOwnPropertyNames(t.state.subjects).length;if(s+=r,r<o)break}let l={};for(let t=0;t<e.length;t++)r=e[t],r.state.subjects&&(l=Object.assign(l,r.state.subjects));r.offset=0,r.total=0,r.limit=0,r.state.subjects=l}return this._fixInfo(r),r}list(e=``){let t=e?.length?{subject:e}:{},n=e=>{let t=e;return t.streams.forEach(e=>{this._fixInfo(e)}),t.streams},i=`${this.prefix}.STREAM.LIST`;return new r.ListerImpl(i,n,this,t)}_fixInfo(e){e.config.sealed=e.config.sealed||!1,e.config.deny_delete=e.config.deny_delete||!1,e.config.deny_purge=e.config.deny_purge||!1,e.config.allow_rollup_hdrs=e.config.allow_rollup_hdrs||!1}async purge(e,n){if(n){let{keep:e,seq:r}=n;if(typeof e==`number`&&typeof r==`number`)throw t.InvalidArgumentError.format([`keep`,`seq`],`are mutually exclusive`)}return(0,i.validateStreamName)(e),await this._request(`${this.prefix}.STREAM.PURGE.${e}`,n)}async deleteMessage(e,t,n=!0){(0,i.validateStreamName)(e);let r={seq:t};return n||(r.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${e}`,r)).success}async getMessage(e,t){(0,i.validateStreamName)(e);try{return new h(await this._request(`${this.prefix}.STREAM.MSG.GET.${e}`,t))}catch(e){return e instanceof u.JetStreamApiError&&e.code===u.JetStreamApiCodes.NoMessageFound?null:Promise.reject(e)}}find(e){return this.findStream(e)}names(e=``){let t=e?.length?{subject:e}:{},n=e=>e.streams,i=`${this.prefix}.STREAM.NAMES`;return new r.ListerImpl(i,n,this,t)}async get(e){let t=await this.info(e);return Promise.resolve(new p(this,t))}};e.StreamAPIImpl=m;var h=class{_header;smr;static jc;constructor(e){this.smr=e}get pending(){return 0}get lastSequence(){return 0}get subject(){return this.smr.message.subject}get seq(){return this.smr.message.seq}get timestamp(){return this.smr.message.time}get time(){return new Date(Date.parse(this.timestamp))}get data(){return this.smr.message.data?this._parse(this.smr.message.data):t.Empty}get header(){if(!this._header)if(this.smr.message.hdrs){let e=this._parse(this.smr.message.hdrs);this._header=t.MsgHdrsImpl.decode(e)}else this._header=(0,t.headers)();return this._header}_parse(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r}json(e){return JSON.parse(new TextDecoder().decode(this.data),e)}string(){return t.TD.decode(this.data)}};e.StoredMsgImpl=h,e.StreamsImpl=class{api;constructor(e){this.api=e}get(e){return this.api.info(e).then(e=>new p(this.api,e))}}})),UB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DirectConsumer=e.DirectMsgImpl=e.DirectStreamAPIImpl=void 0;var t=PB(),n=MB(),r=AB(),i=IB(),a=NB();e.DirectStreamAPIImpl=class extends t.BaseApiClientImpl{constructor(e,t){super(e,t)}async getMessage(e,t){if((0,i.validateStreamName)(e),`start_time`in t){let{min:e,ok:t}=this.nc.features.get(r.Feature.JS_BATCH_DIRECT_GET);if(!t)throw Error(`start_time direct option require server ${e}`)}let n=t,{last_by_subj:s}=n;s&&(n=null);let c=n?JSON.stringify(n):r.Empty,l=this.opts.apiPrefix||`$JS.API`,u=s?`${l}.DIRECT.GET.${e}.${s}`:`${l}.DIRECT.GET.${e}`,d=await this.nc.request(u,c,{timeout:this.timeout});if(d.headers?.code!==0){let e=new a.JetStreamStatus(d);return e.isMessageNotFound()?Promise.resolve(null):Promise.reject(e.toError())}let f=new o(d);return Promise.resolve(f)}getBatch(e,t){return t.batch=t.batch||1024,this.get(e,t)}getLastMessagesFor(e,t){return this.get(e,t)}get(e,t){t={...t};let{min:n,ok:s}=this.nc.features.get(r.Feature.JS_BATCH_DIRECT_GET);if(!s)return Promise.reject(Error(`batch direct require server ${n}`));(0,i.validateStreamName)(e);let c=typeof t.callback==`function`?t.callback:null,l=new r.QueuedIteratorImpl;function u(e,t){if(e){l.push(()=>{e.err?l.stop(e.err):l.stop()});return}l.push(t)}function d(e,t){let n=c;if(typeof t==`function`){t();return}n(e,t)}c&&l.iterClosed.then(e=>{f({err:e||void 0},{}),h.unsubscribe()});let f=c?d:u,p=(0,r.createInbox)(this.nc.options.inboxPrefix),m=!1,h=this.nc.subscribe(p,{timeout:5e3,callback:(e,t)=>{if(e){l.stop(e),h.unsubscribe();return}let n=a.JetStreamStatus.maybeParseStatus(t);if(n){if(n.isNoResults()&&f({},()=>{l.stop()}),n.isEndOfBatch())f({},()=>{l.stop()});else{let e=n.toError();f({err:e},()=>{l.stop(e)})}return}m||(typeof t.headers?.get(`Nats-Num-Pending`)==`string`?m=!0:(h.unsubscribe(),f({},()=>{l.stop()}))),f(null,new o(t))}}),g=`${this.opts.apiPrefix||`$JS.API`}.DIRECT.GET.${e}`,_=JSON.stringify(t,(e,t)=>(e===`up_to_time`||e===`start_time`)&&t instanceof Date?t.toISOString():t);return this.nc.publish(g,_,{reply:p}),Promise.resolve(l)}};var o=class{data;header;constructor(e){if(!e.headers)throw Error(`headers expected`);this.data=e.data,this.header=e.headers}get subject(){return this.header.last(n.DirectMsgHeaders.Subject)}get seq(){let e=this.header.last(n.DirectMsgHeaders.Sequence);return typeof e==`string`?parseInt(e):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(n.DirectMsgHeaders.TimeStamp)}get stream(){return this.header.last(n.DirectMsgHeaders.Stream)}get lastSequence(){let e=this.header.last(n.DirectMsgHeaders.LastSequence);return typeof e==`string`?parseInt(e):0}get pending(){let e=this.header.last(n.DirectMsgHeaders.NumPending);return typeof e==`string`?parseInt(e):-1}json(e){return JSON.parse(new TextDecoder().decode(this.data),e)}string(){return r.TD.decode(this.data)}};e.DirectMsgImpl=o;function s(e){return typeof e==`object`&&`start_time`in e}function c(e){return typeof e==`object`&&`max_bytes`in e}e.DirectConsumer=class{stream;api;cursor;listeners;start;constructor(e,t,n){this.stream=e,this.api=t,this.cursor={last:0},this.listeners=[],this.start=n}getOptions(e){e||={};let t={};return this.cursor.last===0?s(this.start)?t.start_time=this.start.start_time:t.seq=this.start.seq||1:t.seq=this.cursor.last+1,c(e)?t.max_bytes=e.max_bytes:t.batch=e.batch??100,t}status(){let e=new r.QueuedIteratorImpl;return this.listeners.push(e),e}notify(e){this.listeners.length>0&&(()=>{let t=[];this.listeners.forEach(n=>{let r=n;r.done?t.push(r):r.push(e)}),this.listeners=this.listeners.filter(e=>!t.includes(e))})()}debug(){console.log(this.cursor)}consume(e){let t,n,i=new r.QueuedIteratorImpl;return(async()=>{for(;this.cursor.pending===0&&(this.notify({type:`debug`,code:0,description:`sleeping for 2500`}),t=(0,r.delay)(2500),await t),!i.done;){n=(0,r.deferred)();let o=this.getOptions(e);this.notify({type:`next`,options:Object.assign({},e)}),o.callback=(e,t)=>{e?(e.err&&(e.err instanceof a.JetStreamStatusError?this.notify({type:`debug`,code:e.err.code,description:e.err.message}):this.notify({type:`debug`,code:0,description:e.err.message})),n.resolve()):t.lastSequence>0&&t.lastSequence!==this.cursor.last?(s.stop(),n.resolve(),this.notify({type:`reset`,name:`direct`})):(i.push(t),i.received++,this.cursor.last=t.seq,this.cursor.pending=t.pending)};let s=await this.api.getBatch(this.stream,o);i.iterClosed.then(()=>{s.stop(),t?.cancel(),n?.resolve()}),await n}})().catch(e=>{i.stop(e)}),Promise.resolve(i)}async fetch(e){let t=this.getOptions(e),n=new r.QueuedIteratorImpl,i=await this.api.get(this.stream,Object.assign({callback:(e,t)=>{e?n.push(()=>{e.err?n.stop(e.err):n.stop()}):t.lastSequence>0&&t.lastSequence!==this.cursor.last?(n.push(()=>{n.stop()}),i.stop()):(n.push(t),n.received++,this.cursor.last=t.seq,this.cursor.pending=t.pending)}},t));return n.iterClosed.then(()=>{i.stop()}),n}async next(){let e=await this.api.getMessage(this.stream,{seq:this.cursor.last+1}),t=e?.seq;return t&&(this.cursor.last=t),e}}})),WB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BatchPublisherImpl=e.JetStreamClientImpl=e.JetStreamManagerImpl=void 0,e.toJetStreamClient=c,e.jetstream=l,e.jetstreamManager=u;var t=PB(),n=RB(),r=AB(),i=HB(),a=LB(),o=NB(),s=UB();function c(e){return e.nc===void 0?l(e):e}function l(e,t={}){return new f(e,t)}async function u(e,t={}){let n=new d(e,t);if(t.checkAPI!==!1)try{await n.getAccountInfo()}catch(e){throw e}return n}var d=class extends t.BaseApiClientImpl{streams;consumers;direct;constructor(e,t){super(e,t),this.streams=new i.StreamAPIImpl(e,t),this.consumers=new n.ConsumerAPIImpl(e,t),this.direct=new s.DirectStreamAPIImpl(e,t)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return l(this.nc,this.getOptions())}advisories(){let e=new r.QueuedIteratorImpl;return this.nc.subscribe(`$JS.EVENT.ADVISORY.>`,{callback:(t,n)=>{if(t)throw t;try{let t=this.parseJsResponse(n),r=t.type.split(`.`),i=r[r.length-1];e.push({kind:i,data:t})}catch(t){e.stop(t)}}}),e}};e.JetStreamManagerImpl=d;var f=class extends t.BaseApiClientImpl{consumers;streams;consumerAPI;streamAPI;constructor(e,t){super(e,t),this.consumerAPI=new n.ConsumerAPIImpl(e,t),this.streamAPI=new i.StreamAPIImpl(e,t),this.consumers=new i.ConsumersImpl(this.consumerAPI),this.streams=new i.StreamsImpl(this.streamAPI)}jetstreamManager(e){e===void 0&&(e=this.opts.checkAPI);let t=Object.assign({},this.opts,{checkAPI:e});try{(0,r.createInbox)(t.watcherPrefix)}catch(e){return Promise.reject(e)}return u(this.nc,t)}get apiPrefix(){return this.prefix}startBatch(e,t,n){let i=(0,r.deferred)(),a=new p(this);return a.first(e,t,n).then(()=>{i.resolve(a)}).catch(e=>{i.reject(e)}),i}async _publish(e,t=r.Empty,n){n||={},n={...n},n.expect=n.expect||{};let i=n?.headers||(0,r.headers)();if(n&&(n.msgID&&i.set(a.PubHeaders.MsgIdHdr,n.msgID),n.expect.lastMsgID&&i.set(a.PubHeaders.ExpectedLastMsgIdHdr,n.expect.lastMsgID),n.expect.streamName&&i.set(a.PubHeaders.ExpectedStreamHdr,n.expect.streamName),typeof n.expect.lastSequence==`number`&&i.set(a.PubHeaders.ExpectedLastSeqHdr,`${n.expect.lastSequence}`),typeof n.expect.lastSubjectSequence==`number`&&i.set(a.PubHeaders.ExpectedLastSubjectSequenceHdr,`${n.expect.lastSubjectSequence}`),n.expect.lastSubjectSequenceSubject&&i.set(a.PubHeaders.ExpectedLastSubjectSequenceSubjectHdr,n.expect.lastSubjectSequenceSubject),n.ttl&&i.set(a.PubHeaders.MessageTTL,`${n.ttl}`),n.schedule)){let e=n.schedule;e.specification&&(typeof e.specification==`string`?i.set(a.PubHeaders.Schedule,e.specification):e.specification instanceof Date&&i.set(a.PubHeaders.Schedule,`@at `+e.specification.toISOString())),e.target&&i.set(a.PubHeaders.ScheduleTarget,e.target),e.source&&i.set(a.PubHeaders.ScheduleSource,e.source),e.ttl&&i.set(a.PubHeaders.ScheduleTTL,e.ttl)}let s=n.timeout||this.timeout,c={};s&&(c.timeout=s),n&&(c.headers=i);let{retries:l}=n;l||=1;let u=(0,r.backoff)(),d=null;for(let n=0;n<l;n++)try{d=await this.nc.request(e,t,c);break}catch(e){let t=e instanceof r.RequestError?e:null;if((e instanceof r.errors.TimeoutError||t?.isNoResponders())&&n+1<l)await(0,r.delay)(u.backoff(n));else throw t?.isNoResponders()?new o.JetStreamNotEnabled(`jetstream is not enabled`,{cause:e}):e}return d}async publish(e,t=r.Empty,n){let i=await this._publish(e,t,n),a=this.parseJsResponse(i);if(a.stream===``)throw new o.JetStreamError(`invalid ack response`);return a.duplicate=a.duplicate?a.duplicate:!1,a}};e.JetStreamClientImpl=f;var p=class{nc;js;id;count;done;constructor(e){this.count=0,this.id=r.nuid.next(),this.js=e,this.nc=this.js.nc,this.done=!1}async first(e,t,n){n||={},n.headers=n?.headers||(0,r.headers)(),n.headers.set(`Nats-Batch-Id`,this.id),this.count++,n.headers.set(`Nats-Batch-Sequence`,this.count.toString());let i=await this.js._publish(e,t,n);i.data.length>0&&this.js.parseJsResponse(i)}add(e,t,n={ack:!1}){if(this.done)throw Error(`batch publisher is done`);if(n.headers=n?.headers||(0,r.headers)(),n.headers.set(`Nats-Batch-Id`,this.id),this.count++,n.headers.set(`Nats-Batch-Sequence`,this.count.toString()),`ack`in n&&n.ack===!0){let i=(0,r.deferred)();return this.js._publish(e,t,{headers:n.headers,timeout:n.timeout}).then(e=>{e.data.length>0&&this.js.parseJsResponse(e),i.resolve()}).catch(e=>{this.done=!0,i.reject(e)}),i}else return this.nc.publish(e,t,{headers:n.headers})}async commit(e,t,n={}){if(this.done)throw Error(`batch publisher is done`);this.done=!0,n.headers=n?.headers||(0,r.headers)(),n.headers.set(`Nats-Batch-Id`,this.id),this.count++,n.headers.set(`Nats-Batch-Sequence`,this.count.toString()),n.headers.set(`Nats-Batch-Commit`,`1`);let i=(await this.js._publish(e,t,{headers:n.headers,timeout:n.timeout||0})).json();if(i.count!==this.count)throw Error(`batch didn't contain number of published messages`);return i}};e.BatchPublisherImpl=p})),GB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateStreamName=e.jserrors=e.JetStreamStatusError=e.JetStreamStatus=e.JetStreamError=e.JetStreamApiError=e.JetStreamApiCodes=e.isMessageNotFound=e.ListerImpl=e.StoreCompression=e.StorageType=e.RetentionPolicy=e.ReplayPolicy=e.PubHeaders=e.PersistMode=e.DiscardPolicy=e.DeliverPolicy=e.AckPolicy=e.DirectMsgImpl=e.BaseApiClientImpl=e.toJetStreamClient=e.jetstreamManager=e.JetStreamClientImpl=e.jetstream=e.RepublishHeaders=e.JsHeaders=e.isPushConsumer=e.isPullConsumer=e.isOrderedPushConsumerOptions=e.isBoundPushConsumerOptions=e.DirectMsgHeaders=e.AdvisoryKind=void 0;var t=MB();Object.defineProperty(e,`AdvisoryKind`,{enumerable:!0,get:function(){return t.AdvisoryKind}}),Object.defineProperty(e,`DirectMsgHeaders`,{enumerable:!0,get:function(){return t.DirectMsgHeaders}}),Object.defineProperty(e,`isBoundPushConsumerOptions`,{enumerable:!0,get:function(){return t.isBoundPushConsumerOptions}}),Object.defineProperty(e,`isOrderedPushConsumerOptions`,{enumerable:!0,get:function(){return t.isOrderedPushConsumerOptions}}),Object.defineProperty(e,`isPullConsumer`,{enumerable:!0,get:function(){return t.isPullConsumer}}),Object.defineProperty(e,`isPushConsumer`,{enumerable:!0,get:function(){return t.isPushConsumer}}),Object.defineProperty(e,`JsHeaders`,{enumerable:!0,get:function(){return t.JsHeaders}}),Object.defineProperty(e,`RepublishHeaders`,{enumerable:!0,get:function(){return t.RepublishHeaders}});var n=WB();Object.defineProperty(e,`jetstream`,{enumerable:!0,get:function(){return n.jetstream}}),Object.defineProperty(e,`JetStreamClientImpl`,{enumerable:!0,get:function(){return n.JetStreamClientImpl}}),Object.defineProperty(e,`jetstreamManager`,{enumerable:!0,get:function(){return n.jetstreamManager}}),Object.defineProperty(e,`toJetStreamClient`,{enumerable:!0,get:function(){return n.toJetStreamClient}});var r=PB();Object.defineProperty(e,`BaseApiClientImpl`,{enumerable:!0,get:function(){return r.BaseApiClientImpl}});var i=UB();Object.defineProperty(e,`DirectMsgImpl`,{enumerable:!0,get:function(){return i.DirectMsgImpl}});var a=LB();Object.defineProperty(e,`AckPolicy`,{enumerable:!0,get:function(){return a.AckPolicy}}),Object.defineProperty(e,`DeliverPolicy`,{enumerable:!0,get:function(){return a.DeliverPolicy}}),Object.defineProperty(e,`DiscardPolicy`,{enumerable:!0,get:function(){return a.DiscardPolicy}}),Object.defineProperty(e,`PersistMode`,{enumerable:!0,get:function(){return a.PersistMode}}),Object.defineProperty(e,`PubHeaders`,{enumerable:!0,get:function(){return a.PubHeaders}}),Object.defineProperty(e,`ReplayPolicy`,{enumerable:!0,get:function(){return a.ReplayPolicy}}),Object.defineProperty(e,`RetentionPolicy`,{enumerable:!0,get:function(){return a.RetentionPolicy}}),Object.defineProperty(e,`StorageType`,{enumerable:!0,get:function(){return a.StorageType}}),Object.defineProperty(e,`StoreCompression`,{enumerable:!0,get:function(){return a.StoreCompression}});var o=FB();Object.defineProperty(e,`ListerImpl`,{enumerable:!0,get:function(){return o.ListerImpl}});var s=NB();Object.defineProperty(e,`isMessageNotFound`,{enumerable:!0,get:function(){return s.isMessageNotFound}}),Object.defineProperty(e,`JetStreamApiCodes`,{enumerable:!0,get:function(){return s.JetStreamApiCodes}}),Object.defineProperty(e,`JetStreamApiError`,{enumerable:!0,get:function(){return s.JetStreamApiError}}),Object.defineProperty(e,`JetStreamError`,{enumerable:!0,get:function(){return s.JetStreamError}}),Object.defineProperty(e,`JetStreamStatus`,{enumerable:!0,get:function(){return s.JetStreamStatus}}),Object.defineProperty(e,`JetStreamStatusError`,{enumerable:!0,get:function(){return s.JetStreamStatusError}}),Object.defineProperty(e,`jserrors`,{enumerable:!0,get:function(){return s.jserrors}});var c=IB();Object.defineProperty(e,`validateStreamName`,{enumerable:!0,get:function(){return c.validateStreamName}})})),KB=r((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.StoreCompression=e.StorageType=e.RetentionPolicy=e.RepublishHeaders=e.ReplayPolicy=e.PubHeaders=e.PersistMode=e.JsHeaders=e.JetStreamError=e.JetStreamApiError=e.JetStreamApiCodes=e.isPushConsumer=e.isPullConsumer=e.DiscardPolicy=e.DirectMsgHeaders=e.DeliverPolicy=e.AdvisoryKind=e.AckPolicy=e.jetstreamManager=e.jetstream=void 0;var t=GB();Object.defineProperty(e,`jetstream`,{enumerable:!0,get:function(){return t.jetstream}}),Object.defineProperty(e,`jetstreamManager`,{enumerable:!0,get:function(){return t.jetstreamManager}});var n=GB();Object.defineProperty(e,`AckPolicy`,{enumerable:!0,get:function(){return n.AckPolicy}}),Object.defineProperty(e,`AdvisoryKind`,{enumerable:!0,get:function(){return n.AdvisoryKind}}),Object.defineProperty(e,`DeliverPolicy`,{enumerable:!0,get:function(){return n.DeliverPolicy}}),Object.defineProperty(e,`DirectMsgHeaders`,{enumerable:!0,get:function(){return n.DirectMsgHeaders}}),Object.defineProperty(e,`DiscardPolicy`,{enumerable:!0,get:function(){return n.DiscardPolicy}}),Object.defineProperty(e,`isPullConsumer`,{enumerable:!0,get:function(){return n.isPullConsumer}}),Object.defineProperty(e,`isPushConsumer`,{enumerable:!0,get:function(){return n.isPushConsumer}}),Object.defineProperty(e,`JetStreamApiCodes`,{enumerable:!0,get:function(){return n.JetStreamApiCodes}}),Object.defineProperty(e,`JetStreamApiError`,{enumerable:!0,get:function(){return n.JetStreamApiError}}),Object.defineProperty(e,`JetStreamError`,{enumerable:!0,get:function(){return n.JetStreamError}}),Object.defineProperty(e,`JsHeaders`,{enumerable:!0,get:function(){return n.JsHeaders}}),Object.defineProperty(e,`PersistMode`,{enumerable:!0,get:function(){return n.PersistMode}}),Object.defineProperty(e,`PubHeaders`,{enumerable:!0,get:function(){return n.PubHeaders}}),Object.defineProperty(e,`ReplayPolicy`,{enumerable:!0,get:function(){return n.ReplayPolicy}}),Object.defineProperty(e,`RepublishHeaders`,{enumerable:!0,get:function(){return n.RepublishHeaders}}),Object.defineProperty(e,`RetentionPolicy`,{enumerable:!0,get:function(){return n.RetentionPolicy}}),Object.defineProperty(e,`StorageType`,{enumerable:!0,get:function(){return n.StorageType}}),Object.defineProperty(e,`StoreCompression`,{enumerable:!0,get:function(){return n.StoreCompression}})})),qB=jB(),JB=KB();function YB(e){return e.length>=2&&e[0]===31&&e[1]===139}function XB(e){return e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e.slice())}async function ZB(e){if(!YB(e))return e;if(typeof Bun<`u`)return Bun.gunzipSync(XB(e));let t=new DecompressionStream(`gzip`),n=t.writable.getWriter();return n.write(XB(e)).then(()=>n.close()),new Uint8Array(await new Response(t.readable).arrayBuffer())}var QB=new TextEncoder,$B=new TextDecoder;function eV(e){e.natsSubscription?.unsubscribe(),e.eventSubscription?.unsubscribe(),e.consumerMessages?.close(),e.natsSubscription=null,e.eventSubscription=null,e.consumerMessages=null}function tV(e,t){for(let[n,r]of e.entries())eV(r),t(n,r)}var nV=class{resolvedWsUrl=null;nc=null;js=null;started=!1;reconnecting=!1;subscriptions=new Map;statusListeners=new Set;currentStatus=`disconnected`;reconnectTimer=null;reconnectDelayMs=250;resolvedToken=void 0;counter=0;start(){this.started||(this.started=!0,this.discoverAndConnect())}async discoverAndConnect(){try{let e=await(await fetch(`/auth/token`)).json();this.resolvedToken=e.token;let t=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/nats-ws`;if(e.natsWsUrl&&window.location.protocol!==`https:`&&e.natsWsUrl.startsWith(`ws://`)){let t=e.natsWsUrl;console.warn(m_,`Trying direct NATS WS: ${t}`),this.resolvedWsUrl=t;try{if(await this.connect(),this.currentStatus===`connected`){console.warn(m_,`Direct NATS WS connected: ${t}`);return}}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(m_,`Direct NATS WS failed, falling back to proxy: ${t}`)}}this.resolvedWsUrl=t,await this.connect()}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(m_,`NATS discovery failed: ${t}`),this.emitStatus(`disconnected`),this.scheduleReconnect()}}dispose(){this.started=!1,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.unsubscribeAll(),this.nc&&=(this.nc.drain().catch(()=>{}),null),this.js=null,this.emitStatus(`disconnected`)}onStatus(e){return this.statusListeners.add(e),e(this.currentStatus),()=>{this.statusListeners.delete(e)}}subscribe(e,t,n){let r=this.nextId(),i={topic:e,natsSubscription:null,eventSubscription:null,consumerMessages:null,snapshotListener:t,eventListener:n};return this.subscriptions.set(r,i),this.nc&&this.activateSubscription(this.nc,this.js,r,i),()=>{let e=this.subscriptions.get(r);e&&(e.natsSubscription?.unsubscribe(),e.eventSubscription?.unsubscribe(),e.consumerMessages?.close(),this.subscriptions.delete(r),this.nc&&this.command({type:`snapshot.unsubscribe`,subscriptionId:r}).catch(()=>{}))}}subscribeTerminal(e,t){return this.subscribe({type:`terminal`,terminalId:e},t.onSnapshot,t.onEvent)}async command(e,t){if(!this.nc)throw Error(`Not connected`);let n=dh(e.type),r=QB.encode(JSON.stringify(e)),i=await ZB((await this.nc.request(n,r,{timeout:t?.timeoutMs??3e4})).data),a;try{a=JSON.parse($B.decode(i))}catch{throw Error(`Invalid JSON response from server`)}if(!a.ok)throw Error(a.error??`Command failed`);return a.result}async rawRequest(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=QB.encode(JSON.stringify(t??{})),i=await ZB((await this.nc.request(e,r,{timeout:n?.timeoutMs??3e4})).data);try{return JSON.parse($B.decode(i))}catch{throw Error(`Invalid JSON response from raw subject`)}}rawSubscribe(e,t){if(!this.nc)throw Error(`Not connected`);let n=this.nc.subscribe(e);return(async()=>{for await(let r of n)try{let e=await ZB(r.data);t(JSON.parse($B.decode(e)))}catch(t){console.warn(m_,`rawSubscribe handler error on ${e}:`,t instanceof Error?t.message:String(t))}})().catch(()=>void 0),()=>{try{n.unsubscribe()}catch{}}}ensureHealthyConnection(){return(!this.nc||this.currentStatus!==`connected`)&&this.reconnectNow(),Promise.resolve()}async connect(){if(!(!this.started||!this.resolvedWsUrl)){this.emitStatus(`connecting`);try{this.nc=await(0,qB.wsconnect)({servers:this.resolvedWsUrl,...this.resolvedToken?{token:this.resolvedToken}:{},maxReconnectAttempts:-1,reconnectTimeWait:750,pingInterval:15e3,maxPingOut:3}),this.js=(0,JB.jetstream)(this.nc),this.reconnectDelayMs=750,this.emitStatus(`connected`);for(let[e,t]of this.subscriptions.entries())this.activateSubscription(this.nc,this.js,e,t);this.monitorStatus()}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(m_,`NATS connection failed: ${t}`),this.emitStatus(`disconnected`),this.scheduleReconnect()}}}async monitorStatus(){let e=this.nc,t=this.js;if(e){try{for await(let n of e.status()){if(!this.started)break;switch(n.type){case`disconnect`:this.emitStatus(`disconnected`);break;case`reconnect`:this.emitStatus(`connected`),tV(this.subscriptions,(n,r)=>{this.activateSubscription(e,t,n,r)});break;case`reconnecting`:this.emitStatus(`connecting`);break}if(this.nc!==e)break}}catch{}this.started&&!this.reconnecting&&this.nc===e&&(this.emitStatus(`disconnected`),this.scheduleReconnect())}}activateSubscription(e,t,n,r){let i=ch(r.topic);if(r.natsSubscription=e.subscribe(i),this.consumeMessages(n,r.natsSubscription,r.snapshotListener),r.topic.type===`terminal`&&r.eventListener){let t=lh(r.topic.terminalId);r.eventSubscription=e.subscribe(t),this.consumeMessages(n,r.eventSubscription,r.eventListener)}else r.topic.type===`chat`&&r.eventListener&&t&&this.activateJetStreamConsumer(e,t,n,r);this.command({type:`snapshot.subscribe`,subscriptionId:n,topic:r.topic}).then(e=>{this.subscriptions.has(n)&&r.snapshotListener(e)}).catch(e=>{console.warn(m_,`snapshot.subscribe failed for ${ch(r.topic)}:`,e instanceof Error?e.message:String(e))})}async activateJetStreamConsumer(e,t,n,r){if(!(r.topic.type!==`chat`||!r.eventListener))try{let e=await(await t.consumers.get(fh,{filter_subjects:uh(r.topic.chatId),deliver_policy:JB.DeliverPolicy.New})).consume();r.consumerMessages=e,this.consumeMessages(n,e,r.eventListener)}catch(t){let i=t instanceof Error?t.message:String(t);console.warn(m_,`JetStream consumer failed for chat ${r.topic.chatId}: ${i}`);let a=uh(r.topic.chatId);r.eventSubscription=e.subscribe(a),this.consumeMessages(n,r.eventSubscription,r.eventListener)}}async consumeMessages(e,t,n){try{for await(let r of t){if(!this.subscriptions.has(e))break;try{let e=await ZB(r.data);n(JSON.parse($B.decode(e)))}catch{}}}catch{}}unsubscribeAll(){for(let e of this.subscriptions.values())e.natsSubscription?.unsubscribe(),e.eventSubscription?.unsubscribe(),e.consumerMessages?.close(),e.natsSubscription=null,e.eventSubscription=null,e.consumerMessages=null}resetting=!1;async resetConnection(){if(!this.resetting){this.resetting=!0;try{this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnecting=!1,this.unsubscribeAll();let e=this.nc;this.nc=null,this.js=null,e&&await e.close().catch(()=>{})}finally{this.resetting=!1}}}scheduleReconnect(){this.reconnectTimer!==null||!this.started||(this.reconnecting=!0,this.reconnectTimer=window.setTimeout(()=>{(async()=>{await this.resetConnection(),this.discoverAndConnect(),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,3e3)})()},this.reconnectDelayMs))}async reconnectNow(){await this.resetConnection(),this.connect()}emitStatus(e){if(this.currentStatus!==e){this.currentStatus=e;for(let t of this.statusListeners)t(e)}}nextId(){return`nats-${++this.counter}`}};function rV(e,t){(0,j.useEffect)(()=>{if(!t)return;let n=!1;e.rawRequest(ph(`pty.snapshot`),{}).then(e=>{n||e.ok&&e.instances&&AM.getState().applySnapshot(e.instances)}).catch(()=>void 0);let r=e.rawSubscribe(mh(),e=>{let t=AM.getState();e.type===`added`?t.applyDiff({op:`added`,instance:e.instance}):e.type===`updated`?t.applyDiff({op:`updated`,instance:e.instance}):e.type===`removed`&&t.applyDiff({op:`removed`,chatId:e.chatId})});return()=>{n=!0,r()}},[e,t])}var iV=1e3;function aV(){if(typeof window>`u`)return!1;let e=`standalone`in navigator&&navigator.standalone===!0,t=window.matchMedia(`(display-mode: standalone)`).matches;return e||t}function oV(e){let{socket:t,activeChatId:n,connectionStatus:r}=e,i=(0,j.useRef)(null),a=(0,j.useRef)(0),[o,s]=(0,j.useState)(0);return(0,j.useEffect)(()=>{function e(e){let o=Date.now();vj({isStandalone:aV(),hiddenAt:i.current,resumedAt:o,connectionStatus:r})&&(o-a.current<iV||(a.current=o,i.current=null,console.info(`[useAppState] refreshing stale session after app resume`,{trigger:e,activeChatId:n,connectionStatus:r}),t.ensureHealthyConnection(),s(e=>e+1)))}function o(){if(document.visibilityState===`hidden`){i.current=Date.now();return}document.visibilityState===`visible`&&e(`visibilitychange`)}function c(){e(`focus`)}function l(){e(`online`)}function u(){e(`pageshow`)}return document.addEventListener(`visibilitychange`,o),window.addEventListener(`focus`,c),window.addEventListener(`online`,l),window.addEventListener(`pageshow`,u),()=>{document.removeEventListener(`visibilitychange`,o),window.removeEventListener(`focus`,c),window.removeEventListener(`online`,l),window.removeEventListener(`pageshow`,u)}},[n,r,t]),{resumeRefreshNonce:o}}function sV(e,t){let n=(0,j.useRef)(null),r=(0,j.useRef)(`anchoring`),[i,a]=(0,j.useState)(`anchoring`);function o(){let r=e.current,i=t.current;return!r||!i?null:(n.current||=eI(r,i),n.current)}return(0,j.useEffect)(()=>{let e=o();if(!e)return;let t=e.subscribe(()=>{let t=e.getSnapshot();r.current=t,a(t)});return r.current=e.getSnapshot(),a(e.getSnapshot()),()=>{t(),n.current?.destroy(),n.current=null}},[e.current,t.current]),{isFollowing:XF(i),modeRef:r,scrollToBottom:(0,j.useCallback)((e=`smooth`)=>{let t=o();t&&(t.scrollToBottom(e),r.current=t.getSnapshot())},[e,t]),handleInitialScrollDone:(0,j.useCallback)(e=>{let t=o();t&&(t.handleInitialScrollDone(e),r.current=t.getSnapshot())},[e,t]),handleChatChanged:(0,j.useCallback)(()=>{let e=o();e&&(e.handleChatChanged(),r.current=e.getSnapshot())},[e,t]),beginProgrammaticScroll:(0,j.useCallback)(()=>{o()?.beginProgrammaticScroll()},[e,t]),endProgrammaticScroll:(0,j.useCallback)(()=>{o()?.endProgrammaticScroll()},[e,t])}}function cV(e){let{activeChatId:t,scrollRef:n,messages:r,cachedScrollState:i,onChatChanged:a,onInitialScrollDone:o,beginProgrammaticScroll:s,endProgrammaticScroll:c}=e,l=(0,j.useRef)(`idle`),u=(0,j.useRef)(i);return u.current=i,(0,j.useLayoutEffect)(()=>{l.current=`idle`,a();let e=n.current;if(!e)return;let t=u.current;t&&t.scrollMode===`detached`?(s(),e.scrollTop=t.scrollTop,c(),l.current=`complete`,o(`block`)):r.length>0&&(s(),e.scrollTo({top:e.scrollHeight,behavior:`auto`}),c(),l.current=`pre-paint-done`)},[t]),(0,j.useEffect)(()=>{if(l.current!==`pre-paint-done`||r.length===0||!n.current)return;l.current=`stabilizing`,s();let e=0,t=0,i=window.setInterval(()=>{let r=n.current;if(!r||!r.isConnected){window.clearInterval(i),c();return}r.scrollTo({top:r.scrollHeight,behavior:`auto`}),r.scrollHeight===e?t++:(e=r.scrollHeight,t=0);let a=$F(r.scrollHeight-r.scrollTop-r.clientHeight,r.clientHeight);t>=5&&r.scrollHeight>r.clientHeight&&a&&(window.clearInterval(i),l.current=`complete`,o(`tail`),c())},50),a=window.setTimeout(()=>{window.clearInterval(i),l.current!==`complete`&&(l.current=`complete`,o(`tail`),c())},2e3);return()=>{window.clearInterval(i),window.clearTimeout(a),c()}},[t,s,c,o,r.length]),{phaseRef:l}}function lV(e){let{scrollRef:t,anchoringPhase:n,scrollModeRef:r,beginProgrammaticScroll:i,endProgrammaticScroll:a,messageCount:o,runtimeStatus:s,inputHeight:c}=e;(0,j.useLayoutEffect)(()=>{if(n.current!==`complete`)return;let e=t.current;if(!e||r.current!==`following`)return;i(),e.scrollTo({top:e.scrollHeight,behavior:`auto`});let o=window.requestAnimationFrame(()=>a());return()=>{window.cancelAnimationFrame(o),a()}},[i,a,c,o,s])}function uV(e){return e.anchoringPhase!==`complete`||e.scrollMode!==`detached`?!1:$F(e.scrollHeight-e.scrollTop-e.clientHeight,e.clientHeight)}function dV(e){let{activeChatId:t,scrollRef:n,anchoringPhase:r,scrollModeRef:i,scrollFollowToBottom:a}=e;(0,j.useEffect)(()=>{let e=n.current;if(!e||!t)return;let o=e,s=o.firstElementChild instanceof HTMLElement?o.firstElementChild:o;function c(){if(r.current===`complete`){if(i.current===`following`){o.scrollTo({top:o.scrollHeight,behavior:`auto`});return}uV({anchoringPhase:r.current,scrollMode:i.current,scrollHeight:o.scrollHeight,scrollTop:o.scrollTop,clientHeight:o.clientHeight})&&a(`auto`)}}let l=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{c()});return l?.observe(s),()=>{l?.disconnect()}},[t,a,i,r,n])}var fV=320;function pV(e){let{activeChatId:t,messages:n,inputHeight:r,runtime:i,cachedScrollState:a}=e,o=(0,j.useRef)(null),s=(0,j.useRef)(null),{isFollowing:c,modeRef:l,scrollToBottom:u,handleInitialScrollDone:d,handleChatChanged:f,beginProgrammaticScroll:p,endProgrammaticScroll:m}=sV(o,s),{phaseRef:h}=cV({activeChatId:t,scrollRef:o,messages:n,cachedScrollState:a,onChatChanged:f,onInitialScrollDone:d,beginProgrammaticScroll:p,endProgrammaticScroll:m});lV({scrollRef:o,anchoringPhase:h,scrollModeRef:l,beginProgrammaticScroll:p,endProgrammaticScroll:m,messageCount:n.length,runtimeStatus:i?.status,inputHeight:r}),dV({activeChatId:t,scrollRef:o,anchoringPhase:h,scrollModeRef:l,scrollFollowToBottom:u});let g=fV,_=YF(l.current,n.length);function v(){u(`smooth`)}function y(){let e=o.current;e&&gj(e.scrollHeight-e.scrollTop-e.clientHeight,e.clientHeight)&&u(`auto`)}return{scrollRef:o,sentinelRef:s,isFollowing:c,scrollFollowToBottom:u,showScrollButton:_,transcriptPaddingBottom:g,scrollToBottom:v,keepComposerSubmitAnchored:y,scrollModeRef:l,beginProgrammaticScroll:p,endProgrammaticScroll:m}}var mV=`[useTranscriptLifecycle]`;function hV(e,t){if(t===void 0){console.info(`${mV} ${e}`);return}console.info(`${mV} ${e}`,t)}function gV(e){let{socket:t,activeChatId:n,resumeRefreshNonce:r,sidebarData:i,sidebarReady:a,pendingChatId:o,setPendingChatId:s,navigate:c,setProjectSelection:l,setCommandError:u,onChatSnapshotReceived:d,getScrollState:f}=e,p=(0,j.useRef)(d);(0,j.useLayoutEffect)(()=>{p.current=d},[d]);let m=(0,j.useRef)(f);(0,j.useLayoutEffect)(()=>{m.current=f},[f]);let[h,g]=(0,j.useState)(null),[_,v]=(0,j.useState)([]),y=(0,j.useRef)(_),b=(0,j.useRef)(null),x=(0,j.useRef)(0),[S,C]=(0,j.useState)(null),[w,T]=(0,j.useState)(null),[E,D]=(0,j.useState)(!1);return(0,j.useLayoutEffect)(()=>{y.current=_},[_]),(0,j.useEffect)(()=>{if(!n){hV(`clearing chat snapshot for non-chat route`),C(null),T(null),l(e=>Oz(e,{type:`chat.cleared`})),b.current=null,x.current=0,v([]),D(!0);return}C(null),T(null);let e=Sz(n),r=e!==null;r?(hV(`restoring chat render units from cache`,{activeChatId:n,cachedUnits:e.messages.length,stale:e.stale,scrollTop:e.scrollTop,scrollMode:e.scrollMode}),b.current=n,x.current=e.messageCount,v(e.messages),g({scrollTop:e.scrollTop,scrollMode:e.scrollMode}),D(!0)):(g(null),Dj({hasExistingMessages:y.current.length>0,restoredFromCache:!1,currentMessagesChatId:b.current,nextChatId:n})?hV(`re-subscribing to active chat (keeping render units)`,{activeChatId:n}):(hV(`subscribing to chat render units (no cache)`,{activeChatId:n,previousMessagesChatId:b.current}),b.current=null,x.current=0,v([]),D(!1)));let a=!1,o=!1,s=!1,c=null,d=n;function f(e,t){a||(o=!0,b.current=d,v(e),hV(`transcript render units applied`,{chatId:d,source:t,unitCount:e.length}))}async function h(e){if(e===`snapshot_recovery`){if(s)return;s=!0}try{f(await lj({socket:t,chatId:d,offset:Math.max(0,x.current-200),limit:200,isLoading:!0}),`fetched`),D(!0)}catch(t){let n=t instanceof Error?t.message:String(t);if(hV(`transcript render-unit fetch failed`,{chatId:d,source:e,error:n}),e===`snapshot_recovery`&&n.includes(`Not connected`)){s=!1;return}e===`snapshot_recovery`&&(f([],`fetched`),D(!0))}}let _=t.subscribe({type:`chat`,chatId:n},e=>{a||(hV(`chat snapshot received`,{activeChatId:n,snapshotChatId:e?.runtime.chatId??null,snapshotProvider:e?.runtime.provider??null,snapshotStatus:e?.runtime.status??null,renderUnits:e?.renderUnits.length??0}),C(e),e&&(x.current=e.messageCount,f(e.renderUnits,`snapshot`),l(t=>Oz(t,{type:`chat.snapshot_received`,workspaceId:e.runtime.workspaceId})),p.current(e)),D(!0),u(null))},e=>{a||e.chatId===n&&(x.current+=1,c===null&&(c=requestAnimationFrame(()=>{c=null,a||h(`live_event`)})))}),S=t.subscribe({type:`orchestration`,chatId:n},e=>{a||T(e)}),w=r?void 0:setTimeout(()=>{Tj({cancelled:a,initialFetchDone:o,fetchTriggered:s})&&(hV(`snapshot recovery: no render snapshot received, fetching directly`,{chatId:d}),h(`snapshot_recovery`))},cj);return()=>{a=!0,clearTimeout(w),c!==null&&cancelAnimationFrame(c),_(),S();let e=i.workspaceGroups.flatMap(e=>e.chats).find(e=>e.chatId===d);if(d&&b.current===d&&y.current.length>0){let t=m.current();Cz(d,{messages:y.current,messageCount:x.current,cachedAt:Date.now(),lastMessageAt:e?.lastMessageAt,stale:!1,scrollTop:t?.scrollTop??0,scrollMode:t?.scrollMode??`following`})}}},[n,r,t]),(0,j.useEffect)(()=>{if(n&&!(!a||!E)){if(i.workspaceGroups.some(e=>e.chats.some(e=>e.chatId===n))){o===n&&s(null);return}o!==n&&c(`/`)}},[n,E,c,o,i.workspaceGroups,a]),(0,j.useEffect)(()=>{S&&o===S.runtime.chatId&&s(null)},[S,o]),{messages:_,messagesRef:y,messageCountRef:x,chatSnapshot:S,orchestrationHierarchy:w,chatReady:E,cachedScrollState:h}}var _V=[68,32];function vV(){return{isVisible:!1,mainSizes:[..._V],terminals:[],nextTerminalIndex:0}}function yV(e,t){return e[t]??vV()}function bV(e){if(e.length===0)return[];let t=e.reduce((e,t)=>e+Math.max(t,0),0);return!Number.isFinite(t)||t<=0?Array.from({length:e.length},()=>100/e.length):e.map(e=>Math.max(e,0)/t*100)}function xV(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`Terminal ${n}`}function SV(e){if(e.length===0)return e;let t=e.length+1;return e.map(n=>({...n,size:n.size*e.length/t}))}function CV(e,t,n){return{...e,[t]:n(yV(e,t))}}var wV=w()(Wx(e=>({workspaces:{},addTerminal:(t,n)=>e(e=>({workspaces:CV(e.workspaces,t,e=>{let t=SV(e.terminals),r={id:globalThis.crypto?.randomUUID?.()??`terminal-${Date.now()}-${e.nextTerminalIndex}`,title:xV(e.nextTerminalIndex),size:100/(t.length+1)},i=n?Math.max(t.findIndex(e=>e.id===n)+1,0):t.length;return{...e,isVisible:!0,nextTerminalIndex:e.nextTerminalIndex+1,terminals:[...t.slice(0,i),r,...t.slice(i)]}})})),removeTerminal:(t,n)=>e(e=>({workspaces:CV(e.workspaces,t,e=>{let t=e.terminals.filter(e=>e.id!==n);if(t.length===0)return{...e,isVisible:!1,terminals:[]};let r=bV(t.map(e=>e.size));return{...e,terminals:t.map((e,n)=>({...e,size:r[n]??100/t.length}))}})})),toggleVisibility:t=>e(e=>({workspaces:CV(e.workspaces,t,e=>({...e,isVisible:e.terminals.length>0?!e.isVisible:!1}))})),resetMainSizes:t=>e(e=>({workspaces:CV(e.workspaces,t,e=>({...e,mainSizes:[..._V]}))})),setMainSizes:(t,n)=>e(e=>{if(n.length!==2)return e;let r=bV(n);return{workspaces:CV(e.workspaces,t,e=>({...e,mainSizes:r}))}}),setTerminalSizes:(t,n)=>e(e=>({workspaces:CV(e.workspaces,t,e=>{if(n.length!==e.terminals.length)return e;let t=bV(n);return{...e,terminals:e.terminals.map((e,n)=>({...e,size:t[n]??e.size}))}})})),clearProject:t=>e(e=>{let{[t]:n,...r}=e.workspaces;return{workspaces:r}})}),{name:`terminal-layouts`,version:1,storage:Hx(()=>localStorage)}));[..._V];var TV=`tinkaria:ui-update-restart`;function EV(){return window.sessionStorage.getItem(TV)}function DV(e){window.sessionStorage.setItem(TV,e)}function OV(){window.sessionStorage.removeItem(TV)}function kV(e,t){return e?.provider??t?.provider??null}function AV(e,t){let n=kV(e,t);if(!n)return null;if(!t?.model)return e?.provider===n?e.model:null;if(n===`claude`){let e=t.model??$m(`claude`).defaultModel;return rh(e,nh(e,t?.modelOptions?.claude?.contextWindow))}return t?.model??$m(`codex`).defaultModel}function jV(e,t){if(!e?.sessionToken||!e.provider)return!1;let n=kV(e,t);if(!n)return!1;if(n!==e.provider)return!0;let r=AV(e,t);return r?e.model?r!==e.model:!0:!1}function MV(e){let{socket:t,activeChatId:n,navigate:r,dialog:i,sidebarData:a,chatSnapshot:s,runtime:c,selectedProjectId:l,fallbackLocalProjectPath:u,isProcessing:d,localProjects:f,setProjectSelection:p,setSidebarData:m,setPendingChatId:h,setSidebarOpen:g,setCommandError:_,scrollFollowToBottom:v,keepComposerSubmitAnchored:y,activeQueuedText:b,updateSubmitPipeline:S,submitPipeline:C,pendingDeletedChatIdsRef:w}=e,[T,E]=(0,j.useState)(null),[D,O]=(0,j.useState)(null),[k,A]=(0,j.useState)(null),[M,N]=(0,j.useState)(null),[P,F]=(0,j.useState)(null);function I(e){Fj(e.runtime.status)&&S(t=>Fz(t,e.runtime.chatId));let t=e.queuedTurn;t?S(n=>Bz(n,{chatId:e.runtime.chatId,content:t.content,options:{provider:t.provider,model:t.model,modelOptions:t.modelOptions,planMode:t.planMode}})):Fj(e.runtime.status)||S(t=>Bz(t,{chatId:e.runtime.chatId,content:null}))}async function L(e){_(null),await t.command({type:`system.openExternal`,...e})}async function R(e){oS.getState().initializeComposerForNewChat();let i=x();p(t=>Oz(t,{type:`project.explicitly_selected`,workspaceId:e})),h(i),r(`/chat/${i}`),g(!1);try{let n=await t.command({type:`chat.create`,workspaceId:e,chatId:i});n.chatId!==i&&(h(n.chatId),r(`/chat/${n.chatId}`,{replace:!0})),_(null)}catch(e){throw h(null),r(n?`/chat/${n}`:`/`),e}}async function z(e){return e.kind===`project_id`?{workspaceId:e.workspaceId}:e.kind===`local_path`?{workspaceId:(await t.command({type:`project.open`,localPath:e.localPath})).workspaceId,localPath:e.localPath}:{workspaceId:(await t.command(e.project.mode===`new`?{type:`project.create`,localPath:e.project.localPath,title:e.project.title}:{type:`project.open`,localPath:e.project.localPath})).workspaceId,localPath:e.project.localPath}}async function B(e){try{let t=e.kind===`project_id`?null:e.kind===`local_path`?e.localPath:e.project.localPath;t&&O(t);let{workspaceId:n}=await z(e);await R(n)}catch(e){_(e instanceof Error?e.message:String(e))}finally{O(null)}}async function V(e){await B({kind:`project_id`,workspaceId:e})}async function H(e){await B({kind:`local_path`,localPath:e})}async function U(e){await B({kind:`project_request`,project:e})}function W(){let e=Sj({selectedProjectId:l,sidebarProjectId:a.workspaceGroups[0]?.groupKey,fallbackLocalProjectPath:u});if(e){B(e);return}r(`/`)}async function G(e,i){try{let o=l??a.workspaceGroups[0]?.groupKey??null;if(!n&&!o&&u&&(o=(await t.command({type:`project.open`,localPath:u})).workspaceId,p(e=>Oz(e,{type:`project.explicitly_selected`,workspaceId:o}))),!n&&!o)throw Error(`Open a project first`);if(n&&jV(c,i)){let t=kV(c,i)??`claude`;await fe(e,t,AV(c,i)??$m(t).defaultModel,void 0,{modelOptions:i?.modelOptions,planMode:i?.planMode}),_(null);return}v(`auto`);let s=i?.provider===`claude-pty`?95e3:void 0,d=s?{timeoutMs:s}:void 0,f={type:`chat.send`,chatId:n??void 0,workspaceId:n?void 0:o??void 0,provider:i?.provider,content:e,model:i?.model,modelOptions:i?.modelOptions,planMode:i?.planMode},m=await t.command(f,d);if(`needsPick`in m&&m.needsPick){let e=async i=>{await t.command({type:`chat.selectRunner`,chatId:m.chatId,runnerId:i});let a=await t.command(f,d);if(`needsPick`in a&&a.needsPick){F({chatId:a.chatId,candidates:a.candidates,reason:a.reason,retry:e});return}let o=a;!n&&o.chatId&&(h(o.chatId),r(`/chat/${o.chatId}`))};F({chatId:m.chatId,candidates:m.candidates,reason:m.reason,retry:e});return}let g=m;!n&&g.chatId&&(h(g.chatId),r(`/chat/${g.chatId}`)),_(null)}catch(e){throw _(e instanceof Error?e.message:String(e)),e}}async function K(e,r){if(y(),!n)return await G(e,r),`sent`;try{let r=await o(()=>import(`./ptyInstancesStore-D9ag7SYd.js`),[]),i=await o(()=>import(`./pty-client-DZ27IS00.js`),[]);if(((r.usePtyInstancesStore??r.default)?.getState?.())?.instances?.some(e=>e.chatId===n)??!1)return await i.ptyInput(t,n,e),`sent`}catch{}if(Ej(d,b)||Pz(C,n)===`flushing`||Pz(C,n)===`awaiting_busy_ack`){let i=S(t=>Nz(t,{chatId:n,content:e,options:r??void 0})).queuedTextByChat[n]??e;try{let e=await t.command({type:`chat.queue`,chatId:n,provider:r?.provider,content:i,model:r?.model,modelOptions:r?.modelOptions,planMode:r?.planMode});if(`needsPick`in e&&e.needsPick){let a={type:`chat.queue`,chatId:n,provider:r?.provider,content:i,model:r?.model,modelOptions:r?.modelOptions,planMode:r?.planMode},o=async n=>{await t.command({type:`chat.selectRunner`,chatId:e.chatId,runnerId:n});let r=await t.command(a);`needsPick`in r&&r.needsPick&&F({chatId:r.chatId,candidates:r.candidates,reason:r.reason,retry:o})};return F({chatId:e.chatId,candidates:e.candidates,reason:e.reason,retry:o}),`queued`}e.queued||S(e=>zz(e,n))}catch(e){throw _(e instanceof Error?e.message:String(e)),e}return`queued`}S(t=>Iz(t,{chatId:n,content:e}));try{return await G(e,r),S(e=>Lz(e,n)),`sent`}catch(e){throw S(e=>Rz(e,n)),e}}async function q(){if(n)try{await t.command({type:`chat.cancel`,chatId:n})}catch(e){_(e instanceof Error?e.message:String(e))}}async function J(e){if(!await i.confirm({title:`Delete Chat`,description:`Delete "${e.title}"? This cannot be undone.`,confirmLabel:`Delete`,confirmVariant:`destructive`}))return;let o=e.chatId===n?pj(a.workspaceGroups,e.chatId):null;w.current.add(e.chatId),m(t=>dj(t,e.chatId)),Jx.getState().clearQueuedDraft(e.chatId),wz(e.chatId),e.chatId===n&&r(o?`/chat/${o}`:`/`),t.command({type:`chat.delete`,chatId:e.chatId}).then(()=>{w.current.delete(e.chatId)}).catch(t=>{w.current.delete(e.chatId),console.warn(`[useChatCommands] background chat.delete failed:`,t instanceof Error?t.message:String(t))})}async function ee(e,n){let r=n.trim();if(r)try{await t.command({type:`chat.rename`,chatId:e,title:r}),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function Y(e){let n=a.workspaceGroups.find(t=>t.groupKey===e);if(!n)return;let o=n.localPath.split(`/`).filter(Boolean).pop()??n.localPath;if(await i.confirm({title:`Remove`,description:`Remove "${o}" from the sidebar? Existing chats will be removed from Tinkaria.`,confirmLabel:`Remove`,confirmVariant:`destructive`}))try{await t.command({type:`project.remove`,workspaceId:e});for(let e of n.chats)Jx.getState().clearQueuedDraft(e.chatId),wz(e.chatId);wV.getState().clearProject(e),PF.getState().clearProject(e),c?.workspaceId===e&&r(`/`),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function te(e){try{let n=await t.command({type:`independent-workspace.create`,name:e});n?.workspaceId&&r(`/workspace/${n.workspaceId}`),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function ne(e){if(await i.confirm({title:`Delete Workspace`,description:`Delete this workspace? This cannot be undone.`,confirmLabel:`Delete`,confirmVariant:`destructive`}))try{await t.command({type:`independent-workspace.delete`,workspaceId:e}),window.location.pathname===`/workspace/${e}`&&r(`/`),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function re(e,n){let r=n.trim();if(r)try{await t.command({type:`independent-workspace.rename`,workspaceId:e,name:r}),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function ie(e,n){try{await t.command({type:`independent-workspace.set-pinned`,workspaceId:e,pinned:n}),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function ae(e){try{await t.command({type:`independent-workspace.reorder`,orderedWorkspaceIds:e}),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function oe(e){try{await t.command({type:`update.check`,force:e?.force}),_(null)}catch(e){_(e instanceof Error?e.message:String(e))}}async function se(){try{let e=await t.command({type:`update.install`});if(!e.ok){OV(),_(null),await i.alert({title:e.userTitle??`Update failed`,description:e.userMessage??`Tinkaria could not install the update. Try again later.`,closeLabel:`OK`});return}if(e.ok&&e.action===`reload`){window.location.reload();return}e.ok&&e.action===`restart`&&DV(`awaiting_disconnect`),_(null)}catch(e){OV(),_(e instanceof Error?e.message:String(e))}}async function ce(e){let t=c?.localPath??f?.workspaces[0]?.localPath??a.workspaceGroups[0]?.localPath;if(t)try{await L({action:e,localPath:t})}catch(e){_(e instanceof Error?e.message:String(e))}}async function le(e,t){try{await L({action:e,localPath:t})}catch(e){_(e instanceof Error?e.message:String(e))}}async function ue(e){try{let n=await t.command({type:`system.readLocalFilePreview`,localPath:e.path});E({path:n.localPath,content:n.content,line:e.line,column:e.column}),_(null)}catch(e){_(yj(e))}}function de(e){return!1}async function fe(e,i,o,c,u){if(!n)throw Error(`Open a chat first`);let d=s?.runtime?.workspaceId??l??a.workspaceGroups[0]?.groupKey??null;if(!d)throw Error(`Open a project first`);let f=mj(a.workspaceGroups,n)?.title?.trim()||s?.runtime?.title||n,p=rj({sourceTitle:f,intent:e}),m=tj(e),{chatId:v}=await t.command({type:`chat.create`,workspaceId:d});await t.command({type:`chat.rename`,chatId:v,title:p}),h(v),N({chatId:v,kind:`fork`,phase:`compacting`,sourceLabels:[f],previewTitle:p,previewIntent:m}),r(`/chat/${v}`),g(!1),_(null),(async()=>{try{let{prompt:r}=await t.command({type:`chat.generateForkPrompt`,chatId:n,intent:e,preset:c},{timeoutMs:12e4});N(e=>e?.chatId===v?{...e,phase:`starting`}:e);let a=oS.getState().providerDefaults[i],s=u?.modelOptions?i===`claude`?{claude:{...u.modelOptions.claude??a.modelOptions}}:{codex:{...u.modelOptions.codex??a.modelOptions}}:i===`claude`?{claude:{...a.modelOptions}}:{codex:{...a.modelOptions}};await t.command({type:`chat.send`,chatId:v,provider:i,content:r,model:o,modelOptions:s,planMode:u?.planMode??a.planMode})}catch(e){let t=xj(`fork`,e);console.warn(`[fork] background fork failed:`,t),N(e=>aj(e,v,t))}finally{N(e=>oj(e,v))}})()}async function pe(e,n,i,o,s,c){if(e.length<1)throw Error(`Select at least 1 session to merge`);let u=k??l??a.workspaceGroups[0]?.groupKey??null;if(!u)throw Error(`Open a project first`);let d=hj(a.workspaceGroups,e),f=ij({sourceLabels:d,intent:n}),p=tj(n),{chatId:m}=await t.command({type:`chat.create`,workspaceId:u});await t.command({type:`chat.rename`,chatId:m,title:f}),h(m),N({chatId:m,kind:`merge`,phase:`compacting`,sourceLabels:d,previewTitle:f,previewIntent:p}),r(`/chat/${m}`),g(!1),_(null),(async()=>{try{let{prompt:r}=await t.command({type:`chat.generateMergePrompt`,chatIds:e,intent:n,preset:s},{timeoutMs:12e4});N(e=>e?.chatId===m?{...e,phase:`starting`}:e);let a=oS.getState().providerDefaults[i],l=i===`claude`?{claude:{...a.modelOptions}}:{codex:{...a.modelOptions}};if(await t.command({type:`chat.send`,chatId:m,provider:i,content:r,model:o,modelOptions:l}),c)for(let n of e)try{await t.command({type:`chat.delete`,chatId:n})}catch(e){console.warn(`[merge] failed to delete source chat:`,n,e instanceof Error?e.message:String(e))}}catch(e){let t=xj(`merge`,e);console.warn(`[merge] background merge failed:`,t),N(e=>aj(e,m,t))}finally{N(e=>oj(e,m))}})()}async function me(e,r,i){if(n)try{await t.command({type:`chat.respondTool`,chatId:n,toolUseId:e,result:{questions:r,answers:i}})}catch(e){_(e instanceof Error?e.message:String(e))}}async function he(e,r,i,a){if(n){r&&oS.getState().setComposerPlanMode(!1);try{await t.command({type:`chat.respondTool`,chatId:n,toolUseId:e,result:{confirmed:r,...i?{clearContext:!0}:{},...a?{message:a}:{}}})}catch(e){_(e instanceof Error?e.message:String(e))}}}return{localFilePreview:T,startingLocalPath:D,pendingSessionBootstrap:M,pendingMergeProjectId:k,needsPickRequest:P,clearNeedsPickRequest:()=>F(null),handleCreateChat:V,handleOpenLocalProject:H,handleCreateProject:U,handleCheckForUpdates:oe,handleInstallUpdate:se,handleSend:G,handleSubmitFromComposer:K,handleCancel:q,handleDeleteChat:J,handleRenameChat:ee,handleRemoveProject:Y,handleCreateWorkspace:te,handleDeleteWorkspace:ne,handleRenameWorkspace:re,handleTogglePinWorkspace:ie,handleReorderWorkspaces:ae,handleOpenExternal:ce,handleOpenExternalPath:le,handleOpenLocalLink:ue,handleOpenExternalLink:de,closeLocalFilePreview:()=>E(null),handleCompose:W,handleForkSession:fe,handleMergeSession:pe,dismissBootstrapError:()=>N(null),requestMerge:e=>A(e),clearMergeRequest:()=>A(null),handleAskUserQuestion:me,handleExitPlanMode:he,updateSubmitPipelineFromSnapshot:I}}function NV(){let e=(0,j.useRef)(null);return e.current||=new nV,(0,j.useEffect)(()=>{let t=e.current;return t?.start(),()=>{t?.dispose()}},[]),e.current}function PV(e,t){if(t===void 0){console.info(`[useAppState] ${e}`);return}console.info(`[useAppState] ${e}`,t)}function FV(e){return!!(e.activeChatId&&e.sidebarReady&&e.chatUnread&&e.visibilityState===`visible`&&e.hasFocus)}function IV(e){let t=Qe(),n=NV(),r=Cg(),[i,a]=(0,j.useState)({workspaceGroups:[],independentWorkspaces:[]}),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(`connecting`),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(Dz),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),[S,C]=(0,j.useState)(148),[w,T]=(0,j.useState)(null),[E,D]=(0,j.useState)(null),{submitPipeline:O,activeQueuedText:k,updateSubmitPipeline:A,clearQueuedText:M,restoreQueuedText:N}=Vz({activeChatId:e}),P=(0,j.useRef)(null),F=(0,j.useCallback)(e=>{T(bj(e))},[]),I=(0,j.useRef)(()=>{}),L=(0,j.useRef)(new Set),{resumeRefreshNonce:R}=oV({socket:n,activeChatId:e,connectionStatus:u,setNormalizedCommandError:F});(0,j.useEffect)(()=>n.onStatus(e=>{d(e),e===`disconnected`&&Tz()}),[n]),rV(n,u===`connected`),(0,j.useEffect)(()=>n.subscribe({type:`sidebar`},e=>{a(fj(e,L.current)),_(t=>Oz(t,{type:`sidebar.loaded`,firstProjectId:e.workspaceGroups[0]?.groupKey??null})),Jx.getState().reconcileQueuedDrafts(e.workspaceGroups.flatMap(e=>e.chats.map(e=>e.chatId))),Ez(e.workspaceGroups.flatMap(e=>e.chats)),p(!0),T(null)}),[R,n]),(0,j.useEffect)(()=>n.subscribe({type:`local-workspaces`},e=>{s(e),h(!0),T(null)}),[R,n]),(0,j.useEffect)(()=>n.subscribe({type:`update`},e=>{l(e),T(null)}),[R,n]),(0,j.useEffect)(()=>{u===`connected`&&n.command({type:`update.check`,force:!0}).catch(e=>{F(e)})},[u,F,n]),(0,j.useEffect)(()=>{let e=_j(EV(),u);if(e===`awaiting_reconnect`){DV(`awaiting_reconnect`);return}e===`navigate_home`&&(OV(),t(`/`,{replace:!0}))},[u,t]),(0,j.useEffect)(()=>{function e(){c?.lastCheckedAt&&(Date.now()-c.lastCheckedAt<=3600*1e3||n.command({type:`update.check`}).catch(e=>{F(e)}))}return window.addEventListener(`focus`,e),()=>{window.removeEventListener(`focus`,e)}},[F,n,c?.lastCheckedAt]);let z=(0,j.useCallback)(e=>{I.current(e)},[]),B=(0,j.useRef)(null),{messages:V,chatSnapshot:H,orchestrationHierarchy:U,cachedScrollState:W}=gV({socket:n,activeChatId:e,resumeRefreshNonce:R,sidebarData:i,sidebarReady:f,pendingChatId:E,setPendingChatId:D,navigate:t,setProjectSelection:_,setCommandError:T,onChatSnapshotReceived:z,getScrollState:(0,j.useCallback)(()=>{let e=B.current;if(!e)return null;let t=e.scrollRef.current;if(!t)return null;let n=e.scrollModeRef.current;return{scrollTop:t.scrollTop,scrollMode:n===`detached`?`detached`:`following`}},[])});(0,j.useLayoutEffect)(()=>{let e=P.current;if(!e)return;let t=new ResizeObserver(()=>{C(e.getBoundingClientRect().height)});return t.observe(e),C(e.getBoundingClientRect().height),()=>t.disconnect()},[]);let G=(0,j.useMemo)(()=>Cj(H,e),[e,H]),K=(0,j.useMemo)(()=>mj(i.workspaceGroups,e),[e,i.workspaceGroups]);(0,j.useEffect)(()=>{PV(`active snapshot resolved`,{routeChatId:e,rawSnapshotChatId:H?.runtime.chatId??null,rawSnapshotProvider:H?.runtime.provider??null,activeSnapshotChatId:G?.runtime.chatId??null,activeSnapshotProvider:G?.runtime.provider??null,pendingChatId:E})},[e,G,H,E]);let q=(0,j.useMemo)(()=>Nj(V),[V]),J=G?.runtime??null,ee=(0,j.useMemo)(()=>V.find(e=>e.kind===`account_info`)?.message.accountInfo??null,[V]),Y=G?.availableProviders??Qm,te=Fj(J?.status),ne=Pj(J?.status),{scrollRef:re,sentinelRef:ie,scrollFollowToBottom:ae,showScrollButton:oe,transcriptPaddingBottom:se,scrollToBottom:ce,keepComposerSubmitAnchored:le,scrollModeRef:ue,beginProgrammaticScroll:de,endProgrammaticScroll:fe}=pV({activeChatId:e,messages:V,sidebarReady:f,hasSidebarChat:!e||K!==null,inputHeight:S,runtime:J,cachedScrollState:W});B.current={scrollRef:re,scrollModeRef:ue};let pe=o?.workspaces[0]?.localPath??null,me=kz(g).workspaceId,he=J?.localPath??pe??i.workspaceGroups[0]?.localPath,ge=!!(me??J?.workspaceId??i.workspaceGroups[0]?.groupKey??pe),_e=K?.lastMessageAt!==void 0,{currentSessionRuntime:ve,currentRepoStatus:ye}=bz({socket:n,activeChatId:e,sessionProvider:G?.runtime.provider,sessionToken:G?.runtime.sessionToken,isProcessing:te,resumeRefreshNonce:R}),be=(0,j.useCallback)(()=>{let t=e;t&&FV({activeChatId:t,sidebarReady:f,chatUnread:mj(i.workspaceGroups,e)?.unread===!0,visibilityState:document.visibilityState,hasFocus:document.hasFocus()})&&n.command({type:`chat.markRead`,chatId:t}).catch(F)},[e,i.workspaceGroups,f,n,F]);(0,j.useEffect)(()=>{be()},[be]),(0,j.useEffect)(()=>{function e(){be()}return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[be]);let X=MV({socket:n,activeChatId:e,navigate:t,dialog:r,sidebarData:i,chatSnapshot:H,runtime:J,selectedProjectId:me,fallbackLocalProjectPath:pe,isProcessing:te,messages:V,localProjects:o,setProjectSelection:_,setSidebarData:a,setPendingChatId:D,setSidebarOpen:y,setCommandError:T,setNormalizedCommandError:F,scrollFollowToBottom:ae,keepComposerSubmitAnchored:le,activeQueuedText:k,updateSubmitPipeline:A,submitPipeline:O,pendingDeletedChatIdsRef:L});return I.current=X.updateSubmitPipelineFromSnapshot,{socket:n,activeChatId:e,sidebarData:i,localProjects:o,updateSnapshot:c,chatSnapshot:H,orchestrationHierarchy:U,connectionStatus:u,sidebarReady:f,localProjectsReady:m,commandError:w,startingLocalPath:X.startingLocalPath,sidebarOpen:v,sidebarCollapsed:b,scrollRef:re,sentinelRef:ie,inputRef:P,messages:V,latestToolIds:q,runtime:J,currentSessionRuntime:ve,currentRepoStatus:ye,currentAccountInfo:ee,availableProviders:Y,isProcessing:te,canCancel:ne,queuedText:k,transcriptPaddingBottom:se,showScrollButton:oe,navbarLocalPath:he,hasSelectedProject:ge,chatHasKnownMessages:_e,localFilePreview:X.localFilePreview,openSidebar:()=>{y(!0),(`ontouchstart`in window||navigator.maxTouchPoints>0)&&document.activeElement?.blur?.()},closeSidebar:()=>y(!1),collapseSidebar:()=>x(!0),expandSidebar:()=>x(!1),closeLocalFilePreview:X.closeLocalFilePreview,scrollToBottom:ce,beginProgrammaticScroll:de,endProgrammaticScroll:fe,handleCreateChat:X.handleCreateChat,handleOpenLocalProject:X.handleOpenLocalProject,handleCreateProject:X.handleCreateProject,handleCheckForUpdates:X.handleCheckForUpdates,handleInstallUpdate:X.handleInstallUpdate,handleSend:X.handleSend,handleSubmitFromComposer:X.handleSubmitFromComposer,handleCancel:X.handleCancel,clearQueuedText:M,restoreQueuedText:N,handleDeleteChat:X.handleDeleteChat,handleRenameChat:X.handleRenameChat,handleRemoveProject:X.handleRemoveProject,handleCreateWorkspace:X.handleCreateWorkspace,handleDeleteWorkspace:X.handleDeleteWorkspace,handleRenameWorkspace:X.handleRenameWorkspace,handleTogglePinWorkspace:X.handleTogglePinWorkspace,handleReorderWorkspaces:X.handleReorderWorkspaces,handleOpenExternal:X.handleOpenExternal,handleOpenExternalPath:X.handleOpenExternalPath,handleOpenLocalLink:X.handleOpenLocalLink,handleOpenExternalLink:X.handleOpenExternalLink,handleCompose:X.handleCompose,handleForkSession:X.handleForkSession,handleMergeSession:X.handleMergeSession,pendingMergeProjectId:X.pendingMergeProjectId,pendingSessionBootstrap:X.pendingSessionBootstrap,dismissBootstrapError:X.dismissBootstrapError,requestMerge:X.requestMerge,clearMergeRequest:X.clearMergeRequest,handleAskUserQuestion:X.handleAskUserQuestion,handleExitPlanMode:X.handleExitPlanMode,clearCommandError:(0,j.useCallback)(()=>T(null),[]),needsPickRequest:X.needsPickRequest,clearNeedsPickRequest:X.clearNeedsPickRequest}}function LV(e,t){return e.altKey===t.alt&&!!e.shiftKey==!!t.shift&&e.key===t.key}function RV(e,t){return e.scope===`global`||e.scope===t}function zV(e){return e.map(({handler:e,...t})=>t)}function BV(e,t){return(0,j.useEffect)(()=>{let n=n=>{for(let r of e)if(LV(n,r)&&RV(r,t)){n.preventDefault(),n.stopPropagation(),r.handler();return}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),(0,j.useMemo)(()=>zV(e),[e])}var VV={ArrowLeft:`←`,ArrowRight:`→`,ArrowUp:`↑`,ArrowDown:`↓`};function HV(e){return VV[e]?VV[e]:e.length===1?e.toUpperCase():e}var UV=`rounded border border-border bg-muted px-1.5 py-0.5 text-xs font-mono font-medium text-foreground shadow-sm`;function WV({shortcut:e}){return(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.alt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`kbd`,{className:UV,children:`Alt`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`+`})]}),e.shift&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`kbd`,{className:UV,children:`Shift`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`+`})]}),(0,Q.jsx)(`kbd`,{className:UV,children:HV(e.key)})]})}var GV={global:`Global`,"new-chat":`New Chat`};function KV(e){let t={};for(let n of e){let e=t[n.scope];e?e.push(n):t[n.scope]=[n]}return t}function qV({open:e,onClose:t,shortcuts:n}){let r=(0,j.useCallback)(e=>{e.key===`Escape`&&t()},[t]);if((0,j.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)},[e,r]),!e)return null;let i=KV(n);return(0,Q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 transition-opacity`,onClick:t,children:(0,Q.jsxs)(`div`,{className:b(`relative w-full max-w-[400px] rounded-lg border border-border bg-card p-6 shadow-lg`,`animate-in fade-in zoom-in-95 duration-150`),onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`button`,{onClick:t,className:`absolute right-3 top-3 text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close`,children:(0,Q.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,Q.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})}),(0,Q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-4`,children:`Keyboard Shortcuts`}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:[`global`,`new-chat`].map(e=>{let t=i[e];return t?.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2`,children:GV[e]}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:t.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),(0,Q.jsx)(WV,{shortcut:e})]},`${e.alt}-${!!e.shift}-${e.key}`))})]},e):null})})]})})}var JV=1200,YV=320,XV=d({id:`app.layout`,c3ComponentId:`c3-101`,c3ComponentLabel:`app-shell`});function ZV(e){return e.mobileActive&&e.didCopy}function QV({pathname:e,search:t=``,hash:n=``}){let r=new URLSearchParams(t),i=(e.startsWith(`/settings/`)?e.slice(10).split(`/`)[0]:null)||r.get(`tab`),a=new URLSearchParams({tab:`settings`});return(i===`providers`||i===`profiles`||i===`extensions`)&&a.set(`settingsTab`,i),`/?${a.toString()}${n}`}function $V(e){return typeof e?.closest==`function`}function eH(e){return typeof e?.getAttribute==`function`}function tH(e){return typeof e.altKey==`boolean`&&typeof e.shiftKey==`boolean`}function nH(e){return typeof e.clientX==`number`&&typeof e.clientY==`number`}function rH(e){return $V(e)?!!e.closest(`[${p}="true"]`):!1}function iH(){return{altKey:!1,shiftKey:!1}}function aH(e){return{altKey:e.altKey,shiftKey:e.shiftKey}}function oH(e){return eH(e)?e:null}function sH(e,t){let n=iH();function r(e){tH(e)&&(n=aH(e),t.setModifiers(n))}function i(){n=iH(),t.setModifiers(n)}function a(e){if(!nH(e))return;let r=e.target??null;if(rH(r)){t.cancelPendingPointerClear();return}if(l(n))return;t.setPointerPosition({clientX:e.clientX,clientY:e.clientY});let i=oH(r);if(h(i,1).length===0){t.clearPointerTargetWithDelay();return}t.cancelPendingPointerClear(),t.setPointerTarget(i),t.resetHighlight()}return e.addEventListener(`keydown`,r),e.addEventListener(`keyup`,r),e.addEventListener(`blur`,i),e.addEventListener(`pointermove`,a),()=>{e.removeEventListener(`keydown`,r),e.removeEventListener(`keyup`,r),e.removeEventListener(`blur`,i),e.removeEventListener(`pointermove`,a)}}function cH(e){return typeof e?.getBoundingClientRect==`function`}function lH(e,t){let n=e.find(e=>e.getAttribute(`data-ui-id`)===t)??e[0]??null;return cH(n)?n.getBoundingClientRect():null}function uH(e){return e?{top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,width:0,height:0}:null}function dH(e){let t=e.target;if(!t||typeof t.closest!=`function`||!Bh(t))return null;let n=zh(t);return n?(e.preventDefault(),e.stopPropagation(),{target:n,clientX:e.clientX,clientY:e.clientY}):null}async function fH(e){let t=typeof navigator>`u`?null:navigator.clipboard;return t?.writeText?t.writeText(g(e)).then(()=>!0,()=>!1):!1}function pH(){let[e,t]=(0,j.useState)(iH),[n,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(null),[c,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(!1),p=(0,j.useRef)(null),m=(0,j.useRef)(null),g=(0,j.useRef)(!1),_=(0,j.useMemo)(()=>h(n,3),[n]),v=l(e)||d;g.current=v;let y=(0,j.useMemo)(()=>uH(i),[i]),b=o??_[0]?.getAttribute(`data-ui-id`)??null,x=(0,j.useMemo)(()=>lH(_,o),[o,_]);(0,j.useEffect)(()=>sH(window,{setModifiers:t,setPointerTarget:r,setPointerPosition:a,resetHighlight:()=>{s(null)},cancelPendingPointerClear:()=>{m.current!==null&&(clearTimeout(m.current),m.current=null)},clearPointerTargetWithDelay:()=>{if(!g.current){r(null),s(null);return}m.current===null&&(m.current=setTimeout(()=>{r(null),s(null),m.current=null},YV))}}),[]),(0,j.useEffect)(()=>{if(!d)return;function e(e){let t=dH(e);t&&(r(t.target),a({clientX:t.clientX,clientY:t.clientY}),s(null))}return window.addEventListener(`click`,e,{capture:!0}),()=>{window.removeEventListener(`click`,e,{capture:!0})}},[d]),(0,j.useEffect)(()=>()=>{p.current!==null&&clearTimeout(p.current),m.current!==null&&clearTimeout(m.current)},[]);function S(e){fH(e).then(t=>{t&&(ZV({mobileActive:d,didCopy:t})&&(f(!1),r(null),a(null),s(null)),u(e.id),p.current!==null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(t=>t===e.id?null:t),p.current=null},JV))})}function C(){f(e=>(e&&(r(null),a(null),s(null)),!e))}let w=Rh();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ng,{active:v,anchorRect:y,highlightRect:v?x:null,stack:v?_:[],highlightedId:v?b:null,copiedId:c,onCopy:S,onHighlight:s}),w?(0,Q.jsx)(Gh,{active:d,onToggle:C}):null]})}function mH(){let e=Ye(),t=(0,j.useContext)(yz);if(!t)throw Error(`App layout requires state context`);let n=e.pathname===`/`,r=yx(()=>t.openSidebar()),i=yx(()=>t.closeSidebar()),a=yx(()=>t.collapseSidebar()),o=yx(()=>t.expandSidebar()),s=yx(e=>{t.handleCreateChat(e)}),l=yx(e=>{t.handleDeleteChat(e)}),u=yx((e,n)=>{t.handleRenameChat(e,n)}),d=yx(e=>{t.handleRemoveProject(e)}),f=yx(()=>{t.handleInstallUpdate()}),p=yx(e=>{t.requestMerge(e)}),m=yx((e,n)=>{t.handleRenameWorkspace(e,n)}),h=yx((e,n)=>{t.handleTogglePinWorkspace(e,n)}),g=yx(e=>{t.handleReorderWorkspaces(e)}),_=yx(e=>{t.handleDeleteWorkspace(e)}),[v,y]=(0,j.useState)(!1),b=yx(e=>{t.handleCreateWorkspace(e)});return(0,Q.jsxs)(`div`,{className:`flex h-[100dvh] min-h-[100dvh] flex-col overflow-hidden`,...c(XV),children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(LI,{data:t.sidebarData,activeChatId:t.activeChatId,connectionStatus:t.connectionStatus,ready:t.sidebarReady,open:t.sidebarOpen,collapsed:t.sidebarCollapsed,showMobileOpenButton:n,onOpen:r,onClose:i,onCollapse:a,onExpand:o,onCreateChat:s,onDeleteChat:l,onRenameChat:u,onRemoveProject:d,updateSnapshot:t.updateSnapshot,onInstallUpdate:f,onMergeSession:p,onCreateWorkspace:()=>y(!0),onRenameWorkspace:m,onTogglePinWorkspace:h,onReorderWorkspaces:g,onDeleteWorkspace:_}),(0,Q.jsx)(Ot,{context:t})]}),(0,Q.jsx)(RI,{open:v,onOpenChange:y,onConfirm:b})]})}function hH(e,t){let n=Qm.findIndex(t=>t.id===e);return n===-1?e:Qm[(n+t+Qm.length)%Qm.length].id}function gH(e,t,n){if(e.length===0)return null;let r=t===null?n===1?-1:e.length:e.findIndex(e=>e.chatId===t),i=r===-1?n===1?-1:e.length:r;if(n===1)return e.find((e,t)=>t>i&&e.unread)?.chatId??e.find(e=>e.unread)?.chatId??null;for(let t=i-1;t>=0;--t)if(e[t].unread)return e[t].chatId;for(let t=e.length-1;t>=0;--t)if(e[t].unread)return e[t].chatId;return null}function _H(){let e=(0,j.useContext)(yz),t=Qe(),[n,r]=(0,j.useState)(!1),i=oS(e=>e.composerState),a=oS(e=>e.resetComposerFromProvider),o=e&&!e.chatHasKnownMessages?`new-chat`:`global`;return(0,Q.jsx)(qV,{open:n,onClose:()=>r(!1),shortcuts:BV((0,j.useMemo)(()=>{let n=()=>{if(!e)return;let t=e.runtime?.workspaceId??e.sidebarData.workspaceGroups[0]?.groupKey;t&&e.handleCreateChat(t)},o=e=>{a(hH(i.provider,e))},s=n=>{if(!e)return;let r=gH(e.sidebarData.workspaceGroups.flatMap(e=>e.chats),e.activeChatId,n);!r||r===e.activeChatId||t(`/chat/${r}`)};return[{key:`/`,alt:!0,label:`Show shortcuts`,scope:`global`,handler:()=>r(e=>!e)},{key:`n`,alt:!0,label:`New chat`,description:`Same project`,scope:`global`,handler:n},{key:`ArrowLeft`,alt:!0,label:`Previous provider`,scope:`new-chat`,handler:()=>o(-1)},{key:`ArrowRight`,alt:!0,label:`Next provider`,scope:`new-chat`,handler:()=>o(1)},{key:`ArrowUp`,alt:!0,label:`Previous unread session`,scope:`global`,handler:()=>s(-1)},{key:`ArrowDown`,alt:!0,label:`Next unread session`,scope:`global`,handler:()=>s(1)}]},[e,i.provider,t,a]),o)})}function vH(){let e=Ye();return(0,Q.jsx)(Dt,{replace:!0,to:QV({pathname:e.pathname,search:e.search,hash:e.hash})})}function yH(){let e=Ye(),t=IV((e.pathname.startsWith(`/chat/`)?e.pathname.slice(6):null)||null);return(0,Q.jsxs)(yz.Provider,{value:t,children:[(0,Q.jsx)(_H,{}),(0,Q.jsx)(jt,{children:(0,Q.jsxs)(kt,{element:(0,Q.jsx)(mH,{}),children:[(0,Q.jsx)(kt,{path:`/`,element:(0,Q.jsx)(CR,{})}),(0,Q.jsx)(kt,{path:`/tinkaria/*`,element:(0,Q.jsx)(Ph,{})}),(0,Q.jsx)(kt,{path:`/settings/*`,element:(0,Q.jsx)(vH,{})}),(0,Q.jsx)(kt,{path:`/chat/:chatId`,element:(0,Q.jsx)(kI,{})}),(0,Q.jsx)(kt,{path:`/workspace/:id`,element:(0,Q.jsx)(iz,{})}),(0,Q.jsx)(kt,{path:`/project/:groupKey`,element:(0,Q.jsx)(vz,{})})]})})]})}function bH(){return(0,Q.jsxs)(Qc,{children:[(0,Q.jsx)(pH,{}),(0,Q.jsx)(Sg,{children:(0,Q.jsx)(yH,{})}),(0,Q.jsx)(l_,{theme:`dark`,position:`bottom-right`})]})}function xH(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function SH(e,t,n=new Date,r=typeof location<`u`?location.href:``){return{level:e,msg:xH(t),ts:n.toISOString(),url:r}}var CH=1e3,wH=3e3,TH=!1;function EH(e=`/api/logs`){if(TH||typeof window>`u`)return()=>{};TH=!0;let t=[];function n(e){t.length>=CH&&t.shift(),t.push(e)}function r(n=!1){if(t.length===0)return;let r=t;t=[];let i=JSON.stringify({logs:r});try{if(n&&typeof navigator<`u`&&navigator.sendBeacon){navigator.sendBeacon(e,new Blob([i],{type:`application/json`}));return}fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:i,keepalive:!0}).catch(()=>{})}catch{}}let i=[[`debug`,`debug`],[`info`,`info`],[`log`,`info`],[`warn`,`warn`],[`error`,`error`]],a=new Map;for(let[e,t]of i){let r=console[e];a.set(e,r),console[e]=(...e)=>{try{n(SH(t,e))}catch{}r(...e)}}let o=e=>n(SH(`error`,[`window.onerror: ${e.message}`,e.error])),s=e=>n(SH(`error`,[`unhandledrejection:`,e.reason])),c=()=>r(!0);window.addEventListener(`error`,o),window.addEventListener(`unhandledrejection`,s),window.addEventListener(`pagehide`,c),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&r(!0)});let l=window.setInterval(()=>r(!1),wH);return()=>{window.clearInterval(l);for(let[e,t]of a)console[e]=t;window.removeEventListener(`error`,o),window.removeEventListener(`unhandledrejection`,s),window.removeEventListener(`pagehide`,c),TH=!1}}EH();var DH=document.getElementById(`root`);if(!DH)throw Error(`Missing #root`);(0,ki.createRoot)(DH).render((0,Q.jsx)(j.StrictMode,{children:(0,Q.jsx)(xn,{children:(0,Q.jsx)(KI,{children:(0,Q.jsx)(bH,{})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`)});export{li as A,or as B,_x as C,tl as D,$c as E,jr as F,rr as H,Or as I,br as L,$r as M,Gr as N,el as O,Pr as P,ur as R,lS as S,gl as T,ar as V,XO as _,BM as a,zT as b,jM as c,NM as d,xk as f,GO as g,RO as h,LM as i,ii as j,Ei as k,AM as l,BO as m,zM as n,FM as o,HO as p,IM as r,kM as s,RM as t,MM as u,GE as v,C_ as w,_T as x,KT as y,cr as z};
|