@overdeck/desktop 0.50.0 → 0.50.1
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/package.json +1 -1
- package/server/{acceptance-criteria-B_maCGZv.js → acceptance-criteria-DFyrgxW5.js} +2 -2
- package/server/{active-dashboard-bundle-CCqpFWiz.js → active-dashboard-bundle-DbfgP8TS.js} +2 -2
- package/server/{activity-logger-B0X2JJwM.js → activity-logger-DtdKxzPh.js} +1 -1
- package/server/{activity-logger-SlTXYCVf.js → activity-logger-ru8ggv-d.js} +3 -3
- package/server/{advancing-selfheal-BJAfiY-C.js → advancing-selfheal-BdZ1iFJf.js} +5 -5
- package/server/{agent-gc-bhikjoJ_.js → agent-gc-DBMg1vIc.js} +10 -10
- package/server/{agent-idle-D-UQ7gDv.js → agent-idle-CQlwmcRR.js} +10 -10
- package/server/{agent-state-BrUPf_7Z.js → agent-state-B0v3fvGI.js} +1 -1
- package/server/{agent-state-FABw8neJ.js → agent-state-BnyNoDWQ.js} +81 -80
- package/server/{agent-state-service-rDenYSlD.js → agent-state-service-D95wBjA3.js} +4 -4
- package/server/{agent-state-service-BAQApt97.js → agent-state-service-GK2Uy8zc.js} +1 -1
- package/server/{agents-DixZjXWm.js → agents-BdkVgjxC.js} +1 -1
- package/server/{agents-DzpQidT8.js → agents-DMs1aLRU.js} +4 -4
- package/server/{archive-planning-BL1ABtW0.js → archive-planning-CFf5FVHQ.js} +4 -4
- package/server/archive-planning-CNSWQPvz.js +2 -0
- package/server/{artifact-index-jobs-Cjdme0jS.js → artifact-index-jobs-BdeB5RIY.js} +2 -2
- package/server/{assemble-B_JgnCbG.js → assemble-D88iFkP-.js} +2 -2
- package/server/{auto-spawn-consent-BesWchEi.js → auto-spawn-consent-C1avLtkk.js} +6 -6
- package/server/{backlog-auto-trigger-COLq639j.js → backlog-auto-trigger-oKIGNBzZ.js} +2 -2
- package/server/{behavior-DCg8CIWC.js → behavior-CPX0E2Fj.js} +48 -6
- package/server/{bridge-pool-patrol-BDohuMRt.js → bridge-pool-patrol-DstxbANA.js} +2 -2
- package/server/{briefing-freshness-ENa_hW_V.js → briefing-freshness-FF0WLPMc.js} +2 -2
- package/server/build-info-Df2tkRrB.js +2 -0
- package/server/{build-info-WuZT6xyi.js → build-info-DiA6h4T6.js} +3 -3
- package/server/{checkpoint-manager-CSZ7aVQF.js → checkpoint-manager-CkXA-F6Z.js} +2 -2
- package/server/{checkpoint-manager-DXhGRvg4.js → checkpoint-manager-D74ueYZp.js} +1 -1
- package/server/checkpoint-worker.js +1 -1
- package/server/{checkpoints-DUkUsPVS.js → checkpoints-Ds83fUb1.js} +2 -2
- package/server/{checkpoints-tm_w6Y4V.js → checkpoints-JIKy0UFv.js} +1 -1
- package/server/{claude-hooks-provision-CTh9zxEi.js → claude-hooks-provision-BJ8LNIAe.js} +1 -1
- package/server/{claude-hooks-provision-fRofvhTN.js → claude-hooks-provision-D7Z8kANm.js} +2 -2
- package/server/{claude-permissions-DLrb9ovz.js → claude-permissions-Bn53HCXr.js} +2 -2
- package/server/{claude-settings-overlay-BYnXaTVc.js → claude-settings-overlay-CqJZjFqv.js} +2 -2
- package/server/{claude-settings-overlay-CMS5Jab5.js → claude-settings-overlay-QByq1SQa.js} +1 -1
- package/server/{cli-CoQou1t_.js → cli-BXmAb7vN.js} +11 -11
- package/server/cli-BjznnCC3.js +2 -0
- package/server/{cliproxy-DXDQcR3I.js → cliproxy-L_2OxNJf.js} +2 -2
- package/server/{cliproxy-DdhFpcXU.js → cliproxy-ltFu5xfR.js} +1 -1
- package/server/{close-issue-CpQ0BWg-.js → close-issue-BZAf0Ii-.js} +4 -4
- package/server/{closed-issue-reaper-CdcJRvUx.js → closed-issue-reaper-BJa8SbvQ.js} +13 -13
- package/server/{closed-issue-reaper-TymtZM37.js → closed-issue-reaper-DVtyOI4C.js} +1 -1
- package/server/{codex-BValsmtK.js → codex-BqLZKVNm.js} +1 -1
- package/server/{codex-DYyZL8JD.js → codex-DSs-3aOm.js} +5 -5
- package/server/{compaction-continuation-CVjbdGKt.js → compaction-continuation-TG0HYkOq.js} +3 -3
- package/server/{config-NxI9Yl2f.js → config-Cx3N6gWz.js} +2 -2
- package/server/{config-_qaa1UXH.js → config-DP0VV7rX.js} +2 -2
- package/server/{config-CvKH7r7W.js → config-DURnId0k.js} +1 -1
- package/server/{config-yaml-D60AnTIu.js → config-yaml-OoH-ZpTb.js} +25 -1
- package/server/{conflict-gate-hAUCL-un.js → conflict-gate-SgOELW84.js} +4 -4
- package/server/{conflict-gate-0dD1kxjN.js → conflict-gate-pMfhBEVB.js} +1 -1
- package/server/{context-layers-Ds1MnEFI.js → context-layers-D0QBOPJJ.js} +2 -2
- package/server/{context-layers-CdpabJj0.js → context-layers-LY5zt0da.js} +3 -3
- package/server/{continue-CnvrUfxw.js → continue-Cmzd6leL.js} +2 -2
- package/server/{control-settings-Db0uXgVM.js → control-settings-Bdud_B1j.js} +5 -5
- package/server/{conversation-compaction-DzMXGRiJ.js → conversation-compaction-BX9UR8nl.js} +1 -1
- package/server/{conversation-compaction-B-1KETG9.js → conversation-compaction-dFx_2wpa.js} +8 -8
- package/server/{conversation-service-BL-asWPX.js → conversation-service-B3h1erHm.js} +1 -1
- package/server/{conversation-service-BxIOd5ay.js → conversation-service-zgLM2g2D.js} +22 -12
- package/server/{conversations-CEMfwMt-.js → conversations-Ch7UGi0F.js} +1 -1
- package/server/{conversations-nS6QgYpD.js → conversations-JyrMSeOh.js} +5 -5
- package/server/{cost-DTuIRE4y.js → cost-CxXv7ei-.js} +10 -2
- package/server/{cost-3FyqKK56.js → cost-DR57uJFP.js} +8 -8
- package/server/{cost-Cctc-Q9M.js → cost-MZ7EZFDc.js} +3 -3
- package/server/{cost-sync-DfmvLT9L.js → cost-sync-Bq_dyq9k.js} +3 -3
- package/server/{dag-o-dUpw1L.js → dag-CKUsr8wB.js} +2 -2
- package/server/dashboard-db-worker.js +10 -10
- package/server/{deacon-e6py3jkM.js → deacon-BUOpTnmQ.js} +3 -3
- package/server/{deacon-CsisLmPt.js → deacon-C7qZxRuW.js} +119 -119
- package/server/{deacon-canonical-state-DkdkQS5p.js → deacon-canonical-state-hcaZgjoT.js} +2 -2
- package/server/{deacon-event-client-CMQswEHX.js → deacon-event-client-Coiopt4u.js} +2 -2
- package/server/{deacon-event-client-BCjHiGAY.js → deacon-event-client-DJ71Tifg.js} +1 -1
- package/server/{deacon-pending-lifecycle-BzaE76Xo.js → deacon-pending-lifecycle-Dv0-8bZG.js} +2 -2
- package/server/deacon.js +10 -10
- package/server/dead-end-trip-B91w2PGV.js +2 -0
- package/server/{dead-end-trip-Bs3hxIn6.js → dead-end-trip-DH_hA7yS.js} +3 -3
- package/server/{delivery-DhZGRShH.js → delivery-zJM4aIkf.js} +1 -1
- package/server/{deploy-patrol-B8sKkA8h.js → deploy-patrol-Cv96N0s6.js} +7 -7
- package/server/deploy-queue-2cN86Lg4.js +2 -0
- package/server/{deploy-queue-CCGWXFkp.js → deploy-queue-EcksuKE2.js} +2 -2
- package/server/{deploy-window-YuJewzmC.js → deploy-window-BXbzS0zN.js} +4 -4
- package/server/{deploy-window-hgsvZ3UZ.js → deploy-window-CHgL_TTN.js} +1 -1
- package/server/{dev-supervisor-4SBloJHV.js → dev-supervisor-lNaYB136.js} +2 -2
- package/server/{devcontainer-renderer-BiJhwFNi.js → devcontainer-renderer-q8q9aXRd.js} +2 -2
- package/server/{docker-DQzyMXkd.js → docker-BNd0tMdS.js} +1 -1
- package/server/{docker-CWO7dcIP.js → docker-Dk-shfga.js} +3 -3
- package/server/{done-preflight-CGFA0M1b.js → done-preflight-AiXnYYAy.js} +1 -1
- package/server/{done-preflight-Cx9JGznT.js → done-preflight-CukR3Br8.js} +5 -5
- package/server/{ensure-devcontainer-Dk6ZMOUC.js → ensure-devcontainer-BjMV_gdX.js} +1 -1
- package/server/{ensure-devcontainer-DzYBBwnM.js → ensure-devcontainer-YXncXZ5Q.js} +3 -3
- package/server/{event-store-C50Qt-f1.js → event-store-CFnLP8w-.js} +1 -1
- package/server/{event-store-DTns2XZP.js → event-store-DbjldlXW.js} +5 -5
- package/server/{events-B6xW8Cpm.js → events-Bb2x5ijT.js} +3 -3
- package/server/{factory-CWVKwKFE.js → factory-DfIQG-qW.js} +4 -4
- package/server/{feature-registry-storage-vaxRN3WO.js → feature-registry-storage-BzAGS4DA.js} +2 -2
- package/server/{features-DXWwktJB.js → features-KxOILHX8.js} +2 -2
- package/server/{feedback-stuck-retirement-CXAYe2rU.js → feedback-stuck-retirement-BqTHm-1Z.js} +2 -2
- package/server/{feedback-target-yPD_wclF.js → feedback-target-BjLidX0M.js} +10 -10
- package/server/{feedback-target-DSVpi0gT.js → feedback-target-D2CIZFwc.js} +1 -1
- package/server/{feedback-writer-BzN4qvaP.js → feedback-writer-BrSQ4fC-.js} +1 -1
- package/server/{feedback-writer-Ds1Wjsz4.js → feedback-writer-Dgrma-L1.js} +5 -5
- package/server/{flywheel-DWKd7bMc.js → flywheel-D5FchYg4.js} +13 -13
- package/server/{flywheel-BCZS-FlW.js → flywheel-Ds0eOd1P.js} +1 -1
- package/server/{flywheel-CC4gE_rx.js → flywheel-X6kvGnf2.js} +13 -13
- package/server/{flywheel-merge-order-DJwH2KpL.js → flywheel-merge-order-BTY73Efv.js} +7 -7
- package/server/{flywheel-merge-order-DDT3i57u.js → flywheel-merge-order-PTHnouQS.js} +1 -1
- package/server/{forge-CHADjOFs.js → forge-B08cRXEb.js} +2 -2
- package/server/forge-egNLsjVi.js +2 -0
- package/server/{fs-lock-DQ_gUxfq.js → fs-lock-DfiYlr5u.js} +2 -2
- package/server/{fts-operations-asZo2fh1.js → fts-operations-Do1SP0w4.js} +2 -2
- package/server/{git-utils-BdHk8y7g.js → git-utils-DfpFkvwk.js} +4 -4
- package/server/{git-utils-BAMwn9Nf.js → git-utils-fcK3ZRNj.js} +1 -1
- package/server/{github-app-BlMSzSTw.js → github-app-Co8ZhyUJ.js} +2 -2
- package/server/{github-app-BWziYCf3.js → github-app-HAqQZZRD.js} +1 -1
- package/server/{github-client-OK24qpol.js → github-client-C7MUxFzX.js} +1 -1
- package/server/{github-client-w6j5nVlz.js → github-client-wqbDCmlL.js} +2 -2
- package/server/{github-pr-lookup-bGcsEvLE.js → github-pr-lookup-DdLCDdu9.js} +2 -2
- package/server/{harness-binary-DChiynaB.js → harness-binary-BuakhXkB.js} +2 -2
- package/server/{harness-resolve-BplBEbwn.js → harness-resolve-CISjc9FR.js} +4 -4
- package/server/{health-events-BTqsmunw.js → health-events-9RhRGZK1.js} +1 -1
- package/server/{health-events-Bk3LjaJ9.js → health-events-CIE7gy34.js} +2 -2
- package/server/{hooks-EndRNrx9.js → hooks-CmL3TXla.js} +1 -1
- package/server/{hooks-DJR1yR9w.js → hooks-D55VTdQS.js} +2 -2
- package/server/{identity-C3s8lyp0.js → identity-CZbJ0xpl.js} +3 -3
- package/server/{idle-stack-reaper-DtoI4al6.js → idle-stack-reaper-CjovDCet.js} +4 -4
- package/server/{idle-stack-reaper-CBelVOE3.js → idle-stack-reaper-DhbFdkWv.js} +1 -1
- package/server/{infra-CJRi_5Wu.js → infra-BbSWNOpH.js} +4 -4
- package/server/{injection-ADWQ3D0s.js → injection-BSnn_10a.js} +8 -8
- package/server/{injection-BWsgHvrL.js → injection-DsQDBSEi.js} +1 -1
- package/server/inspect-agent-BuSYgRQs.js +2 -0
- package/server/{inspect-agent-CCfNJjKr.js → inspect-agent-DS8j2v6U.js} +12 -12
- package/server/{internal-token-BeIWG_kT.js → internal-token-CUKcTWSG.js} +2 -2
- package/server/{internal-token-BCTEqUCX.js → internal-token-CkrMLCLU.js} +1 -1
- package/server/{io-BCtZoXHo.js → io-BgzG56av.js} +4 -4
- package/server/{issue-closed-CiYAa6bX.js → issue-closed-DZEwD3ol.js} +7 -7
- package/server/{issue-lifecycle-DaKN57sx.js → issue-lifecycle-Bnfbpkmk.js} +1 -1
- package/server/{issue-lifecycle-BETNVVLq.js → issue-lifecycle-LgYeE1o2.js} +24 -24
- package/server/{issue-service-singleton-C_sZ0HjP.js → issue-service-singleton-Bsb0GaY8.js} +10 -10
- package/server/{issue-service-singleton-1Q0ER8Yc.js → issue-service-singleton-COEqWNKE.js} +1 -1
- package/server/{issue-title-fallback-B91iD66g.js → issue-title-fallback-D4_b2XwP.js} +3 -3
- package/server/{issues-RGHQUKhB.js → issues-DYAEUW45.js} +2 -2
- package/server/{jsonl-parser-Dfs1dlYE.js → jsonl-parser-1IqHI9Yb.js} +3 -3
- package/server/{jsonl-resolver-bFtftCDd.js → jsonl-resolver-BJ8Hg-yD.js} +7 -7
- package/server/{kimi-code-BxkDgaj4.js → kimi-code-Cdkk9vRU.js} +1 -1
- package/server/{kimi-code-CNYRA8Dd.js → kimi-code-DwqLCWFw.js} +10 -10
- package/server/{kimi-parser-OcWwmOqF.js → kimi-parser-DFsZQArz.js} +2 -2
- package/server/{label-cleanup-CefxK9tL.js → label-cleanup-Bej6xDZK.js} +2 -2
- package/server/{lifecycle-DVXyUil2.js → lifecycle-BibLMHBH.js} +2 -2
- package/server/{lifecycle-DDZ7w-BY.js → lifecycle-CMpSB9sn.js} +5 -5
- package/server/{lifecycle-io-D7N0vQNj.js → lifecycle-io-CCCAMefe.js} +5 -5
- package/server/{lifecycle-io-D1oBiMce.js → lifecycle-io-CLWwYZaR.js} +1 -1
- package/server/{linear-client-TL32snOy.js → linear-client-BtYl16Cy.js} +1 -1
- package/server/{linear-client-DUN7zCeb.js → linear-client-fpL-qJEa.js} +2 -2
- package/server/{linear-mcp-auth-CtRKSHy5.js → linear-mcp-auth-CQ7ROT1X.js} +1 -1
- package/server/{linear-mcp-auth-bB0CPyjh.js → linear-mcp-auth-nAYWoUbH.js} +4 -4
- package/server/memory-fts-worker.js +1 -1
- package/server/{memory-governor-Cvv_9K0M.js → memory-governor-Mi5zF5zw.js} +10 -10
- package/server/{memory-pressure-patrol-C6DJJQRA.js → memory-pressure-patrol-CDeDh46A.js} +5 -5
- package/server/{merge-DOCR6pHi.js → merge-DCuDLiy9.js} +1 -1
- package/server/{merge-FTk4LsnM.js → merge-_XIivhkq.js} +3 -3
- package/server/{merge-agent-D-4_iQgy.js → merge-agent-svBDRWB6.js} +2 -2
- package/server/{merge-agent-C-dsN9se.js → merge-agent-zF9vqWqY.js} +31 -31
- package/server/{merge-completeness-BOtBUwTU.js → merge-completeness-CQPqu-pI.js} +4 -4
- package/server/{merge-completeness-CoLJxfUY.js → merge-completeness-CeQheehh.js} +1 -1
- package/server/{merge-eligibility-C4rTS97F.js → merge-eligibility-CJrBhQQe.js} +1 -1
- package/server/{merge-eligibility-D7wRnJbj.js → merge-eligibility-DhxVE8qU.js} +3 -3
- package/server/merge-ops-CUzpOPtO.js +2 -0
- package/server/{merge-rebase-KBw4rdh3.js → merge-rebase-Bjo45m3k.js} +2 -2
- package/server/merge-rebase-DkfcUT60.js +2 -0
- package/server/{merge-set-CyW-xSn4.js → merge-set-COZvz2nx.js} +4 -4
- package/server/{merge-set-CVfEM57p.js → merge-set-ChxZgjBB.js} +1 -1
- package/server/{merge-sync-YLvOPAry.js → merge-sync-CCi1Esdx.js} +2 -2
- package/server/{merge-sync-CYGsJy0u.js → merge-sync-DuJ6Vkl3.js} +1 -1
- package/server/{merge-train-VxLn8Ms4.js → merge-train-DTJXF8ph.js} +4 -4
- package/server/{merge-train-deps-D0y4hBB9.js → merge-train-deps-C0P0qGKe.js} +4 -4
- package/server/{merge-verification-BfJRNMiD.js → merge-verification-C5FexOBZ.js} +6 -6
- package/server/{merged-docker-cleanup-worker-Ci9oeFAe.js → merged-docker-cleanup-worker-0SEDG3Ao.js} +1 -1
- package/server/{merged-docker-cleanup-worker-Bh5fKG_b.js → merged-docker-cleanup-worker-C-kSp_jw.js} +3 -3
- package/server/{messaging-Dfbhgjd6.js → messaging-DQi-WEFB.js} +1 -1
- package/server/node_modules/.package-lock.json +17 -17
- package/server/node_modules/@types/node/README.md +1 -1
- package/server/node_modules/@types/node/buffer.buffer.d.ts +5 -0
- package/server/node_modules/@types/node/buffer.d.ts +1 -0
- package/server/node_modules/@types/node/crypto.d.ts +0 -2
- package/server/node_modules/@types/node/dgram.d.ts +119 -4
- package/server/node_modules/@types/node/diagnostics_channel.d.ts +4 -4
- package/server/node_modules/@types/node/ffi.d.ts +1 -1
- package/server/node_modules/@types/node/fs/promises.d.ts +61 -65
- package/server/node_modules/@types/node/fs.d.ts +86 -76
- package/server/node_modules/@types/node/http.d.ts +2 -2
- package/server/node_modules/@types/node/http2.d.ts +2 -2
- package/server/node_modules/@types/node/index.d.ts +1 -0
- package/server/node_modules/@types/node/inspector.d.ts +2 -1
- package/server/node_modules/@types/node/net.d.ts +108 -16
- package/server/node_modules/@types/node/package.json +3 -3
- package/server/node_modules/@types/node/perf_hooks.d.ts +31 -19
- package/server/node_modules/@types/node/quic.d.ts +43 -15
- package/server/node_modules/@types/node/stream/iter.d.ts +4 -4
- package/server/node_modules/@types/node/stream/web.d.ts +20 -0
- package/server/node_modules/@types/node/tls.d.ts +50 -15
- package/server/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +5 -0
- package/server/node_modules/@types/node/ts5.6/index.d.ts +1 -0
- package/server/node_modules/@types/node/ts5.7/index.d.ts +1 -0
- package/server/node_modules/@types/node/tty.d.ts +4 -3
- package/server/node_modules/@types/node/vfs.d.ts +211 -0
- package/server/node_modules/@types/node/vm.d.ts +1 -1
- package/server/node_modules/@types/node/zlib.d.ts +17 -0
- package/server/node_modules/msgpackr/README.md +1 -0
- package/server/node_modules/msgpackr/dist/index-no-eval.cjs +2 -2
- package/server/node_modules/msgpackr/dist/index-no-eval.cjs.map +1 -1
- package/server/node_modules/msgpackr/dist/index-no-eval.min.js +1 -1
- package/server/node_modules/msgpackr/dist/index-no-eval.min.js.map +1 -1
- package/server/node_modules/msgpackr/dist/index.js +2 -2
- package/server/node_modules/msgpackr/dist/index.js.map +1 -1
- package/server/node_modules/msgpackr/dist/index.min.js +1 -1
- package/server/node_modules/msgpackr/dist/index.min.js.map +1 -1
- package/server/node_modules/msgpackr/dist/node.cjs +2 -2
- package/server/node_modules/msgpackr/dist/node.cjs.map +1 -1
- package/server/node_modules/msgpackr/dist/test.js +52 -2
- package/server/node_modules/msgpackr/dist/test.js.map +1 -1
- package/server/node_modules/msgpackr/index.d.cts +1 -0
- package/server/node_modules/msgpackr/index.d.ts +1 -0
- package/server/node_modules/msgpackr/pack.js +2 -2
- package/server/node_modules/msgpackr/package.json +1 -1
- package/server/node_modules/protobufjs/dist/light/protobuf.js +59 -6
- package/server/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/server/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/server/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/server/node_modules/protobufjs/dist/minimal/protobuf.js +22 -2
- package/server/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/server/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/server/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/server/node_modules/protobufjs/dist/protobuf.js +59 -6
- package/server/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/server/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/server/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/server/node_modules/protobufjs/package.json +1 -1
- package/server/node_modules/protobufjs/src/decoder.js +32 -3
- package/server/node_modules/protobufjs/src/reader.js +20 -0
- package/server/node_modules/protobufjs/src/wrappers.js +5 -1
- package/server/node_modules/undici/docs/docs/api/Client.md +4 -0
- package/server/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +3 -2
- package/server/node_modules/undici/docs/docs/api/EventSource.md +4 -0
- package/server/node_modules/undici/docs/docs/api/Interceptors.md +7 -3
- package/server/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +7 -1
- package/server/node_modules/undici/lib/cache/memory-cache-store.js +2 -2
- package/server/node_modules/undici/lib/core/symbols.js +2 -0
- package/server/node_modules/undici/lib/dispatcher/agent.js +7 -2
- package/server/node_modules/undici/lib/dispatcher/balanced-pool.js +7 -4
- package/server/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
- package/server/node_modules/undici/lib/dispatcher/client-h2.js +43 -3
- package/server/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/server/node_modules/undici/lib/dispatcher/dispatcher-base.js +13 -1
- package/server/node_modules/undici/lib/dispatcher/dispatcher.js +15 -1
- package/server/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -0
- package/server/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +10 -3
- package/server/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -1
- package/server/node_modules/undici/lib/dispatcher/retry-agent.js +3 -0
- package/server/node_modules/undici/lib/dispatcher/round-robin-pool.js +1 -1
- package/server/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +91 -21
- package/server/node_modules/undici/lib/handler/cache-handler.js +29 -5
- package/server/node_modules/undici/lib/handler/decorator-handler.js +7 -1
- package/server/node_modules/undici/lib/handler/deduplication-handler.js +12 -6
- package/server/node_modules/undici/lib/handler/redirect-handler.js +21 -4
- package/server/node_modules/undici/lib/handler/retry-handler.js +148 -30
- package/server/node_modules/undici/lib/interceptor/cache.js +65 -12
- package/server/node_modules/undici/lib/interceptor/decompress.js +115 -13
- package/server/node_modules/undici/lib/interceptor/deduplicate.js +5 -4
- package/server/node_modules/undici/lib/interceptor/dns.js +7 -0
- package/server/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/server/node_modules/undici/lib/mock/mock-agent.js +13 -1
- package/server/node_modules/undici/lib/mock/mock-utils.js +11 -10
- package/server/node_modules/undici/lib/util/cache.js +45 -3
- package/server/node_modules/undici/lib/web/cookies/parse.js +150 -147
- package/server/node_modules/undici/lib/web/eventsource/eventsource-stream.js +28 -1
- package/server/node_modules/undici/lib/web/eventsource/eventsource.js +13 -3
- package/server/node_modules/undici/lib/web/fetch/index.js +6 -0
- package/server/node_modules/undici/lib/web/fetch/request.js +2 -3
- package/server/node_modules/undici/lib/web/fetch/util.js +6 -1
- package/server/node_modules/undici/lib/web/webidl/index.js +3 -3
- package/server/node_modules/undici/lib/web/websocket/connection.js +1 -1
- package/server/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/server/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/server/node_modules/undici/package.json +3 -3
- package/server/node_modules/undici/types/client.d.ts +10 -0
- package/server/node_modules/undici/types/interceptors.d.ts +2 -0
- package/server/node_modules/undici/types/mock-agent.d.ts +11 -10
- package/server/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -0
- package/server/node_modules/undici-types/client.d.ts +8 -3
- package/server/node_modules/undici-types/connector.d.ts +1 -0
- package/server/node_modules/undici-types/cookies.d.ts +1 -1
- package/server/node_modules/undici-types/dispatcher.d.ts +3 -3
- package/server/node_modules/undici-types/errors.d.ts +10 -0
- package/server/node_modules/undici-types/fetch.d.ts +5 -1
- package/server/node_modules/undici-types/handlers.d.ts +2 -0
- package/server/node_modules/undici-types/interceptors.d.ts +1 -1
- package/server/node_modules/undici-types/mock-interceptor.d.ts +5 -1
- package/server/node_modules/undici-types/package.json +1 -1
- package/server/node_modules/undici-types/proxy-agent.d.ts +7 -0
- package/server/{orphan-proposed-reconciler-CnP0K2v3.js → orphan-proposed-reconciler--V8GIzmY.js} +2 -2
- package/server/{orphan-proposed-reconciler-nFUlquZt.js → orphan-proposed-reconciler-BSsKWmsB.js} +20 -20
- package/server/package-lock.json +18 -18
- package/server/package.json +1 -1
- package/server/{pan-dir-B4NfzOf3.js → pan-dir-COaYhZel.js} +4 -4
- package/server/{parked-residue-8WbU0y1z.js → parked-residue-Dvr4W9P6.js} +31 -31
- package/server/{paths-rETQhTF2.js → paths-Cm1Q7Old.js} +2 -2
- package/server/{pipeline-agent-reader-CeWhQzXC.js → pipeline-agent-reader-DCCwbUj8.js} +3 -3
- package/server/{pipeline-membership-gather-C9E22B2W.js → pipeline-membership-gather-DGoDOfKO.js} +1 -1
- package/server/{pipeline-membership-gather-Ba0wJNCR.js → pipeline-membership-gather-UN7kHpCD.js} +9 -9
- package/server/{pipeline-notifier-p190L97e.js → pipeline-notifier-DfH2i_zP.js} +2 -2
- package/server/{pipeline-notifier-B5DPXvnr.js → pipeline-notifier-DsCfxoSU.js} +1 -1
- package/server/{post-merge-lifecycle-worker-OQoK8Ckg.js → post-merge-lifecycle-worker-V51p8tSm.js} +2 -2
- package/server/{post-merge-state-DFaf7OI1.js → post-merge-state-Cym5NVlB.js} +4 -4
- package/server/{prd-locations-F2oLSAhy.js → prd-locations-CPuMD55x.js} +3 -3
- package/server/{project-pipelines-CUsa6U59.js → project-pipelines-DdDKdXrG.js} +2 -2
- package/server/{project-repos-BVdi9-ch.js → project-repos-CNrLxJDg.js} +1 -1
- package/server/{project-repos-CsfvLtmr.js → project-repos-DqAT7YV6.js} +2 -2
- package/server/{project-resource-refresh-queue-D2110Guc.js → project-resource-refresh-queue-C-umDazS.js} +1 -1
- package/server/{project-resource-refresh-queue-BehrH4Ai.js → project-resource-refresh-queue-Dh8k2SB7.js} +14 -14
- package/server/{projects-BMuEf14J.js → projects-Crur9uCa.js} +1 -1
- package/server/{prompts-CKpDt8Jn.js → prompts-CvtVJUpG.js} +2 -2
- package/server/{providers-CxPKmyif.js → providers-1BlEh5x1.js} +7 -7
- package/server/{providers-Buv2wmFU.js → providers-Bun8zer5.js} +1 -1
- package/server/public/assets/{chunk-BO2N2NFS-DZOQVqV1.js → chunk-BO2N2NFS-DzUNVdeo.js} +4 -4
- package/server/public/assets/{diagram-OG6HWLK6-oKeXcbO1.js → diagram-OG6HWLK6-D5iThVwA.js} +1 -1
- package/server/public/assets/{dist-2qPmeRzT.js → dist-BLq-IR2D.js} +3 -3
- package/server/public/assets/{dist-ClBlE-Nm.js → dist-RyrOs5EF.js} +1 -1
- package/server/public/assets/{ganttDiagram-6RSMTGT7-BwdG9fQv.js → ganttDiagram-6RSMTGT7-n8bUPXAS.js} +1 -1
- package/server/public/assets/{highlighted-body-OFNGDK62-BzGNdskQ.js → highlighted-body-OFNGDK62-1npo3yiG.js} +1 -1
- package/server/public/assets/{index-Cg6tdZoY.js → index-BvN8bWpz.js} +7 -7
- package/server/public/assets/{index-CdPveU3M.css → index-DgoS288w.css} +1 -1
- package/server/public/assets/{linear-DpEt1TJb.js → linear-Dd96gky1.js} +1 -1
- package/server/public/assets/mermaid-GHXKKRXX-fP93Za-W.js +1 -0
- package/server/public/assets/{pieDiagram-4H26LBE5-9BpM4oRJ.js → pieDiagram-4H26LBE5-CynZvpYP.js} +1 -1
- package/server/public/assets/{prod-CzJiNNEG.js → prod-DBuCX9g-.js} +4 -4
- package/server/public/assets/{quadrantDiagram-W4KKPZXB-BXWVAoZx.js → quadrantDiagram-W4KKPZXB-BNlEKLKN.js} +1 -1
- package/server/public/assets/{sankeyDiagram-5OEKKPKP-5oxodGEw.js → sankeyDiagram-5OEKKPKP-Cq0AMnkD.js} +1 -1
- package/server/public/assets/{xychartDiagram-2RQKCTM6-BChDrHxZ.js → xychartDiagram-2RQKCTM6-D7GXcBy2.js} +1 -1
- package/server/public/index.html +2 -2
- package/server/pull-requests-DV_rJ-1u.js +2 -0
- package/server/{pull-requests-T0OV0Vn4.js → pull-requests-DrhWU9MW.js} +3 -3
- package/server/{rally-CUqj2oIN.js → rally-D5QkIZeb.js} +3 -3
- package/server/rally-DlXjOIAG.js +3 -0
- package/server/{rally-api-BoucQG1u.js → rally-api-BdNfpNGk.js} +1 -1
- package/server/{rally-api-BFPb2oSq.js → rally-api-CNlcoTFM.js} +2 -2
- package/server/{rally-client-CsqLjLLa.js → rally-client-BCU7mVWE.js} +1 -1
- package/server/{rally-client-16iObny7.js → rally-client-C3eB9TM-.js} +4 -4
- package/server/{rebuild-stack-BcBVFJp3.js → rebuild-stack-BupKggo5.js} +2 -2
- package/server/{rebuild-stack-CyXMrj6K.js → rebuild-stack-CNknXJHL.js} +5 -5
- package/server/{reconciler-caYiRnPy.js → reconciler-ComAOr_F.js} +6 -6
- package/server/{reconstruct-cache-3JzPOune.js → reconstruct-cache-DbjgwKRi.js} +6 -6
- package/server/{record-DYOg97Iv.js → record-C4JJCL2f.js} +1 -1
- package/server/{record-update-CDPEX7BH.js → record-update-CWwZsp9Y.js} +1 -1
- package/server/{record-update-BPqpBu3O.js → record-update-Cl56NqoQ.js} +4 -4
- package/server/{recovery-trip-CpfW6LCJ.js → recovery-trip-DA7tCXbp.js} +3 -3
- package/server/{recovery-trip-xqKC07Gy.js → recovery-trip-DFtSA8h5.js} +1 -1
- package/server/{release-engine-C_OOhCaK.js → release-engine-Dk99C48O.js} +5 -5
- package/server/{release-set-DOIDz2vw.js → release-set-x8KH3nrE.js} +3 -3
- package/server/{remote-BTh-sjpX.js → remote-BMZmJC5E.js} +3 -3
- package/server/{remote-xY0B43Ho.js → remote-DyZIg94K.js} +3 -3
- package/server/{remote-agents-DbbN7vSm.js → remote-agents-Blb0vO_M.js} +6 -6
- package/server/{remote-agents-MuXx2gWm.js → remote-agents-MbWzm5Fh.js} +1 -1
- package/server/{remote-completion-LcWCpAm2.js → remote-completion-Bcd13o-J.js} +12 -12
- package/server/{resolver-D4nsxfGo.js → resolver-CZVWKCx0.js} +7 -7
- package/server/{resolver-C2QKOf09.js → resolver-tJeEkPK5.js} +2 -2
- package/server/{resume-ByUrJUNX.js → resume-DmF2andq.js} +1 -1
- package/server/{review-agent-BRBTm1qE.js → review-agent-CmJeQc0K.js} +29 -29
- package/server/{review-agent-Caodi0PX.js → review-agent-DM9S22BL.js} +2 -2
- package/server/{review-artifacts-DgaDlbO4.js → review-artifacts-DCiaejJK.js} +6 -6
- package/server/{review-convoy-liveness-BBvyuRLC.js → review-convoy-liveness-C9F1Q1LN.js} +7 -7
- package/server/{review-run-recovery-THHMKlXJ.js → review-run-recovery-C5TEICtx.js} +2 -2
- package/server/{review-run-recovery-DCzWMMvE.js → review-run-recovery-CRGBh7xs.js} +1 -1
- package/server/{review-status-DpniqzPT.js → review-status-C3PJkfjv.js} +26 -26
- package/server/{review-status-Bge_3XTR.js → review-status-CDs0jQV6.js} +1 -1
- package/server/{review-status-emit-D7sM720S.js → review-status-emit-De6PF3ZH.js} +3 -3
- package/server/{review-status-enrichment-PDI4-faj.js → review-status-enrichment-CclcG8jk.js} +3 -3
- package/server/{review-status-sync-CvpHWyvR.js → review-status-sync-B3GKewT_.js} +1 -1
- package/server/{review-status-sync-C6ZKTI8f.js → review-status-sync-wvgdR1yZ.js} +2 -2
- package/server/{review-verdict-feedback-B2ojHFH5.js → review-verdict-feedback-20s9pG0w.js} +7 -7
- package/server/{review-verdict-feedback-tyMoLT2L.js → review-verdict-feedback-DkMx_cKj.js} +1 -1
- package/server/{review-verdict-writer-Cy_1pnIj.js → review-verdict-writer-BcG5RBWF.js} +6 -6
- package/server/{review-verdict-writer-DjrJ64eS.js → review-verdict-writer-CaJPCD-q.js} +1 -1
- package/server/{rollup-DU3xBQu2.js → rollup-C-GXHbTG.js} +7 -7
- package/server/{rollup-Cp0KEoOu.js → rollup-DR250WyW.js} +1 -1
- package/server/{scanner-BFKG3Gxv.js → scanner-BEAzmMNs.js} +18 -11
- package/server/{search-DhtKwbBC.js → search-BN0MYpZW.js} +2 -2
- package/server/{sequence-io-C-Q19Jez.js → sequence-io-BmVO0K-_.js} +4 -4
- package/server/{sequencer-agent-eN2P2lDz.js → sequencer-agent-CuA9PA_R.js} +6 -6
- package/server/server.js +200 -194
- package/server/{service-CThO0Sar.js → service-D1SZCxH8.js} +56 -56
- package/server/{session-fork-ZYTHtpBh.js → session-fork--SMYFKVu.js} +2 -2
- package/server/{settings-nAT-eK56.js → settings-CETdzCl6.js} +3 -3
- package/server/{settings-CTywpFw5.js → settings-CFi7CdJo.js} +2 -2
- package/server/settings-EGNbGKpP.js +2 -0
- package/server/{shadow-engineering-BHZKPJhq.js → shadow-engineering-CNTXaC9O.js} +2 -2
- package/server/{shadow-state-CZ_LnPsi.js → shadow-state-6jSyeXQ7.js} +1 -1
- package/server/{shadow-state-BTLi4Axs.js → shadow-state-CtYJGNXt.js} +2 -2
- package/server/{shadow-utils-CPLlPHdn.js → shadow-utils-Cq5eMfwI.js} +2 -2
- package/server/{ship-record-BaBla0l_.js → ship-record-STA0P11l.js} +5 -5
- package/server/{ship-record-BlvX8-xv.js → ship-record-neN0oUI9.js} +1 -1
- package/server/{ship-status-rQbPQBsF.js → ship-status-DzDpufmj.js} +2 -2
- package/server/{smart-compaction-CUXn8mfX.js → smart-compaction-CdtKIcDk.js} +1 -1
- package/server/{smart-compaction-D1CNGdZx.js → smart-compaction-tndAhwoc.js} +6 -6
- package/server/{spawn-planning-session-DfEWyrVV.js → spawn-planning-session-1XLgDLjR.js} +2 -2
- package/server/{spawn-planning-session-DCmO6COk.js → spawn-planning-session-CAncCBLX.js} +16 -16
- package/server/{specialist-context-C1-CfYQb.js → specialist-context-B054OP_a.js} +5 -5
- package/server/{specialist-handoff-logger-BDKoz5Z9.js → specialist-handoff-logger-B7jzypoX.js} +2 -2
- package/server/{specialist-logs-BJQFkpdG.js → specialist-logs-DVhOLpwy.js} +3 -3
- package/server/{specialists-CYt1U3Zm.js → specialists-8Pc--yZI.js} +2 -2
- package/server/{specialists-Dx0zRTxX.js → specialists-BVBIMc4L.js} +1 -1
- package/server/{specialists-DhS79T9v.js → specialists-CC_Mnc47.js} +107 -107
- package/server/{specialists-D6MUU31Q.js → specialists-ChvCD2a-.js} +19 -19
- package/server/{specialists-registry-Bng0OFGH.js → specialists-registry-Cim1fPcM.js} +2 -2
- package/server/{specialists-registry-BRLCi61y.js → specialists-registry-CoPNlhud.js} +1 -1
- package/server/specs-Dvq4sOy6.js +3 -0
- package/server/{stack-health-Bz711z1Y.js → stack-health-CvdnSVBV.js} +1 -1
- package/server/{stack-health-BKfNaqMm.js → stack-health-DPXaoAus.js} +3 -3
- package/server/{stale-task-claims-DMRLb5R2.js → stale-task-claims-UoNLemTn.js} +5 -5
- package/server/{stall-sweeper-CBWqSWV2.js → stall-sweeper-C9S8FYKz.js} +7 -7
- package/server/{state-home-DhsMqg8W.js → state-home-BhI8O5lU.js} +2 -2
- package/server/{state-migrate-C2Ouyd6e.js → state-migrate-DtFHcOVZ.js} +6 -6
- package/server/{state-mirror-BPXciz84.js → state-mirror-CpuHFxHb.js} +3 -3
- package/server/{stuck-remediation-kta3KN7c.js → stuck-remediation-B4nKm7B2.js} +13 -13
- package/server/{stuck-remediation-DALieAkx.js → stuck-remediation-hSOOYB9B.js} +1 -1
- package/server/{substrate-bug-weights-service-D_ICP7TI.js → substrate-bug-weights-service-B9f0063E.js} +3 -3
- package/server/{summary-fork-DhhaFhxZ.js → summary-fork-CUyEqFyc.js} +14 -15
- package/server/{summary-fork-CojrFKb6.js → summary-fork-DZcsOvDD.js} +2 -2
- package/server/{supervisor-DqH-laVL.js → supervisor-CGtOs9Em.js} +4 -4
- package/server/supervisor-DoJpD33i.js +2 -0
- package/server/{swarm-readiness-LF8ZF_hc.js → swarm-readiness-0N2p9d2C.js} +3 -3
- package/server/{synthesis-verdict-DSoOFUIV.js → synthesis-verdict-CJdseCuz.js} +1 -1
- package/server/{synthesis-verdict-CGFF8uQI.js → synthesis-verdict-CQdLbK1-.js} +2 -2
- package/server/{system-prerequisites-Lsx0jUUV.js → system-prerequisites-DkDOEjQP.js} +2 -2
- package/server/{teardown-workspace-DMwomEG1.js → teardown-workspace-BxFMcWu7.js} +14 -14
- package/server/{test-agent-queue-Cu0D6BYe.js → test-agent-queue-Dxeae55k.js} +6 -6
- package/server/{test-verdict-9mvl7pQn.js → test-verdict-CJ-to_Hc.js} +1 -1
- package/server/{test-verdict-oNSv1rVr.js → test-verdict-hW5kILg7.js} +2 -2
- package/server/{tldr-daemon-CRSAkhBx.js → tldr-daemon-DKCumqHU.js} +1 -1
- package/server/{tldr-daemon-McqCk2X7.js → tldr-daemon-caxXegkF.js} +2 -2
- package/server/{tmux-CYucGrTl.js → tmux-C-hxv71f.js} +2 -2
- package/server/{tmux-wnT_hg-s.js → tmux-CvAEO9yo.js} +2 -2
- package/server/{tracker-config-tfAOWgng.js → tracker-config-BjqwtkcT.js} +2 -2
- package/server/{tracker-utils-Dbg_pVZg.js → tracker-utils-0cDe6yil.js} +2 -2
- package/server/{tunnel-B1MNIgkL.js → tunnel-BEM7-jgE.js} +1 -1
- package/server/{tunnel-skW68j9B.js → tunnel-SgALz_Pi.js} +2 -2
- package/server/{uat-failure-feedback-ly8ZwtfC.js → uat-failure-feedback-BQzpUFQ6.js} +5 -5
- package/server/{uat-promote-verification-BBaMwfdc.js → uat-promote-verification-BUltWC-b.js} +5 -5
- package/server/{uat-train-D7Ran2FB.js → uat-train-B71QG16n.js} +1 -1
- package/server/{uat-train-BBEiYSep.js → uat-train-BLJ0AAIc.js} +21 -21
- package/server/{validate-BYcBcBwg.js → validate-DqEp2Yb9.js} +3 -3
- package/server/{validation-BfG2jW5C.js → validation-DHEsL3RP.js} +3 -3
- package/server/{validation-nSrYiYvA.js → validation-k4EpMHm0.js} +1 -1
- package/server/{verification-runner-BEq5ZF-h.js → verification-runner-BC_zNOq5.js} +15 -15
- package/server/{verification-runner-CFjAuv9u.js → verification-runner-Bbc-8BbR.js} +1 -1
- package/server/{work-agent-prompt-BnhKNAg7.js → work-agent-prompt-CQWlmw_y.js} +1 -1
- package/server/{work-agent-prompt-CaD2ue8m.js → work-agent-prompt-DM3uza0_.js} +10 -10
- package/server/{work-agent-start-D8NEN5KD.js → work-agent-start-BColr1oI.js} +1 -1
- package/server/{work-agent-start-0nJ-6UeA.js → work-agent-start-cKf7rly8.js} +2 -2
- package/server/workflows-CLrEiTds.js +2 -0
- package/server/{workflows-C7mxM1qc.js → workflows-DrC85n8j.js} +26 -26
- package/server/{workspace-BAhMgMaO.js → workspace-ChRFy_F9.js} +3 -3
- package/server/{workspace-Dbqv9ehn.js → workspace-G3Cus8e9.js} +1 -1
- package/server/{workspace-anchor-drift-Bpa3xoni.js → workspace-anchor-drift-DBbyK_Mf.js} +1 -1
- package/server/{workspace-anchor-drift-B_3kyyxJ.js → workspace-anchor-drift-z7TjOORC.js} +4 -4
- package/server/{workspace-manager-CM8RCrSc.js → workspace-manager-Db3pCmr7.js} +14 -14
- package/server/{workspace-manager-BrbX90Rm.js → workspace-manager-gz9Amovn.js} +1 -1
- package/server/{workspace-metadata-Cu6yfxBS.js → workspace-metadata-C5Ie2FMZ.js} +2 -2
- package/server/{workspace-metadata-BEOwJSdK.js → workspace-metadata-Do-L6GFP.js} +1 -1
- package/server/{workspaces-C7LAuZfe.js → workspaces-D0MWw7Mx.js} +108 -108
- package/server/archive-planning-D3gw32U9.js +0 -2
- package/server/build-info-Dx2qrVhb.js +0 -2
- package/server/cli-BflmtEFM.js +0 -2
- package/server/dead-end-trip-DUbiRMtT.js +0 -2
- package/server/deploy-queue--smqHLhe.js +0 -2
- package/server/forge-4VVCRcF7.js +0 -2
- package/server/inspect-agent-Dhp3hCGp.js +0 -2
- package/server/merge-ops-Cf02szJ5.js +0 -2
- package/server/merge-rebase-Bj7eJAG4.js +0 -2
- package/server/public/assets/mermaid-GHXKKRXX-6KBD_3T_.js +0 -1
- package/server/pull-requests-CmlandI7.js +0 -2
- package/server/rally-DYIn9R2U.js +0 -3
- package/server/settings-ByDRfuuE.js +0 -2
- package/server/specs-oRGyfz6C.js +0 -3
- package/server/supervisor-DSSWo4M2.js +0 -2
- package/server/workflows-BtHRlFIm.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-RyrOs5EF.js","assets/chunk-BO2N2NFS-DzUNVdeo.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-DzyYoeor.js","assets/html-void-elements-DIyBxxO2.js","assets/react-dom-DnbdNgHn.js","assets/jsx-runtime-CEixWuwE.js","assets/styles-DkK0ymA2.css","assets/angular-html-YFZ-qEo2.js","assets/html-CUX3CWXm.js","assets/css-U8jIwd7B.js","assets/javascript-CMCEf6AT.js","assets/angular-ts-B54r7V_n.js","assets/scss-B9l_DMkG.js","assets/apl-CbIltIfi.js","assets/json-C8nZKV3Z.js","assets/xml-DuJ43izn.js","assets/java-DwXGFxfd.js","assets/astro-kQmek0SS.js","assets/postcss-BnjjGg21.js","assets/tsx-BNeRNgay.js","assets/typescript-IaFVOaio.js","assets/blade-_Uc4zzSO.js","assets/html-derivative-UiwgJSUF.js","assets/sql-BoZjwy0s.js","assets/bsl-tWlfQbW2.js","assets/sdbl-Djwdbzuv.js","assets/c-W33irP5E.js","assets/cairo-Cv4i2rVj.js","assets/python-D2TsaySt.js","assets/cobol-Bc0FYmxA.js","assets/coffee-BBgjALtO.js","assets/cpp-_HuA19qD.js","assets/glsl-DB7rO3Hv.js","assets/regexp-Cg9yhs1s.js","assets/crystal-BDsQiQxo.js","assets/shellscript-CtJe2GoF.js","assets/edge-44NINB_l.js","assets/elixir-BvFudoM5.js","assets/elm-Bcvevfeb.js","assets/erb-BOi8y-XV.js","assets/ruby-DXW7M0u6.js","assets/graphql-DtareNVU.js","assets/jsx-7jEc9fS2.js","assets/haml-B_eT_igf.js","assets/lua-DUN8k3vI.js","assets/yaml-C_3EjdK_.js","assets/erlang-BX7w0Ok9.js","assets/markdown-hvmaQbLY.js","assets/fortran-fixed-form-Ctf_ysKA.js","assets/fortran-free-form-BtoOII28.js","assets/fsharp-AvjR9D4f.js","assets/gdresource-Dgj9cWOp.js","assets/gdscript-Cd6RKS1c.js","assets/gdshader-CwGO0jWu.js","assets/git-commit-A3P_opqa.js","assets/diff-B0RdNoYb.js","assets/git-rebase-BCNwX-BV.js","assets/glimmer-js-JE9OX7en.js","assets/glimmer-ts-BlJ_q6LG.js","assets/hack-DxMpTO_4.js","assets/handlebars-CSFAnckr.js","assets/http-ggBV9BA7.js","assets/hurl-Bo3fRJZD.js","assets/csv-7edT5GDb.js","assets/hxml-Y8hs-mDA.js","assets/haxe-Bn69brdB.js","assets/jinja-BNgjwVV6.js","assets/jison-DJFHLmTv.js","assets/julia-CHAVw5nA.js","assets/r-CFG-KSi0.js","assets/just-DA7G4JJf.js","assets/perl-DJbpw6Wl.js","assets/latex-BBzosFBn.js","assets/tex-Djb_8T3k.js","assets/liquid-C5QiuOs4.js","assets/marko-DyeIi_wM.js","assets/less-10_el3T9.js","assets/mdc-B7Bu1-dB.js","assets/nextflow-1Nm7UTNp.js","assets/nextflow-groovy-Dlq_Tqm0.js","assets/nginx-BGk8nZGn.js","assets/nim-Bpgzjh-p.js","assets/php-DQ9BfS13.js","assets/pug-QFMWku9O.js","assets/qml-DbNxxmb8.js","assets/razor-Bm_20ylP.js","assets/csharp-CcF8oQ2Z.js","assets/rst-DiKxgtQw.js","assets/cmake-DbRlIs2B.js","assets/sas-CHMyqMwI.js","assets/shaderlab-BfgwlY9N.js","assets/hlsl-D98WkMKb.js","assets/shellsession-XD3n0AXo.js","assets/soy-B4SQpYLQ.js","assets/sparql-C3_E314U.js","assets/turtle-BQazhbah.js","assets/stata-Dco15DDQ.js","assets/surrealql-DyNEi36w.js","assets/svelte-CQE0K2YM.js","assets/templ-DBGKqxq2.js","assets/go-CfRdqiLh.js","assets/ts-tags-BMQuJI7H.js","assets/twig-CO1mu8ZY.js","assets/vue-BRWc8zFO.js","assets/vue-html-DeoYv0pp.js","assets/vue-vine-DCaC4v_2.js","assets/stylus-DbiVYBZ3.js","assets/xsl-gLKQE284.js","assets/prod-DBuCX9g-.js","assets/chunk-K2UTITRG-CopEAH22.js","assets/chunk-SRAX5OIU-BDhmsJ9Z.js","assets/chunk-ZUYEQ4TG-B82Qm37l.js","assets/chunk-6U3AYISY-WI_aJXfI.js","assets/chunk-Z3N5DIM6-eUM55sD5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,n as t,o as n,r,t as i}from"./chunk-jRWAZmH_.js";import{n as a,t as o}from"./jsx-runtime-CEixWuwE.js";import{t as s}from"./react-dom-DnbdNgHn.js";import{a as c,c as l,d as u,l as d,n as f,o as p,p as m,r as h,s as g,t as _}from"./html-void-elements-DIyBxxO2.js";import{t as v}from"./preload-helper-DzyYoeor.js";import{C as y,E as b,S as x,T as S,a as C,b as w,c as T,d as E,g as D,h as O,i as k,l as A,m as j,n as M,o as N,r as P,s as F,t as I,u as L,v as ee,w as R,y as te}from"./src-CdPLAdYJ.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 ne=i((e=>{var t=s();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),re=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ie=new class extends re{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},ae={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},oe=new class{#e=ae;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function se(e){setTimeout(e,0)}var ce=typeof window>`u`||`Deno`in globalThis;function le(){}function ue(e,t){return typeof e==`function`?e(t):e}function de(e){return typeof e==`number`&&e>=0&&e!==1/0}function fe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function pe(e,t){return typeof e==`function`?e(t):e}function me(e,t){return typeof e==`function`?e(t):e}function he(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==_e(o,t.options))return!1}else if(!ye(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ge(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ve(t.options.mutationKey)!==ve(a))return!1}else if(!ye(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function _e(e,t){return(t?.queryKeyHashFn||ve)(e)}function ve(e){return JSON.stringify(e,(e,t)=>we(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ye(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ye(e[n],t[n])):!1}var be=Object.prototype.hasOwnProperty;function xe(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Ce(e)&&Ce(t);if(!r&&!(we(e)&&we(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:be.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=xe(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Se(e,t){if(!t||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 Ce(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function we(e){if(!Te(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Te(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Te(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ee(e){return new Promise(t=>{oe.setTimeout(t,e)})}function De(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:xe(e,t)}function Oe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function ke(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ae=Symbol();function je(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ae?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Me(e,t){return typeof e==`function`?e(...t):!!e}function Ne(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Pe=(()=>{let e=()=>ce;return{isServer(){return e()},setIsServer(t){e=t}}})();function Fe(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Ie=se;function Le(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Ie,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Re=Le(),ze=new class extends re{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Be(e){return Math.min(1e3*2**e,3e4)}function Ve(e){return(e??`online`)===`online`?ze.isOnline():!0}var He=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ue(e){let t=!1,n=0,r,i=Fe(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new He(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>ie.isFocused()&&(e.networkMode===`always`||ze.isOnline())&&e.canRun(),u=()=>Ve(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Pe.isServer()?0:3),o=e.retryDelay??Be,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),Ee(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var We=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),de(this.gcTime)&&(this.#e=oe.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Pe.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(oe.clearTimeout(this.#e),this.#e=void 0)}};function Ge(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Ne(e,()=>t.signal,()=>n=!0)},u=je(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?ke:Oe;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?qe:Ke,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ke(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Ke(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function qe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Je(e,t){return t?Ke(e,t)!=null:!1}function Ye(e,t){return!t||!e.getPreviousPageParam?!1:qe(e,t)!=null}var Xe=class extends We{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=$e(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=$e(this.options);e.data!==void 0&&(this.setState(Qe(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=De(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(le).catch(le):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>me(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ae||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>pe(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!fe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=je(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Ge(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=Ue({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof He&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof He){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Ze(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Qe(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),Re.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Ze(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Qe(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function $e(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var et=class extends re{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Fe(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),nt(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rt(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rt(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof me(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Se(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&it(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||me(this.options.enabled,this.#t)!==me(t.enabled,this.#t)||pe(this.options.staleTime,this.#t)!==pe(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||me(this.options.enabled,this.#t)!==me(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ot(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(le)),t}#g(){this.#b();let e=pe(this.options.staleTime,this.#t);if(Pe.isServer()||this.#r.isStale||!de(e))return;let t=fe(this.#r.dataUpdatedAt,e)+1;this.#d=oe.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Pe.isServer()||me(this.options.enabled,this.#t)===!1||!de(this.#p)||this.#p===0)&&(this.#f=oe.setInterval(()=>{(this.options.refetchIntervalInBackground||ie.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(oe.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(oe.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&nt(e,t),o=i&&it(e,n,t,r);(a||o)&&(l={...l,...Ze(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=De(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=De(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:at(e,t),refetch:this.refetch,promise:this.#o,isEnabled:me(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Fe())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Se(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){Re.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function tt(e,t){return me(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&me(t.retryOnMount,e)===!1)}function nt(e,t){return tt(e,t)||e.state.data!==void 0&&rt(e,t,t.refetchOnMount)}function rt(e,t,n){if(me(t.enabled,e)!==!1&&pe(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&at(e,t)}return!1}function it(e,t,n,r){return(e!==t||me(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&at(e,n)}function at(e,t){return me(t.enabled,e)!==!1&&e.isStaleByTime(pe(t.staleTime,e))}function ot(e,t){return!Se(e.getCurrentResult(),t)}var st=class extends et{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Je(t,n.data),hasPreviousPage:Ye(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},ct=class extends We{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||lt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ue({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Re.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function lt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ut=class extends re{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new ct({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=dt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=dt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=dt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=dt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Re.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ge(t,e))}findAll(e={}){return this.getAll().filter(t=>ge(e,t))}notify(e){Re.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Re.batch(()=>Promise.all(e.map(e=>e.continue().catch(le))))}};function dt(e){return e.options.scope?.id}var ft=class extends re{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Se(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ve(t.mutationKey)!==ve(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??lt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Re.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function pt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function mt(e,t,n){let r=e.slice(0);return r[t]=n,r}var ht=class extends re{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Re.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Se(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(pt(e,n).forEach(e=>{e.destroy()}),pt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=xe(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new et(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=mt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&Re.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},gt=class extends re{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??_e(r,t),a=this.get(i);return a||(a=new Xe({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Re.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>he(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>he(e,t)):t}notify(e){Re.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Re.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Re.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},_t=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new gt,this.#t=e.mutationCache||new ut,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ie.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ze.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(pe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=ue(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Re.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Re.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Re.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Re.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(le).catch(le)}invalidateQueries(e,t={}){return Re.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Re.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(le)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(le)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(pe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(le).catch(le)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(le).catch(le)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return ze.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ve(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ye(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ve(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ye(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=_e(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ae&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},z=n(a(),1),B=o(),vt=z.createContext(void 0),yt=e=>{let t=z.useContext(vt);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},bt=({client:e,children:t})=>(z.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,B.jsx)(vt.Provider,{value:e,children:t})),xt=z.createContext(!1),St=()=>z.useContext(xt);xt.Provider;function Ct(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var wt=z.createContext(Ct()),Tt=()=>z.useContext(wt),Et=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Me(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Dt=e=>{z.useEffect(()=>{e.clearReset()},[e])},Ot=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Me(n,[e.error,r])),kt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},eee=(e,t)=>e.isLoading&&e.isFetching&&!t,At=(e,t)=>e?.suspense&&t.isPending,jt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function tee({queries:e,...t},n){let r=yt(n),i=St(),a=Tt(),o=z.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{kt(e),Et(e,a,r.getQueryCache().get(e.queryHash))}),Dt(a);let[s]=z.useState(()=>new ht(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;z.useSyncExternalStore(z.useCallback(e=>d?s.subscribe(Re.batchCalls(e)):le,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),z.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>At(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&At(n,e)?jt(n,new et(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Ot({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function nee(e,t,n){let r=St(),i=Tt(),a=yt(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,kt(o),Et(o,i,s),Dt(i);let c=!a.getQueryCache().get(o.queryHash),[l]=z.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(z.useSyncExternalStore(z.useCallback(e=>{let t=d?l.subscribe(Re.batchCalls(e)):le;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),z.useEffect(()=>{l.setOptions(o)},[o,l]),At(o,u))throw jt(o,l,i);if(Ot({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Pe.isServer()&&eee(u,r)&&(c?jt(o,l,i):s?.promise)?.catch(le).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function V(e,t){return nee(e,et,t)}function ree(e,t){let n=yt(t),r=n.getQueryCache();return z.useSyncExternalStore(z.useCallback(e=>r.subscribe(Re.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function Mt(e,t){let n=yt(t),[r]=z.useState(()=>new ft(n,e));z.useEffect(()=>{r.setOptions(e)},[r,e]);let i=z.useSyncExternalStore(z.useCallback(e=>r.subscribe(Re.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=z.useCallback((e,t)=>{r.mutate(e,t).catch(le)},[r]);if(i.error&&Me(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function iee(e,t){return nee(e,st,t)}var aee=n(ne(),1),Nt=typeof window<`u`?window:void 0,Pt=typeof globalThis<`u`?globalThis:Nt;typeof self>`u`&&(Pt.self=Pt),typeof File>`u`&&(Pt.File=function(){});var Ft=Pt?.navigator,It=Pt?.document,Lt=Pt?.location,Rt=Pt?.fetch,zt=Pt!=null&&Pt.XMLHttpRequest&&`withCredentials`in new Pt.XMLHttpRequest?Pt.XMLHttpRequest:void 0,Bt=Pt?.AbortController,oee=Pt?.CompressionStream,Vt=Ft?.userAgent,Ht=Nt??{};function see(){return!(!Nt||!1===Nt.navigator.onLine)}var cee=`1.402.3`,Ut={DEBUG:!1,LIB_VERSION:cee,LIB_NAME:`web`,JS_SDK_VERSION:cee};function lee(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Wt(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){lee(a,r,i,o,s,`next`,e)}function s(e){lee(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function Gt(){return Gt=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gt.apply(null,arguments)}function uee(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Kt=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function qt(e){return typeof e==`string`||e}function Jt(e){return typeof e==`string`?e:void 0}var Yt,Xt=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.AiQueue=`ai_queue`,e.LogsQueue=`logs_queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.SessionReplayEventTriggerActivatedSession=`session_replay_event_trigger_activated_session`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e.DeviceId=`device_id`,e}({}),dee=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),fee=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`],pee=[`token`],mee=`NativeGzipValidationError`,Zt=e=>e.length>=2&&e[0]===31&&e[1]===139,hee=(e,t)=>e===dee.GZipJS||t===dee.GZipJS||t===`gzip`,gee=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,Qt=e=>{var t=Error(`Native gzip produced invalid output: `+e);throw t.name=mee,t},_ee=function(){var e=Wt((function*(e,t){18>e.size&&Qt(`too-short`);var n=new Uint8Array(yield e.slice(0,10).arrayBuffer());Zt(n)&&n[2]===8||Qt(`invalid-header`);var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Yt)return Yt;Yt=[];for(var e=0;256>e;e++){for(var t=e,n=0;8>n;n++)t=1&t?3988292384^t>>>1:t>>>1;Yt[e]=t>>>0}return Yt})(),n=4294967295,r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&Qt(`invalid-crc`);var i=t.length>>>0;r.getUint32(4,!0)!==i&&Qt(`invalid-size`)}));return function(t,n){return e.apply(this,arguments)}}();function $t(){return $t=Wt((function*(e,t,n){t===void 0&&(t=!0);try{var r=new TextEncoder().encode(e),i=new CompressionStream(`gzip`),a=i.writable.getWriter(),o=a.write(r).then((()=>a.close())).catch(function(){var e=Wt((function*(e){try{yield a.abort(e)}catch{}throw e}));return function(t){return e.apply(this,arguments)}}()),s=new Response(i.readable).blob(),c=(yield Promise.all([s,o]))[0];return yield _ee(c,r),c}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}})),$t.apply(this,arguments)}var vee=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),en=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return vee.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function tn(e,t){return e.indexOf(t)!==-1}var nn=function(e){return e.trim()},rn=function(e){return e.replace(/^\$/,``)};function an(e){var t=[];return JSON.stringify(e,(function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n}}))??`null`}var on=Object.prototype,yee=on.hasOwnProperty,sn=on.toString,cn=Array.isArray||function(e){return sn.call(e)===`[object Array]`},ln=e=>typeof e==`function`,un=e=>e===Object(e)&&!cn(e),dn=e=>{if(un(e)){for(var t in e)if(yee.call(e,t))return!1;return!0}return!1},fn=e=>e===void 0,pn=e=>sn.call(e)==`[object String]`,mn=e=>pn(e)&&e.trim().length===0,hn=e=>e===null,gn=e=>fn(e)||hn(e),_n=e=>sn.call(e)==`[object Number]`&&e==e,vn=e=>_n(e)&&e>0,yn=e=>sn.call(e)===`[object Boolean]`,bee=e=>e instanceof FormData,xee=e=>tn(fee,e),See=e=>tn(pee,e);function bn(e){return typeof e!=`object`||!e}function xn(e,t){return{}.toString.call(e)===`[object `+t+`]`}function Sn(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var Cee=[!0,`true`,1,`1`,`yes`],Cn=e=>tn(Cee,e),wee=[!1,`false`,0,`0`,`no`];function wn(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),_n(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),wn(i||n,t,n,r))}var Tee=class{constructor(e){this.tt={},this.et=e.et,this.rt=wn(e.bucketSize,0,100,e.it),this.nt=wn(e.refillRate,0,this.rt,e.it),this.st=wn(e.refillInterval,0,864e5,e.it)}ot(e,t){var n=Math.floor((t-e.lastAccess)/this.st);n>0&&(e.tokens=Math.min(e.tokens+n*this.nt,this.rt),e.lastAccess+=n*this.st)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.tt[r];return i?this.ot(i,n):this.tt[r]=i={tokens:this.rt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.et)==null||t.call(this,e)),i.tokens===0)}stop(){this.tt={}}},Tn=`Mobile`,En=`iOS`,Dn=`Android`,On=`Tablet`,Eee=Dn+` `+On,Dee=`iPad`,Oee=`Apple`,kee=Oee+` Watch`,kn=`Safari`,An=`BlackBerry`,jn=`Samsung`,Mn=jn+`Browser`,Nn=jn+` Internet`,Pn=`Chrome`,Aee=Pn+` OS`,Fn=Pn+` `+En,In=`Internet Explorer`,Ln=In+` `+Tn,Rn=`Opera`,jee=Rn+` Mini`,zn=`Edge`,Bn=`Microsoft `+zn,Vn=`Firefox`,Hn=Vn+` `+En,Un=`Nintendo`,Wn=`PlayStation`,Gn=`Xbox`,Kn=Dn+` `+Tn,qn=Tn+` `+kn,Jn=`Windows`,Yn=Jn+` Phone`,Xn=`Nokia`,Zn=`Ouya`,Qn=`Generic`,Mee=Qn+` `+Tn.toLowerCase(),$n=Qn+` `+On.toLowerCase(),er=`Konqueror`,tr=`Oculus Browser`,nr=`Vivaldi`,Nee=`Yandex`,rr=`Whale`,ir=`DuckDuckGo`,Pee=`Pale Moon`,ar=`Waterfox`,or=`Brave`,Fee=`Google Search App`,sr=`(\\d+(\\.\\d+)?)`,cr=RegExp(`Version/`+sr),Iee=new RegExp(Gn,`i`),Lee=RegExp(Wn+` \\w+`,`i`),Ree=RegExp(Un+` \\w+`,`i`),lr=RegExp(An+`|PlayBook|BB10`,`i`),zee={"NT3.51":`NT 3.11`,"NT4.0":`NT 4.0`,"5.0":`2000`,5.1:`XP`,5.2:`XP`,"6.0":`Vista`,6.1:`7`,6.2:`8`,6.3:`8.1`,6.4:`10`,"10.0":`10`},Bee=function(e,t,n,r){return t||=``,function(e){return e!=null&&e.brave?or:null}(n)||(r!=null&&r.detectGoogleSearchApp&&tn(e,`GSA/`)?Fee:tn(e,` OPR/`)&&tn(e,`Mini`)?jee:tn(e,` OPR/`)?Rn:lr.test(e)?An:tn(e,`IE`+Tn)||tn(e,`WPDesktop`)?Ln:tn(e,`OculusBrowser`)?tr:tn(e,Mn)?Nn:tn(e,zn)||tn(e,`Edg/`)?Bn:tn(e,nr+`/`)?nr:tn(e,`YaBrowser/`)?Nee:tn(e,rr+`/`)?rr:tn(e,ir+`/`)||tn(e,`Ddg/`)?ir:tn(e,`FBIOS`)?`Facebook `+Tn:tn(e,`UCWEB`)||tn(e,`UCBrowser`)?`UC Browser`:tn(e,`CriOS`)?Fn:tn(e,`CrMo`)||tn(e,Pn)?Pn:tn(e,Dn)&&tn(e,kn)?Kn:tn(e,`FxiOS`)?Hn:tn(e.toLowerCase(),er.toLowerCase())?er:tn(e,or+`/`)?or:((e,t)=>t&&tn(t,Oee)||function(e){return tn(e,kn)&&!tn(e,Pn)&&!tn(e,Dn)}(e))(e,t)?tn(e,Tn)?qn:kn:tn(e,`PaleMoon/`)?Pee:tn(e,ar+`/`)?ar:tn(e,Vn)?Vn:tn(e,`MSIE`)||tn(e,`Trident/`)?In:tn(e,`Gecko`)?Vn:``)},Vee={[Ln]:[RegExp(`rv:`+sr)],[Bn]:[RegExp(zn+`?\\/`+sr)],[Pn]:[RegExp(`(`+Pn+`|CrMo)\\/`+sr)],[Fn]:[RegExp(`CriOS\\/`+sr)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+sr)],[kn]:[cr],[qn]:[cr],[Rn]:[RegExp(`(Opera|OPR)\\/`+sr)],[Vn]:[RegExp(Vn+`\\/`+sr)],[Hn]:[RegExp(`FxiOS\\/`+sr)],[er]:[RegExp(`Konqueror[:/]?`+sr,`i`)],[An]:[RegExp(An+` `+sr),cr],[Kn]:[RegExp(`android\\s`+sr,`i`)],[Nn]:[RegExp(Mn+`\\/`+sr)],[tr]:[RegExp(`OculusBrowser\\/`+sr)],[nr]:[RegExp(nr+`\\/`+sr)],[Nee]:[RegExp(`YaBrowser\\/`+sr)],[rr]:[RegExp(rr+`\\/`+sr)],[or]:[RegExp(or+`\\/`+sr)],[ir]:[RegExp(`(DuckDuckGo|Ddg)\\/`+sr)],[Pee]:[RegExp(`PaleMoon\\/`+sr)],[ar]:[RegExp(ar+`\\/`+sr)],[Fee]:[RegExp(`GSA\\/`+sr)],[In]:[RegExp(`(rv:|MSIE )`+sr)],Mozilla:[RegExp(`rv:`+sr)]},Hee=function(e,t,n,r){var i=Vee[Bee(e,t,n,r)];if(fn(i))return null;for(var a=0;i.length>a;a++){var o=e.match(i[a]);if(o)return parseFloat(o[o.length-2])}return null},Uee=[[RegExp(Gn+`; `+Gn+` (.*?)[);]`,`i`),e=>[Gn,e&&e[1]||``]],[new RegExp(Un,`i`),[Un,``]],[new RegExp(Wn,`i`),[Wn,``]],[lr,[An,``]],[new RegExp(Jn,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Yn,``];if(new RegExp(Tn).test(t)&&!/IEMobile\b/.test(t))return[Jn+` `+Tn,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=zee[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[Jn,r]}return[Jn,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[En,[e[3],e[4],e[5]||`0`].join(`.`)]:[En,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=fn(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+Dn+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+Dn+`)`,`i`),e=>e&&e[2]?[Dn,[e[2],e[3],e[4]||`0`].join(`.`)]:[Dn,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[Aee,``]],[/Linux|debian/i,[`Linux`,``]]],Wee=function(e){return Ree.test(e)?Un:Lee.test(e)?Wn:Iee.test(e)?Gn:new RegExp(Zn,`i`).test(e)?Zn:RegExp(`(`+Yn+`|WPDesktop)`,`i`).test(e)?Yn:/iPad/.test(e)?Dee:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?kee:lr.test(e)?An:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Xn,`i`).test(e)?Xn:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(Tn).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Dn:Eee:RegExp(`(pda|`+Tn+`)`,`i`).test(e)?Mee:new RegExp(On,`i`).test(e)&&!RegExp(On+` pc`,`i`).test(e)?$n:``},Gee=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Kee(e,t){return typeof(n=e)==`string`&&Gee.test(n)?e:t();var n}function ur(e){return e&&e.split(`#`)[0]}function dr(e,t){var n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}var qee=e=>e instanceof Error,Jee={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},Yee=Jee.info;function Xee(e){if(yn(e))return{boolValue:e};if(typeof e==`number`)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if(typeof e==`string`)return{stringValue:e};if(cn(e))return{arrayValue:{values:e.map((e=>Xee(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function fr(e){var t=[];for(var n in e){var r=e[n];hn(r)||fn(r)||t.push({key:n,value:Xee(r)})}return t}function Zee(e,t){var n=Jee[e.level||`info`]||Yee,r=n.text,i=n.number,a=String(Date.now())+`000000`,o={};t.distinctId&&(o.posthogDistinctId=t.distinctId),t.sessionId&&(o.sessionId=t.sessionId),t.windowId&&(o[`window.id`]=t.windowId),gn(t.sessionStartTimestamp)||(o.sessionStartTimestamp=String(t.sessionStartTimestamp)),gn(t.lastActivityTimestamp)||(o.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(o[`url.full`]=t.currentUrl),t.screenName&&(o[`screen.name`]=t.screenName),t.appState&&(o[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(o.feature_flags=t.activeFeatureFlags);var s=Gt({},o,e.attributes||{}),c={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:i,severityText:r,body:{stringValue:e.body},attributes:fr(s)};return e.trace_id&&(c.traceId=e.trace_id),e.span_id&&(c.spanId=e.span_id),fn(e.trace_flags)||(c.flags=e.trace_flags),c}function Qee(e,t,n){return Gt({},e.resourceAttributes,{"service.name":e.serviceName||`unknown_service`},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}function $ee(e,t,n,r){return{resourceLogs:[{resource:{attributes:fr(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var ete=class{constructor(e,t,n,r,i,a,o){a===void 0&&(a=()=>Promise.resolve()),this._instance=e,this.Se=t,this.it=n,this.ut=r,this.ht=i,this.dt=a,this.ct=o,this.vt=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.xt=t.maxBufferSize,this.kt=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this.St=t.flushIntervalMs,this.Ct=t.maxBatchRecordsPerPost,this.It=t.rateCapWindowMs,this.Tt=t.maxLogsPerInterval}reset(){this.Mt(),this.vt=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Se.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.Et()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var t=this.Rt(e);if(t!==null)if(t.body){if(this.Pt()){var n={record:Zee(t,this.ut())};this.ht((()=>this.Ot(n)))}}else this.it.info(`Log was rejected in beforeSend function`)}}Rt(e){var t=this.Se.beforeSend;if(!t)return e;var n=cn(t)?t:[t],r=e;for(var i of n)try{var a=i(r);if(!a)return this.it.info(`Log was rejected in beforeSend function`),null;r=a}catch(e){return this.it.error(`Error in beforeSend function for log:`,e),null}return r}Pt(){if(this.Tt===void 0)return!0;var e=Date.now(),t=e-this.bt;return this.It>t&&t>=0||(this.bt=e,this._t=0,this.wt=!1),this.Tt>this._t?(this._t++,!0):(this.wt||=(this.it.warn(`captureLog dropping logs: exceeded `+this.Tt+` logs per `+this.It+`ms`),!0),!1)}flush(){var e=this;return Wt((function*(){if(!e._instance.isDisabled)return e.vt||=e.Ft().finally((()=>{e.vt=null})),e.vt}))()}Ft(){var e=this;return Wt((function*(){e.Mt();var t=e._instance.getPersistedProperty(Xt.LogsQueue)??[];if(t.length!==0)for(var n=t.length,r=0;t.length>0&&n>r;){e.ft=0;var i=Math.min(t.length,e.Ct),a=t.slice(0,i),o=$ee(a.map((e=>e.record)),e.Lt(),e.ct??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance.At(o);if(s.kind===`too-large`&&a.length>1)e.Ct=Math.max(1,Math.floor(a.length/2)),e.it.warn(`Received 413 when sending logs batch of size `+a.length+`, reducing batch size to `+e.Ct);else if(s.kind===`retry-later`||(s.kind===`too-large`?e.it.warn(`Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further.`):s.kind===`ok`&&e.Se.maxBatchRecordsPerPost>e.Ct&&(e.Ct=Math.min(e.Se.maxBatchRecordsPerPost,e.Ct+1)),yield e.$t(a.length),t=e._instance.getPersistedProperty(Xt.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}}))()}$t(e){var t=this;return Wt((function*(){var n=Math.max(0,e-t.ft),r=t._instance.getPersistedProperty(Xt.LogsQueue)??[];t._instance.setPersistedProperty(Xt.LogsQueue,r.slice(n)),yield t.dt()}))()}Lt(){return Qee(this.Se,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ot(e){if(!this._instance.optedOut){var t=this._instance.getPersistedProperty(Xt.LogsQueue)??[];this.kt>t.length||(t.shift(),this.ft++,this.it.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(Xt.LogsQueue,t),this.xt>t.length?this.Nt():this.Et()}}Nt(e){e===void 0&&(e=this.St),this.Dt||=dr((()=>{this.Dt=void 0,this.Et()}),e)}qt(){var e=Math.min(Math.max(0,this.yt-1),6);return this.St*2**e}jt(){var e=this._instance.getPersistedProperty(Xt.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Wt((function*(){t.Mt();var n=t.flush().catch((()=>{}));e===void 0?yield n:yield Promise.race([n,new Promise((t=>dr(t,e)))])}))()}flushWithTimeout(e){var t=this;return Wt((function*(){var n=!1,r=t.flush(),i=new Promise((t=>dr((()=>{n=!0,t()}),e)));try{yield Promise.race([r,i])}finally{n&&r.catch((()=>{}))}}))()}Et(){this.flush().then((()=>{this.yt=0}),(e=>{this.yt++,this.it.error(`PostHog logs flush failed:`,e)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.Nt(this.qt())}))}Mt(){this.Dt&&=(clearTimeout(this.Dt),void 0)}},pr=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function tte(e){return String(e)+`000000`}function nte(e,t,n,r){var i=``;return r&&(i=Object.keys(r).sort().map((e=>JSON.stringify(e)+`:`+JSON.stringify(r[e]))).join(`,`)),e+`\0`+t+`\0`+(n??``)+`\0`+i}var rte=class{constructor(e,t,n){this._instance=e,this.Se=t,this.it=n,this.Ht=new Map,this.vt=null,this.Bt=!1,this.Ut=new Map,this.zt=new Set,this.Vt=0}count(e,t,n){t===void 0&&(t=1),this.Wt({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this.Wt({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this.Wt({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this,t=this.vt,n=function(){var n=Wt((function*(){t&&(yield t.catch((()=>{}))),yield e.Zt()}));return function(){return n.apply(this,arguments)}}()().finally((()=>{this.vt===n&&(this.vt=null)}));return this.vt=n,n}drainWindow(){if(this.Ht.size===0)return null;var e=this.Ht;return this.Ht=new Map,this.Bt=!1,this.Ut=new Map,this.zt=new Set,this.Gt(e)}reset(){this.Vt++,this.Mt(),this.Ht=new Map,this.vt=null,this.Bt=!1,this.Ut=new Map,this.zt=new Set}Wt(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this.Rt(e);if(t!==null)if(t.name&&typeof t.name==`string`)if(typeof t.value==`number`&&Number.isFinite(t.value))if(t.type===`count`&&0>t.value)this.it.warn(`Dropping count '`+t.name+`': counters are monotonic, value must be >= 0`);else{var n,r;try{n=t.attributes?Gt({},t.attributes):void 0,r=nte(t.type,t.name,t.unit,n)}catch(e){this.it.warn(`Dropping metric '`+t.name+`': attributes could not be serialized`,e);return}var i=this.Ht.get(r);if(!i){if(!this.Qt())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.Ht.set(r,i)}var a=this.Ut.get(t.name);a===void 0?this.Ut.set(t.name,t.type):a===t.type||this.zt.has(t.name)||(this.zt.add(t.name),this.it.warn(`Metric name '`+t.name+`' is already used as a `+a+`; recording it as a `+t.type+` too will blend both series in charts. Use a distinct name.`)),this.Jt(i,t.value),this.Nt()}else this.it.warn(`Dropping metric '`+t.name+`': value must be a finite number`);else this.it.warn(`Dropping metric with empty name`)}}Qt(){return this.Se.maxSeriesPerFlush>this.Ht.size||(this.Bt||(this.Bt=!0,this.it.warn(`Metric series cap reached (`+this.Se.maxSeriesPerFlush+` per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Jt(e,t){switch(e.type){case`count`:e.total=(e.total??0)+t;break;case`gauge`:e.last=t;break;case`histogram`:e.hist||={count:0,sum:0,min:t,max:t,bucketCounts:Array(pr.length+1).fill(0)};var n=e.hist;n.count+=1,n.sum+=t,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.bucketCounts[function(e,t){for(var n=0;t.length>n;n++)if(t[n]>=e)return n;return t.length}(t,pr)]+=1}}Rt(e){var t=this.Se.beforeSend;if(!t)return e;var n=cn(t)?t:[t],r=e;for(var i of n)try{var a=i(r);if(!a)return this.it.info(`Metric was rejected in beforeSend function`),null;r=a}catch(e){return this.it.error(`Error in beforeSend function for metric:`,e),null}return r}Nt(){this.Dt||=dr((()=>{this.Dt=void 0,this.flush().catch((e=>{this.it.error(`Metrics flush failed:`,e)}))}),this.Se.flushIntervalMs)}Mt(){this.Dt&&=(clearTimeout(this.Dt),void 0)}Zt(){var e=this;return Wt((function*(){if(e.Ht.size!==0){var t=e.Ht;e.Ht=new Map,e.Bt=!1,e.Ut=new Map,e.zt=new Set;var n=e.Vt,r=yield e._instance.Kt(e.Gt(t));if(n===e.Vt)switch(r.kind){case`ok`:return;case`retry-later`:e.Yt(t),e.Nt();return;case`too-large`:e.it.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e.it.error(`Failed to send metrics batch:`,r.error);return}}}))()}Gt(e){return function(e,t,n,r){return{resourceMetrics:[{resource:{attributes:fr(t)},scopeMetrics:[{scope:{name:n,version:r},metrics:e}]}]}}(this.Xt(e),(t=this.Se,n=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),Gt({},t.resourceAttributes,{"service.name":t.serviceName||`unknown_service`},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":n,"telemetry.sdk.version":r})),this._instance.getLibraryId(),this._instance.getLibraryVersion());var t,n,r}Xt(e){var t=tte(Date.now()),n=new Map;for(var r of e.values()){var i=nte(r.type,r.name,r.unit,void 0),a=n.get(i);a||(a=Gt({name:r.name},r.unit&&{unit:r.unit}),r.type===`count`?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type===`gauge`?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},n.set(i,a));var o=fr(r.attributes??{}),s=tte(r.windowStartMs);if(r.type===`count`){var c={attributes:o,startTimeUnixNano:s,timeUnixNano:t,asDouble:r.total??0};a.sum.dataPoints.push(c)}else if(r.type===`gauge`){var l={attributes:o,timeUnixNano:t,asDouble:r.last??0};a.gauge.dataPoints.push(l)}else r.hist&&a.histogram.dataPoints.push({attributes:o,startTimeUnixNano:s,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:pr})}return Array.from(n.values())}Yt(e){for(var t of e){var n=t[0],r=t[1],i=this.Ht.get(n);if(i)switch(i.windowStartMs=Math.min(i.windowStartMs,r.windowStartMs),i.type){case`count`:i.total=(i.total??0)+(r.total??0);break;case`gauge`:break;case`histogram`:if(r.hist)if(i.hist){i.hist.count+=r.hist.count,i.hist.sum+=r.hist.sum,i.hist.min=Math.min(i.hist.min,r.hist.min),i.hist.max=Math.max(i.hist.max,r.hist.max);for(var a=0;i.hist.bucketCounts.length>a;a++)i.hist.bucketCounts[a]+=r.hist.bucketCounts[a]}else i.hist=r.hist}else this.Qt()&&this.Ht.set(n,r)}}},mr,ite,hr;function ate(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return hr&&n.length===ite||(ite=n.length,hr=n.reduce(((n,r)=>{mr||={};var i=mr[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,mr[r]=[s,c];break}}return n}),{})),hr}}var ote=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return Wt((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&cn(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),Gt({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Wt((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,Gt({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:ate(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return Gt({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},gr=`?`;function _r(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?gr:n,in_app:!0};return fn(r)||(a.lineno=r),fn(i)||(a.colno=i),a}var vr=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?gr:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},ste=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,cte=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,lte=/\((\S*)(?::(\d+))(?::(\d+))\)/,ute=(e,t)=>{var n=ste.exec(e);if(n)return _r(t,n[1],gr,+n[2],+n[3]);var r=cte.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){var i=lte.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}var a=vr(r[1]||gr,r[2]);return _r(t,a[1],a[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},dte=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,fte=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,pte=(e,t)=>{var n=dte.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=fte.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||gr,o=vr(a,i);return _r(t,i=o[1],a=o[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},mte=/\(error: (.*)\)/,hte=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=pn(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return xn(e,`DOMException`)}isDOMError(e){return xn(e,`DOMError`)}},gte=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},_te=class{constructor(){}match(e){return xn(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},vte=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,yte=class{match(e){return typeof e==`string`}coerce(e,t){var n=this.getInfos(e),r=n[0],i=n[1];return{type:r??`Error`,value:i??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(vte);return r&&(t=r[1],n=r[2]),[t,n]}},bte=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function yr(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var xte=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return Sn(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+yr(e)}isSeverityLevel(e){return pn(e)&&!mn(e)&&bte.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(qee(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Ste=class{match(e){return Sn(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+yr(e),stack:t.syntheticException?.stack,synthetic:!0}}},Cte=class{match(e){return bn(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},wte=class{match(e){return xn(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Sn(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return bn(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},br=`$message`,xr=`$timestamp`,Tte=new Set([br,xr]),Sr={enabled:!0,max_bytes:32768};function Cr(e){return e?{enabled:e.enabled??Sr.enabled,max_bytes:Dte(e.max_bytes,Sr.max_bytes)}:Gt({},Sr)}var Ete=class{constructor(e){this.Pe=[],this.Oe=0,this.Se=Cr(e)}setConfig(e){this.Se=Cr(e),this.Fe()}add(e){var t=function(e){var t;try{t=an(e)}catch{return}try{var n=JSON.parse(t);if(!un(n))return;var r=n,i=r[br],a=r[xr];return!pn(i)||i.trim().length===0||!pn(a)&&!_n(a)?void 0:{step:r,json:t}}catch{return}}(e);if(t){var n=function(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e).length;for(var t=encodeURIComponent(e),n=0,r=0;t.length>r;r++)t[r]===`%`?(n+=1,r+=2):n+=1;return n}(t.json);n>this.Se.max_bytes||(this.Pe.push({step:t.step,bytes:n}),this.Oe+=n,this.Fe())}}getAttachable(){return this.Pe.map((e=>e.step))}clear(){this.Pe=[],this.Oe=0}size(){return this.Pe.length}Fe(){for(;this.Oe>this.Se.max_bytes&&this.Pe.length>0;){var e=this.Pe.shift();e&&(this.Oe-=e.bytes)}}};function Dte(e,t){if(!_n(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var wr=function(e,t){var n=(t===void 0?{}:t).debugEnabled,r={k(t){if(Nt&&(Ut.DEBUG||Ht.POSTHOG_DEBUG||n)&&!fn(Nt.console)&&Nt.console){for(var r=(`__rrweb_original__`in Nt.console[t])?Nt.console[t].__rrweb_original__:Nt.console[t],i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];r(e,...a)}},debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`error`,...t)},critical(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];console.error(e,...n)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling `+e)},createLogger:(t,n)=>wr(e+` `+t,n)};return r},Tr=wr(`[PostHog.js]`),Er=Tr.createLogger,Ote=Er(`[ExternalScriptsLoader]`),Dr=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Ote.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=It?.querySelectorAll(`script`);if(r){for(var i,a=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},o=0;r.length>o;o++)if(i=a())return i.v}var s=()=>{if(!It)return n(`document not found`);var r=It.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)It.head.appendChild(r);else{var i,a=It.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):It.body.appendChild(r)}};It!=null&&It.body?s():It?.addEventListener(`DOMContentLoaded`,s)};Ht.__PosthogExtensions__=Ht.__PosthogExtensions__||{},Ht.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.strict_script_versioning)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}Dr(e,r,n)}else Dr(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},Ht.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{Dr(e,e.requestRouter.endpointFor(`api`,t),n)};var Or=`$people_distinct_id`,kr=`$device_id`,Ar=`$device_model`,jr=`__alias`,Mr=`__timers`,Nr=`$autocapture_disabled_server_side`,Pr=`$heatmaps_enabled_server_side`,Fr=`$exception_capture_enabled_server_side`,Ir=`$error_tracking_suppression_rules`,Lr=`$error_tracking_capture_extension_exceptions`,Rr=`$web_vitals_enabled_server_side`,zr=`$dead_clicks_enabled_server_side`,Br=`$product_tours_enabled_server_side`,Vr=`$web_vitals_allowed_metrics`,Hr=`$session_recording_remote_config`,kte=`$replay_sample_rate`,Ate=`$replay_override_sampling`,jte=`$replay_override_linked_flag`,Mte=`$replay_override_url_trigger`,Nte=`$replay_override_event_trigger`,Ur=`$sesid`,Wr=`$session_is_sampled`,Gr=`$enabled_feature_flags`,Kr=`$active_feature_flags`,qr=`$early_access_features`,Jr=`$feature_flag_details`,Yr=`$feature_flag_payloads`,Xr=`$feature_flag_request_id`,Zr=`$override_feature_flags`,Qr=`$override_feature_flag_payloads`,$r=`$stored_person_properties`,ei=`$stored_group_properties`,ti=`$surveys`,ni=`$surveys_loaded_at`,ri=`$surveys_activated`,ii=`ph_product_tours`,ai=`$flag_call_reported`,oi=`$flag_call_reported_session_id`,si=`$feature_flag_errors`,ci=`$feature_flag_evaluated_at`,li=`$user_state`,ui=`$client_session_props`,di=`$capture_rate_limit`,fi=`$initial_campaign_params`,pi=`$initial_referrer_info`,mi=`$initial_person_info`,hi=`$epp`,gi=`__POSTHOG_TOOLBAR__`,_i=`$posthog_cookieless`,vi=`$sdk_debug_extensions_init_method`,yi=`$sdk_debug_extensions_init_time_ms`,bi=`$sdk_debug_recording_script_not_loaded`,xi=`PostHog loadExternalDependency extension not found.`,Si=`on_reject`,Ci=`always`,wi=`anonymous`,Ti=`identified`,Ei=`identified_only`,Di=`visibilitychange`,Oi=`beforeunload`,ki=`$pageview`,Ai=`$pageleave`,ji=`$identify`,Mi=`$groupidentify`;function Ni(e,t){cn(e)&&e.forEach(t)}function Pi(e,t){if(!gn(e))if(cn(e))e.forEach(t);else if(bee(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)yee.call(e,n)&&t(e[n],n)}var Fi=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Ii(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Li=function(e){try{return e()}catch{return}},Pte=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){Tr.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),Tr.critical(e)}}},Ri=function(e){var t={};return Pi(e,(function(e,n){(pn(e)&&e.length>0||_n(e))&&(t[n]=e)})),t},Fte=[`herokuapp.com`,`vercel.app`,`netlify.app`];function Ite(e){var t=e?.hostname;if(!pn(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of Fte)if(n===r)return!1;return!0}function zi(e,t,n,r){var i=r??{},a=i.capture,o=i.passive;e?.addEventListener(t,n,{capture:a!==void 0&&a,passive:o===void 0||o})}function Bi(e){return e.name===`ph_toolbar_internal`}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return _n(e)&&isFinite(e)&&Math.floor(e)===e});var Lte=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Rte=class{constructor(){this.S=0,this.C=0,this.I=new Bte}generate(){var e=this.generateOrAbort();if(fn(e)){this.S=0;var t=this.generateOrAbort();if(fn(t))throw Error(`Could not generate UUID after timestamp reset`);return t}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.M();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return Lte.fromFieldsV7(this.S,Math.trunc(this.C/2**30),this.C&2**30-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}},zte,Vi=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Nt&&!fn(Nt.crypto)&&crypto.getRandomValues&&(Vi=e=>crypto.getRandomValues(e));var Bte=class{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(Vi(this.R),this.O=0),this.R[this.O++]}},Hi=()=>Vte().toString(),Vte=()=>(zte||=new Rte).generate(),Ui=``,Hte=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Wi={N:()=>!!It,F(e){Tr.error(`cookieStore error: `+e)},A(e){if(It){try{for(var t=e+`=`,n=It.cookie.split(`;`).filter((e=>e.length)),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==` `;)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},D(e){var t;try{t=JSON.parse(Wi.A(e))||{}}catch{}return t},q(e,t,n,r,i){if(!It)return!1;try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=It),Ui)return Ui;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+Hi();!Ui&&r--;){var a=n.slice(r).join(`.`),o=i+`=1;domain=.`+a+`;path=/`;t.cookie=o+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=o+`;max-age=0`,Ui=a)}return Ui}(e);if(!n){var r=(e=>{var t=e.match(Hte);return t?t[0]:``})(e);r!==n&&Tr.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(It.location.hostname,r);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),a=`; expires=`+c.toUTCString()}i&&(o=`; secure`);var l=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return l.length>3686.4&&Tr.warn(`cookieStore warning: large cookie, len=`+l.length),It.cookie=l,!0}catch{return!1}},P(e,t){if(It!=null&&It.cookie)try{Wi.q(e,``,-1,t)}catch{return}}},Gi=null,Ki={N(){if(!hn(Gi))return Gi;var e=!0;if(fn(Nt))e=!1;else try{var t=`__mplssupport__`;Ki.q(t,`xyz`),Ki.A(t)!==`"xyz"`&&(e=!1),Ki.P(t)}catch{e=!1}return e||Tr.error(`localStorage unsupported; falling back to cookie store`),Gi=e,e},F(e){Tr.error(`localStorage error: `+e)},A(e){try{return Nt?.localStorage.getItem(e)}catch(e){Ki.F(e)}return null},D(e){try{return JSON.parse(Ki.A(e))||{}}catch{}return null},q(e,t){try{return Nt?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Ki.F(e)}return!1},P(e){try{Nt?.localStorage.removeItem(e)}catch(e){Ki.F(e)}}},Ute=[kr,`distinct_id`,Ur,Wr,hi,mi,li],qi={},Wte={N:()=>!0,F(e){Tr.error(`memoryStorage error: `+e)},A:e=>qi[e]||null,D:e=>qi[e]||null,q:(e,t)=>(qi[e]=t,!0),P(e){delete qi[e]}},Ji=null,Yi={N(){if(!hn(Ji))return Ji;if(Ji=!0,fn(Nt))Ji=!1;else try{var e=`__support__`;Yi.q(e,`xyz`),Yi.A(e)!==`"xyz"`&&(Ji=!1),Yi.P(e)}catch{Ji=!1}return Ji},F(e){Tr.error(`sessionStorage error: `,e)},A(e){try{return Nt?.sessionStorage.getItem(e)}catch(e){Yi.F(e)}return null},D(e){try{return JSON.parse(Yi.A(e))||null}catch{}return null},q(e,t){try{return Nt?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Yi.F(e)}return!1},P(e){try{Nt?.sessionStorage.removeItem(e)}catch(e){Yi.F(e)}}},Gte=class{constructor(e){this._instance=e}get Se(){return this._instance.config}get consent(){return this.Ne()?0:this.De}isOptedOut(){return this.Se.cookieless_mode===Ci||this.isRejected()||this.consent===-1&&this.Se.cookieless_mode===Si}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Se.opt_out_capturing_by_default}optInOut(e){this.qe.q(this.je,+!!e,this.Se.cookie_expiration,this.Se.cross_subdomain_cookie,this.Se.secure_cookie)}reset(){this.qe.P(this.je,this.Se.cross_subdomain_cookie)}get je(){var e=this._instance.config,t=e.token,n=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(n?n+t:`__ph_opt_in_out_`+t)}get De(){var e=this.qe.A(this.je);return Cn(e)?1:tn(wee,e)?0:-1}get qe(){var e=this.Se.opt_out_capturing_persistence_type,t=e===`localStorage`?Ki:Wi;if(!this.He||this.He!==t){this.He=t;var n=e===`localStorage`?Wi:Ki;n.A(this.je)&&(this.He.A(this.je)||this.optInOut(Cn(n.A(this.je))),n.P(this.je,this.Se.cross_subdomain_cookie))}return this.He}Ne(){return!!this.Se.respect_dnt&&[Ft?.doNotTrack,Ft?.msDoNotTrack,Ht.doNotTrack].some((e=>Cn(e)))}};function Xi(e,t){var n,r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!ln(r))return t;try{var i=r(t);return pn(i)&&i?i:t}catch(e){return Tr.error(`Error in get_current_url, falling back to window.location.href`,e),t}}var Kte=1,qte=3,Jte=11;function Zi(e){return e instanceof Element&&(e.id===gi||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function Qi(e){return!!e&&e.nodeType===Kte}function $i(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Yte(e){return!!e&&e.nodeType===qte}function Xte(e){return!!e&&e.nodeType===Jte&&Qi(e.host)}var Zte=1e3;function ea(e){return e?nn(e).split(/\s+/):[]}function Qte(e,t){var n=function(e){var t,n=Nt==null||(t=Nt.location)==null?void 0:t.href;return fn(n)?void 0:Xi(e,n)}(t);return!!(n&&e&&e.some((e=>n.match(e))))}function ta(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return ea(t)}function $te(e){return gn(e)?null:nn(e).split(/(\s+)/).filter((e=>ca(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function na(e){var t=``;return sa(e)&&!lne(e)&&e.childNodes&&e.childNodes.length&&Pi(e.childNodes,(function(e){Yte(e)&&e.textContent&&(t+=$te(e.textContent)??``)})),nn(t)}function ra(e){return fn(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var ia=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function aa(e,t){if(fn(t))return!0;var n,r=function(e){if(t.some((t=>function(e,t){var n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}(e,t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function ene(e){var t=e.parentNode;return!(!t||!Qi(t))&&t}var tne=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],nne=[`next`,`previous`,`prev`,`>`,`<`],rne=[...nne,`+`,`-`,`−`,`–`],ine=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,ane=[`.ph-no-rageclick`,`.ph-no-capture`],one=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function sne(e,t){if(!Nt||oa(e))return!1;var n,r,i,a;if(yn(t)?(n=!!t&&ane,r=void 0,i=!1):(n=t?.css_selector_ignorelist??ane,r=t?.content_ignorelist,i=(a=t?.ignore_text_selection)!=null&&a),!1===n||i&&function(e){return!(!e||!Qi(e))&&(!!$i(e,`textarea`)||($i(e,`input`)?tn(one,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=e.getAttribute==null?void 0:e.getAttribute(`contenteditable`);return t===`true`||t===``}(e)))}(e))return!1;var o=cne(e,!1).targetElementList;return!function(e,t){if(!1===e||fn(e))return!1;var n;if(!0===e)n=nne;else{if(!cn(e))return!1;if(e.length>10)return Tr.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var t=e.safeText,r=e.ariaLabel;return n.some((e=>ine(t,e)||ine(r,e)))}))}(r,o.map((e=>({safeText:na(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!aa(o,n)}var oa=e=>!e||$i(e,`html`)||!Qi(e),cne=(e,t)=>{if(!Nt||oa(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!$i(i,`body`);)if(Xte(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=ene(i);if(!a)break;if(t||ia.indexOf(a.tagName.toLowerCase())>-1)n=!0;else try{var o=Nt.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}catch{}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function sa(e){for(var t=new Set,n=0,r=e;r.parentNode&&!$i(r,`body`);r=r.parentNode){if(n++>=Zte||t.has(r))return!1;t.add(r);var i=ta(r);if(tn(i,`ph-sensitive`)||tn(i,`ph-no-capture`))return!1}if(tn(ta(e),`ph-include`))return!0;var a=e.type||``;if(pn(a))switch(a.toLowerCase()){case`hidden`:case`password`:return!1}var o=e.name||e.id||``;return!pn(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,``))}function lne(e){return!!($i(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||$i(e,`select`)||$i(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var une=`(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})`,dne=RegExp(`^(?:`+une+`)$`),fne=new RegExp(une),pne=`\\d{3}-?\\d{2}-?\\d{4}`,mne=RegExp(`^(`+pne+`)$`),hne=RegExp(`(`+pne+`)`);function ca(e,t){return t===void 0&&(t=!0),!(gn(e)||pn(e)&&(e=nn(e),(t?dne:fne).test((e||``).replace(/[- ]/g,``))||(t?mne:hne).test(e)))}function gne(e){var t=na(e);return ca(t=(t+` `+_ne(e)).trim())?t:``}function _ne(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&Pi(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=na(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+_ne(e)).trim())}catch(e){Tr.error(`[AutoCapture]`,e)}})),t}function vne(e){return e.replace(/"|\\"/g,`\\"`)}function yne(e){var t=e.attr__class;return t?cn(t)?t:ea(t):void 0}var la=Er(`[Dead Clicks]`),bne=()=>!0,xne=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(zr)),r=e.instance.config.capture_dead_clicks;return yn(r)?r:!!un(r)||n},Sne=class{get lazyLoadedDeadClicksAutocapture(){return this.Be}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){`captureDeadClicks`in e&&(this.instance.persistence&&this.instance.persistence.register({[zr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ue((()=>{this.ze()})):this.stop()}Ue(e){var t,n;(t=Ht.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture?e():(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?la.error(`failed to load script`,t):e()}))}ze(){var e;if(It){if(!this.Be&&(e=Ht.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=un(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.Be=Ht.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Be.start(It),la.info(`starting...`)}}else la.error("`document` not found. Cannot start.")}stop(){this.Be&&(this.Be.stop(),this.Be=void 0,la.info(`stopping...`))}},ua=Er(`[SegmentIntegration]`),Cne=`posthog-js`;function wne(e,t){var n=t===void 0?{}:t,r=n.organization,i=n.projectId,a=n.prefix,o=n.severityAllowList,s=o===void 0?[`error`]:o,c=n.sendExceptionsToPostHog,l=c===void 0||c;return t=>{if(s!==`*`&&!s.includes(t.level)||!e.__loaded)return t;t.tags||={};var n=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=n,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var o,c=t.exception?.values||[],u=c.map((e=>Gt({},e,{stacktrace:e.stacktrace?Gt({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>Gt({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:c[0]?.value||t.message,$exception_type:c[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:c[0]?.value||t.message,$sentry_exception_type:c[0]?.type,$sentry_tags:t.tags};return r&&i&&(d.$sentry_url=(a||`https://sentry.io/organizations/`)+r+`/issues/?project=`+i+`&query=`+t.event_id),l&&((o=e.exceptions)==null||o.sendExceptionEvent(d)),t}}var Tne=class{constructor(e,t,n,r,i,a){this.name=Cne,this.setupOnce=function(o){o(wne(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},Ene=class{constructor(e){this.Ve=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(Tr.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.We=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Ze()}Ze(){this.Ge=this._instance.sessionManager?.onSessionId(this.Ve)}destroy(){var e;(e=this.Ge)==null||e.call(this),this.Ge=void 0}doPageView(e,t){var n=this.Qe(e,t);return this.We={pathname:Nt?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.Qe(e,this.We?.pageViewId)}doEvent(){return{$pageview_id:this.We?.pageViewId}}Qe(e,t){var n=this.We;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var a=i.maxScrollHeight,o=i.lastScrollY,s=i.maxScrollY,c=i.maxContentHeight,l=i.lastContentY,u=i.maxContentY;if(!(fn(a)||fn(o)||fn(s)||fn(c)||fn(l)||fn(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?wn(o/a,0,1,Tr):1,f=a>1?wn(s/a,0,1,Tr):1,p=c>1?wn(l/c,0,1,Tr):1,m=c>1?wn(u/c,0,1,Tr):1;r=Fi(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},da=[`flags`,`surveys`],Dne={[Or]:{exposure:`hidden`},[jr]:{exposure:`hidden`},__cmpns:{exposure:`hidden`},[Mr]:{exposure:`hidden`},[Nr]:{exposure:`event`},[Pr]:{exposure:`hidden`},[Fr]:{exposure:`event`},[Ir]:{exposure:`hidden`},[Lr]:{exposure:`event`},[Rr]:{exposure:`event`},[zr]:{exposure:`event`},[Br]:{exposure:`hidden`},[Vr]:{exposure:`event`},[Hr]:{exposure:`hidden`},$session_recording_enabled_server_side:{exposure:`hidden`},[Ur]:{exposure:`hidden`},[Wr]:{exposure:`event`},[kte]:{exposure:`event`,shouldSkipFromEventProperties:e=>hn(e)},$session_past_minimum_duration:{exposure:`event`},$session_recording_url_trigger_activated_session:{exposure:`event`},$session_recording_event_trigger_activated_session:{exposure:`event`},$debug_first_full_snapshot_timestamp:{exposure:`event`},$sess_rec_flush_size:{exposure:`hidden`},[Gr]:{exposure:`derived`,storageGroup:`flags`,shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!un(e))return{};for(var t={},n=Object.keys(e),r=0;n.length>r;r++)t[`$feature/`+n[r]]=e[n[r]];return t}},[Kr]:{exposure:`event`,storageGroup:`flags`},[qr]:{exposure:`hidden`},[Jr]:{exposure:`hidden`,storageGroup:`flags`},[Yr]:{exposure:`event`,storageGroup:`flags`},[Xr]:{exposure:`event`,storageGroup:`flags`,volatile:!0},[Zr]:{exposure:`event`},[Qr]:{exposure:`hidden`},[$r]:{exposure:`hidden`},[ei]:{exposure:`hidden`},[ti]:{exposure:`hidden`,storageGroup:`surveys`},[ni]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[ri]:{exposure:`event`},[ii]:{exposure:`hidden`},$product_tours_activated:{exposure:`hidden`},$conversations_widget_session_id:{exposure:`event`},$conversations_ticket_id:{exposure:`event`},$conversations_widget_state:{exposure:`event`},$conversations_user_traits:{exposure:`event`},[ai]:{exposure:`hidden`},[oi]:{exposure:`hidden`},[si]:{exposure:`hidden`},[ci]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[li]:{exposure:`hidden`},[ui]:{exposure:`hidden`},[di]:{exposure:`hidden`},[fi]:{exposure:`hidden`},[pi]:{exposure:`hidden`},[mi]:{exposure:`hidden`},[hi]:{exposure:`hidden`},[Ate]:{exposure:`event`},[jte]:{exposure:`event`},[Mte]:{exposure:`event`},[Nte]:{exposure:`event`},[vi]:{exposure:`event`},[yi]:{exposure:`event`},[bi]:{exposure:`event`},$sdk_debug_replay_event_trigger_status:{exposure:`event`},$sdk_debug_replay_linked_flag_trigger_status:{exposure:`event`},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:`event`},$sdk_debug_replay_remote_trigger_matching_config:{exposure:`event`},$sdk_debug_replay_trigger_groups_count:{exposure:`event`},$sdk_debug_replay_url_trigger_status:{exposure:`event`},$session_recording_start_reason:{exposure:`event`}},One=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],fa=e=>{var t=Dne[e];if(t)return t;for(var n of One){var r=n[1];if(e.indexOf(n[0])===0)return r}},pa=e=>{var t=It?.createElement(`a`);return fn(t)?null:(t.href=e,t)},ma=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!cn(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{Tr.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},ha=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);cn(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},ga=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},kne=(e,t)=>e>=t&&see(),Ane=(e,t,n,r)=>{if(e===0){if(see()){var i=t+1;return i===n&&r(),i}return t}return 0},_a=`https?://(.*)`,va=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],jne=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...va],ya=`<masked>`,Mne=[`li_fat_id`];function Nne(e,t,n){if(!It)return{};var r,i=t?[...va,...n||[]]:[],a=Pne(ha(It.URL,i,ya),e);return Fi((r={},Pi(Mne,(function(e){var t=Wi.A(e);r[e]=t||null})),r),a)}function Pne(e,t){var n=jne.concat(t||[]),r={};return Pi(n,(function(t){r[t]=ma(e,t)||null})),r}function Fne(e){var t=function(e){return e?e.search(_a+`google.([^/?]*)`)===0?`google`:e.search(_a+`bing.com`)===0?`bing`:e.search(_a+`yahoo.com`)===0?`yahoo`:e.search(_a+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!hn(t)){r.$search_engine=t;var i=It?ma(It.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function Ine(){return navigator.language||navigator.userLanguage}var ba=`$direct`;function Lne(){return It?.referrer||ba}function Rne(e,t,n){n===void 0&&(n=!1);var r=e?[...va,...t||[]]:[],i=(n?ur(Lt?.href):Lt?.href)?.substring(0,1e3);return{r:Lne().substring(0,1e3),u:i?ha(i,r,ya):void 0}}function zne(e,t){t===void 0&&(t=!1);var n=e.r,r=e.u,i=t?ur(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==ba?ba:pa(n)?.host};if(i){a.$current_url=i;var o=pa(i);a.$host=o?.host,a.$pathname=o?.pathname,Fi(a,Pne(i))}return n&&Fi(a,Fne(n)),a}function Bne(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Vne(){try{return new Date().getTimezoneOffset()}catch{return}}var Hne={flags:ci,surveys:ni},Une=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],xa=`main`,Sa=class{constructor(e,t,n){if(n===void 0&&(n=!0),this.Je={},this.Ke=!1,this.Ye=!1,this.Se=e,this.Xe=n,this.props={},this.tr=!1,this.er=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.qe=this.rr(e),this.Ye=this.ir(e),this.load(),e.debug&&Tr.info(`Persistence loaded`,e.persistence,Gt({},this.props)),this.update_config(e,e,t),this.save(),Nt){var r=()=>this.flush();zi(Nt,`beforeunload`,r,{capture:!1}),zi(Nt,`pagehide`,r,{capture:!1})}}nr(){var e=this.Se?.persistence_save_debounce_ms;return _n(e)&&e>0?e:0}isDisabled(){return!!this.sr}rr(e){Une.indexOf(e.persistence.toLowerCase())===-1&&(Tr.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);var t,n=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=!1);var n=[...Ute,...e];return Gt({},Ki,{D(e){try{var n={};try{n=Wi.D(e)||{}}catch{}var r,i=JSON.parse(Ki.A(e)||`{}`);if(t){var a={};for(var o in n){var s=n[o];hn(s)||s===``||(a[o]=s)}r=Fi(i,a)}else r=Fi(n,i);return Ki.q(e,r),r}catch{}return null},q(e,t,r,i,a,o){var s=Ki.q(e,t,void 0,void 0,o);try{var c={};n.forEach((e=>{t[e]&&(c[e]=t[e])})),Object.keys(c).length&&Wi.q(e,c,r,i,a,o)}catch(e){Ki.F(e)}return s},P(e,t){try{Nt?.localStorage.removeItem(e),Wi.P(e,t)}catch(e){Ki.F(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),r=!1,i=e.persistence.toLowerCase();return i===`localstorage`&&Ki.N()?(t=Ki,r=!0):i===`localstorage+cookie`&&n.N()?(t=n,r=!0):i===`sessionstorage`&&Yi.N()?t=Yi:i===`memory`?t=Wte:i===`cookie`?t=Wi:n.N()?(t=n,r=!0):t=Wi,this.Ke=r,t}ar(e){return this.er+`__`+e}ir(e){return this.Ke&&!!e.split_storage}lr(e){var t=e??this.Se.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[ci];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return Pi(this.props,((t,n)=>{var r=fa(n);if(r?.exposure===`derived`){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,n===Gr?()=>this.lr():()=>!1))return;r.transformToEventProperties&&Fi(e,r.transformToEventProperties(t))}else if(!r||r.exposure===`event`){if(r!=null&&r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,(()=>!1)))return;e[n]=t}})),e}load(){if(!this.sr){var e=this.qe.D(this.er);e&&(this.props=Fi({},e)),this.Ye&&this.ur()}}ur(){for(var e of da){var t=Ki.D(this.ar(e));if(t&&!dn(t)){var n=this.hr(e);n.persisted=!0,this.dr(e)||(n.fingerprint=this.cr(t,e)),this.vr(e,t)||Fi(this.props,t)}}}dr(e){return Object.keys(this.props).some((t=>fa(t)?.storageGroup===e))}vr(e,t){var n=Hne[e];if(!n)return!1;var r=t[n],i=this.props[n];return _n(r)&&_n(i)&&i>r}refreshKey(e){if(!this.sr){var t=this.Ye?fa(e)?.storageGroup:void 0,n=t?Ki.D(this.ar(t)):this.qe.D(this.er);if(n&&e in n)this.pr(e,n[e]);else{if(t){var r=this.qe.D(this.er);if(r&&e in r)return void this.pr(e,r[e])}this.gr(e)}}}save(){if(!this.sr){var e=this.nr();e>0?fn(this.mr)&&(this.mr=setTimeout((()=>{this.mr=void 0,this.yr()}),e)):this.yr()}}flush(){fn(this.mr)||(clearTimeout(this.mr),this.mr=void 0,this.yr())}yr(){this.sr||(this.Ye?this.br():this._r(this.qe,this.er,this.props,xa))}br(){var e=this.wr(),t=e.main,n=e.groups;for(var r of(this._r(this.qe,this.er,t,xa),da)){var i,a=n[r];(!dn(a)||(i=this.Je[r])!=null&&i.persisted)&&this._r(Ki,this.ar(r),a,r)}}wr(){var e={},t={};for(var n of da)t[n]={};return Pi(this.props,((n,r)=>{var i=fa(r)?.storageGroup;i?t[i][r]=n:e[r]=n})),{main:e,groups:t}}cr(e,t){if(t===xa)return JSON.stringify(e)+`|`+this.kr+`|`+this.Sr+`|`+this.Cr;var n={};return Pi(e,((e,t)=>{var r;n[t]=(r=fa(t))!=null&&r.volatile?`__volatile__`:e})),JSON.stringify(n)}_r(e,t,n,r){var i=this.hr(r);if(r===xa||i.dirty||fn(i.fingerprint)){var a;try{if((a=this.cr(n,r))===i.fingerprint)return void(i.dirty=!1)}catch{a=void 0}e.q(t,n,this.kr,this.Sr,this.Cr,this.Se.debug)?(i.dirty=!1,r!==xa&&(i.persisted=!0),fn(a)||(i.fingerprint=a)):this.Se.debug&&Tr.warn(`failed to persist storage entry "`+t+`"; will retry on next save`)}}remove(e){var t=(e===void 0?{}:e).keepGroupEntries,n=t!==void 0&&t;if(fn(this.mr)||(clearTimeout(this.mr),this.mr=void 0),this.qe.P(this.er,!1),this.qe.P(this.er,!0),!n&&this.Xe)for(var r of da)Ki.P(this.ar(r));n?delete this.Je[xa]:this.Je={}}clear(){this.remove(),this.props={}}register_once(e,t,n){if(un(e)){fn(t)&&(t=`None`),this.kr=fn(n)?this.Ir:n;var r=!1;if(Pi(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.pr(n,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(un(e)){this.kr=fn(t)?this.Ir:t;var n=!1;if(Pi(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.pr(r,t),n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.gr(e),this.save())}update_campaign_params(){if(!this.tr){var e=Nne(this.Se.custom_campaign_params,this.Se.mask_personal_data_properties,this.Se.custom_personal_data_properties);dn(Ri(e))||this.register(e),this.tr=!0}}update_search_keyword(){var e;this.register((e=It?.referrer)?Fne(e):{})}update_referrer_info(){this.register_once({$referrer:Lne(),$referring_domain:It!=null&&It.referrer&&pa(It.referrer)?.host||ba},void 0)}set_initial_person_info(){this.props[fi]||this.props[pi]||this.register_once({[mi]:Rne(this.Se.mask_personal_data_properties,this.Se.custom_personal_data_properties,this.Se.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};Pi([pi,fi],(t=>{var n=this.props[t];n&&Pi(n,(function(t,n){e[`$initial_`+rn(n)]=t}))}));var t=this.props[mi];return t&&Fi(e,function(e,t){t===void 0&&(t=!1);var n=zne(e,t),r={};return Pi(n,(function(e,t){r[`$initial_`+rn(t)]=e})),r}(t,this.Se.disable_capture_url_hashes)),e}safe_merge(e){return Pi(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){this.Ir=this.kr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var r=e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),i=r?this.rr(e):this.qe,a=this.ir(e);if(r||a!==this.Ye){var o=this.props;this.clear(),this.qe=i,this.Ye=a,this.props=o,this.save()}}set_disabled(e){this.sr=e,this.sr?this.remove():this.save()}set_cross_subdomain(e){e!==this.Sr&&(this.Sr=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Cr&&(this.Cr=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var n=this.props[Mr]||{};n[e]=t,this.pr(Mr,n),this.save()}remove_event_timer(e){var t=this.props[Mr]||{},n=t[e];return fn(n)||(delete t[e],this.pr(Mr,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.pr(e,t),this.save()}pr(e,t){var n;this.props[e]=t,(n=fa(e))!=null&&n.volatile||this.Tr(e)}gr(e){delete this.props[e],this.Tr(e)}Tr(e){var t=fa(e)?.storageGroup;t&&(this.hr(t).dirty=!0)}hr(e){return this.Je[e]||(this.Je[e]={})}},Ca={Activation:`events`,Cancellation:`cancelEvents`},wa={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},Ta={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Ea={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},Da={Popover:`popover`,Inline:`inline`},Wne={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},Gne={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},Kne=Er(`[RateLimiter]`),qne=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Kne.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){Kne.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var n=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,i=new Date().getTime(),a=this.instance.persistence?.get_property(di)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(di,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Oa=Er(`[RemoteConfig]`),Jne=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Ht._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Mr(e){var t,n;(t=Ht.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Er(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/`+this._instance.config.token+`/config`),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return Oa.info(`Using preloaded remote config`,this.remoteConfig),this.Rr(this.remoteConfig),void this.Pr();if(this._instance.Or())return void Oa.warn(`Remote config is disabled. Falling back to local config.`);this.Mr((e=>{if(!e)return Oa.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Er((e=>{this.Rr(e),this.Pr()}));this.Rr(e),this.Pr()}))}catch(e){Oa.error(`Error loading remote config`,e)}}stop(){this.Fr&&=(clearInterval(this.Fr),void 0)}refresh(){!this._instance.Or()&&It&&It.visibilityState!==`hidden`&&this._instance.reloadFeatureFlags()}Pr(){if(!this.Fr){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.Fr=setInterval((()=>{this.refresh()}),e))}}Rr(e){var t;e||Oa.error(`Failed to fetch remote config from PostHog.`),this._instance.Rr(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},ka={GZipJS:`gzip-js`,Base64:`base64`},Aa=Uint8Array,ja=Uint16Array,Ma=Uint32Array,Na=new Aa([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Pa=new Aa([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Yne=new Aa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xne=function(e,t){for(var n=new ja(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Ma(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},Zne=Xne(Na,2),Fa=Zne[1];Zne[0][28]=258,Fa[258]=28;for(var Qne=Xne(Pa,0)[1],Ia=new ja(32768),La=0;32768>La;++La){var Ra=(43690&La)>>>1|(21845&La)<<1;Ia[La]=((65280&(Ra=(61680&(Ra=(52428&Ra)>>>2|(13107&Ra)<<2))>>>4|(3855&Ra)<<4))>>>8|(255&Ra)<<8)>>>1}var za=function(e,t,n){for(var r=e.length,i=0,a=new ja(t);r>i;++i)++a[e[i]-1];var o,s=new ja(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new ja(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[Ia[d]>>>c]=l}else for(o=new ja(r),i=0;r>i;++i)o[i]=Ia[s[e[i]-1]++]>>>15-e[i];return o},Ba=new Aa(288);for(La=0;144>La;++La)Ba[La]=8;for(La=144;256>La;++La)Ba[La]=9;for(La=256;280>La;++La)Ba[La]=7;for(La=280;288>La;++La)Ba[La]=8;var Va=new Aa(32);for(La=0;32>La;++La)Va[La]=5;var $ne=za(Ba,9,0),ere=za(Va,5,0),tre=function(e){return(e/8>>0)+(7&e&&1)},nre=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof ja?ja:e instanceof Ma?Ma:Aa)(n-t);return r.set(e.subarray(t,n)),r},Ha=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Ua=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Wa=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new Aa(0),0];if(i==1){var o=new Aa(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new ja(f+1),m=Ga(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new Aa(p),m]},Ga=function(e,t,n){return e.s==-1?Math.max(Ga(e.l,t,n+1),Ga(e.r,t,n+1)):t[e.s]=n},Ka=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ja(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},qa=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Ja=function(e,t,n){var r=n.length,i=tre(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},rre=function(e,t,n,r,i,a,o,s,c,l,u){Ha(t,u++,n),++i[256];for(var d=Wa(i,15),f=d[0],p=d[1],m=Wa(a,15),h=m[0],g=m[1],_=Ka(f),v=_[0],y=_[1],b=Ka(h),x=b[0],S=b[1],C=new ja(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var T=Wa(C,7),E=T[0],D=T[1],O=19;O>4&&!E[Yne[O-1]];--O);var k,A,j,M,N=l+5<<3,P=qa(i,Ba)+qa(a,Va)+o,F=qa(i,f)+qa(a,h)+o+14+3*O+qa(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(P>=N&&F>=N)return Ja(t,u,e.subarray(c,c+l));if(Ha(t,u,1+(P>F)),u+=2,P>F){k=za(f,p,0),A=f,j=za(h,g,0),M=h;var I=za(E,D,0);for(Ha(t,u,y-257),Ha(t,u+5,S-1),Ha(t,u+10,O-4),u+=14,w=0;O>w;++w)Ha(t,u+3*w,E[Yne[w]]);u+=3*O;for(var L=[v,x],ee=0;2>ee;++ee){var R=L[ee];for(w=0;R.length>w;++w)Ha(t,u,I[te=31&R[w]]),u+=E[te],te>15&&(Ha(t,u,R[w]>>>5&127),u+=R[w]>>>12)}}else k=$ne,A=Ba,j=ere,M=Va;for(w=0;s>w;++w)if(r[w]>255){var te;Ua(t,u,k[257+(te=r[w]>>>18&31)]),u+=A[te+257],te>7&&(Ha(t,u,r[w]>>>23&31),u+=Na[te]);var ne=31&r[w];Ua(t,u,j[ne]),u+=M[ne],ne>3&&(Ua(t,u,r[w]>>>5&8191),u+=Pa[ne])}else Ua(t,u,k[r[w]]),u+=A[r[w]];return Ua(t,u,k[256]),u+A[256]},ire=new Ma([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),are=function(){for(var e=new Ma(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Ya=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function ore(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=are[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new Aa(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Ja(c,l,e.subarray(u,d)):(c[u]=!0,l=Ja(c,l,e.subarray(u,o)))}else{for(var f=ire[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new ja(32768),_=new ja(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new Ma(25e3),S=new ja(288),C=new ja(32),w=0,T=0,E=(u=0,0),D=0,O=0;o>u;++u){var k=b(u),A=32767&u,j=_[k];if(g[A]=j,_[k]=A,u>=D){var M=o-u;if((w>7e3||E>24576)&&M>423){l=rre(e,c,0,x,S,C,T,E,O,u-O,l),E=w=T=0,O=u;for(var N=0;286>N;++N)S[N]=0;for(N=0;30>N;++N)C[N]=0}var P=2,F=0,I=m,L=A-j&32767;if(M>2&&k==b(u-L))for(var ee=Math.min(p,M)-1,R=Math.min(32767,u),te=Math.min(258,M);R>=L&&--I&&A!=j;){if(e[u+P]==e[u+P-L]){for(var ne=0;te>ne&&e[u+ne]==e[u+ne-L];++ne);if(ne>P){if(P=ne,F=L,ne>ee)break;var re=Math.min(L,ne-2),ie=0;for(N=0;re>N;++N){var ae=u-L+N+32768&32767,oe=ae-g[ae]+32768&32767;oe>ie&&(ie=oe,j=ae)}}}L+=(A=j)-(j=g[A])+32768&32767}if(F){x[E++]=268435456|Fa[P]<<18|Qne[F];var se=31&Fa[P],ce=31&Qne[F];T+=Na[se]+Pa[ce],++S[257+se],++C[ce],D=u+P,++w}else x[E++]=e[u],++S[e[u]]}}l=rre(e,c,!0,x,S,C,T,E,O,u-O,l)}return nre(s,0,r+tre(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Ya(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),Ya(l,u-8,n.d()),Ya(l,u-4,r),l}var sre=!!zt||!!Rt,cre=`text/plain`,Xa=!1,Za=(e,t)=>{var n=e.split(`#`),r=n[1],i=n[0].split(`?`),a=i[0],o=i[1];if(!o)return e;var s=o.split(`&`).filter((e=>e.split(`=`)[0]!==t)).join(`&`);return a+(s?`?`+s:``)+(r?`#`+r:``)},Qa=function(e,t,n){n===void 0&&(n=!0);var r=e.split(`?`),i=r[0],a=r[1],o=Gt({},t),s=a?.split(`&`).map((e=>{var t,r=e.split(`=`),i=r[0],a=n&&(t=o[i])!=null?t:r[1];return delete o[i],i+`=`+a}))??[],c=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return Pi(e,(function(e,t){fn(e)||fn(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(o);return c&&s.push(c),i+`?`+s.join(`&`)},$a=(e,t)=>{try{return JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t)}catch{return an(e)}},eo=e=>{if(e.Ae)return e.Ae;var t=e.data,n=e.compression;if(t){if(n===ka.GZipJS){var r=ore(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new Aa(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new Aa(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return nre(r,0,i)}($a(t)),{mtime:0});return{contentType:cre,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===ka.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:$a(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}($a(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=$a(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},lre=e=>{var t,n,r=()=>e.transport===`sendBeacon`?{url:Qa(e.url,{compression:ka.Base64}),encodedBody:eo(Gt({},e,{compression:ka.Base64,Ae:void 0}))}:{url:Za(e.url,`compression`),encodedBody:eo(Gt({},e,{compression:void 0,Ae:void 0}))};try{t=eo(e)}catch(t){if(hee(e.compression,ma(e.url,`compression`)))return Tr.error(`Failed to gzip request body, sending uncompressed payload`,t),r();throw t}return t&&hee(e.compression,ma(e.url,`compression`))&&!((n=t.body)instanceof ArrayBuffer?Zt(new Uint8Array(n)):ArrayBuffer.isView(n)&&Zt(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Xa=!0,r()):{url:e.url,encodedBody:t}},ure=e=>{try{return lre(e)}catch(t){Tr.error(t),e.callback==null||e.callback({statusCode:0,error:t});return}},dre=function(){var e=Wt((function*(e){var t=yield function(e,t,n){return $t.apply(this,arguments)}($a(e.data),Ut.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return Gt({},e,{Ae:{contentType:cre,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),fre=/Failed to fetch|NetworkError|Load failed/i,pre=e=>{var t=ure(e);if(t){var n=t.url,r=t.encodedBody??{},i=r.contentType,a=r.body,o=r.estimatedSize,s=new Headers;Pi(e.headers,(function(e,t){s.append(t,e)})),i&&s.append(`Content-Type`,i);var c=null,l=!1;if(Bt){var u=new Bt;c={signal:u.signal,timeout:setTimeout((()=>{var t,n;l=!0,u.abort((t=e.timeout,(n=Error(`PostHog request timed out`+(t?` after `+t+`ms`:``))).name=`AbortError`,n))}),e.timeout)}}Rt(n,Gt({method:e?.method||`GET`,headers:s,keepalive:e.method===`POST`&&!e.$e&&52428.8>(o||0),body:a,signal:c?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){Tr.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{l&&t?.name===`AbortError`||(e=>e?.name===`TypeError`&&fre.test(e?.message||``))(t)?Tr.warn(t):Tr.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>c?clearTimeout(c.timeout):null))}},to=e=>{try{var t=lre(e),n=t.url,r=t.encodedBody??{},i=r.body,a=r.estimatedSize;if(!i)return;var o=i instanceof Blob?i:new Blob([i],{type:r.contentType});if(Ft.sendBeacon(n,o))return;if(cn(e.data)&&e.data.length>1&&(a??0)>16384){var s=Math.ceil(e.data.length/2);to(Gt({},e,{data:e.data.slice(0,s)})),to(Gt({},e,{data:e.data.slice(s)}));return}Tr.warn(`Beacon of ~`+(a??0)+` bytes was rejected by the browser, falling back to fetch`),pre(Gt({},e,{$e:!0}))}catch(e){Tr.warn(`Beacon send failed`,e)}},mre=[`/e/`,`/s/`],hre=(e,t)=>{var n=(e=>{var t=(e=>{var t=pa(e)?.pathname||e.split(/[?#]/)[0];return t?t[0]===`/`?t:`/`+t:`/`})(e);return mre.some((e=>((e,t)=>e.slice(e.length-t.length)===t)(t,e)))})(e),r=n?Za(e,`ver`):e;return Qa(t===ka.GZipJS?Za(r,`compression`):r,Gt({_:new Date().getTime().toString()},n?{}:{ver:Ut.JS_SDK_VERSION},t===ka.GZipJS?{}:{compression:t}))},no=[];Rt&&no.push({transport:`fetch`,method:pre}),zt&&no.push({transport:`XHR`,method(e){var t=ure(e);if(t){var n=new zt,r=t.encodedBody;n.open(e.method||`GET`,t.url,!0);var i=r??{},a=i.contentType,o=i.body;Pi(e.headers,(function(e,t){n.setRequestHeader(t,e)})),a&&n.setRequestHeader(`Content-Type`,a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var t={statusCode:n.status,text:n.responseText};if(n.status===200)try{t.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(t)}},n.send(o)}}}),Ft!=null&&Ft.sendBeacon&&no.push({transport:`sendBeacon`,method:to});var ro=3e3,gre=class{constructor(e,t){this.Lr=!0,this.Ar=[],this.$r=wn(t?.flush_interval_ms||ro,250,5e3,Tr.createLogger(`flush interval`),ro),this.Nr=e}enqueue(e){this.Ar.push(e),this.Dr||this.qr()}unload(){this.jr();var e=this.Ar.length>0?this.Hr():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Br(Gt({},e,{transport:`sendBeacon`}))}))}enable(){this.Lr=!1,this.qr()}qr(){var e=this;this.Lr||(this.Dr=setTimeout((()=>{if(this.jr(),this.Ar.length>0){var t=this.Hr(),n=function(){var n=t[r],i=new Date().getTime();n.data&&cn(n.data)&&Pi(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Br(n)};for(var r in t)n()}}),this.$r))}Br(e){try{this.Nr(e)}catch(e){Tr.error(e)}}jr(){clearTimeout(this.Dr),this.Dr=void 0}Hr(){var e={};return Pi(this.Ar,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;fn(e[i])&&(e[i]=Gt({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Ar=[],e}},_re=[`retriesPerformedSoFar`],vre=class{constructor(e){this.Ur=!1,this.zr=3e3,this.Ar=[],this._instance=e,this.Ar=[],this.Vr=!0,!fn(Nt)&&`onLine`in Nt.navigator&&(this.Vr=Nt.navigator.onLine,this.Wr=()=>{this.Vr=!0,this.Zr()},this.Gr=()=>{this.Vr=!1},zi(Nt,`online`,this.Wr),zi(Nt,`offline`,this.Gr))}get length(){return this.Ar.length}retriableRequest(e){var t=e.retriesPerformedSoFar,n=uee(e,_re);vn(t)&&(n.url=Qa(n.url,{retry_count:t})),this._instance._send_request(Gt({},n,{callback:e=>{if(e.statusCode!==200&&(400>e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(t??0))return void this.Ot(Gt({retriesPerformedSoFar:t},n));e.statusCode===0&&Tr.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after `+(t??0)+` retries.`)}n.callback==null||n.callback(e)}}))}Ot(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Ar.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),Tr.warn(i),this.Ur||(this.Ur=!0,this.Qr())}Qr(){if(this.Jr&&clearTimeout(this.Jr),this.Ar.length===0)return this.Ur=!1,void(this.Jr=void 0);this.Jr=setTimeout((()=>{this.Vr&&this.Ar.length>0&&this.Zr(),this.Qr()}),this.zr)}Zr(){var e=Date.now(),t=[],n=this.Ar.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Ar=t,n.length>0)for(var r of n)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.Jr&&=(clearTimeout(this.Jr),void 0),this.Ur=!1,fn(Nt)||(this.Wr&&=(Nt.removeEventListener(`online`,this.Wr),void 0),this.Gr&&=(Nt.removeEventListener(`offline`,this.Gr),void 0)),this.Ar)){var t=e.requestOptions;try{this._instance._send_request(Gt({},t,{transport:`sendBeacon`}))}catch(e){Tr.error(e)}}this.Ar=[]}},yre=class{constructor(e){this.Kr=()=>{this.Yr||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.Yr.lastScrollY=Math.ceil(t),this.Yr.maxScrollY=Math.max(t,this.Yr.maxScrollY??0),this.Yr.maxScrollHeight=Math.max(n,this.Yr.maxScrollHeight??0),this.Yr.lastContentY=r,this.Yr.maxContentY=Math.max(r,this.Yr.maxContentY??0),this.Yr.maxContentHeight=Math.max(i,this.Yr.maxContentHeight??0)},this._instance=e}get Xr(){return this._instance.config.scroll_root_selector}getContext(){return this.Yr}resetContext(){var e=this.Yr;return setTimeout(this.Kr,0),e}startMeasuringScrollPosition(){zi(Nt,`scroll`,this.Kr,{capture:!0}),zi(Nt,`scrollend`,this.Kr,{capture:!0}),zi(Nt,`resize`,this.Kr)}scrollElement(){if(!this.Xr)return Nt?.document.documentElement;for(var e of cn(this.Xr)?this.Xr:[this.Xr]){var t=Nt?.document.querySelector(e);if(t)return t}}ti(e){var t=e===`y`?`scrollTop`:`scrollLeft`;if(this.Xr){var n=this.scrollElement();return n&&n[t]||0}return Nt?e===`y`?Nt.scrollY||Nt.pageYOffset||Nt.document.documentElement.scrollTop||0:Nt.scrollX||Nt.pageXOffset||Nt.document.documentElement.scrollLeft||0:0}scrollY(){return this.ti(`y`)}scrollX(){return this.ti(`x`)}},bre=e=>Rne(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),xre=class{constructor(e,t,n,r){this.ei=e=>{var t=this.ri();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.ii(this._instance)};this.ni.register({[ui]:n})}},this._instance=e,this.si=t,this.ni=n,this.ii=r||bre,this.si.onSessionId(this.ei)}ri(){return this.ni.props[ui]}getSetOnceProps(){var e=this.ri()?.props;return e?`r`in e?zne(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return Pi(Ri(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+rn(n)]=t})),e}},io=class{constructor(){this.oi={}}on(e,t){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(t),()=>{this.oi[e]=this.oi[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.oi[e]||[])n(t);for(var r of this.oi[`*`]||[])r(e,t)}},ao=Er(`[SessionId]`),Sre=class{on(e,t){return this.ai.on(e,t)}constructor(e,t,n){var r;if(this.li=null,this.ui=[],this.hi=void 0,this.di=!1,this.ai=new io,this.ci=(e,t)=>!(!vn(e)||!vn(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===Ci)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Se=e.config,this.ni=e.persistence,this.vi=void 0,this.fi=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.pi=t||Hi,this.gi=n||Hi;var i=this.Se.persistence_name||this.Se.token;if(this._sessionTimeoutMs=1e3*wn(this.Se.session_idle_timeout_seconds||1800,60,36e3,ao.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.mi(),this.yi=`ph_`+i+`_window_id`,this.bi=`ph_`+i+`_primary_window_exists`,this.wi()){var a=Yi.D(this.yi),o=Yi.D(this.bi);a&&!o?this.vi=a:Yi.P(this.yi),Yi.q(this.bi,!0)}if((r=this.Se.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Se.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.xi(this.Se.bootstrap.sessionID,new Date().getTime(),s)}catch(e){ao.error(`Invalid sessionID in bootstrap`,e)}this.ki()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return fn(this.ui)&&(this.ui=[]),this.ui.push(e),this.fi&&e(this.fi,this.vi),()=>{this.ui=this.ui.filter((t=>t!==e))}}wi(){return this.Se.persistence!==`memory`&&!this.ni.sr&&Yi.N()}Si(e){e!==this.vi&&(this.vi=e,this.wi()&&Yi.q(this.yi,e))}Ci(){return this.vi?this.vi:this.wi()?Yi.D(this.yi):null}Ii(e){var t=this.li;return!hn(t)&&!hn(e)&&5e3>Math.abs(e-t)}xi(e,t,n){var r=t!==this._sessionActivityTimestamp,i=!(e!==this.fi||n!==this._sessionStartTimestamp);this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.fi=e,i&&!r||i&&this.Ii(t)||(this.li=t,this.ni.register({[Ur]:[t,e,n]}))}Ti(){var e=this.Se?.persistence_save_debounce_ms;return vn(e)&&e>0}Mi(){this.Ti()?this.ni.refreshKey(Ur):(this.ni.flush(),this.ni.load())}Ei(){if(!hn(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.li){this.Mi();var e=this.Ri();e[1]===this.fi&&e[2]===this._sessionStartTimestamp&&(this.li=this._sessionActivityTimestamp,this.ni.register({[Ur]:[this._sessionActivityTimestamp,this.fi??null,this._sessionStartTimestamp]}),this.ni.flush())}}Pi(){var e=this.Ri()[0],t=vn(e)?e:0,n=vn(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}Oi(e){return this.Mi(),this.ci(e,this.Pi())}Ri(){var e=this.ni.props[Ur];return cn(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.li=null,clearTimeout(this.Fi),this.Fi=void 0,this.xi(null,null,null)}destroy(){this.di=!0,this.Ei(),clearTimeout(this.Fi),this.Fi=void 0,this.hi&&Nt&&(Nt.removeEventListener(Oi,this.hi,{capture:!1}),this.hi=void 0),this.ui=[]}ki(){this.hi=()=>{this.Ei(),this.wi()&&Yi.P(this.bi)},zi(Nt,Oi,this.hi,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Se.cookieless_mode===Ci)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),r=this.Ri(),i=r[1],a=r[2],o=this.Pi(),s=this.Ci(),c=vn(a)&&Math.abs(n-a)>864e5,l=!1,u=!1,d=!i,f=i,p=!d&&!e&&this.ci(n,o);if(p){(p=this.Oi(n))||ao.info(`cross-tab refresh kept the session alive`,{sessionId:i});var m=this.Ri();i=m[1],a=m[2]}d||p||c?(i=this.pi(),s=this.gi(),ao.info(`new session ID generated`,{sessionId:i,windowId:s,changeReason:{noSessionId:d,activityTimeout:p,sessionPastMaximumLength:c}}),a=n,l=!0):(s||(s=this.gi(),l=!0),(u=i!==f)&&(ao.info(`adopted cross-tab session id`,{sessionId:i,windowId:s}),l=!0));var h=vn(o)&&e&&!c?o:n,g=vn(a)?a:new Date().getTime();this.Si(s),this.xi(i,h,g),e||this.mi();var _={noSessionId:d,activityTimeout:p,sessionPastMaximumLength:c,crossTabAdoption:u};return l&&this.ui.forEach((e=>e(i,s,_))),{sessionId:i,windowId:s,sessionStartTimestamp:g,changeReason:l?_:void 0,lastActivityTimestamp:o}}mi(){this.di||(clearTimeout(this.Fi),this.Fi=setTimeout((()=>{if(!this.di)if(this.Oi(new Date().getTime())){var e=this.fi;this.resetSessionId(),this.ai.emit(`forcedIdleReset`,{idleSessionId:e})}else this.mi()}),1.1*this.sessionTimeoutMs))}},Cre=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&en(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>en(e?.brand,t))))return!0}catch{}return!!e.webdriver};function wre(){return(wre=Wt((function*(){var e=Ft?.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=(yield e.getHighEntropyValues([`model`]))?.model;return pn(t)&&t.length>0?t:void 0}catch(e){Tr.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}}))).apply(this,arguments)}var oo=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function Tre(e,t,n){return $a({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Ere={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>oo(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!oo(t,e))))),icontains:(e,t)=>t.map(so).some((t=>e.map(so).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(so).every((t=>e.map(so).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},so=e=>e.toLowerCase();function Dre(e,t){return!e||Object.entries(e).every((e=>{var n=e[1],r=t?.[e[0]];if(fn(r)||hn(r))return!1;var i=[String(r)],a=Ere[n.operator];return!!a&&a(n.values,i)}))}var co=`custom`,lo=`i.posthog.com`,Ore=/^\/static\//,kre=class{constructor(e){this.Li={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+lo,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.Li[this.apiHost]||(this.Li[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:co),this.Li[this.apiHost]}Ai(e){if(Ore.test(e)){var t=this.instance.config.asset_host;if(typeof t==`string`)return t.trim().replace(/\/$/,``)||void 0}}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.Ai(t);if(n)return``+n+t}if(this.region===co)return this.apiHost+t;var r=lo+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}};function uo(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var fo=Er(`[Surveys]`),po=`seenSurvey_`,mo=e=>{try{var t=(e=>((e,t)=>``+po+function(e){return e.current_iteration&&e.current_iteration>0?e.id+`_`+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){fo.error(`Failed to persist survey seen state`,e)}},Are=[wa.Popover,wa.Widget,wa.API],jre={ignoreConditions:!1,ignoreDelay:!1,displayType:Da.Popover},Mre=Er(`[PostHog ExternalIntegrations]`),Nre={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},Pre=class{constructor(e){this._instance=e}Ue(e,t){var n;(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return Mre.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(){var t,r,i,a=n[0],o=n[1];!o||(t=Ht.__PosthogExtensions__)!=null&&(t=t.integrations)!=null&&t[a]||e.Ue(Nre[a],(()=>{var t;(t=Ht.__PosthogExtensions__)==null||(t=t.integrations)==null||(t=t[a])==null||t.start(e._instance)})),!o&&(r=Ht.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]&&((i=Ht.__PosthogExtensions__)==null||(i=i.integrations)==null||(i=i[a])==null||i.stop())};for(var n of Object.entries((r=this._instance.config.integrations)??{})){var r;t()}}},ho={},go=0,_o=()=>{},vo=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,yo=`Surveys module not available`,bo=`sanitize_properties is deprecated. Use before_send instead`,xo=`Invalid value for property_denylist config: `,So=`posthog`,Co=!sre&&Vt?.indexOf(`MSIE`)===-1&&Vt?.indexOf(`Mozilla`)===-1,wo=e=>{var t;return Gt({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:Ite(It?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:_o,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Lt&&pn(Lt?.search)&&Lt.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:(Nt==null||(t=Nt.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){Tr.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ei,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:ro},error_tracking:{},_onCapture:_o},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:rne,ignore_text_selection:!0}:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2026-06-25`?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:e&&e>=`2026-05-30`?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>=`2026-05-30`?250:0,split_storage:!(!e||`2026-05-30`>e),detect_google_search_app:!(!e||`2026-05-30`>e),disable_capture_url_hashes:!(!e||`2026-06-25`>e)}))(e))},Fre=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`__preview_disable_beacon`,`disable_beacon`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],To=e=>{var t={};for(var n of Fre){var r=n[0],i=n[1];fn(e[r])||(t[i]=e[r])}var a=Fi({},t,e),o=e.__preview_external_dependency_versioned_paths;return fn(o)||(fn(e.strict_script_versioning)&&(a.strict_script_versioning=!!o),pn(o)&&fn(e.asset_host)&&(a.asset_host=o)),cn(e.property_blacklist)&&(fn(e.property_denylist)?a.property_denylist=e.property_blacklist:cn(e.property_denylist)?a.property_denylist=[...e.property_blacklist,...e.property_denylist]:Tr.error(xo+e.property_denylist)),a},Ire=class{constructor(){this.__forceAllowLocalhost=!1}get $i(){return this.__forceAllowLocalhost}set $i(e){Tr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Eo=class e{Ni(e,t){if(e){var n=this.Di.indexOf(e);n!==-1&&this.Di.splice(n,1)}return this.Di.push(t),t.initialize==null||t.initialize(),t}qi(){return this.config.cookieless_mode===Ci||this.config.cookieless_mode===Si&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new Ire,this.ji=!1,this.version=Ut.LIB_VERSION,this.Hi=new io,this.Di=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=wo(),this.SentryIntegration=Tne,this.sentryIntegration=e=>function(e,t){var n=wne(e,t);return{name:Cne,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Bi=!1,this.Ui=null,this.zi=null,this.Vi=null,this.scrollManager=new yre(this),this.pageViewManager=new Ene(this),this.rateLimiter=new qne(this),this.requestRouter=new kre(this),this.consent=new Gte(this),this.externalIntegrations=new Pre(this);var t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.metrics=t.metrics&&new t.metrics(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{var r=pn(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=pn(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>Tr.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==So){var i=ho[r]??new e;return i._init(t,n,r),ho[r]=i,ho[So][r]=i,i}return this._init(t,n,r)}_init(e,t,n){var r;t===void 0&&(t={});var i=pn(e)?e.trim():``;if(!i)return Tr.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`),this;this.__loaded=!0,this.config={},t.debug=this.Wi(t.debug),this.Zi=t,this.Gi=[],t.person_profiles?this.zi=t.person_profiles:t.process_person&&(this.zi=t.process_person);var a=wo(t.defaults),o=To(t),s=Fi({},a,o,{name:n,token:i});un(a.rageclick)&&un(o.rageclick)&&(s.rageclick=Fi({},a.rageclick,o.rageclick)),un(a.session_recording)&&un(o.session_recording)&&(s.session_recording=Fi({},a.session_recording,o.session_recording)),this.set_config(s),this.config.on_xhr_error&&Tr.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:ka.GZipJS;var c=this.Qi();this.persistence=new Sa(this.config,c),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Sa(Gt({},this.config,{persistence:`sessionStorage`}),c,!1);var l=Gt({},this.persistence.props),u=Gt({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ji=new gre((e=>this.Ki(e)),this.config.request_queue_config),this.Yi=new vre(this),this.__request_queue=[];var d=this.qi();if(d||(this.sessionManager=new Sre(this),this.sessionPropsManager=new xre(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(Tr.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.Xi(d)}),0)):(Tr.info(`Initializing extensions synchronously`),this.Xi(d)),Ut.DEBUG=Ut.DEBUG||this.config.debug,Ut.DEBUG&&Tr.info(`Starting in debug mode`,{this:this,config:t,thisC:Gt({},this.config),p:l,s:u}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=Gt({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),t.bootstrap?.distinctID!==void 0){var f=t.bootstrap.distinctID,p=this.get_distinct_id(),m=this.persistence.get_property(li);if(t.bootstrap.isIdentifiedID&&p!=null&&p!==f&&m===wi)this.identify(f);else if(t.bootstrap.isIdentifiedID&&p!=null&&p!==f&&m===Ti)Tr.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var h=this.config.get_device_id(Hi()),g=t.bootstrap.isIdentifiedID?h:f;this.persistence.set_property(li,t.bootstrap.isIdentifiedID?Ti:wi),this.register({distinct_id:f,$device_id:g})}}if(d)this.register_once({distinct_id:_i,$device_id:null},``);else if(!this.get_distinct_id()){var _=this.config.get_device_id(Hi());this.register_once({distinct_id:_,$device_id:_},``),this.persistence.set_property(li,wi)}return zi(Nt,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||Hi();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(li,Ti)),t()},i=n.user();`then`in i&&ln(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{typeof Promise<`u`&&Promise.resolve||ua.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(ua.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(ua.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,ki),identify:e=>t(e,ji),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.tn())):this.tn(),ln(this.config._onCapture)&&this.config._onCapture!==_o&&(Tr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Tr.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return wre.apply(this,arguments)}().then((e=>{e&&this.register({[Ar]:e})})).catch(_o),this}Xi(t){var n=performance.now(),r=Gt({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Di.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Di.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Di.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Di.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.Di.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Di.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Di.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Di.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Di.push(this.logs=this.logs??new r.logs(this)),r.metrics&&this.Di.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this.Di.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Di.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Di.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Di.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Di.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Di.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,xne)),r.toolbar&&this.Di.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Di.push(this.experiments=this.experiments??new r.experiments(this)),this.Di.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.en){var e=this.en;this.en=void 0,this.Rr(e)}})),this.rn(i,n)}rn(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.rn(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){Tr.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({[vi]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[yi]:r}),this.config.__preview_deferred_init_extensions&&Tr.info(`PostHog extensions initialized (`+r+`ms)`)}Rr(e){var t;if(!It||!It.body)return Tr.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Rr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.en=e),this.nn=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=tn(e.supportedCompression,ka.GZipJS)?ka.GZipJS:tn(e.supportedCompression,ka.Base64)?ka.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.zi?this.zi:Ei}),this.Di.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}tn(){try{this.config.loaded(this)}catch(e){Tr.critical("`loaded` function failed",e)}if(this.sn(),this.config.internal_or_test_user_hostname&&Lt!=null&&Lt.hostname){var e=Lt.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.qi())&&this.an()}),1),this.ln=new Jne(this),this.ln.load()}sn(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ji)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Ni(this.__request_queue,(e=>this.Ki(e))),this.__request_queue=[],this.sn()}_handle_unload(){var e,t,n,r,i;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(t=this.metrics)==null||t.flush(`sendBeacon`),this.config.request_batching?(this.un()&&this.capture(Ai),(n=this.logs)==null||n.flushLogs(`sendBeacon`),(r=this.Ji)==null||r.unload(),(i=this.Yi)==null||i.unload()):this.un()&&this.capture(Ai,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded?Co?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=Gt({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,(fn(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=Gt({},e);t.timeout=t.timeout||6e4;var n=t.transport??`fetch`;n===`sendBeacon`&&fn(t.compression)&&t.data&&(t.compression=ka.Base64),t.url=hre(t.url,t.compression);var r=no.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),i=function(e,t){for(var r=0;e.length>r;r++)if(e[r].transport===n)return e[r]}(r)?.method??r[0].method;if(!i)throw Error(`No available transport method`);n!==`sendBeacon`&&t.data&&t.compression===ka.GZipJS&&oee&&typeof Promise<`u`&&!Xa?dre(t).then((e=>{i(e)})).catch((n=>{if(gee(n))return Xa=!0,void i(Gt({},t,{compression:void 0,url:hre(e.url,void 0)}));(e=>{if(!e||typeof e!=`object`)return!1;var t=`name`in e?String(e.name):``;return gee(e)||t===mee})(n)&&(Xa=!0),i(t)})):i(t)})(Gt({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}Ki(e){this.Yi?this.Yi.retriableRequest(e):this._send_request(e)}_execute_array(e){go++;try{var t,n=[],r=[],i=[];Ni(e,(e=>{if(e)if(cn(t=e[0]))i.push(e);else if(ln(e))try{e.call(this)}catch(t){Tr.error(`Error executing queued PostHog call`,e,t)}else cn(e)&&t===`alias`?n.push(e):cn(e)&&t.indexOf(`capture`)!==-1&&ln(this[t])?i.push(e):r.push(e)}));var a=function(e,t){Ni(e,(function(e){try{if(cn(e[0])){var n=t;Pi(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){Tr.error(`Error executing queued PostHog call`,e,t)}}))};a(n,this),a(r,this),a(i,this)}finally{go--}}push(t){if(go>0&&cn(t)&&pn(t[0])){var n=e.prototype[t[0]];ln(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ji){if(this.is_capturing())if(!fn(e)&&pn(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!pn(t?.$current_url)&&(Tr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.hn||Tr.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=Kee(n?.uuid,Hi),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===ki&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(f.$set=n?.$set);var p=n?.$unset;p&&(f.$unset=p);var m,h,g,_=this.dn(n?.$set_once,e!==Mi,e===ji);if(_&&(f.$set_once=_),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>pn(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){return t===Object(t)?o.has(t)?void 0:(o.add(t),cn(t)?(r=[],Ni(t,(t=>{r.push(e(t))}))):(r={},Pi(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,fn(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===Ta.DISMISSED||e===Ta.SENT){var v=t?.[Ea.SURVEY_ID],y=t?.[Ea.SURVEY_ITERATION];mo({id:v,current_iteration:y}),f.$set=Gt({},f.$set,{[(m={id:v,current_iteration:y},h=e===Ta.SENT?`responded`:`dismissed`,g=`$survey_`+h+`/`+m.id,m.current_iteration&&m.current_iteration>0&&(g=`$survey_`+h+`/`+m.id+`/`+m.current_iteration),g)]:!0})}else e===Ta.SHOWN&&(f.$set=Gt({},f.$set,{[Ea.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Wne.SHOWN){var b=t?.[Gne.TOUR_TYPE];b&&(f.$set=Gt({},f.$set,{[Gne.TOUR_LAST_SEEN_DATE+`/`+b]:new Date().toISOString()}))}var x=Gt({},f.properties.$set,f.$set);if(dn(x)||this.setPersonPropertiesForFlags(x),!gn(this.config.before_send)){var S=this.Rt(f);if(!S)return;(f=S).uuid=Kee(f.uuid,Hi)}this.Hi.emit(`eventCaptured`,f);var C={method:`POST`,url:n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),data:f,compression:`best-available`,batchKey:n?._batchKey,transport:n?.transport};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Ki(C):this.Ji.enqueue(C),f}Tr.critical(`This capture call is ignored due to client rate limiting.`)}}else Tr.error(`No event name provided to posthog.capture`)}else Tr.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),o=Gt({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.qi()&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=Gt({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!pn(o.distinct_id)&&!_n(o.distinct_id)||mn(o.distinct_id))&&Tr.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}var c,l=function(e,t,n,r){var i,a,o;if(r===void 0&&(r=!1),!Vt)return{};var s,c,l,u,d,f=e?[...va,...t||[]]:[],p=function(e){for(var t=0;Uee.length>t;t++){var n=Uee[t],r=n[1],i=n[0].exec(e),a=i&&(ln(r)?r(i,e):r);if(a)return a}return[``,``]}(Vt),m=(s=typeof navigator<`u`?navigator:void 0)!=null&&s.brave?{brave:!0}:{},h={detectGoogleSearchApp:n},g=Fi(Ri({$os:p[0],$os_version:p[1],$browser:Bee(Vt,navigator.vendor,m,h),$device:Wee(Vt),$device_type:(l=Vt,u={userAgentDataPlatform:(i=navigator)==null||(i=i.userAgentData)==null?void 0:i.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:Nt==null||(a=Nt.screen)==null?void 0:a.width,screenHeight:Nt==null||(o=Nt.screen)==null?void 0:o.height,devicePixelRatio:Nt?.devicePixelRatio},d=Wee(l),d===Dee||d===Eee||d===`Kobo`||d===`Kindle Fire`||d===$n?On:d===Un||d===Gn||d===Wn||d===Zn?`Console`:d===kee?`Wearable`:d?Tn:u?.userAgentDataPlatform===`Android`&&(u?.maxTouchPoints??0)>0?600>Math.min(u?.screenWidth??0,u?.screenHeight??0)/(u?.devicePixelRatio??1)?Tn:On:`Desktop`),$timezone:Bne(),$timezone_offset:Vne()}),{$current_url:ha(r?ur(Lt?.href):Lt?.href,f,ya),$host:Lt?.host,$pathname:Lt?.pathname,$raw_user_agent:Vt.length>1e3?Vt.substring(0,997)+`...`:Vt,$browser_version:Hee(Vt,navigator.vendor,m,h),$browser_language:Ine(),$browser_language_prefix:(c=Ine(),typeof c==`string`?c.split(`-`)[0]:void 0),$screen_height:Nt?.screen.height,$screen_width:Nt?.screen.width,$viewport_height:Nt?.innerHeight,$viewport_width:Nt?.innerWidth,$lib:Ut.LIB_NAME,$lib_version:Ut.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ut.SDK_DIST_CHANNEL&&(g.$sdk_dist_channel=Ut.SDK_DIST_CHANNEL),g}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var u=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime()),d=u.windowId;o.$session_id=u.sessionId,o.$window_id=d}this.sessionPropsManager&&Fi(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&Fi(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Yi?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===co&&(o.$lib_custom_api_host=this.config.api_host),c=e!==ki||i?e!==Ai||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=Fi(o,c),e===ki&&It&&(o.title=It.title),!fn(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}Vt&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=Fi({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),cn(this.config.property_denylist)?Pi(this.config.property_denylist,(function(e){delete o[e]})):Tr.error(xo+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(Tr.error(bo),o=p(o,e));var m=this.cn();return o.$process_person_profile=m,m&&!i&&this.vn(`_calculate_event_properties`),o}dn(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.cn()||this.ji&&!n)return e;var r=Fi({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(Tr.error(bo),r=i(r,`$set_once`)),t&&(this.ji=!0),dn(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}fn(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}getAllFeatureFlags(){return this.featureFlags?.getAllFeatureFlags()??[]}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Hi.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:yo}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:yo})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:yo})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=jre),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:yo}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:yo})}pn(e){return!e||mn(e)?(Tr.critical(`Unique user id has not been set in posthog.identify`),!1):e===_i?(Tr.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(Tr.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return Tr.uninitializedWarning(`posthog.identify`);if(_n(e)&&(e=e.toString(),Tr.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.pn(e)&&this.vn(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(kr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(jr)&&(this.unregister(jr),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(li)||wi)===wi;e!==r&&a?(this.persistence.set_property(li,Ti),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(ji,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Vi=Tre(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(ai))}}setPersonProperties(e,t){if((e||t)&&this.vn(`posthog.setPersonProperties`)){var n=Tre(this.get_distinct_id(),e,t);this.Vi===n?Tr.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Vi=n)}}unsetPersonProperties(e){var t,n=(cn(e)?e:[e]).filter((e=>pn(e)&&e.length>0));n.length!==0&&this.vn(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this.Vi=null)}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Gt({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Mi,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else Tr.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;e===void 0&&(e=!0),(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.vn(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c,l,u;if(Tr.info(`reset`),!this.__loaded)return Tr.uninitializedWarning(`posthog.reset`);var d,f=this.get_property(kr),p=this.get_property(Ar),m=this.get_property(Hr);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),fn(m)||(d=this.persistence)==null||d.register({[Hr]:m}),(r=this.surveys)==null||r.reset(),(i=this.ln)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.logs)==null||s.reset(),(c=this.metrics)==null||c.reset(),(l=this.persistence)==null||l.set_property(li,wi),(u=this.sessionManager)==null||u.resetSessionId(),this.Vi=null,this.config.cookieless_mode===Ci)this.register_once({distinct_id:_i,$device_id:null},``);else{var h=this.config.get_device_id(Hi());this.register_once({distinct_id:h,$device_id:e?h:f},``),e||fn(p)||this.register({[Ar]:p})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var t=this;return Wt((function*(){var e,n,r,i,a;t.__loaded?((e=t.logs)==null||e.flushLogs(`sendBeacon`),(n=t.metrics)==null||n.flush(`sendBeacon`),(r=t.Ji)==null||r.unload(),(i=t.Yi)==null||i.unload(),(a=t.featureFlags)==null||a.destroy()):Tr.uninitializedWarning(`posthog.shutdown`)}))()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.gn()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.mn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=t.sessionStartTimestamp,r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t.sessionId);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Or)?(Tr.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.vn(`posthog.alias`)?(fn(t)&&(t=this.get_distinct_id()),e===t?(Tr.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.fn(jr,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=Gt({},this.config);if(un(e)){var n,r,i,a,o,s,c,l,u,d,f;Fi(this.config,To(e));var p=this.Qi();(n=this.persistence)==null||n.update_config(this.config,t,p),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Sa(Gt({},this.config,{persistence:`sessionStorage`}),p,!1);var m=this.Wi(this.config.debug);yn(m)&&(this.config.debug=m),yn(this.config.debug)&&(this.config.debug?(Ut.DEBUG=!0,Ki.N()&&Ki.q(`ph_debug`,!0),Tr.info(`set_config`,{config:e,oldConfig:t,newConfig:Gt({},this.config)})):(Ut.DEBUG=!1,Ki.N()&&Ki.P(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(o=this.tracingHeaders)==null||o.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(u=this.deadClicksAutocapture)==null||u.startIfEnabledOrStop(),(d=this.surveys)==null||d.loadIfEnabled(),this.yn(),(f=this.externalIntegrations)==null||f.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Ut.LIB_NAME=e,Ut.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(Gt({},r,t))}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.bn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??So;return e!==So&&(e=So+`.`+e),e}_isIdentified(){return this.persistence?.get_property(li)===Ti||this.sessionPersistence?.get_property(li)===Ti}cn(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===Ei&&!this._isIdentified()&&dn(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[jr])&&((t=this.persistence)==null||(t=t.props)==null||!t[hi]))}un(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.cn()||this.vn(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.vn(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}vn(e){return this.config.person_profiles===`never`?(Tr.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.fn(hi,!0),!0)}Qi(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Si)}yn(){var e,t,n=this.Qi();return this.persistence?.sr!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.sr!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==Ci){if(this.qi()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Sre(this),this.pageViewManager=new Ene(this),this.persistence&&(this.sessionPropsManager=new xre(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.Ni(this.sessionRecording,new o(this)),this.nn&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.nn)))}var s;this.consent.optInOut(!0),this.yn(),this.sn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Si&&((s=this.surveys)==null||s.loadIfEnabled()),(fn(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.an()}else Tr.warn(vo)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===Ci?Tr.warn(vo):(this.config.cookieless_mode===Si&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.yn(),this.config.cookieless_mode===Si&&(this.register({distinct_id:_i,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.an(),this.sn()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===Ci||(this.config.cookieless_mode===Si?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.yn()}_is_bot(){return Ft?Cre(Ft,this.config.custom_blocked_useragents):void 0}an(){It&&(It.visibilityState===`visible`?this.Bi||(this.Bi=!0,this.capture(ki,{title:It.title},{send_instantly:!0}),this.Ui&&=(It.removeEventListener(Di,this.Ui),null)):this.Ui||(this.Ui=this.an.bind(this),zi(It,Di,this.Ui)))}debug(e){!1===e?(Nt?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(Nt?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Or(){var e,t,n,r,i,a,o=this.Zi||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(Tr.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):(n=`advanced_disable_decide`,r=Tr,i=(t=`advanced_disable_flags`)in(e=o)&&!gn(e[t]),a=n in e&&!gn(e[n]),i?e[t]:!!a&&(r&&r.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])):!!this.config.advanced_disable_flags}Rt(e){if(gn(this.config.before_send))return e;var t=Object.keys(e.properties??{}).filter(See),n=cn(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),gn(r)){var a=`Event '`+e.event+`' was rejected in beforeSend function`;return xee(e.event)?Tr.warn(a+`. This can cause unexpected behavior.`):Tr.info(a),null}r.properties&&!dn(r.properties)||Tr.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}for(var o of t)if(r.properties&&gn(r.properties[o]))return Tr.warn(`Event '`+e.event+`' had its '`+o+`' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){return this.pageViewManager.We?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Wi(e){var t=yn(e)&&!e,n=Ki.N()&&Ki.A(`ph_debug`)===`true`;return!t&&(!!n||e)}};Eo.__defaultExtensionClasses={},Eo.bn=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Pte(e.prototype[t[n]])}(Eo,[`identify`]);var Do=class{constructor(e){this.disabled=!1===e;var t=un(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},Oo=`$copy_autocapture`,ko=Er(`[AutoCapture]`);function Ao(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Lre(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Qi(t));return t}function Rre(e,t){var n,r=t.e,i=t.maskAllElementAttributes,a=t.maskAllText,o=t.elementAttributeIgnoreList,s=t.elementsChainAsString,c=t.disableCaptureUrlHashes;if(!Qi(e))return{props:{}};for(var l=[e],u=new Set([e]),d=e;d.parentNode&&!$i(d,`body`)&&Zte>l.length;)if(Xte(d.parentNode)){var f=d.parentNode.host;if(u.has(f))break;u.add(f),l.push(f),d=f}else{if(!Qi(d.parentNode)||u.has(d.parentNode))break;u.add(d.parentNode),l.push(d.parentNode),d=d.parentNode}var p,m,h=[],g={},_=!1,v=!1;if(Pi(l,(e=>{var t=sa(e);if($i(e,`a`)){var n=e.getAttribute(`href`);_=!!(t&&n&&ca(n))&&(c?ur(n):n)}tn(ta(e),`ph-no-capture`)&&(v=!0),h.push(function(e,t,n,r,i){i===void 0&&(i=!1);var a=e.tagName.toLowerCase(),o={tag_name:a};ia.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?Ao(1024,gne(e)):Ao(1024,na(e)));var s=ta(e);s.length>0&&(o.classes=s.filter((function(e){return e!==``}))),Pi(e.attributes,(function(n){var a;if((!lne(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&ca(n.value)&&(!pn(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){var s=n.value;n.name===`class`&&(s=ea(s).join(` `)),o[`attr__`+n.name]=Ao(1024,n.name===`href`&&i?ur(s):s)}}));for(var c=1,l=1,u=e;u=Lre(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,i,a,o,c)),Fi(g,function(e){if(!sa(e))return{};var t={};return Pi(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&ca(r)&&(t[n]=r)}})),t}(e))})),v)return{props:{},explicitNoCapture:v};if(a||(h[0].$el_text=$i(e,`a`)||$i(e,`button`)?gne(e):na(e)),_){var y;h[0].attr__href=_;var b=pa(_)?.host,x=Nt==null||(y=Nt.location)==null?void 0:y.host;b&&x&&b!==x&&(p=_)}return{props:Fi({$event_type:r.type,$ce_version:1},s?{}:{$elements:h},{$elements_chain:(m=h,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=Gt({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Ii(r).sort(((e,t)=>e[0].localeCompare(t[0]))).forEach((e=>{var t=e[1];return i[vne(e[0].toString())]=vne(t.toString())})),(t+=`:`)+Ii(i).map((e=>e[0]+`="`+e[1]+`"`)).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:yne(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Ii(e).filter((e=>e[0].indexOf(`attr__`)===0)).forEach((e=>t.attributes[e[0]]=e[1])),t}))}(m)))},(n=h[0])!=null&&n.$el_text?{$el_text:h[0]?.$el_text}:{},p&&r.type===`click`?{$external_click_url:p}:{},g)}}var jo=Er(`[ExceptionAutocapture]`),Mo=()=>{},zre=Er(`[TracingHeaders]`),No=Er(`[Web Vitals]`),Po=9e5,Fo=`disabled`,Bre=`lazy_loading`,Io=`awaiting_config`,Lo=`missing_config`;Er(`[SessionRecording]`),Er(`[SessionRecording]`);var Ro=`[SessionRecording]`,zo=Er(Ro),Vre=Er(`[Heatmaps]`);function Hre(e){return un(e)&&`clientX`in e&&`clientY`in e&&_n(e.clientX)&&_n(e.clientY)}var Bo=Er(`[Product Tours]`),Vo=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(Br))},Ure=[`$set_once`,`$set`],Ho=Er(`[SiteApps]`),Wre=`Error while initializing PostHog app with config id `;function Uo(e,t,n){if(gn(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Gre=class{constructor(e){this._n=new io,this.wn=(e,t)=>this.xn(e,t)&&this.kn(e,t)&&this.Sn(e,t)&&this.Cn(e,t),this.xn=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.In=new Set,this.Tn=new Set}init(){var e;fn(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!fn(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.Tn)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.In)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.In.has(e)||this.In.has(t?.event))&&this.Tn&&this.Tn?.size>0&&this.Tn.forEach((e=>{this.Mn(t,e)&&this._n.emit(`actionCaptured`,e.name)}))}En(e){this.onAction(`actionCaptured`,(t=>e(t)))}Mn(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.wn(e,n))return!0;return!1}onAction(e,t){return this._n.on(e,t)}kn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!Uo(r,t.url,t.url_matching||`contains`))return!1}return!0}Sn(e,t){return!!this.Rn(e,t)&&!!this.Pn(e,t)&&!!this.On(e,t)}Rn(e,t){var n;if(t==null||!t.href)return!0;var r=this.Fn(e);if(r.length>0)return r.some((e=>Uo(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&Uo((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}Pn(e,t){var n;if(t==null||!t.text)return!0;var r=this.Fn(e);if(r.length>0)return r.some((e=>Uo(e.text,t.text,t.text_matching||`exact`)||Uo(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!gn(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>Uo(e,a,o))))}On(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}Fn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Cn(e,t){return t==null||!t.properties||t.properties.length===0||Dre(t.properties.reduce(((e,t)=>{var n=cn(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},Kre=class{constructor(e){this.Ln=[],this._instance=e,this.An=new Map,this.$n=new Map,this.Nn=new Map}Dn(e,t){return!!e&&Dre(e.propertyFilters,t?.properties)}qn(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}jn(e,t,n){var r=(n===Ca.Activation?this.An:this.$n).get(e),i=[];return this.Hn((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Dn(a,t)}))}register(e){fn(this._instance?._addCaptureHook)||(this.Bn(e),this.Un(e))}Un(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.zn??(this.zn=new Gre(this._instance),this.zn.init(),this.zn.En((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.zn)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.Nn.get(t.name);n&&n.push(e.id),this.Nn.set(t.name,n||[e.id])}})))})))}Bn(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this.An=this.qn(e,Ca.Activation),this.$n=this.qn(e,Ca.Cancellation))}onEvent(e,t){var n,r,i=this.Vn(),a=(t==null||(n=t.properties)==null?void 0:n.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var o=this.Wn(e,a);if(o===`consume`)return i.info(`event consumed activated item, removing it`,{event:e,itemId:a}),void this.Zn([a]);if(o===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),void this.Gn(a)}if(this.$n.has(e)){var s=this.jn(e,t,Ca.Cancellation);s.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:s.map((e=>e.id))}),this.Zn(s.map((e=>e.id))),s.forEach((e=>this.Qn(e.id))))}if(this.An.has(e)){i.info(`event name matched`,{event:e,eventPayload:t,items:this.An.get(e)});var c=this.jn(e,t,Ca.Activation);this.Jn(c.map((e=>e.id)))}}onAction(e){this.Nn.has(e)&&this.Jn(this.Nn.get(e)||[])}Jn(e){e.length!==0&&(this.Ln=[...new Set([...this.Ln,...e])],this.Vn().info(`updating activated items`,{activatedItems:this.getActivatedIds()}))}Gn(e){this.Ln=this.Ln.filter((t=>t!==e));var t=this.Kn();t.includes(e)||this.Yn([...t,e])}Zn(e){var t=new Set(e);this.Ln=this.Ln.filter((e=>!t.has(e)));var n=this.Kn(),r=n.filter((e=>!t.has(e)));r.length!==n.length&&this.Yn(r)}Kn(){var e,t=this.Xn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getActivatedIds(){return[...new Set([...this.Kn(),...this.Ln])].filter((e=>!this.ts(e)))}reset(){this.Ln=[],this.Kn().length>0&&this.Yn([])}getEventToItemsMap(){return this.An}es(){return this.zn}},qre=class extends Kre{constructor(e){super(e)}Xn(){return ri}rs(){return Ta.SHOWN}Hn(e){var t;(t=this._instance)==null||t.getSurveys(e)}Qn(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Vn(){return fo}Yn(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[ri]:e})}ts(){return!1}Wn(e,t){var n;return this.Hn((e=>{n=e.find((e=>e.id===t))})),!n||function(e){var t;return uo(e)&&!((t=e.conditions)==null||(t=t.events)==null||!t.repeatedActivation)||e.schedule===`always`}(n)?e===Ta.SHOWN?`consume`:`ignore`:e===Ta.SHOWN?`persist`:e===Ta.DISMISSED||e===Ta.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Wo=`SDK is not enabled or survey functionality is not yet loaded`,Jre=`Disabled. Not loading surveys.`,Yre=Nt!=null&&Nt.location?ga(Nt.location.hash,`__posthog`)||ga(location.hash,`state`):null,Xre=`_postHogToolbarParams`,Zre=Er(`[Toolbar]`),Go=Er(`[FeatureFlags]`),Ko=Er(`[FeatureFlags]`,{debugEnabled:!0}),qo=`" failed. Feature flags didn't load in time.`,Qre=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},$re=e=>{var t={};for(var n of Ii(e||{})){var r=n[1];r&&(t[n[0]]=r)}return t},Jo=Er(`[Error tracking]`),eie=`Refusing to render web experiment since the viewer is a likely bot`,tie={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>oo(t,e),not_regex:(e,t)=>!oo(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},nie=class e{get Se(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.ns(`retrieved web experiments from the server`),n.ss=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.ss&&(e.ns(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.ss)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);pn(i)&&t.variants[i]&&n.os(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.ls(o,n._instance)&&n.os(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.ns(eie);else if(!this.Se.disable_web_experiments){if(gn(this.ss))return this.ss=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.ns(`applying feature flags`,t),t.forEach((e=>{var t;if(this.ss&&(t=this.ss)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.ss?.get(e);n&&r!=null&&r.variants[n]&&this.os(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=ma(t?.search,`__experiment_id`),r=ma(t?.search,`__experiment_variant`);n&&r&&(e.ns(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.us(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Se.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Se.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.Se.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}us(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.ns(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.os(i[0].name,n,i[0].variants[n].transforms))}static ls(t,n){return!gn(t.conditions)&&e.hs(t,n)&&e.ds(t)}static hs(t,n){if(gn(t.conditions)||gn(t.conditions?.url))return!0;var r=e.getWindowLocation();if(r){var i,a=Xi(n,r.href);return(i=t.conditions)==null||!i.url||tie[t.conditions?.urlMatchType??`icontains`](t.conditions.url,a)}return!1}static getWindowLocation(){return Nt?.location}static ds(e){if(gn(e.conditions)||gn(e.conditions?.utm))return!0;var t=Nne();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static ns(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];Tr.info(`[WebExperiments] `+e,n)}os(t,n,r){this._is_bot()?e.ns(eie):n===`control`?e.ns(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.ns(`applying transform of variant `+n+` for experiment `+t+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return Ft&&this._instance?Cre(Ft,this.Se.custom_blocked_useragents):void 0}},Yo=Er(`[Conversations]`),Xo=`Conversations not available yet.`,rie=`console`,Zo={featureFlags:class{constructor(e){this.cs=!1,this.vs=!1,this.fs=!1,this.ps=!1,this.gs=!1,this.ys=!1,this.bs=!1,this._s=!1,this.ws=0,this.xs=()=>{var e=this.ks();this.ws=0,e&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],Nt&&zi(Nt,`online`,this.xs)}destroy(){Nt?.removeEventListener(`online`,this.xs)}get Se(){return this._instance.config}get ni(){return this._instance.persistence}Ss(e){return this._instance.get_property(e)}Cs(){var e;return(e=this.ni?.lr(this.Se.feature_flag_cache_ttl_ms))!=null&&e}Is(){return!!this.Cs()&&(this._s||this.fs||(this._s=!0,Go.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}Ts(){var e=this.Se.evaluation_contexts??this.Se.evaluation_environments;return!this.Se.evaluation_environments||this.Se.evaluation_contexts||this.bs||(Go.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.bs=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Go.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}Ms(){return this.Ts().length>0}Es(){var e=this.Se.flag_keys;if(!fn(e)){if(cn(e))return e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Go.error(`Invalid flag key found:`,e,`Expected non-empty string`),t}));Go.error(`Invalid flag_keys found:`,e,`Expected array of non-empty strings`)}}initialize(){var e=this._instance.config,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r,i,a=n!=null&&n.merge&&(r=this.Ss(Gr))!=null?r:{},o=n!=null&&n.merge&&(i=this.Ss(Yr))!=null?i:{},s=Gt({},a,e),c=Gt({},o,t),l={};for(var u of Object.entries(s)){var d=u[0],f=u[1];l[d]={key:d,enabled:qt(f),variant:Jt(f),reason:void 0,metadata:fn(c?.[d])?void 0:{id:0,version:void 0,description:void 0,payload:c[d]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this.vs}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Ss(Jr),t=this.Ss(Zr),n=this.Ss(Qr);if(!n&&!t)return e||{};var r=Fi({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=fn(c)?(a=s?.enabled)!=null&&a:!!c,u=fn(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=Gt({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=Gt({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.cs||=(Go.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((n=>{var r=e[n];return{key:n,enabled:qt(r),variant:Jt(r),payload:Kt(t[n])}}))}getFlagVariants(){var e=this.Ss(Gr),t=this.Ss(Zr);if(!t)return e||{};for(var n=Fi({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.cs||=(Go.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.Ss(Yr),t=this.Ss(Qr);if(!t)return e||{};for(var n=Fi({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.cs||=(Go.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.ps||this.Se.advanced_disable_feature_flags||this.ks()||this.Rs||(this._instance.Hi.emit(`featureFlagsReloading`,!0),this.Rs=setTimeout((()=>{this.Ps()}),5))}Os(){clearTimeout(this.Rs),this.Rs=void 0}ensureFlagsLoaded(){this.vs||this.fs||this.Rs||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ps=e}Ps(e){if(this.Os(),!this._instance.Or()&&!this.ks())if(this.fs)this.gs=!0;else{var t=this.Se.token,n=this.Ss(kr),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Gt({},this.ni?.get_initial_props()||{},this.Ss($r)||{}),group_properties:this.Ss(ei),timezone:Bne()};hn(n)||fn(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Se.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Ms()&&(r.evaluation_contexts=this.Ts());var i=this.Es();fn(i)||(r.flag_keys=i);var a=!!this.Se.advanced_only_evaluate_survey_feature_flags,o=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Se.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.fs=!0,this._instance._send_request({method:`POST`,url:o,data:r,compression:this.Se.disable_compression?void 0:ka.Base64,timeout:this.Se.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,o=!0;if(this.Fs(e.statusCode),e.statusCode===200&&(this.gs||(this.$anon_distinct_id=void 0),o=!1),this.fs=!1,!r.disable_flags||this.gs){this.ys=!o;var s=[];e.error?e.error instanceof Error?s.push(e.error.name===`AbortError`?`timeout`:`connection_error`):s.push(`unknown_error`):e.statusCode!==200&&s.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&s.push(`errors_while_computing_flags`);var c=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));c&&s.push(`quota_limited`),(i=this.ni)==null||i.register({[si]:s}),c?Go.warn(`You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},o,{partialResponse:a}),this.gs&&(this.gs=!1,this.Ps()))}}})}}ks(){return kne(this.ws,3)}Fs(e){this.ws=Ane(e,this.ws,3,(()=>Go.warn(`Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.`)))}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.ys)if(this.vs||this.getFlags()&&this.getFlags().length>0){if(!this.Is()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else Go.warn(`getFeatureFlag for key "`+e+qo)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.ys)if(this.vs||this.getFlags()&&this.getFlags().length>0){if(!this.Is()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Ss(Xr)||void 0,c=this.Ss(ci)||void 0,l=this.Ss(ai)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.Ss(oi);d&&d!==f&&(l={},(u=this.ni)==null||u.register({[ai]:l,[oi]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,y,b;cn(l[e])?l[e].push(o):l[e]=[o],(p=this.ni)==null||p.register({[ai]:l});var x=this.getFeatureFlagDetails(e),S=[...this.Ss(si)??[]];fn(i)&&S.push(`flag_missing`);var C={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.Se.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Se.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.ys};fn(x==null||(g=x.metadata)==null?void 0:g.version)||(C.$feature_flag_version=x.metadata.version);var w,T=(x==null||(_=x.reason)==null?void 0:_.description)??(x==null||(v=x.reason)==null?void 0:v.code);T&&(C.$feature_flag_reason=T),x!=null&&(y=x.metadata)!=null&&y.id&&(C.$feature_flag_id=x.metadata.id),fn(x?.original_variant)&&fn(x?.original_enabled)||(C.$feature_flag_original_response=fn(x.original_variant)?x.original_enabled:x.original_variant),x!=null&&(b=x.metadata)!=null&&b.original_payload&&(C.$feature_flag_original_payload=x==null||(w=x.metadata)==null?void 0:w.original_payload),S.length&&(C.$feature_flag_error=S.join(`,`)),this._instance.capture(`$feature_flag_called`,C)}if(r)return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:Kt(a)}}}else Go.warn(`getFeatureFlagResult for key "`+e+qo)}getRemoteConfigPayload(e,t){var n=this.Se.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.Ms()&&(r.evaluation_contexts=this.Ts());var i=this.Es();fn(i)||(r.flag_keys=i),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Se.disable_compression?void 0:ka.Base64,timeout:this.Se.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.ys){if(this.vs||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return fn(n)?void 0:!!n}Go.warn(`isFeatureEnabled for key "`+e+qo)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.ni){this.vs=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):e.featureFlags&&Go.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(cn(c)){Go.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[Kr]:c,[Gr]:f})}else{var m=c,h=l,g=s;if(a!=null&&a.partialResponse)m=Gt({},n,m),h=Gt({},r,h),g=Gt({},i,g);else if(e.errorsWhileComputingFlags)if(s){var _=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=Gt({},n,Object.fromEntries(Object.entries(m).filter((e=>_.has(e[0]))))),h=Gt({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>_.has(e[0]))))),g=Gt({},i,Object.fromEntries(Object.entries(g||{}).filter((e=>_.has(e[0])))))}else m=Gt({},n,m),h=Gt({},r,h),g=Gt({},i,g);t&&t.register(Gt({[Kr]:Object.keys($re(m)),[Gr]:m||{},[Yr]:h||{},[Jr]:g||{}},u?{[Xr]:u}:{},d?{[ci]:d}:{}))}}})(e,this.ni,r,i,a,n),t||(this._s=!1),this.Ls(t)}}override(e,t){t===void 0&&(t=!1),Go.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.ni)return Go.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.ni.unregister(Zr),this.ni.unregister(Qr),this.Ls(),Ko.info(`All overrides cleared`);if(cn(e)){var t=Qre(e);return this.ni.register({[Zr]:t}),this.Ls(),Ko.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.cs=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.ni.unregister(Zr),Ko.info(`Flag overrides cleared`);else if(r.flags){if(cn(r.flags)){var i=Qre(r.flags);this.ni.register({[Zr]:i})}else this.ni.register({[Zr]:r.flags});Ko.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.ni.unregister(Qr),Ko.info(`Payload overrides cleared`)):r.payloads&&(this.ni.register({[Qr]:r.payloads}),Ko.info(`Payload overrides set`,{payloads:r.payloads}))),this.Ls();return}if(e&&typeof e==`object`)return this.ni.register({[Zr]:e}),this.Ls(),Ko.info(`Flag overrides set`,{flags:e});Go.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.vs){var t=this.As(),n=t.flags,r=t.flagVariants;try{e(n,r)}catch(e){Go.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.Ss(qr)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=Gt({},this.getFlagVariants(),{[e]:t});(r=this.ni)==null||r.register({[Kr]:Object.keys($re(s)),[Gr]:s}),this.Ls()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Ss(qr),i=n?`&`+n.map((e=>`stage=`+e)).join(`&`):``;if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/early_access_features/?token=`+this.Se.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.ni)==null||n.unregister(qr),(r=this.ni)==null||r.register({[qr]:i}),e(i)}}})}As(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}Ls(e){var t=this.As(),n=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach((t=>{try{t(n,r,{errorsLoading:e})}catch(e){Go.error(`Error while running feature flags callback`,e)}}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Ss($r)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[$r]:Gt({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=Gt({},this.Ss($r)||{});e.forEach((e=>{delete n[e]})),this._instance.register({[$r]:n}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this._instance.unregister($r),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Ss(ei)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=Gt({},n[t],e[t]),delete e[t]})),this._instance.register({[ei]:Gt({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Ss(ei)||{};this._instance.register({[ei]:Gt({},t,{[e]:{}})})}else this._instance.unregister(ei)}reset(){this.vs=!1,this.fs=!1,this.ps=!1,this.gs=!1,this.ys=!1,this.$anon_distinct_id=void 0,this.Os(),this.cs=!1,this.ws=0}}},iie={sessionRecording:class{get Se(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var e;return!((e=this.$s)==null||!e.isStarted)}get status(){return this.Ns===Io||this.Ns===Lo?this.Ns:this.$s?.status??this.Ns}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ns=Fo,this.Ds=void 0,this._instance=e,!this._instance.sessionManager)throw zo.error(`started without valid sessionManager`),Error(Ro+` started without valid sessionManager. This is a bug.`);if(this.Se.cookieless_mode===Ci)throw Error(Ro+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get qs(){var e,t=!((e=this._instance.get_property(Hr))==null||!e.enabled),n=!this.Se.disable_session_recording,r=this.Se.disable_session_recording||this._instance.consent.isOptedOut();return Nt&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this.qs||(t=this.$s)==null||!t.isStarted){var n=!fn(Object.assign)&&!fn(Array.from);this.qs&&n?(this.js(e),zo.info(`starting`)):(this.Ns=Fo,this.stopRecording())}}js(e){var t,n,r;this.qs&&(this.Ns!==Io&&this.Ns!==Lo&&(this.Ns=Bre),Ht!=null&&(t=Ht.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=Ht.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Hs(e):(r=Ht.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.Bs,(t=>{if(t)return zo.error(`could not load recorder`,t);this.Hs(e)})))}stopRecording(){var e,t;(e=this.Ds)==null||e.call(this),this.Ds=void 0,(t=this.$s)==null||t.stop()}Us(){var e,t;(e=this.Ds)==null||e.call(this),this.Ds=void 0,(t=this.$s)==null||t.discard()}zs(){var e,t;(e=this.ni)==null||e.unregister(Wr),(t=this.ni)==null||t.unregister(kte)}Vs(e,t){if(gn(e))return null;var n,r=_n(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(zo.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}Ws(e){if(this.ni){var t,n=this.ni,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.Vs(this.Se.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.Vs(t?.sampleRate,`remote config sampleRate`),a=r??i;gn(a)&&this.zs();var o=t?.minimumDurationMilliseconds;n.register({[Hr]:Gt({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:Gt({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:fn(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.Ds)==null||t.call(this),this.Ds=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this.Ws(e),this.Us()):(this.Ws(e),this.startIfEnabledOrStop()):(this.Ns===Io&&(this.Ns=Lo,zo.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.$s)!=null&&n.log?this.$s.log(e,t):zo.warn(`log called before recorder was ready`)}get Bs(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Hr);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Zs(){var e,t=this._instance.get_property(Hr);if(!t)return!1;try{e=typeof t==`object`?t:JSON.parse(t)}catch(e){return zo.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}var n=e.cache_timestamp??Date.now();return 36e5>=Date.now()-n}Hs(e){var t;if((t=Ht.__PosthogExtensions__)==null||!t.initSessionRecording)return zo.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[bi]:!0});if(this.$s||(this.$s=Ht.__PosthogExtensions__?.initSessionRecording(this._instance),this.$s._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Zs()){if(this.Ns===Lo||this.Ns===Io)return;this.Ns=Io,zo.info(`persisted remote config is stale, requesting fresh config before starting`),new Jne(this._instance).load();return}this.Ns=Bre,this.$s.start(e)}onRRwebEmit(e){var t;(t=this.$s)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.$s||(t=this.ni)==null||t.register({[jte]:!0}),(e=this.$s)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.$s||(t=this.ni)==null||t.register({[Ate]:!0}),(e=this.$s)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.$s||(n=this.ni)==null||n.register({[e===`url`?Mte:Nte]:!0}),(t=this.$s)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.$s?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.$s)==null||!n.tryAddCustomEvent(e,t))}}},aie={autocapture:class{constructor(e){this.Gs=!1,this.Qs=null,this.Js=!1,this.instance=e,this.rageclicks=new Do(e.config.rageclick),this.Ks=null}initialize(){this.startIfEnabled()}get Se(){var e=un(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}Ys(){if(this.isBrowserSupported()){if(Nt&&It){var e=e=>{e||=Nt?.event;try{this.Xs(e)}catch(e){ko.error(`Failed to capture event`,e)}};if(zi(It,`submit`,e,{capture:!0}),zi(It,`change`,e,{capture:!0}),zi(It,`click`,e,{capture:!0}),this.Se.capture_copied_text){var t=e=>{e||=Nt?.event;try{this.Xs(e,Oo)}catch(e){ko.error(`Failed to capture copy/cut event`,e)}};zi(It,`copy`,t,{capture:!0}),zi(It,`cut`,t,{capture:!0})}}}else ko.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Gs&&(this.Ys(),this.Gs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.Js=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Nr]:!!e.autocapture_opt_out}),this.Qs=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.Ks=e}getElementSelectors(e){var t,n=[];return(t=this.Ks)==null||t.forEach((t=>{(It?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Nr];if(hn(this.Qs)&&!yn(e)&&!this.instance.Or())return!1;var t=this.Qs??!!e;return!!this.instance.config.autocapture&&!t}Xs(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=ra(e);Yte(r)&&(r=r.parentNode||null),t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&sne(r,this.instance.config.rageclick)&&this.Xs(e,`$rageclick`);var i=t===Oo;if(r&&function(e,t,n,r,i,a){var o,s,c;if(n===void 0&&(n=void 0),!Nt||oa(e)||(o=n)!=null&&o.url_allowlist&&!Qte(n.url_allowlist,a)||(s=n)!=null&&s.url_ignorelist&&Qte(n.url_ignorelist,a))return!1;if((c=n)!=null&&c.dom_event_allowlist){var l=n.dom_event_allowlist;if(l&&!l.some((e=>t.type===e)))return!1}var u=cne(e,r),d=u.parentIsUsefulElement,f=u.targetElementList;if(!function(e,t){var n=t?.element_allowlist;if(fn(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(f,n)||!aa(f,n?.css_selector_allowlist)||aa(f,n?.css_selector_ignorelist??tne))return!1;try{var p=Nt.getComputedStyle(e);if(p&&p.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0}catch{}var m=e.tagName.toLowerCase();switch(m){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return d?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(ia.indexOf(m)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Se,i,i?[`copy`,`cut`]:void 0,this.instance)){var a=Rre(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Se.element_attribute_ignorelist,elementsChainAsString:this.Js,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),o=a.props;if(a.explicitNoCapture)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(o.$element_selectors=s),t===Oo){var c,l=$te(Nt==null||(c=Nt.getSelection())==null?void 0:c.toString()),u=e.type||`clipboard`;if(!l)return!1;o.$selected_content=l,o.$copy_type=u}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return ln(It?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.eo=(Nt==null||(t=Nt.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(Tr.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.ro&&this.ro(),this.ro=void 0,Tr.info(`History API monitoring stopped`)}monitorHistoryChanges(){Nt&&Nt.history&&(this.io(`pushState`),this.io(`replaceState`),this.no())}io(e){var t;if(Nt&&((t=Nt.history[e])==null||!t.__posthog_wrapped__)){var n=this;(function(e,t,n){try{if(!(t in e))return Mo;var r={next:e[t]},i=n((function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.next.apply(this,t)}));return ln(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=i,()=>{if(e[t]!==i)for(var n=e[t];ln(n)&&n.__posthog_layer__;){var a=n.__posthog_layer__;if(a.next===i)return void(a.next=r.next);n=a.next}else e[t]=r.next}}catch{return Mo}})(Nt.history,e,(t=>function(r,i,a){t.call(this,r,i,a),n.so(e)}))}}so(e){try{var t,n=Nt==null||(t=Nt.location)==null?void 0:t.pathname;if(!n)return;n!==this.eo&&this.isEnabled&&this._instance.capture(ki,{navigation_type:e}),this.eo=n}catch(t){Tr.error(`Error capturing `+e+` pageview`,t)}}no(){if(!this.ro){var e=()=>{this.so(`popstate`)};zi(Nt,`popstate`,e),this.ro=()=>{Nt&&Nt.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(e){var t;this.oo=!1,this.Gs=!1,this.ao=null,this.instance=e,this.oo=!((t=this.instance.persistence)==null||!t.props[Pr]),this.rageclicks=new Do(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return un(this.Se.capture_heatmaps)&&this.Se.capture_heatmaps.flush_interval_milliseconds&&(e=this.Se.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return gn(this.Se.capture_heatmaps)?gn(this.Se.enable_heatmaps)?this.oo:this.Se.enable_heatmaps:!1!==this.Se.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Gs)return;Vre.info(`starting...`),this.lo(),this.ke()}else clearInterval(this.ao??void 0),this.uo(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Pr]:t}),this.oo=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.R;return this.R=void 0,e}ho(e){this.fe(e.originalEvent,`deadclick`)}ke(){this.ao&&clearInterval(this.ao),this.ao=It?.visibilityState===`visible`?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}lo(){Nt&&It&&(this.do=this.Zr.bind(this),zi(Nt,Oi,this.do),this.co=e=>this.fe(e||Nt?.event),zi(It,`click`,this.co,{capture:!0}),this.vo=e=>this.fo(e||Nt?.event),zi(It,`mousemove`,this.vo,{capture:!0}),this.po=new Sne(this.instance,bne,this.ho.bind(this)),this.po.startIfEnabledOrStop(),this.mo=this.ke.bind(this),zi(It,Di,this.mo),this.Gs=!0)}uo(){var e;Nt&&It&&(this.do&&Nt.removeEventListener(Oi,this.do),this.co&&It.removeEventListener(`click`,this.co,{capture:!0}),this.vo&&It.removeEventListener(`mousemove`,this.vo,{capture:!0}),this.mo&&It.removeEventListener(Di,this.mo),clearTimeout(this.yo),(e=this.po)==null||e.stop(),this.Gs=!1)}bo(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var r=e;r&&Qi(r)&&!$i(r,`body`);){if(r===n)return!1;var i=void 0;try{i=(r.ownerDocument?.defaultView??Nt)?.getComputedStyle(r).position}catch{return!1}if(tn(t,i))return!0;r=ene(r)}return!1}(ra(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}fe(e,t){var n;if(t===void 0&&(t=`click`),!Zi(e.target)&&Hre(e)){var r=this.bo(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&sne(ra(e),this.instance.config.rageclick)&&this.Wt(Gt({},r,{type:`rageclick`})),this.Wt(r)}}fo(e){!Zi(e.target)&&Hre(e)&&(clearTimeout(this.yo),this.yo=setTimeout((()=>{this.Wt(this.bo(e,`mousemove`))}),500))}Wt(e){if(Nt){var t=this.Se.disable_capture_url_hashes?ur(Nt.location.href):Nt.location.href,n=this.Se.custom_personal_data_properties,r=ha(t,this.Se.mask_personal_data_properties?[...va,...n||[]]:[],ya);this.R=this.R||{},this.R[r]||(this.R[r]=[]),this.R[r].push(e)}}Zr(){this.R&&!dn(this.R)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Sne,webVitalsAutocapture:class{constructor(e){var t;this.oo=!1,this.Gs=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._o=()=>{clearTimeout(this.wo),this.R.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.R.metrics.reduce(((e,t)=>Gt({},e,{[`$web_vitals_`+t.name+`_event`]:Gt({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.xo=e=>{this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var t=this.ko();if(!fn(t))if(gn(e?.name)||gn(e?.value))No.error(`Invalid metric received`,e);else if(!this.So||this.So>e.value){this.R.url!==t&&(this._o(),this.wo=setTimeout(this._o,this.flushToCaptureTimeoutMs)),fn(this.R.url)&&(this.R.url=t),this.R.firstMetricTimestamp=fn(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var n=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),r=Gt({},e,{$current_url:t,timestamp:Date.now()});fn(n)||(r.$session_id=n.sessionId,r.$window_id=n.windowId),this.R.metrics.push(r),this.R.metrics.length===this.allowedMetrics.length&&this._o()}else No.error(`Ignoring metric with value >= `+this.So,e)},this.Co=()=>{if(!this.Gs){var e,t,n,r,i=Ht.__PosthogExtensions__;if(!fn(i)&&!fn(i.postHogWebVitalsCallbacks)){var a=i.postHogWebVitalsCallbacks;e=a.onLCP,t=a.onCLS,n=a.onFCP,r=a.onINP}e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.xo.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.xo.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.xo.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.xo.bind(this)),this.Gs=!0):No.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.oo=!((t=this._instance.persistence)==null||!t.props[Rr]),this.startIfEnabled()}get Io(){return this._instance.config.capture_performance}get allowedMetrics(){var e=un(this.Io)?this.Io?.web_vitals_allowed_metrics:void 0;return gn(e)?this._instance.persistence?.props[Vr]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(un(this.Io)?this.Io.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=un(this.Io)?this.Io.web_vitals_attribution:void 0;return e!=null&&e}get So(){var e=un(this.Io)&&_n(this.Io.__web_vitals_max_value)?this.Io.__web_vitals_max_value:Po;return e>0&&6e4>=e?Po:e}get isEnabled(){var e=Lt?.protocol;if(e!==`http:`&&e!==`https:`)return No.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=un(this.Io)?this.Io.web_vitals:yn(this.Io)?this.Io:void 0;return yn(t)?t:this.oo}startIfEnabled(){this.isEnabled&&!this.Gs&&(No.info(`enabled, starting...`),this.Ue(this.Co))}onRemoteConfig(e){if(`capturePerformance`in e){var t=un(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=un(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Rr]:t}),this._instance.persistence.register({[Vr]:n})),this.oo=t,this.startIfEnabled()}}Ue(e){var t,n;(t=Ht.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?No.error(`failed to load script`,t):e()}))}ko(){var e=Nt?this._instance.config.disable_capture_url_hashes?ur(Nt.location.href):Nt.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return ha(e,this._instance.config.mask_personal_data_properties?[...va,...t||[]]:[],ya)}No.error(`Could not determine current URL`)}}},oie={exceptionObserver:class{constructor(e){var t,n;this.Co=()=>{var e;if(Nt&&this.isEnabled&&(e=Ht.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=Ht.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=Ht.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ht.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.To&&this.Se.capture_unhandled_errors&&(this.To=t(this.captureException.bind(this))),!this.Mo&&this.Se.capture_unhandled_rejections&&(this.Mo=n(this.captureException.bind(this))),!this.Eo&&this.Se.capture_console_errors&&(this.Eo=r(this.captureException.bind(this)))}catch(e){jo.error(`failed to start`,e),this.Ro()}}},this._instance=e,this.Po=!((t=this._instance.persistence)==null||!t.props[Fr]),this.Oo=new Tee(Gt({},((n=this._instance.config.error_tracking)===void 0&&(n={}),{refillRate:n.exceptionRateLimiterRefillRate??n.__exceptionRateLimiterRefillRate??1,bucketSize:n.exceptionRateLimiterBucketSize??n.__exceptionRateLimiterBucketSize??10}),{refillInterval:1e4,it:jo})),this.Se=this.Fo(),this.startIfEnabledOrStop()}Fo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return un(e)?t=Gt({},t,e):(fn(e)?this.Po:e)&&(t=Gt({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Se.capture_console_errors||this.Se.capture_unhandled_errors||this.Se.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(jo.info(`enabled`),this.Ro(),this.Ue(this.Co)):this.Ro()}Ue(e){var t,n;(t=Ht.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return jo.error(`failed to load script`,t);e()}))}Ro(){var e,t,n;(e=this.To)==null||e.call(this),this.To=void 0,(t=this.Mo)==null||t.call(this),this.Mo=void 0,(n=this.Eo)==null||n.call(this),this.Eo=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.Po=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Fr]:this.Po}),this.Se=this.Fo(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this.Fo()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.Oo.consumeRateLimit(r)?jo.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.Lo=[],this.Ao=new ote([new hte,new wte,new _te,new gte,new Ste,new xte,new yte,new Cte],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
|
|
3
3
|
`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=mte.test(s)?s.replace(mte,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return Gt({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||gr});var n}))}(i)}}(`web:javascript`,ute,pte)),this._instance=e,this.Lo=this._instance.persistence?.get_property(Ir)??[],this.$o=Cr(this.No()),this.Do=new Ete(this.$o)}onConfigChange(){this.$o=Cr(this.No()),this.Do.setConfig(this.$o)}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.Lo=t,this._instance.persistence&&this._instance.persistence.register({[Ir]:this.Lo,[Lr]:n})}}get qo(){var e,t=!!this._instance.get_property(Lr);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.Ao.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.$o.enabled)try{if(!pn(e)||e.trim().length===0)return void Jo.warn(`Ignoring exception step because message must be a non-empty string`);var n=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>Tte.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this.jo(t)),r=n.sanitizedProperties,i=n.droppedKeys;i.length>0&&Jo.warn(`Ignoring reserved exception step fields`,{droppedKeys:i}),this.Do.add(Gt({[br]:e,[xr]:new Date().toISOString()},r))}catch(e){Jo.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Ho(t)){if(this.Bo(t))return this.Uo(`Exception dropped: matched a suppression rule`),void Jo.info(`Skipping exception capture because a suppression rule matched`);if(!this.qo&&this.zo(t))return this.Uo(`Exception dropped: thrown by a browser extension`),void Jo.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Vo(t))return this.Uo(`Exception dropped: thrown by the PostHog SDK`),void Jo.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.$o.enabled&&gn(e.$exception_steps)?this.Wo(e):e;try{var r=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,hn:!0});return r&&this.Do.clear(),r}catch(e){Jo.error(`Failed to capture exception event. Dropping this exception.`,e),this.Do.clear();return}}catch(e){Jo.error(`Failed to process exception event. Ignoring this exception.`,e);return}}Wo(e){try{var t=this.Do.getAttachable();return t.length===0?e:Gt({},e,{$exception_steps:t})}catch(t){return Jo.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}Uo(e){this.$o.enabled&&this.Do.add({[br]:e,[xr]:new Date().toISOString()})}jo(e){return un(e)?Gt({},e):{}}No(){return this._instance.config.error_tracking?.exception_steps??{}}Bo(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var n=t.type,r=t.value;return pn(n)&&n.length>0&&e.$exception_types.push(n),pn(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.Lo.some((e=>{var n=e.values.map((e=>{var n=Ere[e.operator],r=cn(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}zo(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}Vo(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}Ho(e){return!gn(e)&&cn(e)}}},sie=Gt({productTours:class{get ni(){return this._instance.persistence}constructor(e){this.Zo=null,this.Go=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(`productTours`in e){var t;if(this.ni&&this.ni.register({[Br]:!!e.productTours}),!Vo(this._instance))return!this.Zo&&gn(this.ni?.props[ii])||Bo.info(`product tours disabled; stopping and clearing cached tours`),(t=this.Zo)==null||t.stop(),this.Zo=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Zo&&Vo(this._instance)&&this.Ue((()=>this.Qo()))}Ue(e){var t,n;(t=Ht.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?Bo.error(`Could not load product tours script`,t):e()}))}Qo(){var e;!this.Zo&&(e=Ht.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Zo=Ht.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!cn(this.Go)||t){var n=this.ni;if(n){var r=n.props[ii];if(cn(r)&&!t)return this.Go=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{if(Vo(this._instance)){var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;Bo.error(i),e([],{isLoaded:!1,error:i});return}var a=cn(t.json.product_tours)?t.json.product_tours:[];this.Go=a,n&&n.register({[ii]:a}),e(a,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.Go,{isLoaded:!0})}getActiveProductTours(e){gn(this.Zo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.Zo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Zo)==null||t.showTourById(e)}previewTour(e){this.Zo?this.Zo.previewTour(e):this.Ue((()=>{var t;this.Qo(),(t=this.Zo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Zo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.Zo)==null||e.nextStep()}previousStep(){var e;(e=this.Zo)==null||e.previousStep()}clearCache(){var e;this.Go=null,(e=this.ni)==null||e.unregister(ii)}resetTour(e){var t;(t=this.Zo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Zo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Zo)==null||t.cancelPendingTour(e)}}},Zo),cie={siteApps:class{constructor(e){this.Jo=0,this._instance=e,this.Ko=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Yo(e,t){if(t){var n=this.globalsForEvent(t);this.Ko.push(n),this.Ko.length>1e3&&(this.Ko=this.Ko.slice(10))}}get siteAppLoaders(){var e;return(e=Ht._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Yo.bind(this));this.Xo=()=>{e(),this.Ko=[],this.Xo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var i of Object.entries(r)){var a=i[0];t[a]={id:n[a],type:a,properties:i[1]}}var o=e.$set_once,s=e.$set;return{event:Gt({},uee(e,Ure),{properties:Gt({},e.properties,s?{$set:Gt({},e.properties?.$set??{},s)}:{},o?{$set_once:Gt({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}ta(e){var t=e.tagName?.toLowerCase();return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Ho.error(`prepare_external_dependency_stylesheet returned null`),null):t===`script`&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Ho.error(`prepare_external_dependency_script returned null`),null):e}ea(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var t=It?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this.Jo++,this.ra)return this.ia();var r=[],i=this,a=new WeakSet,o=(e,t,n)=>{if(e!=null&&e[t]){var i=e[t];e[t]=n(i),r.push((()=>{e[t]=i}))}},s=e=>{if(a.has(e))return e;var t=i.ta(e);return t&&a.add(t),t},c=e=>e.map((e=>typeof e==`string`?e:s(e))).filter((e=>!hn(e)));return o(n,`appendChild`,(e=>function(t){var n=s(t);return n?e.call(this,n):t})),o(n,`insertBefore`,(e=>function(t,n){var r=s(t);return r?e.call(this,r,n):t})),o(n,`replaceChild`,(e=>function(t,n){var r=s(t);return r?e.call(this,r,n):n})),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach((e=>{o(e,`append`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,c(n))})),o(e,`prepend`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,c(n))}))})),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach((e=>{o(e,`before`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,c(n))})),o(e,`after`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,c(n))})),o(e,`replaceWith`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=c(n);return n.length&&!i.length?void 0:e.apply(this,i)}))})),o(t.Element?.prototype,`insertAdjacentElement`,(e=>function(t,n){var r=s(n);return r?e.call(this,t,r):null})),this.ra=()=>{r.forEach((e=>e())),this.ra=void 0},this.ia()}ia(){var e=!1;return()=>{var t;e||(e=!0,this.Jo--,this.Jo===0&&((t=this.ra)==null||t.call(this)))}}na(e,t){t===void 0&&(t=!0);var n=this.ea();try{var r=e(n);return t&&n(),r}catch(e){throw n(),e}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.Ko.length&&(Ho.info(`Processing `+this.Ko.length+` events for site app with id `+e.id),this.Ko.forEach((e=>this.na((()=>t.processEvent==null?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.Xo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Ho.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var a=this.na((t=>e.init({posthog:this._instance,callback(e){t(),i(e)}})),!1).processEvent;a&&(t.processEvent=a),r=!0}catch(t){Ho.error(Wre+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Ho.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}sa(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}oa(e){var t=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e),r=function(r){try{t.na((()=>r.processEvent==null?void 0:r.processEvent(n)))}catch(t){Ho.error(`Error while processing event `+e.event+` for site app `+r.id,t)}};for(var i of Object.values(this.apps))r(i)}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.sa(),void this._instance.on(`eventCaptured`,(e=>this.oa(e)))):void Ho.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.Xo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(){var e,t=o.id,n=o.url;Ht[`__$$ph_site_app_`+t]=i._instance,(e=Ht.__PosthogExtensions__)==null||e.loadSiteApp==null||e.loadSiteApp(i._instance,n,(e=>{if(e)return Ho.error(Wre+t,e)}))};for(var o of e.siteApps)a()}else Ho.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},lie={tracingHeaders:class{constructor(e){this.aa=void 0,this.la=void 0,this.ua=void 0,this.Co=()=>{var e,t,n=this.ha();n?(fn(this.aa)&&(this.aa=(e=Ht.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(n,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),fn(this.la)&&(this.la=(t=Ht.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchFetch(n,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Ro()},this._instance=e}initialize(){this.startIfEnabledOrStop()}Ue(e){var t,n;(t=Ht.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(n=Ht.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return zre.error(`failed to load script`,t);e()}))}da(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}ha(){var e=this.da();return cn(e)?(cn(this.ua)?this.ua.splice(0,this.ua.length,...e):this.ua=[...e],e.length>0?this.ua:void 0):(cn(this.ua)&&this.ua.splice(0),this.ua=e||void 0,this.ua)}Ro(){var e,t;(e=this.aa)==null||e.call(this),(t=this.la)==null||t.call(this),this.aa=void 0,this.la=void 0}startIfEnabledOrStop(){this.ha()?this.Ue(this.Co):this.Ro()}}},uie=Gt({surveys:class{get Se(){return this._instance.config}constructor(e){this.ca=void 0,this._surveyManager=null,this.va=!1,this.fa=[],this.pa=null,this.ga=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Se.disable_surveys){var t=e.surveys;if(gn(t))return fo.warn(`Flags not loaded yet. Not loading surveys.`);var n=cn(t);this.ca=n?t.length>0:t,fo.info(`flags response received, isSurveysEnabled: `+this.ca),this.loadIfEnabled()}}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem(`lastSeenSurveyDate`);for(var t=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(po)||r!=null&&r.startsWith(`inProgressSurvey_`))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.va)fo.info(`Already initializing surveys, skipping...`);else if(this.Se.disable_surveys)fo.info(Jre);else if(this.Se.cookieless_mode&&this._instance.consent.isOptedOut())fo.info(`Not loading surveys in cookieless mode without consent.`);else{var e=Ht?.__PosthogExtensions__;if(e){if(!fn(this.ca)||this.Se.advanced_enable_surveys){var t=this.ca||this.Se.advanced_enable_surveys;this.va=!0;try{var n=e.generateSurveys;if(n)return void this.ma(n,t);var r=e.loadExternalDependency;if(!r)return void this.ya(xi);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.ya(`Could not load surveys script`,n):this.ma(e.generateSurveys,t)}))}catch(e){throw this.ya(`Error initializing surveys`,e),e}finally{this.va=!1}}}else fo.error(`PostHog Extensions not found.`)}}ma(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new qre(this._instance),fo.info(`Surveys loaded successfully`),this.ba({isLoaded:!0})}ya(e,t){fo.error(e,t),this.ba({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fa.push(e),this._surveyManager&&this.ba({isLoaded:!0}),()=>{this.fa=this.fa.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Se.disable_surveys)return fo.info(Jre),e([]);var n,r=this._instance.get_property(ti);if(r&&!t)return e(r,{isLoaded:!0}),void(this._a()&&this.getSurveys((()=>{}),!0));typeof Promise<`u`&&this.pa?this.pa.then((t=>e(t.surveys,t.context))):(typeof Promise<`u`&&(this.pa=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Se.token),method:`GET`,timeout:this.Se.surveys_request_timeout_ms,callback:t=>{var r;this.pa=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;fo.error(a),this.ga=Date.now();var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}this.ga=null;var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(uo(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[ti]:c,[ni]:Date.now()});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}_a(){return this.wa()&&!this.pa&&!this.xa()}wa(){var e=this._instance.get_property(ni);return _n(e)&&Date.now()-e>3e5}xa(){return _n(this.ga)&&3e5>Date.now()-this.ga}markSurveyAsSeen(e,t){mo({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}ba(e){for(var t of this.fa)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){fo.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!gn(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);fo.warn(`init was not called`)}ka(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Sa(e){if(gn(this._surveyManager))return{eligible:!1,reason:Wo};var t=typeof e==`string`?this.ka(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(gn(this._surveyManager))return fo.warn(`init was not called`),{visible:!1,disabledReason:Wo};var t=this.Sa(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return gn(this._surveyManager)?(fo.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Wo})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Sa(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(gn(this._surveyManager))fo.warn(`init was not called`);else{var i=typeof e==`string`?this.ka(e):e;if(i!=null&&i.id)if(Are.includes(i.type)){var a=It?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(fo.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;fo.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),fo.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);fo.warn(`Survey element not found`)}else fo.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else fo.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(gn(this._surveyManager))fo.warn(`init was not called`);else{var r=this.ka(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=Gt({},r,{appearance:Gt({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Da.Popover&&t.initialResponses&&fo.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void fo.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===Da.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else fo.warn(`Survey not found`)}}cancelPendingSurvey(e){gn(this._surveyManager)?fo.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload==null||e.handlePageUnload()}}},Zo),die={toolbar:class{constructor(e){this.instance=e}Ca(e){Ht.ph_toolbar_state=e}Ia(){return Ht.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Bi(this.instance.config)||!Nt||!It)return!1;e??=Nt.location,n??=Nt.history;try{if(!t){try{Nt.localStorage.setItem(`test`,`test`),Nt.localStorage.removeItem(`test`)}catch{return!1}t=Nt?.localStorage}var r,i=Yre||ga(e.hash,`__posthog`)||ga(e.hash,`state`),a=i?Li((()=>JSON.parse(atob(decodeURIComponent(i)))))||Li((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Xre)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Ta(e){var t=Ht.ph_load_toolbar||Ht.ph_load_editor;!gn(t)&&ln(t)?t(e,this.instance):Zre.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(It==null||!It.getElementById(gi));if(!Nt||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=Gt({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(Nt.localStorage.setItem(Xre,JSON.stringify(Gt({},r,{source:void 0}))),this.Ia()===2)this.Ta(r);else if(this.Ia()===0){var i;this.Ca(1),(i=Ht.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return Zre.error(`[Toolbar] Failed to load`,e),void this.Ca(0);this.Ca(2),this.Ta(r)})),zi(Nt,`turbolinks:load`,(()=>{this.Ca(0),this.loadToolbar(r)}))}return!0}Ma(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},fie=Gt({experiments:nie},Zo),pie=Gt({},Zo,iie,aie,oie,sie,cie,uie,lie,die,fie,{conversations:class{constructor(e){this.Ea=void 0,this._conversationsManager=null,this.Ra=!1,this.Pa=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;gn(t)||(yn(t)?this.Ea=t:(this.Ea=t.enabled,this.Pa=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Ea=void 0,this.Pa=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ra||this._instance.config.disable_conversations||Bi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=Ht?.__PosthogExtensions__;if(e&&!fn(this.Ea)&&this.Ea)if(this.Pa&&this.Pa.token){this.Ra=!0;try{var t=e.initConversations;if(t)return this.Oa(t),void(this.Ra=!1);var n=e.loadExternalDependency;if(!n)return void this.Fa(xi);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.Fa(`Could not load conversations script`,t):this.Oa(e.initConversations),this.Ra=!1}))}catch(e){this.Fa(`Error initializing conversations`,e),this.Ra=!1}}else Yo.error(`Conversations enabled but missing token in remote config.`)}}Oa(e){if(this.Pa)try{this._conversationsManager=e(this.Pa,this._instance),Yo.info(`Conversations loaded successfully`)}catch(e){this.Fa(`Error completing conversations initialization`,e)}else Yo.error(`Cannot complete initialization: remote config is null`)}Fa(e,t){Yo.error(e,t),this._conversationsManager=null,this.Ra=!1}show(){this._conversationsManager?this._conversationsManager.show():Yo.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Ea&&!hn(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return Wt((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Yo.warn(Xo),null)}))()}getMessages(e,t){var n=this;return Wt((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Yo.warn(Xo),null)}))()}markAsRead(e){var t=this;return Wt((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Yo.warn(Xo),null)}))()}getTickets(e){var t=this;return Wt((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Yo.warn(Xo),null)}))()}requestRestoreLink(e){var t=this;return Wt((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Yo.warn(Xo),null)}))()}restoreFromToken(e){var t=this;return Wt((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Yo.warn(Xo),null)}))()}restoreFromUrlToken(){var e=this;return Wt((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Yo.warn(Xo),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}gn(){var e;(e=this._conversationsManager)==null||e.setIdentity()}mn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.La=!1,this.Aa=!1,this.it=Er(`[logs]`),this.Ar=[],this.$a=[],this.ws=0,this.Na=()=>{var e,t;this.ws=0,(e=this.Da)==null||e.onReconnect(),(t=this.qa)==null||t.onReconnect()},this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.La=!0),Nt&&zi(Nt,`online`,this.Na)}ja(e,t,n,r){var i,a=function(e,t){var n=e?.flushIntervalMs??3e3,r=e?.maxBufferSize??100,i=t!=null&&t.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,a=fn(i)?Math.max(r,2048):Math.max(r,i),o=e?.resourceAttributes;return{serviceName:o?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:o?.[`service.version`]??e?.serviceVersion,environment:o?.[`deployment.environment`]??e?.environment,resourceAttributes:o,beforeSend:e?.beforeSend,flushIntervalMs:n,maxBufferSize:r,maxQueueSize:a,maxBatchRecordsPerPost:100,rateCapWindowMs:n,maxLogsPerInterval:i,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new ete(this.Ha(e,t),a,this.it,(()=>this.Ba()),(e=>e()),void 0,r),a]}Ua(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.Da||this.za!==t){var n;(n=this.Da)==null||n.reset(),this.za=t;var r=this.ja((()=>this.Ar),(e=>{this.Ar=e}));this.Da=r[0],this.Va=r[1]}return this.Da}Wa(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.qa||this.Za!==t){var n;(n=this.qa)==null||n.reset(),this.Za=t;var r=this.ja((()=>this.$a),(e=>{this.$a=e}),{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},rie);this.qa=r[0],this.Ga=r[1]}return this.qa}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!gn(t)&&t&&(this.La=!0,this.loadIfEnabled())}reset(){var e,t;this.Ar=[],(e=this.Da)==null||e.reset(),this.$a=[],(t=this.qa)==null||t.reset(),this.ws=0}captureLog(e){this.Ua().captureLog(e)}le(e){this.Wa().captureLog(e)}get logger(){return this.Qa||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.Qa}flushLogs(e){e?this.Ja(e):(this.Da&&this.Da.flush().catch((e=>this.it.error(`PostHog logs flush failed:`,e))),this.qa&&this.qa.flush().catch((e=>this.it.error(`PostHog logs flush failed:`,e))))}loadIfEnabled(){if(this.La&&!this.Aa){var e=Ht?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.it.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.Aa=!0)})):this.it.error(xi)}else this.it.error(`PostHog Extensions not found.`)}}Ha(e,t){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:t=>t===Xt.LogsQueue?e():void 0,setPersistedProperty(e,n){e===Xt.LogsQueue&&t(n??[])},At:e=>this.At(e),getLibraryId:()=>Ut.LIB_NAME,getLibraryVersion:()=>Ut.LIB_VERSION}}At(e){return new Promise((t=>{if(kne(this.ws,3))t({kind:`fatal`,error:Error(`logs endpoint is unreachable, dropping batch`)});else{var n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout((()=>r({kind:`retry-later`,error:Error(`logs request timed out`)})),9e4);this._instance._send_request({method:`POST`,url:this.Ka(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;this.Ya(t),r(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==429&&500>t?{kind:`fatal`,error:Error(`logs request failed with status `+t)}:{kind:`retry-later`,error:e.error??Error(`logs request failed with status `+t)})}})}}))}Ya(e){(e!==0||this._instance.__loaded)&&(this.ws=Ane(e,this.ws,3,(()=>this.it.warn(`Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.`))))}Ja(e){this.Ar.length>0&&this.Xa(e,this.Ar,this.Va,Ut.LIB_NAME,(e=>{this.Ar=e})),this.$a.length>0&&this.Xa(e,this.$a,this.Ga,rie,(e=>{this.$a=e}))}Xa(e,t,n,r,i){if(t.length!==0){var a=t.map((e=>e.record));i([]);var o=$ee(a,Qee(n,Ut.LIB_NAME,Ut.LIB_VERSION),r,Ut.LIB_VERSION);this._instance._send_request({method:`POST`,url:this.Ka(),data:o,compression:`best-available`,batchKey:`logs`,transport:e})}}Ka(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}Ba(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.windowId,i=n.sessionStartTimestamp,a=n.lastActivityTimestamp;t.sessionId=n.sessionId,t.windowId=r,gn(i)||(t.sessionStartTimestamp=i),gn(a)||(t.lastActivityTimestamp=a)}if(Ht!=null&&(e=Ht.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?ur(Ht.location.href):Ht.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},{metrics:class{constructor(e){this.it=Er(`[metrics]`),this._instance=e}initialize(){}Ua(){var e,t,n,r,i=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.Da&&this.za===i||((t=this.Da)==null||t.reset(),this.za=i,this.Da=new rte(this.Ha(),{serviceName:(r=(n=i)?.resourceAttributes)?.[`service.name`]??n?.serviceName,serviceVersion:r?.[`service.version`]??n?.serviceVersion,environment:r?.[`deployment.environment`]??n?.environment,resourceAttributes:r,beforeSend:n?.beforeSend,flushIntervalMs:n?.flushIntervalMs??1e4,maxSeriesPerFlush:n?.maxSeriesPerFlush??1e3},this.it)),this.Da}count(e,t,n){t===void 0&&(t=1),this.Ua().count(e,t,n)}gauge(e,t,n){this.Ua().gauge(e,t,n)}histogram(e,t,n){this.Ua().histogram(e,t,n)}flush(e){if(!this.Da)return Promise.resolve();if(e){var t=this.Da.drainWindow();return t&&this.Kt(t,e),Promise.resolve()}return this.Da.flush().catch((e=>this.it.error(`PostHog metrics flush failed:`,e)))}reset(){var e;(e=this.Da)==null||e.reset()}Ha(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Kt:e=>t.Kt(e),getLibraryId:()=>Ut.LIB_NAME,getLibraryVersion:()=>Ut.LIB_VERSION}}Kt(e,t){return new Promise((n=>{var r=!1,i=e=>{r||(r=!0,clearTimeout(a),n(e))},a=setTimeout((()=>i({kind:`retry-later`,error:Error(`metrics request timed out`)})),9e4);this._instance._send_request(Gt({method:`POST`,url:this.tl(),data:e,compression:`best-available`,batchKey:`metrics`},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;i(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==429&&500>t?{kind:`fatal`,error:Error(`metrics request failed with status `+t)}:{kind:`retry-later`,error:e.error??Error(`metrics request failed with status `+t)})}}))}))}tl(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}});Eo.__defaultExtensionClasses=Gt({},pie);var Qo=function(){Ut.SDK_DIST_CHANNEL=`npm`;var e=ho[So]=new Eo;return function(){function e(){e.done||(e.done=!0,Co=!1,Pi(ho,(function(e){e._dom_loaded()})))}It!=null&&It.addEventListener?It.readyState===`complete`?e():zi(It,`DOMContentLoaded`,e,{capture:!1}):Nt&&Tr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}(),$o=!1,mie=[`campaign`,`pathname`,`referrer`,`referring_domain`,`session_entry`,`url`],hie=new Set([`dclid`,`epik`,`fbclid`,`gclid`,`gclsrc`,`igshid`,`irclid`,`li_fat_id`,`mc_cid`,`msclkid`,`rdt_cid`,`ttclid`,`twclid`]);function es(e){if(!e)return e;let t={...e};for(let e of Object.keys(t)){let n=e.toLowerCase().replace(/^\$/,``);(n.startsWith(`utm_`)||hie.has(n)||mie.some(e=>n.includes(e)))&&delete t[e]}return t}function gie(e){if(!e)return null;let t=es(e.properties)??{};if(e.event===`$exception`){for(let e of Object.keys(t))e.startsWith(`$exception_`)&&e!==`$exception_level`&&delete t[e];t.$exception_list=[{type:`OverdeckTelemetryException`,value:`Overdeck browser operation failed`}]}return{...e,properties:t,$set:es(e.$set),$set_once:es(e.$set_once)}}async function _ie(){try{let e=await fetch(`/api/settings`);if(!e.ok)return;let t=await e.json();if((t.telemetry?.effectiveEnabled??t.telemetry?.enabled)===!1)return;Qo.init(`phc_pwvHeDutnCmAm8tZh5hRaQ7mMoho3T9gb4t4qRjK2Zjt`,{api_host:`https://us.i.posthog.com`,person_profiles:`identified_only`,autocapture:!1,capture_pageview:!1,capture_pageleave:!1,capture_exceptions:{capture_unhandled_errors:!0,capture_unhandled_rejections:!0,capture_console_errors:!1},before_send:gie,get_current_url:()=>`https://overdeck.invalid/`,save_campaign_params:!1,save_referrer:!1,disable_session_recording:!0,disable_surveys:!0}),t.telemetry?.installId&&Qo.register({install_id:t.telemetry.installId}),$o=!0}catch{}}function ts(e,t){$o&&Qo.capture(e,t)}function vie(e,t){let n=Error(`Overdeck ${t.action} operation failed`);return n.name=`OverdeckTelemetryException`,n.stack=void 0,n}function ns(e,t){$o&&Qo.captureException(vie(e,t),t)}function rs(e){return e<=0?`0`:e<=2?`1-2`:e<=5?`3-5`:e<=10?`6-10`:`11+`}var yie=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),bie=(...e)=>e.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(` `),xie={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Sie=(0,z.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,z.createElement)(`svg`,{ref:c,...xie,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:bie(`lucide`,i),...s},[...o.map(([e,t])=>(0,z.createElement)(e,t)),...Array.isArray(a)?a:[a]])),H=(e,t)=>{let n=(0,z.forwardRef)(({className:n,...r},i)=>(0,z.createElement)(Sie,{ref:i,iconNode:t,className:bie(`lucide-${yie(e)}`,n),...r}));return n.displayName=`${e}`,n},is=H(`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`}]]),Cie=H(`Anchor`,[[`path`,{d:`M12 22V8`,key:`qkxhtm`}],[`path`,{d:`M5 12H2a10 10 0 0 0 20 0h-3`,key:`1hv3nh`}],[`circle`,{cx:`12`,cy:`5`,r:`3`,key:`rqqgnr`}]]),as=H(`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`}]]),wie=H(`ArrowLeftRight`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Tie=H(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Eie=H(`ArrowRightLeft`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),Die=H(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Oie=H(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),os=H(`BarChart3`,[[`path`,{d:`M3 3v18h18`,key:`1s2lah`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),kie=H(`Beaker`,[[`path`,{d:`M4.5 3h15`,key:`c7n0jr`}],[`path`,{d:`M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3`,key:`m1uhx7`}],[`path`,{d:`M6 14h12`,key:`4cwo0f`}]]),Aie=H(`BellOff`,[[`path`,{d:`M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5`,key:`o7mx20`}],[`path`,{d:`M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7`,key:`16f1lm`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),jie=H(`Bell`,[[`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`,key:`1qo2s2`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}]]),Mie=H(`BookOpenCheck`,[[`path`,{d:`M8 3H2v15h7c1.7 0 3 1.3 3 3V7c0-2.2-1.8-4-4-4Z`,key:`1i8u0n`}],[`path`,{d:`m16 12 2 2 4-4`,key:`mdajum`}],[`path`,{d:`M22 6V3h-6c-2.2 0-4 1.8-4 4v14c0-1.7 1.3-3 3-3h7v-2.3`,key:`jb5l51`}]]),ss=H(`BookOpen`,[[`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`,key:`vv98re`}],[`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`,key:`1cyq3y`}]]),Nie=H(`BookText`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20`,key:`t4utmx`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}]]),cs=H(`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`}]]),ls=H(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),Pie=H(`Brush`,[[`path`,{d:`m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08`,key:`1styjt`}],[`path`,{d:`M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z`,key:`z0l1mu`}]]),Fie=H(`Bug`,[[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M9 7.13v-1a3.003 3.003 0 1 1 6 0v1`,key:`d7y7pr`}],[`path`,{d:`M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6`,key:`xs1cw7`}],[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M6.53 9C4.6 8.8 3 7.1 3 5`,key:`32zzws`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`M3 21c0-2.1 1.7-3.9 3.8-4`,key:`4p0ekp`}],[`path`,{d:`M20.97 5c0 2.1-1.6 3.8-3.5 4`,key:`18gb23`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M17.2 17c2.1.1 3.8 1.9 3.8 4`,key:`k3fwyw`}]]),us=H(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),ds=H(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),fs=H(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ps=H(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ms=H(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Iie=H(`ChevronsLeft`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Lie=H(`ChevronsRight`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),hs=H(`CircleAlert`,[[`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`}]]),gs=H(`CircleCheckBig`,[[`path`,{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`,key:`g774vq`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),_s=H(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Rie=H(`CircleDot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),vs=H(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`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`}]]),zie=H(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ys=H(`CircleStop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,key:`1wrtvo`}]]),Bie=H(`CircleUserRound`,[[`path`,{d:`M18 20a6 6 0 0 0-12 0`,key:`1qehca`}],[`circle`,{cx:`12`,cy:`10`,r:`4`,key:`1h16sb`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),bs=H(`CircleX`,[[`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`}]]),xs=H(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Vie=H(`ClipboardCheck`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),Hie=H(`ClipboardCopy`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2`,key:`4jdomd`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v4`,key:`3hqy98`}],[`path`,{d:`M21 14H11`,key:`1bme5i`}],[`path`,{d:`m15 10-4 4 4 4`,key:`5dvupr`}]]),Ss=H(`ClipboardList`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),Uie=H(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),Cs=H(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),ws=H(`CodeXml`,[[`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`}]]),Ts=H(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),Es=H(`Columns2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),Ds=H(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Os=H(`Container`,[[`path`,{d:`M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z`,key:`1t2lqe`}],[`path`,{d:`M10 21.9V14L2.1 9.1`,key:`o7czzq`}],[`path`,{d:`m10 14 11.9-6.9`,key:`zm5e20`}],[`path`,{d:`M14 19.8v-8.1`,key:`159ecu`}],[`path`,{d:`M18 17.5V9.4`,key:`11uown`}]]),ks=H(`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`}]]),As=H(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),js=H(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Ms=H(`DollarSign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Ns=H(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),Wie=H(`DraftingCompass`,[[`circle`,{cx:`12`,cy:`5`,r:`2`,key:`f1ur92`}],[`path`,{d:`m3 21 8.02-14.26`,key:`1ssaw4`}],[`path`,{d:`m12.99 6.74 1.93 3.44`,key:`iwagvd`}],[`path`,{d:`M19 12c-3.87 4-10.13 4-14 0`,key:`1tsu18`}],[`path`,{d:`m21 21-2.16-3.84`,key:`vylbct`}]]),Ps=H(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Fs=H(`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`}]]),Is=H(`ExternalLink`,[[`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`}]]),Ls=H(`EyeOff`,[[`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`,key:`1jxqfv`}],[`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`,key:`9wicm4`}],[`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`,key:`1jreej`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Rs=H(`Eye`,[[`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z`,key:`rwhkz3`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Gie=H(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),Kie=H(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),zs=H(`FileCode`,[[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}]]),qie=H(`FileCog`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m3.2 12.9-.9-.4`,key:`1i3dj5`}],[`path`,{d:`m3.2 15.1-.9.4`,key:`1fvgj0`}],[`path`,{d:`M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5`,key:`1yo3oz`}],[`path`,{d:`m4.9 11.2-.4-.9`,key:`otmhb9`}],[`path`,{d:`m4.9 16.8-.4.9`,key:`1b8z07`}],[`path`,{d:`m7.5 10.3-.4.9`,key:`11k65u`}],[`path`,{d:`m7.5 17.7-.4-.9`,key:`431x55`}],[`path`,{d:`m9.7 12.5-.9.4`,key:`87sjan`}],[`path`,{d:`m9.7 15.5-.9-.4`,key:`khqm91`}],[`circle`,{cx:`6`,cy:`14`,r:`3`,key:`a1xfv6`}]]),Jie=H(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Yie=H(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),Xie=H(`FilePenLine`,[[`path`,{d:`m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2`,key:`142zxg`}],[`path`,{d:`M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`2t3380`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),Zie=H(`FileSearch`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3`,key:`ms7g94`}],[`path`,{d:`m9 18-1.5-1.5`,key:`1j6qii`}],[`circle`,{cx:`5`,cy:`14`,r:`3`,key:`ufru5t`}]]),Bs=H(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Vs=H(`FileX`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),Qie=H(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Hs=H(`Filter`,[[`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`,key:`1yg77f`}]]),Us=H(`Flag`,[[`path`,{d:`M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z`,key:`i9b6wo`}],[`line`,{x1:`4`,x2:`4`,y1:`22`,y2:`15`,key:`1cm3nv`}]]),Ws=H(`FlaskConical`,[[`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`,key:`pzvekw`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]]),Gs=H(`FolderClosed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),Ks=H(`FolderInput`,[[`path`,{d:`M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),qs=H(`FolderOpen`,[[`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`}]]),Js=H(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Ys=H(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Xs=H(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Zs=H(`Gem`,[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),Qs=H(`GitBranchPlus`,[[`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`}]]),$s=H(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),ec=H(`GitCommitHorizontal`,[[`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`}]]),tc=H(`GitFork`,[[`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`}]]),nc=H(`GitMerge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),rc=H(`GitPullRequest`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),ic=H(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),ac=H(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),$ie=H(`GripVertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),oc=H(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),eae=H(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),sc=H(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),tae=H(`Hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),cc=H(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),nae=H(`Infinity`,[[`path`,{d:`M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z`,key:`1z0uae`}]]),lc=H(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),uc=H(`Key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),dc=H(`Layers`,[[`path`,{d:`m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z`,key:`8b97xw`}],[`path`,{d:`m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65`,key:`dd6zsq`}],[`path`,{d:`m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65`,key:`ep9fru`}]]),fc=H(`LayoutGrid`,[[`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`}]]),rae=H(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),pc=H(`ListOrdered`,[[`line`,{x1:`10`,x2:`21`,y1:`6`,y2:`6`,key:`76qw6h`}],[`line`,{x1:`10`,x2:`21`,y1:`12`,y2:`12`,key:`16nom4`}],[`line`,{x1:`10`,x2:`21`,y1:`18`,y2:`18`,key:`u3jurt`}],[`path`,{d:`M4 6h1v4`,key:`cnovpq`}],[`path`,{d:`M4 10h2`,key:`16xx2s`}],[`path`,{d:`M6 18H4c0-1 2-2 2-3s-1-1.5-2-1`,key:`m9a95d`}]]),mc=H(`ListTodo`,[[`rect`,{x:`3`,y:`5`,width:`6`,height:`6`,rx:`1`,key:`1defrl`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),hc=H(`List`,[[`line`,{x1:`8`,x2:`21`,y1:`6`,y2:`6`,key:`7ey8pc`}],[`line`,{x1:`8`,x2:`21`,y1:`12`,y2:`12`,key:`rjfblc`}],[`line`,{x1:`8`,x2:`21`,y1:`18`,y2:`18`,key:`c3b1m8`}],[`line`,{x1:`3`,x2:`3.01`,y1:`6`,y2:`6`,key:`1g7gq3`}],[`line`,{x1:`3`,x2:`3.01`,y1:`12`,y2:`12`,key:`1pjlvk`}],[`line`,{x1:`3`,x2:`3.01`,y1:`18`,y2:`18`,key:`28t2mc`}]]),gc=H(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),_c=H(`Lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),vc=H(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),iae=H(`MemoryStick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),aae=H(`Menu`,[[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}],[`line`,{x1:`4`,x2:`20`,y1:`6`,y2:`6`,key:`1owob3`}],[`line`,{x1:`4`,x2:`20`,y1:`18`,y2:`18`,key:`yk5zj1`}]]),yc=H(`MessageCircleQuestion`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`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`}]]),bc=H(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),oae=H(`MessageSquarePlus`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}]]),sae=H(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),xc=H(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),cae=H(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2z`,key:`jj09z8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Sc=H(`MicOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M18.89 13.23A7.12 7.12 0 0 0 19 12v-2`,key:`80xlxr`}],[`path`,{d:`M5 10v2a7 7 0 0 0 12 5`,key:`p2k8kg`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),Cc=H(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),wc=H(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Tc=H(`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`}]]),Ec=H(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),Dc=H(`Network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),lae=H(`Package`,[[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`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`}]]),uae=H(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),dae=H(`PanelLeftClose`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),fae=H(`PanelLeftOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),pae=H(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),Oc=H(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),mae=H(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),kc=H(`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`}]]),hae=H(`PinOff`,[[`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`}]]),gae=H(`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`}]]),Ac=H(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),jc=H(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),_ae=H(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),Mc=H(`RefreshCw`,[[`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`}]]),Nc=H(`Rocket`,[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]]),Pc=H(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Fc=H(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Ic=H(`Route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),Lc=H(`Rows2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),vae=H(`Rows3`,[[`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`}]]),Rc=H(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),zc=H(`Scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),Bc=H(`ScrollText`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),Vc=H(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),yae=H(`SendHorizontal`,[[`path`,{d:`m3 3 3 9-3 9 19-9Z`,key:`1aobqy`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),bae=H(`Send`,[[`path`,{d:`m22 2-7 20-4-9-9-4Z`,key:`1q3vgg`}],[`path`,{d:`M22 2 11 13`,key:`nzbqef`}]]),xae=H(`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`}]]),Hc=H(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Uc=H(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Wc=H(`Share2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Gc=H(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Kc=H(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),qc=H(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Sae=H(`ShipWheel`,[[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}],[`path`,{d:`M12 2v7.5`,key:`1e5rl5`}],[`path`,{d:`m19 5-5.23 5.23`,key:`1ezxxf`}],[`path`,{d:`M22 12h-7.5`,key:`le1719`}],[`path`,{d:`m19 19-5.23-5.23`,key:`p3fmgn`}],[`path`,{d:`M12 14.5V22`,key:`dgcmos`}],[`path`,{d:`M10.23 13.77 5 19`,key:`qwopd4`}],[`path`,{d:`M9.5 12H2`,key:`r7bup8`}],[`path`,{d:`M10.23 10.23 5 5`,key:`k2y7lj`}],[`circle`,{cx:`12`,cy:`12`,r:`2.5`,key:`ix0uyj`}]]),Cae=H(`SkipForward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]),Jc=H(`Skull`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`path`,{d:`M8 20v2h8v-2`,key:`ded4og`}],[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M16 20a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20`,key:`xq9p5u`}]]),wae=H(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Yc=H(`Snowflake`,[[`line`,{x1:`2`,x2:`22`,y1:`12`,y2:`12`,key:`1dnqot`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`m20 16-4-4 4-4`,key:`rquw4f`}],[`path`,{d:`m4 8 4 4-4 4`,key:`12s3z9`}],[`path`,{d:`m16 4-4 4-4-4`,key:`1tumq1`}],[`path`,{d:`m8 20 4-4 4 4`,key:`9p200w`}]]),Xc=H(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),Zc=H(`SquareSplitHorizontal`,[[`path`,{d:`M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3`,key:`lubmu8`}],[`path`,{d:`M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3`,key:`1ag34g`}],[`line`,{x1:`12`,x2:`12`,y1:`4`,y2:`20`,key:`1tx1rr`}]]),Tae=H(`SquareSplitVertical`,[[`path`,{d:`M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3`,key:`1pi83i`}],[`path`,{d:`M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3`,key:`ido5k7`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),Qc=H(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),$c=H(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Eae=H(`StarOff`,[[`path`,{d:`M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43`,key:`16m0ql`}],[`path`,{d:`M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91`,key:`1vt8nq`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),el=H(`Star`,[[`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`,key:`8f66p6`}]]),Dae=H(`SunMoon`,[[`path`,{d:`M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4`,key:`1fu5g2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.9 4.9 1.4 1.4`,key:`b9915j`}],[`path`,{d:`m17.7 17.7 1.4 1.4`,key:`qc3ed3`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.3 17.7-1.4 1.4`,key:`5gca6`}],[`path`,{d:`m19.1 4.9-1.4 1.4`,key:`wpu9u6`}]]),tl=H(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Oae=H(`Tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),nl=H(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),kae=H(`ThumbsUp`,[[`path`,{d:`M7 10v12`,key:`1qc93n`}],[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}]]),Aae=H(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),jae=H(`ToggleRight`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`16`,cy:`12`,r:`2`,key:`4ma0v8`}]]),rl=H(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Mae=H(`TrendingUp`,[[`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`,key:`126l90`}],[`polyline`,{points:`16 7 22 7 22 13`,key:`kwv8wd`}]]),il=H(`TriangleAlert`,[[`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`}]]),Nae=H(`Undo`,[[`path`,{d:`M3 7v6h6`,key:`1v2h90`}],[`path`,{d:`M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13`,key:`1r6uu6`}]]),Pae=H(`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`}]]),Fae=H(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),al=H(`Volume2`,[[`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`,key:`16drj5`}],[`path`,{d:`M15.54 8.46a5 5 0 0 1 0 7.07`,key:`ltjumu`}],[`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14`,key:`1kegas`}]]),Iae=H(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Lae=H(`WrapText`,[[`line`,{x1:`3`,x2:`21`,y1:`6`,y2:`6`,key:`4m8b97`}],[`path`,{d:`M3 12h15a3 3 0 1 1 0 6h-4`,key:`1cl7v7`}],[`polyline`,{points:`16 16 14 18 16 20`,key:`1jznyi`}],[`line`,{x1:`3`,x2:`10`,y1:`18`,y2:`18`,key:`1h33wv`}]]),ol=H(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),sl=H(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),cl=H(`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`}]]),ll=(0,z.createContext)(null);function ul(){let e=(0,z.useContext)(ll);if(!e)throw Error(`useConfirm must be used within DialogProvider`);return e.confirm}function dl(){let e=(0,z.useContext)(ll);if(!e)throw Error(`useAlert must be used within DialogProvider`);return e.alert}var fl=0;function Rae(){let[e,t]=(0,z.useState)(0);return(0,z.useEffect)(()=>(fl+=1,t(fl),()=>{--fl}),[]),e}function zae({children:e,onDismiss:t}){let n=Rae(),[r,i]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{requestAnimationFrame(()=>i(!0))},[]),(0,z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,B.jsx)(`div`,{className:`fixed inset-0 bg-black/32 backdrop-blur-sm flex items-center justify-center z-[100]`,onClick:t,style:{"--nested-dialogs":n},children:(0,B.jsx)(`div`,{className:`bg-popover text-popover-foreground rounded-2xl border border-border shadow-lg w-full max-w-md mx-4 transition-all duration-200 ease-in-out ${r?`scale-100 opacity-100`:`scale-[0.98] opacity-0`}`,style:{transform:`scale(${r?`calc(1 - 0.1 * ${n})`:`0.98`})`},onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-modal":`true`,children:e})})}function Bae({options:e,onConfirm:t,onCancel:n}){let r=(0,z.useRef)(null),i=(0,z.useRef)(null),[a,o]=(0,z.useState)(``),s=e.variant===`destructive`,c=!!e.requiredText,l=!c||a===e.requiredText;return(0,z.useEffect)(()=>{s?r.current?.focus():i.current?.focus()},[s]),(0,B.jsxs)(zae,{onDismiss:n,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-4 border-b border-border`,children:[s?(0,B.jsx)(il,{className:`w-5 h-5 text-destructive shrink-0`}):(0,B.jsx)(lc,{className:`w-5 h-5 text-info shrink-0`}),(0,B.jsx)(`h3`,{id:`dialog-title`,className:`text-lg font-semibold text-foreground`,children:e.title})]}),(0,B.jsxs)(`div`,{className:`px-6 py-5 space-y-3`,children:[(0,B.jsx)(`p`,{id:`dialog-message`,className:`text-sm text-foreground whitespace-pre-line select-text cursor-text`,children:e.message}),c?(0,B.jsxs)(`label`,{className:`block text-xs text-muted-foreground`,children:[`Type `,(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:e.requiredText}),` to confirm`,(0,B.jsx)(`input`,{className:`mt-1 w-full rounded border border-border bg-background px-2 py-1.5 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,value:a,onChange:e=>o(e.target.value),"aria-label":`Confirmation text`,autoFocus:!0})]}):null]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-6 py-4 border-t border-border`,children:[(0,B.jsx)(`button`,{ref:r,onClick:n,className:`px-4 py-2 rounded-lg text-sm bg-secondary text-secondary-foreground hover:bg-secondary/80 transition-colors`,children:e.cancelLabel||`Cancel`}),(0,B.jsx)(`button`,{ref:i,onClick:t,disabled:!l,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${s?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:e.confirmLabel||`Confirm`})]})]})}function Vae({options:e,onClose:t}){let n=(0,z.useRef)(null);(0,z.useEffect)(()=>{n.current?.focus()},[]);let r={info:(0,B.jsx)(lc,{className:`w-5 h-5 text-info shrink-0`}),error:(0,B.jsx)(bs,{className:`w-5 h-5 text-destructive shrink-0`}),success:(0,B.jsx)(gs,{className:`w-5 h-5 text-success shrink-0`})},i=e.variant||`info`;return(0,B.jsxs)(zae,{onDismiss:t,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r[i],(0,B.jsx)(`h3`,{id:`alert-title`,className:`text-lg font-semibold text-foreground`,children:e.title||(i===`error`?`Error`:i===`success`?`Success`:`Notice`)})]}),(0,B.jsx)(`button`,{onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,B.jsx)(sl,{className:`w-5 h-5`})})]}),(0,B.jsx)(`div`,{className:`px-6 py-5`,children:(0,B.jsx)(`p`,{id:`alert-message`,className:`text-sm text-foreground whitespace-pre-line select-text cursor-text`,children:e.message})}),(0,B.jsx)(`div`,{className:`flex items-center justify-end px-6 py-4 border-t border-border`,children:(0,B.jsx)(`button`,{ref:n,onClick:t,className:`px-4 py-2 rounded-lg text-sm bg-primary text-primary-foreground hover:bg-primary/90 transition-colors font-medium`,children:`OK`})})]})}function Hae({children:e}){let[t,n]=(0,z.useState)(null),r=(0,z.useRef)(null),i=(0,z.useCallback)(()=>{r.current&&=(r.current.resolve(!1),null)},[]),a=(0,z.useCallback)(e=>(i(),new Promise(t=>{let i={type:`confirm`,options:e,resolve:t};r.current=i,n(i)})),[i]),o=(0,z.useCallback)(e=>(i(),new Promise(t=>{let i={type:`alert`,options:e,resolve:()=>t()};r.current=i,n(i)})),[i]),s=(0,z.useCallback)(()=>{t?.resolve(!0),r.current=null,n(null)},[t]),c=(0,z.useCallback)(()=>{t?.resolve(!1),r.current=null,n(null)},[t]),l=(0,z.useCallback)(()=>{t?.resolve(!1),r.current=null,n(null)},[t]);return(0,B.jsxs)(ll.Provider,{value:{confirm:a,alert:o},children:[e,t?.type===`confirm`&&(0,B.jsx)(Bae,{options:t.options,onConfirm:s,onCancel:c}),t?.type===`alert`&&(0,B.jsx)(Vae,{options:t.options,onClose:l})]})}var pl=n(s(),1),Uae=e=>{switch(e){case`success`:return Kae;case`info`:return Jae;case`warning`:return qae;case`error`:return Yae;default:return null}},Wae=Array(12).fill(0),Gae=({visible:e,className:t})=>z.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},z.createElement(`div`,{className:`sonner-spinner`},Wae.map((e,t)=>z.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Kae=z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},z.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`})),qae=z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},z.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`})),Jae=z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},z.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`})),Yae=z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},z.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`})),Xae=z.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`},z.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),z.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),Zae=()=>{let[e,t]=z.useState(document.hidden);return z.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},ml=1,hl=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:ml++,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=>(this.dismissedToasts.add(e),e||this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,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=e instanceof Promise?e:e(),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],z.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if($ae(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;this.create({id:n,type:`error`,message:r,description:a})}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;this.create({id:n,type:`success`,message:r,description:a})}}).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;this.create({id:n,type:`error`,message:r,description:a})}}).finally(()=>{var e;i&&(this.dismiss(n),n=void 0),(e=t.finally)==null||e.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||ml++;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}},Qae=(e,t)=>{let n=t?.id||ml++;return hl.addToast({title:e,...t,id:n}),n},$ae=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,U=Object.assign(Qae,{success:hl.success,info:hl.info,warning:hl.warning,error:hl.error,custom:hl.custom,message:hl.message,promise:hl.promise,dismiss:hl.dismiss,loading:hl.loading},{getHistory:()=>hl.toasts,getToasts:()=>hl.getActiveToasts()});function eoe(e,{insertAt:t}={}){if(!e||typeof document>`u`)return;let n=document.head||document.getElementsByTagName(`head`)[0],r=document.createElement(`style`);r.type=`text/css`,t===`top`&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}eoe(`:where(html[dir="ltr"]),:where([data-sonner-toaster][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%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][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%)}:where([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:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([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);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([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 #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([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)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([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;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([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);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-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([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}:where([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}:where([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, 0px)) translate(var(--swipe-amount-x, 0px));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{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{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{0%{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-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--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-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-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-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, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--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-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-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],[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],[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],[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],[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:nth-child(1){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)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{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%)}
|
|
4
4
|
`);function gl(e){return e.label!==void 0}var toe=3,noe=`32px`,roe=`16px`,ioe=4e3,aoe=356,ooe=14,soe=20,coe=200;function _l(...e){return e.filter(Boolean).join(` `)}function loe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var uoe=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,loadingIcon:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`,pauseWhenPageIsHidden:D}=e,[O,k]=z.useState(null),[A,j]=z.useState(null),[M,N]=z.useState(!1),[P,F]=z.useState(!1),[I,L]=z.useState(!1),[ee,R]=z.useState(!1),[te,ne]=z.useState(!1),[re,ie]=z.useState(0),[ae,oe]=z.useState(0),se=z.useRef(n.duration||y||ioe),ce=z.useRef(null),le=z.useRef(null),ue=c===0,de=c+1<=o,fe=n.type,pe=n.dismissible!==!1,me=n.className||``,he=n.descriptionClassName||``,ge=z.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),_e=z.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ve=z.useMemo(()=>n.duration||y||ioe,[n.duration,y]),ye=z.useRef(0),be=z.useRef(0),xe=z.useRef(0),Se=z.useRef(null),[Ce,we]=b.split(`-`),Te=z.useMemo(()=>s.reduce((e,t,n)=>n>=ge?e:e+t.height,0),[s,ge]),Ee=Zae(),De=n.invert||t,Oe=fe===`loading`;be.current=z.useMemo(()=>ge*x+Te,[ge,Te]),z.useEffect(()=>{se.current=ve},[ve]),z.useEffect(()=>{N(!0)},[]),z.useEffect(()=>{let e=le.current;if(e){let t=e.getBoundingClientRect().height;return oe(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),z.useLayoutEffect(()=>{if(!M)return;let e=le.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,oe(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])},[M,n.title,n.description,a,n.id]);let ke=z.useCallback(()=>{F(!0),ie(be.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},coe)},[n,d,a,be]);z.useEffect(()=>{if(n.promise&&fe===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||D&&Ee?(()=>{if(xe.current<ye.current){let e=new Date().getTime()-ye.current;se.current-=e}xe.current=new Date().getTime()})():se.current!==1/0&&(ye.current=new Date().getTime(),e=setTimeout(()=>{var e;(e=n.onAutoClose)==null||e.call(n,n),ke()},se.current)),()=>clearTimeout(e)},[u,i,n,fe,D,Ee,ke]),z.useEffect(()=>{n.delete&&ke()},[ke,n.delete]);function Ae(){return T!=null&&T.loading?z.createElement(`div`,{className:_l(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":fe===`loading`},T.loading):S?z.createElement(`div`,{className:_l(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":fe===`loading`},S):z.createElement(Gae,{className:_l(w?.loader,n?.classNames?.loader),visible:fe===`loading`})}return z.createElement(`li`,{tabIndex:0,ref:le,className:_l(_,me,w?.toast,n?.classNames?.toast,w?.default,w?.[fe],n?.classNames?.[fe]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":M,"data-promise":!!n.promise,"data-swiped":te,"data-removed":P,"data-visible":de,"data-y-position":Ce,"data-x-position":we,"data-index":c,"data-front":ue,"data-swiping":I,"data-dismissible":pe,"data-type":fe,"data-invert":De,"data-swipe-out":ee,"data-swipe-direction":A,"data-expanded":!!(u||C&&M),style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${P?re:be.current}px`,"--initial-height":C?`auto`:`${ae}px`,...m,...n.style},onDragEnd:()=>{L(!1),k(null),Se.current=null},onPointerDown:e=>{Oe||!pe||(ce.current=new Date,ie(be.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(L(!0),Se.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e;if(ee||!pe)return;Se.current=null;let t=Number(le.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),r=Number(le.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),i=new Date().getTime()-ce.current?.getTime(),a=O===`x`?t:r,o=Math.abs(a)/i;if(Math.abs(a)>=soe||o>.11){ie(be.current),(e=n.onDismiss)==null||e.call(n,n),j(O===`x`?t>0?`right`:`left`:r>0?`down`:`up`),ke(),R(!0),ne(!1);return}L(!1),k(null)},onPointerMove:t=>{var n,r;if(!Se.current||!pe||window.getSelection()?.toString().length>0)return;let i=t.clientY-Se.current.y,a=t.clientX-Se.current.x,o=e.swipeDirections??loe(b);!O&&(Math.abs(a)>1||Math.abs(i)>1)&&k(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0};O===`y`?(o.includes(`top`)||o.includes(`bottom`))&&(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)&&(s.y=i):O===`x`&&(o.includes(`left`)||o.includes(`right`))&&(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)&&(s.x=a),(Math.abs(s.x)>0||Math.abs(s.y)>0)&&ne(!0),(n=le.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=le.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},_e&&!n.jsx?z.createElement(`button`,{"aria-label":E,"data-disabled":Oe,"data-close-button":!0,onClick:Oe||!pe?()=>{}:()=>{var e;ke(),(e=n.onDismiss)==null||e.call(n,n)},className:_l(w?.closeButton,n?.classNames?.closeButton)},T?.close??Xae):null,n.jsx||(0,z.isValidElement)(n.title)?n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title:z.createElement(z.Fragment,null,fe||n.icon||n.promise?z.createElement(`div`,{"data-icon":``,className:_l(w?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Ae():null,n.type===`loading`?null:n.icon||T?.[fe]||Uae(fe)):null,z.createElement(`div`,{"data-content":``,className:_l(w?.content,n?.classNames?.content)},z.createElement(`div`,{"data-title":``,className:_l(w?.title,n?.classNames?.title)},typeof n.title==`function`?n.title():n.title),n.description?z.createElement(`div`,{"data-description":``,className:_l(v,he,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),(0,z.isValidElement)(n.cancel)?n.cancel:n.cancel&&gl(n.cancel)?z.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{var t,r;gl(n.cancel)&&pe&&((r=(t=n.cancel).onClick)==null||r.call(t,e),ke())},className:_l(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,(0,z.isValidElement)(n.action)?n.action:n.action&&gl(n.action)?z.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{var t,r;gl(n.action)&&((r=(t=n.action).onClick)==null||r.call(t,e),!e.defaultPrevented&&ke())},className:_l(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null))};function doe(){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 foe(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?roe:noe;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 poe=(0,z.forwardRef)(function(e,t){let{invert:n,position:r=`bottom-right`,hotkey:i=[`altKey`,`KeyT`],expand:a,closeButton:o,className:s,offset:c,mobileOffset:l,theme:u=`light`,richColors:d,duration:f,style:p,visibleToasts:m=toe,toastOptions:h,dir:g=doe(),gap:_=ooe,loadingIcon:v,icons:y,containerAriaLabel:b=`Notifications`,pauseWhenPageIsHidden:x}=e,[S,C]=z.useState([]),w=z.useMemo(()=>Array.from(new Set([r].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,r]),[T,E]=z.useState([]),[D,O]=z.useState(!1),[k,A]=z.useState(!1),[j,M]=z.useState(u===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:u),N=z.useRef(null),P=i.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=z.useRef(null),I=z.useRef(!1),L=z.useCallback(e=>{C(t=>{var n;return(n=t.find(t=>t.id===e.id))!=null&&n.delete||hl.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return z.useEffect(()=>hl.subscribe(e=>{if(e.dismiss){C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t));return}setTimeout(()=>{pl.flushSync(()=>{C(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)]})})})}),[]),z.useEffect(()=>{if(u!==`system`){M(u);return}if(u===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[u]),z.useEffect(()=>{S.length<=1&&O(!1)},[S]),z.useEffect(()=>{let e=e=>{var t,n;i.every(t=>e[t]||e.code===t)&&(O(!0),(t=N.current)==null||t.focus()),e.code===`Escape`&&(document.activeElement===N.current||(n=N.current)!=null&&n.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),z.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),z.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,r)=>{let[i,u]=t.split(`-`);return S.length?z.createElement(`ol`,{key:t,dir:g===`auto`?doe():g,tabIndex:-1,ref:N,className:s,"data-sonner-toaster":!0,"data-theme":j,"data-y-position":i,"data-lifted":D&&S.length>1&&!a,"data-x-position":u,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${aoe}px`,"--gap":`${_}px`,...p,...foe(c,l)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.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)},S.filter(e=>!e.position&&r===0||e.position===t).map((r,i)=>z.createElement(uoe,{key:r.id,icons:y,index:i,toast:r,defaultRichColors:d,duration:h?.duration??f,className:h?.className,descriptionClassName:h?.descriptionClassName,invert:n,visibleToasts:m,closeButton:h?.closeButton??o,interacting:k,position:t,style:h?.style,unstyled:h?.unstyled,classNames:h?.classNames,cancelButtonStyle:h?.cancelButtonStyle,actionButtonStyle:h?.actionButtonStyle,removeToast:L,toasts:S.filter(e=>e.position==r.position),heights:T.filter(e=>e.position==r.position),setHeights:E,expandByDefault:a,gap:_,loadingIcon:v,expanded:D,pauseWhenPageIsHidden:x,swipeDirections:e.swipeDirections}))):null}))});function vl(e,t={}){let{timeoutMs:n=2e4,signal:r,...i}=t,a=AbortSignal.timeout(n);return fetch(e,{...i,signal:r?AbortSignal.any([r,a]):a})}var yl=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},moe={pipe(){return yl(this,arguments)}},bl=function(){function e(){}return e.prototype=moe,e}(),xl=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},Sl=e=>e,Cl=e=>()=>e,wl=Cl(!0),hoe=Cl(!1),Tl=Cl(void 0),El=Tl;function goe(e,t,n,r,i,a,o,s,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return s(o(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(s(o(a(i(r(n(t(e.apply(this,arguments)))))))))}}}function Dl(e){let t=new WeakMap;return n=>{if(t.has(n))return t.get(n);let r=e(n);return t.set(n,r),r}}var Ol=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},kl=new WeakSet;function Al(e){return typeof e==`string`}function jl(e){return typeof e==`number`}function _oe(e){return typeof e==`boolean`}function voe(e){return typeof e==`symbol`}function yoe(e){return Al(e)||jl(e)||voe(e)}function Ml(e){return typeof e==`function`}function boe(e){return e!==void 0}function xoe(e){return e!=null}function Soe(e){return!1}function Coe(e){return!0}function woe(e){return typeof e==`object`&&!!e||Ml(e)}var Nl=xl(2,(e,t)=>woe(e)&&t in e);function Toe(e){return Nl(e,Symbol.iterator)||Al(e)}var Pl=`~effect/interfaces/Hash`,Fl=e=>{switch(typeof e){case`number`:return zl(e);case`bigint`:return Bl(e.toString(10));case`boolean`:return Bl(String(e));case`symbol`:return Bl(String(e));case`string`:return Bl(e);case`undefined`:return Bl(`undefined`);case`function`:case`object`:if(e===null)return Bl(`null`);if(e instanceof Date)return Bl(e.toISOString());if(e instanceof RegExp)return Bl(e.toString());{if(kl.has(e))return Il(e);if(Wl.has(e))return Wl.get(e);let t=joe(e,()=>Eoe(e)?e[Pl]():typeof e==`function`?Il(e):Array.isArray(e)||ArrayBuffer.isView(e)?Ooe(e):e instanceof Map?koe(e):e instanceof Set?Aoe(e):Vl(e));return Wl.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Il=e=>(Ul.has(e)||Ul.set(e,zl(Math.floor(Math.random()*(2**53-1)))),Ul.get(e)),Ll=xl(2,(e,t)=>e*53^t),Rl=e=>e&3221225471|e>>>1&1073741824,Eoe=e=>Nl(e,Pl),zl=e=>{if(e!==e)return Bl(`NaN`);if(e===1/0)return Bl(`Infinity`);if(e===-1/0)return Bl(`-Infinity`);let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Rl(t)},Bl=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Rl(t)},Doe=(e,t)=>{let n=12289;for(let r of t)n^=Ll(Fl(r),Fl(e[r]));return Rl(n)},Vl=e=>Doe(e,Ol(e)),Hl=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return Rl(r)},Ooe=Hl(6151,Fl),koe=Hl(Bl(`Map`),([e,t])=>Ll(Fl(e),Fl(t))),Aoe=Hl(Bl(`Set`),Fl),Ul=new WeakMap,Wl=new WeakMap,Gl=new WeakSet;function joe(e,t){if(Gl.has(e))return Bl(`[Circular]`);Gl.add(e);let n=t();return Gl.delete(e),n}var Kl=`~effect/interfaces/Equal`;function ql(){return arguments.length===1?e=>Jl(e,arguments[0]):Jl(arguments[0],arguments[1])}function Jl(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||kl.has(e)||kl.has(t)?!1:Poe(e,t,Noe):!1}function Moe(e,t,n){let r=Yl.has(e),i=Xl.has(t);if(r&&i)return!0;if(r||i)return!1;Yl.add(e),Xl.add(t);let a=n();return Yl.delete(e),Xl.delete(t),a}var Yl=new WeakSet,Xl=new WeakSet;function Noe(e,t){if(Fl(e)!==Fl(t))return!1;if(e instanceof Date)return t instanceof Date?e.toISOString()===t.toISOString():!1;if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=Hoe(e),r=Hoe(t);if(n!==r)return!1;let i=n&&r;return typeof e==`function`&&!i?!1:Moe(e,t,()=>i?e[Kl](t):Array.isArray(e)?!Array.isArray(t)||e.length!==t.length?!1:Foe(e,t):ArrayBuffer.isView(e)?!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength?!1:Ioe(e,t):e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:zoe(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Voe(e,t):Loe(e,t))}function Poe(e,t,n){let r=Zl.get(e);if(!r)r=new WeakMap,Zl.set(e,r);else if(r.has(t))return r.get(t);let i=n(e,t);r.set(t,i);let a=Zl.get(t);return a||(a=new WeakMap,Zl.set(t,a)),a.set(e,i),i}var Zl=new WeakMap;function Foe(e,t){for(let n=0;n<e.length;n++)if(!Jl(e[n],t[n]))return!1;return!0}function Ioe(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 Loe(e,t){let n=Ol(e),r=Ol(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Jl(e[i],t[i]))return!1;return!0}function Roe(e,t){return function(n,r){for(let[i,a]of n){let n=!1;for(let[o,s]of r)if(e(i,o)&&t(a,s)){n=!0;break}if(!n)return!1}return!0}}var zoe=Roe(Jl,Jl);function Boe(e){return function(t,n){for(let r of t){let t=!1;for(let i of n)if(e(r,i)){t=!0;break}if(!t)return!1}return!0}}var Voe=Boe(Jl),Hoe=e=>Nl(e,Kl),Uoe=()=>ql,Woe=e=>(t,n)=>t===n||e(t,n),Goe=(e,t)=>e===t,Koe=()=>Goe;function qoe(e){return Woe((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var Joe=e=>e.length>0,Ql=Symbol.for(`~effect/Redactable`),Yoe=e=>Nl(e,Ql);function $l(e){return Yoe(e)?Xoe(e):e}function Xoe(e){return e[Ql](globalThis[`~effect/Fiber/currentFiber`]?.context??Zoe)}var eu=`~effect/Fiber/currentFiber`,Zoe={"~effect/Context":{},mapUnsafe:new Map,pipe(){return yl(this,arguments)}};function tu(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,n=0){if(Array.isArray(e)){if(r.has(e))return Qoe;if(r.add(e),!i||e.length<=1)return`[${e.map(e=>c(e,n)).join(`,`)}]`;let t=e.map(e=>c(e,n+1)).join(`,
|
|
@@ -43,7 +43,7 @@ import{a as e,n as t,o as n,r,t as i}from"./chunk-jRWAZmH_.js";import{n as a,t a
|
|
|
43
43
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
44
44
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=Ox(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Fke.peek=Ike;function Fke(e){return e.value||``}function Ike(){return`<`}Lke.peek=Rke;function Lke(e,t,n,r){let i=Dx(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Rke(){return`!`}zke.peek=Bke;function zke(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Bke(){return`!`}Vke.peek=Hke;function Vke(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Hke(){return"`"}function Uke(e,t){let n=Cb(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Wke.peek=Gke;function Wke(e,t,n,r){let i=Dx(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Uke(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Gke(e,t,n){return Uke(e,n)?`<`:`[`}Kke.peek=qke;function Kke(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function qke(){return`[`}function Ax(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Jke(e){let t=Ax(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Yke(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Xke(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Zke(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Yke(n):Ax(n),s=e.ordered?o===`.`?`)`:`.`:Jke(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Xke(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Qke(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function $ke(e,t,n,r){let i=Qke(n),a=n.bulletCurrent||Ax(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function eAe(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var tAe=rx([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function nAe(e,t,n,r){return(e.children.some(function(e){return tAe(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function rAe(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}iAe.peek=aAe;function iAe(e,t,n,r){let i=rAe(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=kx(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Ox(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=kx(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Ox(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function aAe(e,t,n){return n.options.strong||`*`}function oAe(e,t,n,r){return n.safe(e.value,r)}function sAe(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function cAe(e,t,n){let r=(Xke(n)+(n.options.ruleSpaces?` `:``)).repeat(sAe(n));return n.options.ruleSpaces?r.slice(0,-1):r}var lAe={blockquote:yke,break:Cke,code:Dke,definition:kke,emphasis:jke,hardBreak:Cke,heading:Pke,html:Fke,image:Lke,imageReference:zke,inlineCode:Vke,link:Wke,linkReference:Kke,list:Zke,listItem:$ke,paragraph:eAe,root:nAe,strong:iAe,text:oAe,thematicBreak:cAe};function uAe(){return{enter:{table:dAe,tableData:mAe,tableHeader:mAe,tableRow:pAe},exit:{codeText:hAe,table:fAe,tableData:jx,tableHeader:jx,tableRow:jx}}}function dAe(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function fAe(e){this.exit(e),this.data.inTable=void 0}function pAe(e){this.enter({type:`tableRow`,children:[]},e)}function jx(e){this.exit(e)}function mAe(e){this.enter({type:`tableCell`,children:[]},e)}function hAe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,gAe));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function gAe(e,t){return t===`|`?t:e}function _Ae(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
45
45
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
46
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return gke(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=lAe.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function vAe(){return{exit:{taskListCheckValueChecked:bAe,taskListCheckValueUnchecked:bAe,paragraph:xAe}}}function yAe(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:SAe}}}function bAe(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function xAe(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function SAe(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=lAe.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function CAe(){return[FOe(),ike(),lke(),uAe(),vAe()]}function wAe(e){return{extensions:[IOe(),ake(e),uke(),_Ae(e),yAe()]}}var TAe={tokenize:IAe,partial:!0},EAe={tokenize:LAe,partial:!0},DAe={tokenize:RAe,partial:!0},OAe={tokenize:zAe,partial:!0},kAe={tokenize:BAe,partial:!0},AAe={name:`wwwAutolink`,tokenize:PAe,previous:VAe},jAe={name:`protocolAutolink`,tokenize:FAe,previous:HAe},Mx={name:`emailAutolink`,tokenize:NAe,previous:UAe},Nx={};function MAe(){return{text:Nx}}for(var Px=48;Px<123;)Nx[Px]=Mx,Px++,Px===58?Px=65:Px===91&&(Px=97);Nx[43]=Mx,Nx[45]=Mx,Nx[46]=Mx,Nx[95]=Mx,Nx[72]=[Mx,jAe],Nx[104]=[Mx,jAe],Nx[87]=[Mx,AAe],Nx[119]=[Mx,AAe];function NAe(e,t,n){let r=this,i,a;return o;function o(t){return!Fx(t)||!UAe.call(r,r.previous)||Ix(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Fx(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(kAe,u,l)(t):t===45||t===95||kb(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Ob(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function PAe(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!VAe.call(r,r.previous)||Ix(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(TAe,e.attempt(EAe,e.attempt(DAe,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function FAe(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&HAe.call(r,r.previous)&&!Ix(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Ob(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ab(t)||Nb(t)||Ib(t)||Fb(t)?n(t):e.attempt(EAe,e.attempt(DAe,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function IAe(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function LAe(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(OAe,c,s)(t):t===null||Nb(t)||Ib(t)||t!==45&&Fb(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function RAe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(OAe,t,a)(o):o===null||Nb(o)||Ib(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zAe(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Nb(o)||Ib(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Nb(e)||Ib(e)?t(e):r(e)}function a(e){return Ob(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Ob(t)?(e.consume(t),o):n(t)}}function BAe(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return kb(e)?n(e):t(e)}}function VAe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Nb(e)}function HAe(e){return!Ob(e)}function UAe(e){return!(e===47||Fx(e))}function Fx(e){return e===43||e===45||e===46||e===95||kb(e)}function Ix(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var WAe={tokenize:QAe,partial:!0};function GAe(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:YAe,continuation:{tokenize:XAe},exit:ZAe}},text:{91:{name:`gfmFootnoteCall`,tokenize:JAe},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:KAe,resolveTo:qAe}}}}function KAe(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Db(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function qAe(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function JAe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Nb(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Db(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Nb(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function YAe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Nb(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Db(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Nb(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),zb(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function XAe(e,t,n){return e.check(Ub,t,e.attempt(WAe,t,n))}function ZAe(e){e.exit(`gfmFootnoteDefinition`)}function QAe(e,t,n){let r=this;return zb(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function $Ae(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Tb(o,o.length,0,Vb(s,e.slice(r+1,n),t)),Tb(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Tb(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Bb(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Bb(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var eje=class{constructor(){this.map=[]}add(e,t,n){tje(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function tje(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function nje(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function rje(){return{flow:{null:{name:`table`,tokenize:ije,resolveAll:aje}}}}function ije(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Mb(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Pb(t)?zb(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Nb(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Pb(t)?zb(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Pb(t)?zb(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Mb(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Pb(t)?zb(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Mb(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Mb(n)?(e.exit(`tableRow`),t(n)):Pb(n)?zb(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Nb(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function aje(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new eje;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(oje(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Lx(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Lx(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Lx(f,t,o,i,n,d)):(o[0]=o[1],d=Lx(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&oje(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=nje(t.events,n))}return e}function Lx(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Rx(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Rx(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Rx(t.events,n[2]),a=Rx(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Rx(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function oje(e,t,n,r,i){let a=[],o=Rx(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Rx(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var sje={name:`tasklistCheck`,tokenize:lje};function cje(){return{text:{91:sje}}}function lje(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Nb(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Mb(r)?t(r):Pb(r)?e.check({tokenize:uje},t,n)(r):n(r)}}function uje(e,t,n){return zb(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function dje(e){return Twe([MAe(),GAe(),$Ae(e),rje(),cje()])}var fje={};function zx(e){let t=this,n=e||fje,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(dje(n)),a.push(CAe()),o.push(wAe(n))}function pje(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function mje(e){return e.replace(/\\/g,`/`)}function hje(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function gje(e){return e.replace(/[\\/]+$/,``)}function _je(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function vje(e){return e.replace(/^\.\/+/u,``).replace(/^\/+/u,``)}function yje(e,t){let{path:n,line:r,column:i}=pje(e),a=hje(mje(n)),o=a;if(t){let e=hje(mje(gje(t))),n=_je(e),r=a.toLowerCase(),i=e.toLowerCase(),s=`${i}/`,c=`${n.toLowerCase()}/`;if(r===i)o=n;else if(r.startsWith(s))o=`${n}/${a.slice(e.length+1)}`;else if(!a.startsWith(`/`)){let e=vje(a);o=r.startsWith(c)?a:`${n}/${e}`}}return r?`${o}:${r}${i?`:${i}`:``}`:o}var Bx=/^[A-Za-z]:[\\/]/,Vx=/^\\\\/,bje=/^([A-Za-z][A-Za-z0-9+.-]*):(.*)$/,xje=/^(~\/|\.{1,2}\/)/,Sje=/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}$/,Cje=/^[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}$/,wje=/:\d+(?::\d+)?$/,Tje=/^\d+(?::\d+)?$/,Eje=[`/Users/`,`/home/`,`/tmp/`,`/var/`,`/etc/`,`/opt/`,`/mnt/`,`/Volumes/`,`/private/`,`/root/`],Dje=/(^|[\s([{"'`])((?:\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root)\/[A-Za-z0-9._~+@%/=-]+|(?:~\/|\.{1,2}\/)?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+)(?::\d+(?::\d+)?)?)/g;function Hx(e){try{return decodeURIComponent(e)}catch{return e}}function Oje(e){return e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e}function kje(e){return Oje(e.trim())}function Aje(e){let t=e.indexOf(`#`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t):``,i=n.indexOf(`?`);return{path:i>=0?n.slice(0,i):n,hash:r}}function jje(e){return/^\/[A-Za-z]:[\\/]/.test(e)?e.slice(1):e}function Mje(e,t){try{let n=new URL(e);if(n.protocol.toLowerCase()!==`file:`)return null;let r=n.pathname;if(r.length===0)return null;let i=jje(r);return{path:t?.decodePath===!1?i:Hx(i),hash:n.hash}}catch{return null}}function Nje(e){if(!e.startsWith(`/`))return!1;if(Eje.some(t=>e.startsWith(t))||wje.test(e))return!0;let t=e.slice(e.lastIndexOf(`/`)+1);return/\.[A-Za-z0-9_-]+$/.test(t)}function Pje(e,t){if(!t||wje.test(e))return e;let n=t.match(/^#L(\d+)(?:C(\d+))?$/i);if(!n?.[1])return e;let r=n[1],i=n[2];return`${e}:${r}${i?`:${i}`:``}`}function Fje(e){return Bx.test(e)||Vx.test(e)||xje.test(e)?!0:e.startsWith(`/`)?Nje(e):Sje.test(e)||Cje.test(e)}function Ije(e){return xje.test(e)||!e.startsWith(`/`)&&!Bx.test(e)&&!Vx.test(e)}function Lje(e){let t=e.match(bje);if(!t)return!1;let n=t[2]??``;return n.startsWith(`//`)?!0:!Tje.test(n)}function Rje(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function zje(e){return e.startsWith(`/`)||Rje(e)}function Bje(e){return Rje(e)||/[A-Za-z]:\\/.test(e)}function Vje(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replace(/\//g,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function Hje(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function Uje(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function Wje(e,t){let{path:n,line:r,column:i}=Uje(e),a=n;if(n.startsWith(`~/`)){let e=Hje(t);if(e){let t=Bje(e)?`\\`:`/`;a=Vje(e,n.slice(2),t)}}else zje(n)||(a=Vje(t,n,Bje(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}function Gje(e){if(!e)return null;let t=kje(e);if(t.length===0||t.startsWith(`#`))return null;let n=t.toLowerCase().startsWith(`file:`)?Mje(t):null,r=n??Aje(t),i=jje(n?r.path.trim():Hx(r.path.trim())),a=Hx(r.hash.trim());return i.length===0||!Bx.test(i)&&!Vx.test(i)&&Lje(i)||!Fje(i)?null:Pje(i,a)}function Kje(e){return Gje(e)!==null}function qje(e,t){let n=Gje(e);return n?Ije(n)?t?Wje(n,t):null:n:null}function Jje(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function Yje(e,t){if(e.length===0)return[{text:e}];let n=[],r=0;Dje.lastIndex=0;for(let i of e.matchAll(Dje)){let a=i[1]??``,o=i[2];if(!o)continue;let s=i.index+a.length,c=s+o.length;s<r||!Xje(o,t)||(s>r&&n.push({text:e.slice(r,s)}),n.push({text:o,href:o}),r=c)}return r===0?[{text:e}]:(r<e.length&&n.push({text:e.slice(r)}),n)}function Xje(e,t){let n=qje(e,t);if(!n)return null;let{path:r,line:i,column:a}=Uje(n),o=i?Number.parseInt(i,10):NaN,s=a?Number.parseInt(a,10):NaN,c=Number.isFinite(o)?o:void 0,l=Number.isFinite(s)?s:void 0;return{filePath:r,targetPath:n,displayPath:yje(n,t),basename:Jje(r),...c===void 0?{}:{line:c},...l===void 0?{}:{column:l}}}var Ux=null;function Zje(e,t,n){let r=e.getBoundingClientRect(),i=Math.min(Math.max(4,t),Math.max(4,window.innerWidth-r.width-4)),a=Math.min(Math.max(4,n),Math.max(4,window.innerHeight-r.height-4));e.style.left=`${i}px`,e.style.top=`${a}px`}function Qje({items:e,x:t,y:n}){Ux?.();let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`,r.dataset.testid=`context-menu-overlay`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-xl animate-in fade-in zoom-in-95`,i.style.left=`${t}px`,i.style.top=`${n}px`,i.setAttribute(`role`,`menu`);let a=()=>{document.removeEventListener(`keydown`,o),document.removeEventListener(`mousedown`,s),r.remove(),i.remove(),Ux===a&&(Ux=null)},o=e=>{e.key===`Escape`&&(e.preventDefault(),a())},s=e=>{i.contains(e.target)||a()};for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.textContent=t.label,e.disabled=t.disabled===!0,e.setAttribute(`role`,`menuitem`),e.className=t.disabled===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-muted-foreground/60 cursor-not-allowed`:t.destructive===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-destructive hover:bg-accent cursor-default`:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-popover-foreground hover:bg-accent cursor-default`,t.disabled!==!0&&e.addEventListener(`click`,()=>{a(),t.onClick()}),i.appendChild(e)}Ux=a,document.body.appendChild(r),document.body.appendChild(i),document.addEventListener(`keydown`,o),document.addEventListener(`mousedown`,s),(window.requestAnimationFrame??(e=>window.setTimeout(e,0)))(()=>Zje(i,t,n))}var $je=`overdeck:last-editor`;function Wx(){try{return localStorage.getItem($je)}catch{return null}}function Gx(e){try{localStorage.setItem($je,e)}catch{}}var eMe=`overdeck:markdown-open-target`;function tMe(){try{return localStorage.getItem(eMe)??`internal`}catch{return`internal`}}function nMe(e){try{localStorage.setItem(eMe,e)}catch{}}function Kx(...e){return e.filter(Boolean).join(` `)}var rMe=(0,z.createContext)(null),iMe=rMe.Provider;function aMe(){return(0,z.useContext)(rMe)}var qx=8,oMe=240;function Jx(e,t,{estimatedWidth:n=280,preferredHeight:r=400}={}){let[i,a]=(0,z.useState)({openUp:!1,align:`left`,maxHeight:r});return(0,z.useLayoutEffect)(()=>{if(!e||!t.current)return;let i=t.current.getBoundingClientRect(),o=window.innerHeight-i.bottom-qx,s=i.top-qx,c=o<Math.min(r,oMe)&&s>o;a({openUp:c,align:i.left+n>window.innerWidth-qx?`right`:`left`,maxHeight:Math.max(120,Math.min(r,c?s:o))})},[e,t,n,r]),i}var sMe=`size-3.5 shrink-0 text-muted-foreground`,cMe=12,lMe=new Set([`c`,`cc`,`cpp`,`cs`,`css`,`go`,`html`,`java`,`js`,`jsx`,`kt`,`mjs`,`php`,`py`,`rb`,`rs`,`scss`,`sh`,`sql`,`swift`,`ts`,`tsx`,`vue`]),uMe=new Set([`log`,`md`,`mdx`,`txt`]),dMe=new Set([`avif`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]),fMe=new Set([`7z`,`gz`,`rar`,`tar`,`tgz`,`zip`]),pMe=new Set([`env`,`toml`,`yaml`,`yml`]),mMe=null,Yx=null;async function hMe(){try{return Yx||=lb().request(e=>e[Cy.getAvailableEditors]()).then(e=>e.editors),await Yx}catch{return Yx=null,[]}}function gMe(e){let t=e.replace(/\\/g,`/`).split(`/`).at(-1)??``,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}var _Me=new Set([`md`,`mdx`,`markdown`]);function vMe(e){return _Me.has(gMe(e))}function yMe(e){let t=gMe(e);return t===`json`?Yie:lMe.has(t)?Kie:uMe.has(t)?Bs:dMe.has(t)?Jie:fMe.has(t)?Gie:pMe.has(t)?qie:Qie}function bMe({displayPath:e,line:t,column:n}){let r=t?e.replace(/:\d+(?::\d+)?$/,``):e,i=t?`L${t}${n?`:C${n}`:``}`:null;return i?`${r} · ${i}`:r}async function xMe(){let e=(await lb().request(e=>e[Cy.getAvailableEditors]())).editors,t=Wx(),n=t&&e.includes(t)?t:xy.find(t=>e.includes(t.id))?.id;if(!n)throw Error(`No available editors found.`);return Gx(n),n}function SMe(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}async function CMe(e,t){try{return mMe||=v(()=>Promise.resolve().then(()=>odt).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),(await mMe).codeToHtml(e,{lang:t||`text`,theme:`github-light`})}catch{return`<pre><code>${SMe(e)}</code></pre>`}}function wMe(e){let t=e.replace(/:\d+(?::\d+)?$/,``).replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean);return n.length>1?n.slice(1).join(`/`):t}function TMe(e){return e.replace(/\\/g,`/`).match(/\/workspaces\/feature-([a-z]+-\d+)(?:\/|:|$)/i)?.[1]?.toUpperCase()}var EMe=(0,z.memo)(function({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a,className:o,issueId:s}){let c=yMe(e),l=bMe({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a}),u=vMe(e),d=aMe(),f=(0,z.useRef)(null),p=(0,z.useRef)(0),m=(0,z.useRef)(!1),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)({status:`loading`}),{openUp:y,align:b,maxHeight:x}=Jx(h,f,{estimatedWidth:520,preferredHeight:360}),S=s??TMe(t),C=(0,z.useMemo)(()=>wMe(n),[n]),w=(0,z.useCallback)(()=>{xMe().then(e=>lb().request(n=>n[Cy.shellOpenInEditor]({cwd:t,editor:e}))).then(()=>{U.success(`Opened in editor`)}).catch(e=>{U.error(`Failed to open file: ${e instanceof Error?e.message:String(e)}`)})},[t]),T=(0,z.useCallback)(e=>{lb().request(n=>n[Cy.shellOpenInEditor]({cwd:t,editor:e})).then(()=>{U.success(`Opened in editor`)}).catch(e=>{U.error(`Failed to open file: ${e instanceof Error?e.message:String(e)}`)})},[t]),E=(0,z.useCallback)(()=>{let t=tMe();if(t===`internal`){if(d){d.openOrFocusEditorPane(e,r);return}w();return}T(t)},[d,e,r,w,T]),D=(0,z.useCallback)(()=>{p.current++,g(!1)},[]),O=(0,z.useCallback)(()=>{let e=S;if(!e){let e=`No issue context available for Quickview`;v({status:`error`,message:e}),g(!0),U.error(e);return}let t=++p.current;v({status:`loading`}),g(!0),lb().request(t=>t[Cy.readWorkspaceFile]({issueId:e,relativePath:C,...i?{line:i}:{},contextLines:cMe})).then(e=>CMe(e.text,e.lang).then(t=>({html:t,result:e}))).then(({html:e,result:n})=>{t===p.current&&v({status:`ready`,html:e,truncated:n.truncated,totalLines:n.totalLines})}).catch(e=>{if(t!==p.current)return;let n=e instanceof Error?e.message:String(e);v({status:`error`,message:n}),U.error(`Failed to load Quickview: ${n}`)})},[i,S,C]),k=(0,z.useCallback)((e,t)=>{navigator.clipboard.writeText(e).then(()=>{U.success(`Copied ${t}`)}).catch(e=>{U.error(`Failed to copy ${t}: ${e instanceof Error?e.message:String(e)}`)})},[]),A=(0,z.useCallback)((i,a)=>{hMe().then(o=>{Qje({x:i,y:a,items:[{label:`Open in internal editor`,onClick:()=>{nMe(`internal`),d?d.openOrFocusEditorPane(e,r):w()}},...xy.filter(e=>o.includes(e.id)).map(e=>({label:`Open in ${e.label}`,onClick:()=>{nMe(e.id),T(e.id)}})),{label:`Copy relative path`,onClick:()=>k(n,`relative path`)},{label:`Copy full path`,onClick:()=>k(t,`full path`)}]})})},[d,e,t,r,w,T,n,k]);return(0,z.useEffect)(()=>{let e=e=>{e.key===`Shift`&&m.current&&!h&&O()},t=e=>{e.key===`Shift`&&D()};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[D,O,h]),(0,B.jsxs)(`span`,{ref:f,className:`relative inline-flex max-w-full align-baseline`,"data-testid":`markdown-file-link-container`,onMouseEnter:e=>{m.current=!0,e.shiftKey&&O()},onMouseLeave:()=>{m.current=!1,D()},children:[(0,B.jsxs)(`a`,{href:t,title:t,className:Kx(`chat-markdown-file-link relative top-[2px] inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-card px-2 py-0.5 font-mono text-[11px] leading-5 text-foreground no-underline transition-colors hover:border-primary/50 hover:bg-accent`,o),onClick:e=>{e.preventDefault(),e.stopPropagation(),u?E():w()},onContextMenu:e=>{if(e.preventDefault(),e.stopPropagation(),u){A(e.clientX,e.clientY);return}Qje({x:e.clientX,y:e.clientY,items:[{label:`Open in editor`,onClick:w},{label:`Copy relative path`,onClick:()=>k(n,`relative path`)},{label:`Copy full path`,onClick:()=>k(t,`full path`)}]})},children:[(0,B.jsx)(c,{className:sMe,"aria-hidden":`true`,"data-testid":`markdown-file-link-icon`}),(0,B.jsx)(`span`,{className:`truncate`,"data-testid":`markdown-file-link-label`,children:l})]}),h&&(0,B.jsxs)(`div`,{"data-testid":`markdown-file-quickview`,className:`absolute z-50 w-[min(520px,calc(100vw-16px))] overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl`,style:{maxHeight:`${x}px`,...y?{bottom:`100%`,marginBottom:6}:{top:`100%`,marginTop:6},...b===`right`?{right:0}:{left:0}},children:[_.status===`loading`&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-xs text-muted-foreground`,"data-testid":`markdown-file-quickview-loading`,children:[(0,B.jsx)(gc,{size:13,className:`animate-spin`,"aria-hidden":`true`}),`Loading preview…`]}),_.status===`error`&&(0,B.jsx)(`div`,{className:`p-3 text-xs text-destructive`,"data-testid":`markdown-file-quickview-error`,children:_.message}),_.status===`ready`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{"data-testid":`markdown-file-quickview-content`,className:`max-h-[300px] overflow-auto text-xs [&_pre]:m-0 [&_pre]:p-3 [&_pre]:text-xs`,dangerouslySetInnerHTML:{__html:_.html}}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[i?`line ${i}`:`top of file`,` · `,_.totalLines,` lines`]}),_.truncated&&(0,B.jsx)(`span`,{"data-testid":`markdown-file-quickview-truncated`,children:`truncated — first 256 KiB`})]})]})]})]})}),DMe=300*1e3,OMe=30*1e3,kMe=5e3,Xx=new Map;function AMe(e,t){return`${e??``}\0${t}`}function jMe(e,t){let n=AMe(e,t),r=Xx.get(n);return r?r.expiresAt<Date.now()?(Xx.delete(n),null):(Xx.delete(n),Xx.set(n,r),{exists:r.exists,kind:r.kind}):null}function MMe(e,t,n,r){if(Xx.size>=kMe){let e=Xx.keys().next().value;e!==void 0&&Xx.delete(e)}let i=n?DMe:OMe;Xx.set(AMe(e,t),{exists:n,kind:r,expiresAt:Date.now()+i})}var Zx=new Map;function NMe(e,t){return`${e??``}\0${t}`}function PMe(e,t){return t?!!e||t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)||t.startsWith(`\\\\`):!1}function FMe(e,t){if(!PMe(e,t))return{state:`missing`};let n=jMe(e,t);return n?n.exists?{state:`exists`,kind:n.kind}:{state:`missing`}:{state:`loading`}}function IMe(e,t){let[n,r]=(0,z.useState)(()=>FMe(e,t));return(0,z.useEffect)(()=>{if(!PMe(e,t)){r({state:`missing`});return}let n=jMe(e,t);if(n){r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`});return}r({state:`loading`});let i=!1,a=NMe(e,t),o=Zx.get(a);return o||(o=lb().request(n=>n[Cy.resolveFilePathExists]({cwd:e,path:t})).then(e=>({exists:e.exists,kind:e.kind})).catch(()=>({exists:!1,kind:null})),Zx.set(a,o),o.finally(()=>{Zx.get(a)===o&&Zx.delete(a)})),o.then(n=>{MMe(e,t,n.exists,n.kind),!i&&r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`})}),()=>{i=!0}},[e,t]),n}var LMe=class{maxEntries;maxMemoryBytes;cache=new Map;totalSize=0;constructor(e,t){this.maxEntries=e,this.maxMemoryBytes=t}get(e){let t=this.cache.get(e);return t?(this.promote(e,t),t.value):null}set(e,t,n){let r=this.cache.get(e);r&&(this.totalSize-=r.approximateSize,this.cache.delete(e)),this.evictIfNeeded(n),this.cache.set(e,{value:t,approximateSize:n}),this.totalSize+=n}clear(){this.cache.clear(),this.totalSize=0}promote(e,t){this.cache.delete(e),this.cache.set(e,t)}evictIfNeeded(e){for(;(this.cache.size>=this.maxEntries||this.totalSize+e>this.maxMemoryBytes)&&this.cache.size>0;){let e=this.cache.keys().next().value;if(e===void 0)break;let t=this.cache.get(e);t&&(this.totalSize-=t.approximateSize),this.cache.delete(e)}}},Z={commandDeck:`_commandDeck_py729_3`,layout:`_layout_py729_13`,sidebar:`_sidebar_py729_20`,resizeHandle:`_resizeHandle_py729_29`,sidebarHeader:`_sidebarHeader_py729_43`,sidebarHeaderRow:`_sidebarHeaderRow_py729_56`,sidebarHeaderGroup:`_sidebarHeaderGroup_py729_65`,sidebarTitle:`_sidebarTitle_py729_73`,sidebarSubtitle:`_sidebarSubtitle_py729_83`,segmentControl:`_segmentControl_py729_90`,segmentButton:`_segmentButton_py729_98`,segmentButtonActive:`_segmentButtonActive_py729_121`,segmentCount:`_segmentCount_py729_127`,projectTree:`_projectTree_py729_137`,sidebarSection:`_sidebarSection_py729_143`,sidebarSectionCollapsed:`_sidebarSectionCollapsed_py729_151`,sectionHeader:`_sectionHeader_py729_155`,sectionTitle:`_sectionTitle_py729_176`,sectionBody:`_sectionBody_py729_180`,membershipStatus:`_membershipStatus_py729_186`,membershipError:`_membershipError_py729_193`,membershipErrorContent:`_membershipErrorContent_py729_212`,membershipErrorDetail:`_membershipErrorDetail_py729_216`,membershipErrorRetry:`_membershipErrorRetry_py729_222`,projectNode:`_projectNode_py729_239`,projectHeader:`_projectHeader_py729_243`,chevron:`_chevron_py729_263`,chevronOpen:`_chevronOpen_py729_269`,projectName:`_projectName_py729_273`,featureCount:`_featureCount_py729_280`,projectCiChip:`_projectCiChip_py729_286`,projectAddConvBtn:`_projectAddConvBtn_py729_300`,featureItem:`_featureItem_py729_321`,featureTitleLine:`_featureTitleLine_py729_337`,featureMetaLine:`_featureMetaLine_py729_344`,featurePipe:`_featurePipe_py729_353`,pipeDone:`_pipeDone_py729_369`,pipeWorking:`_pipeWorking_py729_370`,pipePaused:`_pipePaused_py729_371`,pipeError:`_pipeError_py729_372`,pipeMerged:`_pipeMerged_py729_373`,featureItemSelected:`_featureItemSelected_py729_379`,featureStatus:`_featureStatus_py729_383`,featureLabel:`_featureLabel_py729_392`,featureLabelUntitled:`_featureLabelUntitled_py729_405`,featureBadgeGroup:`_featureBadgeGroup_py729_410`,featureBadge:`_featureBadge_py729_410`,featureBadge_running:`_featureBadge_running_py729_429`,featureBadge_paused:`_featureBadge_paused_py729_436`,featureBadge_troubled:`_featureBadge_troubled_py729_442`,featureBadge_stopped:`_featureBadge_stopped_py729_449`,featureBadge_error:`_featureBadge_error_py729_455`,featureBadge_waiting:`_featureBadge_waiting_py729_461`,featureActivityError:`_featureActivityError_py729_468`,featureResourceChip:`_featureResourceChip_py729_474`,featureResourceLine:`_featureResourceLine_py729_489`,featureResourceStrip:`_featureResourceStrip_py729_497`,featureResourceIcon:`_featureResourceIcon_py729_506`,featureResourcePopover:`_featureResourcePopover_py729_517`,featureResourceRow:`_featureResourceRow_py729_540`,featureResourceCleanupButton:`_featureResourceCleanupButton_py729_548`,featureId_sidebar:`_featureId_sidebar_py729_565`,featureState:`_featureState_py729_573`,featureState_done:`_featureState_done_py729_584`,featureState_progress:`_featureState_progress_py729_590`,featureState_review:`_featureState_review_py729_596`,featureState_context:`_featureState_context_py729_602`,featureState_planning:`_featureState_planning_py729_608`,featureState_todo:`_featureState_todo_py729_614`,featureItemWrapper:`_featureItemWrapper_py729_621`,featureItemWrapperWorking:`_featureItemWrapperWorking_py729_629`,featureItemWrapperError:`_featureItemWrapperError_py729_630`,featureItemWrapperMerged:`_featureItemWrapperMerged_py729_631`,featureItemWrapperReady:`_featureItemWrapperReady_py729_632`,featureItemWrapperPaused:`_featureItemWrapperPaused_py729_633`,unpauseBtn:`_unpauseBtn_py729_650`,sessionSubtitle:`_sessionSubtitle_py729_670`,sessionPausedReason:`_sessionPausedReason_py729_680`,featureItemWrapperNeedsAttention:`_featureItemWrapperNeedsAttention_py729_693`,featureItemWrapperSelected:`_featureItemWrapperSelected_py729_691`,featureItemRow:`_featureItemRow_py729_701`,featureItemCaret:`_featureItemCaret_py729_707`,featureItemCaretPlaceholder:`_featureItemCaretPlaceholder_py729_725`,sessionList:`_sessionList_py729_731`,treeFilterRow:`_treeFilterRow_py729_736`,treeFilterButton:`_treeFilterButton_py729_742`,treeFilterButtonActive:`_treeFilterButtonActive_py729_754`,issueHeader:`_issueHeader_py729_761`,issueHeaderRow:`_issueHeaderRow_py729_770`,issueHeaderLeft:`_issueHeaderLeft_py729_777`,issueHeaderId:`_issueHeaderId_py729_785`,issueHeaderTitle:`_issueHeaderTitle_py729_799`,issueHeaderRight:`_issueHeaderRight_py729_808`,pipelineDots:`_pipelineDots_py729_815`,pipelineDotGroup:`_pipelineDotGroup_py729_821`,pipelineDot:`_pipelineDot_py729_815`,pipelineDotLabel:`_pipelineDotLabel_py729_834`,issueHeaderCost:`_issueHeaderCost_py729_841`,issueHeaderActions:`_issueHeaderActions_py729_847`,issueHeaderBtn:`_issueHeaderBtn_py729_854`,issueHeaderBtnDisabled:`_issueHeaderBtnDisabled_py729_873`,issueHeaderBadge:`_issueHeaderBadge_py729_883`,sessionPanel:`_sessionPanel_py729_893`,sessionPanelHeader:`_sessionPanelHeader_py729_908`,sessionPanelInfo:`_sessionPanelInfo_py729_918`,sessionPanelType:`_sessionPanelType_py729_925`,sessionPanelPresence:`_sessionPanelPresence_py729_935`,sessionPanelModel:`_sessionPanelModel_py729_942`,sessionPanelDuration:`_sessionPanelDuration_py729_951`,sessionPanelToggle:`_sessionPanelToggle_py729_958`,sessionPanelToggleBtn:`_sessionPanelToggleBtn_py729_968`,sessionPanelToggleBtnActive:`_sessionPanelToggleBtnActive_py729_983`,deliveryMethodSelect:`_deliveryMethodSelect_py729_993`,sessionPanelContent:`_sessionPanelContent_py729_1008`,reviewSummary:`_reviewSummary_py729_1017`,reviewSummaryBanner:`_reviewSummaryBanner_py729_1027`,reviewerStrip:`_reviewerStrip_py729_1038`,reviewerCard:`_reviewerCard_py729_1047`,reviewerCardLabel:`_reviewerCardLabel_py729_1060`,reviewerCardStats:`_reviewerCardStats_py729_1068`,reviewSynthesis:`_reviewSynthesis_py729_1077`,reviewSynthesisHeading:`_reviewSynthesisHeading_py729_1084`,sessionPanelTranscript:`_sessionPanelTranscript_py729_1093`,sessionPanelEmpty:`_sessionPanelEmpty_py729_1099`,sessionNode:`_sessionNode_py729_1109`,sessionNodeSelected:`_sessionNodeSelected_py729_1136`,sessionToggleSlot:`_sessionToggleSlot_py729_1140`,sessionDotSlot:`_sessionDotSlot_py729_1141`,sessionIconSlot:`_sessionIconSlot_py729_1151`,sessionIconRunning:`_sessionIconRunning_py729_1163`,sessionIconReview:`_sessionIconReview_py729_1168`,sessionIconPaused:`_sessionIconPaused_py729_1173`,sessionIconError:`_sessionIconError_py729_1178`,sessionModel:`_sessionModel_py729_1183`,sessionToggleButton:`_sessionToggleButton_py729_1191`,sessionTypeBadge:`_sessionTypeBadge_py729_1198`,sessionLabel:`_sessionLabel_py729_1210`,sessionStatus:`_sessionStatus_py729_1220`,sessionStatus_running:`_sessionStatus_running_py729_1230`,sessionStatus_paused:`_sessionStatus_paused_py729_1236`,sessionStatus_error:`_sessionStatus_error_py729_1241`,sessionStatus_starting:`_sessionStatus_starting_py729_1246`,sessionStatus_stopped:`_sessionStatus_stopped_py729_1251`,sessionStatus_unknown:`_sessionStatus_unknown_py729_1252`,sessionStatus_idle:`_sessionStatus_idle_py729_1253`,sessionStatus_working:`_sessionStatus_working_py729_1258`,sessionStatus_thinking:`_sessionStatus_thinking_py729_1263`,sessionStatus_waiting:`_sessionStatus_waiting_py729_1268`,sessionDuration:`_sessionDuration_py729_1273`,featureCost:`_featureCost_py729_1281`,emptyProject:`_emptyProject_py729_1287`,inactiveProjectsSection:`_inactiveProjectsSection_py729_1294`,inactiveProjectsSectionHeader:`_inactiveProjectsSectionHeader_py729_1300`,sessionChildList:`_sessionChildList_py729_1309`,sectionDivider:`_sectionDivider_py729_1314`,projectConvItem:`_projectConvItem_py729_1329`,projectConvItemSelected:`_projectConvItemSelected_py729_1350`,projectConvLabel:`_projectConvLabel_py729_1355`,conversationActions:`_conversationActions_py729_1364`,conversationStopBtn:`_conversationStopBtn_py729_1375`,conversationStarBtn:`_conversationStarBtn_py729_1385`,conversationStarPersistent:`_conversationStarPersistent_py729_1386`,conversationTime:`_conversationTime_py729_1398`,content:`_content_py729_1403`,contentEmpty:`_contentEmpty_py729_1411`,unknownProject:`_unknownProject_py729_1420`,unknownProjectList:`_unknownProjectList_py729_1443`,unknownProjectRetry:`_unknownProjectRetry_py729_1451`,unknownProjectBack:`_unknownProjectBack_py729_1452`,activityColumn:`_activityColumn_py729_1474`,activityColumnCollapsed:`_activityColumnCollapsed_py729_1486`,activityCollapsedLabel:`_activityCollapsedLabel_py729_1505`,featureHeader:`_featureHeader_py729_1515`,featureTitle:`_featureTitle_py729_337`,featureId:`_featureId_py729_565`,badgeBar:`_badgeBar_py729_1539`,badge:`_badge_py729_1539`,badgeDisabled:`_badgeDisabled_py729_1566`,activityContainer:`_activityContainer_py729_1577`,agentSection:`_agentSection_py729_1587`,agentSectionExpanded:`_agentSectionExpanded_py729_1599`,sectionChevron:`_sectionChevron_py729_1622`,sectionType:`_sectionType_py729_1628`,typePlanning:`_typePlanning_py729_1637`,typeWork:`_typeWork_py729_1642`,typeReview:`_typeReview_py729_1647`,typeTest:`_typeTest_py729_1652`,typeMerge:`_typeMerge_py729_1657`,sectionModel:`_sectionModel_py729_1665`,sectionTime:`_sectionTime_py729_1671`,sectionCost:`_sectionCost_py729_1677`,costSummary:`_costSummary_py729_1684`,sectionStatus:`_sectionStatus_py729_1692`,statusRunning:`_statusRunning_py729_1699`,pulse:`_pulse_py729_3013`,statusCompleted:`_statusCompleted_py729_1704`,statusFailed:`_statusFailed_py729_1708`,sectionPreview:`_sectionPreview_py729_1719`,sectionContent:`_sectionContent_py729_1733`,sectionContentConstrained:`_sectionContentConstrained_py729_1749`,sectionResizeHandle:`_sectionResizeHandle_py729_1754`,unreadDot:`_unreadDot_py729_1773`,isolationOverlay:`_isolationOverlay_py729_1782`,isolationHeader:`_isolationHeader_py729_1791`,isolationClose:`_isolationClose_py729_1800`,isolationContent:`_isolationContent_py729_1817`,modalOverlay:`_modalOverlay_py729_1829`,modalContent:`_modalContent_py729_1840`,modalHeader:`_modalHeader_py729_1851`,modalTitle:`_modalTitle_py729_1859`,modalClose:`_modalClose_py729_1865`,modalBody:`_modalBody_py729_1880`,uploadZone:`_uploadZone_py729_1887`,uploadZoneActive:`_uploadZoneActive_py729_1898`,uploadIcon:`_uploadIcon_py729_1904`,uploadText:`_uploadText_py729_1908`,uploadHint:`_uploadHint_py729_1913`,artifactList:`_artifactList_py729_1918`,artifactItem:`_artifactItem_py729_1925`,artifactName:`_artifactName_py729_1941`,artifactDate:`_artifactDate_py729_1948`,syncButton:`_syncButton_py729_1954`,spinning:`_spinning_py729_1983`,spin:`_spin_py729_1983`,shadowToggle:`_shadowToggle_py729_1988`,shadowLabel:`_shadowLabel_py729_1998`,shadowTitle:`_shadowTitle_py729_2002`,shadowDesc:`_shadowDesc_py729_2008`,markdownContent:`_markdownContent_py729_2015`,kbdHint:`_kbdHint_py729_2075`,deaconPanel:`_deaconPanel_py729_2092`,deaconHeader:`_deaconHeader_py729_2097`,deaconTitle:`_deaconTitle_py729_2110`,deaconMeta:`_deaconMeta_py729_2118`,deaconActionCount:`_deaconActionCount_py729_2124`,deaconSpecialists:`_deaconSpecialists_py729_2135`,deaconSpecRow:`_deaconSpecRow_py729_2141`,deaconSpecDot:`_deaconSpecDot_py729_2147`,deaconSpecName:`_deaconSpecName_py729_2154`,deaconSpecFailures:`_deaconSpecFailures_py729_2159`,deaconActions:`_deaconActions_py729_2165`,deaconAction:`_deaconAction_py729_2124`,deaconLogToggle:`_deaconLogToggle_py729_2182`,deaconLogViewer:`_deaconLogViewer_py729_2200`,deaconLogEmpty:`_deaconLogEmpty_py729_2211`,deaconLogEntry:`_deaconLogEntry_py729_2217`,deaconLogTime:`_deaconLogTime_py729_2224`,deaconLogLevel:`_deaconLogLevel_py729_2230`,deaconLogMessage:`_deaconLogMessage_py729_2237`,sidebarFooter:`_sidebarFooter_py729_2245`,versionLabel:`_versionLabel_py729_2255`,conversationSection:`_conversationSection_py729_2266`,conversationHeader:`_conversationHeader_py729_2270`,conversationToggle:`_conversationToggle_py729_2276`,conversationTitle:`_conversationTitle_py729_2297`,conversationAddBtn:`_conversationAddBtn_py729_2301`,conversationListWrapper:`_conversationListWrapper_py729_2323`,conversationControls:`_conversationControls_py729_2329`,convTabBar:`_convTabBar_py729_2340`,convTab:`_convTab_py729_2340`,convTabActive:`_convTabActive_py729_2365`,convTabCount:`_convTabCount_py729_2371`,convSortSelect:`_convSortSelect_py729_2387`,conversationList:`_conversationList_py729_2323`,conversationAddForm:`_conversationAddForm_py729_2419`,conversationInput:`_conversationInput_py729_2423`,conversationError:`_conversationError_py729_2441`,conversationEmpty:`_conversationEmpty_py729_2447`,skeletonList:`_skeletonList_py729_2459`,skeletonItem:`_skeletonItem_py729_2466`,shimmer:`_shimmer_py729_1`,conversationItem:`_conversationItem_py729_2475`,conversationItemConfirming:`_conversationItemConfirming_py729_2517`,conversationItemSelected:`_conversationItemSelected_py729_2524`,conversationMain:`_conversationMain_py729_2529`,conversationName:`_conversationName_py729_2537`,conversationMetaLine:`_conversationMetaLine_py729_2541`,conversationMetaSep:`_conversationMetaSep_py729_2559`,conversationKebabBtn:`_conversationKebabBtn_py729_2566`,conversationDot:`_conversationDot_py729_2632`,conversationWorkingSpinner:`_conversationWorkingSpinner_py729_2636`,conversationWorkingPulse:`_conversationWorkingPulse_py729_2643`,conversationArchiveBtn:`_conversationArchiveBtn_py729_2658`,archiveConfirmInline:`_archiveConfirmInline_py729_2676`,archiveConfirmLabelInline:`_archiveConfirmLabelInline_py729_2684`,archiveConfirmYesInline:`_archiveConfirmYesInline_py729_2689`,archiveConfirmNoInline:`_archiveConfirmNoInline_py729_2690`,conversationSummaryForkBtn:`_conversationSummaryForkBtn_py729_2783`,conversationCopyBtn:`_conversationCopyBtn_py729_2806`,conversationEditBtn:`_conversationEditBtn_py729_2829`,conversationNameInput:`_conversationNameInput_py729_2853`,conversationArchiveBtnLarge:`_conversationArchiveBtnLarge_py729_2866`,conversationModelBar:`_conversationModelBar_py729_2883`,conversationModelLabel:`_conversationModelLabel_py729_2893`,conversationTerminal:`_conversationTerminal_py729_902`,conversationTerminalHeader:`_conversationTerminalHeader_py729_2910`,conversationHeaderContainer:`_conversationHeaderContainer_py729_2922`,conversationSessionId:`_conversationSessionId_py729_2930`,terminalBranchBarMode:`_terminalBranchBarMode_py729_2936`,conversationTerminalTitle:`_conversationTerminalTitle_py729_2941`,conversationTerminalTitleText:`_conversationTerminalTitleText_py729_2957`,titleRegenerating:`_titleRegenerating_py729_2976`,titleShimmerSweep:`_titleShimmerSweep_py729_1`,spinnerIcon:`_spinnerIcon_py729_3006`,pulseIcon:`_pulseIcon_py729_3013`,conversationTerminalStatus:`_conversationTerminalStatus_py729_3019`,copyLinkButton:`_copyLinkButton_py729_3041`,archiveConfirm:`_archiveConfirm_py729_2676`,archiveConfirmLabel:`_archiveConfirmLabel_py729_2684`,archiveConfirmYes:`_archiveConfirmYes_py729_2689`,archiveConfirmNo:`_archiveConfirmNo_py729_2690`,conversationTitleEditBtn:`_conversationTitleEditBtn_py729_3092`,conversationTitleInput:`_conversationTitleInput_py729_3118`,conversationTerminalBody:`_conversationTerminalBody_py729_3132`,conversationHeaderShell:`_conversationHeaderShell_py729_3145`,conversationHeaderPrimary:`_conversationHeaderPrimary_py729_3142`,conversationHeaderActions:`_conversationHeaderActions_py729_3162`,conversationMetaRow:`_conversationMetaRow_py729_3143`,conversationAboutToggle:`_conversationAboutToggle_py729_3184`,conversationAboutToggleActive:`_conversationAboutToggleActive_py729_3205`,headerMenuWrap:`_headerMenuWrap_py729_3212`,headerMenuOverlay:`_headerMenuOverlay_py729_3217`,headerMenu:`_headerMenu_py729_3212`,headerMenuItem:`_headerMenuItem_py729_3241`,headerMenuItemActive:`_headerMenuItemActive_py729_3266`,headerMenuItemCheck:`_headerMenuItemCheck_py729_3270`,headerMenuItemDestructive:`_headerMenuItemDestructive_py729_3277`,headerMenuDivider:`_headerMenuDivider_py729_3286`,headerSubmenu:`_headerSubmenu_py729_3292`,headerMenuDeliveryRow:`_headerMenuDeliveryRow_py729_3312`,conversationAboutDrawer:`_conversationAboutDrawer_py729_3326`,conversationAboutText:`_conversationAboutText_py729_3336`,conversationAboutMeta:`_conversationAboutMeta_py729_3343`,conversationAboutMuted:`_conversationAboutMuted_py729_3351`,conversationResumeOverlay:`_conversationResumeOverlay_py729_3359`,conversationResumeBar:`_conversationResumeBar_py729_3369`,conversationResumeControls:`_conversationResumeControls_py729_3378`,conversationResumeContractToggle:`_conversationResumeContractToggle_py729_3384`,conversationResumeBtn:`_conversationResumeBtn_py729_3407`,conversationClearedBanner:`_conversationClearedBanner_py729_3429`,conversationClearedBannerText:`_conversationClearedBannerText_py729_3450`,viewToggle:`_viewToggle_py729_3456`,viewToggleBtn:`_viewToggleBtn_py729_3467`,viewToggleBtnActive:`_viewToggleBtnActive_py729_3484`,conversationView:`_conversationView_py729_3491`,conversationEmptyState:`_conversationEmptyState_py729_3499`,conversationEmptyStateTitle:`_conversationEmptyStateTitle_py729_3510`,conversationEmptyStateSubtitle:`_conversationEmptyStateSubtitle_py729_3517`,conversationConnecting:`_conversationConnecting_py729_3523`,transcriptSkeleton:`_transcriptSkeleton_py729_3534`,transcriptSkeletonAssistant:`_transcriptSkeletonAssistant_py729_3542`,transcriptSkeletonUser:`_transcriptSkeletonUser_py729_3548`,transcriptSkeletonAvatar:`_transcriptSkeletonAvatar_py729_3553`,transcriptSkeletonLine:`_transcriptSkeletonLine_py729_3554`,transcriptSkeletonLineMedium:`_transcriptSkeletonLineMedium_py729_3555`,transcriptSkeletonLineShort:`_transcriptSkeletonLineShort_py729_3556`,transcriptSkeletonBubble:`_transcriptSkeletonBubble_py729_3557`,transcriptSkeletonBubbleShort:`_transcriptSkeletonBubbleShort_py729_3558`,transcriptSkeletonLines:`_transcriptSkeletonLines_py729_3572`,messagesTimeline:`_messagesTimeline_py729_3613`,messagesTimelineInner:`_messagesTimelineInner_py729_3622`,contextMessageRow:`_contextMessageRow_py729_3632`,contextMessageBlock:`_contextMessageBlock_py729_3636`,contextMessageToggle:`_contextMessageToggle_py729_3644`,contextMessageIcon:`_contextMessageIcon_py729_3665`,contextMessageLabel:`_contextMessageLabel_py729_3670`,contextMessageContent:`_contextMessageContent_py729_3674`,userMessageRow:`_userMessageRow_py729_3680`,subagentTranscript:`_subagentTranscript_py729_3689`,userMessageBubble:`_userMessageBubble_py729_3689`,userMessageText:`_userMessageText_py729_3701`,assistantMessageRow:`_assistantMessageRow_py729_3710`,assistantMessageAvatar:`_assistantMessageAvatar_py729_3718`,assistantMessageContent:`_assistantMessageContent_py729_3725`,messageTimestamp:`_messageTimestamp_py729_3731`,messageMetadata:`_messageMetadata_py729_3737`,messageSeparator:`_messageSeparator_py729_3745`,workLogGroup:`_workLogGroup_py729_3751`,workLogEntry:`_workLogEntry_py729_3761`,workLogTerminalIcon:`_workLogTerminalIcon_py729_3771`,workLogLabel:`_workLogLabel_py729_3780`,workLogDetail:`_workLogDetail_py729_3787`,workLogResult:`_workLogResult_py729_3798`,workLogToolHeader:`_workLogToolHeader_py729_3814`,workLogThinkingResult:`_workLogThinkingResult_py729_3821`,workLogExpandBtn:`_workLogExpandBtn_py729_3836`,failedPromptList:`_failedPromptList_py729_3849`,failedPromptCard:`_failedPromptCard_py729_3856`,failedPromptHeader:`_failedPromptHeader_py729_3863`,failedPromptText:`_failedPromptText_py729_3873`,failedPromptActions:`_failedPromptActions_py729_3881`,workingIndicator:`_workingIndicator_py729_3906`,workingDots:`_workingDots_py729_3915`,workingDotBounce:`_workingDotBounce_py729_1`,workingLabel:`_workingLabel_py729_3936`,chatMarkdown:`_chatMarkdown_py729_3942`,codeBlock:`_codeBlock_py729_4108`,copyButton:`_copyButton_py729_4117`,shikiOutput:`_shikiOutput_py729_4146`,codePlain:`_codePlain_py729_4158`,mdLink:`_mdLink_py729_4168`,mdFallback:`_mdFallback_py729_4175`,composerFooter:`_composerFooter_py729_4186`,composerBox:`_composerBox_py729_4192`,composerBoxDisabled:`_composerBoxDisabled_py729_4209`,composerEditor:`_composerEditor_py729_4215`,composerEditorDisabled:`_composerEditorDisabled_py729_4223`,composerEditable:`_composerEditable_py729_4228`,composerPlaceholder:`_composerPlaceholder_py729_4239`,slashMenu:`_slashMenu_py729_4250`,slashMenuItem:`_slashMenuItem_py729_4264`,slashMenuItemSelected:`_slashMenuItemSelected_py729_4279`,slashMenuLabel:`_slashMenuLabel_py729_4284`,slashMenuDescription:`_slashMenuDescription_py729_4291`,slashMenuMatch:`_slashMenuMatch_py729_4296`,composerToolbar:`_composerToolbar_py729_4304`,composerToolbarSpacer:`_composerToolbarSpacer_py729_4311`,composerToolbarModelDrift:`_composerToolbarModelDrift_py729_4321`,composerToolbarDivider:`_composerToolbarDivider_py729_4340`,sendButton:`_sendButton_py729_4350`,voiceToolbarButton:`_voiceToolbarButton_py729_4374`,voiceToolbarButtonActive:`_voiceToolbarButtonActive_py729_4375`,voiceWidget:`_voiceWidget_py729_4412`,voiceWidgetHeader:`_voiceWidgetHeader_py729_4420`,voiceWidgetActions:`_voiceWidgetActions_py729_4421`,voiceWidgetTitle:`_voiceWidgetTitle_py729_4428`,voiceWidgetMeta:`_voiceWidgetMeta_py729_4434`,voiceModeToggle:`_voiceModeToggle_py729_4440`,voiceModeButton:`_voiceModeButton_py729_4448`,voiceModeActive:`_voiceModeActive_py729_4449`,voiceWidgetControls:`_voiceWidgetControls_py729_4468`,voiceFieldLabel:`_voiceFieldLabel_py729_4475`,voiceSelect:`_voiceSelect_py729_4484`,voiceWaveformCanvas:`_voiceWaveformCanvas_py729_4494`,voiceTranscriptPreview:`_voiceTranscriptPreview_py729_4503`,voiceStartButton:`_voiceStartButton_py729_4523`,voiceStopButton:`_voiceStopButton_py729_4524`,voiceSecondaryButton:`_voiceSecondaryButton_py729_4525`,voiceInsertButton:`_voiceInsertButton_py729_4526`,composerImageStrip:`_composerImageStrip_py729_4563`,composerImageCard:`_composerImageCard_py729_4570`,composerImageThumb:`_composerImageThumb_py729_4582`,composerImageMeta:`_composerImageMeta_py729_4589`,composerImageName:`_composerImageName_py729_4596`,composerImageStatus:`_composerImageStatus_py729_4604`,composerImageError:`_composerImageError_py729_4612`,composerImageRemoveButton:`_composerImageRemoveButton_py729_4617`,composerFileThumb:`_composerFileThumb_py729_4637`,composerFileSize:`_composerFileSize_py729_4645`,spinner:`_spinner_py729_3006`,pickerContainer:`_pickerContainer_py729_4661`,pickerBtn:`_pickerBtn_py729_4667`,pickerHint:`_pickerHint_py729_4694`,pickerLabel:`_pickerLabel_py729_4701`,pickerProviderIcon:`_pickerProviderIcon_py729_4711`,pickerDropdown:`_pickerDropdown_py729_4718`,pickerDropdownUp:`_pickerDropdownUp_py729_4734`,pickerProviderSidebar:`_pickerProviderSidebar_py729_4740`,pickerProviderBtn:`_pickerProviderBtn_py729_4754`,pickerProviderBtnActive:`_pickerProviderBtnActive_py729_4775`,pickerProviderBtnIcon:`_pickerProviderBtnIcon_py729_4792`,providerBadge:`_providerBadge_py729_4799`,pickerMainPanel:`_pickerMainPanel_py729_4815`,pickerHarnessHeader:`_pickerHarnessHeader_py729_4824`,pickerSearchWrapper:`_pickerSearchWrapper_py729_4829`,pickerSearchIcon:`_pickerSearchIcon_py729_4838`,pickerSearchInput:`_pickerSearchInput_py729_4844`,pickerScrollContent:`_pickerScrollContent_py729_4861`,pickerOption:`_pickerOption_py729_4870`,pickerOptionActive:`_pickerOptionActive_py729_4890`,pickerOptionLocked:`_pickerOptionLocked_py729_4909`,pickerOptionLockIcon:`_pickerOptionLockIcon_py729_4918`,pickerOptionContent:`_pickerOptionContent_py729_4926`,pickerOptionRow:`_pickerOptionRow_py729_4935`,pickerOptionSubtitle:`_pickerOptionSubtitle_py729_4943`,pickerOptionProviderDot:`_pickerOptionProviderDot_py729_4954`,pickerNoResults:`_pickerNoResults_py729_4962`,pickerGroupHeader:`_pickerGroupHeader_py729_4971`,pickerGroupNoKey:`_pickerGroupNoKey_py729_4984`,pickerGroupDisabled:`_pickerGroupDisabled_py729_4997`,pickerSectionDivider:`_pickerSectionDivider_py729_5003`,harnessIndicator:`_harnessIndicator_py729_5011`,harnessIndicatorIcon:`_harnessIndicatorIcon_py729_5027`,pickerDropdownSplit:`_pickerDropdownSplit_py729_5034`,pickerScrollArea:`_pickerScrollArea_py729_5035`,harnessOption:`_harnessOption_py729_5039`,harnessOptionActive:`_harnessOptionActive_py729_5058`,harnessOptionLocked:`_harnessOptionLocked_py729_5066`,harnessOptionIcon:`_harnessOptionIcon_py729_5071`,harnessOptionLogo:`_harnessOptionLogo_py729_5080`,harnessOptionBody:`_harnessOptionBody_py729_5086`,harnessOptionName:`_harnessOptionName_py729_5093`,harnessOptionNameRow:`_harnessOptionNameRow_py729_5100`,harnessOptionExperimental:`_harnessOptionExperimental_py729_5107`,harnessOptionDesc:`_harnessOptionDesc_py729_5120`,harnessOptionNote:`_harnessOptionNote_py729_5130`,pickerOptionLabel:`_pickerOptionLabel_py729_5137`,pickerCostBadge:`_pickerCostBadge_py729_5146`,pickerAuthBadge:`_pickerAuthBadge_py729_5154`,pickerAuthBadgeWarn:`_pickerAuthBadgeWarn_py729_5168`,restartPopover:`_restartPopover_py729_5182`,restartPopoverTitle:`_restartPopoverTitle_py729_5196`,restartPopoverDivider:`_restartPopoverDivider_py729_5203`,restartPopoverLabel:`_restartPopoverLabel_py729_5209`,restartPopoverCount:`_restartPopoverCount_py729_5230`,restartPopoverActions:`_restartPopoverActions_py729_5236`,restartPopoverCancel:`_restartPopoverCancel_py729_5243`,restartPopoverConfirm:`_restartPopoverConfirm_py729_5258`,restartPopoverError:`_restartPopoverError_py729_5278`,conversationForkStatus:`_conversationForkStatus_py729_5287`,conversationForkFailed:`_conversationForkFailed_py729_5300`,conversationForkFallbackNote:`_conversationForkFallbackNote_py729_5317`,conversationBranchChip:`_conversationBranchChip_py729_5316`,conversationBranchChipText:`_conversationBranchChipText_py729_5347`,terminalBranchBar:`_terminalBranchBar_py729_2936`,terminalBranchBarText:`_terminalBranchBarText_py729_5371`,terminalBranchBarDrift:`_terminalBranchBarDrift_py729_5386`,terminalBranchBarMissing:`_terminalBranchBarMissing_py729_5391`,forkProgressView:`_forkProgressView_py729_5398`,forkProgressCard:`_forkProgressCard_py729_5406`,forkProgressHeader:`_forkProgressHeader_py729_5418`,forkProgressIcon:`_forkProgressIcon_py729_5424`,forkProgressTitle:`_forkProgressTitle_py729_5430`,forkProgressSubtitle:`_forkProgressSubtitle_py729_5438`,forkProgressTimeline:`_forkProgressTimeline_py729_5450`,forkProgressStep:`_forkProgressStep_py729_5457`,forkProgressStepIndicator:`_forkProgressStepIndicator_py729_5468`,forkProgressStepLine:`_forkProgressStepLine_py729_5477`,"forkProgressStep--done":`_forkProgressStep--done_py729_5486`,forkProgressStepContent:`_forkProgressStepContent_py729_5490`,forkProgressStepLabel:`_forkProgressStepLabel_py729_5497`,forkProgressStepDesc:`_forkProgressStepDesc_py729_5503`,"forkProgressStep--active":`_forkProgressStep--active_py729_5517`,"forkProgressStep--pending":`_forkProgressStep--pending_py729_5525`,"forkProgressStep--failed":`_forkProgressStep--failed_py729_5533`,forkProgressSpinner:`_forkProgressSpinner_py729_5546`,forkSpin:`_forkSpin_py729_1`,forkProgressError:`_forkProgressError_py729_5550`,forkOverlay:`_forkOverlay_py729_5570`,forkDialog:`_forkDialog_py729_5582`,forkHeader:`_forkHeader_py729_5593`,forkHeaderLeft:`_forkHeaderLeft_py729_5601`,forkHeaderIcon:`_forkHeaderIcon_py729_5607`,forkTitle:`_forkTitle_py729_5612`,forkClose:`_forkClose_py729_5619`,forkBody:`_forkBody_py729_5634`,forkDesc:`_forkDesc_py729_5638`,forkFields:`_forkFields_py729_5645`,forkTitleInput:`_forkTitleInput_py729_5651`,forkFooter:`_forkFooter_py729_5670`,forkCancelBtn:`_forkCancelBtn_py729_5677`,forkConfirmBtn:`_forkConfirmBtn_py729_5694`,forkModeGroup:`_forkModeGroup_py729_5719`,forkCheckboxRow:`_forkCheckboxRow_py729_5732`,forkWarning:`_forkWarning_py729_5755`,forkHeaderRight:`_forkHeaderRight_py729_5766`,forkHelpOverlay:`_forkHelpOverlay_py729_5774`,forkHelpDialog:`_forkHelpDialog_py729_5786`,forkHelpBody:`_forkHelpBody_py729_5798`,failedOutbox:`_failedOutbox_py729_5805`,failedMessage:`_failedMessage_py729_5813`,failedMessageBubble:`_failedMessageBubble_py729_5820`,failedMessageActions:`_failedMessageActions_py729_5829`,failedMessageLabel:`_failedMessageLabel_py729_5836`,failedMessageReason:`_failedMessageReason_py729_5842`,failedMessageBtn:`_failedMessageBtn_py729_5851`,planCard:`_planCard_py729_5872`,planCardHeader:`_planCardHeader_py729_5880`,planCardToggle:`_planCardToggle_py729_5889`,planCardTitle:`_planCardTitle_py729_5901`,planCardBadge:`_planCardBadge_py729_5906`,planCardBadgeApproved:`_planCardBadgeApproved_py729_5907`,planCardBadgeRejected:`_planCardBadgeRejected_py729_5908`,planCardResolved:`_planCardResolved_py729_5933`,planCardBody:`_planCardBody_py729_5941`,planCardActions:`_planCardActions_py729_5949`,planCardApproveBtn:`_planCardApproveBtn_py729_5956`,planCardFeedbackBtn:`_planCardFeedbackBtn_py729_5980`,planCardCancelBtn:`_planCardCancelBtn_py729_6005`,planCardFeedbackArea:`_planCardFeedbackArea_py729_6020`,planCardTextarea:`_planCardTextarea_py729_6025`,planCardFeedbackActions:`_planCardFeedbackActions_py729_6042`,compactBoundaryDivider:`_compactBoundaryDivider_py729_6050`,compactBoundaryLine:`_compactBoundaryLine_py729_6057`,compactBoundaryLabel:`_compactBoundaryLabel_py729_6069`,compactBoundaryDetail:`_compactBoundaryDetail_py729_6079`,compactingIndicator:`_compactingIndicator_py729_6084`,compactingPulse:`_compactingPulse_py729_1`,compactingIcon:`_compactingIcon_py729_6095`,compactingSpin:`_compactingSpin_py729_1`,conversationPermissionAlert:`_conversationPermissionAlert_py729_6111`,permissionAlertPulse:`_permissionAlertPulse_py729_1`,sessionPermissionsRow:`_sessionPermissionsRow_py729_6123`,sessionPermissionsIcon:`_sessionPermissionsIcon_py729_6133`,sessionPermissionsLabel:`_sessionPermissionsLabel_py729_6139`,sessionPermissionsTools:`_sessionPermissionsTools_py729_6144`,resourcesGroup:`_resourcesGroup_py729_6151`,resourcesGroupHeader:`_resourcesGroupHeader_py729_6157`,resourcesGroupSummary:`_resourcesGroupSummary_py729_6179`,uatStackTreeGroup:`_uatStackTreeGroup_py729_6187`,uatStackTreeHeader:`_uatStackTreeHeader_py729_6193`,uatStackTreeSummary:`_uatStackTreeSummary_py729_6216`,uatStackActions:`_uatStackActions_py729_6224`,uatStackActionButton:`_uatStackActionButton_py729_6231`,uatStackActionPrimary:`_uatStackActionPrimary_py729_6250`,uatStackActionDanger:`_uatStackActionDanger_py729_6256`,uatStackActionMuted:`_uatStackActionMuted_py729_6262`,uatStackTreeBody:`_uatStackTreeBody_py729_6266`,uatStackTreeReason:`_uatStackTreeReason_py729_6270`,uatStackContainerRow:`_uatStackContainerRow_py729_6276`,uatStackContainerDot:`_uatStackContainerDot_py729_6290`,uatStackContainerDotHealthy:`_uatStackContainerDotHealthy_py729_6297`,uatStackContainerDotStarting:`_uatStackContainerDotStarting_py729_6301`,uatStackContainerDotUnhealthy:`_uatStackContainerDotUnhealthy_py729_6305`,uatStackContainerDotStopped:`_uatStackContainerDotStopped_py729_6309`,uatStackContainerName:`_uatStackContainerName_py729_6313`,uatStackContainerState:`_uatStackContainerState_py729_6322`,containerNode:`_containerNode_py729_6328`,containerName:`_containerName_py729_6341`,containerMetric:`_containerMetric_py729_6347`,branchNode:`_branchNode_py729_6355`,branchBadge:`_branchBadge_py729_6364`,prNode:`_prNode_py729_6369`,prNumber:`_prNumber_py729_6383`,prTitle:`_prTitle_py729_6390`},RMe=new LMe(500,50*1024*1024);function zMe(e,t){return Math.max(e.length*2,t.length*3)}function BMe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t}function VMe(e,t){return`${BMe(e)}:${e.length}:${t}`}var HMe=new Set([`span`,`pre`,`code`,`div`,`br`]),UMe=new Set([`class`,`style`]),WMe=new Set([`color`,`background-color`,`font-style`,`font-weight`,`text-decoration`,`opacity`]);function GMe(e){return e.split(`;`).map(e=>e.trim()).filter(Boolean).filter(e=>{let[t]=e.split(`:`);return t&&WMe.has(t.trim().toLowerCase())}).join(`; `)}var KMe=null;function qMe(){return KMe||=new DOMParser,KMe}function JMe(e){let t=qMe().parseFromString(e,`text/html`);function n(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return null;let t=e,r=t.tagName.toLowerCase();if(!HMe.has(r))return null;let i=document.createElement(r);for(let e of Array.from(t.attributes))if(UMe.has(e.name.toLowerCase()))if(e.name===`style`){let t=GMe(e.value);t&&i.setAttribute(`style`,t)}else i.setAttribute(e.name,e.value);for(let e of Array.from(t.childNodes)){let t=n(e);t&&i.appendChild(t)}return i}let r=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes)){let t=n(e);t&&r.appendChild(t)}let i=document.createElement(`div`);return i.appendChild(r),i.innerHTML}var YMe=null;async function XMe(){return YMe||=v(()=>Promise.resolve().then(()=>odt).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),YMe}async function ZMe(e,t,n){let r=VMe(e,t);if(!n){let e=RMe.get(r);if(e!==null)return e}try{let i=(await XMe()).codeToHtml(e,{lang:t||`text`,theme:`github-light`});return n||RMe.set(r,i,zMe(i,e)),i}catch{return`<pre><code>${e.replace(/</g,`<`).replace(/>/g,`>`)}</code></pre>`}}var Qx=class extends z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function QMe({code:e,lang:t,isStreaming:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),s=(0,z.useRef)(!1);(0,z.useEffect)(()=>(s.current=!1,ZMe(e,t,n).then(e=>{s.current||i(e)}),()=>{s.current=!0}),[e,t,n]);let c=(0,z.useMemo)(()=>r?JMe(r):null,[r]),l=(0,z.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,B.jsxs)(`div`,{className:Z.codeBlock,children:[(0,B.jsx)(`button`,{className:Z.copyButton,onClick:l,title:`Copy code`,children:a?(0,B.jsx)(us,{size:13}):(0,B.jsx)(ks,{size:13})}),c?(0,B.jsx)(`div`,{className:Z.shikiOutput,dangerouslySetInnerHTML:{__html:c}}):(0,B.jsx)(`pre`,{className:Z.codePlain,children:(0,B.jsx)(`code`,{children:e})})]})}function $x(e){return Kje(e)?e:kOe(e)}async function $Me(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}var eNe=(0,z.createContext)(!1);function tNe({children:e}){let{data:t}=V({queryKey:[`settings`],queryFn:$Me,retry:!1});return(0,B.jsx)(eNe.Provider,{value:t?.experimental?.streamdownRenderer===!0,children:e})}var nNe=new Set([`code`,`inlineCode`,`link`,`linkReference`,`definition`]),rNe={...Cx,protocols:{...Cx.protocols,href:void 0}},iNe=z.lazy(async()=>{let[{Streamdown:e,defaultRehypePlugins:t}]=await Promise.all([v(()=>import(`./dist-ClBlE-Nm.js`),__vite__mapDeps([0,1,2,3,4,5,6])),v(()=>Promise.resolve({}),__vite__mapDeps([7]))]),n=[t.raw,[t.sanitize[0],rNe],t.harden];return{default:t=>z.createElement(e,{...t,rehypePlugins:n})}});function aNe({meta:e,cwd:t,issueId:n,fallback:r}){let{state:i}=IMe(t,e.filePath);return i===`exists`?(0,B.jsx)(EMe,{...e,issueId:n}):(0,B.jsx)(B.Fragment,{children:r})}function oNe(e={}){return t=>{let n=t=>{if(!t.children||nNe.has(t.type))return;let r=[];for(let i of t.children)if(i.type===`text`&&i.value!==void 0)for(let t of Yje(i.value,e.cwd))r.push(t.href?{type:`link`,url:t.href,title:null,children:[{type:`text`,value:t.text}]}:{type:`text`,value:t.text});else n(i),r.push(i);t.children=r};n(t)}}function sNe(e,t,n){return{pre({children:t}){let n=z.Children.toArray(t)[0];if(!z.isValidElement(n))return(0,B.jsx)(`pre`,{children:t});let r=n,i=r.props.className??``,a=/language-(\w+)/.exec(i)?.[1]??``,o=String(r.props.children??``).trimEnd();return(0,B.jsx)(Qx,{fallback:(0,B.jsx)(`pre`,{className:Z.codePlain,children:(0,B.jsx)(`code`,{children:o})}),children:(0,B.jsx)(QMe,{code:o,lang:a,isStreaming:e})})},a({href:e,children:r}){let i=Xje(e,t);return i?(0,B.jsx)(aNe,{meta:i,cwd:t,issueId:n,fallback:r}):(0,B.jsx)(`a`,{href:typeof e==`string`&&e.trim().length>0&&!/^(javascript|data|vbscript):/i.test(e.trim())?e:void 0,target:`_blank`,rel:`noopener noreferrer`,className:Z.mdLink,children:r})}}}var cNe=5e4,lNe=8e3;function uNe({text:e}){let[t,n]=(0,z.useState)(!1),r=Math.round(e.length/1024),i=e.length>lNe,a=t||!i?e:e.slice(0,lNe);return(0,B.jsxs)(`div`,{className:Z.chatMarkdown,children:[(0,B.jsxs)(`div`,{style:{fontSize:`0.8em`,opacity:.6,marginBottom:6},children:[`Large message (`,r,` KB) — rendered as plain text to keep the panel responsive.`]}),(0,B.jsxs)(`pre`,{className:Z.mdFallback,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:[a,!t&&i?`
|
|
46
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return gke(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=lAe.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function vAe(){return{exit:{taskListCheckValueChecked:bAe,taskListCheckValueUnchecked:bAe,paragraph:xAe}}}function yAe(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:SAe}}}function bAe(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function xAe(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function SAe(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=lAe.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function CAe(){return[FOe(),ike(),lke(),uAe(),vAe()]}function wAe(e){return{extensions:[IOe(),ake(e),uke(),_Ae(e),yAe()]}}var TAe={tokenize:IAe,partial:!0},EAe={tokenize:LAe,partial:!0},DAe={tokenize:RAe,partial:!0},OAe={tokenize:zAe,partial:!0},kAe={tokenize:BAe,partial:!0},AAe={name:`wwwAutolink`,tokenize:PAe,previous:VAe},jAe={name:`protocolAutolink`,tokenize:FAe,previous:HAe},Mx={name:`emailAutolink`,tokenize:NAe,previous:UAe},Nx={};function MAe(){return{text:Nx}}for(var Px=48;Px<123;)Nx[Px]=Mx,Px++,Px===58?Px=65:Px===91&&(Px=97);Nx[43]=Mx,Nx[45]=Mx,Nx[46]=Mx,Nx[95]=Mx,Nx[72]=[Mx,jAe],Nx[104]=[Mx,jAe],Nx[87]=[Mx,AAe],Nx[119]=[Mx,AAe];function NAe(e,t,n){let r=this,i,a;return o;function o(t){return!Fx(t)||!UAe.call(r,r.previous)||Ix(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Fx(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(kAe,u,l)(t):t===45||t===95||kb(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Ob(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function PAe(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!VAe.call(r,r.previous)||Ix(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(TAe,e.attempt(EAe,e.attempt(DAe,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function FAe(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&HAe.call(r,r.previous)&&!Ix(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Ob(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ab(t)||Nb(t)||Ib(t)||Fb(t)?n(t):e.attempt(EAe,e.attempt(DAe,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function IAe(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function LAe(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(OAe,c,s)(t):t===null||Nb(t)||Ib(t)||t!==45&&Fb(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function RAe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(OAe,t,a)(o):o===null||Nb(o)||Ib(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zAe(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Nb(o)||Ib(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Nb(e)||Ib(e)?t(e):r(e)}function a(e){return Ob(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Ob(t)?(e.consume(t),o):n(t)}}function BAe(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return kb(e)?n(e):t(e)}}function VAe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Nb(e)}function HAe(e){return!Ob(e)}function UAe(e){return!(e===47||Fx(e))}function Fx(e){return e===43||e===45||e===46||e===95||kb(e)}function Ix(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var WAe={tokenize:QAe,partial:!0};function GAe(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:YAe,continuation:{tokenize:XAe},exit:ZAe}},text:{91:{name:`gfmFootnoteCall`,tokenize:JAe},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:KAe,resolveTo:qAe}}}}function KAe(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Db(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function qAe(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function JAe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Nb(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Db(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Nb(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function YAe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Nb(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Db(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Nb(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),zb(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function XAe(e,t,n){return e.check(Ub,t,e.attempt(WAe,t,n))}function ZAe(e){e.exit(`gfmFootnoteDefinition`)}function QAe(e,t,n){let r=this;return zb(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function $Ae(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Tb(o,o.length,0,Vb(s,e.slice(r+1,n),t)),Tb(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Tb(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Bb(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Bb(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var eje=class{constructor(){this.map=[]}add(e,t,n){tje(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function tje(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function nje(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function rje(){return{flow:{null:{name:`table`,tokenize:ije,resolveAll:aje}}}}function ije(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Mb(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Pb(t)?zb(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Nb(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Pb(t)?zb(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Pb(t)?zb(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Mb(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Pb(t)?zb(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Mb(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Mb(n)?(e.exit(`tableRow`),t(n)):Pb(n)?zb(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Nb(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function aje(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new eje;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(oje(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Lx(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Lx(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Lx(f,t,o,i,n,d)):(o[0]=o[1],d=Lx(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&oje(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=nje(t.events,n))}return e}function Lx(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Rx(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Rx(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Rx(t.events,n[2]),a=Rx(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Rx(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function oje(e,t,n,r,i){let a=[],o=Rx(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Rx(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var sje={name:`tasklistCheck`,tokenize:lje};function cje(){return{text:{91:sje}}}function lje(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Nb(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Mb(r)?t(r):Pb(r)?e.check({tokenize:uje},t,n)(r):n(r)}}function uje(e,t,n){return zb(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function dje(e){return Twe([MAe(),GAe(),$Ae(e),rje(),cje()])}var fje={};function zx(e){let t=this,n=e||fje,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(dje(n)),a.push(CAe()),o.push(wAe(n))}function pje(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function mje(e){return e.replace(/\\/g,`/`)}function hje(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function gje(e){return e.replace(/[\\/]+$/,``)}function _je(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function vje(e){return e.replace(/^\.\/+/u,``).replace(/^\/+/u,``)}function yje(e,t){let{path:n,line:r,column:i}=pje(e),a=hje(mje(n)),o=a;if(t){let e=hje(mje(gje(t))),n=_je(e),r=a.toLowerCase(),i=e.toLowerCase(),s=`${i}/`,c=`${n.toLowerCase()}/`;if(r===i)o=n;else if(r.startsWith(s))o=`${n}/${a.slice(e.length+1)}`;else if(!a.startsWith(`/`)){let e=vje(a);o=r.startsWith(c)?a:`${n}/${e}`}}return r?`${o}:${r}${i?`:${i}`:``}`:o}var Bx=/^[A-Za-z]:[\\/]/,Vx=/^\\\\/,bje=/^([A-Za-z][A-Za-z0-9+.-]*):(.*)$/,xje=/^(~\/|\.{1,2}\/)/,Sje=/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}$/,Cje=/^[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}$/,wje=/:\d+(?::\d+)?$/,Tje=/^\d+(?::\d+)?$/,Eje=[`/Users/`,`/home/`,`/tmp/`,`/var/`,`/etc/`,`/opt/`,`/mnt/`,`/Volumes/`,`/private/`,`/root/`],Dje=/(^|[\s([{"'`])((?:\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root)\/[A-Za-z0-9._~+@%/=-]+|(?:~\/|\.{1,2}\/)?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+)(?::\d+(?::\d+)?)?)/g;function Hx(e){try{return decodeURIComponent(e)}catch{return e}}function Oje(e){return e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e}function kje(e){return Oje(e.trim())}function Aje(e){let t=e.indexOf(`#`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t):``,i=n.indexOf(`?`);return{path:i>=0?n.slice(0,i):n,hash:r}}function jje(e){return/^\/[A-Za-z]:[\\/]/.test(e)?e.slice(1):e}function Mje(e,t){try{let n=new URL(e);if(n.protocol.toLowerCase()!==`file:`)return null;let r=n.pathname;if(r.length===0)return null;let i=jje(r);return{path:t?.decodePath===!1?i:Hx(i),hash:n.hash}}catch{return null}}function Nje(e){if(!e.startsWith(`/`))return!1;if(Eje.some(t=>e.startsWith(t))||wje.test(e))return!0;let t=e.slice(e.lastIndexOf(`/`)+1);return/\.[A-Za-z0-9_-]+$/.test(t)}function Pje(e,t){if(!t||wje.test(e))return e;let n=t.match(/^#L(\d+)(?:C(\d+))?$/i);if(!n?.[1])return e;let r=n[1],i=n[2];return`${e}:${r}${i?`:${i}`:``}`}function Fje(e){return Bx.test(e)||Vx.test(e)||xje.test(e)?!0:e.startsWith(`/`)?Nje(e):Sje.test(e)||Cje.test(e)}function Ije(e){return xje.test(e)||!e.startsWith(`/`)&&!Bx.test(e)&&!Vx.test(e)}function Lje(e){let t=e.match(bje);if(!t)return!1;let n=t[2]??``;return n.startsWith(`//`)?!0:!Tje.test(n)}function Rje(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function zje(e){return e.startsWith(`/`)||Rje(e)}function Bje(e){return Rje(e)||/[A-Za-z]:\\/.test(e)}function Vje(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replace(/\//g,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function Hje(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function Uje(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function Wje(e,t){let{path:n,line:r,column:i}=Uje(e),a=n;if(n.startsWith(`~/`)){let e=Hje(t);if(e){let t=Bje(e)?`\\`:`/`;a=Vje(e,n.slice(2),t)}}else zje(n)||(a=Vje(t,n,Bje(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}function Gje(e){if(!e)return null;let t=kje(e);if(t.length===0||t.startsWith(`#`))return null;let n=t.toLowerCase().startsWith(`file:`)?Mje(t):null,r=n??Aje(t),i=jje(n?r.path.trim():Hx(r.path.trim())),a=Hx(r.hash.trim());return i.length===0||!Bx.test(i)&&!Vx.test(i)&&Lje(i)||!Fje(i)?null:Pje(i,a)}function Kje(e){return Gje(e)!==null}function qje(e,t){let n=Gje(e);return n?Ije(n)?t?Wje(n,t):null:n:null}function Jje(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function Yje(e,t){if(e.length===0)return[{text:e}];let n=[],r=0;Dje.lastIndex=0;for(let i of e.matchAll(Dje)){let a=i[1]??``,o=i[2];if(!o)continue;let s=i.index+a.length,c=s+o.length;s<r||!Xje(o,t)||(s>r&&n.push({text:e.slice(r,s)}),n.push({text:o,href:o}),r=c)}return r===0?[{text:e}]:(r<e.length&&n.push({text:e.slice(r)}),n)}function Xje(e,t){let n=qje(e,t);if(!n)return null;let{path:r,line:i,column:a}=Uje(n),o=i?Number.parseInt(i,10):NaN,s=a?Number.parseInt(a,10):NaN,c=Number.isFinite(o)?o:void 0,l=Number.isFinite(s)?s:void 0;return{filePath:r,targetPath:n,displayPath:yje(n,t),basename:Jje(r),...c===void 0?{}:{line:c},...l===void 0?{}:{column:l}}}var Ux=null;function Zje(e,t,n){let r=e.getBoundingClientRect(),i=Math.min(Math.max(4,t),Math.max(4,window.innerWidth-r.width-4)),a=Math.min(Math.max(4,n),Math.max(4,window.innerHeight-r.height-4));e.style.left=`${i}px`,e.style.top=`${a}px`}function Qje({items:e,x:t,y:n}){Ux?.();let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`,r.dataset.testid=`context-menu-overlay`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-xl animate-in fade-in zoom-in-95`,i.style.left=`${t}px`,i.style.top=`${n}px`,i.setAttribute(`role`,`menu`);let a=()=>{document.removeEventListener(`keydown`,o),document.removeEventListener(`mousedown`,s),r.remove(),i.remove(),Ux===a&&(Ux=null)},o=e=>{e.key===`Escape`&&(e.preventDefault(),a())},s=e=>{i.contains(e.target)||a()};for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.textContent=t.label,e.disabled=t.disabled===!0,e.setAttribute(`role`,`menuitem`),e.className=t.disabled===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-muted-foreground/60 cursor-not-allowed`:t.destructive===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-destructive hover:bg-accent cursor-default`:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-popover-foreground hover:bg-accent cursor-default`,t.disabled!==!0&&e.addEventListener(`click`,()=>{a(),t.onClick()}),i.appendChild(e)}Ux=a,document.body.appendChild(r),document.body.appendChild(i),document.addEventListener(`keydown`,o),document.addEventListener(`mousedown`,s),(window.requestAnimationFrame??(e=>window.setTimeout(e,0)))(()=>Zje(i,t,n))}var $je=`overdeck:last-editor`;function Wx(){try{return localStorage.getItem($je)}catch{return null}}function Gx(e){try{localStorage.setItem($je,e)}catch{}}var eMe=`overdeck:markdown-open-target`;function tMe(){try{return localStorage.getItem(eMe)??`internal`}catch{return`internal`}}function nMe(e){try{localStorage.setItem(eMe,e)}catch{}}function Kx(...e){return e.filter(Boolean).join(` `)}var rMe=(0,z.createContext)(null),iMe=rMe.Provider;function aMe(){return(0,z.useContext)(rMe)}var qx=8,oMe=240;function Jx(e,t,{estimatedWidth:n=280,preferredHeight:r=400}={}){let[i,a]=(0,z.useState)({openUp:!1,align:`left`,maxHeight:r});return(0,z.useLayoutEffect)(()=>{if(!e||!t.current)return;let i=t.current.getBoundingClientRect(),o=window.innerHeight-i.bottom-qx,s=i.top-qx,c=o<Math.min(r,oMe)&&s>o;a({openUp:c,align:i.left+n>window.innerWidth-qx?`right`:`left`,maxHeight:Math.max(120,Math.min(r,c?s:o))})},[e,t,n,r]),i}var sMe=`size-3.5 shrink-0 text-muted-foreground`,cMe=12,lMe=new Set([`c`,`cc`,`cpp`,`cs`,`css`,`go`,`html`,`java`,`js`,`jsx`,`kt`,`mjs`,`php`,`py`,`rb`,`rs`,`scss`,`sh`,`sql`,`swift`,`ts`,`tsx`,`vue`]),uMe=new Set([`log`,`md`,`mdx`,`txt`]),dMe=new Set([`avif`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]),fMe=new Set([`7z`,`gz`,`rar`,`tar`,`tgz`,`zip`]),pMe=new Set([`env`,`toml`,`yaml`,`yml`]),mMe=null,Yx=null;async function hMe(){try{return Yx||=lb().request(e=>e[Cy.getAvailableEditors]()).then(e=>e.editors),await Yx}catch{return Yx=null,[]}}function gMe(e){let t=e.replace(/\\/g,`/`).split(`/`).at(-1)??``,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}var _Me=new Set([`md`,`mdx`,`markdown`]);function vMe(e){return _Me.has(gMe(e))}function yMe(e){let t=gMe(e);return t===`json`?Yie:lMe.has(t)?Kie:uMe.has(t)?Bs:dMe.has(t)?Jie:fMe.has(t)?Gie:pMe.has(t)?qie:Qie}function bMe({displayPath:e,line:t,column:n}){let r=t?e.replace(/:\d+(?::\d+)?$/,``):e,i=t?`L${t}${n?`:C${n}`:``}`:null;return i?`${r} · ${i}`:r}async function xMe(){let e=(await lb().request(e=>e[Cy.getAvailableEditors]())).editors,t=Wx(),n=t&&e.includes(t)?t:xy.find(t=>e.includes(t.id))?.id;if(!n)throw Error(`No available editors found.`);return Gx(n),n}function SMe(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}async function CMe(e,t){try{return mMe||=v(()=>Promise.resolve().then(()=>odt).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),(await mMe).codeToHtml(e,{lang:t||`text`,theme:`github-light`})}catch{return`<pre><code>${SMe(e)}</code></pre>`}}function wMe(e){let t=e.replace(/:\d+(?::\d+)?$/,``).replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean);return n.length>1?n.slice(1).join(`/`):t}function TMe(e){return e.replace(/\\/g,`/`).match(/\/workspaces\/feature-([a-z]+-\d+)(?:\/|:|$)/i)?.[1]?.toUpperCase()}var EMe=(0,z.memo)(function({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a,className:o,issueId:s}){let c=yMe(e),l=bMe({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a}),u=vMe(e),d=aMe(),f=(0,z.useRef)(null),p=(0,z.useRef)(0),m=(0,z.useRef)(!1),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)({status:`loading`}),{openUp:y,align:b,maxHeight:x}=Jx(h,f,{estimatedWidth:520,preferredHeight:360}),S=s??TMe(t),C=(0,z.useMemo)(()=>wMe(n),[n]),w=(0,z.useCallback)(()=>{xMe().then(e=>lb().request(n=>n[Cy.shellOpenInEditor]({cwd:t,editor:e}))).then(()=>{U.success(`Opened in editor`)}).catch(e=>{U.error(`Failed to open file: ${e instanceof Error?e.message:String(e)}`)})},[t]),T=(0,z.useCallback)(e=>{lb().request(n=>n[Cy.shellOpenInEditor]({cwd:t,editor:e})).then(()=>{U.success(`Opened in editor`)}).catch(e=>{U.error(`Failed to open file: ${e instanceof Error?e.message:String(e)}`)})},[t]),E=(0,z.useCallback)(()=>{let t=tMe();if(t===`internal`){if(d){d.openOrFocusEditorPane(e,r);return}w();return}T(t)},[d,e,r,w,T]),D=(0,z.useCallback)(()=>{p.current++,g(!1)},[]),O=(0,z.useCallback)(()=>{let e=S;if(!e){let e=`No issue context available for Quickview`;v({status:`error`,message:e}),g(!0),U.error(e);return}let t=++p.current;v({status:`loading`}),g(!0),lb().request(t=>t[Cy.readWorkspaceFile]({issueId:e,relativePath:C,...i?{line:i}:{},contextLines:cMe})).then(e=>CMe(e.text,e.lang).then(t=>({html:t,result:e}))).then(({html:e,result:n})=>{t===p.current&&v({status:`ready`,html:e,truncated:n.truncated,totalLines:n.totalLines})}).catch(e=>{if(t!==p.current)return;let n=e instanceof Error?e.message:String(e);v({status:`error`,message:n}),U.error(`Failed to load Quickview: ${n}`)})},[i,S,C]),k=(0,z.useCallback)((e,t)=>{navigator.clipboard.writeText(e).then(()=>{U.success(`Copied ${t}`)}).catch(e=>{U.error(`Failed to copy ${t}: ${e instanceof Error?e.message:String(e)}`)})},[]),A=(0,z.useCallback)((i,a)=>{hMe().then(o=>{Qje({x:i,y:a,items:[{label:`Open in internal editor`,onClick:()=>{nMe(`internal`),d?d.openOrFocusEditorPane(e,r):w()}},...xy.filter(e=>o.includes(e.id)).map(e=>({label:`Open in ${e.label}`,onClick:()=>{nMe(e.id),T(e.id)}})),{label:`Copy relative path`,onClick:()=>k(n,`relative path`)},{label:`Copy full path`,onClick:()=>k(t,`full path`)}]})})},[d,e,t,r,w,T,n,k]);return(0,z.useEffect)(()=>{let e=e=>{e.key===`Shift`&&m.current&&!h&&O()},t=e=>{e.key===`Shift`&&D()};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[D,O,h]),(0,B.jsxs)(`span`,{ref:f,className:`relative inline-flex max-w-full align-baseline`,"data-testid":`markdown-file-link-container`,onMouseEnter:e=>{m.current=!0,e.shiftKey&&O()},onMouseLeave:()=>{m.current=!1,D()},children:[(0,B.jsxs)(`a`,{href:t,title:t,className:Kx(`chat-markdown-file-link relative top-[2px] inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-card px-2 py-0.5 font-mono text-[11px] leading-5 text-foreground no-underline transition-colors hover:border-primary/50 hover:bg-accent`,o),onClick:e=>{e.preventDefault(),e.stopPropagation(),u?E():w()},onContextMenu:e=>{if(e.preventDefault(),e.stopPropagation(),u){A(e.clientX,e.clientY);return}Qje({x:e.clientX,y:e.clientY,items:[{label:`Open in editor`,onClick:w},{label:`Copy relative path`,onClick:()=>k(n,`relative path`)},{label:`Copy full path`,onClick:()=>k(t,`full path`)}]})},children:[(0,B.jsx)(c,{className:sMe,"aria-hidden":`true`,"data-testid":`markdown-file-link-icon`}),(0,B.jsx)(`span`,{className:`truncate`,"data-testid":`markdown-file-link-label`,children:l})]}),h&&(0,B.jsxs)(`div`,{"data-testid":`markdown-file-quickview`,className:`absolute z-50 w-[min(520px,calc(100vw-16px))] overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl`,style:{maxHeight:`${x}px`,...y?{bottom:`100%`,marginBottom:6}:{top:`100%`,marginTop:6},...b===`right`?{right:0}:{left:0}},children:[_.status===`loading`&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-xs text-muted-foreground`,"data-testid":`markdown-file-quickview-loading`,children:[(0,B.jsx)(gc,{size:13,className:`animate-spin`,"aria-hidden":`true`}),`Loading preview…`]}),_.status===`error`&&(0,B.jsx)(`div`,{className:`p-3 text-xs text-destructive`,"data-testid":`markdown-file-quickview-error`,children:_.message}),_.status===`ready`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{"data-testid":`markdown-file-quickview-content`,className:`max-h-[300px] overflow-auto text-xs [&_pre]:m-0 [&_pre]:p-3 [&_pre]:text-xs`,dangerouslySetInnerHTML:{__html:_.html}}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[i?`line ${i}`:`top of file`,` · `,_.totalLines,` lines`]}),_.truncated&&(0,B.jsx)(`span`,{"data-testid":`markdown-file-quickview-truncated`,children:`truncated — first 256 KiB`})]})]})]})]})}),DMe=300*1e3,OMe=30*1e3,kMe=5e3,Xx=new Map;function AMe(e,t){return`${e??``}\0${t}`}function jMe(e,t){let n=AMe(e,t),r=Xx.get(n);return r?r.expiresAt<Date.now()?(Xx.delete(n),null):(Xx.delete(n),Xx.set(n,r),{exists:r.exists,kind:r.kind}):null}function MMe(e,t,n,r){if(Xx.size>=kMe){let e=Xx.keys().next().value;e!==void 0&&Xx.delete(e)}let i=n?DMe:OMe;Xx.set(AMe(e,t),{exists:n,kind:r,expiresAt:Date.now()+i})}var Zx=new Map;function NMe(e,t){return`${e??``}\0${t}`}function PMe(e,t){return t?!!e||t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)||t.startsWith(`\\\\`):!1}function FMe(e,t){if(!PMe(e,t))return{state:`missing`};let n=jMe(e,t);return n?n.exists?{state:`exists`,kind:n.kind}:{state:`missing`}:{state:`loading`}}function IMe(e,t){let[n,r]=(0,z.useState)(()=>FMe(e,t));return(0,z.useEffect)(()=>{if(!PMe(e,t)){r({state:`missing`});return}let n=jMe(e,t);if(n){r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`});return}r({state:`loading`});let i=!1,a=NMe(e,t),o=Zx.get(a);return o||(o=lb().request(n=>n[Cy.resolveFilePathExists]({cwd:e,path:t})).then(e=>({exists:e.exists,kind:e.kind})).catch(()=>({exists:!1,kind:null})),Zx.set(a,o),o.finally(()=>{Zx.get(a)===o&&Zx.delete(a)})),o.then(n=>{MMe(e,t,n.exists,n.kind),!i&&r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`})}),()=>{i=!0}},[e,t]),n}var LMe=class{maxEntries;maxMemoryBytes;cache=new Map;totalSize=0;constructor(e,t){this.maxEntries=e,this.maxMemoryBytes=t}get(e){let t=this.cache.get(e);return t?(this.promote(e,t),t.value):null}set(e,t,n){let r=this.cache.get(e);r&&(this.totalSize-=r.approximateSize,this.cache.delete(e)),this.evictIfNeeded(n),this.cache.set(e,{value:t,approximateSize:n}),this.totalSize+=n}clear(){this.cache.clear(),this.totalSize=0}promote(e,t){this.cache.delete(e),this.cache.set(e,t)}evictIfNeeded(e){for(;(this.cache.size>=this.maxEntries||this.totalSize+e>this.maxMemoryBytes)&&this.cache.size>0;){let e=this.cache.keys().next().value;if(e===void 0)break;let t=this.cache.get(e);t&&(this.totalSize-=t.approximateSize),this.cache.delete(e)}}},Z={commandDeck:`_commandDeck_py729_3`,layout:`_layout_py729_13`,sidebar:`_sidebar_py729_20`,resizeHandle:`_resizeHandle_py729_29`,sidebarHeader:`_sidebarHeader_py729_43`,sidebarHeaderRow:`_sidebarHeaderRow_py729_56`,sidebarHeaderGroup:`_sidebarHeaderGroup_py729_65`,sidebarTitle:`_sidebarTitle_py729_73`,sidebarSubtitle:`_sidebarSubtitle_py729_83`,segmentControl:`_segmentControl_py729_90`,segmentButton:`_segmentButton_py729_98`,segmentButtonActive:`_segmentButtonActive_py729_121`,segmentCount:`_segmentCount_py729_127`,projectTree:`_projectTree_py729_137`,sidebarSection:`_sidebarSection_py729_143`,sidebarSectionCollapsed:`_sidebarSectionCollapsed_py729_151`,sectionHeader:`_sectionHeader_py729_155`,sectionTitle:`_sectionTitle_py729_176`,sectionBody:`_sectionBody_py729_180`,membershipStatus:`_membershipStatus_py729_186`,membershipError:`_membershipError_py729_193`,membershipErrorContent:`_membershipErrorContent_py729_212`,membershipErrorDetail:`_membershipErrorDetail_py729_216`,membershipErrorRetry:`_membershipErrorRetry_py729_222`,projectNode:`_projectNode_py729_239`,projectHeader:`_projectHeader_py729_243`,chevron:`_chevron_py729_263`,chevronOpen:`_chevronOpen_py729_269`,projectName:`_projectName_py729_273`,featureCount:`_featureCount_py729_280`,projectCiChip:`_projectCiChip_py729_286`,projectAddConvBtn:`_projectAddConvBtn_py729_300`,featureItem:`_featureItem_py729_321`,featureTitleLine:`_featureTitleLine_py729_337`,featureMetaLine:`_featureMetaLine_py729_344`,featurePipe:`_featurePipe_py729_353`,pipeDone:`_pipeDone_py729_369`,pipeWorking:`_pipeWorking_py729_370`,pipePaused:`_pipePaused_py729_371`,pipeError:`_pipeError_py729_372`,pipeMerged:`_pipeMerged_py729_373`,featureItemSelected:`_featureItemSelected_py729_379`,featureStatus:`_featureStatus_py729_383`,featureLabel:`_featureLabel_py729_392`,featureLabelUntitled:`_featureLabelUntitled_py729_405`,featureBadgeGroup:`_featureBadgeGroup_py729_410`,featureBadge:`_featureBadge_py729_410`,featureBadge_running:`_featureBadge_running_py729_429`,featureBadge_paused:`_featureBadge_paused_py729_436`,featureBadge_troubled:`_featureBadge_troubled_py729_442`,featureBadge_stopped:`_featureBadge_stopped_py729_449`,featureBadge_error:`_featureBadge_error_py729_455`,featureBadge_waiting:`_featureBadge_waiting_py729_461`,featureActivityError:`_featureActivityError_py729_468`,featureResourceChip:`_featureResourceChip_py729_474`,featureResourceLine:`_featureResourceLine_py729_489`,featureResourceStrip:`_featureResourceStrip_py729_497`,featureResourceIcon:`_featureResourceIcon_py729_506`,featureResourcePopover:`_featureResourcePopover_py729_517`,featureResourceRow:`_featureResourceRow_py729_540`,featureResourceCleanupButton:`_featureResourceCleanupButton_py729_548`,featureId_sidebar:`_featureId_sidebar_py729_565`,featureState:`_featureState_py729_573`,featureState_done:`_featureState_done_py729_584`,featureState_progress:`_featureState_progress_py729_590`,featureState_review:`_featureState_review_py729_596`,featureState_context:`_featureState_context_py729_602`,featureState_planning:`_featureState_planning_py729_608`,featureState_todo:`_featureState_todo_py729_614`,featureItemWrapper:`_featureItemWrapper_py729_621`,featureItemWrapperWorking:`_featureItemWrapperWorking_py729_629`,featureItemWrapperError:`_featureItemWrapperError_py729_630`,featureItemWrapperMerged:`_featureItemWrapperMerged_py729_631`,featureItemWrapperReady:`_featureItemWrapperReady_py729_632`,featureItemWrapperPaused:`_featureItemWrapperPaused_py729_633`,unpauseBtn:`_unpauseBtn_py729_650`,sessionSubtitle:`_sessionSubtitle_py729_670`,sessionPausedReason:`_sessionPausedReason_py729_680`,featureItemWrapperNeedsAttention:`_featureItemWrapperNeedsAttention_py729_693`,featureItemWrapperSelected:`_featureItemWrapperSelected_py729_691`,featureItemRow:`_featureItemRow_py729_701`,featureItemCaret:`_featureItemCaret_py729_707`,featureItemCaretPlaceholder:`_featureItemCaretPlaceholder_py729_725`,sessionList:`_sessionList_py729_731`,treeFilterRow:`_treeFilterRow_py729_736`,treeFilterButton:`_treeFilterButton_py729_742`,treeFilterButtonActive:`_treeFilterButtonActive_py729_754`,issueHeader:`_issueHeader_py729_761`,issueHeaderRow:`_issueHeaderRow_py729_770`,issueHeaderLeft:`_issueHeaderLeft_py729_777`,issueHeaderId:`_issueHeaderId_py729_785`,issueHeaderTitle:`_issueHeaderTitle_py729_799`,issueHeaderRight:`_issueHeaderRight_py729_808`,pipelineDots:`_pipelineDots_py729_815`,pipelineDotGroup:`_pipelineDotGroup_py729_821`,pipelineDot:`_pipelineDot_py729_815`,pipelineDotLabel:`_pipelineDotLabel_py729_834`,issueHeaderCost:`_issueHeaderCost_py729_841`,issueHeaderActions:`_issueHeaderActions_py729_847`,issueHeaderBtn:`_issueHeaderBtn_py729_854`,issueHeaderBtnDisabled:`_issueHeaderBtnDisabled_py729_873`,issueHeaderBadge:`_issueHeaderBadge_py729_883`,sessionPanel:`_sessionPanel_py729_893`,sessionPanelHeader:`_sessionPanelHeader_py729_908`,sessionPanelInfo:`_sessionPanelInfo_py729_918`,sessionPanelType:`_sessionPanelType_py729_925`,sessionPanelPresence:`_sessionPanelPresence_py729_935`,sessionPanelModel:`_sessionPanelModel_py729_942`,sessionPanelDuration:`_sessionPanelDuration_py729_951`,sessionPanelToggle:`_sessionPanelToggle_py729_958`,sessionPanelToggleBtn:`_sessionPanelToggleBtn_py729_968`,sessionPanelToggleBtnActive:`_sessionPanelToggleBtnActive_py729_983`,deliveryMethodSelect:`_deliveryMethodSelect_py729_993`,sessionPanelContent:`_sessionPanelContent_py729_1008`,reviewSummary:`_reviewSummary_py729_1017`,reviewSummaryBanner:`_reviewSummaryBanner_py729_1027`,reviewerStrip:`_reviewerStrip_py729_1038`,reviewerCard:`_reviewerCard_py729_1047`,reviewerCardLabel:`_reviewerCardLabel_py729_1060`,reviewerCardStats:`_reviewerCardStats_py729_1068`,reviewSynthesis:`_reviewSynthesis_py729_1077`,reviewSynthesisHeading:`_reviewSynthesisHeading_py729_1084`,sessionPanelTranscript:`_sessionPanelTranscript_py729_1093`,sessionPanelEmpty:`_sessionPanelEmpty_py729_1099`,sessionNode:`_sessionNode_py729_1109`,sessionNodeSelected:`_sessionNodeSelected_py729_1136`,sessionToggleSlot:`_sessionToggleSlot_py729_1140`,sessionDotSlot:`_sessionDotSlot_py729_1141`,sessionIconSlot:`_sessionIconSlot_py729_1151`,sessionIconRunning:`_sessionIconRunning_py729_1163`,sessionIconReview:`_sessionIconReview_py729_1168`,sessionIconPaused:`_sessionIconPaused_py729_1173`,sessionIconError:`_sessionIconError_py729_1178`,sessionModel:`_sessionModel_py729_1183`,sessionToggleButton:`_sessionToggleButton_py729_1191`,sessionTypeBadge:`_sessionTypeBadge_py729_1198`,sessionLabel:`_sessionLabel_py729_1210`,sessionStatus:`_sessionStatus_py729_1220`,sessionStatus_running:`_sessionStatus_running_py729_1230`,sessionStatus_paused:`_sessionStatus_paused_py729_1236`,sessionStatus_error:`_sessionStatus_error_py729_1241`,sessionStatus_starting:`_sessionStatus_starting_py729_1246`,sessionStatus_stopped:`_sessionStatus_stopped_py729_1251`,sessionStatus_unknown:`_sessionStatus_unknown_py729_1252`,sessionStatus_idle:`_sessionStatus_idle_py729_1253`,sessionStatus_working:`_sessionStatus_working_py729_1258`,sessionStatus_thinking:`_sessionStatus_thinking_py729_1263`,sessionStatus_waiting:`_sessionStatus_waiting_py729_1268`,sessionDuration:`_sessionDuration_py729_1273`,featureCost:`_featureCost_py729_1281`,emptyProject:`_emptyProject_py729_1287`,inactiveProjectsSection:`_inactiveProjectsSection_py729_1294`,inactiveProjectsSectionHeader:`_inactiveProjectsSectionHeader_py729_1300`,sessionChildList:`_sessionChildList_py729_1309`,sectionDivider:`_sectionDivider_py729_1314`,projectConvItem:`_projectConvItem_py729_1329`,projectConvItemSelected:`_projectConvItemSelected_py729_1350`,projectConvLabel:`_projectConvLabel_py729_1355`,conversationActions:`_conversationActions_py729_1364`,conversationStopBtn:`_conversationStopBtn_py729_1375`,conversationStarBtn:`_conversationStarBtn_py729_1385`,conversationStarPersistent:`_conversationStarPersistent_py729_1386`,conversationTime:`_conversationTime_py729_1398`,content:`_content_py729_1403`,contentEmpty:`_contentEmpty_py729_1411`,unknownProject:`_unknownProject_py729_1420`,unknownProjectList:`_unknownProjectList_py729_1443`,unknownProjectRetry:`_unknownProjectRetry_py729_1451`,unknownProjectBack:`_unknownProjectBack_py729_1452`,activityColumn:`_activityColumn_py729_1474`,activityColumnCollapsed:`_activityColumnCollapsed_py729_1486`,activityCollapsedLabel:`_activityCollapsedLabel_py729_1505`,featureHeader:`_featureHeader_py729_1515`,featureTitle:`_featureTitle_py729_337`,featureId:`_featureId_py729_565`,badgeBar:`_badgeBar_py729_1539`,badge:`_badge_py729_1539`,badgeDisabled:`_badgeDisabled_py729_1566`,activityContainer:`_activityContainer_py729_1577`,agentSection:`_agentSection_py729_1587`,agentSectionExpanded:`_agentSectionExpanded_py729_1599`,sectionChevron:`_sectionChevron_py729_1622`,sectionType:`_sectionType_py729_1628`,typePlanning:`_typePlanning_py729_1637`,typeWork:`_typeWork_py729_1642`,typeReview:`_typeReview_py729_1647`,typeTest:`_typeTest_py729_1652`,typeMerge:`_typeMerge_py729_1657`,sectionModel:`_sectionModel_py729_1665`,sectionTime:`_sectionTime_py729_1671`,sectionCost:`_sectionCost_py729_1677`,costSummary:`_costSummary_py729_1684`,sectionStatus:`_sectionStatus_py729_1692`,statusRunning:`_statusRunning_py729_1699`,pulse:`_pulse_py729_3013`,statusCompleted:`_statusCompleted_py729_1704`,statusFailed:`_statusFailed_py729_1708`,sectionPreview:`_sectionPreview_py729_1719`,sectionContent:`_sectionContent_py729_1733`,sectionContentConstrained:`_sectionContentConstrained_py729_1749`,sectionResizeHandle:`_sectionResizeHandle_py729_1754`,unreadDot:`_unreadDot_py729_1773`,isolationOverlay:`_isolationOverlay_py729_1782`,isolationHeader:`_isolationHeader_py729_1791`,isolationClose:`_isolationClose_py729_1800`,isolationContent:`_isolationContent_py729_1817`,modalOverlay:`_modalOverlay_py729_1829`,modalContent:`_modalContent_py729_1840`,modalHeader:`_modalHeader_py729_1851`,modalTitle:`_modalTitle_py729_1859`,modalClose:`_modalClose_py729_1865`,modalBody:`_modalBody_py729_1880`,uploadZone:`_uploadZone_py729_1887`,uploadZoneActive:`_uploadZoneActive_py729_1898`,uploadIcon:`_uploadIcon_py729_1904`,uploadText:`_uploadText_py729_1908`,uploadHint:`_uploadHint_py729_1913`,artifactList:`_artifactList_py729_1918`,artifactItem:`_artifactItem_py729_1925`,artifactName:`_artifactName_py729_1941`,artifactDate:`_artifactDate_py729_1948`,syncButton:`_syncButton_py729_1954`,spinning:`_spinning_py729_1983`,spin:`_spin_py729_1983`,shadowToggle:`_shadowToggle_py729_1988`,shadowLabel:`_shadowLabel_py729_1998`,shadowTitle:`_shadowTitle_py729_2002`,shadowDesc:`_shadowDesc_py729_2008`,markdownContent:`_markdownContent_py729_2015`,kbdHint:`_kbdHint_py729_2075`,deaconPanel:`_deaconPanel_py729_2092`,deaconHeader:`_deaconHeader_py729_2097`,deaconTitle:`_deaconTitle_py729_2110`,deaconMeta:`_deaconMeta_py729_2118`,deaconActionCount:`_deaconActionCount_py729_2124`,deaconSpecialists:`_deaconSpecialists_py729_2135`,deaconSpecRow:`_deaconSpecRow_py729_2141`,deaconSpecDot:`_deaconSpecDot_py729_2147`,deaconSpecName:`_deaconSpecName_py729_2154`,deaconSpecFailures:`_deaconSpecFailures_py729_2159`,deaconActions:`_deaconActions_py729_2165`,deaconAction:`_deaconAction_py729_2124`,deaconLogToggle:`_deaconLogToggle_py729_2182`,deaconLogViewer:`_deaconLogViewer_py729_2200`,deaconLogEmpty:`_deaconLogEmpty_py729_2211`,deaconLogEntry:`_deaconLogEntry_py729_2217`,deaconLogTime:`_deaconLogTime_py729_2224`,deaconLogLevel:`_deaconLogLevel_py729_2230`,deaconLogMessage:`_deaconLogMessage_py729_2237`,sidebarFooter:`_sidebarFooter_py729_2245`,versionLabel:`_versionLabel_py729_2255`,conversationSection:`_conversationSection_py729_2266`,conversationHeader:`_conversationHeader_py729_2270`,conversationToggle:`_conversationToggle_py729_2276`,conversationTitle:`_conversationTitle_py729_2297`,conversationAddBtn:`_conversationAddBtn_py729_2301`,conversationListWrapper:`_conversationListWrapper_py729_2323`,conversationControls:`_conversationControls_py729_2329`,convTabBar:`_convTabBar_py729_2340`,convTab:`_convTab_py729_2340`,convTabActive:`_convTabActive_py729_2365`,convTabCount:`_convTabCount_py729_2371`,convSortSelect:`_convSortSelect_py729_2387`,conversationList:`_conversationList_py729_2323`,conversationAddForm:`_conversationAddForm_py729_2419`,conversationInput:`_conversationInput_py729_2423`,conversationError:`_conversationError_py729_2441`,conversationEmpty:`_conversationEmpty_py729_2447`,skeletonList:`_skeletonList_py729_2459`,skeletonItem:`_skeletonItem_py729_2466`,shimmer:`_shimmer_py729_1`,conversationItem:`_conversationItem_py729_2475`,conversationItemConfirming:`_conversationItemConfirming_py729_2517`,conversationItemSelected:`_conversationItemSelected_py729_2524`,conversationMain:`_conversationMain_py729_2529`,conversationName:`_conversationName_py729_2537`,conversationMetaLine:`_conversationMetaLine_py729_2541`,conversationMetaSep:`_conversationMetaSep_py729_2559`,conversationKebabBtn:`_conversationKebabBtn_py729_2566`,conversationDot:`_conversationDot_py729_2632`,conversationWorkingSpinner:`_conversationWorkingSpinner_py729_2636`,conversationWorkingPulse:`_conversationWorkingPulse_py729_2643`,conversationArchiveBtn:`_conversationArchiveBtn_py729_2658`,archiveConfirmInline:`_archiveConfirmInline_py729_2676`,archiveConfirmLabelInline:`_archiveConfirmLabelInline_py729_2684`,archiveConfirmYesInline:`_archiveConfirmYesInline_py729_2689`,archiveConfirmNoInline:`_archiveConfirmNoInline_py729_2690`,conversationSummaryForkBtn:`_conversationSummaryForkBtn_py729_2783`,conversationCopyBtn:`_conversationCopyBtn_py729_2806`,conversationEditBtn:`_conversationEditBtn_py729_2829`,conversationNameInput:`_conversationNameInput_py729_2853`,conversationArchiveBtnLarge:`_conversationArchiveBtnLarge_py729_2866`,conversationModelBar:`_conversationModelBar_py729_2883`,conversationModelLabel:`_conversationModelLabel_py729_2893`,conversationTerminal:`_conversationTerminal_py729_902`,conversationTerminalHeader:`_conversationTerminalHeader_py729_2910`,conversationHeaderContainer:`_conversationHeaderContainer_py729_2922`,conversationSessionId:`_conversationSessionId_py729_2930`,terminalBranchBarMode:`_terminalBranchBarMode_py729_2936`,conversationTerminalTitle:`_conversationTerminalTitle_py729_2941`,conversationTerminalTitleText:`_conversationTerminalTitleText_py729_2957`,titleRegenerating:`_titleRegenerating_py729_2976`,titleShimmerSweep:`_titleShimmerSweep_py729_1`,spinnerIcon:`_spinnerIcon_py729_3006`,pulseIcon:`_pulseIcon_py729_3013`,conversationTerminalStatus:`_conversationTerminalStatus_py729_3019`,copyLinkButton:`_copyLinkButton_py729_3041`,archiveConfirm:`_archiveConfirm_py729_2676`,archiveConfirmLabel:`_archiveConfirmLabel_py729_2684`,archiveConfirmYes:`_archiveConfirmYes_py729_2689`,archiveConfirmNo:`_archiveConfirmNo_py729_2690`,conversationTitleEditBtn:`_conversationTitleEditBtn_py729_3092`,conversationTitleInput:`_conversationTitleInput_py729_3118`,conversationTerminalBody:`_conversationTerminalBody_py729_3132`,conversationHeaderShell:`_conversationHeaderShell_py729_3145`,conversationHeaderPrimary:`_conversationHeaderPrimary_py729_3142`,conversationHeaderActions:`_conversationHeaderActions_py729_3162`,conversationMetaRow:`_conversationMetaRow_py729_3143`,conversationAboutToggle:`_conversationAboutToggle_py729_3184`,conversationAboutToggleActive:`_conversationAboutToggleActive_py729_3205`,headerMenuWrap:`_headerMenuWrap_py729_3212`,headerMenuOverlay:`_headerMenuOverlay_py729_3217`,headerMenu:`_headerMenu_py729_3212`,headerMenuItem:`_headerMenuItem_py729_3241`,headerMenuItemActive:`_headerMenuItemActive_py729_3266`,headerMenuItemCheck:`_headerMenuItemCheck_py729_3270`,headerMenuItemDestructive:`_headerMenuItemDestructive_py729_3277`,headerMenuDivider:`_headerMenuDivider_py729_3286`,headerSubmenu:`_headerSubmenu_py729_3292`,headerMenuDeliveryRow:`_headerMenuDeliveryRow_py729_3312`,conversationAboutDrawer:`_conversationAboutDrawer_py729_3326`,conversationAboutText:`_conversationAboutText_py729_3336`,conversationAboutMeta:`_conversationAboutMeta_py729_3343`,conversationAboutMuted:`_conversationAboutMuted_py729_3351`,conversationResumeOverlay:`_conversationResumeOverlay_py729_3359`,conversationResumeBar:`_conversationResumeBar_py729_3369`,conversationResumeControls:`_conversationResumeControls_py729_3378`,conversationResumeContractToggle:`_conversationResumeContractToggle_py729_3384`,conversationResumeBtn:`_conversationResumeBtn_py729_3407`,conversationClearedBanner:`_conversationClearedBanner_py729_3429`,conversationClearedBannerText:`_conversationClearedBannerText_py729_3450`,viewToggle:`_viewToggle_py729_3456`,viewToggleBtn:`_viewToggleBtn_py729_3467`,viewToggleBtnActive:`_viewToggleBtnActive_py729_3484`,conversationView:`_conversationView_py729_3491`,conversationEmptyState:`_conversationEmptyState_py729_3499`,conversationEmptyStateTitle:`_conversationEmptyStateTitle_py729_3510`,conversationEmptyStateSubtitle:`_conversationEmptyStateSubtitle_py729_3517`,conversationConnecting:`_conversationConnecting_py729_3523`,transcriptSkeleton:`_transcriptSkeleton_py729_3534`,transcriptSkeletonAssistant:`_transcriptSkeletonAssistant_py729_3542`,transcriptSkeletonUser:`_transcriptSkeletonUser_py729_3548`,transcriptSkeletonAvatar:`_transcriptSkeletonAvatar_py729_3553`,transcriptSkeletonLine:`_transcriptSkeletonLine_py729_3554`,transcriptSkeletonLineMedium:`_transcriptSkeletonLineMedium_py729_3555`,transcriptSkeletonLineShort:`_transcriptSkeletonLineShort_py729_3556`,transcriptSkeletonBubble:`_transcriptSkeletonBubble_py729_3557`,transcriptSkeletonBubbleShort:`_transcriptSkeletonBubbleShort_py729_3558`,transcriptSkeletonLines:`_transcriptSkeletonLines_py729_3572`,messagesTimeline:`_messagesTimeline_py729_3613`,messagesTimelineInner:`_messagesTimelineInner_py729_3622`,contextMessageRow:`_contextMessageRow_py729_3632`,contextMessageBlock:`_contextMessageBlock_py729_3636`,contextMessageToggle:`_contextMessageToggle_py729_3644`,contextMessageIcon:`_contextMessageIcon_py729_3665`,contextMessageLabel:`_contextMessageLabel_py729_3670`,contextMessageContent:`_contextMessageContent_py729_3674`,userMessageRow:`_userMessageRow_py729_3680`,subagentTranscript:`_subagentTranscript_py729_3689`,userMessageBubble:`_userMessageBubble_py729_3689`,userMessageText:`_userMessageText_py729_3701`,assistantMessageRow:`_assistantMessageRow_py729_3710`,assistantMessageAvatar:`_assistantMessageAvatar_py729_3718`,assistantMessageContent:`_assistantMessageContent_py729_3725`,messageTimestamp:`_messageTimestamp_py729_3731`,messageMetadata:`_messageMetadata_py729_3737`,messageSeparator:`_messageSeparator_py729_3745`,workLogGroup:`_workLogGroup_py729_3751`,workLogEntry:`_workLogEntry_py729_3761`,workLogTerminalIcon:`_workLogTerminalIcon_py729_3771`,workLogLabel:`_workLogLabel_py729_3780`,workLogDetail:`_workLogDetail_py729_3787`,workLogResult:`_workLogResult_py729_3798`,workLogToolHeader:`_workLogToolHeader_py729_3814`,workLogThinkingResult:`_workLogThinkingResult_py729_3821`,workLogExpandBtn:`_workLogExpandBtn_py729_3836`,failedPromptList:`_failedPromptList_py729_3849`,failedPromptCard:`_failedPromptCard_py729_3856`,failedPromptHeader:`_failedPromptHeader_py729_3863`,failedPromptText:`_failedPromptText_py729_3873`,failedPromptActions:`_failedPromptActions_py729_3881`,workingIndicator:`_workingIndicator_py729_3906`,workingDots:`_workingDots_py729_3915`,workingDotBounce:`_workingDotBounce_py729_1`,workingLabel:`_workingLabel_py729_3936`,chatMarkdown:`_chatMarkdown_py729_3942`,codeBlock:`_codeBlock_py729_4108`,copyButton:`_copyButton_py729_4117`,shikiOutput:`_shikiOutput_py729_4146`,codePlain:`_codePlain_py729_4158`,mdLink:`_mdLink_py729_4168`,mdFallback:`_mdFallback_py729_4175`,composerFooter:`_composerFooter_py729_4186`,composerBox:`_composerBox_py729_4192`,composerBoxDisabled:`_composerBoxDisabled_py729_4209`,composerEditor:`_composerEditor_py729_4215`,composerEditorDisabled:`_composerEditorDisabled_py729_4223`,composerEditable:`_composerEditable_py729_4228`,composerPlaceholder:`_composerPlaceholder_py729_4239`,slashMenu:`_slashMenu_py729_4250`,slashMenuItem:`_slashMenuItem_py729_4264`,slashMenuItemSelected:`_slashMenuItemSelected_py729_4279`,slashMenuLabel:`_slashMenuLabel_py729_4284`,slashMenuDescription:`_slashMenuDescription_py729_4291`,slashMenuMatch:`_slashMenuMatch_py729_4296`,composerToolbar:`_composerToolbar_py729_4304`,composerToolbarSpacer:`_composerToolbarSpacer_py729_4311`,composerToolbarModelDrift:`_composerToolbarModelDrift_py729_4321`,composerToolbarDivider:`_composerToolbarDivider_py729_4340`,sendButton:`_sendButton_py729_4350`,voiceToolbarButton:`_voiceToolbarButton_py729_4374`,voiceToolbarButtonActive:`_voiceToolbarButtonActive_py729_4375`,voiceWidget:`_voiceWidget_py729_4412`,voiceWidgetHeader:`_voiceWidgetHeader_py729_4420`,voiceWidgetActions:`_voiceWidgetActions_py729_4421`,voiceWidgetTitle:`_voiceWidgetTitle_py729_4428`,voiceWidgetMeta:`_voiceWidgetMeta_py729_4434`,voiceModeToggle:`_voiceModeToggle_py729_4440`,voiceModeButton:`_voiceModeButton_py729_4448`,voiceModeActive:`_voiceModeActive_py729_4449`,voiceWidgetControls:`_voiceWidgetControls_py729_4468`,voiceFieldLabel:`_voiceFieldLabel_py729_4475`,voiceSelect:`_voiceSelect_py729_4484`,voiceWaveformCanvas:`_voiceWaveformCanvas_py729_4494`,voiceTranscriptPreview:`_voiceTranscriptPreview_py729_4503`,voiceStartButton:`_voiceStartButton_py729_4523`,voiceStopButton:`_voiceStopButton_py729_4524`,voiceSecondaryButton:`_voiceSecondaryButton_py729_4525`,voiceInsertButton:`_voiceInsertButton_py729_4526`,composerImageStrip:`_composerImageStrip_py729_4563`,composerImageCard:`_composerImageCard_py729_4570`,composerImageThumb:`_composerImageThumb_py729_4582`,composerImageMeta:`_composerImageMeta_py729_4589`,composerImageName:`_composerImageName_py729_4596`,composerImageStatus:`_composerImageStatus_py729_4604`,composerImageError:`_composerImageError_py729_4612`,composerImageRemoveButton:`_composerImageRemoveButton_py729_4617`,composerFileThumb:`_composerFileThumb_py729_4637`,composerFileSize:`_composerFileSize_py729_4645`,spinner:`_spinner_py729_3006`,pickerContainer:`_pickerContainer_py729_4661`,pickerBtn:`_pickerBtn_py729_4667`,pickerHint:`_pickerHint_py729_4694`,pickerLabel:`_pickerLabel_py729_4701`,pickerProviderIcon:`_pickerProviderIcon_py729_4711`,pickerDropdown:`_pickerDropdown_py729_4718`,pickerDropdownUp:`_pickerDropdownUp_py729_4734`,pickerProviderSidebar:`_pickerProviderSidebar_py729_4740`,pickerProviderBtn:`_pickerProviderBtn_py729_4754`,pickerProviderBtnActive:`_pickerProviderBtnActive_py729_4775`,pickerProviderBtnIcon:`_pickerProviderBtnIcon_py729_4792`,providerBadge:`_providerBadge_py729_4799`,pickerMainPanel:`_pickerMainPanel_py729_4815`,pickerHarnessHeader:`_pickerHarnessHeader_py729_4824`,pickerSearchWrapper:`_pickerSearchWrapper_py729_4829`,pickerSearchIcon:`_pickerSearchIcon_py729_4838`,pickerSearchInput:`_pickerSearchInput_py729_4844`,pickerScrollContent:`_pickerScrollContent_py729_4861`,pickerOption:`_pickerOption_py729_4870`,pickerOptionActive:`_pickerOptionActive_py729_4890`,pickerOptionLocked:`_pickerOptionLocked_py729_4909`,pickerOptionLockIcon:`_pickerOptionLockIcon_py729_4918`,pickerOptionContent:`_pickerOptionContent_py729_4926`,pickerOptionRow:`_pickerOptionRow_py729_4935`,pickerOptionSubtitle:`_pickerOptionSubtitle_py729_4943`,pickerOptionProviderDot:`_pickerOptionProviderDot_py729_4954`,pickerNoResults:`_pickerNoResults_py729_4962`,pickerGroupHeader:`_pickerGroupHeader_py729_4971`,pickerGroupNoKey:`_pickerGroupNoKey_py729_4984`,pickerGroupDisabled:`_pickerGroupDisabled_py729_4997`,pickerSectionDivider:`_pickerSectionDivider_py729_5003`,harnessIndicator:`_harnessIndicator_py729_5011`,harnessIndicatorIcon:`_harnessIndicatorIcon_py729_5027`,pickerDropdownSplit:`_pickerDropdownSplit_py729_5034`,pickerScrollArea:`_pickerScrollArea_py729_5035`,harnessOption:`_harnessOption_py729_5039`,harnessOptionActive:`_harnessOptionActive_py729_5058`,harnessOptionLocked:`_harnessOptionLocked_py729_5066`,harnessOptionIcon:`_harnessOptionIcon_py729_5071`,harnessOptionLogo:`_harnessOptionLogo_py729_5080`,harnessOptionBody:`_harnessOptionBody_py729_5086`,harnessOptionName:`_harnessOptionName_py729_5093`,harnessOptionNameRow:`_harnessOptionNameRow_py729_5100`,harnessOptionExperimental:`_harnessOptionExperimental_py729_5107`,harnessOptionDesc:`_harnessOptionDesc_py729_5120`,harnessOptionNote:`_harnessOptionNote_py729_5130`,pickerOptionLabel:`_pickerOptionLabel_py729_5137`,pickerCostBadge:`_pickerCostBadge_py729_5146`,pickerAuthBadge:`_pickerAuthBadge_py729_5154`,pickerAuthBadgeWarn:`_pickerAuthBadgeWarn_py729_5168`,restartPopover:`_restartPopover_py729_5182`,restartPopoverTitle:`_restartPopoverTitle_py729_5196`,restartPopoverDivider:`_restartPopoverDivider_py729_5203`,restartPopoverLabel:`_restartPopoverLabel_py729_5209`,restartPopoverCount:`_restartPopoverCount_py729_5230`,restartPopoverActions:`_restartPopoverActions_py729_5236`,restartPopoverCancel:`_restartPopoverCancel_py729_5243`,restartPopoverConfirm:`_restartPopoverConfirm_py729_5258`,restartPopoverError:`_restartPopoverError_py729_5278`,conversationForkStatus:`_conversationForkStatus_py729_5287`,conversationForkFailed:`_conversationForkFailed_py729_5300`,conversationForkFallbackNote:`_conversationForkFallbackNote_py729_5317`,conversationBranchChip:`_conversationBranchChip_py729_5316`,conversationBranchChipText:`_conversationBranchChipText_py729_5347`,terminalBranchBar:`_terminalBranchBar_py729_2936`,terminalBranchBarText:`_terminalBranchBarText_py729_5371`,terminalBranchBarDrift:`_terminalBranchBarDrift_py729_5386`,terminalBranchBarMissing:`_terminalBranchBarMissing_py729_5391`,forkProgressView:`_forkProgressView_py729_5398`,forkProgressCard:`_forkProgressCard_py729_5406`,forkProgressHeader:`_forkProgressHeader_py729_5418`,forkProgressIcon:`_forkProgressIcon_py729_5424`,forkProgressTitle:`_forkProgressTitle_py729_5430`,forkProgressSubtitle:`_forkProgressSubtitle_py729_5438`,forkProgressTimeline:`_forkProgressTimeline_py729_5450`,forkProgressStep:`_forkProgressStep_py729_5457`,forkProgressStepIndicator:`_forkProgressStepIndicator_py729_5468`,forkProgressStepLine:`_forkProgressStepLine_py729_5477`,"forkProgressStep--done":`_forkProgressStep--done_py729_5486`,forkProgressStepContent:`_forkProgressStepContent_py729_5490`,forkProgressStepLabel:`_forkProgressStepLabel_py729_5497`,forkProgressStepDesc:`_forkProgressStepDesc_py729_5503`,"forkProgressStep--active":`_forkProgressStep--active_py729_5517`,"forkProgressStep--pending":`_forkProgressStep--pending_py729_5525`,"forkProgressStep--failed":`_forkProgressStep--failed_py729_5533`,forkProgressSpinner:`_forkProgressSpinner_py729_5546`,forkSpin:`_forkSpin_py729_1`,forkProgressError:`_forkProgressError_py729_5550`,forkOverlay:`_forkOverlay_py729_5570`,forkDialog:`_forkDialog_py729_5582`,forkHeader:`_forkHeader_py729_5593`,forkHeaderLeft:`_forkHeaderLeft_py729_5601`,forkHeaderIcon:`_forkHeaderIcon_py729_5607`,forkTitle:`_forkTitle_py729_5612`,forkClose:`_forkClose_py729_5619`,forkBody:`_forkBody_py729_5634`,forkDesc:`_forkDesc_py729_5638`,forkFields:`_forkFields_py729_5645`,forkTitleInput:`_forkTitleInput_py729_5651`,forkFooter:`_forkFooter_py729_5670`,forkCancelBtn:`_forkCancelBtn_py729_5677`,forkConfirmBtn:`_forkConfirmBtn_py729_5694`,forkModeGroup:`_forkModeGroup_py729_5719`,forkCheckboxRow:`_forkCheckboxRow_py729_5732`,forkWarning:`_forkWarning_py729_5755`,forkHeaderRight:`_forkHeaderRight_py729_5766`,forkHelpOverlay:`_forkHelpOverlay_py729_5774`,forkHelpDialog:`_forkHelpDialog_py729_5786`,forkHelpBody:`_forkHelpBody_py729_5798`,failedOutbox:`_failedOutbox_py729_5805`,failedMessage:`_failedMessage_py729_5813`,failedMessageBubble:`_failedMessageBubble_py729_5820`,failedMessageActions:`_failedMessageActions_py729_5829`,failedMessageLabel:`_failedMessageLabel_py729_5836`,failedMessageReason:`_failedMessageReason_py729_5842`,failedMessageBtn:`_failedMessageBtn_py729_5851`,planCard:`_planCard_py729_5872`,planCardHeader:`_planCardHeader_py729_5880`,planCardToggle:`_planCardToggle_py729_5889`,planCardTitle:`_planCardTitle_py729_5901`,planCardBadge:`_planCardBadge_py729_5906`,planCardBadgeApproved:`_planCardBadgeApproved_py729_5907`,planCardBadgeRejected:`_planCardBadgeRejected_py729_5908`,planCardResolved:`_planCardResolved_py729_5933`,planCardBody:`_planCardBody_py729_5941`,planCardActions:`_planCardActions_py729_5949`,planCardApproveBtn:`_planCardApproveBtn_py729_5956`,planCardFeedbackBtn:`_planCardFeedbackBtn_py729_5980`,planCardCancelBtn:`_planCardCancelBtn_py729_6005`,planCardFeedbackArea:`_planCardFeedbackArea_py729_6020`,planCardTextarea:`_planCardTextarea_py729_6025`,planCardFeedbackActions:`_planCardFeedbackActions_py729_6042`,compactBoundaryDivider:`_compactBoundaryDivider_py729_6050`,compactBoundaryLine:`_compactBoundaryLine_py729_6057`,compactBoundaryLabel:`_compactBoundaryLabel_py729_6069`,compactBoundaryDetail:`_compactBoundaryDetail_py729_6079`,compactingIndicator:`_compactingIndicator_py729_6084`,compactingPulse:`_compactingPulse_py729_1`,compactingIcon:`_compactingIcon_py729_6095`,compactingSpin:`_compactingSpin_py729_1`,conversationPermissionAlert:`_conversationPermissionAlert_py729_6111`,permissionAlertPulse:`_permissionAlertPulse_py729_1`,sessionPermissionsRow:`_sessionPermissionsRow_py729_6123`,sessionPermissionsIcon:`_sessionPermissionsIcon_py729_6133`,sessionPermissionsLabel:`_sessionPermissionsLabel_py729_6139`,sessionPermissionsTools:`_sessionPermissionsTools_py729_6144`,resourcesGroup:`_resourcesGroup_py729_6151`,resourcesGroupHeader:`_resourcesGroupHeader_py729_6157`,resourcesGroupSummary:`_resourcesGroupSummary_py729_6179`,uatStackTreeGroup:`_uatStackTreeGroup_py729_6187`,uatStackTreeHeader:`_uatStackTreeHeader_py729_6193`,uatStackTreeSummary:`_uatStackTreeSummary_py729_6216`,uatStackActions:`_uatStackActions_py729_6224`,uatStackActionButton:`_uatStackActionButton_py729_6231`,uatStackActionPrimary:`_uatStackActionPrimary_py729_6250`,uatStackActionDanger:`_uatStackActionDanger_py729_6256`,uatStackActionMuted:`_uatStackActionMuted_py729_6262`,uatStackTreeBody:`_uatStackTreeBody_py729_6266`,uatStackTreeReason:`_uatStackTreeReason_py729_6270`,uatStackContainerRow:`_uatStackContainerRow_py729_6276`,uatStackContainerDot:`_uatStackContainerDot_py729_6290`,uatStackContainerDotHealthy:`_uatStackContainerDotHealthy_py729_6297`,uatStackContainerDotStarting:`_uatStackContainerDotStarting_py729_6301`,uatStackContainerDotUnhealthy:`_uatStackContainerDotUnhealthy_py729_6305`,uatStackContainerDotStopped:`_uatStackContainerDotStopped_py729_6309`,uatStackContainerName:`_uatStackContainerName_py729_6313`,uatStackContainerState:`_uatStackContainerState_py729_6322`,containerNode:`_containerNode_py729_6328`,containerName:`_containerName_py729_6341`,containerMetric:`_containerMetric_py729_6347`,branchNode:`_branchNode_py729_6355`,branchBadge:`_branchBadge_py729_6364`,prNode:`_prNode_py729_6369`,prNumber:`_prNumber_py729_6383`,prTitle:`_prTitle_py729_6390`},RMe=new LMe(500,50*1024*1024);function zMe(e,t){return Math.max(e.length*2,t.length*3)}function BMe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t}function VMe(e,t){return`${BMe(e)}:${e.length}:${t}`}var HMe=new Set([`span`,`pre`,`code`,`div`,`br`]),UMe=new Set([`class`,`style`]),WMe=new Set([`color`,`background-color`,`font-style`,`font-weight`,`text-decoration`,`opacity`]);function GMe(e){return e.split(`;`).map(e=>e.trim()).filter(Boolean).filter(e=>{let[t]=e.split(`:`);return t&&WMe.has(t.trim().toLowerCase())}).join(`; `)}var KMe=null;function qMe(){return KMe||=new DOMParser,KMe}function JMe(e){let t=qMe().parseFromString(e,`text/html`);function n(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return null;let t=e,r=t.tagName.toLowerCase();if(!HMe.has(r))return null;let i=document.createElement(r);for(let e of Array.from(t.attributes))if(UMe.has(e.name.toLowerCase()))if(e.name===`style`){let t=GMe(e.value);t&&i.setAttribute(`style`,t)}else i.setAttribute(e.name,e.value);for(let e of Array.from(t.childNodes)){let t=n(e);t&&i.appendChild(t)}return i}let r=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes)){let t=n(e);t&&r.appendChild(t)}let i=document.createElement(`div`);return i.appendChild(r),i.innerHTML}var YMe=null;async function XMe(){return YMe||=v(()=>Promise.resolve().then(()=>odt).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),YMe}async function ZMe(e,t,n){let r=VMe(e,t);if(!n){let e=RMe.get(r);if(e!==null)return e}try{let i=(await XMe()).codeToHtml(e,{lang:t||`text`,theme:`github-light`});return n||RMe.set(r,i,zMe(i,e)),i}catch{return`<pre><code>${e.replace(/</g,`<`).replace(/>/g,`>`)}</code></pre>`}}var Qx=class extends z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function QMe({code:e,lang:t,isStreaming:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),s=(0,z.useRef)(!1);(0,z.useEffect)(()=>(s.current=!1,ZMe(e,t,n).then(e=>{s.current||i(e)}),()=>{s.current=!0}),[e,t,n]);let c=(0,z.useMemo)(()=>r?JMe(r):null,[r]),l=(0,z.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,B.jsxs)(`div`,{className:Z.codeBlock,children:[(0,B.jsx)(`button`,{className:Z.copyButton,onClick:l,title:`Copy code`,children:a?(0,B.jsx)(us,{size:13}):(0,B.jsx)(ks,{size:13})}),c?(0,B.jsx)(`div`,{className:Z.shikiOutput,dangerouslySetInnerHTML:{__html:c}}):(0,B.jsx)(`pre`,{className:Z.codePlain,children:(0,B.jsx)(`code`,{children:e})})]})}function $x(e){return Kje(e)?e:kOe(e)}async function $Me(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}var eNe=(0,z.createContext)(!1);function tNe({children:e}){let{data:t}=V({queryKey:[`settings`],queryFn:$Me,retry:!1});return(0,B.jsx)(eNe.Provider,{value:t?.experimental?.streamdownRenderer===!0,children:e})}var nNe=new Set([`code`,`inlineCode`,`link`,`linkReference`,`definition`]),rNe={...Cx,protocols:{...Cx.protocols,href:void 0}},iNe=z.lazy(async()=>{let[{Streamdown:e,defaultRehypePlugins:t}]=await Promise.all([v(()=>import(`./dist-RyrOs5EF.js`),__vite__mapDeps([0,1,2,3,4,5,6])),v(()=>Promise.resolve({}),__vite__mapDeps([7]))]),n=[t.raw,[t.sanitize[0],rNe],t.harden];return{default:t=>z.createElement(e,{...t,rehypePlugins:n})}});function aNe({meta:e,cwd:t,issueId:n,fallback:r}){let{state:i}=IMe(t,e.filePath);return i===`exists`?(0,B.jsx)(EMe,{...e,issueId:n}):(0,B.jsx)(B.Fragment,{children:r})}function oNe(e={}){return t=>{let n=t=>{if(!t.children||nNe.has(t.type))return;let r=[];for(let i of t.children)if(i.type===`text`&&i.value!==void 0)for(let t of Yje(i.value,e.cwd))r.push(t.href?{type:`link`,url:t.href,title:null,children:[{type:`text`,value:t.text}]}:{type:`text`,value:t.text});else n(i),r.push(i);t.children=r};n(t)}}function sNe(e,t,n){return{pre({children:t}){let n=z.Children.toArray(t)[0];if(!z.isValidElement(n))return(0,B.jsx)(`pre`,{children:t});let r=n,i=r.props.className??``,a=/language-(\w+)/.exec(i)?.[1]??``,o=String(r.props.children??``).trimEnd();return(0,B.jsx)(Qx,{fallback:(0,B.jsx)(`pre`,{className:Z.codePlain,children:(0,B.jsx)(`code`,{children:o})}),children:(0,B.jsx)(QMe,{code:o,lang:a,isStreaming:e})})},a({href:e,children:r}){let i=Xje(e,t);return i?(0,B.jsx)(aNe,{meta:i,cwd:t,issueId:n,fallback:r}):(0,B.jsx)(`a`,{href:typeof e==`string`&&e.trim().length>0&&!/^(javascript|data|vbscript):/i.test(e.trim())?e:void 0,target:`_blank`,rel:`noopener noreferrer`,className:Z.mdLink,children:r})}}}var cNe=5e4,lNe=8e3;function uNe({text:e}){let[t,n]=(0,z.useState)(!1),r=Math.round(e.length/1024),i=e.length>lNe,a=t||!i?e:e.slice(0,lNe);return(0,B.jsxs)(`div`,{className:Z.chatMarkdown,children:[(0,B.jsxs)(`div`,{style:{fontSize:`0.8em`,opacity:.6,marginBottom:6},children:[`Large message (`,r,` KB) — rendered as plain text to keep the panel responsive.`]}),(0,B.jsxs)(`pre`,{className:Z.mdFallback,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:[a,!t&&i?`
|
|
47
47
|
…`:``]}),i&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),style:{marginTop:6,fontSize:`0.8em`,background:`none`,border:`none`,color:`var(--color-accent)`,cursor:`pointer`,padding:0},children:t?`Show less`:`Show full message (${r} KB)`})]})}var eS=(0,z.memo)(function({text:e,isStreaming:t=!1,cwd:n,issueId:r,useStreamdown:i}){let a=(0,z.useMemo)(()=>sNe(t,n,r),[t,n,r]),o=(0,z.useMemo)(()=>[zx,[oNe,{cwd:n}]],[n]),s=(0,z.useContext)(eNe),c=i??s;return e.length>cNe?(0,B.jsx)(Qx,{fallback:(0,B.jsx)(`pre`,{className:Z.mdFallback,children:e}),children:(0,B.jsx)(uNe,{text:e})}):(0,B.jsx)(Qx,{fallback:(0,B.jsx)(`pre`,{className:Z.mdFallback,children:e}),children:(0,B.jsx)(`div`,{className:Z.chatMarkdown,children:c?(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(xx,{remarkPlugins:o,components:a,urlTransform:$x,children:e}),children:(0,B.jsx)(iNe,{mode:t?`streaming`:`static`,remarkPlugins:o,components:a,urlTransform:e=>$x(e),children:e})}):(0,B.jsx)(xx,{remarkPlugins:o,components:a,urlTransform:$x,children:e})})})});function dNe({subject:e,isOpen:t,isSubmitting:n=!1,onApprove:r,onRequestChanges:i,onDismiss:a}){let[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(``),u=e?.pendingProposedPlan;if(!t||!e||!u)return null;let d=e.title?.trim()||e.id,f=()=>{c.trim()&&(ts(`plan_changes_requested`,{subject_kind:e.kindLabel===`Conversation`?`conversation`:`agent`}),i(c.trim()),s(!1),l(``))};return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm`,onClick:e=>{e.target===e.currentTarget&&!n&&a()},children:(0,B.jsxs)(`div`,{className:`w-full max-w-3xl overflow-hidden rounded-xl border border-primary/30 bg-card shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-5 py-4`,children:[(0,B.jsx)(`div`,{className:`rounded-full bg-primary/15 p-2`,children:(0,B.jsx)(Vie,{className:`h-5 w-5 text-primary`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`h2`,{className:`truncate text-lg font-semibold text-foreground`,children:d}),(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e.kindLabel??`Agent`,` finished planning and is waiting for your approval to start work.`]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:a,disabled:n,title:`Minimize — keeps the plan in the activity feed's “Needs you” list`,"aria-label":`Minimize`,className:`shrink-0 rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60`,children:(0,B.jsx)(wc,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`space-y-4 px-5 py-4 max-h-[65vh] overflow-y-auto`,children:[(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.kindLabel??`Subject`}),(0,B.jsx)(`p`,{className:`font-mono text-sm text-foreground`,children:e.id}),e.title?(0,B.jsx)(`p`,{className:`mt-1 text-sm font-medium text-foreground`,children:e.title}):null]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Issue`}),(0,B.jsx)(`p`,{className:`font-mono text-sm text-foreground`,children:e.issueId??`Unknown`})]})]}),(0,B.jsx)(`div`,{className:`rounded-md border border-border bg-background/40 px-4 py-3 text-sm`,children:(0,B.jsx)(eS,{text:u.plan,cwd:void 0})}),o&&(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`What should change?`}),(0,B.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),disabled:n,rows:3,placeholder:`Describe what to change — sent to the session as plan feedback.`,className:`w-full rounded-md border border-border bg-background/60 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-none disabled:cursor-not-allowed disabled:opacity-60`,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&f()}})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border bg-card/40 px-5 py-4`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:a,disabled:n,title:`Keeps the plan in the activity feed's “Needs you” list — click it there to reopen`,className:`rounded-md border border-border bg-popover px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-card disabled:cursor-not-allowed disabled:opacity-60`,children:`Minimize`}),o?(0,B.jsxs)(`button`,{type:`button`,onClick:f,disabled:n||!c.trim(),className:`inline-flex items-center gap-2 rounded-md border border-border bg-popover px-4 py-2 text-sm font-semibold text-foreground transition-colors hover:bg-card disabled:cursor-not-allowed disabled:opacity-60`,children:[n&&(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin`}),`Send Feedback`]}):(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),disabled:n,className:`inline-flex items-center gap-2 rounded-md border border-border bg-popover px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-card disabled:cursor-not-allowed disabled:opacity-60`,children:[(0,B.jsx)(xc,{className:`h-4 w-4`}),`Request Changes`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{ts(`plan_approved`,{subject_kind:e.kindLabel===`Conversation`?`conversation`:`agent`}),r()},disabled:n,className:`inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[n?(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin`}):(0,B.jsx)(us,{className:`h-4 w-4`}),`Approve Plan`]})]})]})})}var fNe=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},pNe=e=>e?fNe(e):fNe,mNe=i((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),hNe=i(((e,t)=>{t.exports=mNe()})),gNe=i((e=>{var t=a(),n=hNe();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),a!==void 0&&f.hasValue){var t=f.value;if(a(t,e))return c=t}return c=e}if(t=c,i(s,e))return t;var n=r(e);return a!==void 0&&a(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,a]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),_Ne=n(i(((e,t)=>{t.exports=gNe()}))(),1),{useDebugValue:vNe}=z.default,{useSyncExternalStoreWithSelector:yNe}=_Ne.default,bNe=e=>e;function xNe(e,t=bNe,n){let r=yNe(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return vNe(r),r}var SNe=e=>{let t=typeof e==`function`?pNe(e):e,n=(e,n)=>xNe(t,e,n);return Object.assign(n,t),n},tS=e=>e?SNe(e):SNe,nS=`pan-snapshot-cache-v1`;function CNe(e){return JSON.stringify({data:e,timestamp:new Date().toISOString()})}function wNe(e){try{localStorage.setItem(nS,CNe(e))}catch(t){if((t instanceof DOMException||t instanceof Error)&&t.name===`QuotaExceededError`)try{let t={...e,issues:[]};localStorage.setItem(nS,CNe(t))}catch{}}}function TNe(){try{let e=localStorage.getItem(nS);if(!e)return null;let t=JSON.parse(e);return t?.data?.sequence==null?null:t.data}catch{return null}}var rS=new Set;function iS(e){return rS.add(e),()=>rS.delete(e)}function ENe(e){if(e.length!==0)for(let t of rS)try{t(e)}catch(e){console.error(`[DashboardStore] domain event listener failed:`,e)}}var DNe={...SSe,drawer:{issueId:null,tab:`overview`},tasksViewerIssueId:null,prdViewerIssueId:null,xbriefViewerIssueId:null,bootstrapComplete:!1,snapshotTimestamp:null};function ONe(e,t){return{...jSe(e,t),drawer:e.drawer,tasksViewerIssueId:e.tasksViewerIssueId,prdViewerIssueId:e.prdViewerIssueId,xbriefViewerIssueId:e.xbriefViewerIssueId,bootstrapComplete:!0,snapshotTimestamp:t.timestamp}}function kNe(e,t){return{...zy(e,t),drawer:e.drawer,tasksViewerIssueId:e.tasksViewerIssueId,prdViewerIssueId:e.prdViewerIssueId,xbriefViewerIssueId:e.xbriefViewerIssueId,bootstrapComplete:e.bootstrapComplete,snapshotTimestamp:e.snapshotTimestamp}}function ANe(e,t){return{...MSe(e,t),drawer:e.drawer,tasksViewerIssueId:e.tasksViewerIssueId,prdViewerIssueId:e.prdViewerIssueId,xbriefViewerIssueId:e.xbriefViewerIssueId,bootstrapComplete:e.bootstrapComplete,snapshotTimestamp:e.snapshotTimestamp}}function aS(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e.issueId?(t.searchParams.set(`issue`,e.issueId),t.searchParams.set(`tab`,e.tab)):(t.searchParams.delete(`issue`),t.searchParams.delete(`tab`)),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)}function jNe(){if(typeof window>`u`)return{issueId:null,tab:`overview`};let e=new URLSearchParams(window.location.search);return{issueId:e.get(`issue`),tab:e.get(`tab`)||`overview`}}var oS=null,Q=tS(e=>({...DNe,syncSnapshot:t=>{wNe(t),e(e=>ONe(e,t))},applyEvent:t=>{e(e=>kNe(e,t)),ENe([t])},applyEvents:t=>{e(e=>ANe(e,t)),ENe(t)},seedRecentActivity:t=>e(e=>{let n=new Map;for(let r of[...e.recentActivity,...t]){let e=typeof r?.id==`string`?r.id:null;e&&!n.has(e)&&n.set(e,r)}return{recentActivity:[...n.values()].sort((e,t)=>String(t.timestamp??``).localeCompare(String(e.timestamp??``))).slice(0,50)}}),openIssue:(t,n=`conversation`)=>{oS=null;let r={issueId:t,tab:n};aS(r),e({drawer:r})},openIssueFromRoute:(t,n,r)=>{oS={parentPath:n,routePath:r},e({drawer:{issueId:t,tab:(typeof window<`u`?new URLSearchParams(window.location.search).get(`tab`):null)||`conversation`}})},closeIssue:()=>{let t={issueId:null,tab:`overview`};typeof window<`u`&&oS?.routePath===window.location.pathname?(window.history.replaceState(null,``,oS.parentPath),oS=null):(oS=null,aS(t)),e({drawer:t})},openTasksViewer:t=>e({tasksViewerIssueId:t}),closeTasksViewer:()=>e({tasksViewerIssueId:null}),openPrdViewer:t=>e({prdViewerIssueId:t}),closePrdViewer:()=>e({prdViewerIssueId:null}),openXbriefViewer:t=>e({xbriefViewerIssueId:t}),closeXbriefViewer:()=>e({xbriefViewerIssueId:null}),setDrawerTab:t=>e(e=>{let n={issueId:e.drawer.issueId,tab:t};return aS(n),{drawer:n}}),syncDrawerFromUrl:()=>e(()=>(oS=null,{drawer:jNe()}))}));function sS(e,t){let n,r;return i=>{let a=i[e];return a===n&&r!==void 0?r:(n=a,r=t(a),r)}}var cS=sS(`agentsById`,e=>Object.values(e)),MNe=e=>t=>t.agentsById[e],lS=e=>t=>t.reviewStatusByIssueId[e],NNe=e=>t=>t.observationsByIssueId[e]??[],PNe=e=>{let t=null;for(let n of Object.values(e.healthByIssueId))n.status===`failing`&&(!t||n.updatedAt>t.updatedAt)&&(t=n);return t},FNe=sS(`channelPermissionRequestsById`,e=>Object.values(e).sort((e,t)=>e.createdAt===t.createdAt?e.requestId.localeCompare(t.requestId):e.createdAt.localeCompare(t.createdAt))),INe=sS(`agentsById`,e=>Object.values(e).filter(e=>e.pendingAskUserQuestion!=null).sort((e,t)=>{let n=e.pendingAskUserQuestion?.askedAt??``,r=t.pendingAskUserQuestion?.askedAt??``;return n===r?e.id.localeCompare(t.id):n.localeCompare(r)})),LNe=sS(`agentsById`,e=>Object.values(e).filter(e=>e.pendingProposedPlan!=null).sort((e,t)=>{let n=e.pendingProposedPlan?.askedAt??``,r=t.pendingProposedPlan?.askedAt??``;return n===r?e.id.localeCompare(t.id):n.localeCompare(r)})),uS=sS(`channelPermissionRequestsById`,e=>new Set(Object.values(e??{}).map(e=>e.agentId)));function RNe(e,t,n){let r,i,a;return o=>{let s=e(o),c=t(o);return s===r&&c===i&&a!==void 0?a:(r=s,i=c,a=n(s,c),a)}}function zNe(e){return e?.hasPendingQuestion===!0&&e.pendingQuestionReason===`tool_permission`}var BNe=RNe(e=>e.agentsById,e=>e.channelPermissionRequestsById,(e,t)=>{let n=Object.values(t??{}),r=new Map;for(let e of n){let t=r.get(e.agentId)??[];t.push(e),r.set(e.agentId,t)}let i=[];for(let t of Object.values(e)){let e=t.pendingInputKinds?[...t.pendingInputKinds]:[],n=r.get(t.id)??[],a=[...e];if((n.length>0||zNe(t))&&!a.includes(`permissionRequest`)&&a.push(`permissionRequest`),!(a.length>0))continue;let o=t.pendingAskUserQuestion?.askedAt??t.pendingProposedPlan?.askedAt??n.map(e=>e.createdAt).sort()[0]??``;i.push({agentId:t.id,source:`agent`,issueId:t.issueId,kinds:a,pendingAskUserQuestion:t.pendingAskUserQuestion,pendingProposedPlan:t.pendingProposedPlan,permissionRequestIds:n.map(e=>e.requestId),since:o,pendingQuestionPrompt:t.pendingQuestionPrompt,pendingQuestionReason:t.pendingQuestionReason})}return i.sort((e,t)=>e.since===t.since?e.agentId.localeCompare(t.agentId):e.since.localeCompare(t.since)),i}),VNe=sS(`reviewStatusByIssueId`,e=>Object.values(e).filter(e=>e?.readyForMerge===!0&&e.mergeStatus!==`merged`&&(e.blockerReasons?.length??0)===0).sort((e,t)=>(e.updatedAt??``).localeCompare(t.updatedAt??``))),HNe=sS(`reviewStatusByIssueId`,e=>Object.values(e).filter(e=>(e?.blockerReasons?.length??0)>0&&e.mergeStatus!==`merged`&&e.reviewStatus===`passed`&&(e.testStatus===`passed`||e.testStatus===`skipped`)).sort((e,t)=>(e.updatedAt??``).localeCompare(t.updatedAt??``))),UNe=sS(`reviewStatusByIssueId`,e=>Object.values(e).filter(e=>!!e?.prUrl&&e.readyForMerge!==!0&&e.mergeStatus!==`merged`).sort((e,t)=>(e.updatedAt??``).localeCompare(t.updatedAt??``))),WNe=e=>e.bootstrapComplete,GNe=e=>e.dashboardLifecycle,KNe=e=>e.scanProgress,qNe=e=>t=>t.ciByProjectKey[e],JNe=e=>e.restartGate,YNe=e=>e.resources,dS=e=>e.issuesRaw,XNe=(e,t)=>sS(`issuesRaw`,e=>{let n=e;return t?n:n.filter(e=>e.state!==`canceled`&&e.canonicalStatus!==`canceled`)});typeof window<`u`&&(window.useDashboardStore=Q);function ZNe(){let e={latestSequence:0,highestObservedSequence:0,bootstrapped:!1,pendingReplay:!1,inFlight:null},t=null;function n(){return{...e}}function r(t){return t===-1?`apply`:(t>e.highestObservedSequence&&(e={...e,highestObservedSequence:t}),t<=e.latestSequence?`ignore`:!e.bootstrapped||e.inFlight!==null?(e={...e,pendingReplay:!0},`defer`):t===e.latestSequence+1?`apply`:(e={...e,pendingReplay:!0},`recover`))}function i(t){t>e.latestSequence&&(e={...e,latestSequence:t})}function a(t){e.inFlight||(e={...e,inFlight:{kind:`snapshot`,reason:t}})}function o(t){e={...e,latestSequence:t,bootstrapped:!0,inFlight:null};let n=e.pendingReplay||e.highestObservedSequence>t;return n||(e={...e,pendingReplay:!1}),n}function s(){e.inFlight||(t=e.latestSequence,e={...e,pendingReplay:!1,inFlight:{kind:`replay`,reason:`sequence-gap`}})}function c(){let n=t!==null&&e.latestSequence>t;t=null;let r=n&&e.highestObservedSequence>e.latestSequence;return e={...e,inFlight:null,pendingReplay:r},r}function l(){e={...e,bootstrapped:!1,inFlight:null,pendingReplay:!0}}return{getState:n,classifyDomainEvent:r,markEventBatchApplied:i,beginSnapshotRecovery:a,completeSnapshotRecovery:o,beginReplayRecovery:s,completeReplayRecovery:c,failRecovery:l}}var fS=`pan-recovery-overlay`,pS=`pan.recovery.lastReload`,QNe=`pan.recovery.reloadCount`,$Ne=15e3,ePe=3,tPe=!1;function mS(e){return typeof e==`string`?e:e&&typeof e==`object`&&`message`in e?String(e.message??``):``}function hS(e){if(!e||typeof e!=`object`||!(`stack`in e))return;let t=String(e.stack??``);return t?t.split(`
|
|
48
48
|
`).slice(0,5).join(`
|
|
49
49
|
`):void 0}function gS(e){let t=mS(e).toLowerCase();return t.includes(`failed to fetch dynamically imported module`)||t.includes(`error loading dynamically imported module`)||t.includes(`importing a module script failed`)||t.includes(`module script failed`)||t.includes(`dynamically imported module`)}function nPe(e){let t;if(typeof e==`string`)t=e;else{if(!(e instanceof HTMLElement)||e.tagName!==`SCRIPT`&&e.tagName!==`LINK`)return null;t=e.tagName===`SCRIPT`?e.src:e.href}if(!t)return null;try{let e=new URL(t,window.location.href);return e.origin===window.location.origin?e.href:null}catch{return null}}function _S(e){let t=e.match(/(?:https?:\/\/|\/)[^\s'"<>]+/)?.[0].replace(/[),.;]+$/,``);return t?nPe(t)??void 0:void 0}function rPe(e=Date.now()){let t=Number(sessionStorage.getItem(pS)||`0`),n=Number(sessionStorage.getItem(QNe)||`0`),r=e-t<$Ne?n+1:1;return sessionStorage.setItem(pS,String(e)),sessionStorage.setItem(QNe,String(r)),{count:r,shouldReload:r<=ePe}}function iPe(e,t){let n=Error(e.message??`Frontend recovery reload`);e.stackHead&&(n.stack=e.stackHead);let r={action:`frontend_recovery_reload`,trigger:e.trigger,reload_count:rs(t.count),should_reload:t.shouldReload};ns(n,r),t.shouldReload||ns(n,{...r,action:`frontend_recovery_reload_loop`})}function vS(e,t){document.getElementById(fS)?.remove();let n=document.createElement(`div`);n.id=fS,n.style.cssText=[`position:fixed`,`inset:0`,`z-index:2147483647`,`display:flex`,`flex-direction:column`,`align-items:center`,`justify-content:center`,`gap:16px`,`background:rgba(10,12,16,0.92)`,`color:#e6e6e6`,`font-family:var(--font-sans),system-ui,sans-serif`,`font-size:15px`].join(`;`),n.innerHTML=`
|
|
@@ -51,7 +51,7 @@ import{a as e,n as t,o as n,r,t as i}from"./chunk-jRWAZmH_.js";import{n as a,t a
|
|
|
51
51
|
<div data-pan-recovery-message="true"></div>
|
|
52
52
|
${t?`<button type="button" data-pan-recovery-action="true" style="padding:8px 18px;border-radius:8px;border:1px solid rgba(255,255,255,0.2);background:#1b2533;color:#e6e6e6;cursor:pointer;font-size:14px"></button>`:``}
|
|
53
53
|
<style>@keyframes pan-recovery-spin{to{transform:rotate(360deg)}}</style>
|
|
54
|
-
`;let r=n.querySelector(`[data-pan-recovery-message="true"]`);if(r&&(r.textContent=e),t){let e=n.querySelector(`[data-pan-recovery-action="true"]`);e&&(e.textContent=t.label,e.addEventListener(`click`,t.onClick))}document.body.appendChild(n)}function aPe(){document.getElementById(fS)?.remove()}async function yS(e){if(tPe)return;tPe=!0,vS(`Reconnecting to the dashboard…`);let t=Number(sessionStorage.getItem(pS)||`0`);for(let e=0;;e++){try{if((await fetch(`/`,{cache:`no-store`})).ok)break}catch{}await oPe(Math.min(500+e*250,3e3))}Date.now()-t<4e3&&await oPe(2e3);let n=rPe();if(iPe(e,n),!n.shouldReload){vS(`The dashboard stopped automatic recovery after repeated load failures.${e.resource?` Failing resource: ${e.resource}`:``}`,{label:`Reload dashboard`,onClick:()=>window.location.reload()});return}window.location.reload()}function oPe(e){return new Promise(t=>setTimeout(t,e))}function sPe(){window.addEventListener(`vite:preloadError`,e=>{e.preventDefault();let t=e.payload,n=mS(t);yS({trigger:`vite_preload_error`,resource:_S(n),message:n||void 0,stackHead:hS(t)})}),window.addEventListener(`error`,e=>{let t=nPe(e.target);if(t){yS({trigger:`asset_load_error`,resource:t,message:e.message||`Module asset failed to load`});return}let n=e.error??e.message;if(gS(n)){let e=mS(n);yS({trigger:`window_module_error`,resource:_S(e),message:e||void 0,stackHead:hS(n)})}},!0),window.addEventListener(`unhandledrejection`,e=>{if(gS(e.reason)){let t=mS(e.reason);yS({trigger:`unhandled_rejection`,resource:_S(t),message:t||void 0,stackHead:hS(e.reason)})}})}var cPe=class extends z.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){if(ns(e,{action:`frontend_unhandled_error`,trigger:`root_error_boundary`}),gS(e)){let t=mS(e);yS({trigger:`root_error_boundary`,resource:_S(t),message:t||void 0,stackHead:hS(e)})}}render(){return this.state.hasError?(0,B.jsxs)(`div`,{style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:16,background:`rgba(10,12,16,0.92)`,color:`#e6e6e6`,fontFamily:`var(--font-sans),system-ui,sans-serif`,fontSize:15},children:[(0,B.jsx)(`div`,{children:`The dashboard hit an error.`}),(0,B.jsx)(`button`,{onClick:()=>window.location.reload(),style:{padding:`8px 18px`,borderRadius:8,border:`1px solid rgba(255,255,255,0.2)`,background:`#1b2533`,color:`#e6e6e6`,cursor:`pointer`,fontSize:14},children:`Reload dashboard`})]}):this.props.children}},bS=`overdeck:backend-reconnecting`,xS=`overdeck:reconnected`;function lPe(){window.dispatchEvent(new CustomEvent(bS))}function uPe(){window.dispatchEvent(new CustomEvent(xS))}var dPe=2e3,fPe=3*6e4,pPe=35e3,mPe=6,hPe=2e3,gPe=3e4,_Pe=.2;function vPe(e){return`sequence`in e}function yPe(e,t=Math.random){let n=Math.min(hPe*2**(Math.max(1,Math.floor(e))-1),gPe),r=1+(t()*2-1)*_Pe;return Math.min(gPe,Math.round(n*r))}function SS(){let e=Q(e=>e.syncSnapshot),t=Q(e=>e.applyEvents),n=Q(e=>e.seedRecentActivity),r=(0,z.useRef)(null),i=(0,z.useRef)([]),a=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{let o=ZNe();r.current=o;let s=!1,c=null,l=!1,u=!1,d=null,f=null,p=null,m=null,h=0,g=null;function _(){d&&clearInterval(d),f&&clearTimeout(f),d=null,f=null}function v(){_(),d=setInterval(()=>{if(l){_();return}O().catch(console.error)},dPe),f=setTimeout(()=>{l||vS(`Server unreachable — Retry`,{label:`Retry`,onClick:C}),_()},fPe)}function y(){p&&clearTimeout(p),p=null}function b(){m&&clearTimeout(m),m=null}function x(){u=!0,lPe()}function S(){O().then(e=>{e||w()})}function C(){s||(b(),x(),g?.(),g=null,ECe(),N(),S())}function w(){if(m||s)return;h+=1;let e=yPe(h);m=setTimeout(()=>{m=null,C()},e)}function T(){y(),p=setTimeout(()=>{console.warn(`[EventRouter] domain event stream stale — scheduling reconnect`),x(),vS(`Reconnecting to the dashboard…`),w()},pPe)}let E=TNe();E&&e(E);async function D(){try{let e=await fetch(`/api/activity`);if(!e.ok)return;let t=await e.json();Array.isArray(t)&&n(t)}catch{}}function O(){return c||(s=!0,c=(async()=>{o.beginSnapshotRecovery(`bootstrap`);try{let t=await lb().request(e=>e[Cy.getSnapshot]({}));return e(t),D(),l=!0,_(),o.completeSnapshotRecovery(t.sequence)&&await k(t.sequence),u&&(u=!1,h=0,b(),aPe(),uPe()),!0}catch(e){return console.error(`[EventRouter] bootstrap failed:`,e),o.failRecovery(),!1}finally{s=!1,c=null}})(),c)}async function k(e){o.beginReplayRecovery();try{let n=(await lb().request(t=>t[Cy.replayEvents]({fromSequence:e}))).filter(vPe);if(n.length>0&&(t(n),o.markEventBatchApplied(n[n.length-1].sequence)),o.completeReplayRecovery()){await k(o.getState().latestSequence);return}A()}catch(e){console.error(`[EventRouter] replay failed:`,e),o.failRecovery()}}function A(){let e=i.current.splice(0).sort((e,t)=>e.sequence-t.sequence),n=[];for(let t of e){let e=o.classifyDomainEvent(t.sequence);if(e!==`ignore`){if(e===`apply`){n.push(t),o.markEventBatchApplied(t.sequence);continue}if(i.current.push(t),e===`recover`){k(o.getState().latestSequence).catch(console.error);break}}}n.length>0&&t(n)}function j(){a.current||(a.current=!0,setTimeout(()=>{a.current=!1,A()},16))}function M(e){if(h=0,b(),T(),u||aPe(),!vPe(e))return;let t=o.classifyDomainEvent(e.sequence);if(t!==`ignore`){if(t===`defer`){i.current.push(e);return}if(t===`recover`){i.current.push(e);let t=o.getState().latestSequence;k(t).catch(console.error);return}i.current.push(e),j()}}function N(){g?.(),g=lb().subscribe(e=>e[Cy.subscribeDomainEvents]({}),e=>M(e),{onReconnect:()=>{console.log(`[EventRouter] transport reconnected — re-bootstrapping snapshot`),S()},onRetry:e=>{if(x(),e>=mPe){vS(`Server unreachable — Retry`,{label:`Retry`,onClick:C});return}vS(`Reconnecting to the dashboard…`)}}),T()}return N(),O(),v(),()=>{_(),y(),b(),g?.()}},[e,t,n]),null}var bPe=1,xPe=.9,SPe=.8,CPe=.17,CS=.1,wS=.999,wPe=.9999,TPe=.99,EPe=/[\\\/_+.#"@\[\(\{&]/,DPe=/[\\\/_+.#"@\[\(\{&]/g,OPe=/[\s-]/,kPe=/[\s-]/g;function TS(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?bPe:TPe;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=TS(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=bPe:EPe.test(e.charAt(l-1))?(d*=SPe,p=e.slice(i,l-1).match(DPe),p&&i>0&&(d*=wS**+p.length)):OPe.test(e.charAt(l-1))?(d*=xPe,m=e.slice(i,l-1).match(kPe),m&&i>0&&(d*=wS**+m.length)):(d*=CPe,i>0&&(d*=wS**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=wPe)),(d<CS&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=TS(e,t,n,r,l+1,a+2,o),f*CS>d&&(d=f*CS)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function APe(e){return e.toLowerCase().replace(kPe,` `)}function jPe(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,TS(e,t,APe(e),APe(t),0,0,{})}typeof window<`u`&&window.document&&window.document.createElement;function ES(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function MPe(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function DS(...e){return t=>{let n=!1,r=e.map(e=>{let r=MPe(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():MPe(e[t],null)}}}}function OS(...e){return z.useCallback(DS(...e),e)}function NPe(e,t){let n=z.createContext(t),r=e=>{let{children:t,...r}=e,i=z.useMemo(()=>r,Object.values(r));return(0,B.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=z.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function kS(e,t=[]){let n=[];function r(t,r){let i=z.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=z.useMemo(()=>o,Object.values(o));return(0,B.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=z.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=>z.createContext(e));return function(n){let r=n?.[e]||t;return z.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,PPe(i,...t)]}function PPe(...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 z.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var AS=globalThis?.document?z.useLayoutEffect:()=>{},FPe=z.useId||(()=>void 0),IPe=0;function jS(e){let[t,n]=z.useState(FPe());return AS(()=>{e||n(e=>e??String(IPe++))},[e]),e||(t?`radix-${t}`:``)}var LPe=z.useInsertionEffect||AS;function MS({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=RPe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=z.useRef(e!==void 0);z.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,z.useCallback(t=>{if(s){let n=zPe(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function RPe({defaultProp:e,onChange:t}){let[n,r]=z.useState(e),i=z.useRef(n),a=z.useRef(t);return LPe(()=>{a.current=t},[t]),z.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function zPe(e){return typeof e==`function`}function NS(e){let t=BPe(e),n=z.forwardRef((e,n)=>{let{children:r,...i}=e,a=z.Children.toArray(r),o=a.find(HPe);if(o){let e=o.props.children,r=a.map(t=>t===o?z.Children.count(e)>1?z.Children.only(null):z.isValidElement(e)?e.props.children:null:t);return(0,B.jsx)(t,{...i,ref:n,children:z.isValidElement(e)?z.cloneElement(e,void 0,r):null})}return(0,B.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function BPe(e){let t=z.forwardRef((e,t)=>{let{children:n,...r}=e;if(z.isValidElement(n)){let e=WPe(n),i=UPe(r,n.props);return n.type!==z.Fragment&&(i.ref=t?DS(t,e):e),z.cloneElement(n,i)}return z.Children.count(n)>1?z.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var VPe=Symbol(`radix.slottable`);function HPe(e){return z.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===VPe}function UPe(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 WPe(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 PS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=NS(`Primitive.${t}`),r=z.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,B.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function GPe(e,t){e&&pl.flushSync(()=>e.dispatchEvent(t))}function FS(e){let t=z.useRef(e);return z.useEffect(()=>{t.current=e}),z.useMemo(()=>(...e)=>t.current?.(...e),[])}function KPe(e,t=globalThis?.document){let n=FS(e);z.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 qPe=`DismissableLayer`,IS=`dismissableLayer.update`,JPe=`dismissableLayer.pointerDownOutside`,YPe=`dismissableLayer.focusOutside`,XPe,ZPe=z.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),LS=z.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=z.useContext(ZPe),[u,d]=z.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=z.useState({}),m=OS(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=eFe(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=tFe(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return KPe(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),z.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(XPe=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),nFe(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=XPe)}},[u,f,n,l]),z.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),nFe())},[u,l]),z.useEffect(()=>{let e=()=>p({});return document.addEventListener(IS,e),()=>document.removeEventListener(IS,e)},[]),(0,B.jsx)(PS.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:ES(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ES(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ES(e.onPointerDownCapture,x.onPointerDownCapture)})});LS.displayName=qPe;var QPe=`DismissableLayerBranch`,$Pe=z.forwardRef((e,t)=>{let n=z.useContext(ZPe),r=z.useRef(null),i=OS(t,r);return z.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,B.jsx)(PS.div,{...e,ref:i})});$Pe.displayName=QPe;function eFe(e,t=globalThis?.document){let n=FS(e),r=z.useRef(!1),i=z.useRef(()=>{});return z.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){rFe(JPe,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 tFe(e,t=globalThis?.document){let n=FS(e),r=z.useRef(!1);return z.useEffect(()=>{let e=e=>{e.target&&!r.current&&rFe(YPe,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 nFe(){let e=new CustomEvent(IS);document.dispatchEvent(e)}function rFe(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?GPe(i,a):i.dispatchEvent(a)}var RS=`focusScope.autoFocusOnMount`,zS=`focusScope.autoFocusOnUnmount`,iFe={bubbles:!1,cancelable:!0},aFe=`FocusScope`,BS=z.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=z.useState(null),l=FS(i),u=FS(a),d=z.useRef(null),f=OS(t,e=>c(e)),p=z.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;z.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:VS(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||VS(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&VS(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]),z.useEffect(()=>{if(s){fFe.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(RS,iFe);s.addEventListener(RS,l),s.dispatchEvent(t),t.defaultPrevented||(oFe(hFe(cFe(s)),{select:!0}),document.activeElement===e&&VS(s))}return()=>{s.removeEventListener(RS,l),setTimeout(()=>{let t=new CustomEvent(zS,iFe);s.addEventListener(zS,u),s.dispatchEvent(t),t.defaultPrevented||VS(e??document.body,{select:!0}),s.removeEventListener(zS,u),fFe.remove(p)},0)}}},[s,l,u,p]);let m=z.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]=sFe(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&VS(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&VS(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,B.jsx)(PS.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});BS.displayName=aFe;function oFe(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(VS(r,{select:t}),document.activeElement!==n)return}function sFe(e){let t=cFe(e);return[lFe(t,e),lFe(t.reverse(),e)]}function cFe(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 lFe(e,t){for(let n of e)if(!uFe(n,{upTo:t}))return n}function uFe(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 dFe(e){return e instanceof HTMLInputElement&&`select`in e}function VS(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&dFe(e)&&t&&e.select()}}var fFe=pFe();function pFe(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=mFe(e,t),e.unshift(t)},remove(t){e=mFe(e,t),e[0]?.resume()}}}function mFe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function hFe(e){return e.filter(e=>e.tagName!==`A`)}var gFe=`Portal`,HS=z.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=z.useState(!1);AS(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?pl.createPortal((0,B.jsx)(PS.div,{...r,ref:t}),o):null});HS.displayName=gFe;function _Fe(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var US=e=>{let{present:t,children:n}=e,r=vFe(t),i=typeof n==`function`?n({present:r.isPresent}):z.Children.only(n),a=OS(r.ref,yFe(i));return typeof n==`function`||r.isPresent?z.cloneElement(i,{ref:a}):null};US.displayName=`Presence`;function vFe(e){let[t,n]=z.useState(),r=z.useRef(null),i=z.useRef(e),a=z.useRef(`none`),[o,s]=_Fe(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return z.useEffect(()=>{let e=WS(r.current);a.current=o===`mounted`?e:`none`},[o]),AS(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=WS(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),AS(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=WS(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=WS(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:z.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function WS(e){return e?.animationName||`none`}function yFe(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 GS=0;function bFe(){z.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??xFe()),document.body.insertAdjacentElement(`beforeend`,e[1]??xFe()),GS++,()=>{GS===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),GS--}},[])}function xFe(){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 KS=function(){return KS=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},KS.apply(this,arguments)};function SFe(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 CFe(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 qS=`right-scroll-bar-position`,JS=`width-before-scroll-bar`,wFe=`with-scroll-bars-hidden`,TFe=`--removed-body-scroll-bar-size`;function YS(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function EFe(e,t){var n=(0,z.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 DFe=typeof window<`u`?z.useLayoutEffect:z.useEffect,OFe=new WeakMap;function kFe(e,t){var n=EFe(t||null,function(t){return e.forEach(function(e){return YS(e,t)})});return DFe(function(){var t=OFe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||YS(e,null)}),i.forEach(function(e){r.has(e)||YS(e,a)})}OFe.set(n,e)},[e]),n}function AFe(e){return e}function jFe(e,t){t===void 0&&(t=AFe);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 MFe(e){e===void 0&&(e={});var t=jFe(null);return t.options=KS({async:!0,ssr:!1},e),t}var NFe=function(e){var t=e.sideCar,n=SFe(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 z.createElement(r,KS({},n))};NFe.isSideCarExport=!0;function PFe(e,t){return e.useMedium(t),NFe}var FFe=MFe(),XS=function(){},ZS=z.forwardRef(function(e,t){var n=z.useRef(null),r=z.useState({onScrollCapture:XS,onWheelCapture:XS,onTouchMoveCapture:XS}),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=SFe(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=kFe([n,t]),C=KS(KS({},b),i);return z.createElement(z.Fragment,null,u&&z.createElement(x,{sideCar:FFe,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?z.cloneElement(z.Children.only(s),KS(KS({},C),{ref:S})):z.createElement(v,KS({},C,{className:c,ref:S}),s))});ZS.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ZS.classNames={fullWidth:JS,zeroRight:qS};var IFe,LFe=function(){if(IFe)return IFe;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function RFe(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=LFe();return t&&e.setAttribute(`nonce`,t),e}function zFe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BFe(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var VFe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=RFe())&&(zFe(t,n),BFe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},HFe=function(){var e=VFe();return function(t,n){z.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},UFe=function(){var e=HFe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},WFe={left:0,top:0,right:0,gap:0},QS=function(e){return parseInt(e||``,10)||0},GFe=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[QS(n),QS(r),QS(i)]},KFe=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return WFe;var t=GFe(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])}},qFe=UFe(),$S=`data-scroll-locked`,JFe=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
54
|
+
`;let r=n.querySelector(`[data-pan-recovery-message="true"]`);if(r&&(r.textContent=e),t){let e=n.querySelector(`[data-pan-recovery-action="true"]`);e&&(e.textContent=t.label,e.addEventListener(`click`,t.onClick))}document.body.appendChild(n)}function aPe(){document.getElementById(fS)?.remove()}async function yS(e){if(tPe)return;tPe=!0,vS(`Reconnecting to the dashboard…`);let t=Number(sessionStorage.getItem(pS)||`0`);for(let e=0;;e++){try{if((await fetch(`/`,{cache:`no-store`})).ok)break}catch{}await oPe(Math.min(500+e*250,3e3))}Date.now()-t<4e3&&await oPe(2e3);let n=rPe();if(iPe(e,n),!n.shouldReload){vS(`The dashboard stopped automatic recovery after repeated load failures.${e.resource?` Failing resource: ${e.resource}`:``}`,{label:`Reload dashboard`,onClick:()=>window.location.reload()});return}window.location.reload()}function oPe(e){return new Promise(t=>setTimeout(t,e))}function sPe(){window.addEventListener(`vite:preloadError`,e=>{e.preventDefault();let t=e.payload,n=mS(t);yS({trigger:`vite_preload_error`,resource:_S(n),message:n||void 0,stackHead:hS(t)})}),window.addEventListener(`error`,e=>{let t=nPe(e.target);if(t){yS({trigger:`asset_load_error`,resource:t,message:e.message||`Module asset failed to load`});return}let n=e.error??e.message;if(gS(n)){let e=mS(n);yS({trigger:`window_module_error`,resource:_S(e),message:e||void 0,stackHead:hS(n)})}},!0),window.addEventListener(`unhandledrejection`,e=>{if(gS(e.reason)){let t=mS(e.reason);yS({trigger:`unhandled_rejection`,resource:_S(t),message:t||void 0,stackHead:hS(e.reason)})}})}var cPe=class extends z.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){if(ns(e,{action:`frontend_unhandled_error`,trigger:`root_error_boundary`}),gS(e)){let t=mS(e);yS({trigger:`root_error_boundary`,resource:_S(t),message:t||void 0,stackHead:hS(e)})}}render(){return this.state.hasError?(0,B.jsxs)(`div`,{style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:16,background:`rgba(10,12,16,0.92)`,color:`#e6e6e6`,fontFamily:`var(--font-sans),system-ui,sans-serif`,fontSize:15},children:[(0,B.jsx)(`div`,{children:`The dashboard hit an error.`}),(0,B.jsx)(`button`,{onClick:()=>window.location.reload(),style:{padding:`8px 18px`,borderRadius:8,border:`1px solid rgba(255,255,255,0.2)`,background:`#1b2533`,color:`#e6e6e6`,cursor:`pointer`,fontSize:14},children:`Reload dashboard`})]}):this.props.children}},bS=`overdeck:backend-reconnecting`,xS=`overdeck:reconnected`;function lPe(){window.dispatchEvent(new CustomEvent(bS))}function uPe(){window.dispatchEvent(new CustomEvent(xS))}var dPe=2e3,fPe=3*6e4,pPe=35e3,mPe=6,hPe=2e3,gPe=3e4,_Pe=.2;function vPe(e){return`sequence`in e}function yPe(e,t=Math.random){let n=Math.min(hPe*2**(Math.max(1,Math.floor(e))-1),gPe),r=1+(t()*2-1)*_Pe;return Math.min(gPe,Math.round(n*r))}function SS(){let e=Q(e=>e.syncSnapshot),t=Q(e=>e.applyEvents),n=Q(e=>e.seedRecentActivity),r=(0,z.useRef)(null),i=(0,z.useRef)([]),a=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{let o=ZNe();r.current=o;let s=!1,c=null,l=!1,u=!1,d=null,f=null,p=null,m=null,h=0,g=0,_=null;function v(){d&&clearInterval(d),f&&clearTimeout(f),d=null,f=null}function y(){v(),d=setInterval(()=>{if(l){v();return}k().catch(console.error)},dPe),f=setTimeout(()=>{l||vS(`Server unreachable — Retry`,{label:`Retry`,onClick:()=>w()}),v()},fPe)}function b(){p&&clearTimeout(p),p=null}function x(){m&&clearTimeout(m),m=null}function S(){u=!0,lPe()}function C(){k().then(e=>{e||T()})}function w(e){if(s)return;let t=e?.fullReset??!0;x(),S(),_?.(),_=null,t&&ECe(),P(),C()}function T(e){if(m||s)return;h+=1;let t=yPe(h);m=setTimeout(()=>{m=null,w(e)},t)}function E(){b(),p=setTimeout(()=>{g+=1,console.warn(`[EventRouter] domain event stream stale — scheduling reconnect (strike ${g})`),S(),T({fullReset:g>1})},pPe)}let D=TNe();D&&e(D);async function O(){try{let e=await fetch(`/api/activity`);if(!e.ok)return;let t=await e.json();Array.isArray(t)&&n(t)}catch{}}function k(){return c||(s=!0,c=(async()=>{o.beginSnapshotRecovery(`bootstrap`);try{let t=await lb().request(e=>e[Cy.getSnapshot]({}));return e(t),O(),l=!0,v(),o.completeSnapshotRecovery(t.sequence)&&await A(t.sequence),u&&(u=!1,h=0,x(),aPe(),uPe()),!0}catch(e){return console.error(`[EventRouter] bootstrap failed:`,e),o.failRecovery(),!1}finally{s=!1,c=null}})(),c)}async function A(e){o.beginReplayRecovery();try{let n=(await lb().request(t=>t[Cy.replayEvents]({fromSequence:e}))).filter(vPe);if(n.length>0&&(t(n),o.markEventBatchApplied(n[n.length-1].sequence)),o.completeReplayRecovery()){await A(o.getState().latestSequence);return}j()}catch(e){console.error(`[EventRouter] replay failed:`,e),o.failRecovery()}}function j(){let e=i.current.splice(0).sort((e,t)=>e.sequence-t.sequence),n=[];for(let t of e){let e=o.classifyDomainEvent(t.sequence);if(e!==`ignore`){if(e===`apply`){n.push(t),o.markEventBatchApplied(t.sequence);continue}if(i.current.push(t),e===`recover`){A(o.getState().latestSequence).catch(console.error);break}}}n.length>0&&t(n)}function M(){a.current||(a.current=!0,setTimeout(()=>{a.current=!1,j()},16))}function N(e){if(h=0,g=0,x(),E(),u||aPe(),!vPe(e))return;let t=o.classifyDomainEvent(e.sequence);if(t!==`ignore`){if(t===`defer`){i.current.push(e);return}if(t===`recover`){i.current.push(e);let t=o.getState().latestSequence;A(t).catch(console.error);return}i.current.push(e),M()}}function P(){_?.(),_=lb().subscribe(e=>e[Cy.subscribeDomainEvents]({}),e=>N(e),{onReconnect:()=>{console.log(`[EventRouter] transport reconnected — re-bootstrapping snapshot`),C()},onRetry:e=>{S(),e>=mPe&&vS(`Server unreachable — Retry`,{label:`Retry`,onClick:()=>w()})}}),E()}return P(),k(),y(),()=>{v(),b(),x(),_?.()}},[e,t,n]),null}var bPe=1,xPe=.9,SPe=.8,CPe=.17,CS=.1,wS=.999,wPe=.9999,TPe=.99,EPe=/[\\\/_+.#"@\[\(\{&]/,DPe=/[\\\/_+.#"@\[\(\{&]/g,OPe=/[\s-]/,kPe=/[\s-]/g;function TS(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?bPe:TPe;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=TS(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=bPe:EPe.test(e.charAt(l-1))?(d*=SPe,p=e.slice(i,l-1).match(DPe),p&&i>0&&(d*=wS**+p.length)):OPe.test(e.charAt(l-1))?(d*=xPe,m=e.slice(i,l-1).match(kPe),m&&i>0&&(d*=wS**+m.length)):(d*=CPe,i>0&&(d*=wS**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=wPe)),(d<CS&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=TS(e,t,n,r,l+1,a+2,o),f*CS>d&&(d=f*CS)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function APe(e){return e.toLowerCase().replace(kPe,` `)}function jPe(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,TS(e,t,APe(e),APe(t),0,0,{})}typeof window<`u`&&window.document&&window.document.createElement;function ES(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function MPe(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function DS(...e){return t=>{let n=!1,r=e.map(e=>{let r=MPe(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():MPe(e[t],null)}}}}function OS(...e){return z.useCallback(DS(...e),e)}function NPe(e,t){let n=z.createContext(t),r=e=>{let{children:t,...r}=e,i=z.useMemo(()=>r,Object.values(r));return(0,B.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=z.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function kS(e,t=[]){let n=[];function r(t,r){let i=z.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=z.useMemo(()=>o,Object.values(o));return(0,B.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=z.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=>z.createContext(e));return function(n){let r=n?.[e]||t;return z.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,PPe(i,...t)]}function PPe(...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 z.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var AS=globalThis?.document?z.useLayoutEffect:()=>{},FPe=z.useId||(()=>void 0),IPe=0;function jS(e){let[t,n]=z.useState(FPe());return AS(()=>{e||n(e=>e??String(IPe++))},[e]),e||(t?`radix-${t}`:``)}var LPe=z.useInsertionEffect||AS;function MS({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=RPe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=z.useRef(e!==void 0);z.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,z.useCallback(t=>{if(s){let n=zPe(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function RPe({defaultProp:e,onChange:t}){let[n,r]=z.useState(e),i=z.useRef(n),a=z.useRef(t);return LPe(()=>{a.current=t},[t]),z.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function zPe(e){return typeof e==`function`}function NS(e){let t=BPe(e),n=z.forwardRef((e,n)=>{let{children:r,...i}=e,a=z.Children.toArray(r),o=a.find(HPe);if(o){let e=o.props.children,r=a.map(t=>t===o?z.Children.count(e)>1?z.Children.only(null):z.isValidElement(e)?e.props.children:null:t);return(0,B.jsx)(t,{...i,ref:n,children:z.isValidElement(e)?z.cloneElement(e,void 0,r):null})}return(0,B.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function BPe(e){let t=z.forwardRef((e,t)=>{let{children:n,...r}=e;if(z.isValidElement(n)){let e=WPe(n),i=UPe(r,n.props);return n.type!==z.Fragment&&(i.ref=t?DS(t,e):e),z.cloneElement(n,i)}return z.Children.count(n)>1?z.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var VPe=Symbol(`radix.slottable`);function HPe(e){return z.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===VPe}function UPe(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 WPe(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 PS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=NS(`Primitive.${t}`),r=z.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,B.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function GPe(e,t){e&&pl.flushSync(()=>e.dispatchEvent(t))}function FS(e){let t=z.useRef(e);return z.useEffect(()=>{t.current=e}),z.useMemo(()=>(...e)=>t.current?.(...e),[])}function KPe(e,t=globalThis?.document){let n=FS(e);z.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 qPe=`DismissableLayer`,IS=`dismissableLayer.update`,JPe=`dismissableLayer.pointerDownOutside`,YPe=`dismissableLayer.focusOutside`,XPe,ZPe=z.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),LS=z.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=z.useContext(ZPe),[u,d]=z.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=z.useState({}),m=OS(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=eFe(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=tFe(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return KPe(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),z.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(XPe=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),nFe(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=XPe)}},[u,f,n,l]),z.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),nFe())},[u,l]),z.useEffect(()=>{let e=()=>p({});return document.addEventListener(IS,e),()=>document.removeEventListener(IS,e)},[]),(0,B.jsx)(PS.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:ES(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ES(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ES(e.onPointerDownCapture,x.onPointerDownCapture)})});LS.displayName=qPe;var QPe=`DismissableLayerBranch`,$Pe=z.forwardRef((e,t)=>{let n=z.useContext(ZPe),r=z.useRef(null),i=OS(t,r);return z.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,B.jsx)(PS.div,{...e,ref:i})});$Pe.displayName=QPe;function eFe(e,t=globalThis?.document){let n=FS(e),r=z.useRef(!1),i=z.useRef(()=>{});return z.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){rFe(JPe,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 tFe(e,t=globalThis?.document){let n=FS(e),r=z.useRef(!1);return z.useEffect(()=>{let e=e=>{e.target&&!r.current&&rFe(YPe,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 nFe(){let e=new CustomEvent(IS);document.dispatchEvent(e)}function rFe(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?GPe(i,a):i.dispatchEvent(a)}var RS=`focusScope.autoFocusOnMount`,zS=`focusScope.autoFocusOnUnmount`,iFe={bubbles:!1,cancelable:!0},aFe=`FocusScope`,BS=z.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=z.useState(null),l=FS(i),u=FS(a),d=z.useRef(null),f=OS(t,e=>c(e)),p=z.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;z.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:VS(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||VS(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&VS(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]),z.useEffect(()=>{if(s){fFe.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(RS,iFe);s.addEventListener(RS,l),s.dispatchEvent(t),t.defaultPrevented||(oFe(hFe(cFe(s)),{select:!0}),document.activeElement===e&&VS(s))}return()=>{s.removeEventListener(RS,l),setTimeout(()=>{let t=new CustomEvent(zS,iFe);s.addEventListener(zS,u),s.dispatchEvent(t),t.defaultPrevented||VS(e??document.body,{select:!0}),s.removeEventListener(zS,u),fFe.remove(p)},0)}}},[s,l,u,p]);let m=z.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]=sFe(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&VS(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&VS(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,B.jsx)(PS.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});BS.displayName=aFe;function oFe(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(VS(r,{select:t}),document.activeElement!==n)return}function sFe(e){let t=cFe(e);return[lFe(t,e),lFe(t.reverse(),e)]}function cFe(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 lFe(e,t){for(let n of e)if(!uFe(n,{upTo:t}))return n}function uFe(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 dFe(e){return e instanceof HTMLInputElement&&`select`in e}function VS(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&dFe(e)&&t&&e.select()}}var fFe=pFe();function pFe(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=mFe(e,t),e.unshift(t)},remove(t){e=mFe(e,t),e[0]?.resume()}}}function mFe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function hFe(e){return e.filter(e=>e.tagName!==`A`)}var gFe=`Portal`,HS=z.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=z.useState(!1);AS(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?pl.createPortal((0,B.jsx)(PS.div,{...r,ref:t}),o):null});HS.displayName=gFe;function _Fe(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var US=e=>{let{present:t,children:n}=e,r=vFe(t),i=typeof n==`function`?n({present:r.isPresent}):z.Children.only(n),a=OS(r.ref,yFe(i));return typeof n==`function`||r.isPresent?z.cloneElement(i,{ref:a}):null};US.displayName=`Presence`;function vFe(e){let[t,n]=z.useState(),r=z.useRef(null),i=z.useRef(e),a=z.useRef(`none`),[o,s]=_Fe(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return z.useEffect(()=>{let e=WS(r.current);a.current=o===`mounted`?e:`none`},[o]),AS(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=WS(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),AS(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=WS(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=WS(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:z.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function WS(e){return e?.animationName||`none`}function yFe(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 GS=0;function bFe(){z.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??xFe()),document.body.insertAdjacentElement(`beforeend`,e[1]??xFe()),GS++,()=>{GS===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),GS--}},[])}function xFe(){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 KS=function(){return KS=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},KS.apply(this,arguments)};function SFe(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 CFe(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 qS=`right-scroll-bar-position`,JS=`width-before-scroll-bar`,wFe=`with-scroll-bars-hidden`,TFe=`--removed-body-scroll-bar-size`;function YS(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function EFe(e,t){var n=(0,z.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 DFe=typeof window<`u`?z.useLayoutEffect:z.useEffect,OFe=new WeakMap;function kFe(e,t){var n=EFe(t||null,function(t){return e.forEach(function(e){return YS(e,t)})});return DFe(function(){var t=OFe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||YS(e,null)}),i.forEach(function(e){r.has(e)||YS(e,a)})}OFe.set(n,e)},[e]),n}function AFe(e){return e}function jFe(e,t){t===void 0&&(t=AFe);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 MFe(e){e===void 0&&(e={});var t=jFe(null);return t.options=KS({async:!0,ssr:!1},e),t}var NFe=function(e){var t=e.sideCar,n=SFe(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 z.createElement(r,KS({},n))};NFe.isSideCarExport=!0;function PFe(e,t){return e.useMedium(t),NFe}var FFe=MFe(),XS=function(){},ZS=z.forwardRef(function(e,t){var n=z.useRef(null),r=z.useState({onScrollCapture:XS,onWheelCapture:XS,onTouchMoveCapture:XS}),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=SFe(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=kFe([n,t]),C=KS(KS({},b),i);return z.createElement(z.Fragment,null,u&&z.createElement(x,{sideCar:FFe,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?z.cloneElement(z.Children.only(s),KS(KS({},C),{ref:S})):z.createElement(v,KS({},C,{className:c,ref:S}),s))});ZS.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ZS.classNames={fullWidth:JS,zeroRight:qS};var IFe,LFe=function(){if(IFe)return IFe;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function RFe(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=LFe();return t&&e.setAttribute(`nonce`,t),e}function zFe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BFe(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var VFe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=RFe())&&(zFe(t,n),BFe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},HFe=function(){var e=VFe();return function(t,n){z.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},UFe=function(){var e=HFe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},WFe={left:0,top:0,right:0,gap:0},QS=function(e){return parseInt(e||``,10)||0},GFe=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[QS(n),QS(r),QS(i)]},KFe=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return WFe;var t=GFe(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])}},qFe=UFe(),$S=`data-scroll-locked`,JFe=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
55
55
|
.${wFe} {
|
|
56
56
|
overflow: hidden ${r};
|
|
57
57
|
padding-right: ${s}px ${r};
|
|
@@ -319,7 +319,7 @@ Any planning artifacts in the workspace will be preserved.`,confirmLabel:`Stop P
|
|
|
319
319
|
`),l=!d.isEmpty();else if(l=!1,cB(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else !mV(d)&&!Yz(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=ZB(),n=t.getEditorState()._selection,r=DB(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(r===null)return;let[i,a]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(a.key,a.offset,a.type,!0),aR(this)}clone(){let t=this.anchor,n=this.focus;return new e(pB(t.key,t.offset,t.type),pB(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=VV(this.format,e,null),this.dirty=!0}setFormat(e){this.format=e,this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=VL[e];return(this.format&t)!==0}insertRawText(e){let t=e.split(/(\r?\n|\t)/),n=[],r=t.length;for(let e=0;e<r;e++){let r=t[e];r===`
|
|
320
320
|
`||r===`\r
|
|
321
321
|
`?n.push(Jz()):r===` `?n.push(dB()):n.push(sB(r))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,a=t,o=n;!this.isCollapsed()&&n.isBefore(t)&&(a=n,o=t),a.type===`element`&&function(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=sB();if(o.setFormat(n),o.setStyle(r),CV(a))a.splice(0,0,[o]);else{let e=gV(i)?SV().append(o):o;a===null?i.append(e):a.insertBefore(e)}e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}(a,o,r,i),o.type===`element`&&hU(o,xU(mU(o,`next`)));let s=a.offset,c=o.offset,l=this.getNodes(),u=l.length,d=l[0];cB(d)||OL(26);let f=d.getTextContent().length,p=d.getParentOrThrow(),m=l[u-1];if(u===1&&o.type===`element`&&(c=f,o.set(a.key,c,`text`)),this.isCollapsed()&&s===f&&(RV(d)||!d.canInsertTextAfter()||!p.canInsertTextAfter()&&d.getNextSibling()===null)){let t=d.getNextSibling();if(cB(t)&&t.canInsertTextBefore()&&!RV(t)||(t=sB(),t.setFormat(r),t.setStyle(i),p.canInsertTextAfter()?d.insertAfter(t):p.insertAfter(t)),t.select(0,0),d=t,e!==``)return void this.insertText(e)}else if(this.isCollapsed()&&s===0&&(RV(d)||!d.canInsertTextBefore()||!p.canInsertTextBefore()&&d.getPreviousSibling()===null)){let t=d.getPreviousSibling();if(cB(t)&&!RV(t)||(t=sB(),t.setFormat(r),p.canInsertTextBefore()?d.insertBefore(t):p.insertBefore(t)),t.select(),d=t,e!==``)return void this.insertText(e)}else if(d.isSegmented()&&s!==f){let e=sB(d.getTextContent());e.setFormat(r),d.replace(e),d=e}else if(!this.isCollapsed()&&e!==``){let t=m.getParent();if(!p.canInsertTextBefore()||!p.canInsertTextAfter()||dV(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(``),EB(this.anchor,this.focus),void this.insertText(e)}if(u===1){if(LV(d)){let t=sB(e);t.select(),d.replace(t);return}let t=d.getFormat(),n=d.getStyle();if(s!==c||t===r&&n===i){if(fB(d)){let t=sB(e);t.setFormat(r),t.setStyle(i),t.select(),d.replace(t);return}}else{if(d.getTextContent()!==``){let t=sB(e);if(t.setFormat(r),t.setStyle(i),t.select(),s===0)d.insertBefore(t,!1);else{let[e]=d.splitText(s);e.insertAfter(t,!1)}t.isComposing()&&this.anchor.type===`text`&&(this.anchor.offset-=e.length);return}d.setFormat(r),d.setStyle(i)}let a=c-s;d=d.spliceText(s,a,e,!0),d.getTextContent()===``?d.remove():this.anchor.type===`text`&&(this.format=t,this.style=n,d.isComposing()&&(this.anchor.offset-=e.length))}else{let t=new Set([...d.getParentKeys(),...m.getParentKeys()]),n=dV(d)?d:d.getParentOrThrow(),r=dV(m)?m:m.getParentOrThrow(),i=m;if(!n.is(r)&&r.isInline())do i=r,r=r.getParentOrThrow();while(r.isInline());if(o.type===`text`&&(c!==0||m.getTextContent()===``)||o.type===`element`&&m.getIndexWithinParent()<c)if(cB(m)&&!LV(m)&&c!==m.getTextContentSize()){if(m.isSegmented()){let e=sB(m.getTextContent());m.replace(e),m=e}gV(o.getNode())||o.type!==`text`||(m=m.spliceText(0,c,``)),t.add(m.__key)}else{let e=m.getParentOrThrow();e.canBeEmpty()||e.getChildrenSize()!==1?m.remove():e.remove()}else t.add(m.__key);let a=r.getChildren(),p=new Set(l),h=n.is(r),g=n.isInline()&&d.getNextSibling()===null?n:d;for(let e=a.length-1;e>=0;e--){let t=a[e];if(t.is(d)||dV(t)&&t.isParentOf(d))break;t.isAttached()&&(!p.has(t)||t.is(i)?h||g.insertAfter(t,!1):t.remove())}if(!h){let e=r,n=null;for(;e!==null;){let r=e.getChildren(),i=r.length;(i===0||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(LV(d))if(s===f)d.select();else{let t=sB(e);t.select(),d.replace(t)}else d=d.spliceText(s,f-s,e,!0),d.getTextContent()===``?d.remove():this.anchor.type===`text`&&(this.format=d.getFormat(),this.style=d.getStyle(),d.isComposing()&&(this.anchor.offset-=e.length));for(let e=1;e<u;e++){let n=l[e],r=n.__key;t.has(r)||n.remove()}}}removeText(){let e=jB()===this;gU(this,Ret(_U(this))),e&&jB()!==this&&eH(this)}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void WV(null);let n=this.getNodes(),r=[];for(let e of n)cB(e)&&r.push(e);let i=t=>{n.forEach(n=>{if(dV(n)){let r=n.getFormatFlags(e,t);n.setTextFormat(r)}})},a=r.length;if(a===0)return this.toggleFormat(e),WV(null),void i(t);let o=this.anchor,s=this.focus,c=this.isBackward(),l=c?s:o,u=c?o:s,d=0,f=r[0],p=l.type===`element`?0:l.offset;if(l.type===`text`&&p===f.getTextContentSize()&&(d=1,f=r[1],p=0),f==null)return;let m=f.getFormatFlags(e,t);i(m);let h=a-1,g=r[h],_=u.type===`text`?u.offset:g.getTextContentSize();if(f.is(g)){if(p===_)return;if(RV(f)||p===0&&_===f.getTextContentSize())f.setFormat(m);else{let e=f.splitText(p,_),t=p===0?e[0]:e[1];t.setFormat(m),l.type===`text`&&l.set(t.__key,0,`text`),u.type===`text`&&u.set(t.__key,_-p,`text`)}this.format=m;return}p===0||RV(f)||([,f]=f.splitText(p),p=0),f.setFormat(m);let v=g.getFormatFlags(e,m);_>0&&(_===g.getTextContentSize()||RV(g)||([g]=g.splitText(_)),g.setFormat(v));for(let t=d+1;t<h;t++){let n=r[t],i=n.getFormatFlags(e,v);n.setFormat(i)}l.type===`text`&&l.set(f.__key,p,`text`),u.type===`text`&&u.set(g.__key,_,`text`),this.format=m|v}insertNodes(e){if(e.length===0)return;if(this.isCollapsed()||this.removeText(),this.anchor.key===`root`){this.insertParagraph();let t=jB();return _B(t)||OL(134),t.insertNodes(e)}let t=(this.isBackward()?this.focus:this.anchor).getNode(),n=WH(t,LH),r=e[e.length-1];if(dV(n)&&`__language`in n){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=zB(this);n.splice(t,0,e),r.selectEnd()}return}if(!e.some(e=>(dV(e)||mV(e))&&!e.isInline())){dV(n)||OL(211,t.constructor.name,t.getType());let i=zB(this);n.splice(i,0,e),r.selectEnd();return}let i=function(e){let t=SV(),n=null;for(let r=0;r<e.length;r++){let i=e[r],a=Yz(i);if(a||mV(i)&&i.isInline()||dV(i)&&i.isInline()||cB(i)||i.isParentRequired()){if(n===null&&(n=i.createParentElementNode(),t.append(n),a))continue;n!==null&&n.append(i)}else t.append(i),n=null}return t}(e),a=i.getLastDescendant(),o=i.getChildren(),s=!dV(n)||!n.isEmpty()?this.insertParagraph():null,c=o[o.length-1],l=o[0];var u;dV(u=l)&&LH(u)&&!u.isEmpty()&&dV(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(dV(n)||OL(211,t.constructor.name,t.getType()),n.append(...l.getChildren()),l=o[1]),l&&(n===null&&OL(212,t.constructor.name,t.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||OL(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(n,l));let d=WH(a,LH);s&&dV(d)&&(s.canMergeWhenEmpty()||LH(c))&&(d.append(...s.getChildren()),s.remove()),dV(n)&&n.isEmpty()&&n.remove(),a.selectEnd();let f=dV(n)?n.getLastChild():null;Yz(f)&&d!==n&&f.remove()}insertParagraph(){if(this.anchor.key===`root`){let e=SV();return QV().splice(this.anchor.offset,0,[e]),e.select(),e}let e=zB(this),t=WH(this.anchor.getNode(),LH);dV(t)||OL(213);let n=t.getChildAtIndex(e),r=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(e){let t=Jz();if(this.insertNodes([t]),e){let e=t.getParentOrThrow(),n=t.getIndexWithinParent();e.select(n,n)}}extract(){let e=[...this.getNodes()],t=e.length,n=e[0],r=e[t-1],[i,a]=xB(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(cB(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(cB(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),cB(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(BB(this,e,t,n))return;let r=e===`move`,i=ZB(),a=MH(EH(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();if(s===null||o===null||!dV(c)||c.isInline()||c.canBeEmpty()||jH(o,i,s),this.dirty){let e=bH(i,this.anchor.key),t=bH(i,this.focus.key);this.anchor.type===`text`&&(e=BV(e)),this.focus.type===`text`&&(t=BV(t)),e&&t&&LB(a,e,this.anchor.offset,t,this.focus.offset)}if(function(e,t,n,r){e.modify(t,n,r)}(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=a.getRangeAt(0),n=this.anchor.getNode(),i=gV(n)?n:vet(n);if(this.applyDOMRange(e),this.dirty=!0,!r){let n=this.getNodes(),r=[],o=!1;for(let e=0;e<n.length;e++){let t=n[e];wH(t,i)?r.push(t):o=!0}if(o&&r.length>0)if(t){let e=r[0];dV(e)?e.selectStart():e.getParentOrThrow().selectStart()}else{let e=r[r.length-1];dV(e)?e.selectEnd():e.getParentOrThrow().selectEnd()}a.anchorNode===e.startContainer&&a.anchorOffset===e.startOffset||function(e){let t=e.focus,n=e.anchor,r=n.key,i=n.offset,a=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,a,!0)}(this)}}n===`lineboundary`&&BB(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&dV(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(dV(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=oU(mU(t,e?`previous`:`next`));if(r.getTextSlices().every(e=>e===null||e.distance===0)){let e={type:`initial`};for(let t of r.iterNodeCarets(`shadowRoot`))if($H(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(dV(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=xU(t);gU(this,sU(e,e)),r.anchor.origin.remove()}return}e.type!==`merge-next-block`&&e.type!==`merge-block`||(e={block:e.block,caret:t,type:`merge-block`})}}else{if(e.type===`merge-block`)break;if(QH(t)){if(dV(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(mV(t.origin)){if(!t.origin.isIsolated())if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&dV(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=kB();e.add(t.origin.getKey()),eH(e)}else t.origin.remove();return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return gU(this,sU(!t.origin.isEmpty()&&n.isEmpty()?vU(eU(n,t.direction)):r.anchor,t)),this.removeText()}}let i=this.focus;if(this.modify(`extend`,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&SB(this,t.getNode()))return}else{let r=i.type===`text`?i.getNode():null;if(n=t.type===`text`?t.getNode():null,r!==null&&r.isSegmented()){let t=i.offset,a=r.getTextContentSize();if(r.is(n)||e&&t!==a||!e&&t!==0)return void CB(r,e,t)}else if(n!==null&&n.isSegmented()){let i=t.offset,a=n.getTextContentSize();if(n.is(r)||e&&i!==0||!e&&i!==a)return void CB(n,e,i)}(function(e,t){let n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&n.type===`text`&&r.type===`text`){let e=n.offset,a=r.offset,o=e<a,s=o?e:a,c=o?a:e,l=c-1;s!==l&&(function(e){return!(nH(e)||$9e(e))})(i.getTextContent().slice(s,c))&&(t?r.set(r.key,l,r.type):n.set(n.key,l,n.type))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type===`element`&&this.anchor.offset===0){let e=this.anchor.getNode();e.isEmpty()&&gV(e.getParent())&&e.getPreviousSibling()===null&&SB(this,e)}}deleteLine(e){this.isCollapsed()&&this.modify(`extend`,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):this.removeText()}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify(`extend`,e,`word`)}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function yB(e){return e instanceof gB}function bB(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function xB(e){let t=e.getStartEndPoints();if(t===null)return[0,0];let[n,r]=t;return n.type===`element`&&r.type===`element`&&n.key===r.key&&n.offset===r.offset?[0,0]:[bB(n),bB(r)]}function SB(e,t){for(let n=t;n;n=n.getParent()){if(dV(n)){if(n.collapseAtStart(e))return!0;if(DH(n))break}if(n.getPreviousSibling())break}return!1}var $9e=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function CB(e,t,n){let r=e,i=r.getTextContent().split(/(?=\s)/g),a=i.length,o=0,s=0;for(let e=0;e<a;e++){let r=e===a-1;if(s=o,o+=i[e].length,t&&o===n||o>n||r){i.splice(e,1),r&&(s=void 0);break}}let c=i.join(``).trim();c===``?r.remove():(r.setTextContent(c),r.select(s,s))}function wB(e,t,n,r){let i,a=t;if(NH(e)){let o=!1,s=e.childNodes,c=s.length,l=r._blockCursorElement;a===c&&(o=!0,a=c-1);let u=s[a],d=!1;if(u===l)u=s[a+1],d=!0;else if(l!==null){let n=l.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,l)&&a--}if(i=tH(u),cB(i))a=nU(i,o?`next`:`previous`);else{let s=tH(e);if(s===null)return null;if(dV(s)){let c=r.getElementByKey(s.getKey());c===null&&OL(214);let l=s.getDOMSlot(c);[s,a]=l.resolveChildIndex(s,c,e,t),dV(s)||OL(215),o&&a>=s.getChildrenSize()&&(a=Math.max(0,s.getChildrenSize()-1));let u=s.getChildAtIndex(a);if(dV(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=o?u.getLastDescendant():u.getFirstDescendant();e===null?s=u:(u=e,s=dV(u)?u:u.getParentOrThrow()),a=0}cB(u)?(i=u,s=null,a=nU(u,o?`next`:`previous`)):u!==s&&o&&!d&&(dV(s)||OL(216),a=Math.min(s.getChildrenSize(),a+1))}else{let n=s.getIndexWithinParent();a=t===0&&mV(s)&&tH(e)===s?n:n+1,s=s.getParentOrThrow()}if(dV(s))return pB(s.__key,a,`element`)}}else i=tH(e);return cB(i)?pB(i.__key,nU(i,a,`clamp`),`text`):null}function TB(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&dV(a)&&a.isInline()){let t=a.getPreviousSibling();cB(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else dV(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):cB(r)&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&dV(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&dV(a)&&a.isInline()&&!a.canInsertTextAfter()){let t=a.getNextSibling();cB(t)&&e.set(t.__key,0,`text`)}}}function EB(e,t,n){if(e.type===`text`&&t.type===`text`){let n=e.isBefore(t),r=e.is(t);TB(e,n,r),TB(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}function DB(e,t,n,r,i,a){if(e===null||n===null||!NV(i,e,n))return null;let o=wB(e,t,_B(a)?a.anchor:null,i);if(o===null)return null;let s=wB(n,r,_B(a)?a.focus:null,i);if(s===null)return null;if(o.type===`element`&&s.type===`element`){let t=tH(e),r=tH(n);if(mV(t)&&mV(r))return null}return EB(o,s),[o,s]}function OB(e,t,n,r,i,a){let o=XB(),s=new vB(pB(e,t,i),pB(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function eet(){return new vB(pB(`root`,0,`element`),pB(`root`,0,`element`),0,``)}function kB(){return new gB(new Set)}function AB(e,t,n,r){let i=n._window;if(i===null)return null;let a=r||i.event,o=a?a.type:void 0,s=o===`selectionchange`,c=!GL&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(_B(e)&&!c)return e.clone();if(t===null)return null;if(l=t.anchorNode,u=t.focusNode,d=t.anchorOffset,f=t.focusOffset,(s||o===void 0)&&_B(e)&&!NV(n,l,u))return e.clone();let p=DB(l,d,u,f,n,e);if(p===null)return null;let[m,h]=p,g=0,_=``;if(_B(e)){let t=e.anchor;if(m.key===t.key)g=e.format,_=e.style;else{let e=m.getNode();cB(e)?(g=e.getFormat(),_=e.getStyle()):dV(e)&&(g=e.getTextFormat(),_=e.getTextStyle())}}return new vB(m,h,g,_)}function jB(){return XB()._selection}function MB(){return ZB()._editorState._selection}function NB(e,t,n,r=1){let i=e.anchor,a=e.focus,o=i.getNode(),s=a.getNode();if(!t.is(o)&&!t.is(s))return;let c=t.__key;if(e.isCollapsed()){let t=i.offset;if(n<=t&&r>0||n<t&&r<0){let n=Math.max(0,t+r);i.set(c,n,`element`),a.set(c,n,`element`),PB(e)}}else{let o=e.isBackward(),s=o?a:i,l=s.getNode(),u=o?i:a,d=u.getNode();if(t.is(l)){let e=s.offset;(n<=e&&r>0||n<e&&r<0)&&s.set(c,Math.max(0,e+r),`element`)}if(t.is(d)){let e=u.offset;(n<=e&&r>0||n<e&&r<0)&&u.set(c,Math.max(0,e+r),`element`)}}PB(e)}function PB(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!dV(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(cB(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}return}if(dV(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(cB(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(dV(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(cB(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}function FB(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,cB(i)?s=`text`:dV(i)&&(s=`element`)):(a=r.__key,cB(r)?(o=r.getTextContentSize(),s=`text`):dV(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function IB(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function LB(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function RB(e,t,n){let r=bH(e,t.getKey());if(dV(t)){let e=t.getDOMSlot(r);return[e.element,n+e.getFirstChildOffset()]}return[r,n]}function tet(e,t,n,r,i,a,o){let s=r.anchorNode,c=r.focusNode,l=r.anchorOffset,u=r.focusOffset,d=document.activeElement;if(i.has(`collaboration`)&&d!==a||d!==null&&MV(d))return;if(!_B(t))return void(e!==null&&NV(n,s,c)&&r.removeAllRanges());let f=t.anchor,p=t.focus,m=f.getNode(),h=p.getNode(),[g,_]=RB(n,m,f.offset),[v,y]=RB(n,h,p.offset),b=t.format,x=t.style,S=t.isCollapsed(),C=g,w=v,T=!1;var E,D,O,k,A;if((f.type===`text`?(C=BV(g),T=m.getFormat()!==b||m.getStyle()!==x):_B(e)&&e.anchor.type===`text`&&(T=!0),p.type===`text`&&(w=BV(v)),C!==null&&w!==null)&&(S&&(e===null||T||_B(e)&&(e.format!==b||e.style!==x))&&(E=b,D=x,O=_,k=f.key,A=performance.now(),kz=[E,D,O,k,A]),l!==_||u!==y||s!==C||c!==w||r.type===`Range`&&S||(d!==null&&a.contains(d)||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0}),f.type===`element`))){if(LB(r,C,_,w,y),!jL||!t.isCollapsed()||a===null||i.has(`skip-selection-focus`)||document.activeElement!==null&&a.contains(document.activeElement)||a.focus({preventScroll:!0}),!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===document.activeElement){let e=_B(t)&&t.anchor.type===`element`?C.childNodes[_]||null:r.rangeCount>0?r.getRangeAt(0):null;if(e!==null){let t;if(e instanceof Text){let n=document.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=SH(n),i=TH(r);if(r===null||i===null)return;let{top:a,bottom:o}=t,s=0,c=0,l=n;for(;l!==null;){let t=l===r.body;if(t)s=0,c=EH(e).innerHeight;else{let e=l.getBoundingClientRect();s=e.top,c=e.bottom}let n=0;if(a<s?n=-(s-a):o>c&&(n=o-c),n!==0)if(t)i.scrollBy(0,n);else{let e=l.scrollTop;l.scrollTop+=n;let t=l.scrollTop-e;a-=t,o-=t}if(t)break;l=xH(l)}})(n,t,a)}}Sz=!0}}function zB(e){let t=e;e.isCollapsed()||t.removeText();let n=jB();_B(n)&&(t=n),_B(t)||OL(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!LH(i);){let e=i;if([i,a]=net(i,a),e.is(i))break}return a}function net(e,t){let n=e.getParent();if(!n){let e=SV();return QV().append(e),e.select(),[QV(),0]}if(cB(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!dV(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new vB(pB(e.__key,t,`element`),pB(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function BB(e,t,n,r,i=`decorators-and-blocks`){if(t===`move`&&r===`character`&&!e.isCollapsed()){let[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}let a=mU(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!SU(c)){for(let e of c){l=!1;let{origin:t}=e;if(!mV(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of oU(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if($H(e))e.origin.isInline()||(c=e);else{if(dV(e.origin))continue;mV(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&mV(c.origin)&&c.origin.isKeyboardSelectable()){let e=kB();return e.add(c.origin.getKey()),eH(e),!0}return c=xU(c),s&&hU(e.anchor,c),hU(e.focus,c),l||!o}var VB=null,HB=null,UB=!1,WB=!1,GB=0,KB={characterData:!0,childList:!0,subtree:!0};function qB(){return UB||VB!==null&&VB._readOnly}function JB(){UB&&OL(13)}function YB(){GB>99&&OL(14)}function XB(){return VB===null&&OL(195,QB()),VB}function ZB(){return HB===null&&OL(196,QB()),HB}function QB(){let e=0,t=new Set,n=EV.version;if(typeof window<`u`)for(let r of document.querySelectorAll(`[contenteditable]`)){let i=IV(r);if(PV(i))e++;else if(i){let e=String(i.constructor.version||`<0.17.1`);e===n&&(e+=` (separately built, likely a bundler configuration issue)`),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(`, `)}`),r}function ret(){return HB}function $B(e,t,n){let r=t.__type,i=kV(e,r),a=n.get(r);a===void 0&&(a=Array.from(i.transforms),n.set(r,a));let o=a.length;for(let e=0;e<o&&(a[e](t),t.isAttached());e++);}function eV(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function tV(e,t){if(!t)return;let n=e._updateTags,r=t;Array.isArray(t)||(r=[t]);for(let e of r)n.add(e)}function nV(e,t){let n=e.type,r=t.get(n);r===void 0&&OL(17,n);let i=r.klass;e.type!==i.getType()&&OL(18,i.name);let a=i.importJSON(e),o=e.children;if(dV(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=nV(o[e],t);a.append(n)}return a}function rV(e,t,n){let r=VB,i=UB,a=HB;VB=t,UB=!0,HB=e;try{return n()}finally{VB=r,UB=i,HB=a}}function iV(e,t){let n=e._pendingEditorState,r=e._rootElement,i=e._headless||r===null;if(n===null)return;let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=VB,u=UB,d=HB,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){HB=e,VB=n,UB=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=x9e(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),WB)throw t;wV(e,null,r,n),XL(e),e._dirtyType=2,WB=!0,iV(e,a),WB=!1;return}finally{p.observe(r,KB),e._updating=f,VB=l,UB=u,HB=d}}n._readOnly||=!0;let h=e._dirtyLeaves,g=e._dirtyElements,_=e._normalizedNodes,v=e._updateTags,y=e._deferred;c&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements=new Map,e._normalizedNodes=new Set,e._updateTags=new Set),function(e,t){let n=e._decorators,r=e._pendingDecorators||n,i=t._nodeMap,a;for(a in r)i.has(a)||(r===n&&(r=XV(e)),delete r[a])}(e,n);let b=i?null:MH(EH(e));if(e._editable&&b!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){HB=e,VB=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&jH(t,e,r),tet(o,s,e,b,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(_B(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(document.activeElement)){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())AH(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&AH(t)){let n=t.getPreviousSibling();(n===null||AH(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=e.getElementByKey(a.__key);r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=document.createElement(`div`);n.contentEditable=`false`,n.setAttribute(`data-lexical-cursor`,`true`);let r=t.blockCursor;return r!==void 0&&(typeof r==`string`&&(r=t.blockCursor=EU(r)),r!==void 0&&n.classList.add(...r)),n}(e._config)),t.style.caretColor=`transparent`,c===null?n.appendChild(r):n.insertBefore(r,c);return}}r!==null&&jH(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,KB),HB=d,VB=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),_B(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(zR,void 0);let x=e._pendingDecorators;x!==null&&(e._decorators=x,e._pendingDecorators=null,aV(`decorator`,e,!0,x)),function(e,t,n){let r=ZV(t),i=ZV(n);r!==i&&aV(`textcontent`,e,!0,i)}(e,t||a,n),aV(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),function(e,t){if(e._deferred=[],t.length!==0){let n=e._updating;e._updating=!0;try{for(let e=0;e<t.length;e++)t[e]()}finally{e._updating=n}}}(e,y),function(e){let t=e._updates;if(t.length!==0){let n=t.shift();if(n){let[t,r]=n;sV(e,t,r)}}}(e)}function aV(e,t,n,...r){let i=t._updating;t._updating=n;try{let n=Array.from(t._listeners[e]);for(let e=0;e<n.length;e++)n[e].apply(null,r)}finally{t._updating=i}}function oV(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&OL(191),a._flushSync=!0),o&&e._deferred.push(o),tV(e,i.tag)),a==null?sV(e,n,i):n()}}return r}function sV(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,tV(e,n.tag),a=n.skipTransforms||!1,o=n.discrete||!1),i&&e._deferred.push(i);let s=e._editorState,c=e._pendingEditorState,l=!1;(c===null||c._readOnly)&&(c=e._pendingEditorState=_V(c||s),l=!0),c._flushSync=o;let u=VB,d=UB,f=HB,p=e._updating;VB=c,UB=!1,e._updating=!0,HB=e;let m=e._headless||e.getRootElement()===null;OV(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=MH(EH(e));return _B(n)||n==null?AB(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=oV(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(_B(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);cB(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&iR(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=GV(),o=new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=new Set;for(let e of s){let r=i.get(e);cB(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&iR(r),r!==void 0&&eV(r,a)&&$B(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){GB++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map,l.delete(`root`)&&l.set(`root`,!0);for(let e of l){let n=e[0],s=e[1];if(r.set(n,s),!s)continue;let c=i.get(n);c!==void 0&&eV(c,a)&&$B(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,GB++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),oV(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(dV(t)&&WL(t,e,i,a,o,r),i.has(e)||r.delete(e),o.push(e)))}for(let e of o)a.delete(e);for(let e of n){let t=a.get(e);t===void 0||t.isAttached()||(i.has(e)||n.delete(e),a.delete(e))}}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(_B(i)){let e=c._nodeMap,t=i.anchor.key,n=i.focus.key;e.get(t)!==void 0&&e.get(n)!==void 0||OL(19)}else yB(i)&&i._nodes.size===0&&(c._selection=null)}catch(t){t instanceof Error&&e._onError(t),e._pendingEditorState=s,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),iV(e);return}finally{VB=u,UB=d,HB=f,e._updating=p,GB=0}e._dirtyType!==0||e._deferred.length>0||function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(r!==null){if(r.dirty||!r.is(n))return!0}else if(n!==null)return!0;return!1}(c,e)?c._flushSync?(c._flushSync=!1,iV(e)):l&&det(()=>{iV(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function cV(e,t,n){HB===e&&n===void 0?t():sV(e,t,n)}var iet=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&OL(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&OL(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&OL(224),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(LL||PL||NL);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before,i=document.createElement(`br`);if(n.insertBefore(i,r),e){let e=document.createElement(`img`);e.setAttribute(`data-lexical-linebreak`,`true`),e.style.cssText=`display: inline !important; border: 0px !important; margin: 0px !important;`,e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset();return[e,Math.min(t+e.getChildrenSize(),Math.max(t,r))]}let i=lV(t,n);i.push(r);let a=lV(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function lV(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&OL(225),n.reverse()}var uV=class extends Gz{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){return o9e[this.getFormat()]||``}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let e=ZB()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[],t=this.getFirstChild();for(;t!==null;){if(cB(t)&&e.push(t),dV(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;dV(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;dV(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return dV(e)&&e.getLastDescendant()||e||null}let r=t[e];return dV(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:KV(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&OL(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:KV(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&OL(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=``,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),dV(i)&&r!==n-1&&!i.isInline()&&(e+=zL)}return e}getTextContentSize(){let e=0,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),dV(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=HL[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=VL[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return VV(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){JB();let n=jB(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(cB(e)||dV(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(cB(e)||dV(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return _B(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):OB(o,r,o,i,`element`,`element`)}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(e=>e.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e===``?0:HL[e],this}setStyle(e){return this.getWritable().__style=e||``,this}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){Wz(this)&&OL(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||OL(226,String(e),String(t),String(r));let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0)if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&OL(100);let t=e.getNextSibling(),n=e.__key;HV(e.getWritable()),s.push(n),e=t}}let d=l;for(let e of n){d!==null&&e.is(d)&&(l=d=d.getPreviousSibling());let t=e.getWritable();t.__parent===a&&u--,HV(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&OL(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=jB();if(_B(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;fV(r,t,n)&&FB(r,r.getNode(),this,l,c),fV(i,t,n)&&FB(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||DH(this)||this.remove()}}return i}getDOMSlot(e){return new iet(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(NH(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`);let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||DH(this)||this.getChildren().some(cB)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=this.getDOMSlot(e),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function dV(e){return e instanceof uV}function fV(e,t,n){let r=e.getNode();for(;r;){let e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}var pV=class extends Gz{decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function mV(e){return e instanceof pV}var hV=class e extends uV{__cachedText;static getType(){return`root`}static clone(){return new e}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){OL(51)}getTextContent(){let e=this.__cachedText;return!qB()&&ZB()._dirtyType!==0||e===null?super.getTextContent():e}remove(){OL(52)}replace(e){OL(53)}insertBefore(e){OL(54)}insertAfter(e){OL(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)dV(e)||mV(e)||OL(282);return super.splice(e,t,n)}static importJSON(e){return QV().updateFromJSON(e)}collapseAtStart(){return!0}};function gV(e){return e instanceof hV}function _V(e){return new bV(new Map(e._nodeMap))}function vV(){return new bV(new Map([[`root`,new hV]]))}function yV(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&OL(130,n.name),dV(e)){let r=t.children;Array.isArray(r)||OL(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=yV(i[e]);r.push(t)}}return t}function aet(e){return e instanceof bV}var bV=class e{_nodeMap;_selection;_flushSync;_readOnly;constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return rV(t&&t.editor||null,this,e)}clone(t){let n=new e(this._nodeMap,t===void 0?this._selection:t);return n._readOnly=!0,n}toJSON(){return rV(null,this,()=>({root:yV(QV())}))}},oet=class extends uV{static getType(){return`artificial`}createDOM(e){return document.createElement(`div`)}},xV=class e extends uV{static getType(){return`paragraph`}static clone(t){return new e(t.__key)}createDOM(e){let t=document.createElement(`p`),n=hH(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:set,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);if(NH(t)){this.isEmpty()&&t.append(document.createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}static importJSON(e){return SV().updateFromJSON(e)}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(cB);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=SV();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||cB(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function set(e){let t=SV();if(e.style&&(t.setFormat(e.style.textAlign),Tet(e,t)),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in HL&&t.setFormat(n)}return{node:t}}function SV(){return OH(new xV)}function CV(e){return e instanceof xV}function wV(e,t,n,r){let i=e._keyToDOMMap;i.clear(),e._editorState=vV(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,e._updateTags=new Set,e._updates=[],e._blockCursorElement=null;let a=e._observer;a!==null&&(a.disconnect(),e._observer=null),t!==null&&(t.textContent=``),n!==null&&(n.textContent=``,i.set(`root`,n))}function cet(e){let t=new Set,n=new Set,r=e;for(;r;){let{ownNodeConfig:e}=UH(r),i=r.transform;if(!n.has(i)){n.add(i);let e=r.transform();e&&t.add(e)}if(e){let n=e.$transform;n&&t.add(n),r=e.extends}else{let e=Object.getPrototypeOf(r);r=e.prototype instanceof Gz&&e!==Gz?e:void 0}}return t}function TV(e){let t=e||{},n=ret(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=vV(),s=t.namespace||(i===null?iH():i._config.namespace),c=t.editorState,l=[hV,rB,qz,uB,xV,oet,...t.nodes||[]],{onError:u,html:d}=t,f=t.editable===void 0||t.editable,p;if(e===void 0&&n!==null)p=n._nodes;else{p=new Map;for(let e=0;e<l.length;e++){let t=l[e],n=null,r=null;if(typeof t!=`function`){let e=t;t=e.replace,n=e.with,r=e.withKlass||null}UH(t);let i=t.getType(),a=cet(t);p.set(i,{exportDOM:d&&d.export?d.export.get(t):void 0,klass:t,replace:n,replaceWithKlass:r,sharedNodeState:h9e(l[e]),transforms:a})}}let m=new EV(o,i,p,{disableEvents:a,namespace:s,theme:r},u||console.error,function(e,t){let n=new Map,r=new Set,i=e=>{Object.keys(e).forEach(t=>{let r=n.get(t);r===void 0&&(r=[],n.set(t,r)),r.push(e[t])})};return e.forEach(e=>{let t=e.klass.importDOM;if(t==null||r.has(t))return;r.add(t);let n=t.call(e.klass);n!==null&&i(n)}),t&&i(t),n}(p,d?d.import:void 0),f,e);return c!==void 0&&(m._pendingEditorState=c,m._dirtyType=2),function(e){e.registerCommand(BR,L9e,0),e.registerCommand(VR,R9e,0),e.registerCommand(HR,z9e,0),e.registerCommand(UR,B9e,0),e.registerCommand(tz,V9e,0)}(m),m}var EV=class{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(e,t,n,r,i,a,o,s){this._createEditorArgs=s,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=iH(),this._onError=i,this._htmlConversions=a,this._editable=o,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){let t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){let t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){let t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){let t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){let t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&OL(35);let r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(e);i===void 0&&OL(36,String(e));let a=i[n];return a.add(t),()=>{a.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&OL(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=BH(n).get(t.getType());if(!r)return;let i=new Map;for(let e of r.keys())i.set(e,`created`);i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set([`registerMutationListener`])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){let n=BH(e.getEditorState()),r=[];for(let e of t){let t=n.get(e);t&&r.push(t)}r.length!==0&&e.update(()=>{for(let e of r)for(let t of e.keys()){let e=KV(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:Kz}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return yH(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=hH(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,wV(this,t,e,r),t!==null&&(this._config.disableEvents||H9e(t),n!=null&&t.classList.remove(...n)),e!==null){let t=TH(e),r=e.style;r.userSelect=`text`,r.whiteSpace=`pre-wrap`,r.wordBreak=`break-word`,e.setAttribute(`data-lexical-editor`,`true`),this._window=t,this._dirtyType=2,XL(this),this._updateTags.add(Kz),iV(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;bz.set(e,n);let r=xz.get(n)??0;r<1&&n.addEventListener(`selectionchange`,zz),xz.set(n,r+1),e.__lexicalEditor=t;let i=Lz(e);for(let n=0;n<hz.length;n++){let[r,a]=hz[n],o=typeof a==`function`?e=>{Vz(e)||(Bz(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(Vz(e))return;Bz(e);let n=t.isEditable();switch(r){case`cut`:return n&&yH(t,uz,e);case`copy`:return yH(t,lz,e);case`paste`:return n&&yH(t,JR,e);case`dragstart`:return n&&yH(t,cz,e);case`dragover`:return n&&yH(t,A9e,e);case`dragend`:return n&&yH(t,j9e,e);case`focus`:return n&&yH(t,P9e,e);case`blur`:return n&&yH(t,F9e,e);case`drop`:return n&&yH(t,sz,e)}};e.addEventListener(r,o),i.push(()=>{e.removeEventListener(r,o)})}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(Kz),iV(this);aV(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&OL(38);let n=e;n._readOnly&&(n=_V(e),n._selection=e._selection?e._selection.clone():null),YL(this);let r=this._pendingEditorState,i=this._updateTags,a=t===void 0?null:t.tag;r===null||r.isEmpty()||(a!=null&&i.add(a),iV(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,a!=null&&i.add(a),this._updating||iV(this)}parseEditorState(e,t){return function(e,t,n){let r=vV(),i=VB,a=UB,o=HB,s=t._dirtyElements,c=t._dirtyLeaves,l=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=new Map,t._dirtyLeaves=new Set,t._cloneNotNeeded=new Set,t._dirtyType=0,VB=r,UB=!1,HB=t,OV(null);try{let i=t._nodes;nV(e.root,i),n&&n(),r._readOnly=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=s,t._dirtyLeaves=c,t._cloneNotNeeded=l,t._dirtyType=u,VB=i,UB=a,HB=o}return r}(typeof e==`string`?JSON.parse(e):e,this,t)}read(e){return iV(this),this.getEditorState().read(e,{editor:this})}update(e,t){(function(e,t,n){e._updating?e._updates.push([t,n]):sV(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),cV(this,()=>{let r=jB(),i=QV();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||eH(r.clone()),CH(`focus`),_et(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=MH(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,aV(`editable`,this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};EV.version=`0.41.0+prod.esm`;var DV=null;function OV(e){DV=e}var uet=1;function kV(e,t){let n=AV(e,t);return n===void 0&&OL(30,t),n}function AV(e,t){return e._nodes.get(t)}var det=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function jV(e){return mV(YV(e))}function MV(e){let t=document.activeElement;if(!NH(t))return!1;let n=t.nodeName;return mV(YV(e))&&(n===`INPUT`||n===`TEXTAREA`||t.contentEditable===`true`&&IV(t)==null)}function NV(e,t,n){let r=e.getRootElement();try{return r!==null&&r.contains(t)&&r.contains(n)&&t!==null&&!MV(t)&&FV(t)===e}catch{return!1}}function PV(e){return e instanceof EV}function FV(e){let t=e;for(;t!=null;){let e=IV(t);if(PV(e))return e;t=xH(t)}return null}function IV(e){return e?e.__lexicalEditor:null}function LV(e){return fB(e)||e.isToken()}function RV(e){return LV(e)||e.isSegmented()}function zV(e){return PH(e)&&e.nodeType===3}function fet(e){return PH(e)&&e.nodeType===9}function BV(e){let t=e;for(;t!=null;){if(zV(t))return t;t=t.firstChild}return null}function VV(e,t,n){let r=VL[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~VL.superscript:t===`superscript`?i&=~VL.subscript:t===`lowercase`?(i&=~VL.uppercase,i&=~VL.capitalize):t===`uppercase`?(i&=~VL.lowercase,i&=~VL.capitalize):t===`capitalize`&&(i&=~VL.lowercase,i&=~VL.uppercase),i}function pet(e,t){let n=function(){let e=DV;return DV=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);JB(),YB();let r=ZB(),i=XB(),a=``+ uet++;i._nodeMap.set(a,e),dV(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType=1,e.__key=a}function HV(e){let t=e.getParent();if(t!==null){let n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),a=e.getNextSibling(),o=a===null?null:a.__key,s=i===null?null:i.__key,c=i===null?null:i.getWritable(),l=a===null?null:a.getWritable();i===null&&(r.__first=o),a===null&&(r.__last=s),c!==null&&(c.__next=o),l!==null&&(l.__prev=s),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function UV(e){YB(),Wz(e)&&OL(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent,r=XB(),i=ZB(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent}}(n,a,o);let s=t.__key;i._dirtyType=1,dV(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function WV(e){JB();let t=ZB(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=KV(n);e!==null&&e.getWritable()}if(e!==null){let t=KV(e);t!==null&&t.getWritable()}}}function GV(){return qB()?null:ZB()._compositionKey}function KV(e,t){let n=(t||XB())._nodeMap.get(e);return n===void 0?null:n}function qV(e,t){let n=JV(e,ZB());return n===void 0?null:KV(n,t)}function JV(e,t){return e[`__lexicalKey_${t._key}`]}function YV(e,t){let n=e;for(;n!=null;){let e=qV(n,t);if(e!==null)return e;n=xH(n)}return null}function XV(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function ZV(e){return e.read(()=>QV().getTextContent())}function QV(){return $V(XB())}function $V(e){return e._nodeMap.get(`root`)}function eH(e){JB();let t=XB();e!==null&&(e.dirty=!0,e.setCachedNodes(null)),t._selection=e}function tH(e){let t=ZB(),n=function(e,t){let n=e;for(;n!=null;){let e=JV(n,t);if(e!==void 0)return e;n=xH(n)}return null}(e,t);return n===null?e===t.getRootElement()?KV(`root`):null:KV(n)}function nH(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function rH(e){let t=[],n=e;for(;n!==null;)t.push(n),n=n._parentEditor;return t}function iH(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function aH(e){return zV(e)?e.nodeValue:null}function oH(e,t,n){let r=MH(EH(t));if(r===null)return;let i=r.anchorNode,{anchorOffset:a,focusOffset:o}=r;if(i!==null){let t=aH(i),r=YV(i);if(t!==null&&cB(r)){if((t===RL||t===BL)&&n){let e=n.length;t=n,a=e,o=e}t!==null&&sH(r,t,a,o,e)}}}function sH(e,t,n,r,i){let a=e;if(a.isAttached()&&(i||!a.isDirty())){let o=a.isComposing(),s=t;if((o||i)&&(t.endsWith(RL)&&(s=t.slice(0,-RL.length)),i)){let e=BL,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){if(s===``){if(WV(null),NL||PL||LL)a.remove();else{let e=ZB();setTimeout(()=>{e.update(()=>{a.isAttached()&&a.remove()})},20)}return}let t=a.getParent(),i=MB(),c=a.getTextContentSize(),l=GV(),u=a.getKey();if(a.isToken()||l!==null&&u===l&&!o||_B(i)&&(t!==null&&!t.canInsertTextBefore()&&i.anchor.offset===0||i.anchor.key===e.__key&&i.anchor.offset===0&&!a.canInsertTextBefore()&&!o||i.focus.key===e.__key&&i.focus.offset===c&&!a.canInsertTextAfter()&&!o))return void a.markDirty();let d=jB();if(!_B(d)||n===null||r===null)return void cH(a,s,d);if(d.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=sB(a.getTextContent());a.replace(e),a=e}cH(a,s,d)}}}function cH(e,t,n){if(e.setTextContent(t),_B(n)){let t=e.getKey();for(let r of[`anchor`,`focus`]){let i=n[r];i.type===`text`&&i.key===t&&(i.offset=nU(e,i.offset,`clamp`))}}}function lH(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function met(e,t){return lH(e,t,`altKey`)&&lH(e,t,`ctrlKey`)&&lH(e,t,`shiftKey`)&&lH(e,t,`metaKey`)}function uH(e,t,n){if(!met(e,n))return!1;if(e.key.toLowerCase()===t.toLowerCase())return!0;if(t.length>1||e.key.length===1&&e.key.charCodeAt(0)<=127)return!1;let r=`Key`+t.toUpperCase();return e.code===r}var dH={ctrlKey:!AL,metaKey:AL},fH={altKey:AL,ctrlKey:!AL};function pH(e){return e.key===`Backspace`}function mH(e){return uH(e,`a`,dH)}function het(e){let t=QV();if(_B(e)){let t=e.anchor,n=e.focus,r=t.getNode().getTopLevelElementOrThrow().getParentOrThrow();return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),aR(e),e}{let e=t.select(0,t.getChildrenSize());return eH(aR(e)),e}}function hH(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});let n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;let i=e[t];if(typeof i==`string`){let e=EU(i);return n[t]=e,e}return i}function gH(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&OL(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function _H(e,t,n){let r=e.getParent(),i=n,a=e;return r!==null&&(t&&n===0?(i=a.getIndexWithinParent(),a=r):t||n!==a.getChildrenSize()||(i=a.getIndexWithinParent()+1,a=r)),a.getChildAtIndex(t?i-1:i)}function get(e,t){let n=e.offset;if(e.type===`element`)return _H(e.getNode(),t,n);{let r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){let e=t?r.getPreviousSibling():r.getNextSibling();return e===null?_H(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function vH(e){let t=EH(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function yH(e,t,n){return function(e,t,n){let r=rH(e);for(let i=4;i>=0;i--)for(let a=0;a<r.length;a++){let o=r[a],s=o._commands.get(t);if(s!==void 0){let t=s[i];if(t!==void 0){let r=Array.from(t),i=r.length,a=!1;if(cV(o,()=>{for(let t=0;t<i;t++)if(r[t](n,e))return void(a=!0)}),a)return a}}}return!1}(e,t,n)}function bH(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&OL(75,t),n}function xH(e){let t=e.assignedSlot||e.parentElement;return FH(t)?t.host:t}function SH(e){return fet(e)?e:NH(e)?e.ownerDocument:null}function CH(e){JB(),ZB()._updateTags.add(e)}function _et(e){JB(),ZB()._deferred.push(e)}function wH(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function TH(e){let t=SH(e);return t?t.defaultView:null}function EH(e){let t=e._window;return t===null&&OL(78),t}function vet(e){let t=e.getParentOrThrow();for(;t!==null;){if(DH(t))return t;t=t.getParentOrThrow()}return t}function DH(e){return gV(e)||dV(e)&&e.isShadowRoot()}function OH(e){let t=ZB(),n=e.getType(),r=AV(t,n);r===void 0&&OL(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||OL(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||OL(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&OL(203,e.constructor.name,n,r.name,r.getType()),t}return e}function kH(e,t){!gV(e.getParent())||dV(t)||mV(t)||OL(99)}function yet(e){let t=KV(e);return t===null&&OL(63,e),t}function AH(e){return(mV(e)||dV(e)&&!e.canBeEmpty())&&!e.isInline()}function jH(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function MH(e){return kL?(e||window).getSelection():null}function bet(e){let t=TH(e);return t?t.getSelection():null}function NH(e){return PH(e)&&e.nodeType===1}function PH(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function FH(e){return PH(e)&&e.nodeType===11}function xet(e){let t=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,`i`);return e.nodeName.match(t)!==null}function IH(e){let t=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,`i`);return e.nodeName.match(t)!==null}function LH(e){if(mV(e)&&!e.isInline())return!0;if(!dV(e)||DH(e))return!1;let t=e.getFirstChild(),n=t===null||Yz(t)||cB(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function RH(){return ZB()}var zH=new WeakMap,Cet=new Map;function BH(e){if(!e._readOnly&&e.isEmpty())return Cet;e._readOnly||OL(192);let t=zH.get(e);return t||(t=function(e){let t=new Map;for(let[n,r]of e._nodeMap){let e=r.__type,i=t.get(e);i||(i=new Map,t.set(e,i)),i.set(n,r)}return t}(e),zH.set(e,t)),t}function VH(e){let t=e.constructor.clone(e);return t.afterCloneFrom(e),t}function wet(e){return(t=VH(e))[Uz]=!0,t;var t}function Tet(e,t){let n=parseInt(e.style.paddingInlineStart,10)||0,r=Math.round(n/40);t.setIndent(r)}function Eet(e){return!0===e.__lexicalUnmanaged}function HH(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==Gz[t]}function UH(e){let t=UL in e.prototype?e.prototype[UL]():void 0,n=function(e){if(!(e===Gz||e.prototype instanceof Gz)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{EV.version&&(n=JSON.parse(EV.version))}catch{}OL(290,e.name,t,n)}return e===pV||e===uV||e===Gz}(e),r=!n&&HH(e,`getType`)?e.getType():void 0,i,a=r;if(t)if(r)i=t[r];else for(let[e,n]of Object.entries(t))a=e,i=n;if(!n&&a&&(HH(e,`getType`)||(e.getType=()=>a),HH(e,`clone`)||(e.clone=t=>(OV(t),new e)),HH(e,`importJSON`)||(e.importJSON=i&&i.$importJSON||(t=>new e().updateFromJSON(t))),!HH(e,`importDOM`)&&i)){let{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:a}}function Det(e){let t=RH();return JB(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}var WH=(e,t)=>{let n=e;for(;n!=null&&!gV(n);){if(t(n))return n;n=n.getParent()}return null},Oet={next:`previous`,previous:`next`},GH=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return cU({hasNext:QH,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return eU(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return eU(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&OL(263,Array.from(o).join(` `))}else i.insert(e);i=eU(e,this.direction)}for(let e of o.values())e.remove();return this}},KH=class e extends GH{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:iU(e,this.direction)}getParentCaret(e=`root`){return eU(JH(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=qH(this.direction);return eU(this.getNodeAtCaret(),e)||iU(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}},ket={root:gV,shadowRoot:DH};function qH(e){return Oet[e]}function JH(e,t=`root`){return ket[t](e)?null:e}var YH=class e extends GH{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:eU(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return dV(this.origin)?iU(this.origin,this.direction):null}getParentCaret(e=`root`){return eU(JH(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=qH(this.direction);return eU(this.getNodeAtCaret(),e)||iU(this.origin.getParentOrThrow(),e)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof e||t instanceof XH)&&this.direction===t.direction&&this.origin.is(t.origin)}},XH=class e extends GH{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:tU(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return eU(JH(this.getParentAtCaret(),e),this.direction)}getFlipped(){return tU(this.origin,qH(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof YH||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return eU(this.origin,this.direction)}};function ZH(e){return e instanceof XH}function QH(e){return e instanceof YH}function $H(e){return e instanceof KH}var Aet={next:class extends XH{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends XH{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},jet={next:class extends YH{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends YH{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},Met={next:class extends KH{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends KH{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function eU(e,t){return e?new jet[t](e):null}function tU(e,t,n){return e?new Aet[t](e,nU(e,n)):null}function nU(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&q7e(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function rU(e,t){return new Fet(e,t)}function iU(e,t){return dV(e)?new Met[t](e):null}function Net(e){return e&&e.getChildCaret()||e}function aU(e){return e&&Net(e.getAdjacentCaret())}var Pet=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return ZH(t)?function(e,t){let{direction:n,origin:r}=e;return rU(e,nU(r,t===`focus`?qH(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[rU(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=ZH(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=ZH(n),i=t=>t.isSameNodeCaret(n)?null:aU(t)||t.getParentCaret(e);return cU({hasNext:e=>e!==null&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets(`root`)}},Fet=class{type=`slice`;caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){let{distance:e,caret:{offset:t}}=this,n=t+e;return n<t?[n,t]:[t,n]}getTextContent(){let[e,t]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(e,t)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){let{caret:{origin:e,direction:t}}=this,[n,r]=this.getSliceIndices(),i=e.getTextContent();return tU(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function oU(e){return sU(e,eU(QV(),e.direction))}function Iet(e){return sU(e,e)}function sU(e,t){return e.direction!==t.direction&&OL(265),new Pet(e,t,e.direction)}function cU(e){let{initial:t,hasNext:n,step:r,map:i}=e,a=t;return{[Symbol.iterator](){return this},next(){if(!n(a))return{done:!0,value:void 0};let e={done:!1,value:i(a)};return a=r(a),e}}}function lU(e,t){let n=pU(e.origin,t.origin);switch(n===null&&OL(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return uU(n)}}function uU(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function dU(e,t){return t.is(e)}function fU(e){return dV(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function pU(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=new Map;for(let[t,r]=fU(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=fU(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(dU(e,r)||OL(276),{commonAncestor:r,type:`ancestor`}):i===null?(dU(t,r)||OL(277),{commonAncestor:r,type:`descendant`}):((dV(a)||dU(e,a))&&(dV(i)||dU(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||OL(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function mU(e,t){let{type:n,key:r,offset:i}=e,a=yet(e.key);return n===`text`?(cB(a)||OL(266,a.getType(),r),tU(a,t,i)):(dV(a)||OL(267,a.getType(),r),zet(a,e.offset,t))}function hU(e,t){let{origin:n,direction:r}=t,i=r===`next`;ZH(t)?e.set(n.getKey(),t.offset,`text`):QH(t)?cB(n)?e.set(n.getKey(),nU(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):($H(t)&&dV(n)||OL(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function Let(e){let t=jB(),n=_B(t)?t:eet();return gU(n,e),eH(n),n}function gU(e,t){hU(e.anchor,t.anchor),hU(e.focus,t.focus)}function _U(e){let{anchor:t,focus:n}=e,r=mU(t,`next`),i=mU(n,`next`),a=lU(r,i)<=0?`next`:`previous`;return sU(CU(r,a),CU(i,a))}function vU(e){let{direction:t,origin:n}=e,r=eU(n,qH(t)).getNodeAtCaret();return r?eU(r,t):iU(n.getParentOrThrow(),t)}function yU(e,t=`root`){let n=[e];for(let r=$H(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(vU(r));return n}function bU(e){return!!e&&e.origin.isAttached()}function Ret(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=wU(e,r),o=yU(a.anchor,n),s=yU(a.focus.getFlipped(),n),c=new Set,l=[];for(let e of a.iterNodeCarets(n))if($H(e))c.add(e.origin.getKey());else if(QH(e)){let{origin:t}=e;dV(t)&&!c.has(t.getKey())||l.push(t)}for(let e of l)e.remove();for(let e of a.getTextSlices()){if(!e)continue;let{origin:t}=e.caret,n=t.getTextContentSize(),a=vU(eU(t,r)),c=t.getMode();if(Math.abs(e.distance)===n&&i===`removeEmptySlices`||c===`token`&&e.distance!==0)a.remove();else if(e.distance!==0){i=`removeEmptySlices`;let t=e.removeTextSlice(),n=e.caret.origin;if(c===`segmented`){let e=t.origin,n=sB(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=tU(n,r,t.offset)}n.is(o[0].origin)&&(o[0]=t),n.is(s[0].origin)&&(s[0]=t.getFlipped())}}let u,d;for(let e of o)if(bU(e)){u=xU(e);break}for(let e of s)if(bU(e)){d=xU(e);break}let f=function(e,t,n){if(!e||!t)return null;let r=e.getParentAtCaret(),i=t.getParentAtCaret();if(!r||!i)return null;let a=r.getParents().reverse();a.push(r);let o=i.getParents().reverse();o.push(i);let s=Math.min(a.length,o.length),c;for(c=0;c<s&&a[c]===o[c];c++);let l=(e,t)=>{let n;for(let r=c;r<e.length;r++){let i=e[r];if(DH(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,LH),d=u&&l(o,e=>n.has(e.getKey())&&LH(e));return u&&d?[u,d]:null}(u,d,c);if(f){let[e,t]=f;iU(e,`previous`).splice(0,t.getChildren());let n=t.getParent();for(t.remove(!0);n&&n.isEmpty();){let e=n;n=n.getParent(),e.remove(!0)}}let p=[u,d,...o,...s].find(bU);if(p)return Iet(CU(xU(p),e.direction));OL(269,JSON.stringify(o.map(e=>e.origin.__key)))}function xU(e){let t=function(e){let t=e;for(;$H(t);){let e=aU(t);if(!$H(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(cB(t.origin))return ZH(t)?t:tU(t.origin,n,n);let r=t.getAdjacentCaret();return QH(r)&&cB(r.origin)?tU(r.origin,n,qH(n)):t}function SU(e){return ZH(e)&&e.offset!==nU(e.origin,e.direction)}function CU(e,t){return e.direction===t?e:e.getFlipped()}function wU(e,t){return e.direction===t?e:sU(CU(e.focus,t),CU(e.anchor,t))}function zet(e,t,n){let r=iU(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return CU(r,n)}function TU(e){return e}function Bet(e){return e}function Vet(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function EU(...e){let t=[];for(let n of e)if(n&&typeof n==`string`)for(let[e]of n.matchAll(/\S+/g))t.push(e);return t}function Het(e,...t){let n=EU(...t);n.length>0&&e.classList.add(...n)}function DU(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}var OU=(0,z.createContext)(null);function Uet(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function kU(){let e=(0,z.useContext)(OU);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}var AU=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Wet=AU?z.useLayoutEffect:z.useEffect,jU={tag:Kz};function Get({initialConfig:e,children:t}){let n=(0,z.useMemo)(()=>{let{theme:t,namespace:n,nodes:r,onError:i,editorState:a,html:o}=e,s=Uet(null,t),c=TV({editable:e.editable,html:o,namespace:n,nodes:r,onError:e=>i(e,c),theme:t});return function(e,t){if(t!==null){if(t===void 0)e.update(()=>{let t=QV();if(t.isEmpty()){let n=SV();t.append(n);let r=AU?document.activeElement:null;(jB()!==null||r!==null&&r===e.getRootElement())&&n.select()}},jU);else if(t!==null)switch(typeof t){case`string`:{let n=e.parseEditorState(t);e.setEditorState(n,jU);break}case`object`:e.setEditorState(t,jU);break;case`function`:e.update(()=>{QV().isEmpty()&&t(e)},jU)}}}(c,a),[c,s]},[]);return Wet(()=>{let t=e.editable,[r]=n;r.setEditable(t===void 0||t)},[]),(0,B.jsx)(OU.Provider,{value:n,children:t})}var Ket=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function qet(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function Jet(){return function(e){let[t]=kU(),n=(0,z.useMemo)(()=>e(t),[t,e]),[r,i]=(0,z.useState)(()=>n.initialValueFn()),a=(0,z.useRef)(r);return Ket(()=>{let{initialValueFn:e,subscribe:t}=n,r=e();return a.current!==r&&(a.current=r,i(r)),t(e=>{a.current=e,i(e)})},[n,e]),r}(qet)}function MU(e){let t=RH().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function Yet(e){return MU(gV(e)?e:e.getParentOrThrow())}function Xet(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!RV(t)&&r!==null){let[i,a]=r,o=e.isBackward(),s=i.getNode(),c=a.getNode(),l=t.is(s),u=t.is(c);if(l||u){let[r,i]=xB(e),a=s.is(c),l=t.is(o?c:s),u=t.is(o?s:c),d,f=0;a?(f=r>i?i:r,d=r>i?r:i):l?(f=o?i:r,d=void 0):u&&(f=0,d=o?r:i);let p=t.__text.slice(f,d);p!==t.__text&&(n===`clone`&&(t=wet(t)),t.__text=p)}}return t}function NU(e){let t=PU(e);return t!==null&&t.writingMode===`vertical-rl`}function PU(e){let t=e.anchor.getNode();return dV(t)?MU(t):Yet(t)}function FU(e,t){let n=NU(e)?!t:t;IU(e)&&(n=!n);let r=mU(e.focus,n?`previous`:`next`);if(SU(r))return!1;for(let e of oU(r)){if($H(e))return!e.origin.isInline();if(!dV(e.origin)){if(mV(e.origin))return!0;break}}return!1}function Zet(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function IU(e){let t=PU(e);return t!==null&&t.direction===`rtl`}function LU(e,t,n){let r=IU(e),i;i=NU(e)||r?!n:n,Zet(e,t,i,`character`)}var RU=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Qet=RU&&`documentMode`in document?document.documentMode:null;RU&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),RU&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),!(!RU||!(`InputEvent`in window)||Qet)&&`getTargetRanges`in new window.InputEvent(`input`),RU&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),RU&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&window.MSStream,RU&&/Android/.test(navigator.userAgent),RU&&/^(?=.*Chrome).*/i.test(navigator.userAgent),RU&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent);function zU(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}var $et=Symbol.for(`preact-signals`);function BU(){if(WU>1)return void WU--;let e,t=!1;for(;HU!==void 0;){let n=HU;for(HU=void 0,GU++;n!==void 0;){let r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&YU(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(GU=0,WU--,t)throw e}var VU,HU;function UU(e){let t=VU;VU=void 0;try{return e()}finally{VU=t}}var WU=0,GU=0,KU=0;function qU(e){if(VU===void 0)return;let t=e.n;return t===void 0||t.t!==VU?(t={i:0,S:e,p:VU.s,n:void 0,t:VU,e:void 0,x:void 0,r:t},VU.s!==void 0&&(VU.s.n=t),VU.s=t,e.n=t,32&VU.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=VU.s,t.n=void 0,VU.s.n=t,VU.s=t),t):void 0}function JU(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function YU(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function XU(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ZU(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function QU(e,t){JU.call(this,void 0),this.x=e,this.s=void 0,this.g=KU-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function $U(e){let t=e.u;if(e.u=void 0,typeof t==`function`){WU++;let n=VU;VU=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,eW(e),t}finally{VU=n,BU()}}}function eW(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,$U(e)}function ett(e){if(VU!==this)throw Error(`Out-of-order effect`);ZU(this),VU=e,this.f&=-2,8&this.f&&eW(this),BU()}function tW(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}function ttt(e,t){let n=new tW(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}JU.prototype.brand=$et,JU.prototype.h=function(){return!0},JU.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?UU(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},JU.prototype.U=function(e){if(this.t!==void 0){let t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&UU(()=>{var e;(e=this.Z)==null||e.call(this)}))}},JU.prototype.subscribe=function(e){return ttt(()=>{let t=this.value,n=VU;VU=void 0;try{e(t)}finally{VU=n}},{name:`sub`})},JU.prototype.valueOf=function(){return this.value},JU.prototype.toString=function(){return this.value+``},JU.prototype.toJSON=function(){return this.value},JU.prototype.peek=function(){let e=VU;VU=void 0;try{return this.value}finally{VU=e}},Object.defineProperty(JU.prototype,`value`,{get(){let e=qU(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(GU>100)throw Error(`Cycle detected`);this.v=e,this.i++,KU++,WU++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{BU()}}}}),QU.prototype=new JU,QU.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===KU))return!0;if(this.g=KU,this.f|=1,this.i>0&&!YU(this))return this.f&=-2,!0;let e=VU;try{XU(this),VU=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return VU=e,ZU(this),this.f&=-2,!0},QU.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}JU.prototype.S.call(this,e)},QU.prototype.U=function(e){if(this.t!==void 0&&(JU.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}},QU.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(QU.prototype,`value`,{get(){if(1&this.f)throw Error(`Cycle detected`);let e=qU(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),tW.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e==`function`&&(this.u=e)}finally{e()}},tW.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,$U(this),XU(this),WU++;let e=VU;return VU=this,ett.bind(this,e)},tW.prototype.N=function(){2&this.f||(this.f|=2,this.o=HU,HU=this)},tW.prototype.d=function(){this.f|=8,1&this.f||eW(this)},tW.prototype.dispose=function(){this.d()};function ntt(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}m9e(`format`,{parse:e=>typeof e==`number`?e:0});function nW(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function rW(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)n[e]=rW(n[e],r[e]);return e}return t}var iW=0,aW=1,oW=2,sW=3,cW=4,lW=5,uW=6,dW=7;function fW(e){return e.id===iW}function pW(e){return e.id===oW}function rtt(e){return function(e){return e.id===aW}(e)||nW(305,String(e.id),String(aW)),Object.assign(e,{id:oW})}var itt=new Set,att=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:iW}}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):Vet;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;pW(t)||nW(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=function(e,t,n){return Object.assign(e,{config:t,id:sW,registerState:n})}(t,this.mergeConfigs(),n),a;this.state=i,this.extension.init&&(a=this.extension.init(e,i.config,n)),this.state=function(e,t,n){return Object.assign(e,{id:cW,initResult:t,registerState:n})}(i,a,r)}build(e){let t=this.state,n;t.id!==cW&&nW(307,String(t.id),String(lW)),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(e,t,n){return Object.assign(e,{id:lW,output:t,registerState:n})}(t,n,r)}register(e,t){this._signal=t;let n=this.state;n.id!==lW&&nW(308,String(n.id),String(lW));let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=function(e){return Object.assign(e,{id:uW})}(n),()=>{let e=this.state;e.id!==dW&&nW(309,String(n.id),String(dW)),this.state=function(e){return Object.assign(e,{id:lW})}(e),r&&r()}}afterRegistration(e){let t=this.state,n;return t.id!==uW&&nW(310,String(t.id),String(uW)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=function(e){return Object.assign(e,{id:dW})}(t),n}getSignal(){return this._signal===void 0&&nW(311),this._signal}getInitResult(){this.extension.init===void 0&&nW(312,this.extension.name);let e=this.state;return function(e){return e.id>=cW}(e)||nW(313,String(e.id),String(cW)),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return function(e){return e.id>=sW}(e)||nW(314,String(e.id),String(sW)),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&nW(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&nW(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=dW}(e)||nW(316,String(e.id),String(dW)),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||itt}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;(function(e){return e.id>=lW})(e)||nW(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}},mW={tag:Kz};function ott(){let e=QV();e.isEmpty()&&e.append(SV())}var stt=TU({config:Bet({setOptions:mW,updateOptions:mW}),init:({$initialEditorState:e=ott})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){let i=r.getInitResult();if(!i.initialized){i.initialized=!0;let{$initialEditorState:r}=i;if(aet(r))e.setEditorState(r,n);else if(typeof r==`function`)e.update(()=>{r(e)},t);else if(r&&(typeof r==`string`||typeof r==`object`)){let t=e.parseEditorState(r);e.setEditorState(t,n)}}return()=>{}},name:`@lexical/extension/InitialState`,nodes:[hV,rB,qz,uB,xV]}),hW=Symbol.for(`@lexical/extension/LexicalBuilder`);function gW(){}function ctt(e){throw e}function _W(e){return Array.isArray(e)?e:[e]}var vW=`0.41.0+prod.esm`,ltt=class e{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=vW,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[_W(stt)];for(let e of t)n.push(_W(e));return new e(n)}static maybeFromEditor(t){let n=t[hW];return n&&(n.PACKAGE_VERSION!==vW&&nW(292,n.PACKAGE_VERSION,vW),n instanceof e||nW(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&nW(294),n}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(TV({...n,...t?{onError:e=>{t(e,r)}}:{}}),{[hW]:this});for(let e of this.sortedExtensionReps())e.build(r);return r}buildEditor(){let e=gW;function t(){try{e()}finally{e=gW}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=DU(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&nW(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]))}addExtension(e){this._sortedExtensionReps!==void 0&&nW(296);let[t]=_W(e);typeof t.name!=`string`&&nW(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&nW(298,t.name),!n){n=new att(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&nW(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&nW(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=_W(e);this.addEdge(t.name,n[0].name,n.slice(1)),this.addExtension(n)}for(let[e,n]of t.peerDependencies||[])this.addEdge(t.name,e,n?[n]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(pW(i))return;let a=n.extension.name;var o;fW(i)||nW(300,a,r||`[unknown]`),fW(o=i)||nW(304,String(o.id),String(iW)),i=Object.assign(o,{id:aW}),n.state=i;let s=this.outgoingConfigEdges.get(a);if(s)for(let e of s.keys()){let n=this.extensionNameMap.get(e);n&&t(n,a)}i=rtt(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())fW(e.state)&&t(e);for(let t of e)for(let[e,n]of this.outgoingConfigEdges.get(t.extension.name)||[])if(n.length>0){let t=this.extensionNameMap.get(e);if(t)for(let e of n)t.configs.add(e)}for(let[e,...t]of this.roots)if(t.length>0){let n=this.extensionNameMap.get(e.name);n===void 0&&nW(301,e.name);for(let e of t)n.configs.add(e)}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let n of t){let t=n.register(e,i);t&&r.push(t)}for(let n of t){let t=n.afterRegistration(e);t&&r.push(t)}return DU(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},a={},o=this.sortedExtensionReps();for(let s of o){let{extension:o}=s;if(o.onError!==void 0&&(e.onError=o.onError),o.disableEvents!==void 0&&(e.disableEvents=o.disableEvents),o.parentEditor!==void 0&&(e.parentEditor=o.parentEditor),o.editable!==void 0&&(e.editable=o.editable),o.namespace!==void 0&&(e.namespace=o.namespace),o.$initialEditorState!==void 0&&(e.$initialEditorState=o.$initialEditorState),o.nodes)for(let e of ntt(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&nW(302,o.name,e.replace.name,t.extension.name),n.set(e.replace,s)}t.add(e)}if(o.html){if(o.html.export)for(let[e,t]of o.html.export.entries())r.set(e,t);o.html.import&&Object.assign(i,o.html.import)}o.theme&&rW(a,o.theme)}Object.keys(a).length>0&&(e.theme=a),t.size&&(e.nodes=[...t]);let s=Object.keys(i).length>0,c=r.size>0;(s||c)&&(e.html={},s&&(e.html.import=i),c&&(e.html.export=r));for(let t of o)t.init(e);return e.onError||=ctt,e}},utt=class e extends pV{static getType(){return`horizontalrule`}static clone(t){return new e(t.__key)}static importJSON(e){return yW().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:dtt,priority:0})}}exportDOM(){return{element:document.createElement(`hr`)}}createDOM(e){let t=document.createElement(`hr`);return Het(t,e.theme.hr),t}getTextContent(){return`
|
|
322
|
-
`}isInline(){return!1}updateDOM(){return!1}};function dtt(){return{node:yW()}}function yW(){return Det(utt)}var ftt=TU({name:`@lexical/react/ReactProvider`});function ptt(){return QV().getTextContent()}function mtt(e,t=!0){if(e)return!1;let n=ptt();return t&&(n=n.trim()),n===``}function htt(e){if(!mtt(e,!1))return!1;let t=QV().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(mV(n))return!1;if(dV(n)){if(!CV(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!cB(n))return!1}}}return!0}function bW(e){return()=>htt(e)}function gtt(e){let t=window.location.origin,n=n=>{if(n.origin!==t)return;let r=e.getRootElement();if(document.activeElement!==r)return;let i=n.data;if(typeof i==`string`){let t;try{t=JSON.parse(i)}catch{return}if(t&&t.protocol===`nuanria_messaging`&&t.type===`request`){let r=t.payload;if(r&&r.functionId===`makeChanges`){let t=r.args;if(t){let[r,i,a,o,s]=t;e.update(()=>{let e=jB();if(_B(e)){let t=e.anchor,c=t.getNode(),l=0,u=0;if(cB(c)&&r>=0&&i>=0&&(l=r,u=r+i,e.setTextNodeRange(c,l,c,u)),l===u&&a===``||(e.insertRawText(a),c=t.getNode()),cB(c)){l=o,u=o+s;let t=c.getTextContentSize();l=l>t?t:l,u=u>t?t:u,e.setTextNodeRange(c,l,c,u)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener(`message`,n,!0),()=>{window.removeEventListener(`message`,n,!0)}}function _tt(e,t){if(typeof document>`u`||typeof window>`u`&&global.window===void 0)throw Error(`To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.`);let n=document.createElement(`div`),r=QV().getChildren();for(let i=0;i<r.length;i++)xW(e,r[i],n,t);return n.innerHTML}function xW(e,t,n,r=null){let i=r===null||t.isSelected(r),a=dV(t)&&t.excludeFromCopy(`html`),o=t;r!==null&&cB(t)&&(o=Xet(r,t,`clone`));let s=dV(o)?o.getChildren():[],c=AV(e,o.getType()),l;l=c&&c.exportDOM!==void 0?c.exportDOM(e,o):o.exportDOM(e);let{element:u,after:d}=l;if(!u)return!1;let f=document.createDocumentFragment();for(let n=0;n<s.length;n++){let a=s[n],o=xW(e,a,f,r);!i&&dV(t)&&o&&t.extractWithChild(a,r,`html`)&&(i=!0)}if(i&&!a){if((NH(u)||FH(u))&&u.append(f),n.append(u),d){let e=d.call(o,u);e&&(FH(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(f);return i}function vtt(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ytt(e,t=jB()){return t??vtt(166),_B(t)&&t.isCollapsed()||t.getNodes().length===0?``:_tt(e,t)}function SW(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var CW=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,btt=CW&&`documentMode`in document?document.documentMode:null,xtt=CW&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Stt=!(!CW||!(`InputEvent`in window)||btt)&&`getTargetRanges`in new window.InputEvent(`input`),Ctt=CW&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),wW=CW&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,wtt=CW&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ttt=CW&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&xtt&&!wtt;function TW(e,t){t.update(()=>{if(e!==null){let n=zU(e,KeyboardEvent)?null:e.clipboardData,r=jB();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=ytt(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function Ett(e){return DU(e.registerCommand(WR,e=>{let t=jB();return!!_B(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(XR,e=>{let t=jB();return!!_B(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(ZR,e=>{let t=jB();return!!_B(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(qR,e=>{let t=jB();if(!_B(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)SW(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(YR,()=>{let e=jB();return!!_B(e)&&(e.removeText(),!0)},0),e.registerCommand(GR,e=>{let t=jB();return!!_B(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(KR,()=>{let e=jB();return!!_B(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(rz,e=>{let t=jB();if(!_B(t))return!1;let n=e,r=n.shiftKey;return!!FU(t,!0)&&(n.preventDefault(),LU(t,r,!0),!0)},0),e.registerCommand(nz,e=>{let t=jB();if(!_B(t))return!1;let n=e,r=n.shiftKey;return!!FU(t,!1)&&(n.preventDefault(),LU(t,r,!1),!0)},0),e.registerCommand(az,t=>!!_B(jB())&&(!wW||navigator.language!==`ko-KR`)&&(t.preventDefault(),e.dispatchCommand(WR,!0)),0),e.registerCommand(oz,t=>!!_B(jB())&&(t.preventDefault(),e.dispatchCommand(WR,!1)),0),e.registerCommand(iz,t=>{if(!_B(jB()))return!1;if(t!==null){if((wW||Ctt||Ttt)&&Stt)return!1;t.preventDefault()}return e.dispatchCommand(GR,!1)},0),e.registerCommand(dz,()=>(het(),!0),0),e.registerCommand(lz,t=>!!_B(jB())&&(TW(t,e),!0),0),e.registerCommand(uz,t=>!!_B(jB())&&(function(e,t){TW(e,t),t.update(()=>{let e=jB();_B(e)&&e.removeText()})}(t,e),!0),0),e.registerCommand(JR,t=>!!_B(jB())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=jB(),n=zU(e,ClipboardEvent)?e.clipboardData:null;n!=null&&_B(t)&&SW(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(sz,e=>!!_B(jB())&&(e.preventDefault(),!0),0),e.registerCommand(cz,e=>!!_B(jB())&&(e.preventDefault(),!0),0))}function Dtt(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var EW=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function Ott({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,z.useState)(()=>e.getDecorators());return EW(()=>e.registerDecoratorListener(e=>{(0,pl.flushSync)(()=>{r(e)})}),[e]),(0,z.useEffect)(()=>{r(e.getDecorators())},[e]),(0,z.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,B.jsx)(t,{onError:t=>e._onError(t),children:(0,B.jsx)(z.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,pl.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function ktt({editor:e,ErrorBoundary:t}){return function(e){let t=ltt.maybeFromEditor(e);if(t&&t.hasExtensionByName(ftt.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&Dtt(320,e);return!0}return!1}(e)?null:(0,B.jsx)(Ott,{editor:e,ErrorBoundary:t})}function DW(e){return e.getEditorState().read(bW(e.isComposing()))}function Att({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=kU();return function(e){EW(()=>DU(Ett(e),gtt(e)),[e])}(r),(0,B.jsxs)(B.Fragment,{children:[e,(0,B.jsx)(jtt,{content:t}),(0,B.jsx)(ktt,{editor:r,ErrorBoundary:n})]})}function jtt({content:e}){let[t]=kU(),n=function(e){let[t,n]=(0,z.useState)(()=>DW(e));return EW(()=>{function t(){n(DW(e))}return t(),DU(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=Jet();return n?typeof e==`function`?e(r):e:null}var OW=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function Mtt({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,z.useState)(e.isEditable()),T=(0,z.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,z.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return OW(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,B.jsx)(`div`,{"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":C&&g===`combobox`?!!o:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y,...x})}var Ntt=(0,z.forwardRef)(Mtt);function kW(e){return e.getEditorState().read(bW(e.isComposing()))}var Ptt=(0,z.forwardRef)(Ftt);function Ftt(e,t){let{placeholder:n,...r}=e,[i]=kU();return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ntt,{editor:i,...r,ref:t}),n!=null&&(0,B.jsx)(Itt,{editor:i,content:n})]})}function Itt({content:e,editor:t}){let n=function(e){let[t,n]=(0,z.useState)(()=>kW(e));return OW(()=>{function t(){n(kW(e))}return t(),DU(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,z.useState)(t.isEditable());if((0,z.useLayoutEffect)(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,B.jsx)(`div`,{"aria-hidden":!0,children:a})}function Ltt(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(_B(a)&&_B(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||gV(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&cB(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!cB(l)||!cB(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function Rtt(e,t){let n=Date.now(),r=0,i=Date.now(),a=0,o=null;return(s,c,l,u,d,f)=>{let p=Date.now();if(f.has(`composition-start`)&&(i=n,a=r,o=s),f.has(`historic`))return r=0,n=p,2;f.has(`composition-end`)&&o&&(n=i,r=a,s=o);let m=Ltt(s,c,u,d,e.isComposing()),h=(()=>{let i=l===null||l.editor===e,a=f.has(U9e);if(!a&&i&&f.has(`history-merge`))return 0;if(m===1)return 2;if(s===null)return 1;let o=c._selection;if(!(u.size>0||d.size>0))return o===null?2:0;let h=typeof t==`number`?t:t.peek();return!1===a&&m!==0&&m===r&&p<n+h&&i||u.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(_B(a)&&_B(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!cB(r)||!cB(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(u)[0],s,c)?0:1})();return n=p,r=m,h}}function AW(e){e.undoStack=[],e.redoStack=[],e.current=null}function ztt(e,t,n){let r=Rtt(e,n);return DU(e.registerCommand($R,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(r.length!==0){let i=t.current,a=r.pop();i!==null&&(n.push(i),e.dispatchCommand(fz,!0)),r.length===0&&e.dispatchCommand(pz,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(ez,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(n.length!==0){let i=t.current;i!==null&&(r.push(i),e.dispatchCommand(pz,!0));let a=n.pop();n.length===0&&e.dispatchCommand(fz,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(M9e,()=>(AW(t),!1),0),e.registerCommand(N9e,()=>(AW(t),e.dispatchCommand(fz,!1),e.dispatchCommand(pz,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:i,dirtyLeaves:a,dirtyElements:o,tags:s})=>{let c=t.current,l=t.redoStack,u=t.undoStack,d=c===null?null:c.editorState;if(c!==null&&n===d)return;let f=r(i,n,c,a,o,s);if(f===1)l.length!==0&&(t.redoStack=[],e.dispatchCommand(fz,!1)),c!==null&&(u.push({...c}),e.dispatchCommand(pz,!0));else if(f===2)return;t.current={editor:e,editorState:n}}))}function Btt(){return{current:null,redoStack:[],undoStack:[]}}function Vtt({delay:e,externalHistoryState:t}){let[n]=kU();return function(e,t,n=1e3){let r=(0,z.useMemo)(()=>t||Btt(),[t]);(0,z.useEffect)(()=>ztt(e,r,n),[n,e,r])}(n,t,e),null}var Htt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function Utt({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){let[r]=kU();return Htt(()=>{if(n)return r.registerUpdateListener(({editorState:i,dirtyElements:a,dirtyLeaves:o,prevEditorState:s,tags:c})=>{t&&a.size===0&&o.size===0||e&&c.has(`history-merge`)||s.isEmpty()||n(i,r,c)})},[r,e,t,n]),null}var Wtt=[{id:`handoff`,label:`/handoff`,description:`Open the handoff dialog for this conversation (trailing text becomes focus)`,insert:`/handoff `,category:`Conversation`}],Gtt=cCe.map(e=>{let t=e.path.join(` `);return{id:e.id,label:e.display,description:e.description,insert:lCe[t]??`${e.display}${e.args.length>0?` `:``}`,category:`Overdeck`}}),Ktt=uCe.map(e=>({id:e.id,label:e.display,description:e.description,insert:e.insert,category:`Overdeck`}));function jW(e){let t=tb(e);return[...(t.nativeCommands??[]).map(n=>({id:`native-${e}-${n.name.slice(1)}`,label:n.name,description:n.description,insert:n.insert,category:`${t.displayName} native`})),...Wtt,...Gtt,...Ktt]}jW(`claude-code`);function MW(e){return`conv-draft:${e}`}function NW(e){try{return localStorage.getItem(MW(e))??``}catch{return``}}function PW(e,t){try{t?localStorage.setItem(MW(e),t):localStorage.removeItem(MW(e))}catch{}}function qtt({conversationName:e,onCommandKeyDown:t,onTextChange:n,onSlashKey:r}){let[i]=kU(),a=(0,z.useRef)(null),o=(0,z.useRef)(NW(e)),s=(0,z.useRef)(!1);return(0,z.useEffect)(()=>i.registerCommand(iz,e=>e?.shiftKey?!1:(e?.preventDefault(),t(`Enter`),!0),3),[i,t]),(0,z.useEffect)(()=>{let e=i.getRootElement();if(!e)return;let t=t=>{if(t.key===`/`&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let n=t.target;(n===e||e.contains(n))&&r(e)}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,r]),(0,z.useEffect)(()=>(s.current=!1,()=>{s.current=!0,a.current&&clearTimeout(a.current),PW(e,o.current)}),[e]),(0,z.useEffect)(()=>{let t=()=>PW(e,o.current),n=()=>{document.visibilityState===`hidden`&&t()};return window.addEventListener(`pagehide`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`pagehide`,t),document.removeEventListener(`visibilitychange`,n)}},[e]),(0,B.jsx)(Utt,{onChange:(0,z.useCallback)(()=>{s.current||i.read(()=>{let t=QV().getTextContent();o.current=t,n(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{PW(e,t)},300)})},[i,e,n])})}function Jtt({editorRef:e}){let[t]=kU();return(0,z.useEffect)(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}var Ytt=[`overdeck`,`ovr`];function FW(e,t){let n=t.toLowerCase(),r=Ytt.find(e=>n===e||n.startsWith(`${e} `)),i=r?`pan${n.slice(r.length)}`:null;return e.filter(e=>{let t=`${e.label} ${e.description}`.toLowerCase();return t.includes(n)||i!==null&&t.includes(i)})}function IW(e,t,n){if(!t)return e;let r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);if(a<0)return e;let o=a+t.length;return(0,B.jsxs)(B.Fragment,{children:[e.slice(0,a),(0,B.jsx)(`mark`,{className:n,children:e.slice(a,o)}),e.slice(o)]})}function Xtt({commands:e,filter:t,selectedIndex:n,onSelect:r,onClose:i,anchorRect:a}){let o=FW(e,t),s=(0,z.useRef)(null);if((0,z.useEffect)(()=>{let e=e=>{e.target.closest(`.${Z.slashMenu}`)||i()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),(0,z.useEffect)(()=>{if(s.current){let e=s.current.querySelector(`[aria-selected="true"]`);e&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`nearest`})}},[n]),o.length===0)return null;let c=a?a.left:0,l=a?window.innerHeight-a.top+4:0,u=o.reduce((e,t)=>{let n=t.category||`Commands`;return e[n]||(e[n]=[]),e[n].push(t),e},{}),d=Object.keys(u);return(0,B.jsx)(`div`,{ref:s,className:Z.slashMenu,style:{bottom:l,left:c},role:`listbox`,"aria-label":`Slash commands`,children:d.map(e=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-gray-500 px-3 py-1.5`,children:e}),u[e].map(e=>{let i=o.findIndex(t=>t.id===e.id),a=t?e.label.toLowerCase().includes(t.toLowerCase()):!1;return(0,B.jsxs)(`button`,{className:`${Z.slashMenuItem} ${i===n?Z.slashMenuItemSelected:``}`,onClick:()=>r(e),role:`option`,"aria-selected":i===n,children:[(0,B.jsx)(`span`,{className:Z.slashMenuLabel,children:a?IW(e.label,t,Z.slashMenuMatch):e.label}),(0,B.jsx)(`span`,{className:Z.slashMenuDescription,children:a?e.description:IW(e.description,t,Z.slashMenuMatch)})]},e.id)})]},e))})}function Ztt({conversationName:e,harness:t=`claude-code`,disabled:n=!1,placeholder:r=`Message the agent…`,onCommandKeyDown:i,editorRef:a,onChange:o,onPaste:s}){let c=NW(e),[l,u]=(0,z.useState)(c),[d,f]=(0,z.useState)(!1),p=(0,z.useRef)(!1),[m,h]=(0,z.useState)(0),[g,_]=(0,z.useState)(null),v={namespace:`composer:${e}`,onError:e=>console.error(`[ComposerPromptEditor]`,e),...c?{editorState:e=>{let t=QV(),n=SV();n.append(sB(c)),t.append(n)}}:{}},y=(0,z.useCallback)(e=>{u(e),p.current&&e.includes(`/`)&&(f(!0),p.current=!1),o?.(e)},[o]),b=(0,z.useMemo)(()=>{let e=l.lastIndexOf(`/`);return e<0?null:{slashIdx:e,filterText:l.slice(e+1)}},[l]),x=(0,z.useMemo)(()=>jW(t),[t]),S=(0,z.useMemo)(()=>FW(x,b?.filterText??``),[x,b]),C=(0,z.useCallback)(e=>{let t=window.getSelection(),n=null;if(t&&t.rangeCount>0){let e=t.getRangeAt(0).getBoundingClientRect();(e.width>0||e.height>0||e.top>0||e.left>0||e.bottom>0)&&(n=e)}n||=e.getBoundingClientRect(),_(n),p.current=!0,f(!0),h(0)},[]),w=(0,z.useCallback)(e=>{let t=a?.current;t&&t.update(()=>{let t=QV(),n=t.getTextContent(),r=b?.slashIdx??n.lastIndexOf(`/`),i=r>=0?n.slice(0,r):n;t.clear();let a=SV();a.append(sB(i+e.insert)),t.append(a)}),f(!1),p.current=!1,h(0)},[a,b]),T=(0,z.useCallback)(()=>{f(!1),p.current=!1,h(0)},[]);return(0,z.useEffect)(()=>{d&&!p.current&&!b&&T()},[d,b,T]),(0,z.useEffect)(()=>{h(0)},[b?.filterText]),(0,z.useEffect)(()=>{if(!d||!b)return;let e=e=>{e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),S.length>0&&h(e=>(e+1)%S.length)):e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),S.length>0&&h(e=>(e-1+S.length)%S.length)):e.key===`Enter`?S.length>0&&S[m]&&(e.preventDefault(),e.stopPropagation(),w(S[m])):e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),T()):e.key===`Tab`&&T()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[d,b,m,S,w,T]),(0,B.jsxs)(`div`,{style:{position:`relative`},children:[(0,B.jsx)(Get,{initialConfig:v,children:(0,B.jsxs)(`div`,{className:`${Z.composerEditor} ${n?Z.composerEditorDisabled:``}`,children:[(0,B.jsx)(Att,{contentEditable:(0,B.jsx)(Ptt,{className:Z.composerEditable,onPaste:s,"aria-placeholder":r,placeholder:()=>l?null:(0,B.jsx)(`div`,{className:Z.composerPlaceholder,children:r})}),ErrorBoundary:({children:e})=>(0,B.jsx)(B.Fragment,{children:e})}),(0,B.jsx)(Vtt,{}),(0,B.jsx)(qtt,{conversationName:e,onCommandKeyDown:i,onTextChange:y,onSlashKey:C}),a&&(0,B.jsx)(Jtt,{editorRef:a})]})},e),d&&S.length>0&&(0,B.jsx)(Xtt,{commands:x,filter:b?.filterText??``,selectedIndex:m,onSelect:w,onClose:T,anchorRect:g})]})}var Qtt=25e4,$tt=6e3;function ent(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function tnt({onCommitted:e}={}){let[t,n]=(0,z.useState)(``),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),d=(0,z.useRef)(null),f=(0,z.useRef)(null),p=(0,z.useRef)(null),m=(0,z.useRef)(null),h=(0,z.useRef)(null),g=(0,z.useRef)(null),_=(0,z.useRef)(``),v=(0,z.useRef)(null),y=(0,z.useCallback)(e=>{o(!1),e&&d.current?.close(),e&&(d.current=null),h.current?.disconnect(),m.current?.disconnect(),g.current?.disconnect(),p.current?.close(),f.current?.getTracks().forEach(e=>e.stop()),h.current=null,m.current=null,g.current=null,p.current=null,f.current=null,u(null)},[]),b=(0,z.useCallback)(async(e=!0)=>{let t=d.current;return y(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,$tt);v.current=()=>{window.clearTimeout(t),e()}}),v.current=null),y(!0),_.current},[y]),x=(0,z.useCallback)(async t=>{if(!a){c(null);try{let r=await navigator.mediaDevices.getUserMedia({audio:t?{deviceId:{exact:t}}:!0}),a=new AudioContext({sampleRate:16e3}),s=a.createMediaStreamSource(r),l=a.createAnalyser(),y=a.createScriptProcessor(4096,1,1),x=new WebSocket(ent(`/ws/voice`));x.binaryType=`arraybuffer`,x.onmessage=t=>{let r=JSON.parse(String(t.data));if(r.type===`transcript:partial`&&n(r.text),r.type===`transcript:committed`){n(``);let t=[_.current,r.text].filter(Boolean).join(` `);_.current=t,i(t),e?.(r.text)}r.type===`transcript:finalized`&&v.current?.(),r.type===`error`&&c(r.error)},x.onerror=()=>c(`Voice connection failed`),x.onclose=()=>{d.current===x&&b(!1)},y.onaudioprocess=e=>{if(x.readyState!==WebSocket.OPEN||x.bufferedAmount>Qtt)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}x.send(n.buffer)},s.connect(l),l.connect(y),y.connect(a.destination),d.current=x,f.current=r,p.current=a,m.current=s,g.current=l,h.current=y,u(l),o(!0)}catch(e){c(e instanceof Error?e.message:`Unable to start voice input`),b()}}},[a,e,b]),S=(0,z.useCallback)(()=>{n(``),i(``),_.current=``},[]);return(0,z.useEffect)(()=>()=>{b(!1)},[b]),{start:x,stop:b,partialText:t,committedText:r,isListening:a,error:s,analyserNode:l,resetTranscript:S}}function nnt({conversation:e,onInsert:t,onSendDirect:n,onStateChange:r,autoStartToken:i=0}){let[a,o]=(0,z.useState)(`edit`),[s,c]=(0,z.useState)([]),[l,u]=(0,z.useState)(``),d=(0,z.useRef)(null),f=(0,z.useRef)(a),{start:p,stop:m,partialText:h,committedText:g,isListening:_,error:v,analyserNode:y,resetTranscript:b}=tnt({onCommitted:e=>{f.current===`direct`&&n(e)}}),x=[g,h].filter(Boolean).join(` `);(0,z.useEffect)(()=>{f.current=a},[a]),(0,z.useEffect)(()=>(r?.({isListening:_,error:v}),()=>r?.({isListening:!1,error:null})),[v,_,r]),(0,z.useEffect)(()=>{i<=0||_||p(l||void 0)},[i,l,_,p]),(0,z.useEffect)(()=>{navigator.mediaDevices?.enumerateDevices?.().then(e=>{c(e.filter(e=>e.kind===`audioinput`))})},[]),(0,z.useEffect)(()=>{let e=d.current,t=y;if(!e||!t||!_)return;let n=e.getContext(`2d`);if(!n)return;let r=new Uint8Array(t.frequencyBinCount),i=0,a=()=>{i=window.requestAnimationFrame(a),t.getByteTimeDomainData(r),n.clearRect(0,0,e.width,e.height),n.strokeStyle=`hsl(210 100% 62%)`,n.lineWidth=2,n.beginPath(),r.forEach((t,i)=>{let a=i/Math.max(1,r.length-1)*e.width,o=t/255*e.height;i===0?n.moveTo(a,o):n.lineTo(a,o)}),n.stroke()};return a(),()=>window.cancelAnimationFrame(i)},[y,_]);let S=(0,z.useCallback)(()=>{(async()=>{let e=(await m()).trim();a===`edit`&&e&&t(e),b()})()},[a,t,b,m]),C=(0,z.useCallback)(()=>{m(!1),b()},[b,m]);return(0,B.jsxs)(`div`,{className:Z.voiceWidget,"data-testid":`voice-widget`,children:[(0,B.jsxs)(`div`,{className:Z.voiceWidgetHeader,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:Z.voiceWidgetTitle,children:`Voice input`}),(0,B.jsx)(`div`,{className:Z.voiceWidgetMeta,children:e.name})]}),(0,B.jsxs)(`div`,{className:Z.voiceModeToggle,role:`group`,"aria-label":`Voice send mode`,children:[(0,B.jsx)(`button`,{type:`button`,className:a===`edit`?Z.voiceModeActive:Z.voiceModeButton,onClick:()=>o(`edit`),title:`Transcript fills the composer so you can review and edit before sending`,children:`Edit`}),(0,B.jsx)(`button`,{type:`button`,className:a===`direct`?Z.voiceModeActive:Z.voiceModeButton,onClick:()=>o(`direct`),title:`Each finished sentence is sent to the agent immediately`,children:`Direct`})]})]}),(0,B.jsx)(`div`,{className:Z.voiceWidgetControls,children:(0,B.jsxs)(`label`,{className:Z.voiceFieldLabel,children:[`Mic`,(0,B.jsxs)(`select`,{className:Z.voiceSelect,value:l,onChange:e=>u(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Default microphone`}),s.map((e,t)=>(0,B.jsx)(`option`,{value:e.deviceId,children:e.label||`Microphone ${t+1}`},e.deviceId))]})]})}),(0,B.jsx)(`canvas`,{ref:d,className:Z.voiceWaveformCanvas,width:480,height:56,"aria-label":`Voice waveform`}),(0,B.jsx)(`textarea`,{className:Z.voiceTranscriptPreview,value:x,readOnly:!0,placeholder:v?`Voice error: ${v}`:`Live transcript preview will appear here…`}),(0,B.jsx)(`div`,{className:Z.voiceWidgetMeta,children:a===`edit`?`Edit mode — Insert transcript drops the text into the composer so you can review it before sending.`:`Direct mode — each finished sentence is sent to the agent as you speak.`}),(0,B.jsxs)(`div`,{className:Z.voiceWidgetActions,children:[(0,B.jsxs)(`button`,{type:`button`,className:_?Z.voiceStopButton:Z.voiceStartButton,onClick:()=>_?S():void p(l||void 0),children:[_?(0,B.jsx)(Sc,{size:14}):(0,B.jsx)(Cc,{size:14}),_?`Listening`:`Start`]}),(0,B.jsxs)(`button`,{type:`button`,className:Z.voiceSecondaryButton,onClick:C,children:[(0,B.jsx)(sl,{size:14}),` Discard`]}),a===`edit`&&(0,B.jsxs)(`button`,{type:`button`,className:Z.voiceInsertButton,onClick:S,disabled:!x.trim(),children:[(0,B.jsx)(us,{size:14}),` Insert transcript`]})]})]})}var LW={"claude-fable-5":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-5":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-4-8":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-4-7":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-4-6":[`low`,`medium`,`high`,`max`],"claude-sonnet-5":[`low`,`medium`,`high`],"claude-sonnet-4-6":[`low`,`medium`,`high`],"claude-haiku-4-5-20251001":[]},rnt={...LW},RW={anthropic:`Anthropic`,openai:`OpenAI`,google:`Google`,minimax:`MiniMax`,zai:`Z.AI`,kimi:`Kimi`,mimo:`Xiaomi MiMo`,nous:`Nous Portal`,dashscope:`Alibaba DashScope`,openrouter:`OpenRouter`},zW=[{provider:`anthropic`,label:`Anthropic`,models:[{id:`claude-fable-5`,label:`Claude Fable 5`,provider:`anthropic`,costDisplay:`$90/1M`,costPer1MTokens:90,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-opus-5`,label:`Claude Opus 5`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-opus-4-8`,label:`Claude Opus 4.8`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-opus-4-7`,label:`Claude Opus 4.7`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-sonnet-5`,label:`Claude Sonnet 5`,provider:`anthropic`,costDisplay:`$6/1M`,costPer1MTokens:6,effortLevels:[`low`,`medium`,`high`]},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`,provider:`anthropic`,costDisplay:`$15/1M`,costPer1MTokens:15,effortLevels:[`low`,`medium`,`high`]},{id:`claude-opus-4-6`,label:`Claude Opus 4.6`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`max`]},{id:`claude-haiku-4-5-20251001`,label:`Claude Haiku 4.5`,provider:`anthropic`,costDisplay:`$1/1M`,costPer1MTokens:1,effortLevels:[]}]},{provider:`openai`,label:`OpenAI`,models:[{id:`gpt-5.6-sol`,label:`GPT-5.6 Sol`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-sol[372k]`,label:`GPT-5.6 Sol 372K`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-terra`,label:`GPT-5.6 Terra`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-terra[372k]`,label:`GPT-5.6 Terra 372K`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-luna`,label:`GPT-5.6 Luna`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-luna[372k]`,label:`GPT-5.6 Luna 372K`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.5`,label:`GPT-5.5`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.4`,label:`GPT-5.4`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]}]}],BW=`conv-composer-model`,VW=`conv-composer-harness`,HW=`Experimental: converts the transcript to the new harness format. May lose fidelity; falls back to a fresh session on failure.`,int=``,UW=new Set(zW.flatMap(e=>e.models.map(e=>e.id)));function WW(e){return UW.has(e)}var GW=new Set;function ant(e){return GW.add(e),()=>{GW.delete(e)}}function KW(e){UW=new Set(e.flatMap(e=>e.models.map(e=>e.id)));for(let e of GW)e()}function qW(e=DD()){try{let e=localStorage.getItem(BW);if(e&&WW(e))return e}catch{}return e||int}function JW(e){try{localStorage.setItem(BW,e)}catch{}}function ont(){try{let e=localStorage.getItem(VW);if(ZW(e))return e}catch{}return`claude-code`}function YW(e){try{localStorage.setItem(VW,e)}catch{}}function XW(e){return e===0?`FREE`:e<1?`$${e.toFixed(2)}/1M`:`$${Math.round(e)}/1M`}function ZW(e){return e===`claude-code`||e===`ohmypi`||e===`codex`||e===`acp`||e===`kimi-code`}function QW(e,t){return t[e]??`claude-code`}function $W({value:e,onChange:t,disabled:n=!1,harness:r,onHarnessChange:i,onComboChange:a,liveConversation:o=!1,followProviderDefault:s=!1}){let[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(zW),[f,p]=(0,z.useState)({}),[m,h]=(0,z.useState)({anthropic:`claude-code`,openai:`codex`}),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(null),w=(0,z.useRef)(null),T=(0,z.useRef)(o);T.current=o;let{openUp:E,align:D,maxHeight:O}=Jx(c,w);(0,z.useEffect)(()=>{c||x(``)},[c]),(0,z.useEffect)(()=>{async function n(){try{await OD();let[n,r,i]=await Promise.allSettled([fetch(`/api/settings/available-models`).then(e=>e.json()),fetch(`/api/settings/openrouter/models`).then(e=>e.json()),fetch(`/api/settings`).then(e=>e.json())]),a=n.status===`fulfilled`?n.value:{},o=r.status===`fulfilled`?r.value:{models:[],favorites:[]};if(i.status===`fulfilled`){let e=i.value.models?.provider_default_harnesses??{},t=i.value.models?.provider_harnesses??{},n={};for(let[t,r]of Object.entries(e))ZW(r)&&(n[t]=r);for(let[e,r]of Object.entries(t))ZW(r)&&(n[e]=r);h(e=>({...e,...n})),y(i.value.experimental?.showHarnessModelPermutations===!0),_(!0)}let s=[];for(let[e,t]of Object.entries(a)){if(e===`openrouter`||!Array.isArray(t)||t.length===0)continue;let n=t.map(t=>({id:t.id,label:t.baseName??t.name.replace(/ — Kimi Code CLI$/,``),provider:e,costDisplay:XW(t.costPer1MTokens),costPer1MTokens:t.costPer1MTokens,effortLevels:t.effortLevels??rnt[t.id]??[],baseName:t.baseName}));s.push({provider:e,label:RW[e]??e,models:RWe(n)})}let c=new Set(o.favorites??[]),l=(o.models??[]).filter(e=>c.has(e.id));l.length>0&&s.push({provider:`openrouter`,label:`OpenRouter`,models:l.map(e=>({id:e.id,label:e.name,provider:`openrouter`,costDisplay:XW(e.promptCostPer1M),costPer1MTokens:e.promptCostPer1M,effortLevels:e.supportsThinking?[`low`,`medium`,`high`]:[]}))});let u=s.length>0?s:zW;KW(u),s.length>0&&d(s);let f=qW(DD());!T.current&&f&&f!==e&&WW(f)&&t(f,u.flatMap(e=>e.models).find(e=>e.id===f)?.effortLevels??[]);let m=u.flatMap(e=>e.models.map(e=>e.id));m.length>0&&p((await fetch(`/api/settings/harness-policy?models=${encodeURIComponent(m.join(`,`))}`).then(e=>e.json())).decisions??{})}catch{KW(zW)}}n()},[]),(0,z.useEffect)(()=>{if(!c)return;function e(e){w.current&&!w.current.contains(e.target)&&l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let k=(0,z.useMemo)(()=>{let e=u;S!==null&&(e=e.filter(e=>e.provider===S));let t=b.trim().toLowerCase();return t&&(e=e.map(e=>({...e,models:e.models.filter(e=>e.label.toLowerCase().includes(t))})).filter(e=>e.models.length>0)),e},[u,S,b]),A=u.flatMap(e=>e.models),j=A.find(t=>t.id===e&&(t.harness===void 0||t.harness===r))??A.find(t=>t.id===e),M=j?QW(j.provider,m):void 0,N=j?.harness??(v?r:M??r),P=AD(j?.costPer1MTokens);(0,z.useEffect)(()=>{!s||!g||v||!M||M===r||!i||(i(M),YW(M))},[s,g,v,M,r,i]);let F=u.length>1,I=k.length>1,L=k.length>1;function ee(e){let n=e.harness??QW(e.provider,m),o=r!==void 0&&i,s=o&&r!==n;o&&(e.harness!==void 0||!v&&s)?(a?a(e.id,e.effortLevels,n):(t(e.id,e.effortLevels),i(n)),YW(n)):t(e.id,e.effortLevels),localStorage.setItem(BW,e.id),l(!1)}let R=j?.label??e;return(0,B.jsxs)(`div`,{ref:w,className:Z.pickerContainer,children:[(0,B.jsxs)(`button`,{className:Z.pickerBtn,onClick:()=>l(e=>!e),disabled:n,type:`button`,children:[j&&(0,B.jsx)(ID,{provider:j.provider,label:RW[j.provider]??j.provider,className:Z.pickerProviderIcon}),(0,B.jsx)(`span`,{className:Z.pickerLabel,children:R}),N===`ohmypi`&&(0,B.jsxs)(`span`,{className:Z.harnessIndicator,title:`oh-my-pi harness active`,children:[(0,B.jsx)(FD,{harness:`ohmypi`,className:Z.harnessIndicatorIcon}),`oh-my-pi`]}),N===`codex`&&(0,B.jsxs)(`span`,{className:Z.harnessIndicator,title:`Codex harness active`,children:[(0,B.jsx)(FD,{harness:`codex`,className:Z.harnessIndicatorIcon}),`Codex`]}),P&&(0,B.jsx)(jD,{level:P,compact:!0,costPer1MTokens:j?.costPer1MTokens}),(0,B.jsx)(ds,{size:11})]}),c&&(0,B.jsxs)(`div`,{className:`${Z.pickerDropdown} ${E?Z.pickerDropdownUp:``}`,style:{maxHeight:`${O}px`,...D===`right`?{left:`auto`,right:0}:{}},children:[F&&(0,B.jsxs)(`div`,{className:Z.pickerProviderSidebar,children:[(0,B.jsx)(`button`,{type:`button`,className:`${Z.pickerProviderBtn} ${S===null?Z.pickerProviderBtnActive:``}`,onClick:()=>C(null),title:`All providers`,children:(0,B.jsx)(fc,{size:13})}),u.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`${Z.pickerProviderBtn} ${S===e.provider?Z.pickerProviderBtnActive:``}`,onClick:()=>C(e.provider),title:e.label,children:(0,B.jsx)(ID,{provider:e.provider,label:e.label,className:Z.pickerProviderBtnIcon})},e.provider))]}),(0,B.jsxs)(`div`,{className:Z.pickerMainPanel,children:[v&&r!==void 0&&i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`${Z.pickerGroupHeader} ${Z.pickerHarnessHeader}`,children:`Harness`}),jWe.map(t=>{let n=LD(t.id,e,f),a=r===t.id,s=!n.allowed,c=o&&!a,l=c?HW:s?n.reason??t.description:t.description;return(0,B.jsxs)(`button`,{type:`button`,className:`${Z.harnessOption} ${a?Z.harnessOptionActive:``} ${s?Z.harnessOptionLocked:``}`,onClick:()=>{a||s||i(t.id)},disabled:s,title:l,children:[(0,B.jsx)(`span`,{className:Z.harnessOptionIcon,children:a?(0,B.jsx)(us,{size:11}):(0,B.jsx)(FD,{harness:t.id,className:Z.harnessOptionLogo})}),(0,B.jsxs)(`span`,{className:Z.harnessOptionBody,children:[(0,B.jsxs)(`span`,{className:Z.harnessOptionNameRow,children:[a&&(0,B.jsx)(FD,{harness:t.id,className:Z.harnessOptionLogo}),(0,B.jsx)(`span`,{className:Z.harnessOptionName,children:t.label}),c&&(0,B.jsx)(`span`,{className:Z.harnessOptionExperimental,children:`Experimental`})]}),t.description&&(0,B.jsx)(`span`,{className:Z.harnessOptionDesc,children:t.description}),c&&(0,B.jsx)(`span`,{className:Z.harnessOptionDesc,children:HW}),s&&n.reason&&(0,B.jsx)(`span`,{className:Z.harnessOptionNote,children:n.reason})]})]},t.id)}),(0,B.jsx)(`div`,{className:Z.pickerSectionDivider})]}),(0,B.jsxs)(`div`,{className:Z.pickerSearchWrapper,children:[(0,B.jsx)(Vc,{size:11,className:Z.pickerSearchIcon}),(0,B.jsx)(`input`,{type:`text`,className:Z.pickerSearchInput,placeholder:`Search models…`,value:b,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),autoFocus:!0})]}),(0,B.jsx)(`div`,{className:Z.pickerScrollContent,children:k.length>0?k.map(t=>(0,B.jsxs)(`div`,{children:[L&&(0,B.jsx)(`div`,{className:Z.pickerGroupHeader,children:t.label}),t.models.map(t=>{let n=AD(t.costPer1MTokens),i=t.harness??(v?r:QW(t.provider,m)),a=i?LD(i,t.id,f):{allowed:!0},o=!a.allowed,s=t.id===e&&(t.harness===void 0||t.harness===r);return(0,B.jsx)(`button`,{className:`${Z.pickerOption} ${s?Z.pickerOptionActive:``} ${o?Z.pickerOptionLocked:``}`,onClick:()=>{o||ee(t)},disabled:o,title:o?a.reason:void 0,type:`button`,children:(0,B.jsxs)(`span`,{className:Z.pickerOptionContent,children:[(0,B.jsxs)(`span`,{className:Z.pickerOptionRow,children:[(0,B.jsx)(`span`,{className:Z.pickerOptionLabel,children:t.label}),o&&(0,B.jsx)(`span`,{className:Z.pickerOptionLockIcon,title:a.reason,children:(0,B.jsx)(_c,{size:10})}),n&&(0,B.jsx)(jD,{level:n,compact:!0,costPer1MTokens:t.costPer1MTokens}),t.costDisplay&&(0,B.jsx)(`span`,{className:Z.pickerCostBadge,children:t.costDisplay})]}),I&&(0,B.jsxs)(`span`,{className:Z.pickerOptionSubtitle,children:[(0,B.jsx)(kWe,{provider:t.provider}),RW[t.provider]??t.provider]})]})},`${t.id}::${t.harness??``}`)})]},t.provider)):(0,B.jsxs)(`div`,{className:Z.pickerNoResults,children:[`No models match “`,b,`”`]})})]})]})]})}var eG={anthropic:{name:`Anthropic`,models:[{id:`claude-fable-5`,name:`Claude Fable 5`,icon:Zs,tier:`premium`,costPer1MTokens:90,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Mythos-class flagship — long-horizon autonomous work, low→max effort. ~2× Opus pricing ($10 in / $50 out).`},{id:`claude-opus-5`,name:`Claude Opus 5`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Current Opus (July 2026) — near-Fable-5 capability at half the cost, 1M context, low→max effort`},{id:`claude-opus-4-8`,name:`Claude Opus 4.8`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous flagship — xhigh/max effort, deepest reasoning`},{id:`claude-opus-4-7`,name:`Claude Opus 4.7`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous flagship — xhigh/max effort, deepest reasoning`},{id:`claude-opus-4-6`,name:`Claude Opus 4.6`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous Opus, strong reasoning and planning`},{id:`claude-sonnet-5`,name:`Claude Sonnet 5`,icon:Xc,tier:`balanced`,costPer1MTokens:6,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Current Sonnet — 1M context, intro pricing through Aug 31, 2026`},{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`,icon:Xc,tier:`balanced`,costPer1MTokens:9,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous Sonnet — fast, capable, great for implementation`},{id:`claude-haiku-4-5`,name:`Claude Haiku 4.5`,icon:cl,tier:`fast`,costPer1MTokens:1,capabilities:[`fast`,`cost-efficient`,`code`],description:`Fastest, ideal for simple tasks`}]},openai:{name:`OpenAI`,models:[{id:`gpt-5.6-sol`,name:`GPT-5.6 Sol`,icon:Zs,tier:`premium`,costPer1MTokens:17.5,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI flagship (July 2026), new default. 272K session window (billing-tier safe), $5 in / $30 out per 1M.`},{id:`gpt-5.6-sol[372k]`,name:`GPT-5.6 Sol 372K`,icon:Zs,tier:`premium`,costPer1MTokens:17.5,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Sol with the 372K long-context window. Input past 272K bills at 2x in / 1.5x out for the whole request — for long-research sessions that accept the surcharge.`},{id:`gpt-5.6-terra`,name:`GPT-5.6 Terra`,icon:Xc,tier:`balanced`,costPer1MTokens:7,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI balanced tier (July 2026). GPT-5.5-competitive at lower cost. 272K session window (billing-tier safe), $2 in / $12 out per 1M.`},{id:`gpt-5.6-terra[372k]`,name:`GPT-5.6 Terra 372K`,icon:Xc,tier:`balanced`,costPer1MTokens:7,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Terra with the 372K long-context window. Input past 272K bills at 2x in / 1.5x out for the whole request.`},{id:`gpt-5.6-luna`,name:`GPT-5.6 Luna`,icon:cl,tier:`fast`,costPer1MTokens:.7,capabilities:[`fast`,`cost-efficient`,`code`],description:`OpenAI fastest/cheapest tier (July 2026). 272K session window (billing-tier safe), $0.20 in / $1.20 out per 1M.`},{id:`gpt-5.6-luna[372k]`,name:`GPT-5.6 Luna 372K`,icon:cl,tier:`fast`,costPer1MTokens:.7,capabilities:[`fast`,`cost-efficient`,`code`],description:`Luna with the 372K long-context window. Input past 272K bills at 2x in / 1.5x out for the whole request.`},{id:`gpt-5.5`,name:`GPT-5.5`,icon:Zs,tier:`premium`,costPer1MTokens:17.5,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI flagship (April 2026). 1.05M context, $5 in / $30 out per 1M.`},{id:`gpt-5.4`,name:`GPT-5.4`,icon:Xc,tier:`balanced`,costPer1MTokens:8.75,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Balanced GPT-5.4. 1.05M context, strong coding.`},{id:`gpt-5.4-mini`,name:`GPT-5.4 Mini`,icon:Ws,tier:`fast`,costPer1MTokens:2.625,capabilities:[`fast`,`cost-efficient`,`code`],description:`Fast and efficient. 400K context. $0.75 in / $4.50 out.`},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,icon:Zs,tier:`premium`,costPer1MTokens:7.875,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Coding-optimized (Feb 2026). 400K context, 85% SWE-Bench Verified. $1.75 in / $14 out.`},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,icon:cl,tier:`fast`,costPer1MTokens:7.875,capabilities:[`fast`,`code`,`cost-efficient`],description:`Ultra-fast coder (1000+ tok/s). ChatGPT-Pro-only research preview; routes via Codex CLI subscription auth — not generally available via raw API.`},{id:`gpt-5.2`,name:`GPT-5.2`,icon:Xc,tier:`balanced`,costPer1MTokens:7.875,capabilities:[`reasoning`,`code`,`agentic`],description:`Long-running agents (Dec 2025). 80% SWE-Bench, 92.4% GPQA-Diamond. Reserve for deep deliberation, not high-frequency polling.`}]},google:{name:`Google`,models:[{id:`gemini-3.1-pro-preview`,name:`Gemini 3.1 Pro`,icon:dc,tier:`premium`,costPer1MTokens:7,capabilities:[`reasoning`,`large-context`,`code`],description:`Google flagship, 1M context, strong agentic coding`},{id:`gemini-3.1-flash-lite-preview`,name:`Gemini 3.1 Flash Lite`,icon:cl,tier:`fast`,costPer1MTokens:.9,capabilities:[`fast`,`cost-efficient`,`large-context`],description:`Most cost-efficient Google model`}]},kimi:{name:`Kimi (Moonshot)`,models:[{id:`k3`,name:`Kimi K3`,icon:Zs,tier:`premium`,costPer1MTokens:9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi flagship coding model (July 2026). Always-thinking 2.8T MoE, 256K context.`},{id:`k3[1m]`,name:`Kimi K3 (1M)`,icon:Zs,tier:`premium`,costPer1MTokens:9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi K3 coding endpoint with the full 1,048,576-token context window.`},{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,icon:dc,tier:`premium`,costPer1MTokens:2.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi coding-first flagship (June 2026). 1T MoE, multimodal, 262K context.`},{id:`kimi-k2.6`,name:`Kimi K2.6`,icon:dc,tier:`premium`,costPer1MTokens:1.6,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi smartest model (April 2026). Native multimodal, superior agentic coding.`},{id:`kimi-k2.5`,name:`Kimi K2.5`,icon:dc,tier:`premium`,costPer1MTokens:1.6,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Best open-source coding, 256K context, 76.8% SWE-bench`},{id:`K2.6-code-preview`,name:`K2.6-code-preview`,icon:Ws,tier:`premium`,costPer1MTokens:1.6,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi coding preview model.`}]},zai:{name:`Zhipu (GLM)`,models:[{id:`glm-5.2`,name:`GLM-5.2`,icon:Dc,tier:`premium`,costPer1MTokens:2.9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Z.AI flagship, 1M context, high/max effort, strong agentic coding. Text-only (vision is a separate model line).`},{id:`glm-5.1`,name:`GLM-5.1`,icon:Dc,tier:`premium`,costPer1MTokens:2.9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Previous Z.AI flagship, 200K context, strong agentic coding. Text-only (vision is a separate model line).`}]},minimax:{name:`MiniMax`,models:[{id:`MiniMax-M3`,name:`M3`,icon:Zs,tier:`premium`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`MSA architecture, 1M context, top-tier coding, native multimodal`},{id:`minimax-m2.7-highspeed`,name:`M2.7 Highspeed`,icon:cl,tier:`premium`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`56.22% SWE-Pro, 100 tps, 204K context, $0.06/M blended`},{id:`minimax-m2.7`,name:`M2.7`,icon:dc,tier:`balanced`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`56.22% SWE-Pro, 10B active params, 204K context`}]},mimo:{name:`Xiaomi MiMo`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,icon:dc,tier:`premium`,costPer1MTokens:2,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],supportsImages:!1,description:`Flagship reasoning model, 1M context, enhanced agent efficiency. Text-only on Token-Plan endpoints.`},{id:`mimo-v2.5`,name:`MiMo V2.5`,icon:cl,tier:`balanced`,costPer1MTokens:1,capabilities:[`code`,`agentic`,`fast`,`vision`],supportsImages:!0,description:`Multimodal model, 262K context, strong agentic coding`}]},nous:{name:`Nous Portal`,models:[{id:`qwen/qwen3.6-plus`,name:`Qwen 3.6 Plus`,icon:Dc,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`,`cost-efficient`],description:`Qwen 3.6 Plus via Nous Portal, currently free with 1M context.`}]},dashscope:{name:`Alibaba DashScope`,models:[{id:`qwen3-max`,name:`Qwen3 Max`,icon:Zs,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope flagship reasoning model.`},{id:`qwen3-coder-plus`,name:`Qwen3 Coder Plus`,icon:Ws,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope coding-specialist model.`},{id:`qwen3-plus`,name:`Qwen3 Plus`,icon:Xc,tier:`balanced`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope balanced Qwen3 model.`},{id:`qwen3.7-max`,name:`Qwen3.7 Max`,icon:Zs,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope flagship Qwen3.7 Max model.`},{id:`qwen3.8-max`,name:`Qwen3.8 Max`,icon:Zs,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope flagship Qwen3.8 Max preview; free 1M-token Model Studio quota.`}]},xai:{name:`xAI (Grok)`,models:[{id:`grok-build-0.1`,name:`Grok Build 0.1`,icon:cl,tier:`premium`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`,`vision`],description:`xAI's agentic coding model (May 2026). 256K context, reasoning always active.`}]},quantumllama:{name:`QuantumLlama`,models:[{id:`ql-reason-70b`,name:`QL Reason 70B`,icon:Ws,tier:`premium`,costPer1MTokens:16,capabilities:[`reasoning`,`code`,`large-context`],description:`Fictional benchmark provider (PAN-3252) — no live endpoint. 200K context, $8 in / $24 out per 1M.`},{id:`ql-swift-8b`,name:`QL Swift 8B`,icon:Ws,tier:`balanced`,costPer1MTokens:4,capabilities:[`code`,`fast`],description:`Fictional benchmark provider (PAN-3252) — no live endpoint. 128K context, $2 in / $6 out per 1M.`},{id:`ql-nano-1b`,name:`QL Nano 1B`,icon:Ws,tier:`fast`,costPer1MTokens:.8,capabilities:[`fast`,`cost-efficient`],description:`Fictional benchmark provider (PAN-3252) — no live endpoint. 32K context, $0.40 in / $1.20 out per 1M.`}]}};function tG(e){for(let t of Object.values(eG)){let n=t.models.find(t=>t.id===e);if(n)return n}}function nG(e){return tG(e)?.supportsImages!==!1}var rG=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium`},{id:`high`,label:`High (default)`},{id:`xhigh`,label:`Extra High`},{id:`max`,label:`Max`}],iG=`conv-composer-effort`,snt=`high`;function cnt(){try{let e=localStorage.getItem(iG);if(e&&rG.some(t=>t.id===e))return e}catch{}return snt}function lnt({value:e,onChange:t,disabled:n=!1,availableLevels:r}){let[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null),{openUp:s,align:c,maxHeight:l}=Jx(i,o,{preferredHeight:240}),u=r!==void 0&&r.length===0,d=r&&r.length>0?rG.filter(e=>r.includes(e.id)):rG,f=d.find(t=>t.id===e)??d.find(e=>e.id===`medium`)??d[0]??rG[1];(0,z.useEffect)(()=>{if(!i)return;function e(e){o.current&&!o.current.contains(e.target)&&a(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);function p(e){t(e),localStorage.setItem(iG,e),a(!1)}return u?(0,B.jsx)(`div`,{className:Z.pickerContainer,children:(0,B.jsx)(`span`,{className:Z.pickerHint,children:`effort n/a for this model`})}):(0,B.jsxs)(`div`,{ref:o,className:Z.pickerContainer,children:[(0,B.jsxs)(`button`,{className:Z.pickerBtn,onClick:()=>a(e=>!e),disabled:n,type:`button`,children:[(0,B.jsx)(`span`,{className:Z.pickerLabel,children:f.label}),(0,B.jsx)(ds,{size:11})]}),i&&(0,B.jsx)(`div`,{className:`${Z.pickerDropdown} ${s?Z.pickerDropdownUp:``}`,style:{maxHeight:`${l}px`,...c===`right`?{left:`auto`,right:0}:{}},children:d.map(t=>(0,B.jsx)(`button`,{className:`${Z.pickerOption} ${t.id===e?Z.pickerOptionActive:``}`,onClick:()=>p(t.id),type:`button`,children:t.label},t.id))})]})}function unt(e){if(!e)return null;let t=Math.max(0,Math.round(e.estimatedTokens)),n=e.contextWindow>0?e.contextWindow:null,r=n===null?null:Math.min(100,Math.max(0,e.percentUsed));return{usedTokens:t,maxTokens:n,usedPercentage:r,remainingTokens:n===null?null:Math.max(0,n-t),remainingPercentage:r===null?null:Math.max(0,100-r),activeBytes:e.activeBytes,lastInputTokens:e.lastInputTokens,lastCacheReadTokens:e.lastCacheReadTokens,lastCacheCreationTokens:e.lastCacheCreationTokens,maxObservedInputTokens:e.maxObservedInputTokens,lastModel:e.lastModel,lastTurnAt:e.lastTurnAt}}function aG(e){return e===null||!Number.isFinite(e)?`0`:e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}var oG={root:`_root_19ian_10`,ring:`_ring_19ian_28`,ringSvg:`_ringSvg_19ian_37`,ringTrack:`_ringTrack_19ian_45`,ringProgress:`_ringProgress_19ian_49`,ringInner:`_ringInner_19ian_59`,tone_low:`_tone_low_19ian_77`,tone_medium:`_tone_medium_19ian_81`,tone_high:`_tone_high_19ian_85`,wrapper:`_wrapper_19ian_95`,popover:`_popover_19ian_101`,popoverHeader:`_popoverHeader_19ian_123`,popoverHeaderLabel:`_popoverHeaderLabel_19ian_130`,popoverExtBadge:`_popoverExtBadge_19ian_138`,popoverPrimary:`_popoverPrimary_19ian_149`,popoverPercent:`_popoverPercent_19ian_156`,popoverFraction:`_popoverFraction_19ian_162`,popoverGrid:`_popoverGrid_19ian_168`,popoverFooter:`_popoverFooter_19ian_191`,popoverFooterLabel:`_popoverFooterLabel_19ian_205`,popoverFooterValue:`_popoverFooterValue_19ian_212`,popoverNote:`_popoverNote_19ian_220`};function dnt(e){return e<50?`low`:e<=80?`medium`:`high`}function fnt(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(e)}%`}function pnt(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}var sG=9.75,cG=2*Math.PI*sG;function mnt({usage:e}){let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]);let i=(0,z.useCallback)(e=>{e.stopPropagation(),n(e=>!e)},[]);if(!e)return null;let a=e.usedPercentage===null?0:Math.max(0,Math.min(100,e.usedPercentage)),o=dnt(a),s=cG-a/100*cG,c=fnt(e.usedPercentage),l=e.maxTokens!==null&&c?`${c} · ${aG(e.usedTokens)}/${aG(e.maxTokens)} context used · click for details`:`${aG(e.usedTokens)} tokens used so far · click for details`,u=e.usedPercentage===null?aG(e.usedTokens):`${Math.round(e.usedPercentage)}`,d=e.maxTokens!==null&&c?`Context window ${c} used — click to expand`:`Context window ${aG(e.usedTokens)} tokens used — click to expand`,f=pnt(e.lastTurnAt),p=typeof e.maxObservedInputTokens==`number`&&e.maxTokens!==null&&e.maxTokens>2e5;return(0,B.jsxs)(`span`,{ref:r,className:oG.wrapper,children:[(0,B.jsx)(`button`,{type:`button`,className:`${oG.root} ${oG[`tone_${o}`]}`,title:l,"aria-label":d,"aria-expanded":t,"aria-haspopup":`dialog`,onClick:i,"data-testid":`context-window-meter`,"data-tone":o,children:(0,B.jsxs)(`span`,{className:oG.ring,children:[(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:oG.ringSvg,"aria-hidden":`true`,"data-testid":`context-window-meter-ring`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:sG,fill:`none`,className:oG.ringTrack,strokeWidth:`3`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:sG,fill:`none`,className:oG.ringProgress,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:cG,strokeDashoffset:s,"data-testid":`context-window-meter-progress`})]}),(0,B.jsx)(`span`,{className:oG.ringInner,"data-testid":`context-window-meter-label`,children:u})]})}),t&&(0,B.jsxs)(`div`,{className:oG.popover,role:`dialog`,"aria-label":`Context window detail`,"data-testid":`context-window-meter-popover`,children:[(0,B.jsxs)(`div`,{className:oG.popoverHeader,children:[(0,B.jsx)(`span`,{className:oG.popoverHeaderLabel,children:`Context window`}),p&&(0,B.jsx)(`span`,{className:oG.popoverExtBadge,title:`1M extended-context auto-detected from observed usage`,children:`1M mode`})]}),(0,B.jsx)(`div`,{className:oG.popoverPrimary,children:e.maxTokens!==null&&c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:oG.popoverPercent,children:c}),(0,B.jsxs)(`span`,{className:oG.popoverFraction,children:[aG(e.usedTokens),` / `,aG(e.maxTokens)]})]}):(0,B.jsxs)(`span`,{className:oG.popoverFraction,children:[aG(e.usedTokens),` tokens`]})}),(e.lastInputTokens!==void 0||e.lastCacheReadTokens!==void 0||e.lastCacheCreationTokens!==void 0)&&(0,B.jsxs)(`dl`,{className:oG.popoverGrid,children:[e.lastInputTokens!==void 0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Input`}),(0,B.jsx)(`dd`,{children:aG(e.lastInputTokens)})]}),e.lastCacheReadTokens!==void 0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Cache read`}),(0,B.jsx)(`dd`,{children:aG(e.lastCacheReadTokens)})]}),e.lastCacheCreationTokens!==void 0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Cache create`}),(0,B.jsx)(`dd`,{children:aG(e.lastCacheCreationTokens)})]}),e.remainingTokens!==null&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Remaining`}),(0,B.jsx)(`dd`,{children:aG(e.remainingTokens)})]})]}),(e.lastModel||f)&&(0,B.jsxs)(`div`,{className:oG.popoverFooter,children:[e.lastModel&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:oG.popoverFooterLabel,children:`Last turn model`}),(0,B.jsx)(`span`,{className:oG.popoverFooterValue,children:e.lastModel})]}),f&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:oG.popoverFooterLabel,children:`Last turn at`}),(0,B.jsx)(`span`,{className:oG.popoverFooterValue,children:f})]})]}),(0,B.jsxs)(`p`,{className:oG.popoverNote,children:[`Sourced from the last assistant turn's `,(0,B.jsx)(`code`,{children:`usage`}),` in the JSONL — matches Claude Code's terminal indicator.`]})]})]})}var lG=[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`],uG=`.txt,.md,.markdown,.json,.jsonl,.log,.csv,.tsv,.yaml,.yml,.toml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.sh,.bash,.sql,.diff,.patch,.ini,.conf,.cfg,.pdf`.split(`,`);function dG(e){let t=e.lastIndexOf(`.`);return t<=0?``:e.slice(t).toLowerCase()}var hnt={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".txt":`text/plain`,".md":`text/markdown`,".markdown":`text/markdown`,".json":`application/json`,".jsonl":`application/jsonlines`,".log":`text/plain`,".csv":`text/csv`,".tsv":`text/tab-separated-values`,".yaml":`application/yaml`,".yml":`application/yaml`,".toml":`application/toml`,".xml":`application/xml`,".html":`text/html`,".css":`text/css`,".js":`text/javascript`,".jsx":`text/javascript`,".ts":`text/typescript`,".tsx":`text/typescript`,".py":`text/x-python`,".sh":`application/x-sh`,".bash":`application/x-sh`,".sql":`application/sql`,".diff":`text/x-diff`,".patch":`text/x-diff`,".ini":`text/plain`,".conf":`text/plain`,".cfg":`text/plain`,".pdf":`application/pdf`};function fG(e){if(pG(e.name)||mG(e.name))return null;let t=dG(e.name);return lG.includes(t)?`image`:uG.includes(t)?`file`:null}function gnt(e){return e.type?e.type:hnt[dG(e.name)]??`text/plain`}function pG(e){return e.startsWith(`.`)}function mG(e){return!pG(e)&&dG(e)===``}var _nt=[...lG,...uG].join(`,`),hG=[],vnt=[],ynt=[],bnt=[];function xnt(){return{sending:!1,attachments:[],optimistic:[],optimisticBaseCount:0,failed:[],commandResults:[]}}function Snt(e){return!e.sending&&e.attachments.length===0&&e.optimistic.length===0&&e.failed.length===0&&e.commandResults.length===0}function Cnt(e){if(!e||typeof e!=`object`)return!1;let t=e;switch(t.kind){case`captured`:return(t.status===`completed`||t.status===`failed`)&&typeof t.command==`string`&&typeof t.output==`string`&&typeof t.truncated==`boolean`;case`activity`:return t.status===`accepted`&&typeof t.command==`string`&&typeof t.activityId==`string`&&typeof t.message==`string`;case`ui`:return t.status===`requires_ui`&&(t.action===`handoff`||t.action===`fork`)&&t.args!==null&&typeof t.args==`object`;case`confirmation`:return t.status===`confirmation_required`&&typeof t.nonce==`string`&&typeof t.consequence==`string`&&(t.typedText===void 0||typeof t.typedText==`string`);case`terminal-only`:return t.status===`rejected`&&typeof t.message==`string`;default:return!1}}var gG=class extends Error{status;reason;retryable;constructor(e,t){super(e),this.name=`MessageSendError`,this.status=t.status,this.reason=t.reason,this.retryable=t.status===void 0||t.status>=500||t.status===408||t.status===429}};function _G(e){return e instanceof gG?{error:e.reason??e.message,retryable:e.retryable}:{error:e instanceof Error?e.message:String(e),retryable:!0}}async function vG(e,t,n,r,i){let a=n?`/api/agents/${encodeURIComponent(n)}/message`:`/api/conversations/${encodeURIComponent(e)}/message`,o={message:t,...r&&!n?{deliverAs:r}:{},...i?{confirmationNonce:i.nonce,...i.typedText===void 0?{}:{confirmationText:i.typedText}}:{}},s;try{s=await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)})}catch(e){throw new gG(`Failed to send message: ${e instanceof Error?e.message:String(e)}`,{})}let c=await s.text().catch(()=>``),l=null;if(c)try{l=JSON.parse(c)}catch{l=null}if(Cnt(l))return l;if(!s.ok){let e=l&&typeof l==`object`&&`error`in l&&typeof l.error==`string`?l.error:c;throw new gG(`Failed to send message (${s.status})${e?`: ${e}`:``}`,{status:s.status,reason:e||void 0})}return null}async function wnt(e,t,n){let r=new FormData;r.append(`file`,t),r.append(`filename`,t.name),r.append(`mimeType`,n===`image`&&t.type?t.type:gnt(t));let i=await fetch(`/api/conversations/${encodeURIComponent(e)}/upload-image`,{method:`POST`,body:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`Failed to upload attachment (${i.status})${e?`: ${e}`:``}`)}let a;try{a=await i.json()}catch{throw Error(`Attachment upload response was not valid JSON`)}if(!a||typeof a!=`object`||!(`path`in a)||typeof a.path!=`string`||a.path.length===0)throw Error(`Attachment upload response did not include a path`);return a.path}async function Tnt(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/delete-image`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to delete attachment (${n.status})${e?`: ${e}`:``}`)}}function yG(e){e&&typeof URL.revokeObjectURL==`function`&&URL.revokeObjectURL(e)}function bG(e,t){Tnt(e,t).catch(e=>{console.error(`[composerStore] Failed to delete attachment:`,e)})}var Ent=3,xG=0,SG=[],CG=new Set;function wG(){for(;xG<Ent&&SG.length>0;){let e=SG.shift();xG++,wnt(e.conversationName,e.file,e.kind).then(t=>{xG--;try{CG.has(e.id)?(CG.delete(e.id),bG(e.conversationName,t)):EG.getState().updateAttachment(e.conversationName,e.id,{serverPath:t,error:null})}finally{wG()}},t=>{xG--;try{if(CG.has(e.id)){CG.delete(e.id);return}let n=t instanceof Error?t.message:`Failed to upload attachment`;EG.getState().updateAttachment(e.conversationName,e.id,{error:n})}finally{wG()}})}}function TG(e,t,n){let r=n(e[t]??xnt()),i={...e};return Snt(r)?delete i[t]:i[t]=r,i}var EG=tS((e,t)=>({byConversation:{},setSending:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>e.sending===n?e:{...e,sending:n})})),enqueueAttachments:(t,n)=>{let r=[],i=[];for(let e of n){let n=fG(e);if(!n){i.push(e);continue}r.push({id:crypto.randomUUID(),conversationName:t,kind:n,file:e,previewUrl:n===`image`?URL.createObjectURL(e):null,serverPath:null,error:null})}return r.length===0?{rejected:i}:(e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,attachments:[...e.attachments,...r]}))})),SG.push(...r),wG(),{rejected:i})},updateAttachment:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,attachments:e.attachments.map(e=>e.id===n?{...e,...r}:e)}))})),removeAttachment:(n,r)=>{let i=t().byConversation[n]?.attachments.find(e=>e.id===r);if(i)if(yG(i.previewUrl),i.serverPath)bG(n,i.serverPath);else{let e=SG.findIndex(e=>e.id===r);e>=0?SG.splice(e,1):CG.add(r)}e(e=>({byConversation:TG(e.byConversation,n,e=>({...e,attachments:e.attachments.filter(e=>e.id!==r)}))}))},consumeAttachments:n=>{let r=t().byConversation[n];if(r){for(let e of r.attachments)yG(e.previewUrl);e(e=>({byConversation:TG(e.byConversation,n,e=>({...e,attachments:[]}))}))}},addOptimistic:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,optimisticBaseCount:e.optimistic.length===0?r:e.optimisticBaseCount,optimistic:[...e.optimistic,{id:`optimistic-${Date.now()}-${e.optimistic.length}`,role:`user`,text:n,createdAt:new Date().toISOString()}]}))})),acknowledgeOptimistic:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>{let t=!1;return{...e,optimistic:e.optimistic.map(e=>t||e.acknowledged||e.text!==n?e:(t=!0,{...e,acknowledged:!0}))}})})),clearOptimistic:t=>e(e=>({byConversation:TG(e.byConversation,t,e=>e.optimistic.length===0?e:{...e,optimistic:[],optimisticBaseCount:0})})),failSend:(t,n,r=`prompt`,i)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,optimistic:r===`prompt`?[]:e.optimistic,optimisticBaseCount:r===`prompt`?0:e.optimisticBaseCount,failed:[...e.failed,{id:`failed-${Date.now()}`,text:n,kind:r,createdAt:new Date().toISOString(),...i?.error===void 0?{}:{error:i.error},...i?.retryable===void 0?{}:{retryable:i.retryable}}]}))})),removeFailed:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,failed:e.failed.filter(e=>e.id!==n)}))})),addCommandResult:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,commandResults:[...e.commandResults,{id:`command-result-${Date.now()}-${e.commandResults.length}`,role:`system`,text:n,commandText:n,commandResult:r,createdAt:new Date().toISOString()}]}))})),replaceCommandResult:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,commandResults:e.commandResults.map(e=>e.id===n?{...e,commandResult:r}:e)}))})),removeCommandResult:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,commandResults:e.commandResults.filter(e=>e.id!==n)}))})),retryFailed:async(e,n,r,i,a)=>{let{addOptimistic:o,addCommandResult:s,removeFailed:c,failSend:l}=t(),u=t().byConversation[e]?.failed.find(e=>e.id===n)?.kind??`prompt`;u===`prompt`&&o(e,r,i),c(e,n);try{let t=await vG(e,r,a);return u===`command`&&t&&t.kind!==`ui`&&s(e,r,t),t}catch(t){return l(e,r,u,_G(t)),null}}}));function Dnt(e){return EG(t=>t.byConversation[e]?.sending??!1)}function Ont(e){return EG(t=>t.byConversation[e]?.attachments??hG)}function knt(e){return EG(t=>t.byConversation[e]?.optimistic??vnt)}function Ant(e){return EG(t=>t.byConversation[e]?.optimisticBaseCount??0)}function jnt(e){return EG(t=>t.byConversation[e]?.failed??ynt)}function Mnt(e){return EG(t=>t.byConversation[e]?.commandResults??bnt)}function Nnt(e){return EG.getState().byConversation[e]?.attachments??hG}function Pnt(){return _nt}function Fnt(e){return e.harness===`ohmypi`||e.harness===`pi`}function Int(e){switch(e.effort){case`low`:case`medium`:case`high`:case`xhigh`:case`max`:return e.effort;default:return!e.sessionAlive&&!e.claudeSessionId?cnt():`high`}}function DG(e,t,n){window.dispatchEvent(new CustomEvent(`overdeck:open-fork-modal`,{detail:{conversation:e,mode:t===`handoff`?`handoff`:`summary`,focus:n}}))}function Lnt(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log10(e)/3),t.length-1);return`${(e/1e3**n).toFixed(n===0?0:1)} ${t[n]}`}function Rnt({conversation:e,onSend:t,onSendAcknowledged:n,onSendFailed:r,agentId:i,contextWindowUsage:a=null,agentBusy:o=!1}){let s=Int(e),[c,l]=(0,z.useState)(e.model??DD()),[u,d]=(0,z.useState)((e.harness===`pi`?`ohmypi`:e.harness)??`claude-code`),[f,p]=(0,z.useState)(s),[m,h]=(0,z.useState)(`auto`),[g,_]=(0,z.useState)(!1),v=Dnt(e.name),y=Ont(e.name),b=EG(e=>e.setSending),x=EG(e=>e.enqueueAttachments),S=EG(e=>e.removeAttachment),C=EG(e=>e.consumeAttachments),w=EG(e=>e.addCommandResult),[T,E]=(0,z.useState)(``),[D,O]=(0,z.useState)(!1),[k,A]=(0,z.useState)(0),[j,M]=(0,z.useState)({isListening:!1,error:null}),N=(0,z.useRef)(null),P=(0,z.useRef)(null),F=(0,z.useRef)(e.name),I=(0,z.useRef)(e.name);I.current=e.name,(0,z.useEffect)(()=>{p(s)},[e.name,s]);let L=Fnt(e),ee=!e.sessionAlive||v,R=!i&&!e.sessionAlive&&!e.claudeSessionId,te=T.trim()===``,ne=(0,z.useCallback)(t=>{let n=[],r=[];for(let e of t)fG(e)===`image`?n.push(e):r.push(e);if(n.length>0&&!nG(c)){let e=tG(c);U.warning(`${e?.name??c} can't read images — image${n.length===1?``:`s`} not attached. Switch to a vision-capable model (e.g. MiMo V2.5) to send images.`)}let i=nG(c)?t:r,{rejected:a}=x(e.name,i);if(a.length>0){let e=a.filter(e=>pG(e.name)),t=a.filter(e=>mG(e.name)),n=a.filter(e=>!pG(e.name)&&!mG(e.name)),r=e=>e.map(e=>e.name).join(`, `);e.length>0&&U.warning(`${r(e)} not supported (dotfile).`),t.length>0&&U.warning(`${r(t)} not supported (extensionless file).`),n.length>0&&U.warning(`${r(n)} not supported.`)}},[x,e.name,c]),re=(0,z.useCallback)(()=>{P.current?.click()},[]),ie=(0,z.useCallback)(e=>{let t=e.target.files?Array.from(e.target.files):[];t.length>0&&ne(t),e.target.value=``},[ne]),ae=(0,z.useCallback)(t=>{S(e.name,t)},[S,e.name]),oe=(0,z.useCallback)(e=>{e!==u&&(d(e),YW(e))},[u]),se=(0,z.useCallback)((e,t)=>{l(e),JW(e)},[]),ce=(0,z.useCallback)((e,t,n)=>{l(e),JW(e),d(n),YW(n)},[]),le=(0,z.useCallback)(t=>{let n=f;p(t),!(!L||i||!e.sessionAlive)&&(async()=>{let r=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/thinking-level`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:t})});if(!r.ok){p(n);let e=await r.text().catch(()=>``);throw Error(`Failed to set thinking level (${r.status})${e?`: ${e}`:``}`)}})().catch(e=>{console.error(`[ComposerFooter] Failed to set thinking level:`,e),U.error(e instanceof Error?e.message:`Failed to set thinking level`)})},[i,e.name,e.sessionAlive,f,L]),ue=(0,z.useCallback)(()=>{!L||i||g||(_(!0),(async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/compact`,{method:`POST`});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Failed to compact conversation (${t.status})${e?`: ${e}`:``}`)}U.success(`Compaction requested`)})().catch(e=>{console.error(`[ComposerFooter] Failed to compact:`,e),U.error(e instanceof Error?e.message:`Failed to compact conversation`)}).finally(()=>{_(!1)}))},[i,g,e.name,L]),de=(0,z.useCallback)(e=>{if(v){e.preventDefault();return}let t=e.clipboardData;if(!t)return;let n=[],r=t.files?Array.from(t.files):[];if(r.length>0)n.push(...r);else if(t.items){for(let e of Array.from(t.items))if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}}if(n.length>0){e.preventDefault(),ne(n);return}let i=Array.from(t.types??[]),a=i.some(e=>e.startsWith(`image/`)),o=i.includes(`Files`),s=i.includes(`text/uri-list`);if(a||o){e.preventDefault(),typeof navigator<`u`&&navigator.clipboard?.read?(async()=>{try{let e=await navigator.clipboard.read(),t=[];for(let n of e)for(let e of n.types){if(!e.startsWith(`image/`))continue;let r=await n.getType(e),i=e.split(`/`)[1]?.split(`+`)[0]||`png`;t.push(new File([r],`paste-${Date.now()}.${i}`,{type:e}))}t.length>0?ne(t):U.error(`Couldn't read the pasted image. Try saving it to a file and dragging it onto the composer.`)}catch{U.error(`Clipboard read denied. Grant clipboard permission, or drag the image onto the composer instead.`)}})():U.error(`Couldn't read the pasted image. Try dragging the file onto the composer instead.`);return}s&&(e.preventDefault(),U.error(`Paste-from-file-manager isn't supported. Drag the file onto the composer instead.`))},[ne,v]),fe=(0,z.useCallback)(t=>{if(t.preventDefault(),v||!e.sessionAlive)return;let n=Array.from(t.dataTransfer.files);n.length!==0&&ne(n)},[ne,v,e.sessionAlive]),pe=(0,z.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.kind===`file`)&&e.preventDefault()},[]),me=(0,z.useCallback)(async a=>{let o=N.current;if(!o){console.warn(`[ComposerFooter] handleSubmit: editor ref not ready`);return}if(ee){console.warn(`[ComposerFooter] handleSubmit: isDisabled=true, sessionAlive=%s sending=%s`,e.sessionAlive,v);return}let s=a?.trim()??``;a===void 0&&o.read(()=>{s=QV().getTextContent().trim()});let c=s.match(/^\/(?:pan[\s-])?handoff(?:\s+(.+))?$/i);if(c){DG(e,`handoff`,c[1]?.trim()||void 0),o.update(()=>{QV().clear()}),E(``);return}let l=e.name,u=Nnt(l);if(u.filter(e=>!e.serverPath&&!e.error).length>0){U.error(`Please wait for uploads to finish`);return}if(u.filter(e=>e.error).length>0){U.error(`Remove failed uploads before sending`);return}let d=u.filter(e=>e.serverPath);if(!s&&d.length===0)return;b(l,!0);let f=[d.map(e=>`@${e.serverPath}`).join(`
|
|
322
|
+
`}isInline(){return!1}updateDOM(){return!1}};function dtt(){return{node:yW()}}function yW(){return Det(utt)}var ftt=TU({name:`@lexical/react/ReactProvider`});function ptt(){return QV().getTextContent()}function mtt(e,t=!0){if(e)return!1;let n=ptt();return t&&(n=n.trim()),n===``}function htt(e){if(!mtt(e,!1))return!1;let t=QV().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(mV(n))return!1;if(dV(n)){if(!CV(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!cB(n))return!1}}}return!0}function bW(e){return()=>htt(e)}function gtt(e){let t=window.location.origin,n=n=>{if(n.origin!==t)return;let r=e.getRootElement();if(document.activeElement!==r)return;let i=n.data;if(typeof i==`string`){let t;try{t=JSON.parse(i)}catch{return}if(t&&t.protocol===`nuanria_messaging`&&t.type===`request`){let r=t.payload;if(r&&r.functionId===`makeChanges`){let t=r.args;if(t){let[r,i,a,o,s]=t;e.update(()=>{let e=jB();if(_B(e)){let t=e.anchor,c=t.getNode(),l=0,u=0;if(cB(c)&&r>=0&&i>=0&&(l=r,u=r+i,e.setTextNodeRange(c,l,c,u)),l===u&&a===``||(e.insertRawText(a),c=t.getNode()),cB(c)){l=o,u=o+s;let t=c.getTextContentSize();l=l>t?t:l,u=u>t?t:u,e.setTextNodeRange(c,l,c,u)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener(`message`,n,!0),()=>{window.removeEventListener(`message`,n,!0)}}function _tt(e,t){if(typeof document>`u`||typeof window>`u`&&global.window===void 0)throw Error(`To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.`);let n=document.createElement(`div`),r=QV().getChildren();for(let i=0;i<r.length;i++)xW(e,r[i],n,t);return n.innerHTML}function xW(e,t,n,r=null){let i=r===null||t.isSelected(r),a=dV(t)&&t.excludeFromCopy(`html`),o=t;r!==null&&cB(t)&&(o=Xet(r,t,`clone`));let s=dV(o)?o.getChildren():[],c=AV(e,o.getType()),l;l=c&&c.exportDOM!==void 0?c.exportDOM(e,o):o.exportDOM(e);let{element:u,after:d}=l;if(!u)return!1;let f=document.createDocumentFragment();for(let n=0;n<s.length;n++){let a=s[n],o=xW(e,a,f,r);!i&&dV(t)&&o&&t.extractWithChild(a,r,`html`)&&(i=!0)}if(i&&!a){if((NH(u)||FH(u))&&u.append(f),n.append(u),d){let e=d.call(o,u);e&&(FH(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(f);return i}function vtt(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ytt(e,t=jB()){return t??vtt(166),_B(t)&&t.isCollapsed()||t.getNodes().length===0?``:_tt(e,t)}function SW(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var CW=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,btt=CW&&`documentMode`in document?document.documentMode:null,xtt=CW&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Stt=!(!CW||!(`InputEvent`in window)||btt)&&`getTargetRanges`in new window.InputEvent(`input`),Ctt=CW&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),wW=CW&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,wtt=CW&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ttt=CW&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&xtt&&!wtt;function TW(e,t){t.update(()=>{if(e!==null){let n=zU(e,KeyboardEvent)?null:e.clipboardData,r=jB();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=ytt(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function Ett(e){return DU(e.registerCommand(WR,e=>{let t=jB();return!!_B(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(XR,e=>{let t=jB();return!!_B(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(ZR,e=>{let t=jB();return!!_B(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(qR,e=>{let t=jB();if(!_B(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)SW(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(YR,()=>{let e=jB();return!!_B(e)&&(e.removeText(),!0)},0),e.registerCommand(GR,e=>{let t=jB();return!!_B(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(KR,()=>{let e=jB();return!!_B(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(rz,e=>{let t=jB();if(!_B(t))return!1;let n=e,r=n.shiftKey;return!!FU(t,!0)&&(n.preventDefault(),LU(t,r,!0),!0)},0),e.registerCommand(nz,e=>{let t=jB();if(!_B(t))return!1;let n=e,r=n.shiftKey;return!!FU(t,!1)&&(n.preventDefault(),LU(t,r,!1),!0)},0),e.registerCommand(az,t=>!!_B(jB())&&(!wW||navigator.language!==`ko-KR`)&&(t.preventDefault(),e.dispatchCommand(WR,!0)),0),e.registerCommand(oz,t=>!!_B(jB())&&(t.preventDefault(),e.dispatchCommand(WR,!1)),0),e.registerCommand(iz,t=>{if(!_B(jB()))return!1;if(t!==null){if((wW||Ctt||Ttt)&&Stt)return!1;t.preventDefault()}return e.dispatchCommand(GR,!1)},0),e.registerCommand(dz,()=>(het(),!0),0),e.registerCommand(lz,t=>!!_B(jB())&&(TW(t,e),!0),0),e.registerCommand(uz,t=>!!_B(jB())&&(function(e,t){TW(e,t),t.update(()=>{let e=jB();_B(e)&&e.removeText()})}(t,e),!0),0),e.registerCommand(JR,t=>!!_B(jB())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=jB(),n=zU(e,ClipboardEvent)?e.clipboardData:null;n!=null&&_B(t)&&SW(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(sz,e=>!!_B(jB())&&(e.preventDefault(),!0),0),e.registerCommand(cz,e=>!!_B(jB())&&(e.preventDefault(),!0),0))}function Dtt(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var EW=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function Ott({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,z.useState)(()=>e.getDecorators());return EW(()=>e.registerDecoratorListener(e=>{(0,pl.flushSync)(()=>{r(e)})}),[e]),(0,z.useEffect)(()=>{r(e.getDecorators())},[e]),(0,z.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,B.jsx)(t,{onError:t=>e._onError(t),children:(0,B.jsx)(z.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,pl.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function ktt({editor:e,ErrorBoundary:t}){return function(e){let t=ltt.maybeFromEditor(e);if(t&&t.hasExtensionByName(ftt.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&Dtt(320,e);return!0}return!1}(e)?null:(0,B.jsx)(Ott,{editor:e,ErrorBoundary:t})}function DW(e){return e.getEditorState().read(bW(e.isComposing()))}function Att({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=kU();return function(e){EW(()=>DU(Ett(e),gtt(e)),[e])}(r),(0,B.jsxs)(B.Fragment,{children:[e,(0,B.jsx)(jtt,{content:t}),(0,B.jsx)(ktt,{editor:r,ErrorBoundary:n})]})}function jtt({content:e}){let[t]=kU(),n=function(e){let[t,n]=(0,z.useState)(()=>DW(e));return EW(()=>{function t(){n(DW(e))}return t(),DU(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=Jet();return n?typeof e==`function`?e(r):e:null}var OW=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function Mtt({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,z.useState)(e.isEditable()),T=(0,z.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,z.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return OW(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,B.jsx)(`div`,{"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":C&&g===`combobox`?!!o:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y,...x})}var Ntt=(0,z.forwardRef)(Mtt);function kW(e){return e.getEditorState().read(bW(e.isComposing()))}var Ptt=(0,z.forwardRef)(Ftt);function Ftt(e,t){let{placeholder:n,...r}=e,[i]=kU();return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ntt,{editor:i,...r,ref:t}),n!=null&&(0,B.jsx)(Itt,{editor:i,content:n})]})}function Itt({content:e,editor:t}){let n=function(e){let[t,n]=(0,z.useState)(()=>kW(e));return OW(()=>{function t(){n(kW(e))}return t(),DU(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,z.useState)(t.isEditable());if((0,z.useLayoutEffect)(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,B.jsx)(`div`,{"aria-hidden":!0,children:a})}function Ltt(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(_B(a)&&_B(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||gV(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&cB(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!cB(l)||!cB(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function Rtt(e,t){let n=Date.now(),r=0,i=Date.now(),a=0,o=null;return(s,c,l,u,d,f)=>{let p=Date.now();if(f.has(`composition-start`)&&(i=n,a=r,o=s),f.has(`historic`))return r=0,n=p,2;f.has(`composition-end`)&&o&&(n=i,r=a,s=o);let m=Ltt(s,c,u,d,e.isComposing()),h=(()=>{let i=l===null||l.editor===e,a=f.has(U9e);if(!a&&i&&f.has(`history-merge`))return 0;if(m===1)return 2;if(s===null)return 1;let o=c._selection;if(!(u.size>0||d.size>0))return o===null?2:0;let h=typeof t==`number`?t:t.peek();return!1===a&&m!==0&&m===r&&p<n+h&&i||u.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(_B(a)&&_B(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!cB(r)||!cB(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(u)[0],s,c)?0:1})();return n=p,r=m,h}}function AW(e){e.undoStack=[],e.redoStack=[],e.current=null}function ztt(e,t,n){let r=Rtt(e,n);return DU(e.registerCommand($R,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(r.length!==0){let i=t.current,a=r.pop();i!==null&&(n.push(i),e.dispatchCommand(fz,!0)),r.length===0&&e.dispatchCommand(pz,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(ez,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(n.length!==0){let i=t.current;i!==null&&(r.push(i),e.dispatchCommand(pz,!0));let a=n.pop();n.length===0&&e.dispatchCommand(fz,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(M9e,()=>(AW(t),!1),0),e.registerCommand(N9e,()=>(AW(t),e.dispatchCommand(fz,!1),e.dispatchCommand(pz,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:i,dirtyLeaves:a,dirtyElements:o,tags:s})=>{let c=t.current,l=t.redoStack,u=t.undoStack,d=c===null?null:c.editorState;if(c!==null&&n===d)return;let f=r(i,n,c,a,o,s);if(f===1)l.length!==0&&(t.redoStack=[],e.dispatchCommand(fz,!1)),c!==null&&(u.push({...c}),e.dispatchCommand(pz,!0));else if(f===2)return;t.current={editor:e,editorState:n}}))}function Btt(){return{current:null,redoStack:[],undoStack:[]}}function Vtt({delay:e,externalHistoryState:t}){let[n]=kU();return function(e,t,n=1e3){let r=(0,z.useMemo)(()=>t||Btt(),[t]);(0,z.useEffect)(()=>ztt(e,r,n),[n,e,r])}(n,t,e),null}var Htt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?z.useLayoutEffect:z.useEffect;function Utt({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){let[r]=kU();return Htt(()=>{if(n)return r.registerUpdateListener(({editorState:i,dirtyElements:a,dirtyLeaves:o,prevEditorState:s,tags:c})=>{t&&a.size===0&&o.size===0||e&&c.has(`history-merge`)||s.isEmpty()||n(i,r,c)})},[r,e,t,n]),null}var Wtt=[{id:`handoff`,label:`/handoff`,description:`Open the handoff dialog for this conversation (trailing text becomes focus)`,insert:`/handoff `,category:`Conversation`}],Gtt=cCe.map(e=>{let t=e.path.join(` `);return{id:e.id,label:e.display,description:e.description,insert:lCe[t]??`${e.display}${e.args.length>0?` `:``}`,category:`Overdeck`}}),Ktt=uCe.map(e=>({id:e.id,label:e.display,description:e.description,insert:e.insert,category:`Overdeck`}));function jW(e){let t=tb(e);return[...(t.nativeCommands??[]).map(n=>({id:`native-${e}-${n.name.slice(1)}`,label:n.name,description:n.description,insert:n.insert,category:`${t.displayName} native`})),...Wtt,...Gtt,...Ktt]}jW(`claude-code`);function MW(e){return`conv-draft:${e}`}function NW(e){try{return localStorage.getItem(MW(e))??``}catch{return``}}function PW(e,t){try{t?localStorage.setItem(MW(e),t):localStorage.removeItem(MW(e))}catch{}}function qtt({conversationName:e,onCommandKeyDown:t,onTextChange:n,onSlashKey:r}){let[i]=kU(),a=(0,z.useRef)(null),o=(0,z.useRef)(NW(e)),s=(0,z.useRef)(!1);return(0,z.useEffect)(()=>i.registerCommand(iz,e=>e?.shiftKey?!1:(e?.preventDefault(),t(`Enter`),!0),3),[i,t]),(0,z.useEffect)(()=>{let e=i.getRootElement();if(!e)return;let t=t=>{if(t.key===`/`&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let n=t.target;(n===e||e.contains(n))&&r(e)}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,r]),(0,z.useEffect)(()=>(s.current=!1,()=>{s.current=!0,a.current&&clearTimeout(a.current),PW(e,o.current)}),[e]),(0,z.useEffect)(()=>{let t=()=>PW(e,o.current),n=()=>{document.visibilityState===`hidden`&&t()};return window.addEventListener(`pagehide`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`pagehide`,t),document.removeEventListener(`visibilitychange`,n)}},[e]),(0,B.jsx)(Utt,{onChange:(0,z.useCallback)(()=>{s.current||i.read(()=>{let t=QV().getTextContent();o.current=t,n(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{PW(e,t)},300)})},[i,e,n])})}function Jtt({editorRef:e}){let[t]=kU();return(0,z.useEffect)(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}var Ytt=[`overdeck`,`ovr`];function FW(e,t){let n=t.toLowerCase(),r=Ytt.find(e=>n===e||n.startsWith(`${e} `)),i=r?`pan${n.slice(r.length)}`:null;return e.filter(e=>{let t=`${e.label} ${e.description}`.toLowerCase();return t.includes(n)||i!==null&&t.includes(i)})}function IW(e,t,n){if(!t)return e;let r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);if(a<0)return e;let o=a+t.length;return(0,B.jsxs)(B.Fragment,{children:[e.slice(0,a),(0,B.jsx)(`mark`,{className:n,children:e.slice(a,o)}),e.slice(o)]})}function Xtt({commands:e,filter:t,selectedIndex:n,onSelect:r,onClose:i,anchorRect:a}){let o=FW(e,t),s=(0,z.useRef)(null);if((0,z.useEffect)(()=>{let e=e=>{e.target.closest(`.${Z.slashMenu}`)||i()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),(0,z.useEffect)(()=>{if(s.current){let e=s.current.querySelector(`[aria-selected="true"]`);e&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`nearest`})}},[n]),o.length===0)return null;let c=a?a.left:0,l=a?window.innerHeight-a.top+4:0,u=o.reduce((e,t)=>{let n=t.category||`Commands`;return e[n]||(e[n]=[]),e[n].push(t),e},{}),d=Object.keys(u);return(0,B.jsx)(`div`,{ref:s,className:Z.slashMenu,style:{bottom:l,left:c},role:`listbox`,"aria-label":`Slash commands`,children:d.map(e=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-gray-500 px-3 py-1.5`,children:e}),u[e].map(e=>{let i=o.findIndex(t=>t.id===e.id),a=t?e.label.toLowerCase().includes(t.toLowerCase()):!1;return(0,B.jsxs)(`button`,{className:`${Z.slashMenuItem} ${i===n?Z.slashMenuItemSelected:``}`,onClick:()=>r(e),role:`option`,"aria-selected":i===n,children:[(0,B.jsx)(`span`,{className:Z.slashMenuLabel,children:a?IW(e.label,t,Z.slashMenuMatch):e.label}),(0,B.jsx)(`span`,{className:Z.slashMenuDescription,children:a?e.description:IW(e.description,t,Z.slashMenuMatch)})]},e.id)})]},e))})}function Ztt({conversationName:e,harness:t=`claude-code`,disabled:n=!1,placeholder:r=`Message the agent…`,onCommandKeyDown:i,editorRef:a,onChange:o,onPaste:s}){let c=NW(e),[l,u]=(0,z.useState)(c),[d,f]=(0,z.useState)(!1),p=(0,z.useRef)(!1),[m,h]=(0,z.useState)(0),[g,_]=(0,z.useState)(null),v={namespace:`composer:${e}`,onError:e=>console.error(`[ComposerPromptEditor]`,e),...c?{editorState:e=>{let t=QV(),n=SV();n.append(sB(c)),t.append(n)}}:{}},y=(0,z.useCallback)(e=>{u(e),p.current&&e.includes(`/`)&&(f(!0),p.current=!1),o?.(e)},[o]),b=(0,z.useMemo)(()=>{let e=l.lastIndexOf(`/`);return e<0?null:{slashIdx:e,filterText:l.slice(e+1)}},[l]),x=(0,z.useMemo)(()=>jW(t),[t]),S=(0,z.useMemo)(()=>FW(x,b?.filterText??``),[x,b]),C=(0,z.useCallback)(e=>{let t=window.getSelection(),n=null;if(t&&t.rangeCount>0){let e=t.getRangeAt(0).getBoundingClientRect();(e.width>0||e.height>0||e.top>0||e.left>0||e.bottom>0)&&(n=e)}n||=e.getBoundingClientRect(),_(n),p.current=!0,f(!0),h(0)},[]),w=(0,z.useCallback)(e=>{let t=a?.current;t&&t.update(()=>{let t=QV(),n=t.getTextContent(),r=b?.slashIdx??n.lastIndexOf(`/`),i=r>=0?n.slice(0,r):n;t.clear();let a=SV();a.append(sB(i+e.insert)),t.append(a)}),f(!1),p.current=!1,h(0)},[a,b]),T=(0,z.useCallback)(()=>{f(!1),p.current=!1,h(0)},[]);return(0,z.useEffect)(()=>{d&&!p.current&&!b&&T()},[d,b,T]),(0,z.useEffect)(()=>{h(0)},[b?.filterText]),(0,z.useEffect)(()=>{if(!d||!b)return;let e=e=>{e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),S.length>0&&h(e=>(e+1)%S.length)):e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),S.length>0&&h(e=>(e-1+S.length)%S.length)):e.key===`Enter`?S.length>0&&S[m]&&(e.preventDefault(),e.stopPropagation(),w(S[m])):e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),T()):e.key===`Tab`&&T()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[d,b,m,S,w,T]),(0,B.jsxs)(`div`,{style:{position:`relative`},children:[(0,B.jsx)(Get,{initialConfig:v,children:(0,B.jsxs)(`div`,{className:`${Z.composerEditor} ${n?Z.composerEditorDisabled:``}`,children:[(0,B.jsx)(Att,{contentEditable:(0,B.jsx)(Ptt,{className:Z.composerEditable,onPaste:s,"aria-placeholder":r,placeholder:()=>l?null:(0,B.jsx)(`div`,{className:Z.composerPlaceholder,children:r})}),ErrorBoundary:({children:e})=>(0,B.jsx)(B.Fragment,{children:e})}),(0,B.jsx)(Vtt,{}),(0,B.jsx)(qtt,{conversationName:e,onCommandKeyDown:i,onTextChange:y,onSlashKey:C}),a&&(0,B.jsx)(Jtt,{editorRef:a})]})},e),d&&S.length>0&&(0,B.jsx)(Xtt,{commands:x,filter:b?.filterText??``,selectedIndex:m,onSelect:w,onClose:T,anchorRect:g})]})}var Qtt=25e4,$tt=6e3;function ent(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function tnt({onCommitted:e}={}){let[t,n]=(0,z.useState)(``),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),d=(0,z.useRef)(null),f=(0,z.useRef)(null),p=(0,z.useRef)(null),m=(0,z.useRef)(null),h=(0,z.useRef)(null),g=(0,z.useRef)(null),_=(0,z.useRef)(``),v=(0,z.useRef)(null),y=(0,z.useCallback)(e=>{o(!1),e&&d.current?.close(),e&&(d.current=null),h.current?.disconnect(),m.current?.disconnect(),g.current?.disconnect(),p.current?.close(),f.current?.getTracks().forEach(e=>e.stop()),h.current=null,m.current=null,g.current=null,p.current=null,f.current=null,u(null)},[]),b=(0,z.useCallback)(async(e=!0)=>{let t=d.current;return y(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,$tt);v.current=()=>{window.clearTimeout(t),e()}}),v.current=null),y(!0),_.current},[y]),x=(0,z.useCallback)(async t=>{if(!a){c(null);try{let r=await navigator.mediaDevices.getUserMedia({audio:t?{deviceId:{exact:t}}:!0}),a=new AudioContext({sampleRate:16e3}),s=a.createMediaStreamSource(r),l=a.createAnalyser(),y=a.createScriptProcessor(4096,1,1),x=new WebSocket(ent(`/ws/voice`));x.binaryType=`arraybuffer`,x.onmessage=t=>{let r=JSON.parse(String(t.data));if(r.type===`transcript:partial`&&n(r.text),r.type===`transcript:committed`){n(``);let t=[_.current,r.text].filter(Boolean).join(` `);_.current=t,i(t),e?.(r.text)}r.type===`transcript:finalized`&&v.current?.(),r.type===`error`&&c(r.error)},x.onerror=()=>c(`Voice connection failed`),x.onclose=()=>{d.current===x&&b(!1)},y.onaudioprocess=e=>{if(x.readyState!==WebSocket.OPEN||x.bufferedAmount>Qtt)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}x.send(n.buffer)},s.connect(l),l.connect(y),y.connect(a.destination),d.current=x,f.current=r,p.current=a,m.current=s,g.current=l,h.current=y,u(l),o(!0)}catch(e){c(e instanceof Error?e.message:`Unable to start voice input`),b()}}},[a,e,b]),S=(0,z.useCallback)(()=>{n(``),i(``),_.current=``},[]);return(0,z.useEffect)(()=>()=>{b(!1)},[b]),{start:x,stop:b,partialText:t,committedText:r,isListening:a,error:s,analyserNode:l,resetTranscript:S}}function nnt({conversation:e,onInsert:t,onSendDirect:n,onStateChange:r,autoStartToken:i=0}){let[a,o]=(0,z.useState)(`edit`),[s,c]=(0,z.useState)([]),[l,u]=(0,z.useState)(``),d=(0,z.useRef)(null),f=(0,z.useRef)(a),{start:p,stop:m,partialText:h,committedText:g,isListening:_,error:v,analyserNode:y,resetTranscript:b}=tnt({onCommitted:e=>{f.current===`direct`&&n(e)}}),x=[g,h].filter(Boolean).join(` `);(0,z.useEffect)(()=>{f.current=a},[a]),(0,z.useEffect)(()=>(r?.({isListening:_,error:v}),()=>r?.({isListening:!1,error:null})),[v,_,r]),(0,z.useEffect)(()=>{i<=0||_||p(l||void 0)},[i,l,_,p]),(0,z.useEffect)(()=>{navigator.mediaDevices?.enumerateDevices?.().then(e=>{c(e.filter(e=>e.kind===`audioinput`))})},[]),(0,z.useEffect)(()=>{let e=d.current,t=y;if(!e||!t||!_)return;let n=e.getContext(`2d`);if(!n)return;let r=new Uint8Array(t.frequencyBinCount),i=0,a=()=>{i=window.requestAnimationFrame(a),t.getByteTimeDomainData(r),n.clearRect(0,0,e.width,e.height),n.strokeStyle=`hsl(210 100% 62%)`,n.lineWidth=2,n.beginPath(),r.forEach((t,i)=>{let a=i/Math.max(1,r.length-1)*e.width,o=t/255*e.height;i===0?n.moveTo(a,o):n.lineTo(a,o)}),n.stroke()};return a(),()=>window.cancelAnimationFrame(i)},[y,_]);let S=(0,z.useCallback)(()=>{(async()=>{let e=(await m()).trim();a===`edit`&&e&&t(e),b()})()},[a,t,b,m]),C=(0,z.useCallback)(()=>{m(!1),b()},[b,m]);return(0,B.jsxs)(`div`,{className:Z.voiceWidget,"data-testid":`voice-widget`,children:[(0,B.jsxs)(`div`,{className:Z.voiceWidgetHeader,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:Z.voiceWidgetTitle,children:`Voice input`}),(0,B.jsx)(`div`,{className:Z.voiceWidgetMeta,children:e.name})]}),(0,B.jsxs)(`div`,{className:Z.voiceModeToggle,role:`group`,"aria-label":`Voice send mode`,children:[(0,B.jsx)(`button`,{type:`button`,className:a===`edit`?Z.voiceModeActive:Z.voiceModeButton,onClick:()=>o(`edit`),title:`Transcript fills the composer so you can review and edit before sending`,children:`Edit`}),(0,B.jsx)(`button`,{type:`button`,className:a===`direct`?Z.voiceModeActive:Z.voiceModeButton,onClick:()=>o(`direct`),title:`Each finished sentence is sent to the agent immediately`,children:`Direct`})]})]}),(0,B.jsx)(`div`,{className:Z.voiceWidgetControls,children:(0,B.jsxs)(`label`,{className:Z.voiceFieldLabel,children:[`Mic`,(0,B.jsxs)(`select`,{className:Z.voiceSelect,value:l,onChange:e=>u(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Default microphone`}),s.map((e,t)=>(0,B.jsx)(`option`,{value:e.deviceId,children:e.label||`Microphone ${t+1}`},e.deviceId))]})]})}),(0,B.jsx)(`canvas`,{ref:d,className:Z.voiceWaveformCanvas,width:480,height:56,"aria-label":`Voice waveform`}),(0,B.jsx)(`textarea`,{className:Z.voiceTranscriptPreview,value:x,readOnly:!0,placeholder:v?`Voice error: ${v}`:`Live transcript preview will appear here…`}),(0,B.jsx)(`div`,{className:Z.voiceWidgetMeta,children:a===`edit`?`Edit mode — Insert transcript drops the text into the composer so you can review it before sending.`:`Direct mode — each finished sentence is sent to the agent as you speak.`}),(0,B.jsxs)(`div`,{className:Z.voiceWidgetActions,children:[(0,B.jsxs)(`button`,{type:`button`,className:_?Z.voiceStopButton:Z.voiceStartButton,onClick:()=>_?S():void p(l||void 0),children:[_?(0,B.jsx)(Sc,{size:14}):(0,B.jsx)(Cc,{size:14}),_?`Listening`:`Start`]}),(0,B.jsxs)(`button`,{type:`button`,className:Z.voiceSecondaryButton,onClick:C,children:[(0,B.jsx)(sl,{size:14}),` Discard`]}),a===`edit`&&(0,B.jsxs)(`button`,{type:`button`,className:Z.voiceInsertButton,onClick:S,disabled:!x.trim(),children:[(0,B.jsx)(us,{size:14}),` Insert transcript`]})]})]})}var LW={"claude-fable-5":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-5":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-4-8":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-4-7":[`low`,`medium`,`high`,`xhigh`,`max`],"claude-opus-4-6":[`low`,`medium`,`high`,`max`],"claude-sonnet-5":[`low`,`medium`,`high`],"claude-sonnet-4-6":[`low`,`medium`,`high`],"claude-haiku-4-5-20251001":[]},rnt={...LW},RW={anthropic:`Anthropic`,openai:`OpenAI`,google:`Google`,minimax:`MiniMax`,zai:`Z.AI`,kimi:`Kimi`,mimo:`Xiaomi MiMo`,nous:`Nous Portal`,dashscope:`Alibaba DashScope`,openrouter:`OpenRouter`},zW=[{provider:`anthropic`,label:`Anthropic`,models:[{id:`claude-fable-5`,label:`Claude Fable 5`,provider:`anthropic`,costDisplay:`$90/1M`,costPer1MTokens:90,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-opus-5`,label:`Claude Opus 5`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-opus-4-8`,label:`Claude Opus 4.8`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-opus-4-7`,label:`Claude Opus 4.7`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`xhigh`,`max`]},{id:`claude-sonnet-5`,label:`Claude Sonnet 5`,provider:`anthropic`,costDisplay:`$6/1M`,costPer1MTokens:6,effortLevels:[`low`,`medium`,`high`]},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`,provider:`anthropic`,costDisplay:`$15/1M`,costPer1MTokens:15,effortLevels:[`low`,`medium`,`high`]},{id:`claude-opus-4-6`,label:`Claude Opus 4.6`,provider:`anthropic`,costDisplay:`$45/1M`,costPer1MTokens:45,effortLevels:[`low`,`medium`,`high`,`max`]},{id:`claude-haiku-4-5-20251001`,label:`Claude Haiku 4.5`,provider:`anthropic`,costDisplay:`$1/1M`,costPer1MTokens:1,effortLevels:[]}]},{provider:`openai`,label:`OpenAI`,models:[{id:`gpt-6-astra`,label:`GPT-6 Astra`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-sol`,label:`GPT-5.6 Sol`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-sol[372k]`,label:`GPT-5.6 Sol 372K`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-terra`,label:`GPT-5.6 Terra`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-terra[372k]`,label:`GPT-5.6 Terra 372K`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-luna`,label:`GPT-5.6 Luna`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.6-luna[372k]`,label:`GPT-5.6 Luna 372K`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.5`,label:`GPT-5.5`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]},{id:`gpt-5.4`,label:`GPT-5.4`,provider:`openai`,costDisplay:`$0/1M`,effortLevels:[]}]}],BW=`conv-composer-model`,VW=`conv-composer-harness`,HW=`Experimental: converts the transcript to the new harness format. May lose fidelity; falls back to a fresh session on failure.`,int=``,UW=new Set(zW.flatMap(e=>e.models.map(e=>e.id)));function WW(e){return UW.has(e)}var GW=new Set;function ant(e){return GW.add(e),()=>{GW.delete(e)}}function KW(e){UW=new Set(e.flatMap(e=>e.models.map(e=>e.id)));for(let e of GW)e()}function qW(e=DD()){try{let e=localStorage.getItem(BW);if(e&&WW(e))return e}catch{}return e||int}function JW(e){try{localStorage.setItem(BW,e)}catch{}}function ont(){try{let e=localStorage.getItem(VW);if(ZW(e))return e}catch{}return`claude-code`}function YW(e){try{localStorage.setItem(VW,e)}catch{}}function XW(e){return e===0?`FREE`:e<1?`$${e.toFixed(2)}/1M`:`$${Math.round(e)}/1M`}function ZW(e){return e===`claude-code`||e===`ohmypi`||e===`codex`||e===`acp`||e===`kimi-code`}function QW(e,t){return t[e]??`claude-code`}function $W({value:e,onChange:t,disabled:n=!1,harness:r,onHarnessChange:i,onComboChange:a,liveConversation:o=!1,followProviderDefault:s=!1}){let[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(zW),[f,p]=(0,z.useState)({}),[m,h]=(0,z.useState)({anthropic:`claude-code`,openai:`codex`}),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(null),w=(0,z.useRef)(null),T=(0,z.useRef)(o);T.current=o;let{openUp:E,align:D,maxHeight:O}=Jx(c,w);(0,z.useEffect)(()=>{c||x(``)},[c]),(0,z.useEffect)(()=>{async function n(){try{await OD();let[n,r,i]=await Promise.allSettled([fetch(`/api/settings/available-models`).then(e=>e.json()),fetch(`/api/settings/openrouter/models`).then(e=>e.json()),fetch(`/api/settings`).then(e=>e.json())]),a=n.status===`fulfilled`?n.value:{},o=r.status===`fulfilled`?r.value:{models:[],favorites:[]};if(i.status===`fulfilled`){let e=i.value.models?.provider_default_harnesses??{},t=i.value.models?.provider_harnesses??{},n={};for(let[t,r]of Object.entries(e))ZW(r)&&(n[t]=r);for(let[e,r]of Object.entries(t))ZW(r)&&(n[e]=r);h(e=>({...e,...n})),y(i.value.experimental?.showHarnessModelPermutations===!0),_(!0)}let s=[];for(let[e,t]of Object.entries(a)){if(e===`openrouter`||!Array.isArray(t)||t.length===0)continue;let n=t.map(t=>({id:t.id,label:t.baseName??t.name.replace(/ — Kimi Code CLI$/,``),provider:e,costDisplay:XW(t.costPer1MTokens),costPer1MTokens:t.costPer1MTokens,effortLevels:t.effortLevels??rnt[t.id]??[],baseName:t.baseName}));s.push({provider:e,label:RW[e]??e,models:RWe(n)})}let c=new Set(o.favorites??[]),l=(o.models??[]).filter(e=>c.has(e.id));l.length>0&&s.push({provider:`openrouter`,label:`OpenRouter`,models:l.map(e=>({id:e.id,label:e.name,provider:`openrouter`,costDisplay:XW(e.promptCostPer1M),costPer1MTokens:e.promptCostPer1M,effortLevels:e.supportsThinking?[`low`,`medium`,`high`]:[]}))});let u=s.length>0?s:zW;KW(u),s.length>0&&d(s);let f=qW(DD());!T.current&&f&&f!==e&&WW(f)&&t(f,u.flatMap(e=>e.models).find(e=>e.id===f)?.effortLevels??[]);let m=u.flatMap(e=>e.models.map(e=>e.id));m.length>0&&p((await fetch(`/api/settings/harness-policy?models=${encodeURIComponent(m.join(`,`))}`).then(e=>e.json())).decisions??{})}catch{KW(zW)}}n()},[]),(0,z.useEffect)(()=>{if(!c)return;function e(e){w.current&&!w.current.contains(e.target)&&l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let k=(0,z.useMemo)(()=>{let e=u;S!==null&&(e=e.filter(e=>e.provider===S));let t=b.trim().toLowerCase();return t&&(e=e.map(e=>({...e,models:e.models.filter(e=>e.label.toLowerCase().includes(t))})).filter(e=>e.models.length>0)),e},[u,S,b]),A=u.flatMap(e=>e.models),j=A.find(t=>t.id===e&&(t.harness===void 0||t.harness===r))??A.find(t=>t.id===e),M=j?QW(j.provider,m):void 0,N=j?.harness??(v?r:M??r),P=AD(j?.costPer1MTokens);(0,z.useEffect)(()=>{!s||!g||v||!M||M===r||!i||(i(M),YW(M))},[s,g,v,M,r,i]);let F=u.length>1,I=k.length>1,L=k.length>1;function ee(e){let n=e.harness??QW(e.provider,m),o=r!==void 0&&i,s=o&&r!==n;o&&(e.harness!==void 0||!v&&s)?(a?a(e.id,e.effortLevels,n):(t(e.id,e.effortLevels),i(n)),YW(n)):t(e.id,e.effortLevels),localStorage.setItem(BW,e.id),l(!1)}let R=j?.label??e;return(0,B.jsxs)(`div`,{ref:w,className:Z.pickerContainer,children:[(0,B.jsxs)(`button`,{className:Z.pickerBtn,onClick:()=>l(e=>!e),disabled:n,type:`button`,children:[j&&(0,B.jsx)(ID,{provider:j.provider,label:RW[j.provider]??j.provider,className:Z.pickerProviderIcon}),(0,B.jsx)(`span`,{className:Z.pickerLabel,children:R}),N===`ohmypi`&&(0,B.jsxs)(`span`,{className:Z.harnessIndicator,title:`oh-my-pi harness active`,children:[(0,B.jsx)(FD,{harness:`ohmypi`,className:Z.harnessIndicatorIcon}),`oh-my-pi`]}),N===`codex`&&(0,B.jsxs)(`span`,{className:Z.harnessIndicator,title:`Codex harness active`,children:[(0,B.jsx)(FD,{harness:`codex`,className:Z.harnessIndicatorIcon}),`Codex`]}),P&&(0,B.jsx)(jD,{level:P,compact:!0,costPer1MTokens:j?.costPer1MTokens}),(0,B.jsx)(ds,{size:11})]}),c&&(0,B.jsxs)(`div`,{className:`${Z.pickerDropdown} ${E?Z.pickerDropdownUp:``}`,style:{maxHeight:`${O}px`,...D===`right`?{left:`auto`,right:0}:{}},children:[F&&(0,B.jsxs)(`div`,{className:Z.pickerProviderSidebar,children:[(0,B.jsx)(`button`,{type:`button`,className:`${Z.pickerProviderBtn} ${S===null?Z.pickerProviderBtnActive:``}`,onClick:()=>C(null),title:`All providers`,children:(0,B.jsx)(fc,{size:13})}),u.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`${Z.pickerProviderBtn} ${S===e.provider?Z.pickerProviderBtnActive:``}`,onClick:()=>C(e.provider),title:e.label,children:(0,B.jsx)(ID,{provider:e.provider,label:e.label,className:Z.pickerProviderBtnIcon})},e.provider))]}),(0,B.jsxs)(`div`,{className:Z.pickerMainPanel,children:[v&&r!==void 0&&i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`${Z.pickerGroupHeader} ${Z.pickerHarnessHeader}`,children:`Harness`}),jWe.map(t=>{let n=LD(t.id,e,f),a=r===t.id,s=!n.allowed,c=o&&!a,l=c?HW:s?n.reason??t.description:t.description;return(0,B.jsxs)(`button`,{type:`button`,className:`${Z.harnessOption} ${a?Z.harnessOptionActive:``} ${s?Z.harnessOptionLocked:``}`,onClick:()=>{a||s||i(t.id)},disabled:s,title:l,children:[(0,B.jsx)(`span`,{className:Z.harnessOptionIcon,children:a?(0,B.jsx)(us,{size:11}):(0,B.jsx)(FD,{harness:t.id,className:Z.harnessOptionLogo})}),(0,B.jsxs)(`span`,{className:Z.harnessOptionBody,children:[(0,B.jsxs)(`span`,{className:Z.harnessOptionNameRow,children:[a&&(0,B.jsx)(FD,{harness:t.id,className:Z.harnessOptionLogo}),(0,B.jsx)(`span`,{className:Z.harnessOptionName,children:t.label}),c&&(0,B.jsx)(`span`,{className:Z.harnessOptionExperimental,children:`Experimental`})]}),t.description&&(0,B.jsx)(`span`,{className:Z.harnessOptionDesc,children:t.description}),c&&(0,B.jsx)(`span`,{className:Z.harnessOptionDesc,children:HW}),s&&n.reason&&(0,B.jsx)(`span`,{className:Z.harnessOptionNote,children:n.reason})]})]},t.id)}),(0,B.jsx)(`div`,{className:Z.pickerSectionDivider})]}),(0,B.jsxs)(`div`,{className:Z.pickerSearchWrapper,children:[(0,B.jsx)(Vc,{size:11,className:Z.pickerSearchIcon}),(0,B.jsx)(`input`,{type:`text`,className:Z.pickerSearchInput,placeholder:`Search models…`,value:b,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),autoFocus:!0})]}),(0,B.jsx)(`div`,{className:Z.pickerScrollContent,children:k.length>0?k.map(t=>(0,B.jsxs)(`div`,{children:[L&&(0,B.jsx)(`div`,{className:Z.pickerGroupHeader,children:t.label}),t.models.map(t=>{let n=AD(t.costPer1MTokens),i=t.harness??(v?r:QW(t.provider,m)),a=i?LD(i,t.id,f):{allowed:!0},o=!a.allowed,s=t.id===e&&(t.harness===void 0||t.harness===r);return(0,B.jsx)(`button`,{className:`${Z.pickerOption} ${s?Z.pickerOptionActive:``} ${o?Z.pickerOptionLocked:``}`,onClick:()=>{o||ee(t)},disabled:o,title:o?a.reason:void 0,type:`button`,children:(0,B.jsxs)(`span`,{className:Z.pickerOptionContent,children:[(0,B.jsxs)(`span`,{className:Z.pickerOptionRow,children:[(0,B.jsx)(`span`,{className:Z.pickerOptionLabel,children:t.label}),o&&(0,B.jsx)(`span`,{className:Z.pickerOptionLockIcon,title:a.reason,children:(0,B.jsx)(_c,{size:10})}),n&&(0,B.jsx)(jD,{level:n,compact:!0,costPer1MTokens:t.costPer1MTokens}),t.costDisplay&&(0,B.jsx)(`span`,{className:Z.pickerCostBadge,children:t.costDisplay})]}),I&&(0,B.jsxs)(`span`,{className:Z.pickerOptionSubtitle,children:[(0,B.jsx)(kWe,{provider:t.provider}),RW[t.provider]??t.provider]})]})},`${t.id}::${t.harness??``}`)})]},t.provider)):(0,B.jsxs)(`div`,{className:Z.pickerNoResults,children:[`No models match “`,b,`”`]})})]})]})]})}var eG={anthropic:{name:`Anthropic`,models:[{id:`claude-fable-5`,name:`Claude Fable 5`,icon:Zs,tier:`premium`,costPer1MTokens:90,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Mythos-class flagship — long-horizon autonomous work, low→max effort. ~2× Opus pricing ($10 in / $50 out).`},{id:`claude-opus-5`,name:`Claude Opus 5`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Current Opus (July 2026) — near-Fable-5 capability at half the cost, 1M context, low→max effort`},{id:`claude-opus-4-8`,name:`Claude Opus 4.8`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous flagship — xhigh/max effort, deepest reasoning`},{id:`claude-opus-4-7`,name:`Claude Opus 4.7`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous flagship — xhigh/max effort, deepest reasoning`},{id:`claude-opus-4-6`,name:`Claude Opus 4.6`,icon:Zs,tier:`premium`,costPer1MTokens:45,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous Opus, strong reasoning and planning`},{id:`claude-sonnet-5`,name:`Claude Sonnet 5`,icon:Xc,tier:`balanced`,costPer1MTokens:6,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Current Sonnet — 1M context, intro pricing through Aug 31, 2026`},{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`,icon:Xc,tier:`balanced`,costPer1MTokens:9,capabilities:[`reasoning`,`code`,`vision`,`agentic`],description:`Previous Sonnet — fast, capable, great for implementation`},{id:`claude-haiku-4-5`,name:`Claude Haiku 4.5`,icon:cl,tier:`fast`,costPer1MTokens:1,capabilities:[`fast`,`cost-efficient`,`code`],description:`Fastest, ideal for simple tasks`}]},openai:{name:`OpenAI`,models:[{id:`gpt-6-astra`,name:`GPT-6 Astra`,icon:Zs,tier:`premium`,costPer1MTokens:30,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI flagship (September 2026), first GPT-6 generation. 272K session window (billing-tier safe), $10 in / $50 out per 1M.`},{id:`gpt-5.6-sol`,name:`GPT-5.6 Sol`,icon:Zs,tier:`premium`,costPer1MTokens:17.5,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI flagship (July 2026), new default. 272K session window (billing-tier safe), $5 in / $30 out per 1M.`},{id:`gpt-5.6-sol[372k]`,name:`GPT-5.6 Sol 372K`,icon:Zs,tier:`premium`,costPer1MTokens:17.5,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Sol with the 372K long-context window. Input past 272K bills at 2x in / 1.5x out for the whole request — for long-research sessions that accept the surcharge.`},{id:`gpt-5.6-terra`,name:`GPT-5.6 Terra`,icon:Xc,tier:`balanced`,costPer1MTokens:7,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI balanced tier (July 2026). GPT-5.5-competitive at lower cost. 272K session window (billing-tier safe), $2 in / $12 out per 1M.`},{id:`gpt-5.6-terra[372k]`,name:`GPT-5.6 Terra 372K`,icon:Xc,tier:`balanced`,costPer1MTokens:7,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Terra with the 372K long-context window. Input past 272K bills at 2x in / 1.5x out for the whole request.`},{id:`gpt-5.6-luna`,name:`GPT-5.6 Luna`,icon:cl,tier:`fast`,costPer1MTokens:.7,capabilities:[`fast`,`cost-efficient`,`code`],description:`OpenAI fastest/cheapest tier (July 2026). 272K session window (billing-tier safe), $0.20 in / $1.20 out per 1M.`},{id:`gpt-5.6-luna[372k]`,name:`GPT-5.6 Luna 372K`,icon:cl,tier:`fast`,costPer1MTokens:.7,capabilities:[`fast`,`cost-efficient`,`code`],description:`Luna with the 372K long-context window. Input past 272K bills at 2x in / 1.5x out for the whole request.`},{id:`gpt-5.5`,name:`GPT-5.5`,icon:Zs,tier:`premium`,costPer1MTokens:17.5,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`OpenAI flagship (April 2026). 1.05M context, $5 in / $30 out per 1M.`},{id:`gpt-5.4`,name:`GPT-5.4`,icon:Xc,tier:`balanced`,costPer1MTokens:8.75,capabilities:[`reasoning`,`code`,`vision`,`agentic`,`large-context`],description:`Balanced GPT-5.4. 1.05M context, strong coding.`},{id:`gpt-5.4-mini`,name:`GPT-5.4 Mini`,icon:Ws,tier:`fast`,costPer1MTokens:2.625,capabilities:[`fast`,`cost-efficient`,`code`],description:`Fast and efficient. 400K context. $0.75 in / $4.50 out.`},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,icon:Zs,tier:`premium`,costPer1MTokens:7.875,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Coding-optimized (Feb 2026). 400K context, 85% SWE-Bench Verified. $1.75 in / $14 out.`},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,icon:cl,tier:`fast`,costPer1MTokens:7.875,capabilities:[`fast`,`code`,`cost-efficient`],description:`Ultra-fast coder (1000+ tok/s). ChatGPT-Pro-only research preview; routes via Codex CLI subscription auth — not generally available via raw API.`},{id:`gpt-5.2`,name:`GPT-5.2`,icon:Xc,tier:`balanced`,costPer1MTokens:7.875,capabilities:[`reasoning`,`code`,`agentic`],description:`Long-running agents (Dec 2025). 80% SWE-Bench, 92.4% GPQA-Diamond. Reserve for deep deliberation, not high-frequency polling.`}]},google:{name:`Google`,models:[{id:`gemini-3.1-pro-preview`,name:`Gemini 3.1 Pro`,icon:dc,tier:`premium`,costPer1MTokens:7,capabilities:[`reasoning`,`large-context`,`code`],description:`Google flagship, 1M context, strong agentic coding`},{id:`gemini-3.1-flash-lite-preview`,name:`Gemini 3.1 Flash Lite`,icon:cl,tier:`fast`,costPer1MTokens:.9,capabilities:[`fast`,`cost-efficient`,`large-context`],description:`Most cost-efficient Google model`}]},kimi:{name:`Kimi (Moonshot)`,models:[{id:`k3`,name:`Kimi K3`,icon:Zs,tier:`premium`,costPer1MTokens:9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi flagship coding model (July 2026). Always-thinking 2.8T MoE, 256K context.`},{id:`k3[1m]`,name:`Kimi K3 (1M)`,icon:Zs,tier:`premium`,costPer1MTokens:9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi K3 coding endpoint with the full 1,048,576-token context window.`},{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,icon:dc,tier:`premium`,costPer1MTokens:2.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi coding-first flagship (June 2026). 1T MoE, multimodal, 262K context.`},{id:`kimi-k2.6`,name:`Kimi K2.6`,icon:dc,tier:`premium`,costPer1MTokens:1.6,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi smartest model (April 2026). Native multimodal, superior agentic coding.`},{id:`kimi-k2.5`,name:`Kimi K2.5`,icon:dc,tier:`premium`,costPer1MTokens:1.6,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Best open-source coding, 256K context, 76.8% SWE-bench`},{id:`K2.6-code-preview`,name:`K2.6-code-preview`,icon:Ws,tier:`premium`,costPer1MTokens:1.6,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Kimi coding preview model.`}]},zai:{name:`Zhipu (GLM)`,models:[{id:`glm-5.2`,name:`GLM-5.2`,icon:Dc,tier:`premium`,costPer1MTokens:2.9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Z.AI flagship, 1M context, high/max effort, strong agentic coding. Text-only (vision is a separate model line).`},{id:`glm-5.1`,name:`GLM-5.1`,icon:Dc,tier:`premium`,costPer1MTokens:2.9,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`Previous Z.AI flagship, 200K context, strong agentic coding. Text-only (vision is a separate model line).`}]},minimax:{name:`MiniMax`,models:[{id:`MiniMax-M3`,name:`M3`,icon:Zs,tier:`premium`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`MSA architecture, 1M context, top-tier coding, native multimodal`},{id:`minimax-m2.7-highspeed`,name:`M2.7 Highspeed`,icon:cl,tier:`premium`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`56.22% SWE-Pro, 100 tps, 204K context, $0.06/M blended`},{id:`minimax-m2.7`,name:`M2.7`,icon:dc,tier:`balanced`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`56.22% SWE-Pro, 10B active params, 204K context`}]},mimo:{name:`Xiaomi MiMo`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,icon:dc,tier:`premium`,costPer1MTokens:2,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],supportsImages:!1,description:`Flagship reasoning model, 1M context, enhanced agent efficiency. Text-only on Token-Plan endpoints.`},{id:`mimo-v2.5`,name:`MiMo V2.5`,icon:cl,tier:`balanced`,costPer1MTokens:1,capabilities:[`code`,`agentic`,`fast`,`vision`],supportsImages:!0,description:`Multimodal model, 262K context, strong agentic coding`}]},nous:{name:`Nous Portal`,models:[{id:`qwen/qwen3.6-plus`,name:`Qwen 3.6 Plus`,icon:Dc,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`,`cost-efficient`],description:`Qwen 3.6 Plus via Nous Portal, currently free with 1M context.`}]},dashscope:{name:`Alibaba DashScope`,models:[{id:`qwen3-max`,name:`Qwen3 Max`,icon:Zs,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope flagship reasoning model.`},{id:`qwen3-coder-plus`,name:`Qwen3 Coder Plus`,icon:Ws,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope coding-specialist model.`},{id:`qwen3-plus`,name:`Qwen3 Plus`,icon:Xc,tier:`balanced`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope balanced Qwen3 model.`},{id:`qwen3.7-max`,name:`Qwen3.7 Max`,icon:Zs,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope flagship Qwen3.7 Max model.`},{id:`qwen3.8-max`,name:`Qwen3.8 Max`,icon:Zs,tier:`premium`,costPer1MTokens:0,capabilities:[`reasoning`,`code`,`agentic`,`large-context`],description:`DashScope flagship Qwen3.8 Max preview; free 1M-token Model Studio quota.`}]},xai:{name:`xAI (Grok)`,models:[{id:`grok-build-0.1`,name:`Grok Build 0.1`,icon:cl,tier:`premium`,costPer1MTokens:1.5,capabilities:[`reasoning`,`code`,`agentic`,`large-context`,`vision`],description:`xAI's agentic coding model (May 2026). 256K context, reasoning always active.`}]},quantumllama:{name:`QuantumLlama`,models:[{id:`ql-reason-70b`,name:`QL Reason 70B`,icon:Ws,tier:`premium`,costPer1MTokens:16,capabilities:[`reasoning`,`code`,`large-context`],description:`Fictional benchmark provider (PAN-3252) — no live endpoint. 200K context, $8 in / $24 out per 1M.`},{id:`ql-swift-8b`,name:`QL Swift 8B`,icon:Ws,tier:`balanced`,costPer1MTokens:4,capabilities:[`code`,`fast`],description:`Fictional benchmark provider (PAN-3252) — no live endpoint. 128K context, $2 in / $6 out per 1M.`},{id:`ql-nano-1b`,name:`QL Nano 1B`,icon:Ws,tier:`fast`,costPer1MTokens:.8,capabilities:[`fast`,`cost-efficient`],description:`Fictional benchmark provider (PAN-3252) — no live endpoint. 32K context, $0.40 in / $1.20 out per 1M.`}]}};function tG(e){for(let t of Object.values(eG)){let n=t.models.find(t=>t.id===e);if(n)return n}}function nG(e){return tG(e)?.supportsImages!==!1}var rG=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium`},{id:`high`,label:`High (default)`},{id:`xhigh`,label:`Extra High`},{id:`max`,label:`Max`}],iG=`conv-composer-effort`,snt=`high`;function cnt(){try{let e=localStorage.getItem(iG);if(e&&rG.some(t=>t.id===e))return e}catch{}return snt}function lnt({value:e,onChange:t,disabled:n=!1,availableLevels:r}){let[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null),{openUp:s,align:c,maxHeight:l}=Jx(i,o,{preferredHeight:240}),u=r!==void 0&&r.length===0,d=r&&r.length>0?rG.filter(e=>r.includes(e.id)):rG,f=d.find(t=>t.id===e)??d.find(e=>e.id===`medium`)??d[0]??rG[1];(0,z.useEffect)(()=>{if(!i)return;function e(e){o.current&&!o.current.contains(e.target)&&a(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);function p(e){t(e),localStorage.setItem(iG,e),a(!1)}return u?(0,B.jsx)(`div`,{className:Z.pickerContainer,children:(0,B.jsx)(`span`,{className:Z.pickerHint,children:`effort n/a for this model`})}):(0,B.jsxs)(`div`,{ref:o,className:Z.pickerContainer,children:[(0,B.jsxs)(`button`,{className:Z.pickerBtn,onClick:()=>a(e=>!e),disabled:n,type:`button`,children:[(0,B.jsx)(`span`,{className:Z.pickerLabel,children:f.label}),(0,B.jsx)(ds,{size:11})]}),i&&(0,B.jsx)(`div`,{className:`${Z.pickerDropdown} ${s?Z.pickerDropdownUp:``}`,style:{maxHeight:`${l}px`,...c===`right`?{left:`auto`,right:0}:{}},children:d.map(t=>(0,B.jsx)(`button`,{className:`${Z.pickerOption} ${t.id===e?Z.pickerOptionActive:``}`,onClick:()=>p(t.id),type:`button`,children:t.label},t.id))})]})}function unt(e){if(!e)return null;let t=Math.max(0,Math.round(e.estimatedTokens)),n=e.contextWindow>0?e.contextWindow:null,r=n===null?null:Math.min(100,Math.max(0,e.percentUsed));return{usedTokens:t,maxTokens:n,usedPercentage:r,remainingTokens:n===null?null:Math.max(0,n-t),remainingPercentage:r===null?null:Math.max(0,100-r),activeBytes:e.activeBytes,lastInputTokens:e.lastInputTokens,lastCacheReadTokens:e.lastCacheReadTokens,lastCacheCreationTokens:e.lastCacheCreationTokens,maxObservedInputTokens:e.maxObservedInputTokens,lastModel:e.lastModel,lastTurnAt:e.lastTurnAt}}function aG(e){return e===null||!Number.isFinite(e)?`0`:e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}var oG={root:`_root_19ian_10`,ring:`_ring_19ian_28`,ringSvg:`_ringSvg_19ian_37`,ringTrack:`_ringTrack_19ian_45`,ringProgress:`_ringProgress_19ian_49`,ringInner:`_ringInner_19ian_59`,tone_low:`_tone_low_19ian_77`,tone_medium:`_tone_medium_19ian_81`,tone_high:`_tone_high_19ian_85`,wrapper:`_wrapper_19ian_95`,popover:`_popover_19ian_101`,popoverHeader:`_popoverHeader_19ian_123`,popoverHeaderLabel:`_popoverHeaderLabel_19ian_130`,popoverExtBadge:`_popoverExtBadge_19ian_138`,popoverPrimary:`_popoverPrimary_19ian_149`,popoverPercent:`_popoverPercent_19ian_156`,popoverFraction:`_popoverFraction_19ian_162`,popoverGrid:`_popoverGrid_19ian_168`,popoverFooter:`_popoverFooter_19ian_191`,popoverFooterLabel:`_popoverFooterLabel_19ian_205`,popoverFooterValue:`_popoverFooterValue_19ian_212`,popoverNote:`_popoverNote_19ian_220`};function dnt(e){return e<50?`low`:e<=80?`medium`:`high`}function fnt(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(e)}%`}function pnt(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}var sG=9.75,cG=2*Math.PI*sG;function mnt({usage:e}){let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]);let i=(0,z.useCallback)(e=>{e.stopPropagation(),n(e=>!e)},[]);if(!e)return null;let a=e.usedPercentage===null?0:Math.max(0,Math.min(100,e.usedPercentage)),o=dnt(a),s=cG-a/100*cG,c=fnt(e.usedPercentage),l=e.maxTokens!==null&&c?`${c} · ${aG(e.usedTokens)}/${aG(e.maxTokens)} context used · click for details`:`${aG(e.usedTokens)} tokens used so far · click for details`,u=e.usedPercentage===null?aG(e.usedTokens):`${Math.round(e.usedPercentage)}`,d=e.maxTokens!==null&&c?`Context window ${c} used — click to expand`:`Context window ${aG(e.usedTokens)} tokens used — click to expand`,f=pnt(e.lastTurnAt),p=typeof e.maxObservedInputTokens==`number`&&e.maxTokens!==null&&e.maxTokens>2e5;return(0,B.jsxs)(`span`,{ref:r,className:oG.wrapper,children:[(0,B.jsx)(`button`,{type:`button`,className:`${oG.root} ${oG[`tone_${o}`]}`,title:l,"aria-label":d,"aria-expanded":t,"aria-haspopup":`dialog`,onClick:i,"data-testid":`context-window-meter`,"data-tone":o,children:(0,B.jsxs)(`span`,{className:oG.ring,children:[(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:oG.ringSvg,"aria-hidden":`true`,"data-testid":`context-window-meter-ring`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:sG,fill:`none`,className:oG.ringTrack,strokeWidth:`3`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:sG,fill:`none`,className:oG.ringProgress,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:cG,strokeDashoffset:s,"data-testid":`context-window-meter-progress`})]}),(0,B.jsx)(`span`,{className:oG.ringInner,"data-testid":`context-window-meter-label`,children:u})]})}),t&&(0,B.jsxs)(`div`,{className:oG.popover,role:`dialog`,"aria-label":`Context window detail`,"data-testid":`context-window-meter-popover`,children:[(0,B.jsxs)(`div`,{className:oG.popoverHeader,children:[(0,B.jsx)(`span`,{className:oG.popoverHeaderLabel,children:`Context window`}),p&&(0,B.jsx)(`span`,{className:oG.popoverExtBadge,title:`1M extended-context auto-detected from observed usage`,children:`1M mode`})]}),(0,B.jsx)(`div`,{className:oG.popoverPrimary,children:e.maxTokens!==null&&c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:oG.popoverPercent,children:c}),(0,B.jsxs)(`span`,{className:oG.popoverFraction,children:[aG(e.usedTokens),` / `,aG(e.maxTokens)]})]}):(0,B.jsxs)(`span`,{className:oG.popoverFraction,children:[aG(e.usedTokens),` tokens`]})}),(e.lastInputTokens!==void 0||e.lastCacheReadTokens!==void 0||e.lastCacheCreationTokens!==void 0)&&(0,B.jsxs)(`dl`,{className:oG.popoverGrid,children:[e.lastInputTokens!==void 0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Input`}),(0,B.jsx)(`dd`,{children:aG(e.lastInputTokens)})]}),e.lastCacheReadTokens!==void 0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Cache read`}),(0,B.jsx)(`dd`,{children:aG(e.lastCacheReadTokens)})]}),e.lastCacheCreationTokens!==void 0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Cache create`}),(0,B.jsx)(`dd`,{children:aG(e.lastCacheCreationTokens)})]}),e.remainingTokens!==null&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Remaining`}),(0,B.jsx)(`dd`,{children:aG(e.remainingTokens)})]})]}),(e.lastModel||f)&&(0,B.jsxs)(`div`,{className:oG.popoverFooter,children:[e.lastModel&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:oG.popoverFooterLabel,children:`Last turn model`}),(0,B.jsx)(`span`,{className:oG.popoverFooterValue,children:e.lastModel})]}),f&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:oG.popoverFooterLabel,children:`Last turn at`}),(0,B.jsx)(`span`,{className:oG.popoverFooterValue,children:f})]})]}),(0,B.jsxs)(`p`,{className:oG.popoverNote,children:[`Sourced from the last assistant turn's `,(0,B.jsx)(`code`,{children:`usage`}),` in the JSONL — matches Claude Code's terminal indicator.`]})]})]})}var lG=[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`],uG=`.txt,.md,.markdown,.json,.jsonl,.log,.csv,.tsv,.yaml,.yml,.toml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.sh,.bash,.sql,.diff,.patch,.ini,.conf,.cfg,.pdf`.split(`,`);function dG(e){let t=e.lastIndexOf(`.`);return t<=0?``:e.slice(t).toLowerCase()}var hnt={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".txt":`text/plain`,".md":`text/markdown`,".markdown":`text/markdown`,".json":`application/json`,".jsonl":`application/jsonlines`,".log":`text/plain`,".csv":`text/csv`,".tsv":`text/tab-separated-values`,".yaml":`application/yaml`,".yml":`application/yaml`,".toml":`application/toml`,".xml":`application/xml`,".html":`text/html`,".css":`text/css`,".js":`text/javascript`,".jsx":`text/javascript`,".ts":`text/typescript`,".tsx":`text/typescript`,".py":`text/x-python`,".sh":`application/x-sh`,".bash":`application/x-sh`,".sql":`application/sql`,".diff":`text/x-diff`,".patch":`text/x-diff`,".ini":`text/plain`,".conf":`text/plain`,".cfg":`text/plain`,".pdf":`application/pdf`};function fG(e){if(pG(e.name)||mG(e.name))return null;let t=dG(e.name);return lG.includes(t)?`image`:uG.includes(t)?`file`:null}function gnt(e){return e.type?e.type:hnt[dG(e.name)]??`text/plain`}function pG(e){return e.startsWith(`.`)}function mG(e){return!pG(e)&&dG(e)===``}var _nt=[...lG,...uG].join(`,`),hG=[],vnt=[],ynt=[],bnt=[];function xnt(){return{sending:!1,attachments:[],optimistic:[],optimisticBaseCount:0,failed:[],commandResults:[]}}function Snt(e){return!e.sending&&e.attachments.length===0&&e.optimistic.length===0&&e.failed.length===0&&e.commandResults.length===0}function Cnt(e){if(!e||typeof e!=`object`)return!1;let t=e;switch(t.kind){case`captured`:return(t.status===`completed`||t.status===`failed`)&&typeof t.command==`string`&&typeof t.output==`string`&&typeof t.truncated==`boolean`;case`activity`:return t.status===`accepted`&&typeof t.command==`string`&&typeof t.activityId==`string`&&typeof t.message==`string`;case`ui`:return t.status===`requires_ui`&&(t.action===`handoff`||t.action===`fork`)&&t.args!==null&&typeof t.args==`object`;case`confirmation`:return t.status===`confirmation_required`&&typeof t.nonce==`string`&&typeof t.consequence==`string`&&(t.typedText===void 0||typeof t.typedText==`string`);case`terminal-only`:return t.status===`rejected`&&typeof t.message==`string`;default:return!1}}var gG=class extends Error{status;reason;retryable;constructor(e,t){super(e),this.name=`MessageSendError`,this.status=t.status,this.reason=t.reason,this.retryable=t.status===void 0||t.status>=500||t.status===408||t.status===429}};function _G(e){return e instanceof gG?{error:e.reason??e.message,retryable:e.retryable}:{error:e instanceof Error?e.message:String(e),retryable:!0}}async function vG(e,t,n,r,i){let a=n?`/api/agents/${encodeURIComponent(n)}/message`:`/api/conversations/${encodeURIComponent(e)}/message`,o={message:t,...r&&!n?{deliverAs:r}:{},...i?{confirmationNonce:i.nonce,...i.typedText===void 0?{}:{confirmationText:i.typedText}}:{}},s;try{s=await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)})}catch(e){throw new gG(`Failed to send message: ${e instanceof Error?e.message:String(e)}`,{})}let c=await s.text().catch(()=>``),l=null;if(c)try{l=JSON.parse(c)}catch{l=null}if(Cnt(l))return l;if(!s.ok){let e=l&&typeof l==`object`&&`error`in l&&typeof l.error==`string`?l.error:c;throw new gG(`Failed to send message (${s.status})${e?`: ${e}`:``}`,{status:s.status,reason:e||void 0})}return null}async function wnt(e,t,n){let r=new FormData;r.append(`file`,t),r.append(`filename`,t.name),r.append(`mimeType`,n===`image`&&t.type?t.type:gnt(t));let i=await fetch(`/api/conversations/${encodeURIComponent(e)}/upload-image`,{method:`POST`,body:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`Failed to upload attachment (${i.status})${e?`: ${e}`:``}`)}let a;try{a=await i.json()}catch{throw Error(`Attachment upload response was not valid JSON`)}if(!a||typeof a!=`object`||!(`path`in a)||typeof a.path!=`string`||a.path.length===0)throw Error(`Attachment upload response did not include a path`);return a.path}async function Tnt(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/delete-image`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to delete attachment (${n.status})${e?`: ${e}`:``}`)}}function yG(e){e&&typeof URL.revokeObjectURL==`function`&&URL.revokeObjectURL(e)}function bG(e,t){Tnt(e,t).catch(e=>{console.error(`[composerStore] Failed to delete attachment:`,e)})}var Ent=3,xG=0,SG=[],CG=new Set;function wG(){for(;xG<Ent&&SG.length>0;){let e=SG.shift();xG++,wnt(e.conversationName,e.file,e.kind).then(t=>{xG--;try{CG.has(e.id)?(CG.delete(e.id),bG(e.conversationName,t)):EG.getState().updateAttachment(e.conversationName,e.id,{serverPath:t,error:null})}finally{wG()}},t=>{xG--;try{if(CG.has(e.id)){CG.delete(e.id);return}let n=t instanceof Error?t.message:`Failed to upload attachment`;EG.getState().updateAttachment(e.conversationName,e.id,{error:n})}finally{wG()}})}}function TG(e,t,n){let r=n(e[t]??xnt()),i={...e};return Snt(r)?delete i[t]:i[t]=r,i}var EG=tS((e,t)=>({byConversation:{},setSending:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>e.sending===n?e:{...e,sending:n})})),enqueueAttachments:(t,n)=>{let r=[],i=[];for(let e of n){let n=fG(e);if(!n){i.push(e);continue}r.push({id:crypto.randomUUID(),conversationName:t,kind:n,file:e,previewUrl:n===`image`?URL.createObjectURL(e):null,serverPath:null,error:null})}return r.length===0?{rejected:i}:(e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,attachments:[...e.attachments,...r]}))})),SG.push(...r),wG(),{rejected:i})},updateAttachment:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,attachments:e.attachments.map(e=>e.id===n?{...e,...r}:e)}))})),removeAttachment:(n,r)=>{let i=t().byConversation[n]?.attachments.find(e=>e.id===r);if(i)if(yG(i.previewUrl),i.serverPath)bG(n,i.serverPath);else{let e=SG.findIndex(e=>e.id===r);e>=0?SG.splice(e,1):CG.add(r)}e(e=>({byConversation:TG(e.byConversation,n,e=>({...e,attachments:e.attachments.filter(e=>e.id!==r)}))}))},consumeAttachments:n=>{let r=t().byConversation[n];if(r){for(let e of r.attachments)yG(e.previewUrl);e(e=>({byConversation:TG(e.byConversation,n,e=>({...e,attachments:[]}))}))}},addOptimistic:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,optimisticBaseCount:e.optimistic.length===0?r:e.optimisticBaseCount,optimistic:[...e.optimistic,{id:`optimistic-${Date.now()}-${e.optimistic.length}`,role:`user`,text:n,createdAt:new Date().toISOString()}]}))})),acknowledgeOptimistic:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>{let t=!1;return{...e,optimistic:e.optimistic.map(e=>t||e.acknowledged||e.text!==n?e:(t=!0,{...e,acknowledged:!0}))}})})),clearOptimistic:t=>e(e=>({byConversation:TG(e.byConversation,t,e=>e.optimistic.length===0?e:{...e,optimistic:[],optimisticBaseCount:0})})),failSend:(t,n,r=`prompt`,i)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,optimistic:r===`prompt`?[]:e.optimistic,optimisticBaseCount:r===`prompt`?0:e.optimisticBaseCount,failed:[...e.failed,{id:`failed-${Date.now()}`,text:n,kind:r,createdAt:new Date().toISOString(),...i?.error===void 0?{}:{error:i.error},...i?.retryable===void 0?{}:{retryable:i.retryable}}]}))})),removeFailed:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,failed:e.failed.filter(e=>e.id!==n)}))})),addCommandResult:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,commandResults:[...e.commandResults,{id:`command-result-${Date.now()}-${e.commandResults.length}`,role:`system`,text:n,commandText:n,commandResult:r,createdAt:new Date().toISOString()}]}))})),replaceCommandResult:(t,n,r)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,commandResults:e.commandResults.map(e=>e.id===n?{...e,commandResult:r}:e)}))})),removeCommandResult:(t,n)=>e(e=>({byConversation:TG(e.byConversation,t,e=>({...e,commandResults:e.commandResults.filter(e=>e.id!==n)}))})),retryFailed:async(e,n,r,i,a)=>{let{addOptimistic:o,addCommandResult:s,removeFailed:c,failSend:l}=t(),u=t().byConversation[e]?.failed.find(e=>e.id===n)?.kind??`prompt`;u===`prompt`&&o(e,r,i),c(e,n);try{let t=await vG(e,r,a);return u===`command`&&t&&t.kind!==`ui`&&s(e,r,t),t}catch(t){return l(e,r,u,_G(t)),null}}}));function Dnt(e){return EG(t=>t.byConversation[e]?.sending??!1)}function Ont(e){return EG(t=>t.byConversation[e]?.attachments??hG)}function knt(e){return EG(t=>t.byConversation[e]?.optimistic??vnt)}function Ant(e){return EG(t=>t.byConversation[e]?.optimisticBaseCount??0)}function jnt(e){return EG(t=>t.byConversation[e]?.failed??ynt)}function Mnt(e){return EG(t=>t.byConversation[e]?.commandResults??bnt)}function Nnt(e){return EG.getState().byConversation[e]?.attachments??hG}function Pnt(){return _nt}function Fnt(e){return e.harness===`ohmypi`||e.harness===`pi`}function Int(e){switch(e.effort){case`low`:case`medium`:case`high`:case`xhigh`:case`max`:return e.effort;default:return!e.sessionAlive&&!e.claudeSessionId?cnt():`high`}}function DG(e,t,n){window.dispatchEvent(new CustomEvent(`overdeck:open-fork-modal`,{detail:{conversation:e,mode:t===`handoff`?`handoff`:`summary`,focus:n}}))}function Lnt(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log10(e)/3),t.length-1);return`${(e/1e3**n).toFixed(n===0?0:1)} ${t[n]}`}function Rnt({conversation:e,onSend:t,onSendAcknowledged:n,onSendFailed:r,agentId:i,contextWindowUsage:a=null,agentBusy:o=!1}){let s=Int(e),[c,l]=(0,z.useState)(e.model??DD()),[u,d]=(0,z.useState)((e.harness===`pi`?`ohmypi`:e.harness)??`claude-code`),[f,p]=(0,z.useState)(s),[m,h]=(0,z.useState)(`auto`),[g,_]=(0,z.useState)(!1),v=Dnt(e.name),y=Ont(e.name),b=EG(e=>e.setSending),x=EG(e=>e.enqueueAttachments),S=EG(e=>e.removeAttachment),C=EG(e=>e.consumeAttachments),w=EG(e=>e.addCommandResult),[T,E]=(0,z.useState)(``),[D,O]=(0,z.useState)(!1),[k,A]=(0,z.useState)(0),[j,M]=(0,z.useState)({isListening:!1,error:null}),N=(0,z.useRef)(null),P=(0,z.useRef)(null),F=(0,z.useRef)(e.name),I=(0,z.useRef)(e.name);I.current=e.name,(0,z.useEffect)(()=>{p(s)},[e.name,s]);let L=Fnt(e),ee=!e.sessionAlive||v,R=!i&&!e.sessionAlive&&!e.claudeSessionId,te=T.trim()===``,ne=(0,z.useCallback)(t=>{let n=[],r=[];for(let e of t)fG(e)===`image`?n.push(e):r.push(e);if(n.length>0&&!nG(c)){let e=tG(c);U.warning(`${e?.name??c} can't read images — image${n.length===1?``:`s`} not attached. Switch to a vision-capable model (e.g. MiMo V2.5) to send images.`)}let i=nG(c)?t:r,{rejected:a}=x(e.name,i);if(a.length>0){let e=a.filter(e=>pG(e.name)),t=a.filter(e=>mG(e.name)),n=a.filter(e=>!pG(e.name)&&!mG(e.name)),r=e=>e.map(e=>e.name).join(`, `);e.length>0&&U.warning(`${r(e)} not supported (dotfile).`),t.length>0&&U.warning(`${r(t)} not supported (extensionless file).`),n.length>0&&U.warning(`${r(n)} not supported.`)}},[x,e.name,c]),re=(0,z.useCallback)(()=>{P.current?.click()},[]),ie=(0,z.useCallback)(e=>{let t=e.target.files?Array.from(e.target.files):[];t.length>0&&ne(t),e.target.value=``},[ne]),ae=(0,z.useCallback)(t=>{S(e.name,t)},[S,e.name]),oe=(0,z.useCallback)(e=>{e!==u&&(d(e),YW(e))},[u]),se=(0,z.useCallback)((e,t)=>{l(e),JW(e)},[]),ce=(0,z.useCallback)((e,t,n)=>{l(e),JW(e),d(n),YW(n)},[]),le=(0,z.useCallback)(t=>{let n=f;p(t),!(!L||i||!e.sessionAlive)&&(async()=>{let r=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/thinking-level`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:t})});if(!r.ok){p(n);let e=await r.text().catch(()=>``);throw Error(`Failed to set thinking level (${r.status})${e?`: ${e}`:``}`)}})().catch(e=>{console.error(`[ComposerFooter] Failed to set thinking level:`,e),U.error(e instanceof Error?e.message:`Failed to set thinking level`)})},[i,e.name,e.sessionAlive,f,L]),ue=(0,z.useCallback)(()=>{!L||i||g||(_(!0),(async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/compact`,{method:`POST`});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Failed to compact conversation (${t.status})${e?`: ${e}`:``}`)}U.success(`Compaction requested`)})().catch(e=>{console.error(`[ComposerFooter] Failed to compact:`,e),U.error(e instanceof Error?e.message:`Failed to compact conversation`)}).finally(()=>{_(!1)}))},[i,g,e.name,L]),de=(0,z.useCallback)(e=>{if(v){e.preventDefault();return}let t=e.clipboardData;if(!t)return;let n=[],r=t.files?Array.from(t.files):[];if(r.length>0)n.push(...r);else if(t.items){for(let e of Array.from(t.items))if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}}if(n.length>0){e.preventDefault(),ne(n);return}let i=Array.from(t.types??[]),a=i.some(e=>e.startsWith(`image/`)),o=i.includes(`Files`),s=i.includes(`text/uri-list`);if(a||o){e.preventDefault(),typeof navigator<`u`&&navigator.clipboard?.read?(async()=>{try{let e=await navigator.clipboard.read(),t=[];for(let n of e)for(let e of n.types){if(!e.startsWith(`image/`))continue;let r=await n.getType(e),i=e.split(`/`)[1]?.split(`+`)[0]||`png`;t.push(new File([r],`paste-${Date.now()}.${i}`,{type:e}))}t.length>0?ne(t):U.error(`Couldn't read the pasted image. Try saving it to a file and dragging it onto the composer.`)}catch{U.error(`Clipboard read denied. Grant clipboard permission, or drag the image onto the composer instead.`)}})():U.error(`Couldn't read the pasted image. Try dragging the file onto the composer instead.`);return}s&&(e.preventDefault(),U.error(`Paste-from-file-manager isn't supported. Drag the file onto the composer instead.`))},[ne,v]),fe=(0,z.useCallback)(t=>{if(t.preventDefault(),v||!e.sessionAlive)return;let n=Array.from(t.dataTransfer.files);n.length!==0&&ne(n)},[ne,v,e.sessionAlive]),pe=(0,z.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.kind===`file`)&&e.preventDefault()},[]),me=(0,z.useCallback)(async a=>{let o=N.current;if(!o){console.warn(`[ComposerFooter] handleSubmit: editor ref not ready`);return}if(ee){console.warn(`[ComposerFooter] handleSubmit: isDisabled=true, sessionAlive=%s sending=%s`,e.sessionAlive,v);return}let s=a?.trim()??``;a===void 0&&o.read(()=>{s=QV().getTextContent().trim()});let c=s.match(/^\/(?:pan[\s-])?handoff(?:\s+(.+))?$/i);if(c){DG(e,`handoff`,c[1]?.trim()||void 0),o.update(()=>{QV().clear()}),E(``);return}let l=e.name,u=Nnt(l);if(u.filter(e=>!e.serverPath&&!e.error).length>0){U.error(`Please wait for uploads to finish`);return}if(u.filter(e=>e.error).length>0){U.error(`Remove failed uploads before sending`);return}let d=u.filter(e=>e.serverPath);if(!s&&d.length===0)return;b(l,!0);let f=[d.map(e=>`@${e.serverPath}`).join(`
|
|
323
323
|
`),s].filter(Boolean).join(`
|
|
324
324
|
`),p=/^\/pan(?:\s|$)/i.test(s),h=p?s:f;try{if(l!==I.current)return;p||t?.(f);let r=await vG(l,h,i,L&&m!==`auto`?m:void 0);r?.kind===`ui`?DG(e,r.action,r.args.focus||void 0):r?w(l,h,r):n?.(h),p||C(l),l===I.current&&(o.update(()=>{QV().clear()}),E(``))}catch(e){console.error(`[ComposerFooter] Failed to send:`,e),U.error(e instanceof Error?e.message:`Failed to send message`),r?.(h,p?`command`:`prompt`,_G(e))}finally{b(l,!1),o.focus()}},[w,i,e,C,m,u,ee,c,t,n,r,L,v,b]);(0,z.useEffect)(()=>{F.current!==e.name&&(F.current=e.name,l(e.model??DD()),d((e.harness===`pi`?`ohmypi`:e.harness)??`claude-code`),E(NW(e.name)))},[e.name,e.model]);let he=(0,z.useCallback)(e=>{let t=e.trim();if(!t)return;let n=N.current;n&&(n.update(()=>{let e=QV(),n=e.getTextContent().trim();e.clear();let r=SV();r.append(sB([n,t].filter(Boolean).join(n?`
|
|
325
325
|
`:``))),e.append(r)}),E(e=>[e.trim(),t].filter(Boolean).join(e.trim()?`
|
|
@@ -653,7 +653,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[nY(e),e])),Fst=new Map([[`s`,hY(383)],[hY(38
|
|
|
653
653
|
color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
|
|
654
654
|
text-decoration-color: currentColor;
|
|
655
655
|
}
|
|
656
|
-
`;function Xdt(e,t=`diff-panel`){if(!e)return null;let n=e.trim();if(n.length===0)return null;try{let e=Eut(n,Vdt(n,t)).flatMap(e=>e.files);return e.length>0?{kind:`files`,files:e}:{kind:`raw`,text:n,reason:`Unsupported diff format. Showing raw patch.`}}catch{return{kind:`raw`,text:n,reason:`Failed to parse patch. Showing raw patch.`}}}function WX(e){let t=e.name??e.prevName??``;return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t}function Zdt(e){return e.cacheKey??`${e.prevName??`none`}:${e.name}`}function Qdt(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function GX(){return VX(Object.fromEntries(new URLSearchParams(window.location.search)))}function $dt(e){let t=new URLSearchParams(window.location.search);t.delete(`diff`),t.delete(`diffTurnId`),t.delete(`diffFilePath`),e.diff&&t.set(`diff`,e.diff),e.diffTurnId&&t.set(`diffTurnId`,e.diffTurnId),e.diffFilePath&&t.set(`diffFilePath`,e.diffFilePath);let n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.pushState({},``,r)}function eft(){let e=new URLSearchParams(window.location.search);e.delete(`diff`),e.delete(`diffTurnId`),e.delete(`diffFilePath`);let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.pushState({},``,n)}function KX(e){return(0,B.jsx)(`button`,{type:`button`,role:`button`,"aria-label":e.ariaLabel,title:e.title,"aria-pressed":e.pressed,className:Kx(`inline-flex size-7 items-center justify-center rounded-md border text-muted-foreground transition-colors`,e.pressed?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 hover:border-border hover:text-foreground/80`),onClick:()=>e.onPressedChange(!e.pressed),children:e.children})}function tft({files:e,onSelectFile:t,isLoading:n}){if(n)return(0,B.jsx)(Jdt,{label:`Loading file list...`});if(e.length===0)return(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No changed files in this selection.`});let r=[...e].sort((e,t)=>e.path.localeCompare(t.path,void 0,{numeric:!0,sensitivity:`base`}));return(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto px-2 py-2`,children:[(0,B.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-muted-foreground/70`,children:[e.length,` changed file`,e.length===1?``:`s`,` — select a file to view its diff`]}),(0,B.jsx)(`div`,{className:`space-y-px`,children:r.map(e=>{let n=e.path.split(`/`),r=n.pop()??e.path,i=n.join(`/`);return(0,B.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-[11px] transition-colors hover:bg-accent`,onClick:()=>t(e.path),children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[i&&(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[i,`/`]}),(0,B.jsx)(`span`,{className:`text-foreground/90`,children:r})]}),(0,B.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[e.additions!=null&&e.additions>0&&(0,B.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions!=null&&e.deletions>0&&(0,B.jsxs)(`span`,{className:`ml-1 text-red-400`,children:[`-`,e.deletions]})]})]},e.path)})})]})}function nft({mode:e=`inline`,agentId:t,turnDiffSummaries:n,onClose:r,diffUrlPrefix:i,defaultView:a=`full`,isolateSelection:o=!1}){let{resolvedTheme:s}=mO(),{prefs:c,update:l}=jdt(),u=c.diffRenderMode,d=c.diffWordWrap,f=(0,z.useRef)(null),p=(0,z.useRef)(null),[m,h]=(0,z.useState)(!1),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(GX);(0,z.useEffect)(()=>{if(o)return;let e=()=>y(GX());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[o]);let[b,x]=(0,z.useState)(()=>a===`vs-main`?{diff:`1`,diffTurnId:`vs-main`}:{diff:`1`}),S=o?b:v,C=e=>{o?x(e):($dt(e),y(GX()))},w=()=>{o?x({}):(eft(),y(GX()))},T=e===`inline`||S.diff===`1`,E=S.diffTurnId??null,D=E===null?null:S.diffFilePath??null,O=(0,z.useMemo)(()=>[...n].sort((e,t)=>{let n=e.checkpointTurnCount??0,r=t.checkpointTurnCount??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[n]),k=E===`vs-main`,A=E===null||k?void 0:O.find(e=>e.turnId===E)??O[0],j=i??`/api/agents/${encodeURIComponent(t)}/diffs`,M=!D,N=M&&!!A,{data:P,isLoading:F}=V({queryKey:k?[`diff-vs-main`,t,D??null]:A?[`diff-turn`,t,A.turnId,D??null]:[`diff-full`,t,D??null],queryFn:async()=>{let e=k?`${j}/vs-main`:A?`${j}/${encodeURIComponent(A.turnId)}`:`${j}/full`;D&&(e+=`?file=${encodeURIComponent(D)}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch diff`);return t.json()},enabled:T&&!N}),I=M?A?.files??P?.files:void 0,L=P?.diff,ee=typeof L==`string`&&L.trim().length===0,R=(0,z.useMemo)(()=>Xdt(L,`diff-panel:${s}`),[s,L]),te=(0,z.useMemo)(()=>!R||R.kind!==`files`?[]:[...R.files].sort((e,t)=>WX(e).localeCompare(WX(t),void 0,{numeric:!0,sensitivity:`base`})),[R]);(0,z.useEffect)(()=>{!D||!f.current||Array.from(f.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===D)?.scrollIntoView({block:`nearest`})},[D,te]);let ne=(0,z.useCallback)(()=>{let e=p.current;if(!e){h(!1),_(!1);return}let t=Math.max(0,e.scrollWidth-e.clientWidth);h(e.scrollLeft>4),_(e.scrollLeft<t-4)},[]),re=(0,z.useCallback)(e=>{let t=p.current;t&&t.scrollBy({left:e,behavior:`smooth`})},[]),ie=(0,z.useCallback)(e=>{let t=p.current;t&&(t.scrollWidth<=t.clientWidth+1||Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollBy({left:e.deltaY,behavior:`auto`})))},[]);(0,z.useEffect)(()=>{let e=p.current;if(!e)return;let t=window.requestAnimationFrame(()=>ne()),n=()=>ne();e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(()=>ne());return r.observe(e),()=>{window.cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),r.disconnect()}},[ne]),(0,z.useEffect)(()=>{let e=window.requestAnimationFrame(()=>ne());return()=>window.cancelAnimationFrame(e)},[O,E,ne]),(0,z.useEffect)(()=>{let e=p.current;e&&e.querySelector(`[data-turn-chip-selected='true']`)?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},[A?.turnId,E]);let ae=e=>{C({diff:`1`,diffTurnId:e})},oe=e=>{let t=E??void 0;C({diff:`1`,...t&&{diffTurnId:t},diffFilePath:e})},se=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[m&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-8 z-10 w-7 bg-gradient-to-r from-card to-transparent`}),g&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-8 z-10 w-7 bg-gradient-to-l from-card to-transparent`}),(0,B.jsx)(`button`,{type:`button`,className:Kx(`absolute left-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,m?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>re(-180),disabled:!m,"aria-label":`Scroll turn list left`,children:(0,B.jsx)(fs,{className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:Kx(`absolute right-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,g?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>re(180),disabled:!g,"aria-label":`Scroll turn list right`,children:(0,B.jsx)(ps,{className:`size-3.5`})}),(0,B.jsxs)(`div`,{ref:p,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,onWheel:ie,children:[(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>{C({diff:`1`})},"data-turn-chip-selected":E===null,children:(0,B.jsx)(`div`,{className:Kx(`rounded-md border px-2 py-1 text-left transition-colors`,E===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,B.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`})})}),(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>{C({diff:`1`,diffTurnId:`vs-main`})},"data-turn-chip-selected":k,children:(0,B.jsx)(`div`,{className:Kx(`rounded-md border px-2 py-1 text-left transition-colors`,k?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,B.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`vs main`})})}),O.map((e,t)=>(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>ae(e.turnId),title:e.turnId,"data-turn-chip-selected":e.turnId===A?.turnId,children:(0,B.jsx)(`div`,{className:Kx(`rounded-md border px-2 py-1 text-left transition-colors`,e.turnId===A?.turnId?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,e.checkpointTurnCount??O.length-t]}),(0,B.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:Qdt(e.completedAt)})]})})},e.turnId))]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,B.jsx)(KX,{pressed:u===`stacked`,onPressedChange:()=>l({diffRenderMode:`stacked`}),ariaLabel:`Stacked diff view`,children:(0,B.jsx)(vae,{className:`size-3`})}),(0,B.jsx)(KX,{pressed:u===`split`,onPressedChange:()=>l({diffRenderMode:`split`}),ariaLabel:`Split diff view`,children:(0,B.jsx)(Es,{className:`size-3`})}),(0,B.jsx)(KX,{pressed:d,onPressedChange:e=>l({diffWordWrap:e}),ariaLabel:d?`Disable diff line wrapping`:`Enable diff line wrapping`,title:d?`Disable line wrapping`:`Enable line wrapping`,children:(0,B.jsx)(Lae,{className:`size-3`})}),e===`inline`&&(0,B.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-md border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:border-border hover:text-foreground/80`,onClick:()=>{let e=new URLSearchParams;e.set(`diff`,`1`),e.set(`prefix`,j),e.set(`agentId`,t),E&&e.set(`diffTurnId`,E),D&&e.set(`diffFilePath`,D),window.open(`/popout/diff?${e.toString()}`,`_blank`,`width=1000,height=800`)},"aria-label":`Open diff in new window`,title:`Pop out`,children:(0,B.jsx)(Is,{className:`size-3`})}),r&&(0,B.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-md border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:border-border hover:text-foreground/80`,onClick:()=>{w(),r?.()},"aria-label":`Close diff panel`,children:(0,B.jsx)(sl,{className:`size-3`})})]})]});return T?(0,B.jsx)(qdt,{mode:e,header:se,children:O.length===0&&!k?(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):M?(0,B.jsx)(tft,{files:I??[],onSelectFile:oe,isLoading:F&&!I}):(0,B.jsx)(`div`,{ref:f,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:R?R.kind===`files`?(0,B.jsx)(fdt,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:te.map(e=>{let t=WX(e),n=`${Zdt(e)}:${s}`;return(0,B.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,children:(0,B.jsx)(Ddt,{fileDiff:e,options:{diffStyle:c.diffRenderMode===`split`?`split`:`unified`,lineDiffType:c.lineDiffType,overflow:c.diffWordWrap?`wrap`:`scroll`,diffIndicators:c.diffIndicators,hunkSeparators:c.hunkSeparators,expandUnchanged:c.expandUnchanged,collapsedContextThreshold:c.collapsedContextThreshold,lineHoverHighlight:c.lineHoverHighlight,disableLineNumbers:c.disableLineNumbers,enableLineSelection:c.enableLineSelection,theme:Fdt(s),themeType:s,unsafeCSS:Ydt}})},n)})}):(0,B.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:R.reason}),(0,B.jsx)(`pre`,{className:Kx(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,d?`overflow-auto whitespace-pre-wrap break-words`:`overflow-auto`),children:R.text})]})}):F?(0,B.jsx)(Jdt,{label:`Loading checkpoint diff...`}):(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,B.jsx)(`p`,{children:ee?`No net changes in this selection.`:`No patch available for this selection.`})})})}):null}function rft(e){return new Worker(`/assets/worker-C-69Fj6S.js`,{name:e?.name})}function ift({themeName:e}){let t=xdt(),n=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{if(!t)return;let r=t.getDiffRenderOptions();n.current&&r.theme===e||(n.current=!0,t.setRenderOptions({...r,theme:e}).catch(()=>void 0))},[e,t]),null}function aft({children:e}){let{resolvedTheme:t}=mO(),n=Fdt(t);return(0,B.jsxs)(bdt,{poolOptions:{workerFactory:()=>new rft,poolSize:(0,z.useMemo)(()=>{let e=typeof navigator>`u`?4:Math.max(1,navigator.hardwareConcurrency||4);return Math.max(2,Math.min(6,Math.floor(e/2)))},[]),totalASTLRUCacheSize:240},highlighterOptions:{theme:n,tokenizeMaxLineLength:1e3},children:[(0,B.jsx)(ift,{themeName:n}),e]})}var qX=e=>[`conversation-messages`,e],oft=(e,t)=>[`conversation-messages`,e,`subagent`,t];function sft(e,t){let n=e;for(let e of t){if(typeof e.sequence!=`number`||e.sequence<=n)return!1;n=e.sequence}return!0}function JX(e,t){if(t.length===0)return e;if(e.length===0)return t;let n=e[e.length-1],r=t[0];if(r.id===n.id){let n=[...e.slice(0,-1),r],i=t.slice(1);if(i.length===0)return n;if(typeof r.sequence==`number`&&sft(r.sequence,i))return[...n,...i]}else if(typeof n.sequence==`number`&&sft(n.sequence,t))return[...e,...t];let i=new Set(e.map(e=>e.id));if(t.every(e=>!i.has(e.id)))return[...e,...t];let a=new Map;for(let t of e)a.set(t.id,t);for(let e of t)a.set(e.id,e);return Array.from(a.values())}function cft(e,t){if(t.kind===`discovering`)return e?.discovering?e:{messages:e?.messages??[],workLog:e?.workLog??[],streaming:e?.streaming??!0,...e,discovering:!0};if(t.kind===`subagents`)return{messages:e?.messages??[],workLog:e?.workLog??[],streaming:e?.streaming??!0,...e,subagents:t.subagents};let n=t.snapshot!==!1,r=n&&t.messages.length<(e?.messages.length??0),i=n&&!r;return{...e,messages:i?t.messages:JX(e?.messages??[],t.messages),workLog:i?t.workLog:JX(e?.workLog??[],t.workLog),streaming:t.streaming,proposedPlan:t.proposedPlan??e?.proposedPlan,compactBoundaries:i?t.compactBoundaries:JX(e?.compactBoundaries??[],t.compactBoundaries??[]),contextUsage:`contextUsage`in t?t.contextUsage:e?.contextUsage,discovering:!1}}function lft(e){if(e.id!==void 0&&e.id>=0){if(e.endedAt)return!1;if(e.harness==null)return!0;let t=tb(e.harness);return t.supportsConversationStreaming||t.supportsPatchProjection}if(!e.sessionAlive)return!1;let t=e.name??``,n=/^(agent-|planning-|specialist-)/.test(t),r=tb(e.harness).supportsConversationStreaming;return n&&r}function uft(e){let t=yt(),n=lft(e),r=`${n?`enabled`:`disabled`}:${e.name}`,[i,a]=(0,z.useState)(null),o=i===r;return(0,z.useLayoutEffect)(()=>{a(null)},[r]),(0,z.useEffect)(()=>{if(!n)return;let i=qX(e.name);t.cancelQueries({queryKey:i});let o=lb().subscribe(t=>t[Cy.subscribeConversationMessages]({conversationName:e.name}),e=>{a(r),t.setQueryData(i,t=>cft(t,e))});return()=>{o()}},[e.name,n,t,r]),{enabled:n,receivedFirstPayload:o}}function dft(e,t){let n=yt(),r=t!==null&&lft(e),i=(0,z.useMemo)(()=>oft(e.name,t??``),[t,e.name]);return(0,z.useEffect)(()=>{if(!t||!r)return;n.cancelQueries({queryKey:i});let a=lb().subscribe(n=>n[Cy.subscribeConversationMessages]({conversationName:e.name,agentId:t}),e=>{n.setQueryData(i,t=>cft(t,e))});return()=>a()},[t,e.name,n,i,r]),(0,z.useEffect)(()=>{if(t)return()=>n.removeQueries({queryKey:i,exact:!0})},[t,n,i]),V({queryKey:i,queryFn:async({signal:n})=>{let r=await vl(`/api/conversations/${encodeURIComponent(e.name)}/messages?agentId=${encodeURIComponent(t??``)}`,{signal:n});if(!r.ok)throw Error(`Failed to fetch subagent messages`);return r.json()},enabled:t!==null&&!r})}var fft=`overdeck.ui.agentsRailCollapsed`;function pft(){return new URLSearchParams(window.location.search).get(`subagent`)}function YX(e){let t=new URLSearchParams(window.location.search);e?t.set(`subagent`,e):t.delete(`subagent`);let n=t.toString();window.history.pushState({},``,n?`${window.location.pathname}?${n}`:window.location.pathname),window.dispatchEvent(new PopStateEvent(`popstate`))}function mft(e){let[t,n]=(0,z.useState)(pft);(0,z.useEffect)(()=>{let e=()=>n(pft());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let r=(0,z.useCallback)(()=>YX(null),[]);return{selectedAgentId:t,selectedSubagent:e.find(e=>e.agentId===t)??null,clearSelection:r}}function hft({conversation:e,subagents:t,selectedAgentId:n}){let r=(0,z.useCallback)(e=>YX(e),[]),[i,a]=(0,z.useState)(()=>typeof window<`u`&&localStorage.getItem(fft)===`true`),o=(0,z.useCallback)(e=>{a(e);try{localStorage.setItem(fft,String(e))}catch{}},[]);return t.length===0?null:i?(0,B.jsxs)(`button`,{type:`button`,className:`flex w-[30px] min-w-[30px] shrink-0 cursor-pointer flex-col items-center gap-2.5 border-l border-border bg-card pt-2.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:()=>o(!1),title:`Show Agents`,"aria-label":`Show agents rail`,children:[(0,B.jsx)(fs,{size:16}),(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] [writing-mode:vertical-rl]`,children:`Agents`})]}):(0,B.jsxs)(`aside`,{"aria-label":`Conversation agents`,className:`flex min-h-0 w-64 min-w-0 shrink-0 flex-col border-l border-border bg-card`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center border-b border-border px-3 text-xs font-medium text-muted-foreground`,children:[`Agents`,(0,B.jsx)(`button`,{type:`button`,className:`ml-auto rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,"aria-label":`Collapse agents rail`,onClick:()=>o(!0),children:(0,B.jsx)(sl,{className:`h-4 w-4`,"aria-hidden":`true`})})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,B.jsx)(gft,{label:`Main agent`,description:e.title??e.name,status:e.sessionAlive?`running`:`done`,selected:n===null,onClick:()=>r(null)}),t.map(e=>(0,B.jsx)(gft,{label:e.agentType,description:e.description,status:e.status,depth:e.spawnDepth,selected:n===e.agentId,onClick:()=>r(e.agentId)},e.agentId))]})]})}function gft({label:e,description:t,status:n,depth:r,selected:i,onClick:a}){return(0,B.jsxs)(`button`,{type:`button`,"aria-current":i?`true`:void 0,className:`flex w-full items-start gap-2 border-b border-l-2 border-b-border px-3 py-2 text-left transition-colors ${i?`border-l-primary bg-accent`:`border-l-transparent hover:bg-accent`}`,onClick:a,children:[(0,B.jsx)(`span`,{"aria-label":n,className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${n===`running`?`bg-primary`:`bg-muted-foreground/40`}`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate text-xs font-medium text-foreground`,children:e}),(0,B.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),r!==void 0&&r>1&&(0,B.jsxs)(`span`,{className:`rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`depth `,r]})]})}function _ft({conversation:e,subagent:t,resolvedTheme:n,onBack:r}){let i=dft(e,t.agentId);return(0,B.jsxs)(`div`,{className:`${Z.subagentTranscript} flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Back to main agent`,className:`rounded-sm p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:r,children:(0,B.jsx)(Tie,{size:16})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:[t.agentType,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,t.description]})]})]}),(0,B.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:i.isLoading?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(gc,{size:14,className:`animate-spin text-primary`}),`Loading transcript…`]}):i.isError?(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-sm text-destructive-foreground`,children:`Couldn't load this subagent transcript.`}):(0,B.jsx)(DL,{messages:i.data?.messages??[],workLog:i.data?.workLog??[],streaming:i.data?.streaming??t.status===`running`,conversationName:`${e.name}:${t.agentId}`,cwd:e.cwd,issueId:e.issueId,resolvedTheme:n})})]})}var XX=[{key:`summarizing`,label:`Summarizing`,description:`Generating a concise summary of the parent conversation`},{key:`spawning`,label:`Spawning`,description:`Starting a new Claude Code session`},{key:`injecting`,label:`Injecting`,description:`Seeding the new session with conversation context`}];function vft({forkStatus:e,forkError:t,parentTitle:n}){let r=e===`failed`,i=XX.findIndex(t=>t.key===e);return(0,B.jsx)(`div`,{className:Z.forkProgressView,children:(0,B.jsxs)(`div`,{className:Z.forkProgressCard,children:[(0,B.jsxs)(`div`,{className:Z.forkProgressHeader,children:[(0,B.jsx)(Qs,{size:20,className:Z.forkProgressIcon}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:Z.forkProgressTitle,children:r?`Fork Failed`:`Setting up fork…`}),n&&(0,B.jsxs)(`p`,{className:Z.forkProgressSubtitle,children:[`Forking from `,(0,B.jsx)(`strong`,{children:n})]})]})]}),(0,B.jsx)(`div`,{className:Z.forkProgressTimeline,children:XX.map((e,t)=>{let n;return n=r?t<i?`done`:t===i||i===-1&&t===0?`failed`:`pending`:t<i?`done`:t===i?`active`:`pending`,(0,B.jsxs)(`div`,{className:`${Z.forkProgressStep} ${Z[`forkProgressStep--${n}`]}`,children:[(0,B.jsxs)(`div`,{className:Z.forkProgressStepIndicator,children:[n===`done`&&(0,B.jsx)(_s,{size:18}),n===`active`&&(0,B.jsx)(gc,{size:18,className:Z.forkProgressSpinner}),n===`pending`&&(0,B.jsx)(xs,{size:18}),n===`failed`&&(0,B.jsx)(hs,{size:18}),t<XX.length-1&&(0,B.jsx)(`div`,{className:Z.forkProgressStepLine})]}),(0,B.jsxs)(`div`,{className:Z.forkProgressStepContent,children:[(0,B.jsx)(`span`,{className:Z.forkProgressStepLabel,children:e.label}),(0,B.jsx)(`span`,{className:Z.forkProgressStepDesc,children:e.description})]})]},e.key)})}),r&&t&&(0,B.jsxs)(`div`,{className:Z.forkProgressError,children:[(0,B.jsx)(hs,{size:14}),(0,B.jsx)(`span`,{children:t})]})]})})}function yft({discovering:e}){return(0,B.jsxs)(`div`,{className:Z.conversationConnecting,role:`status`,"aria-label":e?`Discovering conversation`:`Loading conversation`,children:[(0,B.jsxs)(`div`,{className:Z.transcriptSkeleton,"aria-hidden":`true`,children:[(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonAssistant,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonAvatar}),(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonLines,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLine}),(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLineShort})]})]}),(0,B.jsx)(`div`,{className:Z.transcriptSkeletonUser,children:(0,B.jsx)(`span`,{className:Z.transcriptSkeletonBubble})}),(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonAssistant,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonAvatar}),(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonLines,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLineMedium}),(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLineShort})]})]}),(0,B.jsx)(`div`,{className:Z.transcriptSkeletonUser,children:(0,B.jsx)(`span`,{className:Z.transcriptSkeletonBubbleShort})})]}),e&&(0,B.jsx)(`span`,{children:`Discovering conversation…`})]})}function bft(e,t,n){window.dispatchEvent(new CustomEvent(`overdeck:open-fork-modal`,{detail:{conversation:e,mode:t===`handoff`?`handoff`:`summary`,focus:n}}))}function xft({conversation:e,agentId:t,serverBaseCount:n,onSendFailed:r}){let i=jnt(e.name),a=Mnt(e.name),o=EG(e=>e.failSend),s=EG(e=>e.removeFailed),c=EG(e=>e.retryFailed),l=EG(e=>e.replaceCommandResult),u=EG(e=>e.removeCommandResult),d=(0,z.useCallback)((t,n,i)=>{o(e.name,t,n,i),r?.()},[e.name,o,r]),f=(0,z.useCallback)((r,i)=>{c(e.name,r,i,n,t).then(t=>{t?.kind===`ui`&&bft(e,t.action,t.args.focus||void 0)})},[t,e,c,n]);return{commandResults:a,failedMessages:i,handleConfirmCommand:(0,z.useCallback)(async(n,r)=>{let i=a.find(e=>e.id===n),o=i?.commandResult;if(!i?.commandText||o?.kind!==`confirmation`)throw Error(`This command confirmation is no longer available.`);let s=await vG(e.name,i.commandText,t,void 0,{nonce:o.nonce,typedText:r});if(!s)throw Error(`The command did not return a structured result.`);if(s.kind===`ui`){u(e.name,n),bft(e,s.action,s.args.focus||void 0);return}l(e.name,n,s)},[t,a,e,u,l]),handleDiscardFailed:(0,z.useCallback)(t=>{s(e.name,t)},[e.name,s]),handleRetryFailed:f,handleSendFailed:d}}function ZX({options:e,value:t,onChange:n,ariaLabel:r}){return(0,B.jsx)(`div`,{className:Z.viewToggle,role:`tablist`,"aria-label":r,children:e.map(e=>(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,"aria-label":e.disabled&&e.disabledReason?`${e.label} — ${e.disabledReason}`:void 0,className:`${Z.viewToggleBtn} ${t===e.id?Z.viewToggleBtnActive:``}`,disabled:e.disabled,title:e.disabledReason,onClick:()=>n(e.id),children:e.label},e.id))})}var Sft=600*1e3;function Cft(e,t=Date.now()){if(!e)return!1;let n=Date.parse(e);return Number.isFinite(n)&&t-n<Sft}var wft={init:cl,thinking:gc,bash:nl,file:zs,search:Vc,web:ac,agent:gc,tool:ol,processing:gc};async function Tft(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/delivery-method`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deliveryMethod:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to update delivery method (${n.status})${e?`: ${e}`:``}`)}}function QX({conversation:e,viewMode:t=`conversation`,onViewModeChange:n,onArchived:r,roundMarkers:i,roundMetadata:a,embedded:o=!1,agentId:s,targetMessageId:c,targetMessageIndex:l,targetMessageNonce:u,onTargetMessageHandled:d,hideToolCalls:f,onToggleHideToolCalls:p,onEmbeddedResume:m,embeddedResumeLabel:h,hideComposer:g=!1,onSendFailed:_}){let[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!0),[S,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(!1),E=ul(),D=lO(e.name,()=>{}),[O,k]=(0,z.useState)(()=>e.model||DD()),[A,j]=(0,z.useState)(()=>(e.harness===`pi`?`ohmypi`:e.harness)??`claude-code`),[M,N]=(0,z.useState)(!1),[P,F]=(0,z.useState)(``),I=(0,z.useRef)(null),L=(0,z.useRef)(``),ee=(0,z.useRef)(!1),R=yt(),te=(0,z.useMemo)(()=>qX(e.name),[e.name]),{enabled:ne,receivedFirstPayload:re}=uft(e),ie=(0,z.useRef)(ne);ie.current=ne;let[ae,oe]=(0,z.useState)(e.deliveryMethod??`auto`),[se,ce]=(0,z.useState)(!1),[le,ue]=(0,z.useState)(!1);(0,z.useEffect)(()=>{ue(!1)},[e.name]),(0,z.useEffect)(()=>{e.model&&e.model!==O&&k(e.model)},[e.model]),(0,z.useEffect)(()=>{e.harness&&e.harness!==A&&j(e.harness===`pi`?`ohmypi`:e.harness)},[e.harness]),(0,z.useEffect)(()=>{e.deliveryMethod&&e.deliveryMethod!==ae&&oe(e.deliveryMethod)},[e.deliveryMethod]),(0,z.useEffect)(()=>{ne&&R.cancelQueries({queryKey:te})},[te,R,ne]),(0,z.useEffect)(()=>{v&&e.sessionAlive&&y(!1)},[v,e.sessionAlive]),(0,z.useEffect)(()=>{y(!1)},[e.name]);let{data:de,isLoading:fe}=V({queryKey:te,queryFn:async({signal:t})=>{let n=await Eft(e.name,t,s);if(ie.current){let e=R.getQueryData(te);if(e&&e.messages.length>=n.messages.length)return e}return n},enabled:!ne,refetchInterval:ne?!1:e.sessionAlive?2e3:!1}),pe=de?.subagents??[],{selectedAgentId:me,selectedSubagent:he,clearSelection:ge}=mft(pe),_e=de?.messages??[],ve=de?.workLog??[],ye=!s&&!e.sessionAlive&&!e.claudeSessionId&&_e.length===0,be=ZWe(e.sessionAlive,de==null?[]:_e,ve),xe=be?JWe(_e,ve):`thinking`,Se=KD(xe,be?YWe(ve):void 0),Ce=wft[xe],we=qD(xe)?Z.spinnerIcon:Z.pulseIcon,{resolvedTheme:Te}=mO(),Ee=e.id<0,{data:De}=V({queryKey:[`conversation-diffs`,e.name],queryFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/diffs`);return t.ok?t.json():null},enabled:!Ee,refetchInterval:5e3}),Oe=(0,z.useMemo)(()=>{let e=new Map;if(!De?.summaries)return e;let t=(de?.messages??[]).filter(e=>e.role===`assistant`).sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime());for(let n of De.summaries){if(n.assistantMessageId){e.set(n.assistantMessageId,n);continue}if(t.length>0&&n.completedAt){let r=new Date(n.completedAt).getTime(),i=null,a=1/0;for(let e of t){let t=r-new Date(e.createdAt).getTime();t>=0&&t<a&&(a=t,i=e.id)}i&&a<10080*60*1e3&&e.set(i,n)}}return e},[De?.summaries,de?.messages]),[ke,Ae]=(0,z.useState)(()=>VX(Object.fromEntries(new URLSearchParams(window.location.search))).diff===`1`);(0,z.useEffect)(()=>{let e=()=>{Ae(VX(Object.fromEntries(new URLSearchParams(window.location.search))).diff===`1`)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let je=(0,z.useCallback)((e,t)=>{let n=new URLSearchParams(window.location.search);n.set(`diff`,`1`),n.set(`diffTurnId`,e),t?n.set(`diffFilePath`,t):n.delete(`diffFilePath`);let r=`${window.location.pathname}?${n.toString()}`;window.history.pushState({},``,r),window.dispatchEvent(new PopStateEvent(`popstate`)),Ae(!0)},[]),Me=(0,z.useCallback)(()=>{let e=new URLSearchParams(window.location.search);e.delete(`diff`),e.delete(`diffTurnId`),e.delete(`diffFilePath`);let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)),Ae(!1)},[]),Ne=Mt({mutationFn:()=>Vnt(e.name,O,e.effort??void 0,A,b),onSuccess:()=>{R.invalidateQueries({queryKey:[`conversations`]}),R.invalidateQueries({queryKey:qX(e.name)}),oL(e.name),y(!0)}}),Pe=Mt({mutationFn:({model:t,harness:n})=>{if(s)throw Error(`Agent models are locked after spawn`);return fetch(`/api/conversations/${encodeURIComponent(e.name)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,harness:n})}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`Failed to switch model (${e.status})`)}return e.json()})},onSuccess:(t,{model:n,harness:r})=>{JW(n),YW(r),R.invalidateQueries({queryKey:[`conversations`]}),R.invalidateQueries({queryKey:qX(e.name)})},onError:e=>{U.error(e.message,{duration:6e3})}}),Fe=Mt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/abort`,{method:`POST`});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Failed to stop turn (${t.status})${e?`: ${e}`:``}`)}},onError:e=>{U.error(e.message,{duration:6e3})}}),Ie=Mt({mutationFn:t=>BGe(e.name,t),onSuccess:()=>{R.invalidateQueries({queryKey:[`conversations`]})}}),Le=Mt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/retitle`,{method:`POST`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Failed to regenerate title`);return n},onSuccess:e=>{R.invalidateQueries({queryKey:[`conversations`]}),U.success(`Renamed to "${e.title}"`,{duration:4e3})},onError:e=>{U.error(e.message,{duration:6e3})}}),Re=V({queryKey:[`conversation-about`,e.name],queryFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/about`);if(!t.ok)throw Error(`Failed to load conversation summary`);return t.json()},enabled:le&&!o,staleTime:6e4}),ze=Mt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/about?refresh=1`),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Failed to refresh summary`);return n},onSuccess:t=>{R.setQueryData([`conversation-about`,e.name],t)},onError:e=>{U.error(e.message,{duration:6e3})}}),Be=(0,z.useCallback)(()=>{ee.current=!1;let t=e.title??e.name;L.current=t,F(t),N(!0),setTimeout(()=>{I.current?.select()},0)},[e.title,e.name]),Ve=(0,z.useCallback)(()=>{if(ee.current)return;ee.current=!0;let t=L.current.trim(),n=e.title??e.name;N(!1),t&&t!==n&&Ie.mutate(t)},[e.title,e.name,Ie]),He=(0,z.useCallback)(()=>{N(!1),F(``)},[]),Ue=(0,z.useCallback)(()=>{Ne.mutate()},[Ne]),We=(0,z.useCallback)(async()=>{try{await fetch(`/api/conversations/${encodeURIComponent(e.name)}/archive`,{method:`POST`}),R.invalidateQueries({queryKey:[`conversations`]}),_Ge(e.name),r?.()}catch(e){console.error(`[ConversationPanel] Archive failed:`,e)}},[e.name,R,r]),Ge=(0,z.useCallback)(()=>{let t=de?.messages??[];if(t.length===0){U.error(`No messages to export yet`);return}let n=t.map(e=>`## ${e.role}\n\n${e.text??``}\n`).join(`
|
|
656
|
+
`;function Xdt(e,t=`diff-panel`){if(!e)return null;let n=e.trim();if(n.length===0)return null;try{let e=Eut(n,Vdt(n,t)).flatMap(e=>e.files);return e.length>0?{kind:`files`,files:e}:{kind:`raw`,text:n,reason:`Unsupported diff format. Showing raw patch.`}}catch{return{kind:`raw`,text:n,reason:`Failed to parse patch. Showing raw patch.`}}}function WX(e){let t=e.name??e.prevName??``;return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t}function Zdt(e){return e.cacheKey??`${e.prevName??`none`}:${e.name}`}function Qdt(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function GX(){return VX(Object.fromEntries(new URLSearchParams(window.location.search)))}function $dt(e){let t=new URLSearchParams(window.location.search);t.delete(`diff`),t.delete(`diffTurnId`),t.delete(`diffFilePath`),e.diff&&t.set(`diff`,e.diff),e.diffTurnId&&t.set(`diffTurnId`,e.diffTurnId),e.diffFilePath&&t.set(`diffFilePath`,e.diffFilePath);let n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.pushState({},``,r)}function eft(){let e=new URLSearchParams(window.location.search);e.delete(`diff`),e.delete(`diffTurnId`),e.delete(`diffFilePath`);let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.pushState({},``,n)}function KX(e){return(0,B.jsx)(`button`,{type:`button`,role:`button`,"aria-label":e.ariaLabel,title:e.title,"aria-pressed":e.pressed,className:Kx(`inline-flex size-7 items-center justify-center rounded-md border text-muted-foreground transition-colors`,e.pressed?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 hover:border-border hover:text-foreground/80`),onClick:()=>e.onPressedChange(!e.pressed),children:e.children})}function tft({files:e,onSelectFile:t,isLoading:n}){if(n)return(0,B.jsx)(Jdt,{label:`Loading file list...`});if(e.length===0)return(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No changed files in this selection.`});let r=[...e].sort((e,t)=>e.path.localeCompare(t.path,void 0,{numeric:!0,sensitivity:`base`}));return(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto px-2 py-2`,children:[(0,B.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-muted-foreground/70`,children:[e.length,` changed file`,e.length===1?``:`s`,` — select a file to view its diff`]}),(0,B.jsx)(`div`,{className:`space-y-px`,children:r.map(e=>{let n=e.path.split(`/`),r=n.pop()??e.path,i=n.join(`/`);return(0,B.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-[11px] transition-colors hover:bg-accent`,onClick:()=>t(e.path),children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[i&&(0,B.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[i,`/`]}),(0,B.jsx)(`span`,{className:`text-foreground/90`,children:r})]}),(0,B.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[e.additions!=null&&e.additions>0&&(0,B.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions!=null&&e.deletions>0&&(0,B.jsxs)(`span`,{className:`ml-1 text-red-400`,children:[`-`,e.deletions]})]})]},e.path)})})]})}function nft({mode:e=`inline`,agentId:t,turnDiffSummaries:n,onClose:r,diffUrlPrefix:i,defaultView:a=`full`,isolateSelection:o=!1}){let{resolvedTheme:s}=mO(),{prefs:c,update:l}=jdt(),u=c.diffRenderMode,d=c.diffWordWrap,f=(0,z.useRef)(null),p=(0,z.useRef)(null),[m,h]=(0,z.useState)(!1),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(GX);(0,z.useEffect)(()=>{if(o)return;let e=()=>y(GX());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[o]);let[b,x]=(0,z.useState)(()=>a===`vs-main`?{diff:`1`,diffTurnId:`vs-main`}:{diff:`1`}),S=o?b:v,C=e=>{o?x(e):($dt(e),y(GX()))},w=()=>{o?x({}):(eft(),y(GX()))},T=e===`inline`||S.diff===`1`,E=S.diffTurnId??null,D=E===null?null:S.diffFilePath??null,O=(0,z.useMemo)(()=>[...n].sort((e,t)=>{let n=e.checkpointTurnCount??0,r=t.checkpointTurnCount??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[n]),k=E===`vs-main`,A=E===null||k?void 0:O.find(e=>e.turnId===E)??O[0],j=i??`/api/agents/${encodeURIComponent(t)}/diffs`,M=!D,N=M&&!!A,{data:P,isLoading:F}=V({queryKey:k?[`diff-vs-main`,t,D??null]:A?[`diff-turn`,t,A.turnId,D??null]:[`diff-full`,t,D??null],queryFn:async()=>{let e=k?`${j}/vs-main`:A?`${j}/${encodeURIComponent(A.turnId)}`:`${j}/full`;D&&(e+=`?file=${encodeURIComponent(D)}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch diff`);return t.json()},enabled:T&&!N}),I=M?A?.files??P?.files:void 0,L=P?.diff,ee=typeof L==`string`&&L.trim().length===0,R=(0,z.useMemo)(()=>Xdt(L,`diff-panel:${s}`),[s,L]),te=(0,z.useMemo)(()=>!R||R.kind!==`files`?[]:[...R.files].sort((e,t)=>WX(e).localeCompare(WX(t),void 0,{numeric:!0,sensitivity:`base`})),[R]);(0,z.useEffect)(()=>{!D||!f.current||Array.from(f.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===D)?.scrollIntoView({block:`nearest`})},[D,te]);let ne=(0,z.useCallback)(()=>{let e=p.current;if(!e){h(!1),_(!1);return}let t=Math.max(0,e.scrollWidth-e.clientWidth);h(e.scrollLeft>4),_(e.scrollLeft<t-4)},[]),re=(0,z.useCallback)(e=>{let t=p.current;t&&t.scrollBy({left:e,behavior:`smooth`})},[]),ie=(0,z.useCallback)(e=>{let t=p.current;t&&(t.scrollWidth<=t.clientWidth+1||Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollBy({left:e.deltaY,behavior:`auto`})))},[]);(0,z.useEffect)(()=>{let e=p.current;if(!e)return;let t=window.requestAnimationFrame(()=>ne()),n=()=>ne();e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(()=>ne());return r.observe(e),()=>{window.cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),r.disconnect()}},[ne]),(0,z.useEffect)(()=>{let e=window.requestAnimationFrame(()=>ne());return()=>window.cancelAnimationFrame(e)},[O,E,ne]),(0,z.useEffect)(()=>{let e=p.current;e&&e.querySelector(`[data-turn-chip-selected='true']`)?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},[A?.turnId,E]);let ae=e=>{C({diff:`1`,diffTurnId:e})},oe=e=>{let t=E??void 0;C({diff:`1`,...t&&{diffTurnId:t},diffFilePath:e})},se=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[m&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-8 z-10 w-7 bg-gradient-to-r from-card to-transparent`}),g&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-8 z-10 w-7 bg-gradient-to-l from-card to-transparent`}),(0,B.jsx)(`button`,{type:`button`,className:Kx(`absolute left-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,m?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>re(-180),disabled:!m,"aria-label":`Scroll turn list left`,children:(0,B.jsx)(fs,{className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,className:Kx(`absolute right-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,g?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>re(180),disabled:!g,"aria-label":`Scroll turn list right`,children:(0,B.jsx)(ps,{className:`size-3.5`})}),(0,B.jsxs)(`div`,{ref:p,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,onWheel:ie,children:[(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>{C({diff:`1`})},"data-turn-chip-selected":E===null,children:(0,B.jsx)(`div`,{className:Kx(`rounded-md border px-2 py-1 text-left transition-colors`,E===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,B.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`})})}),(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>{C({diff:`1`,diffTurnId:`vs-main`})},"data-turn-chip-selected":k,children:(0,B.jsx)(`div`,{className:Kx(`rounded-md border px-2 py-1 text-left transition-colors`,k?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,B.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`vs main`})})}),O.map((e,t)=>(0,B.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>ae(e.turnId),title:e.turnId,"data-turn-chip-selected":e.turnId===A?.turnId,children:(0,B.jsx)(`div`,{className:Kx(`rounded-md border px-2 py-1 text-left transition-colors`,e.turnId===A?.turnId?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,e.checkpointTurnCount??O.length-t]}),(0,B.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:Qdt(e.completedAt)})]})})},e.turnId))]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,B.jsx)(KX,{pressed:u===`stacked`,onPressedChange:()=>l({diffRenderMode:`stacked`}),ariaLabel:`Stacked diff view`,children:(0,B.jsx)(vae,{className:`size-3`})}),(0,B.jsx)(KX,{pressed:u===`split`,onPressedChange:()=>l({diffRenderMode:`split`}),ariaLabel:`Split diff view`,children:(0,B.jsx)(Es,{className:`size-3`})}),(0,B.jsx)(KX,{pressed:d,onPressedChange:e=>l({diffWordWrap:e}),ariaLabel:d?`Disable diff line wrapping`:`Enable diff line wrapping`,title:d?`Disable line wrapping`:`Enable line wrapping`,children:(0,B.jsx)(Lae,{className:`size-3`})}),e===`inline`&&(0,B.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-md border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:border-border hover:text-foreground/80`,onClick:()=>{let e=new URLSearchParams;e.set(`diff`,`1`),e.set(`prefix`,j),e.set(`agentId`,t),E&&e.set(`diffTurnId`,E),D&&e.set(`diffFilePath`,D),window.open(`/popout/diff?${e.toString()}`,`_blank`,`width=1000,height=800`)},"aria-label":`Open diff in new window`,title:`Pop out`,children:(0,B.jsx)(Is,{className:`size-3`})}),r&&(0,B.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-md border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:border-border hover:text-foreground/80`,onClick:()=>{w(),r?.()},"aria-label":`Close diff panel`,children:(0,B.jsx)(sl,{className:`size-3`})})]})]});return T?(0,B.jsx)(qdt,{mode:e,header:se,children:O.length===0&&!k?(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):M?(0,B.jsx)(tft,{files:I??[],onSelectFile:oe,isLoading:F&&!I}):(0,B.jsx)(`div`,{ref:f,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:R?R.kind===`files`?(0,B.jsx)(fdt,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:te.map(e=>{let t=WX(e),n=`${Zdt(e)}:${s}`;return(0,B.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,children:(0,B.jsx)(Ddt,{fileDiff:e,options:{diffStyle:c.diffRenderMode===`split`?`split`:`unified`,lineDiffType:c.lineDiffType,overflow:c.diffWordWrap?`wrap`:`scroll`,diffIndicators:c.diffIndicators,hunkSeparators:c.hunkSeparators,expandUnchanged:c.expandUnchanged,collapsedContextThreshold:c.collapsedContextThreshold,lineHoverHighlight:c.lineHoverHighlight,disableLineNumbers:c.disableLineNumbers,enableLineSelection:c.enableLineSelection,theme:Fdt(s),themeType:s,unsafeCSS:Ydt}})},n)})}):(0,B.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:R.reason}),(0,B.jsx)(`pre`,{className:Kx(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,d?`overflow-auto whitespace-pre-wrap break-words`:`overflow-auto`),children:R.text})]})}):F?(0,B.jsx)(Jdt,{label:`Loading checkpoint diff...`}):(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,B.jsx)(`p`,{children:ee?`No net changes in this selection.`:`No patch available for this selection.`})})})}):null}function rft(e){return new Worker(`/assets/worker-C-69Fj6S.js`,{name:e?.name})}function ift({themeName:e}){let t=xdt(),n=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{if(!t)return;let r=t.getDiffRenderOptions();n.current&&r.theme===e||(n.current=!0,t.setRenderOptions({...r,theme:e}).catch(()=>void 0))},[e,t]),null}function aft({children:e}){let{resolvedTheme:t}=mO(),n=Fdt(t);return(0,B.jsxs)(bdt,{poolOptions:{workerFactory:()=>new rft,poolSize:(0,z.useMemo)(()=>{let e=typeof navigator>`u`?4:Math.max(1,navigator.hardwareConcurrency||4);return Math.max(2,Math.min(6,Math.floor(e/2)))},[]),totalASTLRUCacheSize:240},highlighterOptions:{theme:n,tokenizeMaxLineLength:1e3},children:[(0,B.jsx)(ift,{themeName:n}),e]})}var qX=e=>[`conversation-messages`,e],oft=(e,t)=>[`conversation-messages`,e,`subagent`,t];function sft(e,t){let n=e;for(let e of t){if(typeof e.sequence!=`number`||e.sequence<=n)return!1;n=e.sequence}return!0}function JX(e,t){if(t.length===0)return e;if(e.length===0)return t;let n=e[e.length-1],r=t[0];if(r.id===n.id){let n=[...e.slice(0,-1),r],i=t.slice(1);if(i.length===0)return n;if(typeof r.sequence==`number`&&sft(r.sequence,i))return[...n,...i]}else if(typeof n.sequence==`number`&&sft(n.sequence,t))return[...e,...t];let i=new Set(e.map(e=>e.id));if(t.every(e=>!i.has(e.id)))return[...e,...t];let a=new Map;for(let t of e)a.set(t.id,t);for(let e of t)a.set(e.id,e);return Array.from(a.values())}function cft(e,t){if(t.kind===`discovering`)return e?.discovering?e:{messages:e?.messages??[],workLog:e?.workLog??[],streaming:e?.streaming??!0,...e,discovering:!0};if(t.kind===`subagents`)return{messages:e?.messages??[],workLog:e?.workLog??[],streaming:e?.streaming??!0,...e,subagents:t.subagents};let n=t.snapshot!==!1,r=n&&t.messages.length<(e?.messages.length??0),i=n&&!r;return{...e,messages:i?t.messages:JX(e?.messages??[],t.messages),workLog:i?t.workLog:JX(e?.workLog??[],t.workLog),streaming:t.streaming,proposedPlan:t.proposedPlan??e?.proposedPlan,compactBoundaries:i?t.compactBoundaries:JX(e?.compactBoundaries??[],t.compactBoundaries??[]),contextUsage:`contextUsage`in t?t.contextUsage:e?.contextUsage,discovering:!1}}function lft(e){if(e.id!==void 0&&e.id>=0){if(e.endedAt)return!1;if(e.harness==null)return!0;let t=tb(e.harness);return t.supportsConversationStreaming||t.supportsPatchProjection}if(!e.sessionAlive)return!1;let t=e.name??``,n=/^(agent-|planning-|specialist-)/.test(t),r=tb(e.harness).supportsConversationStreaming;return n&&r}function uft(e){let t=yt(),n=lft(e),r=`${n?`enabled`:`disabled`}:${e.name}`,[i,a]=(0,z.useState)(null),o=i===r;return(0,z.useLayoutEffect)(()=>{a(null)},[r]),(0,z.useEffect)(()=>{if(!n)return;let i=qX(e.name);t.cancelQueries({queryKey:i});let o=lb().subscribe(t=>t[Cy.subscribeConversationMessages]({conversationName:e.name}),e=>{a(r),t.setQueryData(i,t=>cft(t,e))});return()=>{o()}},[e.name,n,t,r]),{enabled:n,receivedFirstPayload:o}}function dft(e,t){let n=yt(),r=t!==null&&lft(e),i=(0,z.useMemo)(()=>oft(e.name,t??``),[t,e.name]);return(0,z.useEffect)(()=>{if(!t||!r)return;n.cancelQueries({queryKey:i});let a=lb().subscribe(n=>n[Cy.subscribeConversationMessages]({conversationName:e.name,agentId:t}),e=>{n.setQueryData(i,t=>cft(t,e))});return()=>a()},[t,e.name,n,i,r]),(0,z.useEffect)(()=>{if(t)return()=>n.removeQueries({queryKey:i,exact:!0})},[t,n,i]),V({queryKey:i,queryFn:async({signal:n})=>{let r=await vl(`/api/conversations/${encodeURIComponent(e.name)}/messages?agentId=${encodeURIComponent(t??``)}`,{signal:n});if(!r.ok)throw Error(`Failed to fetch subagent messages`);return r.json()},enabled:t!==null&&!r})}var fft=`overdeck.ui.agentsRailCollapsed`;function pft(){return new URLSearchParams(window.location.search).get(`subagent`)}function YX(e){let t=new URLSearchParams(window.location.search);e?t.set(`subagent`,e):t.delete(`subagent`);let n=t.toString();window.history.pushState({},``,n?`${window.location.pathname}?${n}`:window.location.pathname),window.dispatchEvent(new PopStateEvent(`popstate`))}function mft(e){let[t,n]=(0,z.useState)(pft);(0,z.useEffect)(()=>{let e=()=>n(pft());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let r=(0,z.useCallback)(()=>YX(null),[]);return{selectedAgentId:t,selectedSubagent:e.find(e=>e.agentId===t)??null,clearSelection:r}}function hft({conversation:e,subagents:t,selectedAgentId:n}){let r=(0,z.useCallback)(e=>YX(e),[]),[i,a]=(0,z.useState)(()=>typeof window<`u`&&localStorage.getItem(fft)===`true`),o=(0,z.useCallback)(e=>{a(e);try{localStorage.setItem(fft,String(e))}catch{}},[]);return t.length===0?null:i?(0,B.jsxs)(`button`,{type:`button`,className:`flex w-[30px] min-w-[30px] shrink-0 cursor-pointer flex-col items-center gap-2.5 border-l border-border bg-card pt-2.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:()=>o(!1),title:`Show Agents`,"aria-label":`Show agents rail`,children:[(0,B.jsx)(fs,{size:16}),(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] [writing-mode:vertical-rl]`,children:`Agents`})]}):(0,B.jsxs)(`aside`,{"aria-label":`Conversation agents`,className:`flex min-h-0 w-64 min-w-0 shrink-0 flex-col border-l border-border bg-card`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center border-b border-border px-3 text-xs font-medium text-muted-foreground`,children:[`Agents`,(0,B.jsx)(`button`,{type:`button`,className:`ml-auto rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,"aria-label":`Collapse agents rail`,onClick:()=>o(!0),children:(0,B.jsx)(sl,{className:`h-4 w-4`,"aria-hidden":`true`})})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,B.jsx)(gft,{label:`Main agent`,description:e.title??e.name,status:e.sessionAlive?`running`:`done`,selected:n===null,onClick:()=>r(null)}),t.map(e=>(0,B.jsx)(gft,{label:e.agentType,description:e.description,status:e.status,halo:e.status===`running`,depth:e.spawnDepth,selected:n===e.agentId,onClick:()=>r(e.agentId)},e.agentId))]})]})}function gft({label:e,description:t,status:n,halo:r=!1,depth:i,selected:a,onClick:o}){return(0,B.jsxs)(`button`,{type:`button`,"aria-current":a?`true`:void 0,className:`flex w-full items-start gap-2 border-b border-l-2 border-b-border px-3 py-2 text-left transition-colors ${a?`border-l-primary bg-accent`:`border-l-transparent hover:bg-accent`}`,onClick:o,children:[(0,B.jsxs)(`span`,{"aria-label":n,className:`relative mt-1.5 flex h-2.5 w-2.5 shrink-0 items-center justify-center`,children:[r&&(0,B.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-primary opacity-60`}),(0,B.jsx)(`span`,{className:`relative inline-flex rounded-full ${n===`running`?`h-2.5 w-2.5 bg-primary`:`h-2 w-2 bg-muted-foreground/40`}`})]}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate text-xs font-medium text-foreground`,children:e}),(0,B.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),i!==void 0&&i>1&&(0,B.jsxs)(`span`,{className:`rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`depth `,i]})]})}function _ft({conversation:e,subagent:t,resolvedTheme:n,onBack:r}){let i=dft(e,t.agentId);return(0,B.jsxs)(`div`,{className:`${Z.subagentTranscript} flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Back to main agent`,className:`rounded-sm p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:r,children:(0,B.jsx)(Tie,{size:16})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:[t.agentType,` `,(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,t.description]})]})]}),(0,B.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:i.isLoading?(0,B.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(gc,{size:14,className:`animate-spin text-primary`}),`Loading transcript…`]}):i.isError?(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-sm text-destructive-foreground`,children:`Couldn't load this subagent transcript.`}):(0,B.jsx)(DL,{messages:i.data?.messages??[],workLog:i.data?.workLog??[],streaming:i.data?.streaming??t.status===`running`,conversationName:`${e.name}:${t.agentId}`,cwd:e.cwd,issueId:e.issueId,resolvedTheme:n})})]})}var XX=[{key:`summarizing`,label:`Summarizing`,description:`Generating a concise summary of the parent conversation`},{key:`spawning`,label:`Spawning`,description:`Starting a new Claude Code session`},{key:`injecting`,label:`Injecting`,description:`Seeding the new session with conversation context`}];function vft({forkStatus:e,forkError:t,parentTitle:n}){let r=e===`failed`,i=XX.findIndex(t=>t.key===e);return(0,B.jsx)(`div`,{className:Z.forkProgressView,children:(0,B.jsxs)(`div`,{className:Z.forkProgressCard,children:[(0,B.jsxs)(`div`,{className:Z.forkProgressHeader,children:[(0,B.jsx)(Qs,{size:20,className:Z.forkProgressIcon}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:Z.forkProgressTitle,children:r?`Fork Failed`:`Setting up fork…`}),n&&(0,B.jsxs)(`p`,{className:Z.forkProgressSubtitle,children:[`Forking from `,(0,B.jsx)(`strong`,{children:n})]})]})]}),(0,B.jsx)(`div`,{className:Z.forkProgressTimeline,children:XX.map((e,t)=>{let n;return n=r?t<i?`done`:t===i||i===-1&&t===0?`failed`:`pending`:t<i?`done`:t===i?`active`:`pending`,(0,B.jsxs)(`div`,{className:`${Z.forkProgressStep} ${Z[`forkProgressStep--${n}`]}`,children:[(0,B.jsxs)(`div`,{className:Z.forkProgressStepIndicator,children:[n===`done`&&(0,B.jsx)(_s,{size:18}),n===`active`&&(0,B.jsx)(gc,{size:18,className:Z.forkProgressSpinner}),n===`pending`&&(0,B.jsx)(xs,{size:18}),n===`failed`&&(0,B.jsx)(hs,{size:18}),t<XX.length-1&&(0,B.jsx)(`div`,{className:Z.forkProgressStepLine})]}),(0,B.jsxs)(`div`,{className:Z.forkProgressStepContent,children:[(0,B.jsx)(`span`,{className:Z.forkProgressStepLabel,children:e.label}),(0,B.jsx)(`span`,{className:Z.forkProgressStepDesc,children:e.description})]})]},e.key)})}),r&&t&&(0,B.jsxs)(`div`,{className:Z.forkProgressError,children:[(0,B.jsx)(hs,{size:14}),(0,B.jsx)(`span`,{children:t})]})]})})}function yft({discovering:e}){return(0,B.jsxs)(`div`,{className:Z.conversationConnecting,role:`status`,"aria-label":e?`Discovering conversation`:`Loading conversation`,children:[(0,B.jsxs)(`div`,{className:Z.transcriptSkeleton,"aria-hidden":`true`,children:[(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonAssistant,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonAvatar}),(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonLines,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLine}),(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLineShort})]})]}),(0,B.jsx)(`div`,{className:Z.transcriptSkeletonUser,children:(0,B.jsx)(`span`,{className:Z.transcriptSkeletonBubble})}),(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonAssistant,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonAvatar}),(0,B.jsxs)(`div`,{className:Z.transcriptSkeletonLines,children:[(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLineMedium}),(0,B.jsx)(`span`,{className:Z.transcriptSkeletonLineShort})]})]}),(0,B.jsx)(`div`,{className:Z.transcriptSkeletonUser,children:(0,B.jsx)(`span`,{className:Z.transcriptSkeletonBubbleShort})})]}),e&&(0,B.jsx)(`span`,{children:`Discovering conversation…`})]})}function bft(e,t,n){window.dispatchEvent(new CustomEvent(`overdeck:open-fork-modal`,{detail:{conversation:e,mode:t===`handoff`?`handoff`:`summary`,focus:n}}))}function xft({conversation:e,agentId:t,serverBaseCount:n,onSendFailed:r}){let i=jnt(e.name),a=Mnt(e.name),o=EG(e=>e.failSend),s=EG(e=>e.removeFailed),c=EG(e=>e.retryFailed),l=EG(e=>e.replaceCommandResult),u=EG(e=>e.removeCommandResult),d=(0,z.useCallback)((t,n,i)=>{o(e.name,t,n,i),r?.()},[e.name,o,r]),f=(0,z.useCallback)((r,i)=>{c(e.name,r,i,n,t).then(t=>{t?.kind===`ui`&&bft(e,t.action,t.args.focus||void 0)})},[t,e,c,n]);return{commandResults:a,failedMessages:i,handleConfirmCommand:(0,z.useCallback)(async(n,r)=>{let i=a.find(e=>e.id===n),o=i?.commandResult;if(!i?.commandText||o?.kind!==`confirmation`)throw Error(`This command confirmation is no longer available.`);let s=await vG(e.name,i.commandText,t,void 0,{nonce:o.nonce,typedText:r});if(!s)throw Error(`The command did not return a structured result.`);if(s.kind===`ui`){u(e.name,n),bft(e,s.action,s.args.focus||void 0);return}l(e.name,n,s)},[t,a,e,u,l]),handleDiscardFailed:(0,z.useCallback)(t=>{s(e.name,t)},[e.name,s]),handleRetryFailed:f,handleSendFailed:d}}function ZX({options:e,value:t,onChange:n,ariaLabel:r}){return(0,B.jsx)(`div`,{className:Z.viewToggle,role:`tablist`,"aria-label":r,children:e.map(e=>(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,"aria-label":e.disabled&&e.disabledReason?`${e.label} — ${e.disabledReason}`:void 0,className:`${Z.viewToggleBtn} ${t===e.id?Z.viewToggleBtnActive:``}`,disabled:e.disabled,title:e.disabledReason,onClick:()=>n(e.id),children:e.label},e.id))})}var Sft=600*1e3;function Cft(e,t=Date.now()){if(!e)return!1;let n=Date.parse(e);return Number.isFinite(n)&&t-n<Sft}var wft={init:cl,thinking:gc,bash:nl,file:zs,search:Vc,web:ac,agent:gc,tool:ol,processing:gc};async function Tft(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/delivery-method`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deliveryMethod:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to update delivery method (${n.status})${e?`: ${e}`:``}`)}}function QX({conversation:e,viewMode:t=`conversation`,onViewModeChange:n,onArchived:r,roundMarkers:i,roundMetadata:a,embedded:o=!1,agentId:s,targetMessageId:c,targetMessageIndex:l,targetMessageNonce:u,onTargetMessageHandled:d,hideToolCalls:f,onToggleHideToolCalls:p,onEmbeddedResume:m,embeddedResumeLabel:h,hideComposer:g=!1,onSendFailed:_}){let[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!0),[S,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(!1),E=ul(),D=lO(e.name,()=>{}),[O,k]=(0,z.useState)(()=>e.model||DD()),[A,j]=(0,z.useState)(()=>(e.harness===`pi`?`ohmypi`:e.harness)??`claude-code`),[M,N]=(0,z.useState)(!1),[P,F]=(0,z.useState)(``),I=(0,z.useRef)(null),L=(0,z.useRef)(``),ee=(0,z.useRef)(!1),R=yt(),te=(0,z.useMemo)(()=>qX(e.name),[e.name]),{enabled:ne,receivedFirstPayload:re}=uft(e),ie=(0,z.useRef)(ne);ie.current=ne;let[ae,oe]=(0,z.useState)(e.deliveryMethod??`auto`),[se,ce]=(0,z.useState)(!1),[le,ue]=(0,z.useState)(!1);(0,z.useEffect)(()=>{ue(!1)},[e.name]),(0,z.useEffect)(()=>{e.model&&e.model!==O&&k(e.model)},[e.model]),(0,z.useEffect)(()=>{e.harness&&e.harness!==A&&j(e.harness===`pi`?`ohmypi`:e.harness)},[e.harness]),(0,z.useEffect)(()=>{e.deliveryMethod&&e.deliveryMethod!==ae&&oe(e.deliveryMethod)},[e.deliveryMethod]),(0,z.useEffect)(()=>{ne&&R.cancelQueries({queryKey:te})},[te,R,ne]),(0,z.useEffect)(()=>{v&&e.sessionAlive&&y(!1)},[v,e.sessionAlive]),(0,z.useEffect)(()=>{y(!1)},[e.name]);let{data:de,isLoading:fe}=V({queryKey:te,queryFn:async({signal:t})=>{let n=await Eft(e.name,t,s);if(ie.current){let e=R.getQueryData(te);if(e&&e.messages.length>=n.messages.length)return e}return n},enabled:!ne,refetchInterval:ne?!1:e.sessionAlive?2e3:!1}),pe=de?.subagents??[],{selectedAgentId:me,selectedSubagent:he,clearSelection:ge}=mft(pe),_e=de?.messages??[],ve=de?.workLog??[],ye=!s&&!e.sessionAlive&&!e.claudeSessionId&&_e.length===0,be=ZWe(e.sessionAlive,de==null?[]:_e,ve),xe=be?JWe(_e,ve):`thinking`,Se=KD(xe,be?YWe(ve):void 0),Ce=wft[xe],we=qD(xe)?Z.spinnerIcon:Z.pulseIcon,{resolvedTheme:Te}=mO(),Ee=e.id<0,{data:De}=V({queryKey:[`conversation-diffs`,e.name],queryFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/diffs`);return t.ok?t.json():null},enabled:!Ee,refetchInterval:5e3}),Oe=(0,z.useMemo)(()=>{let e=new Map;if(!De?.summaries)return e;let t=(de?.messages??[]).filter(e=>e.role===`assistant`).sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime());for(let n of De.summaries){if(n.assistantMessageId){e.set(n.assistantMessageId,n);continue}if(t.length>0&&n.completedAt){let r=new Date(n.completedAt).getTime(),i=null,a=1/0;for(let e of t){let t=r-new Date(e.createdAt).getTime();t>=0&&t<a&&(a=t,i=e.id)}i&&a<10080*60*1e3&&e.set(i,n)}}return e},[De?.summaries,de?.messages]),[ke,Ae]=(0,z.useState)(()=>VX(Object.fromEntries(new URLSearchParams(window.location.search))).diff===`1`);(0,z.useEffect)(()=>{let e=()=>{Ae(VX(Object.fromEntries(new URLSearchParams(window.location.search))).diff===`1`)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let je=(0,z.useCallback)((e,t)=>{let n=new URLSearchParams(window.location.search);n.set(`diff`,`1`),n.set(`diffTurnId`,e),t?n.set(`diffFilePath`,t):n.delete(`diffFilePath`);let r=`${window.location.pathname}?${n.toString()}`;window.history.pushState({},``,r),window.dispatchEvent(new PopStateEvent(`popstate`)),Ae(!0)},[]),Me=(0,z.useCallback)(()=>{let e=new URLSearchParams(window.location.search);e.delete(`diff`),e.delete(`diffTurnId`),e.delete(`diffFilePath`);let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)),Ae(!1)},[]),Ne=Mt({mutationFn:()=>Vnt(e.name,O,e.effort??void 0,A,b),onSuccess:()=>{R.invalidateQueries({queryKey:[`conversations`]}),R.invalidateQueries({queryKey:qX(e.name)}),oL(e.name),y(!0)}}),Pe=Mt({mutationFn:({model:t,harness:n})=>{if(s)throw Error(`Agent models are locked after spawn`);return fetch(`/api/conversations/${encodeURIComponent(e.name)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,harness:n})}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`Failed to switch model (${e.status})`)}return e.json()})},onSuccess:(t,{model:n,harness:r})=>{JW(n),YW(r),R.invalidateQueries({queryKey:[`conversations`]}),R.invalidateQueries({queryKey:qX(e.name)})},onError:e=>{U.error(e.message,{duration:6e3})}}),Fe=Mt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/abort`,{method:`POST`});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Failed to stop turn (${t.status})${e?`: ${e}`:``}`)}},onError:e=>{U.error(e.message,{duration:6e3})}}),Ie=Mt({mutationFn:t=>BGe(e.name,t),onSuccess:()=>{R.invalidateQueries({queryKey:[`conversations`]})}}),Le=Mt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/retitle`,{method:`POST`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Failed to regenerate title`);return n},onSuccess:e=>{R.invalidateQueries({queryKey:[`conversations`]}),U.success(`Renamed to "${e.title}"`,{duration:4e3})},onError:e=>{U.error(e.message,{duration:6e3})}}),Re=V({queryKey:[`conversation-about`,e.name],queryFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/about`);if(!t.ok)throw Error(`Failed to load conversation summary`);return t.json()},enabled:le&&!o,staleTime:6e4}),ze=Mt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/about?refresh=1`),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Failed to refresh summary`);return n},onSuccess:t=>{R.setQueryData([`conversation-about`,e.name],t)},onError:e=>{U.error(e.message,{duration:6e3})}}),Be=(0,z.useCallback)(()=>{ee.current=!1;let t=e.title??e.name;L.current=t,F(t),N(!0),setTimeout(()=>{I.current?.select()},0)},[e.title,e.name]),Ve=(0,z.useCallback)(()=>{if(ee.current)return;ee.current=!0;let t=L.current.trim(),n=e.title??e.name;N(!1),t&&t!==n&&Ie.mutate(t)},[e.title,e.name,Ie]),He=(0,z.useCallback)(()=>{N(!1),F(``)},[]),Ue=(0,z.useCallback)(()=>{Ne.mutate()},[Ne]),We=(0,z.useCallback)(async()=>{try{await fetch(`/api/conversations/${encodeURIComponent(e.name)}/archive`,{method:`POST`}),R.invalidateQueries({queryKey:[`conversations`]}),_Ge(e.name),r?.()}catch(e){console.error(`[ConversationPanel] Archive failed:`,e)}},[e.name,R,r]),Ge=(0,z.useCallback)(()=>{let t=de?.messages??[];if(t.length===0){U.error(`No messages to export yet`);return}let n=t.map(e=>`## ${e.role}\n\n${e.text??``}\n`).join(`
|
|
657
657
|
`),r=`# ${e.title??e.name}\n\n`,i=new Blob([r+n],{type:`text/markdown`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${(e.title??e.name).replace(/[^\w.-]+/g,`-`)}.md`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),U.success(`Transcript exported`)},[de,e.title,e.name]),Ke=(0,z.useCallback)(t=>{t===`terminal`&&x5e(e.name),n?.(t)},[n,e.name]),qe=(0,z.useCallback)(async t=>{ce(!0);try{await Tft(e.name,t),oe(t)}catch(e){console.error(`[ConversationPanel] Failed to update delivery method:`,e)}finally{ce(!1)}},[e.name]),Je=vL(e.name),Ye=f??Je.hideToolCalls,Xe=p??Je.toggleHideToolCalls,Ze=(0,z.useCallback)(()=>{let n=new URLSearchParams;t===`terminal`&&n.set(`view`,`terminal`);let r=n.toString(),i=`${window.location.origin}/conv/${e.id}${r?`?${r}`:``}`;navigator.clipboard.writeText(i).then(()=>{C(!0),setTimeout(()=>C(!1),2e3)})},[e.id,t]),Qe=(0,z.useCallback)(()=>{let n=new URLSearchParams;t===`terminal`&&n.set(`view`,`terminal`);let r=n.toString(),i=`/popout/conversation/${e.id}${r?`?${r}`:``}`;window.open(i,`_blank`,`popup=yes,width=920,height=1040`)},[e.id,t]),$e=(0,z.useCallback)(()=>{window.open(`/api/conversations/${encodeURIComponent(e.name)}/handoff-doc`,`_blank`,`noopener,noreferrer`)},[e.name]),et=(0,z.useCallback)(()=>{e.handoffTargetConvId&&(window.location.href=`/conv/${e.handoffTargetConvId}`)},[e.handoffTargetConvId]),tt=e.sessionAlive||v,nt=ke?`conversation`:t;S5e(!!e.needsTerminal&&tt,t,n);let rt=!!e.forkStatus&&e.forkStatus!==`failed`,it=e.forkStatus===`failed`,at=!!e.spawnError,ot=!e.sessionAlive&&!e.endedAt&&!at&&Cft(e.createdAt),st=rt||ot?`var(--info)`:it||at?`var(--destructive)`:e.sessionAlive?`var(--info)`:`var(--muted-foreground)`,ct=rt?`forking`:ot?`starting`:it||at?`failed`:e.sessionAlive?`active`:`ended`,lt=be&&(e.harness===`ohmypi`||e.harness===`pi`);return(0,B.jsxs)(`div`,{className:Z.conversationTerminal,children:[!o&&(0,B.jsxs)(`div`,{className:`${Z.conversationHeaderShell} ${Z.conversationHeaderContainer}`,onContextMenu:e=>{M||(e.preventDefault(),T(!0))},children:[(0,B.jsxs)(`div`,{className:Z.conversationHeaderPrimary,children:[(0,B.jsxs)(`span`,{className:Z.conversationTerminalTitle,children:[be&&(0,B.jsx)(`span`,{title:Se,style:{display:`contents`},children:(0,B.jsx)(Ce,{size:14,className:we,"aria-label":Se})}),M?(0,B.jsx)(`input`,{ref:I,className:Z.conversationTitleInput,value:P,onChange:e=>{F(e.target.value),L.current=e.target.value},onKeyDown:e=>{e.key===`Enter`&&Ve(),e.key===`Escape`&&He()},onBlur:Ve,"aria-label":`Rename ${e.name}`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`${Z.conversationTerminalTitleText} ${Le.isPending?Z.titleRegenerating:``}`,children:e.title??e.name}),e.transcriptMissing&&(0,B.jsx)(`span`,{title:`Transcript missing — this conversation had activity, but its history file no longer exists on disk. The history cannot be recovered.`,"aria-label":`Transcript missing`,style:{display:`inline-flex`,alignItems:`center`,color:`var(--warning)`,flexShrink:0},children:(0,B.jsx)(Vs,{size:13})}),(0,B.jsx)(`button`,{className:Z.conversationTitleEditBtn,onClick:Be,title:`Rename conversation`,"aria-label":`Rename ${e.name}`,children:(0,B.jsx)(kc,{size:12})})]})]}),(0,B.jsxs)(`div`,{className:Z.conversationHeaderActions,children:[tt&&(0,B.jsx)(ZX,{ariaLabel:`Conversation view`,value:nt,onChange:Ke,options:[{id:`conversation`,label:`Conversation`},{id:`terminal`,label:`Terminal`}]}),(0,B.jsxs)(`button`,{className:`${Z.conversationAboutToggle} ${le?Z.conversationAboutToggleActive:``}`,onClick:()=>ue(e=>!e),title:le?`Hide conversation summary`:`Show conversation summary`,"aria-label":le?`Hide about this conversation`:`Show about this conversation`,"aria-pressed":le,children:[(0,B.jsx)(lc,{size:14}),(0,B.jsx)(`span`,{children:`About`})]}),(0,B.jsxs)(`button`,{className:`${Z.conversationAboutToggle} ${Ye?Z.conversationAboutToggleActive:``}`,onClick:Xe,title:Ye?`Show tool calls`:`Hide tool calls`,"aria-label":Ye?`Show tool calls`:`Hide tool calls`,"aria-pressed":Ye,children:[(0,B.jsx)(ol,{size:14}),(0,B.jsx)(`span`,{children:`Tools`})]}),lt&&(0,B.jsxs)(`button`,{className:`${Z.conversationAboutToggle} ${Fe.isPending?Z.conversationAboutToggleActive:``}`,onClick:()=>Fe.mutate(),disabled:Fe.isPending,title:`Stop current turn`,"aria-label":`Stop current turn`,children:[Fe.isPending?(0,B.jsx)(gc,{size:14,className:Z.spinnerIcon}):(0,B.jsx)($c,{size:14}),(0,B.jsx)(`span`,{children:Fe.isPending?`Stopping…`:`Stop`})]}),(0,B.jsx)(`button`,{className:Z.copyLinkButton,onClick:Ze,title:`Copy link to conversation`,"aria-label":`Copy link to conversation`,children:S?(0,B.jsx)(us,{size:14}):(0,B.jsx)(ks,{size:14})}),(0,B.jsx)(`button`,{className:Z.copyLinkButton,onClick:Qe,title:`Detach conversation`,"aria-label":`Detach conversation`,children:(0,B.jsx)(Is,{size:14})}),(0,B.jsxs)(`div`,{className:Z.headerMenuWrap,children:[(0,B.jsx)(`button`,{className:Z.copyLinkButton,onClick:()=>T(e=>!e),title:`More actions`,"aria-label":`More conversation actions`,"aria-haspopup":`menu`,"aria-expanded":w,children:(0,B.jsx)(Ps,{size:16})}),w&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:Z.headerMenuOverlay,onClick:()=>T(!1)}),(0,B.jsxs)(`div`,{role:`menu`,className:Z.headerMenu,children:[(0,B.jsxs)(`button`,{role:`menuitem`,className:`${Z.headerMenuItem} ${e.isFavorited?Z.headerMenuItemActive:``}`,onClick:()=>{D.toggleFavorite({name:e.name,favorited:!!e.isFavorited}),T(!1)},children:[(0,B.jsx)(el,{size:14,style:{fill:e.isFavorited?`currentColor`:`none`}}),e.isFavorited?`Unfavorite`:`Favorite`]}),(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{Le.mutate(),T(!1)},disabled:Le.isPending,children:[Le.isPending?(0,B.jsx)(gc,{size:14,className:Z.spinnerIcon}):(0,B.jsx)(Xc,{size:14}),`Regenerate title`]}),e.harness===`claude-code`&&(0,B.jsxs)(`div`,{className:Z.headerMenuDeliveryRow,children:[(0,B.jsx)(`span`,{children:`Delivery method`}),(0,B.jsxs)(`select`,{className:Z.deliveryMethodSelect,value:ae,onChange:e=>qe(e.target.value),disabled:se,title:`Message delivery method`,"aria-label":`Message delivery method`,children:[(0,B.jsx)(`option`,{value:`auto`,children:`Auto`}),(0,B.jsx)(`option`,{value:`channels`,children:`Channels`}),(0,B.jsx)(`option`,{value:`tmux`,children:`Tmux`})]})]}),(0,B.jsx)(`div`,{className:Z.headerMenuDivider}),e.claudeSessionId&&(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{D.openForkModal(e,{mode:`handoff`}),T(!1)},children:[(0,B.jsx)(Wc,{size:14}),`Hand off to new conversation`]}),e.claudeSessionId&&e.harness!==`pi`&&(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{D.openForkModal(e),T(!1)},children:[(0,B.jsx)(Qs,{size:14}),`Create summary fork`]}),(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{Ge(),T(!1)},children:[(0,B.jsx)(Ns,{size:14}),`Export transcript`]}),(e.handoffDocPath||e.handoffTargetConvId)&&(0,B.jsx)(`div`,{className:Z.headerMenuDivider}),e.handoffDocPath&&(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{$e(),T(!1)},children:[(0,B.jsx)(Bs,{size:14}),`Open handoff doc`]}),e.handoffTargetConvId&&(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{et(),T(!1)},children:[(0,B.jsx)(Is,{size:14}),`Open handoff target`]}),(e.sessionAlive||r)&&(0,B.jsx)(`div`,{className:Z.headerMenuDivider}),e.sessionAlive&&(0,B.jsxs)(`button`,{role:`menuitem`,className:Z.headerMenuItem,onClick:()=>{D.stop(e.name),T(!1)},children:[(0,B.jsx)($c,{size:14}),`Stop agent`]}),r&&(0,B.jsxs)(`button`,{role:`menuitem`,className:`${Z.headerMenuItem} ${Z.headerMenuItemDestructive}`,onClick:async()=>{T(!1),await E({title:e.isFavorited?`Archive favorited conversation`:`Archive conversation`,message:e.isFavorited?`"${e.title??e.name}" is favorited.\n\nArchiving will remove the favorite, end the session, and move it to the archive.`:`Archive "${e.title??e.name}"? This ends the session and moves it to the archive.`,confirmLabel:`Archive`,cancelLabel:`Cancel`,variant:`destructive`})&&We()},children:[(0,B.jsx)(as,{size:14}),`Archive conversation`]})]})]})]})]})]}),(0,B.jsxs)(`div`,{className:Z.conversationMetaRow,children:[(0,B.jsxs)(`span`,{className:Z.conversationTerminalStatus,children:[(0,B.jsx)(xs,{size:7,style:{fill:st,color:st}}),ct]}),e.branch&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:Z.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,B.jsxs)(`span`,{className:Z.terminalBranchBar,title:`${e.isWorktree?`Worktree`:`Local`} · ${e.cwd}`,children:[e.isWorktree?(0,B.jsx)(tc,{size:12}):(0,B.jsx)(Ys,{size:12}),(0,B.jsx)(`span`,{className:Z.terminalBranchBarMode,children:e.isWorktree?`Worktree`:`Local`}),(0,B.jsx)(`span`,{className:Z.terminalBranchBarText,children:e.branch})]})]}),(0,B.jsx)(`span`,{className:Z.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,B.jsx)(tL,{openInCwd:e.cwd}),e.totalCost!==void 0&&e.totalCost>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:Z.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,B.jsx)(`span`,{className:Z.featureCost,children:e.totalCost<.01?`<$0.01`:`$${e.totalCost.toFixed(2)}`})]}),(0,B.jsx)(`span`,{className:Z.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,B.jsx)(`span`,{className:Z.conversationSessionId,children:e.sessionFile?.split(`/`).pop()?.replace(`.jsonl`,``)??e.name})]})]}),!o&&le&&(0,B.jsx)(`div`,{className:Z.conversationAboutDrawer,children:Re.isLoading||ze.isPending?(0,B.jsxs)(`span`,{className:Z.conversationAboutMuted,children:[(0,B.jsx)(gc,{size:12,className:Z.spinnerIcon}),`Summarizing conversation…`]}):Re.isError?(0,B.jsx)(`span`,{className:Z.conversationAboutMuted,children:`Couldn't load the conversation summary.`}):Re.data?.summary?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:Z.conversationAboutText,children:Re.data.summary}),(0,B.jsxs)(`div`,{className:Z.conversationAboutMeta,children:[(0,B.jsxs)(`span`,{children:[`Summary of `,Re.data.messageCount,` `,Re.data.messageCount===1?`message`:`messages`]}),(0,B.jsx)(`button`,{className:Z.copyLinkButton,onClick:()=>ze.mutate(),disabled:ze.isPending,title:`Regenerate summary`,"aria-label":`Regenerate conversation summary`,children:(0,B.jsx)(Mc,{size:12})})]})]}):(0,B.jsx)(`span`,{className:Z.conversationAboutMuted,children:`Not enough conversation yet to summarize.`})}),(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:Z.conversationTerminalBody,children:[tt&&nt===`terminal`&&(0,B.jsx)(KP,{sessionName:e.tmuxSession}),(nt===`conversation`||!tt)&&(he?(0,B.jsx)(_ft,{conversation:e,subagent:he,resolvedTheme:Te,onBack:ge}):(0,B.jsx)(Dft,{conversation:e,onResume:m??(!o&&!tt&&!ot?Ue:void 0),onArchive:o?void 0:We,resumePending:Ne.isPending,resumeLabel:h,sendResumeContract:m?void 0:b,onSendResumeContractChange:m?void 0:x,hideComposer:g,onSendFailed:_,roundMarkers:i,roundMetadata:a,turnDiffSummaryByAssistantMessageId:Oe,onOpenTurnDiff:je,resolvedTheme:Te,agentId:s,hideToolCalls:Ye,workingPhase:be?xe:void 0,agentBusy:be,streamMessagesEnabled:ne,receivedFirstPayload:re,messagesData:de,messagesLoading:fe,onOpenTerminal:tt?()=>Ke(`terminal`):void 0,targetMessageId:c,targetMessageIndex:l,targetMessageNonce:u,onTargetMessageHandled:d,modelPicker:o?void 0:(0,B.jsx)($W,{value:O,harness:A,liveConversation:e.sessionAlive,disabled:!ye,onHarnessChange:e=>{ye&&(j(e),Pe.mutate({model:O,harness:e}))},onChange:e=>{ye&&(k(e),Pe.mutate({model:e,harness:A}))}})}))]}),ke&&De?.summaries&&(0,B.jsx)(aft,{children:(0,B.jsx)(nft,{mode:`inline`,agentId:s??e.name,turnDiffSummaries:De.summaries,onClose:Me,diffUrlPrefix:`/api/conversations/${encodeURIComponent(e.name)}/diffs`})}),(0,B.jsx)(hft,{conversation:e,subagents:pe,selectedAgentId:me})]}),D.forkTarget&&(0,B.jsx)(WD,{conversation:D.forkTarget,initialMode:D.forkTargetMode,initialFocus:D.forkTargetFocus,isPending:D.isForkPending,onClose:D.closeForkModal,onConfirm:(e,t,n,r,i,a,o,s,c,l,u,d,f,p)=>{D.submitFork(e,t,n,r,i,a,o,s,c,l,u,d,f,p)}})]})}async function Eft(e,t,n){let r=await vl(`/api/conversations/${encodeURIComponent(e)}/messages`,{signal:t});if(r.status===404&&n)return{messages:[],workLog:[],streaming:!1};if(!r.ok)throw Error(`Failed to fetch messages`);return r.json()}function Dft({conversation:e,onResume:t,onArchive:n,resumePending:r,resumeLabel:i,sendResumeContract:a,onSendResumeContractChange:o,hideComposer:s=!1,onSendFailed:c,modelPicker:l,roundMarkers:u,roundMetadata:d,turnDiffSummaryByAssistantMessageId:f,onOpenTurnDiff:p,resolvedTheme:m,agentId:h,hideToolCalls:g,workingPhase:_,agentBusy:v=!1,streamMessagesEnabled:y=!1,receivedFirstPayload:b=!1,messagesData:x,messagesLoading:S,onOpenTerminal:C,targetMessageId:w,targetMessageIndex:T,targetMessageNonce:E,onTargetMessageHandled:D}){let O=Q(t=>t.conversationsCompactingByName?.[e.name]??!1),k=knt(e.name),A=Ant(e.name),j=EG(e=>e.addOptimistic),M=EG(e=>e.acknowledgeOptimistic),N=EG(e=>e.clearOptimistic),P=EG(e=>e.failSend),F=yt(),I=(0,z.useRef)(e.forkStatus);(0,z.useEffect)(()=>{let t=I.current;I.current=e.forkStatus,t&&!e.forkStatus&&F.invalidateQueries({queryKey:qX(e.name)})},[e.forkStatus,e.name,F]);let L=x,ee=S??!1,R=(0,z.useMemo)(()=>new Map((L?.subagents??[]).map(e=>[e.toolUseId,e])),[L?.subagents]),te=(0,z.useCallback)(e=>{let t=R.get(e);t&&YX(t.agentId)},[R]),{livePaneChoice:ne,answeredPaneChoices:re,handlePaneChoiceAnswered:ie}=Bnt(e.name,h),ae=L?.messages??[],oe=L?.workLog??[],{commandResults:se,failedMessages:ce,handleConfirmCommand:le,handleDiscardFailed:ue,handleRetryFailed:de,handleSendFailed:fe}=xft({conversation:e,agentId:h,serverBaseCount:ae.length,onSendFailed:c}),pe=unt(L?.contextUsage??e.contextUsage??null),me=ae.slice(A).filter(e=>e.role===`user`).length,he=Math.min(k.length,me),ge=k.slice(he),_e=k.length>0&&ge.length===0,ve=[...ae,...ge,...se],ye=(0,z.useCallback)(t=>{j(e.name,t,ae.length)},[j,e.name,ae.length]),be=(0,z.useCallback)(t=>{e.harness!==`ohmypi`&&e.harness!==`pi`||M(e.name,t)},[M,e.harness,e.name]);(0,z.useEffect)(()=>{_e&&N(e.name)},[_e,N,e.name]),(0,z.useEffect)(()=>{if(ge.length===0)return;let t=ge[0],n=Date.parse(t.createdAt||``);if(Number.isNaN(n))return;let r=n+((L?.compactBoundaries??[]).some(e=>{let t=Date.parse(e.timestamp);return!Number.isNaN(t)&&t>=n})?2e4:XWe),i=setTimeout(()=>P(e.name,t.text),Math.max(0,r-Date.now()));return()=>clearTimeout(i)},[ge,L?.compactBoundaries,P,e.name]);let xe=!!e.forkStatus&&e.forkStatus!==`failed`,Se=e.forkStatus===`failed`,Ce=xe||Se,we=!!e.spawnError,Te=y&&!b&&ve.length===0,Ee=y&&L?.discovering===!0&&ve.length===0,De=ve.length>0||oe.length>0,Oe=!e.sessionAlive&&!e.endedAt&&!we&&!Ce&&Cft(e.createdAt)&&!De,ke=!ee&&!Ee&&!Te&&!De&&e.sessionAlive,Ae=!ee&&!Ee&&!Te&&!y&&L==null&&!Oe&&!we&&!Ce,je=!ee&&!Ee&&!Te&&L!=null&&!De&&!e.sessionAlive&&!we&&!Oe,Me=O||ZWe(e.sessionAlive,ve,oe),Ne=e.title?.replace(/^Summary Fork:\s*/,``)||void 0,Pe=(0,z.useMemo)(()=>{let e=Hnt(d,ve);return e.length>0?e:u??[]},[d,ve,u]);return(0,B.jsxs)(`div`,{className:Z.conversationView,children:[ee||Ee||Te?(0,B.jsx)(yft,{discovering:Ee}):L?.error?(0,B.jsxs)(`div`,{className:Z.conversationEmptyState,children:[(0,B.jsx)(`p`,{className:Z.conversationEmptyStateTitle,style:{color:`var(--warning)`},children:`⚠ Session could not be resolved`}),(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:L.error})]}):Ae?(0,B.jsxs)(`div`,{className:Z.conversationEmptyState,children:[(0,B.jsx)(`p`,{className:Z.conversationEmptyStateTitle,style:{color:`var(--warning)`},children:`⚠ Couldn't load history`}),(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:`The request for this conversation's messages failed — the saved history may still be intact.`}),(0,B.jsx)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:(0,B.jsx)(`button`,{className:Z.conversationArchiveBtnLarge,onClick:()=>F.invalidateQueries({queryKey:qX(e.name)}),children:`Retry`})})]}):Oe?(0,B.jsxs)(`div`,{className:Z.conversationEmptyState,children:[(0,B.jsxs)(`p`,{className:Z.conversationEmptyStateTitle,children:[(0,B.jsx)(gc,{size:16,style:{display:`inline`,verticalAlign:`middle`,marginRight:6,animation:`spin 1s linear infinite`}}),`Starting…`]}),(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:`Waiting for the session to start.`})]}):we?(0,B.jsxs)(`div`,{className:Z.conversationEmptyState,children:[(0,B.jsx)(`p`,{className:Z.conversationEmptyStateTitle,children:`Failed to start`}),(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:e.spawnError}),(0,B.jsx)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:(0,B.jsx)(`button`,{className:Z.conversationArchiveBtnLarge,onClick:()=>n?.(),children:`Archive`})})]}):Ce&&ve.length===0?(0,B.jsx)(vft,{forkStatus:e.forkStatus,forkError:e.forkError,parentTitle:Ne}):je?(0,B.jsxs)(`div`,{className:Z.conversationEmptyState,children:[e.transcriptMissing?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:Z.conversationEmptyStateTitle,style:{color:`var(--warning)`},children:`⚠ Transcript missing`}),(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:`This conversation had activity, but its transcript file no longer exists on disk. The history cannot be recovered.`})]}):(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:`This conversation has no saved history. The session may have ended before any messages were exchanged.`}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:[t&&(0,B.jsx)(OG,{modelPicker:l,sendResumeContract:a,onSendResumeContractChange:o,onResume:t,resumePending:r,resumeLabel:i,className:Z.conversationResumeControls}),(0,B.jsx)(`button`,{className:Z.conversationArchiveBtnLarge,onClick:()=>n?.(),children:`Archive`})]})]}):ke?(0,B.jsxs)(`div`,{className:Z.conversationEmptyState,children:[(0,B.jsx)(`p`,{className:Z.conversationEmptyStateTitle,children:`How can I help you?`}),(0,B.jsx)(`p`,{className:Z.conversationEmptyStateSubtitle,children:`Type a message below to start the conversation.`})]}):(0,B.jsx)(DL,{messages:ve,workLog:oe,streaming:Me,roundMarkers:Pe,failedMessages:ce,onRetryFailed:de,onDiscardFailed:ue,onConfirmCommand:le,proposedPlan:L?.proposedPlan,paneChoice:ne,answeredPaneChoices:re,onPaneChoiceAnswered:ie,onOpenTerminal:C,compactBoundaries:L?.compactBoundaries,compacting:O,conversationName:e.name,cwd:e.cwd,issueId:e.issueId,subagentByToolUseId:R,onOpenSubagent:te,turnDiffSummaryByAssistantMessageId:f,onOpenTurnDiff:p,resolvedTheme:m,hideToolCalls:g,workingPhase:_,targetMessageId:w,targetMessageIndex:T,targetMessageNonce:E,onTargetMessageHandled:D}),je?null:e.clearedToConvId?(0,B.jsxs)(`button`,{type:`button`,className:Z.conversationClearedBanner,onClick:()=>{window.location.href=`/conv/${e.clearedToConvId}`},title:`Open conv/${e.clearedToConvId}`,"aria-label":`Open conversation that continues after /clear (conv/${e.clearedToConvId})`,children:[(0,B.jsx)(Pc,{size:14}),(0,B.jsxs)(`span`,{className:Z.conversationClearedBannerText,children:[`Conversation cleared — continued in `,(0,B.jsxs)(`strong`,{children:[`conv/`,e.clearedToConvId]})]}),(0,B.jsx)(Die,{size:14})]}):Ce?null:t?(0,B.jsx)(OG,{modelPicker:l,sendResumeContract:a,onSendResumeContractChange:o,onResume:t,resumePending:r,resumeLabel:i}):s?null:(0,B.jsx)(Rnt,{conversation:e,onSend:ye,onSendAcknowledged:be,onSendFailed:fe,agentId:h,contextWindowUsage:pe,agentBusy:v})]})}function $X({issueId:e,density:t,surface:n=`issue-view`}){let r=yt(),i=lL(e),a=rL(e=>e.openRecovery),{groups:o,defaultModel:s,harnessPolicy:c}=VD(),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(s),[h,g]=(0,z.useState)(`claude-code`);(0,z.useEffect)(()=>{s&&m(s)},[s]);let _=i.all.find(e=>e.action.key===`startAgent`),v=i.all.find(e=>e.action.key===`resumeSession`),y=i.agent?.troubled?`troubled`:i.agent?.paused?`paused`:null,b=y&&_?.enabled?`start`:v?.enabled?`resume`:_?.enabled?`start`:null,x=Mt({mutationFn:async t=>{let n=i.agent?.id,r=t===`resume`?`/api/agents/${n}/resume`:`/api/agents`,o=t===`resume`?{}:{issueId:e,projectId:i.issue?.project?.id};t===`start`&&d&&(o.model=p,o.harness=h);let s=await fetch(r,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(o)});if(!s.ok){let n=await s.text(),r=null;try{r=JSON.parse(n)}catch{}let i=s.status===409?aL(r):null;if(i)throw a({...i,issueId:e}),new b8e;let o=r;throw Error(o?.error??o?.message??(t===`resume`?`Failed to resume session`:`Failed to start work agent`))}},onSuccess:(e,t)=>{t===`resume`&&i.agent?.id&&oL(i.agent.id),nL(r)}});if(!b)return null;let S=t===`rail`||n!==`issue-view`,C=n===`chip`?`▶ Resume · ${e}`:n===`inline`?`Resume · ${e}`:`Resume session · ${e}`,w=n===`chip`?`▶ Start · ${e}`:n===`inline`?`Start · ${e}`:`Start work agent`,T=b===`resume`?C:w,E=S?`${b===`resume`?`Resuming`:`Starting`}… · ${e}`:b===`resume`?`Resuming…`:`Starting…`,D=b===`resume`?`inline-flex items-center gap-1 rounded-[4px] border border-info/30 bg-info/10 px-1.5 py-0.5 text-[10px] font-medium text-info-foreground transition-colors hover:bg-info/20 disabled:opacity-50`:`inline-flex items-center gap-1 rounded-[4px] px-1.5 py-0.5 text-[10px] font-medium text-primary transition-colors hover:text-primary/80 disabled:opacity-50`,O=b===`resume`?`inline-flex items-center gap-1.5 rounded-[var(--radius-sm)] border border-info/40 bg-info/10 px-2.5 py-1.5 text-[12px] font-semibold text-info-foreground transition-colors hover:bg-info/20 disabled:opacity-50`:`rounded-[var(--radius-sm)] bg-primary px-2.5 py-1.5 text-[12px] font-medium text-primary-foreground disabled:opacity-50`;return(0,B.jsxs)(`div`,{"data-section":`StartAgentCta`,className:S?`inline-flex items-center gap-2`:`w-full space-y-2`,onClick:e=>e.stopPropagation(),children:[(0,B.jsx)(`button`,{type:`button`,disabled:x.isPending,title:b===`resume`?`Reopens the saved session for ${e} with its memory intact`:void 0,className:S?D:O,onClick:()=>{let t=i.agent?.id;if(y&&_?.enabled&&t){a({kind:y,agentId:t,issueId:e});return}x.mutate(b)},children:x.isPending?E:T}),!S&&b===`start`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px]`,"aria-expanded":l,onClick:()=>u(e=>!e),children:[(0,B.jsx)(Hc,{className:`h-3 w-3`}),`Overrides`,(0,B.jsx)(ds,{className:`h-3 w-3`})]}),l&&(0,B.jsxs)(`div`,{className:`rounded border border-border p-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`Override default harness and model`]}),d&&(0,B.jsx)(HD,{model:p,harness:h,onModelChange:m,onHarnessChange:g,groups:o,harnessPolicy:c,modelLabel:`Agent model`})]})]}),x.error&&!(x.error instanceof b8e)&&(0,B.jsx)(`p`,{role:`alert`,className:`text-[12px] text-destructive select-text cursor-text`,onClick:e=>e.stopPropagation(),children:x.error.message})]})}var Oft=new Set([`stopped`,`dead`,`failed`]);function eZ(e){return Oft.has(e.status)}function kft(e){let t=eZ(e);return{id:-1,name:e.id,tmuxSession:e.id,status:t?`ended`:`active`,cwd:e.workspace??``,issueId:e.issueId??null,createdAt:e.startedAt??e.lastActivity??``,endedAt:t?e.lastActivity??e.startedAt??null:null,lastAttachedAt:null,sessionAlive:!t,sessionFile:e.id,model:e.model,harness:e.harness??e.runtime??null}}async function Aft(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/git-info`);return t.ok?t.json():null}function jft(e){let t=e.filter(e=>!eZ(e));return t.find(e=>e.role===`work`)??e.find(e=>e.role===`work`)??t[0]??e[0]??null}function Mft(e){let t=/^agent-[a-z]+-\d+-slot-(\d+)$/i.exec(e.id);return t?`Slot ${t[1]} · ${e.id}`:`${e.role?`${e.role[0].toUpperCase()}${e.role.slice(1)}`:`Agent`} · ${e.id}`}function Nft({view:e,agents:t,agentId:n,onSelectAgent:r,onChangeView:i,issueId:a,hideComposer:o=!1}){let s=`drawer-tab-panel-${e}`,c=(0,z.useMemo)(()=>t.find(e=>e.id===n)??null,[t,n]),l=(0,z.useMemo)(()=>c?kft(c):null,[c]),{hideToolCalls:u,toggleHideToolCalls:d}=vL(c?.id??``),{data:f}=V({queryKey:[`agent-git-info`,c?.id],queryFn:()=>c?Aft(c.id):Promise.resolve(null),enabled:!!c,staleTime:3e4,refetchInterval:3e4}),p=c?eZ(c)?`Session ended — no live terminal to attach`:void 0:`No agent selected — start work to attach a terminal`,m=i?(0,B.jsx)(ZX,{ariaLabel:`Agent session view`,value:e,onChange:i,options:[{id:`conversation`,label:`Conversation`},{id:`terminal`,label:`Terminal`,disabled:!!p,disabledReason:p}]}):null;if(!c||!l)return(0,B.jsxs)(`div`,{"data-testid":s,className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px]`,children:[m&&(0,B.jsx)(`div`,{className:`mb-[12px] flex items-center`,children:m}),(0,B.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:e===`conversation`?`Conversation`:`Terminal`}),(0,B.jsx)(`p`,{className:`text-[12px] font-medium text-foreground`,children:`Nothing here yet — no agent has started on this issue.`}),(0,B.jsxs)(`p`,{className:`mt-[4px] text-[12px] leading-5 text-muted-foreground`,children:[`Start work and the live `,e===`conversation`?`conversation`:`terminal`,` appears here. Everything else about the issue is one tab away (Overview).`]}),a&&(0,B.jsx)(`div`,{className:`mt-[12px]`,children:(0,B.jsx)($X,{issueId:a,density:`console`})})]});let h=!!(f?.actualBranch||f?.workspaceMissing),g=!!f?.branchDrifted,_=!!f?.workspaceMissing;return(0,B.jsxs)(`div`,{"data-testid":s,className:`flex min-h-0 flex-1 flex-col gap-[10px]`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[8px]`,children:[m,t.length>1&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Agent`}),(0,B.jsx)(`select`,{value:c.id,onChange:e=>r(e.target.value),"aria-label":`Select agent session`,className:`rounded-[var(--radius-sm)] border border-border bg-card px-[8px] py-[4px] text-[12px] text-foreground`,children:t.map(e=>(0,B.jsx)(`option`,{value:e.id,children:Mft(e)},e.id))})]}),h&&(0,B.jsx)(`span`,{className:`${Z.terminalBranchBar} ${_?Z.terminalBranchBarMissing:g?Z.terminalBranchBarDrift:``}`,title:_?`Workspace missing on disk: ${f?.workspacePath??`(unknown path)`}`:g?`Expected ${f?.expectedBranch??`(none)`}, on ${f?.actualBranch??`(none)`}`:`${f?.workspacePath??``}`,"data-testid":`drawer-agent-branch-chip`,children:_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(hs,{size:12}),(0,B.jsx)(`span`,{className:Z.terminalBranchBarMode,children:`Worktree missing`})]}):(0,B.jsxs)(B.Fragment,{children:[g?(0,B.jsx)(il,{size:12}):(0,B.jsx)(tc,{size:12}),(0,B.jsx)(`span`,{className:Z.terminalBranchBarMode,children:g?`Drifted`:`Worktree`}),(0,B.jsx)(`span`,{className:Z.terminalBranchBarText,children:f?.actualBranch})]})}),(0,B.jsxs)(`button`,{type:`button`,className:`ml-auto ${Z.conversationAboutToggle} ${u?Z.conversationAboutToggleActive:``}`,onClick:d,title:u?`Show tool calls`:`Hide tool calls`,"aria-label":u?`Show tool calls`:`Hide tool calls`,"aria-pressed":u,children:[(0,B.jsx)(ol,{size:14}),(0,B.jsx)(`span`,{children:`Tools`})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-[var(--radius)] border border-border`,children:e===`conversation`?(0,B.jsx)(QX,{conversation:l,viewMode:`conversation`,embedded:!0,agentId:c.id,hideToolCalls:u,onToggleHideToolCalls:d,hideComposer:o},c.id):eZ(c)?(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center p-[18px] text-[13px] text-muted-foreground`,children:`Session ended — no live terminal to attach.`}):(0,B.jsx)(KP,{sessionName:c.id},c.id)})]})}var Pft={work:`bg-primary`,review:`bg-signal-review`,ship:`bg-warning`,done:`bg-success`,info:`bg-info`};function Fft(e){if(!e)return`just now`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Ift({activityRail:e,compact:t=!1,limit:n}){let r=n?e.slice(0,n):e,i=(0,z.useRef)(null),a=e[0]?.id;return(0,z.useEffect)(()=>{i.current&&(i.current.scrollTop=0)},[a]),(0,B.jsx)(`aside`,{"data-component":`drawer-activity-rail`,"data-testid":`drawer-activity-rail`,className:t?`w-full bg-transparent`:`w-[320px] shrink-0 border-l border-border bg-card/70`,children:(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[t?null:(0,B.jsx)(`div`,{className:`border-b border-border px-[16px] py-[13px]`,children:(0,B.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Live Activity`})}),(0,B.jsx)(`div`,{ref:i,"data-testid":`drawer-activity-rail-scroll`,className:t?`max-h-52 overflow-auto pt-2`:`min-h-0 flex-1 overflow-auto px-[16px] py-[14px]`,children:r.length===0?(0,B.jsx)(`div`,{className:`rounded-[12px] border border-dashed border-border px-[12px] py-[18px] text-center text-[12px] text-muted-foreground`,children:`No activity yet.`}):(0,B.jsx)(`div`,{className:`space-y-[12px]`,children:r.map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr] gap-[10px]`,"data-phase":e.phase,children:[(0,B.jsx)(`span`,{"data-testid":`drawer-activity-dot-${e.phase}`,className:Kx(`mt-[4px] h-[8px] w-[8px] rounded-full`,Pft[e.phase])}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-[12px] leading-[18px] text-foreground`,children:e.message}),(0,B.jsx)(`div`,{className:`mt-[2px] font-mono text-[10px] leading-none text-muted-foreground`,children:Fft(e.when)})]})]},e.id))})})]})})}function Lft(){let{activityRail:e}=_L();return(0,B.jsx)(Ift,{activityRail:e})}function tZ(e){return e.artifact.title||e.artifact.slug}function Rft(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString([],{month:`2-digit`,day:`2-digit`,year:`2-digit`})}function zft(e){return`Made by ${e.artifact.agentRole??`user`} via ${e.artifact.agentHarness??`user`} for ${e.artifact.issueId??e.artifact.workspaceId??`unscoped work`}`}function Bft(e,t){return t===`pending`?e.pendingChanges:t===`unshared`?e.status===`unshared`:t===`published`?e.status===`published`:!0}function Vft(e,t,n){if(n===`title`)return tZ(e).localeCompare(tZ(t));let r=new Date(e.artifact.publishedAt??e.artifact.createdAt).getTime(),i=new Date(t.artifact.publishedAt??t.artifact.createdAt).getTime();return(Number.isNaN(i)?0:i)-(Number.isNaN(r)?0:r)}function nZ({children:e,tone:t}){return(0,B.jsx)(`span`,{"data-testid":`artifact-badge-${t}`,className:Kx(`rounded-full border px-[7px] py-[2px] text-[10px] font-medium leading-none`,t===`published`&&`border-success/40 bg-success/10 text-success-foreground`,t===`pending`&&`border-warning/40 bg-warning/10 text-warning-foreground`,t===`unshared`&&`border-muted-foreground/30 bg-muted/40 text-muted-foreground`),children:e})}function Hft(e,t,n){return e&&{artifacts:e.artifacts.map(e=>e.artifact.slug===t?{...e,artifact:n.artifact,status:`unshared`}:e)}}function Uft({issueId:e}){let t=yt(),[n,r]=(0,z.useState)(`all`),[i,a]=(0,z.useState)(`recent`),[o,s]=(0,z.useState)(null),c=[`drawer-artifacts`,e],{data:l,isLoading:u,isError:d}=V({queryKey:c,queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}/artifacts`);if(!t.ok)throw Error(`Failed to load artifacts for ${e}`);return t.json()},retry:!1}),f=Mt({mutationFn:async e=>{let t=await fetch(`/api/artifacts/${e}/unshare`,{method:`POST`,headers:await sb()});if(!t.ok)throw Error(`Failed to unshare artifact ${e}`);return{slug:e,response:await t.json()}},onSuccess:({slug:e,response:n})=>{t.setQueryData(c,t=>Hft(t,e,n))}}),p=(0,z.useMemo)(()=>[...l?.artifacts??[]].filter(e=>Bft(e,n)).sort((e,t)=>Vft(e,t,i)),[l?.artifacts,n,i]),m=async e=>{await navigator.clipboard?.writeText(e.urls.wrapperUrl),s(e.artifact.slug)};return(0,B.jsxs)(`div`,{"data-testid":`drawer-tab-panel-artifacts`,className:`space-y-[14px]`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-[10px] rounded-[var(--radius)] border border-border bg-card p-[12px]`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Artifacts`}),(0,B.jsx)(`div`,{className:`mt-[2px] text-[13px] text-muted-foreground`,children:`Browser-viewable work products for this issue.`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[8px]`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-[6px] text-[12px] text-muted-foreground`,children:[`Filter`,(0,B.jsxs)(`select`,{"aria-label":`Filter artifacts`,className:`rounded-[var(--radius-sm)] border border-border bg-background px-[8px] py-[5px] text-[12px] text-foreground`,value:n,onChange:e=>r(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All`}),(0,B.jsx)(`option`,{value:`published`,children:`Published`}),(0,B.jsx)(`option`,{value:`pending`,children:`Pending changes`}),(0,B.jsx)(`option`,{value:`unshared`,children:`Unshared`})]})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-[6px] text-[12px] text-muted-foreground`,children:[`Sort`,(0,B.jsxs)(`select`,{"aria-label":`Sort artifacts`,className:`rounded-[var(--radius-sm)] border border-border bg-background px-[8px] py-[5px] text-[12px] text-foreground`,value:i,onChange:e=>a(e.target.value),children:[(0,B.jsx)(`option`,{value:`recent`,children:`Most recent`}),(0,B.jsx)(`option`,{value:`title`,children:`Title`})]})]})]})]}),u?(0,B.jsx)(`div`,{className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px] text-[13px] text-muted-foreground`,children:`Loading artifacts…`}):d?(0,B.jsx)(`div`,{className:`rounded-[var(--radius)] border border-dashed border-destructive/40 bg-card/60 p-[18px] text-[13px] text-destructive-foreground`,children:`Failed to load artifacts`}):p.length===0?(0,B.jsx)(`div`,{className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px] text-[13px] text-muted-foreground`,children:`No artifacts published for this issue yet.`}):(0,B.jsx)(`div`,{className:`grid gap-[12px] md:grid-cols-2`,"data-testid":`drawer-artifact-grid`,children:p.map(e=>(0,B.jsxs)(`article`,{"data-testid":`drawer-artifact-card-${e.artifact.slug}`,className:`overflow-hidden rounded-[var(--radius)] border border-border bg-card`,children:[(0,B.jsx)(`div`,{className:`aspect-video border-b border-border bg-muted/30`,children:e.thumbnailUrl?(0,B.jsx)(`img`,{src:e.thumbnailUrl,alt:`Thumbnail for ${tZ(e)}`,className:`h-full w-full object-cover`}):(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center font-mono text-[11px] text-muted-foreground`,children:e.artifact.slug})}),(0,B.jsxs)(`div`,{className:`space-y-[10px] p-[12px]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h3`,{className:`truncate text-[15px] font-medium text-foreground`,title:tZ(e),children:tZ(e)}),(0,B.jsx)(`div`,{className:`mt-[3px] text-[12px] text-muted-foreground`,"data-testid":`drawer-artifact-maker`,children:zft(e)})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-[8px] font-mono text-[10px] text-muted-foreground`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`block uppercase tracking-[0.08em]`,children:`Created`}),(0,B.jsx)(`span`,{className:`text-foreground`,children:Rft(e.artifact.createdAt)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`block uppercase tracking-[0.08em]`,children:`Workspace`}),(0,B.jsx)(`span`,{className:`text-foreground`,children:e.artifact.workspaceId??`—`})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-[6px]`,children:[e.status===`published`?(0,B.jsx)(nZ,{tone:`published`,children:`Published`}):null,e.pendingChanges?(0,B.jsx)(nZ,{tone:`pending`,children:`Pending Changes`}):null,e.status===`unshared`?(0,B.jsx)(nZ,{tone:`unshared`,children:`Unshared`}):null]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-[8px] pt-[2px]`,children:[(0,B.jsx)(`a`,{href:e.urls.wrapperUrl,target:`_blank`,rel:`noreferrer`,className:`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[12px] text-foreground transition-colors hover:bg-accent`,children:`Open Wrapper`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[12px] text-foreground transition-colors hover:bg-accent`,onClick:()=>void m(e),children:o===e.artifact.slug?`Copied`:`Copy Link`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[12px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.status===`unshared`||f.isPending,onClick:()=>f.mutate(e.artifact.slug),children:`Unshare`})]})]})]},e.artifact.artifactId))})]})}var Wft={draft:`badge-bg-muted text-muted-foreground`,proposed:`badge-bg-primary text-primary`,approved:`badge-bg-success text-success`,pending:`badge-bg-warning text-warning`,running:`badge-bg-primary text-primary`,completed:`badge-bg-success text-success`,blocked:`badge-bg-destructive text-destructive`,failed:`badge-bg-destructive text-destructive`,cancelled:`badge-bg-muted text-muted-foreground`};function Gft(e){if(!e)return`—`;try{return new Date(e).toLocaleString(void 0,{dateStyle:`short`,timeStyle:`short`})}catch{return e}}function Kft({doc:e,onInspectionPolicyChange:t,isUpdatingInspectionPolicy:n=!1}){let{plan:r,xBRIEFInfo:i}=e,a=Wft[r.status]??`badge-bg-muted text-muted-foreground`;return(0,B.jsxs)(`div`,{className:`p-4 border-b border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsx)(`h2`,{className:`text-lg font-semibold text-foreground leading-tight`,children:r.title}),(0,B.jsx)(`span`,{className:`shrink-0 px-2 py-0.5 rounded text-xs font-medium ${a}`,children:r.status})]}),(0,B.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-6 gap-y-1 text-xs text-muted-foreground`,children:[r.uid&&(0,B.jsxs)(`div`,{className:`col-span-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`uid `}),(0,B.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:r.uid})]}),r.author&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`author `}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:r.author})]}),i.author&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`tool `}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:i.author})]}),r.created&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`created `}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:Gft(r.created)})]}),r.updated&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`updated `}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:Gft(r.updated)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`inspection `}),t?(0,B.jsxs)(`select`,{"aria-label":`Inspection policy`,className:`bg-card border border-border rounded px-1 py-0.5 text-xs text-muted-foreground`,value:i.inspectionPolicy??`auto`,disabled:n,onChange:e=>t(e.target.value),children:[(0,B.jsx)(`option`,{value:`auto`,children:`auto`}),(0,B.jsx)(`option`,{value:`never`,children:`never`}),(0,B.jsx)(`option`,{value:`fast`,children:`fast`}),(0,B.jsx)(`option`,{value:`deep`,children:`deep`})]}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:i.inspectionPolicy??`auto`})]}),r.sequence!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`seq `}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:r.sequence})]})]})]})}var qft=[`Problem`,`Proposal`,`Constraint`,`Risk`,`Alternative`];function Jft({narratives:e}){if(!e)return null;let t=[...qft.filter(t=>e[t]),...Object.keys(e).filter(t=>!qft.includes(t)&&e[t])];return t.length===0?null:(0,B.jsx)(`div`,{className:`p-4 border-b border-border space-y-4`,children:t.map(t=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1`,children:t}),(0,B.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-muted-foreground`,children:(0,B.jsx)(xx,{remarkPlugins:[zx],children:e[t]})})]},t))})}function Yft({references:e}){return e.length===0?null:(0,B.jsxs)(`div`,{className:`p-4 border-b border-border`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`References`}),(0,B.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex items-center gap-1.5 text-sm`,children:[e.type&&(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`[`,e.type,`]`]}),(0,B.jsxs)(`a`,{href:e.uri,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:text-primary/80 flex items-center gap-1 truncate`,children:[e.label??e.uri,(0,B.jsx)(Is,{className:`w-3 h-3 shrink-0`})]})]},t))})]})}var Xft={completed:`text-success border-success/50`,running:`text-primary border-primary/50`,in_progress:`text-primary border-primary/50`,blocked:`text-destructive border-destructive/50`,failed:`text-destructive border-destructive/50`,cancelled:`text-muted-foreground border-border`,pending:`text-muted-foreground border-border`,draft:`text-muted-foreground border-border`},Zft={critical:`badge-bg-destructive text-destructive`,high:`badge-bg-warning text-warning-foreground`,medium:`badge-bg-warning text-warning`,low:`badge-bg-muted text-muted-foreground`},Qft={trivial:`badge-bg-muted text-muted-foreground`,simple:`badge-bg-success text-success`,medium:`badge-bg-warning text-warning`,complex:`badge-bg-warning text-warning-foreground`,expert:`badge-bg-destructive text-destructive`};function $ft({sub:e}){return e.status===`completed`?(0,B.jsx)(_s,{className:`w-3.5 h-3.5 text-success shrink-0`}):e.status===`blocked`||e.status===`failed`?(0,B.jsx)(bs,{className:`w-3.5 h-3.5 text-destructive shrink-0`}):e.status===`running`||e.status===`in_progress`?(0,B.jsx)(Cs,{className:`w-3.5 h-3.5 text-primary shrink-0`}):(0,B.jsx)(xs,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`})}function ept({item:e}){let[t,n]=(0,z.useState)(!1),r=Xft[e.status]??Xft.pending,i=e.metadata?.difficulty,a=(e.items??e.subItems??[]).filter(e=>e.metadata?.kind===`acceptance_criterion`);return(0,B.jsxs)(`div`,{className:`border rounded-lg overflow-hidden ${r}`,children:[(0,B.jsxs)(`button`,{className:`w-full flex items-start gap-2 p-3 text-left hover:bg-muted transition-colors`,onClick:()=>n(e=>!e),"aria-expanded":t,children:[(0,B.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:t?(0,B.jsx)(ds,{className:`w-4 h-4`}):(0,B.jsx)(ps,{className:`w-4 h-4`})}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),e.priority&&(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs ${Zft[e.priority]??``}`,children:e.priority}),i&&(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs ${Qft[i]??``}`,children:i}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status})]}),a.length>0&&!t&&(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:[a.filter(e=>e.status===`completed`).length,`/`,a.length,` AC`]})]})]}),t&&(0,B.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,children:[e.narrative?.Action&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e.narrative.Action}),a.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-1`,children:`Acceptance Criteria`}),(0,B.jsx)(`ul`,{className:`space-y-1`,children:a.map(e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-1.5 text-sm`,children:[(0,B.jsx)($ft,{sub:e}),(0,B.jsx)(`span`,{className:e.status===`completed`?`text-success line-through`:`text-muted-foreground`,children:e.title})]},e.id))})]})]})]})}function tpt({items:e}){return e.length===0?(0,B.jsx)(`p`,{className:`text-muted-foreground text-sm p-4`,children:`No items in this plan.`}):(0,B.jsx)(`div`,{className:`p-4 space-y-2`,children:e.map(e=>(0,B.jsx)(ept,{item:e},e.id))})}function npt({doc:e}){let t=e.readiness??rpt(e),n=Object.entries(t.overlapMatrix).flatMap(([e,t])=>Object.entries(t).filter(([t])=>e<t).map(([t,n])=>({itemId:e,otherId:t,sharedFiles:n})));return(0,B.jsxs)(`section`,{className:`p-4 border-b border-border`,"aria-label":`Readiness report`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:`Readiness report`}),(0,B.jsxs)(`div`,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-1`,children:`Dependency waves`}),t.waves.length===0?(0,B.jsx)(`p`,{children:`No dependency waves.`}):(0,B.jsx)(`ol`,{className:`space-y-1`,children:t.waves.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`wave `,e.index]}),(0,B.jsxs)(`span`,{children:[`: `,e.items.map(e=>e.id).join(`, `)]})]},e.index))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-1`,children:`File-overlap matrix`}),n.length===0?(0,B.jsx)(`p`,{children:`No cross-item file overlaps.`}):(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,B.jsx)(`th`,{className:`py-1 pr-3 text-left font-semibold text-muted-foreground`,children:`Items`}),(0,B.jsx)(`th`,{className:`py-1 text-left font-semibold text-muted-foreground`,children:`Shared files`})]})}),(0,B.jsx)(`tbody`,{children:n.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-border/60`,children:[(0,B.jsxs)(`td`,{className:`py-1 pr-3 font-mono text-muted-foreground`,children:[e.itemId,` / `,e.otherId]}),(0,B.jsx)(`td`,{className:`py-1 text-muted-foreground`,children:e.sharedFiles.join(`, `)||`conservative overlap`})]},`${e.itemId}-${e.otherId}`))})]})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-1`,children:`Conflict groups`}),t.conflictGroups.length===0?(0,B.jsx)(`p`,{children:`No conflict groups.`}):(0,B.jsx)(`ul`,{className:`space-y-1`,children:t.conflictGroups.map(e=>(0,B.jsxs)(`li`,{className:`text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`font-mono`,children:e.itemIds.join(` + `)}),(0,B.jsxs)(`span`,{children:[` (`,e.reason,`)`]}),e.sharedFiles.length>0&&(0,B.jsxs)(`span`,{children:[`: `,e.sharedFiles.join(`, `)]})]},e.itemIds.join(`|`)))})]})]})]})}function rpt(e){let t=ipt(e),n=Object.fromEntries(e.plan.items.map(e=>[e.id,{}])),r=new Map(e.plan.items.map(e=>[e.id,{id:e.id,overlaps:[]}])),i=[];for(let t=0;t<e.plan.items.length;t++)for(let a=t+1;a<e.plan.items.length;a++){let o=e.plan.items[t],s=e.plan.items[a],c=apt(o,s),l=o.metadata?.files_scope_confidence===`low`||s.metadata?.files_scope_confidence===`low`;c.length===0&&!l||(n[o.id][s.id]=c,n[s.id][o.id]=c,r.get(o.id)?.overlaps.push({itemId:s.id,sharedFiles:c}),r.get(s.id)?.overlaps.push({itemId:o.id,sharedFiles:c}),i.push({itemIds:[o.id,s.id],sharedFiles:c,reason:l?`low_confidence`:`file_overlap`}))}return{items:Array.from(r.values()),waves:t,conflictGroups:i,overlapMatrix:n}}function ipt(e){let t=e.plan.items.filter(e=>![`completed`,`cancelled`,`blocked`,`running`].includes(e.status)),n=new Set(t.map(e=>e.id)),r=new Set(e.plan.items.filter(e=>e.status===`completed`||e.status===`cancelled`).map(e=>e.id)),i=new Map(t.map(e=>[e.id,0])),a=new Map(t.map(e=>[e.id,[]]));for(let t of e.plan.edges.filter(e=>e.type===`blocks`))!n.has(t.to)||r.has(t.from)||(i.set(t.to,(i.get(t.to)??0)+1),n.has(t.from)&&a.get(t.from)?.push(t.to));let o=new Map(e.plan.items.map(e=>[e.id,e])),s=[],c=t.map(e=>e.id).filter(e=>(i.get(e)??0)===0),l=0;for(;c.length>0;){s.push({index:l,items:c.map(e=>({id:e,title:o.get(e).title}))});let e=[];for(let t of c)for(let n of a.get(t)??[]){let t=(i.get(n)??1)-1;i.set(n,t),t===0&&e.push(n)}c=e,l+=1}return s}function apt(e,t){let n=opt(e),r=opt(t),i=new Set;for(let e of n)r.includes(e)&&i.add(e);for(let e of r)n.includes(e)&&i.add(e);return Array.from(i).sort()}function opt(e){let t=e.metadata?.files_scope;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}var spt=`xbrief-viewer-tab`,cpt=[{id:`list`,label:`List`,Icon:hc},{id:`dag`,label:`DAG`,Icon:$s},{id:`raw`,label:`Raw JSON`,Icon:ws}];function rZ({doc:e,initialTab:t,activeTab:n,onTabChange:r,showTabBar:i=!0,onInspectionPolicyChange:a,isUpdatingInspectionPolicy:o=!1}){let[s,c]=(0,z.useState)(()=>t||(localStorage.getItem(spt)??`list`)),l=n??s,u=e=>{n===void 0&&c(e),r?.(e)};return(0,z.useEffect)(()=>{localStorage.setItem(spt,l)},[l]),e?(0,B.jsxs)(`div`,{className:`flex flex-col h-full bg-card text-foreground overflow-hidden`,children:[i&&(0,B.jsx)(`div`,{className:`flex shrink-0 border-b border-border`,role:`tablist`,"aria-label":`xBRIEF view`,children:cpt.map(({id:e,label:t,Icon:n})=>(0,B.jsxs)(`button`,{role:`tab`,"aria-selected":l===e,onClick:()=>u(e),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium transition-colors ${l===e?`border-b-2 border-primary text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,B.jsx)(n,{className:`h-4 w-4`}),t]},e))}),(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 ${l===`dag`?`flex flex-col overflow-hidden`:`overflow-y-auto`}`,children:[l===`list`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Kft,{doc:e,onInspectionPolicyChange:a,isUpdatingInspectionPolicy:o}),e.plan.narratives&&(0,B.jsx)(Jft,{narratives:e.plan.narratives}),e.plan.references&&e.plan.references.length>0&&(0,B.jsx)(Yft,{references:e.plan.references}),(0,B.jsx)(npt,{doc:e}),(0,B.jsx)(tpt,{items:e.plan.items})]}),l===`dag`&&(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,style:{minHeight:400},"data-testid":`xbrief-dag-pane`,children:(0,B.jsx)(lpt,{issueId:e.plan.id})}),l===`raw`&&(0,B.jsx)(`pre`,{className:`p-4 text-xs text-success font-mono whitespace-pre-wrap break-all`,children:JSON.stringify(e,null,2)})]})]}):(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No plan available`})}function lpt({issueId:e}){let[t,n]=(0,z.useState)(null);return(0,z.useEffect)(()=>{v(()=>Promise.resolve().then(()=>H1e).then(e=>{n(()=>e.PlanMapViewer)}),void 0).catch(()=>{})},[]),t?(0,B.jsx)(t,{issueId:e}):(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Loading DAG...`})}typeof window<`u`&&window.document&&window.document.createElement;function iZ(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function upt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function dpt(...e){return t=>{let n=!1,r=e.map(e=>{let r=upt(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():upt(e[t],null)}}}}function aZ(...e){return z.useCallback(dpt(...e),e)}function fpt(e,t=[]){let n=[];function r(t,r){let i=z.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=z.useMemo(()=>o,Object.values(o));return(0,B.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=z.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>z.createContext(e));return function(n){let r=n?.[e]||t;return z.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,ppt(i,...t)]}function ppt(...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 z.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function mpt(e){let t=z.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];Spt(r)&&typeof oZ==`function`&&(r=oZ(r._payload)),z.Children.forEach(r,e=>{if(bpt(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Spt(n)&&typeof oZ==`function`&&(n=oZ(n._payload)),a=_pt(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=z.cloneElement(a,void 0,s):!o&&z.Children.count(r)===1&&z.isValidElement(r)&&(a=r);let c=a?ypt(a):void 0,l=aZ(n,c);if(!a){if(r||r===0)throw Error(o?Tpt(e):wpt(e));return r}let u=vpt(i,a.props??{});return a.type!==z.Fragment&&(u.ref=n?l:c),z.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var hpt=Symbol.for(`radix.slottable`);function gpt(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=hpt,t}var _pt=(e,t)=>{if(`child`in e.props){let t=e.props.child;return z.isValidElement(t)?z.cloneElement(t,void 0,e.props.children(t.props.children)):null}return z.isValidElement(t)?t:null};function vpt(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 ypt(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)}function bpt(e){return z.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===hpt}var xpt=Symbol.for(`react.lazy`);function Spt(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===xpt&&`_payload`in e&&Cpt(e._payload)}function Cpt(e){return typeof e==`object`&&!!e&&`then`in e}var wpt=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Tpt=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,oZ=z.use,sZ=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=mpt(`Primitive.${t}`),r=z.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,B.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ept(e,t){e&&pl.flushSync(()=>e.dispatchEvent(t))}function cZ(e){let t=z.useRef(e);return z.useEffect(()=>{t.current=e}),z.useMemo(()=>((...e)=>t.current?.(...e)),[])}var Dpt=`DismissableLayer`,lZ=`dismissableLayer.update`,Opt=`dismissableLayer.pointerDownOutside`,kpt=`dismissableLayer.focusOutside`,Apt,jpt=z.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Mpt=z.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=z.useContext(jpt),[d,f]=z.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=z.useState({}),h=aZ(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=z.useRef(!1),C=Ipt(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:z.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=Lpt(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=cZ(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return z.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),z.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Apt=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Rpt(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Apt))}},[d,p,n,u]),z.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Rpt())},[d,u]),z.useEffect(()=>{let e=()=>m({});return document.addEventListener(lZ,e),()=>document.removeEventListener(lZ,e)},[]),(0,B.jsx)(sZ.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:iZ(e.onFocusCapture,w.onFocusCapture),onBlurCapture:iZ(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:iZ(e.onPointerDownCapture,C.onPointerDownCapture)})});Mpt.displayName=Dpt;var Npt=`DismissableLayerBranch`,Ppt=z.forwardRef((e,t)=>{let n=z.useContext(jpt),r=z.useRef(null),i=aZ(t,r);return z.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,B.jsx)(sZ.div,{...e,ref:i})});Ppt.displayName=Npt;var Fpt=()=>!0;function Ipt(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Fpt}=t,s=cZ(e),c=z.useRef(!1),l=z.useRef(!1),u=z.useRef(new Map),d=z.useRef(()=>{});return z.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}function t(){return Array.from(u.current.values()).some(Boolean)}function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}function p(e){l.current&&u.current.set(e.type,!1)}let m=a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||zpt(Opt,s,p,{discrete:!0})};if(!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:()=>c.current=!0}}function Lpt(e,t=globalThis?.document){let n=cZ(e),r=z.useRef(!1);return z.useEffect(()=>{let e=e=>{e.target&&!r.current&&zpt(kpt,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 Rpt(){let e=new CustomEvent(lZ);document.dispatchEvent(e)}function zpt(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?Ept(i,a):i.dispatchEvent(a)}var uZ=globalThis?.document?z.useLayoutEffect:()=>{},Bpt=z.useId||(()=>void 0),Vpt=0;function Hpt(e){let[t,n]=z.useState(Bpt());return uZ(()=>{e||n(e=>e??String(Vpt++))},[e]),e||(t?`radix-${t}`:``)}var Upt=`Arrow`,Wpt=z.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,B.jsx)(sZ.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,B.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Wpt.displayName=Upt;var Gpt=Wpt;function Kpt(e){let[t,n]=z.useState(void 0);return uZ(()=>{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 dZ=`Popper`,[qpt,Jpt]=fpt(dZ),[Ypt,Xpt]=qpt(dZ),Zpt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=z.useState(null),[a,o]=z.useState(void 0);return(0,B.jsx)(Ypt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Zpt.displayName=dZ;var Qpt=`PopperAnchor`,$pt=z.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Xpt(Qpt,n),o=z.useRef(null),s=a.onAnchorChange,c=aZ(t,z.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=z.useRef(null);z.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&pZ(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,B.jsx)(sZ.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});$pt.displayName=Qpt;var fZ=`PopperContent`,[emt,tmt]=qpt(fZ),nmt=z.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=Xpt(fZ,n),[_,v]=z.useState(null),y=aZ(t,v),[b,x]=z.useState(null),S=Kpt(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(omt),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=KF({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>HF(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[qF({mainAxis:i+w,alignmentAxis:o}),c&&JF({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?YF():void 0,...k}),c&&XF({...k}),ZF({...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&&$F({element:b,padding:s}),smt({arrowWidth:C,arrowHeight:w}),f&&QF({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),F=g.setPlacementState;uZ(()=>(F(M),()=>{F(void 0)}),[M,F]);let[I,L]=pZ(M),ee=cZ(m);uZ(()=>{N&&ee?.()},[N,ee]);let R=P.arrow?.x,te=P.arrow?.y,ne=P.arrow?.centerOffset!==0,[re,ie]=z.useState();return uZ(()=>{_&&ie(window.getComputedStyle(_).zIndex)},[_]),(0,B.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:re,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,B.jsx)(emt,{scope:n,placedSide:I,placedAlign:L,onArrowChange:x,arrowX:R,arrowY:te,shouldHideArrow:ne,children:(0,B.jsx)(sZ.div,{"data-side":I,"data-align":L,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});nmt.displayName=fZ;var rmt=`PopperArrow`,imt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},amt=z.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=tmt(rmt,n),a=imt[i.placedSide];return(0,B.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,B.jsx)(Gpt,{...r,ref:t,style:{...r.style,display:`block`}})})});amt.displayName=rmt;function omt(e){return e!==null}var smt=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]=pZ(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 pZ(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var cmt=Zpt,lmt=$pt,umt=nmt,dmt=amt,fmt=`Portal`,pmt=z.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=z.useState(!1);uZ(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?pl.createPortal((0,B.jsx)(sZ.div,{...r,ref:t}),o):null});pmt.displayName=fmt;function mmt(e,t){return z.useReducer((e,n)=>t[e][n]??e,e)}var mZ=e=>{let{present:t,children:n}=e,r=hmt(t),i=typeof n==`function`?n({present:r.isPresent}):z.Children.only(n),a=_mt(r.ref,vmt(i));return typeof n==`function`||r.isPresent?z.cloneElement(i,{ref:a}):null};mZ.displayName=`Presence`;function hmt(e){let[t,n]=z.useState(),r=z.useRef(null),i=z.useRef(e),a=z.useRef(`none`),o=z.useRef(void 0),[s,c]=mmt(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return z.useEffect(()=>{s===`mounted`?(a.current=o.current??hZ(r.current),o.current=void 0):a.current=`none`},[s]),uZ(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=hZ(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),uZ(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=hZ(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=hZ(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:z.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=hZ(t)}else r.current=null;n(e)},[])}}function gmt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function _mt(...e){let t=z.useRef(e);return t.current=e,z.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=gmt(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():gmt(n[e],null)}}},[])}function hZ(e){return e?.animationName||`none`}function vmt(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 ymt=z.useInsertionEffect||uZ;function bmt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=xmt({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=z.useRef(e!==void 0);z.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,z.useCallback(t=>{if(s){let n=Smt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function xmt({defaultProp:e,onChange:t}){let[n,r]=z.useState(e),i=z.useRef(n),a=z.useRef(t);return ymt(()=>{a.current=t},[t]),z.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Smt(e){return typeof e==`function`}var Cmt=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`}),wmt=`VisuallyHidden`,Tmt=z.forwardRef((e,t)=>(0,B.jsx)(sZ.span,{...e,ref:t,style:{...Cmt,...e.style}}));Tmt.displayName=wmt;var Emt=Tmt,[gZ,Dmt]=fpt(`Tooltip`,[Jpt]),_Z=Jpt(),Omt=`TooltipProvider`,kmt=700,vZ=`tooltip.open`,[Amt,yZ]=gZ(Omt),jmt=e=>{let{__scopeTooltip:t,delayDuration:n=kmt,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=z.useRef(!0),s=z.useRef(!1),c=z.useRef(0);return z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,B.jsx)(Amt,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};jmt.displayName=Omt;var bZ=`Tooltip`,[Mmt,xZ]=gZ(bZ),Nmt=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=yZ(bZ,e.__scopeTooltip),l=_Z(t),[u,d]=z.useState(null),f=Hpt(),p=z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=z.useRef(!1),[_,v]=bmt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(vZ))):c.onClose(),a?.(e)},caller:bZ}),y=z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,B.jsx)(cmt,{...l,children:(0,B.jsx)(Mmt,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Nmt.displayName=bZ;var SZ=`TooltipTrigger`,Pmt=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=xZ(SZ,n),a=yZ(SZ,n),o=_Z(n),s=aZ(t,z.useRef(null),i.onTriggerChange),c=z.useRef(!1),l=z.useRef(!1),u=z.useCallback(()=>c.current=!1,[]);return z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,B.jsx)(lmt,{asChild:!0,...o,children:(0,B.jsx)(sZ.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:iZ(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:iZ(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:iZ(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:iZ(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:iZ(e.onBlur,i.onClose),onClick:iZ(e.onClick,i.onClose)})})});Pmt.displayName=SZ;var CZ=`TooltipPortal`,[Fmt,Imt]=gZ(CZ,{forceMount:void 0}),Lmt=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=xZ(CZ,t);return(0,B.jsx)(Fmt,{scope:t,forceMount:n,children:(0,B.jsx)(mZ,{present:n||a.open,children:(0,B.jsx)(pmt,{asChild:!0,container:i,children:r})})})};Lmt.displayName=CZ;var wZ=`TooltipContent`,Rmt=z.forwardRef((e,t)=>{let n=Imt(wZ,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=xZ(wZ,e.__scopeTooltip);return(0,B.jsx)(mZ,{present:r||o.open,children:o.disableHoverableContent?(0,B.jsx)(Umt,{side:i,...a,ref:t}):(0,B.jsx)(zmt,{side:i,...a,ref:t})})}),zmt=z.forwardRef((e,t)=>{let n=xZ(wZ,e.__scopeTooltip),r=yZ(wZ,e.__scopeTooltip),i=z.useRef(null),a=aZ(t,i),[o,s]=z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=z.useCallback(()=>{s(null),d(!1)},[d]),p=z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=qmt(r,Kmt(r,n.getBoundingClientRect())),a=Jmt(t.getBoundingClientRect());s(Xmt([...i,...a])),d(!0)},[d]);return z.useEffect(()=>()=>f(),[f]),z.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]),z.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=!Ymt(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,B.jsx)(Umt,{...e,ref:a})}),[Bmt,Vmt]=gZ(bZ,{isInside:!1}),Hmt=gpt(`TooltipContent`),Umt=z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=xZ(wZ,n),l=_Z(n),{onClose:u}=c;return z.useEffect(()=>(document.addEventListener(vZ,u),()=>document.removeEventListener(vZ,u)),[u]),z.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,B.jsx)(Mpt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,B.jsxs)(umt,{"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,B.jsx)(Hmt,{children:r}),(0,B.jsx)(Bmt,{scope:n,isInside:!0,children:(0,B.jsx)(Emt,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Rmt.displayName=wZ;var Wmt=`TooltipArrow`,Gmt=z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=_Z(n);return Vmt(Wmt,n).isInside?null:(0,B.jsx)(dmt,{...i,...r,ref:t})});Gmt.displayName=Wmt;function Kmt(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 qmt(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 Jmt(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 Ymt(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 Xmt(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)),Zmt(t)}function Zmt(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 Qmt=jmt,$mt=Nmt,eht=Pmt,tht=Lmt,nht=Rmt,rht=Gmt,iht=Qmt;function aht({content:e,children:t,side:n=`top`}){return(0,B.jsxs)($mt,{children:[(0,B.jsx)(eht,{asChild:!0,children:t}),(0,B.jsx)(tht,{children:(0,B.jsxs)(nht,{side:n,sideOffset:5,collisionPadding:8,className:`z-[1000] max-w-[248px] rounded-md border border-border bg-card px-2.5 py-2 text-[11.5px] leading-relaxed text-foreground shadow-lg`,children:[e,(0,B.jsx)(rht,{className:`fill-border`,width:9,height:4.5})]})})]})}function oht({label:e,content:t,side:n=`top`}){return(0,B.jsx)(aht,{content:t,side:n,children:(0,B.jsx)(`button`,{type:`button`,"data-help-trigger":``,"aria-label":`${e} help`,className:`inline-flex h-[13px] w-[13px] shrink-0 items-center justify-center rounded-full border border-border text-[8.5px] font-medium leading-none text-muted-foreground hover:border-foreground hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-primary`,children:(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`?`})})})}function sht({title:e,body:t,options:n}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,B.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:t}),n&&n.length>0&&(0,B.jsx)(`dl`,{className:`mt-1.5 space-y-1 border-t border-border pt-1.5`,children:n.map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:e}),(0,B.jsxs)(`dd`,{className:`inline text-muted-foreground`,children:[` — `,t]})]},e))})]})}var cht=440,lht=`w-full rounded border border-border bg-popover px-2 py-0.5 text-[11.5px] font-medium text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50`,TZ={reviewMode:{hint:`How much AI review runs before merge.`,title:`Review mode`,body:`How much AI review runs once the work agent finishes. Typecheck, lint, and tests always run first — this dial never skips them.`,options:[[`Quick`,`One reviewer makes a single self-review pass.`],[`Full`,`Four reviewers — security, correctness, performance, requirements — run in parallel, then a fifth synthesizes their reports.`],[`None`,`Skips AI review only. The issue still advances to test and merge.`]]},reviewModel:{hint:`Which model reviews this issue.`,title:`Review model`,body:`Overrides the model used to review this issue. Leave on Default to use the model configured for the review role.`},workModel:{hint:`Pins the implementation model for this issue.`,title:`Work model`,body:`Pins the model every work agent on this issue uses. It takes effect on the next spawn and applies to every dispatch after that — a running agent keeps the model it started with.`},swarm:{hint:`Run plan items in parallel across several agents.`,title:`Swarm`,body:`Whether several work agents take independent plan items on this issue at the same time.`,options:[[`Off`,`One work agent at a time.`],[`Auto`,`Swarms when the xBRIEF is partitionable and at least two items are independently startable.`],[`Always`,`Behaves the same as Auto today — it does not yet force a swarm on a plan that cannot partition.`]]},standingCrew:{hint:`Route each item to a model tier by difficulty.`,title:`Standing crew`,body:`Routes each plan item to a model tier by its declared difficulty or kind, instead of running everything on one model. Items the tier table cannot place fall back to the work role’s model. Default shows both the value and where it came from — this issue, the plan’s xBRIEF metadata, or your global config.`,options:[[`On`,`Use the tier table to pick a model per item.`],[`Off`,`Every item runs on the work role’s model.`]]}};function EZ({ariaLabel:e,value:t,resolvedLabel:n,options:r,disabled:i,onChange:a}){let o=`border-l border-border px-2 py-0.5 text-[11px] font-medium first:border-l-0 disabled:opacity-50`;return(0,B.jsxs)(`div`,{className:`inline-flex overflow-hidden rounded border border-border`,role:`group`,"aria-label":e,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":t===null,className:`${o} ${t===null?`bg-primary/12 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`}`,disabled:i,onClick:()=>a(null),children:[`Default `,(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`· `,n]})]}),r.map(([e,n])=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:`${o} ${t===e?`bg-primary/12 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`}`,disabled:i,onClick:()=>a(e),children:n},e))]})}function DZ({label:e,help:t,overridden:n,reset:r,note:i,children:a}){return(0,B.jsxs)(`div`,{className:`my-2 grid grid-cols-[108px_1fr] items-start gap-2.5`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 pt-1 text-[12px] font-medium ${n?`text-foreground`:`text-muted-foreground`}`,children:[(0,B.jsx)(`span`,{className:`h-[5px] w-[5px] shrink-0 rounded-full bg-primary ${n?`opacity-100`:`opacity-0`}`}),e,(0,B.jsx)(oht,{label:e,side:`top`,content:(0,B.jsx)(sht,{title:t.title,body:t.body,options:t.options})})]}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[a,r]}),(0,B.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-muted-foreground`,children:t.hint}),i]})]})}function uht({issueId:e}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)({}),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(null),_=(0,z.useRef)(null),v=(0,z.useRef)(null),y=(0,z.useRef)(null),b=(0,z.useCallback)(async()=>{let t=encodeURIComponent(e),[r,a,s,l]=await Promise.all([fetch(`/api/review/${t}/config`),fetch(`/api/issues/${t}/staffing`),fetch(`/api/issues/${t}/swarm-policy`),fetch(`/api/settings/available-models`)]);if(r.ok){let e=await r.json();e.override&&e.resolved&&n(e)}if(a.ok){let e=await a.json();e.override&&e.resolved&&i(e)}if(s.ok){let e=await s.json();e.resolved&&o(e)}l.ok&&c(await l.json())},[e]);(0,z.useEffect)(()=>{let e=!1;return b().catch(()=>{e||n(null)}),()=>{e=!0}},[b]);let x=(0,z.useMemo)(()=>Object.values(s).flat().filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t).sort((e,t)=>e.name.localeCompare(t.name)),[s]),S=(0,z.useCallback)(async(e,t,n=`POST`)=>{u(!0);try{let r=await fetch(e,{method:n,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok)await b();else{let e=r.statusText||`Request failed (HTTP ${r.status})`;try{let t=await r.json();typeof t.error==`string`?e=t.error:typeof t.message==`string`&&(e=t.message)}catch{}U.error(`Failed to save issue policy`,{description:e})}}catch(e){let t=e instanceof Error&&e.message?e.message:typeof e==`string`&&e?e:`Request failed`;U.error(`Failed to save issue policy`,{description:t})}finally{u(!1)}},[b]),C=(0,z.useCallback)(()=>{let e=_.current?.getBoundingClientRect();if(!e)return;let t=Math.min(cht,Math.max(0,window.innerWidth-16));g({top:e.bottom+6,left:Math.max(8,Math.min(e.left,window.innerWidth-t-8))})},[]),w=(0,z.useCallback)(e=>{if(p){m(!1);return}y.current=e,C(),m(!0)},[p,C]),T=(0,z.useCallback)(e=>{y.current=e,C(),m(!0)},[C]);if((0,z.useEffect)(()=>{if(!p)return;v.current?.querySelector(`button:not([data-help-trigger]), select`)?.focus();let e=e=>{let t=e.target;!_.current?.contains(t)&&!v.current?.contains(t)&&m(!1)},t=e=>{e.key===`Escape`&&(m(!1),y.current?.focus())},n=()=>m(!1);return document.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t),window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[p]),!t||!r||!a)return null;let E=encodeURIComponent(e),D=r.resolved.tiered?`tiered`:r.resolved.model,O=!!(r.override.workModel&&r.override.workModel!==r.resolved.recordedModel),k=r.tieredExecution.effective&&!!r.override.workModel,A=e=>x.find(t=>t.id===e)?.name??e,j=[t.override.reviewMode&&{key:`review`,label:`review`,value:t.override.reviewMode},t.override.reviewModel&&{key:`review-model`,label:`review model`,value:A(t.override.reviewModel)},r.override.workModel&&{key:`work`,label:`work`,value:`${A(r.override.workModel)}${k?` · replaces crews`:``}`},a.configured?.mode&&{key:`swarm`,label:`swarm`,value:a.configured.mode},r.tieredExecution.override&&{key:`crew`,label:`crew`,value:r.tieredExecution.override}].filter(e=>!!e),M=j.length,N=async()=>{u(!0),f(null);try{let t=await fetch(`/api/agents/agent-${e.toLowerCase()}/restart-fresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({spawn:!0,model:r.override.workModel})}),n=await t.json();if(iL(t.status,n,e,{url:`/api/agents/agent-${e.toLowerCase()}/restart-fresh`,body:{spawn:!0,model:r.override.workModel}}))return;f(t.ok?`Fresh restart requested.`:n.error??`Restart failed.`),t.ok&&await b()}catch{f(`Restart failed.`)}finally{u(!1)}},P=async()=>{t.override.reviewMode!==null&&await S(`/api/review/${E}/config`,{reviewMode:null}),t.override.reviewModel!==null&&await S(`/api/review/${E}/config`,{reviewModel:null}),r.override.workModel!==null&&await S(`/api/issues/${E}/staffing`,{workModel:null}),a.configured?.mode&&await S(`/api/issues/${E}/swarm-policy`,{value:null}),r.tieredExecution.override!==null&&await S(`/api/workspaces/${E}/tiered-execution`,{override:null},`PATCH`)},F=`text-[10.5px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50`;return(0,B.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`issue-policy-strip`,title:`Per-issue review and staffing overrides`,children:[(0,B.jsxs)(`button`,{ref:_,type:`button`,"aria-label":`Issue policies`,"aria-expanded":p,className:`inline-flex h-[22px] items-center gap-1.5 rounded border border-border px-2 text-[11px] font-medium hover:bg-muted hover:text-foreground ${M>0?`text-foreground`:`text-muted-foreground`}`,onClick:e=>w(e.currentTarget),children:[(0,B.jsxs)(`svg`,{"aria-hidden":`true`,className:`h-[11px] w-[11px]`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,B.jsx)(`line`,{x1:`2`,y1:`4.5`,x2:`14`,y2:`4.5`}),(0,B.jsx)(`circle`,{cx:`6`,cy:`4.5`,r:`1.7`,fill:`currentColor`}),(0,B.jsx)(`line`,{x1:`2`,y1:`11.5`,x2:`14`,y2:`11.5`}),(0,B.jsx)(`circle`,{cx:`10.5`,cy:`11.5`,r:`1.7`,fill:`currentColor`})]}),`Policies`,M>0&&(0,B.jsx)(`span`,{className:`inline-flex min-w-[14px] items-center justify-center rounded-sm bg-primary/12 px-1 text-[9px] text-primary`,children:M})]}),j.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex h-5 items-center gap-1 rounded border border-primary/32 bg-primary/8 px-1.5 text-[11px] font-medium text-foreground`,onClick:e=>T(e.currentTarget),children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.label,` ·`]}),` `,e.value]},e.key)),O&&(0,B.jsx)(`button`,{type:`button`,className:`inline-flex h-5 items-center rounded border border-warning/32 bg-warning/8 px-1.5 text-[11px] font-medium text-warning-foreground`,onClick:e=>T(e.currentTarget),children:`restart pending`}),p&&h&&(0,pl.createPortal)((0,B.jsx)(iht,{delayDuration:200,skipDelayDuration:300,children:(0,B.jsxs)(`div`,{ref:v,role:`dialog`,"aria-label":`Issue policy overrides`,tabIndex:-1,className:`fixed z-[100] w-[440px] max-w-[calc(100vw-16px)] rounded-lg border border-border bg-popover px-4 pb-3 pt-3.5 shadow-lg`,style:{top:h.top,left:h.left},children:[(0,B.jsx)(`h3`,{className:`mb-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Review`}),(0,B.jsx)(DZ,{label:`Mode`,help:TZ.reviewMode,overridden:!!t.override.reviewMode,reset:t.override.reviewMode?(0,B.jsx)(`button`,{type:`button`,"aria-label":`Reset review mode to default`,className:F,disabled:l,onClick:()=>S(`/api/review/${E}/config`,{reviewMode:null}),children:`reset`}):void 0,children:(0,B.jsx)(EZ,{ariaLabel:`Review mode for this issue`,value:t.override.reviewMode,resolvedLabel:t.resolved.reviewMode,options:[[`quick`,`Quick`],[`full`,`Full`],[`none`,`None`]],disabled:l,onChange:e=>S(`/api/review/${E}/config`,{reviewMode:e})})}),(0,B.jsx)(DZ,{label:`Model`,help:TZ.reviewModel,overridden:!!t.override.reviewModel,reset:t.override.reviewModel?(0,B.jsx)(`button`,{type:`button`,"aria-label":`Reset review model to default`,className:F,disabled:l,onClick:()=>S(`/api/review/${E}/config`,{reviewModel:null}),children:`reset`}):void 0,children:(0,B.jsxs)(`select`,{"aria-label":`Review model for this issue`,className:lht,disabled:l,value:t.override.reviewModel??``,onChange:e=>S(`/api/review/${E}/config`,{reviewModel:e.target.value||null}),children:[(0,B.jsxs)(`option`,{value:``,children:[`Default · `,t.resolved.reviewModel?A(t.resolved.reviewModel):`per-role default`]}),x.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(`h3`,{className:`mb-2 mt-4 border-t border-border pt-3 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Work`}),(0,B.jsx)(DZ,{label:`Model`,help:TZ.workModel,overridden:!!r.override.workModel,reset:r.override.workModel?(0,B.jsx)(`button`,{type:`button`,"aria-label":`Reset work model to default`,className:F,disabled:l,onClick:()=>S(`/api/issues/${E}/staffing`,{workModel:null}),children:`reset`}):void 0,note:k?(0,B.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-muted-foreground`,children:`Overrides crew routing — every item on this issue runs this model.`}):void 0,children:(0,B.jsxs)(`select`,{"aria-label":`Work model for this issue`,className:lht,disabled:l,value:r.override.workModel??``,onChange:e=>S(`/api/issues/${E}/staffing`,{workModel:e.target.value||null}),children:[(0,B.jsxs)(`option`,{value:``,children:[`Default · `,D]}),x.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(DZ,{label:`Swarm`,help:TZ.swarm,overridden:!!a.configured?.mode,reset:a.configured?.mode?(0,B.jsx)(`button`,{type:`button`,"aria-label":`Reset swarm mode to default`,className:F,disabled:l,onClick:()=>S(`/api/issues/${E}/swarm-policy`,{value:null}),children:`reset`}):void 0,children:(0,B.jsx)(EZ,{ariaLabel:`Swarm mode for this issue`,value:a.configured?.mode??null,resolvedLabel:a.resolved.mode,options:[[`off`,`Off`],[`auto`,`Auto`],[`always`,`Always`]],disabled:l,onChange:e=>S(`/api/issues/${E}/swarm-policy`,{value:e?{mode:e}:null})})}),(0,B.jsx)(DZ,{label:`Standing crew`,help:TZ.standingCrew,overridden:!!r.tieredExecution.override,reset:r.tieredExecution.override?(0,B.jsx)(`button`,{type:`button`,"aria-label":`Reset standing crew to default`,className:F,disabled:l,onClick:()=>S(`/api/workspaces/${E}/tiered-execution`,{override:null},`PATCH`),children:`reset`}):void 0,children:(0,B.jsx)(EZ,{ariaLabel:`Standing crew routing for this issue`,value:r.tieredExecution.override,resolvedLabel:`${r.tieredExecution.effective?`on`:`off`} (${r.tieredExecution.source===`issue-override`?`issue`:r.tieredExecution.source===`plan-metadata`?`plan`:`global`})`,options:[[`on`,`On`],[`off`,`Off`]],disabled:l,onChange:e=>S(`/api/workspaces/${E}/tiered-execution`,{override:e},`PATCH`)})}),O&&(0,B.jsxs)(`div`,{className:`mt-3 rounded-md border border-warning/32 bg-warning/8 px-2.5 py-2 text-[11.5px] font-medium text-warning-foreground`,children:[(0,B.jsx)(`div`,{children:`The work-model override applies to the next spawn; running agents are never restarted automatically.`}),(0,B.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded border border-warning/45 px-2 py-0.5 text-[11px] font-medium hover:bg-warning/10 disabled:opacity-50`,disabled:l,onClick:N,children:`Restart agent with new staffing`}),d&&(0,B.jsx)(`span`,{children:d})]})]}),(0,B.jsxs)(`div`,{className:`mt-3.5 flex items-center justify-between border-t border-border pt-2.5`,children:[(0,B.jsx)(`span`,{className:`text-[10.5px] font-medium text-muted-foreground`,children:`Overrides apply to this issue only.`}),M>0&&(0,B.jsx)(`button`,{type:`button`,className:`text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50`,disabled:l,onClick:P,children:`Reset all to defaults`})]})]})}),document.body)]})}var OZ={wrap:`_wrap_1exzz_2`,header:`_header_1exzz_3`,title:`_title_1exzz_4`,badge:`_badge_1exzz_5`,ok:`_ok_1exzz_6`,bad:`_bad_1exzz_5`,run:`_run_1exzz_8`,idle:`_idle_1exzz_9`,steps:`_steps_1exzz_11`,step:`_step_1exzz_11`,stepIcon:`_stepIcon_1exzz_13`,stepLabel:`_stepLabel_1exzz_14`,stepCurrent:`_stepCurrent_1exzz_15`,stepBar:`_stepBar_1exzz_16`,okIcon:`_okIcon_1exzz_17`,badIcon:`_badIcon_1exzz_18`,idleIcon:`_idleIcon_1exzz_19`,spin:`_spin_1exzz_20`,shipSpin:`_shipSpin_1exzz_1`,log:`_log_1exzz_23`,logLine:`_logLine_1exzz_28`,logTs:`_logTs_1exzz_29`,logText:`_logText_1exzz_30`,empty:`_empty_1exzz_31`},kZ=[{key:`rebasing`,label:`Rebase onto main`,matches:[`rebasing`]},{key:`verifying`,label:`Verify (quality gates)`,matches:[`verifying`,`validating-pr`]},{key:`squash-merging`,label:`Merge PR`,matches:[`squash-merging`,`merging`]},{key:`post-merge-cleanup`,label:`Post-merge cleanup`,matches:[`post-merge-cleanup`]}];function dht(e){return e?kZ.findIndex(t=>t.matches.includes(e)):-1}function fht(e){let t=dht(e.mergeStep);return t>=0?kZ[t].label:e.mergeStep??e.status}function AZ({ship:e,compact:t=!1,onClick:n}){let{status:r,mergeStep:i,log:a}=e,o=r===`merging`||r===`verifying`,s=r===`failed`,c=r===`merged`,l=dht(i),u=a?.lines??[];return t?!o&&!c&&!s?null:(0,B.jsx)(`div`,{className:Z.sessionList,"data-section":`ship-progress-compact`,children:(0,B.jsxs)(`button`,{type:`button`,className:Z.sessionNode,onClick:n,title:`The merge door is working this issue — click to open its cockpit (Ship tab shows the live log)`,"data-testid":`ship-door-row`,style:{display:`flex`,alignItems:`center`,gap:6},children:[c?(0,B.jsx)(_s,{size:12,style:{color:`var(--success)`,flexShrink:0}}):s?(0,B.jsx)(bs,{size:12,style:{color:`var(--destructive)`,flexShrink:0}}):(0,B.jsx)(gc,{size:12,className:Z.spinning,style:{color:`var(--primary)`,flexShrink:0}}),(0,B.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:`Ship`}),(0,B.jsx)(`span`,{style:{fontSize:11,color:`var(--muted-foreground)`},children:fht(e)})]})}):(0,B.jsxs)(`div`,{className:OZ.wrap,"data-section":`ship-progress-full`,children:[(0,B.jsxs)(`div`,{className:OZ.header,children:[(0,B.jsx)(`span`,{className:OZ.title,children:`Ship — merge door`}),(0,B.jsx)(`span`,{className:`${OZ.badge} ${c?OZ.ok:s?OZ.bad:o?OZ.run:OZ.idle}`,children:c?`merged`:s?`failed`:o?r:r??`idle`})]}),(0,B.jsx)(`div`,{className:OZ.steps,"data-section":`ship-progress-steps`,children:kZ.map((e,t)=>{let n=c?!0:l>t,r=!c&&l===t,i=`pending`;return n?i=`done`:r&&(i=`current`),(0,B.jsxs)(`div`,{className:OZ.step,"data-section":`ship-progress-step`,"data-step-key":e.key,"data-step-state":i,children:[(0,B.jsx)(`span`,{className:OZ.stepIcon,children:n?(0,B.jsx)(_s,{size:13,className:OZ.okIcon}):r&&s?(0,B.jsx)(bs,{size:13,className:OZ.badIcon}):r&&o?(0,B.jsx)(gc,{size:13,className:OZ.spin}):(0,B.jsx)(xs,{size:13,className:OZ.idleIcon})}),(0,B.jsx)(`span`,{className:`${OZ.stepLabel} ${r?OZ.stepCurrent:``}`,children:e.label}),t<kZ.length-1?(0,B.jsx)(`span`,{className:OZ.stepBar}):null]},e.key)})}),(0,B.jsx)(`div`,{className:OZ.log,"data-section":`ship-progress-log`,children:u.length===0?(0,B.jsx)(`div`,{className:OZ.empty,children:o?`Waiting for door output…`:`No ship activity yet this session. Logs appear here live when a merge runs (the merge door is server-side — rebase, quality gates, PR merge, cleanup).`}):u.map((e,t)=>(0,B.jsxs)(`div`,{className:OZ.logLine,children:[(0,B.jsx)(`span`,{className:OZ.logTs,children:e.ts.slice(11,19)}),(0,B.jsx)(`span`,{className:OZ.logText,children:e.line})]},t))})]})}function jZ(e,t){return t?.status===`running`||t?.status===`starting`?!0:e.status===`running`||e.status===`starting`?e.presence!==`ended`:!1}function MZ(e){return e?.readyForMerge===!0}function pht(e){let t=e;return t?.mergeStep??t?.mergeStatus??null}function mht(e){return e?.stuckReason||(e?.blockerReasons?.[0]?e.blockerReasons[0].summary:e?.reviewStatus===`blocked`?`Review blocked`:e?.reviewStatus===`failed`?`Review failed`:e?.testStatus===`dispatch_failed`?`Test dispatch failed`:e?.testStatus===`failed`?`Tests failed`:e?.mergeStatus===`failed`?`Merge failed`:e?.verificationStatus===`failed`?`Verification failed`:`Needs attention`)}var hht={awaiting_input:0,stuck:1,troubled:2,paused:3,stale_review:4,blocker:5,pickup_gate:6,ready_for_merge:7,stopped:8};function ght(e){return e.map((e,t)=>({item:e,index:t})).sort((e,t)=>hht[e.item.kind]-hht[t.item.kind]||e.index-t.index).map(({item:e})=>e)}function NZ(e,t){let n=`pending`;return e?.mergeStatus===`merged`?n=`merged`:MZ(e)?n=`ready`:e?.mergeStatus===`queued`?n=`queued`:e?.mergeStatus===`merging`?n=`merging`:e?.mergeStatus===`verifying`?n=`verifying`:e?.mergeStatus===`failed`&&(n=`failed`),{status:n,readyForMerge:MZ(e),mergeStep:pht(e),blockerReason:n===`ready`||n===`merged`?void 0:mht(e),log:t??null}}async function PZ(e){let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status} ${t.statusText} — ${e}`);return t.json()}function _ht(e){return V({queryKey:[`command-deck-planning`,e,`summary`],queryFn:()=>PZ(`/api/command-deck/planning/${e}?summary=1`),refetchInterval:6e4})}function vht(e,t){return V({queryKey:[`command-deck-planning`,e,`full`],queryFn:()=>PZ(`/api/command-deck/planning/${e}`),refetchInterval:!1,...t})}function yht(e,t){return V({queryKey:[`workspace-plan`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}/plan`);if(t.status===404)return null;if(!t.ok)throw Error(`HTTP ${t.status} ${t.statusText} — /api/workspaces/${e}/plan`);return t.json()},refetchInterval:3e4,...t})}function FZ(e){return V({queryKey:[`command-deck-activity`,e,`summary`],queryFn:()=>PZ(`/api/command-deck/activity/${e}?summary=1`),refetchInterval:e=>{let t=e.state.data?.sections;return t?t.some(e=>e.status===`running`||e.status===`active`)?5e3:3e4:5e3}})}function IZ(e){return V({queryKey:[`review-status`,e],queryFn:()=>PZ(`/api/review/${e}/status`),refetchInterval:3e4})}function bht(e){return V({queryKey:[`ship-log`,e],queryFn:()=>PZ(`/api/issues/${e}/ship-log`),refetchInterval:e=>{let t=e.state.data?.mergeStatus;return t===`merging`||t===`verifying`?2e3:15e3}})}function LZ(e){return V({queryKey:[`issueCosts`,e],queryFn:()=>PZ(`/api/issues/${e}/costs`),refetchInterval:3e4})}function RZ(e,t){return V({queryKey:[`issueCheckRuns`,e],queryFn:()=>PZ(`/api/issues/${e}/check-runs`),refetchInterval:3e4,enabled:!!e,...t})}function zZ(e,t){return V({queryKey:[`issuePr`,e],queryFn:()=>PZ(`/api/issues/${e}/pr`),refetchInterval:3e4,enabled:!!e,...t})}function xht(e){return V({queryKey:[`issuePr`,e,`details`],queryFn:()=>PZ(`/api/issues/${e}/pr/details`),select:e=>({issueId:e.issueId,diff:e.diff,error:e.error}),refetchInterval:!1})}function Sht(e){return V({queryKey:[`issueDiscussions`,e],queryFn:()=>PZ(`/api/issues/${e}/discussions`),refetchInterval:3e4})}function BZ(e,t){return V({queryKey:[`workspace`,e],queryFn:()=>PZ(`/api/workspaces/${e}`),refetchInterval:3e4,...t})}function Cht(e,t){let n=Array.from(new Set(e.filter(Boolean).map(e=>e.toUpperCase()))).sort();return V({queryKey:[`workspace-stack-health`,n],queryFn:()=>PZ(`/api/workspace-stack-health?issueIds=${encodeURIComponent(n.join(`,`))}`),enabled:n.length>0,refetchInterval:3e4,...t})}function VZ({issueId:e,density:t,children:n,...r}){let i=r[`data-component`];return(0,B.jsxs)(`div`,{...r,"data-component":typeof i==`string`?i:`issue-view`,"data-density":t,children:[(t===`cockpit`||t===`console`)&&(0,B.jsx)(`div`,{"data-section":t===`console`?`IssuePolicyStrip / PoliciesControl`:`ReviewPolicyControl`,children:(0,B.jsx)(uht,{issueId:e})}),t===`console`&&(0,B.jsx)(`div`,{"data-section":`StartAgentCta`,children:(0,B.jsx)($X,{issueId:e,density:t})}),n]})}function wht({issueId:e,onClick:t}){let{data:n}=IZ(e);return(0,B.jsx)(AZ,{ship:NZ(n),compact:!0,onClick:t})}function HZ({onClick:e,className:t,ariaLabel:n=`Expand issue full screen`}){return(0,B.jsx)(`button`,{type:`button`,className:t,"aria-label":n,title:n,onClick:t=>{t.stopPropagation(),e()},children:`⛶`})}var Tht={work:`bg-primary`,review:`bg-signal-review`,ship:`bg-warning`,done:`bg-success`,info:`bg-info`};function Eht(){let{activityFull:e}=_L();return(0,B.jsx)(`div`,{"data-testid":`drawer-tab-panel-activity`,children:e.length===0?(0,B.jsx)(`div`,{className:`rounded-[12px] border border-dashed border-border px-[12px] py-[18px] text-center text-[12px] text-muted-foreground`,children:`No activity yet.`}):(0,B.jsx)(`div`,{className:`space-y-[12px]`,children:e.map(e=>{let t=new Date(e.when),n=e.when?Number.isNaN(t.getTime())?e.when:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):`just now`;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr] gap-[10px]`,"data-phase":e.phase,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:Kx(`mt-[4px] h-[8px] w-[8px] rounded-full`,Tht[e.phase])}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-[12px] leading-[18px] text-foreground`,children:e.message}),(0,B.jsx)(`div`,{className:`mt-[2px] font-mono text-[10px] leading-none text-muted-foreground`,children:n})]})]},e.id)})})})}function Dht({issueId:e}){let t=Q(e=>e.openXbriefViewer),{data:n,isLoading:r,isError:i}=V({queryKey:[`drawer-xbrief-plan`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}/plan`);return t.ok?t.json():null},retry:!1});return(0,B.jsxs)(`div`,{"data-testid":`drawer-tab-panel-plan`,className:`relative`,children:[(0,B.jsx)(HZ,{ariaLabel:`Expand xBRIEF full screen`,onClick:()=>t(e),className:`absolute right-2 top-2 z-10 rounded border border-border bg-card px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`}),r?(0,B.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Loading plan…`}):i?(0,B.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Failed to load plan`}):(0,B.jsx)(rZ,{doc:n??null,initialTab:`dag`})]})}var Oht=new Set([``,`unknown`,`specialist`,`planning`,`idle`,`none`]);function kht(e){let t=(e??``).trim();return Oht.has(t.toLowerCase())?``:t.replace(/^claude-/,``)}function Aht(e,t){if(e===void 0||Number.isNaN(e)||e<=0)return;let n=t&&t>0?` · ${t>=1e6?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e3)}k`} tok`:``;return`$${e.toFixed(2)}${n}`}function jht(e){switch(e){case`planning`:case`work`:case`knowledge`:case`strike`:case`review`:case`reviewer`:case`test`:case`ship`:case`merge`:case`legacy`:return e;default:return`work`}}function Mht(e){let t=e.toLowerCase();return t===`running`||t===`active`||t===`working`||t===`thinking`?`running`:t===`starting`?`starting`:t===`error`||t===`failed`||t===`blocked`||t===`dispatch_failed`?`error`:t===`stopped`||t===`completed`?`stopped`:`unknown`}function Nht(e){let t=e.toLowerCase();return t===`running`||t===`active`||t===`working`||t===`thinking`||t===`starting`?`active`:`ended`}function Pht(e){return{type:jht(e.type),sessionId:e.sessionId,tmuxSession:e.tmuxSession,model:e.model,startedAt:e.startedAt,duration:e.duration,status:Mht(e.status),presence:Nht(e.status),role:e.role,roundMetadata:e.roundMetadata?{...e.roundMetadata,history:e.roundMetadata.history.map(e=>({...e,durationSec:e.durationSec??void 0}))}:void 0,awaitingInput:e.awaitingInput,awaitingInputPrompt:e.awaitingInputPrompt,awaitingInputReason:e.awaitingInputReason,pendingInputKinds:e.pendingInputKinds}}function Fht(e){let t=/^agent-[a-z]+-\d+-slot-(\d+)$/i.exec(e);return t?Number(t[1]):null}function Iht(e){let t=e.type===`work`?Fht(e.sessionId):null;if(t!==null)return`Slot ${t}`;switch(e.type){case`ship`:case`merge`:return`Ship`;case`test`:return`Test`;case`review`:return`Review`;case`reviewer`:return e.role?e.role[0].toUpperCase()+e.role.slice(1):`Reviewer`;case`work`:return`Work`;case`knowledge`:return`Knowledge`;case`strike`:return`Strike`;case`planning`:return`Plan`;case`legacy`:return`Plan`;default:return e.type}}function Lht(e){return e.type===`reviewer`&&e.role?`reviewer-${e.role}`:e.type}function Rht(e,t){return e.awaitingInput?`waiting`:t?.paused||e.paused?`paused`:jZ(e,t)?`running`:e.status===`error`||t?.status===`error`?`error`:e.status===`stopped`||e.status===`unknown`?`done`:e.status}function zht(e){if(e.type!==`reviewer`)return null;let{latestReviewResult:t,latestStatus:n}=e.roundMetadata??{};return t===`APPROVED`?`approved`:t===`CHANGES_REQUESTED`||n===`failed`||e.status===`error`?`changes_requested`:null}function Bht(e){return e?e.hasPendingQuestion===!0||(e.pendingInputCount??0)>0||e.pendingAskUserQuestion!=null||e.pendingProposedPlan!=null:!1}function UZ(e,t){return Object.values(t).find(t=>t.sessionId===e.sessionId||t.id===e.sessionId||e.tmuxSession&&t.sessionId===e.tmuxSession||t.id===e.tmuxSession)}function Vht(e,t){if(!t)return;let n=t.sessions.find(t=>t.sessionId===e.sessionId||t.agentId&&(t.agentId===e.tmuxSession||t.agentId===e.sessionId));return n?Aht(n.cost,n.tokenCount):void 0}function Hht(e,t,n){let r=UZ(e,t);return{sessionId:e.sessionId,type:e.type,label:Iht(e),icon:Lht(e),role:e.role,status:Rht(e,r),active:jZ(e,r),model:kht(e.model),harness:e.harness??r?.runtime,startedAt:e.startedAt,cost:Vht(e,n),duration:e.duration??null,verdict:zht(e),pendingInput:e.awaitingInput===!0||Bht(r)}}function Uht(e,t){if(e?.mergeStatus===`merged`)return`merged`;if(e?.mergeStatus===`verifying`)return`verifying`;if(MZ(e))return`ready`;if(e?.mergeStatus===`queued`||e?.mergeStatus===`merging`)return`ship`;if(e?.testStatus===`testing`)return`test`;if(e?.verificationStatus===`running`)return`verify`;if(e?.reviewStatus===`reviewing`||e?.reviewStatus===`passed`||e?.reviewStatus===`failed`||e?.reviewStatus===`blocked`)return`review`;let n=t.find(e=>jZ(e,void 0))?.type;return n===`planning`||n===`legacy`?`plan`:n?`work`:`todo`}function Wht(e,t){return e?.mergeStatus===`merged`?`Merged — ready to close out`:MZ(e)?`Review & tests passed — ready to merge`:e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`?t?.type===`work`?`Review blocked — work agent is fixing it`:`Review blocked — awaiting the work agent`:e?.testStatus===`testing`?`Tests running`:e?.verificationStatus===`running`?`Verification running`:t?`${t.label} agent is working`:`Idle — awaiting the pipeline`}function Ght(e){return e?e.mergeStatus===`merged`?`merged — close out`:MZ(e)?`merge to main`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?`work agent fixes → re-review`:e.reviewStatus===`reviewing`?`review in progress`:e.testStatus===`testing`?`test in progress`:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?`fix tests → re-run`:e.reviewStatus===`passed`&&e.testStatus!==`passed`&&e.testStatus!==`skipped`?`dispatch test`:`awaiting pipeline`:`start work`}function Kht(e,t,n,r,i,a,o){let s=a?.resolvedTotalCost??a?.totalCost??0;return{issueId:e,title:t,branch:n,projectName:r,phase:Uht(i,o),cost:s>0?`$${s.toFixed(2)}`:void 0}}function qht(e,t){let n=t.find(e=>e.active),r=(e?.history??[]).slice().sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()).slice(0,3).map(e=>({type:e.type,status:e.status,timestamp:e.timestamp}));return{now:Wht(e,n),nextAction:Ght(e),recentEvents:r}}function WZ(e,t){let n=e??`pending`;return{status:n,active:t,done:n===`passed`||n===`skipped`||n===`merged`||n===`completed`}}function Jht(e,t){let n=e?.mergeStatus===`merged`,r=t.some(e=>e.type===`planning`||e.type===`legacy`),i=t.some(e=>e.type===`work`||e.type===`strike`),a=r&&t.some(e=>(e.type===`planning`||e.type===`legacy`)&&jZ(e,void 0)),o=t.some(e=>(e.type===`work`||e.type===`strike`)&&jZ(e,void 0)),s=t.some(e=>(e.type===`review`||e.type===`reviewer`)&&jZ(e,void 0)),c=t.some(e=>e.type===`test`&&jZ(e,void 0)),l=e?.reviewStatus===`reviewing`||(e?.reviewStatus===void 0||e.reviewStatus===`pending`)&&s,u=e?.testStatus===`testing`||(e?.testStatus===void 0||e.testStatus===`pending`)&&c,d=e?.mergeStatus===`queued`||e?.mergeStatus===`merging`||e?.mergeStatus===`verifying`;return{plan:WZ(r?`passed`:`pending`,a),work:WZ(i?`passed`:`pending`,o),review:WZ(n?`passed`:e?.reviewStatus,l),test:WZ(n?`passed`:e?.testStatus,u),ship:WZ(n?`merged`:MZ(e)?`ready`:e?.mergeStatus??`pending`,d)}}function Yht(e){return e===`passed`||e===`failed`||e===`pending`||e===`running`||e===`skipped`||e===`infra-unavailable`?e:e===`testing`?`running`:`pending`}function GZ(e,t){let n=(t?.verificationNotes??``).match(/Verification FAILED at (typecheck|lint|test)\b/i),r=n?[`typecheck`,`lint`,`test`].indexOf(n[1].toLowerCase()):-1,i=[`typecheck`,`lint`,`test`].indexOf(e);return t?.verificationStatus===`passed`?`passed`:t?.verificationStatus===`failed`?r<0?`failed`:i<r?`passed`:i===r?`failed`:`pending`:t?.verificationStatus===`running`?i===0?`running`:`pending`:t?.verificationStatus===`skipped`?`skipped`:`pending`}function Xht(e,t){let n=e?.verificationCycleCount?`cycle ${e.verificationCycleCount}${e.verificationMaxCycles?`/${e.verificationMaxCycles}`:``}`:void 0,r=!t?.exists||t?.hasDocker===!1?`infra-unavailable`:Yht(e?.uatStatus),i=[{id:`typecheck`,label:`typecheck`,status:GZ(`typecheck`,e)},{id:`lint`,label:`lint`,status:GZ(`lint`,e)},{id:`test`,label:`test`,status:GZ(`test`,e)},{id:`uat`,label:`UAT`,status:r}];return{status:e?.verificationStatus??`pending`,cycle:n,gates:i}}function Zht(e){return e?.log?{startedAt:e.log.startedAt,updatedAt:e.log.updatedAt,step:e.log.step,lines:e.log.lines}:null}function Qht(e){return{sections:e?.sections??[],totalCost:e?.totalCost??0,aggregateCost:e?.aggregateCost??null}}function $ht(e){return{exists:e?.exists??!1,workspace:e}}function egt(e,t,n,r){let i=[];for(let n of e){let e=UZ(n,t);if((n.awaitingInput||Bht(e))&&i.push({kind:`awaiting_input`,sessionId:n.sessionId,prompt:n.awaitingInputPrompt??e?.pendingQuestionPrompt??e?.pendingAskUserQuestion?.questions[0]?.question,reason:n.awaitingInputReason??e?.pendingQuestionReason}),n.troubled||e?.troubled){let t=e?.troubledReason;i.push({kind:`troubled`,sessionId:n.sessionId,reason:n.troubledReason??t??e?.lastFailureReason})}(n.paused||e?.paused)&&i.push({kind:`paused`,sessionId:n.sessionId,reason:n.pausedReason??e?.pausedReason})}n?.stuck&&i.push({kind:`stuck`,reason:n.stuckReason??n.stuckDetails});let a=e.some(e=>(e.type===`review`||e.type===`reviewer`)&&e.presence===`active`);e.some(e=>e.type===`reviewer`&&e.presence===`ended`)&&!a&&(n?.reviewStatus===`pending`||n?.reviewStatus===`failed`)&&i.push({kind:`stale_review`,reason:`Leftover review specialist sessions must be cleared before a clean review can run.`}),n?.blockerReasons?.[0]&&i.push({kind:`blocker`,reason:n.blockerReasons[0].details??n.blockerReasons[0].summary});let o=new Set((r?.labels??[]).map(e=>e.toLowerCase()));r?.hasPlan===!0&&o.has(`ready`)&&!o.has(`released`)&&!o.has(`parked`)&&!o.has(`vetoed`)&&!o.has(`objection`)&&i.push({kind:`pickup_gate`,reason:`The plan is ready, but work cannot be picked up until an operator releases it.`}),MZ(n)&&i.push({kind:`ready_for_merge`});let s=e.find(e=>e.type===`work`||e.type===`strike`);s&&!jZ(s,UZ(s,t))&&n?.mergeStatus!==`merged`&&i.push({kind:`stopped`,sessionId:s.sessionId});let c=ght(i);return{needsYou:c[0]??null,needsYouItems:c}}function tgt(e,t,n,r,i,a,o,s,c,l,u){let d=(s?.sections??[]).map(Pht),f=d.map(e=>Hht(e,c,a));return{header:Kht(e,t,n,r,i,a,d),narrative:qht(i,f),pipeline:Jht(i,d),agents:f,verification:Xht(i,o),ship:NZ(i,Zht(l)),activity:Qht(s),resources:$ht(o),operator:egt(d,c,i,u)}}function ngt(e,t){let n=IZ(e),r=LZ(e),i=BZ(e),a=FZ(e),o=bht(e),s=Q(e=>e.agentsById),c=Q(dS)??[],l=(0,z.useMemo)(()=>c.find(t=>t.identifier.toLowerCase()===e.toLowerCase()),[e,c]);return(0,z.useMemo)(()=>tgt(e,t?.title,t?.branch,t?.projectName,n.data,r.data,i.data,a.data,s,o.data,l),[e,t?.title,t?.branch,t?.projectName,n.data,r.data,i.data,a.data,s,o.data,l])}var KZ=[`agent-row-caret`,`agent-row-icon`,`agent-row-label`,`agent-row-model`,`agent-row-status`,`agent-row-duration`,`agent-row-cost`,`agent-row-verdict`,`agent-row-context-menu`,`agent-row-paused-reason`],rgt=[`ship-progress-full`,`ship-progress-compact`,`ship-progress-steps`,`ship-progress-step`,`ship-progress-log`],qZ=[`verification-gates`,`verification-gate`],igt=[`beads-panel`,`beads-panel-compact`],JZ=[`active-agent-panel`,`active-agent-panel-header`,`active-agent-panel-resume`,`active-agent-panel-tell`];[...KZ,...rgt,...qZ,...igt,...JZ];var agt={passed:`border-success/40 bg-success/10 text-success-foreground`,failed:`border-destructive/40 bg-destructive/10 text-destructive-foreground`,running:`border-info/40 bg-info/10 text-info-foreground`,skipped:`border-muted text-muted-foreground`,pending:`border-muted text-muted-foreground`,"infra-unavailable":`border-muted text-muted-foreground`},YZ={passed:`pass`,failed:`fail`,running:`running`,skipped:`skipped`,pending:`pending`,"infra-unavailable":`unavailable`};function ogt({verification:e}){return(0,B.jsxs)(`section`,{"data-testid":`verification-gates`,"data-section":qZ[0],className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,B.jsxs)(`div`,{className:`mb-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:[`Verification Gates`,e.cycle?(0,B.jsx)(`span`,{className:`ml-2 normal-case`,children:e.cycle}):null]}),(0,B.jsx)(`div`,{className:`grid grid-cols-4 gap-[8px]`,children:e.gates.map(e=>(0,B.jsxs)(`div`,{"data-testid":`verification-gate-${e.id}`,"data-section":qZ[1],"data-gate-id":e.id,"data-gate-status":e.status,"aria-label":`${e.label}: ${YZ[e.status]}`,title:`${e.label}: ${YZ[e.status]}`,className:Kx(`rounded-[10px] border bg-background/45 px-[12px] py-[10px]`,agt[e.status]),children:[(0,B.jsx)(`div`,{className:`text-[14px] font-medium leading-none`,children:YZ[e.status]}),(0,B.jsx)(`div`,{className:`mt-[6px] font-mono text-[10px] uppercase leading-none text-muted-foreground`,children:e.label})]},e.id))})]})}function XZ({issueId:e}){let{verification:t}=ngt(e);return(0,B.jsx)(ogt,{verification:t})}var sgt={"WORK RUNNING":{label:`WORK RUNNING`,className:`badge-bg-info badge-border-info text-info-foreground`,pulse:!0},"REVIEW RUNNING":{label:`REVIEW RUNNING`,className:`badge-bg-warning badge-border-warning text-warning-foreground`,pulse:!0},"SHIP RUNNING":{label:`SHIP RUNNING`,className:`badge-bg-signal-review badge-border-signal-review text-signal-review-foreground`,pulse:!0},"STRIKE RUNNING":{label:`STRIKE RUNNING`,className:`border-[#ff6a00] bg-[#ff6a00]/15 text-[#ff6a00]`,pulse:!0},PLANNING:{label:`PLANNING`,className:`badge-bg-signal-review badge-border-signal-review text-signal-review-foreground`,pulse:!0},INPUT:{label:`INPUT`,className:`badge-bg-warning badge-border-warning text-warning-foreground`,pulse:!0},"READY TO MERGE":{label:`READY TO MERGE`,className:`badge-bg-success badge-border-success text-success-foreground`,pulse:!1},MERGED:{label:`MERGED`,className:`badge-bg-success badge-border-success text-success-foreground`,pulse:!1},"CHANGES REQUESTED":{label:`CHANGES REQUESTED`,className:`badge-bg-destructive badge-border-destructive text-destructive-foreground`,pulse:!1},"MERGE BLOCKED":{label:`MERGE BLOCKED`,className:`badge-bg-destructive badge-border-destructive text-destructive-foreground`,pulse:!1},"CI BLOCKED":{label:`CI BLOCKED`,className:`badge-bg-warning badge-border-warning text-warning-foreground`,pulse:!1},UNREACHABLE:{label:`UNREACHABLE`,className:`badge-bg-destructive badge-border-destructive text-destructive-foreground`,pulse:!1},"QUEUED FOR PLAN":{label:`QUEUED FOR PLAN`,className:`bg-transparent border-border text-muted-foreground`,pulse:!1},READY:{label:`READY`,className:`badge-bg-info badge-border-info text-info-foreground`,pulse:!1},STOPPED:{label:`STOPPED`,className:`bg-transparent border-muted-foreground/40 text-muted-foreground`,pulse:!1}},cgt={className:`badge-bg-destructive badge-border-destructive text-destructive-foreground`,pulse:!1};function ZZ(e){let t=e.variant===`STUCK · Nh`?{...cgt,label:`STUCK · ${e.hours}h`}:sgt[e.variant];return(0,B.jsxs)(`span`,{"data-component":`verb-badge`,"data-variant":e.variant,className:Kx(`inline-flex items-center gap-[5px] rounded-[var(--radius-sm)] border px-[6px] py-[2px] text-[10px] font-medium uppercase leading-none tracking-[0.05em]`,t.className,e.className),children:[t.pulse&&(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`h-[6px] w-[6px] rounded-full bg-current pulse`}),(0,B.jsx)(`span`,{children:t.label})]})}function lgt(e){let t=Date.now()-new Date(e).getTime();if(t<0)return`just now`;let n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);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 QZ(e){if(!e)return`Unknown`;let t=e.replace(/^(?:oai|cx|go)@/,``);return t.includes(`opus-5`)||t.includes(`opus.5`)?`Opus 5`:t.includes(`opus-4-8`)||t.includes(`opus-4.8`)?`Opus 4.8`:t.includes(`opus-4-7`)||t.includes(`opus-4.7`)?`Opus 4.7`:t.includes(`opus-4-6`)||t.includes(`opus-4.6`)?`Opus 4.6`:t.includes(`opus-4-5`)||t.includes(`opus-4.5`)?`Opus 4.5`:t.includes(`opus-4-1`)?`Opus 4.1`:t.includes(`opus-4`)||t.includes(`opus`)?`Opus 4`:t.includes(`sonnet-5`)||t.includes(`sonnet.5`)?`Sonnet 5`:t.includes(`sonnet-4-6`)||t.includes(`sonnet-4.6`)?`Sonnet 4.6`:t.includes(`sonnet-4-5`)||t.includes(`sonnet-4.5`)?`Sonnet 4.5`:t.includes(`sonnet-4`)||t.includes(`sonnet`)?`Sonnet 4`:t.includes(`haiku-4-5`)||t.includes(`haiku-4.5`)?`Haiku 4.5`:t.includes(`haiku-3`)?`Haiku 3`:t.includes(`haiku`)?`Haiku 4.5`:t.includes(`gpt-5.6-sol[372k]`)?`GPT-5.6 Sol 372K`:t.includes(`gpt-5.6-terra[372k]`)?`GPT-5.6 Terra 372K`:t.includes(`gpt-5.6-luna[372k]`)?`GPT-5.6 Luna 372K`:t.includes(`gpt-5.6-sol`)?`GPT-5.6 Sol`:t.includes(`gpt-5.6-terra`)?`GPT-5.6 Terra`:t.includes(`gpt-5.6-luna`)?`GPT-5.6 Luna`:t.includes(`gpt-5.5-pro`)?`GPT-5.5 Pro`:t.includes(`gpt-5.5`)?`GPT-5.5`:t.includes(`gpt-5.4-pro`)?`GPT-5.4 Pro`:t.includes(`gpt-5.4-mini`)?`GPT-5.4 Mini`:t.includes(`gpt-5.4`)?`GPT-5.4`:t.includes(`gpt-5.3-codex`)?`GPT-5.3 Codex`:t.includes(`gpt-5.3`)?`GPT-5.3`:t.includes(`gpt-5.2`)?`GPT-5.2`:t.includes(`gpt-5.1`)?`GPT-5.1`:t.includes(`gpt-5`)?`GPT-5`:t.includes(`gpt-4o`)?`GPT-4o`:t.includes(`gpt-4`)?`GPT-4`:t.includes(`gpt-3`)?`GPT-3`:t.includes(`o4-mini`)||t===`o4-mini`?`O4 Mini`:t.includes(`o3-mini`)?`O3 Mini`:t.includes(`o3`)?`O3`:t.includes(`o1`)?`O1`:t.includes(`gemini-3.1-pro-preview`)||t.includes(`gemini-3.1-pro`)?`Gemini 3.1 Pro`:t.includes(`gemini-3-flash`)?`Gemini 3 Flash`:t.includes(`gemini-3`)?`Gemini 3`:t.includes(`gemini-2.5`)?`Gemini 2.5`:t.includes(`gemini`)?`Gemini`:e}function ugt({agentId:e,isEffectivelyLive:t,className:n}){let[r,i]=(0,z.useState)(!1);return(0,B.jsx)(`div`,{"data-testid":`active-agent-panel-tell`,"data-section":JZ[3],className:n,children:(0,B.jsx)(AKe,{className:`mt-[10px] flex gap-[8px]`,sending:r,onSend:async n=>{if(r)return!1;i(!0);try{let r=t?`/api/agents/${e}/tell`:`/api/agents/${e}/resume`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:n})});if(!i.ok){let e=await i.text();return console.warn(`[tell-composer] send ${i.status} ${r}: ${e.slice(0,300)}`),!1}return!0}catch(e){return console.error(`[tell-composer] send error:`,e),!1}finally{i(!1)}},ariaLabel:`Tell ${e}`,placeholder:t?`Tell this agent...`:`Send a message to resume...`})})}function dgt(e,t){let n=e.firstFailureInRunAt??e.lastFailureAt??e.lastActivity??e.startedAt;if(!n)return 0;let r=new Date(n).getTime();return Number.isNaN(r)?0:Math.max(0,Math.floor((t.getTime()-r)/36e5))}function fgt(e){return e===`unknown`}function pgt(e,t){return e.troubled||e.status===`error`||fgt(e.status)?{variant:`STUCK · Nh`,hours:dgt(e,new Date),className:`text-[9px]`}:eGe(e,t)?{variant:`INPUT`,className:`text-[9px]`}:e.status===`stopped`?{variant:`STOPPED`,className:`text-[9px]`}:e.role===`plan`?{variant:`PLANNING`,className:`text-[9px]`}:e.role===`review`||e.role===`test`?{variant:`REVIEW RUNNING`,className:`text-[9px]`}:e.role===`ship`?{variant:`SHIP RUNNING`,className:`text-[9px]`}:e.role===`strike`?{variant:`STRIKE RUNNING`,className:`text-[9px]`}:{variant:`WORK RUNNING`,className:`text-[9px]`}}function mgt(e){return e===void 0?`loading`:e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:e>0?`$${e.toFixed(3)}`:`$0`}function $Z({agentId:e,density:t=`console`,className:n,title:r}){let i=Q(MNe(e)),a=Q(uS),o=lL(i?.issueId??``),s=i?.issueId?o.all.find(e=>e.action.key===`resumeSession`):void 0,c=t===`console`?`active-agent`:void 0,l=(0,B.jsxs)(`section`,{id:c,"data-testid":`active-agent-panel`,"data-section":JZ[0],className:Kx(`rounded-[var(--radius)] border border-border bg-card p-[14px]`,n),children:[(0,B.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:r??`Active Agent`}),(0,B.jsx)(`div`,{className:`rounded-[10px] border border-border bg-background/45 px-[12px] py-[14px] text-[12px] text-muted-foreground`,children:`No active agent.`})]});if(!i||fgt(i.status))return l;let u=`${QZ(i.model)} · ${Zv(i)} · spend ${mgt(i.costSoFar)}`,d=i.status===`running`||i.status===`starting`;return(0,B.jsxs)(`section`,{id:c,"data-testid":`active-agent-panel`,"data-section":JZ[0],className:Kx(`rounded-[var(--radius)] border border-border bg-card p-[14px]`,t===`console`&&`border-l-[3px] border-l-signal-review`,n),children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-[12px]`,"data-section":JZ[1],children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[8px]`,children:[(0,B.jsx)(`h3`,{className:`truncate font-mono text-[13px] font-semibold leading-none text-foreground`,children:i.id}),(0,B.jsx)(ZZ,{...pgt(i,a)})]}),(0,B.jsx)(`div`,{className:`mt-[6px] text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,children:i.status===`stopped`?`Stopped Agent — send a message to resume`:r??`Active Agent`})]}),(0,B.jsx)(`div`,{className:`shrink-0 text-right font-mono text-[10px] leading-none text-muted-foreground`,children:u})]}),!d&&s?.enabled&&(0,B.jsx)(`button`,{type:`button`,"data-testid":`active-agent-panel-resume`,"data-section":JZ[2],title:`Reopens the saved session with its memory intact.`,className:`mt-[10px] w-full rounded-[var(--radius-sm)] border border-primary/30 bg-primary/10 px-[12px] py-[8px] text-[12px] font-medium text-primary transition-colors hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>s.invoke(),disabled:s.isPending,children:s.isPending?`Resuming…`:`▶ Resume session · ${i.issueId}`}),i?.issueId&&(0,B.jsx)(dL,{issueId:i.issueId,actions:o}),(0,B.jsx)(ugt,{agentId:i.id,isEffectivelyLive:d})]})}function hgt(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.issueId==`string`&&!!t.state&&typeof t.state==`object`&&typeof t.state.ready==`boolean`&&typeof t.state.planned==`boolean`&&typeof t.state.parked==`boolean`&&typeof t.state.blocksMain==`boolean`&&typeof t.state.released==`boolean`&&typeof t.state.objection==`boolean`&&typeof t.gate==`string`&&(typeof t.planning==`string`||t.planning===null)&&typeof t.inSequence==`boolean`}var eQ={fontSize:10,textTransform:`uppercase`,letterSpacing:`0.1em`,color:`var(--muted-foreground)`,marginBottom:7},tQ={fontSize:12,color:`var(--muted-foreground)`,marginTop:7,lineHeight:1.45},ggt={interactive:`Interactive: a human drives planning — a HARD gate. The Flywheel surfaces it as needs-you and never auto-runs it.`,skip:`Skip: no planning — pan start --auto straight to work (trivial/tiny/urgent).`,auto:`Auto: the AI plans it end-to-end (pan plan --auto).`},_gt={ready:`Promote: jump the queue ahead of rank (and auto-plan it if it has no spec yet).`,blocked:`Vetoed: an absolute NO — never auto-picked, planned, or struck, even to unblock the pipeline.`,auto:`Auto: normal eligibility (Ready · Planned · Released · not parked · not vetoed).`};function vgt({value:e,options:t,onChange:n}){return(0,B.jsx)(`div`,{style:{display:`flex`,borderRadius:4,overflow:`hidden`,border:`1px solid var(--color-border)`},children:t.map(t=>{let r=e===t.value;return(0,B.jsx)(`button`,{onClick:()=>n(t.value),style:{flex:1,padding:`3px 6px`,fontSize:10,fontWeight:r?700:400,border:`none`,cursor:`pointer`,background:r?t.activeColor??`#3b82f6`:`var(--color-surface)`,color:r?`#fff`:`var(--color-fg-muted)`,transition:`all 0.15s`},children:t.label},t.value)})})}function nQ({label:e,hint:t,on:n,color:r,onChange:i}){return(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:12,margin:`9px 0`},children:[(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:12,fontWeight:500},children:e}),(0,B.jsx)(`div`,{style:{fontSize:10,color:`var(--muted-foreground)`,lineHeight:1.4,marginTop:2},children:t})]}),(0,B.jsx)(`button`,{onClick:()=>i(!n),"aria-pressed":n,style:{flexShrink:0,width:38,height:22,borderRadius:12,border:`none`,cursor:`pointer`,position:`relative`,background:n?`color-mix(in srgb, ${r} 60%, transparent)`:`var(--input)`,transition:`background 0.15s`},children:(0,B.jsx)(`span`,{style:{position:`absolute`,top:2,left:n?18:2,width:18,height:18,borderRadius:`50%`,background:`#fff`,transition:`left 0.15s`,boxShadow:`0 1px 2px rgba(0,0,0,0.4)`}})})]})}function rQ({issueId:e,onOpenIssueBrowser:t}){let n=yt(),{data:r,isLoading:i,error:a}=V({queryKey:[`backlog-issue-state`,e],queryFn:async()=>{let t=await fetch(`/api/backlog/issue-state?issueId=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(!hgt(n))throw Error(`Invalid pickup state response`);return n},staleTime:1e4}),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!1),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(`auto`),[b,x]=(0,z.useState)(`auto`);(0,z.useEffect)(()=>{if(!r)return;let e=r.state;l(e.ready),d(e.parked),p(e.blocksMain),h(e.released),_(e.objection),y(r.gate||`auto`),x(r.planning||`auto`)},[r]);let S=!!r?.state.planned,C=!!r?.inSequence;function w(){n.invalidateQueries({queryKey:[`backlog-issue-state`,e]}),n.invalidateQueries({queryKey:[`backlog-sequence`]})}async function T(t,n){t===`ready`&&l(n),t===`parked`&&d(n),t===`blocksMain`&&p(n),t===`released`&&h(n),t===`objection`&&_(n),s(!0);try{await fetch(`/api/backlog/sequence/labels`,{method:`POST`,headers:await sb(),body:JSON.stringify({issueId:e,[t]:n})}),w()}finally{s(!1)}}async function E(t){s(!0);try{await fetch(`/api/issues/${e}/start-planning`,{method:`POST`,headers:await sb(),body:JSON.stringify({auto:t===`auto`,autoStart:!1})}).catch(()=>{}),w()}finally{s(!1)}}async function D(){await T(`objection`,!1),await T(`parked`,!0)}async function O(t){y(t),s(!0);try{await fetch(`/api/backlog/sequence/gate`,{method:`POST`,headers:await sb(),body:JSON.stringify({issueId:e,gate:t})}),w()}finally{s(!1)}}async function k(t){x(t),s(!0);try{await fetch(`/api/backlog/sequence/planning`,{method:`POST`,headers:await sb(),body:JSON.stringify({issueId:e,planning:t})}),w()}finally{s(!1)}}let A={fontSize:11,fontWeight:500,padding:`5px 11px`,borderRadius:7,cursor:`pointer`,border:`1px solid var(--border)`,background:`var(--accent)`,color:`var(--foreground)`},j={...A,border:`none`,background:`var(--primary)`,color:`var(--primary-foreground)`},M={...A,border:`1px solid color-mix(in srgb, var(--destructive) 50%, transparent)`,background:`color-mix(in srgb, var(--destructive) 8%, transparent)`,color:`var(--destructive-foreground)`},N={fontSize:11,background:`none`,border:`none`,color:`var(--muted-foreground)`,textDecoration:`underline`,cursor:`pointer`,padding:2},P=e=>({fontSize:10,fontWeight:500,padding:`1px 7px`,borderRadius:5,border:`1px solid`,whiteSpace:`nowrap`,...e===`released`?{color:`var(--success-foreground)`,borderColor:`color-mix(in srgb, var(--success) 40%, transparent)`,background:`color-mix(in srgb, var(--success) 12%, transparent)`}:{color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 34%, transparent)`,background:`color-mix(in srgb, var(--info) 9%, transparent)`}});return i?(0,B.jsx)(QP,{label:`Pickup state`,timeoutMs:8e3,children:(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--muted-foreground)`},children:`Loading pickup state…`})}):a||!r?(0,B.jsx)(`div`,{style:{fontSize:11,color:`var(--destructive-foreground)`},children:a?String(a):`No pickup state`}):(0,B.jsxs)(`div`,{style:{color:`var(--foreground)`},children:[(0,B.jsxs)(`div`,{style:{marginBottom:13},children:[(0,B.jsxs)(`div`,{style:eQ,children:[`Plan → Release · operator (PAN-2059) `,o&&`…`]}),g?(0,B.jsxs)(`div`,{style:{border:`1px solid color-mix(in srgb, var(--destructive) 34%, transparent)`,background:`color-mix(in srgb, var(--destructive) 6%, transparent)`,borderRadius:9,padding:`10px 11px`},children:[(0,B.jsx)(`div`,{style:{fontSize:11.5,color:`var(--destructive-foreground)`,marginBottom:6},children:`🛑 Held for review — AI objection`}),(0,B.jsxs)(`div`,{style:{fontSize:11,color:`var(--muted-foreground)`,lineHeight:1.5,marginBottom:9},children:[`The planning agent objects to this work (doesn't make sense / would worsen the product / superseded).`,` `,t&&(0,B.jsx)(`button`,{style:{...N,padding:0},onClick:()=>t(e),children:`View the write-up on the issue ↗`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,B.jsx)(`button`,{style:M,onClick:()=>T(`objection`,!1),disabled:o,children:`Override → Plan anyway`}),(0,B.jsx)(`button`,{style:A,onClick:D,disabled:o,children:`Accept & park`})]})]}):S?m?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,flexWrap:`wrap`},children:[(0,B.jsx)(`span`,{style:P(`released`),children:`▶ released · pickable`}),(0,B.jsx)(`button`,{style:N,onClick:()=>T(`released`,!1),disabled:o,children:`Recall`})]}),(0,B.jsx)(`div`,{style:tQ,children:`Released — eligible for pickup. Recall pulls it back to planned (held).`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,flexWrap:`wrap`},children:[(0,B.jsx)(`span`,{style:P(`planned`),children:`✓ planned`}),(0,B.jsx)(`button`,{style:j,onClick:()=>T(`released`,!0),disabled:o,children:`Release ▶`}),(0,B.jsx)(`button`,{style:N,onClick:()=>E(`auto`),disabled:o,children:`Re-plan`})]}),(0,B.jsxs)(`div`,{style:tQ,children:[`Plan ready — review it, then `,(0,B.jsx)(`b`,{children:`Release`}),` for pickup. `,(0,B.jsx)(`b`,{children:`Not pickable until released.`})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,B.jsx)(`button`,{style:j,onClick:()=>E(`auto`),disabled:o,children:`Plan (Auto)`}),(0,B.jsx)(`button`,{style:A,onClick:()=>E(`interactive`),disabled:o,children:`⚑ Plan (Interactive)`})]}),(0,B.jsx)(`div`,{style:tQ,children:`Generates the xBRIEF + tasks. Auto runs end-to-end and stops before pickup; Interactive opens a Q&A session. The plan must be Released before an agent can pick it up.`})]})]}),(0,B.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:[(0,B.jsxs)(`div`,{style:eQ,children:[`Pipeline state · operator controls `,o&&`…`]}),(0,B.jsx)(nQ,{label:`Ready`,color:`var(--success)`,on:c,hint:`Definition of Ready — when off, the Flywheel won't auto-pick it (the entry gate).`,onChange:e=>T(`ready`,e)}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,margin:`9px 0`},children:[(0,B.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:`Planned`}),(0,B.jsx)(`span`,{style:{fontSize:10,fontWeight:500,padding:`1px 6px`,borderRadius:5,border:`1px solid`,...S?{color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 34%, transparent)`,background:`color-mix(in srgb, var(--info) 9%, transparent)`}:{color:`var(--warning-foreground)`,borderColor:`color-mix(in srgb, var(--warning) 34%, transparent)`,background:`color-mix(in srgb, var(--warning) 9%, transparent)`}},children:S?`✓ has spec + tasks`:`✗ no spec`}),(0,B.jsx)(`span`,{style:{fontSize:10,color:`var(--muted-foreground)`},children:`derived`})]}),(0,B.jsx)(nQ,{label:`Blocks main 🔴`,color:`var(--destructive)`,on:f,hint:`Flywheel prioritizes / strikes it even with auto-pickup off (never if vetoed).`,onChange:e=>T(`blocksMain`,e)}),(0,B.jsx)(nQ,{label:`Park`,color:`var(--warning)`,on:u,hint:`Defer — needs human design/discussion; excluded from auto-pickup, reversible.`,onChange:e=>T(`parked`,e)})]}),C?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:[(0,B.jsx)(`div`,{style:eQ,children:`Planning · AI-suggested, operator-overridable`}),(0,B.jsx)(vgt,{value:b,options:[{value:`skip`,label:`Skip`},{value:`auto`,label:`Auto`},{value:`interactive`,label:`⚑ Interactive`,activeColor:`#b45309`}],onChange:k}),(0,B.jsx)(`div`,{style:tQ,children:ggt[b]??``})]}),(0,B.jsxs)(`div`,{style:{marginBottom:4},children:[(0,B.jsxs)(`div`,{style:eQ,children:[`Pickup gate · operator `,o&&`…`]}),(0,B.jsx)(vgt,{value:v,options:[{value:`auto`,label:`Auto`},{value:`ready`,label:`📌 Promote`,activeColor:`#15803d`},{value:`blocked`,label:`⛔ Vetoed`,activeColor:`#b91c1c`}],onChange:O}),(0,B.jsx)(`div`,{style:tQ,children:_gt[v]??``})]})]}):(0,B.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,fontSize:11,color:`var(--muted-foreground)`,lineHeight:1.5},children:`Not in the ranked backlog yet — the planning-mode and promote/veto gate appear once a sequencer pass ranks it. The actions above still apply.`})]})}function iQ(e){return!e.running&&e.status?.toLowerCase().includes(`exited`)?e.lastFailureReason?`unhealthy`:`stopped`:e.health===`healthy`?`healthy`:e.health===`starting`?`starting`:e.health===`unhealthy`?`unhealthy`:e.running?e.health===`unknown`?`unknown`:`healthy`:e.lastFailureReason?`unhealthy`:`stopped`}function ygt(e){let t=iQ(e);return t===`stopped`&&e.status?e.status:t}function bgt(e){switch(iQ(e)){case`healthy`:return`text-success`;case`starting`:return`text-warning`;case`unhealthy`:return`text-destructive`;default:return`text-muted-foreground`}}function xgt(e){switch(iQ(e)){case`healthy`:return Z.uatStackContainerDotHealthy;case`starting`:return Z.uatStackContainerDotStarting;case`unhealthy`:return Z.uatStackContainerDotUnhealthy;default:return Z.uatStackContainerDotStopped}}function Sgt({status:e,pending:t}){let n=iQ(e);return t||n===`starting`?(0,B.jsx)(gc,{className:`h-3 w-3 animate-spin text-warning`}):n===`healthy`?(0,B.jsx)(us,{className:`h-3 w-3 text-success`}):n===`unhealthy`?(0,B.jsx)(sl,{className:`h-3 w-3 text-destructive`}):(0,B.jsx)(xs,{className:`h-3 w-3 text-muted-foreground`})}function aQ(e){let t=e.toLowerCase();return t.includes(`postgres`)||t.includes(`db`)?`postgres`:t.includes(`redis`)?`redis`:t.includes(`api`)?`api`:t.includes(`frontend`)||t.includes(`fe`)?`frontend`:t.includes(`server`)?`server`:e.replace(/^overdeck-feature-[^-]+-\d+-?/,``)}function Cgt([e]){let t=aQ(e),n=[`postgres`,`redis`,`api`,`frontend`,`server`].indexOf(t);return`${n===-1?99:n}:${t}:${e}`}function oQ(e){if(!e)return null;let t=new Date(e).getTime();if(Number.isNaN(t))return null;let n=Math.max(1,Math.round((Date.now()-t)/1e3));if(n<60)return`${n}s ago`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function wgt(e){let t=oQ(e.map(([,e])=>e.lastProbeAt).filter(e=>!!e).sort().at(-1));return t?t.replace(/\s+ago$/,``):null}function Tgt(e){if(e.uptime)return`Up ${e.uptime}`;if(e.status){let t=oQ(e.lastProbeAt);return t?`${e.status} ${t}`:e.status}return e.running?ygt(e):`not running`}function Egt({containers:e,stackHealth:t,pending:n,lifecycle:r=`active`}){if(r===`merged`||r===`idle`)return`stale`;let i=Object.entries(e??{});if(i.length===0&&t?.healthy===void 0&&!n)return null;if(n)return`starting`;if(i.length===0&&t?.stackExpected===!1)return`absent`;let a=i.map(([,e])=>iQ(e));return i.length>0&&a.every(e=>e===`stopped`)?`stopped`:a.includes(`starting`)?`starting`:a.includes(`unhealthy`)||t?.healthy===!1?`unhealthy`:t?.healthy===!0||i.length>0&&a.every(e=>e===`healthy`)?`healthy`:a.includes(`stopped`)?`stopped`:`healthy`}function sQ({containers:e,stackHealth:t,pending:n,lifecycle:r}){let i=Object.entries(e??{}),a=i.length,o=i.filter(([,e])=>iQ(e)===`healthy`).length,s=Egt({containers:e,stackHealth:t,pending:n,lifecycle:r});if(!s)return null;let c=s===`starting`||s===`unhealthy`;if(s===`stale`)return{label:`UAT stack merged · idle`,healthyCount:o,totalCount:a,active:!1,state:s};if(s===`absent`)return{label:`UAT stack not built`,healthyCount:o,totalCount:a,active:!1,state:s};if(s===`healthy`)return{label:a>0?`UAT stack ${o}/${a} healthy`:`UAT stack healthy`,healthyCount:o,totalCount:a,active:c,state:s};if(s===`starting`)return{label:a>0?`UAT stack ${o}/${a} healthy`:`UAT stack rebuilding`,healthyCount:o,totalCount:a,active:c,state:s};if(s===`unhealthy`)return{label:a>0?`UAT stack ${o}/${a} unhealthy`:`UAT stack unhealthy`,healthyCount:o,totalCount:a,active:c,state:s};let l=wgt(i);return{label:l?`UAT stack stopped ${l}`:`UAT stack stopped`,healthyCount:o,totalCount:a,active:c,state:s}}function Dgt({summary:e}){return e.state===`starting`?(0,B.jsx)(gc,{className:`h-3.5 w-3.5 animate-spin text-warning`}):e.state===`healthy`?(0,B.jsx)(us,{className:`h-3.5 w-3.5 text-success`}):e.state===`unhealthy`?(0,B.jsx)(sl,{className:`h-3.5 w-3.5 text-destructive`}):(0,B.jsx)(xs,{className:`h-3.5 w-3.5 text-muted-foreground`})}function Ogt(e){switch(e.state){case`healthy`:return`text-success`;case`starting`:return`text-warning`;case`unhealthy`:return`text-destructive`;default:return`text-muted-foreground`}}function cQ({containers:e,stackHealth:t,frontendUrl:n,apiUrl:r,pending:i,lifecycle:a=`active`,density:o=`full`,className:s=``}){let c=Object.entries(e??{}).sort((e,t)=>Cgt(e).localeCompare(Cgt(t))),l=sQ({containers:e,stackHealth:t,pending:i,lifecycle:a});if(!l)return null;let u=l.state===`unhealthy`||l.state===`starting`?t?.reasons?.[0]:void 0,d=o===`full`||i||l.state===`unhealthy`||l.state===`starting`,f=c.map(([,e])=>oQ(e.lastProbeAt)).find(Boolean);return o===`tree`?(0,B.jsxs)(`div`,{className:`${Z.uatStackTreeBody} ${s}`,"data-testid":`uat-stack-status`,children:[u&&(0,B.jsx)(`p`,{className:Z.uatStackTreeReason,children:u}),c.map(([e,t])=>(0,B.jsxs)(`div`,{className:Z.uatStackContainerRow,children:[(0,B.jsx)(`span`,{className:`${Z.uatStackContainerDot} ${xgt(t)}`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:Z.uatStackContainerName,title:e,children:aQ(e)}),(0,B.jsx)(`span`,{className:`${Z.uatStackContainerState} ${bgt(t)}`,children:Tgt(t)})]},e))]}):(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/20 p-2.5 text-xs ${s}`,"data-testid":`uat-stack-status`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(Dgt,{summary:l}),(0,B.jsx)(`span`,{className:`font-semibold ${Ogt(l)}`,children:l.label}),f&&(0,B.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`last probe `,f]}),n&&l.state===`healthy`&&(0,B.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`ml-auto inline-flex items-center gap-1 text-[11px] text-info-foreground hover:underline`,children:[`UAT `,(0,B.jsx)(Is,{className:`h-3 w-3`})]})]}),u&&(0,B.jsx)(`p`,{className:`mt-1.5 text-[11px] text-muted-foreground`,children:u}),d&&c.length>0&&(0,B.jsx)(`div`,{className:`mt-2 grid gap-1.5`,children:c.map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-2 rounded border border-border/70 bg-background/70 px-2 py-1.5`,children:[(0,B.jsx)(Sgt,{status:t,pending:i&&iQ(t)!==`healthy`}),(0,B.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,title:e,children:aQ(e)}),(0,B.jsx)(`span`,{className:`text-[11px] ${bgt(t)}`,children:ygt(t)}),(0,B.jsxs)(`span`,{className:`col-start-2 col-span-2 min-w-0 truncate text-[11px] text-muted-foreground`,children:[t.uptime?`Up ${t.uptime}`:t.status||`not running`,t.ports?.length?` · ports ${t.ports.join(`, `)}`:``,t.lastFailureReason?` · ${t.lastFailureReason}`:``]})]},e))}),o===`full`&&l.state!==`absent`&&(n||r)&&(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px]`,children:[n&&(0,B.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-info-foreground hover:underline`,children:[`Frontend `,(0,B.jsx)(Is,{className:`h-3 w-3`})]}),r&&(0,B.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-info-foreground hover:underline`,children:[`API `,(0,B.jsx)(Is,{className:`h-3 w-3`})]})]})]})}var kgt={"open-uat":{id:`open-uat`,label:`UAT`,icon:`external-link`,tone:`primary`},"open-api":{id:`open-api`,label:`API`,icon:`external-link`},logs:{id:`logs`,label:`Logs`,icon:`logs`},restart:{id:`restart`,label:`Restart`,icon:`rotate-ccw`},rebuild:{id:`rebuild`,label:`Rebuild`,icon:`hammer`},stop:{id:`stop`,label:`Stop`,icon:`square`},start:{id:`start`,label:`Start`,icon:`play`,tone:`primary`},"open-state-dir":{id:`open-state-dir`,label:`Open state dir`,icon:`folder`},"copy-stack-name":{id:`copy-stack-name`,label:`Copy stack name`,icon:`copy`},reap:{id:`reap`,label:`Reap`,icon:`trash`,tone:`danger`}};function lQ(e,t={}){return{...kgt[e],...t}}function uQ(e){let t=e.filter(e=>e.id!==`reap`),n=e.find(e=>e.id===`reap`);return n?[...t,{...n,tone:`danger`}]:t}function Agt(e,t=`active`){switch(t===`merged`?`stale`:e){case`healthy`:return{inline:[lQ(`open-uat`),lQ(`open-api`)],menu:uQ([lQ(`open-uat`),lQ(`open-api`),lQ(`logs`,{label:`View logs`}),lQ(`restart`),lQ(`rebuild`),lQ(`stop`),lQ(`open-state-dir`),lQ(`copy-stack-name`),lQ(`reap`)])};case`starting`:return{inline:[lQ(`logs`)],menu:uQ([lQ(`open-uat`),lQ(`open-api`),lQ(`logs`,{label:`View logs`}),lQ(`restart`),lQ(`rebuild`),lQ(`stop`),lQ(`open-state-dir`),lQ(`copy-stack-name`),lQ(`reap`)])};case`unhealthy`:return{inline:[lQ(`logs`,{tone:`primary`}),lQ(`rebuild`)],menu:uQ([lQ(`open-uat`),lQ(`open-api`),lQ(`logs`,{label:`View logs`,tone:`primary`}),lQ(`rebuild`),lQ(`restart`),lQ(`stop`),lQ(`open-state-dir`),lQ(`copy-stack-name`),lQ(`reap`)])};case`stopped`:return{inline:[lQ(`start`),lQ(`reap`)],menu:uQ([lQ(`logs`,{label:`View logs`}),lQ(`rebuild`),lQ(`open-state-dir`),lQ(`copy-stack-name`),lQ(`reap`)])};case`stale`:return{inline:[lQ(`reap`,{label:`Reap workspace`,tone:`primary`})],menu:uQ([lQ(`logs`,{label:`View logs`}),lQ(`start`),lQ(`open-state-dir`),lQ(`copy-stack-name`),lQ(`reap`,{label:`Reap workspace`})])};case`absent`:return{inline:[lQ(`rebuild`,{label:`Build stack`,tone:`primary`})],menu:uQ([lQ(`rebuild`,{label:`Build stack`}),lQ(`open-state-dir`),lQ(`copy-stack-name`),lQ(`reap`)])}}}function jgt(e,t){return Object.keys(t??{})[0]?.match(/^(.+)-[a-z0-9_]+-\d+$/i)?.[1]??`overdeck-feature-${e.toLowerCase()}`}function Mgt(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):e:{}}async function dQ(e,t){let n=t?.method?.toUpperCase(),r=!!n&&n!==`GET`&&n!==`HEAD`,i=await fetch(e,{...t,headers:{...r?await sb():{},...Mgt(t?.headers)}}),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(typeof a.error==`string`?a.error:`Request failed: ${i.status}`);return a}async function Ngt(){let e=await dQ(`/api/prereqs/enableHttps`);if(e.ready===!0)return;let t=Array.isArray(e.missing)?e.missing.filter(e=>typeof e==`string`):[],n=t.length>0?t.join(`, `):`Docker, Traefik, or HTTPS certificates`;throw Error(`UAT HTTPS setup is incomplete (${n}). Run pan install in a terminal; if Docker is missing, install/start Docker first, then run pan install again.`)}function Pgt({issueId:e,workspace:t,queryClient:n}){return async r=>{try{switch(r.id){case`open-uat`:if(!t?.frontendUrl)throw Error(`UAT frontend URL is not available`);await Ngt(),window.open(t.frontendUrl,`_blank`,`noopener,noreferrer`);return;case`open-api`:if(!t?.apiUrl)throw Error(`UAT API URL is not available`);await Ngt(),window.open(t.apiUrl,`_blank`,`noopener,noreferrer`);return;case`copy-stack-name`:{let n=jgt(e,t?.containers);await navigator.clipboard?.writeText(n),U.success(`Stack name copied`);return}case`logs`:{let t=await dQ(`/api/workspaces/${encodeURIComponent(e)}/stack-logs`),n=typeof t.logs==`string`?t.logs:``;await navigator.clipboard?.writeText(n),U.success(`UAT logs copied`);return}case`open-state-dir`:{let t=await dQ(`/api/workspaces/${encodeURIComponent(e)}/state-dir`),n=typeof t.path==`string`?t.path:``;if(!n)throw Error(`Workspace state directory is not available`);await navigator.clipboard?.writeText(n),U.success(`State dir path copied`);return}case`rebuild`:await dQ(`/api/workspaces/${encodeURIComponent(e)}/rebuild-stack`,{method:`POST`}),U.success(`Rebuilding UAT stack for ${e}`);break;case`restart`:await dQ(`/api/workspaces/${encodeURIComponent(e)}/stack/restart`,{method:`POST`}),U.success(`Restarting UAT stack for ${e}`);break;case`start`:await dQ(`/api/workspaces/${encodeURIComponent(e)}/stack/start`,{method:`POST`}),U.success(`Starting UAT stack for ${e}`);break;case`stop`:await dQ(`/api/workspaces/${encodeURIComponent(e)}/stack/stop`,{method:`POST`}),U.success(`Stopping UAT stack for ${e}`);break;case`reap`:if(!window.confirm(`Reap workspace for ${e}?\n\nThis tears down the workspace through the standard workspace teardown path. It does not use deep-wipe.`)){U.info(`Reap canceled`);return}await dQ(`/api/workspaces/${encodeURIComponent(e)}/reap`,{method:`POST`}),U.success(`Reaping workspace for ${e}`);break}await n.invalidateQueries({queryKey:[`workspace`,e]}),await n.invalidateQueries({queryKey:[`workspace-stack-health`]})}catch(e){U.error(e instanceof Error?e.message:`Failed to run ${r.label}`)}}}function Fgt(e){return e.tone===`primary`?`inline-flex items-center gap-1 rounded-[var(--radius-sm)] border border-info/40 bg-info/10 px-2 py-0.5 text-[11px] font-medium text-info-foreground transition-colors hover:bg-info/20`:e.tone===`danger`?`inline-flex items-center gap-1 rounded-[var(--radius-sm)] border border-destructive/40 px-2 py-0.5 text-[11px] text-destructive transition-colors hover:bg-destructive/10`:`inline-flex items-center gap-1 rounded-[var(--radius-sm)] border border-border px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-accent`}function Igt({issueId:e,className:t=``}){let n=BZ(e).data,r=yt(),[i,a]=(0,z.useState)(null);if(!n?.exists)return null;let o=sQ({containers:n.containers,stackHealth:n.stackHealth});if(!n.frontendUrl&&!n.apiUrl&&!o)return null;let s=n.frontendUrl?.replace(/^https?:\/\//,``),c=o?.state!==`absent`,l=o?Agt(o.state).inline.filter(e=>e.id!==`open-uat`&&e.id!==`open-api`):[],u=async t=>{a(t.id);try{await Pgt({issueId:e,workspace:n,queryClient:r})(t)}finally{a(null)}};return(0,B.jsxs)(`section`,{"data-section":`uat-environment`,"data-testid":`uat-environment-panel`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px] ${t}`,children:[(0,B.jsxs)(`div`,{className:`mb-[8px] flex items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`UAT environment`}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[l.map(e=>(0,B.jsxs)(`button`,{type:`button`,disabled:i!==null,"data-testid":`uat-panel-action-${e.id}`,className:Fgt(e),onClick:()=>void u(e),children:[i===e.id&&(0,B.jsx)(gc,{className:`h-3 w-3 animate-spin`}),e.label]},e.id)),n.apiUrl&&c&&(0,B.jsxs)(`a`,{href:n.apiUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-info-foreground hover:underline`,children:[`API `,(0,B.jsx)(Is,{className:`h-3 w-3`})]})]})]}),n.frontendUrl&&c&&(0,B.jsxs)(`a`,{href:n.frontendUrl,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${n.frontendUrl} to UAT this feature`,className:`mb-[10px] flex items-center gap-2 rounded-[var(--radius-sm)] border border-info/40 bg-info/10 px-3 py-2 text-[13px] font-medium text-info-foreground transition-colors hover:bg-info/20`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:s}),(0,B.jsx)(Is,{className:`ml-auto h-3.5 w-3.5 shrink-0`})]}),n.frontendUrl&&!c&&(0,B.jsx)(`div`,{title:`This will be the UAT URL once the stack is built`,className:`mb-[10px] flex items-center gap-2 rounded-[var(--radius-sm)] border border-border bg-muted/20 px-3 py-2 text-[13px] text-muted-foreground`,children:(0,B.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:s})}),(0,B.jsx)(cQ,{containers:n.containers,stackHealth:n.stackHealth,frontendUrl:n.frontendUrl,apiUrl:n.apiUrl,density:`full`})]})}var fQ=[`plan`,`work`,`review`,`test`,`ship`,`done`],Lgt={plan:`Plan`,work:`Work`,review:`Review`,test:`Test`,ship:`Ship`,done:`Done`};function pQ(e){return Lgt[e]}var mQ=`done`,hQ=`current`,gQ=`pending`,_Q=`attention`,Rgt={planning_active:{plan:hQ,work:gQ,review:gQ,test:gQ,ship:gQ,done:gQ},planning_done_awaiting_work:{plan:mQ,work:hQ,review:gQ,test:gQ,ship:gQ,done:gQ},in_progress_work_running:{plan:mQ,work:hQ,review:gQ,test:gQ,ship:gQ,done:gQ},in_progress_work_idle:{plan:mQ,work:hQ,review:gQ,test:gQ,ship:gQ,done:gQ},in_review_reviewers_running:{plan:mQ,work:mQ,review:hQ,test:gQ,ship:gQ,done:gQ},in_review_changes_requested:{plan:mQ,work:mQ,review:_Q,test:gQ,ship:gQ,done:gQ},in_review_approved:{plan:mQ,work:mQ,review:mQ,test:hQ,ship:gQ,done:gQ},testing_running:{plan:mQ,work:mQ,review:mQ,test:hQ,ship:gQ,done:gQ},testing_failures:{plan:mQ,work:mQ,review:mQ,test:_Q,ship:gQ,done:gQ},verification_failing:{plan:mQ,work:mQ,review:mQ,test:_Q,ship:gQ,done:gQ},ready_to_merge:{plan:mQ,work:mQ,review:mQ,test:mQ,ship:hQ,done:gQ},merging:{plan:mQ,work:mQ,review:mQ,test:mQ,ship:hQ,done:gQ},verifying:{plan:mQ,work:mQ,review:mQ,test:mQ,ship:hQ,done:gQ},merged:{plan:mQ,work:mQ,review:mQ,test:mQ,ship:mQ,done:hQ},done:{plan:mQ,work:mQ,review:mQ,test:mQ,ship:mQ,done:mQ},canceled:{plan:gQ,work:gQ,review:gQ,test:gQ,ship:gQ,done:gQ},generic:{plan:gQ,work:gQ,review:gQ,test:gQ,ship:gQ,done:gQ}};function vQ(e){return Rgt[e]}var zgt={planning_active:0,planning_done_awaiting_work:0,in_progress_work_running:1,in_progress_work_idle:1,in_review_reviewers_running:2,in_review_changes_requested:2,in_review_approved:2,testing_running:2,testing_failures:2,verification_failing:2,ready_to_merge:3,merging:3,verifying:3,merged:4,done:4,canceled:0,generic:0};function Bgt(e){return zgt[e]}function Vgt(e){let t=Rgt[e];for(let e of fQ)if(t[e]===`current`||t[e]===`attention`)return e;return null}var Hgt={done:`bg-success`,current:`bg-signal-review`,attention:`bg-destructive`,pending:`bg-muted opacity-60`},Ugt={done:`text-success-foreground`,current:`text-signal-review-foreground`,attention:`text-destructive-foreground`,pending:`text-muted-foreground`};function Wgt({rail:e,agents:t,meta:n,activePhase:r,onSelectPhase:i,className:a}){return(0,B.jsx)(`div`,{"data-component":`phase-rail`,className:Kx(`grid auto-cols-fr grid-flow-col overflow-hidden rounded-lg border border-border bg-card`,a),children:fQ.map((a,o)=>{let s=e[a],c=t?.[a],l=n?.[a]??(s===`done`?`done`:s===`current`?`in progress`:s===`attention`?`needs a look`:`queued`),u=!!i&&c?.hasConversation!==!1;return(0,B.jsxs)(`button`,{type:`button`,"data-phase":a,"data-state":s,disabled:!u,onClick:()=>u&&i?.(a),className:Kx(`relative min-w-0 px-3 pb-2 pt-2.5 text-left transition-colors`,o>0&&`border-l border-border`,u&&`hover:bg-accent`,r===a&&`bg-primary/8`,!u&&`cursor-default`),children:[(0,B.jsx)(`span`,{className:Kx(`absolute inset-x-0 top-0 h-0.5`,Hgt[s])}),(0,B.jsxs)(`span`,{className:Kx(`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em]`,Ugt[s]),children:[c?.live&&(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-info`}),pQ(a)]}),(0,B.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-muted-foreground`,children:l}),c&&(0,B.jsxs)(`span`,{className:`mt-0.5 block truncate font-mono text-[10px] text-muted-foreground`,children:[c.name,c.runtime?` · ${c.runtime}`:``]})]},a)})})}var Ggt={plan:`plan`,work:`work`,review:`review`,test:`test`,ship:`ship`};function Kgt(e){let t={};for(let n of e){let e=Ggt[n.role??``];if(!e)continue;let r=n.status===`running`||n.status===`starting`||n.status===`healthy`,i=t[e];(!i||r&&!i.live)&&(t[e]={name:n.id,model:n.model,runtime:n.runtime,live:r,hasConversation:!0})}return t}var qgt={planned:`plan`,implemented:`work`,reviewed:`review`,shipping:`ship`,merged:`done`};function Jgt({issueId:e,onSelectPhase:t,activePhase:n}){let r=Q(e=>e.drawer.issueId),{issue:i,agents:a,reviewStatus:o,phaseTimeline:s}=g5e(e??r)??{issue:null,agents:[],reviewStatus:void 0,phaseTimeline:[]},c=(0,z.useMemo)(()=>vQ(II({reviewStatus:o??null,agent:a.find(e=>![`stopped`,`failed`,`dead`].includes(e.status))??a[0]??null,hasPlan:i?.hasPlan===!0,hasTasks:i?.hasTasks===!0,issueCanonicalState:i?.state??i?.status??null,isMerged:o?.mergeStatus===`merged`})),[i,a,o]),l=(0,z.useMemo)(()=>{let e={test:`—`};for(let t of s){let n=qgt[t.id];n&&(e[n]=t.when)}return e},[s]);return(0,B.jsx)(`div`,{"data-testid":`drawer-phase-timeline`,children:(0,B.jsx)(Wgt,{rail:c,agents:Kgt(a),meta:l,onSelectPhase:t,activePhase:n})})}var Ygt={running:`bg-info animate-pulse`,done:`bg-success`,queued:`bg-muted-foreground/50`,failed:`bg-destructive`},Xgt={running:`Running`,done:`Done`,queued:`Queued`,failed:`Failed`};function Zgt({specialists:e,activeId:t,onSelect:n,className:r}){return e.length===0?null:(0,B.jsx)(`div`,{"data-component":`specialist-strip`,className:Kx(`flex gap-1.5`,r),children:e.map(e=>{let r=!!n&&e.hasConversation!==!1&&e.status!==`queued`,i=e.verdict===`APPROVED`?(0,B.jsx)(`span`,{className:`rounded-sm border border-success/30 bg-success/10 px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-success-foreground`,children:`Approved`}):e.verdict===`CHANGES_REQUESTED`?(0,B.jsx)(`span`,{className:`rounded-sm border border-destructive/30 bg-destructive/10 px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-destructive-foreground`,children:`Changes`}):(0,B.jsx)(`span`,{className:Kx(`rounded-sm border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,e.status===`running`?`border-warning/30 bg-warning/10 text-warning-foreground`:`border-border text-muted-foreground`),children:Xgt[e.status]});return(0,B.jsxs)(`button`,{type:`button`,"data-specialist":e.id,"data-status":e.status,disabled:!r,onClick:()=>r&&n?.(e),className:Kx(`grid min-w-0 flex-1 grid-cols-[auto_auto_1fr] items-center gap-x-1.5 rounded-lg border border-border bg-card px-2.5 py-1.5 text-left transition-colors`,r&&`hover:border-foreground/15`,t===e.id&&`border-primary/45 bg-primary/5`,!r&&`cursor-default opacity-80`),children:[(0,B.jsx)(`span`,{className:Kx(`h-2 w-2 rounded-full`,Ygt[e.status])}),(0,B.jsx)(`span`,{className:`truncate font-mono text-[11px]`,children:e.name}),(0,B.jsx)(`span`,{className:`justify-self-start`,children:i}),e.lastLine&&(0,B.jsx)(`span`,{className:`col-span-full mt-0.5 truncate text-[10px] text-muted-foreground`,children:e.lastLine})]},e.id)})})}var yQ=[`security`,`correctness`,`performance`,`requirements`],Qgt=/-review-([a-z]+)$/i;function $gt(e){let t=[];for(let n of e){let e=Qgt.exec(n.id);if(!e)continue;let r=e[1].toLowerCase();if(r===`supervisor`)continue;let i=n.status===`running`||n.status===`starting`||n.status===`healthy`;t.push({type:`reviewer`,role:r,sessionId:n.id,model:n.model??``,status:n.status===`error`||n.status===`failed`?`error`:i?`running`:`stopped`,presence:i?`active`:`ended`,startedAt:n.startedAt??``})}return t}function e_t(e){let t=e?.roundMetadata?.latestReviewResult;return t===`APPROVED`||t===`CHANGES_REQUESTED`?t:null}function t_t(e,t,n){if(t)return t.status===`error`||t.roundMetadata?.latestStatus===`failed`?`failed`:t.presence===`active`||t.presence===`idle`?`running`:`done`;let r=n?.[e];return r===`running`?`running`:r===`done`?`done`:`queued`}function n_t(e,t,n){if(t){let e=e_t(t),n=t.roundMetadata?.latestRound;return e===`APPROVED`?`approved${n?` · round ${n}`:``}`:e===`CHANGES_REQUESTED`?`changes requested${n?` · round ${n}`:``}`:t.presence===`active`||t.presence===`idle`?`reviewing now…`:`review complete`}let r=n?.[e];return r===`running`?`reviewing now…`:r===`done`?`review complete`:`starts when the convoy slot frees`}function r_t(e,t){let n=new Map;for(let t of e)t.type===`reviewer`&&t.role&&n.set(t.role,t);let r=t?.reviewSubStatuses,i=t?.reviewStatus;return[...new Set([...yQ,...n.keys(),...Object.keys(r??{})])].map(e=>{let t=n.get(e),a=r?.[e],o;return o=t?{id:e,name:`review.${e}`,status:t_t(e,t,r),verdict:e_t(t),lastLine:n_t(e,t,r),model:t?.model,hasConversation:!0}:a===`running`||a===`done`?{id:e,name:`review.${e}`,status:a===`running`?`running`:`done`,verdict:null,lastLine:a===`running`?`reviewing now…`:`review complete`,hasConversation:!1}:i===`passed`||i===`skipped`?{id:e,name:`review.${e}`,status:`done`,verdict:`APPROVED`,lastLine:`approved · convoy complete`,hasConversation:!1}:i===`failed`||i===`blocked`?{id:e,name:`review.${e}`,status:`failed`,verdict:`CHANGES_REQUESTED`,lastLine:`changes requested · convoy complete`,hasConversation:!1}:{id:e,name:`review.${e}`,status:`queued`,verdict:null,lastLine:`starts when the convoy slot frees`,hasConversation:!1},o}).sort((e,t)=>{let n=yQ.indexOf(e.id),r=yQ.indexOf(t.id);return(n===-1?99:n)-(r===-1?99:r)})}var i_t=new Set([`stopped`,`dead`,`failed`]);function a_t(e,t){let n=e.filter(e=>e.role===t);return n.find(e=>!i_t.has(e.status))??n.find(e=>e.id.endsWith(`-review-supervisor`))??n[0]}function o_t({issueId:e,agents:t,reviewStatus:n,reviewerSessions:r,activeAgentId:i,onOpenAgentConversation:a,onSelectPhase:o,className:s}){let c=(0,z.useMemo)(()=>r_t(r??$gt(t),n),[r,t,n]),l=(0,z.useMemo)(()=>{let e=t.find(e=>e.id===i)?.role;return e===`plan`||e===`work`||e===`review`||e===`test`||e===`ship`?e:null},[t,i]),u=(0,z.useMemo)(()=>{if(!i)return null;let e=/-review-([a-z]+)$/i.exec(i);return e?e[1].toLowerCase():null},[i]);return(0,B.jsxs)(`div`,{"data-component":`issue-detail-shell`,"data-section":`Pipeline Band`,className:s,children:[(0,B.jsx)(Jgt,{issueId:e??void 0,activePhase:l,onSelectPhase:o??(e=>{let n=a_t(t,e);n&&a(n.id)})}),c.length>0&&(0,B.jsx)(`div`,{className:`mt-2`,"data-section":`SpecialistStrip`,children:(0,B.jsx)(Zgt,{specialists:c,activeId:u,onSelect:e=>{let n=t.find(t=>t.id.toLowerCase().endsWith(`-review-${e.id.toLowerCase()}`));n&&a(n.id)}})})]})}var bQ={wrap:`_wrap_1xoim_5`,head:`_head_1xoim_13`,title:`_title_1xoim_14`,sum:`_sum_1xoim_15`,files:`_files_1xoim_17`,acts:`_acts_1xoim_18`,add:`_add_1xoim_19`,del:`_del_1xoim_20`,btn:`_btn_1xoim_22`,grid:`_grid_1xoim_25`,tree:`_tree_1xoim_28`,row:`_row_1xoim_32`,sel:`_sel_1xoim_39`,car:`_car_1xoim_40`,ftype:`_ftype_1xoim_41`,nm:`_nm_1xoim_42`,cnt:`_cnt_1xoim_43`,dirrow:`_dirrow_1xoim_44`,dirname:`_dirname_1xoim_45`,fileIndent:`_fileIndent_1xoim_46`,bar:`_bar_1xoim_48`,g:`_g_1xoim_25`,r:`_r_1xoim_32`,diff:`_diff_1xoim_53`,dhead:`_dhead_1xoim_54`,path:`_path_1xoim_56`,lines:`_lines_1xoim_59`,dl:`_dl_1xoim_60`,ln:`_ln_1xoim_61`,tx:`_tx_1xoim_62`,hunk:`_hunk_1xoim_67`,empty:`_empty_1xoim_70`,sub:`_sub_1xoim_71`,loading:`_loading_1xoim_72`},s_t={ts:`TS`,tsx:`TSX`,js:`JS`,jsx:`JSX`,mjs:`JS`,cjs:`JS`,json:`{}`,css:`CSS`,scss:`CSS`,md:`MD`,mdx:`MD`,yaml:`YML`,yml:`YML`,html:`HTM`,sh:`SH`,py:`PY`,go:`GO`,rs:`RS`,sql:`SQL`,toml:`TOM`,lock:`LCK`,png:`IMG`,jpg:`IMG`,jpeg:`IMG`,svg:`SVG`,gif:`IMG`};function c_t(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.includes(`.`)?t.slice(t.lastIndexOf(`.`)+1).toLowerCase():``;return s_t[n]??(n?n.slice(0,3).toUpperCase():`·`)}var l_t=e=>e.slice(e.lastIndexOf(`/`)+1),u_t=e=>{let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``};function d_t({add:e,del:t}){let n=e+t,r=n?Math.round(e/n*100):0;return(0,B.jsxs)(`span`,{className:bQ.bar,children:[(0,B.jsx)(`span`,{className:bQ.g,style:{width:`${r}%`}}),(0,B.jsx)(`span`,{className:bQ.r,style:{width:`${n?100-r:0}%`}})]})}function f_t(e){let t=new Map;if(!e)return t;let n=``,r=[];for(let i of e.split(`
|
|
658
658
|
`))if(i.startsWith(`diff --git `)){n&&t.set(n,r),r=[];let e=/\sb\/(.+)$/.exec(i);n=e?e[1]:``}else n&&r.push(i);return n&&t.set(n,r),t}function p_t(e){let t=[],n=0;for(let r of e)if(r.startsWith(`@@`)){let e=r.split(`@@`)[1]??``,i=/\+(\d+)/.exec(e);n=i?parseInt(i[1],10):n,t.push({kind:`hunk`,n:null,text:r})}else r.startsWith(`+`)&&!r.startsWith(`+++`)?t.push({kind:`add`,n:n++,text:r}):r.startsWith(`-`)&&!r.startsWith(`---`)?t.push({kind:`del`,n:null,text:r}):r.startsWith(`--- `)||r.startsWith(`+++ `)||r.startsWith(`index `)||r.startsWith(`new file`)||r.startsWith(`deleted file`)||r.startsWith(`rename `)||r.startsWith(`similarity `)||r.startsWith(`Binary `)||r.startsWith(`old mode`)||r.startsWith(`new mode`)||t.push({kind:`ctx`,n:n++,text:r});return t}function xQ({add:e,del:t}){return(0,B.jsxs)(`span`,{className:bQ.cnt,children:[e?(0,B.jsxs)(`span`,{className:bQ.add,children:[`+`,e]}):null,e&&t?` `:null,t?(0,B.jsxs)(`span`,{className:bQ.del,children:[`−`,t]}):null]})}function m_t({issueId:e}){let t=zZ(e),n=xht(e),r=t.data?.pr?.files??[],[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(new Set),c=i??r[0]?.path??null,l=(0,z.useMemo)(()=>{let e=new Map;for(let t of r){let n=u_t(t.path);e.has(n)||e.set(n,[]),e.get(n).push(t)}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[r]),u=(0,z.useMemo)(()=>f_t(n.data?.diff),[n.data?.diff]),d=(0,z.useMemo)(()=>c?p_t(u.get(c)??[]):[],[u,c]),f=r.find(e=>e.path===c);if(t.isLoading)return(0,B.jsx)(`div`,{className:bQ.wrap,children:(0,B.jsx)(`div`,{className:bQ.loading,children:`Loading changed files…`})});if(!t.data?.pr)return(0,B.jsx)(`div`,{className:bQ.wrap,children:(0,B.jsx)(`div`,{className:bQ.empty,children:`No pull request for this issue yet.`})});let p=t.data.pr.additions??r.reduce((e,t)=>e+t.additions,0),m=t.data.pr.deletions??r.reduce((e,t)=>e+t.deletions,0);return(0,B.jsxs)(`div`,{className:bQ.wrap,children:[(0,B.jsxs)(`div`,{className:bQ.head,children:[(0,B.jsx)(`span`,{className:bQ.title,children:`Changed files`}),(0,B.jsxs)(`span`,{className:bQ.sum,children:[(0,B.jsx)(`b`,{children:r.length}),` `,(0,B.jsx)(`span`,{className:bQ.files,children:`files`}),` · `,(0,B.jsxs)(`span`,{className:bQ.add,children:[`+`,p]}),` `,(0,B.jsxs)(`span`,{className:bQ.del,children:[`−`,m]})]}),(0,B.jsxs)(`span`,{className:bQ.acts,children:[(0,B.jsx)(`button`,{type:`button`,className:bQ.btn,onClick:()=>s(new Set(l.map(e=>e[0]).filter(Boolean))),children:`Collapse all`}),(0,B.jsx)(`button`,{type:`button`,className:bQ.btn,onClick:()=>s(new Set),children:`Expand all`}),t.data.pr.url&&(0,B.jsx)(`a`,{className:bQ.btn,href:t.data.pr.url,target:`_blank`,rel:`noreferrer`,children:`Open PR ↗`})]})]}),(0,B.jsxs)(`div`,{className:bQ.grid,children:[(0,B.jsxs)(`div`,{className:bQ.tree,children:[r.length===0&&(0,B.jsx)(`div`,{className:bQ.empty,children:`No files changed.`}),l.map(([e,t])=>{let n=o.has(e),r=t.reduce((e,t)=>e+t.additions,0),i=t.reduce((e,t)=>e+t.deletions,0);return(0,B.jsxs)(`div`,{children:[e&&(0,B.jsxs)(`button`,{type:`button`,className:`${bQ.row} ${bQ.dirrow}`,onClick:()=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[(0,B.jsx)(`span`,{className:bQ.car,children:n?`▸`:`▾`}),(0,B.jsx)(`span`,{className:bQ.ftype,children:`📁`}),(0,B.jsx)(`span`,{className:bQ.nm,children:(0,B.jsx)(`span`,{className:bQ.dirname,children:e})}),(0,B.jsx)(d_t,{add:r,del:i}),(0,B.jsx)(xQ,{add:r,del:i})]}),!n&&t.map(t=>(0,B.jsxs)(`button`,{type:`button`,className:`${bQ.row} ${e?bQ.fileIndent:``} ${t.path===c?bQ.sel:``}`,onClick:()=>a(t.path),title:t.path,children:[(0,B.jsx)(`span`,{className:bQ.car}),(0,B.jsx)(`span`,{className:bQ.ftype,children:c_t(t.path)}),(0,B.jsx)(`span`,{className:bQ.nm,children:l_t(t.path)}),(0,B.jsx)(d_t,{add:t.additions,del:t.deletions}),(0,B.jsx)(xQ,{add:t.additions,del:t.deletions})]},t.path))]},e||`__root`)})]}),(0,B.jsx)(`div`,{className:bQ.diff,children:c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:bQ.dhead,children:[(0,B.jsx)(`span`,{className:bQ.ftype,children:c_t(c)}),(0,B.jsx)(`span`,{className:bQ.path,children:c}),f&&(0,B.jsx)(xQ,{add:f.additions,del:f.deletions})]}),n.isLoading?(0,B.jsx)(`div`,{className:bQ.loading,children:`Loading diff…`}):d.length===0?(0,B.jsxs)(`div`,{className:bQ.empty,children:[`No text diff for this file`,(0,B.jsx)(`span`,{className:bQ.sub,children:`(binary, renamed, or no line changes)`})]}):(0,B.jsx)(`div`,{className:bQ.lines,children:d.map((e,t)=>{let n=e.kind===`hunk`?bQ.hunk:e.kind===`add`?bQ.add:e.kind===`del`?bQ.del:``;return(0,B.jsxs)(`div`,{className:`${bQ.dl} ${n}`,children:[(0,B.jsx)(`span`,{className:bQ.ln,children:e.n??``}),(0,B.jsx)(`span`,{className:bQ.tx,children:e.text})]},t)})})]}):(0,B.jsxs)(`div`,{className:bQ.empty,children:[`Select a file to view its diff`,(0,B.jsx)(`span`,{className:bQ.sub,children:`or “Open PR ↗” for the full review`})]})})]})]})}var h_t=[{id:`overview`,label:`Overview`},{id:`plan`,label:`Plan map`},{id:`tasks`,label:`Tasks`},{id:`session`,label:`Session`},{id:`activity`,label:`Activity`},{id:`files`,label:`Files`},{id:`artifacts`,label:`Artifacts`}],SQ=new Set([`session`,`conversation`,`terminal`]);function g_t({issueId:e}){return(0,B.jsx)(`section`,{"data-testid":`drawer-pickup-section`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:(0,B.jsx)(rQ,{issueId:e,onOpenIssueBrowser:e=>{let t=TO(e);t&&window.open(t,`_blank`,`noopener,noreferrer`)}})})}function __t(e){return V({queryKey:[`drawer-workspace`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}`);return t.ok?t.json():null},retry:!1})}function v_t({issueId:e}){let{data:t}=__t(e);return!t?.exists||!t.path?null:(0,B.jsxs)(`section`,{"data-testid":`drawer-workspace-section`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,B.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Workspace`}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-[12px]`,children:[(0,B.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[11px] leading-[18px] text-muted-foreground`,title:t.path,children:t.path}),(0,B.jsx)(`div`,{className:`shrink-0`,children:(0,B.jsx)(tL,{openInCwd:t.path})})]}),t.git?.branch&&(0,B.jsxs)(`div`,{"data-testid":`drawer-workspace-branch`,className:`mt-[6px] truncate font-mono text-[11px] leading-[16px] text-muted-foreground`,title:t.git.branch,children:[`⎇ `,t.git.branch]})]})}function y_t({issueId:e}){let{data:t}=__t(e),n=Object.entries(t?.containers??{});return t?.exists?(0,B.jsxs)(`div`,{"data-section":`DrawerResourcesFacet`,className:`shrink-0 border-l border-border bg-card/70 px-[14px] py-[10px]`,children:[(0,B.jsx)(`div`,{className:`mb-[6px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Resources`}),n.length>0?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:n.map(([e,t])=>(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,title:`${e}: ${t.status??(t.running?`running`:`stopped`)}${t.uptime?` · up ${t.uptime}`:``}`,children:[(0,B.jsx)(`span`,{"data-testid":`drawer-resource-dot-${e}`,className:Kx(`h-[7px] w-[7px] rounded-full`,t.running?t.health===`unhealthy`?`bg-destructive`:`bg-success`:`bg-muted-foreground/40`)}),(0,B.jsx)(`span`,{className:`font-mono`,children:e})]},e))}):(0,B.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Workspace on disk — no containers running.`})]}):null}function b_t(e){return e.replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function x_t({tab:e}){return(0,B.jsxs)(`div`,{"data-testid":`drawer-tab-panel-${e}`,className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px]`,children:[(0,B.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:b_t(e)}),(0,B.jsx)(`p`,{className:`text-[13px] leading-6 text-muted-foreground`,children:`This drawer section will appear here as data streams in.`})]})}function S_t({agents:e}){let t=e.filter(e=>e.paused===!0);if(t.length===0)return null;let n=async e=>{try{let t=await fetch(`/api/agents/${e}/unpause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to unpause agent`);U.success(`${e} unpaused — deacon resumes it on the next patrol`)}catch(e){U.error(e instanceof Error?e.message:`Failed to unpause agent`)}};return(0,B.jsx)(`div`,{"data-testid":`drawer-paused-banner`,className:`space-y-[6px] border-b border-border px-[22px] py-[10px]`,children:t.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-[10px] rounded-[var(--radius-sm)] border px-[12px] py-[8px] badge-border-warning badge-bg-warning`,children:[(0,B.jsx)(`span`,{className:`text-[14px] leading-none text-warning-foreground`,children:`⏸`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`text-[13px] font-medium text-warning-foreground`,children:[(0,B.jsx)(`span`,{className:`font-mono`,children:e.id}),` is paused`]}),e.pausedReason&&(0,B.jsx)(`div`,{className:`truncate text-[12px] text-warning-foreground/75`,title:e.pausedReason,children:e.pausedReason})]}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`drawer-unpause-${e.id}`,onClick:()=>void n(e.id),className:`inline-flex shrink-0 items-center gap-[4px] rounded-[var(--radius-sm)] border px-[10px] py-[5px] text-[12px] font-medium badge-border-warning text-warning-foreground transition-colors hover:bg-warning/20`,children:`▶ Unpause`})]},e.id))})}function C_t({tab:e,onSelectTab:t,tasksBadge:n}){return(0,B.jsx)(`nav`,{"data-component":`drawer-tabs`,"data-testid":`drawer-tabs`,className:`border-b border-border bg-background/95 px-[14px]`,role:`tablist`,"aria-label":`Issue drawer sections`,children:(0,B.jsx)(`div`,{className:`flex min-w-0 items-center overflow-x-auto`,children:h_t.map(r=>{let i=r.id===`session`?SQ.has(e):e===r.id;return(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-testid":`drawer-tab-${r.id}`,className:Kx(`relative flex shrink-0 items-center px-[14px] py-[10px] text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`text-foreground`),onClick:()=>t(r.id===`session`?e===`terminal`?`terminal`:`conversation`:r.id),children:[r.label,r.id===`tasks`?(0,B.jsx)(`span`,{"data-testid":`drawer-tab-tasks-count`,className:`ml-[6px] rounded-full bg-primary/15 px-[5px] py-[1px] font-mono text-[10px] leading-none text-primary`,children:n??`0/0`}):null,i?(0,B.jsx)(`span`,{"data-testid":`drawer-tab-active-underline`,className:`absolute bottom-0 left-[14px] right-[14px] h-[2px] bg-primary`}):null]},r.id)})})})}function w_t({issueId:e,density:t,agents:n,reviewStatus:r,tab:i,onSelectTab:a,tasksBadge:o,conversationHeight:s=420,showTabs:c=!0,className:l}){let[u,d]=(0,z.useState)(null),f=(0,z.useMemo)(()=>u&&n.some(e=>e.id===u)?u:jft(n)?.id??null,[u,n]),p=(0,B.jsx)(o_t,{issueId:e,agents:n,reviewStatus:r,activeAgentId:i===`conversation`||i===`session`?f:null,onOpenAgentConversation:e=>{d(e),a(`conversation`)}}),m=(t,r)=>(0,B.jsx)(`div`,{"data-section":`DrawerAgentSession`,className:`flex min-h-0 flex-1 flex-col`,children:(0,B.jsx)(Nft,{view:t,agents:n,agentId:f,onSelectAgent:d,onChangeView:r,issueId:e})}),h=m(`conversation`);return t===`rail`?(0,B.jsxs)(`div`,{"data-component":`issue-detail`,"data-density":`rail`,className:l,children:[(0,B.jsx)(`div`,{"data-section":`PhaseTimeline`,children:p}),(0,B.jsx)(`div`,{className:`mt-2 min-h-0 overflow-hidden`,style:{height:s},children:h}),(0,B.jsx)(`div`,{className:`mt-2`,"data-section":`IssueDetailActionStrip`,children:(0,B.jsx)(fL,{issueId:e,mode:`primary-strip`,className:`flex items-center gap-1`})})]}):(0,B.jsxs)(`div`,{"data-component":`issue-detail`,"data-density":t,className:Kx(`flex min-h-0 flex-1 flex-col`,l),children:[(0,B.jsx)(`div`,{"data-section":`DrawerPausedBanner`,children:(0,B.jsx)(S_t,{agents:n})}),c&&(0,B.jsx)(`div`,{"data-section":`DrawerTabs`,children:(0,B.jsx)(C_t,{tab:i,onSelectTab:a,tasksBadge:o})}),(0,B.jsx)(`div`,{"data-section":`PhaseTimeline`,className:`px-[22px] pt-[10px]`,children:p}),(0,B.jsxs)(`div`,{className:Kx(`grid min-h-0 flex-1`,t===`page`?`grid-cols-[minmax(0,1fr)_360px]`:`grid-cols-[minmax(0,1fr)_320px]`),children:[(0,B.jsx)(`div`,{className:Kx(`flex min-w-0 flex-col`,SQ.has(i)?`min-h-0 p-[14px]`:`overflow-auto px-[22px] py-[18px]`),children:i===`overview`?(0,B.jsxs)(`div`,{"data-testid":`drawer-tab-panel-overview`,className:`space-y-[14px]`,children:[(0,B.jsx)(`div`,{"data-section":`DrawerPickupSection / PickupGateControls`,children:(0,B.jsx)(g_t,{issueId:e})}),(0,B.jsx)(`div`,{"data-section":`DrawerWorkspaceSection`,children:(0,B.jsx)(v_t,{issueId:e})}),(0,B.jsx)(`div`,{"data-section":`UatEnvironmentPanel`,children:(0,B.jsx)(Igt,{issueId:e})}),(0,B.jsx)(`div`,{"data-section":`DrawerActiveAgent`,children:(0,B.jsx)($Z,{agentId:f??``,density:`console`})}),(0,B.jsx)(`div`,{"data-section":`DrawerTasksList`,children:(0,B.jsx)(tF,{issueId:e})})]}):i===`tasks`?(0,B.jsx)(`div`,{"data-testid":`drawer-tab-panel-tasks`,"data-section":`DrawerTasksList`,children:(0,B.jsx)(tF,{issueId:e})}):i===`plan`?(0,B.jsx)(`div`,{"data-section":`DrawerPlanPanel / XBriefViewer`,children:(0,B.jsx)(Dht,{issueId:e})}):i===`activity`?(0,B.jsx)(`div`,{"data-section":`DrawerActivityRail / DrawerActivityPanel`,children:(0,B.jsx)(Eht,{})}):i===`artifacts`?(0,B.jsx)(`div`,{"data-section":`DrawerArtifactsPanel`,children:(0,B.jsx)(Uft,{issueId:e})}):i===`files`?(0,B.jsx)(`div`,{"data-testid":`drawer-tab-panel-files`,"data-section":`ChangedFilesView`,children:(0,B.jsx)(m_t,{issueId:e})}):SQ.has(i)?m(i===`terminal`?`terminal`:`conversation`,a):(0,B.jsx)(x_t,{tab:i})}),(0,B.jsxs)(`div`,{"data-section":`DrawerActivityRail / DrawerActivityPanel`,className:`flex min-h-0 flex-col`,children:[(0,B.jsx)(`div`,{"data-section":`DrawerVerificationGates`,className:`shrink-0 border-l border-border bg-card/70 p-[10px]`,children:(0,B.jsx)(XZ,{issueId:e})}),(0,B.jsx)(y_t,{issueId:e}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(Lft,{})})]})]})]})}function T_t(e){return e.length===0?`0/0`:`${e.filter(e=>e.status===`done`).length}/${e.length}`}function E_t(){let e=Q(e=>e.drawer),t=Q(e=>e.closeIssue),n=Q(e=>e.setDrawerTab),r=Q(e=>e.syncDrawerFromUrl),{issue:i,agents:a,reviewStatus:o,tasks:s}=_L();return(0,z.useEffect)(()=>{r()},[r]),(0,z.useEffect)(()=>{if(!e.issueId)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,e.issueId]),(0,z.useEffect)(()=>{if(!e.issueId)return;let t=null,n=0,r=()=>{if(window.location.hash!==`#active-agent`)return;let e=document.getElementById(`active-agent`);if(e){e.scrollIntoView({block:`start`});return}n++,n<30&&(t=window.requestAnimationFrame(r))},i=()=>{t&&=(window.cancelAnimationFrame(t),null),n=0,r()};return i(),window.addEventListener(`hashchange`,i),()=>{window.removeEventListener(`hashchange`,i),t&&window.cancelAnimationFrame(t)}},[e.issueId]),e.issueId?(0,B.jsx)(`div`,{"data-component":`issue-drawer`,"data-testid":`issue-drawer-scrim`,className:`fixed inset-0 z-[100] flex justify-end bg-black/20 backdrop-blur-[2px]`,onClick:t,children:(0,B.jsx)(`aside`,{role:`dialog`,"aria-modal":`true`,"aria-label":i?`Issue ${i.identifier}`:`Issue ${e.issueId}`,"data-testid":`issue-drawer`,className:`flex h-screen w-[min(980px,calc(100vw-48px))] max-w-[calc(100vw-48px)] origin-right scale-100 flex-col overflow-hidden border-l border-border bg-background opacity-100 shadow-[-24px_0_64px_rgb(0_0_0_/_40%)] animate-[issue-drawer-slide-in_200ms_ease-in-out]`,onClick:e=>e.stopPropagation(),children:(0,B.jsxs)(VZ,{issueId:e.issueId,density:`console`,className:`contents`,children:[(0,B.jsxs)(`header`,{"data-section":`Header bar`,className:`flex h-[52px] items-center gap-[12px] border-b border-border px-[22px]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground`,children:e.issueId}),(0,B.jsx)(`h2`,{className:`truncate font-display text-[22px] font-semibold leading-none tracking-[-0.01em] text-foreground`,children:i?.title??`Issue details`})]}),(()=>{let t=TO(e.issueId??``,i?.url);return t?(0,B.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e.issueId} on its tracker`,className:`inline-flex items-center gap-[6px] rounded-[var(--radius-sm)] border border-border px-[10px] py-[6px] text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,B.jsx)(Is,{className:`h-[14px] w-[14px]`}),`Issue`]}):null})(),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Close issue drawer`,className:`rounded-[var(--radius-sm)] border border-border px-[10px] py-[6px] text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:t,children:`×`})]}),(0,B.jsx)(w_t,{issueId:e.issueId,density:`drawer`,agents:a,reviewStatus:o,tab:e.tab,onSelectTab:e=>n(e),tasksBadge:T_t(s)}),(0,B.jsx)(`div`,{"data-section":`DrawerActionBar`,children:(0,B.jsx)(_5e,{})})]})})}):null}var D_t=`overdeck:convo-dock`;function O_t(){try{let e=localStorage.getItem(D_t);if(e){let t=JSON.parse(e);if(Array.isArray(t.items))return{items:t.items.slice(0,8),expanded:t.expanded!==!1}}}catch{}return{items:[],expanded:!1}}function CQ(e){try{localStorage.setItem(D_t,JSON.stringify({items:e.items,expanded:e.expanded}))}catch{}}var wQ=tS(e=>({...O_t(),add:t=>e(e=>{let n={items:[{issueId:t,addedAt:Date.now()},...e.items.filter(e=>e.issueId!==t)].slice(0,8),expanded:!0};return CQ(n),n}),remove:t=>e(e=>{let n={items:e.items.filter(e=>e.issueId!==t),expanded:e.expanded};return CQ(n),n}),setExpanded:t=>e(e=>{let n={...e,expanded:t};return CQ(n),n})}));function k_t({item:e,needsYou:t,onClose:n}){let r=Q(e=>e.issuesRaw),[i,a]=(0,z.useState)(null);if(e.type===`conversation`){let n=(r??[]).find(t=>t.identifier.toLowerCase()===e.issueId.toLowerCase());return(0,B.jsxs)(`div`,{className:Kx(`rounded-xl border bg-card shadow-sm`,t?`border-warning/40`:`border-border`),"data-dock-panel":`conv-${e.conversationName}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[t&&(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 flex-none animate-pulse rounded-full bg-warning`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate font-mono text-[11px]`,children:e.conversationName}),(0,B.jsxs)(`div`,{className:`truncate text-[10.5px] text-muted-foreground`,children:[e.issueId,n?` · ${n.title}`:``]})]})]}),(0,B.jsx)(`div`,{className:`h-[420px] border-t border-border p-2`,children:(0,B.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-xs text-muted-foreground`,children:[(0,B.jsx)(`div`,{children:`Pending conversation`}),(0,B.jsx)(`div`,{className:`text-[10px] mt-1`,children:`Answer from Needs You strip`})]})})]})}let o=e.agents,s=i&&o.some(e=>e.id===i)?i:jft(o)?.id??null,c=(r??[]).find(t=>t.identifier.toLowerCase()===e.issueId.toLowerCase());return(0,B.jsxs)(`div`,{className:Kx(`rounded-xl border bg-card shadow-sm`,t?`border-warning/40`:`border-border`),"data-dock-panel":e.issueId,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[t&&(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 flex-none animate-pulse rounded-full bg-warning`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate font-mono text-[11px]`,children:s??`no agent`}),(0,B.jsxs)(`div`,{className:`truncate text-[10.5px] text-muted-foreground`,children:[e.issueId,c?` · ${c.title}`:``]})]}),(0,B.jsx)(`button`,{onClick:n,className:`flex-none text-muted-foreground hover:text-foreground`,"aria-label":`Close ${e.issueId}`,children:(0,B.jsx)(sl,{size:13})})]}),(0,B.jsx)(`div`,{className:`h-[420px] border-t border-border p-2`,children:(0,B.jsx)(Nft,{view:`conversation`,agents:o,agentId:s,onSelectAgent:a,issueId:e.issueId})})]})}function A_t(){let{items:e,expanded:t,remove:n,setExpanded:r}=wQ(),i=jG(),a=Q(e=>e.agentsById),o=Q(e=>e.issuesRaw),s=(0,z.useMemo)(()=>new Set((i??[]).map(e=>e.issueId?.toLowerCase()).filter(Boolean)),[i]),c=(0,z.useMemo)(()=>{let t=o??[],n=Object.values(a??{}),r=new Map;for(let e of n){let t=e.issueId?.toLowerCase();if(!t)continue;let n=r.get(t)??[];n.push(e),r.set(t,n)}let s=new Map;for(let e of i??[])if(e.pendingAskUserQuestion&&e.issueId&&!r.has(e.issueId.toLowerCase())){let t=e.issueId.toLowerCase(),n=s.get(t)??[];n.push({agentId:e.agentId,issueId:e.issueId}),s.set(t,n)}let c=[],l=new Set;for(let n of e){let e=n.issueId.toLowerCase();if(t.find(t=>t.identifier.toLowerCase()===e))if(s.has(e)){let t=s.get(e)??[];for(let e of t)c.push({type:`conversation`,conversationName:e.agentId,issueId:e.issueId});l.add(e)}else c.push({type:`issue`,issueId:n.issueId,agents:r.get(e)??[]})}for(let[e,n]of s.entries())if(!l.has(e)&&t.find(t=>t.identifier.toLowerCase()===e))for(let e of n)c.push({type:`conversation`,conversationName:e.agentId,issueId:e.issueId});return c},[e,i,a,o]),l=(0,z.useMemo)(()=>[...c].sort((e,t)=>{let n=(e.type,e.issueId),r=(t.type,t.issueId);return Number(s.has(r.toLowerCase()))-Number(s.has(n.toLowerCase()))||(e.type===`conversation`)-+(t.type===`conversation`)}),[c,s]);return t?(0,B.jsxs)(`aside`,{"data-component":`conversation-dock`,className:`fixed bottom-0 right-0 top-12 z-40 flex w-[340px] flex-col border-l border-border bg-background/95 shadow-[-16px_0_48px_rgb(0_0_0/30%)] backdrop-blur`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-4 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-[13px] font-medium`,children:`Conversations`}),s.size>0&&(0,B.jsxs)(`span`,{className:`rounded-sm border border-warning/30 bg-warning/10 px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-warning-foreground`,children:[s.size,` needs you`]}),(0,B.jsx)(`button`,{onClick:()=>r(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,"aria-label":`Collapse dock`,children:(0,B.jsx)(sl,{size:14})})]}),(0,B.jsxs)(`div`,{className:`flex-1 space-y-2 overflow-y-auto p-2.5`,children:[l.length===0&&(0,B.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-[11px] text-muted-foreground`,children:`Nothing docked. Hover an issue and "pop into dock" — conversations stay with you while you navigate.`}),l.map(e=>{let t=(e.type,e.issueId),r=e.type===`conversation`?`${e.issueId}-${e.conversationName}`:e.issueId;return(0,B.jsx)(k_t,{item:e,needsYou:s.has(t.toLowerCase()),onClose:()=>{e.type===`issue`&&n(e.issueId)}},r)})]})]}):(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),"data-component":`conversation-dock-handle`,className:`fixed bottom-6 right-0 z-40 flex items-center gap-1.5 rounded-l-lg border border-r-0 border-border bg-card px-2.5 py-2 text-[11px] text-muted-foreground shadow-lg hover:text-foreground`,children:[(0,B.jsx)(xc,{size:13}),c.length>0&&(0,B.jsx)(`span`,{className:`font-mono text-[10px]`,children:c.length})]})}async function TQ(e,t){let n=await fetch(e,{method:`POST`,credentials:`include`,headers:await sb(),body:t===void 0?`{}`:JSON.stringify(t)});if(!n.ok){let e=await n.text(),t=`Request failed (${n.status})`;try{t=JSON.parse(e).error||t}catch{}throw Error(t)}return n.json().catch(()=>null)}var j_t={resumable:{title:e=>`${e.agentId} has a saved session`,body:`Resume it to continue with its memory intact, or start fresh (for example to switch model).`,primary:`Resume session`},troubled:{title:e=>`${e.agentId} is troubled${e.detail?` (${e.detail})`:``}`,body:`The deacon quarantined this agent after repeated failures — starting it is blocked until the gate is cleared. Clear the gate and start again?`,primary:`Clear gate & start`},paused:{title:e=>`${e.agentId} is paused${e.detail?` (${e.detail})`:``}`,body:`This agent was deliberately paused — starting it is blocked until it is unpaused. Unpause and start it?`,primary:`Unpause & start`},"live-session":{title:e=>`${e.agentId} is still running`,body:`Restarting it (for example with a different model) requires stopping it first. The workspace, plan, and branch are kept.`,primary:`Stop & restart`}};function M_t(){let e=rL(e=>e.request),t=rL(e=>e.closeRecovery),n=rL(e=>e.openRecovery),r=yt(),i=dl(),[a,o]=(0,z.useState)(null);if(!e)return null;let{agentId:s,issueId:c,kind:l}=e,u=j_t[l],d=e=>{o(null),i({message:e instanceof Error?e.message:`Recovery failed`,variant:`error`})},f=async()=>{if(!c)return!1;let e=await fetch(`/api/agents`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({issueId:c})});if(e.ok)return!1;let t=await e.json().catch(()=>null),r=e.status===409?aL(t):null;if(r)return o(null),n({...r,issueId:c}),!0;throw Error(t?.error||`Request failed (${e.status})`)};return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center bg-black/40`,onClick:t,children:(0,B.jsxs)(`div`,{role:`dialog`,"aria-label":u.title(e),"data-testid":`resumable-session-dialog`,"data-kind":l,className:`w-full max-w-md rounded-lg border border-border bg-popover p-4 text-sm text-popover-foreground shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`h3`,{className:`font-medium`,children:[(0,B.jsx)(`span`,{className:`font-mono`,children:s}),u.title(e).slice(s.length)]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Close`,className:`text-muted-foreground hover:text-foreground`,onClick:t,children:(0,B.jsx)(sl,{size:16})})]}),(0,B.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:u.body}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,"data-testid":`recovery-primary`,onClick:async()=>{o(`primary`);try{if(l===`live-session`){let t=await fetch(`/api/agents/${encodeURIComponent(s)}`,{method:`DELETE`,credentials:`include`,headers:await sb()});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||`Failed to stop ${s}`)}e.retry?(await TQ(e.retry.url,e.retry.body??{}),U.success(`${s} stopped — restarting`)):U.success(`${s} stopped`)}else if(l===`resumable`)await TQ(`/api/agents/${encodeURIComponent(s)}/resume`),oL(s);else if(l===`troubled`){if(await TQ(`/api/agents/${encodeURIComponent(s)}/untroubled`),await f())return;U.success(c?`${s} gate cleared — starting`:`${s} gate cleared`)}else if((await TQ(`/api/agents/${encodeURIComponent(s)}/unpause`))?.resumeTriggered===!0)U.success(`${s} unpaused — resuming now`);else{if(await f())return;U.success(c?`${s} unpaused — starting`:`${s} unpaused`)}t(),await nL(r)}catch(e){d(e)}},disabled:!!a,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-opacity disabled:opacity-50`,children:[a===`primary`?(0,B.jsx)(gc,{size:13,className:`animate-spin`}):l===`resumable`?(0,B.jsx)(Ac,{size:13}):l===`live-session`?(0,B.jsx)($c,{size:13}):(0,B.jsx)(Kc,{size:13}),l===`live-session`&&!e.retry?`Stop agent`:u.primary]}),l===`resumable`&&(0,B.jsxs)(`button`,{type:`button`,"data-testid":`recovery-start-fresh`,onClick:async()=>{o(`fresh`);try{if(await TQ(`/api/agents/${encodeURIComponent(s)}/reset-session`),await f())return;U.success(c?`${s} reset — fresh session starting`:`${s} session memory discarded`),t(),await nL(r)}catch(e){d(e)}},disabled:!!a,className:`inline-flex items-center gap-1.5 rounded-md border border-input px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,children:[a===`fresh`?(0,B.jsx)(gc,{size:13,className:`animate-spin`}):(0,B.jsx)(Pc,{size:13}),`Start fresh`]}),(0,B.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto rounded-md px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground`,children:`Cancel`})]}),a&&(0,B.jsx)(`p`,{"data-testid":`recovery-pending-hint`,className:`mt-3 text-[11px] leading-4 text-muted-foreground`,children:`Starting can take a few minutes when the workspace docker stack needs to come up. Closing this won't stop it.`})]})})}function N_t(e,t){let n=e instanceof Date?e:new Date(e),r=t.getTime()-n.getTime();if(r<=3e5)return`Just Now`;if(F_t(n,t))return I_t(n);let i=new Date(t);return i.setDate(t.getDate()-1),F_t(n,i)?`Yesterday ${L_t(n)} · ${I_t(n)}`:r>=0&&r<=10080*60*1e3?`${R_t(n)} ${L_t(n)}`:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...n.getFullYear()===t.getFullYear()?{}:{year:`numeric`}})}function P_t(e,t){let n=[];for(let r of e){let e=t(r),i=n.at(-1);i?.label===e?i.items.push(r):n.push({label:e,items:[r]})}return n}function F_t(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function I_t(e){return e.toLocaleTimeString(`en-US`,{hour:`numeric`})}function L_t(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function R_t(e){return e.toLocaleDateString(`en-US`,{weekday:`long`})}var z_t={operational:{label:`Event`,title:`Operational event — pipeline & system activity (agent lifecycle, reviews, merges, git). Not AI-generated.`},memory:{label:`Memory`,title:`Memory observation — an AI-distilled summary of agent work, extracted from the transcript.`}};function EQ({kind:e,className:t=``}){let n=e===`memory`?ls:is,{label:r,title:i}=z_t[e];return(0,B.jsxs)(`span`,{"data-testid":`notification-class-${e}`,title:i,className:`inline-flex h-5 items-center gap-1 rounded-sm border border-border bg-muted/40 px-1.5 text-[10px] font-medium text-muted-foreground ${t}`,children:[(0,B.jsx)(n,{className:`h-3 w-3`,"aria-hidden":`true`}),r]})}function DQ({status:e,className:t=``}){return(0,B.jsx)(`span`,{"data-testid":`action-status-chip`,className:`shrink-0 rounded-full border border-border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground ${t}`.trim(),children:e})}function B_t(e){let t=[e.workspaceId,e.issueId,e.timestamp].filter(Boolean).join(` · `);return[e.headline,e.summary&&e.summary!==e.headline?e.summary:null,t||null].filter(Boolean).join(`
|
|
659
659
|
|
|
@@ -733,7 +733,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
733
733
|
monaco.config({ paths: { vs: '...' } })
|
|
734
734
|
|
|
735
735
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
736
|
-
`},BXt=PXt(RXt)(zXt),VXt={config:IXt},HXt=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function UXt(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],UXt(e[n],t[n]))}),uXt(uXt({},e),t)}var WXt={type:`cancelation`,msg:`operation is manually canceled`};function M8(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(WXt):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var GXt=[`monaco`],KXt=pXt(MXt.create({config:NXt,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),N8=KXt[0],P8=KXt[1];function qXt(e){var t=VXt.config(e),n=t.monaco,r=dXt(t,GXt);P8(function(e){return{config:UXt(e.config,r),monaco:n}})}function JXt(){var e=N8(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(P8({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),M8(F8);if(window.monaco&&window.monaco.editor)return $Xt(window.monaco),e.resolve(window.monaco),M8(F8);HXt(YXt,ZXt)(QXt)}return M8(F8)}function YXt(e){return document.body.appendChild(e)}function XXt(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function ZXt(e){var t=N8(function(e){return{config:e.config,reject:e.reject}}),n=XXt(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function QXt(){var e=N8(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;$Xt(n),e.resolve(n)},function(t){e.reject(t)})}function $Xt(e){N8().monaco||P8({monaco:e})}function eZt(){return N8(function(e){return e.monaco})}var F8=new Promise(function(e,t){return P8({resolve:e,reject:t})}),tZt={config:qXt,init:JXt,__getMonacoInstance:eZt},I8={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},nZt={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function rZt({children:e}){return z.createElement(`div`,{style:nZt.container},e)}var iZt=rZt;function aZt({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return z.createElement(`section`,{style:{...I8.wrapper,width:e,height:t},...o},!n&&z.createElement(iZt,null,r),z.createElement(`div`,{ref:i,style:{...I8.fullWidth,...!n&&I8.hide},className:a}))}var oZt=(0,z.memo)(aZt);function sZt(e){(0,z.useEffect)(e,[])}var cZt=sZt;function lZt(e,t,n=!0){let r=(0,z.useRef)(!0);(0,z.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var L8=lZt;function R8(){}function z8(e,t,n,r){return uZt(e,r)||dZt(e,t,n,r)}function uZt(e,t){return e.editor.getModel(fZt(e,t))}function dZt(e,t,n,r){return e.editor.createModel(t,n,r?fZt(e,r):void 0)}function fZt(e,t){return e.Uri.parse(t)}function pZt({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:p=`100%`,className:m,wrapperProps:h={},beforeMount:g=R8,onMount:_=R8}){let[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!0),S=(0,z.useRef)(null),C=(0,z.useRef)(null),w=(0,z.useRef)(null),T=(0,z.useRef)(_),E=(0,z.useRef)(g),D=(0,z.useRef)(!1);cZt(()=>{let e=tZt.init();return e.then(e=>(C.current=e)&&x(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>S.current?A():e.cancel()}),L8(()=>{if(S.current&&C.current){let t=S.current.getOriginalEditor(),i=z8(C.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),L8(()=>{if(S.current&&C.current){let e=S.current.getModifiedEditor(),r=z8(C.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),L8(()=>{let e=S.current.getModifiedEditor();e.getOption(C.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),L8(()=>{S.current?.getModel()?.original.setValue(e||``)},[e],v),L8(()=>{let{original:e,modified:t}=S.current.getModel();C.current.editor.setModelLanguage(e,r||n||`text`),C.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),L8(()=>{C.current?.editor.setTheme(l)},[l],v),L8(()=>{S.current?.updateOptions(d)},[d],v);let O=(0,z.useCallback)(()=>{if(!C.current)return;E.current(C.current);let s=z8(C.current,e||``,r||n||`text`,a||``),c=z8(C.current,t||``,i||n||`text`,o||``);S.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),k=(0,z.useCallback)(()=>{!D.current&&w.current&&(S.current=C.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...d}),O(),C.current?.editor.setTheme(l),y(!0),D.current=!0)},[d,l,O]);(0,z.useEffect)(()=>{v&&T.current(S.current,C.current)},[v]),(0,z.useEffect)(()=>{!b&&!v&&k()},[b,v,k]);function A(){let e=S.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),S.current?.dispose()}return z.createElement(oZt,{width:p,height:f,isEditorReady:v,loading:u,_ref:w,className:m,wrapperProps:h})}(0,z.memo)(pZt);function mZt(e){let t=(0,z.useRef)();return(0,z.useEffect)(()=>{t.current=e},[e]),t.current}var hZt=mZt,B8=new Map;function gZt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p=`100%`,height:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=R8,onMount:v=R8,onChange:y,onValidate:b=R8}){let[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(!0),T=(0,z.useRef)(null),E=(0,z.useRef)(null),D=(0,z.useRef)(null),O=(0,z.useRef)(v),k=(0,z.useRef)(_),A=(0,z.useRef)(),j=(0,z.useRef)(r),M=hZt(a),N=(0,z.useRef)(!1),P=(0,z.useRef)(!1);cZt(()=>{let e=tZt.init();return e.then(e=>(T.current=e)&&w(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>E.current?I():e.cancel()}),L8(()=>{let o=z8(T.current,e||r||``,t||i||``,a||n||``);o!==E.current?.getModel()&&(d&&B8.set(M,E.current?.saveViewState()),E.current?.setModel(o),d&&E.current?.restoreViewState(B8.get(a)))},[a],x),L8(()=>{E.current?.updateOptions(l)},[l],x),L8(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(P.current=!0,E.current.executeEdits(``,[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),P.current=!1))},[r],x),L8(()=>{let e=E.current?.getModel();e&&i&&T.current?.editor.setModelLanguage(e,i)},[i],x),L8(()=>{s!==void 0&&E.current?.revealLine(s)},[s],x),L8(()=>{T.current?.editor.setTheme(o)},[o],x);let F=(0,z.useCallback)(()=>{if(!(!D.current||!T.current)&&!N.current){k.current(T.current);let c=a||n,f=z8(T.current,r||e||``,t||i||``,c||``);E.current=T.current?.editor.create(D.current,{model:f,automaticLayout:!0,...l},u),d&&E.current.restoreViewState(B8.get(c)),T.current.editor.setTheme(o),s!==void 0&&E.current.revealLine(s),S(!0),N.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);(0,z.useEffect)(()=>{x&&O.current(E.current,T.current)},[x]),(0,z.useEffect)(()=>{!C&&!x&&F()},[C,x,F]),j.current=r,(0,z.useEffect)(()=>{x&&y&&(A.current?.dispose(),A.current=E.current?.onDidChangeModelContent(e=>{P.current||y(E.current.getValue(),e)}))},[x,y]),(0,z.useEffect)(()=>{if(x){let e=T.current.editor.onDidChangeMarkers(e=>{let t=E.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=T.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]);function I(){A.current?.dispose(),f?d&&B8.set(a,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return z.createElement(oZt,{width:p,height:m,isEditorReady:x,loading:c,_ref:D,className:h,wrapperProps:g})}var _Zt=(0,z.memo)(gZt);function vZt({value:e,onChange:t,disabled:n=!1}){return(0,B.jsx)(_Zt,{height:`100%`,language:`markdown`,theme:`vs-dark`,value:e,loading:(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading editor…`}),options:{minimap:{enabled:!1},wordWrap:`on`,lineNumbers:`on`,readOnly:n,scrollBeyondLastLine:!1,fontSize:13,padding:{top:16,bottom:16},automaticLayout:!0},onChange:e=>t(e??``)})}var yZt=class extends Error{status;body;constructor(e,t,n){super(e),this.status=t,this.body=n,this.name=`ContextApiError`}},V8={layers:[`context`,`layers`]};async function bZt(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function xZt(e,t){if(t&&typeof t==`object`){let e=t;if(typeof e.error==`string`)return e.error;if(typeof e.message==`string`)return e.message}return typeof t==`string`&&t.trim()?t:`Context API request failed with status ${e}`}async function H8(e,t){let n={Accept:`application/json`};t.body!==void 0&&(n[`Content-Type`]=`application/json`);let r=await fetch(e,{method:t.method,credentials:`include`,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body)}),i=await bZt(r);if(!r.ok)throw new yZt(xZt(r.status,i),r.status,i);return i}function SZt(){return H8(`/api/context/layers`,{method:`GET`})}function CZt(e){return H8(`/api/context/preview`,{method:`POST`,body:e})}function wZt(e){return H8(`/api/context/layers`,{method:`PUT`,body:e})}function TZt(e={operation:`sync`}){return H8(`/api/context/sync`,{method:`POST`,body:e})}function EZt(){return V({queryKey:V8.layers,queryFn:SZt})}function DZt(){return Mt({mutationFn:CZt})}function OZt(){let e=yt();return Mt({mutationFn:wZt,onSuccess:()=>{e.invalidateQueries({queryKey:V8.layers})}})}function kZt(){let e=yt();return Mt({mutationFn:TZt,onSuccess:()=>{e.invalidateQueries({queryKey:V8.layers})}})}function U8(e){switch(e.kind){case`global`:return`global`;case`project`:return`project:${e.projectKey}`;case`workspace`:return`workspace:${e.projectKey}:${e.workspacePath}`}}function AZt(e){switch(e.kind){case`global`:return{kind:`global`};case`project`:return{kind:`project`,projectKey:e.projectKey};case`workspace`:return{kind:`workspace`,projectKey:e.projectKey,workspacePath:e.workspacePath}}}function jZt(e){switch(e.kind){case`global`:return`~/.overdeck/context/global.md`;case`project`:return`.pan/context/project.md`;case`workspace`:return`.pan/context/workspace.md`}}function MZt(e){switch(e){case`global`:return`Global context`;case`project`:return`Project context`;case`workspace`:return`Workspace context`}}function W8(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function NZt({error:e}){return(0,B.jsx)(`div`,{className:`h-full w-full p-6`,children:(0,B.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load context layers: `,W8(e)]})})}function PZt(e){let t=e.layer?U8(e.layer):`preview`;return`${e.level.toUpperCase()} · ${t}: ${e.message}`}function FZt(){let{data:e,isLoading:t,error:n,refetch:r}=EZt(),i=DZt(),a=OZt(),o=kZt(),s=i.mutateAsync,[c,l]=(0,z.useState)(`global`),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(``),[m,h]=(0,z.useState)({}),[g,_]=(0,z.useState)(`claude-code`),[v,y]=(0,z.useState)(null),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(null),w=(0,z.useMemo)(()=>e?.workspaces.filter(e=>e.projectKey===u)??[],[e?.workspaces,u]);(0,z.useEffect)(()=>{if(!e)return;let t=e.projects[0]?.projectKey??``;d(n=>e.projects.some(e=>e.projectKey===n)?n:t)},[e]),(0,z.useEffect)(()=>{e&&p(w.some(e=>e.path===f)?f:w[0]?.path??``)},[e,w,f]);let T=(0,z.useMemo)(()=>c===`global`?{kind:`global`}:u?c===`project`?{kind:`project`,projectKey:u}:f?{kind:`workspace`,projectKey:u,workspacePath:f}:null:null,[c,u,f]),E=(0,z.useMemo)(()=>{if(!e||!T)return null;let t=U8(T);return e.layers.find(e=>U8(AZt(e))===t)??null},[e,T]),D=(0,z.useMemo)(()=>e?e.layers.flatMap(e=>{let t=AZt(e),n=m[U8(t)];return n===void 0?[]:[{target:t,content:n}]}):[],[e,m]),O=T?U8(T):``,k=E?m[O]??E.content:``,A=e?.projects.find(e=>e.projectKey===u)??null,j=e?.workspaces.find(e=>e.path===f)??null,M=!!E&&m[O]!==void 0&&m[O]!==E.content,N=a.isPending||o.isPending,P=(0,z.useMemo)(()=>e?c===`global`?e.targets.filter(e=>e.layerKind===`global`):c===`project`?e.targets.filter(e=>e.layerKind===`project`&&e.projectKey===u):[]:[],[e,c,u]);(0,z.useEffect)(()=>{if(!T||!E){y(null);return}let e=!1;x(null);let t=window.setTimeout(()=>{s({operation:`preview`,selectedLayer:T,drafts:D}).then(t=>{e||y(t)}).catch(t=>{e||x(W8(t))})},300);return()=>{e=!0,window.clearTimeout(t)}},[D,s,E,T]);async function F(e){if(!(!T||!E)){C(null);try{await a.mutateAsync({operation:`save`,target:T,content:k}),e&&await o.mutateAsync({operation:`sync`}),await r(),h(e=>{let{[O]:t,...n}=e;return n}),U.success(e?`Context saved and synced`:`Context saved`)}catch(e){let t=W8(e);C(t),U.error(t)}}}if(t)return(0,B.jsx)(`div`,{className:`h-full w-full p-6 text-sm text-muted-foreground`,children:`Loading context layers…`});if(n)return(0,B.jsx)(NZt,{error:n});let I=v?.previews[g]??``,L=v?.diagnostics??[];return(0,B.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden bg-background text-foreground`,children:[(0,B.jsxs)(`aside`,{className:`w-80 shrink-0 overflow-y-auto border-r border-border bg-card/40 p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-5`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Context`}),(0,B.jsx)(`h1`,{className:`mt-1 text-lg font-semibold`,children:`Layer editor`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:`Edit the context markdown Overdeck injects into coding-agent sessions.`})]}),(0,B.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,B.jsx)(`legend`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Layer`}),[`global`,`project`,`workspace`].map(e=>(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-sm`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`context-layer-kind`,value:e,checked:c===e,onChange:()=>l(e)}),(0,B.jsx)(`span`,{children:MZt(e)})]},e))]}),(0,B.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:u,onChange:e=>d(e.target.value),disabled:!e?.projects.length||c===`global`,children:e?.projects.length?e.projects.map(e=>(0,B.jsx)(`option`,{value:e.projectKey,children:e.name},e.projectKey)):(0,B.jsx)(`option`,{value:``,children:`No registered projects`})})]}),(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`Workspace`}),(0,B.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:f,onChange:e=>p(e.target.value),disabled:c!==`workspace`||w.length===0,children:w.length?w.map(e=>(0,B.jsx)(`option`,{value:e.path,children:e.issueId??e.name},e.path)):(0,B.jsx)(`option`,{value:``,children:`No workspaces for this project`})})]})]}),(0,B.jsx)(`div`,{className:`mt-5 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:E?(0,B.jsxs)(`dl`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Layer file`}),(0,B.jsx)(`dd`,{className:`mt-1 font-mono`,children:jZt(E)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Resolved path`}),(0,B.jsx)(`dd`,{className:`mt-1 break-all font-mono`,children:E.file})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,B.jsx)(`dd`,{className:`mt-1`,children:E.exists?`File exists`:`File has not been created yet`})]})]}):(0,B.jsx)(`p`,{children:`Select a project or workspace to edit its context layer.`})}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`Where this gets injected`}),(0,B.jsxs)(`p`,{className:`mt-1 leading-5`,children:[(0,B.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`pan sync`}),` writes a managed region — between `,(0,B.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`BEGIN/END OVERDECK CONTEXT`}),` markers — into the files below. Anything you wrote `,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`outside`}),` those markers is never modified. Edit the layer source here, not the region.`]}),P.length>0?(0,B.jsx)(`ul`,{className:`mt-2 space-y-2`,children:P.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`div`,{className:`break-all font-mono text-foreground`,children:e.path}),(0,B.jsx)(`div`,{className:`mt-0.5`,children:e.exists?e.hasUserContent?`Has your own content — preserved outside the managed region.`:e.hasManagedRegion?`Managed by Overdeck (no other content).`:`Exists — a managed region is added on next sync.`:`Not created yet — created on next sync.`})]},e.path))}):c===`workspace`?(0,B.jsx)(`p`,{className:`mt-2`,children:`Workspace context is auto-assembled into the workspace and is not injected into any hand-authored file.`}):(0,B.jsx)(`p`,{className:`mt-2`,children:`No injection targets for this selection yet (the project has no project.md).`})]}),c===`workspace`?(0,B.jsxs)(`p`,{className:`mt-4 rounded-lg border border-info/30 bg-info/10 p-3 text-xs leading-5 text-info-foreground`,children:[(0,B.jsx)(`span`,{className:`font-semibold`,children:`Workspace context:`}),` .pan/context/workspace.md is auto-assembled for each workspace and may not exist until a workspace is created.`]}):null]}),(0,B.jsxs)(`section`,{className:`flex min-w-0 flex-1 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,B.jsx)(`header`,{className:`shrink-0 border-b border-border px-4 py-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-semibold`,children:MZt(c)}),(0,B.jsx)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:c===`global`?`Applies to every registered project.`:c===`project`?A?.path??`No project selected`:j?.path??`No workspace selected`})]}),E?(0,B.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:M?`Edited`:`Loaded`}):null]})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:E?(0,B.jsx)(vZt,{value:k,disabled:N,onChange:e=>h(t=>({...t,[O]:e}))}):(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`No context layer is available for the current selection.`})}),(0,B.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-border px-4 py-3`,children:[(0,B.jsx)(`div`,{className:`min-w-0 text-xs text-muted-foreground`,children:S?(0,B.jsx)(`span`,{className:`text-destructive`,children:S}):M?`Unsaved changes`:`No unsaved changes`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!1),children:a.isPending&&!o.isPending?`Saving…`:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!0),children:N&&o.isPending?`Syncing…`:`Save & Sync`})]})]})]}),(0,B.jsxs)(`aside`,{className:`flex w-[28rem] shrink-0 flex-col overflow-hidden border-l border-border bg-card/30`,children:[(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-border p-4`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Preview`}),(0,B.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-1 rounded-lg bg-muted p-1`,children:[[`claude-code`,`Claude Code output`],[`ohmypi`,`oh-my-pi output`],[`fullPrompt`,`Full injected prompt`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1.5 text-xs transition-colors ${g===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>_(e),children:t},e))})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:b?(0,B.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:b}):i.isPending&&!I?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Rendering preview…`}):I?(0,B.jsx)(`pre`,{className:`whitespace-pre-wrap rounded-lg border border-border bg-background p-3 text-xs leading-5 text-foreground`,children:I}):(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preview updates after the editor changes.`})}),(0,B.jsxs)(`div`,{className:`max-h-40 shrink-0 overflow-auto border-t border-border p-4`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Validation`}),L.length>0?(0,B.jsx)(`ul`,{className:`mt-2 space-y-2 text-xs`,children:L.map((e,t)=>(0,B.jsx)(`li`,{className:e.level===`error`?`text-destructive`:`text-warning-foreground`,children:PZt(e)},`${e.message}-${t}`))}):(0,B.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No validation issues.`})]})]})]})]})}var IZt=!1,LZt=5e3;function RZt(e=IZt){return e?`Browse, search, and edit this project knowledge bundle.`:`View and search here; edit knowledge through /okf author so changes stay PR-gated.`}async function zZt(e){let t=await fetch(`/api/knowledge-viewer/status?project=${encodeURIComponent(e)}`,{credentials:`include`}),n=await t.json();if(!t.ok)throw Error(n.error||`Knowledge viewer status could not be loaded`);return n}async function BZt(e,t){let n=await fetch(`/api/knowledge-viewer/${e}`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({project:t})}),r=await n.json();if(!n.ok)throw Error(r.error||`Knowledge viewer ${e} failed`);return r}function VZt({projectKey:e}){let t=yt(),n=(0,z.useRef)(null),r=(0,z.useRef)(null),[i,a]=(0,z.useState)(`loading`),o=V({queryKey:[`command-deck-projects`],queryFn:UC,enabled:!e,staleTime:3e4}),s=(0,z.useMemo)(()=>e??o.data?.[0]?.key??null,[e,o.data]),c=V({queryKey:[`knowledge-viewer-status`,s],queryFn:()=>zZt(s),enabled:!!s,refetchInterval:2e3}),l=Mt({mutationFn:()=>BZt(`install`,s),onSuccess:async()=>{n.current=null,await t.invalidateQueries({queryKey:[`knowledge-viewer-status`,s]})}}),u=Mt({mutationFn:()=>BZt(`start`,s),onSuccess:e=>{t.setQueryData([`knowledge-viewer-status`,s],e)}}),d=c.data;(0,z.useEffect)(()=>{if(!s){r.current=null;return}if(d?.running){n.current=null,r.current=s;return}r.current===s&&(n.current=null,r.current=null)},[s,d?.running]),(0,z.useEffect)(()=>{!s||!d?.bundleConfigured||!d.installed||d.running||d.starting||n.current===s||u.isPending||(n.current=s,u.mutate())},[s,u,d]),(0,z.useEffect)(()=>{if(a(`loading`),!d?.running)return;if(d.embeddable===!1||!d.proxyUrl){a(`blocked`);return}let e=window.setTimeout(()=>a(`blocked`),LZt);return()=>window.clearTimeout(e)},[s,d?.embeddable,d?.proxyUrl,d?.running]);let f=(0,z.useCallback)(()=>a(`ready`),[]),p=(0,z.useCallback)(()=>{n.current=s,u.reset(),u.mutate()},[s,u]),m=o.isLoading||!!s&&c.isLoading,h=o.error??c.error??l.error??u.error,g=d?.starting||u.isPending,_=d?.running&&(d.embeddable===!1||!d.proxyUrl||i===`blocked`);return(0,B.jsx)(`main`,{className:`h-full overflow-y-auto bg-background p-6`,"data-testid":`knowledge-page`,children:(0,B.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(ss,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),(0,B.jsx)(`h1`,{className:`text-xl font-medium text-foreground`,children:`Knowledge`})]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:RZt()})]}),m&&(0,B.jsx)(G8,{title:`Loading knowledge configuration`}),!m&&!s&&(0,B.jsx)(HZt,{title:`No project is available`,description:`Register a project before opening its knowledge bundle.`}),!m&&h&&(0,B.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`alert`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(hs,{className:`mt-0.5 h-5 w-5 text-destructive`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer unavailable`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:h.message}),d?.bundleConfigured&&d.installed&&(0,B.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Retry viewer`})]})]})}),!m&&!h&&d&&!d.bundleConfigured&&(0,B.jsx)(HZt,{title:`No knowledge bundle configured`,description:`Create or connect the project knowledge bundle, then return here.`,command:`/okf init`}),!m&&!h&&d?.bundleConfigured&&!d.installed&&(0,B.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Install the local knowledge viewer`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`OpenKnowledge is installed only after this explicit request. It runs as a separate local program.`}),d.message&&(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl font-mono text-xs text-muted-foreground`,children:d.message}),d.setupPlan?.steps.length?(0,B.jsx)(`ol`,{className:`mt-4 max-w-2xl list-decimal space-y-2 pl-5 text-sm text-muted-foreground`,"data-testid":`knowledge-setup-plan`,children:d.setupPlan.steps.map(e=>(0,B.jsx)(`li`,{children:e},e))}):null,(0,B.jsxs)(`button`,{type:`button`,onClick:()=>l.mutate(),disabled:l.isPending,className:`mt-5 inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-opacity disabled:opacity-50`,children:[l.isPending?(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}):(0,B.jsx)(Ns,{className:`h-4 w-4`,"aria-hidden":`true`}),l.isPending?`Setting up the viewer`:`Set up the viewer`]})]}),!m&&!h&&d?.bundleConfigured&&d.installed&&g&&(0,B.jsx)(G8,{title:`Starting knowledge viewer`}),!m&&!h&&d?.bundleConfigured&&d.installed&&!d.running&&!g&&n.current===s&&(0,B.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-stopped`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer stopped`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer exited before it could reconnect. Restart the read-only snapshot to continue browsing.`}),(0,B.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Restart viewer`})]}),!m&&!h&&_&&(0,B.jsx)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-blocked`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(hs,{className:`mt-0.5 h-5 w-5 text-warning`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Viewer opens in a separate tab`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer refused dashboard framing. Open its disposable read-only snapshot directly to browse and search.`}),d.url&&(0,B.jsx)(`a`,{href:d.url,target:`_blank`,rel:`noreferrer`,className:`mt-4 inline-flex text-sm font-medium text-primary hover:underline`,children:`Open viewer`})]})]})}),!m&&!h&&d?.running&&d.proxyUrl&&!_&&(0,B.jsxs)(`section`,{className:`relative flex min-h-[70vh] flex-col overflow-hidden rounded-lg bg-card`,"data-testid":`knowledge-viewer-embedded`,children:[(0,B.jsx)(`div`,{className:`border-b border-border px-4 py-3`,children:(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Read-only snapshot — viewer edits are discarded. Use `,(0,B.jsx)(`span`,{className:`font-mono`,children:`/okf author`}),` for durable changes.`]})}),i===`loading`&&(0,B.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 top-11 z-10 flex items-center justify-center bg-card`,children:(0,B.jsx)(G8,{title:`Loading knowledge workspace`})}),(0,B.jsx)(`iframe`,{title:`OpenKnowledge viewer`,src:d.proxyUrl,sandbox:`allow-downloads allow-forms allow-popups allow-same-origin allow-scripts`,onLoad:f,onError:()=>a(`blocked`),className:`min-h-[66vh] w-full flex-1 border-0 bg-background`})]})]})})}function G8({title:e}){return(0,B.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`status`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(gc,{className:`h-5 w-5 animate-spin text-info`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`This usually takes a few seconds.`})]})]})})}function HZt({title:e,description:t,command:n}){return(0,B.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:t}),n&&(0,B.jsx)(`code`,{className:`mt-4 inline-block rounded-sm bg-muted px-2 py-1 font-mono text-xs text-foreground`,children:n})]})}function UZt({sessions:e,selectedId:t,onSelect:n,hasMore:r=!1,isLoadingMore:i=!1,onLoadMore:a}){let o=(0,z.useRef)(null),s=bL({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>36,overscan:12}),c=s.getVirtualItems();return(0,z.useEffect)(()=>{let t=c.at(-1);!t||!r||i||!a||t.index>=e.length-8&&a()},[r,i,a,e.length,c]),(0,B.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto`,role:`table`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] gap-3 border-b border-border bg-background px-3 py-2 text-xs font-medium text-muted-foreground sticky top-0 z-10`,role:`row`,children:[(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{children:`Session`}),(0,B.jsx)(`div`,{children:`Model`}),(0,B.jsx)(`div`,{className:`text-right`,children:`Msgs`}),(0,B.jsx)(`div`,{className:`text-right`,children:`Cost`}),(0,B.jsx)(`div`,{children:`Last Active`})]}),(0,B.jsx)(`div`,{style:{height:s.getTotalSize(),position:`relative`},children:c.map(r=>{let i=e[r.index];if(!i)return null;let a=`${i.source}:${i.id}`,o=a===t,s=i.workspacePath??i.jsonlPath??`Unknown session path`,c=s.split(`/`).slice(-2).join(`/`),l=i.conversationTitle??i.conversationName??c,u=i.summary??s;return(0,B.jsxs)(`div`,{role:`row`,"data-session-key":a,onClick:()=>n(o?null:a),className:`absolute left-0 right-0 grid cursor-pointer grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] items-center gap-3 border-b border-border px-3 text-xs transition-colors ${o?`bg-primary/8 border-primary/32`:`hover:bg-card`}`,style:{height:r.size,transform:`translateY(${r.start}px)`},children:[(0,B.jsx)(`div`,{className:`text-center`,children:i.source===`managed-archived`?(0,B.jsx)(Cie,{className:`inline h-3 w-3 text-muted-foreground`}):i.overdeckManaged?(0,B.jsx)(el,{className:`inline h-3 w-3 text-primary`}):i.enrichmentLevel>0?(0,B.jsx)(gs,{className:`inline h-3 w-3 text-success`}):(0,B.jsx)(xs,{className:`inline h-3 w-3 text-muted-foreground/50`})}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-foreground`,title:`${l} — ${u}`,children:l}),u&&(0,B.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:u}),i.source===`managed-archived`?(0,B.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`Archived`,i.panIssueId?` · ${i.panIssueId}`:``]}):i.overdeckManaged&&(0,B.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[`Managed`,i.panIssueId?` · ${i.panIssueId}`:``]}),i.harness!==`claude-code`&&(0,B.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border bg-card px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:i.harness})]}),(0,B.jsx)(`div`,{className:`truncate text-muted-foreground`,children:i.primaryModel?i.primaryModel.split(`-`).slice(-2).join(`-`):`—`}),(0,B.jsx)(`div`,{className:`text-right font-mono text-muted-foreground`,children:i.messageCount}),(0,B.jsx)(`div`,{className:`text-right font-mono`,children:i.estimatedCost>0?(0,B.jsxs)(`span`,{className:`text-signal-cost-foreground`,children:[`$`,i.estimatedCost.toFixed(4)]}):(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`—`})}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:i.lastTs?WZt(i.lastTs):`—`})]},a)})}),i&&(0,B.jsx)(`div`,{className:`px-3 py-2 text-center text-xs text-muted-foreground`,children:`Loading more…`})]})}function WZt(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/864e5);return r===0?`today`:r===1?`yesterday`:r<7?`${r}d ago`:r<30?`${Math.floor(r/7)}w ago`:t.toISOString().slice(0,10)}catch{return e}}async function GZt(e){let t=await fetch(`/api/conversations/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Failed to load conversation: ${t.status}`);return await t.json()}async function KZt(e){let t=await fetch(`/api/discovered-sessions/${e}/messages`);if(t.status===410)throw Error(`TRANSCRIPT_GONE`);if(!t.ok)throw Error(`Failed to load transcript: ${t.status}`);return await t.json()}function qZt(e){return e.conversationName?e.conversationName:e.source===`managed-archived`?String(e.id):e.conversationId??null}function JZt({session:e}){let{resolvedTheme:t}=mO(),n=qZt(e),r=V({queryKey:[`sessions-feed-conversation`,n],queryFn:()=>GZt(n),enabled:n!==null,refetchInterval:5e3}),i=V({queryKey:[`discovered-session-messages`,e.id],queryFn:()=>KZt(e.id),enabled:n===null});return n===null?i.isLoading&&i.data===void 0?(0,B.jsx)(K8,{children:`Loading transcript…`}):i.error instanceof Error&&i.error.message===`TRANSCRIPT_GONE`?(0,B.jsx)(K8,{children:`Transcript file no longer on disk.`}):i.isError||i.data===void 0?(0,B.jsx)(K8,{children:`Couldn’t load this transcript.`}):(0,B.jsx)(DL,{messages:i.data.messages,workLog:i.data.workLog??[],streaming:i.data.streaming??!1,proposedPlan:i.data.proposedPlan,compactBoundaries:i.data.compactBoundaries,resolvedTheme:t,conversationName:e.conversationName??void 0,cwd:e.workspacePath??void 0,issueId:e.panIssueId}):r.isLoading&&r.data===void 0?(0,B.jsx)(K8,{children:`Loading conversation…`}):r.isError||r.data===void 0?(0,B.jsx)(K8,{children:`Couldn’t load this conversation.`}):(0,B.jsx)(QX,{conversation:r.data,viewMode:`conversation`,embedded:!0})}function K8({children:e}){return(0,B.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e})}async function YZt(e,t){await lb().request(n=>n[Cy.enrichSessions]({ids:[e],level:t.tier,confirmed:t.confirmed,...t.model?{model:t.model}:{}}))}async function XZt(e){await lb().request(t=>t[Cy.embedSessions]({ids:[e]}))}async function ZZt(e){if(!e)throw Error(`Archived conversation is missing its name`);let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok)throw Error(`Unarchive failed: ${t.status}`)}function QZt(e,t){let n=typeof e==`object`&&e&&`code`in e?String(e.code??``):``,r=/^COST_THRESHOLD:([^:]+):([^:]+):([^:]+)$/.exec(n);return r?{tier:t.tier,estimatedCost:Number(r[1]),threshold:Number(r[2]),sessionCount:Number(r[3]),model:t.model}:null}function $Zt(e){return{id:e.id,source:`discovered`,harness:e.harness??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,summaryDetailed:e.summaryDetailed??null,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function eQt(e){return $Zt(await lb().request(t=>t[Cy.getDiscoveredSession]({id:e})))}function tQt(e,t){return t?{...e,harness:t.harness??e.harness,jsonlPath:t.jsonlPath??e.jsonlPath,workspacePath:t.workspacePath??e.workspacePath,primaryModel:t.primaryModel??e.primaryModel,messageCount:t.messageCount||e.messageCount,firstTs:t.firstTs??e.firstTs,lastTs:t.lastTs??e.lastTs,estimatedCost:t.estimatedCost||e.estimatedCost,tokenInput:t.tokenInput||e.tokenInput,tokenOutput:t.tokenOutput||e.tokenOutput,toolsUsed:t.toolsUsed.length>0?t.toolsUsed:e.toolsUsed,filesTouched:t.filesTouched.length>0?t.filesTouched:e.filesTouched,tags:t.tags.length>0?t.tags:e.tags,summary:t.summary??e.summary,summaryDetailed:t.summaryDetailed??e.summaryDetailed,enrichmentLevel:t.enrichmentLevel||e.enrichmentLevel,enrichmentFailed:t.enrichmentFailed,panIssueId:t.panIssueId??e.panIssueId}:e}function nQt({session:e,onClose:t}){let n=yt(),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(``),s=e.source===`managed-archived`,c=s?e.discoveredId??null:e.id,l=Q(t=>t.enrichProgressBySessionId[e.id]),{data:u}=V({queryKey:[`discovered-session`,c],queryFn:()=>eQt(c),staleTime:1/0,placeholderData:e,enabled:c!=null}),d=s?tQt(e,u):u??e,f=d.conversationId??(s?String(d.id):null),p=()=>{n.invalidateQueries({queryKey:[`discovered-session`,e.id]}),n.invalidateQueries({queryKey:[`discovered-sessions`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`discovered-sessions-search`]}),n.invalidateQueries({queryKey:[`discovered-sessions-stats`]})},m=Mt({mutationFn:t=>YZt(e.id,t),onSuccess:()=>{i(null),p()},onError:(e,t)=>{i(QZt(e,t))}}),h=Mt({mutationFn:()=>XZt(e.id),onSuccess:p}),g=Mt({mutationFn:()=>ZZt(d.conversationName),onSuccess:()=>{n.invalidateQueries({queryKey:[`archived-conversations`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`conversations`]})}}),_=(e,t)=>(0,B.jsxs)(`div`,{className:`flex gap-2 text-xs py-1 border-b border-border`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground w-28 shrink-0`,children:e}),(0,B.jsx)(`span`,{className:`text-foreground font-mono break-all`,children:t??`—`})]}),v=e=>{let t=a.trim();m.mutate({tier:e,...t?{model:t}:{}})};return(0,B.jsxs)(`div`,{className:`flex flex-col h-full border-l border-border bg-background`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`Session #`,d.id]}),(0,B.jsx)(`span`,{className:d.overdeckManaged?`rounded border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,title:d.overdeckManaged?`Overdeck-managed session`:`Ad-hoc discovered session`,children:d.overdeckManaged?`Managed${d.panIssueId?` · ${d.panIssueId}`:``}`:`Ad-hoc`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f&&(0,B.jsx)(`button`,{onClick:()=>{f&&(window.history.pushState(null,``,Eyt(String(f))),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`rounded border border-border px-2 py-1 text-xs text-foreground transition-colors hover:border-border hover:bg-card`,children:`Open in Command Deck`}),(0,B.jsx)(`button`,{onClick:t,"aria-label":`Close session detail`,className:`text-muted-foreground/70 hover:text-foreground transition-colors`,children:(0,B.jsx)(sl,{className:`h-4 w-4`})})]})]}),(0,B.jsxs)(`details`,{open:!0,className:`shrink-0 border-b border-border`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground hover:text-foreground`,children:`Metadata and actions`}),(0,B.jsxs)(`div`,{className:`max-h-[38vh] overflow-auto px-3 py-2 space-y-4`,children:[d.summary&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Summary`}),(0,B.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed`,children:d.summary})]}),d.summaryDetailed&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Detailed`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:d.summaryDetailed})]}),d.tags.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tags`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.tags.map(e=>(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 bg-muted text-muted-foreground rounded text-[10px]`,children:e},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Metadata`}),_(`Workspace`,d.workspacePath),_(`Model`,d.primaryModel),_(`Messages`,d.messageCount),_(`Input tokens`,d.tokenInput.toLocaleString()),_(`Output tokens`,d.tokenOutput.toLocaleString()),_(`Est. cost`,d.estimatedCost>0?`$${d.estimatedCost.toFixed(6)}`:null),_(`First active`,d.firstTs?q8(d.firstTs):null),_(`Last active`,d.lastTs?q8(d.lastTs):null),s&&_(`Archived at`,d.archivedAt?q8(d.archivedAt):null),d.panIssueId&&_(`Issue`,d.panIssueId),_(`Enrichment`,d.enrichmentLevel===0?`None`:`L${d.enrichmentLevel}`)]}),d.toolsUsed.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tools Used`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.toolsUsed.map(e=>(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 bg-card text-muted-foreground rounded text-[10px] font-mono`,children:e},e))})]}),d.filesTouched.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Files Touched`}),(0,B.jsx)(`div`,{className:`space-y-1 max-h-28 overflow-auto`,children:d.filesTouched.map(e=>(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono break-all`,children:e},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`File`}),(0,B.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,B.jsx)(Is,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 font-mono break-all`,children:d.jsonlPath??`No JSONL path available`})]})]})]}),(0,B.jsx)(`div`,{className:`px-3 py-2 border-t border-border`,children:s?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:`Archived conversation`}),(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mb-2`,children:`Restore this conversation to the active Command Deck list.`}),(0,B.jsx)(`button`,{onClick:()=>g.mutate(),disabled:g.isPending||g.isSuccess,className:`rounded bg-warning/12 px-2 py-1 text-xs text-warning-foreground transition-colors hover:bg-warning/16 disabled:opacity-50`,children:g.isPending?`Unarchiving…`:`Unarchive`}),g.isSuccess&&(0,B.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Conversation restored`}),g.isError&&(0,B.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:g.error instanceof Error?g.error.message:`Unarchive failed`})]}):(0,B.jsxs)(B.Fragment,{children:[d.enrichmentLevel<3&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:d.enrichmentFailed?`Enrichment failed — retry:`:`Enrich this session`}),(0,B.jsx)(`div`,{className:`text-[10px] text-warning-foreground/80 mb-1.5`,children:`Sends redacted conversation excerpts to the configured enrichment provider.`}),(0,B.jsxs)(`label`,{className:`mb-2 block text-[10px] text-muted-foreground`,children:[`Custom model`,(0,B.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Use default provider model`,className:`mt-1 w-full rounded border border-border bg-card px-2 py-1 text-[10px] text-foreground placeholder:text-muted-foreground/70 focus:border-primary focus:outline-none`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d.enrichmentLevel<1&&(0,B.jsxs)(`button`,{onClick:()=>v(1),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,B.jsx)(Xc,{className:`h-3 w-3`}),`Quick (L1)`]}),d.enrichmentLevel<2&&(0,B.jsxs)(`button`,{onClick:()=>v(2),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,B.jsx)(Xc,{className:`h-3 w-3 text-muted-foreground`}),`Detailed (L2)`]}),(0,B.jsxs)(`button`,{onClick:()=>v(3),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,B.jsx)(Xc,{className:`h-3 w-3 text-muted-foreground`}),`Deep (L3)`]})]})]}),m.isPending&&(0,B.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Enriching…`}),l&&(0,B.jsxs)(`div`,{className:l.success?`text-[10px] text-success mt-1`:`text-[10px] text-destructive mt-1`,children:[`L`,l.level,` `,l.success?`complete`:`failed: ${l.error??`unknown error`}`,` · `,l.model]}),r&&(0,B.jsxs)(`div`,{className:`mt-2 rounded border border-warning/32 bg-warning/8 p-2 text-[10px] text-warning-foreground`,children:[`Estimated cost $`,r.estimatedCost.toFixed(4),` exceeds threshold $`,r.threshold.toFixed(2),` for `,r.sessionCount,` session`,r.sessionCount===1?``:`s`,`.`,(0,B.jsx)(`button`,{onClick:()=>m.mutate({tier:r.tier,confirmed:!0,model:r.model}),disabled:m.isPending,className:`ml-2 rounded bg-warning/12 px-1.5 py-0.5 text-warning-foreground disabled:opacity-50`,children:`Confirm`})]}),m.isError&&!r&&(0,B.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Enrichment failed`}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-border pt-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Semantic embedding`}),(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:`Generate or refresh this session's vector index.`})]}),(0,B.jsx)(`button`,{onClick:()=>h.mutate(),disabled:h.isPending,className:`px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:`Embed`})]}),h.isPending&&(0,B.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Embedding…`}),h.isSuccess&&(0,B.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Embedding complete`}),h.isError&&(0,B.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Embedding failed`})]})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(JZt,{session:d})})]})}function q8(e){try{return new Date(e).toISOString().replace(`T`,` `).slice(0,16)}catch{return e}}function rQt({isScanning:e,onScan:t,lastResult:n,progress:r}){let i=e||r?.active===!0;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?.active?(0,B.jsxs)(`span`,{className:`text-[10px] text-primary font-mono`,children:[r.dirsProcessed,`/`,r.dirsTotal,` files · `,r.sessionsFound,` sessions · `,(r.elapsedMs/1e3).toFixed(1),`s`]}):n&&!i&&(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,n.inserted,` ↑`,n.updated,` ·`,(n.durationMs/1e3).toFixed(1),`s`]}),(0,B.jsxs)(`button`,{onClick:t,disabled:i,className:`flex items-center gap-1.5 rounded px-3 py-1.5 bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 text-xs transition-colors`,children:[(0,B.jsx)(Mc,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),i?`Scanning…`:`Scan`]})]})}var iQt=[{label:`All time`,value:``},{label:`Today`,value:`today`},{label:`Last 7 days`,value:`7d`},{label:`Last 30 days`,value:`30d`},{label:`Last 90 days`,value:`90d`}],aQt=[{label:`All`,value:`all`},{label:`Discovered`,value:`discovered`},{label:`Managed-archived`,value:`managed-archived`}];function oQt({filters:e,facets:t,onChange:n}){let r=t.harnesses.some(e=>e.value!==`claude-code`);return(0,B.jsxs)(`div`,{className:`w-48 shrink-0 border-r border-border bg-background p-3 overflow-auto`,children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:`Filters`}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Source`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:aQt.map(t=>(0,B.jsx)(`button`,{onClick:()=>n(`source`,t.value===`all`?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${(e.source??`all`)===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:t.label},t.value))})]}),r&&(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Harness`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.harnesses.map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`harness`,e.harness===t.value?void 0:t.value),className:`px-1.5 py-0.5 text-[10px] font-mono transition-colors ${e.harness===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Time range`}),(0,B.jsx)(`select`,{value:e.since??``,onChange:e=>n(`since`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:iQt.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:t.timeRanges.map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`since`,e.since===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.since===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace path`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-workspaces`,value:e.workspace??``,onChange:e=>n(`workspace`,e.target.value||void 0),placeholder:`e.g. /Projects/myapp`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-workspaces`,children:t.workspaces.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Model`}),(0,B.jsxs)(`select`,{value:e.model??``,onChange:e=>n(`model`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:[(0,B.jsx)(`option`,{value:``,children:`All models`}),t.models.map(e=>(0,B.jsxs)(`option`,{value:e.value,children:[e.value,` (`,e.count,`)`]},e.value))]}),(0,B.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.models.slice(0,8).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`model`,e.model===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.model===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tag`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-tags`,value:e.tag??``,onChange:e=>n(`tag`,e.target.value||void 0),placeholder:`e.g. bugfix`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-tags`,children:t.tags.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tags.slice(0,12).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`tag`,e.tag===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tag===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tool`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-tools`,value:e.tool??``,onChange:e=>n(`tool`,e.target.value||void 0),placeholder:`e.g. Read`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-tools`,children:t.tools.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tools.slice(0,12).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`tool`,e.tool===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tool===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`File touched`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-files`,value:e.file??``,onChange:e=>n(`file`,e.target.value||void 0),placeholder:`e.g. src/index.ts`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-files`,children:t.files.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.files.slice(0,8).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`file`,e.file===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.file===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace cost`}),(0,B.jsx)(`div`,{className:`space-y-1 max-h-24 overflow-auto`,children:t.workspaces.slice(0,8).map(e=>(0,B.jsxs)(`button`,{onClick:()=>n(`workspace`,e.value),className:`w-full text-left text-[10px] text-muted-foreground hover:text-foreground truncate`,title:e.value,children:[e.count,` · $`,(e.cost??0).toFixed(4),` · `,e.value]},e.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Cost ranges`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.costRanges.map(t=>(0,B.jsxs)(`button`,{onClick:()=>{let r=e.minCost===t.minCost&&e.maxCost===t.maxCost;n(`minCost`,r?void 0:t.minCost),n(`maxCost`,r?void 0:t.maxCost)},className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.minCost===t.minCost&&e.maxCost===t.maxCost?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:`Estimated total $${(t.cost??0).toFixed(4)}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Enrichment levels`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.enrichmentLevels.map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`enrichmentLevel`,e.enrichmentLevel===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.enrichmentLevel===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[`L`,t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Min cost`,(0,B.jsx)(`input`,{type:`number`,step:`0.001`,value:e.minCost??``,onChange:e=>n(`minCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]}),(0,B.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Max cost`,(0,B.jsx)(`input`,{type:`number`,step:`0.001`,value:e.maxCost??``,onChange:e=>n(`maxCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.managed===!0,onChange:e=>n(`managed`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Overdeck-managed`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.enriched===!0,onChange:e=>n(`enriched`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Enriched only`})]})]}),Object.values(e).some(Boolean)&&(0,B.jsx)(`button`,{onClick:()=>{n(`since`,void 0),n(`harness`,void 0),n(`workspace`,void 0),n(`managed`,void 0),n(`enriched`,void 0),n(`model`,void 0),n(`tag`,void 0),n(`tool`,void 0),n(`file`,void 0),n(`minCost`,void 0),n(`maxCost`,void 0),n(`enrichmentLevel`,void 0)},className:`mt-4 text-[10px] text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:`Clear filters`})]})}function sQt(e){return`${e.source}:${e.id}`}function cQt(e){let t=new Set,n=[];for(let r of e??[])for(let e of r.rows){let r=sQt(e);t.has(r)||(t.add(r),n.push(e))}return n}function lQt(e){return`${e.source}:${e.id}`}function uQt(e){return{harnesses:[],models:e?.primaryModels.map(e=>({value:e.value,count:e.count}))??[],workspaces:[],tags:e?.tags.map(e=>({value:e.value,count:e.count}))??[],tools:e?.tools.map(e=>({value:e.value,count:e.count}))??[],files:e?.files.map(e=>({value:e.value,count:e.count}))??[],timeRanges:e?.timeBuckets.map(e=>({value:e.value===`24h`?`today`:e.value,label:e.value===`24h`?`Today`:e.value,count:e.count}))??[],costRanges:e?.costBuckets.map(e=>({value:e.value,label:e.value,count:e.count,minCost:e.value===`<$0.10`?void 0:e.value===`$0.10-1`?`0.10`:e.value===`$1-10`?`1`:`10`,maxCost:e.value===`<$0.10`?`0.10`:e.value===`$0.10-1`?`1`:e.value===`$1-10`?`10`:void 0}))??[],enrichmentLevels:e?.enrichmentLevels.map(e=>({value:String(e.value),count:e.count}))??[]}}function dQt(e){let t=new URLSearchParams;return e.harness&&t.set(`harness`,e.harness),e.workspace&&t.set(`workspacePath`,e.workspace),e.since&&t.set(`since`,e.since),e.managed&&t.set(`managed`,`true`),e.enriched&&t.set(`enriched`,`true`),e.model&&t.set(`primaryModel`,e.model),e.tag&&t.set(`tag`,e.tag),e.tool&&t.set(`tool`,e.tool),e.file&&t.set(`file`,e.file),e.minCost&&t.set(`minCost`,e.minCost),e.maxCost&&t.set(`maxCost`,e.maxCost),e.enrichmentLevel&&t.set(`enrichmentLevel`,e.enrichmentLevel),e.source&&e.source!==`all`&&t.set(`source`,e.source),t}function J8(e){let t={},n=e.get(`harness`),r=e.get(`workspacePath`),i=e.get(`primaryModel`),a=e.get(`since`),o=e.get(`managed`),s=e.get(`enriched`),c=e.get(`tag`),l=e.get(`tool`),u=e.get(`file`),d=e.get(`minCost`),f=e.get(`maxCost`),p=e.get(`enrichmentLevel`),m=e.get(`source`),h=e.get(`query`);return n&&(t.harness=n),r&&(t.workspacePath=r),i&&(t.primaryModel=i),a&&(t.since=a),o&&(t.managed=o===`true`),s&&(t.enriched=s===`true`),c&&(t.tags=[c]),l&&(t.tools=[l]),u&&(t.files=[u]),d&&Number.isFinite(Number(d))&&(t.minCost=Number(d)),f&&Number.isFinite(Number(f))&&(t.maxCost=Number(f)),p&&Number.isFinite(Number(p))&&(t.enrichmentLevel=Number(p)),(m===`discovered`||m===`managed-archived`)&&(t.source=m),h&&(t.query=h),t}function fQt(e){return{id:e.id,source:`discovered`,discoveredId:e.id,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}function pQt(e){return{id:e.id,source:e.source,discoveredId:e.discoveredId??null,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,archivedAt:e.archivedAt??null,jsonlPath:e.jsonlPath??null,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[],filesTouched:[],tags:[...e.tags],summary:e.summary??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function mQt(e,t){let n=await lb().request(n=>n[Cy.listSessionsFeed]({...J8(e),limit:Number(e.get(`limit`)??50),...t?{cursor:t}:{}}));return{rows:n.rows.map(pQt),nextCursor:n.nextCursor??null}}async function hQt(e){return lb().request(t=>t[Cy.getSessionsFeedFacets]({...J8(e),limit:Number(e.get(`limit`)??50)}))}async function gQt(e,t,n=50,r=0,i=!1){let a=await lb().request(a=>a[Cy.searchConversations]({...J8(t),query:e,semantic:i,limit:n,offset:r}));return{...a,sessions:a.sessions.map(fQt)}}async function _Qt(){let e=await lb().request(e=>e[Cy.getConversationStats]({}));return{...e,embeddingModels:e.embeddingModels?.map(e=>({...e}))}}async function vQt(e){return lb().request(t=>t[Cy.getConversationCost](J8(e)))}async function yQt(){return lb().request(e=>e[Cy.scanConversations]({mode:`system`}))}function bQt({initialSessionKey:e=null}){let t=yt(),n=Q(KNe),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(e),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(0),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)({}),h=p.source??`all`,g=r.trim(),[_,v]=(0,z.useState)(g),y=h!==`managed-archived`,b=d&&y,x=b?_:``,S=b?``:g,C=dQt(p);(0,z.useEffect)(()=>{if(!b){v(g);return}let e=window.setTimeout(()=>v(g),350);return()=>window.clearTimeout(e)},[b,g]),(0,z.useEffect)(()=>{!y&&d&&(f(!1),u(0))},[y,d]),(0,z.useEffect)(()=>{o(e)},[e]);let w=new URLSearchParams({limit:`100`});for(let[e,t]of C)w.set(e,t);S&&w.set(`query`,S);let T=iee({queryKey:[`sessions-feed`,w.toString()],queryFn:({pageParam:e})=>mQt(w,e),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:!x}),{data:E}=V({queryKey:[`sessions-feed-facets`,w.toString()],queryFn:()=>hQt(w),enabled:!x,staleTime:3e4}),{data:D,isLoading:O}=V({queryKey:[`discovered-sessions-search`,x,C.toString(),l,b],queryFn:()=>gQt(x,C,50,l,b),enabled:!!x}),{data:k}=V({queryKey:[`discovered-sessions-stats`],queryFn:_Qt,staleTime:3e4}),{data:A}=V({queryKey:[`discovered-sessions-cost`,C.toString()],queryFn:()=>vQt(C),staleTime:3e4}),j=Mt({mutationFn:yQt,onSuccess:()=>{t.invalidateQueries({queryKey:[`sessions-feed`]}),t.invalidateQueries({queryKey:[`sessions-feed-facets`]}),t.invalidateQueries({queryKey:[`discovered-sessions-stats`]})}}),M=x?O:T.isLoading,N=cQt(T.data?.pages),P=x?D?.sessions??[]:N,F=a==null?null:P.find(e=>lQt(e)===a)??null,I=uQt(E),L=[h===`all`?null:{key:`source`,label:`Source: ${h===`discovered`?`Discovered`:`Managed-archived`}`},p.harness?{key:`harness`,label:`Harness: ${p.harness}`}:null,p.workspace?{key:`workspace`,label:`Workspace: ${p.workspace}`}:null,p.model?{key:`model`,label:`Model: ${p.model}`}:null,p.tag?{key:`tag`,label:`Tag: ${p.tag}`}:null,p.tool?{key:`tool`,label:`Tool: ${p.tool}`}:null,p.file?{key:`file`,label:`File: ${p.file}`}:null,p.since?{key:`since`,label:`Since: ${p.since}`}:null,p.managed?{key:`managed`,label:`Managed`}:null,p.enriched?{key:`enriched`,label:`Enriched`}:null,p.minCost?{key:`minCost`,label:`Min cost: $${p.minCost}`}:null,p.maxCost?{key:`maxCost`,label:`Max cost: $${p.maxCost}`}:null,p.enrichmentLevel?{key:`enrichmentLevel`,label:`Enrichment: L${p.enrichmentLevel}`}:null].filter(e=>e!==null);(0,z.useEffect)(()=>{x||a==null||F!=null||!T.hasNextPage||T.isFetchingNextPage||T.fetchNextPage()},[x,T,F,a]);let ee=(0,z.useCallback)(e=>{i(e),u(0)},[]),R=(0,z.useCallback)((e,t)=>{m(n=>({...n,[e]:t})),u(0)},[]),te=(0,z.useCallback)(e=>{o(e);let t=new URLSearchParams(window.location.search);e?t.set(`session`,e):t.delete(`session`);let n=t.toString();window.history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`)},[]);return(0,B.jsxs)(`div`,{className:`flex flex-col h-full bg-background text-foreground`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border shrink-0`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-medium text-foreground`,children:`Session History`}),k&&(0,B.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground ml-2`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-foreground font-mono`,children:k.total}),` indexed`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-success font-mono`,children:k.enriched}),` enriched`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-primary font-mono`,children:k.managedCount}),` managed`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`span`,{className:`text-signal-cost-foreground font-mono`,children:[`$`,(A?.totalCost??0).toFixed(4)]}),` est. cost`]})]}),(0,B.jsx)(`div`,{className:`flex-1`}),(0,B.jsxs)(`div`,{className:`relative w-72`,children:[(0,B.jsx)(Vc,{className:`absolute left-2.5 top-2 h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`input`,{type:`text`,placeholder:`Search sessions…`,value:r,onChange:e=>ee(e.target.value),className:`w-full bg-card border border-border rounded pl-8 pr-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`})]}),(0,B.jsx)(`button`,{onClick:()=>{y&&(f(e=>!e),u(0))},disabled:!y,className:`px-3 py-1.5 rounded text-xs border transition-colors ${y?b?`bg-signal-review/8 border-signal-review/32 text-signal-review-foreground`:`bg-card border-border text-muted-foreground hover:border-border`:`bg-muted border-border text-muted-foreground/60 cursor-not-allowed`}`,children:b?`Semantic`:`Keyword`}),(0,B.jsxs)(`button`,{onClick:()=>c(e=>!e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs border transition-colors ${s?`bg-primary border-primary text-primary-foreground`:`bg-card border-border text-muted-foreground hover:border-border`}`,children:[(0,B.jsx)(Hs,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,B.jsx)(rQt,{isScanning:j.isPending,onScan:()=>j.mutate(),lastResult:j.data,progress:n})]}),L.length>0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-border bg-background shrink-0 text-xs`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Active filters`}),L.map(e=>(0,B.jsxs)(`button`,{onClick:()=>{R(e.key,void 0),e.key===`minCost`&&R(`maxCost`,void 0),e.key===`maxCost`&&R(`minCost`,void 0)},className:`px-2 py-1 rounded-sm bg-primary/8 text-primary border border-primary/32 hover:bg-primary hover:text-primary-foreground transition-colors`,children:[e.label,` `,(0,B.jsx)(`span`,{className:`text-primary`,children:`×`})]},e.key)),(0,B.jsx)(`button`,{onClick:()=>m({}),className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Clear all`})]}),(0,B.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[s&&(0,B.jsx)(oQt,{filters:p,facets:I,onChange:R}),(0,B.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 overflow-hidden ${F?`border-r border-border`:``}`,children:[x&&D?.error&&(0,B.jsxs)(`div`,{className:`px-4 py-2 border-b border-warning/32 bg-warning/8 text-warning-foreground text-xs`,children:[`Semantic search unavailable: `,D.error]}),M?(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Loading sessions…`}):P.length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-32 text-muted-foreground gap-2`,children:[(0,B.jsx)(`span`,{className:`text-sm`,children:`No sessions found`}),!k?.total&&(0,B.jsx)(`span`,{className:`text-xs`,children:`Run a scan to discover Claude Code sessions`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(UZt,{sessions:P,selectedId:a,onSelect:te,hasMore:!x&&T.hasNextPage,isLoadingMore:T.isFetchingNextPage,onLoadMore:()=>{T.fetchNextPage()}}),x&&D&&D.total>50&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-border shrink-0 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[l+1,`–`,l+P.length,` of `,D.total,` results`]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{disabled:l===0,onClick:()=>u(e=>Math.max(0,e-50)),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Prev`}),(0,B.jsx)(`button`,{disabled:l+50>=D.total,onClick:()=>u(e=>e+50),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Next`})]})]})]})]}),F&&(0,B.jsx)(`div`,{className:`min-w-[28rem] flex-[1.15] overflow-hidden`,children:(0,B.jsx)(nQt,{session:F,onClose:()=>te(null)})})]})]})}function xQt(e){return e===`warming`?(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin text-primary`}):e===`ready`?(0,B.jsx)(_s,{className:`h-4 w-4 text-green-500`}):e===`failed`?(0,B.jsx)(hs,{className:`h-4 w-4 text-destructive`}):(0,B.jsx)(xs,{className:`h-4 w-4 text-muted-foreground`})}function SQt({mode:e,warmupStatus:t,isListening:n,onStart:r,onBackToStaging:i,onReset:a,onToggleMic:o,voiceError:s}){return(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`AutoPreso`}),(0,B.jsx)(`h2`,{className:`mt-1 text-lg font-semibold`,children:`Voice whiteboard`})]}),(0,B.jsx)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs font-medium capitalize text-muted-foreground`,children:e})]}),(0,B.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-lg px-3 py-2 text-sm font-semibold transition-colors ${n?`bg-destructive text-destructive-foreground`:`bg-primary text-primary-foreground`}`,children:n?`Stop mic`:`Start mic`}),(0,B.jsx)(`button`,{type:`button`,onClick:e===`staging`?r:i,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-foreground hover:bg-accent`,children:e===`staging`?`Go live`:`Back to staging`})]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-muted/40 p-3 text-sm`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-foreground`,children:[xQt(t),`Warmup: `,(0,B.jsx)(`span`,{className:`capitalize`,children:t})]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The whiteboard agent uses the staged canvas as context before live transcription starts.`})]}),s&&(0,B.jsx)(`div`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),(0,B.jsx)(`button`,{type:`button`,onClick:a,className:`mt-3 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Reset session`})]})}function CQt({partialText:e,turns:t}){let n=(0,z.useRef)(null);return(0,z.useEffect)(()=>{n.current?.scrollIntoView({block:`end`})},[e,t]),(0,B.jsxs)(`section`,{className:`min-h-0 flex-1 rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Transcript`}),(0,B.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto pr-1 text-sm`,children:[t.length===0&&!e&&(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:`Spoken turns will appear here while AutoPreso listens.`}),t.map((e,t)=>(0,B.jsxs)(`article`,{className:`rounded-lg bg-muted/40 p-2 text-foreground`,children:[(0,B.jsx)(`time`,{className:`mb-1 block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.timestamp.toLocaleTimeString()}),(0,B.jsx)(`p`,{children:e.text})]},`${e.timestamp.toISOString()}-${t}`)),e&&(0,B.jsx)(`p`,{className:`rounded-lg border border-dashed border-border p-2 italic text-muted-foreground`,children:e}),(0,B.jsx)(`div`,{ref:n})]})]})}var wQt=25e4,TQt=6e3,EQt=200;function DQt(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function OQt(){let[e,t]=(0,z.useState)([]),[n,r]=(0,z.useState)(`staging`),[i,a]=(0,z.useState)(`idle`),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)([]),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(null),g=(0,z.useRef)(null),_=(0,z.useRef)(null),v=(0,z.useRef)(null),y=(0,z.useRef)(0),b=(0,z.useRef)(!0),x=(0,z.useRef)(null),S=(0,z.useRef)(null),C=(0,z.useRef)(null),w=(0,z.useRef)(null),T=(0,z.useRef)(null),E=(0,z.useRef)(null),D=(0,z.useCallback)(()=>{g.current?.close();let e=new WebSocket(DQt(`/ws/autopreso`));g.current=e,e.onopen=()=>{y.current=0},e.onmessage=e=>{let n=JSON.parse(String(e.data));(n.type===`whiteboard:snapshot`||n.type===`whiteboard:update`)&&(n.elements&&t(n.elements),n.mode&&r(n.mode),n.warmupStatus&&a(n.warmupStatus))},e.onclose=()=>{if(!b.current||g.current!==e)return;let t=Math.min(1e3*2**y.current,1e4);y.current+=1,v.current=window.setTimeout(D,t)}},[]),O=(0,z.useCallback)(e=>{d(!1),e&&_.current?.close(),e&&(_.current=null),C.current?.disconnect(),w.current?.disconnect(),T.current?.disconnect(),S.current?.close(),x.current?.getTracks().forEach(e=>e.stop()),C.current=null,w.current=null,T.current=null,S.current=null,x.current=null,h(null)},[]),k=(0,z.useCallback)(async(e=!0)=>{let t=_.current;O(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,TQt);E.current=()=>{window.clearTimeout(t),e()}}),E.current=null),O(!0)},[O]);return(0,z.useEffect)(()=>(b.current=!0,D(),()=>{b.current=!1,v.current&&window.clearTimeout(v.current),v.current=null;let e=g.current;g.current=null,e?.close(),k(!1)}),[D,k]),{elements:e,mode:n,warmupStatus:i,partialText:o,committedTurns:c,isListening:u,voiceError:f,startListening:(0,z.useCallback)(async()=>{if(u)return;p(null);let e=null,t=null,n=null,r=null,i=null,a=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0});let o=window.AudioContext;t=new o({sampleRate:24e3}),n=t.createMediaStreamSource(e),r=t.createAnalyser(),i=t.createScriptProcessor(4096,1,1),a=new WebSocket(DQt(`/ws/voice`)),a.binaryType=`arraybuffer`,a.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`transcript:partial`&&s(t.text),t.type===`transcript:committed`&&(s(``),l(e=>[...e,{text:t.text,timestamp:new Date}].slice(-EQt))),t.type===`transcript:finalized`&&E.current?.(),t.type===`error`&&p(t.error)},a.onclose=()=>{_.current===a&&k(!1)},i.onaudioprocess=e=>{if(a?.readyState!==WebSocket.OPEN||a.bufferedAmount>wQt)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}a.send(n.buffer)},n.connect(r),r.connect(i),i.connect(t.destination),x.current=e,S.current=t,w.current=n,T.current=r,C.current=i,_.current=a,h(r),d(!0)}catch(o){a?.close(),i?.disconnect(),n?.disconnect(),r?.disconnect(),t?.close(),e?.getTracks().forEach(e=>e.stop()),p(o instanceof Error?o.message:`Unable to start voice input`)}},[u,k]),stopListening:k,analyserNode:m}}var kQt=(0,z.lazy)(async()=>({default:(await v(()=>import(`./prod-CzJiNNEG.js`),__vite__mapDeps([109,2,3,110,111,112,6,113,114,5]))).Excalidraw}));function AQt(){let{elements:e,mode:t,warmupStatus:n,partialText:r,committedTurns:i,isListening:a,voiceError:o,startListening:s,stopListening:c}=OQt(),[l,u]=(0,z.useState)([]),d=(0,z.useRef)(null),f=t===`live`?e:l,p=(0,z.useMemo)(()=>({elements:f}),[f]),m=(0,z.useCallback)(async()=>{await fetch(`/api/autopreso/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({elements:l,screenshotBase64:null})})},[l]),h=(0,z.useCallback)(async()=>{await fetch(`/api/autopreso/back-to-staging`,{method:`POST`})},[]),g=(0,z.useCallback)(async()=>{await fetch(`/api/autopreso/session/reset`,{method:`POST`}),u([]),d.current?.updateScene?.({elements:[]})},[]),_=(0,z.useCallback)(()=>{a?c():s()},[a,s,c]),v=(0,z.useCallback)(e=>{t===`staging`&&u(e)},[t]),y=(0,z.useCallback)(e=>{d.current=e},[]);return(0,z.useEffect)(()=>{t===`live`&&d.current?.updateScene?.({elements:e})},[t,e]),(0,B.jsxs)(`div`,{className:`flex h-full w-full gap-4 overflow-hidden bg-background p-4 text-foreground`,children:[(0,B.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading whiteboard…`}),children:(0,B.jsx)(kQt,{excalidrawAPI:y,initialData:p,onChange:v,viewModeEnabled:t===`live`},t)})}),(0,B.jsxs)(`aside`,{className:`flex w-96 shrink-0 flex-col gap-4 overflow-y-auto`,children:[(0,B.jsx)(SQt,{mode:t,warmupStatus:n,isListening:a,onStart:m,onBackToStaging:h,onReset:g,onToggleMic:_,voiceError:o}),(0,B.jsx)(CQt,{turns:i,partialText:r})]})]})}function Y8({fallback:e,children:t}){return Q(WNe)?(0,B.jsx)(B.Fragment,{children:t}):(0,B.jsx)(B.Fragment,{children:e})}var jQt=`overdeck:ui-mode`,MQt=`overdeck:last-tab`;function NQt(){if(typeof window>`u`)return`advanced`;try{let e=window.localStorage.getItem(jQt);return e===`simple`||e===`advanced`?e:window.localStorage.getItem(MQt)?`advanced`:`simple`}catch{return`advanced`}}var X8=tS(e=>({mode:NQt(),setMode:t=>{try{window.localStorage.setItem(jQt,t)}catch{}e({mode:t})},simpleIssueId:null,openSimpleIssue:t=>e({simpleIssueId:t}),closeSimpleIssue:()=>e({simpleIssueId:null})}));function PQt(e){if(typeof window>`u`)return;let t=e?`/issues/${encodeURIComponent(e)}`:`/`;window.location.pathname!==t&&window.history.pushState({},``,t)}var Z8={home:{greetingFallback:`Hello.`,needsYouTitle:`Needs you`,needsYouSub:`Work pauses until you answer. Everything else keeps going.`,workingTitle:`Working now`,workingSub:`Nothing for you to do on these — you'll be told when they're ready.`,readyTitle:`Ready to merge`,doneTitle:`Finished`,composerPlaceholder:`Describe what you want built or fixed, in plain words…`,composerButton:`Talk it through`,nothingNeedsYou:`Nothing needs you right now. Nice.`,quietEmpty:`Nothing here yet.`},issue:{backToMyWork:`← My work`,composerPlaceholder:`Say something to the agent… (steer it, correct it, ask why)`,composerHint:`Talking to it never interrupts the work — it reads you between tasks.`,answerPlaceholder:`Type your answer…`,answerHint:`One sentence is enough. It continues immediately after you answer.`,whatHappened:`What happened`,advancedDisclosure:`Advanced — the machinery behind this task`,getHelp:`Get help`,steps:[`Started`,`Writing code`,`Checking`,`Ready`],feedTitle:`What it's doing`,waitingOnYou:`waiting on you`,taskStartedPrefix:`Task started · told to `,rawPromptDisclosure:`See the full instructions it was given`,readMore:`Read more`,showLess:`Show less`,pausedWaiting:`Paused — waiting for your answer`,pausedToStart:`Paused — waiting for you to start the work`,sentToAgent:`Sent to the agent`,questionTitle:`It has a question for you`,screenExcerptLabel:`Here's what it's showing on its screen:`,questionAskedPrefix:`Asked `,questionPauseSuffix:`work pauses until you answer — everything else keeps going`,questionAnswerPlaceholder:`Or type your own answer…`,answerSend:`Send answer`,questionOptionsHint:`Pick an option or write one sentence — it continues as soon as you answer.`,answerSentTitle:`Answer sent`,answerSentSub:`It's reading your answer and getting back to work.`,liveLabel:`live`,readyLiveRow:`All checks passed — ready when you are`},mode:{simple:`Simple`,advanced:`Advanced`}};function Q8(){let e=X8(e=>e.mode),t=X8(e=>e.setMode);return(0,B.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-lg border border-input`,children:[{id:`simple`,label:Z8.mode.simple},{id:`advanced`,label:Z8.mode.advanced}].map(n=>(0,B.jsx)(`button`,{onClick:()=>t(n.id),className:Kx(`px-3 py-1.5 text-xs font-medium transition-colors`,e===n.id?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`),children:n.label},n.id))})}function FQt({state:e,pipelineState:t}){let n=Z8.issue.steps,r=Bgt(t),i=e===`needs-you`;return(0,B.jsx)(`div`,{className:`mt-5 flex`,role:`list`,children:n.map((t,a)=>{let o=a<r||e===`done`,s=a===r&&e!==`done`&&e!==`ready`,c=a===n.length-1;return(0,B.jsxs)(`div`,{role:`listitem`,className:`relative flex-1 pt-3.5 text-center`,children:[(0,B.jsx)(`span`,{className:Kx(`absolute left-0 right-0 top-[5px] h-0.5`,a===0&&`left-1/2`,c&&`right-1/2`,o||s?`bg-success`:`bg-muted`)}),(0,B.jsx)(`span`,{className:Kx(`absolute left-1/2 top-0 h-3 w-3 -translate-x-1/2 rounded-full border-2`,o&&`border-transparent bg-success`,s&&!i&&`border-transparent bg-info shadow-[0_0_0_3px] shadow-info/25`,s&&i&&`border-transparent bg-warning shadow-[0_0_0_3px] shadow-warning/25`,!o&&!s&&`border-border bg-muted`)}),(0,B.jsx)(`span`,{className:Kx(`text-[11.5px]`,o&&`text-success-foreground`,s&&`font-medium text-foreground`,!o&&!s&&`text-muted-foreground`),children:t}),s&&i&&(0,B.jsx)(`span`,{className:`mt-0.5 block text-[10.5px] text-warning-foreground`,children:Z8.issue.waitingOnYou})]},t)})})}var IQt={"not-started":{accent:`border-transparent`,iconBg:`bg-muted text-muted-foreground`,icon:(0,B.jsx)(zie,{size:15})},working:{accent:`border-info`,iconBg:`bg-info/10 text-info-foreground`,icon:(0,B.jsx)(gc,{size:15})},"needs-you":{accent:`border-warning`,iconBg:`bg-warning/10 text-warning-foreground`,icon:(0,B.jsx)(vs,{size:15})},ready:{accent:`border-success`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,B.jsx)(us,{size:15})},done:{accent:`border-transparent`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,B.jsx)(us,{size:15})}};function LQt({display:e,children:t}){let n=IQt[e.state];return(0,B.jsxs)(`div`,{className:Kx(`mt-4 rounded-2xl border-l-[3px] bg-card p-4`,`shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border dark:shadow-none`,n.accent),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:Kx(`flex h-8 w-8 flex-none items-center justify-center rounded-full`,n.iconBg),children:n.icon}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[15px] font-medium`,children:e.title}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.sentence})]})]}),t&&(0,B.jsx)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-2`,children:t})]})}function RQt({completed:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,B.jsx)(`div`,{className:`mt-2.5 h-1 overflow-hidden rounded-full bg-accent`,"aria-label":`${e} of ${t}`,children:(0,B.jsx)(`div`,{className:`h-full rounded-full bg-info`,style:{width:`${n}%`}})})}function $8({children:e,onClick:t,disabled:n,tone:r=`primary`}){return(0,B.jsx)(`button`,{"data-slot":`primary-action`,onClick:t,disabled:n,className:Kx(`inline-flex h-9 items-center rounded-lg px-4 text-[13.5px] font-medium text-white transition-opacity`,r===`success`?`bg-success text-[#04120c]`:`bg-primary text-primary-foreground`,n?`cursor-not-allowed opacity-50`:`hover:opacity-90`),children:e})}function e5({children:e,onClick:t,disabled:n}){return(0,B.jsx)(`button`,{onClick:t,disabled:n,className:Kx(`inline-flex h-9 items-center rounded-lg border border-input px-4 text-[13.5px] font-medium text-muted-foreground transition-colors`,n?`cursor-not-allowed opacity-50`:`hover:bg-accent hover:text-foreground`),children:e})}var zQt=`overdeck:talk-project`;function BQt(e){try{let t=localStorage.getItem(zQt);if(t&&e.some(e=>e.key===t))return t}catch{}let t=window.location.pathname.match(/^\/command-deck\/([^/]+)/);return t&&e.some(e=>e.key===t[1])?t[1]:e[0]?.key}function VQt(e){return[`I want to discuss a possible task with you first — do not file anything yet.`,``,`The task idea, in my words:`,`"""`,e.trim(),`"""`,``,`Discuss it with me: ask what you need to know, point out what is underspecified or wrong, and help me sharpen it.`,`Only when I explicitly say it is ready (e.g. "file it"), file it as an issue in the tracker with a good title and body based on our discussion, and give me the issue link (e.g. PAN-1234).`].join(`
|
|
736
|
+
`},BXt=PXt(RXt)(zXt),VXt={config:IXt},HXt=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function UXt(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],UXt(e[n],t[n]))}),uXt(uXt({},e),t)}var WXt={type:`cancelation`,msg:`operation is manually canceled`};function M8(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(WXt):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var GXt=[`monaco`],KXt=pXt(MXt.create({config:NXt,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),N8=KXt[0],P8=KXt[1];function qXt(e){var t=VXt.config(e),n=t.monaco,r=dXt(t,GXt);P8(function(e){return{config:UXt(e.config,r),monaco:n}})}function JXt(){var e=N8(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(P8({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),M8(F8);if(window.monaco&&window.monaco.editor)return $Xt(window.monaco),e.resolve(window.monaco),M8(F8);HXt(YXt,ZXt)(QXt)}return M8(F8)}function YXt(e){return document.body.appendChild(e)}function XXt(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function ZXt(e){var t=N8(function(e){return{config:e.config,reject:e.reject}}),n=XXt(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function QXt(){var e=N8(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;$Xt(n),e.resolve(n)},function(t){e.reject(t)})}function $Xt(e){N8().monaco||P8({monaco:e})}function eZt(){return N8(function(e){return e.monaco})}var F8=new Promise(function(e,t){return P8({resolve:e,reject:t})}),tZt={config:qXt,init:JXt,__getMonacoInstance:eZt},I8={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},nZt={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function rZt({children:e}){return z.createElement(`div`,{style:nZt.container},e)}var iZt=rZt;function aZt({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return z.createElement(`section`,{style:{...I8.wrapper,width:e,height:t},...o},!n&&z.createElement(iZt,null,r),z.createElement(`div`,{ref:i,style:{...I8.fullWidth,...!n&&I8.hide},className:a}))}var oZt=(0,z.memo)(aZt);function sZt(e){(0,z.useEffect)(e,[])}var cZt=sZt;function lZt(e,t,n=!0){let r=(0,z.useRef)(!0);(0,z.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var L8=lZt;function R8(){}function z8(e,t,n,r){return uZt(e,r)||dZt(e,t,n,r)}function uZt(e,t){return e.editor.getModel(fZt(e,t))}function dZt(e,t,n,r){return e.editor.createModel(t,n,r?fZt(e,r):void 0)}function fZt(e,t){return e.Uri.parse(t)}function pZt({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:p=`100%`,className:m,wrapperProps:h={},beforeMount:g=R8,onMount:_=R8}){let[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!0),S=(0,z.useRef)(null),C=(0,z.useRef)(null),w=(0,z.useRef)(null),T=(0,z.useRef)(_),E=(0,z.useRef)(g),D=(0,z.useRef)(!1);cZt(()=>{let e=tZt.init();return e.then(e=>(C.current=e)&&x(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>S.current?A():e.cancel()}),L8(()=>{if(S.current&&C.current){let t=S.current.getOriginalEditor(),i=z8(C.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),L8(()=>{if(S.current&&C.current){let e=S.current.getModifiedEditor(),r=z8(C.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),L8(()=>{let e=S.current.getModifiedEditor();e.getOption(C.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),L8(()=>{S.current?.getModel()?.original.setValue(e||``)},[e],v),L8(()=>{let{original:e,modified:t}=S.current.getModel();C.current.editor.setModelLanguage(e,r||n||`text`),C.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),L8(()=>{C.current?.editor.setTheme(l)},[l],v),L8(()=>{S.current?.updateOptions(d)},[d],v);let O=(0,z.useCallback)(()=>{if(!C.current)return;E.current(C.current);let s=z8(C.current,e||``,r||n||`text`,a||``),c=z8(C.current,t||``,i||n||`text`,o||``);S.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),k=(0,z.useCallback)(()=>{!D.current&&w.current&&(S.current=C.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...d}),O(),C.current?.editor.setTheme(l),y(!0),D.current=!0)},[d,l,O]);(0,z.useEffect)(()=>{v&&T.current(S.current,C.current)},[v]),(0,z.useEffect)(()=>{!b&&!v&&k()},[b,v,k]);function A(){let e=S.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),S.current?.dispose()}return z.createElement(oZt,{width:p,height:f,isEditorReady:v,loading:u,_ref:w,className:m,wrapperProps:h})}(0,z.memo)(pZt);function mZt(e){let t=(0,z.useRef)();return(0,z.useEffect)(()=>{t.current=e},[e]),t.current}var hZt=mZt,B8=new Map;function gZt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p=`100%`,height:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=R8,onMount:v=R8,onChange:y,onValidate:b=R8}){let[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(!0),T=(0,z.useRef)(null),E=(0,z.useRef)(null),D=(0,z.useRef)(null),O=(0,z.useRef)(v),k=(0,z.useRef)(_),A=(0,z.useRef)(),j=(0,z.useRef)(r),M=hZt(a),N=(0,z.useRef)(!1),P=(0,z.useRef)(!1);cZt(()=>{let e=tZt.init();return e.then(e=>(T.current=e)&&w(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>E.current?I():e.cancel()}),L8(()=>{let o=z8(T.current,e||r||``,t||i||``,a||n||``);o!==E.current?.getModel()&&(d&&B8.set(M,E.current?.saveViewState()),E.current?.setModel(o),d&&E.current?.restoreViewState(B8.get(a)))},[a],x),L8(()=>{E.current?.updateOptions(l)},[l],x),L8(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(P.current=!0,E.current.executeEdits(``,[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),P.current=!1))},[r],x),L8(()=>{let e=E.current?.getModel();e&&i&&T.current?.editor.setModelLanguage(e,i)},[i],x),L8(()=>{s!==void 0&&E.current?.revealLine(s)},[s],x),L8(()=>{T.current?.editor.setTheme(o)},[o],x);let F=(0,z.useCallback)(()=>{if(!(!D.current||!T.current)&&!N.current){k.current(T.current);let c=a||n,f=z8(T.current,r||e||``,t||i||``,c||``);E.current=T.current?.editor.create(D.current,{model:f,automaticLayout:!0,...l},u),d&&E.current.restoreViewState(B8.get(c)),T.current.editor.setTheme(o),s!==void 0&&E.current.revealLine(s),S(!0),N.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);(0,z.useEffect)(()=>{x&&O.current(E.current,T.current)},[x]),(0,z.useEffect)(()=>{!C&&!x&&F()},[C,x,F]),j.current=r,(0,z.useEffect)(()=>{x&&y&&(A.current?.dispose(),A.current=E.current?.onDidChangeModelContent(e=>{P.current||y(E.current.getValue(),e)}))},[x,y]),(0,z.useEffect)(()=>{if(x){let e=T.current.editor.onDidChangeMarkers(e=>{let t=E.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=T.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]);function I(){A.current?.dispose(),f?d&&B8.set(a,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return z.createElement(oZt,{width:p,height:m,isEditorReady:x,loading:c,_ref:D,className:h,wrapperProps:g})}var _Zt=(0,z.memo)(gZt);function vZt({value:e,onChange:t,disabled:n=!1}){return(0,B.jsx)(_Zt,{height:`100%`,language:`markdown`,theme:`vs-dark`,value:e,loading:(0,B.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading editor…`}),options:{minimap:{enabled:!1},wordWrap:`on`,lineNumbers:`on`,readOnly:n,scrollBeyondLastLine:!1,fontSize:13,padding:{top:16,bottom:16},automaticLayout:!0},onChange:e=>t(e??``)})}var yZt=class extends Error{status;body;constructor(e,t,n){super(e),this.status=t,this.body=n,this.name=`ContextApiError`}},V8={layers:[`context`,`layers`]};async function bZt(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function xZt(e,t){if(t&&typeof t==`object`){let e=t;if(typeof e.error==`string`)return e.error;if(typeof e.message==`string`)return e.message}return typeof t==`string`&&t.trim()?t:`Context API request failed with status ${e}`}async function H8(e,t){let n={Accept:`application/json`};t.body!==void 0&&(n[`Content-Type`]=`application/json`);let r=await fetch(e,{method:t.method,credentials:`include`,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body)}),i=await bZt(r);if(!r.ok)throw new yZt(xZt(r.status,i),r.status,i);return i}function SZt(){return H8(`/api/context/layers`,{method:`GET`})}function CZt(e){return H8(`/api/context/preview`,{method:`POST`,body:e})}function wZt(e){return H8(`/api/context/layers`,{method:`PUT`,body:e})}function TZt(e={operation:`sync`}){return H8(`/api/context/sync`,{method:`POST`,body:e})}function EZt(){return V({queryKey:V8.layers,queryFn:SZt})}function DZt(){return Mt({mutationFn:CZt})}function OZt(){let e=yt();return Mt({mutationFn:wZt,onSuccess:()=>{e.invalidateQueries({queryKey:V8.layers})}})}function kZt(){let e=yt();return Mt({mutationFn:TZt,onSuccess:()=>{e.invalidateQueries({queryKey:V8.layers})}})}function U8(e){switch(e.kind){case`global`:return`global`;case`project`:return`project:${e.projectKey}`;case`workspace`:return`workspace:${e.projectKey}:${e.workspacePath}`}}function AZt(e){switch(e.kind){case`global`:return{kind:`global`};case`project`:return{kind:`project`,projectKey:e.projectKey};case`workspace`:return{kind:`workspace`,projectKey:e.projectKey,workspacePath:e.workspacePath}}}function jZt(e){switch(e.kind){case`global`:return`~/.overdeck/context/global.md`;case`project`:return`.pan/context/project.md`;case`workspace`:return`.pan/context/workspace.md`}}function MZt(e){switch(e){case`global`:return`Global context`;case`project`:return`Project context`;case`workspace`:return`Workspace context`}}function W8(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function NZt({error:e}){return(0,B.jsx)(`div`,{className:`h-full w-full p-6`,children:(0,B.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load context layers: `,W8(e)]})})}function PZt(e){let t=e.layer?U8(e.layer):`preview`;return`${e.level.toUpperCase()} · ${t}: ${e.message}`}function FZt(){let{data:e,isLoading:t,error:n,refetch:r}=EZt(),i=DZt(),a=OZt(),o=kZt(),s=i.mutateAsync,[c,l]=(0,z.useState)(`global`),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(``),[m,h]=(0,z.useState)({}),[g,_]=(0,z.useState)(`claude-code`),[v,y]=(0,z.useState)(null),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(null),w=(0,z.useMemo)(()=>e?.workspaces.filter(e=>e.projectKey===u)??[],[e?.workspaces,u]);(0,z.useEffect)(()=>{if(!e)return;let t=e.projects[0]?.projectKey??``;d(n=>e.projects.some(e=>e.projectKey===n)?n:t)},[e]),(0,z.useEffect)(()=>{e&&p(w.some(e=>e.path===f)?f:w[0]?.path??``)},[e,w,f]);let T=(0,z.useMemo)(()=>c===`global`?{kind:`global`}:u?c===`project`?{kind:`project`,projectKey:u}:f?{kind:`workspace`,projectKey:u,workspacePath:f}:null:null,[c,u,f]),E=(0,z.useMemo)(()=>{if(!e||!T)return null;let t=U8(T);return e.layers.find(e=>U8(AZt(e))===t)??null},[e,T]),D=(0,z.useMemo)(()=>e?e.layers.flatMap(e=>{let t=AZt(e),n=m[U8(t)];return n===void 0?[]:[{target:t,content:n}]}):[],[e,m]),O=T?U8(T):``,k=E?m[O]??E.content:``,A=e?.projects.find(e=>e.projectKey===u)??null,j=e?.workspaces.find(e=>e.path===f)??null,M=!!E&&m[O]!==void 0&&m[O]!==E.content,N=a.isPending||o.isPending,P=(0,z.useMemo)(()=>e?c===`global`?e.targets.filter(e=>e.layerKind===`global`):c===`project`?e.targets.filter(e=>e.layerKind===`project`&&e.projectKey===u):[]:[],[e,c,u]);(0,z.useEffect)(()=>{if(!T||!E){y(null);return}let e=!1;x(null);let t=window.setTimeout(()=>{s({operation:`preview`,selectedLayer:T,drafts:D}).then(t=>{e||y(t)}).catch(t=>{e||x(W8(t))})},300);return()=>{e=!0,window.clearTimeout(t)}},[D,s,E,T]);async function F(e){if(!(!T||!E)){C(null);try{await a.mutateAsync({operation:`save`,target:T,content:k}),e&&await o.mutateAsync({operation:`sync`}),await r(),h(e=>{let{[O]:t,...n}=e;return n}),U.success(e?`Context saved and synced`:`Context saved`)}catch(e){let t=W8(e);C(t),U.error(t)}}}if(t)return(0,B.jsx)(`div`,{className:`h-full w-full p-6 text-sm text-muted-foreground`,children:`Loading context layers…`});if(n)return(0,B.jsx)(NZt,{error:n});let I=v?.previews[g]??``,L=v?.diagnostics??[];return(0,B.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden bg-background text-foreground`,children:[(0,B.jsxs)(`aside`,{className:`w-80 shrink-0 overflow-y-auto border-r border-border bg-card/40 p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-5`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Context`}),(0,B.jsx)(`h1`,{className:`mt-1 text-lg font-semibold`,children:`Layer editor`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:`Edit the context markdown Overdeck injects into coding-agent sessions.`})]}),(0,B.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,B.jsx)(`legend`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Layer`}),[`global`,`project`,`workspace`].map(e=>(0,B.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-sm`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`context-layer-kind`,value:e,checked:c===e,onChange:()=>l(e)}),(0,B.jsx)(`span`,{children:MZt(e)})]},e))]}),(0,B.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:u,onChange:e=>d(e.target.value),disabled:!e?.projects.length||c===`global`,children:e?.projects.length?e.projects.map(e=>(0,B.jsx)(`option`,{value:e.projectKey,children:e.name},e.projectKey)):(0,B.jsx)(`option`,{value:``,children:`No registered projects`})})]}),(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`Workspace`}),(0,B.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:f,onChange:e=>p(e.target.value),disabled:c!==`workspace`||w.length===0,children:w.length?w.map(e=>(0,B.jsx)(`option`,{value:e.path,children:e.issueId??e.name},e.path)):(0,B.jsx)(`option`,{value:``,children:`No workspaces for this project`})})]})]}),(0,B.jsx)(`div`,{className:`mt-5 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:E?(0,B.jsxs)(`dl`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Layer file`}),(0,B.jsx)(`dd`,{className:`mt-1 font-mono`,children:jZt(E)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Resolved path`}),(0,B.jsx)(`dd`,{className:`mt-1 break-all font-mono`,children:E.file})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,B.jsx)(`dd`,{className:`mt-1`,children:E.exists?`File exists`:`File has not been created yet`})]})]}):(0,B.jsx)(`p`,{children:`Select a project or workspace to edit its context layer.`})}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`Where this gets injected`}),(0,B.jsxs)(`p`,{className:`mt-1 leading-5`,children:[(0,B.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`pan sync`}),` writes a managed region — between `,(0,B.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`BEGIN/END OVERDECK CONTEXT`}),` markers — into the files below. Anything you wrote `,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`outside`}),` those markers is never modified. Edit the layer source here, not the region.`]}),P.length>0?(0,B.jsx)(`ul`,{className:`mt-2 space-y-2`,children:P.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`div`,{className:`break-all font-mono text-foreground`,children:e.path}),(0,B.jsx)(`div`,{className:`mt-0.5`,children:e.exists?e.hasUserContent?`Has your own content — preserved outside the managed region.`:e.hasManagedRegion?`Managed by Overdeck (no other content).`:`Exists — a managed region is added on next sync.`:`Not created yet — created on next sync.`})]},e.path))}):c===`workspace`?(0,B.jsx)(`p`,{className:`mt-2`,children:`Workspace context is auto-assembled into the workspace and is not injected into any hand-authored file.`}):(0,B.jsx)(`p`,{className:`mt-2`,children:`No injection targets for this selection yet (the project has no project.md).`})]}),c===`workspace`?(0,B.jsxs)(`p`,{className:`mt-4 rounded-lg border border-info/30 bg-info/10 p-3 text-xs leading-5 text-info-foreground`,children:[(0,B.jsx)(`span`,{className:`font-semibold`,children:`Workspace context:`}),` .pan/context/workspace.md is auto-assembled for each workspace and may not exist until a workspace is created.`]}):null]}),(0,B.jsxs)(`section`,{className:`flex min-w-0 flex-1 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,B.jsx)(`header`,{className:`shrink-0 border-b border-border px-4 py-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-semibold`,children:MZt(c)}),(0,B.jsx)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:c===`global`?`Applies to every registered project.`:c===`project`?A?.path??`No project selected`:j?.path??`No workspace selected`})]}),E?(0,B.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:M?`Edited`:`Loaded`}):null]})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:E?(0,B.jsx)(vZt,{value:k,disabled:N,onChange:e=>h(t=>({...t,[O]:e}))}):(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`No context layer is available for the current selection.`})}),(0,B.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-border px-4 py-3`,children:[(0,B.jsx)(`div`,{className:`min-w-0 text-xs text-muted-foreground`,children:S?(0,B.jsx)(`span`,{className:`text-destructive`,children:S}):M?`Unsaved changes`:`No unsaved changes`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!1),children:a.isPending&&!o.isPending?`Saving…`:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!0),children:N&&o.isPending?`Syncing…`:`Save & Sync`})]})]})]}),(0,B.jsxs)(`aside`,{className:`flex w-[28rem] shrink-0 flex-col overflow-hidden border-l border-border bg-card/30`,children:[(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-border p-4`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Preview`}),(0,B.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-1 rounded-lg bg-muted p-1`,children:[[`claude-code`,`Claude Code output`],[`ohmypi`,`oh-my-pi output`],[`fullPrompt`,`Full injected prompt`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1.5 text-xs transition-colors ${g===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>_(e),children:t},e))})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:b?(0,B.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:b}):i.isPending&&!I?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Rendering preview…`}):I?(0,B.jsx)(`pre`,{className:`whitespace-pre-wrap rounded-lg border border-border bg-background p-3 text-xs leading-5 text-foreground`,children:I}):(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preview updates after the editor changes.`})}),(0,B.jsxs)(`div`,{className:`max-h-40 shrink-0 overflow-auto border-t border-border p-4`,children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Validation`}),L.length>0?(0,B.jsx)(`ul`,{className:`mt-2 space-y-2 text-xs`,children:L.map((e,t)=>(0,B.jsx)(`li`,{className:e.level===`error`?`text-destructive`:`text-warning-foreground`,children:PZt(e)},`${e.message}-${t}`))}):(0,B.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No validation issues.`})]})]})]})]})}var IZt=!1,LZt=5e3;function RZt(e=IZt){return e?`Browse, search, and edit this project knowledge bundle.`:`View and search here; edit knowledge through /okf author so changes stay PR-gated.`}async function zZt(e){let t=await fetch(`/api/knowledge-viewer/status?project=${encodeURIComponent(e)}`,{credentials:`include`}),n=await t.json();if(!t.ok)throw Error(n.error||`Knowledge viewer status could not be loaded`);return n}async function BZt(e,t){let n=await fetch(`/api/knowledge-viewer/${e}`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({project:t})}),r=await n.json();if(!n.ok)throw Error(r.error||`Knowledge viewer ${e} failed`);return r}function VZt({projectKey:e}){let t=yt(),n=(0,z.useRef)(null),r=(0,z.useRef)(null),[i,a]=(0,z.useState)(`loading`),o=V({queryKey:[`command-deck-projects`],queryFn:UC,enabled:!e,staleTime:3e4}),s=(0,z.useMemo)(()=>e??o.data?.[0]?.key??null,[e,o.data]),c=V({queryKey:[`knowledge-viewer-status`,s],queryFn:()=>zZt(s),enabled:!!s,refetchInterval:2e3}),l=Mt({mutationFn:()=>BZt(`install`,s),onSuccess:async()=>{n.current=null,await t.invalidateQueries({queryKey:[`knowledge-viewer-status`,s]})}}),u=Mt({mutationFn:()=>BZt(`start`,s),onSuccess:e=>{t.setQueryData([`knowledge-viewer-status`,s],e)}}),d=c.data;(0,z.useEffect)(()=>{if(!s){r.current=null;return}if(d?.running){n.current=null,r.current=s;return}r.current===s&&(n.current=null,r.current=null)},[s,d?.running]),(0,z.useEffect)(()=>{!s||!d?.bundleConfigured||!d.installed||d.running||d.starting||n.current===s||u.isPending||(n.current=s,u.mutate())},[s,u,d]),(0,z.useEffect)(()=>{if(a(`loading`),!d?.running)return;if(d.embeddable===!1||!d.proxyUrl){a(`blocked`);return}let e=window.setTimeout(()=>a(`blocked`),LZt);return()=>window.clearTimeout(e)},[s,d?.embeddable,d?.proxyUrl,d?.running]);let f=(0,z.useCallback)(()=>a(`ready`),[]),p=(0,z.useCallback)(()=>{n.current=s,u.reset(),u.mutate()},[s,u]),m=o.isLoading||!!s&&c.isLoading,h=o.error??c.error??l.error??u.error,g=d?.starting||u.isPending,_=d?.running&&(d.embeddable===!1||!d.proxyUrl||i===`blocked`);return(0,B.jsx)(`main`,{className:`h-full overflow-y-auto bg-background p-6`,"data-testid":`knowledge-page`,children:(0,B.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(ss,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),(0,B.jsx)(`h1`,{className:`text-xl font-medium text-foreground`,children:`Knowledge`})]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:RZt()})]}),m&&(0,B.jsx)(G8,{title:`Loading knowledge configuration`}),!m&&!s&&(0,B.jsx)(HZt,{title:`No project is available`,description:`Register a project before opening its knowledge bundle.`}),!m&&h&&(0,B.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`alert`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(hs,{className:`mt-0.5 h-5 w-5 text-destructive`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer unavailable`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:h.message}),d?.bundleConfigured&&d.installed&&(0,B.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Retry viewer`})]})]})}),!m&&!h&&d&&!d.bundleConfigured&&(0,B.jsx)(HZt,{title:`No knowledge bundle configured`,description:`Create or connect the project knowledge bundle, then return here.`,command:`/okf init`}),!m&&!h&&d?.bundleConfigured&&!d.installed&&(0,B.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Install the local knowledge viewer`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`OpenKnowledge is installed only after this explicit request. It runs as a separate local program.`}),d.message&&(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl font-mono text-xs text-muted-foreground`,children:d.message}),d.setupPlan?.steps.length?(0,B.jsx)(`ol`,{className:`mt-4 max-w-2xl list-decimal space-y-2 pl-5 text-sm text-muted-foreground`,"data-testid":`knowledge-setup-plan`,children:d.setupPlan.steps.map(e=>(0,B.jsx)(`li`,{children:e},e))}):null,(0,B.jsxs)(`button`,{type:`button`,onClick:()=>l.mutate(),disabled:l.isPending,className:`mt-5 inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-opacity disabled:opacity-50`,children:[l.isPending?(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}):(0,B.jsx)(Ns,{className:`h-4 w-4`,"aria-hidden":`true`}),l.isPending?`Setting up the viewer`:`Set up the viewer`]})]}),!m&&!h&&d?.bundleConfigured&&d.installed&&g&&(0,B.jsx)(G8,{title:`Starting knowledge viewer`}),!m&&!h&&d?.bundleConfigured&&d.installed&&!d.running&&!g&&n.current===s&&(0,B.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-stopped`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer stopped`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer exited before it could reconnect. Restart the read-only snapshot to continue browsing.`}),(0,B.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Restart viewer`})]}),!m&&!h&&_&&(0,B.jsx)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-blocked`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(hs,{className:`mt-0.5 h-5 w-5 text-warning`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Viewer opens in a separate tab`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer refused dashboard framing. Open its disposable read-only snapshot directly to browse and search.`}),d.url&&(0,B.jsx)(`a`,{href:d.url,target:`_blank`,rel:`noreferrer`,className:`mt-4 inline-flex text-sm font-medium text-primary hover:underline`,children:`Open viewer`})]})]})}),!m&&!h&&d?.running&&d.proxyUrl&&!_&&(0,B.jsxs)(`section`,{className:`relative flex min-h-[70vh] flex-col overflow-hidden rounded-lg bg-card`,"data-testid":`knowledge-viewer-embedded`,children:[(0,B.jsx)(`div`,{className:`border-b border-border px-4 py-3`,children:(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Read-only snapshot — viewer edits are discarded. Use `,(0,B.jsx)(`span`,{className:`font-mono`,children:`/okf author`}),` for durable changes.`]})}),i===`loading`&&(0,B.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 top-11 z-10 flex items-center justify-center bg-card`,children:(0,B.jsx)(G8,{title:`Loading knowledge workspace`})}),(0,B.jsx)(`iframe`,{title:`OpenKnowledge viewer`,src:d.proxyUrl,sandbox:`allow-downloads allow-forms allow-popups allow-same-origin allow-scripts`,onLoad:f,onError:()=>a(`blocked`),className:`min-h-[66vh] w-full flex-1 border-0 bg-background`})]})]})})}function G8({title:e}){return(0,B.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`status`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(gc,{className:`h-5 w-5 animate-spin text-info`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`This usually takes a few seconds.`})]})]})})}function HZt({title:e,description:t,command:n}){return(0,B.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:t}),n&&(0,B.jsx)(`code`,{className:`mt-4 inline-block rounded-sm bg-muted px-2 py-1 font-mono text-xs text-foreground`,children:n})]})}function UZt({sessions:e,selectedId:t,onSelect:n,hasMore:r=!1,isLoadingMore:i=!1,onLoadMore:a}){let o=(0,z.useRef)(null),s=bL({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>36,overscan:12}),c=s.getVirtualItems();return(0,z.useEffect)(()=>{let t=c.at(-1);!t||!r||i||!a||t.index>=e.length-8&&a()},[r,i,a,e.length,c]),(0,B.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto`,role:`table`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] gap-3 border-b border-border bg-background px-3 py-2 text-xs font-medium text-muted-foreground sticky top-0 z-10`,role:`row`,children:[(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{children:`Session`}),(0,B.jsx)(`div`,{children:`Model`}),(0,B.jsx)(`div`,{className:`text-right`,children:`Msgs`}),(0,B.jsx)(`div`,{className:`text-right`,children:`Cost`}),(0,B.jsx)(`div`,{children:`Last Active`})]}),(0,B.jsx)(`div`,{style:{height:s.getTotalSize(),position:`relative`},children:c.map(r=>{let i=e[r.index];if(!i)return null;let a=`${i.source}:${i.id}`,o=a===t,s=i.workspacePath??i.jsonlPath??`Unknown session path`,c=s.split(`/`).slice(-2).join(`/`),l=i.conversationTitle??i.conversationName??c,u=i.summary??s;return(0,B.jsxs)(`div`,{role:`row`,"data-session-key":a,onClick:()=>n(o?null:a),className:`absolute left-0 right-0 grid cursor-pointer grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] items-center gap-3 border-b border-border px-3 text-xs transition-colors ${o?`bg-primary/8 border-primary/32`:`hover:bg-card`}`,style:{height:r.size,transform:`translateY(${r.start}px)`},children:[(0,B.jsx)(`div`,{className:`text-center`,children:i.source===`managed-archived`?(0,B.jsx)(Cie,{className:`inline h-3 w-3 text-muted-foreground`}):i.overdeckManaged?(0,B.jsx)(el,{className:`inline h-3 w-3 text-primary`}):i.enrichmentLevel>0?(0,B.jsx)(gs,{className:`inline h-3 w-3 text-success`}):(0,B.jsx)(xs,{className:`inline h-3 w-3 text-muted-foreground/50`})}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-foreground`,title:`${l} — ${u}`,children:l}),u&&(0,B.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:u}),i.source===`managed-archived`?(0,B.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`Archived`,i.panIssueId?` · ${i.panIssueId}`:``]}):i.overdeckManaged&&(0,B.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[`Managed`,i.panIssueId?` · ${i.panIssueId}`:``]}),i.harness!==`claude-code`&&(0,B.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border bg-card px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:i.harness})]}),(0,B.jsx)(`div`,{className:`truncate text-muted-foreground`,children:i.primaryModel?i.primaryModel.split(`-`).slice(-2).join(`-`):`—`}),(0,B.jsx)(`div`,{className:`text-right font-mono text-muted-foreground`,children:i.messageCount}),(0,B.jsx)(`div`,{className:`text-right font-mono`,children:i.estimatedCost>0?(0,B.jsxs)(`span`,{className:`text-signal-cost-foreground`,children:[`$`,i.estimatedCost.toFixed(4)]}):(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`—`})}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:i.lastTs?WZt(i.lastTs):`—`})]},a)})}),i&&(0,B.jsx)(`div`,{className:`px-3 py-2 text-center text-xs text-muted-foreground`,children:`Loading more…`})]})}function WZt(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/864e5);return r===0?`today`:r===1?`yesterday`:r<7?`${r}d ago`:r<30?`${Math.floor(r/7)}w ago`:t.toISOString().slice(0,10)}catch{return e}}async function GZt(e){let t=await fetch(`/api/conversations/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Failed to load conversation: ${t.status}`);return await t.json()}async function KZt(e){let t=await fetch(`/api/discovered-sessions/${e}/messages`);if(t.status===410)throw Error(`TRANSCRIPT_GONE`);if(!t.ok)throw Error(`Failed to load transcript: ${t.status}`);return await t.json()}function qZt(e){return e.conversationName?e.conversationName:e.source===`managed-archived`?String(e.id):e.conversationId??null}function JZt({session:e}){let{resolvedTheme:t}=mO(),n=qZt(e),r=V({queryKey:[`sessions-feed-conversation`,n],queryFn:()=>GZt(n),enabled:n!==null,refetchInterval:5e3}),i=V({queryKey:[`discovered-session-messages`,e.id],queryFn:()=>KZt(e.id),enabled:n===null});return n===null?i.isLoading&&i.data===void 0?(0,B.jsx)(K8,{children:`Loading transcript…`}):i.error instanceof Error&&i.error.message===`TRANSCRIPT_GONE`?(0,B.jsx)(K8,{children:`Transcript file no longer on disk.`}):i.isError||i.data===void 0?(0,B.jsx)(K8,{children:`Couldn’t load this transcript.`}):(0,B.jsx)(DL,{messages:i.data.messages,workLog:i.data.workLog??[],streaming:i.data.streaming??!1,proposedPlan:i.data.proposedPlan,compactBoundaries:i.data.compactBoundaries,resolvedTheme:t,conversationName:e.conversationName??void 0,cwd:e.workspacePath??void 0,issueId:e.panIssueId}):r.isLoading&&r.data===void 0?(0,B.jsx)(K8,{children:`Loading conversation…`}):r.isError||r.data===void 0?(0,B.jsx)(K8,{children:`Couldn’t load this conversation.`}):(0,B.jsx)(QX,{conversation:r.data,viewMode:`conversation`,embedded:!0})}function K8({children:e}){return(0,B.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e})}async function YZt(e,t){await lb().request(n=>n[Cy.enrichSessions]({ids:[e],level:t.tier,confirmed:t.confirmed,...t.model?{model:t.model}:{}}))}async function XZt(e){await lb().request(t=>t[Cy.embedSessions]({ids:[e]}))}async function ZZt(e){if(!e)throw Error(`Archived conversation is missing its name`);let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok)throw Error(`Unarchive failed: ${t.status}`)}function QZt(e,t){let n=typeof e==`object`&&e&&`code`in e?String(e.code??``):``,r=/^COST_THRESHOLD:([^:]+):([^:]+):([^:]+)$/.exec(n);return r?{tier:t.tier,estimatedCost:Number(r[1]),threshold:Number(r[2]),sessionCount:Number(r[3]),model:t.model}:null}function $Zt(e){return{id:e.id,source:`discovered`,harness:e.harness??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,summaryDetailed:e.summaryDetailed??null,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function eQt(e){return $Zt(await lb().request(t=>t[Cy.getDiscoveredSession]({id:e})))}function tQt(e,t){return t?{...e,harness:t.harness??e.harness,jsonlPath:t.jsonlPath??e.jsonlPath,workspacePath:t.workspacePath??e.workspacePath,primaryModel:t.primaryModel??e.primaryModel,messageCount:t.messageCount||e.messageCount,firstTs:t.firstTs??e.firstTs,lastTs:t.lastTs??e.lastTs,estimatedCost:t.estimatedCost||e.estimatedCost,tokenInput:t.tokenInput||e.tokenInput,tokenOutput:t.tokenOutput||e.tokenOutput,toolsUsed:t.toolsUsed.length>0?t.toolsUsed:e.toolsUsed,filesTouched:t.filesTouched.length>0?t.filesTouched:e.filesTouched,tags:t.tags.length>0?t.tags:e.tags,summary:t.summary??e.summary,summaryDetailed:t.summaryDetailed??e.summaryDetailed,enrichmentLevel:t.enrichmentLevel||e.enrichmentLevel,enrichmentFailed:t.enrichmentFailed,panIssueId:t.panIssueId??e.panIssueId}:e}function nQt({session:e,onClose:t}){let n=yt(),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(``),s=e.source===`managed-archived`,c=s?e.discoveredId??null:e.id,l=Q(t=>t.enrichProgressBySessionId[e.id]),{data:u}=V({queryKey:[`discovered-session`,c],queryFn:()=>eQt(c),staleTime:1/0,placeholderData:e,enabled:c!=null}),d=s?tQt(e,u):u??e,f=d.conversationId??(s?String(d.id):null),p=()=>{n.invalidateQueries({queryKey:[`discovered-session`,e.id]}),n.invalidateQueries({queryKey:[`discovered-sessions`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`discovered-sessions-search`]}),n.invalidateQueries({queryKey:[`discovered-sessions-stats`]})},m=Mt({mutationFn:t=>YZt(e.id,t),onSuccess:()=>{i(null),p()},onError:(e,t)=>{i(QZt(e,t))}}),h=Mt({mutationFn:()=>XZt(e.id),onSuccess:p}),g=Mt({mutationFn:()=>ZZt(d.conversationName),onSuccess:()=>{n.invalidateQueries({queryKey:[`archived-conversations`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`conversations`]})}}),_=(e,t)=>(0,B.jsxs)(`div`,{className:`flex gap-2 text-xs py-1 border-b border-border`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground w-28 shrink-0`,children:e}),(0,B.jsx)(`span`,{className:`text-foreground font-mono break-all`,children:t??`—`})]}),v=e=>{let t=a.trim();m.mutate({tier:e,...t?{model:t}:{}})};return(0,B.jsxs)(`div`,{className:`flex flex-col h-full border-l border-border bg-background`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`Session #`,d.id]}),(0,B.jsx)(`span`,{className:d.overdeckManaged?`rounded border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,title:d.overdeckManaged?`Overdeck-managed session`:`Ad-hoc discovered session`,children:d.overdeckManaged?`Managed${d.panIssueId?` · ${d.panIssueId}`:``}`:`Ad-hoc`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f&&(0,B.jsx)(`button`,{onClick:()=>{f&&(window.history.pushState(null,``,Eyt(String(f))),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`rounded border border-border px-2 py-1 text-xs text-foreground transition-colors hover:border-border hover:bg-card`,children:`Open in Command Deck`}),(0,B.jsx)(`button`,{onClick:t,"aria-label":`Close session detail`,className:`text-muted-foreground/70 hover:text-foreground transition-colors`,children:(0,B.jsx)(sl,{className:`h-4 w-4`})})]})]}),(0,B.jsxs)(`details`,{open:!0,className:`shrink-0 border-b border-border`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground hover:text-foreground`,children:`Metadata and actions`}),(0,B.jsxs)(`div`,{className:`max-h-[38vh] overflow-auto px-3 py-2 space-y-4`,children:[d.summary&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Summary`}),(0,B.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed`,children:d.summary})]}),d.summaryDetailed&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Detailed`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:d.summaryDetailed})]}),d.tags.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tags`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.tags.map(e=>(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 bg-muted text-muted-foreground rounded text-[10px]`,children:e},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Metadata`}),_(`Workspace`,d.workspacePath),_(`Model`,d.primaryModel),_(`Messages`,d.messageCount),_(`Input tokens`,d.tokenInput.toLocaleString()),_(`Output tokens`,d.tokenOutput.toLocaleString()),_(`Est. cost`,d.estimatedCost>0?`$${d.estimatedCost.toFixed(6)}`:null),_(`First active`,d.firstTs?q8(d.firstTs):null),_(`Last active`,d.lastTs?q8(d.lastTs):null),s&&_(`Archived at`,d.archivedAt?q8(d.archivedAt):null),d.panIssueId&&_(`Issue`,d.panIssueId),_(`Enrichment`,d.enrichmentLevel===0?`None`:`L${d.enrichmentLevel}`)]}),d.toolsUsed.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tools Used`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.toolsUsed.map(e=>(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 bg-card text-muted-foreground rounded text-[10px] font-mono`,children:e},e))})]}),d.filesTouched.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Files Touched`}),(0,B.jsx)(`div`,{className:`space-y-1 max-h-28 overflow-auto`,children:d.filesTouched.map(e=>(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono break-all`,children:e},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`File`}),(0,B.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,B.jsx)(Is,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 font-mono break-all`,children:d.jsonlPath??`No JSONL path available`})]})]})]}),(0,B.jsx)(`div`,{className:`px-3 py-2 border-t border-border`,children:s?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:`Archived conversation`}),(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mb-2`,children:`Restore this conversation to the active Command Deck list.`}),(0,B.jsx)(`button`,{onClick:()=>g.mutate(),disabled:g.isPending||g.isSuccess,className:`rounded bg-warning/12 px-2 py-1 text-xs text-warning-foreground transition-colors hover:bg-warning/16 disabled:opacity-50`,children:g.isPending?`Unarchiving…`:`Unarchive`}),g.isSuccess&&(0,B.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Conversation restored`}),g.isError&&(0,B.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:g.error instanceof Error?g.error.message:`Unarchive failed`})]}):(0,B.jsxs)(B.Fragment,{children:[d.enrichmentLevel<3&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:d.enrichmentFailed?`Enrichment failed — retry:`:`Enrich this session`}),(0,B.jsx)(`div`,{className:`text-[10px] text-warning-foreground/80 mb-1.5`,children:`Sends redacted conversation excerpts to the configured enrichment provider.`}),(0,B.jsxs)(`label`,{className:`mb-2 block text-[10px] text-muted-foreground`,children:[`Custom model`,(0,B.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Use default provider model`,className:`mt-1 w-full rounded border border-border bg-card px-2 py-1 text-[10px] text-foreground placeholder:text-muted-foreground/70 focus:border-primary focus:outline-none`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d.enrichmentLevel<1&&(0,B.jsxs)(`button`,{onClick:()=>v(1),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,B.jsx)(Xc,{className:`h-3 w-3`}),`Quick (L1)`]}),d.enrichmentLevel<2&&(0,B.jsxs)(`button`,{onClick:()=>v(2),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,B.jsx)(Xc,{className:`h-3 w-3 text-muted-foreground`}),`Detailed (L2)`]}),(0,B.jsxs)(`button`,{onClick:()=>v(3),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,B.jsx)(Xc,{className:`h-3 w-3 text-muted-foreground`}),`Deep (L3)`]})]})]}),m.isPending&&(0,B.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Enriching…`}),l&&(0,B.jsxs)(`div`,{className:l.success?`text-[10px] text-success mt-1`:`text-[10px] text-destructive mt-1`,children:[`L`,l.level,` `,l.success?`complete`:`failed: ${l.error??`unknown error`}`,` · `,l.model]}),r&&(0,B.jsxs)(`div`,{className:`mt-2 rounded border border-warning/32 bg-warning/8 p-2 text-[10px] text-warning-foreground`,children:[`Estimated cost $`,r.estimatedCost.toFixed(4),` exceeds threshold $`,r.threshold.toFixed(2),` for `,r.sessionCount,` session`,r.sessionCount===1?``:`s`,`.`,(0,B.jsx)(`button`,{onClick:()=>m.mutate({tier:r.tier,confirmed:!0,model:r.model}),disabled:m.isPending,className:`ml-2 rounded bg-warning/12 px-1.5 py-0.5 text-warning-foreground disabled:opacity-50`,children:`Confirm`})]}),m.isError&&!r&&(0,B.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Enrichment failed`}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-border pt-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Semantic embedding`}),(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:`Generate or refresh this session's vector index.`})]}),(0,B.jsx)(`button`,{onClick:()=>h.mutate(),disabled:h.isPending,className:`px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:`Embed`})]}),h.isPending&&(0,B.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Embedding…`}),h.isSuccess&&(0,B.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Embedding complete`}),h.isError&&(0,B.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Embedding failed`})]})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(JZt,{session:d})})]})}function q8(e){try{return new Date(e).toISOString().replace(`T`,` `).slice(0,16)}catch{return e}}function rQt({isScanning:e,onScan:t,lastResult:n,progress:r}){let i=e||r?.active===!0;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?.active?(0,B.jsxs)(`span`,{className:`text-[10px] text-primary font-mono`,children:[r.dirsProcessed,`/`,r.dirsTotal,` files · `,r.sessionsFound,` sessions · `,(r.elapsedMs/1e3).toFixed(1),`s`]}):n&&!i&&(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,n.inserted,` ↑`,n.updated,` ·`,(n.durationMs/1e3).toFixed(1),`s`]}),(0,B.jsxs)(`button`,{onClick:t,disabled:i,className:`flex items-center gap-1.5 rounded px-3 py-1.5 bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 text-xs transition-colors`,children:[(0,B.jsx)(Mc,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),i?`Scanning…`:`Scan`]})]})}var iQt=[{label:`All time`,value:``},{label:`Today`,value:`today`},{label:`Last 7 days`,value:`7d`},{label:`Last 30 days`,value:`30d`},{label:`Last 90 days`,value:`90d`}],aQt=[{label:`All`,value:`all`},{label:`Discovered`,value:`discovered`},{label:`Managed-archived`,value:`managed-archived`}];function oQt({filters:e,facets:t,onChange:n}){let r=t.harnesses.some(e=>e.value!==`claude-code`);return(0,B.jsxs)(`div`,{className:`w-48 shrink-0 border-r border-border bg-background p-3 overflow-auto`,children:[(0,B.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:`Filters`}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Source`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:aQt.map(t=>(0,B.jsx)(`button`,{onClick:()=>n(`source`,t.value===`all`?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${(e.source??`all`)===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:t.label},t.value))})]}),r&&(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Harness`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.harnesses.map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`harness`,e.harness===t.value?void 0:t.value),className:`px-1.5 py-0.5 text-[10px] font-mono transition-colors ${e.harness===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Time range`}),(0,B.jsx)(`select`,{value:e.since??``,onChange:e=>n(`since`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:iQt.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:t.timeRanges.map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`since`,e.since===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.since===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace path`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-workspaces`,value:e.workspace??``,onChange:e=>n(`workspace`,e.target.value||void 0),placeholder:`e.g. /Projects/myapp`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-workspaces`,children:t.workspaces.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Model`}),(0,B.jsxs)(`select`,{value:e.model??``,onChange:e=>n(`model`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:[(0,B.jsx)(`option`,{value:``,children:`All models`}),t.models.map(e=>(0,B.jsxs)(`option`,{value:e.value,children:[e.value,` (`,e.count,`)`]},e.value))]}),(0,B.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.models.slice(0,8).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`model`,e.model===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.model===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tag`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-tags`,value:e.tag??``,onChange:e=>n(`tag`,e.target.value||void 0),placeholder:`e.g. bugfix`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-tags`,children:t.tags.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tags.slice(0,12).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`tag`,e.tag===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tag===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tool`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-tools`,value:e.tool??``,onChange:e=>n(`tool`,e.target.value||void 0),placeholder:`e.g. Read`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-tools`,children:t.tools.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tools.slice(0,12).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`tool`,e.tool===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tool===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`File touched`}),(0,B.jsx)(`input`,{type:`text`,list:`conversation-files`,value:e.file??``,onChange:e=>n(`file`,e.target.value||void 0),placeholder:`e.g. src/index.ts`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,B.jsx)(`datalist`,{id:`conversation-files`,children:t.files.map(e=>(0,B.jsx)(`option`,{value:e.value},e.value))}),(0,B.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.files.slice(0,8).map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`file`,e.file===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.file===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace cost`}),(0,B.jsx)(`div`,{className:`space-y-1 max-h-24 overflow-auto`,children:t.workspaces.slice(0,8).map(e=>(0,B.jsxs)(`button`,{onClick:()=>n(`workspace`,e.value),className:`w-full text-left text-[10px] text-muted-foreground hover:text-foreground truncate`,title:e.value,children:[e.count,` · $`,(e.cost??0).toFixed(4),` · `,e.value]},e.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Cost ranges`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.costRanges.map(t=>(0,B.jsxs)(`button`,{onClick:()=>{let r=e.minCost===t.minCost&&e.maxCost===t.maxCost;n(`minCost`,r?void 0:t.minCost),n(`maxCost`,r?void 0:t.maxCost)},className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.minCost===t.minCost&&e.maxCost===t.maxCost?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:`Estimated total $${(t.cost??0).toFixed(4)}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Enrichment levels`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.enrichmentLevels.map(t=>(0,B.jsxs)(`button`,{onClick:()=>n(`enrichmentLevel`,e.enrichmentLevel===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.enrichmentLevel===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[`L`,t.value,`: `,t.count]},t.value))})]}),(0,B.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Min cost`,(0,B.jsx)(`input`,{type:`number`,step:`0.001`,value:e.minCost??``,onChange:e=>n(`minCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]}),(0,B.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Max cost`,(0,B.jsx)(`input`,{type:`number`,step:`0.001`,value:e.maxCost??``,onChange:e=>n(`maxCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.managed===!0,onChange:e=>n(`managed`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Overdeck-managed`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.enriched===!0,onChange:e=>n(`enriched`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Enriched only`})]})]}),Object.values(e).some(Boolean)&&(0,B.jsx)(`button`,{onClick:()=>{n(`since`,void 0),n(`harness`,void 0),n(`workspace`,void 0),n(`managed`,void 0),n(`enriched`,void 0),n(`model`,void 0),n(`tag`,void 0),n(`tool`,void 0),n(`file`,void 0),n(`minCost`,void 0),n(`maxCost`,void 0),n(`enrichmentLevel`,void 0)},className:`mt-4 text-[10px] text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:`Clear filters`})]})}function sQt(e){return`${e.source}:${e.id}`}function cQt(e){let t=new Set,n=[];for(let r of e??[])for(let e of r.rows){let r=sQt(e);t.has(r)||(t.add(r),n.push(e))}return n}function lQt(e){return`${e.source}:${e.id}`}function uQt(e){return{harnesses:[],models:e?.primaryModels.map(e=>({value:e.value,count:e.count}))??[],workspaces:[],tags:e?.tags.map(e=>({value:e.value,count:e.count}))??[],tools:e?.tools.map(e=>({value:e.value,count:e.count}))??[],files:e?.files.map(e=>({value:e.value,count:e.count}))??[],timeRanges:e?.timeBuckets.map(e=>({value:e.value===`24h`?`today`:e.value,label:e.value===`24h`?`Today`:e.value,count:e.count}))??[],costRanges:e?.costBuckets.map(e=>({value:e.value,label:e.value,count:e.count,minCost:e.value===`<$0.10`?void 0:e.value===`$0.10-1`?`0.10`:e.value===`$1-10`?`1`:`10`,maxCost:e.value===`<$0.10`?`0.10`:e.value===`$0.10-1`?`1`:e.value===`$1-10`?`10`:void 0}))??[],enrichmentLevels:e?.enrichmentLevels.map(e=>({value:String(e.value),count:e.count}))??[]}}function dQt(e){let t=new URLSearchParams;return e.harness&&t.set(`harness`,e.harness),e.workspace&&t.set(`workspacePath`,e.workspace),e.since&&t.set(`since`,e.since),e.managed&&t.set(`managed`,`true`),e.enriched&&t.set(`enriched`,`true`),e.model&&t.set(`primaryModel`,e.model),e.tag&&t.set(`tag`,e.tag),e.tool&&t.set(`tool`,e.tool),e.file&&t.set(`file`,e.file),e.minCost&&t.set(`minCost`,e.minCost),e.maxCost&&t.set(`maxCost`,e.maxCost),e.enrichmentLevel&&t.set(`enrichmentLevel`,e.enrichmentLevel),e.source&&e.source!==`all`&&t.set(`source`,e.source),t}function J8(e){let t={},n=e.get(`harness`),r=e.get(`workspacePath`),i=e.get(`primaryModel`),a=e.get(`since`),o=e.get(`managed`),s=e.get(`enriched`),c=e.get(`tag`),l=e.get(`tool`),u=e.get(`file`),d=e.get(`minCost`),f=e.get(`maxCost`),p=e.get(`enrichmentLevel`),m=e.get(`source`),h=e.get(`query`);return n&&(t.harness=n),r&&(t.workspacePath=r),i&&(t.primaryModel=i),a&&(t.since=a),o&&(t.managed=o===`true`),s&&(t.enriched=s===`true`),c&&(t.tags=[c]),l&&(t.tools=[l]),u&&(t.files=[u]),d&&Number.isFinite(Number(d))&&(t.minCost=Number(d)),f&&Number.isFinite(Number(f))&&(t.maxCost=Number(f)),p&&Number.isFinite(Number(p))&&(t.enrichmentLevel=Number(p)),(m===`discovered`||m===`managed-archived`)&&(t.source=m),h&&(t.query=h),t}function fQt(e){return{id:e.id,source:`discovered`,discoveredId:e.id,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}function pQt(e){return{id:e.id,source:e.source,discoveredId:e.discoveredId??null,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,archivedAt:e.archivedAt??null,jsonlPath:e.jsonlPath??null,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[],filesTouched:[],tags:[...e.tags],summary:e.summary??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function mQt(e,t){let n=await lb().request(n=>n[Cy.listSessionsFeed]({...J8(e),limit:Number(e.get(`limit`)??50),...t?{cursor:t}:{}}));return{rows:n.rows.map(pQt),nextCursor:n.nextCursor??null}}async function hQt(e){return lb().request(t=>t[Cy.getSessionsFeedFacets]({...J8(e),limit:Number(e.get(`limit`)??50)}))}async function gQt(e,t,n=50,r=0,i=!1){let a=await lb().request(a=>a[Cy.searchConversations]({...J8(t),query:e,semantic:i,limit:n,offset:r}));return{...a,sessions:a.sessions.map(fQt)}}async function _Qt(){let e=await lb().request(e=>e[Cy.getConversationStats]({}));return{...e,embeddingModels:e.embeddingModels?.map(e=>({...e}))}}async function vQt(e){return lb().request(t=>t[Cy.getConversationCost](J8(e)))}async function yQt(){return lb().request(e=>e[Cy.scanConversations]({mode:`system`}))}function bQt({initialSessionKey:e=null}){let t=yt(),n=Q(KNe),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(e),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(0),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)({}),h=p.source??`all`,g=r.trim(),[_,v]=(0,z.useState)(g),y=h!==`managed-archived`,b=d&&y,x=b?_:``,S=b?``:g,C=dQt(p);(0,z.useEffect)(()=>{if(!b){v(g);return}let e=window.setTimeout(()=>v(g),350);return()=>window.clearTimeout(e)},[b,g]),(0,z.useEffect)(()=>{!y&&d&&(f(!1),u(0))},[y,d]),(0,z.useEffect)(()=>{o(e)},[e]);let w=new URLSearchParams({limit:`100`});for(let[e,t]of C)w.set(e,t);S&&w.set(`query`,S);let T=iee({queryKey:[`sessions-feed`,w.toString()],queryFn:({pageParam:e})=>mQt(w,e),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:!x}),{data:E}=V({queryKey:[`sessions-feed-facets`,w.toString()],queryFn:()=>hQt(w),enabled:!x,staleTime:3e4}),{data:D,isLoading:O}=V({queryKey:[`discovered-sessions-search`,x,C.toString(),l,b],queryFn:()=>gQt(x,C,50,l,b),enabled:!!x}),{data:k}=V({queryKey:[`discovered-sessions-stats`],queryFn:_Qt,staleTime:3e4}),{data:A}=V({queryKey:[`discovered-sessions-cost`,C.toString()],queryFn:()=>vQt(C),staleTime:3e4}),j=Mt({mutationFn:yQt,onSuccess:()=>{t.invalidateQueries({queryKey:[`sessions-feed`]}),t.invalidateQueries({queryKey:[`sessions-feed-facets`]}),t.invalidateQueries({queryKey:[`discovered-sessions-stats`]})}}),M=x?O:T.isLoading,N=cQt(T.data?.pages),P=x?D?.sessions??[]:N,F=a==null?null:P.find(e=>lQt(e)===a)??null,I=uQt(E),L=[h===`all`?null:{key:`source`,label:`Source: ${h===`discovered`?`Discovered`:`Managed-archived`}`},p.harness?{key:`harness`,label:`Harness: ${p.harness}`}:null,p.workspace?{key:`workspace`,label:`Workspace: ${p.workspace}`}:null,p.model?{key:`model`,label:`Model: ${p.model}`}:null,p.tag?{key:`tag`,label:`Tag: ${p.tag}`}:null,p.tool?{key:`tool`,label:`Tool: ${p.tool}`}:null,p.file?{key:`file`,label:`File: ${p.file}`}:null,p.since?{key:`since`,label:`Since: ${p.since}`}:null,p.managed?{key:`managed`,label:`Managed`}:null,p.enriched?{key:`enriched`,label:`Enriched`}:null,p.minCost?{key:`minCost`,label:`Min cost: $${p.minCost}`}:null,p.maxCost?{key:`maxCost`,label:`Max cost: $${p.maxCost}`}:null,p.enrichmentLevel?{key:`enrichmentLevel`,label:`Enrichment: L${p.enrichmentLevel}`}:null].filter(e=>e!==null);(0,z.useEffect)(()=>{x||a==null||F!=null||!T.hasNextPage||T.isFetchingNextPage||T.fetchNextPage()},[x,T,F,a]);let ee=(0,z.useCallback)(e=>{i(e),u(0)},[]),R=(0,z.useCallback)((e,t)=>{m(n=>({...n,[e]:t})),u(0)},[]),te=(0,z.useCallback)(e=>{o(e);let t=new URLSearchParams(window.location.search);e?t.set(`session`,e):t.delete(`session`);let n=t.toString();window.history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`)},[]);return(0,B.jsxs)(`div`,{className:`flex flex-col h-full bg-background text-foreground`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border shrink-0`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-medium text-foreground`,children:`Session History`}),k&&(0,B.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground ml-2`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-foreground font-mono`,children:k.total}),` indexed`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-success font-mono`,children:k.enriched}),` enriched`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-primary font-mono`,children:k.managedCount}),` managed`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsxs)(`span`,{className:`text-signal-cost-foreground font-mono`,children:[`$`,(A?.totalCost??0).toFixed(4)]}),` est. cost`]})]}),(0,B.jsx)(`div`,{className:`flex-1`}),(0,B.jsxs)(`div`,{className:`relative w-72`,children:[(0,B.jsx)(Vc,{className:`absolute left-2.5 top-2 h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`input`,{type:`text`,placeholder:`Search sessions…`,value:r,onChange:e=>ee(e.target.value),className:`w-full bg-card border border-border rounded pl-8 pr-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`})]}),(0,B.jsx)(`button`,{onClick:()=>{y&&(f(e=>!e),u(0))},disabled:!y,className:`px-3 py-1.5 rounded text-xs border transition-colors ${y?b?`bg-signal-review/8 border-signal-review/32 text-signal-review-foreground`:`bg-card border-border text-muted-foreground hover:border-border`:`bg-muted border-border text-muted-foreground/60 cursor-not-allowed`}`,children:b?`Semantic`:`Keyword`}),(0,B.jsxs)(`button`,{onClick:()=>c(e=>!e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs border transition-colors ${s?`bg-primary border-primary text-primary-foreground`:`bg-card border-border text-muted-foreground hover:border-border`}`,children:[(0,B.jsx)(Hs,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,B.jsx)(rQt,{isScanning:j.isPending,onScan:()=>j.mutate(),lastResult:j.data,progress:n})]}),L.length>0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-border bg-background shrink-0 text-xs`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Active filters`}),L.map(e=>(0,B.jsxs)(`button`,{onClick:()=>{R(e.key,void 0),e.key===`minCost`&&R(`maxCost`,void 0),e.key===`maxCost`&&R(`minCost`,void 0)},className:`px-2 py-1 rounded-sm bg-primary/8 text-primary border border-primary/32 hover:bg-primary hover:text-primary-foreground transition-colors`,children:[e.label,` `,(0,B.jsx)(`span`,{className:`text-primary`,children:`×`})]},e.key)),(0,B.jsx)(`button`,{onClick:()=>m({}),className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Clear all`})]}),(0,B.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[s&&(0,B.jsx)(oQt,{filters:p,facets:I,onChange:R}),(0,B.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 overflow-hidden ${F?`border-r border-border`:``}`,children:[x&&D?.error&&(0,B.jsxs)(`div`,{className:`px-4 py-2 border-b border-warning/32 bg-warning/8 text-warning-foreground text-xs`,children:[`Semantic search unavailable: `,D.error]}),M?(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Loading sessions…`}):P.length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-32 text-muted-foreground gap-2`,children:[(0,B.jsx)(`span`,{className:`text-sm`,children:`No sessions found`}),!k?.total&&(0,B.jsx)(`span`,{className:`text-xs`,children:`Run a scan to discover Claude Code sessions`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(UZt,{sessions:P,selectedId:a,onSelect:te,hasMore:!x&&T.hasNextPage,isLoadingMore:T.isFetchingNextPage,onLoadMore:()=>{T.fetchNextPage()}}),x&&D&&D.total>50&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-border shrink-0 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[l+1,`–`,l+P.length,` of `,D.total,` results`]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{disabled:l===0,onClick:()=>u(e=>Math.max(0,e-50)),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Prev`}),(0,B.jsx)(`button`,{disabled:l+50>=D.total,onClick:()=>u(e=>e+50),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Next`})]})]})]})]}),F&&(0,B.jsx)(`div`,{className:`min-w-[28rem] flex-[1.15] overflow-hidden`,children:(0,B.jsx)(nQt,{session:F,onClose:()=>te(null)})})]})]})}function xQt(e){return e===`warming`?(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin text-primary`}):e===`ready`?(0,B.jsx)(_s,{className:`h-4 w-4 text-green-500`}):e===`failed`?(0,B.jsx)(hs,{className:`h-4 w-4 text-destructive`}):(0,B.jsx)(xs,{className:`h-4 w-4 text-muted-foreground`})}function SQt({mode:e,warmupStatus:t,isListening:n,onStart:r,onBackToStaging:i,onReset:a,onToggleMic:o,voiceError:s}){return(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`AutoPreso`}),(0,B.jsx)(`h2`,{className:`mt-1 text-lg font-semibold`,children:`Voice whiteboard`})]}),(0,B.jsx)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs font-medium capitalize text-muted-foreground`,children:e})]}),(0,B.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-lg px-3 py-2 text-sm font-semibold transition-colors ${n?`bg-destructive text-destructive-foreground`:`bg-primary text-primary-foreground`}`,children:n?`Stop mic`:`Start mic`}),(0,B.jsx)(`button`,{type:`button`,onClick:e===`staging`?r:i,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-foreground hover:bg-accent`,children:e===`staging`?`Go live`:`Back to staging`})]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-muted/40 p-3 text-sm`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-foreground`,children:[xQt(t),`Warmup: `,(0,B.jsx)(`span`,{className:`capitalize`,children:t})]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The whiteboard agent uses the staged canvas as context before live transcription starts.`})]}),s&&(0,B.jsx)(`div`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),(0,B.jsx)(`button`,{type:`button`,onClick:a,className:`mt-3 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Reset session`})]})}function CQt({partialText:e,turns:t}){let n=(0,z.useRef)(null);return(0,z.useEffect)(()=>{n.current?.scrollIntoView({block:`end`})},[e,t]),(0,B.jsxs)(`section`,{className:`min-h-0 flex-1 rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Transcript`}),(0,B.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto pr-1 text-sm`,children:[t.length===0&&!e&&(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:`Spoken turns will appear here while AutoPreso listens.`}),t.map((e,t)=>(0,B.jsxs)(`article`,{className:`rounded-lg bg-muted/40 p-2 text-foreground`,children:[(0,B.jsx)(`time`,{className:`mb-1 block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.timestamp.toLocaleTimeString()}),(0,B.jsx)(`p`,{children:e.text})]},`${e.timestamp.toISOString()}-${t}`)),e&&(0,B.jsx)(`p`,{className:`rounded-lg border border-dashed border-border p-2 italic text-muted-foreground`,children:e}),(0,B.jsx)(`div`,{ref:n})]})]})}var wQt=25e4,TQt=6e3,EQt=200;function DQt(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function OQt(){let[e,t]=(0,z.useState)([]),[n,r]=(0,z.useState)(`staging`),[i,a]=(0,z.useState)(`idle`),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)([]),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(null),g=(0,z.useRef)(null),_=(0,z.useRef)(null),v=(0,z.useRef)(null),y=(0,z.useRef)(0),b=(0,z.useRef)(!0),x=(0,z.useRef)(null),S=(0,z.useRef)(null),C=(0,z.useRef)(null),w=(0,z.useRef)(null),T=(0,z.useRef)(null),E=(0,z.useRef)(null),D=(0,z.useCallback)(()=>{g.current?.close();let e=new WebSocket(DQt(`/ws/autopreso`));g.current=e,e.onopen=()=>{y.current=0},e.onmessage=e=>{let n=JSON.parse(String(e.data));(n.type===`whiteboard:snapshot`||n.type===`whiteboard:update`)&&(n.elements&&t(n.elements),n.mode&&r(n.mode),n.warmupStatus&&a(n.warmupStatus))},e.onclose=()=>{if(!b.current||g.current!==e)return;let t=Math.min(1e3*2**y.current,1e4);y.current+=1,v.current=window.setTimeout(D,t)}},[]),O=(0,z.useCallback)(e=>{d(!1),e&&_.current?.close(),e&&(_.current=null),C.current?.disconnect(),w.current?.disconnect(),T.current?.disconnect(),S.current?.close(),x.current?.getTracks().forEach(e=>e.stop()),C.current=null,w.current=null,T.current=null,S.current=null,x.current=null,h(null)},[]),k=(0,z.useCallback)(async(e=!0)=>{let t=_.current;O(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,TQt);E.current=()=>{window.clearTimeout(t),e()}}),E.current=null),O(!0)},[O]);return(0,z.useEffect)(()=>(b.current=!0,D(),()=>{b.current=!1,v.current&&window.clearTimeout(v.current),v.current=null;let e=g.current;g.current=null,e?.close(),k(!1)}),[D,k]),{elements:e,mode:n,warmupStatus:i,partialText:o,committedTurns:c,isListening:u,voiceError:f,startListening:(0,z.useCallback)(async()=>{if(u)return;p(null);let e=null,t=null,n=null,r=null,i=null,a=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0});let o=window.AudioContext;t=new o({sampleRate:24e3}),n=t.createMediaStreamSource(e),r=t.createAnalyser(),i=t.createScriptProcessor(4096,1,1),a=new WebSocket(DQt(`/ws/voice`)),a.binaryType=`arraybuffer`,a.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`transcript:partial`&&s(t.text),t.type===`transcript:committed`&&(s(``),l(e=>[...e,{text:t.text,timestamp:new Date}].slice(-EQt))),t.type===`transcript:finalized`&&E.current?.(),t.type===`error`&&p(t.error)},a.onclose=()=>{_.current===a&&k(!1)},i.onaudioprocess=e=>{if(a?.readyState!==WebSocket.OPEN||a.bufferedAmount>wQt)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}a.send(n.buffer)},n.connect(r),r.connect(i),i.connect(t.destination),x.current=e,S.current=t,w.current=n,T.current=r,C.current=i,_.current=a,h(r),d(!0)}catch(o){a?.close(),i?.disconnect(),n?.disconnect(),r?.disconnect(),t?.close(),e?.getTracks().forEach(e=>e.stop()),p(o instanceof Error?o.message:`Unable to start voice input`)}},[u,k]),stopListening:k,analyserNode:m}}var kQt=(0,z.lazy)(async()=>({default:(await v(()=>import(`./prod-DBuCX9g-.js`),__vite__mapDeps([109,2,3,110,111,112,6,113,114,5]))).Excalidraw}));function AQt(){let{elements:e,mode:t,warmupStatus:n,partialText:r,committedTurns:i,isListening:a,voiceError:o,startListening:s,stopListening:c}=OQt(),[l,u]=(0,z.useState)([]),d=(0,z.useRef)(null),f=t===`live`?e:l,p=(0,z.useMemo)(()=>({elements:f}),[f]),m=(0,z.useCallback)(async()=>{await fetch(`/api/autopreso/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({elements:l,screenshotBase64:null})})},[l]),h=(0,z.useCallback)(async()=>{await fetch(`/api/autopreso/back-to-staging`,{method:`POST`})},[]),g=(0,z.useCallback)(async()=>{await fetch(`/api/autopreso/session/reset`,{method:`POST`}),u([]),d.current?.updateScene?.({elements:[]})},[]),_=(0,z.useCallback)(()=>{a?c():s()},[a,s,c]),v=(0,z.useCallback)(e=>{t===`staging`&&u(e)},[t]),y=(0,z.useCallback)(e=>{d.current=e},[]);return(0,z.useEffect)(()=>{t===`live`&&d.current?.updateScene?.({elements:e})},[t,e]),(0,B.jsxs)(`div`,{className:`flex h-full w-full gap-4 overflow-hidden bg-background p-4 text-foreground`,children:[(0,B.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading whiteboard…`}),children:(0,B.jsx)(kQt,{excalidrawAPI:y,initialData:p,onChange:v,viewModeEnabled:t===`live`},t)})}),(0,B.jsxs)(`aside`,{className:`flex w-96 shrink-0 flex-col gap-4 overflow-y-auto`,children:[(0,B.jsx)(SQt,{mode:t,warmupStatus:n,isListening:a,onStart:m,onBackToStaging:h,onReset:g,onToggleMic:_,voiceError:o}),(0,B.jsx)(CQt,{turns:i,partialText:r})]})]})}function Y8({fallback:e,children:t}){return Q(WNe)?(0,B.jsx)(B.Fragment,{children:t}):(0,B.jsx)(B.Fragment,{children:e})}var jQt=`overdeck:ui-mode`,MQt=`overdeck:last-tab`;function NQt(){if(typeof window>`u`)return`advanced`;try{let e=window.localStorage.getItem(jQt);return e===`simple`||e===`advanced`?e:window.localStorage.getItem(MQt)?`advanced`:`simple`}catch{return`advanced`}}var X8=tS(e=>({mode:NQt(),setMode:t=>{try{window.localStorage.setItem(jQt,t)}catch{}e({mode:t})},simpleIssueId:null,openSimpleIssue:t=>e({simpleIssueId:t}),closeSimpleIssue:()=>e({simpleIssueId:null})}));function PQt(e){if(typeof window>`u`)return;let t=e?`/issues/${encodeURIComponent(e)}`:`/`;window.location.pathname!==t&&window.history.pushState({},``,t)}var Z8={home:{greetingFallback:`Hello.`,needsYouTitle:`Needs you`,needsYouSub:`Work pauses until you answer. Everything else keeps going.`,workingTitle:`Working now`,workingSub:`Nothing for you to do on these — you'll be told when they're ready.`,readyTitle:`Ready to merge`,doneTitle:`Finished`,composerPlaceholder:`Describe what you want built or fixed, in plain words…`,composerButton:`Talk it through`,nothingNeedsYou:`Nothing needs you right now. Nice.`,quietEmpty:`Nothing here yet.`},issue:{backToMyWork:`← My work`,composerPlaceholder:`Say something to the agent… (steer it, correct it, ask why)`,composerHint:`Talking to it never interrupts the work — it reads you between tasks.`,answerPlaceholder:`Type your answer…`,answerHint:`One sentence is enough. It continues immediately after you answer.`,whatHappened:`What happened`,advancedDisclosure:`Advanced — the machinery behind this task`,getHelp:`Get help`,steps:[`Started`,`Writing code`,`Checking`,`Ready`],feedTitle:`What it's doing`,waitingOnYou:`waiting on you`,taskStartedPrefix:`Task started · told to `,rawPromptDisclosure:`See the full instructions it was given`,readMore:`Read more`,showLess:`Show less`,pausedWaiting:`Paused — waiting for your answer`,pausedToStart:`Paused — waiting for you to start the work`,sentToAgent:`Sent to the agent`,questionTitle:`It has a question for you`,screenExcerptLabel:`Here's what it's showing on its screen:`,questionAskedPrefix:`Asked `,questionPauseSuffix:`work pauses until you answer — everything else keeps going`,questionAnswerPlaceholder:`Or type your own answer…`,answerSend:`Send answer`,questionOptionsHint:`Pick an option or write one sentence — it continues as soon as you answer.`,answerSentTitle:`Answer sent`,answerSentSub:`It's reading your answer and getting back to work.`,liveLabel:`live`,readyLiveRow:`All checks passed — ready when you are`},mode:{simple:`Simple`,advanced:`Advanced`}};function Q8(){let e=X8(e=>e.mode),t=X8(e=>e.setMode);return(0,B.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-lg border border-input`,children:[{id:`simple`,label:Z8.mode.simple},{id:`advanced`,label:Z8.mode.advanced}].map(n=>(0,B.jsx)(`button`,{onClick:()=>t(n.id),className:Kx(`px-3 py-1.5 text-xs font-medium transition-colors`,e===n.id?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`),children:n.label},n.id))})}function FQt({state:e,pipelineState:t}){let n=Z8.issue.steps,r=Bgt(t),i=e===`needs-you`;return(0,B.jsx)(`div`,{className:`mt-5 flex`,role:`list`,children:n.map((t,a)=>{let o=a<r||e===`done`,s=a===r&&e!==`done`&&e!==`ready`,c=a===n.length-1;return(0,B.jsxs)(`div`,{role:`listitem`,className:`relative flex-1 pt-3.5 text-center`,children:[(0,B.jsx)(`span`,{className:Kx(`absolute left-0 right-0 top-[5px] h-0.5`,a===0&&`left-1/2`,c&&`right-1/2`,o||s?`bg-success`:`bg-muted`)}),(0,B.jsx)(`span`,{className:Kx(`absolute left-1/2 top-0 h-3 w-3 -translate-x-1/2 rounded-full border-2`,o&&`border-transparent bg-success`,s&&!i&&`border-transparent bg-info shadow-[0_0_0_3px] shadow-info/25`,s&&i&&`border-transparent bg-warning shadow-[0_0_0_3px] shadow-warning/25`,!o&&!s&&`border-border bg-muted`)}),(0,B.jsx)(`span`,{className:Kx(`text-[11.5px]`,o&&`text-success-foreground`,s&&`font-medium text-foreground`,!o&&!s&&`text-muted-foreground`),children:t}),s&&i&&(0,B.jsx)(`span`,{className:`mt-0.5 block text-[10.5px] text-warning-foreground`,children:Z8.issue.waitingOnYou})]},t)})})}var IQt={"not-started":{accent:`border-transparent`,iconBg:`bg-muted text-muted-foreground`,icon:(0,B.jsx)(zie,{size:15})},working:{accent:`border-info`,iconBg:`bg-info/10 text-info-foreground`,icon:(0,B.jsx)(gc,{size:15})},"needs-you":{accent:`border-warning`,iconBg:`bg-warning/10 text-warning-foreground`,icon:(0,B.jsx)(vs,{size:15})},ready:{accent:`border-success`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,B.jsx)(us,{size:15})},done:{accent:`border-transparent`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,B.jsx)(us,{size:15})}};function LQt({display:e,children:t}){let n=IQt[e.state];return(0,B.jsxs)(`div`,{className:Kx(`mt-4 rounded-2xl border-l-[3px] bg-card p-4`,`shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border dark:shadow-none`,n.accent),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:Kx(`flex h-8 w-8 flex-none items-center justify-center rounded-full`,n.iconBg),children:n.icon}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[15px] font-medium`,children:e.title}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.sentence})]})]}),t&&(0,B.jsx)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-2`,children:t})]})}function RQt({completed:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,B.jsx)(`div`,{className:`mt-2.5 h-1 overflow-hidden rounded-full bg-accent`,"aria-label":`${e} of ${t}`,children:(0,B.jsx)(`div`,{className:`h-full rounded-full bg-info`,style:{width:`${n}%`}})})}function $8({children:e,onClick:t,disabled:n,tone:r=`primary`}){return(0,B.jsx)(`button`,{"data-slot":`primary-action`,onClick:t,disabled:n,className:Kx(`inline-flex h-9 items-center rounded-lg px-4 text-[13.5px] font-medium text-white transition-opacity`,r===`success`?`bg-success text-[#04120c]`:`bg-primary text-primary-foreground`,n?`cursor-not-allowed opacity-50`:`hover:opacity-90`),children:e})}function e5({children:e,onClick:t,disabled:n}){return(0,B.jsx)(`button`,{onClick:t,disabled:n,className:Kx(`inline-flex h-9 items-center rounded-lg border border-input px-4 text-[13.5px] font-medium text-muted-foreground transition-colors`,n?`cursor-not-allowed opacity-50`:`hover:bg-accent hover:text-foreground`),children:e})}var zQt=`overdeck:talk-project`;function BQt(e){try{let t=localStorage.getItem(zQt);if(t&&e.some(e=>e.key===t))return t}catch{}let t=window.location.pathname.match(/^\/command-deck\/([^/]+)/);return t&&e.some(e=>e.key===t[1])?t[1]:e[0]?.key}function VQt(e){return[`I want to discuss a possible task with you first — do not file anything yet.`,``,`The task idea, in my words:`,`"""`,e.trim(),`"""`,``,`Discuss it with me: ask what you need to know, point out what is underspecified or wrong, and help me sharpen it.`,`Only when I explicitly say it is ready (e.g. "file it"), file it as an issue in the tracker with a good title and body based on our discussion, and give me the issue link (e.g. PAN-1234).`].join(`
|
|
737
737
|
`)}function HQt(){let[e,t]=(0,z.useState)(``),[n,r]=(0,z.useState)(()=>DD()||`claude-opus-4-6`),[i,a]=(0,z.useState)(`claude-code`),o=V({queryKey:[`projects`],queryFn:UC,staleTime:6e4}).data??[],[s,c]=(0,z.useState)(void 0),l=s??BQt(o);(0,z.useEffect)(()=>{OD().then(()=>{let e=DD();e&&r(e)})},[]);let u=Mt({mutationFn:async e=>{let t=await fetch(`/api/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:n,harness:i,projectKey:l,message:VQt(e)})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to start the conversation (${t.status})`)}return t.json()},onSuccess:e=>{if(e?.name){try{l&&localStorage.setItem(zQt,l)}catch{}window.location.assign(`/conv/${encodeURIComponent(e.name)}`)}}}),d=()=>{let t=e.trim();t&&u.mutate(t)};return(0,B.jsxs)(`div`,{className:`mt-4 flex items-center gap-2.5`,children:[(0,B.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d()},placeholder:Z8.home.composerPlaceholder,className:`h-11 flex-1 rounded-2xl border border-input bg-card px-4 text-sm text-foreground outline-none focus:border-ring`,"data-testid":`talk-it-through-input`}),o.length>0&&(0,B.jsx)(`select`,{value:l,onChange:e=>c(e.target.value),"aria-label":`Project for this conversation`,"data-testid":`talk-it-through-project`,className:`h-11 max-w-[150px] rounded-xl border border-input bg-card px-2 text-xs text-muted-foreground outline-none focus:border-ring`,children:o.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.name},e.key))}),(0,B.jsx)($W,{value:n,onChange:e=>r(e),harness:i,onHarnessChange:e=>a(e)}),(0,B.jsx)($8,{disabled:!e.trim()||u.isPending,onClick:d,children:u.isPending?`Starting…`:Z8.home.composerButton})]})}var t5=Z8.home;function n5(e,t){t(e.issue.identifier),PQt(e.issue.identifier)}var UQt=1440*60*1e3;function WQt(e,t=Date.now()){return e.filter(e=>{if(e.display.state!==`not-started`)return!1;let n=Date.parse(e.issue.createdAt??``);return Number.isFinite(n)&&t-n<UQt}).sort((e,t)=>(t.issue.createdAt??``).localeCompare(e.issue.createdAt??``)).slice(0,5)}function GQt({item:e,onOpen:t}){let n=J$(),r=KQt(e.issue.createdAt);return(0,B.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px]`,children:e.issue.identifier}),r&&(0,B.jsxs)(`span`,{children:[`filed `,r]})]}),(0,B.jsx)(`button`,{onClick:t,className:`mt-0.5 block w-full truncate text-left text-sm font-medium hover:underline`,children:e.issue.title})]}),(0,B.jsx)(e5,{onClick:t,children:`Open`}),(0,B.jsx)($8,{disabled:n.startPlanning.isPending,onClick:()=>n.startPlanning.mutate({issueId:e.issue.identifier}),children:`Start planning`})]})}function KQt(e){let t=Date.parse(e??``);if(!Number.isFinite(t))return``;let n=Math.round((Date.now()-t)/6e4);return n<60?`${Math.max(n,1)}m ago`:`${Math.round(n/60)}h ago`}function qQt({item:e,subject:t,onOpen:n}){let r=J$(),i=Q(e=>e.agentsById),[a,o]=(0,z.useState)(``),s=t?.agentId,c=!!(s&&!i?.[s]),l=s??e.pendingInputAgent?.id,u=t?.pendingAskUserQuestion?.questions?.[0]?.question??e.display.sentence,d=r.answer.isPending;return(0,B.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-warning/40 bg-card p-4 shadow-sm`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:(0,B.jsxs)(`span`,{children:[`Question · `,(e.issue.title,``),e.issue.identifier]})}),(0,B.jsx)(`button`,{onClick:n,className:`mt-1 text-left text-[15px] font-medium hover:underline`,children:e.issue.title}),(0,B.jsx)(`p`,{className:`mt-2 text-[13.5px] leading-relaxed`,children:u}),(0,B.jsxs)(`div`,{className:`mt-2.5 flex gap-2`,children:[(0,B.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&l&&r.answer.mutate({agentId:l,text:a.trim(),isConversation:c})},placeholder:Z8.issue.answerPlaceholder,className:`h-9 flex-1 rounded-lg border border-input bg-muted px-3 text-[13px] text-foreground outline-none focus:border-ring`}),(0,B.jsx)($8,{disabled:!a.trim()||!l||d,onClick:()=>l&&r.answer.mutate({agentId:l,text:a.trim(),isConversation:c}),children:e.display.primaryAction??`Answer`})]}),(0,B.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:Z8.issue.answerHint})]})}function JQt({item:e,kind:t,onOpen:n}){let r=J$(),i=e.primaryAgent,a=r.tell.isPending||r.recover.isPending||r.unstick.isPending||r.startWork.isPending,o=t===`stuck`,s=t===`start-work`;return(0,B.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-warning/40 bg-card p-4 shadow-sm`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:(0,B.jsxs)(`span`,{children:[o?`Stuck`:s?e.display.title:`Problems found`,` · `,e.issue.identifier]})}),(0,B.jsx)(`button`,{onClick:n,className:`mt-1 text-left text-[15px] font-medium hover:underline`,children:e.issue.title}),(0,B.jsx)(`p`,{className:`mt-2 text-[13.5px] leading-relaxed`,children:e.display.sentence}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?(0,B.jsx)($8,{disabled:a,onClick:()=>r.startWork.mutate({issueId:e.issue.identifier}),children:e.display.primaryAction}):o?(0,B.jsx)($8,{disabled:a||!e.reviewStuck&&!i,onClick:()=>{e.reviewStuck&&r.unstick.mutate({issueId:e.issue.identifier}),e.agentStuck&&i&&r.recover.mutate({agentId:i.id})},children:`Get it unstuck`}):(0,B.jsx)($8,{disabled:!i||a,onClick:()=>i&&r.tell.mutate({agentId:i.id,message:`Please address the review findings and get this back to green.`}),children:`Tell the agent to fix them`}),(0,B.jsx)(e5,{onClick:n,children:`Open`})]})]})}function YQt({item:e,onOpen:t}){return(0,B.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-3.5 rounded-xl border border-border bg-card px-4 py-3.5 shadow-sm`,children:[(0,B.jsx)(`span`,{className:`h-2 w-2 flex-none animate-pulse rounded-full bg-info`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`button`,{onClick:t,className:`block w-full truncate text-left text-sm font-medium hover:underline`,children:e.issue.title}),(0,B.jsxs)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`text-info-foreground`,children:e.display.title}),e.taskProgress?` · task ${e.taskProgress.completed} of ${e.taskProgress.total}`:``,e.expectation?` · ${e.expectation}`:``]}),e.taskProgress&&(0,B.jsx)(RQt,{completed:e.taskProgress.completed,total:e.taskProgress.total})]}),(0,B.jsx)(e5,{onClick:t,children:`Watch`})]})}function XQt({item:e,onOpen:t}){let n=J$();return(0,B.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-success/40 bg-card p-4 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`All checks passed · `,e.issue.identifier]}),(0,B.jsx)(`button`,{onClick:t,className:`mt-1 text-left text-[15px] font-medium hover:underline`,children:e.issue.title}),(0,B.jsx)(`p`,{className:`mt-2 text-[13.5px] leading-relaxed`,children:e.display.sentence}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,B.jsx)($8,{tone:`success`,disabled:n.merge.isPending,onClick:()=>n.merge.mutate({issueId:e.issue.identifier}),children:`Merge to main`}),e.prUrl&&(0,B.jsx)(e5,{onClick:()=>window.open(e.prUrl,`_blank`,`noopener`),children:`See the changes`}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`Nothing merges by itself here`})]})]})}function ZQt(){let e=Q(e=>e.issuesRaw),t=Q(e=>e.agentsById),n=Q(e=>e.reviewStatusByIssueId),r=jG(),i=X8(e=>e.openSimpleIssue),{derivations:a,buckets:o,byIdentifier:s}=(0,z.useMemo)(()=>{let r=e??[],i=Object.values(t??{}),a=new Map;for(let e of i){let t=e.issueId?.toLowerCase();if(!t)continue;let n=a.get(t)??[];n.push(e),a.set(t,n)}let o=r.map(e=>K$(e,a.get(e.identifier.toLowerCase())??[],n?.[e.identifier]));return{derivations:o,buckets:gCt(o),byIdentifier:new Map(o.map(e=>[e.issue.identifier.toLowerCase(),e]))}},[e,t,n]),c=(0,z.useMemo)(()=>{let e=new Map;for(let t of r??[])t.issueId&&e.set(t.issueId.toLowerCase(),t);return e},[r]),l=(0,z.useMemo)(()=>{let e=new Set(o.needsYou.map(e=>e.derivation.issue.identifier.toLowerCase())),t=[];for(let[n,r]of c){if(e.has(n))continue;let i=s.get(n);i&&t.push({derivation:i,subject:r})}return t},[o.needsYou,c,s]),u=o.needsYou.length+l.length,d=(0,z.useMemo)(()=>WQt(a),[a]);return(0,B.jsx)(`div`,{"data-component":`simple-home-page`,className:`h-full w-full overflow-y-auto`,children:(0,B.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 pb-24 pt-7`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-medium`,children:u>0?`${u} thing${u===1?``:`s`} need${u===1?`s`:``} you.`:t5.greetingFallback}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:u>0?`Everything else is moving on its own.`:t5.nothingNeedsYou}),(0,B.jsxs)(`div`,{className:`mt-3 flex gap-4 text-[13px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{className:`font-medium text-foreground`,children:o.working.length}),` being worked on`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{className:`font-medium text-foreground`,children:o.ready.length}),` ready to merge`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{className:`font-medium text-foreground`,children:o.finished.length}),` finished this week`]})]})]}),(0,B.jsx)(Q8,{})]}),(0,B.jsx)(HQt,{}),(0,B.jsxs)(`section`,{className:`mt-8`,children:[(0,B.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[t5.needsYouTitle,` `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u})]}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t5.needsYouSub}),u===0&&(0,B.jsx)(`div`,{className:`mt-3 rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:t5.nothingNeedsYou}),o.needsYou.map(({derivation:e,kind:t})=>t===`question`?(0,B.jsx)(qQt,{item:e,subject:c.get(e.issue.identifier.toLowerCase()),onOpen:()=>n5(e,i)},e.issue.identifier):(0,B.jsx)(JQt,{item:e,kind:t,onOpen:()=>n5(e,i)},e.issue.identifier)),l.map(({derivation:e,subject:t})=>(0,B.jsx)(qQt,{item:e,subject:t,onOpen:()=>n5(e,i)},`q-${e.issue.identifier}`))]}),d.length>0&&(0,B.jsxs)(`section`,{className:`mt-8`,children:[(0,B.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[`Just filed `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d.length})]}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Fresh from your conversations — start planning when you're ready.`}),d.map(e=>(0,B.jsx)(GQt,{item:e,onOpen:()=>n5(e,i)},e.issue.identifier))]}),(0,B.jsxs)(`section`,{className:`mt-8`,children:[(0,B.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[t5.workingTitle,` `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.working.length})]}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t5.workingSub}),o.working.map(e=>(0,B.jsx)(YQt,{item:e,onOpen:()=>n5(e,i)},e.issue.identifier))]}),o.ready.length>0&&(0,B.jsxs)(`section`,{className:`mt-8`,children:[(0,B.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[t5.readyTitle,` `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.ready.length})]}),o.ready.map(e=>(0,B.jsx)(XQt,{item:e,onOpen:()=>n5(e,i)},e.issue.identifier))]}),o.finished.length>0&&(0,B.jsxs)(`section`,{className:`mt-8`,children:[(0,B.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[t5.doneTitle,` `,(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.finished.length})]}),(0,B.jsx)(`div`,{className:`mt-2`,children:o.finished.slice(0,8).map(e=>(0,B.jsxs)(`button`,{onClick:()=>n5(e,i),className:`flex w-full items-center gap-2.5 border-b border-border py-2.5 text-left text-[13px] last:border-none hover:bg-accent/40`,children:[(0,B.jsx)(`span`,{className:`flex h-4 w-4 flex-none items-center justify-center rounded-full bg-success/15 text-[10px] text-success-foreground`,children:`✓`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.issue.title}),(0,B.jsx)(`span`,{className:`ml-auto flex-none text-[11.5px] text-muted-foreground`,children:e.issue.identifier})]},e.issue.identifier))})]})]})})}function QQt(e){let t=e.url??``,n=/^https?:\/\/github\.com\/([^/]+\/[^/]+)\/issues\/\d+/.exec(t);if(n){let t=encodeURIComponent(`[HELP] ${e.identifier}: ${e.title}`.slice(0,200));return`https://github.com/${n[1]}/issues/new?title=${t}`}let r=/^https?:\/\/linear\.app\/([^/]+)\/issue\//.exec(t);return r?`https://linear.app/${r[1]}/new`:null}var r5=280,$Qt=80,i5=2,e$t={Bash:`Ran`,Read:`Read`,Edit:`Edited`,MultiEdit:`Edited`,Write:`Wrote`,NotebookEdit:`Edited`,Glob:`Searched`,Grep:`Searched`,LS:`Listed files in`,WebFetch:`Fetched`,WebSearch:`Searched the web for`,TodoWrite:`Updated the task list`},t$t={Bash:`Ran a command`,Read:`Read a file`,Edit:`Edited a file`,MultiEdit:`Edited a file`,Write:`Wrote a file`,NotebookEdit:`Edited a file`,Glob:`Searched the code`,Grep:`Searched the code`,LS:`Listed files`,WebFetch:`Fetched a page`,WebSearch:`Searched the web`,TodoWrite:`Updated the task list`};function n$t(e){return e.replace(/```[\s\S]*?```/g,` … `).replace(/`([^`]*)`/g,`$1`).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/__([^_]+)__/g,`$1`).replace(/(^|\s)\*([^*\n]+)\*(?=\s|$)/g,`$1$2`).replace(/^\s*[-*+]\s+/gm,``).replace(/\s+/g,` `).trim()}function r$t(e){return e.tone===`error`||/^error[:\s]/i.test(e.detail??``)}function i$t(e){let t=e.changedFiles??[];if(t.length>0)return`Edited ${t.slice(0,i5).join(`, `)}${t.length>i5?` (+${t.length-i5} more)`:``}`;if(e.command)return`Ran ${e.command.length>$Qt?`${e.command.slice(0,$Qt)}…`:e.command}`;if(r$t(e)&&e.detail)return e.detail;let n=e$t[e.label];return n&&e.detail?`${n} ${e.detail}`:e.detail?e.detail:t$t[e.label]??e.label}function a$t(e){let t=[],n=!1;for(let r of e.messages){if(r.role===`user`&&!n){n=!0,t.push({kind:`system`,id:`sys-${r.id}`,createdAt:r.createdAt,text:Z8.issue.taskStartedPrefix+e.issueTitle.toLowerCase(),raw:r.text});continue}if(r.role===`user`){t.push({kind:`reply`,id:`re-${r.id}`,createdAt:r.createdAt,text:r.text});continue}if(r.role===`assistant`){let e=n$t(r.text);t.push({kind:`say`,id:`say-${r.id}`,createdAt:r.createdAt,preview:e.length>r5?`${e.slice(0,r5)}…`:e,full:r.text,clamp:r.text.length>r5})}}for(let n of e.workLog)n.tone!==`thinking`&&t.push({kind:`action`,id:`act-${n.id}`,createdAt:n.createdAt,text:i$t(n),files:n.changedFiles,failed:r$t(n)});return t.map((e,t)=>({entry:e,index:t})).sort((e,t)=>{let n=new Date(e.entry.createdAt).getTime(),r=new Date(t.entry.createdAt).getTime();return n===r?e.index-t.index:n-r}).map(({entry:e})=>e)}var a5=Z8.issue;function o$t({issue:e,agents:t,agent:n,onSelectAgent:r,state:i,needsYouReason:a}){let o=(0,z.useMemo)(()=>kft(n),[n]),{enabled:s}=uft(o),c=yt(),l=(0,z.useMemo)(()=>qX(o.name),[o.name]),u=!eZ(n),{data:d}=V({queryKey:l,queryFn:async({signal:e})=>{let t=await Eft(o.name,e,n.id);if(s){let e=c.getQueryData(l);if(e&&e.messages.length>=t.messages.length)return e}return t},enabled:!s,refetchInterval:s?!1:u?2e3:!1}),f=(0,z.useMemo)(()=>d?.messages??[],[d]),p=(0,z.useMemo)(()=>d?.workLog??[],[d]),m=(0,z.useMemo)(()=>a$t({messages:f,workLog:p,issueTitle:e.title}),[f,p,e.title]),h=(0,z.useRef)(null),g=(0,z.useRef)(!0);(0,z.useEffect)(()=>{let e=h.current;e&&g.current&&(e.scrollTop=e.scrollHeight)},[m.length]);let _=u&&(n.status===`running`||n.status===`starting`),v=i===`needs-you`;return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2.5`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium`,children:a5.feedTitle}),v?(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-warning-foreground`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),` `,a5.waitingOnYou]}):_?(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-info-foreground`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-info`}),` `,a5.liveLabel]}):null,(0,B.jsxs)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:[s$t(n.role),` agent · `,(0,B.jsx)(`span`,{className:`font-mono`,children:n.id.replace(/^agent-/,``)})]})]}),t.length>1&&(0,B.jsx)(`div`,{className:`mt-2 inline-flex overflow-hidden rounded-lg border border-input`,children:t.map(e=>(0,B.jsx)(`button`,{onClick:()=>r(e.id),className:Kx(`px-3 py-1.5 text-xs font-medium transition-colors`,e.id===n.id?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`),children:s$t(e.role)},e.id))}),(0,B.jsxs)(`div`,{ref:h,onScroll:e=>{let t=e.currentTarget;g.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},className:`mt-2.5 max-h-[470px] overflow-y-auto border-t border-border`,children:[m.map(e=>(0,B.jsx)(c$t,{entry:e},e.id)),(0,B.jsx)(l$t,{state:i,needsYouReason:a,running:_,messages:f,workLog:p})]})]})}function s$t(e){return e?`${e[0].toUpperCase()}${e.slice(1)}`:`Agent`}function c$t({entry:e}){let[t,n]=(0,z.useState)(!1),r=(0,B.jsx)(`span`,{className:`mt-0.5 flex-none text-[11px] text-muted-foreground`,children:JD(e.createdAt,new Date)});return e.kind===`system`?(0,B.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,B.jsx)(Us,{size:13})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[e.text,(0,B.jsxs)(`details`,{className:`mt-1`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-[11.5px] underline underline-offset-2`,children:a5.rawPromptDisclosure}),(0,B.jsx)(`pre`,{className:`mt-2 max-h-[180px] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-accent p-2.5 font-mono text-[11.5px] leading-relaxed`,children:e.raw})]})]}),r]}):e.kind===`say`?(0,B.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,B.jsx)(sae,{size:13})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 text-[13.5px]`,children:[t?(0,B.jsx)(eS,{text:e.full}):e.preview,e.clamp&&(0,B.jsx)(`button`,{onClick:()=>n(e=>!e),className:`ml-1.5 text-[11.5px] text-info-foreground`,children:t?a5.showLess:a5.readMore})]}),r]}):e.kind===`action`?(0,B.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,B.jsx)(ol,{size:13})}),(0,B.jsx)(`div`,{className:Kx(`min-w-0 flex-1 truncate text-[13px]`,e.failed?`text-destructive-foreground`:`text-muted-foreground`),children:e.text}),r]}):(0,B.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,B.jsx)(bae,{size:13})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 text-[13px]`,children:[(0,B.jsx)(`span`,{className:`mr-1.5 text-[11px] text-muted-foreground`,children:a5.sentToAgent}),(0,B.jsx)(`span`,{className:Kx(!t&&`line-clamp-3`),children:e.text}),e.text.length>280&&(0,B.jsx)(`button`,{onClick:()=>n(e=>!e),className:`ml-1.5 text-[11.5px] text-info-foreground`,children:t?a5.showLess:a5.readMore})]}),r]})}function l$t({state:e,needsYouReason:t,running:n,messages:r,workLog:i}){if(e===`needs-you`)return(0,B.jsxs)(`div`,{className:`flex gap-2.5 px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-1.5 w-4 flex-none text-center text-[10px] text-warning`,children:`●`}),(0,B.jsx)(`div`,{className:`flex-1 text-[13px] text-warning-foreground`,children:t===`start-work`?a5.pausedToStart:a5.pausedWaiting}),(0,B.jsx)(`span`,{className:`mt-0.5 flex-none text-[11px] text-muted-foreground`,children:`now`})]});if(n){let e=KD(JWe(r,i),YWe(i));return(0,B.jsxs)(`div`,{className:`flex gap-2.5 px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-1.5 w-4 flex-none text-center text-[10px] text-info`,children:`●`}),(0,B.jsx)(`div`,{className:`flex-1 text-[13px] text-info-foreground`,children:e}),(0,B.jsx)(`span`,{className:`mt-0.5 flex-none text-[11px] text-muted-foreground`,children:`now`})]})}return e===`ready`?(0,B.jsxs)(`div`,{className:`flex gap-2.5 px-0.5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`mt-1.5 w-4 flex-none text-center text-[10px] text-success`,children:`●`}),(0,B.jsx)(`div`,{className:`flex-1 text-[13px] text-success-foreground`,children:a5.readyLiveRow})]}):null}var o5=Z8.issue;function u$t(e){let t=e.pendingAskUserQuestion?.questions;return Array.isArray(t)&&t.length===1&&t[0].multiSelect!==!0}function d$t({agent:e,onSend:t,sending:n}){let[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(!1);if(!u$t(e))return null;let l=e.pendingAskUserQuestion,u=l.questions[0];if(s)return(0,B.jsx)(`div`,{className:`mt-4 rounded-2xl border-l-[3px] border-info bg-card p-4 shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-full bg-info/10 text-info-foreground`,children:(0,B.jsx)(gc,{size:15})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[15px] font-medium`,children:o5.answerSentTitle}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:o5.answerSentSub})]})]})});let d=()=>{let e=a.trim()||r;!e||n||t(e,()=>c(!0))};return(0,B.jsxs)(`div`,{className:`mt-4 rounded-2xl border-l-[3px] border-warning bg-card p-4 shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-full bg-warning/10 text-warning-foreground`,children:(0,B.jsx)(vs,{size:15})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[15px] font-medium`,children:o5.questionTitle}),(0,B.jsxs)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[o5.questionAskedPrefix,JD(l.askedAt,new Date),` · `,o5.questionPauseSuffix]})]})]}),(0,B.jsx)(`div`,{className:`mt-3 rounded-[10px] bg-accent px-3.5 py-3 text-[14px] leading-relaxed`,children:u.question}),u.options.length>0&&(0,B.jsx)(`div`,{className:`mt-2.5 grid gap-2`,children:u.options.map(e=>(0,B.jsxs)(`button`,{onClick:()=>i(e.label),className:Kx(`flex items-start gap-2.5 rounded-[10px] border border-input px-3 py-2.5 text-left text-[13.5px]`,r===e.label&&`border-ring shadow-[0_0_0_1px] shadow-ring`),children:[(0,B.jsx)(`span`,{className:Kx(`mt-[3px] h-3.5 w-3.5 flex-none rounded-full border-2 border-muted-foreground`,r===e.label&&`border-primary bg-primary shadow-[inset_0_0_0_2.5px] shadow-card`)}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:e.label}),e.description&&(0,B.jsx)(`span`,{className:`block text-[12.5px] text-muted-foreground`,children:e.description})]})]},e.label))}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,B.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d()},placeholder:o5.questionAnswerPlaceholder,className:`h-[38px] flex-1 rounded-[10px] border border-input bg-transparent px-3 text-[13.5px] outline-none focus:border-ring`}),(0,B.jsx)($8,{disabled:n||!a.trim()&&!r,onClick:d,children:o5.answerSend})]}),(0,B.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground`,children:o5.questionOptionsHint})]})}var f$t=Z8.issue,p$t=40;function m$t({agentId:e}){let{data:t}=V({queryKey:[`simple-terminal-excerpt`,e],queryFn:async()=>{let t=await fetch(`/api/agents/${e}/output?lines=${p$t}`);return t.ok?((await t.json()).output??``).replace(/\s+$/,``):``},refetchInterval:15e3}),n=(0,z.useRef)(null);return(0,z.useEffect)(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[t]),t?(0,B.jsxs)(`div`,{className:`w-full`,children:[(0,B.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:f$t.screenExcerptLabel}),(0,B.jsx)(`pre`,{ref:n,className:`mt-1.5 max-h-52 overflow-y-auto whitespace-pre-wrap break-words rounded-[10px] bg-accent px-3.5 py-3 font-mono text-[11.5px] leading-relaxed text-foreground`,children:t})]}):null}var s5=Z8.issue;function h$t({issueId:e}){let t=Q(e=>e.issuesRaw),n=Q(e=>e.agentsById),r=Q(e=>e.reviewStatusByIssueId),i=Q(e=>e.openIssue),a=X8(e=>e.closeSimpleIssue),o=J$(),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(null),f=(0,z.useMemo)(()=>{let i=t??[],a=i.find(t=>t.identifier===e)??i.find(t=>t.identifier.toLowerCase()===e.toLowerCase());return a?K$(a,Object.values(n??{}).filter(e=>e.issueId?.toLowerCase()===a.identifier.toLowerCase()),r?.[a.identifier]):null},[t,n,r,e]);if(!f)return(0,B.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,B.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 pt-7`,children:[(0,B.jsx)(x,{}),(0,B.jsx)(`p`,{className:`mt-8 text-sm text-muted-foreground`,children:`Can't find that task. It may have moved — head back and pick another.`})]})});let p=f,m=p.primaryAgent,h=p.display.needsYouReason===`question`?p.pendingInputAgent:void 0,g=p.agents.find(e=>e.id===u)??m,_=h!=null&&u$t(h),v=QQt(p.issue),y=o.tell.isPending||o.answer.isPending||o.recover.isPending||o.unstick.isPending||o.merge.isPending||o.startWork.isPending,b=()=>{let e=c.trim();e&&(h?o.answer.mutate({agentId:h.id,text:e}):g&&o.tell.mutate({agentId:g.id,message:e}),l(``))};return(0,B.jsx)(`div`,{"data-component":`simple-issue-page`,className:`h-full w-full overflow-y-auto`,children:(0,B.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 pb-24 pt-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(x,{}),(0,B.jsx)(Q8,{})]}),(0,B.jsxs)(`div`,{className:`mt-3.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`font-mono`,children:p.issue.identifier}),p.issue.project?.name&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:`·`}),(0,B.jsx)(`span`,{children:p.issue.project.name})]})]}),(0,B.jsx)(`h1`,{className:`mt-1 text-[21px] font-medium leading-snug`,children:p.issue.title})]}),(0,B.jsx)(FQt,{state:p.display.state,pipelineState:p.pipelineState}),_?(0,B.jsx)(d$t,{agent:h,sending:o.answer.isPending,onSend:(e,t)=>o.answer.mutate({agentId:h.id,text:e},{onSuccess:t})}):(0,B.jsxs)(LQt,{display:p.display,children:[h&&(0,B.jsx)(m$t,{agentId:h.id}),p.expectation&&(0,B.jsx)(`span`,{className:`w-full text-xs text-muted-foreground`,children:p.expectation}),(()=>{let e=p.display.primaryAction;if(!e)return null;switch(e){case`Merge to main`:return(0,B.jsx)($8,{tone:`success`,disabled:y,onClick:()=>o.merge.mutate({issueId:p.issue.identifier}),children:e});case`Start work`:return(0,B.jsx)($8,{disabled:y,onClick:()=>o.startWork.mutate({issueId:p.issue.identifier}),children:e});case`Get it unstuck`:return(0,B.jsx)($8,{disabled:y||!p.reviewStuck&&!m,onClick:()=>{p.reviewStuck&&o.unstick.mutate({issueId:p.issue.identifier}),p.agentStuck&&m&&o.recover.mutate({agentId:m.id})},children:e});case`Tell the agent to fix them`:return(0,B.jsx)($8,{disabled:!m||y,onClick:()=>m&&o.tell.mutate({agentId:m.id,message:`Please address the review findings and get this back to green.`}),children:e});case`See what changed`:return p.prUrl?(0,B.jsx)($8,{onClick:()=>window.open(p.prUrl,`_blank`,`noopener`),children:e}):null;case`Answer`:return(0,B.jsx)($8,{disabled:y,onClick:()=>s.current?.focus(),children:e});default:return null}})(),p.display.secondaryActions.map(e=>e===`See what changed`&&p.prUrl?(0,B.jsx)(e5,{onClick:()=>window.open(p.prUrl,`_blank`,`noopener`),children:e},e):e===`Tell the agent something`?(0,B.jsx)(e5,{onClick:()=>s.current?.focus(),children:e},e):null)]}),(0,B.jsxs)(`section`,{className:`mt-6`,children:[(0,B.jsx)(`div`,{className:`mt-2.5`,children:m?(0,B.jsx)(o$t,{issue:p.issue,agents:p.agents,agent:g,onSelectAgent:d,state:p.display.state,needsYouReason:p.display.needsYouReason}):(0,B.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:`Nothing to show yet — updates appear here as it works.`})}),!_&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-2xl border border-input bg-card py-2 pl-3.5 pr-2 focus-within:border-ring`,children:[(0,B.jsx)(`input`,{ref:s,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:h?s5.answerPlaceholder:s5.composerPlaceholder,className:`flex-1 bg-transparent text-[13.5px] text-foreground outline-none`}),(0,B.jsx)(`button`,{onClick:b,disabled:!c.trim()||!g&&!h||y,className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary text-primary-foreground transition-opacity disabled:opacity-40`,"aria-label":`Send`,children:`➤`})]}),(0,B.jsx)(`div`,{className:`mt-1.5 pl-1 text-[11px] text-muted-foreground`,children:h?s5.answerHint:s5.composerHint})]})]}),(0,B.jsx)(`div`,{className:`mt-8 rounded-xl border border-border bg-card`,children:(0,B.jsxs)(`button`,{onClick:()=>i(p.issue.identifier,`overview`),className:`flex w-full items-center gap-2 px-4 py-3 text-left text-[13px] text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(`span`,{children:`▸`}),` `,s5.advancedDisclosure]})}),(0,B.jsxs)(`div`,{className:`mt-6 text-center text-xs text-muted-foreground`,children:[`Something look wrong?`,` `,v?(0,B.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,className:`text-info-foreground underline underline-offset-2`,children:s5.getHelp}):(0,B.jsx)(`span`,{className:`text-info-foreground`,children:s5.getHelp}),` `,`— a human sees these.`]})]})});function x(){return(0,B.jsxs)(`button`,{onClick:()=>{a(),PQt(null)},className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(Tie,{size:13}),` `,Z8.issue.backToMyWork.replace(`← `,``)]})}}function g$t({advanced:e}){let t=X8(e=>e.mode),n=X8(e=>e.simpleIssueId);return t===`simple`?n?(0,B.jsx)(h$t,{issueId:n}):(0,B.jsx)(ZQt,{}):(0,B.jsx)(B.Fragment,{children:e})}function _$t(){return(0,B.jsx)(`div`,{className:`flex gap-4 overflow-x-auto pb-4`,children:[{title:`Todo`,color:`border-primary`},{title:`In Progress`,color:`border-yellow-500`},{title:`In Review`,color:`border-purple-500`},{title:`Done`,color:`border-success`}].map(e=>(0,B.jsxs)(`div`,{className:`border-t-4 ${e.color} bg-card rounded-lg min-w-[280px] flex-1`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`div`,{className:`h-4 w-24 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-4 w-6 animate-pulse bg-muted rounded`})]})}),(0,B.jsx)(`div`,{className:`p-3 space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,B.jsxs)(`div`,{className:`bg-card rounded-lg p-3 space-y-2`,children:[(0,B.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse bg-muted rounded`}),(0,B.jsxs)(`div`,{className:`flex gap-2 mt-2`,children:[(0,B.jsx)(`div`,{className:`h-5 w-16 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-5 w-10 animate-pulse bg-muted rounded`})]})]},t))})]},e.title))})}function v$t(){return(0,B.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6 p-6 w-full`,children:[(0,B.jsxs)(`div`,{className:`bg-card rounded-lg`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[(0,B.jsx)(`div`,{className:`h-4 w-36 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-6 w-20 animate-pulse bg-muted rounded`})]}),(0,B.jsx)(`div`,{className:`divide-y divide-divider`,children:Array.from({length:4}).map((e,t)=>(0,B.jsxs)(`div`,{className:`p-4 flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`div`,{className:`h-8 w-8 animate-pulse bg-muted rounded-full`}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`div`,{className:`h-3 w-32 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-muted rounded`})]})]}),(0,B.jsx)(`div`,{className:`h-5 w-16 animate-pulse bg-muted rounded`})]},t))})]}),(0,B.jsxs)(`div`,{className:`bg-card rounded-lg p-4`,children:[(0,B.jsx)(`div`,{className:`h-4 w-28 animate-pulse bg-muted rounded mb-4`}),(0,B.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,B.jsx)(`div`,{className:`h-3 animate-pulse bg-muted rounded`,style:{width:`${60+t%3*15}%`}},t))})]})]})}function y$t(){return(0,B.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden bg-background`,children:[(0,B.jsxs)(`div`,{className:`flex h-[52px] shrink-0 items-center gap-[12px] border-b border-border bg-background px-[22px]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 space-y-[4px]`,children:[(0,B.jsx)(`div`,{className:`h-[8px] w-[80px] animate-pulse rounded bg-muted`}),(0,B.jsx)(`div`,{className:`h-[14px] w-[100px] animate-pulse rounded bg-muted`})]}),(0,B.jsx)(`div`,{className:`flex-1 h-[32px] min-w-[280px] animate-pulse rounded-[var(--radius-lg)] bg-muted`}),(0,B.jsx)(`div`,{className:`h-[32px] w-[120px] animate-pulse rounded-[var(--radius-lg)] bg-muted`}),(0,B.jsx)(`div`,{className:`ml-auto h-[32px] w-[110px] animate-pulse rounded-[var(--radius-lg)] bg-muted`})]}),(0,B.jsx)(`div`,{className:`flex shrink-0 border-b border-border bg-background`,children:Array.from({length:5}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex-1 border-r border-border last:border-r-0 px-[18px] py-[12px] space-y-[6px]`,children:[(0,B.jsx)(`div`,{className:`h-[10px] w-[70px] animate-pulse rounded bg-muted`}),(0,B.jsx)(`div`,{className:`h-[20px] w-[40px] animate-pulse rounded bg-muted`}),(0,B.jsx)(`div`,{className:`h-[9px] w-[55px] animate-pulse rounded bg-muted`})]},t))}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[8px] border-b border-border bg-background px-[22px] py-[10px]`,children:[Array.from({length:6}).map((e,t)=>(0,B.jsx)(`div`,{className:`h-[28px] animate-pulse rounded-[var(--radius-sm)] bg-muted ${t===0?`w-[40px]`:`w-[56px]`}`},t)),(0,B.jsxs)(`div`,{className:`ml-auto flex gap-[6px]`,children:[(0,B.jsx)(`div`,{className:`h-[28px] w-[70px] animate-pulse rounded-[var(--radius-sm)] bg-muted`}),(0,B.jsx)(`div`,{className:`h-[28px] w-[60px] animate-pulse rounded-[var(--radius-sm)] bg-muted`})]})]}),(0,B.jsx)(`div`,{className:`flex-1 overflow-auto`,children:[`Ship`,`Review`,`Work`,`Plan`].map(e=>(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-[10px] border-b border-border px-[22px] py-[12px]`,children:[(0,B.jsx)(`div`,{className:`h-[8px] w-[8px] animate-pulse rounded-full bg-muted`}),(0,B.jsx)(`div`,{className:`h-[14px] w-[60px] animate-pulse rounded bg-muted`}),(0,B.jsx)(`div`,{className:`h-[16px] w-[24px] animate-pulse rounded-[var(--radius-sm)] bg-muted`})]}),Array.from({length:3}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-[10px] border-b border-border px-[22px] py-[12px]`,children:[(0,B.jsx)(`div`,{className:`h-[10px] w-[10px] animate-pulse rounded bg-muted shrink-0`}),(0,B.jsx)(`div`,{className:`h-[12px] flex-1 animate-pulse rounded bg-muted`}),(0,B.jsx)(`div`,{className:`h-[18px] w-[90px] animate-pulse rounded bg-muted`}),(0,B.jsx)(`div`,{className:`h-[10px] w-[55px] animate-pulse rounded bg-muted`})]},t))]},e))})]})}function b$t(){return(0,B.jsxs)(`div`,{className:`god-view flex flex-col flex-1 min-h-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border shrink-0`,children:[(0,B.jsx)(`div`,{className:`h-4 w-48 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-4 w-24 animate-pulse bg-muted rounded`})]}),(0,B.jsxs)(`div`,{className:`flex flex-1 gap-3 px-3 pb-3 pt-2 min-h-0 overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`flex-1 grid grid-cols-3 gap-3 content-start overflow-auto`,children:Array.from({length:6}).map((e,t)=>(0,B.jsxs)(`div`,{className:`bg-card rounded-lg p-3 space-y-2 min-h-[120px]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`h-6 w-6 animate-pulse bg-muted rounded-full`}),(0,B.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-muted rounded`})]}),(0,B.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse bg-muted rounded`}),(0,B.jsx)(`div`,{className:`h-16 animate-pulse bg-muted rounded mt-2`})]},t))}),(0,B.jsxs)(`div`,{className:`w-[220px] shrink-0 space-y-3`,children:[(0,B.jsxs)(`div`,{className:`bg-card rounded-lg p-3`,children:[(0,B.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-muted rounded mb-3`}),Array.from({length:4}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,B.jsx)(`div`,{className:`h-2 w-2 animate-pulse bg-muted rounded-full`}),(0,B.jsx)(`div`,{className:`h-3 flex-1 animate-pulse bg-muted rounded`})]},t))]}),(0,B.jsxs)(`div`,{className:`bg-card rounded-lg p-3`,children:[(0,B.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-muted rounded mb-3`}),(0,B.jsx)(`div`,{className:`h-32 animate-pulse bg-muted rounded`})]})]})]})]})}function c5(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}project=${encodeURIComponent(t)}`:e}function x$t(e){let t=(e.state??e.status).toLowerCase();return e.stateType!==`completed`&&e.stateType!==`canceled`&&![`done`,`closed`,`completed`,`canceled`,`cancelled`].includes(t)}function S$t(e){let t=new Map;for(let n of e)if(n.status!==`complete`)for(let e of n.items)t.set(e.issue.toUpperCase(),n);return t}async function C$t(e,t,n,r){let i=await fetch(c5(`/api/orders/${encodeURIComponent(e)}/items`,r),{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({item:{issue:t,lane:n}})}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error??`Could not add ${t} (${i.status})`);return a}function w$t({book:e,books:t,onBookChange:n,issues:r,project:i}){let a=Q(dS),o=r??a,[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(`A`),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),h=(0,z.useMemo)(()=>S$t(t),[t]),g=(0,z.useMemo)(()=>{let e=s.trim().toLowerCase();return e?o.filter(x$t).filter(t=>[t.identifier,t.title,...t.labels].some(t=>t.toLowerCase().includes(e))).slice(0,10):[]},[o,s]),_=async t=>{f(t),m(null);try{n(await C$t(e.id,t,l,i))}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}};return(0,B.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-3`,"aria-label":`Search and add issues`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Search open issues`}),(0,B.jsx)(`div`,{className:`ml-auto flex rounded-md border border-border p-0.5 text-[10px]`,children:[`A`,`B`].map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>u(e),"aria-pressed":l===e,className:`rounded-sm px-2 py-0.5 ${l===e?`bg-muted text-foreground`:`text-muted-foreground`}`,children:[`Lane `,e]},e))})]}),(0,B.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 rounded-md border border-input bg-background px-2 py-1.5`,children:[(0,B.jsx)(Vc,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Search issues by id, title, or label`}),(0,B.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`ID, title, or label`,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none`})]}),(0,B.jsxs)(`div`,{className:`mt-2 grid gap-1`,children:[g.map(t=>{let n=h.get(t.identifier.toUpperCase()),r=n?n.id===e.id?`Already in this book`:`In ${n.name}`:null;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5 first:border-t-0`,children:[(0,B.jsx)(`span`,{className:`w-20 shrink-0 font-mono text-[11px] text-foreground`,children:t.identifier}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:t.title}),(0,B.jsx)(`button`,{type:`button`,disabled:!!r||d===t.identifier,title:r??`Add to Lane ${l}`,onClick:()=>void _(t.identifier),className:`w-20 rounded-md border border-border px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:r??(d===t.identifier?`Adding…`:`+ Lane ${l}`)})]},t.id)}),s.trim()&&g.length===0&&(0,B.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No matching open issues.`})]}),(0,B.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:`Adding changes the plan only; dispatch begins when the book's run starts.`}),p&&(0,B.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,role:`alert`,children:p})]})}function T$t({book:e,onBookChange:t,project:n}){let[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)(`A`),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null);(0,z.useEffect)(()=>{let t=!0;return fetch(c5(`/api/orders/backlog-candidates?limit=10`,n)).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error??`Could not load backlog candidates (${e.status})`);return t?.candidates??[]}).then(n=>{if(!t)return;let r=new Set(e.items.map(e=>e.issue.toUpperCase()));i(n.filter(e=>!r.has(e.issue.toUpperCase())).sort((e,t)=>e.rank-t.rank).slice(0,10))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e.id,e.items,n]);let d=async r=>{c(r),u(null);try{let o=await fetch(c5(`/api/orders/${encodeURIComponent(e.id)}/items`,n),{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({item:{issue:r,lane:a}})}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error??`Could not add ${r} (${o.status})`);t(s),i(e=>e.filter(e=>e.issue!==r))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(null)}};return(0,B.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-3`,"aria-label":`Backlog candidates`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Backlog top 10`}),(0,B.jsx)(`div`,{className:`ml-auto flex rounded-md border border-border p-0.5 text-[10px]`,children:[`A`,`B`].map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-pressed":a===e,className:`rounded-sm px-2 py-0.5 ${a===e?`bg-muted text-foreground`:`text-muted-foreground`}`,children:[`Lane `,e]},e))})]}),(0,B.jsxs)(`div`,{className:`mt-2 grid gap-1`,children:[r.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5 first:border-t-0`,children:[(0,B.jsxs)(`span`,{"data-testid":`sequence-rank`,className:`w-6 shrink-0 text-[10px] text-muted-foreground`,children:[`#`,e.rank]}),(0,B.jsx)(`span`,{className:`w-20 shrink-0 font-mono text-[11px] text-foreground`,children:e.issue}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:e.why}),(0,B.jsx)(`button`,{type:`button`,disabled:s===e.issue,onClick:()=>void d(e.issue),className:`w-16 rounded-md border border-border px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,children:s===e.issue?`Adding…`:`+ ${a}`})]},e.issue)),r.length===0&&!l&&(0,B.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No unassigned backlog candidates.`})]}),(0,B.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:`Sequencer rank informs planning order; order-book lane position governs this run.`}),l&&(0,B.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,role:`alert`,children:l})]})}function E$t(e){if(e.status===`running`)return`Active · ${e.progress.landed}/${e.progress.total} landed`;if(e.status===`ready`)return`Queued · ${e.items.length} items`;if(e.status===`draft`)return`Draft · ${e.items.length} items`;let t=e.status===`complete`&&e.runId?` · retro ✓`:``;return`${e.status===`complete`?`Drained`:`Draining`} · ${e.progress.landed}/${e.progress.total} landed${t}`}function D$t({books:e,selectedId:t,onSelect:n,onCreate:r}){let[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(null),f=async()=>{let e=o.trim();if(!(!e||c)){l(!0),d(null);try{await r(e),s(``),a(!1)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}}};return(0,B.jsxs)(`section`,{className:`flex shrink-0 items-center gap-2 overflow-x-auto border-b border-border bg-muted/30 px-4 py-2`,"aria-label":`Order books`,children:[e.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":e.id===t,className:`min-w-44 rounded-lg border bg-card px-3 py-2 text-left transition-colors ${e.id===t?`border-primary/50`:`border-border hover:border-border/80`}`,children:[(0,B.jsx)(`span`,{className:`block truncate text-xs font-medium text-foreground`,children:e.name}),(0,B.jsx)(`span`,{className:`mt-0.5 block text-[10px] font-medium text-muted-foreground`,children:E$t(e)})]},e.id)),i?(0,B.jsxs)(`div`,{className:`flex min-w-64 items-center gap-2 rounded-lg border border-border bg-card p-2`,children:[(0,B.jsx)(`label`,{className:`sr-only`,htmlFor:`new-order-book-name`,children:`Book name`}),(0,B.jsx)(`input`,{id:`new-order-book-name`,autoFocus:!0,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f(),e.key===`Escape`&&a(!1)},placeholder:`Book name`,className:`min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs text-foreground outline-none focus:border-primary/50`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:!o.trim()||c,className:`rounded-md border border-primary/40 px-2 py-1.5 text-xs text-foreground disabled:opacity-40`,children:c?`Creating…`:`Create`}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Cancel new book`,onClick:()=>a(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,B.jsx)(sl,{className:`h-4 w-4`})}),u&&(0,B.jsx)(`span`,{role:`alert`,className:`text-xs text-destructive`,children:u})]}):(0,B.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex shrink-0 items-center rounded-md px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:`+ New book`})]})}function O$t(e){return e===`in-pipeline`?`border-l-2 border-l-info bg-info/[0.08]`:e===`landed`?`border-l-2 border-l-success bg-success/[0.08]`:`border-l-2 border-l-transparent`}function k$t({item:e,title:t,state:n,hasPrd:r,onDragStart:i,onDrop:a,onSwapLane:o,onRequirementsChange:s,onRemove:c}){let l=n===`in-pipeline`||n===`landed`,[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(e.prereqs.join(`, `)),[m,h]=(0,z.useState)(e.reVerify),[g,_]=(0,z.useState)(e.planAtPickup??!1),[v,y]=(0,z.useState)(!1);(0,z.useEffect)(()=>p(e.prereqs.join(`, `)),[e.prereqs]),(0,z.useEffect)(()=>h(e.reVerify),[e.reVerify]),(0,z.useEffect)(()=>_(e.planAtPickup??!1),[e.planAtPickup]);let b=async()=>{y(!0);try{await s(e.issue,{prereqs:[...new Set(f.split(/[\s,]+/).map(e=>e.trim().toUpperCase()).filter(Boolean))],reVerify:m,planAtPickup:g}),d(!1)}catch{}finally{y(!1)}};return(0,B.jsxs)(`div`,{draggable:!u,onDragStart:()=>i(e.issue),onDragOver:e=>e.preventDefault(),onDrop:t=>a(t,e.lane,e.order),"data-item-state":n,className:`border-t border-border first:border-t-0 ${O$t(n)}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs`,children:[(0,B.jsx)($ie,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`,"aria-hidden":`true`}),(0,B.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[e.lane,e.order,` · book`]}),(0,B.jsx)(`span`,{className:`w-20 shrink-0 font-mono text-[11px] text-foreground`,children:e.issue}),t?(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,title:t,children:t}):(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,"aria-hidden":`true`}),e.prereqs.length>0&&(0,B.jsxs)(`span`,{className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:[`after `,e.prereqs.join(`, `)]}),e.reVerify&&(0,B.jsx)(`span`,{className:`rounded-sm border px-1.5 py-0.5 text-[10px] ${l?`border-border text-muted-foreground`:`border-warning/[0.32] bg-warning/[0.08] text-warning-foreground`}`,children:`re-verify`}),e.planAtPickup&&(0,B.jsx)(`span`,{className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:`plan at pickup`}),(0,B.jsx)(`span`,{className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:r?`PRD ✓`:`no PRD`}),(0,B.jsx)(`span`,{className:`w-16 shrink-0 text-right text-[10px] ${n===`in-pipeline`?`text-info`:n===`landed`?`text-success`:`text-muted-foreground`}`,children:n}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Edit holds for ${e.issue}`,children:(0,B.jsx)(Hc,{className:`h-3.5 w-3.5`})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,"aria-label":`Move ${e.issue} to Lane ${e.lane===`A`?`B`:`A`}`,children:[`→ `,e.lane===`A`?`B`:`A`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>c(e.issue),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${e.issue} from book`,children:(0,B.jsx)(rl,{className:`h-3.5 w-3.5`})})]}),u&&(0,B.jsxs)(`div`,{className:`grid gap-2 border-t border-border bg-muted/20 px-3 py-3 text-[11px] md:grid-cols-[1fr_auto_auto_auto]`,"aria-label":`Holds for ${e.issue}`,children:[(0,B.jsxs)(`label`,{className:`grid gap-1 text-muted-foreground`,children:[`Prerequisites`,(0,B.jsx)(`input`,{"aria-label":`Prerequisites for ${e.issue}`,value:f,onChange:e=>p(e.target.value),placeholder:`PAN-100, PAN-101`,className:`rounded-md border border-input bg-background px-2 py-1.5 font-mono text-foreground`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 self-end pb-1.5 text-muted-foreground`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),`Re-verify PRD`]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 self-end pb-1.5 text-muted-foreground`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),`Plan at pickup`]}),(0,B.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>void b(),className:`self-end rounded-md border border-primary/40 px-2.5 py-1.5 text-foreground disabled:opacity-40`,children:v?`Saving…`:`Save holds`})]})]})}async function A$t(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error??`Order book mutation failed (${e.status})`);return t}function j$t(e,t,n){return e.progress.items?.find(e=>e.issue===t)?.closed?`landed`:n.has(t.toUpperCase())?`in-pipeline`:e.settings.posture===`drain`?`held`:`released`}function M$t({book:e,inFlightIssues:t=new Set,issues:n,onBookChange:r,project:i}){let a=Q(dS),o=n??a,s=(0,z.useMemo)(()=>new Map(o.map(e=>[e.identifier.toUpperCase(),e.title])),[o]),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),f=async(t,n)=>{d(null),r(await A$t(await fetch(c5(`/api/orders/${encodeURIComponent(e.id)}/items/${encodeURIComponent(t)}`,i),{method:`PATCH`,credentials:`include`,headers:await sb(),body:JSON.stringify(n)})))},p=(e,t,n)=>{e.preventDefault(),e.stopPropagation(),c&&(f(c,{lane:t,order:n}).catch(e=>d(e instanceof Error?e.message:String(e))),l(null))},m=t=>{let n=t.lane===`A`?`B`:`A`,r=e.items.filter(e=>e.lane===n).length+1;f(t.issue,{lane:n,order:r}).catch(e=>d(e instanceof Error?e.message:String(e)))},h=async(e,t)=>{try{await f(e,t)}catch(e){throw d(e instanceof Error?e.message:String(e)),e}},g=async t=>{d(null);try{r(await A$t(await fetch(c5(`/api/orders/${encodeURIComponent(e.id)}/items/${encodeURIComponent(t)}`,i),{method:`DELETE`,credentials:`include`,headers:await sb()})))}catch(e){d(e instanceof Error?e.message:String(e))}};return(0,B.jsxs)(`section`,{className:`grid gap-3 lg:grid-cols-2`,"aria-label":`Order book lane editor`,children:[[`A`,`B`].map(n=>{let r=e.items.filter(e=>e.lane===n).sort((e,t)=>e.order-t.order);return(0,B.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-2 border-b border-border px-3 py-2`,children:[(0,B.jsxs)(`h2`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:[`Lane `,n]}),(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n===`A`?`parallel · up to ${e.settings.laneAConcurrency}`:`strictly serial · one in flight`}),(0,B.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[r.length,` items`]})]}),r.map(n=>(0,B.jsx)(k$t,{item:n,title:s.get(n.issue.toUpperCase()),state:j$t(e,n.issue,t),hasPrd:e.itemReadiness?.[n.issue]?.hasPrd??!0,onDragStart:l,onDrop:p,onSwapLane:m,onRequirementsChange:h,onRemove:e=>void g(e)},n.issue)),(0,B.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>p(e,n,r.length+1),className:`border-t border-dashed border-border px-3 py-2 text-center text-[11px] text-muted-foreground`,children:[`Drop issues here for Lane `,n]})]},n)}),u&&(0,B.jsx)(`p`,{className:`lg:col-span-2 text-xs text-destructive`,role:`alert`,children:u})]})}var l5=[{status:`draft`,label:`Draft`},{status:`ready`,label:`Ready`},{status:`running`,label:`Running`},{status:`drained`,label:`Drained = run ends`},{status:`complete`,label:`Complete`}];function N$t({status:e}){let t=l5.findIndex(t=>t.status===e);return(0,B.jsx)(`nav`,{className:`flex flex-wrap items-center gap-1`,"aria-label":`Order book lifecycle`,children:l5.map((e,n)=>{let r=n===t,i=n<t;return(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`span`,{"aria-current":r?`step`:void 0,"data-state":r?`current`:i?`done`:`upcoming`,className:`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-[11px] font-medium ${r?`border-primary/50 bg-primary/10 text-foreground`:i?`border-success/30 bg-success/10 text-success`:`border-border bg-card text-muted-foreground`}`,children:[(0,B.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center rounded-full border border-current text-[9px]`,children:i?`✓`:n+1}),e.label]}),n<l5.length-1&&(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`px-1 text-[10px] text-muted-foreground`,children:`→`})]},e.status)})})}function P$t(e){let t=e.issueId.toUpperCase(),n=e.book.items.find(e=>e.issue.toUpperCase()===t);if(!n){let n=e.offBook===!0;return{eligible:n,overrideUsed:n,...n?{}:{code:`off-book`,message:`Issue ${t} is not in active order book ${e.book.id}; work-agent dispatch is blocked. Retry with --off-book only for an intentional exception.`},conditions:[{key:`book-membership`,met:n,detail:n?`Issue ${t} is outside the book and the operator supplied --off-book.`:`Issue ${t} is not a member of ${e.book.id}.`}]}}let r=new Map(e.progress.items.map(e=>[e.issue.toUpperCase(),e.terminal]));for(let[t,n]of e.prerequisiteTerminal??[])r.has(t.toUpperCase())||r.set(t.toUpperCase(),n);let i=n.prereqs.find(e=>r.get(e.toUpperCase())!==!0),a=i===void 0,o=e.book.items.filter(n=>n.issue.toUpperCase()!==t&&e.inFlightIssues.has(n.issue.toUpperCase())),s=n.lane===`B`?o.find(e=>e.lane===`B`):void 0,c=o.filter(e=>e.lane===`A`).length,l=n.lane===`B`?s===void 0:c<e.book.settings.laneAConcurrency,u=e.book.settings.posture===`open`,d=!n.reVerify,f=[{key:`book-membership`,met:!0,detail:`${t} is a member of ${e.book.id}.`},{key:`pickup-posture`,met:u,detail:u?`Order-book pickup posture is OPEN.`:`Order-book pickup posture is DRAIN.`},{key:`lane-slot`,met:l,detail:n.lane===`B`?s?`Lane B is occupied by ${s.issue}.`:`Lane B has no issue in flight.`:`${c}/${e.book.settings.laneAConcurrency} Lane A slots are in flight.`},{key:`prerequisites`,met:a,detail:i?`Prerequisite ${i.toUpperCase()} is not terminal.`:`Every prerequisite is landed or parked.`},{key:`prd-reverified`,met:d,detail:d?`No PRD re-verification is pending.`:`${t} requires PRD re-verification before dispatch.`}];return u?i?{eligible:!1,overrideUsed:!1,code:`prerequisite-unmet`,message:`Issue ${t} cannot start because prerequisite ${i.toUpperCase()} has not landed or been parked.`,conditions:f}:d?s?{eligible:!1,overrideUsed:!1,code:`lane-b-busy`,message:`Issue ${t} cannot start in Lane B because ${s.issue} is still in flight; Lane B allows one active issue at a time.`,conditions:f}:n.lane===`A`&&!l?{eligible:!1,overrideUsed:!1,code:`lane-a-full`,message:`Issue ${t} cannot start in Lane A because ${c} issues are already in flight and laneAConcurrency is ${e.book.settings.laneAConcurrency}.`,conditions:f}:{eligible:!0,overrideUsed:!1,conditions:f}:{eligible:!1,overrideUsed:!1,code:`reverify-required`,message:`Issue ${t} cannot start until its PRD has been re-verified against current main.`,conditions:f}:{eligible:!1,overrideUsed:!1,code:`book-draining`,message:`Issue ${t} cannot start because order book ${e.book.id} is in DRAIN posture; no new book items may dispatch.`,conditions:f}}function F$t(e,t){return t?`closed`:e?e.status===`merged`||e.verb===`shipping`||e.verb===`merging`?`merged`:e.verb===`planning`?`planning`:e.verb===`reviewing`||e.verb===`testing`?`review`:`working`:`queued`}function I$t(e){return e===`planning`||e===`working`?`border-l-info bg-info/[0.08] text-info`:e===`review`?`border-l-warning bg-warning/[0.08] text-warning-foreground`:e===`merged`||e===`closed`?`border-l-success bg-success/[0.08] text-success`:`border-l-transparent text-muted-foreground`}var L$t={"pickup-posture":`Pickup posture`,"lane-slot":`Serial B-slot free`,prerequisites:`Prereqs landed`,"prd-reverified":`PRD re-verified`};function R$t({book:e,initialStatus:t,onOpenReport:n}){let[r,i]=(0,z.useState)(t??null);(0,z.useEffect)(()=>{let e=!0;t===void 0?fetch(`/api/flywheel/current`).then(e=>e.ok?e.json():null).then(t=>{e&&t&&i(t)}).catch(()=>{}):i(t);let n=ub(t=>{e&&i(t)});return()=>{e=!1,n()}},[t]);let a=r?.orders?.bookId===e.id?r:null,o=(0,z.useMemo)(()=>new Map((a?.activePipeline??[]).map(e=>[e.issueId.toUpperCase(),e])),[a]),s=(0,z.useMemo)(()=>new Set([...a?.orders?.laneAInFlight??[],...a?.orders?.laneBInFlight?[a.orders.laneBInFlight]:[]].map(e=>e.toUpperCase())),[a]),c=(0,z.useMemo)(()=>new Map(Object.entries(e.prerequisiteTerminal??{})),[e.prerequisiteTerminal]),l=e.items.map(t=>{let n=e.progress.items?.find(e=>e.issue.toUpperCase()===t.issue.toUpperCase());return{issue:t.issue,lane:t.lane,order:t.order,closed:n?.closed??!1,parked:n?.parked??!1,terminal:n?.terminal??!1}});return(0,B.jsxs)(`section`,{className:`grid gap-3`,"aria-label":`Order book progress`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,B.jsx)(`h2`,{className:`font-medium text-foreground`,children:`Live checklist`}),(0,B.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[a?.orders?.landed??e.progress.landed,`/`,a?.orders?.total??e.progress.total,` landed`]}),a&&(0,B.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:a.runId})]}),(0,B.jsxs)(`div`,{className:`mt-3 overflow-hidden rounded-lg border border-border`,children:[e.items.map(t=>{let n=l.find(e=>e.issue===t.issue),r=F$t(o.get(t.issue.toUpperCase()),n.terminal),i=P$t({book:e,progress:{bookId:e.id,total:e.progress.total,landed:e.progress.landed,drained:e.progress.drained,items:l},issueId:t.issue,inFlightIssues:s,prerequisiteTerminal:c}),a=r===`queued`;return(0,B.jsxs)(`div`,{"data-live-status":r,className:`border-l-2 border-t border-border px-3 py-2 first:border-t-0 ${I$t(r)}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[t.lane,t.order,` · book`]}),(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:t.issue}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] uppercase tracking-wide`,children:r})]}),a&&(0,B.jsx)(`div`,{className:`mt-2 grid gap-1 sm:grid-cols-2`,"aria-label":`${t.issue} eligibility`,children:i.conditions.filter(e=>e.key!==`book-membership`).map(e=>(0,B.jsxs)(`span`,{title:e.detail,className:`text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:e.met?`text-success`:`text-destructive`,children:e.met?`✓`:`✕`}),` `,L$t[e.key]??e.key]},e.key))})]},t.issue)}),e.items.length===0&&(0,B.jsx)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:`No items in this book.`})]})]}),a?.orders?.drained&&(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-success/30 bg-success/[0.08] p-4 text-xs text-success`,role:`status`,children:[(0,B.jsx)(`span`,{children:`✓ Order book drained. The run is over; report and retrospective are ready.`}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(a.runId),className:`ml-auto flex items-center gap-1 rounded-md border border-success/30 px-2.5 py-1.5 text-[11px] hover:bg-success/10`,children:[`Open report & retro `,(0,B.jsx)(Is,{className:`h-3 w-3`})]})]})]})}var u5={drain:`Operator paused new pickup.`,open:`Operator reopened pickup.`},z$t={drain:`In-flight items will finish. Nothing new dispatches from this book until it is reopened.`,open:`Eligible items will start dispatching again — Lane A up to its concurrency, Lane B one at a time in order.`},B$t={open:`Dispatch is live: eligible items start when a slot frees, Lane B strictly in order.`,drain:`Draining: in-flight items finish, nothing new starts until reopened.`},V$t={drain:`Switch to drain`,open:`Reopen pickup`},d5={open:`border-info/[0.32] bg-info/[0.08] text-info-foreground`,drain:`border-warning/[0.32] bg-warning/[0.08] text-warning-foreground`},H$t=1600;function U$t(e){return`${String(e.getUTCHours()).padStart(2,`0`)}:${String(e.getUTCMinutes()).padStart(2,`0`)}:${String(e.getUTCSeconds()).padStart(2,`0`)}Z`}function W$t(e){let t=new Date(e);return`${t.toLocaleString(`en-US`,{month:`short`,day:`numeric`,timeZone:`UTC`})}, ${String(t.getUTCHours()).padStart(2,`0`)}:${String(t.getUTCMinutes()).padStart(2,`0`)}Z`}function G$t(e,t){return e===`open`&&t===u5.drain||e===`drain`&&t===u5.open}function f5({save:e}){return e.state===`saving`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground`,role:`status`,children:[(0,B.jsx)(gc,{size:10,className:`animate-spin`}),`Saving…`]}):e.state===`saved`?(0,B.jsx)(`span`,{className:`text-[10px] text-success`,role:`status`,children:`Saved ✓`}):e.state===`error`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-destructive`,role:`alert`,children:[`Couldn't save`,(0,B.jsx)(`button`,{type:`button`,onClick:e.retry,className:`underline`,children:`Retry`})]}):null}var K$t=1,q$t=8,J$t=500,Y$t=550,X$t=/\.md$/i;function Z$t({settings:e,onChange:t}){let[n,r]=(0,z.useState)(e.laneAConcurrency),[i,a]=(0,z.useState)(e.briefOverlay??``),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)({posture:{state:`idle`},lane:{state:`idle`},brief:{state:`idle`}}),[m,h]=(0,z.useState)(null),g=(0,z.useRef)({}),_=(0,z.useRef)(null),v=(0,z.useRef)(),y=(0,z.useRef)(),b=(0,z.useRef)(e.briefOverlay??``);(0,z.useEffect)(()=>r(e.laneAConcurrency),[e.laneAConcurrency]),(0,z.useEffect)(()=>a(e.briefOverlay??``),[e.briefOverlay]);let x=i.trim(),S=x===``?{text:`None — items run with their PRDs alone.`,tone:`muted`}:X$t.test(x)?{text:`Appended to every item's kickoff brief.`,tone:`success`}:{text:`Not a markdown file — expected a repo-relative .md path.`,tone:`error`};(0,z.useEffect)(()=>{o&&_.current?.select()},[o]);let C=(e,n)=>{clearTimeout(g.current[e]),p(t=>({...t,[e]:{state:`saving`}})),t(n).then(()=>{h(new Date),p(t=>({...t,[e]:{state:`saved`}})),g.current[e]=setTimeout(()=>p(t=>({...t,[e]:{state:`idle`}})),H$t)},()=>p(t=>({...t,[e]:{state:`error`,retry:()=>C(e,n)}})))},w=e=>{a(e),clearTimeout(y.current),y.current=setTimeout(()=>{let t=e.trim();if(t===``){b.current!==``&&(b.current=``,C(`brief`,{briefOverlay:``}));return}X$t.test(t)&&t!==b.current&&(b.current=t,C(`brief`,{briefOverlay:t}))},Y$t)},T=e=>{r(t=>{let n=Math.min(q$t,Math.max(K$t,t+e));return clearTimeout(v.current),v.current=setTimeout(()=>C(`lane`,{laneAConcurrency:n}),J$t),n})};return(0,B.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,"aria-label":`Run settings`,children:[(0,B.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Run settings`}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex-1`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Lane A concurrency`}),(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`How many parallel-safe Lane A items may run at once. Lane B ignores this — it is always one item at a time, in order.`})]}),(0,B.jsx)(f5,{save:f.lane}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Decrease Lane A concurrency`,disabled:n<=K$t,onClick:()=>T(-1),className:`rounded-md border border-input px-2 py-1 text-foreground disabled:opacity-40`,children:`−`}),(0,B.jsx)(`span`,{className:`w-4 text-center font-mono tabular-nums text-foreground`,children:n}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Increase Lane A concurrency`,disabled:n>=q$t,onClick:()=>T(1),className:`rounded-md border border-input px-2 py-1 text-foreground disabled:opacity-40`,children:`+`})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`Brief overlay`}),(0,B.jsx)(f5,{save:f.brief}),(0,B.jsx)(`input`,{"aria-label":`Brief overlay`,value:i,onChange:e=>w(e.target.value),placeholder:`docs/briefs/refactor-p3.md`,className:`min-w-56 rounded-md border border-input bg-background px-2 py-1 font-mono text-[11px] text-foreground`})]}),(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Markdown appended to every item's kickoff brief for this run.`}),(0,B.jsx)(`p`,{className:`text-[11px] ${S.tone===`error`?`text-destructive`:S.tone===`success`?`text-success`:`text-muted-foreground`}`,children:S.text})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`Pickup posture`}),(0,B.jsx)(f5,{save:f.posture}),(0,B.jsx)(`div`,{className:`flex gap-1`,children:[`open`,`drain`].map(t=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":e.posture===t,onClick:()=>{t!==e.posture&&(s(t),d(u5[t]))},className:`rounded-md border px-2 py-1 text-[10px] uppercase tracking-wide ${e.posture===t?d5[t]:`border-border text-muted-foreground`}`,children:t},t))})]}),(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:B$t[e.posture]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`capitalize text-foreground`,children:e.posture}),(0,B.jsx)(`span`,{children:`· set by`}),(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:e.postureSetBy??`operator`}),e.postureSetAt&&(0,B.jsxs)(`span`,{children:[`· `,W$t(e.postureSetAt)]}),(0,B.jsxs)(`span`,{children:[`— "`,e.postureReason??`No reason recorded.`,`"`]}),G$t(e.posture,e.postureReason)&&(0,B.jsx)(`span`,{className:`rounded-sm border border-warning/[0.32] bg-warning/[0.08] px-1 py-0.5 text-[10px] uppercase text-warning-foreground`,title:`This reason was recorded before the current posture was set — it describes a previous state.`,children:`stale reason`})]}),o&&(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-2 ${d5[o]}`,children:[(0,B.jsx)(`p`,{className:`text-[11px]`,children:z$t[o]}),(0,B.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Why? Recorded on the run and shown to anyone reading this book.`}),(0,B.jsx)(`input`,{ref:_,"aria-label":`Posture reason`,value:u,onChange:e=>d(e.target.value),className:`rounded-md border border-input bg-background px-2 py-1 text-[11px] text-foreground`})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>{C(`posture`,{posture:o,postureReason:u.trim()||u5[o]}),s(null)},className:`rounded-md border px-2 py-1 text-[10px] uppercase tracking-wide ${d5[o]}`,children:V$t[o]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:`rounded-md border border-border px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Cancel`})]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`Off-book pickup`}),(0,B.jsx)(`button`,{type:`button`,"aria-expanded":c,onClick:()=>l(e=>!e),className:`text-[11px] text-muted-foreground underline`,children:`how the override works`})]}),(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`🔒 Blocked while this book runs — fixed policy, not a preference.`}),c&&(0,B.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`While a run is active the flywheel only starts issues that are in this book. Starting anything else requires`,` `,(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:`pan start <id> --off-book`}),`, which succeeds but is written to the run record with who ran it and when — an audited exception, not a setting.`]})]})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-border pt-2 text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`Changes save automatically`}),(0,B.jsx)(`span`,{className:`font-mono`,children:m?`last saved ${U$t(m)}`:`last saved —`})]})]})}function Q$t({status:e,blocks:t,warns:n,starting:r=!1,onPreview:i,onQueue:a,onStart:o}){let s=t.length>0,c=e===`draft`,l=e===`ready`,u=r?c?`Queueing…`:`Starting…`:c?`Queue book`:l?`Start run`:e===`running`?`Run active`:`Book complete`;return(0,B.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,"aria-label":`Start validation`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Start validation`}),(0,B.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:s?`${t.length} blocking`:`Ready to start`})]}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[t.map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 p-2 text-xs`,role:`alert`,children:[(0,B.jsx)(bs,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:e.issue}),` `,(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:e.message})]})]},`${e.code}-${e.issue}`)),n.map(e=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/[0.32] bg-warning/[0.08] p-2 text-xs`,children:[(0,B.jsx)(il,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning-foreground`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:e.issue}),` `,(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:e.message})]})]},`${e.code}-${e.issue}`)),!s&&n.length===0&&(0,B.jsx)(`p`,{className:`text-xs text-success`,children:`✓ No blocking findings.`})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(Rs,{className:`h-3.5 w-3.5`}),` Preview brief`]}),(0,B.jsxs)(`button`,{type:`button`,disabled:s||r||!c&&!l,title:s?`Resolve every blocking finding before queueing or starting this book`:void 0,onClick:c?a:o,className:`flex items-center gap-1.5 rounded-md border border-primary/50 bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:[(0,B.jsx)(Ac,{className:`h-3.5 w-3.5`}),` `,u]})]})]})}async function p5(e){let t=await e.json().catch(()=>null);return typeof t?.error==`string`?t.error:`Request failed (${e.status})`}function $$t(){return new URLSearchParams(window.location.search).get(`project`)}function e1t(){let[e,t]=(0,z.useState)([]),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!0),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(`setup`),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)($$t),[v,y]=(0,z.useState)(null),{data:b=[]}=V({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);return e.json()},staleTime:6e4}),x=(0,z.useRef)(0),S=(0,z.useCallback)(async()=>{let e=++x.current;a(!0),s(null);try{let n=await fetch(c5(`/api/orders`,g));if(!n.ok)throw Error(await p5(n));let i=await n.json();if(x.current!==e)return;t(i.books),i.project&&y(i.project),r(e=>e&&i.books.some(t=>t.id===e)?e:i.books.find(e=>e.status===`running`)?.id??i.books.find(e=>e.status===`ready`||e.status===`draft`)?.id??i.books[0]?.id??null)}catch(t){if(x.current!==e)return;s(t instanceof Error?t.message:String(t))}finally{x.current===e&&a(!1)}},[g]),C=(0,z.useCallback)(e=>{_(e),r(null),t([]),l(null),h(null);let n=new URLSearchParams(window.location.search);n.set(`project`,e),window.history.replaceState(null,``,`${window.location.pathname}?${n.toString()}`)},[]),w=g??v,T=(0,z.useMemo)(()=>{let e=b.map(e=>e.key);return w&&!e.includes(w)?[w,...e]:e},[b,w]);(0,z.useEffect)(()=>{S()},[S]);let E=(0,z.useMemo)(()=>e.find(e=>e.id===n)??null,[e,n]),D=(0,z.useCallback)(e=>{t(t=>t.map(t=>t.id===e.id?e:t))},[]);(0,z.useEffect)(()=>{if(!n)return;let e=!0;return fetch(c5(`/api/orders/${encodeURIComponent(n)}`,g)).then(async e=>{if(!e.ok)throw Error(await p5(e));return e.json()}).then(t=>{e&&D(t)}).catch(t=>{e&&h(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[n,D,g]);let O=async e=>{let n=await fetch(c5(`/api/orders`,g),{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({name:e})});if(!n.ok)throw Error(await p5(n));let i=await n.json();t(e=>[...e,i]),r(i.id)},k=async e=>{if(!E)return;let t=await fetch(c5(`/api/orders/${encodeURIComponent(E.id)}`,g),{method:`PATCH`,credentials:`include`,headers:await sb(),body:JSON.stringify(e)});if(!t.ok)throw Error(await p5(t));D(await t.json())},A=async e=>{await k({settings:e})},j=async()=>{if(E){p(!0),h(null);try{await k({status:`ready`}),h(`${E.name} is queued and ready to start.`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},M=async()=>{if(!E)return;h(null);let e=await fetch(c5(`/api/orders/${encodeURIComponent(E.id)}/preview-brief`,g));if(!e.ok){h(await p5(e));return}l((await e.json()).brief)},N=async e=>{let t=await fetch(`/api/flywheel/report/open`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({runId:e})});t.ok||h(await p5(t))},P=async()=>{if(E){p(!0),h(null);try{let e=await fetch(c5(`/api/orders/${encodeURIComponent(E.id)}/start`,g),{method:`POST`,credentials:`include`,headers:await sb()});if(!e.ok)throw Error(await p5(e));h(`Started ${(await e.json()).runId} from ${E.name}.`),await S()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,B.jsxs)(`main`,{className:`flex h-full w-full flex-col overflow-hidden bg-background font-medium`,"aria-label":`Order Book page`,children:[(0,B.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-border px-5 py-3`,children:[(0,B.jsx)(ss,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-sm font-medium text-foreground`,children:`Order Book`}),(0,B.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Operator special orders executed with lane semantics`})]}),(0,B.jsxs)(`label`,{className:`ml-2 flex items-center gap-1.5 border-l border-border pl-3 text-[11px] text-muted-foreground`,children:[`Project`,(0,B.jsxs)(`select`,{"aria-label":`Order book project`,value:w??``,onChange:e=>C(e.target.value),className:`rounded-sm border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-[11px] text-foreground`,children:[!w&&(0,B.jsx)(`option`,{value:``,children:`Loading…`}),T.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),E&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`ml-2 border-l border-border pl-3 font-mono text-[11px] text-muted-foreground`,children:E.id}),(0,B.jsx)(`span`,{className:`rounded-sm border border-border bg-muted/40 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:E.status}),(0,B.jsx)(`div`,{className:`ml-auto flex rounded-md border border-border p-0.5 text-[10px]`,"aria-label":`Order book view`,children:[`setup`,`progress`].map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded-sm px-2.5 py-1 capitalize ${u===e?`bg-muted text-foreground`:`text-muted-foreground`}`,children:e},e))}),(0,B.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[u===`setup`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:E.progress.landed}),`/`,(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:E.progress.total}),` landed`]}):`Live progress below`,E.runId&&(0,B.jsxs)(B.Fragment,{children:[` · run `,(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:E.runId})]})]})]})]}),(0,B.jsx)(D$t,{books:e,selectedId:n,onSelect:r,onCreate:O}),(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto p-5`,children:[i&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,children:[(0,B.jsx)(gc,{className:`h-4 w-4 animate-spin`}),` Loading order books…`]}),o&&(0,B.jsxs)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:[o,(0,B.jsx)(`button`,{type:`button`,onClick:()=>void S(),className:`ml-3 underline`,children:`Retry`})]}),!i&&!o&&!E&&(0,B.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center text-sm text-muted-foreground`,children:`No order books yet. Create one to assemble a Flywheel campaign.`}),!i&&E&&(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-6xl flex-col gap-4`,children:[(0,B.jsx)(N$t,{status:E.status}),u===`setup`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{"data-testid":`order-book-posture`,"data-posture":E.settings.posture,className:`flex flex-wrap items-center gap-3 rounded-lg border px-4 py-3 ${E.settings.posture===`drain`?`border-warning/[0.32] bg-warning/[0.08]`:`border-border bg-card`}`,children:[(0,B.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:`Pickup posture`}),(0,B.jsx)(`span`,{className:`rounded-sm border px-2 py-1 text-[11px] font-medium ${E.settings.posture===`drain`?`border-warning/[0.32] bg-warning/[0.08] text-warning-foreground`:`border-border bg-muted/40 text-foreground`}`,children:E.settings.posture.toUpperCase()}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E.settings.posture===`drain`?`Drain set by ${E.settings.postureSetBy??`operator`}${E.settings.postureSetAt?` on ${E.settings.postureSetAt.slice(0,10)}`:``} — ${E.settings.postureReason??`No reason recorded.`}`:`Open posture permits eligible order-book items to dispatch; no operator hold is active.`})]}),(0,B.jsx)(M$t,{book:E,onBookChange:D,project:g}),(0,B.jsxs)(`section`,{className:`grid gap-3 lg:grid-cols-2`,"aria-label":`Add issues to order book`,children:[(0,B.jsx)(w$t,{book:E,books:e,onBookChange:D,project:g}),(0,B.jsx)(T$t,{book:E,onBookChange:D,project:g})]}),(0,B.jsxs)(`section`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,B.jsx)(Z$t,{settings:E.settings,onChange:A},E.id),(0,B.jsx)(Q$t,{status:E.status,blocks:E.validation?.blocks??[],warns:E.validation?.warns??[],starting:f,onPreview:()=>void M(),onQueue:()=>void j(),onStart:()=>void P()})]}),m&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:m}),c&&(0,B.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,"aria-label":`Brief preview`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,B.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Brief preview`}),(0,B.jsx)(`button`,{type:`button`,className:`ml-auto text-xs text-muted-foreground hover:text-foreground`,onClick:()=>l(null),children:`Close`})]}),(0,B.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap font-mono text-[11px] text-muted-foreground`,children:c})]})]}):(0,B.jsx)(R$t,{book:E,onOpenReport:e=>void N(e)})]})]})]})}function m5(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=m5(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var{useDebugValue:t1t}=z.default,{useSyncExternalStoreWithSelector:n1t}=_Ne.default,r1t=e=>e;function i1t(e,t=r1t,n){let r=n1t(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return t1t(r),r}var a1t=(e,t)=>{let n=pNe(e),r=(e,r=t)=>i1t(n,e,r);return Object.assign(r,n),r},o1t=(e,t)=>e?a1t(e,t):a1t;function h5(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var g5=e=>()=>e;function _5(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}_5.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function s1t(e){return!e.ctrlKey&&!e.button}function c1t(){return this.parentNode}function l1t(e,t){return t??{x:e.x,y:e.y}}function u1t(){return navigator.maxTouchPoints||`ontouchstart`in this}function d1t(){var e=s1t,t=c1t,n=l1t,r=u1t,i={},a=E(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,N).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(L(n.view).on(`mousemove.drag`,m,F).on(`mouseup.drag`,h,F),P(n.view),T(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(C(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){L(e.view).on(`mousemove.drag mouseup.drag`,null),k(e.view,l),C(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(T(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(C(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(T(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=A(l||r,t),p,m,h;if((h=n.call(e,new _5(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=A(l||a,t),_=o;break}u.call(r,e,new _5(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:g5(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:g5(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:g5(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:g5(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var v5=(0,z.createContext)(null),f1t=v5.Provider,y5={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?`target`:`source`} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},p1t=y5.error001();function b5(e,t){let n=(0,z.useContext)(v5);if(n===null)throw Error(p1t);return i1t(n,e,t)}var x5=()=>{let e=(0,z.useContext)(v5);if(e===null)throw Error(p1t);return(0,z.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},m1t=e=>e.userSelectionActive?`none`:`all`;function h1t({position:e,children:t,className:n,style:r,...i}){let a=b5(m1t),o=`${e}`.split(`-`);return z.createElement(`div`,{className:m5([`react-flow__panel`,n,...o]),style:{...r,pointerEvents:a},...i},t)}function g1t({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:z.createElement(h1t,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro`},z.createElement(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`},`React Flow`))}var _1t=(0,z.memo)(({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u})=>{let d=(0,z.useRef)(null),[f,p]=(0,z.useState)({x:0,y:0,width:0,height:0}),m=m5([`react-flow__edge-textwrapper`,l]);return(0,z.useEffect)(()=>{if(d.current){let e=d.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n===void 0||!n?null:z.createElement(`g`,{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:m,visibility:f.width?`visible`:`hidden`,...u},i&&z.createElement(`rect`,{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),z.createElement(`text`,{className:`react-flow__edge-text`,y:f.height/2,dy:`0.3em`,ref:d,style:r},n),c)}),S5=e=>({width:e.offsetWidth,height:e.offsetHeight}),C5=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),w5=(e={x:0,y:0},t)=>({x:C5(e.x,t[0][0],t[1][0]),y:C5(e.y,t[0][1],t[1][1])}),v1t=(e,t,n)=>e<t?C5(Math.abs(e-t),1,50)/50:e>n?-C5(Math.abs(e-n),1,50)/50:0,y1t=(e,t)=>[v1t(e.x,35,t.width-35)*20,v1t(e.y,35,t.height-35)*20],b1t=e=>e.getRootNode?.()||window?.document,x1t=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),T5=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),S1t=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),C1t=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),E5=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},w1t=e=>D5(e.width)&&D5(e.height)&&D5(e.x)&&D5(e.y),D5=e=>!isNaN(e)&&isFinite(e),O5=Symbol.for(`internals`),T1t=[`Enter`,` `,`Escape`],E1t=(e,t)=>{},D1t=e=>`nativeEvent`in e;function k5(e){let t=(D1t(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return[`INPUT`,`SELECT`,`TEXTAREA`].includes(t?.nodeName)||t?.hasAttribute(`contenteditable`)||!!t?.closest(`.nokey`)}var O1t=e=>`clientX`in e,A5=(e,t)=>{let n=O1t(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},j5=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0,M5=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:p=20})=>z.createElement(z.Fragment,null,z.createElement(`path`,{id:e,style:u,d:t,fill:`none`,className:`react-flow__edge-path`,markerEnd:d,markerStart:f}),p&&z.createElement(`path`,{d:t,fill:`none`,strokeOpacity:0,strokeWidth:p,className:`react-flow__edge-interaction`}),i&&D5(n)&&D5(r)?z.createElement(_1t,{x:n,y:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l}):null);M5.displayName=`BaseEdge`;function N5(e,t,n){return n===void 0?n:r=>{let i=t().edges.find(t=>t.id===e);i&&n(r,{...i})}}function k1t({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function A1t({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}var P5;(function(e){e.Strict=`strict`,e.Loose=`loose`})(P5||={});var F5;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(F5||={});var I5;(function(e){e.Partial=`partial`,e.Full=`full`})(I5||={});var L5;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(L5||={});var R5;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(R5||={});var z5;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(z5||={});function j1t({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===z5.Left||e===z5.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function M1t({sourceX:e,sourceY:t,sourcePosition:n=z5.Bottom,targetX:r,targetY:i,targetPosition:a=z5.Top}){let[o,s]=j1t({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=j1t({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=A1t({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}var B5=(0,z.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=z5.Bottom,targetPosition:a=z5.Top,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=M1t({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a});return z.createElement(M5,{path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})});B5.displayName=`SimpleBezierEdge`;var N1t={[z5.Left]:{x:-1,y:0},[z5.Right]:{x:1,y:0},[z5.Top]:{x:0,y:-1},[z5.Bottom]:{x:0,y:1}},P1t=({source:e,sourcePosition:t=z5.Bottom,target:n})=>t===z5.Left||t===z5.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},F1t=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function I1t({source:e,sourcePosition:t=z5.Bottom,target:n,targetPosition:r=z5.Top,center:i,offset:a}){let o=N1t[t],s=N1t[r],c={x:e.x+o.x*a,y:e.y+o.y*a},l={x:n.x+s.x*a,y:n.y+s.y*a},u=P1t({source:c,sourcePosition:t,target:l}),d=u.x===0?`y`:`x`,f=u[d],p=[],m,h,g={x:0,y:0},_={x:0,y:0},[v,y,b,x]=k1t({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[d]*s[d]===-1){m=i.x??v,h=i.y??y;let e=[{x:m,y:c.y},{x:m,y:l.y}],t=[{x:c.x,y:h},{x:l.x,y:h}];p=o[d]===f?d===`x`?e:t:d===`x`?t:e}else{let i=[{x:c.x,y:l.y}],u=[{x:l.x,y:c.y}];if(p=d===`x`?o.x===f?u:i:o.y===f?i:u,t===r){let t=Math.abs(e[d]-n[d]);if(t<=a){let r=Math.min(a-1,a-t);o[d]===f?g[d]=(c[d]>e[d]?-1:1)*r:_[d]=(l[d]>n[d]?-1:1)*r}}if(t!==r){let e=d===`x`?`y`:`x`,t=o[d]===s[e],n=c[e]>l[e],r=c[e]<l[e];(o[d]===1&&(!t&&n||t&&r)||o[d]!==1&&(!t&&r||t&&n))&&(p=d===`x`?i:u)}let v={x:c.x+g.x,y:c.y+g.y},y={x:l.x+_.x,y:l.y+_.y};Math.max(Math.abs(v.x-p[0].x),Math.abs(y.x-p[0].x))>=Math.max(Math.abs(v.y-p[0].y),Math.abs(y.y-p[0].y))?(m=(v.x+y.x)/2,h=p[0].y):(m=p[0].x,h=(v.y+y.y)/2)}return[[e,{x:c.x+g.x,y:c.y+g.y},...p,{x:l.x+_.x,y:l.y+_.y},n],m,h,b,x]}function L1t(e,t,n,r){let i=Math.min(F1t(e,t)/2,F1t(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function V5({sourceX:e,sourceY:t,sourcePosition:n=z5.Bottom,targetX:r,targetY:i,targetPosition:a=z5.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20}){let[u,d,f,p,m]=I1t({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l});return[u.reduce((e,t,n)=>{let r=``;return r=n>0&&n<u.length-1?L1t(u[n-1],t,u[n+1],o):`${n===0?`M`:`L`}${t.x} ${t.y}`,e+=r,e},``),d,f,p,m]}var H5=(0,z.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:d=z5.Bottom,targetPosition:f=z5.Top,markerEnd:p,markerStart:m,pathOptions:h,interactionWidth:g})=>{let[_,v,y]=V5({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:h?.borderRadius,offset:h?.offset});return z.createElement(M5,{path:_,labelX:v,labelY:y,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:p,markerStart:m,interactionWidth:g})});H5.displayName=`SmoothStepEdge`;var U5=(0,z.memo)(e=>z.createElement(H5,{...e,pathOptions:(0,z.useMemo)(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));U5.displayName=`StepEdge`;function R1t({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=k1t({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var W5=(0,z.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:p})=>{let[m,h,g]=R1t({sourceX:e,sourceY:t,targetX:n,targetY:r});return z.createElement(M5,{path:m,labelX:h,labelY:g,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:p})});W5.displayName=`StraightEdge`;function G5(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function z1t({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case z5.Left:return[t-G5(t-r,a),n];case z5.Right:return[t+G5(r-t,a),n];case z5.Top:return[t,n-G5(n-i,a)];case z5.Bottom:return[t,n+G5(i-n,a)]}}function B1t({sourceX:e,sourceY:t,sourcePosition:n=z5.Bottom,targetX:r,targetY:i,targetPosition:a=z5.Top,curvature:o=.25}){let[s,c]=z1t({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=z1t({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=A1t({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}var K5=(0,z.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=z5.Bottom,targetPosition:a=z5.Top,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,pathOptions:h,interactionWidth:g})=>{let[_,v,y]=B1t({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a,curvature:h?.curvature});return z.createElement(M5,{path:_,labelX:v,labelY:y,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:g})});K5.displayName=`BezierEdge`;var q5=(0,z.createContext)(null),V1t=q5.Provider;q5.Consumer;var H1t=()=>(0,z.useContext)(q5),U1t=e=>`id`in e&&`source`in e&&`target`in e,W1t=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||``}-${n}${r||``}`,J5=(e,t)=>e===void 0?``:typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`,G1t=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),K1t=(e,t)=>{if(!e.source||!e.target)return y5.error006(),t;let n;return n=U1t(e)?{...e}:{...e,id:W1t(e)},G1t(n,t)?t:t.concat(n)},Y5=({x:e,y:t},[n,r,i],a,[o,s])=>{let c={x:(e-n)/i,y:(t-r)/i};return a?{x:o*Math.round(c.x/o),y:s*Math.round(c.y/s)}:c},q1t=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),X5=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};let n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},Z5=(e,t=[0,0])=>e.length===0?{x:0,y:0,width:0,height:0}:S1t(e.reduce((e,n)=>{let{x:r,y:i}=X5(n,t).positionAbsolute;return x1t(e,T5({x:r,y:i,width:n.width||0,height:n.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),J1t=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1,s=[0,0])=>{let c={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},l=[];return e.forEach(e=>{let{width:t,height:n,selectable:r=!0,hidden:i=!1}=e;if(o&&!r||i)return!1;let{positionAbsolute:u}=X5(e,s),d=E5(c,{x:u.x,y:u.y,width:t||0,height:n||0}),f=t===void 0||n===void 0||t===null||n===null,p=a&&d>0,m=(t||0)*(n||0);(f||p||d>=m||e.dragging)&&l.push(e)}),l},Y1t=(e,t)=>{let n=e.map(e=>e.id);return t.filter(e=>n.includes(e.source)||n.includes(e.target))},X1t=(e,t,n,r,i,a=.1)=>{let o=t/(e.width*(1+a)),s=n/(e.height*(1+a)),c=C5(Math.min(o,s),r,i),l=e.x+e.width/2,u=e.y+e.height/2;return{x:t/2-l*c,y:n/2-u*c,zoom:c}},Q5=(e,t=0)=>e.transition().duration(t);function Z1t(e,t,n,r){return(t[n]||[]).reduce((t,i)=>(`${e.id}-${i.id}-${n}`!==r&&t.push({id:i.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+i.x+i.width/2,y:(e.positionAbsolute?.y??0)+i.y+i.height/2}),t),[])}function Q1t(e,t,n,r,i,a){let{x:o,y:s}=A5(e),c=t.elementsFromPoint(o,s).find(e=>e.classList.contains(`react-flow__handle`));if(c){let e=c.getAttribute(`data-nodeid`);if(e){let t=$5(void 0,c),r=c.getAttribute(`data-handleid`),o=a({nodeId:e,id:r,type:t});if(o){let a=i.find(n=>n.nodeId===e&&n.type===t&&n.id===r);return{handle:{id:r,type:t,nodeId:e,x:a?.x||n.x,y:a?.y||n.y},validHandleResult:o}}}}let l=[],u=1/0;if(i.forEach(e=>{let t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=r){let n=a(e);t<=u&&(t<u?l=[{handle:e,validHandleResult:n}]:t===u&&l.push({handle:e,validHandleResult:n}),u=t)}}),!l.length)return{handle:null,validHandleResult:e0t()};if(l.length===1)return l[0];let d=l.some(({validHandleResult:e})=>e.isValid),f=l.some(({handle:e})=>e.type===`target`);return l.find(({handle:e,validHandleResult:t})=>f?e.type===`target`:d?t.isValid:!0)||l[0]}var $1t={source:null,target:null,sourceHandle:null,targetHandle:null},e0t=()=>({handleDomNode:null,isValid:!1,connection:$1t,endHandle:null});function t0t(e,t,n,r,i,a,o){let s=i===`target`,c=o.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),l={...e0t(),handleDomNode:c};if(c){let e=$5(void 0,c),i=c.getAttribute(`data-nodeid`),o=c.getAttribute(`data-handleid`),u=c.classList.contains(`connectable`),d=c.classList.contains(`connectableend`),f={source:s?i:n,sourceHandle:s?o:r,target:s?n:i,targetHandle:s?r:o};l.connection=f,u&&d&&(t===P5.Strict?s&&e===`source`||!s&&e===`target`:i!==n||o!==r)&&(l.endHandle={nodeId:i,handleId:o,type:e},l.isValid=a(f))}return l}function n0t({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((e,i)=>{if(i[O5]){let{handleBounds:a}=i[O5],o=[],s=[];a&&(o=Z1t(i,a,`source`,`${t}-${n}-${r}`),s=Z1t(i,a,`target`,`${t}-${n}-${r}`)),e.push(...o,...s)}return e},[])}function $5(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function e7(e){e?.classList.remove(`valid`,`connecting`,`react-flow__handle-valid`,`react-flow__handle-connecting`)}function r0t(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function i0t({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:a,setState:o,isValidConnection:s,edgeUpdaterType:c,onReconnectEnd:l}){let u=b1t(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:p,connectionRadius:m,onConnectStart:h,panBy:g,getNodes:_,cancelConnection:v}=a(),y=0,b,{x,y:S}=A5(e),C=u?.elementFromPoint(x,S),w=$5(c,C),T=f?.getBoundingClientRect();if(!T||!w)return;let E,D=A5(e,T),O=!1,k=null,A=!1,j=null,M=n0t({nodes:_(),nodeId:n,handleId:t,handleType:w}),N=()=>{if(!p)return;let[e,t]=y1t(D,T);g({x:e,y:t}),y=requestAnimationFrame(N)};o({connectionPosition:D,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:w,connectionStartHandle:{nodeId:n,handleId:t,type:w},connectionEndHandle:null}),h?.(e,{nodeId:n,handleId:t,handleType:w});function P(e){let{transform:r}=a();D=A5(e,T);let{handle:c,validHandleResult:l}=Q1t(e,u,Y5(D,r,!1,[1,1]),m,M,e=>t0t(e,d,n,t,i?`target`:`source`,s,u));if(b=c,O||=(N(),!0),j=l.handleDomNode,k=l.connection,A=l.isValid,o({connectionPosition:b&&A?q1t({x:b.x,y:b.y},r):D,connectionStatus:r0t(!!b,A),connectionEndHandle:l.endHandle}),!b&&!A&&!j)return e7(E);k.source!==k.target&&j&&(e7(E),E=j,j.classList.add(`connecting`,`react-flow__handle-connecting`),j.classList.toggle(`valid`,A),j.classList.toggle(`react-flow__handle-valid`,A))}function F(e){(b||j)&&k&&A&&r?.(k),a().onConnectEnd?.(e),c&&l?.(e),e7(E),v(),cancelAnimationFrame(y),O=!1,A=!1,k=null,j=null,u.removeEventListener(`mousemove`,P),u.removeEventListener(`mouseup`,F),u.removeEventListener(`touchmove`,P),u.removeEventListener(`touchend`,F)}u.addEventListener(`mousemove`,P),u.addEventListener(`mouseup`,F),u.addEventListener(`touchmove`,P),u.addEventListener(`touchend`,F)}var a0t=()=>!0,o0t=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),s0t=(e,t,n)=>r=>{let{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:o}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||a?.nodeId===e&&a?.handleId===t&&a?.type===n,clickConnecting:o?.nodeId===e&&o?.handleId===t&&o?.type===n}},c0t=(0,z.forwardRef)(({type:e=`source`,position:t=z5.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p)=>{let m=o||null,h=e===`target`,g=x5(),_=H1t(),{connectOnClick:v,noPanClassName:y}=b5(o0t,h5),{connecting:b,clickConnecting:x}=b5(s0t(_,m,e),h5);_||g.getState().onError?.(`010`,y5.error010());let S=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(K1t(i,e))}n?.(i),s?.(i)},C=e=>{if(!_)return;let t=O1t(e);i&&(t&&e.button===0||!t)&&i0t({event:e,handleId:m,nodeId:_,onConnect:S,isTarget:h,getState:g.getState,setState:g.setState,isValidConnection:n||g.getState().isValidConnection||a0t}),t?u?.(e):d?.(e)};return z.createElement(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${_}-${m}-${e}`,className:m5([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,connecting:x,connectionindicator:r&&(i&&!b||a&&b)}]),onMouseDown:C,onTouchStart:C,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,handleId:m}});return}let l=b1t(t.target),u=n||c||a0t,{connection:d,isValid:f}=t0t({nodeId:_,id:m,type:e},s,o.nodeId,o.handleId||null,o.type,u,l);f&&S(d),a?.(t),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f},c)});c0t.displayName=`Handle`;var t7=(0,z.memo)(c0t),l0t=({data:e,isConnectable:t,targetPosition:n=z5.Top,sourcePosition:r=z5.Bottom})=>z.createElement(z.Fragment,null,z.createElement(t7,{type:`target`,position:n,isConnectable:t}),e?.label,z.createElement(t7,{type:`source`,position:r,isConnectable:t}));l0t.displayName=`DefaultNode`;var n7=(0,z.memo)(l0t),u0t=({data:e,isConnectable:t,sourcePosition:n=z5.Bottom})=>z.createElement(z.Fragment,null,e?.label,z.createElement(t7,{type:`source`,position:n,isConnectable:t}));u0t.displayName=`InputNode`;var d0t=(0,z.memo)(u0t),f0t=({data:e,isConnectable:t,targetPosition:n=z5.Top})=>z.createElement(z.Fragment,null,z.createElement(t7,{type:`target`,position:n,isConnectable:t}),e?.label);f0t.displayName=`OutputNode`;var p0t=(0,z.memo)(f0t),r7=()=>null;r7.displayName=`GroupNode`;var m0t=e=>({selectedNodes:e.getNodes().filter(e=>e.selected),selectedEdges:e.edges.filter(e=>e.selected).map(e=>({...e}))}),i7=e=>e.id;function h0t(e,t){return h5(e.selectedNodes.map(i7),t.selectedNodes.map(i7))&&h5(e.selectedEdges.map(i7),t.selectedEdges.map(i7))}var g0t=(0,z.memo)(({onSelectionChange:e})=>{let t=x5(),{selectedNodes:n,selectedEdges:r}=b5(m0t,h0t);return(0,z.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(e=>e(i))},[n,r,e]),null});g0t.displayName=`SelectionListener`;var _0t=e=>!!e.onSelectionChange;function v0t({onSelectionChange:e}){let t=b5(_0t);return e||t?z.createElement(g0t,{onSelectionChange:e}):null}var y0t=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function a7(e,t){(0,z.useEffect)(()=>{e!==void 0&&t(e)},[e])}function o7(e,t,n){(0,z.useEffect)(()=>{t!==void 0&&n({[e]:t})},[t])}var b0t=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:a,onConnectEnd:o,onClickConnectStart:s,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:p,elevateNodesOnSelect:m,minZoom:h,maxZoom:g,nodeExtent:_,onNodesChange:v,onEdgesChange:y,elementsSelectable:b,connectionMode:x,snapGrid:S,snapToGrid:C,translateExtent:w,connectOnClick:T,defaultEdgeOptions:E,fitView:D,fitViewOptions:O,onNodesDelete:k,onEdgesDelete:A,onNodeDrag:j,onNodeDragStart:M,onNodeDragStop:N,onSelectionDrag:P,onSelectionDragStart:F,onSelectionDragStop:I,noPanClassName:L,nodeOrigin:ee,rfId:R,autoPanOnConnect:te,autoPanOnNodeDrag:ne,onError:re,connectionRadius:ie,isValidConnection:ae,nodeDragThreshold:oe})=>{let{setNodes:se,setEdges:ce,setDefaultNodesAndEdges:le,setMinZoom:ue,setMaxZoom:de,setTranslateExtent:fe,setNodeExtent:pe,reset:me}=b5(y0t,h5),he=x5();return(0,z.useEffect)(()=>{let e=r?.map(e=>({...e,...E}));return le(n,e),()=>{me()}},[]),o7(`defaultEdgeOptions`,E,he.setState),o7(`connectionMode`,x,he.setState),o7(`onConnect`,i,he.setState),o7(`onConnectStart`,a,he.setState),o7(`onConnectEnd`,o,he.setState),o7(`onClickConnectStart`,s,he.setState),o7(`onClickConnectEnd`,c,he.setState),o7(`nodesDraggable`,l,he.setState),o7(`nodesConnectable`,u,he.setState),o7(`nodesFocusable`,d,he.setState),o7(`edgesFocusable`,f,he.setState),o7(`edgesUpdatable`,p,he.setState),o7(`elementsSelectable`,b,he.setState),o7(`elevateNodesOnSelect`,m,he.setState),o7(`snapToGrid`,C,he.setState),o7(`snapGrid`,S,he.setState),o7(`onNodesChange`,v,he.setState),o7(`onEdgesChange`,y,he.setState),o7(`connectOnClick`,T,he.setState),o7(`fitViewOnInit`,D,he.setState),o7(`fitViewOnInitOptions`,O,he.setState),o7(`onNodesDelete`,k,he.setState),o7(`onEdgesDelete`,A,he.setState),o7(`onNodeDrag`,j,he.setState),o7(`onNodeDragStart`,M,he.setState),o7(`onNodeDragStop`,N,he.setState),o7(`onSelectionDrag`,P,he.setState),o7(`onSelectionDragStart`,F,he.setState),o7(`onSelectionDragStop`,I,he.setState),o7(`noPanClassName`,L,he.setState),o7(`nodeOrigin`,ee,he.setState),o7(`rfId`,R,he.setState),o7(`autoPanOnConnect`,te,he.setState),o7(`autoPanOnNodeDrag`,ne,he.setState),o7(`onError`,re,he.setState),o7(`connectionRadius`,ie,he.setState),o7(`isValidConnection`,ae,he.setState),o7(`nodeDragThreshold`,oe,he.setState),a7(e,se),a7(t,ce),a7(h,ue),a7(g,de),a7(w,fe),a7(_,pe),null},x0t={display:`none`},S0t={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},C0t=`react-flow__node-desc`,w0t=`react-flow__edge-desc`,T0t=`react-flow__aria-live`,E0t=e=>e.ariaLiveMessage;function D0t({rfId:e}){let t=b5(E0t);return z.createElement(`div`,{id:`${T0t}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:S0t},t)}function O0t({rfId:e,disableKeyboardA11y:t}){return z.createElement(z.Fragment,null,z.createElement(`div`,{id:`${C0t}-${e}`,style:x0t},`Press enter or space to select a node.`,!t&&`You can then use the arrow keys to move the node around.`,` Press delete to remove it and escape to cancel.`,` `),z.createElement(`div`,{id:`${w0t}-${e}`,style:x0t},`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`),!t&&z.createElement(D0t,{rfId:e}))}var s7=(e=null,t={actInsideInputWithModifier:!0})=>{let[n,r]=(0,z.useState)(!1),i=(0,z.useRef)(!1),a=(0,z.useRef)(new Set([])),[o,s]=(0,z.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.split(`+`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,z.useEffect)(()=>{let n=typeof document<`u`?document:null,c=t?.target||n;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&k5(e))return!1;let n=A0t(e.code,s);a.current.add(e[n]),k0t(o,a.current,!1)&&(e.preventDefault(),r(!0))},n=e=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&k5(e))return!1;let n=A0t(e.code,s);k0t(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[n]),e.key===`Meta`&&a.current.clear(),i.current=!1},l=()=>{a.current.clear(),r(!1)};return c?.addEventListener(`keydown`,e),c?.addEventListener(`keyup`,n),window.addEventListener(`blur`,l),()=>{c?.removeEventListener(`keydown`,e),c?.removeEventListener(`keyup`,n),window.removeEventListener(`blur`,l)}}},[e,r]),n};function k0t(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function A0t(e,t){return t.includes(e)?`code`:`key`}function j0t(e,t,n,r){let i=e.parentNode||e.parentId;if(!i)return n;let a=t.get(i),o=X5(a,r);return j0t(a,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(a[O5]?.z??0)>(n.z??0)?a[O5]?.z??0:n.z??0},r)}function M0t(e,t,n){e.forEach(r=>{let i=r.parentNode||r.parentId;if(i&&!e.has(i))throw Error(`Parent node ${i} not found`);if(i||n?.[r.id]){let{x:i,y:a,z:o}=j0t(r,e,{...r.position,z:r[O5]?.z??0},t);r.positionAbsolute={x:i,y:a},r[O5].z=o,n?.[r.id]&&(r[O5].isParent=!0)}})}function c7(e,t,n,r){let i=new Map,a={},o=r?1e3:0;return e.forEach(e=>{let n=(D5(e.zIndex)?e.zIndex:0)+(e.selected?o:0),r=t.get(e.id),s={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(a[c]=!0);let l=r?.type&&r?.type!==e.type;Object.defineProperty(s,O5,{enumerable:!1,value:{handleBounds:l?void 0:r?.[O5]?.handleBounds,z:n}}),i.set(e.id,s)}),M0t(i,n,a),i}function N0t(e,t={}){let{getNodes:n,width:r,height:i,minZoom:a,maxZoom:o,d3Zoom:s,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:d}=e(),f=t.initial&&!l&&u;if(s&&c&&(f||!t.initial)){let e=n().filter(e=>{let n=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return t.nodes?.length?n&&t.nodes.some(t=>t.id===e.id):n}),l=e.every(e=>e.width&&e.height);if(e.length>0&&l){let{x:n,y:l,zoom:u}=X1t(Z5(e,d),r,i,t.minZoom??a,t.maxZoom??o,t.padding??.1),f=M.translate(n,l).scale(u);return typeof t.duration==`number`&&t.duration>0?s.transform(Q5(c,t.duration),f):s.transform(c,f),!0}}return!1}function P0t(e,t){return e.forEach(e=>{let n=t.get(e.id);n&&t.set(n.id,{...n,[O5]:n[O5],selected:e.selected})}),new Map(t)}function F0t(e,t){return t.map(t=>{let n=e.find(e=>e.id===t.id);return n&&(t.selected=n.selected),t})}function l7({changedNodes:e,changedEdges:t,get:n,set:r}){let{nodeInternals:i,edges:a,onNodesChange:o,onEdgesChange:s,hasDefaultNodes:c,hasDefaultEdges:l}=n();e?.length&&(c&&r({nodeInternals:P0t(e,i)}),o?.(e)),t?.length&&(l&&r({edges:F0t(t,a)}),s?.(t))}var u7=()=>{},I0t={zoomIn:u7,zoomOut:u7,zoomTo:u7,getZoom:()=>1,setViewport:u7,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:u7,fitBounds:u7,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},L0t=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),R0t=()=>{let e=x5(),{d3Zoom:t,d3Selection:n}=b5(L0t,h5);return(0,z.useMemo)(()=>n&&t?{zoomIn:e=>t.scaleBy(Q5(n,e?.duration),1.2),zoomOut:e=>t.scaleBy(Q5(n,e?.duration),1/1.2),zoomTo:(e,r)=>t.scaleTo(Q5(n,r?.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(r,i)=>{let[a,o,s]=e.getState().transform,c=M.translate(r.x??a,r.y??o).scale(r.zoom??s);t.transform(Q5(n,i?.duration),c)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},fitView:t=>N0t(e.getState,t),setCenter:(r,i,a)=>{let{width:o,height:s,maxZoom:c}=e.getState(),l=a?.zoom===void 0?c:a.zoom,u=o/2-r*l,d=s/2-i*l,f=M.translate(u,d).scale(l);t.transform(Q5(n,a?.duration),f)},fitBounds:(r,i)=>{let{width:a,height:o,minZoom:s,maxZoom:c}=e.getState(),{x:l,y:u,zoom:d}=X1t(r,a,o,s,c,i?.padding??.1),f=M.translate(l,u).scale(d);t.transform(Q5(n,i?.duration),f)},project:t=>{let{transform:n,snapToGrid:r,snapGrid:i}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Y5(t,n,r,i)},screenToFlowPosition:t=>{let{transform:n,snapToGrid:r,snapGrid:i,domNode:a}=e.getState();if(!a)return t;let{x:o,y:s}=a.getBoundingClientRect();return Y5({x:t.x-o,y:t.y-s},n,r,i)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=q1t(t,n);return{x:o.x+i,y:o.y+a}},viewportInitialized:!0}:I0t,[t,n])};function d7(){let e=R0t(),t=x5(),n=(0,z.useCallback)(()=>t.getState().getNodes().map(e=>({...e})),[]),r=(0,z.useCallback)(e=>t.getState().nodeInternals.get(e),[]),i=(0,z.useCallback)(()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},[]),a=(0,z.useCallback)(e=>{let{edges:n=[]}=t.getState();return n.find(t=>t.id===e)},[]),o=(0,z.useCallback)(e=>{let{getNodes:n,setNodes:r,hasDefaultNodes:i,onNodesChange:a}=t.getState(),o=n(),s=typeof e==`function`?e(o):e;i?r(s):a&&a(s.length===0?o.map(e=>({type:`remove`,id:e.id})):s.map(e=>({item:e,type:`reset`})))},[]),s=(0,z.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a}=t.getState(),o=typeof e==`function`?e(n):e;i?r(o):a&&a(o.length===0?n.map(e=>({type:`remove`,id:e.id})):o.map(e=>({item:e,type:`reset`})))},[]),c=(0,z.useCallback)(e=>{let n=Array.isArray(e)?e:[e],{getNodes:r,setNodes:i,hasDefaultNodes:a,onNodesChange:o}=t.getState();a?i([...r(),...n]):o&&o(n.map(e=>({item:e,type:`add`})))},[]),l=(0,z.useCallback)(e=>{let n=Array.isArray(e)?e:[e],{edges:r=[],setEdges:i,hasDefaultEdges:a,onEdgesChange:o}=t.getState();a?i([...r,...n]):o&&o(n.map(e=>({item:e,type:`add`})))},[]),u=(0,z.useCallback)(()=>{let{getNodes:e,edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e().map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},[]),d=(0,z.useCallback)(({nodes:e,edges:n})=>{let{nodeInternals:r,getNodes:i,edges:a,hasDefaultNodes:o,hasDefaultEdges:s,onNodesDelete:c,onEdgesDelete:l,onNodesChange:u,onEdgesChange:d}=t.getState(),f=(e||[]).map(e=>e.id),p=(n||[]).map(e=>e.id),m=i().reduce((e,t)=>{let n=t.parentNode||t.parentId,r=!f.includes(t.id)&&n&&e.find(e=>e.id===n);return(typeof t.deletable!=`boolean`||t.deletable)&&(f.includes(t.id)||r)&&e.push(t),e},[]),h=a.filter(e=>typeof e.deletable==`boolean`?e.deletable:!0),g=h.filter(e=>p.includes(e.id));if(m||g){let e=Y1t(m,h),n=[...g,...e],i=n.reduce((e,t)=>(e.includes(t.id)||e.push(t.id),e),[]);(s||o)&&(s&&t.setState({edges:a.filter(e=>!i.includes(e.id))}),o&&(m.forEach(e=>{r.delete(e.id)}),t.setState({nodeInternals:new Map(r)}))),i.length>0&&(l?.(n),d&&d(i.map(e=>({id:e,type:`remove`})))),m.length>0&&(c?.(m),u&&u(m.map(e=>({id:e.id,type:`remove`}))))}},[]),f=(0,z.useCallback)(e=>{let n=w1t(e),r=n?null:t.getState().nodeInternals.get(e.id);return!n&&!r?[null,null,n]:[n?e:C1t(r),r,n]},[]),p=(0,z.useCallback)((e,n=!0,r)=>{let[i,a,o]=f(e);return i?(r||t.getState().getNodes()).filter(e=>{if(!o&&(e.id===a.id||!e.positionAbsolute))return!1;let t=E5(C1t(e),i);return n&&t>0||t>=i.width*i.height}):[]},[]),m=(0,z.useCallback)((e,t,n=!0)=>{let[r]=f(e);if(!r)return!1;let i=E5(r,t);return n&&i>0||i>=r.width*r.height},[]);return(0,z.useMemo)(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:a,setNodes:o,setEdges:s,addNodes:c,addEdges:l,toObject:u,deleteElements:d,getIntersectingNodes:p,isNodeIntersecting:m}),[e,n,r,i,a,o,s,c,l,u,d,p,m])}var z0t={actInsideInputWithModifier:!1},B0t=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{let n=x5(),{deleteElements:r}=d7(),i=s7(e,z0t),a=s7(t);(0,z.useEffect)(()=>{if(i){let{edges:e,getNodes:t}=n.getState();r({nodes:t().filter(e=>e.selected),edges:e.filter(e=>e.selected)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,z.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])};function V0t(e){let t=x5();(0,z.useEffect)(()=>{let n,r=()=>{if(!e.current)return;let n=S5(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,y5.error004()),t.setState({width:n.width||500,height:n.height||500})};return r(),window.addEventListener(`resize`,r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener(`resize`,r),n&&e.current&&n.unobserve(e.current)}},[])}var f7={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},H0t=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,p7=e=>({x:e.x,y:e.y,zoom:e.k}),m7=(e,t)=>e.target.closest(`.${t}`),U0t=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),W0t=e=>{let t=e.ctrlKey&&j5()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},G0t=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),K0t=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:c=F5.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:f,translateExtent:p,minZoom:m,maxZoom:h,zoomActivationKeyCode:g,preventScrolling:_=!0,children:v,noWheelClassName:y,noPanClassName:b})=>{let x=(0,z.useRef)(),S=x5(),C=(0,z.useRef)(!1),w=(0,z.useRef)(!1),T=(0,z.useRef)(null),E=(0,z.useRef)({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:O,d3ZoomHandler:k,userSelectionActive:j}=b5(G0t,h5),N=s7(g),P=(0,z.useRef)(0),F=(0,z.useRef)(!1),ee=(0,z.useRef)();return V0t(T),(0,z.useEffect)(()=>{if(T.current){let e=T.current.getBoundingClientRect(),t=I().scaleExtent([m,h]).translateExtent(p),n=L(T.current).call(t),r=M.translate(f.x,f.y).scale(C5(f.zoom,m,h)),i=[[0,0],[e.width,e.height]],a=t.constrain()(r,i,p);t.transform(n,a),t.wheelDelta(W0t),S.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on(`wheel.zoom`),transform:[a.x,a.y,a.k],domNode:T.current.closest(`.react-flow`)})}},[]),(0,z.useEffect)(()=>{O&&D&&(o&&!N&&!j?O.on(`wheel.zoom`,r=>{if(m7(r,y))return!1;r.preventDefault(),r.stopImmediatePropagation();let i=O.property(`__zoom`).k||1;if(r.ctrlKey&&a){let e=A(r),t=i*2**W0t(r);D.scaleTo(O,t,e,r);return}let o=r.deltaMode===1?20:1,l=c===F5.Vertical?0:r.deltaX*o,u=c===F5.Horizontal?0:r.deltaY*o;!j5()&&r.shiftKey&&c!==F5.Vertical&&(l=r.deltaY*o,u=0),D.translateBy(O,-(l/i)*s,-(u/i)*s,{internal:!0});let d=p7(O.property(`__zoom`)),{onViewportChangeStart:f,onViewportChange:p,onViewportChangeEnd:m}=S.getState();clearTimeout(ee.current),F.current||(F.current=!0,t?.(r,d),f?.(d)),F.current&&(e?.(r,d),p?.(d),ee.current=setTimeout(()=>{n?.(r,d),m?.(d),F.current=!1},150))},{passive:!1}):k!==void 0&&O.on(`wheel.zoom`,function(e,t){if(!_&&e.type===`wheel`&&!e.ctrlKey||m7(e,y))return null;e.preventDefault(),k.call(this,e,t)},{passive:!1}))},[j,o,c,O,D,k,N,a,_,y,t,e,n]),(0,z.useEffect)(()=>{D&&D.on(`start`,e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;P.current=e.sourceEvent?.button;let{onViewportChangeStart:n}=S.getState(),r=p7(e.transform);C.current=!0,E.current=r,e.sourceEvent?.type===`mousedown`&&S.setState({paneDragging:!0}),n?.(r),t?.(e.sourceEvent,r)})},[D,t]),(0,z.useEffect)(()=>{D&&(j&&!C.current?D.on(`zoom`,null):j||D.on(`zoom`,t=>{let{onViewportChange:n}=S.getState();if(S.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),w.current=!!(r&&U0t(d,P.current??0)),(e||n)&&!t.sourceEvent?.internal){let r=p7(t.transform);n?.(r),e?.(t.sourceEvent,r)}}))},[j,D,e,d,r]),(0,z.useEffect)(()=>{D&&D.on(`end`,e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;let{onViewportChangeEnd:t}=S.getState();if(C.current=!1,S.setState({paneDragging:!1}),r&&U0t(d,P.current??0)&&!w.current&&r(e.sourceEvent),w.current=!1,(n||t)&&H0t(E.current,e.transform)){let r=p7(e.transform);E.current=r,clearTimeout(x.current),x.current=setTimeout(()=>{t?.(r),n?.(e.sourceEvent,r)},o?150:0)}})},[D,o,d,n,r]),(0,z.useEffect)(()=>{D&&D.filter(e=>{let t=N||i,n=a&&e.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&e.button===1&&e.type===`mousedown`&&(m7(e,`react-flow__node`)||m7(e,`react-flow__edge`)))return!0;if(!d&&!t&&!o&&!l&&!a||j||!l&&e.type===`dblclick`||m7(e,y)&&e.type===`wheel`||m7(e,b)&&(e.type!==`wheel`||o&&e.type===`wheel`&&!N)||!a&&e.ctrlKey&&e.type===`wheel`||!t&&!o&&!n&&e.type===`wheel`||!d&&(e.type===`mousedown`||e.type===`touchstart`)||Array.isArray(d)&&!d.includes(e.button)&&e.type===`mousedown`)return!1;let r=Array.isArray(d)&&d.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||e.type===`wheel`)&&r})},[j,D,i,a,o,l,d,u,N]),z.createElement(`div`,{className:`react-flow__renderer`,ref:T,style:f7},v)},q0t=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function J0t(){let{userSelectionActive:e,userSelectionRect:t}=b5(q0t,h5);return e&&t?z.createElement(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Y0t(e,t){let n=t.parentNode||t.parentId,r=e.find(e=>e.id===n);if(r){let e=t.position.x+t.width-r.width,n=t.position.y+t.height-r.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,e>0&&(r.style.width+=e),n>0&&(r.style.height+=n),t.position.x<0){let e=Math.abs(t.position.x);r.position.x=r.position.x-e,r.style.width+=e,t.position.x=0}if(t.position.y<0){let e=Math.abs(t.position.y);r.position.y=r.position.y-e,r.style.height+=e,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function X0t(e,t){if(e.some(e=>e.type===`reset`))return e.filter(e=>e.type===`reset`).map(e=>e.item);let n=e.filter(e=>e.type===`add`).map(e=>e.item);return t.reduce((t,n)=>{let r=e.filter(e=>e.id===n.id);if(r.length===0)return t.push(n),t;let i={...n};for(let e of r)if(e)switch(e.type){case`select`:i.selected=e.selected;break;case`position`:e.position!==void 0&&(i.position=e.position),e.positionAbsolute!==void 0&&(i.positionAbsolute=e.positionAbsolute),e.dragging!==void 0&&(i.dragging=e.dragging),i.expandParent&&Y0t(t,i);break;case`dimensions`:e.dimensions!==void 0&&(i.width=e.dimensions.width,i.height=e.dimensions.height),e.updateStyle!==void 0&&(i.style={...i.style||{},...e.dimensions}),typeof e.resizing==`boolean`&&(i.resizing=e.resizing),i.expandParent&&Y0t(t,i);break;case`remove`:return t}return t.push(i),t},n)}function Z0t(e,t){return X0t(e,t)}function Q0t(e,t){return X0t(e,t)}var h7=(e,t)=>({id:e,type:`select`,selected:t});function g7(e,t){return e.reduce((e,n)=>{let r=t.includes(n.id);return!n.selected&&r?(n.selected=!0,e.push(h7(n.id,!0))):n.selected&&!r&&(n.selected=!1,e.push(h7(n.id,!1))),e},[])}var _7=(e,t)=>n=>{n.target===t.current&&e?.(n)},$0t=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),e2t=(0,z.memo)(({isSelecting:e,selectionMode:t=I5.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:o,onPaneScroll:s,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:d})=>{let f=(0,z.useRef)(null),p=x5(),m=(0,z.useRef)(0),h=(0,z.useRef)(0),g=(0,z.useRef)(),{userSelectionActive:_,elementsSelectable:v,dragging:y}=b5($0t,h5),b=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,h.current=0},x=e=>{a?.(e),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},S=e=>{if(Array.isArray(n)&&n?.includes(2)){e.preventDefault();return}o?.(e)},C=s?e=>s(e):void 0,w=t=>{let{resetSelectedElements:n,domNode:i}=p.getState();if(g.current=i?.getBoundingClientRect(),!v||!e||t.button!==0||t.target!==f.current||!g.current)return;let{x:a,y:o}=A5(t,g.current);n(),p.setState({userSelectionRect:{width:0,height:0,startX:a,startY:o,x:a,y:o}}),r?.(t)},T=n=>{let{userSelectionRect:r,nodeInternals:i,edges:a,transform:o,onNodesChange:s,onEdgesChange:c,nodeOrigin:l,getNodes:u}=p.getState();if(!e||!g.current||!r)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});let d=A5(n,g.current),f=r.startX??0,_=r.startY??0,v={...r,x:d.x<f?d.x:f,y:d.y<_?d.y:_,width:Math.abs(d.x-f),height:Math.abs(d.y-_)},y=u(),b=J1t(i,v,o,t===I5.Partial,!0,l),x=Y1t(b,a).map(e=>e.id),S=b.map(e=>e.id);if(m.current!==S.length){m.current=S.length;let e=g7(y,S);e.length&&s?.(e)}if(h.current!==x.length){h.current=x.length;let e=g7(a,x);e.length&&c?.(e)}p.setState({userSelectionRect:v})},E=e=>{if(e.button!==0)return;let{userSelectionRect:t}=p.getState();!_&&t&&e.target===f.current&&x?.(e),p.setState({nodesSelectionActive:m.current>0}),b(),i?.(e)},D=e=>{_&&(p.setState({nodesSelectionActive:m.current>0}),i?.(e)),b()},O=v&&(e||_);return z.createElement(`div`,{className:m5([`react-flow__pane`,{dragging:y,selection:e}]),onClick:O?void 0:_7(x,f),onContextMenu:_7(S,f),onWheel:_7(C,f),onMouseEnter:O?void 0:c,onMouseDown:O?w:void 0,onMouseMove:O?T:l,onMouseUp:O?E:void 0,onMouseLeave:O?D:u,ref:f,style:f7},d,z.createElement(J0t,null))});e2t.displayName=`Pane`;function t2t(e,t){let n=e.parentNode||e.parentId;if(!n)return!1;let r=t.get(n);return r?r.selected?!0:t2t(r,t):!1}function n2t(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function r2t(e,t,n,r){return Array.from(e.values()).filter(n=>(n.selected||n.id===r)&&(!n.parentNode||n.parentId||!t2t(n,e))&&(n.draggable||t&&n.draggable===void 0)).map(e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-(e.positionAbsolute?.x??0),y:n.y-(e.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}))}function i2t(e,t){return!t||t===`parent`?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function a2t(e,t,n,r,i=[0,0],a){let o=i2t(e,e.extent||r),s=o,c=e.parentNode||e.parentId;if(e.extent===`parent`&&!e.expandParent)if(c&&e.width&&e.height){let t=n.get(c),{x:r,y:a}=X5(t,i).positionAbsolute;s=t&&D5(r)&&D5(a)&&D5(t.width)&&D5(t.height)?[[r+e.width*i[0],a+e.height*i[1]],[r+t.width-e.width+e.width*i[0],a+t.height-e.height+e.height*i[1]]]:s}else a?.(`005`,y5.error005()),s=o;else if(e.extent&&c&&e.extent!==`parent`){let{x:t,y:r}=X5(n.get(c),i).positionAbsolute;s=[[e.extent[0][0]+t,e.extent[0][1]+r],[e.extent[1][0]+t,e.extent[1][1]+r]]}let l={x:0,y:0};c&&(l=X5(n.get(c),i).positionAbsolute);let u=s&&s!==`parent`?w5(t,s):t;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function v7({nodeId:e,dragItems:t,nodeInternals:n}){let r=t.map(e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute}));return[e?r.find(t=>t.id===e):r[0],r]}var o2t=(e,t,n,r)=>{let i=t.querySelectorAll(e);if(!i||!i.length)return null;let a=Array.from(i),o=t.getBoundingClientRect(),s={x:o.width*r[0],y:o.height*r[1]};return a.map(e=>{let t=e.getBoundingClientRect();return{id:e.getAttribute(`data-handleid`),position:e.getAttribute(`data-handlepos`),x:(t.left-o.left-s.x)/n,y:(t.top-o.top-s.y)/n,...S5(e)}})};function y7(e,t,n){return n===void 0?n:r=>{let i=t().nodeInternals.get(e);i&&n(r,{...i})}}function b7({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeInternals:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,y5.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function s2t(){let e=x5();return(0,z.useCallback)(({sourceEvent:t})=>{let{transform:n,snapGrid:r,snapToGrid:i}=e.getState(),a=t.touches?t.touches[0].clientX:t.clientX,o=t.touches?t.touches[0].clientY:t.clientY,s={x:(a-n[0])/n[2],y:(o-n[1])/n[2]};return{xSnapped:i?r[0]*Math.round(s.x/r[0]):s.x,ySnapped:i?r[1]*Math.round(s.y/r[1]):s.y,...s}},[])}function x7(e){return(t,n,r)=>e?.(t,r)}function c2t({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,selectNodesOnDrag:o}){let s=x5(),[c,l]=(0,z.useState)(!1),u=(0,z.useRef)([]),d=(0,z.useRef)({x:null,y:null}),f=(0,z.useRef)(0),p=(0,z.useRef)(null),m=(0,z.useRef)({x:0,y:0}),h=(0,z.useRef)(null),g=(0,z.useRef)(!1),_=(0,z.useRef)(!1),v=(0,z.useRef)(!1),y=s2t();return(0,z.useEffect)(()=>{if(e?.current){let c=L(e.current),b=({x:e,y:t})=>{let{nodeInternals:n,onNodeDrag:r,onSelectionDrag:a,updateNodePositions:o,nodeExtent:c,snapGrid:f,snapToGrid:p,nodeOrigin:m,onError:g}=s.getState();d.current={x:e,y:t};let _=!1,v={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&c&&(v=T5(Z5(u.current,m))),u.current=u.current.map(r=>{let i={x:e-r.distance.x,y:t-r.distance.y};p&&(i.x=f[0]*Math.round(i.x/f[0]),i.y=f[1]*Math.round(i.y/f[1]));let a=[[c[0][0],c[0][1]],[c[1][0],c[1][1]]];u.current.length>1&&c&&!r.extent&&(a[0][0]=r.positionAbsolute.x-v.x+c[0][0],a[1][0]=r.positionAbsolute.x+(r.width??0)-v.x2+c[1][0],a[0][1]=r.positionAbsolute.y-v.y+c[0][1],a[1][1]=r.positionAbsolute.y+(r.height??0)-v.y2+c[1][1]);let o=a2t(r,i,n,a,m,g);return _=_||r.position.x!==o.position.x||r.position.y!==o.position.y,r.position=o.position,r.positionAbsolute=o.positionAbsolute,r}),!_)return;o(u.current,!0,!0),l(!0);let y=i?r:x7(a);if(y&&h.current){let[e,t]=v7({nodeId:i,dragItems:u.current,nodeInternals:n});y(h.current,e,t)}},x=()=>{if(!p.current)return;let[e,t]=y1t(m.current,p.current);if(e!==0||t!==0){let{transform:n,panBy:r}=s.getState();d.current.x=(d.current.x??0)-e/n[2],d.current.y=(d.current.y??0)-t/n[2],r({x:e,y:t})&&b(d.current)}f.current=requestAnimationFrame(x)},S=t=>{let{nodeInternals:n,multiSelectionActive:r,nodesDraggable:c,unselectNodesAndEdges:l,onNodeDragStart:f,onSelectionDragStart:p}=s.getState();_.current=!0;let m=i?f:x7(p);(!o||!a)&&!r&&i&&(n.get(i)?.selected||l()),i&&a&&o&&b7({id:i,store:s,nodeRef:e});let h=y(t);if(d.current=h,u.current=r2t(n,c,h,i),m&&u.current){let[e,r]=v7({nodeId:i,dragItems:u.current,nodeInternals:n});m(t.sourceEvent,e,r)}};if(t)c.on(`.drag`,null);else{let t=d1t().on(`start`,e=>{let{domNode:t,nodeDragThreshold:n}=s.getState();n===0&&S(e),v.current=!1,d.current=y(e),p.current=t?.getBoundingClientRect()||null,m.current=A5(e.sourceEvent,p.current)}).on(`drag`,e=>{let t=y(e),{autoPanOnNodeDrag:n,nodeDragThreshold:r}=s.getState();if(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!g.current&&_.current&&n&&(g.current=!0,x()),!_.current){let n=t.xSnapped-(d?.current?.x??0),i=t.ySnapped-(d?.current?.y??0);Math.sqrt(n*n+i*i)>r&&S(e)}(d.current.x!==t.xSnapped||d.current.y!==t.ySnapped)&&u.current&&_.current&&(h.current=e.sourceEvent,m.current=A5(e.sourceEvent,p.current),b(t))}}).on(`end`,e=>{if(!(!_.current||v.current)&&(l(!1),g.current=!1,_.current=!1,cancelAnimationFrame(f.current),u.current)){let{updateNodePositions:t,nodeInternals:n,onNodeDragStop:r,onSelectionDragStop:a}=s.getState(),o=i?r:x7(a);if(t(u.current,!1,!1),o){let[t,r]=v7({nodeId:i,dragItems:u.current,nodeInternals:n});o(e.sourceEvent,t,r)}}}).filter(t=>{let i=t.target;return!t.button&&(!n||!n2t(i,`.${n}`,e))&&(!r||n2t(i,r,e))});return c.call(t),()=>{c.on(`.drag`,null)}}}},[e,t,n,r,a,s,i,o,y]),c}function l2t(){let e=x5();return(0,z.useCallback)(t=>{let{nodeInternals:n,nodeExtent:r,updateNodePositions:i,getNodes:a,snapToGrid:o,snapGrid:s,onError:c,nodesDraggable:l}=e.getState(),u=a().filter(e=>e.selected&&(e.draggable||l&&e.draggable===void 0)),d=o?s[0]:5,f=o?s[1]:5,p=t.isShiftPressed?4:1,m=t.x*d*p,h=t.y*f*p;i(u.map(e=>{if(e.positionAbsolute){let t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+h};o&&(t.x=s[0]*Math.round(t.x/s[0]),t.y=s[1]*Math.round(t.y/s[1]));let{positionAbsolute:i,position:a}=a2t(e,t,n,r,void 0,c);e.position=a,e.positionAbsolute=i}return e}),!0,!1)},[])}var S7={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},C7=e=>{let t=({id:t,type:n,data:r,xPos:i,yPos:a,xPosOrigin:o,yPosOrigin:s,selected:c,onClick:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:f,onContextMenu:p,onDoubleClick:m,style:h,className:g,isDraggable:_,isSelectable:v,isConnectable:y,isFocusable:b,selectNodesOnDrag:x,sourcePosition:S,targetPosition:C,hidden:w,resizeObserver:T,dragHandle:E,zIndex:D,isParent:O,noDragClassName:k,noPanClassName:A,initialized:j,disableKeyboardA11y:M,ariaLabel:N,rfId:P,hasHandleBounds:F})=>{let I=x5(),L=(0,z.useRef)(null),ee=(0,z.useRef)(null),R=(0,z.useRef)(S),te=(0,z.useRef)(C),ne=(0,z.useRef)(n),re=v||_||l||u||d||f,ie=l2t(),ae=y7(t,I.getState,u),oe=y7(t,I.getState,d),se=y7(t,I.getState,f),ce=y7(t,I.getState,p),le=y7(t,I.getState,m),ue=e=>{let{nodeDragThreshold:n}=I.getState();if(v&&(!x||!_||n>0)&&b7({id:t,store:I,nodeRef:L}),l){let n=I.getState().nodeInternals.get(t);n&&l(e,{...n})}},de=e=>{k5(e)||M||(T1t.includes(e.key)&&v?b7({id:t,store:I,unselect:e.key===`Escape`,nodeRef:L}):_&&c&&Object.prototype.hasOwnProperty.call(S7,e.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${e.key.replace(`Arrow`,``).toLowerCase()}. New position, x: ${~~i}, y: ${~~a}`}),ie({x:S7[e.key].x,y:S7[e.key].y,isShiftPressed:e.shiftKey})))};(0,z.useEffect)(()=>()=>{ee.current&&=(T?.unobserve(ee.current),null)},[]),(0,z.useEffect)(()=>{if(L.current&&!w){let e=L.current;(!j||!F||ee.current!==e)&&(ee.current&&T?.unobserve(ee.current),T?.observe(e),ee.current=e)}},[w,j,F]),(0,z.useEffect)(()=>{let e=ne.current!==n,r=R.current!==S,i=te.current!==C;L.current&&(e||r||i)&&(e&&(ne.current=n),r&&(R.current=S),i&&(te.current=C),I.getState().updateNodeDimensions([{id:t,nodeElement:L.current,forceUpdate:!0}]))},[t,n,S,C]);let fe=c2t({nodeRef:L,disabled:w||!_,noDragClassName:k,handleSelector:E,nodeId:t,isSelectable:v,selectNodesOnDrag:x});return w?null:z.createElement(`div`,{className:m5([`react-flow__node`,`react-flow__node-${n}`,{[A]:_},g,{selected:c,selectable:v,parent:O,dragging:fe}]),ref:L,style:{zIndex:D,transform:`translate(${o}px,${s}px)`,pointerEvents:re?`all`:`none`,visibility:j?`visible`:`hidden`,...h},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:ae,onMouseMove:oe,onMouseLeave:se,onContextMenu:ce,onClick:ue,onDoubleClick:le,onKeyDown:b?de:void 0,tabIndex:b?0:void 0,role:b?`button`:void 0,"aria-describedby":M?void 0:`${C0t}-${P}`,"aria-label":N},z.createElement(V1t,{value:t},z.createElement(e,{id:t,data:r,type:n,xPos:i,yPos:a,selected:c,isConnectable:y,sourcePosition:S,targetPosition:C,dragging:fe,dragHandle:E,zIndex:D})))};return t.displayName=`NodeWrapper`,(0,z.memo)(t)},u2t=e=>({...Z5(e.getNodes().filter(e=>e.selected),e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive});function d2t({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=x5(),{width:i,height:a,x:o,y:s,transformString:c,userSelectionActive:l}=b5(u2t,h5),u=l2t(),d=(0,z.useRef)(null);if((0,z.useEffect)(()=>{n||d.current?.focus({preventScroll:!0})},[n]),c2t({nodeRef:d}),l||!i||!a)return null;let f=e?t=>{e(t,r.getState().getNodes().filter(e=>e.selected))}:void 0;return z.createElement(`div`,{className:m5([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:c}},z.createElement(`div`,{ref:d,className:`react-flow__nodesselection-rect`,onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(S7,e.key)&&u({x:S7[e.key].x,y:S7[e.key].y,isShiftPressed:e.shiftKey})},style:{width:i,height:a,top:s,left:o}}))}var f2t=(0,z.memo)(d2t),p2t=e=>e.nodesSelectionActive,m2t=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,deleteKeyCode:s,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:f,selectionMode:p,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:_,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:x,panOnScroll:S,panOnScrollSpeed:C,panOnScrollMode:w,zoomOnDoubleClick:T,panOnDrag:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,onSelectionContextMenu:M,noWheelClassName:N,noPanClassName:P,disableKeyboardA11y:F})=>{let I=b5(p2t),L=s7(d),ee=s7(_),R=ee||E,te=ee||S,ne=L||f&&R!==!0;return B0t({deleteKeyCode:s,multiSelectionKeyCode:g}),z.createElement(K0t,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:x,panOnScroll:te,panOnScrollSpeed:C,panOnScrollMode:w,zoomOnDoubleClick:T,panOnDrag:!L&&R,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,zoomActivationKeyCode:v,preventScrolling:j,noWheelClassName:N,noPanClassName:P},z.createElement(e2t,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:R,isSelecting:!!ne,selectionMode:p},e,I&&z.createElement(f2t,{onSelectionContextMenu:M,noPanClassName:P,disableKeyboardA11y:F})))};m2t.displayName=`FlowRenderer`;var h2t=(0,z.memo)(m2t);function g2t(e){return b5((0,z.useCallback)(t=>e?J1t(t.nodeInternals,{x:0,y:0,width:t.width,height:t.height},t.transform,!0):t.getNodes(),[e]))}function _2t(e){let t={input:C7(e.input||d0t),default:C7(e.default||n7),output:C7(e.output||p0t),group:C7(e.group||r7)},n=Object.keys(e).filter(e=>![`input`,`default`,`output`,`group`].includes(e)).reduce((t,n)=>(t[n]=C7(e[n]||n7),t),{});return{...t,...n}}var v2t=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r||i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},y2t=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),b2t=e=>{let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:a,onError:o}=b5(y2t,h5),s=g2t(e.onlyRenderVisibleElements),c=(0,z.useRef)(),l=(0,z.useMemo)(()=>{if(typeof ResizeObserver>`u`)return null;let e=new ResizeObserver(e=>{a(e.map(e=>({id:e.target.getAttribute(`data-id`),nodeElement:e.target,forceUpdate:!0})))});return c.current=e,e},[]);return(0,z.useEffect)(()=>()=>{c?.current?.disconnect()},[]),z.createElement(`div`,{className:`react-flow__nodes`,style:f7},s.map(a=>{let s=a.type||`default`;e.nodeTypes[s]||(o?.(`003`,y5.error003(s)),s=`default`);let c=e.nodeTypes[s]||e.nodeTypes.default,u=!!(a.draggable||t&&a.draggable===void 0),d=!!(a.selectable||i&&a.selectable===void 0),f=!!(a.connectable||n&&a.connectable===void 0),p=!!(a.focusable||r&&a.focusable===void 0),m=e.nodeExtent?w5(a.positionAbsolute,e.nodeExtent):a.positionAbsolute,h=m?.x??0,g=m?.y??0,_=v2t({x:h,y:g,width:a.width??0,height:a.height??0,origin:e.nodeOrigin});return z.createElement(c,{key:a.id,id:a.id,className:a.className,style:a.style,type:s,data:a.data,sourcePosition:a.sourcePosition||z5.Bottom,targetPosition:a.targetPosition||z5.Top,hidden:a.hidden,xPos:h,yPos:g,xPosOrigin:_.x,yPosOrigin:_.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!a.selected,isDraggable:u,isSelectable:d,isConnectable:f,isFocusable:p,resizeObserver:l,dragHandle:a.dragHandle,zIndex:a[O5]?.z??0,isParent:!!a[O5]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!a.width&&!!a.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:a.ariaLabel,hasHandleBounds:!!a[O5]?.handleBounds})}))};b2t.displayName=`NodeRenderer`;var x2t=(0,z.memo)(b2t),S2t=(e,t,n)=>n===z5.Left?e-t:n===z5.Right?e+t:e,C2t=(e,t,n)=>n===z5.Top?e-t:n===z5.Bottom?e+t:e,w2t=`react-flow__edgeupdater`,T2t=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s})=>z.createElement(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:m5([w2t,`${w2t}-${s}`]),cx:S2t(t,r,e),cy:C2t(n,r,e),r,stroke:`transparent`,fill:`transparent`}),E2t=()=>!0,w7=e=>{let t=({id:t,className:n,type:r,data:i,onClick:a,onEdgeDoubleClick:o,selected:s,animated:c,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:h,source:g,target:_,sourceX:v,sourceY:y,targetX:b,targetY:x,sourcePosition:S,targetPosition:C,elementsSelectable:w,hidden:T,sourceHandleId:E,targetHandleId:D,onContextMenu:O,onMouseEnter:k,onMouseMove:A,onMouseLeave:j,reconnectRadius:M,onReconnect:N,onReconnectStart:P,onReconnectEnd:F,markerEnd:I,markerStart:L,rfId:ee,ariaLabel:R,isFocusable:te,isReconnectable:ne,pathOptions:re,interactionWidth:ie,disableKeyboardA11y:ae})=>{let oe=(0,z.useRef)(null),[se,ce]=(0,z.useState)(!1),[le,ue]=(0,z.useState)(!1),de=x5(),fe=(0,z.useMemo)(()=>`url('#${J5(L,ee)}')`,[L,ee]),pe=(0,z.useMemo)(()=>`url('#${J5(I,ee)}')`,[I,ee]);if(T)return null;let me=e=>{let{edges:n,addSelectedEdges:r,unselectNodesAndEdges:i,multiSelectionActive:o}=de.getState(),s=n.find(e=>e.id===t);s&&(w&&(de.setState({nodesSelectionActive:!1}),s.selected&&o?(i({nodes:[],edges:[s]}),oe.current?.blur()):r([t])),a&&a(e,s))},he=N5(t,de.getState,o),ge=N5(t,de.getState,O),_e=N5(t,de.getState,k),ve=N5(t,de.getState,A),ye=N5(t,de.getState,j),be=(e,n)=>{if(e.button!==0)return;let{edges:r,isValidConnection:i}=de.getState(),a=n?_:g,o=(n?D:E)||null,s=n?`target`:`source`,c=i||E2t,l=n,u=r.find(e=>e.id===t);ue(!0),P?.(e,u,s),i0t({event:e,handleId:o,nodeId:a,onConnect:e=>N?.(u,e),isTarget:l,getState:de.getState,setState:de.setState,isValidConnection:c,edgeUpdaterType:s,onReconnectEnd:e=>{ue(!1),F?.(e,u,s)}})},xe=e=>be(e,!0),Se=e=>be(e,!1),Ce=()=>ce(!0),we=()=>ce(!1),Te=!w&&!a;return z.createElement(`g`,{className:m5([`react-flow__edge`,`react-flow__edge-${r}`,n,{selected:s,animated:c,inactive:Te,updating:se}]),onClick:me,onDoubleClick:he,onContextMenu:ge,onMouseEnter:_e,onMouseMove:ve,onMouseLeave:ye,onKeyDown:te?e=>{if(!ae&&T1t.includes(e.key)&&w){let{unselectNodesAndEdges:n,addSelectedEdges:r,edges:i}=de.getState();e.key===`Escape`?(oe.current?.blur(),n({edges:[i.find(e=>e.id===t)]})):r([t])}}:void 0,tabIndex:te?0:void 0,role:te?`button`:`img`,"data-testid":`rf__edge-${t}`,"aria-label":R===null?void 0:R||`Edge from ${g} to ${_}`,"aria-describedby":te?`${w0t}-${ee}`:void 0,ref:oe},!le&&z.createElement(e,{id:t,source:g,target:_,selected:s,animated:c,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,data:i,style:h,sourceX:v,sourceY:y,targetX:b,targetY:x,sourcePosition:S,targetPosition:C,sourceHandleId:E,targetHandleId:D,markerStart:fe,markerEnd:pe,pathOptions:re,interactionWidth:ie}),ne&&z.createElement(z.Fragment,null,(ne===`source`||ne===!0)&&z.createElement(T2t,{position:S,centerX:v,centerY:y,radius:M,onMouseDown:xe,onMouseEnter:Ce,onMouseOut:we,type:`source`}),(ne===`target`||ne===!0)&&z.createElement(T2t,{position:C,centerX:b,centerY:x,radius:M,onMouseDown:Se,onMouseEnter:Ce,onMouseOut:we,type:`target`})))};return t.displayName=`EdgeWrapper`,(0,z.memo)(t)};function D2t(e){let t={default:w7(e.default||K5),straight:w7(e.bezier||W5),step:w7(e.step||U5),smoothstep:w7(e.step||H5),simplebezier:w7(e.simplebezier||B5)},n=Object.keys(e).filter(e=>![`default`,`bezier`].includes(e)).reduce((t,n)=>(t[n]=w7(e[n]||K5),t),{});return{...t,...n}}function O2t(e,t,n=null){let r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,a=n?.width||t.width,o=n?.height||t.height;switch(e){case z5.Top:return{x:r+a/2,y:i};case z5.Right:return{x:r+a,y:i+o/2};case z5.Bottom:return{x:r+a/2,y:i+o};case z5.Left:return{x:r,y:i+o/2}}}function k2t(e,t){return e?e.length===1||!t?e[0]:t&&e.find(e=>e.id===t)||null:null}var A2t=(e,t,n,r,i,a)=>{let o=O2t(n,e,t),s=O2t(a,r,i);return{sourceX:o.x,sourceY:o.y,targetX:s.x,targetY:s.y}};function j2t({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:a,width:o,height:s,transform:c}){let l={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+a)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);let u=T5({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:o/c[2],height:s/c[2]}),d=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),f=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(d*f)>0}function M2t(e){let t=e?.[O5]?.handleBounds||null,n=t&&e?.width&&e?.height&&e?.positionAbsolute?.x!==void 0&&e?.positionAbsolute?.y!==void 0;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}var N2t=[{level:0,isMaxLevel:!0,edges:[]}];function P2t(e,t,n=!1){let r=-1,i=e.reduce((e,i)=>{let a=D5(i.zIndex),o=a?i.zIndex:0;if(n){let e=t.get(i.target),n=t.get(i.source),r=i.selected||e?.selected||n?.selected,s=Math.max(n?.[O5]?.z||0,e?.[O5]?.z||0,1e3);o=(a?i.zIndex:0)+(r?s:0)}return e[o]?e[o].push(i):e[o]=[i],r=o>r?o:r,e},{}),a=Object.entries(i).map(([e,t])=>{let n=+e;return{edges:t,level:n,isMaxLevel:n===r}});return a.length===0?N2t:a}function F2t(e,t,n){return P2t(b5((0,z.useCallback)(n=>e?n.edges.filter(e=>{let r=t.get(e.source),i=t.get(e.target);return r?.width&&r?.height&&i?.width&&i?.height&&j2t({sourcePos:r.positionAbsolute||{x:0,y:0},targetPos:i.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:i.width,targetHeight:i.height,width:n.width,height:n.height,transform:n.transform})}):n.edges,[e,t])),t,n)}var I2t=({color:e=`none`,strokeWidth:t=1})=>z.createElement(`polyline`,{style:{stroke:e,strokeWidth:t},strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,points:`-5,-4 0,0 -5,4`}),L2t=({color:e=`none`,strokeWidth:t=1})=>z.createElement(`polyline`,{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),R2t={[R5.Arrow]:I2t,[R5.ArrowClosed]:L2t};function z2t(e){let t=x5();return(0,z.useMemo)(()=>Object.prototype.hasOwnProperty.call(R2t,e)?R2t[e]:(t.getState().onError?.(`009`,y5.error009(e)),null),[e])}var B2t=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=z2t(t);return c?z.createElement(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`},z.createElement(c,{color:n,strokeWidth:o})):null},V2t=({defaultColor:e,rfId:t})=>n=>{let r=[];return n.edges.reduce((n,i)=>([i.markerStart,i.markerEnd].forEach(i=>{if(i&&typeof i==`object`){let a=J5(i,t);r.includes(a)||(n.push({id:a,color:i.color||e,...i}),r.push(a))}}),n),[]).sort((e,t)=>e.id.localeCompare(t.id))},H2t=({defaultColor:e,rfId:t})=>{let n=b5((0,z.useCallback)(V2t({defaultColor:e,rfId:t}),[e,t]),(e,t)=>!(e.length!==t.length||e.some((e,n)=>e.id!==t[n].id)));return z.createElement(`defs`,null,n.map(e=>z.createElement(B2t,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient})))};H2t.displayName=`MarkerDefinitions`;var U2t=(0,z.memo)(H2t),W2t=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),G2t=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,reconnectRadius:h,children:g,disableKeyboardA11y:_})=>{let{edgesFocusable:v,edgesUpdatable:y,elementsSelectable:b,width:x,height:S,connectionMode:C,nodeInternals:w,onError:T}=b5(W2t,h5),E=F2t(t,w,n);return x?z.createElement(z.Fragment,null,E.map(({level:t,edges:n,isMaxLevel:g})=>z.createElement(`svg`,{key:t,style:{zIndex:t},width:x,height:S,className:`react-flow__edges react-flow__container`},g&&z.createElement(U2t,{defaultColor:e,rfId:r}),z.createElement(`g`,null,n.map(e=>{let[t,n,g]=M2t(w.get(e.source)),[x,S,E]=M2t(w.get(e.target));if(!g||!E)return null;let D=e.type||`default`;i[D]||(T?.(`011`,y5.error011(D)),D=`default`);let O=i[D]||i.default,k=C===P5.Strict?S.target:(S.target??[]).concat(S.source??[]),A=k2t(n.source,e.sourceHandle),j=k2t(k,e.targetHandle),M=A?.position||z5.Bottom,N=j?.position||z5.Top,P=!!(e.focusable||v&&e.focusable===void 0),F=e.reconnectable||e.updatable,I=f!==void 0&&(F||y&&F===void 0);if(!A||!j)return T?.(`008`,y5.error008(A,e)),null;let{sourceX:L,sourceY:ee,targetX:R,targetY:te}=A2t(t,A,M,x,j,N);return z.createElement(O,{key:e.id,id:e.id,className:m5([e.className,a]),type:D,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:L,sourceY:ee,targetX:R,targetY:te,sourcePosition:M,targetPosition:N,elementsSelectable:b,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,reconnectRadius:h,rfId:r,ariaLabel:e.ariaLabel,isFocusable:P,isReconnectable:I,pathOptions:`pathOptions`in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:_})})))),g):null};G2t.displayName=`EdgeRenderer`;var K2t=(0,z.memo)(G2t),q2t=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function J2t({children:e}){let t=b5(q2t);return z.createElement(`div`,{className:`react-flow__viewport react-flow__container`,style:{transform:t}},e)}function Y2t(e){let t=d7(),n=(0,z.useRef)(!1);(0,z.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var X2t={[z5.Left]:z5.Right,[z5.Right]:z5.Left,[z5.Top]:z5.Bottom,[z5.Bottom]:z5.Top},Z2t=({nodeId:e,handleType:t,style:n,type:r=L5.Bezier,CustomComponent:i,connectionStatus:a})=>{let{fromNode:o,handleId:s,toX:c,toY:l,connectionMode:u}=b5((0,z.useCallback)(t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode}),[e]),h5),d=o?.[O5]?.handleBounds,f=d?.[t];if(u===P5.Loose&&(f||=d?.[t===`source`?`target`:`source`]),!o||!f)return null;let p=s?f.find(e=>e.id===s):f[0],m=p?p.x+p.width/2:(o.width??0)/2,h=p?p.y+p.height/2:o.height??0,g=(o.positionAbsolute?.x??0)+m,_=(o.positionAbsolute?.y??0)+h,v=p?.position,y=v?X2t[v]:null;if(!v||!y)return null;if(i)return z.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:o,fromHandle:p,fromX:g,fromY:_,toX:c,toY:l,fromPosition:v,toPosition:y,connectionStatus:a});let b=``,x={sourceX:g,sourceY:_,sourcePosition:v,targetX:c,targetY:l,targetPosition:y};return r===L5.Bezier?[b]=B1t(x):r===L5.Step?[b]=V5({...x,borderRadius:0}):r===L5.SmoothStep?[b]=V5(x):r===L5.SimpleBezier?[b]=M1t(x):b=`M${g},${_} ${c},${l}`,z.createElement(`path`,{d:b,fill:`none`,className:`react-flow__connection-path`,style:n})};Z2t.displayName=`ConnectionLine`;var Q2t=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function $2t({containerStyle:e,style:t,type:n,component:r}){let{nodeId:i,handleType:a,nodesConnectable:o,width:s,height:c,connectionStatus:l}=b5(Q2t,h5);return i&&a&&s&&o?z.createElement(`svg`,{style:e,width:s,height:c,className:`react-flow__edges react-flow__connectionline react-flow__container`},z.createElement(`g`,{className:m5([`react-flow__connection`,l])},z.createElement(Z2t,{nodeId:i,handleType:a,style:t,type:n,CustomComponent:r,connectionStatus:l}))):null}function e4t(e,t){return(0,z.useRef)(null),x5(),(0,z.useMemo)(()=>t(e),[e])}var t4t=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:a,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:m,onSelectionStart:h,onSelectionEnd:g,connectionLineType:_,connectionLineStyle:v,connectionLineComponent:y,connectionLineContainerStyle:b,selectionKeyCode:x,selectionOnDrag:S,selectionMode:C,multiSelectionKeyCode:w,panActivationKeyCode:T,zoomActivationKeyCode:E,deleteKeyCode:D,onlyRenderVisibleElements:O,elementsSelectable:k,selectNodesOnDrag:A,defaultViewport:j,translateExtent:M,minZoom:N,maxZoom:P,preventScrolling:F,defaultMarkerColor:I,zoomOnScroll:L,zoomOnPinch:ee,panOnScroll:R,panOnScrollSpeed:te,panOnScrollMode:ne,zoomOnDoubleClick:re,panOnDrag:ie,onPaneClick:ae,onPaneMouseEnter:oe,onPaneMouseMove:se,onPaneMouseLeave:ce,onPaneScroll:le,onPaneContextMenu:ue,onEdgeContextMenu:de,onEdgeMouseEnter:fe,onEdgeMouseMove:pe,onEdgeMouseLeave:me,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,reconnectRadius:ve,noDragClassName:ye,noWheelClassName:be,noPanClassName:xe,elevateEdgesOnSelect:Se,disableKeyboardA11y:Ce,nodeOrigin:we,nodeExtent:Te,rfId:Ee})=>{let De=e4t(e,_2t),Oe=e4t(t,D2t);return Y2t(a),z.createElement(h2t,{onPaneClick:ae,onPaneMouseEnter:oe,onPaneMouseMove:se,onPaneMouseLeave:ce,onPaneContextMenu:ue,onPaneScroll:le,deleteKeyCode:D,selectionKeyCode:x,selectionOnDrag:S,selectionMode:C,onSelectionStart:h,onSelectionEnd:g,multiSelectionKeyCode:w,panActivationKeyCode:T,zoomActivationKeyCode:E,elementsSelectable:k,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:L,zoomOnPinch:ee,zoomOnDoubleClick:re,panOnScroll:R,panOnScrollSpeed:te,panOnScrollMode:ne,panOnDrag:ie,defaultViewport:j,translateExtent:M,minZoom:N,maxZoom:P,onSelectionContextMenu:m,preventScrolling:F,noDragClassName:ye,noWheelClassName:be,noPanClassName:xe,disableKeyboardA11y:Ce},z.createElement(J2t,null,z.createElement(K2t,{edgeTypes:Oe,onEdgeClick:s,onEdgeDoubleClick:l,onlyRenderVisibleElements:O,onEdgeContextMenu:de,onEdgeMouseEnter:fe,onEdgeMouseMove:pe,onEdgeMouseLeave:me,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,reconnectRadius:ve,defaultMarkerColor:I,noPanClassName:xe,elevateEdgesOnSelect:!!Se,disableKeyboardA11y:Ce,rfId:Ee},z.createElement($2t,{style:v,type:_,component:y,containerStyle:b})),z.createElement(`div`,{className:`react-flow__edgelabel-renderer`}),z.createElement(x2t,{nodeTypes:De,onNodeClick:o,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,selectNodesOnDrag:A,onlyRenderVisibleElements:O,noPanClassName:xe,noDragClassName:ye,disableKeyboardA11y:Ce,nodeOrigin:we,nodeExtent:Te,rfId:Ee})))};t4t.displayName=`GraphView`;var n4t=(0,z.memo)(t4t),T7=[[-1/0,-1/0],[1/0,1/0]],E7={rfId:`1`,width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:T7,nodeExtent:T7,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:`source`,connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:P5.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:E1t,isValidConnection:void 0},r4t=()=>o1t((e,t)=>({...E7,setNodes:n=>{let{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:a}=t();e({nodeInternals:c7(n,r,i,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{let{defaultEdgeOptions:r={}}=t();e({edges:n.map(e=>({...r,...e}))})},setDefaultNodesAndEdges:(n,r)=>{let i=n!==void 0,a=r!==void 0;e({nodeInternals:i?c7(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map,edges:a?r:[],hasDefaultNodes:i,hasDefaultEdges:a})},updateNodeDimensions:n=>{let{onNodesChange:r,nodeInternals:i,fitViewOnInit:a,fitViewOnInitDone:o,fitViewOnInitOptions:s,domNode:c,nodeOrigin:l}=t(),u=c?.querySelector(`.react-flow__viewport`);if(!u)return;let d=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=n.reduce((e,t)=>{let n=i.get(t.id);if(n?.hidden)i.set(n.id,{...n,[O5]:{...n[O5],handleBounds:void 0}});else if(n){let r=S5(t.nodeElement);r.width&&r.height&&(n.width!==r.width||n.height!==r.height||t.forceUpdate)&&(i.set(n.id,{...n,[O5]:{...n[O5],handleBounds:{source:o2t(`.source`,t.nodeElement,f,l),target:o2t(`.target`,t.nodeElement,f,l)}},...r}),e.push({id:n.id,type:`dimensions`,dimensions:r}))}return e},[]);M0t(i,l);let m=o||a&&!o&&N0t(t,{initial:!0,...s});e({nodeInternals:new Map(i),fitViewOnInitDone:m}),p?.length>0&&r?.(p)},updateNodePositions:(e,n=!0,r=!1)=>{let{triggerNodeChanges:i}=t();i(e.map(e=>{let t={id:e.id,type:`position`,dragging:r};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t}))},triggerNodeChanges:n=>{let{onNodesChange:r,nodeInternals:i,hasDefaultNodes:a,nodeOrigin:o,getNodes:s,elevateNodesOnSelect:c}=t();n?.length&&(a&&e({nodeInternals:c7(Z0t(n,s()),i,o,c)}),r?.(n))},addSelectedNodes:n=>{let{multiSelectionActive:r,edges:i,getNodes:a}=t(),o,s=null;r?o=n.map(e=>h7(e,!0)):(o=g7(a(),n),s=g7(i,[])),l7({changedNodes:o,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{let{multiSelectionActive:r,edges:i,getNodes:a}=t(),o,s=null;r?o=n.map(e=>h7(e,!0)):(o=g7(i,n),s=g7(a(),[])),l7({changedNodes:s,changedEdges:o,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{let{edges:i,getNodes:a}=t(),o=n||a(),s=r||i;l7({changedNodes:o.map(e=>(e.selected=!1,h7(e.id,!1))),changedEdges:s.map(e=>h7(e.id,!1)),get:t,set:e})},setMinZoom:n=>{let{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{let{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{let{edges:n,getNodes:r}=t();l7({changedNodes:r().filter(e=>e.selected).map(e=>h7(e.id,!1)),changedEdges:n.filter(e=>e.selected).map(e=>h7(e.id,!1)),get:t,set:e})},setNodeExtent:n=>{let{nodeInternals:r}=t();r.forEach(e=>{e.positionAbsolute=w5(e.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:e=>{let{transform:n,width:r,height:i,d3Zoom:a,d3Selection:o,translateExtent:s}=t();if(!a||!o||!e.x&&!e.y)return!1;let c=M.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),l=[[0,0],[r,i]],u=a?.constrain()(c,l,s);return a.transform(o,u),n[0]!==u.x||n[1]!==u.y||n[2]!==u.k},cancelConnection:()=>e({connectionNodeId:E7.connectionNodeId,connectionHandleId:E7.connectionHandleId,connectionHandleType:E7.connectionHandleType,connectionStatus:E7.connectionStatus,connectionStartHandle:E7.connectionStartHandle,connectionEndHandle:E7.connectionEndHandle}),reset:()=>e({...E7})}),Object.is),i4t=({children:e})=>{let t=(0,z.useRef)(null);return t.current||=r4t(),z.createElement(f1t,{value:t.current},e)};i4t.displayName=`ReactFlowProvider`;var a4t=({children:e})=>(0,z.useContext)(v5)?z.createElement(z.Fragment,null,e):z.createElement(i4t,null,e);a4t.displayName=`ReactFlowWrapper`;var o4t={input:d0t,default:n7,output:p0t,group:r7},s4t={default:K5,straight:W5,step:U5,smoothstep:H5,simplebezier:B5},c4t=[0,0],l4t=[15,15],u4t={x:0,y:0,zoom:1},d4t={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0},f4t=(0,z.forwardRef)(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a=o4t,edgeTypes:o=s4t,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onSelectionChange:O,onSelectionDragStart:k,onSelectionDrag:A,onSelectionDragStop:j,onSelectionContextMenu:M,onSelectionStart:N,onSelectionEnd:P,connectionMode:F=P5.Strict,connectionLineType:I=L5.Bezier,connectionLineStyle:L,connectionLineComponent:ee,connectionLineContainerStyle:R,deleteKeyCode:te=`Backspace`,selectionKeyCode:ne=`Shift`,selectionOnDrag:re=!1,selectionMode:ie=I5.Full,panActivationKeyCode:ae=`Space`,multiSelectionKeyCode:oe=j5()?`Meta`:`Control`,zoomActivationKeyCode:se=j5()?`Meta`:`Control`,snapToGrid:ce=!1,snapGrid:le=l4t,onlyRenderVisibleElements:ue=!1,selectNodesOnDrag:de=!0,nodesDraggable:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=c4t,edgesFocusable:ge,edgesUpdatable:_e,elementsSelectable:ve,defaultViewport:ye=u4t,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=T7,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=F5.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,children:ze,onEdgeContextMenu:Be,onEdgeDoubleClick:Ve,onEdgeMouseEnter:He,onEdgeMouseMove:Ue,onEdgeMouseLeave:We,onEdgeUpdate:Ge,onEdgeUpdateStart:Ke,onEdgeUpdateEnd:qe,onReconnect:Je,onReconnectStart:Ye,onReconnectEnd:Xe,reconnectRadius:Ze=10,edgeUpdaterRadius:Qe=10,onNodesChange:$e,onEdgesChange:et,noDragClassName:tt=`nodrag`,noWheelClassName:nt=`nowheel`,noPanClassName:rt=`nopan`,fitView:it=!1,fitViewOptions:at,connectOnClick:ot=!0,attributionPosition:st,proOptions:ct,defaultEdgeOptions:lt,elevateNodesOnSelect:ut=!0,elevateEdgesOnSelect:dt=!1,disableKeyboardA11y:ft=!1,autoPanOnConnect:pt=!0,autoPanOnNodeDrag:mt=!0,connectionRadius:ht=20,isValidConnection:gt,onError:_t,style:B,id:vt,nodeDragThreshold:yt,...bt},xt)=>{let St=vt||`1`;return z.createElement(`div`,{...bt,style:{...B,...d4t},ref:xt,className:m5([`react-flow`,i]),"data-testid":`rf__wrapper`,id:vt},z.createElement(a4t,null,z.createElement(n4t,{onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:I,connectionLineStyle:L,connectionLineComponent:ee,connectionLineContainerStyle:R,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:ie,deleteKeyCode:te,multiSelectionKeyCode:oe,panActivationKeyCode:ae,zoomActivationKeyCode:se,onlyRenderVisibleElements:ue,selectNodesOnDrag:de,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,onSelectionContextMenu:M,onSelectionStart:N,onSelectionEnd:P,onEdgeContextMenu:Be,onEdgeDoubleClick:Ve,onEdgeMouseEnter:He,onEdgeMouseMove:Ue,onEdgeMouseLeave:We,onReconnect:Je??Ge,onReconnectStart:Ye??Ke,onReconnectEnd:Xe??qe,reconnectRadius:Ze??Qe,defaultMarkerColor:Te,noDragClassName:tt,noWheelClassName:nt,noPanClassName:rt,elevateEdgesOnSelect:dt,rfId:St,disableKeyboardA11y:ft,nodeOrigin:he,nodeExtent:we}),z.createElement(b0t,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesUpdatable:_e,elementsSelectable:ve,elevateNodesOnSelect:ut,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:$e,onEdgesChange:et,snapToGrid:ce,snapGrid:le,connectionMode:F,translateExtent:Se,connectOnClick:ot,defaultEdgeOptions:lt,fitView:it,fitViewOptions:at,onNodesDelete:E,onEdgesDelete:D,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:A,onSelectionDragStart:k,onSelectionDragStop:j,noPanClassName:rt,nodeOrigin:he,rfId:St,autoPanOnConnect:pt,autoPanOnNodeDrag:mt,onError:_t,connectionRadius:ht,isValidConnection:gt,nodeDragThreshold:yt}),z.createElement(v0t,{onSelectionChange:O}),ze,z.createElement(g1t,{proOptions:ct,position:st}),z.createElement(O0t,{rfId:St,disableKeyboardA11y:ft})))});f4t.displayName=`ReactFlow`;function p4t(e){return t=>{let[n,r]=(0,z.useState)(t);return[n,r,(0,z.useCallback)(t=>r(n=>e(t,n)),[])]}}var m4t=p4t(Z0t),h4t=p4t(Q0t);function g4t(){return z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`},z.createElement(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`}))}function _4t(){return z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`},z.createElement(`path`,{d:`M0 0h32v4.2H0z`}))}function v4t(){return z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`},z.createElement(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`}))}function y4t(){return z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`},z.createElement(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`}))}function b4t(){return z.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`},z.createElement(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`}))}var D7=({children:e,className:t,...n})=>z.createElement(`button`,{type:`button`,className:m5([`react-flow__controls-button`,t]),...n},e);D7.displayName=`ControlButton`;var x4t=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),S4t=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`})=>{let f=x5(),[p,m]=(0,z.useState)(!1),{isInteractive:h,minZoomReached:g,maxZoomReached:_}=b5(x4t,h5),{zoomIn:v,zoomOut:y,fitView:b}=d7();return(0,z.useEffect)(()=>{m(!0)},[]),p?z.createElement(h1t,{className:m5([`react-flow__controls`,l]),position:d,style:e,"data-testid":`rf__controls`},t&&z.createElement(z.Fragment,null,z.createElement(D7,{onClick:()=>{v(),a?.()},className:`react-flow__controls-zoomin`,title:`zoom in`,"aria-label":`zoom in`,disabled:_},z.createElement(g4t,null)),z.createElement(D7,{onClick:()=>{y(),o?.()},className:`react-flow__controls-zoomout`,title:`zoom out`,"aria-label":`zoom out`,disabled:g},z.createElement(_4t,null))),n&&z.createElement(D7,{className:`react-flow__controls-fitview`,onClick:()=>{b(i),s?.()},title:`fit view`,"aria-label":`fit view`},z.createElement(v4t,null)),r&&z.createElement(D7,{className:`react-flow__controls-interactive`,onClick:()=>{f.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:`toggle interactivity`,"aria-label":`toggle interactivity`},h?z.createElement(b4t,null):z.createElement(y4t,null)),u):null};S4t.displayName=`Controls`;var C4t=(0,z.memo)(S4t),O7;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(O7||={});function w4t({color:e,dimensions:t,lineWidth:n}){return z.createElement(`path`,{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function T4t({color:e,radius:t}){return z.createElement(`circle`,{cx:t,cy:t,r:t,fill:e})}var E4t={[O7.Dots]:`#91919a`,[O7.Lines]:`#eee`,[O7.Cross]:`#e2e2e2`},D4t={[O7.Dots]:1,[O7.Lines]:1,[O7.Cross]:6},O4t=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function k4t({id:e,variant:t=O7.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=2,color:o,style:s,className:c}){let l=(0,z.useRef)(null),{transform:u,patternId:d}=b5(O4t,h5),f=o||E4t[t],p=r||D4t[t],m=t===O7.Dots,h=t===O7.Cross,g=Array.isArray(n)?n:[n,n],_=[g[0]*u[2]||1,g[1]*u[2]||1],v=p*u[2],y=h?[v,v]:_,b=m?[v/a,v/a]:[y[0]/a,y[1]/a];return z.createElement(`svg`,{className:m5([`react-flow__background`,c]),style:{...s,position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},ref:l,"data-testid":`rf__background`},z.createElement(`pattern`,{id:d+e,x:u[0]%_[0],y:u[1]%_[1],width:_[0],height:_[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${b[0]},-${b[1]})`},m?z.createElement(T4t,{color:f,radius:v/a}):z.createElement(w4t,{dimensions:y,color:f,lineWidth:i})),z.createElement(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${d+e})`}))}k4t.displayName=`Background`;var A4t=(0,z.memo)(k4t),j4t=Object.defineProperty,M4t=(e,t,n)=>t in e?j4t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N4t=(e,t)=>{for(var n in t)j4t(e,n,{get:t[n],enumerable:!0})},P4t=(e,t,n)=>M4t(e,typeof t==`symbol`?t:t+``,n),F4t={};N4t(F4t,{Graph:()=>k7,alg:()=>M7,json:()=>H4t,version:()=>V4t});var I4t=Object.defineProperty,L4t=(e,t)=>{for(var n in t)I4t(e,n,{get:t[n],enumerable:!0})},k7=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e?e.multigraph:!1,this._isCompound=`compound`in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e==`function`?this._defaultNodeLabelFn=e:this._defaultNodeLabelFn=()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let t of this.successors(e))n.add(t);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return typeof e==`function`?this._defaultEdgeLabelFn=e:this._defaultEdgeLabelFn=()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=A7(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=B4t(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,R4t(this._preds[a],i),R4t(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?j7(this._isDirected,e):A7(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r==`object`?r:{label:r}}hasEdge(e,t,n){return(arguments.length===1?j7(this._isDirected,e):A7(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?j7(this._isDirected,e):A7(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],z4t(this._preds[t],e),z4t(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function R4t(e,t){e[t]?e[t]++:e[t]=1}function z4t(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function A7(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function B4t(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function j7(e,t){return A7(e,t.v,t.w,t.name)}var V4t=`4.0.1`,H4t={};L4t(H4t,{read:()=>K4t,write:()=>U4t});function U4t(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:W4t(e),edges:G4t(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function W4t(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function G4t(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function K4t(e){let t=new k7(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var M7={};L4t(M7,{CycleException:()=>P7,bellmanFord:()=>J4t,components:()=>X4t,dijkstra:()=>N7,dijkstraAll:()=>e3t,findCycles:()=>n3t,floydWarshall:()=>i3t,isAcyclic:()=>s3t,postorder:()=>d3t,preorder:()=>f3t,prim:()=>p3t,shortestPaths:()=>m3t,tarjan:()=>t3t,topsort:()=>o3t});var q4t=()=>1;function J4t(e,t,n,r){return Y4t(e,String(t),n||q4t,r||function(t){return e.outEdges(t)})}function Y4t(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=n(e);i[e.v].distance+t<i[e.w].distance&&(i[e.w]={distance:i[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w;c({v:n,w:n===t.v?t.w:t.v})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function X4t(e){let t={},n=[],r;function i(n){n in t||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var Z4t=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},Q4t=()=>1;function N7(e,t,n,r){return $4t(e,String(t),n||Q4t,r||function(t){return e.outEdges(t)})}function $4t(e,t,n,r){let i={},a=new Z4t,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t],c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0&&(o=a.removeMin(),s=i[o],s.distance!==1/0);)r(o).forEach(c);return i}function e3t(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=N7(e,i,t,n),r},{})}function t3t(e){let t=0,n=[],r={},i=[];function a(o){let s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){e in r?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){let e=[],t;do t=n.pop(),r[t].onStack=!1,e.push(t);while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function n3t(e){return t3t(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var r3t=()=>1;function i3t(e,t,n){return a3t(e,t||r3t,n||function(t){return e.outEdges(t)})}function a3t(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){let t=r[e];i.forEach(function(n){let a=r[n];i.forEach(function(n){let r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}var P7=class extends Error{constructor(...e){super(...e)}};function o3t(e){let t={},n={},r=[];function i(a){if(a in n)throw new P7;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new P7;return r}function s3t(e){try{o3t(e)}catch(e){if(e instanceof P7)return!1;throw e}return!0}function c3t(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=l3t(e,t,n===`post`,o,a,r,i)}),i}function l3t(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=l3t(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function u3t(e,t,n){return c3t(e,t,n,function(e,t){return e.push(t),e},[])}function d3t(e,t){return u3t(e,t,`post`)}function f3t(e,t){return u3t(e,t,`pre`)}function p3t(e,t){let n=new k7,r={},i=new Z4t,a;function o(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(o!==void 0){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){i.add(e,1/0),n.setNode(e)}),i.decrease(e.nodes()[0],0);let s=!1;for(;i.size()>0;){if(a=i.removeMin(),a in r)n.setEdge(a,r[a]);else{if(s)throw Error(`Input graph is not connected: `+e);s=!0}e.nodeEdges(a).forEach(o)}return n}function m3t(e,t,n,r){return h3t(e,t,n,r??(t=>e.outEdges(t)??[]))}function h3t(e,t,n,r){if(n===void 0)return N7(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=r(a[o]);for(let e=0;e<s.length;e++){let t=s[e],r=t.v===a[o]?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return J4t(e,t,n,r)}return N7(e,t,n,r)}function F7(e,t,n,r){let i=r;for(;e.hasNode(i);)i=R7(r);return n.dummy=t,e.setNode(i,n),i}function g3t(e){let t=new k7().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function _3t(e){let t=new k7({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function v3t(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function I7(e){let t=z7(w3t(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function y3t(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=L7(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function b3t(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=L7(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function x3t(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),F7(e,`border`,i,t)}function S3t(e,t=C3t){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var C3t=65535;function L7(e,t){return t.length>C3t?e(...S3t(t).map(t=>e(...t))):e(...t)}function w3t(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return L7(Math.max,t)}function T3t(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function E3t(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function D3t(e,t){return t()}var O3t=0;function R7(e){return e+(``+ ++O3t)}function z7(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function B7(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function V7(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function k3t(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var H7=`\0`,A3t=`3.0.0`,j3t=class{constructor(){P4t(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return M3t(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&M3t(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,N3t)),n=n._prev;return`[`+e.join(`, `)+`]`}};function M3t(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function N3t(e,t){if(e!==`_next`&&e!==`_prev`)return t}var P3t=j3t,F3t=()=>1;function I3t(e,t){if(e.nodeCount()<=1)return[];let n=R3t(e,t||F3t);return L3t(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function L3t(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)U7(e,t,n,o);for(;o=i.dequeue();)U7(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(U7(e,t,n,o,!0)||[]);break}}}return r}function U7(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,W7(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,W7(t,n,o)}),e.removeNode(r.v),o}function R3t(e,t){let n=new k7,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=z3t(i+r+3).map(()=>new P3t),o=r+1;return n.nodes().forEach(e=>{W7(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function W7(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function z3t(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function B3t(e){(e.graph().acyclicer===`greedy`?I3t(e,t(e)):V3t(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,R7(`rev`))});function t(e){return t=>e.edge(t).weight}}function V3t(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function H3t(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function U3t(e){e.graph().dummyChains=[],e.edges().forEach(t=>W3t(e,t))}function W3t(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=F7(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function G3t(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function G7(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=L7(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function K7(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var K3t=q3t;function q3t(e){let t=new k7({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;J3t(t,e)<i&&(a=Y3t(t,e),a);)o=t.hasNode(a.v)?K7(e,a):-K7(e,a),X3t(t,e,o);return t}function J3t(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!K7(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function Y3t(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=K7(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function X3t(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Z3t,postorder:Q3t}=M7,$3t=q7;q7.initLowLimValues=Y7,q7.initCutValues=J7,q7.calcCutValue=t6t,q7.leaveEdge=r6t,q7.enterEdge=i6t,q7.exchangeEdges=a6t;function q7(e){e=g3t(e),G7(e);let t=K3t(e);Y7(t),J7(t,e);let n,r;for(;n=r6t(t);)r=i6t(t,e,n),a6t(t,e,n,r)}function J7(e,t){let n=Q3t(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>e6t(e,t,n))}function e6t(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=t6t(e,t,n)}function t6t(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,s6t(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Y7(e,t){arguments.length<2&&(t=e.nodes()[0]),n6t(e,{},1,t)}function n6t(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=n6t(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function r6t(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function i6t(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===c6t(e,e.node(t.v),s)&&c!==c6t(e,e.node(t.w),s)).reduce((e,n)=>K7(t,n)<K7(t,e)?n:e)}function a6t(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Y7(e),J7(e,t),o6t(e,t)}function o6t(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Z3t(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function s6t(e,t,n){return e.hasEdge(t,n)}function c6t(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var l6t=u6t;function u6t(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:p6t(e);break;case`tight-tree`:f6t(e);break;case`longest-path`:d6t(e);break;case`none`:break;default:p6t(e)}}var d6t=G7;function f6t(e){G7(e),K3t(e)}function p6t(e){$3t(e)}var m6t=h6t;function h6t(e){let t=_6t(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=g6t(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function g6t(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function _6t(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(H7).forEach(r),t}function v6t(e){let t=F7(e,`root`,{},`_root`),n=b6t(e),r=Object.values(n),i=L7(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=x6t(e)+1;e.children(H7).forEach(r=>y6t(e,t,a,o,i,n,r)),e.graph().nodeRankFactor=a}function y6t(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=x3t(e,`_bt`),l=x3t(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{y6t(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function b6t(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(H7).forEach(e=>n(e,1)),t}function x6t(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function S6t(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var C6t=w6t;function w6t(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)T6t(e,`borderLeft`,`_bl`,n,i,t),T6t(e,`borderRight`,`_br`,n,i,t)}}e.children(H7).forEach(t)}function T6t(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=F7(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function E6t(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&O6t(e)}function D6t(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&A6t(e),(t===`lr`||t===`rl`)&&(j6t(e),O6t(e))}function O6t(e){e.nodes().forEach(t=>k6t(e.node(t))),e.edges().forEach(t=>k6t(e.edge(t)))}function k6t(e){let t=e.width;e.width=e.height,e.height=t}function A6t(e){e.nodes().forEach(t=>X7(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(X7),Object.hasOwn(r,`y`)&&X7(r)})}function X7(e){e.y=-e.y}function j6t(e){e.nodes().forEach(t=>Z7(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Z7),Object.hasOwn(r,`x`)&&Z7(r)})}function Z7(e){let t=e.x;e.x=e.y,e.y=t}function M6t(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),r=n.map(t=>e.node(t).rank),i=z7(L7(Math.max,r)+1).map(()=>[]);function a(n){if(t[n])return;t[n]=!0,i[e.node(n).rank].push(n);let r=e.successors(n);r&&r.forEach(a)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(a),i}function N6t(e,t){let n=0;for(let r=1;r<t.length;++r)n+=P6t(e,t[r-1],t[r]);return n}function P6t(e,t,n){let r=k3t(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function F6t(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function I6t(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),L6t(Object.values(n).filter(e=>!e.indegree))}function L6t(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&R6t(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>B7(e,[`vs`,`i`,`barycenter`,`weight`]))}function R6t(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function z6t(e,t){let n=T3t(e,e=>Object.hasOwn(e,`barycenter`)),r=n.lhs,i=n.rhs.sort((e,t)=>t.i-e.i),a=[],o=0,s=0,c=0;r.sort(V6t(!!t)),c=B6t(a,i,c),r.forEach(e=>{c+=e.vs.length,a.push(e.vs),o+=e.barycenter*e.weight,s+=e.weight,c=B6t(a,i,c)});let l={vs:a.flat(1)};return s&&(l.barycenter=o/s,l.weight=s),l}function B6t(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function V6t(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function H6t(e,t,n,r){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=i.filter(e=>e!==o&&e!==s));let l=F6t(e,i);l.forEach(t=>{if(e.children(t.v).length){let i=H6t(e,t.v,n,r);c[t.v]=i,Object.hasOwn(i,`barycenter`)&&W6t(t,i)}});let u=I6t(l,n);U6t(u,c);let d=z6t(u,r);if(o&&s){d.vs=[o,d.vs,s].flat(1);let t=e.predecessors(o);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(s),i=e.node(r[0]);Object.hasOwn(d,`barycenter`)||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+n.order+i.order)/(d.weight+2),d.weight+=2}}return d}function U6t(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function W6t(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function G6t(e,t,n,r){r||=e.nodes();let i=K6t(e),a=new k7({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function K6t(e){let t;for(;e.hasNode(t=R7(`_root`)););return t}function q6t(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function J6t(e,t={}){if(typeof t.customOrder==`function`){t.customOrder(e,J6t);return}let n=w3t(e),r=Y6t(e,z7(1,n+1),`inEdges`),i=Y6t(e,z7(n-1,-1,-1),`outEdges`),a=M6t(e);if(Z6t(e,a),t.disableOptimalOrderHeuristic)return;let o=1/0,s,c=t.constraints||[];for(let t=0,n=0;n<4;++t,++n){X6t(t%2?r:i,t%4>=2,c),a=I7(e);let l=N6t(e,a);l<o?(n=0,s=Object.assign({},a),o=l):l===o&&(s=structuredClone(a))}Z6t(e,s)}function Y6t(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return G6t(e,t,n,r.get(t)||[])})}function X6t(e,t,n){let r=new k7;e.forEach(function(e){n.forEach(e=>r.setEdge(e.left,e.right));let i=e.graph().root,a=H6t(e,i,r,t);a.vs.forEach((t,n)=>e.node(t).order=n),q6t(e,r,a.vs)})}function Z6t(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Q6t(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=e8t(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&t8t(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function $6t(e,t){let n={};function r(t,r,i,a,o){z7(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&t8t(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function e8t(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function t8t(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function n8t(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function r8t(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s&&s.length){let r=s.sort((e,t)=>{let n=o[e],r=o[t];return(n===void 0?0:n)-(r===void 0?0:r)}),c=(r.length-1)/2;for(let s=Math.floor(c),l=Math.ceil(c);s<=l;++s){let c=r[s];if(c===void 0)continue;let l=o[c];if(l!==void 0&&a[e]===e&&t<l&&!n8t(n,e,c)){let n=i[c];n!==void 0&&(a[c]=e,a[e]=i[e]=n,t=l)}}}})}),{root:i,align:a}}function i8t(e,t,n,r,i=!1){let a={},o=a8t(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function a8t(e,t,n,r){let i=new k7,a=e.graph(),o=u8t(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function o8t(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=d8t(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function s8t(e,t){let n=Object.values(t),r=L7(Math.min,n),i=L7(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-L7(Math.min,c);a!==`l`&&(l=i-L7(Math.max,c)),l&&(e[o]=V7(s,e=>e+l))})})}function c8t(e,t=void 0){let n=e.ul;return n?V7(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function l8t(e){let t=I7(e),n=Object.assign(Q6t(e,t),$6t(e,t)),r={},i;return[`u`,`d`].forEach(a=>{i=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(i=i.map(e=>Object.values(e).reverse()));let o=r8t(e,i,n,t=>(a===`u`?e.predecessors(t):e.successors(t))||[]),s=i8t(e,i,o.root,o.align,t===`r`);t===`r`&&(s=V7(s,e=>-e)),r[a+t]=s})}),s8t(r,o8t(e,r)),c8t(r,e.graph().align)}function u8t(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),c}}function d8t(e,t){return e.node(t).width}function f8t(e){e=_3t(e),p8t(e),Object.entries(l8t(e)).forEach(([t,n])=>e.node(t).x=n)}function p8t(e){let t=I7(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);i===`top`?r.y=a+r.height/2:i===`bottom`?r.y=a+n-r.height/2:r.y=a+n/2}),a+=n+r})}function m8t(e,t={}){let n=t.debugTiming?E3t:D3t;return n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>T8t(e));return n(` runLayout`,()=>h8t(r,n,t)),n(` updateInputGraph`,()=>g8t(e,r)),r})}function h8t(e,t,n){t(` makeSpaceForEdgeLabels`,()=>E8t(e)),t(` removeSelfEdges`,()=>F8t(e)),t(` acyclic`,()=>B3t(e)),t(` nestingGraph.run`,()=>v6t(e)),t(` rank`,()=>l6t(_3t(e))),t(` injectEdgeLabelProxies`,()=>D8t(e)),t(` removeEmptyRanks`,()=>b3t(e)),t(` nestingGraph.cleanup`,()=>S6t(e)),t(` normalizeRanks`,()=>y3t(e)),t(` assignRankMinMax`,()=>O8t(e)),t(` removeEdgeLabelProxies`,()=>k8t(e)),t(` normalize.run`,()=>U3t(e)),t(` parentDummyChains`,()=>m6t(e)),t(` addBorderSegments`,()=>C6t(e)),t(` order`,()=>J6t(e,n)),t(` insertSelfEdges`,()=>I8t(e)),t(` adjustCoordinateSystem`,()=>E6t(e)),t(` position`,()=>f8t(e)),t(` positionSelfEdges`,()=>L8t(e)),t(` removeBorderNodes`,()=>P8t(e)),t(` normalize.undo`,()=>G3t(e)),t(` fixupEdgeLabelCoords`,()=>M8t(e)),t(` undoCoordinateSystem`,()=>D6t(e)),t(` translateGraph`,()=>A8t(e)),t(` assignNodeIntersects`,()=>j8t(e)),t(` reversePoints`,()=>N8t(e)),t(` acyclic.undo`,()=>H3t(e))}function g8t(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var _8t=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],v8t={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},y8t=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],b8t=[`width`,`height`,`rank`],x8t={width:0,height:0},S8t=[`minlen`,`weight`,`width`,`height`,`labeloffset`],C8t={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},w8t=[`labelpos`];function T8t(e){let t=new k7({multigraph:!0,compound:!0}),n=$7(e.graph());return t.setGraph(Object.assign({},v8t,Q7(n,_8t),B7(n,y8t))),e.nodes().forEach(n=>{let r=Q7($7(e.node(n)),b8t);Object.keys(x8t).forEach(e=>{r[e]===void 0&&(r[e]=x8t[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=$7(e.edge(n));t.setEdge(n,Object.assign({},C8t,Q7(r,S8t),B7(r,w8t)))}),t}function E8t(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function D8t(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);F7(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function O8t(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function k8t(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function A8t(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function j8t(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(v3t(r,a)),n.points.push(v3t(i,o))})}function M8t(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function N8t(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function P8t(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function F8t(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function I8t(e){I7(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{F7(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function L8t(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`selfedge`){let r=n,i=e.node(r.e.v),a=i.x+i.width/2,o=i.y,s=n.x-a,c=i.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*s/3,y:o-c},{x:a+5*s/6,y:o-c},{x:a+s,y:o},{x:a+5*s/6,y:o+c},{x:a+2*s/3,y:o+c}],r.label.x=n.x,r.label.y=n.y}})}function Q7(e,t){return V7(B7(e,t),Number)}function $7(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function R8t(e){let t=I7(e),n=new k7({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var z8t={graphlib:F4t,version:A3t,layout:m8t,debug:R8t,util:{time:E3t,notime:D3t}},B8t={XS:{w:150,h:90},S:{w:168,h:90},M:{w:196,h:94},L:{w:216,h:94},XL:{w:236,h:98}};function V8t(e){return B8t[e]??B8t.M}var H8t={critical:`crit`,high:`high`,medium:`med`,low:`low`};function U8t(e){return(e||`M`).toLowerCase()}function W8t(e,t){if(e.length>1&&t.length<e.length*.75){let t=Math.min(5,Math.ceil(Math.sqrt(e.length*1.4)));return e.map((e,n)=>{let r=n%t,i=Math.floor(n/t);return{...e,position:{x:r*265,y:i*120}}})}let n=new z8t.graphlib.Graph;n.setGraph({rankdir:`TB`,nodesep:50,ranksep:80}),n.setDefaultEdgeLabel(()=>({}));for(let t of e){let e=V8t(t.data.node.size);n.setNode(t.id,{width:e.w,height:e.h})}for(let e of t)n.setEdge(e.source,e.target);return z8t.layout(n),e.map(e=>{let{x:t,y:r}=n.node(e.id),i=V8t(e.data.node.size);return{...e,position:{x:t-i.w/2,y:r-i.h/2}}})}function G8t({data:e}){let{node:t,onSelect:n}=e,r=[`node`,U8t(t.size),H8t[t.importance]??`med`];t.inPipeline&&r.push(`pipe`),t.condition===`needs-refinement`&&r.push(`cond-refine`),t.condition===`stale`&&r.push(`cond-stale`),t.gate===`blocked`&&r.push(`gate-blocked`),t.isEpic&&r.push(`epic`);let i=t.gate===`ready`&&!t.inPipeline;return i&&r.push(`gate-promoted`),(0,B.jsxs)(`div`,{className:r.join(` `),onClick:()=>n(t),children:[(0,B.jsx)(t7,{type:`target`,position:z5.Top,className:`edge-handle`}),(0,B.jsxs)(`div`,{className:`row1`,children:[(0,B.jsxs)(`span`,{className:`rank`,children:[`#`,t.rank]}),(0,B.jsx)(`span`,{className:`iid`,children:t.issueId}),(0,B.jsx)(`span`,{className:`size-tag`,children:t.size})]}),(0,B.jsx)(`div`,{className:`title`,children:t.title||t.why}),(0,B.jsxs)(`div`,{className:`chips`,children:[i&&(0,B.jsx)(`span`,{className:`chip promoted`,children:`📌 PROMOTED`}),t.gate===`blocked`&&(0,B.jsx)(`span`,{className:`chip held`,children:`⛔ VETOED`}),t.inPipeline&&(0,B.jsxs)(`span`,{className:`chip verb work`,children:[(0,B.jsx)(`span`,{className:`pulsedot`}),`in pipeline`]}),t.condition===`needs-refinement`&&(0,B.jsx)(`span`,{className:`chip refine`,children:`⚠ REFINE`}),t.condition===`stale`&&(0,B.jsx)(`span`,{className:`chip stale`,children:`⊘ STALE`}),t.isEpic&&(0,B.jsx)(`span`,{className:`chip epic`,children:`EPIC`}),t.ready&&(0,B.jsx)(`span`,{className:`chip ready`,children:`✓ READY`}),t.hasPrd&&(0,B.jsx)(`span`,{className:`chip prd`,children:`PRD`}),(0,B.jsx)(`span`,{className:`score`,children:t.score})]}),(0,B.jsx)(t7,{type:`source`,position:z5.Bottom,className:`edge-handle`})]})}var K8t={issueNode:G8t};function q8t(e,t,n){let r=e.map(e=>({id:e.issueId,type:`issueNode`,position:{x:0,y:0},data:{node:e,onSelect:n}})),i=t.map((e,t)=>{let n=e.type===`informs`,r=e.type===`contains`,i=r?`color-mix(in srgb, var(--primary) 58%, transparent)`:n?`color-mix(in srgb, var(--info) 60%, transparent)`:`color-mix(in srgb, var(--muted-foreground) 55%, transparent)`;return{id:`e-${t}-${e.from}-${e.to}`,source:e.from,target:e.to,type:`default`,markerEnd:{type:R5.ArrowClosed,width:14,height:14,color:i},style:{stroke:i,strokeWidth:r?1.2:1.5,strokeDasharray:n?`5 4`:r?`2 5`:void 0}}});return{nodes:W8t(r,i),edges:i}}var J8t={critical:`var(--destructive)`,high:`var(--warning)`,medium:`var(--color-neutral-400)`,low:`color-mix(in srgb, var(--muted-foreground) 55%, transparent)`};function Y8t(e){let t=[];return e.inPipeline&&t.push({label:`in pipeline`,kind:`pipeline`}),e.condition===`needs-refinement`&&t.push({label:`⚠ needs refinement`,kind:`refine`}),e.condition===`stale`&&t.push({label:`⊘ likely stale · candidate to close`,kind:`stale`}),e.ready&&t.push({label:`✓ READY`,kind:`ready`}),e.hasPrd&&t.push({label:`PRD`,kind:`prd`}),t.length===0&&t.push({label:`not yet planned`,kind:`none`}),t}function X8t(e){let t={fontSize:10,fontWeight:500,letterSpacing:`0.04em`,padding:`1px 6px`,borderRadius:`var(--radius-sm, 4px)`,border:`1px solid`,lineHeight:`15px`,whiteSpace:`nowrap`};switch(e){case`ready`:return{...t,color:`var(--success-foreground)`,borderColor:`color-mix(in srgb, var(--success) 32%, transparent)`,background:`color-mix(in srgb, var(--success) 10%, transparent)`};case`refine`:return{...t,color:`var(--warning-foreground)`,borderColor:`color-mix(in srgb, var(--warning) 32%, transparent)`,background:`color-mix(in srgb, var(--warning) 10%, transparent)`};case`pipeline`:return{...t,color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 32%, transparent)`,background:`color-mix(in srgb, var(--info) 10%, transparent)`};default:return{...t,color:`var(--muted-foreground)`,borderColor:`var(--border)`,background:`var(--accent)`}}}var Z8t={display:`grid`,gridTemplateColumns:`auto 1fr`,gap:`7px 14px`,fontSize:12},e9={color:`var(--muted-foreground)`},t9={color:`var(--foreground)`,textAlign:`right`},n9={flex:1,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:4,fontSize:10,textTransform:`uppercase`,letterSpacing:`0.06em`,fontWeight:500,padding:`5px 6px`,borderRadius:6,cursor:`pointer`,border:`1px solid var(--border)`,background:`var(--accent)`,color:`var(--foreground)`};function Q8t({node:e,onClose:t,onIssueAction:n}){let r=Y8t(e),i=Math.max(0,Math.min(100,e.score));return(0,B.jsxs)(`div`,{style:{width:320,flexShrink:0,background:`var(--card)`,borderLeft:`1px solid var(--border)`,padding:`16px`,overflowY:`auto`,display:`flex`,flexDirection:`column`,color:`var(--foreground)`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,marginBottom:8},children:[(0,B.jsxs)(`span`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.12em`,color:`var(--muted-foreground)`},children:[`Why rank #`,e.rank]}),(0,B.jsx)(`button`,{onClick:t,style:{background:`none`,border:`none`,color:`var(--muted-foreground)`,cursor:`pointer`,fontSize:14,lineHeight:1,padding:`0 2px`},children:`×`})]}),(0,B.jsx)(`div`,{style:{fontFamily:`var(--font-mono)`,fontSize:12,color:`var(--muted-foreground)`},children:e.issueId}),e.title&&(0,B.jsx)(`div`,{style:{fontSize:14,fontWeight:500,lineHeight:1.35,margin:`2px 0 10px`},children:e.title}),n&&(0,B.jsxs)(`div`,{style:{display:`flex`,gap:6,margin:`${e.title?0:10}px 0 14px`},children:[(0,B.jsx)(`button`,{style:n9,onClick:()=>n(e.issueId,`panel`),title:`Open the full issue cockpit (deep-linked tab)`,children:`⛶ Panel`}),(0,B.jsx)(`button`,{style:n9,onClick:()=>n(e.issueId,`modal`),title:`Open the issue overlay (quick peek, stays on this page)`,children:`▢ Overlay`}),(0,B.jsx)(`button`,{style:n9,onClick:()=>n(e.issueId,`browser`),title:`Open the issue on GitHub in a new tab`,children:`↗ GitHub`})]}),(0,B.jsxs)(`div`,{style:{...Z8t,marginTop:e.title?0:12},children:[(0,B.jsx)(`span`,{style:e9,children:`Importance`}),(0,B.jsx)(`span`,{style:t9,children:(0,B.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,B.jsx)(`span`,{style:{width:10,height:10,borderRadius:3,background:J8t[e.importance]??`var(--muted-foreground)`}}),e.importance]})}),(0,B.jsx)(`span`,{style:e9,children:`Impact score`}),(0,B.jsxs)(`span`,{style:{...t9,fontFamily:`var(--font-mono)`},children:[e.score,` / 100`]})]}),(0,B.jsx)(`div`,{style:{height:5,borderRadius:3,background:`var(--accent)`,overflow:`hidden`,marginTop:3,marginBottom:12},children:(0,B.jsx)(`div`,{style:{height:`100%`,width:`${i}%`,borderRadius:3,background:`linear-gradient(90deg, var(--warning), var(--destructive))`}})}),(0,B.jsxs)(`div`,{style:{...Z8t,marginBottom:14},children:[(0,B.jsx)(`span`,{style:e9,children:`Est. size`}),(0,B.jsxs)(`span`,{style:t9,children:[e.size,` effort`]}),(0,B.jsx)(`span`,{style:e9,children:`Depends on`}),(0,B.jsx)(`span`,{style:{...t9,fontFamily:`var(--font-mono)`},children:e.dependsOn.length?e.dependsOn.join(`, `):`— none`})]}),r.length>0&&(0,B.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginBottom:14},children:r.map((e,t)=>(0,B.jsx)(`span`,{style:X8t(e.kind),children:e.label},t))}),(0,B.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:(0,B.jsx)(rQ,{issueId:e.issueId,onOpenIssueBrowser:n?e=>n(e,`browser`):void 0})}),(0,B.jsxs)(`div`,{style:{fontSize:12,lineHeight:1.6,color:`color-mix(in srgb, var(--foreground) 88%, transparent)`,borderTop:`1px solid var(--border)`,paddingTop:13},children:[(0,B.jsx)(`div`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.1em`,color:`var(--muted-foreground)`,marginBottom:6},children:`AI rationale · from sequence.md`}),e.why,e.rationale&&(0,B.jsx)(`div`,{style:{marginTop:8},children:e.rationale})]})]})}function $8t({data:e,className:t,selectedNodeId:n,onSelectNode:r,onIssueAction:i}){let[a,o]=(0,z.useState)(null),s=r!==void 0,c=s?e.nodes.find(e=>e.issueId===n)??null:a,l=(0,z.useCallback)(e=>{s?r?.(n===e.issueId?null:e):o(t=>t?.issueId===e.issueId?null:e)},[s,r,n]),u=(0,z.useCallback)(()=>{s?r?.(null):o(null)},[s,r]),{nodes:d,edges:f}=(0,z.useMemo)(()=>q8t(e.nodes,e.edges,l),[e.nodes,e.edges,l]),[p,m,h]=m4t(d),[g,_,v]=h4t(f);return(0,z.useEffect)(()=>{let{nodes:t,edges:n}=q8t(e.nodes,e.edges,l);if(m(t),_(n),!s&&a){let t=e.nodes.find(e=>e.issueId===a.issueId);t&&o(t)}},[e.nodes,e.edges,l,m,_,a,s]),(0,B.jsxs)(`div`,{className:`bk-dag-root${t?` ${t}`:``}`,style:{width:`100%`,height:`100%`,display:`flex`,background:`var(--background)`},children:[(0,B.jsx)(`style`,{children:`
|
|
738
738
|
/* ── Backlog DAG nodes — ported from docs/design/mockups/backlog-sequencer-scaled-opus.html, scoped to .bk-dag-root ── */
|
|
739
739
|
.bk-dag-root .react-flow { background: transparent; }
|
|
@@ -854,7 +854,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
854
854
|
.bkf-bi { font-family:ui-monospace,monospace; font-size:9.5px; color:var(--muted-foreground); }
|
|
855
855
|
.bkf-bt { font-size:10px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
856
856
|
.bkf-makespan { margin-top:10px; font-size:11px; color:var(--muted-foreground); }
|
|
857
|
-
`,c5t={ok:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,"needs-refinement":`border border-[color-mix(in_srgb,var(--warning)_36%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,stale:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)] line-through opacity-70`},l5t={ready:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,blocked:`border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,auto:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`},u5t={critical:`bg-[var(--destructive)]`,high:`bg-[var(--warning)]`,medium:`bg-[var(--color-neutral-400)]`,low:`bg-[var(--muted-foreground)] opacity-60`},i9=`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border text-xs transition-colors`,a9=`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-fg-muted)] hover:border-[color-mix(in_srgb,var(--color-fg)_25%,transparent)]`,o9={info:`border-[color-mix(in_srgb,var(--info)_45%,transparent)] bg-[color-mix(in_srgb,var(--info)_12%,transparent)] text-[var(--info-foreground)]`,success:`border-[color-mix(in_srgb,var(--success)_45%,transparent)] bg-[color-mix(in_srgb,var(--success)_12%,transparent)] text-[var(--success-foreground)]`,warning:`border-[color-mix(in_srgb,var(--warning)_45%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,danger:`border-[color-mix(in_srgb,var(--destructive)_45%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_12%,transparent)] text-[var(--destructive-foreground)]`,neutral:`border-[color-mix(in_srgb,var(--color-fg)_28%,transparent)] bg-[color-mix(in_srgb,var(--color-fg)_8%,transparent)] text-[var(--color-fg)]`},s9={info:`bg-[var(--info-foreground)]`,success:`bg-[var(--success-foreground)]`,warning:`bg-[var(--warning-foreground)]`,danger:`bg-[var(--destructive-foreground)]`,neutral:`bg-[var(--color-fg-muted)]`},d5t={now:`Now`,next:`Next`,later:`Later`,someday:`Someday`},f5t={now:`border border-[color-mix(in_srgb,var(--destructive)_34%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,next:`border border-[color-mix(in_srgb,var(--warning)_34%,transparent)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] text-[var(--warning-foreground)]`,later:`border border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[color-mix(in_srgb,var(--info)_9%,transparent)] text-[var(--info-foreground)]`,someday:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`};function c9(e,t){return e<=Math.min(14,t)?`now`:e<=Math.min(52,t)?`next`:e<=Math.min(148,t)?`later`:`someday`}var p5t=150;function m5t({onIssueAction:e}={}){let t=yt(),[n,r]=(0,z.useState)(`dag`),[i,a]=(0,z.useState)(`all`),[o,s]=(0,z.useState)(`all`),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!0),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(`incremental`),[S,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(null),[E,D]=(0,z.useState)(`now`),[O,k]=(0,z.useState)(``),[A,j]=(0,z.useState)(!1),[M,N]=(0,z.useState)(null),[P,F]=(0,z.useState)(null),[I,L]=(0,z.useState)(null),[ee,R]=(0,z.useState)(()=>new Set),[te,ne]=(0,z.useState)(null),{data:re,isLoading:ie,error:ae,refetch:oe}=V({queryKey:[`backlog-sequence`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequence`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:6e4}),{data:se=[]}=V({queryKey:[`order-books`],queryFn:async()=>{let e=await fetch(`/api/orders`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).books??[]},staleTime:15e3}),ce=(0,z.useMemo)(()=>se.filter(e=>e.status!==`complete`),[se]),le=(0,z.useMemo)(()=>ce.find(e=>e.status===`running`)??ce.find(e=>e.status===`ready`)??ce[0]??null,[ce]),ue=(0,z.useMemo)(()=>{let e=new Map;for(let t of ce)for(let n of t.items)e.set(n.issue.toUpperCase(),t);return e},[ce]),{data:de}=V({queryKey:[`sequencer-status`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequencer-status`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:3e3}),fe=de?.running??!1,pe=(0,z.useRef)(!1);(0,z.useEffect)(()=>{pe.current&&!fe&&oe(),pe.current=fe},[fe,oe]);let[me,he]=(0,z.useState)(()=>Date.now());(0,z.useEffect)(()=>{if(!fe)return;let e=setInterval(()=>he(Date.now()),1e3);return()=>clearInterval(e)},[fe]);let ge=de?.startedAt?Math.max(0,Math.floor((me-new Date(de.startedAt).getTime())/1e3)):0,_e=re?.nodes??[],ve=(0,z.useMemo)(()=>_e.filter(e=>e.condition===`stale`),[_e]),ye=(0,z.useMemo)(()=>_e.filter(e=>e.condition===`needs-refinement`),[_e]),be=(0,z.useMemo)(()=>{let e=_e.length,t={now:0,next:0,later:0,someday:0};return _e.forEach(n=>{let r=c9(n.rank,e);t[r]++}),t},[_e]),xe=(0,z.useMemo)(()=>_e.filter(e=>e.inPipeline).length,[_e]),Se=(0,z.useMemo)(()=>_e.filter(e=>e.state?.ready??!1).length,[_e]),Ce=(0,z.useMemo)(()=>_e.filter(e=>e.hasPrd).length,[_e]),we=(0,z.useMemo)(()=>_e.filter(e=>{if(E&&c9(e.rank,_e.length)!==E||i!==`all`&&e.importance!==i||o!==`all`&&e.condition!==o||c&&!e.inPipeline||u&&!(e.state?.ready??!1)||A&&!e.hasPrd)return!1;if(O){let t=O.toLowerCase();if(!e.issueId.toLowerCase().includes(t)&&!e.why.toLowerCase().includes(t))return!1}return!0}),[_e,i,o,c,u,A,E,O]),Te=(0,z.useMemo)(()=>{if(!re)return{nodes:[],edges:[]};let e=we.length;if(e<=p5t){let e=new Set(we.map(e=>e.issueId));return{nodes:we,edges:re.edges.filter(t=>e.has(t.from)&&e.has(t.to))}}let t=Math.max(Math.floor(e*.1),20),n=new Set(we.slice(0,t).map(e=>e.issueId));we.filter(e=>e.inPipeline).forEach(e=>n.add(e.issueId));let r=new Set(n);for(let e of re.edges)n.has(e.from)&&r.add(e.to),n.has(e.to)&&r.add(e.from);return{nodes:we.filter(e=>r.has(e.issueId)),edges:re.edges.filter(e=>r.has(e.from)&&r.has(e.to))}},[re,we]),Ee=we.length-Te.nodes.length;async function De(){if(!g){_(!0),T(null),C(!1);try{let e=await fetch(`/api/backlog/sequence/regenerate`,{method:`POST`,headers:await sb(),body:JSON.stringify({pass:b})});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{let n=await e.text().catch(()=>``);n&&(t=n.slice(0,300))}throw Error(t)}setTimeout(()=>oe(),2e3)}catch(e){T(e instanceof Error?e.message:String(e))}finally{_(!1)}}}async function Oe(){if(!(v||g)&&window.confirm(`Delete the backlog sequencing? This removes the ranked sequence (sequence.md + cache) and any operator gate overrides. A re-sequence pass regenerates it.`)){y(!0),T(null);try{let e=await fetch(`/api/backlog/sequence/clear`,{method:`POST`,headers:await sb()});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{}throw Error(t)}setTimeout(()=>oe(),500)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}}async function ke(e){await fetch(`/api/issues/${e}/start-planning`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>{})}async function Ae(e){(await fetch(`/api/issues/${e}/close`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>null))?.ok&&t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function je(e,n){if(!(!le||I)){L(e),ne(null);try{let r=await fetch(`/api/orders/${encodeURIComponent(le.id)}/items`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({item:{issue:e,lane:n}})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`Request failed (HTTP ${r.status})`)}R(t=>new Set(t).add(e.toUpperCase())),F(null),await t.invalidateQueries({queryKey:[`order-books`]})}catch(e){ne(e instanceof Error?e.message:String(e))}finally{L(null)}}}let Me=e=>c5t[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`,Ne=e=>l5t[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`;return(0,B.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-[var(--color-bg)] text-[var(--color-fg)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-4 px-6 py-4 border-b border-[var(--color-border)] shrink-0 flex-wrap bg-[var(--color-bg)]`,children:[(0,B.jsxs)(`div`,{className:`min-w-[280px] flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(pc,{className:`w-4 h-4 text-[var(--color-accent)]`}),(0,B.jsxs)(`h1`,{className:`font-display text-[22px] leading-tight font-medium tracking-normal text-[var(--color-fg)]`,children:[`Backlog Sequencer`,_e.length>0&&(0,B.jsxs)(`span`,{className:`ml-2 font-mono text-sm font-normal text-[var(--color-fg-muted)]`,children:[`· `,_e.length,` open`]})]})]}),(0,B.jsx)(`p`,{className:`mt-1 max-w-2xl text-[13px] leading-5 text-[var(--color-fg-muted)]`,children:`Ranked backlog flow with active-tier graphing, dependency context, and operator gates for pickup and planning.`})]}),(0,B.jsxs)(`div`,{className:`flex rounded-md overflow-hidden border border-[var(--color-border)] bg-[var(--color-surface)]`,children:[(0,B.jsxs)(`button`,{onClick:()=>r(`list`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`list`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(pc,{className:`w-3 h-3`}),`List`]}),(0,B.jsxs)(`button`,{onClick:()=>r(`dag`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`dag`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(tc,{className:`w-3 h-3`}),`DAG`]}),(0,B.jsxs)(`button`,{onClick:()=>r(`forecast`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`forecast`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),`Forecast`]})]}),(0,B.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border ${m?`border-[var(--color-accent)] text-[var(--color-accent)] bg-[color-mix(in_srgb,var(--color-accent)_8%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(Hs,{className:`w-3 h-3`}),`Filters `,we.length!==_e.length&&`(${we.length})`]}),ve.length>0&&(0,B.jsxs)(`button`,{onClick:()=>p(e=>!e),className:`px-3 py-1.5 text-xs rounded-md border ${f?`border-[var(--warning)] text-[var(--warning-foreground)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[`⊘ `,ve.length,` stale`]}),(0,B.jsxs)(`div`,{className:`relative ml-auto flex items-center gap-1`,children:[(0,B.jsxs)(`button`,{onClick:Oe,disabled:v||g||fe,className:`px-2.5 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:text-[var(--destructive)] hover:border-[color-mix(in_srgb,var(--destructive)_40%,transparent)] disabled:opacity-50`,title:`Delete the backlog sequencing (sequence.md + cache). Re-sequence regenerates it.`,children:[(0,B.jsx)(rl,{className:`w-3 h-3`}),v?`Clearing…`:`Clear`]}),(0,B.jsxs)(`button`,{onClick:De,disabled:g||fe,className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[color-mix(in_srgb,var(--color-accent)_10%,transparent)] disabled:opacity-50`,title:`Run ${b} pass`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),g||fe?`Sequencing…`:`Re-sequence`]}),(0,B.jsx)(`button`,{onClick:()=>C(e=>!e),className:`px-2 py-1.5 text-xs rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`,title:`Select pass type`,children:`▾`}),S&&(0,B.jsx)(`div`,{className:`absolute right-0 top-full mt-1 z-20 bg-[var(--color-surface)] border border-[var(--color-border)] rounded shadow-lg text-xs`,children:[`auto`,`creation`,`incremental`,`review`].map(e=>(0,B.jsx)(`button`,{onClick:()=>{x(e),C(!1)},className:`block w-full text-left px-3 py-1.5 hover:bg-[var(--color-surface-hover)] ${b===e?`text-[var(--color-accent)]`:`text-[var(--color-fg)]`}`,children:e},e))})]}),(0,B.jsx)(`button`,{onClick:()=>oe(),className:`p-2 rounded-md hover:bg-[var(--color-surface-hover)] text-[var(--color-fg-muted)] hover:text-[var(--color-fg)]`,title:`Refresh`,children:(0,B.jsx)(Mc,{className:`w-3.5 h-3.5`})})]}),fe&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-2 bg-[color-mix(in_srgb,var(--info)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--info)_28%,transparent)] text-xs`,children:[(0,B.jsx)(Mc,{className:`w-3.5 h-3.5 animate-spin text-[var(--info-foreground)]`}),(0,B.jsx)(`span`,{className:`text-[var(--info-foreground)] font-medium`,children:`Sequencing pass running`}),(0,B.jsxs)(`span`,{className:`text-[var(--color-fg)]`,children:[`ranked `,(0,B.jsx)(`b`,{className:`font-mono`,children:de?.processed??0}),` / `,(0,B.jsx)(`b`,{className:`font-mono`,children:de?.total??`…`}),` issues`]}),(0,B.jsxs)(`span`,{className:`text-[var(--color-fg-muted)] tabular-nums`,children:[`· `,Math.floor(ge/60),`m `,String(ge%60).padStart(2,`0`),`s`]}),(0,B.jsx)(`span`,{className:`ml-auto text-[var(--color-fg-muted)]`,children:`the new sequence appears automatically when it finishes`})]}),w&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--destructive)_26%,transparent)] text-xs`,children:[(0,B.jsx)(`span`,{className:`text-[var(--destructive-foreground)] font-medium`,children:`Run pass failed`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:w}),(0,B.jsx)(`button`,{onClick:()=>T(null),className:`px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_16%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_26%,transparent)] shrink-0`,children:`Dismiss`})]}),m&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-3 px-6 py-3 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-xs shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Importance:`}),[`all`,`critical`,`high`,`medium`,`low`].map(e=>(0,B.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-md border ${i===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Condition:`}),[`all`,`ok`,`needs-refinement`,`stale`].map(e=>(0,B.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-md border ${o===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`In pipeline`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Ready only`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Has PRD`})]}),(0,B.jsx)(`div`,{className:`ml-auto`,children:(0,B.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`filter by id / title…`,className:`h-6 px-2 rounded border border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] text-xs placeholder:text-[var(--color-fg-muted)]/50 focus:outline-none focus:border-[var(--color-accent)] min-w-[180px]`})})]}),f&&ve.length>0&&(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-5 py-3`,children:[(0,B.jsxs)(`div`,{className:`text-xs font-medium text-[var(--color-fg-muted)] mb-2`,children:[`Candidates to close (`,ve.length,`)`]}),(0,B.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-40 overflow-y-auto`,children:ve.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[var(--color-accent)] w-24 shrink-0`,children:e.issueId}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:e.why}),(0,B.jsx)(`button`,{onClick:()=>Ae(e.issueId),className:`px-2 py-0.5 rounded text-[10px] border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_14%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_24%,transparent)] shrink-0`,children:`Close`})]},e.issueId))})]}),ye.length>0&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--warning)_26%,transparent)] text-xs`,children:[(0,B.jsxs)(`span`,{className:`text-[var(--warning-foreground)] font-medium`,children:[`⚠ `,ye.length,` need refinement`]}),(0,B.jsxs)(`span`,{className:`text-[var(--color-fg-muted)]`,children:[ye.slice(0,5).map(e=>e.issueId).join(`, `),ye.length>5?` +${ye.length-5}`:``]}),(0,B.jsx)(`button`,{onClick:()=>ke(ye[0].issueId),className:`ml-auto px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--warning)_32%,transparent)] bg-[color-mix(in_srgb,var(--warning)_16%,transparent)] text-[var(--warning-foreground)] hover:bg-[color-mix(in_srgb,var(--warning)_26%,transparent)] shrink-0`,children:`Draft PRD →`})]}),_e.length>0&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-6 py-2.5 border-b border-[var(--color-border)] shrink-0`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border border-[var(--color-border)] bg-[var(--color-surface)] text-xs text-[var(--color-fg-muted)]`,children:[(0,B.jsx)(`b`,{className:`text-[var(--color-fg)] font-medium font-mono`,children:_e.length}),` open issues`]}),(0,B.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`${i9} ${c?o9.info:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.info}`}),`In pipeline `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:xe})]}),(0,B.jsxs)(`button`,{onClick:()=>d(e=>!e),className:`${i9} ${u?o9.success:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.success}`}),`Ready `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:Se})]}),(0,B.jsxs)(`button`,{onClick:()=>j(e=>!e),className:`${i9} ${A?o9.neutral:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.neutral}`}),`Has PRD `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:Ce})]}),ye.length>0&&(0,B.jsxs)(`button`,{onClick:()=>s(e=>e===`needs-refinement`?`all`:`needs-refinement`),className:`${i9} ${o===`needs-refinement`?o9.warning:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.warning}`}),`⚠ Needs refinement `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ye.length})]}),ve.length>0&&(0,B.jsxs)(`button`,{onClick:()=>s(e=>e===`stale`?`all`:`stale`),className:`${i9} ${o===`stale`?o9.neutral:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full opacity-60 shrink-0 ${s9.neutral}`}),`⊘ Stale candidates `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ve.length})]}),(0,B.jsxs)(`button`,{onClick:()=>D(e=>e===`now`?null:`now`),className:`${i9} ${E===`now`?o9.danger:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.danger}`}),`Tier 1 · Now `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:be.now})]})]}),_e.length>0&&(0,B.jsx)(`div`,{className:`flex gap-2 px-6 py-3 border-b border-[var(--color-border)] shrink-0`,children:[{key:`now`,emoji:`🔴`,label:`Now`,count:be.now,sub:`act on these first`,accent:`border-l-[var(--destructive)]`,ring:`ring-[color-mix(in_srgb,var(--destructive)_50%,transparent)]`},{key:`next`,emoji:`🟠`,label:`Next`,count:be.next,sub:`queued behind Now`,accent:`border-l-[var(--warning)]`,ring:`ring-[color-mix(in_srgb,var(--warning)_50%,transparent)]`},{key:`later`,emoji:`🔵`,label:`Later`,count:be.later,sub:`planned horizon`,accent:`border-l-[var(--info)]`,ring:`ring-[color-mix(in_srgb,var(--info)_50%,transparent)]`},{key:`someday`,emoji:`⚪`,label:`Someday`,count:be.someday,sub:`long tail`,accent:`border-l-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`,ring:`ring-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`}].map(e=>(0,B.jsxs)(`button`,{onClick:()=>D(t=>t===e.key?null:e.key),className:`flex-1 min-w-[140px] flex flex-col gap-0.5 px-3.5 py-2.5 border border-l-4 ${e.accent} rounded-lg bg-[var(--color-surface)] text-left hover:bg-[var(--color-surface-hover)] transition-colors shadow-sm ${E===e.key?`ring-1 ${e.ring} border-[var(--color-border)]`:`border-[var(--color-border)]`}`,children:[(0,B.jsxs)(`span`,{className:`text-xs text-[var(--color-fg)]`,children:[e.emoji,` `,e.label]}),(0,B.jsx)(`span`,{className:`font-mono text-lg font-medium text-[var(--color-fg)] leading-tight`,children:e.count}),(0,B.jsx)(`span`,{className:`text-[10px] text-[var(--color-fg-muted)]`,children:e.sub})]},e.key))}),E&&_e.length>0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-1.5 border-b border-[var(--color-border)] bg-[var(--color-surface)] shrink-0 text-xs text-[var(--color-fg-muted)]`,children:[(0,B.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-widest bg-[var(--color-accent)] text-[var(--color-fg)]`,children:[`Showing `,d5t[E]]}),(0,B.jsxs)(`span`,{children:[we.length,` of `,_e.length,` issues`,n===`dag`?` rendered as a graph`:``,` — click the tier again to show all`]})]}),(0,B.jsxs)(`div`,{className:`flex-1 overflow-hidden flex`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden flex flex-col`,children:[ie&&(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--color-fg-muted)] text-sm`,children:`Loading sequence…`}),ae&&(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--destructive-foreground)] text-sm`,children:String(ae)}),!ie&&!ae&&_e.length===0&&(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-3 text-[var(--color-fg-muted)]`,children:[(0,B.jsx)(pc,{className:`w-8 h-8 opacity-40`}),(0,B.jsx)(`p`,{className:`text-sm`,children:`No backlog sequence yet.`}),(0,B.jsx)(`p`,{className:`text-xs`,children:`Run a creation pass to rank the open backlog.`}),(0,B.jsxs)(`button`,{onClick:()=>{x(`creation`),De()},disabled:g,className:`px-3 py-1.5 text-xs rounded border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[var(--color-accent)]/10 disabled:opacity-50 flex items-center gap-1`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),g?`Spawning…`:`Run creation pass`]})]}),!ie&&!ae&&_e.length>0&&n===`list`&&(0,B.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,B.jsx)(`thead`,{className:`sticky top-0 bg-[var(--color-surface)] border-b border-[var(--color-border)]`,children:(0,B.jsxs)(`tr`,{className:`text-[var(--color-fg-muted)]`,children:[(0,B.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-8 cursor-help`,title:`Pickup rank — lower means the Flywheel works it sooner`,children:`#`}),(0,B.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-6 cursor-help`,title:`Importance — red = critical, orange = high, gray = medium, dim = low`,children:`●`}),(0,B.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-28 cursor-help`,title:`Issue ID. Markers: ▶ in pipeline · ⚠ needs refinement · P has PRD · ✓ planned (spec + tasks)`,children:`Issue`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-16 cursor-help`,title:`Tier band by rank: Now · Next · Later · Someday`,children:`Tier`}),(0,B.jsx)(`th`,{className:`text-left px-2 py-2 font-medium cursor-help`,title:`One-line rationale for this ranking (from the sequencer)`,children:`Why`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Estimated effort: XS / S / M / L / XL`,children:`Size`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-24 cursor-help`,title:`AI condition: ok · needs-refinement (vague spec) · stale (likely close)`,children:`Condition`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-20 cursor-help`,title:`Operator pickup gate: auto (normal) · promote (jump queue) · vetoed (never pick)`,children:`Gate`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Impact score (0–100) the sequencer assigned`,children:`Score`}),(0,B.jsx)(`th`,{className:`px-2 py-2 font-medium w-28`,children:(0,B.jsx)(`span`,{className:`sr-only`,children:`Order book`})})]})}),(0,B.jsx)(`tbody`,{children:we.map(e=>{let t=c9(e.rank,_e.length),n=e.condition===`stale`,r=e.condition===`needs-refinement`,i=M?.issueId===e.issueId;return(0,B.jsxs)(`tr`,{onClick:()=>N(t=>t?.issueId===e.issueId?null:e),className:`group transition-colors cursor-pointer ${n?`opacity-50`:``} ${i?`bg-[color-mix(in_srgb,var(--color-accent)_14%,transparent)] ring-inset ring-1 ring-[var(--color-accent)]`:`even:bg-[color-mix(in_srgb,var(--color-fg)_3%,transparent)] hover:bg-[color-mix(in_srgb,var(--color-fg)_9%,transparent)]`}`,children:[(0,B.jsx)(`td`,{className:`text-right px-3 py-2 text-[var(--color-fg-muted)] tabular-nums border-l-2 ${e.inPipeline?`border-l-[var(--info)]`:`border-l-transparent`}`,children:e.rank}),(0,B.jsx)(`td`,{className:`px-2 py-2`,children:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${u5t[e.importance]??`bg-[var(--color-fg-muted)]`}`,title:`Importance: ${e.importance}`})}),(0,B.jsxs)(`td`,{className:`px-2 py-2 font-mono text-[var(--color-accent)]`,children:[e.issueId,e.inPipeline&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`In pipeline — active work / review / test`,children:`▶`}),r&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--warning-foreground)] align-top`,title:`Needs refinement — vague/underspecified`,children:`⚠`}),e.hasPrd&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`Has PRD`,children:`P`}),e.ready&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--success-foreground)] align-top`,title:`Has spec — ready for work`,children:`✓`})]}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${f5t[t]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`}`,children:d5t[t]})}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-[var(--color-fg)] max-w-xs truncate ${n?`line-through`:``}`,children:e.why}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)]`,children:e.size}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Me(e.condition)}`,title:e.condition===`needs-refinement`?`Needs refinement — vague/underspecified`:e.condition===`stale`?`Stale — likely a candidate to close`:`OK — well-specified`,children:e.condition===`needs-refinement`?`⚠ refine`:e.condition===`stale`?`⊘ stale`:e.condition})}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ne(e.gate)}`,title:e.gate===`ready`?e.inPipeline?`Auto (in-pipeline pin)`:`Promoted — jumps the queue`:e.gate===`blocked`?`Vetoed — never auto-picked`:`Auto — normal eligibility`,children:e.gate===`ready`?e.inPipeline?`auto`:`📌`:e.gate===`blocked`?`⛔`:e.gate})}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)] tabular-nums`,children:e.score}),(0,B.jsxs)(`td`,{className:`relative px-2 py-2 text-right`,onClick:e=>e.stopPropagation(),children:[ue.has(e.issueId.toUpperCase())||ee.has(e.issueId.toUpperCase())?(0,B.jsx)(`a`,{href:`/orders`,className:`text-[10px] text-[var(--color-accent)] opacity-0 hover:underline group-hover:opacity-100 focus:opacity-100`,children:`Open order book`}):(0,B.jsx)(`button`,{type:`button`,disabled:!le,onClick:()=>{ne(null),F(t=>t===e.issueId?null:e.issueId)},className:`rounded border border-[var(--color-border)] px-2 py-1 text-[10px] text-[var(--color-fg-muted)] opacity-0 transition-opacity hover:border-[var(--color-accent)] hover:text-[var(--color-accent)] focus:opacity-100 disabled:cursor-not-allowed disabled:opacity-30 group-hover:opacity-100`,title:le?`Add to ${le.name}`:`Create an order book first`,children:`+ Order book`}),P===e.issueId&&le&&(0,B.jsxs)(`div`,{className:`absolute right-2 top-full z-30 w-52 rounded-md border border-[var(--color-border)] bg-[var(--color-surface)] p-2 text-left shadow-lg`,role:`dialog`,"aria-label":`Choose lane for ${e.issueId}`,children:[(0,B.jsxs)(`p`,{className:`truncate text-[10px] text-[var(--color-fg-muted)]`,children:[`Add to `,le.name]}),(0,B.jsx)(`div`,{className:`mt-2 flex gap-2`,children:[`A`,`B`].map(t=>(0,B.jsxs)(`button`,{type:`button`,disabled:I===e.issueId,onClick:()=>{je(e.issueId,t)},className:`flex-1 rounded border border-[var(--color-border)] px-2 py-1 text-[10px] text-[var(--color-fg)] hover:border-[var(--color-accent)] disabled:opacity-50`,children:[`Lane `,t]},t))}),(0,B.jsx)(`a`,{href:`/orders`,className:`mt-2 block text-[10px] text-[var(--color-accent)] hover:underline`,children:`Open Order Book`}),te&&(0,B.jsx)(`p`,{className:`mt-2 text-[10px] text-[var(--destructive)]`,role:`alert`,children:te})]})]})]},e.issueId)})})]})}),!ie&&!ae&&_e.length>0&&n===`dag`&&re&&(0,B.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[Ee>0&&(0,B.jsxs)(`div`,{className:`shrink-0 text-xs text-center py-1 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-[var(--color-fg-muted)]`,children:[`Showing `,Te.nodes.length,` of `,we.length,` issues (top tier + neighbors); `,Ee,` collapsed`]}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)($8t,{data:Te,className:`w-full h-full`,selectedNodeId:M?.issueId,onSelectNode:e=>N(e),onIssueAction:e})})]}),!ie&&!ae&&_e.length>0&&n===`forecast`&&(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(a5t,{className:`w-full h-full`,onSelectIssue:e=>N(_e.find(t=>t.issueId===e)??null)})})]}),M&&(0,B.jsx)(Q8t,{node:M,onClose:()=>N(null),onIssueAction:e})]})]})}var h5t={exploring:{label:`Exploring`,color:`var(--primary)`,icon:Vc},planning:{label:`Planning`,color:`var(--signal-review, var(--primary))`,icon:Ss},building:{label:`Building`,color:`var(--success, #10b981)`,icon:Pie},verifying:{label:`Verifying`,color:`var(--warning, #f59e0b)`,icon:_s},cleaning:{label:`Cleaning`,color:`var(--muted-foreground)`,icon:Sae},shipping:{label:`Shipping`,color:`var(--primary)`,icon:Nc}};function g5t(e){return e.filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,3)}function _5t(e,t){if(!e)return!1;let n=Date.parse(e.timestamp);return!Number.isNaN(n)&&t.getTime()-n>3600*1e3}function l9({label:e,value:t,tone:n}){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:n??`var(--foreground)`},children:t})]})}function v5t({issue:e,status:t,observations:n,stats:r,onOpenWorkspaceHome:i,now:a=new Date}){let o=t?.phase??`exploring`,s=h5t[o],c=s.icon,l=g5t(n),u=_5t(l[0],a),d=t?.headline||e.title,f=t?.summary||e.description||`No workspace status summary yet.`;return(0,B.jsxs)(`button`,{type:`button`,"data-testid":`workspace-status-card`,onClick:i,className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,"aria-label":`Open ${e.identifier} workspace overview`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{"data-testid":`workspace-status-phase-icon`,"data-phase":o,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border`,style:{color:s.color,borderColor:s.color,background:`color-mix(in srgb, currentColor 10%, transparent)`},children:(0,B.jsx)(c,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,title:d,children:d}),(0,B.jsx)(`span`,{"data-testid":`workspace-status-phase-label`,className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,style:{color:s.color,borderColor:s.color},children:s.label}),u&&(0,B.jsxs)(`span`,{"data-testid":`workspace-status-stale`,className:`ml-auto flex shrink-0 items-center gap-1 text-[10px] font-semibold text-warning`,children:[(0,B.jsx)(il,{className:`h-3 w-3`}),`Stale`]})]}),(0,B.jsx)(`p`,{"data-testid":`workspace-status-summary`,className:`mt-1 text-xs text-muted-foreground`,style:{display:`-webkit-box`,WebkitLineClamp:3,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:f})]})]}),(0,B.jsx)(`ul`,{"data-testid":`workspace-status-observations`,className:`mt-3 space-y-1 text-xs text-muted-foreground`,children:l.length===0?(0,B.jsx)(`li`,{className:`text-muted-foreground/70`,children:`No recent action status.`}):l.map(e=>(0,B.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),e.actionStatus?(0,B.jsx)(DQ,{status:e.actionStatus}):null,(0,B.jsx)(`span`,{className:`min-w-0 truncate`,title:e.summary,children:e.summary})]},e.id))}),(0,B.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-3 border-t border-border pt-3`,children:[(0,B.jsx)(l9,{label:`Additions`,value:`+${r.additions}`,tone:`var(--success, #10b981)`}),(0,B.jsx)(l9,{label:`Deletions`,value:`-${r.deletions}`,tone:`var(--destructive)`}),(0,B.jsx)(l9,{label:`Commits`,value:r.commits}),(0,B.jsx)(l9,{label:`PRs`,value:r.prs})]})]})}var y5t={justNow:`Just Now`,earlierToday:`Earlier Today`,yesterday:`Yesterday`,thisWeek:`This Week`,thisMonth:`This Month`,older:`Older`},b5t=[`justNow`,`earlierToday`,`yesterday`,`thisWeek`,`thisMonth`,`older`];async function x5t(){let e=await fetch(`/api/registry/features`);if(!e.ok)throw Error(`Registry request failed (${e.status})`);let t=await e.json();return Array.isArray(t.entries)?t.entries:[]}async function S5t(){let e=await fetch(`/api/metrics/summary`);if(!e.ok)throw Error(`Metrics summary request failed (${e.status})`);return e.json()}function C5t({onOpenWorkspaceHome:e,onNewProject:t,onSelectProject:n,onOpenSettings:r,now:i}={}){let a=V({queryKey:[`feature-registry`],queryFn:x5t,staleTime:3e4,retry:!1}),o=V({queryKey:[`metrics-summary`],queryFn:S5t,staleTime:3e4,retry:!1}),s=V({queryKey:[`command-deck-projects`],queryFn:UC,staleTime:3e4,retry:!1}),c=s.data??[],l=hO(e=>e.showPlannedBacklog),u=Q(e=>e.issuesRaw),d=Q(e=>e.statusByIssueId),f=Q(e=>e.observationsByIssueId),p=Q(e=>e.agentsById),m=Q(e=>e.reviewStatusByIssueId),h=Q(PNe),g=i??new Date,_=(0,z.useMemo)(()=>F5t({issuesRaw:u,statusByIssueId:d,observationsByIssueId:f,agentsById:p,reviewStatusByIssueId:m}),[p,u,f,m,d]),v=(0,z.useMemo)(()=>P5t(f),[f]),y=(0,z.useMemo)(()=>k5t(O5t({agentsById:p,reviewStatusByIssueId:m,dailyCost:o.data?.today?.totalCost,now:g})),[p,g,o.data?.today?.totalCost,m]);return(0,B.jsx)(`div`,{className:`h-full w-full overflow-y-auto bg-background`,children:(0,B.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 p-6`,children:[(0,B.jsx)(`header`,{className:`rounded-xl border border-border bg-card p-6 shadow-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Overdeck Home`}),(0,B.jsx)(`h1`,{className:`mt-2 text-3xl font-semibold text-foreground`,children:`System briefing`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm text-muted-foreground`,children:`A live landing page for current workspace context, cross-workspace ownership, and memory-first guidance.`})]}),(0,B.jsx)(Q8,{})]})}),(0,B.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,"aria-label":`Home summary`,children:y.map(e=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,B.jsx)(`p`,{className:`mt-2 text-2xl font-semibold tabular-nums ${e.tone??`text-foreground`}`,children:e.value}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail})]},e.label))}),(0,B.jsx)(w5t,{observations:v,failure:h,onOpenSettings:r,now:g}),(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`workspace-status-title`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`workspace-status-title`,className:`text-lg font-semibold text-foreground`,children:`Workspaces`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Live workspace status rollups from memory observations.`})]}),(0,B.jsx)(`div`,{className:`mt-4`,children:_.length>0?(0,B.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:_.map(t=>(0,B.jsx)(v5t,{issue:t.issue,status:t.status,observations:t.observations,stats:t.stats,onOpenWorkspaceHome:()=>e?.(t.issue.identifier),now:i},t.issue.identifier))}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No workspace status is available yet.`}),(0,B.jsx)(`p`,{className:`mt-1`,children:`Workspace cards will appear after memory status or observations are recorded for an issue.`})]})})]}),(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`knowledge-registry-title`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`knowledge-registry-title`,className:`text-lg font-semibold text-foreground`,children:`Knowledge Registry`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Feature ownership across issues, workspaces, and agents.`})]}),a.isFetching&&(0,B.jsx)(`span`,{className:`mt-2 rounded-full border border-border px-2 py-1 text-xs text-muted-foreground sm:mt-0`,children:`Refreshing`})]}),(0,B.jsx)(`div`,{className:`mt-4`,children:a.isError?(0,B.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Knowledge Registry could not be loaded. The rest of Home is still available.`}):a.isLoading?(0,B.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading registry entries…`}):a.data&&a.data.length>0?(0,B.jsx)(V5t,{entries:a.data}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No features are registered yet.`}),(0,B.jsxs)(`p`,{className:`mt-1`,children:[`Add one with `,(0,B.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`pan registry tag <issueId> <feature>`}),`. Automatic classification will populate future entries as issue and workspace lifecycle wiring lands.`]})]})})]}),(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-projects-title`,"data-testid":`home-projects`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`home-projects-title`,className:`text-lg font-semibold text-foreground`,children:`Projects`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your registered projects — click one to open its deck.`})]}),t&&(0,B.jsx)(`button`,{"data-testid":`home-new-project`,onClick:t,className:`rounded-lg border border-border bg-muted/20 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]}),(0,B.jsx)(`div`,{className:`mt-4`,children:s.isLoading?(0,B.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading projects…`}):s.isError?(0,B.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Projects could not be loaded. The rest of Home is still available.`}):c.length>0?(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:c.map(e=>{let t=HC(e.features,l),r=t.length>0;return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{"data-testid":`home-project-${e.name}`,onClick:()=>n?.(e.name),title:e.path,className:`flex w-full items-center gap-3 px-4 py-3 text-left text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:[(0,B.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${r?`bg-primary`:`bg-muted-foreground/30`}`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),r&&(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t.length})]})},e.path)})}):(0,B.jsxs)(`div`,{"data-testid":`home-projects-empty`,className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No projects yet.`}),(0,B.jsx)(`p`,{className:`mt-1`,children:`Create your first project to get started.`}),t&&(0,B.jsx)(`button`,{"data-testid":`home-new-project-empty`,onClick:t,className:`mt-3 rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]})})]})]})})}function w5t({observations:e,failure:t,onOpenSettings:n,now:r}){let i=(0,z.useMemo)(()=>gBt(e,e=>e.timestamp,r),[e,r]);return(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-activity-title`,"data-testid":`home-activity-feed`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`home-activity-title`,className:`text-lg font-semibold text-foreground`,children:`Activity Feed`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Recent actionable memory observations across workspaces.`})]}),t&&(0,B.jsx)(T5t,{failure:t,onOpenSettings:n}),e.length===0?(0,B.jsxs)(`div`,{"data-testid":`home-activity-empty`,className:`mt-4 rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No actionable observations yet.`}),(0,B.jsx)(`p`,{className:`mt-1`,children:`Observations are extracted from running work agents — they appear here once an agent makes a change worth recording.`})]}):(0,B.jsx)(`div`,{className:`mt-4 space-y-5`,children:b5t.map(e=>{let t=i[e];return t.length===0?null:(0,B.jsxs)(`section`,{"data-testid":`home-activity-bucket-${e}`,children:[(0,B.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:y5t[e]}),(0,B.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,B.jsx)(D5t,{observation:e,now:r},e.id))})]},e)})})]})}function T5t({failure:e,onOpenSettings:t}){let n=E5t(e);return(0,B.jsx)(`div`,{"data-testid":`home-memory-failure`,className:`mt-4 rounded-lg border border-destructive/32 bg-destructive/8 p-4 text-sm text-foreground`,role:`alert`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(il,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`font-medium text-destructive`,children:`Memory extraction is failing`}),(0,B.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),e.detail?(0,B.jsx)(`p`,{className:`mt-2 break-words font-mono text-[11px] text-muted-foreground`,children:e.detail}):null,(0,B.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:`Memory observations and agent memory injection are disabled until this is fixed.`}),t?(0,B.jsx)(`button`,{onClick:t,className:`mt-3 rounded-sm border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground hover:bg-accent transition-colors`,children:`Open Settings › Memory`}):null]})]})})}function E5t(e){let t=(e.detail??``).toLowerCase();return t.includes(`could not resolve authentication`)||t.includes(`anthropic_api_key`)||t.includes(`x-api-key`)?`The Anthropic API provider has no API key. Switch the extraction provider to cliproxy (your ChatGPT subscription) in Settings › Memory.`:t.includes(`unknown provider for model`)||t.includes(`does not exist`)||t.includes(`unknown model`)?`The configured extraction model is not available on cliproxy. Pick a served model (e.g. gpt-5.4-mini) in Settings › Memory.`:t.includes(`401`)||t.includes(`unauthorized`)||t.includes(`expired`)?`The extraction provider rejected the credentials — the codex/ChatGPT subscription token used by cliproxy may have expired. Re-authenticate, then it will recover automatically.`:`Background memory-extraction calls are failing. Check the extraction provider and model in Settings › Memory.`}function D5t({observation:e,now:t}){return(0,B.jsxs)(`li`,{className:`rounded-lg border border-border bg-background p-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(DQ,{status:e.actionStatus}),(0,B.jsx)(`p`,{className:`font-semibold text-foreground`,children:e.summary})]}),(0,B.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[e.workspaceId,` · `,e.issueId,` · `,(0,B.jsx)(`time`,{dateTime:e.timestamp,children:JD(e.timestamp,t)})]}),e.narrative?(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:e.narrative}):null,e.files.length>0?(0,B.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Files`,children:e.files.map(e=>(0,B.jsx)(`code`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,e.tags.length>0?(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,"aria-label":`Tags`,children:e.tags.map(e=>(0,B.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,(0,B.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,B.jsx)(EQ,{kind:`memory`})})]})}function O5t({agentsById:e={},reviewStatusByIssueId:t={},dailyCost:n,now:r}){let i=Object.values(e),a=Object.values(t);return{runningAgents:i.filter(A5t).length,gatedAgents:i.filter(j5t).length,recentMerges:a.filter(e=>M5t(e,r)).length,failedVerifications:a.filter(N5t).length,dailyCost:typeof n==`number`&&Number.isFinite(n)?n:null}}function k5t(e){return[{label:`Running agents`,value:String(e.runningAgents),detail:`Live or starting sessions`,tone:e.runningAgents>0?`text-primary`:void 0},{label:`Paused / troubled`,value:String(e.gatedAgents),detail:`Agents gated by pause or failures`,tone:e.gatedAgents>0?`text-warning`:void 0},{label:`Merged today`,value:String(e.recentMerges),detail:`Merges in the last 24 hours`,tone:e.recentMerges>0?`text-success`:void 0},{label:`Needs verification`,value:String(e.failedVerifications),detail:`Failed checks or merge blockers`,tone:e.failedVerifications>0?`text-destructive`:void 0},{label:`Cost today`,value:e.dailyCost===null?`Unavailable`:`$${e.dailyCost.toFixed(2)}`,detail:`UTC daily cost summary`,tone:e.dailyCost===null?`text-muted-foreground`:`text-success`}]}function A5t(e){return e.hasLiveTmuxSession===!0||e.status===`running`||e.status===`starting`}function j5t(e){return e.paused===!0||e.troubled===!0||e.status!==`stopped`&&(e.consecutiveFailures??0)>0}function M5t(e,t){if(e.mergeStatus!==`merged`||!e.updatedAt)return!1;let n=Date.parse(e.updatedAt);return!Number.isNaN(n)&&t.getTime()-n<=1440*60*1e3}function N5t(e){return e.verificationStatus===`failed`||e.testStatus===`failed`||e.uatStatus===`failed`||(e.blockerReasons?.length??0)>0}function P5t(e){return Object.values(e).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function F5t({issuesRaw:e,statusByIssueId:t={},observationsByIssueId:n={},agentsById:r={},reviewStatusByIssueId:i={}}){let a=new Map;for(let t of e){let e=z5t(t);e&&a.set(e.identifier,e)}let o=new Set;for(let e of Object.keys(t))o.add(e);for(let[e,t]of Object.entries(n))t.length>0&&o.add(e);for(let e of Object.values(r))e.issueId&&I5t(e)&&o.add(e.issueId);return[...o].sort(nb).map(e=>{let r=t[e],o=n[e]??[];return{issue:a.get(e)??{identifier:e,title:r?.headline||e,description:r?.summary},status:r,observations:o,stats:L5t(o,i[e])}})}function I5t(e){return e.hasLiveTmuxSession===!0||[`healthy`,`running`,`starting`,`stuck`,`warning`].includes(e.status)}function L5t(e,t){return{additions:0,deletions:0,commits:e.filter(R5t).length,prs:+!!t?.prUrl}}function R5t(e){return e.tags.some(e=>[`commit`,`commits`,`git.commit`].includes(e.toLowerCase()))}function z5t(e){return!B5t(e)||typeof e.identifier!=`string`||typeof e.title!=`string`?null:{identifier:e.identifier,title:e.title,description:typeof e.description==`string`?e.description:void 0}}function B5t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function V5t({entries:e}){return(0,B.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`min-w-full divide-y divide-border text-sm`,children:[(0,B.jsx)(`thead`,{className:`bg-muted/40 text-left text-xs uppercase tracking-wide text-muted-foreground`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Feature`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Issue`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Workspace`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Agent`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Status`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Updated`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Tags`})]})}),(0,B.jsx)(`tbody`,{className:`divide-y divide-border bg-card`,children:e.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{className:`px-4 py-3 font-medium text-foreground`,children:e.featureName}),(0,B.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningIssueId??`—`}),(0,B.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningWorkspaceId??`—`}),(0,B.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningAgentId??`—`}),(0,B.jsx)(`td`,{className:`px-4 py-3`,children:(0,B.jsx)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-1 text-xs font-medium text-foreground`,children:e.status})}),(0,B.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:H5t(e.updatedAt)}),(0,B.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:e.tags.length>0?e.tags.join(`, `):`—`})]},e.featureId))})]})})})}function H5t(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function U5t({initialProjectKey:e=``,onCreated:t}={}){let[n,r]=(0,z.useState)(``),[i,a]=(0,z.useState)(e),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(`shared`),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(!0),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(null),b=(0,z.useRef)(0),x=(0,z.useRef)(0);(0,z.useEffect)(()=>()=>{x.current+=1},[]);let S=c===`isolated`?``:o,C=(0,z.useMemo)(()=>({project:i,name:n,isolated:c===`isolated`,...S?{targetPath:S}:{},...u?{parentBranch:u}:{}}),[S,c,n,u,i]);(0,z.useEffect)(()=>{p(null),h(!0),y(null);let e=++b.current,t=setTimeout(()=>{(async()=>{try{let t=await vl(`/api/workspace-registry/resolve`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(C)});if(!t.ok){e===b.current&&y(`Could not resolve the workspace intent (HTTP ${t.status}).`);return}let n=await t.json();if(e!==b.current)return;p(n),h(!1)}catch{e===b.current&&y(`Could not reach the server to resolve the workspace intent.`)}})()},300);return()=>clearTimeout(t)},[C]);let w=(0,z.useCallback)(e=>(f?.findings??[]).filter(t=>t.field===e),[f]),T=(f?.findings.length??0)>0;return{name:n,setName:r,projectKey:i,setProjectKey:a,targetPath:o,setTargetPath:s,mode:c,setMode:l,parentBranch:u,setParentBranch:d,effectiveTargetPath:S,intent:f,stale:m,creating:g,error:v,findingsFor:w,hasFindings:T,canCreate:!g&&!m&&!!f&&!T,submitIntent:(0,z.useCallback)(async(e=C)=>{y(null),_(!0);let n=++x.current;try{let r=await vl(`/api/workspace-registry`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(e)});if(n!==x.current)return null;if(!r.ok){let e=await r.json().catch(()=>({}));return n===x.current&&(e.findings?.length?(p(t=>t&&{...t,findings:e.findings??[]}),y(e.findings[0]?.message??`The workspace intent was rejected.`)):y(e.error??`HTTP ${r.status}`)),null}let i=await r.json();return n===x.current?(t?.(i.id),i.id):null}catch(e){return n===x.current&&y(e instanceof Error?e.message:String(e)),null}finally{n===x.current&&_(!1)}},[t,C])}}var W5t=[],G5t=[],K5t=[[`AUTOMATE`,`Nightly dependency-audit sweep across all registered projects`],[`DELEGATE`,`Triage the untriaged backlog and draft a priority proposal`],[`EXPLORE`,`Map how the merge train decides dispatch order`],[`BUILD`,`Prototype kanban swimlanes grouped by project`],[`PLAN`,`Plan the Q3 cost-governor roadmap from open issues`],[`DESIGN`,`Redesign the agent card footer around the new style guide`]];function q5t({onCancel:e,onCreated:t}){let n=(0,z.useRef)(null),r=(0,z.useRef)(!1),i=yt(),[a]=(0,z.useState)(()=>byt()??``),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!1),[g,_]=(0,z.useState)(null),[v,y]=(0,z.useState)(!1),b=U5t({initialProjectKey:a,onCreated:t}),x=V({queryKey:[`registered-projects`],queryFn:async()=>{let e=await vl(`/api/registered-projects`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t)?t:[]},staleTime:6e4}),S=V({queryKey:[`workspace-registry`],queryFn:async()=>{let e=await vl(`/api/workspace-registry`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.workspaces)?t.workspaces:[]},staleTime:1e4,refetchInterval:1e4}),C=x.data??W5t,w=S.data??G5t,T=(0,z.useMemo)(()=>{let e=new Map;for(let t of w)e.set(t.projectId,Math.max(e.get(t.projectId)??0,t.lastAccessedAt));return[...C].sort((t,n)=>(e.get(n.key)??0)-(e.get(t.key)??0))},[C,w]);(0,z.useEffect)(()=>{if(!x.isSuccess||r.current)return;r.current=!0;let e=a?T.find(e=>e.key===a||e.name===a)?.key:void 0;e&&b.projectKey!==e?b.setProjectKey(e):!b.projectKey&&T.length===1&&b.setProjectKey(T[0]?.key??``)},[b.projectKey,b.setProjectKey,a,T,x.isSuccess]),(0,z.useEffect)(()=>{if(b.setTargetPath(``),_(null),d(!1),p(!1),!b.projectKey)return;let e=!1;return(async()=>{try{let t=await vl(`/api/workspace-registry/project-targets?project=${encodeURIComponent(b.projectKey)}`,{credentials:`include`});if(e||!t.ok)return;let n=await t.json();if(e)return;_(n),b.setTargetPath(n.primaryPath)}catch{}})(),()=>{e=!0}},[b.projectKey,b.setTargetPath]),(0,z.useEffect)(()=>{if(y(!1),!b.projectKey)return;let e=!1;return(async()=>{try{let t=await vl(`/api/workspace-registry?project=${encodeURIComponent(b.projectKey)}&kind=main&includeArchived=true`,{credentials:`include`});if(e||!t.ok)return;let n=await t.json();e||y((n.workspaces??[]).length===0)}catch{}})(),()=>{e=!0}},[b.projectKey]);let E=(0,z.useMemo)(()=>{if(!g)return[];let e=new Set;return[g.primaryPath,...g.targets.map(e=>e.path)].filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[g]),D=b.mode===`isolated`?b.intent?.path??`Resolved isolated path`:b.targetPath||b.intent?.path||`Choose target directory`,O=[`name`,`project`,`targetPath`,`parentBranch`].flatMap(e=>b.findingsFor(e)),k=b.parentBranch||b.intent?.parentBranch,A=!b.parentBranch&&b.intent?.parentBranchGuessed;return(0,B.jsxs)(`div`,{"data-testid":`new-workspace-page`,className:`h-full w-full overflow-y-auto bg-background`,children:[(0,B.jsxs)(`form`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col px-8 py-12 lg:px-12 lg:py-16`,onSubmit:e=>{e.preventDefault(),b.canCreate&&b.submitIntent()},children:[(0,B.jsxs)(`div`,{"data-testid":`new-workspace-project-chip-row`,"data-region":`project-chip-row`,"data-selected-project":b.projectKey,className:`relative mb-8 flex min-h-9 flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,B.jsx)(jc,{className:`h-4 w-4`}),`add existing`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,B.jsx)(Js,{className:`h-4 w-4`}),`new project`]}),T.slice(0,5).map(e=>(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-project-chip`,"data-project-key":e.key,"aria-pressed":b.projectKey===e.key,onClick:()=>b.setProjectKey(e.key),className:`inline-flex h-9 items-center rounded-lg border px-3 text-sm transition-colors ${b.projectKey===e.key?`border-foreground/40 bg-accent text-foreground`:`border-input text-foreground hover:bg-accent`}`,children:e.name},e.key)),T.length>5&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":c,onClick:()=>l(e=>!e),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[`more projects`,(0,B.jsx)(ds,{className:`h-3.5 w-3.5`})]}),c&&(0,B.jsx)(`div`,{"data-testid":`new-workspace-project-overflow`,className:`absolute left-0 top-11 z-30 min-w-64 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:T.slice(5).map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>{b.setProjectKey(e.key),l(!1)},className:`block w-full rounded-md px-3 py-2 text-left text-sm text-popover-foreground hover:bg-accent`,children:e.name},e.key))})]})]}),(0,B.jsx)(`input`,{ref:n,"data-testid":`new-workspace-hero-title`,"data-region":`hero-title`,"aria-label":`Workspace name`,className:`display-xl mb-7 w-full border-0 bg-transparent p-0 text-foreground caret-primary outline-none placeholder:text-muted-foreground/40`,value:b.name,onChange:e=>b.setName(e.target.value),placeholder:`Untitled workspace`,autoComplete:`off`,spellCheck:!1,autoFocus:!0}),(0,B.jsxs)(`div`,{"data-testid":`new-workspace-target-row`,"data-region":`target-row`,className:`relative mb-10 flex min-h-9 flex-wrap items-center gap-2.5`,children:[(0,B.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-target-chip`,disabled:b.mode===`isolated`,"aria-expanded":u,onClick:()=>d(e=>!e),className:`inline-flex h-9 max-w-full items-center gap-2 rounded-lg border border-input bg-transparent px-3 font-mono text-xs text-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,B.jsx)(Ys,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:D}),(0,B.jsx)(ds,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,B.jsx)(`div`,{className:`inline-flex h-9 overflow-hidden rounded-lg border border-input`,"aria-label":`Workspace mode`,children:[`shared`,`isolated`].map(e=>(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-mode-${e}`,"aria-pressed":b.mode===e,onClick:()=>b.setMode(e),className:`px-3 text-sm transition-colors ${b.mode===e?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e===`shared`?`Shared directory`:`Isolated worktree`},e))}),(0,B.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-advanced-toggle`,"aria-expanded":m,onClick:()=>h(e=>!e),className:`eyebrow inline-flex items-center gap-1 bg-transparent px-1 py-2 text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(ps,{className:`h-3 w-3 transition-transform ${m?`rotate-90`:``}`}),`Advanced`]}),u&&b.mode===`shared`&&(0,B.jsxs)(`div`,{"data-testid":`new-workspace-target-menu`,className:`absolute left-0 top-11 z-20 min-w-72 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:[E.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>{b.setTargetPath(e),d(!1),p(!1)},className:`block w-full rounded-md px-3 py-2 text-left font-mono text-xs text-popover-foreground hover:bg-accent`,children:e},e)),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{p(!0),d(!1)},className:`block w-full rounded-md px-3 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Browse…`})]}),m&&(0,B.jsx)(`input`,{"data-testid":`new-workspace-parent-branch-input`,"aria-label":`Parent branch`,value:b.parentBranch,onChange:e=>b.setParentBranch(e.target.value),placeholder:b.intent?.parentBranch??`parent branch`,className:`h-9 min-w-56 rounded-lg border border-input bg-transparent px-3 font-mono text-xs text-foreground outline-none placeholder:text-muted-foreground focus:border-ring`}),f&&b.mode===`shared`&&(0,B.jsx)(`div`,{className:`w-full rounded-lg border border-border bg-card p-3`,children:(0,B.jsx)(AQ,{initialPath:b.targetPath||void 0,onSelect:e=>{b.setTargetPath(e),p(!1)}})})]}),v&&b.projectKey&&(0,B.jsxs)(`div`,{"data-testid":`new-workspace-bootstrap-main`,className:`mb-5 flex items-center justify-between gap-4 rounded-lg border border-border px-3 py-2`,children:[(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`This project has no main workspace registered yet.`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-bootstrap-main-button`,disabled:b.creating,onClick:()=>{b.submitIntent({project:b.projectKey,bootstrapMain:!0}).then(e=>{e&&y(!1)})},className:`shrink-0 rounded-lg border border-input bg-transparent px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:`Register main workspace`})]}),(0,B.jsx)(`div`,{"data-testid":`new-workspace-hairline-top`,"data-region":`hairline-top`,className:`mb-5 border-t border-border`}),(0,B.jsxs)(`div`,{"data-testid":`new-workspace-status-strip`,"data-region":`status-strip`,className:`mb-5 flex min-h-12 flex-wrap items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center font-mono text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`mr-2 h-1.5 w-1.5 shrink-0 rounded-full bg-success`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{children:`Memory enabled`}),O.length>0||b.error?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{"data-testid":`new-workspace-status-finding`,className:`text-destructive-foreground`,children:O.map(e=>e.message).join(` · `)||b.error})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:b.mode===`isolated`?`Isolated worktree`:`Files shared`}),(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:b.intent?.isGitRepository?`git repository`:`no git detected`}),b.intent?.path&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:b.intent.path})]}),b.intent?.branchName&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsxs)(`span`,{children:[`creates `,b.intent.branchName]})]}),b.intent?.wouldCreateWorktree&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:`worktree`})]}),b.intent?.unregisteredTargetPath&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{className:`text-destructive-foreground`,children:`unregistered target`})]}),k&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsxs)(`span`,{"data-testid":`new-workspace-status-parent`,children:[`parent `,k,A?` (inferred)`:``]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-cancel`,onClick:()=>{window.history.state?.tab===`workspace-new`&&window.history.length>1?window.history.back():e?e():(window.history.replaceState({tab:`home`},``,`/`),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`eyebrow bg-transparent px-2 py-2 text-muted-foreground hover:text-foreground`,children:`Cancel`}),(0,B.jsxs)(`button`,{type:`submit`,"data-testid":`new-workspace-submit`,disabled:!b.canCreate,className:`inline-flex h-12 items-center gap-3 rounded-xl bg-primary/15 px-5 text-sm font-semibold text-primary transition-colors hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-40`,children:[`Start workspace`,(0,B.jsx)(`span`,{className:`inline-grid h-6 min-w-6 place-items-center rounded-md bg-foreground/10 px-1.5 font-mono text-xs`,children:`↵`})]})]})]}),(0,B.jsx)(`div`,{"data-testid":`new-workspace-hairline-bottom`,"data-region":`hairline-bottom`,className:`mb-8 border-t border-border`}),(0,B.jsxs)(`div`,{"data-testid":`new-workspace-idea-grid`,"data-region":`idea-grid`,className:`min-h-48 flex-1`,children:[(0,B.jsx)(`h2`,{className:`eyebrow mb-4 font-mono`,children:`Ideas for your next workspace`}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3`,children:K5t.map(([e,t])=>(0,B.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-idea-card`,onClick:()=>{b.setName(t),n.current?.focus()},className:`flex min-h-28 flex-col gap-2 rounded-xl border border-transparent bg-foreground/[0.03] p-4 text-left transition-colors hover:bg-foreground/[0.055] active:scale-[0.985]`,children:[(0,B.jsx)(`span`,{className:`eyebrow font-mono`,children:e}),(0,B.jsx)(`span`,{className:`text-sm leading-relaxed text-foreground`,children:t})]},e))})]})]}),(0,B.jsx)(Lvt,{isOpen:o,onClose:()=>s(!1),onCreated:e=>{i.setQueryData([`registered-projects`],(t=[])=>[e,...t.filter(t=>t.key!==e.key)]),i.invalidateQueries({queryKey:[`registered-projects`],refetchType:`none`}),b.setProjectKey(e.key),s(!1)}})]})}function J5t(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Y5t(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function X5t(e){return e/100*window.innerHeight}function Z5t(e){return e/100*window.innerWidth}function Q5t(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 u9({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Q5t(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Y5t(t,i);break;case`em`:r=J5t(t,i);break;case`vh`:r=X5t(i);break;case`vw`:r=Z5t(i);break}return r}function d9(e){return parseFloat(e.toFixed(3))}function f9({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 p9(e){let{panels:t}=e,n=f9({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=d9(u9({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=d9(u9({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=d9(u9({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=d9(u9({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 m9(e,t=`Assertion error`){if(!e)throw Error(t)}function h9(e,t){return Array.from(t).sort(e===`horizontal`?$5t:e7t)}function $5t(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function e7t(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function t7t(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function n7t(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 r7t({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}=n7t(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return m9(i,`No rect found`),i}var g9;function i7t(){return g9===void 0&&(g9=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),g9}function a7t(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=h9(n,Array.from(t.children).filter(t7t).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,r7t({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=i7t()?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:f9({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 o7t=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)}}},_9=new Map,s7t=new o7t;function c7t(e){_9=new Map(_9),_9.delete(e)}function l7t(e,t){for(let[t]of _9)if(t.id===e)return t}function v9(e,t){for(let[t,n]of _9)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function y9(){return _9}function b9(e,t){return s7t.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function x9(e,t){let n=_9.get(e);_9=new Map(_9),_9.set(e,t),s7t.emit(`groupChange`,{group:e,prev:n,next:t})}function u7t(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=n7t(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 d7t(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function f7t(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:v7t(e),b:v7t(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();m9(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:_7t(g7t(n.a)),b:_7t(g7t(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 p7t=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function m7t(e){let t=getComputedStyle(y7t(e)??e).display;return t===`flex`||t===`inline-flex`}function h7t(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||m7t(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`||p7t.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function g7t(e){let t=e.length;for(;t--;){let n=e[t];if(m9(n,`Missing node`),h7t(n))return n}return null}function _7t(e){return e&&Number(getComputedStyle(e).zIndex)||0}function v7t(e){let t=[];for(;e;)t.push(e),e=y7t(e);return t}function y7t(e){let{parentNode:t}=e;return d7t(t)?t.host:t}function b7t(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 x7t({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!t7t(n)||n.contains(e)||e.contains(n))return!0;if(f7t(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(b7t(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function S9(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=a7t(r),a=u7t(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&x7t({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function S7t(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 C9(e,t,n=0){return Math.abs(d9(e)-d9(t))<=n}function w9(e,t){return C9(e,t)?0:e>t?1:-1}function T9({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(w9(r,c)<0)if(a){let e=(i+c)/2;r=w9(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=d9(r),r}function E9({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(C9(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;m9(u!=null,`Invalid first pivot index`),m9(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];m9(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(m9(n!=null,`Previous layout not found for panel index ${t}`),C9(n,i)){let t=o-n;w9(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];m9(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(m9(n!=null,`Previous layout not found for panel index ${t}`),C9(n,o)){let t=n-i;w9(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];m9(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&w9(i,c)<0)if(e>0){let t=c-o,n=t/2;w9(i+e,c)<0&&(e=w9(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;w9(i-e,c)<0&&(e=w9(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];m9(e!=null,`Previous layout not found for panel index ${r}`);let a=T9({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];m9(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=T9({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!C9(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(S7t(c,l))return i;{let t=e<0?d:u,r=s[t];m9(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=T9({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!C9(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];m9(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=T9({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(C9(i,s)||(t-=s-i,l[r]=s),C9(t,0))break;e>0?r--:r++}}}if(!C9(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 D9(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||w9(e[n],t[n])!==0)return!1;return!0}function O9({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(!C9(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];m9(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];m9(i!=null,`No layout data found for index ${e}`);let o=r[e];m9(o!=null,`No layout data found for index ${e}`);let s=T9({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!C9(a,0))for(let e=0;e<t.length;e++){let n=r[e];m9(n!=null,`No layout data found for index ${e}`);let i=n+a,o=T9({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,C9(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function C7t({groupId:e,panelId:t}){let n=()=>{let t=y9();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=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&C9(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:d9(100-e)}}return E9({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=O9({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});D9(c,u)||x9(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(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&&C9(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=f9({group:t});s(d9(u9({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function w7t(e){e.defaultPrevented||S9(e,y9()).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=C7t({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function k9(e){let t=y9();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 T7t({groupId:e}){let t=()=>{let t=y9();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=O9({layout:e,panelConstraints:r});return n?o:(D9(o,c)||x9(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function A9(e,t){let n=k9(e),r=v9(n.id,!0),i=n.separators.find(t=>t.element===e);m9(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);m9(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=T7t({groupId:n.id}).getLayout(),c=O9({layout:E9({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});D9(s,c)||x9(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function E7t(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=k9(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&A9(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&A9(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&A9(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&A9(t,-5);break;case`End`:e.preventDefault(),A9(t,100);break;case`Enter`:{e.preventDefault();let n=k9(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=v9(n.id,!0),o=n.separators.find(e=>e.element===t);m9(o,`Matching separator not found`);let s=a.get(o);m9(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(m9(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];A9(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=k9(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);m9(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(),A9(t,-100);break}}var j9={cursorFlags:0,state:`inactive`},M9=new o7t;function N9(){return j9}function D7t(e){return M9.addListener(`change`,e)}function O7t(e){let t=j9,n={...j9};n.cursorFlags=e,j9=n,M9.emit(`change`,{prev:t,next:n})}function P9(e){let t=j9;j9=e,M9.emit(`change`,{prev:t,next:e})}function k7t(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=y9(),n=S9(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),P9({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var A7t=e=>e,F9=()=>{},j7t=1,M7t=2,N7t=4,P7t=8,F7t=3,I7t=12,I9;function L7t(){return I9===void 0&&(I9=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(I9=!0)),I9}function R7t({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&&L7t()){let t=(e&j7t)!==0,n=(e&M7t)!==0,r=(e&N7t)!==0,i=(e&P7t)!==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 L7t()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var z7t=new WeakMap;function L9(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=z7t.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=N9();switch(r.state){case`active`:case`hover`:{let e=R7t({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}z7t.set(e,{prevStyle:t,styleSheet:n})}function B7t({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=E9({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(D9(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?j7t:M7t;break;case`vertical`:s|=d<0?N7t:P7t;break}}else x9(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&F7t:c|=s&F7t,t.movementY===0?c|=o&I7t:c|=s&I7t,O7t(c),L9(e)}function V7t(e){let t=y9(),n=N9();switch(n.state){case`active`:B7t({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function H7t(e){if(e.defaultPrevented)return;let t=N9(),n=y9();switch(t.state){case`active`:if(e.buttons===0){P9({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=v9(e.group.id,!0);x9(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)}B7t({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=S9(e,n);r.length===0?t.state!==`inactive`&&P9({cursorFlags:0,state:`inactive`}):P9({cursorFlags:0,hitRegions:r,state:`hover`}),L9(e.currentTarget);break}}}function U7t(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(N9().state){case`hover`:P9({cursorFlags:0,state:`inactive`})}}function W7t(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=N9();switch(t.state){case`active`:P9({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(L9(e.currentTarget),t.hitRegions.forEach(e=>{let t=v9(e.group.id,!0);x9(e.group,t)}),e.preventDefault())}}function G7t(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=d9(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=d9((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function K7t(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=f9({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:d9(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function q7t(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 J7t({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=d9(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]=d9((r[e]??0)/a*l);else{let e=d9(l/c.length);for(let t of c)u[t]=e}return u}function Y7t(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 R9=new Map;function X7t(e){let t=!0;m9(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=f9({group:e});if(t===0)return;let n=v9(e.id);if(!n)return;let r=p9(e),i=n.defaultLayoutDeferred?G7t(r):n.layout,a=O9({layout:J7t({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&D9(n.layout,a)&&q7t(n.derivedPanelConstraints,r)&&n.groupSize===t)return;x9(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else K7t(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{m9(!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=f9({group:e}),s=p9(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Y7t(e.panels,l)||(l=void 0));let u=O9({layout:e.mutableState.layouts[c]??l??G7t(s),panelConstraints:s}),d=e.element.ownerDocument;R9.set(d,(R9.get(d)??0)+1);let f=new Map;return a7t(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),x9(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{m9(!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`,E7t)}),R9.get(d)===1&&(d.addEventListener(`dblclick`,w7t,!0),d.addEventListener(`pointerdown`,k7t,!0),d.addEventListener(`pointerleave`,V7t),d.addEventListener(`pointermove`,H7t),d.addEventListener(`pointerout`,U7t),d.addEventListener(`pointerup`,W7t,!0)),function(){t=!1,R9.set(d,Math.max(0,(R9.get(d)??0)-1)),c7t(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,E7t)}),R9.get(d)||(d.removeEventListener(`dblclick`,w7t,!0),d.removeEventListener(`pointerdown`,k7t,!0),d.removeEventListener(`pointerleave`,V7t),d.removeEventListener(`pointermove`,H7t),d.removeEventListener(`pointerout`,U7t),d.removeEventListener(`pointerup`,W7t,!0)),a.disconnect()}}function Z7t(){let[e,t]=(0,z.useState)({});return[e,(0,z.useCallback)(()=>t({}),[])]}function z9(e){let t=(0,z.useId)();return`${e??t}`}var B9=typeof window<`u`?z.useLayoutEffect:z.useEffect;function V9(e){let t=(0,z.useRef)(e);return B9(()=>{t.current=e},[e]),(0,z.useCallback)((...e)=>t.current?.(...e),[t])}function H9(...e){return V9(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function U9(e){let t=(0,z.useRef)({...e});return B9(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Q7t=(0,z.createContext)(null);function $7t(e,t){let n=(0,z.useRef)({getLayout:()=>({}),setLayout:A7t});(0,z.useImperativeHandle)(t,()=>n.current,[]),B9(()=>{Object.assign(n.current,T7t({groupId:e}))})}function e9t({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,z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=V9(e=>{D9(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=V9(e=>{D9(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=z9(s),v=(0,z.useRef)(null),[y,b]=Z7t(),x=(0,z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=H9(v,a);$7t(_,o);let C=V9((e,t)=>{let r=N9(),i=l7t(e),a=v9(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=U9({defaultLayout:n,disableCursor:r}),T=(0,z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=h9(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=h9(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=l7t(_),i=v9(_);r&&i&&x9(r,{...i,derivedPanelConstraints:p9(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,z.useRef)(null);return B9(()=>{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=X7t(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=v9(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=b9(_,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=C9(t.collapsedSize,i[t.panelId]),a=C9(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=N9().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,B.jsx)(Q7t.Provider,{value:T,children:(0,B.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})})}e9t.displayName=`Group`;function W9(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function t9t({id:e,panelIds:t,storage:n}){let r=W9(e,[]),i=n.getItem(r);if(i)try{let e=JSON.parse(i);if(t){let n=e[t.join(`,`)];if(n&&Array.isArray(n.layout)&&t.length===n.layout.length){let e={};for(let r=0;r<t.length;r++)e[t[r]]=n.layout[r];return e}}else{let t=Object.keys(e);if(t.length===1){let n=e[t[0]];if(n&&Array.isArray(n.layout)){let e=t[0].split(`,`);if(e.length===n.layout.length){let t={};for(let r=0;r<e.length;r++)t[e[r]]=n.layout[r];return t}}}}}catch{}}function n9t({debounceSaveMs:e=100,panelIds:t,storage:n=localStorage,...r}){let i=t!==void 0,a=`id`in r?r.id:r.groupId,o=W9(a,t??[]),s=(0,z.useSyncExternalStore)(r9t,()=>n.getItem(o),()=>n.getItem(o)),c=(0,z.useMemo)(()=>{if(s){let e=JSON.parse(s),t=Object.values(e);if(Array.from(t).every(e=>typeof e==`number`))return e}},[s]),l=(0,z.useMemo)(()=>{if(!c)return t9t({id:a,panelIds:t,storage:n})},[c,a,t,n]),u=c??l,d=(0,z.useRef)(null),f=(0,z.useCallback)(()=>{let e=d.current;e&&(d.current=null,clearTimeout(e))},[]);(0,z.useLayoutEffect)(()=>()=>{f()},[f]);let p=(0,z.useCallback)(e=>{f();let t;t=i?W9(a,Object.keys(e)):W9(a,[]);try{n.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[f,i,a,n]);return{defaultLayout:u,onLayoutChange:(0,z.useCallback)(t=>{f(),e===0?p(t):d.current=setTimeout(()=>{p(t)},e)},[f,e,p]),onLayoutChanged:p}}function r9t(){return function(){}}function G9(){let e=(0,z.useContext)(Q7t);return m9(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function i9t(e,t){let{id:n}=G9(),r=(0,z.useRef)({collapse:F9,expand:F9,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:F9});(0,z.useImperativeHandle)(t,()=>r.current,[]),B9(()=>{Object.assign(r.current,C7t({groupId:n,panelId:e}))})}function K9({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=z9(c),_=U9({disabled:a}),v=(0,z.useRef)(null),y=H9(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=G9(),T=d!==null,E=V9((e,t,n)=>{d?.(e,c,n)});B9(()=>{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,z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),i9t(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,z.useSyncExternalStore)(e=>b9(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,B.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...a9t,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,B.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}K9.displayName=`Panel`;var a9t={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function o9t({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=O9({layout:E9({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=O9({layout:E9({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function q9({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=z9(a),l=U9({disabled:n,disableDoubleClick:r}),[u,d]=(0,z.useState)({}),[f,p]=(0,z.useState)(`inactive`),[m,h]=(0,z.useState)(!1),g=(0,z.useRef)(null),_=H9(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=G9(),C=b===`horizontal`?`vertical`:`horizontal`;B9(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=D7t(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=b9(y,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(o9t({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,z.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,B.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}q9.displayName=`Separator`;function s9t(e,t){return e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)}function c9t({workspaceId:e,onBack:t}){let{data:n}=V({queryKey:[`workspace-registry`,e],queryFn:async()=>{let t=await fetch(`/api/workspace-registry/${e}`);return t.ok?t.json():null}}),{data:r}=V({queryKey:[`workspace-registry`,e,`memory`],queryFn:async()=>{let t=await fetch(`/api/workspace-registry/${e}/memory`);return t.ok?t.json():null},refetchInterval:15e3,enabled:!!n}),{data:i}=V({queryKey:[`workspace-plan`,n?.issueId],queryFn:async()=>{if(!n?.issueId)return null;let e=await fetch(`/api/workspaces/${n.issueId}/plan`);return e.ok?e.json():null},enabled:!!n?.issueId}),{data:a}=V({queryKey:[`conversations`],queryFn:dO,refetchInterval:1e4}),o=Array.isArray(a)?a:[],[s,c]=(0,z.useState)(!1),l=(0,z.useMemo)(()=>{if(s||!n)return;let t=new Set;for(let r of o)(r.workspaceId==null?s9t(r.cwd,n.path):r.workspaceId===e)&&t.add(r.id);return t},[s,n,e,o]),u=jLe(e),d=(0,z.useCallback)(t=>{OLe(e,t)},[e]),[f,p]=(0,z.useState)(null),m=o.find(e=>e.name===f)??null,h=Q(cS),g=(0,z.useMemo)(()=>{if(!n?.issueId)return null;let e=n.issueId.toLowerCase();return h.find(t=>t.issueId?.toLowerCase()===e)??null},[h,n]),_=(0,z.useMemo)(()=>{let t=n?.layoutConfig??null;return{getItem:()=>t,setItem:(n,r)=>{t=r;let i;try{i=JSON.parse(r)}catch{return}fetch(`/api/workspace-registry/${e}/layout`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({layout:i})})}}},[e,n!==void 0]),{defaultLayout:v,onLayoutChanged:y}=n9t({id:`workspace-${e}`,storage:_}),b=yt(),x=ul(),[S,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(null),E=(0,z.useCallback)(()=>{b.invalidateQueries({queryKey:[`workspace-registry`]}),b.invalidateQueries({queryKey:[`workspace-registry`,e]})},[b,e]),D=(0,z.useCallback)(async(t,n)=>{T(null);try{let r=await vl(`/api/workspace-registry/${e}${t}`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(n)});return r.ok?(E(),!0):(T((await r.json().catch(()=>({}))).error??`HTTP ${r.status}`),!1)}catch(e){return T(e instanceof Error?e.message:String(e)),!1}},[e,E]),O=(0,z.useCallback)(()=>{D(`/favorite`,{favorite:!n?.isFavorite})},[D,n?.isFavorite]),k=(0,z.useCallback)(async()=>{await x({title:`Archive workspace`,message:`Archive '${n?.name}'? It disappears from the rail but its files, branch and memory are left untouched.`,confirmLabel:`Archive`,variant:`destructive`})&&D(`/archive`,{archived:!0})},[x,D,n?.name]),A=(0,z.useCallback)(async e=>{C(!1);let t=n?.kind===`main`;await x({title:`Relocate workspace`,message:t?`Point the main workspace at ${e}? Its path will diverge from projects.yaml's primary path.`:`Point '${n?.name}' at ${e}?`,confirmLabel:`Relocate`,...t?{variant:`destructive`,requiredText:n?.name??`main`}:{}})&&D(`/relocate`,t?{path:e,force:!0}:{path:e})},[x,D,n?.kind,n?.name]);return n?(0,B.jsxs)(`div`,{className:`flex flex-col w-full h-full overflow-hidden`,"data-testid":`workspace-view`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-border shrink-0`,children:[t&&(0,B.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`workspace-view-back`,className:`text-muted-foreground hover:text-foreground text-sm`,children:`← Back`}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:n.title??n.name}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:n.kind}),n.kind!==`issue`&&(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,"data-testid":`workspace-view-actions`,children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-favorite`,onClick:O,"aria-pressed":n.isFavorite,className:`text-xs text-muted-foreground hover:text-foreground`,children:n.isFavorite?`Unfavorite`:`Favorite`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-relocate`,onClick:()=>C(e=>!e),className:`text-xs text-muted-foreground hover:text-foreground`,children:`Relocate`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-archive`,onClick:()=>void k(),className:`text-xs text-destructive hover:brightness-110`,children:`Archive`})]})]}),S&&n.kind!==`issue`&&(0,B.jsx)(`div`,{className:`border-b border-border px-4 py-2 shrink-0`,"data-testid":`workspace-view-relocate-picker`,children:(0,B.jsx)(AQ,{onSelect:e=>void A(e),initialPath:n.path})}),w&&(0,B.jsx)(`div`,{className:`border-b border-border px-4 py-2 text-xs text-destructive shrink-0`,"data-testid":`workspace-view-action-error`,children:w}),(0,B.jsx)(MLe,{workspaceId:e,kind:n.kind,issueId:n.issueId,isGitRepository:n.isGitRepository!==!1,runCommand:n.runCommand??null,runCommandDefault:n.runCommandDefault??null,runCommandOptions:n.runCommandOptions??[],openInEditorConfigured:n.openInEditorConfigured===!0,runSessionName:u,onRunSessionChange:d},e),n.kind===`issue`&&n.issueId&&(0,B.jsxs)(`div`,{className:`border-b border-border p-3 space-y-3 shrink-0 max-h-64 overflow-y-auto`,"data-testid":`workspace-view-issue-panels`,children:[(0,B.jsx)(XZ,{issueId:n.issueId}),(0,B.jsx)(rZ,{doc:i??null,showTabBar:!1})]}),(0,B.jsxs)(e9t,{orientation:`horizontal`,defaultLayout:v,onLayoutChanged:y,className:`flex-1 min-h-0`,id:`workspace-${e}`,children:[(0,B.jsxs)(K9,{id:`terminal`,defaultSize:34,minSize:15,className:`min-w-0 h-full overflow-hidden flex flex-col`,children:[g?(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(KP,{sessionName:g.id,embedded:!0})}):u?null:(0,B.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,"data-testid":`workspace-view-no-terminal`,children:`No active agent terminal for this workspace.`}),u&&(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col border-t border-border first:border-t-0`,"data-testid":`workspace-view-run-terminal`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground px-3 py-1 shrink-0`,children:`Run`}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(KP,{sessionName:u,embedded:!0})})]})]}),(0,B.jsx)(q9,{className:`w-px bg-border`}),(0,B.jsxs)(K9,{id:`conversations`,defaultSize:33,minSize:15,className:`min-w-0 h-full overflow-hidden flex flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground`,children:`Conversations`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-all-conversations-toggle`,onClick:()=>c(e=>!e),className:`text-[10px] text-muted-foreground hover:text-foreground`,children:s?`This workspace`:`All conversations`})]}),(0,B.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:m?(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-conversation-back`,onClick:()=>p(null),className:`text-left px-3 py-1.5 text-[11px] text-muted-foreground hover:text-foreground border-b border-border shrink-0`,children:`← All conversations`}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(QX,{conversation:m,embedded:!0})})]}):(0,B.jsx)(UGe,{selectedConversation:f,onSelectConversation:p,includeIds:l})})]}),(0,B.jsx)(q9,{className:`w-px bg-border`}),(0,B.jsxs)(K9,{id:`memory`,defaultSize:33,minSize:15,className:`min-w-0 h-full overflow-y-auto p-3`,children:[(0,B.jsxs)(`p`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground mb-2`,children:[`Memory`,r?.status&&(0,B.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/70`,"data-testid":`workspace-view-memory-phase`,children:[r.status.phase,typeof r.status.confidence==`number`&&` · confidence ${r.status.confidence}`]})]}),r?.status?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`workspace-view-memory-status`,children:[(0,B.jsx)(`p`,{className:`text-sm text-foreground`,children:r.status.headline}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.status.summary}),r.status.nextSteps.length>0&&(0,B.jsx)(`ul`,{className:`text-xs text-muted-foreground list-disc pl-4`,children:r.status.nextSteps.map(e=>(0,B.jsx)(`li`,{children:e},e))})]}):(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`No memory status yet.`}),(0,B.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground mt-4 mb-2`,children:`Observations`}),(0,B.jsx)(`ul`,{className:`space-y-2`,"data-testid":`workspace-view-observation-timeline`,children:(r?.observations??[]).map(e=>(0,B.jsxs)(`li`,{className:`text-xs text-muted-foreground border-l-2 border-border pl-2`,children:[(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.timestamp}),(0,B.jsx)(`p`,{className:`text-foreground`,children:e.actionStatus??e.summary})]},e.id))})]})]})]}):(0,B.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,"data-testid":`workspace-view-loading`,children:`Loading workspace…`})}function l9t({backendDown:e,restarting:t,children:n}){let[r,i]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let e=()=>i(!0),t=()=>i(!1);return window.addEventListener(bS,e),window.addEventListener(xS,t),()=>{window.removeEventListener(bS,e),window.removeEventListener(xS,t)}},[]),!e&&!t&&!r?n:(0,B.jsx)(`div`,{role:`status`,className:`flex h-full w-full items-center justify-center bg-background p-8`,children:(0,B.jsxs)(`div`,{className:`flex max-w-md items-start gap-3 text-left`,children:[(0,B.jsx)(Mc,{className:`mt-0.5 h-5 w-5 shrink-0 animate-spin text-primary`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:t?`Dashboard is restarting`:`Waiting for backend data`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Live data will return automatically when the backend connection is restored.`})]})]})})}function u9t({activeTab:e,backendDown:t,restarting:n,issues:r,selectedConvId:i,conversationViewMode:a,selectedProjectKey:o,pendingConversationTarget:s,cockpitRoute:c,workspaceRouteId:l,onWorkspaceViewBack:u,onWorkspaceCreated:d,initialSessionKey:f,onOpenWorkspaceHome:p,onNewProject:m,onSelectProject:h,onOpenSettings:g,onConvIdChange:_,onConversationViewModeChange:v,onPendingConversationTargetConsumed:y,onProjectPrefixChange:b,onCockpitChange:x,onSearchOpen:S,onTabChange:C,onOpenIssue:w,onPlanDialogChange:T,onSelectAgent:E,onBacklogIssueAction:D,keyboardShortcutsDisabled:O=!1}){return(0,B.jsxs)(l9t,{backendDown:t,restarting:n,children:[e===`home`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(g$t,{advanced:(0,B.jsx)(C5t,{onOpenWorkspaceHome:p,onNewProject:m,onSelectProject:h,onOpenSettings:g})})}),e===`command-deck`&&(0,B.jsx)(`div`,{className:`w-full h-full`,children:(0,B.jsx)(gHt,{issues:r,convId:i,conversationViewMode:a,onConvIdChange:_,onConversationViewModeChange:v,pendingConversationTarget:s,onPendingConversationTargetConsumed:y,selectedProject:o,onSelectProject:h,onProjectPrefixChange:b,cockpitIssue:c,onCockpitChange:x})}),e===`workspace-new`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(q5t,{onCancel:()=>C(`home`),onCreated:d})}),e===`workspace`&&l&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(c9t,{workspaceId:l,onBack:u})}),e===`pipeline`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(y$t,{}),children:(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(rUt,{onSearchOpen:S,onTabChange:e=>C(e),keyboardShortcutsDisabled:O})})}),e===`awaiting-merge`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-auto`,children:(0,B.jsx)(DWt,{})}),e===`kanban`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:(0,B.jsx)(_$t,{})}),children:(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:[(0,B.jsx)(rTt,{}),(0,B.jsx)(CCt,{selectedIssue:null,onSelectIssue:e=>{e&&w(e)},onPlanDialogChange:T,keyboardShortcutsDisabled:O})]})})}),e===`agents`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(v$t,{}),children:(0,B.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,B.jsx)(dwt,{onNavigateToIssues:()=>C(`kanban`)})})}),e===`resources`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(AGt,{onNavigateToAgents:e=>{E(e),C(`agents`)}})}),e===`knowledge`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(VZt,{projectKey:o})}),e===`skills`&&(0,B.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,B.jsx)(zwt,{})}),e===`context`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(FZt,{})}),e===`health`&&(0,B.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,B.jsx)(Rwt,{})}),e===`activity`&&(0,B.jsx)(`div`,{className:`w-full h-full`,children:(0,B.jsx)(tTt,{onClose:()=>C(`kanban`)})}),e===`metrics`&&(0,B.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,B.jsx)(oTt,{})}),e===`costs`&&(0,B.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,B.jsx)(Hjt,{})}),e===`autopreso`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(AQt,{})}),e===`flywheel`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(vWt,{onOpenSettings:g,onNavigateAgent:e=>{E(e),C(`agents`)},onNavigateIssue:e=>w(e)})}),e===`orders`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(e1t,{})}),e===`backlog`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(m5t,{onIssueAction:D})}),e===`settings`&&(0,B.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,B.jsx)(FPt,{})}),e===`sessions`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(bQt,{initialSessionKey:f})}),e===`god-view`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,B.jsx)(b$t,{})}),children:(0,B.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,B.jsx)(GYt,{})})}),e===`deacon`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(rXt,{})})]})}var J9=[`boot-reconciliation`];async function d9t(){let e=await fetch(`/api/boot-reconciliation`);if(!e.ok)throw Error(`GET /api/boot-reconciliation -> ${e.status}`);return e.json()}async function f9t(e){let t=await fetch(`/api/boot-reconciliation/decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`POST /api/boot-reconciliation/decision -> ${t.status}`)}return t.json()}async function p9t(){let e=await fetch(`/api/boot-reconciliation/extend`,{method:`POST`});if(!e.ok)throw Error(`POST /api/boot-reconciliation/extend -> ${e.status}`)}function m9t(e={},t=0){let n=[[`workspace_missing`,`workspace missing`],[`merged`,`already merged`],[`completed`,`completed`],[`other`,`not resumable`]].map(([t,n])=>({count:e[t]??0,label:n})).filter(e=>e.count>0).map(e=>`${e.count} ${e.label}`);return t>0&&n.push(`${t} deferred`),n.join(`, `)}function h9t(e){switch(e){case`already-running`:return`already running`;case`no-resumable-session`:return`no resumable session`;case`deferred-concurrency`:return`deferred by concurrency limit`;case`deferred-load`:return`deferred by load gate`;case`deferred-memory`:return`deferred by memory gate`;case`resumed`:return`resumed`;default:return e.replaceAll(`-`,` `)}}function g9t(e){if(e.skipped||e.deferred){let t=m9t(e.skipped,e.deferred??0);return e.count>0?`Boot decision saved. Resuming ${e.count} agent${e.count===1?``:`s`}.${t?` Also skipped ${t}.`:``}`:`Boot decision saved. No agents resumed${t?` — ${t}`:``}.`}let t=Array.isArray(e.outcomes)?e.outcomes.filter(e=>e.outcome===`skipped`):[];if(t.length===0)return`Boot decision saved. Resumed ${e.count} agent${e.count===1?``:`s`}.`;let n=new Map;for(let e of t)n.set(e.reason,(n.get(e.reason)??0)+1);let r=Array.from(n.entries()).map(([e,t])=>`${t} ${h9t(e)}`).join(`, `);return`Boot decision saved. Resumed ${e.count} — ${t.length} skipped (${r}).`}async function _9t(){let e=await fetch(`/api/deacon/pause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paused:!0})});if(!e.ok)throw Error(`POST /api/deacon/pause -> ${e.status}`);return e.json()}function v9t(e){if(!e)return`startup`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function y9t(e){if(!e)return`unknown`;let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=Math.max(0,Math.round((Date.now()-t.getTime())/1e3));if(n<60)return`${n}s ago`;let r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function b9t(e){let[t,n]=(0,z.useState)(Date.now());if((0,z.useEffect)(()=>{let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[]),!e)return 0;let r=Date.parse(e)-t;return Math.max(0,Math.ceil(r/1e3))}function x9t(e){let t=Math.max(0,Math.ceil(e)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function S9t(e){switch(e){case`running_remote`:return`Running remote ($)`;case`orphaned`:return`Orphaned (tmux gone)`;case`paused_troubled`:return`Paused / troubled`;default:return`Stopped cleanly`}}var C9t=[`running_remote`,`orphaned`,`stopped_cleanly`,`paused_troubled`];function w9t(){let e=yt(),t=dl(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)({}),{data:o}=V({queryKey:J9,queryFn:d9t,staleTime:5e3,refetchInterval:e=>{let t=e.state.data?.decision;return t===`pending`?1e4:t===`hold_all`||t===`per_agent`?3e4:!1},refetchOnWindowFocus:!0});(0,z.useEffect)(()=>{let t=()=>{e.invalidateQueries({queryKey:J9})};return window.addEventListener(`overdeck:reconnected`,t),()=>window.removeEventListener(`overdeck:reconnected`,t)},[e]),(0,z.useEffect)(()=>{if(!o)return;let e=Array.isArray(o.set)?o.set:[],t=o.perAgent??{};a(Object.fromEntries(e.filter(e=>!e.readOnly).map(e=>[e.issueId,t[e.issueId]??(e.stoppedByUser?`hold`:`resume`)])))},[o]);let s=Mt({mutationFn:f9t,onSuccess:n=>{e.invalidateQueries({queryKey:J9}),e.invalidateQueries({queryKey:[`agents`]}),t({message:g9t(n),variant:`success`})},onError:e=>{t({message:`Boot reconciliation failed: ${e.message}`,variant:`error`})}}),c=Mt({mutationFn:_9t,onSuccess:()=>{e.invalidateQueries({queryKey:[`deacon`,`pause`]}),s.mutate({decision:`hold_all`})},onError:e=>{t({message:`Freeze failed: ${e.message}`,variant:`error`})}}),l=(0,z.useMemo)(()=>{let e=new Map;for(let t of C9t)e.set(t,[]);let t=Array.isArray(o?.set)?o.set:[];for(let n of t)e.get(n.concern)?.push(n);return e},[o?.set]),u=b9t(o?.graceDeadline??null),d=jG().length>0,f=o?.graceExtensions??0,p=o?.maxGraceExtensions??0,m=d&&f<p;if((0,z.useEffect)(()=>{o?.decision!==`pending`||!d||f>=p||u>30||p9t().then(()=>{e.invalidateQueries({queryKey:J9})}).catch(()=>{})},[o?.decision,d,f,p,u,e]),o&&(o.decision===`hold_all`||o.decision===`per_agent`)){let e=o.perAgent??{},t=(Array.isArray(o.set)?o.set:[]).filter(t=>!t.readOnly&&(o.decision!==`per_agent`||e[t.issueId]!==`resume`));if((o.heldCount??0)===0)return null;let n=s.isPending;return(0,B.jsxs)(`div`,{className:`badge-bg-warning badge-border-warning flex items-center gap-2 border-b px-4 py-1.5`,"data-testid":`boot-reconciliation-held-banner`,children:[(0,B.jsx)(Oc,{className:`w-4 h-4 shrink-0 text-warning`}),(0,B.jsxs)(`p`,{className:`flex-1 truncate text-xs font-medium text-warning-foreground`,title:`Boot reconciliation is holding ${t.length} stopped agent${t.length===1?``:`s`} from the boot at ${v9t(o.decidedAt??o.graceDeadline)}. Held agents will not pick up work until resumed. Resume all puts them back to work; pan start <id> spawns one individually.`,children:[`Holding `,t.length,` stopped agent`,t.length===1?``:`s`,` from boot — they won't pick up work until resumed`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate({decision:`resume_all`}),disabled:n,"data-testid":`boot-reconciliation-held-resume-all`,className:`inline-flex h-[26px] shrink-0 items-center gap-1.5 rounded-[var(--radius-sm)] bg-warning px-[10px] text-[11px] font-medium text-warning-foreground transition-opacity hover:bg-warning/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),n?`Resuming…`:`Resume all`]})]})}if(o?.decision!==`pending`)return null;let h=(Array.isArray(o.set)?o.set:[]).filter(e=>!e.readOnly).length,g=Array.isArray(o.context)?o.context:[];if(h===0)return null;let _=s.isPending||c.isPending;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[110] flex items-start justify-center overflow-y-auto bg-black/45 px-4 py-8 backdrop-blur-sm`,children:(0,B.jsxs)(`section`,{className:`w-full max-w-5xl rounded-lg border badge-border-warning bg-card text-foreground shadow-2xl`,"data-testid":`boot-reconciliation-modal`,"aria-label":`Boot reconciliation`,children:[(0,B.jsx)(`div`,{className:`border-b badge-border-warning px-5 py-4`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-warning`,children:[(0,B.jsx)(il,{className:`h-4 w-4`}),`Unverified dashboard boot`]}),(0,B.jsx)(`h2`,{className:`mt-1 text-xl font-semibold text-foreground`,children:`Boot Reconciliation`}),(0,B.jsxs)(`p`,{className:`mt-1 max-w-3xl text-sm text-muted-foreground`,children:[h,` stopped `,h===1?`agent is`:`agents are`,` held from the boot at `,v9t(o.decidedAt??o.graceDeadline),`. Resume them now, keep them stopped, or choose per agent. The server timer is authoritative; no agent resumes before this boot decision is applied.`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border badge-border-warning badge-bg-warning px-3 py-2`,children:[(0,B.jsx)(`div`,{className:`grid h-12 w-12 place-items-center rounded-full border-4 border-warning/70 text-sm font-semibold text-warning-foreground`,children:u}),(0,B.jsxs)(`div`,{className:`text-sm`,children:[(0,B.jsxs)(`div`,{className:`font-semibold text-warning-foreground`,children:[`Applying boot default in `,x9t(u)]}),(0,B.jsx)(`div`,{className:`text-xs text-warning-foreground/70`,children:m?`Paused — answer the other open question first (${f}/${p} extensions used).`:`If the timer runs out, clean boots resume and crash boots stay stopped.`})]})]})]})}),(0,B.jsxs)(`div`,{className:`grid gap-4 px-5 py-4`,children:[C9t.map(e=>{let t=l.get(e)??[];return t.length===0?null:(0,B.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/60`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 px-3 py-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:S9t(e)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.length})]}),(0,B.jsx)(`div`,{className:`divide-y divide-border/60`,children:t.map(e=>{let t=i[e.issueId]??`resume`;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-3 px-3 py-2`,"data-testid":`boot-reconciliation-row-${e.issueId}`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-sm font-semibold text-foreground`,children:e.issueId}),(0,B.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:e.role}),e.remote&&(0,B.jsx)(`span`,{className:`rounded border badge-border-success badge-bg-success px-1.5 py-0.5 text-[11px] text-success-foreground`,children:`remote`}),e.readOnly&&(0,B.jsx)(`span`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:`read-only`})]}),(0,B.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.model??`unknown model`,` - `,e.whyStopped,` - last activity `,y9t(e.lastActivity),e.cost==null?``:` - $${e.cost.toFixed(2)}`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n&&!e.readOnly?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>({...t,[e.issueId]:`resume`})),"data-testid":`boot-reconciliation-resume-${e.issueId}`,className:`inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium ${t===`resume`?`bg-success text-success-foreground hover:bg-success/90`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:[(0,B.jsx)(Ac,{className:`h-3.5 w-3.5`}),`Resume`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>({...t,[e.issueId]:`hold`})),"data-testid":`boot-reconciliation-hold-${e.issueId}`,className:`inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium ${t===`hold`?`bg-warning text-warning-foreground hover:bg-warning/90`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:[(0,B.jsx)(Oc,{className:`h-3.5 w-3.5`}),`Keep`]})]}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.readOnly?`Not resumable here`:`Resume candidate`}),(0,B.jsx)(`button`,{type:`button`,disabled:!0,title:`Kill actions are supplied by the remote inventory contract.`,className:`inline-flex h-8 items-center rounded-md border border-border px-2 text-xs text-muted-foreground`,children:`Kill`})]})]},e.id)})})]},e)}),g.length>0&&(0,B.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-background/40`,"data-testid":`boot-reconciliation-context`,children:[(0,B.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-sm text-muted-foreground`,children:[`Not part of this boot decision (`,g.length,`) — paused, troubled, or running remote from earlier sessions`]}),(0,B.jsx)(`div`,{className:`divide-y divide-border/60 border-t border-border/70`,children:g.map(e=>(0,B.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2 px-3 py-2`,"data-testid":`boot-reconciliation-context-row-${e.issueId}`,children:[(0,B.jsx)(`span`,{className:`font-mono text-sm font-semibold text-foreground`,children:e.issueId}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.whyStopped})]},e.id))})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border/70 px-5 py-4`,children:[n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{s.mutate({decision:`per_agent`,perAgent:i})},disabled:_,"data-testid":`boot-reconciliation-apply-per-agent`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-success px-3 text-sm font-semibold text-success-foreground hover:bg-success/90 disabled:opacity-50`,children:[(0,B.jsx)(_s,{className:`h-4 w-4`}),`Apply per-agent choices`]}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Resuming `,Object.values(i).filter(e=>e===`resume`).length,` of `,h,`; read-only rows stay stopped.`]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate({decision:`resume_all`}),disabled:_,"data-testid":`boot-reconciliation-resume-all`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-warning px-3 text-sm font-semibold text-warning-foreground hover:bg-warning/90 disabled:opacity-50`,children:[(0,B.jsx)(Ac,{className:`h-4 w-4`}),`Resume all now`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate({decision:`hold_all`}),disabled:_,"data-testid":`boot-reconciliation-hold-all`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-muted px-3 text-sm font-medium text-foreground hover:bg-muted/80 disabled:opacity-50`,children:[(0,B.jsx)(Oc,{className:`h-4 w-4`}),`Keep all stopped`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),disabled:_,"data-testid":`boot-reconciliation-review-each`,className:`inline-flex h-9 items-center gap-1.5 rounded-md border border-border px-3 text-sm font-medium text-foreground hover:bg-muted disabled:opacity-50`,children:[(0,B.jsx)(Uie,{className:`h-4 w-4`}),`Review each`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c.mutate(),disabled:_,"data-testid":`boot-reconciliation-freeze`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-destructive px-3 text-sm font-semibold text-destructive-foreground hover:bg-destructive/90 disabled:opacity-50`,children:[(0,B.jsx)(Yc,{className:`h-4 w-4`}),`Freeze everything`]})]}),(0,B.jsx)(`div`,{className:`ml-auto max-w-xl text-xs text-muted-foreground`,children:`Freeze uses the existing persisted Deacon pause surface. The boot choice is saved durably, so a watchdog restart does not re-prompt this boot.`})]})]})})}async function T9t(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}function E9t({onOpenSettings:e}){let{data:t}=V({queryKey:[`settings`],queryFn:T9t,retry:!1});return t?.background_ai?.cheap_mode===!0?(0,B.jsxs)(`button`,{type:`button`,"data-testid":`low-cost-mode-pill`,onClick:()=>{Ujt(`background-ai`),e?.()},title:`Background AI (titles, memory, enrichment, narration) is off to save cost. Memory in particular is one of Overdeck's most valuable features — click to choose what runs.`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,B.jsx)(Xs,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Low-cost mode`,(0,B.jsx)(hs,{className:`h-3.5 w-3.5 text-muted-foreground/70`,"aria-hidden":`true`})]}):null}function D9t(e){_vt(e)}function O9t(){let e=MG(),[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);if((0,z.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),e.length===0)return null;let i=`${e.length} decision${e.length===1?``:`s`} waiting on you — click to view`;return(0,B.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),title:i,"aria-label":i,"aria-expanded":t,"data-testid":`decisions-indicator`,className:`inline-flex h-5 items-center gap-1.5 rounded-sm border px-1.5 text-[10px] font-medium badge-bg-warning badge-border-warning text-warning-foreground tabular-nums`,children:[(0,B.jsx)(Bie,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e.length]}),t&&(0,B.jsx)(`div`,{className:`absolute top-full right-0 z-[200] mt-2 w-[26rem] max-h-[70vh] overflow-y-auto rounded-xl border border-border bg-popover p-2 text-sm shadow-lg`,children:(0,B.jsx)(bvt,{onOpenSubject:e=>{D9t(e),n(!1)}})})]})}async function k9t(e){let t=await fetch(`/api/flywheel/current`,{signal:e});if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}function A9t({onActivate:e}){let[t,n]=(0,z.useState)(null);(0,z.useEffect)(()=>{let e=!1,t=0,r=null;(async()=>{r?.abort();let i=new AbortController;r=i;let a=t;try{let o=await k9t(i.signal);!e&&r===i&&t===a&&n(o)}catch{}})();let i=ub(e=>{t+=1,r?.abort(),r=null,n(e)});return()=>{e=!0,t+=1,r?.abort(),i()}},[]);let r=t?.openQuestions?.length??0;if(r===0)return null;let i=`${r} open Flywheel question${r===1?``:`s`} — click to view`;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{JUt(),e()},title:i,"aria-label":i,className:`inline-flex h-5 items-center gap-1.5 rounded-sm border px-1.5 text-[10px] font-medium badge-bg-warning badge-border-warning text-warning-foreground tabular-nums`,children:[(0,B.jsx)(yc,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r]})}async function j9t(){let e=await fetch(`/api/cloister/status`);if(!e.ok)throw Error(`Failed to fetch Cloister status`);return e.json()}async function M9t(){if(!(await fetch(`/api/cloister/start`,{method:`POST`})).ok)throw Error(`Failed to start Cloister`)}async function N9t(){if(!(await fetch(`/api/cloister/stop`,{method:`POST`})).ok)throw Error(`Failed to stop Cloister`)}async function P9t(){let e=await fetch(`/api/cloister/emergency-stop`,{method:`POST`});if(!e.ok)throw Error(`Failed to execute emergency stop`);return e.json()}async function F9t(){let e=await vl(`/api/conversations`);return e.ok?e.json():[]}async function I9t(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`Failed to fetch settings`);return e.json()}async function L9t(){let e=await fetch(`/api/tts/health`);if(!e.ok)throw Error(`Failed to fetch TTS health`);return e.json()}async function R9t(){let e=await fetch(`/api/agents/restart-with-current-config`);if(!e.ok)throw Error(`Failed to fetch restart config list`);let t=await e.json();return{items:t.items||[],changedAgents:t.changedAgents||0}}function z9t(e,t){if(t)return`TTS: Health check failed`;if(!e)return`TTS: Checking daemon`;if(!e.ok)return e.error?`TTS: ${e.error}`:`TTS: Daemon offline`;let n=[e.model===void 0?void 0:`model: ${String(e.model)}`,e.queueDepth===void 0?e.queue===void 0?void 0:`queue: ${String(e.queue)}`:`queue: ${String(e.queueDepth)}`,typeof e.pid==`number`?`pid: ${e.pid}`:void 0,e.gpuMemoryUsedMb===void 0?void 0:`VRAM: ${e.gpuMemoryUsedMb}MB`].filter(Boolean);return n.length>0?`TTS: Running (${n.join(`, `)})`:`TTS: Running`}function B9t({onOpenSettings:e}){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!0),[s,c]=(0,z.useState)(!0),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(new Set),h=(0,z.useRef)(null),g=(0,z.useRef)(null),[_,v]=(0,z.useState)(null),y=yt(),{data:b,refetch:x}=V({queryKey:[`cloister-status`],queryFn:j9t,refetchInterval:1e4}),{data:S}=V({queryKey:[`specialists-raw`],queryFn:async()=>{let e=await fetch(`/api/specialists`);return e.ok?e.json():null},refetchInterval:3e4}),{data:C=[]}=V({queryKey:[`conversations`],queryFn:F9t,refetchInterval:1e4}),{data:w}=V({queryKey:[`settings`],queryFn:I9t,retry:!1}),T=w?.tts?.enabled===!0,{data:E,isError:D}=V({queryKey:[`tts-health`],queryFn:L9t,enabled:T,refetchInterval:1e4,retry:!1}),{data:O}=V({queryKey:[`restart-config-list`],queryFn:R9t,enabled:d,refetchInterval:5e3}),k=Q(cS).filter(e=>e.status===`running`).length,A=C.filter(e=>e.sessionAlive).length,j=(S?.projects??[]).filter(e=>e.isRunning),M=(0,z.useCallback)(()=>{if(g.current){let e=g.current.getBoundingClientRect();v({left:e.left,bottom:window.innerHeight-e.top+8})}i(!0)},[]);(0,z.useEffect)(()=>{if(!r)return;let e=e=>{h.current&&!h.current.contains(e.target)&&g.current&&!g.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let N=Mt({mutationFn:async({convs:e,doAgents:t})=>{let n=[];e&&n.push(fetch(`/api/conversations/restart-all`,{method:`POST`})),t&&n.push(fetch(`/api/agents/restart-all`,{method:`POST`}));let r=await Promise.all(n);for(let e of r)if(!e.ok)throw Error(`Restart failed: ${e.statusText}`)},onSuccess:()=>{y.invalidateQueries({queryKey:[`conversations`]}),x(),i(!1)}}),P=Mt({mutationFn:async e=>{let t=await fetch(`/api/agents/restart-with-current-config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentIds:e})});if(!t.ok)throw Error(`Restart failed: ${t.statusText}`);return t.json()},onSuccess:()=>{y.invalidateQueries({queryKey:[`agents`]}),x(),f(!1),m(new Set)}}),F=async()=>{u(!0);try{b?.running?await N9t():await M9t(),await x()}finally{u(!1)}},I=async()=>{await P9t(),n(!1),x()},L=()=>{!a&&!s||N.mutate({convs:a,doAgents:s})};if(!b)return(0,B.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:(0,B.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,B.jsx)(Uc,{className:`w-3.5 h-3.5`})})});let ee=b.summary.warning>0||b.summary.stuck>0,R=b.agentsNeedingAttention.length,te=D?`bg-destructive`:E?.ok?`bg-success`:`bg-muted-foreground`;return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-1`,title:b.running?`Cloister: Running`:`Cloister: Stopped`,children:b.running?(0,B.jsx)(jie,{className:`w-3.5 h-3.5 text-success`}):(0,B.jsx)(Aie,{className:`w-3.5 h-3.5 text-muted-foreground`})}),b.running&&b.summary.total>0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[b.summary.active>0&&(0,B.jsx)(`span`,{className:`text-success`,children:b.summary.active}),b.summary.warning>0&&(0,B.jsx)(`span`,{className:`text-warning`,children:b.summary.warning}),b.summary.stuck>0&&(0,B.jsx)(`span`,{className:`text-destructive`,children:b.summary.stuck})]}),j.length>0&&(0,B.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-success`,title:`Ephemeral: ${j.map(e=>`${e.projectKey.toUpperCase()} ${e.specialistType}`).join(`, `)}`,children:[(0,B.jsx)(cl,{className:`w-3 h-3`}),j.length]}),ee&&(0,B.jsx)(`span`,{title:`${R} agent${R===1?``:`s`} need attention`,children:(0,B.jsx)(il,{className:`w-3.5 h-3.5 text-warning`})}),T&&(0,B.jsxs)(`span`,{"data-testid":`tts-health-badge`,className:`flex items-center gap-1 rounded bg-popover px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,title:z9t(E,D),children:[(0,B.jsx)(`span`,{"data-testid":`tts-health-dot`,className:`h-1.5 w-1.5 rounded-full ${te}`}),`TTS`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{onClick:F,disabled:l,className:`px-2 py-0.5 rounded text-xs transition-colors ${l?`bg-card text-muted-foreground cursor-wait`:b.running?`bg-popover text-foreground hover:bg-card`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:l?`…`:b.running?`Stop Cloister`:`Start Cloister`}),(0,B.jsx)(`button`,{onClick:()=>f(!0),className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart agents with current config`,children:(0,B.jsx)(cl,{className:`w-3.5 h-3.5 ${P.isPending?`animate-spin`:``}`})}),(0,B.jsx)(`button`,{ref:g,onClick:()=>r?i(!1):M(),className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart sessions`,children:(0,B.jsx)(Mc,{className:`w-3.5 h-3.5 ${N.isPending?`animate-spin`:``}`})}),r&&_&&(0,pl.createPortal)((0,B.jsxs)(`div`,{ref:h,style:{position:`fixed`,zIndex:9999,left:_.left,bottom:_.bottom,width:256,borderRadius:6,border:`1px solid var(--border, #333)`,boxShadow:`0 4px 12px rgba(0,0,0,0.4)`,backgroundColor:`var(--card, #0c1018)`},children:[(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-foreground border-b border-border`,children:`Restart Sessions`}),(0,B.jsxs)(`div`,{className:`p-2 space-y-1`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),(0,B.jsx)(`span`,{children:`Conversations`}),(0,B.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,A,` active)`]})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),(0,B.jsx)(`span`,{children:`Workspace Agents`}),(0,B.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,k,` active)`]})]})]}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-3 py-2 border-t border-border`,children:[(0,B.jsx)(`button`,{onClick:()=>i(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,B.jsx)(`button`,{onClick:L,disabled:N.isPending||!a&&!s,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:N.isPending?`Restarting...`:`Restart`})]}),N.isError&&(0,B.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive border-t border-border`,children:N.error.message})]}),document.body),d&&(0,pl.createPortal)((0,B.jsx)(`div`,{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center`,children:(0,B.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-lg max-w-2xl max-h-96 overflow-auto w-96`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-border flex justify-between items-center`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Restart Agents with Current Config`}),(0,B.jsx)(`button`,{onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]}),(0,B.jsx)(`div`,{className:`p-4 space-y-3 max-h-64 overflow-y-auto`,children:O?.items.length===0?(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No eligible agents to restart.`}):O?.items.map(e=>(0,B.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:p.has(e.agentId),onChange:t=>{let n=new Set(p);t.target.checked?n.add(e.agentId):n.delete(e.agentId),m(n)},disabled:e.paused||e.troubled,className:`accent-primary mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium text-foreground`,children:e.issueId}),(0,B.jsxs)(`div`,{className:`text-[10px] text-muted-foreground space-y-0.5`,children:[(0,B.jsxs)(`div`,{children:[`Current: `,e.currentModel,` / `,e.currentHarness]}),e.changed&&(0,B.jsxs)(`div`,{className:`text-warning`,children:[`→ New: `,e.newModel,` / `,e.newHarness]}),!e.changed&&(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:`No change needed`}),(e.paused||e.troubled)&&(0,B.jsxs)(`div`,{className:`text-destructive`,children:[e.paused?`Paused`:`Troubled`,` — cannot restart`]})]})]})]},e.agentId))}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-4 py-3 border-t border-border`,children:[(0,B.jsx)(`button`,{onClick:()=>f(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,B.jsx)(`button`,{onClick:()=>P.mutate(Array.from(p)),disabled:P.isPending||p.size===0,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:P.isPending?`Restarting...`:`Restart (${p.size})`})]}),P.isError&&(0,B.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive border-t border-border`,children:P.error.message})]})}),document.body),t?(0,B.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-0.5 badge-bg-destructive rounded border badge-border-destructive`,children:[(0,B.jsx)(`span`,{className:`text-xs text-destructive`,children:`Kill all?`}),(0,B.jsx)(`button`,{onClick:I,className:`px-1.5 py-0.5 rounded text-xs bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Yes`}),(0,B.jsx)(`button`,{onClick:()=>n(!1),className:`px-1.5 py-0.5 rounded text-xs bg-popover text-foreground hover:bg-card`,children:`No`})]}):(0,B.jsx)(`button`,{onClick:()=>n(!0),className:`p-1 rounded text-xs badge-bg-destructive text-destructive border badge-border-destructive hover:bg-destructive/20 transition-colors`,title:`Emergency stop — kill all agents (hotkey: ${kCe})`,children:(0,B.jsx)(ys,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,B.jsx)(Uc,{className:`w-3.5 h-3.5`})})]})]})}function V9t({onOpenSettings:e}){let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`button`,{ref:r,type:`button`,"aria-label":`System controls`,"aria-expanded":t,title:`System controls — Cloister, restart, emergency stop, settings`,onClick:()=>n(e=>!e),className:`rounded-md p-1.5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring ${t?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:(0,B.jsx)(wae,{className:`h-4 w-4`,"aria-hidden":`true`})}),t&&(0,B.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 rounded-lg border border-border bg-popover p-2 shadow-lg`,children:(0,B.jsx)(B9t,{onOpenSettings:e})})]})}var H9t=/^PAN-(AC|PI(-PROMPT)?|TEST|REVIEW|SHIP|SUB(REVIEW|SIGNAL)?)-?\d*$/;function U9t(e){let t=e.lastActivity??e.startedAt;if(!t)return null;let n=Date.parse(t);return Number.isFinite(n)?n:null}function W9t(e,t=Date.now()){if(e.hasLiveTmuxSession===!0||e.hasLiveTmuxSession===void 0&&(e.status===`running`||e.status===`starting`))return`active`;let n=U9t(e);return H9t.test(e.issueId)&&n!==null&&t-n>6048e5?`orphan_test`:`stopped`}var G9t=new Set([`running`,`active`,`starting`,`thinking`,`working`]),K9t=new Set([`flywheel`,`sequencer`,`knowledge`]);function q9t(e){return G9t.has(e)}function J9t(e){if(e.pausedReason)return`paused: ${e.pausedReason}`;if(e.paused)return`paused`;if(e.troubled){let t=e.consecutiveFailures;return`troubled (${t} failure${t===1?``:`s`})`}return e.stoppedByUser?`stopped by operator`:`stopped cleanly`}function Y9t(e){window.location.pathname!==e&&window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function X9t(e){Y9t(`/issues/${encodeURIComponent(e)}`)}function Z9t(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Q9t({agent:e,title:t,contextLine:n,onNavigate:r}){return(0,B.jsxs)(`button`,{type:`button`,className:`block w-full rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-accent`,onClick:()=>{e.issueId&&!K9t.has(e.role??``)?X9t(e.issueId):Y9t(`/agents`),r?.()},children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-foreground`,children:e.issueId??e.id}),t&&(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,title:t,children:t}),e.role&&(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground`,children:e.role})]}),(0,B.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-muted-foreground`,children:n})]})}var $9t=new Set([`plan`,`review`,`test`,`ship`]),een=new Set([`in_review`,`verifying_on_main`,`done`,`canceled`,`merged`,`closed`]);function ten({variant:e=`banner`}={}){let t=Q(cS),n=Q(dS),r=new Map,i=new Map;for(let e of n){let t=typeof e.identifier==`string`?e.identifier.toUpperCase():null,n=typeof e.canonicalStatus==`string`?e.canonicalStatus:null,a=typeof e.title==`string`?e.title:null;t&&n&&r.set(t,n),t&&a&&i.set(t,a)}let a=(0,z.useRef)(new Set);(0,z.useEffect)(()=>{let e=new Set(t.filter(e=>e.resolution===`api_error`).map(e=>e.id));for(let n of e)if(!a.current.has(n)){let e=t.find(e=>e.id===n)?.issueId||n;U.warning(`${e}: API error — auto-retry nudge sent`,{duration:8e3})}a.current=e},[t]);let o=new Set([`plan`,`work`,`review`,`test`,`ship`]),s=t.filter(e=>{if(!e.issueId||W9t({issueId:e.issueId,status:e.status,hasLiveTmuxSession:e.hasLiveTmuxSession??e.lifecycle?.hasLiveTmuxSession,lastActivity:e.lastActivity,startedAt:e.startedAt})!==`stopped`||e.runtimeState===`completed`||e.resolution===`completed`||e.resolution===`done`||e.lifecycle?.isCompleted||!e.role||!o.has(e.role))return!1;if($9t.has(e.role)){let t=r.get(e.issueId.toUpperCase());if(t&&een.has(t))return!1}let t=e.lastActivity?new Date(e.lastActivity).getTime():0,n=e.startedAt?new Date(e.startedAt).getTime():0,i=Math.max(t,n);return i>0&&Date.now()-i<6048e5}),c=new Map;for(let e of s){let t=e.issueId||e.id,n=c.get(t);if(!n){c.set(t,e);continue}let r=Math.max(n.lastActivity?new Date(n.lastActivity).getTime():0,n.startedAt?new Date(n.startedAt).getTime():0);Math.max(e.lastActivity?new Date(e.lastActivity).getTime():0,e.startedAt?new Date(e.startedAt).getTime():0)>r&&c.set(t,e)}let l=Array.from(c.values()),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(!1),v=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!g)return;let e=e=>{v.current?.contains(e.target)||_(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]);let y=(0,z.useCallback)(async()=>{if(f)return;p(!0),h(null);let e=[],t=!1;for(let n of l)if(n.issueId)try{let r={issueId:n.issueId},i=r,a=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}));if(a.status===409&&o.requiresAcknowledgement){if(!window.confirm((o.guardrails?.warnings??[]).map(e=>`• ${e.message}`).join(`
|
|
857
|
+
`,c5t={ok:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,"needs-refinement":`border border-[color-mix(in_srgb,var(--warning)_36%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,stale:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)] line-through opacity-70`},l5t={ready:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,blocked:`border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,auto:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`},u5t={critical:`bg-[var(--destructive)]`,high:`bg-[var(--warning)]`,medium:`bg-[var(--color-neutral-400)]`,low:`bg-[var(--muted-foreground)] opacity-60`},i9=`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border text-xs transition-colors`,a9=`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-fg-muted)] hover:border-[color-mix(in_srgb,var(--color-fg)_25%,transparent)]`,o9={info:`border-[color-mix(in_srgb,var(--info)_45%,transparent)] bg-[color-mix(in_srgb,var(--info)_12%,transparent)] text-[var(--info-foreground)]`,success:`border-[color-mix(in_srgb,var(--success)_45%,transparent)] bg-[color-mix(in_srgb,var(--success)_12%,transparent)] text-[var(--success-foreground)]`,warning:`border-[color-mix(in_srgb,var(--warning)_45%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,danger:`border-[color-mix(in_srgb,var(--destructive)_45%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_12%,transparent)] text-[var(--destructive-foreground)]`,neutral:`border-[color-mix(in_srgb,var(--color-fg)_28%,transparent)] bg-[color-mix(in_srgb,var(--color-fg)_8%,transparent)] text-[var(--color-fg)]`},s9={info:`bg-[var(--info-foreground)]`,success:`bg-[var(--success-foreground)]`,warning:`bg-[var(--warning-foreground)]`,danger:`bg-[var(--destructive-foreground)]`,neutral:`bg-[var(--color-fg-muted)]`},d5t={now:`Now`,next:`Next`,later:`Later`,someday:`Someday`},f5t={now:`border border-[color-mix(in_srgb,var(--destructive)_34%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,next:`border border-[color-mix(in_srgb,var(--warning)_34%,transparent)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] text-[var(--warning-foreground)]`,later:`border border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[color-mix(in_srgb,var(--info)_9%,transparent)] text-[var(--info-foreground)]`,someday:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`};function c9(e,t){return e<=Math.min(14,t)?`now`:e<=Math.min(52,t)?`next`:e<=Math.min(148,t)?`later`:`someday`}var p5t=150;function m5t({onIssueAction:e}={}){let t=yt(),[n,r]=(0,z.useState)(`dag`),[i,a]=(0,z.useState)(`all`),[o,s]=(0,z.useState)(`all`),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!0),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(`incremental`),[S,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(null),[E,D]=(0,z.useState)(`now`),[O,k]=(0,z.useState)(``),[A,j]=(0,z.useState)(!1),[M,N]=(0,z.useState)(null),[P,F]=(0,z.useState)(null),[I,L]=(0,z.useState)(null),[ee,R]=(0,z.useState)(()=>new Set),[te,ne]=(0,z.useState)(null),{data:re,isLoading:ie,error:ae,refetch:oe}=V({queryKey:[`backlog-sequence`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequence`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:6e4}),{data:se=[]}=V({queryKey:[`order-books`],queryFn:async()=>{let e=await fetch(`/api/orders`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).books??[]},staleTime:15e3}),ce=(0,z.useMemo)(()=>se.filter(e=>e.status!==`complete`),[se]),le=(0,z.useMemo)(()=>ce.find(e=>e.status===`running`)??ce.find(e=>e.status===`ready`)??ce[0]??null,[ce]),ue=(0,z.useMemo)(()=>{let e=new Map;for(let t of ce)for(let n of t.items)e.set(n.issue.toUpperCase(),t);return e},[ce]),{data:de}=V({queryKey:[`sequencer-status`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequencer-status`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:3e3}),fe=de?.running??!1,pe=(0,z.useRef)(!1);(0,z.useEffect)(()=>{pe.current&&!fe&&oe(),pe.current=fe},[fe,oe]);let[me,he]=(0,z.useState)(()=>Date.now());(0,z.useEffect)(()=>{if(!fe)return;let e=setInterval(()=>he(Date.now()),1e3);return()=>clearInterval(e)},[fe]);let ge=de?.startedAt?Math.max(0,Math.floor((me-new Date(de.startedAt).getTime())/1e3)):0,_e=re?.nodes??[],ve=(0,z.useMemo)(()=>_e.filter(e=>e.condition===`stale`),[_e]),ye=(0,z.useMemo)(()=>_e.filter(e=>e.condition===`needs-refinement`),[_e]),be=(0,z.useMemo)(()=>{let e=_e.length,t={now:0,next:0,later:0,someday:0};return _e.forEach(n=>{let r=c9(n.rank,e);t[r]++}),t},[_e]),xe=(0,z.useMemo)(()=>_e.filter(e=>e.inPipeline).length,[_e]),Se=(0,z.useMemo)(()=>_e.filter(e=>e.state?.ready??!1).length,[_e]),Ce=(0,z.useMemo)(()=>_e.filter(e=>e.hasPrd).length,[_e]),we=(0,z.useMemo)(()=>_e.filter(e=>{if(E&&c9(e.rank,_e.length)!==E||i!==`all`&&e.importance!==i||o!==`all`&&e.condition!==o||c&&!e.inPipeline||u&&!(e.state?.ready??!1)||A&&!e.hasPrd)return!1;if(O){let t=O.toLowerCase();if(!e.issueId.toLowerCase().includes(t)&&!e.why.toLowerCase().includes(t))return!1}return!0}),[_e,i,o,c,u,A,E,O]),Te=(0,z.useMemo)(()=>{if(!re)return{nodes:[],edges:[]};let e=we.length;if(e<=p5t){let e=new Set(we.map(e=>e.issueId));return{nodes:we,edges:re.edges.filter(t=>e.has(t.from)&&e.has(t.to))}}let t=Math.max(Math.floor(e*.1),20),n=new Set(we.slice(0,t).map(e=>e.issueId));we.filter(e=>e.inPipeline).forEach(e=>n.add(e.issueId));let r=new Set(n);for(let e of re.edges)n.has(e.from)&&r.add(e.to),n.has(e.to)&&r.add(e.from);return{nodes:we.filter(e=>r.has(e.issueId)),edges:re.edges.filter(e=>r.has(e.from)&&r.has(e.to))}},[re,we]),Ee=we.length-Te.nodes.length;async function De(){if(!g){_(!0),T(null),C(!1);try{let e=await fetch(`/api/backlog/sequence/regenerate`,{method:`POST`,headers:await sb(),body:JSON.stringify({pass:b})});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{let n=await e.text().catch(()=>``);n&&(t=n.slice(0,300))}throw Error(t)}setTimeout(()=>oe(),2e3)}catch(e){T(e instanceof Error?e.message:String(e))}finally{_(!1)}}}async function Oe(){if(!(v||g)&&window.confirm(`Delete the backlog sequencing? This removes the ranked sequence (sequence.md + cache) and any operator gate overrides. A re-sequence pass regenerates it.`)){y(!0),T(null);try{let e=await fetch(`/api/backlog/sequence/clear`,{method:`POST`,headers:await sb()});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{}throw Error(t)}setTimeout(()=>oe(),500)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}}async function ke(e){await fetch(`/api/issues/${e}/start-planning`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>{})}async function Ae(e){(await fetch(`/api/issues/${e}/close`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>null))?.ok&&t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function je(e,n){if(!(!le||I)){L(e),ne(null);try{let r=await fetch(`/api/orders/${encodeURIComponent(le.id)}/items`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify({item:{issue:e,lane:n}})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`Request failed (HTTP ${r.status})`)}R(t=>new Set(t).add(e.toUpperCase())),F(null),await t.invalidateQueries({queryKey:[`order-books`]})}catch(e){ne(e instanceof Error?e.message:String(e))}finally{L(null)}}}let Me=e=>c5t[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`,Ne=e=>l5t[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`;return(0,B.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-[var(--color-bg)] text-[var(--color-fg)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-4 px-6 py-4 border-b border-[var(--color-border)] shrink-0 flex-wrap bg-[var(--color-bg)]`,children:[(0,B.jsxs)(`div`,{className:`min-w-[280px] flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(pc,{className:`w-4 h-4 text-[var(--color-accent)]`}),(0,B.jsxs)(`h1`,{className:`font-display text-[22px] leading-tight font-medium tracking-normal text-[var(--color-fg)]`,children:[`Backlog Sequencer`,_e.length>0&&(0,B.jsxs)(`span`,{className:`ml-2 font-mono text-sm font-normal text-[var(--color-fg-muted)]`,children:[`· `,_e.length,` open`]})]})]}),(0,B.jsx)(`p`,{className:`mt-1 max-w-2xl text-[13px] leading-5 text-[var(--color-fg-muted)]`,children:`Ranked backlog flow with active-tier graphing, dependency context, and operator gates for pickup and planning.`})]}),(0,B.jsxs)(`div`,{className:`flex rounded-md overflow-hidden border border-[var(--color-border)] bg-[var(--color-surface)]`,children:[(0,B.jsxs)(`button`,{onClick:()=>r(`list`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`list`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(pc,{className:`w-3 h-3`}),`List`]}),(0,B.jsxs)(`button`,{onClick:()=>r(`dag`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`dag`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(tc,{className:`w-3 h-3`}),`DAG`]}),(0,B.jsxs)(`button`,{onClick:()=>r(`forecast`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`forecast`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),`Forecast`]})]}),(0,B.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border ${m?`border-[var(--color-accent)] text-[var(--color-accent)] bg-[color-mix(in_srgb,var(--color-accent)_8%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,B.jsx)(Hs,{className:`w-3 h-3`}),`Filters `,we.length!==_e.length&&`(${we.length})`]}),ve.length>0&&(0,B.jsxs)(`button`,{onClick:()=>p(e=>!e),className:`px-3 py-1.5 text-xs rounded-md border ${f?`border-[var(--warning)] text-[var(--warning-foreground)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[`⊘ `,ve.length,` stale`]}),(0,B.jsxs)(`div`,{className:`relative ml-auto flex items-center gap-1`,children:[(0,B.jsxs)(`button`,{onClick:Oe,disabled:v||g||fe,className:`px-2.5 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:text-[var(--destructive)] hover:border-[color-mix(in_srgb,var(--destructive)_40%,transparent)] disabled:opacity-50`,title:`Delete the backlog sequencing (sequence.md + cache). Re-sequence regenerates it.`,children:[(0,B.jsx)(rl,{className:`w-3 h-3`}),v?`Clearing…`:`Clear`]}),(0,B.jsxs)(`button`,{onClick:De,disabled:g||fe,className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[color-mix(in_srgb,var(--color-accent)_10%,transparent)] disabled:opacity-50`,title:`Run ${b} pass`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),g||fe?`Sequencing…`:`Re-sequence`]}),(0,B.jsx)(`button`,{onClick:()=>C(e=>!e),className:`px-2 py-1.5 text-xs rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`,title:`Select pass type`,children:`▾`}),S&&(0,B.jsx)(`div`,{className:`absolute right-0 top-full mt-1 z-20 bg-[var(--color-surface)] border border-[var(--color-border)] rounded shadow-lg text-xs`,children:[`auto`,`creation`,`incremental`,`review`].map(e=>(0,B.jsx)(`button`,{onClick:()=>{x(e),C(!1)},className:`block w-full text-left px-3 py-1.5 hover:bg-[var(--color-surface-hover)] ${b===e?`text-[var(--color-accent)]`:`text-[var(--color-fg)]`}`,children:e},e))})]}),(0,B.jsx)(`button`,{onClick:()=>oe(),className:`p-2 rounded-md hover:bg-[var(--color-surface-hover)] text-[var(--color-fg-muted)] hover:text-[var(--color-fg)]`,title:`Refresh`,children:(0,B.jsx)(Mc,{className:`w-3.5 h-3.5`})})]}),fe&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-2 bg-[color-mix(in_srgb,var(--info)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--info)_28%,transparent)] text-xs`,children:[(0,B.jsx)(Mc,{className:`w-3.5 h-3.5 animate-spin text-[var(--info-foreground)]`}),(0,B.jsx)(`span`,{className:`text-[var(--info-foreground)] font-medium`,children:`Sequencing pass running`}),(0,B.jsxs)(`span`,{className:`text-[var(--color-fg)]`,children:[`ranked `,(0,B.jsx)(`b`,{className:`font-mono`,children:de?.processed??0}),` / `,(0,B.jsx)(`b`,{className:`font-mono`,children:de?.total??`…`}),` issues`]}),(0,B.jsxs)(`span`,{className:`text-[var(--color-fg-muted)] tabular-nums`,children:[`· `,Math.floor(ge/60),`m `,String(ge%60).padStart(2,`0`),`s`]}),(0,B.jsx)(`span`,{className:`ml-auto text-[var(--color-fg-muted)]`,children:`the new sequence appears automatically when it finishes`})]}),w&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--destructive)_26%,transparent)] text-xs`,children:[(0,B.jsx)(`span`,{className:`text-[var(--destructive-foreground)] font-medium`,children:`Run pass failed`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:w}),(0,B.jsx)(`button`,{onClick:()=>T(null),className:`px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_16%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_26%,transparent)] shrink-0`,children:`Dismiss`})]}),m&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-3 px-6 py-3 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-xs shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Importance:`}),[`all`,`critical`,`high`,`medium`,`low`].map(e=>(0,B.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-md border ${i===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Condition:`}),[`all`,`ok`,`needs-refinement`,`stale`].map(e=>(0,B.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-md border ${o===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`In pipeline`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Ready only`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Has PRD`})]}),(0,B.jsx)(`div`,{className:`ml-auto`,children:(0,B.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`filter by id / title…`,className:`h-6 px-2 rounded border border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] text-xs placeholder:text-[var(--color-fg-muted)]/50 focus:outline-none focus:border-[var(--color-accent)] min-w-[180px]`})})]}),f&&ve.length>0&&(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-5 py-3`,children:[(0,B.jsxs)(`div`,{className:`text-xs font-medium text-[var(--color-fg-muted)] mb-2`,children:[`Candidates to close (`,ve.length,`)`]}),(0,B.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-40 overflow-y-auto`,children:ve.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[var(--color-accent)] w-24 shrink-0`,children:e.issueId}),(0,B.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:e.why}),(0,B.jsx)(`button`,{onClick:()=>Ae(e.issueId),className:`px-2 py-0.5 rounded text-[10px] border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_14%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_24%,transparent)] shrink-0`,children:`Close`})]},e.issueId))})]}),ye.length>0&&(0,B.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--warning)_26%,transparent)] text-xs`,children:[(0,B.jsxs)(`span`,{className:`text-[var(--warning-foreground)] font-medium`,children:[`⚠ `,ye.length,` need refinement`]}),(0,B.jsxs)(`span`,{className:`text-[var(--color-fg-muted)]`,children:[ye.slice(0,5).map(e=>e.issueId).join(`, `),ye.length>5?` +${ye.length-5}`:``]}),(0,B.jsx)(`button`,{onClick:()=>ke(ye[0].issueId),className:`ml-auto px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--warning)_32%,transparent)] bg-[color-mix(in_srgb,var(--warning)_16%,transparent)] text-[var(--warning-foreground)] hover:bg-[color-mix(in_srgb,var(--warning)_26%,transparent)] shrink-0`,children:`Draft PRD →`})]}),_e.length>0&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-6 py-2.5 border-b border-[var(--color-border)] shrink-0`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border border-[var(--color-border)] bg-[var(--color-surface)] text-xs text-[var(--color-fg-muted)]`,children:[(0,B.jsx)(`b`,{className:`text-[var(--color-fg)] font-medium font-mono`,children:_e.length}),` open issues`]}),(0,B.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`${i9} ${c?o9.info:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.info}`}),`In pipeline `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:xe})]}),(0,B.jsxs)(`button`,{onClick:()=>d(e=>!e),className:`${i9} ${u?o9.success:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.success}`}),`Ready `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:Se})]}),(0,B.jsxs)(`button`,{onClick:()=>j(e=>!e),className:`${i9} ${A?o9.neutral:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.neutral}`}),`Has PRD `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:Ce})]}),ye.length>0&&(0,B.jsxs)(`button`,{onClick:()=>s(e=>e===`needs-refinement`?`all`:`needs-refinement`),className:`${i9} ${o===`needs-refinement`?o9.warning:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.warning}`}),`⚠ Needs refinement `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ye.length})]}),ve.length>0&&(0,B.jsxs)(`button`,{onClick:()=>s(e=>e===`stale`?`all`:`stale`),className:`${i9} ${o===`stale`?o9.neutral:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full opacity-60 shrink-0 ${s9.neutral}`}),`⊘ Stale candidates `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ve.length})]}),(0,B.jsxs)(`button`,{onClick:()=>D(e=>e===`now`?null:`now`),className:`${i9} ${E===`now`?o9.danger:a9}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${s9.danger}`}),`Tier 1 · Now `,(0,B.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:be.now})]})]}),_e.length>0&&(0,B.jsx)(`div`,{className:`flex gap-2 px-6 py-3 border-b border-[var(--color-border)] shrink-0`,children:[{key:`now`,emoji:`🔴`,label:`Now`,count:be.now,sub:`act on these first`,accent:`border-l-[var(--destructive)]`,ring:`ring-[color-mix(in_srgb,var(--destructive)_50%,transparent)]`},{key:`next`,emoji:`🟠`,label:`Next`,count:be.next,sub:`queued behind Now`,accent:`border-l-[var(--warning)]`,ring:`ring-[color-mix(in_srgb,var(--warning)_50%,transparent)]`},{key:`later`,emoji:`🔵`,label:`Later`,count:be.later,sub:`planned horizon`,accent:`border-l-[var(--info)]`,ring:`ring-[color-mix(in_srgb,var(--info)_50%,transparent)]`},{key:`someday`,emoji:`⚪`,label:`Someday`,count:be.someday,sub:`long tail`,accent:`border-l-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`,ring:`ring-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`}].map(e=>(0,B.jsxs)(`button`,{onClick:()=>D(t=>t===e.key?null:e.key),className:`flex-1 min-w-[140px] flex flex-col gap-0.5 px-3.5 py-2.5 border border-l-4 ${e.accent} rounded-lg bg-[var(--color-surface)] text-left hover:bg-[var(--color-surface-hover)] transition-colors shadow-sm ${E===e.key?`ring-1 ${e.ring} border-[var(--color-border)]`:`border-[var(--color-border)]`}`,children:[(0,B.jsxs)(`span`,{className:`text-xs text-[var(--color-fg)]`,children:[e.emoji,` `,e.label]}),(0,B.jsx)(`span`,{className:`font-mono text-lg font-medium text-[var(--color-fg)] leading-tight`,children:e.count}),(0,B.jsx)(`span`,{className:`text-[10px] text-[var(--color-fg-muted)]`,children:e.sub})]},e.key))}),E&&_e.length>0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-1.5 border-b border-[var(--color-border)] bg-[var(--color-surface)] shrink-0 text-xs text-[var(--color-fg-muted)]`,children:[(0,B.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-widest bg-[var(--color-accent)] text-[var(--color-fg)]`,children:[`Showing `,d5t[E]]}),(0,B.jsxs)(`span`,{children:[we.length,` of `,_e.length,` issues`,n===`dag`?` rendered as a graph`:``,` — click the tier again to show all`]})]}),(0,B.jsxs)(`div`,{className:`flex-1 overflow-hidden flex`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden flex flex-col`,children:[ie&&(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--color-fg-muted)] text-sm`,children:`Loading sequence…`}),ae&&(0,B.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--destructive-foreground)] text-sm`,children:String(ae)}),!ie&&!ae&&_e.length===0&&(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-3 text-[var(--color-fg-muted)]`,children:[(0,B.jsx)(pc,{className:`w-8 h-8 opacity-40`}),(0,B.jsx)(`p`,{className:`text-sm`,children:`No backlog sequence yet.`}),(0,B.jsx)(`p`,{className:`text-xs`,children:`Run a creation pass to rank the open backlog.`}),(0,B.jsxs)(`button`,{onClick:()=>{x(`creation`),De()},disabled:g,className:`px-3 py-1.5 text-xs rounded border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[var(--color-accent)]/10 disabled:opacity-50 flex items-center gap-1`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),g?`Spawning…`:`Run creation pass`]})]}),!ie&&!ae&&_e.length>0&&n===`list`&&(0,B.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,B.jsx)(`thead`,{className:`sticky top-0 bg-[var(--color-surface)] border-b border-[var(--color-border)]`,children:(0,B.jsxs)(`tr`,{className:`text-[var(--color-fg-muted)]`,children:[(0,B.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-8 cursor-help`,title:`Pickup rank — lower means the Flywheel works it sooner`,children:`#`}),(0,B.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-6 cursor-help`,title:`Importance — red = critical, orange = high, gray = medium, dim = low`,children:`●`}),(0,B.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-28 cursor-help`,title:`Issue ID. Markers: ▶ in pipeline · ⚠ needs refinement · P has PRD · ✓ planned (spec + tasks)`,children:`Issue`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-16 cursor-help`,title:`Tier band by rank: Now · Next · Later · Someday`,children:`Tier`}),(0,B.jsx)(`th`,{className:`text-left px-2 py-2 font-medium cursor-help`,title:`One-line rationale for this ranking (from the sequencer)`,children:`Why`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Estimated effort: XS / S / M / L / XL`,children:`Size`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-24 cursor-help`,title:`AI condition: ok · needs-refinement (vague spec) · stale (likely close)`,children:`Condition`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-20 cursor-help`,title:`Operator pickup gate: auto (normal) · promote (jump queue) · vetoed (never pick)`,children:`Gate`}),(0,B.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Impact score (0–100) the sequencer assigned`,children:`Score`}),(0,B.jsx)(`th`,{className:`px-2 py-2 font-medium w-28`,children:(0,B.jsx)(`span`,{className:`sr-only`,children:`Order book`})})]})}),(0,B.jsx)(`tbody`,{children:we.map(e=>{let t=c9(e.rank,_e.length),n=e.condition===`stale`,r=e.condition===`needs-refinement`,i=M?.issueId===e.issueId;return(0,B.jsxs)(`tr`,{onClick:()=>N(t=>t?.issueId===e.issueId?null:e),className:`group transition-colors cursor-pointer ${n?`opacity-50`:``} ${i?`bg-[color-mix(in_srgb,var(--color-accent)_14%,transparent)] ring-inset ring-1 ring-[var(--color-accent)]`:`even:bg-[color-mix(in_srgb,var(--color-fg)_3%,transparent)] hover:bg-[color-mix(in_srgb,var(--color-fg)_9%,transparent)]`}`,children:[(0,B.jsx)(`td`,{className:`text-right px-3 py-2 text-[var(--color-fg-muted)] tabular-nums border-l-2 ${e.inPipeline?`border-l-[var(--info)]`:`border-l-transparent`}`,children:e.rank}),(0,B.jsx)(`td`,{className:`px-2 py-2`,children:(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${u5t[e.importance]??`bg-[var(--color-fg-muted)]`}`,title:`Importance: ${e.importance}`})}),(0,B.jsxs)(`td`,{className:`px-2 py-2 font-mono text-[var(--color-accent)]`,children:[e.issueId,e.inPipeline&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`In pipeline — active work / review / test`,children:`▶`}),r&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--warning-foreground)] align-top`,title:`Needs refinement — vague/underspecified`,children:`⚠`}),e.hasPrd&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`Has PRD`,children:`P`}),e.ready&&(0,B.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--success-foreground)] align-top`,title:`Has spec — ready for work`,children:`✓`})]}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${f5t[t]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`}`,children:d5t[t]})}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-[var(--color-fg)] max-w-xs truncate ${n?`line-through`:``}`,children:e.why}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)]`,children:e.size}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Me(e.condition)}`,title:e.condition===`needs-refinement`?`Needs refinement — vague/underspecified`:e.condition===`stale`?`Stale — likely a candidate to close`:`OK — well-specified`,children:e.condition===`needs-refinement`?`⚠ refine`:e.condition===`stale`?`⊘ stale`:e.condition})}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,B.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ne(e.gate)}`,title:e.gate===`ready`?e.inPipeline?`Auto (in-pipeline pin)`:`Promoted — jumps the queue`:e.gate===`blocked`?`Vetoed — never auto-picked`:`Auto — normal eligibility`,children:e.gate===`ready`?e.inPipeline?`auto`:`📌`:e.gate===`blocked`?`⛔`:e.gate})}),(0,B.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)] tabular-nums`,children:e.score}),(0,B.jsxs)(`td`,{className:`relative px-2 py-2 text-right`,onClick:e=>e.stopPropagation(),children:[ue.has(e.issueId.toUpperCase())||ee.has(e.issueId.toUpperCase())?(0,B.jsx)(`a`,{href:`/orders`,className:`text-[10px] text-[var(--color-accent)] opacity-0 hover:underline group-hover:opacity-100 focus:opacity-100`,children:`Open order book`}):(0,B.jsx)(`button`,{type:`button`,disabled:!le,onClick:()=>{ne(null),F(t=>t===e.issueId?null:e.issueId)},className:`rounded border border-[var(--color-border)] px-2 py-1 text-[10px] text-[var(--color-fg-muted)] opacity-0 transition-opacity hover:border-[var(--color-accent)] hover:text-[var(--color-accent)] focus:opacity-100 disabled:cursor-not-allowed disabled:opacity-30 group-hover:opacity-100`,title:le?`Add to ${le.name}`:`Create an order book first`,children:`+ Order book`}),P===e.issueId&&le&&(0,B.jsxs)(`div`,{className:`absolute right-2 top-full z-30 w-52 rounded-md border border-[var(--color-border)] bg-[var(--color-surface)] p-2 text-left shadow-lg`,role:`dialog`,"aria-label":`Choose lane for ${e.issueId}`,children:[(0,B.jsxs)(`p`,{className:`truncate text-[10px] text-[var(--color-fg-muted)]`,children:[`Add to `,le.name]}),(0,B.jsx)(`div`,{className:`mt-2 flex gap-2`,children:[`A`,`B`].map(t=>(0,B.jsxs)(`button`,{type:`button`,disabled:I===e.issueId,onClick:()=>{je(e.issueId,t)},className:`flex-1 rounded border border-[var(--color-border)] px-2 py-1 text-[10px] text-[var(--color-fg)] hover:border-[var(--color-accent)] disabled:opacity-50`,children:[`Lane `,t]},t))}),(0,B.jsx)(`a`,{href:`/orders`,className:`mt-2 block text-[10px] text-[var(--color-accent)] hover:underline`,children:`Open Order Book`}),te&&(0,B.jsx)(`p`,{className:`mt-2 text-[10px] text-[var(--destructive)]`,role:`alert`,children:te})]})]})]},e.issueId)})})]})}),!ie&&!ae&&_e.length>0&&n===`dag`&&re&&(0,B.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[Ee>0&&(0,B.jsxs)(`div`,{className:`shrink-0 text-xs text-center py-1 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-[var(--color-fg-muted)]`,children:[`Showing `,Te.nodes.length,` of `,we.length,` issues (top tier + neighbors); `,Ee,` collapsed`]}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)($8t,{data:Te,className:`w-full h-full`,selectedNodeId:M?.issueId,onSelectNode:e=>N(e),onIssueAction:e})})]}),!ie&&!ae&&_e.length>0&&n===`forecast`&&(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(a5t,{className:`w-full h-full`,onSelectIssue:e=>N(_e.find(t=>t.issueId===e)??null)})})]}),M&&(0,B.jsx)(Q8t,{node:M,onClose:()=>N(null),onIssueAction:e})]})]})}var h5t={exploring:{label:`Exploring`,color:`var(--primary)`,icon:Vc},planning:{label:`Planning`,color:`var(--signal-review, var(--primary))`,icon:Ss},building:{label:`Building`,color:`var(--success, #10b981)`,icon:Pie},verifying:{label:`Verifying`,color:`var(--warning, #f59e0b)`,icon:_s},cleaning:{label:`Cleaning`,color:`var(--muted-foreground)`,icon:Sae},shipping:{label:`Shipping`,color:`var(--primary)`,icon:Nc}};function g5t(e){return e.filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,3)}function _5t(e,t){if(!e)return!1;let n=Date.parse(e.timestamp);return!Number.isNaN(n)&&t.getTime()-n>3600*1e3}function l9({label:e,value:t,tone:n}){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:n??`var(--foreground)`},children:t})]})}function v5t({issue:e,status:t,observations:n,stats:r,onOpenWorkspaceHome:i,now:a=new Date}){let o=t?.phase??`exploring`,s=h5t[o],c=s.icon,l=g5t(n),u=_5t(l[0],a),d=t?.headline||e.title,f=t?.summary||e.description||`No workspace status summary yet.`;return(0,B.jsxs)(`button`,{type:`button`,"data-testid":`workspace-status-card`,onClick:i,className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,"aria-label":`Open ${e.identifier} workspace overview`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{"data-testid":`workspace-status-phase-icon`,"data-phase":o,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border`,style:{color:s.color,borderColor:s.color,background:`color-mix(in srgb, currentColor 10%, transparent)`},children:(0,B.jsx)(c,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,title:d,children:d}),(0,B.jsx)(`span`,{"data-testid":`workspace-status-phase-label`,className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,style:{color:s.color,borderColor:s.color},children:s.label}),u&&(0,B.jsxs)(`span`,{"data-testid":`workspace-status-stale`,className:`ml-auto flex shrink-0 items-center gap-1 text-[10px] font-semibold text-warning`,children:[(0,B.jsx)(il,{className:`h-3 w-3`}),`Stale`]})]}),(0,B.jsx)(`p`,{"data-testid":`workspace-status-summary`,className:`mt-1 text-xs text-muted-foreground`,style:{display:`-webkit-box`,WebkitLineClamp:3,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:f})]})]}),(0,B.jsx)(`ul`,{"data-testid":`workspace-status-observations`,className:`mt-3 space-y-1 text-xs text-muted-foreground`,children:l.length===0?(0,B.jsx)(`li`,{className:`text-muted-foreground/70`,children:`No recent action status.`}):l.map(e=>(0,B.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),e.actionStatus?(0,B.jsx)(DQ,{status:e.actionStatus}):null,(0,B.jsx)(`span`,{className:`min-w-0 truncate`,title:e.summary,children:e.summary})]},e.id))}),(0,B.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-3 border-t border-border pt-3`,children:[(0,B.jsx)(l9,{label:`Additions`,value:`+${r.additions}`,tone:`var(--success, #10b981)`}),(0,B.jsx)(l9,{label:`Deletions`,value:`-${r.deletions}`,tone:`var(--destructive)`}),(0,B.jsx)(l9,{label:`Commits`,value:r.commits}),(0,B.jsx)(l9,{label:`PRs`,value:r.prs})]})]})}var y5t={justNow:`Just Now`,earlierToday:`Earlier Today`,yesterday:`Yesterday`,thisWeek:`This Week`,thisMonth:`This Month`,older:`Older`},b5t=[`justNow`,`earlierToday`,`yesterday`,`thisWeek`,`thisMonth`,`older`];async function x5t(){let e=await fetch(`/api/registry/features`);if(!e.ok)throw Error(`Registry request failed (${e.status})`);let t=await e.json();return Array.isArray(t.entries)?t.entries:[]}async function S5t(){let e=await fetch(`/api/metrics/summary`);if(!e.ok)throw Error(`Metrics summary request failed (${e.status})`);return e.json()}function C5t({onOpenWorkspaceHome:e,onNewProject:t,onSelectProject:n,onOpenSettings:r,now:i}={}){let a=V({queryKey:[`feature-registry`],queryFn:x5t,staleTime:3e4,retry:!1}),o=V({queryKey:[`metrics-summary`],queryFn:S5t,staleTime:3e4,retry:!1}),s=V({queryKey:[`command-deck-projects`],queryFn:UC,staleTime:3e4,retry:!1}),c=s.data??[],l=hO(e=>e.showPlannedBacklog),u=Q(e=>e.issuesRaw),d=Q(e=>e.statusByIssueId),f=Q(e=>e.observationsByIssueId),p=Q(e=>e.agentsById),m=Q(e=>e.reviewStatusByIssueId),h=Q(PNe),g=i??new Date,_=(0,z.useMemo)(()=>F5t({issuesRaw:u,statusByIssueId:d,observationsByIssueId:f,agentsById:p,reviewStatusByIssueId:m}),[p,u,f,m,d]),v=(0,z.useMemo)(()=>P5t(f),[f]),y=(0,z.useMemo)(()=>k5t(O5t({agentsById:p,reviewStatusByIssueId:m,dailyCost:o.data?.today?.totalCost,now:g})),[p,g,o.data?.today?.totalCost,m]);return(0,B.jsx)(`div`,{className:`h-full w-full overflow-y-auto bg-background`,children:(0,B.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 p-6`,children:[(0,B.jsx)(`header`,{className:`rounded-xl border border-border bg-card p-6 shadow-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Overdeck Home`}),(0,B.jsx)(`h1`,{className:`mt-2 text-3xl font-semibold text-foreground`,children:`System briefing`}),(0,B.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm text-muted-foreground`,children:`A live landing page for current workspace context, cross-workspace ownership, and memory-first guidance.`})]}),(0,B.jsx)(Q8,{})]})}),(0,B.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,"aria-label":`Home summary`,children:y.map(e=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,B.jsx)(`p`,{className:`mt-2 text-2xl font-semibold tabular-nums ${e.tone??`text-foreground`}`,children:e.value}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail})]},e.label))}),(0,B.jsx)(w5t,{observations:v,failure:h,onOpenSettings:r,now:g}),(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`workspace-status-title`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`workspace-status-title`,className:`text-lg font-semibold text-foreground`,children:`Workspaces`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Live workspace status rollups from memory observations.`})]}),(0,B.jsx)(`div`,{className:`mt-4`,children:_.length>0?(0,B.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:_.map(t=>(0,B.jsx)(v5t,{issue:t.issue,status:t.status,observations:t.observations,stats:t.stats,onOpenWorkspaceHome:()=>e?.(t.issue.identifier),now:i},t.issue.identifier))}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No workspace status is available yet.`}),(0,B.jsx)(`p`,{className:`mt-1`,children:`Workspace cards will appear after memory status or observations are recorded for an issue.`})]})})]}),(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`knowledge-registry-title`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`knowledge-registry-title`,className:`text-lg font-semibold text-foreground`,children:`Knowledge Registry`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Feature ownership across issues, workspaces, and agents.`})]}),a.isFetching&&(0,B.jsx)(`span`,{className:`mt-2 rounded-full border border-border px-2 py-1 text-xs text-muted-foreground sm:mt-0`,children:`Refreshing`})]}),(0,B.jsx)(`div`,{className:`mt-4`,children:a.isError?(0,B.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Knowledge Registry could not be loaded. The rest of Home is still available.`}):a.isLoading?(0,B.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading registry entries…`}):a.data&&a.data.length>0?(0,B.jsx)(V5t,{entries:a.data}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No features are registered yet.`}),(0,B.jsxs)(`p`,{className:`mt-1`,children:[`Add one with `,(0,B.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`pan registry tag <issueId> <feature>`}),`. Automatic classification will populate future entries as issue and workspace lifecycle wiring lands.`]})]})})]}),(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-projects-title`,"data-testid":`home-projects`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`home-projects-title`,className:`text-lg font-semibold text-foreground`,children:`Projects`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your registered projects — click one to open its deck.`})]}),t&&(0,B.jsx)(`button`,{"data-testid":`home-new-project`,onClick:t,className:`rounded-lg border border-border bg-muted/20 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]}),(0,B.jsx)(`div`,{className:`mt-4`,children:s.isLoading?(0,B.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading projects…`}):s.isError?(0,B.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Projects could not be loaded. The rest of Home is still available.`}):c.length>0?(0,B.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:c.map(e=>{let t=HC(e.features,l),r=t.length>0;return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{"data-testid":`home-project-${e.name}`,onClick:()=>n?.(e.name),title:e.path,className:`flex w-full items-center gap-3 px-4 py-3 text-left text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:[(0,B.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${r?`bg-primary`:`bg-muted-foreground/30`}`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),r&&(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t.length})]})},e.path)})}):(0,B.jsxs)(`div`,{"data-testid":`home-projects-empty`,className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No projects yet.`}),(0,B.jsx)(`p`,{className:`mt-1`,children:`Create your first project to get started.`}),t&&(0,B.jsx)(`button`,{"data-testid":`home-new-project-empty`,onClick:t,className:`mt-3 rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]})})]})]})})}function w5t({observations:e,failure:t,onOpenSettings:n,now:r}){let i=(0,z.useMemo)(()=>gBt(e,e=>e.timestamp,r),[e,r]);return(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-activity-title`,"data-testid":`home-activity-feed`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{id:`home-activity-title`,className:`text-lg font-semibold text-foreground`,children:`Activity Feed`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Recent actionable memory observations across workspaces.`})]}),t&&(0,B.jsx)(T5t,{failure:t,onOpenSettings:n}),e.length===0?(0,B.jsxs)(`div`,{"data-testid":`home-activity-empty`,className:`mt-4 rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,B.jsx)(`p`,{className:`font-medium text-foreground`,children:`No actionable observations yet.`}),(0,B.jsx)(`p`,{className:`mt-1`,children:`Observations are extracted from running work agents — they appear here once an agent makes a change worth recording.`})]}):(0,B.jsx)(`div`,{className:`mt-4 space-y-5`,children:b5t.map(e=>{let t=i[e];return t.length===0?null:(0,B.jsxs)(`section`,{"data-testid":`home-activity-bucket-${e}`,children:[(0,B.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:y5t[e]}),(0,B.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,B.jsx)(D5t,{observation:e,now:r},e.id))})]},e)})})]})}function T5t({failure:e,onOpenSettings:t}){let n=E5t(e);return(0,B.jsx)(`div`,{"data-testid":`home-memory-failure`,className:`mt-4 rounded-lg border border-destructive/32 bg-destructive/8 p-4 text-sm text-foreground`,role:`alert`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(il,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`font-medium text-destructive`,children:`Memory extraction is failing`}),(0,B.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),e.detail?(0,B.jsx)(`p`,{className:`mt-2 break-words font-mono text-[11px] text-muted-foreground`,children:e.detail}):null,(0,B.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:`Memory observations and agent memory injection are disabled until this is fixed.`}),t?(0,B.jsx)(`button`,{onClick:t,className:`mt-3 rounded-sm border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground hover:bg-accent transition-colors`,children:`Open Settings › Memory`}):null]})]})})}function E5t(e){let t=(e.detail??``).toLowerCase();return t.includes(`could not resolve authentication`)||t.includes(`anthropic_api_key`)||t.includes(`x-api-key`)?`The Anthropic API provider has no API key. Switch the extraction provider to cliproxy (your ChatGPT subscription) in Settings › Memory.`:t.includes(`unknown provider for model`)||t.includes(`does not exist`)||t.includes(`unknown model`)?`The configured extraction model is not available on cliproxy. Pick a served model (e.g. gpt-5.4-mini) in Settings › Memory.`:t.includes(`401`)||t.includes(`unauthorized`)||t.includes(`expired`)?`The extraction provider rejected the credentials — the codex/ChatGPT subscription token used by cliproxy may have expired. Re-authenticate, then it will recover automatically.`:`Background memory-extraction calls are failing. Check the extraction provider and model in Settings › Memory.`}function D5t({observation:e,now:t}){return(0,B.jsxs)(`li`,{className:`rounded-lg border border-border bg-background p-3 text-xs`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(DQ,{status:e.actionStatus}),(0,B.jsx)(`p`,{className:`font-semibold text-foreground`,children:e.summary})]}),(0,B.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[e.workspaceId,` · `,e.issueId,` · `,(0,B.jsx)(`time`,{dateTime:e.timestamp,children:JD(e.timestamp,t)})]}),e.narrative?(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:e.narrative}):null,e.files.length>0?(0,B.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Files`,children:e.files.map(e=>(0,B.jsx)(`code`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,e.tags.length>0?(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,"aria-label":`Tags`,children:e.tags.map(e=>(0,B.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,(0,B.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,B.jsx)(EQ,{kind:`memory`})})]})}function O5t({agentsById:e={},reviewStatusByIssueId:t={},dailyCost:n,now:r}){let i=Object.values(e),a=Object.values(t);return{runningAgents:i.filter(A5t).length,gatedAgents:i.filter(j5t).length,recentMerges:a.filter(e=>M5t(e,r)).length,failedVerifications:a.filter(N5t).length,dailyCost:typeof n==`number`&&Number.isFinite(n)?n:null}}function k5t(e){return[{label:`Running agents`,value:String(e.runningAgents),detail:`Live or starting sessions`,tone:e.runningAgents>0?`text-primary`:void 0},{label:`Paused / troubled`,value:String(e.gatedAgents),detail:`Agents gated by pause or failures`,tone:e.gatedAgents>0?`text-warning`:void 0},{label:`Merged today`,value:String(e.recentMerges),detail:`Merges in the last 24 hours`,tone:e.recentMerges>0?`text-success`:void 0},{label:`Needs verification`,value:String(e.failedVerifications),detail:`Failed checks or merge blockers`,tone:e.failedVerifications>0?`text-destructive`:void 0},{label:`Cost today`,value:e.dailyCost===null?`Unavailable`:`$${e.dailyCost.toFixed(2)}`,detail:`UTC daily cost summary`,tone:e.dailyCost===null?`text-muted-foreground`:`text-success`}]}function A5t(e){return e.hasLiveTmuxSession===!0||e.status===`running`||e.status===`starting`}function j5t(e){return e.paused===!0||e.troubled===!0||e.status!==`stopped`&&(e.consecutiveFailures??0)>0}function M5t(e,t){if(e.mergeStatus!==`merged`||!e.updatedAt)return!1;let n=Date.parse(e.updatedAt);return!Number.isNaN(n)&&t.getTime()-n<=1440*60*1e3}function N5t(e){return e.verificationStatus===`failed`||e.testStatus===`failed`||e.uatStatus===`failed`||(e.blockerReasons?.length??0)>0}function P5t(e){return Object.values(e).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function F5t({issuesRaw:e,statusByIssueId:t={},observationsByIssueId:n={},agentsById:r={},reviewStatusByIssueId:i={}}){let a=new Map;for(let t of e){let e=z5t(t);e&&a.set(e.identifier,e)}let o=new Set;for(let e of Object.keys(t))o.add(e);for(let[e,t]of Object.entries(n))t.length>0&&o.add(e);for(let e of Object.values(r))e.issueId&&I5t(e)&&o.add(e.issueId);return[...o].sort(nb).map(e=>{let r=t[e],o=n[e]??[];return{issue:a.get(e)??{identifier:e,title:r?.headline||e,description:r?.summary},status:r,observations:o,stats:L5t(o,i[e])}})}function I5t(e){return e.hasLiveTmuxSession===!0||[`healthy`,`running`,`starting`,`stuck`,`warning`].includes(e.status)}function L5t(e,t){return{additions:0,deletions:0,commits:e.filter(R5t).length,prs:+!!t?.prUrl}}function R5t(e){return e.tags.some(e=>[`commit`,`commits`,`git.commit`].includes(e.toLowerCase()))}function z5t(e){return!B5t(e)||typeof e.identifier!=`string`||typeof e.title!=`string`?null:{identifier:e.identifier,title:e.title,description:typeof e.description==`string`?e.description:void 0}}function B5t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function V5t({entries:e}){return(0,B.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`min-w-full divide-y divide-border text-sm`,children:[(0,B.jsx)(`thead`,{className:`bg-muted/40 text-left text-xs uppercase tracking-wide text-muted-foreground`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Feature`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Issue`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Workspace`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Agent`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Status`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Updated`}),(0,B.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Tags`})]})}),(0,B.jsx)(`tbody`,{className:`divide-y divide-border bg-card`,children:e.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{className:`px-4 py-3 font-medium text-foreground`,children:e.featureName}),(0,B.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningIssueId??`—`}),(0,B.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningWorkspaceId??`—`}),(0,B.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningAgentId??`—`}),(0,B.jsx)(`td`,{className:`px-4 py-3`,children:(0,B.jsx)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-1 text-xs font-medium text-foreground`,children:e.status})}),(0,B.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:H5t(e.updatedAt)}),(0,B.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:e.tags.length>0?e.tags.join(`, `):`—`})]},e.featureId))})]})})})}function H5t(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function U5t({initialProjectKey:e=``,onCreated:t}={}){let[n,r]=(0,z.useState)(``),[i,a]=(0,z.useState)(e),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(`shared`),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(!0),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(null),b=(0,z.useRef)(0),x=(0,z.useRef)(0);(0,z.useEffect)(()=>()=>{x.current+=1},[]);let S=c===`isolated`?``:o,C=(0,z.useMemo)(()=>({project:i,name:n,isolated:c===`isolated`,...S?{targetPath:S}:{},...u?{parentBranch:u}:{}}),[S,c,n,u,i]);(0,z.useEffect)(()=>{p(null),h(!0),y(null);let e=++b.current,t=setTimeout(()=>{(async()=>{try{let t=await vl(`/api/workspace-registry/resolve`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(C)});if(!t.ok){e===b.current&&y(`Could not resolve the workspace intent (HTTP ${t.status}).`);return}let n=await t.json();if(e!==b.current)return;p(n),h(!1)}catch{e===b.current&&y(`Could not reach the server to resolve the workspace intent.`)}})()},300);return()=>clearTimeout(t)},[C]);let w=(0,z.useCallback)(e=>(f?.findings??[]).filter(t=>t.field===e),[f]),T=(f?.findings.length??0)>0;return{name:n,setName:r,projectKey:i,setProjectKey:a,targetPath:o,setTargetPath:s,mode:c,setMode:l,parentBranch:u,setParentBranch:d,effectiveTargetPath:S,intent:f,stale:m,creating:g,error:v,findingsFor:w,hasFindings:T,canCreate:!g&&!m&&!!f&&!T,submitIntent:(0,z.useCallback)(async(e=C)=>{y(null),_(!0);let n=++x.current;try{let r=await vl(`/api/workspace-registry`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(e)});if(n!==x.current)return null;if(!r.ok){let e=await r.json().catch(()=>({}));return n===x.current&&(e.findings?.length?(p(t=>t&&{...t,findings:e.findings??[]}),y(e.findings[0]?.message??`The workspace intent was rejected.`)):y(e.error??`HTTP ${r.status}`)),null}let i=await r.json();return n===x.current?(t?.(i.id),i.id):null}catch(e){return n===x.current&&y(e instanceof Error?e.message:String(e)),null}finally{n===x.current&&_(!1)}},[t,C])}}var W5t=[],G5t=[],K5t=[[`AUTOMATE`,`Nightly dependency-audit sweep across all registered projects`],[`DELEGATE`,`Triage the untriaged backlog and draft a priority proposal`],[`EXPLORE`,`Map how the merge train decides dispatch order`],[`BUILD`,`Prototype kanban swimlanes grouped by project`],[`PLAN`,`Plan the Q3 cost-governor roadmap from open issues`],[`DESIGN`,`Redesign the agent card footer around the new style guide`]];function q5t({onCancel:e,onCreated:t}){let n=(0,z.useRef)(null),r=(0,z.useRef)(!1),i=yt(),[a]=(0,z.useState)(()=>byt()??``),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!1),[g,_]=(0,z.useState)(null),[v,y]=(0,z.useState)(!1),b=U5t({initialProjectKey:a,onCreated:t}),x=V({queryKey:[`registered-projects`],queryFn:async()=>{let e=await vl(`/api/registered-projects`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t)?t:[]},staleTime:6e4}),S=V({queryKey:[`workspace-registry`],queryFn:async()=>{let e=await vl(`/api/workspace-registry`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.workspaces)?t.workspaces:[]},staleTime:1e4,refetchInterval:1e4}),C=x.data??W5t,w=S.data??G5t,T=(0,z.useMemo)(()=>{let e=new Map;for(let t of w)e.set(t.projectId,Math.max(e.get(t.projectId)??0,t.lastAccessedAt));return[...C].sort((t,n)=>(e.get(n.key)??0)-(e.get(t.key)??0))},[C,w]);(0,z.useEffect)(()=>{if(!x.isSuccess||r.current)return;r.current=!0;let e=a?T.find(e=>e.key===a||e.name===a)?.key:void 0;e&&b.projectKey!==e?b.setProjectKey(e):!b.projectKey&&T.length===1&&b.setProjectKey(T[0]?.key??``)},[b.projectKey,b.setProjectKey,a,T,x.isSuccess]),(0,z.useEffect)(()=>{if(b.setTargetPath(``),_(null),d(!1),p(!1),!b.projectKey)return;let e=!1;return(async()=>{try{let t=await vl(`/api/workspace-registry/project-targets?project=${encodeURIComponent(b.projectKey)}`,{credentials:`include`});if(e||!t.ok)return;let n=await t.json();if(e)return;_(n),b.setTargetPath(n.primaryPath)}catch{}})(),()=>{e=!0}},[b.projectKey,b.setTargetPath]),(0,z.useEffect)(()=>{if(y(!1),!b.projectKey)return;let e=!1;return(async()=>{try{let t=await vl(`/api/workspace-registry?project=${encodeURIComponent(b.projectKey)}&kind=main&includeArchived=true`,{credentials:`include`});if(e||!t.ok)return;let n=await t.json();e||y((n.workspaces??[]).length===0)}catch{}})(),()=>{e=!0}},[b.projectKey]);let E=(0,z.useMemo)(()=>{if(!g)return[];let e=new Set;return[g.primaryPath,...g.targets.map(e=>e.path)].filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[g]),D=b.mode===`isolated`?b.intent?.path??`Resolved isolated path`:b.targetPath||b.intent?.path||`Choose target directory`,O=[`name`,`project`,`targetPath`,`parentBranch`].flatMap(e=>b.findingsFor(e)),k=b.parentBranch||b.intent?.parentBranch,A=!b.parentBranch&&b.intent?.parentBranchGuessed;return(0,B.jsxs)(`div`,{"data-testid":`new-workspace-page`,className:`h-full w-full overflow-y-auto bg-background`,children:[(0,B.jsxs)(`form`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col px-8 py-12 lg:px-12 lg:py-16`,onSubmit:e=>{e.preventDefault(),b.canCreate&&b.submitIntent()},children:[(0,B.jsxs)(`div`,{"data-testid":`new-workspace-project-chip-row`,"data-region":`project-chip-row`,"data-selected-project":b.projectKey,className:`relative mb-8 flex min-h-9 flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,B.jsx)(jc,{className:`h-4 w-4`}),`add existing`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,B.jsx)(Js,{className:`h-4 w-4`}),`new project`]}),T.slice(0,5).map(e=>(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-project-chip`,"data-project-key":e.key,"aria-pressed":b.projectKey===e.key,onClick:()=>b.setProjectKey(e.key),className:`inline-flex h-9 items-center rounded-lg border px-3 text-sm transition-colors ${b.projectKey===e.key?`border-foreground/40 bg-accent text-foreground`:`border-input text-foreground hover:bg-accent`}`,children:e.name},e.key)),T.length>5&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":c,onClick:()=>l(e=>!e),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[`more projects`,(0,B.jsx)(ds,{className:`h-3.5 w-3.5`})]}),c&&(0,B.jsx)(`div`,{"data-testid":`new-workspace-project-overflow`,className:`absolute left-0 top-11 z-30 min-w-64 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:T.slice(5).map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>{b.setProjectKey(e.key),l(!1)},className:`block w-full rounded-md px-3 py-2 text-left text-sm text-popover-foreground hover:bg-accent`,children:e.name},e.key))})]})]}),(0,B.jsx)(`input`,{ref:n,"data-testid":`new-workspace-hero-title`,"data-region":`hero-title`,"aria-label":`Workspace name`,className:`display-xl mb-7 w-full border-0 bg-transparent p-0 text-foreground caret-primary outline-none placeholder:text-muted-foreground/40`,value:b.name,onChange:e=>b.setName(e.target.value),placeholder:`Untitled workspace`,autoComplete:`off`,spellCheck:!1,autoFocus:!0}),(0,B.jsxs)(`div`,{"data-testid":`new-workspace-target-row`,"data-region":`target-row`,className:`relative mb-10 flex min-h-9 flex-wrap items-center gap-2.5`,children:[(0,B.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-target-chip`,disabled:b.mode===`isolated`,"aria-expanded":u,onClick:()=>d(e=>!e),className:`inline-flex h-9 max-w-full items-center gap-2 rounded-lg border border-input bg-transparent px-3 font-mono text-xs text-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,B.jsx)(Ys,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`truncate`,children:D}),(0,B.jsx)(ds,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,B.jsx)(`div`,{className:`inline-flex h-9 overflow-hidden rounded-lg border border-input`,"aria-label":`Workspace mode`,children:[`shared`,`isolated`].map(e=>(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-mode-${e}`,"aria-pressed":b.mode===e,onClick:()=>b.setMode(e),className:`px-3 text-sm transition-colors ${b.mode===e?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e===`shared`?`Shared directory`:`Isolated worktree`},e))}),(0,B.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-advanced-toggle`,"aria-expanded":m,onClick:()=>h(e=>!e),className:`eyebrow inline-flex items-center gap-1 bg-transparent px-1 py-2 text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(ps,{className:`h-3 w-3 transition-transform ${m?`rotate-90`:``}`}),`Advanced`]}),u&&b.mode===`shared`&&(0,B.jsxs)(`div`,{"data-testid":`new-workspace-target-menu`,className:`absolute left-0 top-11 z-20 min-w-72 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:[E.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>{b.setTargetPath(e),d(!1),p(!1)},className:`block w-full rounded-md px-3 py-2 text-left font-mono text-xs text-popover-foreground hover:bg-accent`,children:e},e)),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{p(!0),d(!1)},className:`block w-full rounded-md px-3 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Browse…`})]}),m&&(0,B.jsx)(`input`,{"data-testid":`new-workspace-parent-branch-input`,"aria-label":`Parent branch`,value:b.parentBranch,onChange:e=>b.setParentBranch(e.target.value),placeholder:b.intent?.parentBranch??`parent branch`,className:`h-9 min-w-56 rounded-lg border border-input bg-transparent px-3 font-mono text-xs text-foreground outline-none placeholder:text-muted-foreground focus:border-ring`}),f&&b.mode===`shared`&&(0,B.jsx)(`div`,{className:`w-full rounded-lg border border-border bg-card p-3`,children:(0,B.jsx)(AQ,{initialPath:b.targetPath||void 0,onSelect:e=>{b.setTargetPath(e),p(!1)}})})]}),v&&b.projectKey&&(0,B.jsxs)(`div`,{"data-testid":`new-workspace-bootstrap-main`,className:`mb-5 flex items-center justify-between gap-4 rounded-lg border border-border px-3 py-2`,children:[(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`This project has no main workspace registered yet.`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-bootstrap-main-button`,disabled:b.creating,onClick:()=>{b.submitIntent({project:b.projectKey,bootstrapMain:!0}).then(e=>{e&&y(!1)})},className:`shrink-0 rounded-lg border border-input bg-transparent px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:`Register main workspace`})]}),(0,B.jsx)(`div`,{"data-testid":`new-workspace-hairline-top`,"data-region":`hairline-top`,className:`mb-5 border-t border-border`}),(0,B.jsxs)(`div`,{"data-testid":`new-workspace-status-strip`,"data-region":`status-strip`,className:`mb-5 flex min-h-12 flex-wrap items-center justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center font-mono text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`mr-2 h-1.5 w-1.5 shrink-0 rounded-full bg-success`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{children:`Memory enabled`}),O.length>0||b.error?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{"data-testid":`new-workspace-status-finding`,className:`text-destructive-foreground`,children:O.map(e=>e.message).join(` · `)||b.error})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:b.mode===`isolated`?`Isolated worktree`:`Files shared`}),(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:b.intent?.isGitRepository?`git repository`:`no git detected`}),b.intent?.path&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:b.intent.path})]}),b.intent?.branchName&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsxs)(`span`,{children:[`creates `,b.intent.branchName]})]}),b.intent?.wouldCreateWorktree&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{children:`worktree`})]}),b.intent?.unregisteredTargetPath&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsx)(`span`,{className:`text-destructive-foreground`,children:`unregistered target`})]}),k&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,B.jsxs)(`span`,{"data-testid":`new-workspace-status-parent`,children:[`parent `,k,A?` (inferred)`:``]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-cancel`,onClick:()=>{window.history.state?.tab===`workspace-new`&&window.history.length>1?window.history.back():e?e():(window.history.replaceState({tab:`home`},``,`/`),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`eyebrow bg-transparent px-2 py-2 text-muted-foreground hover:text-foreground`,children:`Cancel`}),(0,B.jsxs)(`button`,{type:`submit`,"data-testid":`new-workspace-submit`,disabled:!b.canCreate,className:`inline-flex h-12 items-center gap-3 rounded-xl bg-primary/15 px-5 text-sm font-semibold text-primary transition-colors hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-40`,children:[`Start workspace`,(0,B.jsx)(`span`,{className:`inline-grid h-6 min-w-6 place-items-center rounded-md bg-foreground/10 px-1.5 font-mono text-xs`,children:`↵`})]})]})]}),(0,B.jsx)(`div`,{"data-testid":`new-workspace-hairline-bottom`,"data-region":`hairline-bottom`,className:`mb-8 border-t border-border`}),(0,B.jsxs)(`div`,{"data-testid":`new-workspace-idea-grid`,"data-region":`idea-grid`,className:`min-h-48 flex-1`,children:[(0,B.jsx)(`h2`,{className:`eyebrow mb-4 font-mono`,children:`Ideas for your next workspace`}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3`,children:K5t.map(([e,t])=>(0,B.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-idea-card`,onClick:()=>{b.setName(t),n.current?.focus()},className:`flex min-h-28 flex-col gap-2 rounded-xl border border-transparent bg-foreground/[0.03] p-4 text-left transition-colors hover:bg-foreground/[0.055] active:scale-[0.985]`,children:[(0,B.jsx)(`span`,{className:`eyebrow font-mono`,children:e}),(0,B.jsx)(`span`,{className:`text-sm leading-relaxed text-foreground`,children:t})]},e))})]})]}),(0,B.jsx)(Lvt,{isOpen:o,onClose:()=>s(!1),onCreated:e=>{i.setQueryData([`registered-projects`],(t=[])=>[e,...t.filter(t=>t.key!==e.key)]),i.invalidateQueries({queryKey:[`registered-projects`],refetchType:`none`}),b.setProjectKey(e.key),s(!1)}})]})}function J5t(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Y5t(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function X5t(e){return e/100*window.innerHeight}function Z5t(e){return e/100*window.innerWidth}function Q5t(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 u9({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Q5t(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Y5t(t,i);break;case`em`:r=J5t(t,i);break;case`vh`:r=X5t(i);break;case`vw`:r=Z5t(i);break}return r}function d9(e){return parseFloat(e.toFixed(3))}function f9({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 p9(e){let{panels:t}=e,n=f9({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=d9(u9({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=d9(u9({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=d9(u9({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=d9(u9({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 m9(e,t=`Assertion error`){if(!e)throw Error(t)}function h9(e,t){return Array.from(t).sort(e===`horizontal`?$5t:e7t)}function $5t(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function e7t(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function t7t(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function n7t(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 r7t({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}=n7t(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return m9(i,`No rect found`),i}var g9;function i7t(){return g9===void 0&&(g9=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),g9}function a7t(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=h9(n,Array.from(t.children).filter(t7t).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,r7t({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=i7t()?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:f9({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 o7t=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)}}},_9=new Map,s7t=new o7t;function c7t(e){_9=new Map(_9),_9.delete(e)}function l7t(e,t){for(let[t]of _9)if(t.id===e)return t}function v9(e,t){for(let[t,n]of _9)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function y9(){return _9}function b9(e,t){return s7t.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function x9(e,t){let n=_9.get(e);_9=new Map(_9),_9.set(e,t),s7t.emit(`groupChange`,{group:e,prev:n,next:t})}function u7t(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=n7t(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 d7t(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function f7t(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:v7t(e),b:v7t(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();m9(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:_7t(g7t(n.a)),b:_7t(g7t(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 p7t=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function m7t(e){let t=getComputedStyle(y7t(e)??e).display;return t===`flex`||t===`inline-flex`}function h7t(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||m7t(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`||p7t.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function g7t(e){let t=e.length;for(;t--;){let n=e[t];if(m9(n,`Missing node`),h7t(n))return n}return null}function _7t(e){return e&&Number(getComputedStyle(e).zIndex)||0}function v7t(e){let t=[];for(;e;)t.push(e),e=y7t(e);return t}function y7t(e){let{parentNode:t}=e;return d7t(t)?t.host:t}function b7t(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 x7t({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!t7t(n)||n.contains(e)||e.contains(n))return!0;if(f7t(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(b7t(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function S9(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=a7t(r),a=u7t(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&x7t({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function S7t(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 C9(e,t,n=0){return Math.abs(d9(e)-d9(t))<=n}function w9(e,t){return C9(e,t)?0:e>t?1:-1}function T9({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(w9(r,c)<0)if(a){let e=(i+c)/2;r=w9(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=d9(r),r}function E9({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(C9(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;m9(u!=null,`Invalid first pivot index`),m9(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];m9(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(m9(n!=null,`Previous layout not found for panel index ${t}`),C9(n,i)){let t=o-n;w9(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];m9(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(m9(n!=null,`Previous layout not found for panel index ${t}`),C9(n,o)){let t=n-i;w9(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];m9(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&w9(i,c)<0)if(e>0){let t=c-o,n=t/2;w9(i+e,c)<0&&(e=w9(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;w9(i-e,c)<0&&(e=w9(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];m9(e!=null,`Previous layout not found for panel index ${r}`);let a=T9({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];m9(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=T9({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!C9(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(S7t(c,l))return i;{let t=e<0?d:u,r=s[t];m9(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=T9({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!C9(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];m9(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=T9({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(C9(i,s)||(t-=s-i,l[r]=s),C9(t,0))break;e>0?r--:r++}}}if(!C9(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 D9(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||w9(e[n],t[n])!==0)return!1;return!0}function O9({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(!C9(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];m9(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];m9(i!=null,`No layout data found for index ${e}`);let o=r[e];m9(o!=null,`No layout data found for index ${e}`);let s=T9({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!C9(a,0))for(let e=0;e<t.length;e++){let n=r[e];m9(n!=null,`No layout data found for index ${e}`);let i=n+a,o=T9({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,C9(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function C7t({groupId:e,panelId:t}){let n=()=>{let t=y9();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=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&C9(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:d9(100-e)}}return E9({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=O9({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});D9(c,u)||x9(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(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&&C9(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=f9({group:t});s(d9(u9({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function w7t(e){e.defaultPrevented||S9(e,y9()).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=C7t({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function k9(e){let t=y9();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 T7t({groupId:e}){let t=()=>{let t=y9();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=O9({layout:e,panelConstraints:r});return n?o:(D9(o,c)||x9(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function A9(e,t){let n=k9(e),r=v9(n.id,!0),i=n.separators.find(t=>t.element===e);m9(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);m9(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=T7t({groupId:n.id}).getLayout(),c=O9({layout:E9({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});D9(s,c)||x9(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function E7t(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=k9(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&A9(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&A9(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&A9(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&A9(t,-5);break;case`End`:e.preventDefault(),A9(t,100);break;case`Enter`:{e.preventDefault();let n=k9(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=v9(n.id,!0),o=n.separators.find(e=>e.element===t);m9(o,`Matching separator not found`);let s=a.get(o);m9(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(m9(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];A9(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=k9(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);m9(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(),A9(t,-100);break}}var j9={cursorFlags:0,state:`inactive`},M9=new o7t;function N9(){return j9}function D7t(e){return M9.addListener(`change`,e)}function O7t(e){let t=j9,n={...j9};n.cursorFlags=e,j9=n,M9.emit(`change`,{prev:t,next:n})}function P9(e){let t=j9;j9=e,M9.emit(`change`,{prev:t,next:e})}function k7t(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=y9(),n=S9(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),P9({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var A7t=e=>e,F9=()=>{},j7t=1,M7t=2,N7t=4,P7t=8,F7t=3,I7t=12,I9;function L7t(){return I9===void 0&&(I9=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(I9=!0)),I9}function R7t({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&&L7t()){let t=(e&j7t)!==0,n=(e&M7t)!==0,r=(e&N7t)!==0,i=(e&P7t)!==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 L7t()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var z7t=new WeakMap;function L9(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=z7t.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=N9();switch(r.state){case`active`:case`hover`:{let e=R7t({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}z7t.set(e,{prevStyle:t,styleSheet:n})}function B7t({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=E9({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(D9(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?j7t:M7t;break;case`vertical`:s|=d<0?N7t:P7t;break}}else x9(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&F7t:c|=s&F7t,t.movementY===0?c|=o&I7t:c|=s&I7t,O7t(c),L9(e)}function V7t(e){let t=y9(),n=N9();switch(n.state){case`active`:B7t({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function H7t(e){if(e.defaultPrevented)return;let t=N9(),n=y9();switch(t.state){case`active`:if(e.buttons===0){P9({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=v9(e.group.id,!0);x9(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)}B7t({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=S9(e,n);r.length===0?t.state!==`inactive`&&P9({cursorFlags:0,state:`inactive`}):P9({cursorFlags:0,hitRegions:r,state:`hover`}),L9(e.currentTarget);break}}}function U7t(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(N9().state){case`hover`:P9({cursorFlags:0,state:`inactive`})}}function W7t(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=N9();switch(t.state){case`active`:P9({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(L9(e.currentTarget),t.hitRegions.forEach(e=>{let t=v9(e.group.id,!0);x9(e.group,t)}),e.preventDefault())}}function G7t(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=d9(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=d9((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function K7t(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=f9({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:d9(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function q7t(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 J7t({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=d9(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]=d9((r[e]??0)/a*l);else{let e=d9(l/c.length);for(let t of c)u[t]=e}return u}function Y7t(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 R9=new Map;function X7t(e){let t=!0;m9(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=f9({group:e});if(t===0)return;let n=v9(e.id);if(!n)return;let r=p9(e),i=n.defaultLayoutDeferred?G7t(r):n.layout,a=O9({layout:J7t({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&D9(n.layout,a)&&q7t(n.derivedPanelConstraints,r)&&n.groupSize===t)return;x9(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else K7t(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{m9(!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=f9({group:e}),s=p9(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Y7t(e.panels,l)||(l=void 0));let u=O9({layout:e.mutableState.layouts[c]??l??G7t(s),panelConstraints:s}),d=e.element.ownerDocument;R9.set(d,(R9.get(d)??0)+1);let f=new Map;return a7t(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),x9(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{m9(!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`,E7t)}),R9.get(d)===1&&(d.addEventListener(`dblclick`,w7t,!0),d.addEventListener(`pointerdown`,k7t,!0),d.addEventListener(`pointerleave`,V7t),d.addEventListener(`pointermove`,H7t),d.addEventListener(`pointerout`,U7t),d.addEventListener(`pointerup`,W7t,!0)),function(){t=!1,R9.set(d,Math.max(0,(R9.get(d)??0)-1)),c7t(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,E7t)}),R9.get(d)||(d.removeEventListener(`dblclick`,w7t,!0),d.removeEventListener(`pointerdown`,k7t,!0),d.removeEventListener(`pointerleave`,V7t),d.removeEventListener(`pointermove`,H7t),d.removeEventListener(`pointerout`,U7t),d.removeEventListener(`pointerup`,W7t,!0)),a.disconnect()}}function Z7t(){let[e,t]=(0,z.useState)({});return[e,(0,z.useCallback)(()=>t({}),[])]}function z9(e){let t=(0,z.useId)();return`${e??t}`}var B9=typeof window<`u`?z.useLayoutEffect:z.useEffect;function V9(e){let t=(0,z.useRef)(e);return B9(()=>{t.current=e},[e]),(0,z.useCallback)((...e)=>t.current?.(...e),[t])}function H9(...e){return V9(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function U9(e){let t=(0,z.useRef)({...e});return B9(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Q7t=(0,z.createContext)(null);function $7t(e,t){let n=(0,z.useRef)({getLayout:()=>({}),setLayout:A7t});(0,z.useImperativeHandle)(t,()=>n.current,[]),B9(()=>{Object.assign(n.current,T7t({groupId:e}))})}function e9t({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,z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=V9(e=>{D9(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=V9(e=>{D9(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=z9(s),v=(0,z.useRef)(null),[y,b]=Z7t(),x=(0,z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=H9(v,a);$7t(_,o);let C=V9((e,t)=>{let r=N9(),i=l7t(e),a=v9(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=U9({defaultLayout:n,disableCursor:r}),T=(0,z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=h9(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=h9(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=l7t(_),i=v9(_);r&&i&&x9(r,{...i,derivedPanelConstraints:p9(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,z.useRef)(null);return B9(()=>{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=X7t(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=v9(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=b9(_,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=C9(t.collapsedSize,i[t.panelId]),a=C9(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=N9().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,B.jsx)(Q7t.Provider,{value:T,children:(0,B.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})})}e9t.displayName=`Group`;function W9(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function t9t({id:e,panelIds:t,storage:n}){let r=W9(e,[]),i=n.getItem(r);if(i)try{let e=JSON.parse(i);if(t){let n=e[t.join(`,`)];if(n&&Array.isArray(n.layout)&&t.length===n.layout.length){let e={};for(let r=0;r<t.length;r++)e[t[r]]=n.layout[r];return e}}else{let t=Object.keys(e);if(t.length===1){let n=e[t[0]];if(n&&Array.isArray(n.layout)){let e=t[0].split(`,`);if(e.length===n.layout.length){let t={};for(let r=0;r<e.length;r++)t[e[r]]=n.layout[r];return t}}}}}catch{}}function n9t({debounceSaveMs:e=100,panelIds:t,storage:n=localStorage,...r}){let i=t!==void 0,a=`id`in r?r.id:r.groupId,o=W9(a,t??[]),s=(0,z.useSyncExternalStore)(r9t,()=>n.getItem(o),()=>n.getItem(o)),c=(0,z.useMemo)(()=>{if(s){let e=JSON.parse(s),t=Object.values(e);if(Array.from(t).every(e=>typeof e==`number`))return e}},[s]),l=(0,z.useMemo)(()=>{if(!c)return t9t({id:a,panelIds:t,storage:n})},[c,a,t,n]),u=c??l,d=(0,z.useRef)(null),f=(0,z.useCallback)(()=>{let e=d.current;e&&(d.current=null,clearTimeout(e))},[]);(0,z.useLayoutEffect)(()=>()=>{f()},[f]);let p=(0,z.useCallback)(e=>{f();let t;t=i?W9(a,Object.keys(e)):W9(a,[]);try{n.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[f,i,a,n]);return{defaultLayout:u,onLayoutChange:(0,z.useCallback)(t=>{f(),e===0?p(t):d.current=setTimeout(()=>{p(t)},e)},[f,e,p]),onLayoutChanged:p}}function r9t(){return function(){}}function G9(){let e=(0,z.useContext)(Q7t);return m9(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function i9t(e,t){let{id:n}=G9(),r=(0,z.useRef)({collapse:F9,expand:F9,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:F9});(0,z.useImperativeHandle)(t,()=>r.current,[]),B9(()=>{Object.assign(r.current,C7t({groupId:n,panelId:e}))})}function K9({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=z9(c),_=U9({disabled:a}),v=(0,z.useRef)(null),y=H9(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=G9(),T=d!==null,E=V9((e,t,n)=>{d?.(e,c,n)});B9(()=>{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,z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),i9t(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,z.useSyncExternalStore)(e=>b9(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,B.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...a9t,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,B.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}K9.displayName=`Panel`;var a9t={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function o9t({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=O9({layout:E9({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=O9({layout:E9({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function q9({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=z9(a),l=U9({disabled:n,disableDoubleClick:r}),[u,d]=(0,z.useState)({}),[f,p]=(0,z.useState)(`inactive`),[m,h]=(0,z.useState)(!1),g=(0,z.useRef)(null),_=H9(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=G9(),C=b===`horizontal`?`vertical`:`horizontal`;B9(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=D7t(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=b9(y,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(o9t({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,z.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,B.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}q9.displayName=`Separator`;function s9t(e,t){return e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)}function c9t({workspaceId:e,onBack:t}){let{data:n}=V({queryKey:[`workspace-registry`,e],queryFn:async()=>{let t=await fetch(`/api/workspace-registry/${e}`);return t.ok?t.json():null}}),{data:r}=V({queryKey:[`workspace-registry`,e,`memory`],queryFn:async()=>{let t=await fetch(`/api/workspace-registry/${e}/memory`);return t.ok?t.json():null},refetchInterval:15e3,enabled:!!n}),{data:i}=V({queryKey:[`workspace-plan`,n?.issueId],queryFn:async()=>{if(!n?.issueId)return null;let e=await fetch(`/api/workspaces/${n.issueId}/plan`);return e.ok?e.json():null},enabled:!!n?.issueId}),{data:a}=V({queryKey:[`conversations`],queryFn:dO,refetchInterval:1e4}),o=Array.isArray(a)?a:[],[s,c]=(0,z.useState)(!1),l=(0,z.useMemo)(()=>{if(s||!n)return;let t=new Set;for(let r of o)(r.workspaceId==null?s9t(r.cwd,n.path):r.workspaceId===e)&&t.add(r.id);return t},[s,n,e,o]),u=jLe(e),d=(0,z.useCallback)(t=>{OLe(e,t)},[e]),[f,p]=(0,z.useState)(null),m=o.find(e=>e.name===f)??null,h=Q(cS),g=(0,z.useMemo)(()=>{if(!n?.issueId)return null;let e=n.issueId.toLowerCase();return h.find(t=>t.issueId?.toLowerCase()===e)??null},[h,n]),_=(0,z.useMemo)(()=>{let t=n?.layoutConfig??null;return{getItem:()=>t,setItem:(n,r)=>{t=r;let i;try{i=JSON.parse(r)}catch{return}fetch(`/api/workspace-registry/${e}/layout`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({layout:i})})}}},[e,n!==void 0]),{defaultLayout:v,onLayoutChanged:y}=n9t({id:`workspace-${e}`,storage:_}),b=yt(),x=ul(),[S,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(null),E=(0,z.useCallback)(()=>{b.invalidateQueries({queryKey:[`workspace-registry`]}),b.invalidateQueries({queryKey:[`workspace-registry`,e]})},[b,e]),D=(0,z.useCallback)(async(t,n)=>{T(null);try{let r=await vl(`/api/workspace-registry/${e}${t}`,{method:`POST`,credentials:`include`,headers:await sb(),body:JSON.stringify(n)});return r.ok?(E(),!0):(T((await r.json().catch(()=>({}))).error??`HTTP ${r.status}`),!1)}catch(e){return T(e instanceof Error?e.message:String(e)),!1}},[e,E]),O=(0,z.useCallback)(()=>{D(`/favorite`,{favorite:!n?.isFavorite})},[D,n?.isFavorite]),k=(0,z.useCallback)(async()=>{await x({title:`Archive workspace`,message:`Archive '${n?.name}'? It disappears from the rail but its files, branch and memory are left untouched.`,confirmLabel:`Archive`,variant:`destructive`})&&D(`/archive`,{archived:!0})},[x,D,n?.name]),A=(0,z.useCallback)(async e=>{C(!1);let t=n?.kind===`main`;await x({title:`Relocate workspace`,message:t?`Point the main workspace at ${e}? Its path will diverge from projects.yaml's primary path.`:`Point '${n?.name}' at ${e}?`,confirmLabel:`Relocate`,...t?{variant:`destructive`,requiredText:n?.name??`main`}:{}})&&D(`/relocate`,t?{path:e,force:!0}:{path:e})},[x,D,n?.kind,n?.name]);return n?(0,B.jsxs)(`div`,{className:`flex flex-col w-full h-full overflow-hidden`,"data-testid":`workspace-view`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-border shrink-0`,children:[t&&(0,B.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`workspace-view-back`,className:`text-muted-foreground hover:text-foreground text-sm`,children:`← Back`}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:n.title??n.name}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:n.kind}),n.kind!==`issue`&&(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,"data-testid":`workspace-view-actions`,children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-favorite`,onClick:O,"aria-pressed":n.isFavorite,className:`text-xs text-muted-foreground hover:text-foreground`,children:n.isFavorite?`Unfavorite`:`Favorite`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-relocate`,onClick:()=>C(e=>!e),className:`text-xs text-muted-foreground hover:text-foreground`,children:`Relocate`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-archive`,onClick:()=>void k(),className:`text-xs text-destructive hover:brightness-110`,children:`Archive`})]})]}),S&&n.kind!==`issue`&&(0,B.jsx)(`div`,{className:`border-b border-border px-4 py-2 shrink-0`,"data-testid":`workspace-view-relocate-picker`,children:(0,B.jsx)(AQ,{onSelect:e=>void A(e),initialPath:n.path})}),w&&(0,B.jsx)(`div`,{className:`border-b border-border px-4 py-2 text-xs text-destructive shrink-0`,"data-testid":`workspace-view-action-error`,children:w}),(0,B.jsx)(MLe,{workspaceId:e,kind:n.kind,issueId:n.issueId,isGitRepository:n.isGitRepository!==!1,runCommand:n.runCommand??null,runCommandDefault:n.runCommandDefault??null,runCommandOptions:n.runCommandOptions??[],openInEditorConfigured:n.openInEditorConfigured===!0,runSessionName:u,onRunSessionChange:d},e),n.kind===`issue`&&n.issueId&&(0,B.jsxs)(`div`,{className:`border-b border-border p-3 space-y-3 shrink-0 max-h-64 overflow-y-auto`,"data-testid":`workspace-view-issue-panels`,children:[(0,B.jsx)(XZ,{issueId:n.issueId}),(0,B.jsx)(rZ,{doc:i??null,showTabBar:!1})]}),(0,B.jsxs)(e9t,{orientation:`horizontal`,defaultLayout:v,onLayoutChanged:y,className:`flex-1 min-h-0`,id:`workspace-${e}`,children:[(0,B.jsxs)(K9,{id:`terminal`,defaultSize:34,minSize:15,className:`min-w-0 h-full overflow-hidden flex flex-col`,children:[g?(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(KP,{sessionName:g.id,embedded:!0})}):u?null:(0,B.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,"data-testid":`workspace-view-no-terminal`,children:`No active agent terminal for this workspace.`}),u&&(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col border-t border-border first:border-t-0`,"data-testid":`workspace-view-run-terminal`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground px-3 py-1 shrink-0`,children:`Run`}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(KP,{sessionName:u,embedded:!0})})]})]}),(0,B.jsx)(q9,{className:`w-px bg-border`}),(0,B.jsxs)(K9,{id:`conversations`,defaultSize:33,minSize:15,className:`min-w-0 h-full overflow-hidden flex flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground`,children:`Conversations`}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-all-conversations-toggle`,onClick:()=>c(e=>!e),className:`text-[10px] text-muted-foreground hover:text-foreground`,children:s?`This workspace`:`All conversations`})]}),(0,B.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:m?(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-conversation-back`,onClick:()=>p(null),className:`text-left px-3 py-1.5 text-[11px] text-muted-foreground hover:text-foreground border-b border-border shrink-0`,children:`← All conversations`}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(QX,{conversation:m,embedded:!0})})]}):(0,B.jsx)(UGe,{selectedConversation:f,onSelectConversation:p,includeIds:l})})]}),(0,B.jsx)(q9,{className:`w-px bg-border`}),(0,B.jsxs)(K9,{id:`memory`,defaultSize:33,minSize:15,className:`min-w-0 h-full overflow-y-auto p-3`,children:[(0,B.jsxs)(`p`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground mb-2`,children:[`Memory`,r?.status&&(0,B.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/70`,"data-testid":`workspace-view-memory-phase`,children:[r.status.phase,typeof r.status.confidence==`number`&&` · confidence ${r.status.confidence}`]})]}),r?.status?(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`workspace-view-memory-status`,children:[(0,B.jsx)(`p`,{className:`text-sm text-foreground`,children:r.status.headline}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.status.summary}),r.status.nextSteps.length>0&&(0,B.jsx)(`ul`,{className:`text-xs text-muted-foreground list-disc pl-4`,children:r.status.nextSteps.map(e=>(0,B.jsx)(`li`,{children:e},e))})]}):(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`No memory status yet.`}),(0,B.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground mt-4 mb-2`,children:`Observations`}),(0,B.jsx)(`ul`,{className:`space-y-2`,"data-testid":`workspace-view-observation-timeline`,children:(r?.observations??[]).map(e=>(0,B.jsxs)(`li`,{className:`text-xs text-muted-foreground border-l-2 border-border pl-2`,children:[(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.timestamp}),(0,B.jsx)(`p`,{className:`text-foreground`,children:e.actionStatus??e.summary})]},e.id))})]})]})]}):(0,B.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,"data-testid":`workspace-view-loading`,children:`Loading workspace…`})}function l9t({backendDown:e,restarting:t,children:n}){let[r,i]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let e=()=>i(!0),t=()=>i(!1);return window.addEventListener(bS,e),window.addEventListener(xS,t),()=>{window.removeEventListener(bS,e),window.removeEventListener(xS,t)}},[]),e||t?(0,B.jsx)(`div`,{role:`status`,className:`flex h-full w-full items-center justify-center bg-background p-8`,children:(0,B.jsxs)(`div`,{className:`flex max-w-md items-start gap-3 text-left`,children:[(0,B.jsx)(Mc,{className:`mt-0.5 h-5 w-5 shrink-0 animate-spin text-primary`,"aria-hidden":`true`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:t?`Dashboard is restarting`:`Waiting for backend data`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Live data will return automatically when the backend connection is restored.`})]})]})}):(0,B.jsxs)(B.Fragment,{children:[n,r&&(0,B.jsx)(`div`,{role:`status`,className:`pointer-events-none fixed left-1/2 top-3 z-50 -translate-x-1/2`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground shadow-md`,children:[(0,B.jsx)(Mc,{className:`h-4 w-4 animate-spin text-primary`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{children:`Connection lost — reconnecting…`})]})})]})}function u9t({activeTab:e,backendDown:t,restarting:n,issues:r,selectedConvId:i,conversationViewMode:a,selectedProjectKey:o,pendingConversationTarget:s,cockpitRoute:c,workspaceRouteId:l,onWorkspaceViewBack:u,onWorkspaceCreated:d,initialSessionKey:f,onOpenWorkspaceHome:p,onNewProject:m,onSelectProject:h,onOpenSettings:g,onConvIdChange:_,onConversationViewModeChange:v,onPendingConversationTargetConsumed:y,onProjectPrefixChange:b,onCockpitChange:x,onSearchOpen:S,onTabChange:C,onOpenIssue:w,onPlanDialogChange:T,onSelectAgent:E,onBacklogIssueAction:D,keyboardShortcutsDisabled:O=!1}){return(0,B.jsxs)(l9t,{backendDown:t,restarting:n,children:[e===`home`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(g$t,{advanced:(0,B.jsx)(C5t,{onOpenWorkspaceHome:p,onNewProject:m,onSelectProject:h,onOpenSettings:g})})}),e===`command-deck`&&(0,B.jsx)(`div`,{className:`w-full h-full`,children:(0,B.jsx)(gHt,{issues:r,convId:i,conversationViewMode:a,onConvIdChange:_,onConversationViewModeChange:v,pendingConversationTarget:s,onPendingConversationTargetConsumed:y,selectedProject:o,onSelectProject:h,onProjectPrefixChange:b,cockpitIssue:c,onCockpitChange:x})}),e===`workspace-new`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(q5t,{onCancel:()=>C(`home`),onCreated:d})}),e===`workspace`&&l&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(c9t,{workspaceId:l,onBack:u})}),e===`pipeline`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(y$t,{}),children:(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(rUt,{onSearchOpen:S,onTabChange:e=>C(e),keyboardShortcutsDisabled:O})})}),e===`awaiting-merge`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-auto`,children:(0,B.jsx)(DWt,{})}),e===`kanban`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:(0,B.jsx)(_$t,{})}),children:(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:[(0,B.jsx)(rTt,{}),(0,B.jsx)(CCt,{selectedIssue:null,onSelectIssue:e=>{e&&w(e)},onPlanDialogChange:T,keyboardShortcutsDisabled:O})]})})}),e===`agents`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(v$t,{}),children:(0,B.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,B.jsx)(dwt,{onNavigateToIssues:()=>C(`kanban`)})})}),e===`resources`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(AGt,{onNavigateToAgents:e=>{E(e),C(`agents`)}})}),e===`knowledge`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(VZt,{projectKey:o})}),e===`skills`&&(0,B.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,B.jsx)(zwt,{})}),e===`context`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(FZt,{})}),e===`health`&&(0,B.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,B.jsx)(Rwt,{})}),e===`activity`&&(0,B.jsx)(`div`,{className:`w-full h-full`,children:(0,B.jsx)(tTt,{onClose:()=>C(`kanban`)})}),e===`metrics`&&(0,B.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,B.jsx)(oTt,{})}),e===`costs`&&(0,B.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,B.jsx)(Hjt,{})}),e===`autopreso`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(AQt,{})}),e===`flywheel`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(vWt,{onOpenSettings:g,onNavigateAgent:e=>{E(e),C(`agents`)},onNavigateIssue:e=>w(e)})}),e===`orders`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(e1t,{})}),e===`backlog`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(m5t,{onIssueAction:D})}),e===`settings`&&(0,B.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,B.jsx)(FPt,{})}),e===`sessions`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(bQt,{initialSessionKey:f})}),e===`god-view`&&(0,B.jsx)(Y8,{fallback:(0,B.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,B.jsx)(b$t,{})}),children:(0,B.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,B.jsx)(GYt,{})})}),e===`deacon`&&(0,B.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,B.jsx)(rXt,{})})]})}var J9=[`boot-reconciliation`];async function d9t(){let e=await fetch(`/api/boot-reconciliation`);if(!e.ok)throw Error(`GET /api/boot-reconciliation -> ${e.status}`);return e.json()}async function f9t(e){let t=await fetch(`/api/boot-reconciliation/decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`POST /api/boot-reconciliation/decision -> ${t.status}`)}return t.json()}async function p9t(){let e=await fetch(`/api/boot-reconciliation/extend`,{method:`POST`});if(!e.ok)throw Error(`POST /api/boot-reconciliation/extend -> ${e.status}`)}function m9t(e={},t=0){let n=[[`workspace_missing`,`workspace missing`],[`merged`,`already merged`],[`completed`,`completed`],[`other`,`not resumable`]].map(([t,n])=>({count:e[t]??0,label:n})).filter(e=>e.count>0).map(e=>`${e.count} ${e.label}`);return t>0&&n.push(`${t} deferred`),n.join(`, `)}function h9t(e){switch(e){case`already-running`:return`already running`;case`no-resumable-session`:return`no resumable session`;case`deferred-concurrency`:return`deferred by concurrency limit`;case`deferred-load`:return`deferred by load gate`;case`deferred-memory`:return`deferred by memory gate`;case`resumed`:return`resumed`;default:return e.replaceAll(`-`,` `)}}function g9t(e){if(e.skipped||e.deferred){let t=m9t(e.skipped,e.deferred??0);return e.count>0?`Boot decision saved. Resuming ${e.count} agent${e.count===1?``:`s`}.${t?` Also skipped ${t}.`:``}`:`Boot decision saved. No agents resumed${t?` — ${t}`:``}.`}let t=Array.isArray(e.outcomes)?e.outcomes.filter(e=>e.outcome===`skipped`):[];if(t.length===0)return`Boot decision saved. Resumed ${e.count} agent${e.count===1?``:`s`}.`;let n=new Map;for(let e of t)n.set(e.reason,(n.get(e.reason)??0)+1);let r=Array.from(n.entries()).map(([e,t])=>`${t} ${h9t(e)}`).join(`, `);return`Boot decision saved. Resumed ${e.count} — ${t.length} skipped (${r}).`}async function _9t(){let e=await fetch(`/api/deacon/pause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paused:!0})});if(!e.ok)throw Error(`POST /api/deacon/pause -> ${e.status}`);return e.json()}function v9t(e){if(!e)return`startup`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function y9t(e){if(!e)return`unknown`;let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=Math.max(0,Math.round((Date.now()-t.getTime())/1e3));if(n<60)return`${n}s ago`;let r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function b9t(e){let[t,n]=(0,z.useState)(Date.now());if((0,z.useEffect)(()=>{let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[]),!e)return 0;let r=Date.parse(e)-t;return Math.max(0,Math.ceil(r/1e3))}function x9t(e){let t=Math.max(0,Math.ceil(e)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function S9t(e){switch(e){case`running_remote`:return`Running remote ($)`;case`orphaned`:return`Orphaned (tmux gone)`;case`paused_troubled`:return`Paused / troubled`;default:return`Stopped cleanly`}}var C9t=[`running_remote`,`orphaned`,`stopped_cleanly`,`paused_troubled`];function w9t(){let e=yt(),t=dl(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)({}),{data:o}=V({queryKey:J9,queryFn:d9t,staleTime:5e3,refetchInterval:e=>{let t=e.state.data?.decision;return t===`pending`?1e4:t===`hold_all`||t===`per_agent`?3e4:!1},refetchOnWindowFocus:!0});(0,z.useEffect)(()=>{let t=()=>{e.invalidateQueries({queryKey:J9})};return window.addEventListener(`overdeck:reconnected`,t),()=>window.removeEventListener(`overdeck:reconnected`,t)},[e]),(0,z.useEffect)(()=>{if(!o)return;let e=Array.isArray(o.set)?o.set:[],t=o.perAgent??{};a(Object.fromEntries(e.filter(e=>!e.readOnly).map(e=>[e.issueId,t[e.issueId]??(e.stoppedByUser?`hold`:`resume`)])))},[o]);let s=Mt({mutationFn:f9t,onSuccess:n=>{e.invalidateQueries({queryKey:J9}),e.invalidateQueries({queryKey:[`agents`]}),t({message:g9t(n),variant:`success`})},onError:e=>{t({message:`Boot reconciliation failed: ${e.message}`,variant:`error`})}}),c=Mt({mutationFn:_9t,onSuccess:()=>{e.invalidateQueries({queryKey:[`deacon`,`pause`]}),s.mutate({decision:`hold_all`})},onError:e=>{t({message:`Freeze failed: ${e.message}`,variant:`error`})}}),l=(0,z.useMemo)(()=>{let e=new Map;for(let t of C9t)e.set(t,[]);let t=Array.isArray(o?.set)?o.set:[];for(let n of t)e.get(n.concern)?.push(n);return e},[o?.set]),u=b9t(o?.graceDeadline??null),d=jG().length>0,f=o?.graceExtensions??0,p=o?.maxGraceExtensions??0,m=d&&f<p;if((0,z.useEffect)(()=>{o?.decision!==`pending`||!d||f>=p||u>30||p9t().then(()=>{e.invalidateQueries({queryKey:J9})}).catch(()=>{})},[o?.decision,d,f,p,u,e]),o&&(o.decision===`hold_all`||o.decision===`per_agent`)){let e=o.perAgent??{},t=(Array.isArray(o.set)?o.set:[]).filter(t=>!t.readOnly&&(o.decision!==`per_agent`||e[t.issueId]!==`resume`));if((o.heldCount??0)===0)return null;let n=s.isPending;return(0,B.jsxs)(`div`,{className:`badge-bg-warning badge-border-warning flex items-center gap-2 border-b px-4 py-1.5`,"data-testid":`boot-reconciliation-held-banner`,children:[(0,B.jsx)(Oc,{className:`w-4 h-4 shrink-0 text-warning`}),(0,B.jsxs)(`p`,{className:`flex-1 truncate text-xs font-medium text-warning-foreground`,title:`Boot reconciliation is holding ${t.length} stopped agent${t.length===1?``:`s`} from the boot at ${v9t(o.decidedAt??o.graceDeadline)}. Held agents will not pick up work until resumed. Resume all puts them back to work; pan start <id> spawns one individually.`,children:[`Holding `,t.length,` stopped agent`,t.length===1?``:`s`,` from boot — they won't pick up work until resumed`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate({decision:`resume_all`}),disabled:n,"data-testid":`boot-reconciliation-held-resume-all`,className:`inline-flex h-[26px] shrink-0 items-center gap-1.5 rounded-[var(--radius-sm)] bg-warning px-[10px] text-[11px] font-medium text-warning-foreground transition-opacity hover:bg-warning/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,B.jsx)(Ac,{className:`w-3 h-3`}),n?`Resuming…`:`Resume all`]})]})}if(o?.decision!==`pending`)return null;let h=(Array.isArray(o.set)?o.set:[]).filter(e=>!e.readOnly).length,g=Array.isArray(o.context)?o.context:[];if(h===0)return null;let _=s.isPending||c.isPending;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[110] flex items-start justify-center overflow-y-auto bg-black/45 px-4 py-8 backdrop-blur-sm`,children:(0,B.jsxs)(`section`,{className:`w-full max-w-5xl rounded-lg border badge-border-warning bg-card text-foreground shadow-2xl`,"data-testid":`boot-reconciliation-modal`,"aria-label":`Boot reconciliation`,children:[(0,B.jsx)(`div`,{className:`border-b badge-border-warning px-5 py-4`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-warning`,children:[(0,B.jsx)(il,{className:`h-4 w-4`}),`Unverified dashboard boot`]}),(0,B.jsx)(`h2`,{className:`mt-1 text-xl font-semibold text-foreground`,children:`Boot Reconciliation`}),(0,B.jsxs)(`p`,{className:`mt-1 max-w-3xl text-sm text-muted-foreground`,children:[h,` stopped `,h===1?`agent is`:`agents are`,` held from the boot at `,v9t(o.decidedAt??o.graceDeadline),`. Resume them now, keep them stopped, or choose per agent. The server timer is authoritative; no agent resumes before this boot decision is applied.`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border badge-border-warning badge-bg-warning px-3 py-2`,children:[(0,B.jsx)(`div`,{className:`grid h-12 w-12 place-items-center rounded-full border-4 border-warning/70 text-sm font-semibold text-warning-foreground`,children:u}),(0,B.jsxs)(`div`,{className:`text-sm`,children:[(0,B.jsxs)(`div`,{className:`font-semibold text-warning-foreground`,children:[`Applying boot default in `,x9t(u)]}),(0,B.jsx)(`div`,{className:`text-xs text-warning-foreground/70`,children:m?`Paused — answer the other open question first (${f}/${p} extensions used).`:`If the timer runs out, clean boots resume and crash boots stay stopped.`})]})]})]})}),(0,B.jsxs)(`div`,{className:`grid gap-4 px-5 py-4`,children:[C9t.map(e=>{let t=l.get(e)??[];return t.length===0?null:(0,B.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/60`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 px-3 py-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:S9t(e)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.length})]}),(0,B.jsx)(`div`,{className:`divide-y divide-border/60`,children:t.map(e=>{let t=i[e.issueId]??`resume`;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-3 px-3 py-2`,"data-testid":`boot-reconciliation-row-${e.issueId}`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-sm font-semibold text-foreground`,children:e.issueId}),(0,B.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:e.role}),e.remote&&(0,B.jsx)(`span`,{className:`rounded border badge-border-success badge-bg-success px-1.5 py-0.5 text-[11px] text-success-foreground`,children:`remote`}),e.readOnly&&(0,B.jsx)(`span`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:`read-only`})]}),(0,B.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.model??`unknown model`,` - `,e.whyStopped,` - last activity `,y9t(e.lastActivity),e.cost==null?``:` - $${e.cost.toFixed(2)}`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n&&!e.readOnly?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>({...t,[e.issueId]:`resume`})),"data-testid":`boot-reconciliation-resume-${e.issueId}`,className:`inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium ${t===`resume`?`bg-success text-success-foreground hover:bg-success/90`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:[(0,B.jsx)(Ac,{className:`h-3.5 w-3.5`}),`Resume`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>({...t,[e.issueId]:`hold`})),"data-testid":`boot-reconciliation-hold-${e.issueId}`,className:`inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium ${t===`hold`?`bg-warning text-warning-foreground hover:bg-warning/90`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:[(0,B.jsx)(Oc,{className:`h-3.5 w-3.5`}),`Keep`]})]}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.readOnly?`Not resumable here`:`Resume candidate`}),(0,B.jsx)(`button`,{type:`button`,disabled:!0,title:`Kill actions are supplied by the remote inventory contract.`,className:`inline-flex h-8 items-center rounded-md border border-border px-2 text-xs text-muted-foreground`,children:`Kill`})]})]},e.id)})})]},e)}),g.length>0&&(0,B.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-background/40`,"data-testid":`boot-reconciliation-context`,children:[(0,B.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-sm text-muted-foreground`,children:[`Not part of this boot decision (`,g.length,`) — paused, troubled, or running remote from earlier sessions`]}),(0,B.jsx)(`div`,{className:`divide-y divide-border/60 border-t border-border/70`,children:g.map(e=>(0,B.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2 px-3 py-2`,"data-testid":`boot-reconciliation-context-row-${e.issueId}`,children:[(0,B.jsx)(`span`,{className:`font-mono text-sm font-semibold text-foreground`,children:e.issueId}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.whyStopped})]},e.id))})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border/70 px-5 py-4`,children:[n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{s.mutate({decision:`per_agent`,perAgent:i})},disabled:_,"data-testid":`boot-reconciliation-apply-per-agent`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-success px-3 text-sm font-semibold text-success-foreground hover:bg-success/90 disabled:opacity-50`,children:[(0,B.jsx)(_s,{className:`h-4 w-4`}),`Apply per-agent choices`]}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Resuming `,Object.values(i).filter(e=>e===`resume`).length,` of `,h,`; read-only rows stay stopped.`]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate({decision:`resume_all`}),disabled:_,"data-testid":`boot-reconciliation-resume-all`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-warning px-3 text-sm font-semibold text-warning-foreground hover:bg-warning/90 disabled:opacity-50`,children:[(0,B.jsx)(Ac,{className:`h-4 w-4`}),`Resume all now`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s.mutate({decision:`hold_all`}),disabled:_,"data-testid":`boot-reconciliation-hold-all`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-muted px-3 text-sm font-medium text-foreground hover:bg-muted/80 disabled:opacity-50`,children:[(0,B.jsx)(Oc,{className:`h-4 w-4`}),`Keep all stopped`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),disabled:_,"data-testid":`boot-reconciliation-review-each`,className:`inline-flex h-9 items-center gap-1.5 rounded-md border border-border px-3 text-sm font-medium text-foreground hover:bg-muted disabled:opacity-50`,children:[(0,B.jsx)(Uie,{className:`h-4 w-4`}),`Review each`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c.mutate(),disabled:_,"data-testid":`boot-reconciliation-freeze`,className:`inline-flex h-9 items-center gap-1.5 rounded-md bg-destructive px-3 text-sm font-semibold text-destructive-foreground hover:bg-destructive/90 disabled:opacity-50`,children:[(0,B.jsx)(Yc,{className:`h-4 w-4`}),`Freeze everything`]})]}),(0,B.jsx)(`div`,{className:`ml-auto max-w-xl text-xs text-muted-foreground`,children:`Freeze uses the existing persisted Deacon pause surface. The boot choice is saved durably, so a watchdog restart does not re-prompt this boot.`})]})]})})}async function T9t(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}function E9t({onOpenSettings:e}){let{data:t}=V({queryKey:[`settings`],queryFn:T9t,retry:!1});return t?.background_ai?.cheap_mode===!0?(0,B.jsxs)(`button`,{type:`button`,"data-testid":`low-cost-mode-pill`,onClick:()=>{Ujt(`background-ai`),e?.()},title:`Background AI (titles, memory, enrichment, narration) is off to save cost. Memory in particular is one of Overdeck's most valuable features — click to choose what runs.`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,B.jsx)(Xs,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Low-cost mode`,(0,B.jsx)(hs,{className:`h-3.5 w-3.5 text-muted-foreground/70`,"aria-hidden":`true`})]}):null}function D9t(e){_vt(e)}function O9t(){let e=MG(),[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);if((0,z.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),e.length===0)return null;let i=`${e.length} decision${e.length===1?``:`s`} waiting on you — click to view`;return(0,B.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),title:i,"aria-label":i,"aria-expanded":t,"data-testid":`decisions-indicator`,className:`inline-flex h-5 items-center gap-1.5 rounded-sm border px-1.5 text-[10px] font-medium badge-bg-warning badge-border-warning text-warning-foreground tabular-nums`,children:[(0,B.jsx)(Bie,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e.length]}),t&&(0,B.jsx)(`div`,{className:`absolute top-full right-0 z-[200] mt-2 w-[26rem] max-h-[70vh] overflow-y-auto rounded-xl border border-border bg-popover p-2 text-sm shadow-lg`,children:(0,B.jsx)(bvt,{onOpenSubject:e=>{D9t(e),n(!1)}})})]})}async function k9t(e){let t=await fetch(`/api/flywheel/current`,{signal:e});if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}function A9t({onActivate:e}){let[t,n]=(0,z.useState)(null);(0,z.useEffect)(()=>{let e=!1,t=0,r=null;(async()=>{r?.abort();let i=new AbortController;r=i;let a=t;try{let o=await k9t(i.signal);!e&&r===i&&t===a&&n(o)}catch{}})();let i=ub(e=>{t+=1,r?.abort(),r=null,n(e)});return()=>{e=!0,t+=1,r?.abort(),i()}},[]);let r=t?.openQuestions?.length??0;if(r===0)return null;let i=`${r} open Flywheel question${r===1?``:`s`} — click to view`;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{JUt(),e()},title:i,"aria-label":i,className:`inline-flex h-5 items-center gap-1.5 rounded-sm border px-1.5 text-[10px] font-medium badge-bg-warning badge-border-warning text-warning-foreground tabular-nums`,children:[(0,B.jsx)(yc,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r]})}async function j9t(){let e=await fetch(`/api/cloister/status`);if(!e.ok)throw Error(`Failed to fetch Cloister status`);return e.json()}async function M9t(){if(!(await fetch(`/api/cloister/start`,{method:`POST`})).ok)throw Error(`Failed to start Cloister`)}async function N9t(){if(!(await fetch(`/api/cloister/stop`,{method:`POST`})).ok)throw Error(`Failed to stop Cloister`)}async function P9t(){let e=await fetch(`/api/cloister/emergency-stop`,{method:`POST`});if(!e.ok)throw Error(`Failed to execute emergency stop`);return e.json()}async function F9t(){let e=await vl(`/api/conversations`);return e.ok?e.json():[]}async function I9t(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`Failed to fetch settings`);return e.json()}async function L9t(){let e=await fetch(`/api/tts/health`);if(!e.ok)throw Error(`Failed to fetch TTS health`);return e.json()}async function R9t(){let e=await fetch(`/api/agents/restart-with-current-config`);if(!e.ok)throw Error(`Failed to fetch restart config list`);let t=await e.json();return{items:t.items||[],changedAgents:t.changedAgents||0}}function z9t(e,t){if(t)return`TTS: Health check failed`;if(!e)return`TTS: Checking daemon`;if(!e.ok)return e.error?`TTS: ${e.error}`:`TTS: Daemon offline`;let n=[e.model===void 0?void 0:`model: ${String(e.model)}`,e.queueDepth===void 0?e.queue===void 0?void 0:`queue: ${String(e.queue)}`:`queue: ${String(e.queueDepth)}`,typeof e.pid==`number`?`pid: ${e.pid}`:void 0,e.gpuMemoryUsedMb===void 0?void 0:`VRAM: ${e.gpuMemoryUsedMb}MB`].filter(Boolean);return n.length>0?`TTS: Running (${n.join(`, `)})`:`TTS: Running`}function B9t({onOpenSettings:e}){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!0),[s,c]=(0,z.useState)(!0),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(new Set),h=(0,z.useRef)(null),g=(0,z.useRef)(null),[_,v]=(0,z.useState)(null),y=yt(),{data:b,refetch:x}=V({queryKey:[`cloister-status`],queryFn:j9t,refetchInterval:1e4}),{data:S}=V({queryKey:[`specialists-raw`],queryFn:async()=>{let e=await fetch(`/api/specialists`);return e.ok?e.json():null},refetchInterval:3e4}),{data:C=[]}=V({queryKey:[`conversations`],queryFn:F9t,refetchInterval:1e4}),{data:w}=V({queryKey:[`settings`],queryFn:I9t,retry:!1}),T=w?.tts?.enabled===!0,{data:E,isError:D}=V({queryKey:[`tts-health`],queryFn:L9t,enabled:T,refetchInterval:1e4,retry:!1}),{data:O}=V({queryKey:[`restart-config-list`],queryFn:R9t,enabled:d,refetchInterval:5e3}),k=Q(cS).filter(e=>e.status===`running`).length,A=C.filter(e=>e.sessionAlive).length,j=(S?.projects??[]).filter(e=>e.isRunning),M=(0,z.useCallback)(()=>{if(g.current){let e=g.current.getBoundingClientRect();v({left:e.left,bottom:window.innerHeight-e.top+8})}i(!0)},[]);(0,z.useEffect)(()=>{if(!r)return;let e=e=>{h.current&&!h.current.contains(e.target)&&g.current&&!g.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let N=Mt({mutationFn:async({convs:e,doAgents:t})=>{let n=[];e&&n.push(fetch(`/api/conversations/restart-all`,{method:`POST`})),t&&n.push(fetch(`/api/agents/restart-all`,{method:`POST`}));let r=await Promise.all(n);for(let e of r)if(!e.ok)throw Error(`Restart failed: ${e.statusText}`)},onSuccess:()=>{y.invalidateQueries({queryKey:[`conversations`]}),x(),i(!1)}}),P=Mt({mutationFn:async e=>{let t=await fetch(`/api/agents/restart-with-current-config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentIds:e})});if(!t.ok)throw Error(`Restart failed: ${t.statusText}`);return t.json()},onSuccess:()=>{y.invalidateQueries({queryKey:[`agents`]}),x(),f(!1),m(new Set)}}),F=async()=>{u(!0);try{b?.running?await N9t():await M9t(),await x()}finally{u(!1)}},I=async()=>{await P9t(),n(!1),x()},L=()=>{!a&&!s||N.mutate({convs:a,doAgents:s})};if(!b)return(0,B.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:(0,B.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,B.jsx)(Uc,{className:`w-3.5 h-3.5`})})});let ee=b.summary.warning>0||b.summary.stuck>0,R=b.agentsNeedingAttention.length,te=D?`bg-destructive`:E?.ok?`bg-success`:`bg-muted-foreground`;return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-1`,title:b.running?`Cloister: Running`:`Cloister: Stopped`,children:b.running?(0,B.jsx)(jie,{className:`w-3.5 h-3.5 text-success`}):(0,B.jsx)(Aie,{className:`w-3.5 h-3.5 text-muted-foreground`})}),b.running&&b.summary.total>0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[b.summary.active>0&&(0,B.jsx)(`span`,{className:`text-success`,children:b.summary.active}),b.summary.warning>0&&(0,B.jsx)(`span`,{className:`text-warning`,children:b.summary.warning}),b.summary.stuck>0&&(0,B.jsx)(`span`,{className:`text-destructive`,children:b.summary.stuck})]}),j.length>0&&(0,B.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-success`,title:`Ephemeral: ${j.map(e=>`${e.projectKey.toUpperCase()} ${e.specialistType}`).join(`, `)}`,children:[(0,B.jsx)(cl,{className:`w-3 h-3`}),j.length]}),ee&&(0,B.jsx)(`span`,{title:`${R} agent${R===1?``:`s`} need attention`,children:(0,B.jsx)(il,{className:`w-3.5 h-3.5 text-warning`})}),T&&(0,B.jsxs)(`span`,{"data-testid":`tts-health-badge`,className:`flex items-center gap-1 rounded bg-popover px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,title:z9t(E,D),children:[(0,B.jsx)(`span`,{"data-testid":`tts-health-dot`,className:`h-1.5 w-1.5 rounded-full ${te}`}),`TTS`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{onClick:F,disabled:l,className:`px-2 py-0.5 rounded text-xs transition-colors ${l?`bg-card text-muted-foreground cursor-wait`:b.running?`bg-popover text-foreground hover:bg-card`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:l?`…`:b.running?`Stop Cloister`:`Start Cloister`}),(0,B.jsx)(`button`,{onClick:()=>f(!0),className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart agents with current config`,children:(0,B.jsx)(cl,{className:`w-3.5 h-3.5 ${P.isPending?`animate-spin`:``}`})}),(0,B.jsx)(`button`,{ref:g,onClick:()=>r?i(!1):M(),className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart sessions`,children:(0,B.jsx)(Mc,{className:`w-3.5 h-3.5 ${N.isPending?`animate-spin`:``}`})}),r&&_&&(0,pl.createPortal)((0,B.jsxs)(`div`,{ref:h,style:{position:`fixed`,zIndex:9999,left:_.left,bottom:_.bottom,width:256,borderRadius:6,border:`1px solid var(--border, #333)`,boxShadow:`0 4px 12px rgba(0,0,0,0.4)`,backgroundColor:`var(--card, #0c1018)`},children:[(0,B.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-foreground border-b border-border`,children:`Restart Sessions`}),(0,B.jsxs)(`div`,{className:`p-2 space-y-1`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),(0,B.jsx)(`span`,{children:`Conversations`}),(0,B.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,A,` active)`]})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),(0,B.jsx)(`span`,{children:`Workspace Agents`}),(0,B.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,k,` active)`]})]})]}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-3 py-2 border-t border-border`,children:[(0,B.jsx)(`button`,{onClick:()=>i(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,B.jsx)(`button`,{onClick:L,disabled:N.isPending||!a&&!s,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:N.isPending?`Restarting...`:`Restart`})]}),N.isError&&(0,B.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive border-t border-border`,children:N.error.message})]}),document.body),d&&(0,pl.createPortal)((0,B.jsx)(`div`,{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center`,children:(0,B.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-lg max-w-2xl max-h-96 overflow-auto w-96`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-border flex justify-between items-center`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Restart Agents with Current Config`}),(0,B.jsx)(`button`,{onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]}),(0,B.jsx)(`div`,{className:`p-4 space-y-3 max-h-64 overflow-y-auto`,children:O?.items.length===0?(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No eligible agents to restart.`}):O?.items.map(e=>(0,B.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:p.has(e.agentId),onChange:t=>{let n=new Set(p);t.target.checked?n.add(e.agentId):n.delete(e.agentId),m(n)},disabled:e.paused||e.troubled,className:`accent-primary mt-0.5`}),(0,B.jsxs)(`div`,{className:`flex-1`,children:[(0,B.jsx)(`div`,{className:`font-medium text-foreground`,children:e.issueId}),(0,B.jsxs)(`div`,{className:`text-[10px] text-muted-foreground space-y-0.5`,children:[(0,B.jsxs)(`div`,{children:[`Current: `,e.currentModel,` / `,e.currentHarness]}),e.changed&&(0,B.jsxs)(`div`,{className:`text-warning`,children:[`→ New: `,e.newModel,` / `,e.newHarness]}),!e.changed&&(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:`No change needed`}),(e.paused||e.troubled)&&(0,B.jsxs)(`div`,{className:`text-destructive`,children:[e.paused?`Paused`:`Troubled`,` — cannot restart`]})]})]})]},e.agentId))}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-4 py-3 border-t border-border`,children:[(0,B.jsx)(`button`,{onClick:()=>f(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,B.jsx)(`button`,{onClick:()=>P.mutate(Array.from(p)),disabled:P.isPending||p.size===0,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:P.isPending?`Restarting...`:`Restart (${p.size})`})]}),P.isError&&(0,B.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive border-t border-border`,children:P.error.message})]})}),document.body),t?(0,B.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-0.5 badge-bg-destructive rounded border badge-border-destructive`,children:[(0,B.jsx)(`span`,{className:`text-xs text-destructive`,children:`Kill all?`}),(0,B.jsx)(`button`,{onClick:I,className:`px-1.5 py-0.5 rounded text-xs bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Yes`}),(0,B.jsx)(`button`,{onClick:()=>n(!1),className:`px-1.5 py-0.5 rounded text-xs bg-popover text-foreground hover:bg-card`,children:`No`})]}):(0,B.jsx)(`button`,{onClick:()=>n(!0),className:`p-1 rounded text-xs badge-bg-destructive text-destructive border badge-border-destructive hover:bg-destructive/20 transition-colors`,title:`Emergency stop — kill all agents (hotkey: ${kCe})`,children:(0,B.jsx)(ys,{className:`w-3.5 h-3.5`})}),(0,B.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,B.jsx)(Uc,{className:`w-3.5 h-3.5`})})]})]})}function V9t({onOpenSettings:e}){let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`button`,{ref:r,type:`button`,"aria-label":`System controls`,"aria-expanded":t,title:`System controls — Cloister, restart, emergency stop, settings`,onClick:()=>n(e=>!e),className:`rounded-md p-1.5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring ${t?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:(0,B.jsx)(wae,{className:`h-4 w-4`,"aria-hidden":`true`})}),t&&(0,B.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 rounded-lg border border-border bg-popover p-2 shadow-lg`,children:(0,B.jsx)(B9t,{onOpenSettings:e})})]})}var H9t=/^PAN-(AC|PI(-PROMPT)?|TEST|REVIEW|SHIP|SUB(REVIEW|SIGNAL)?)-?\d*$/;function U9t(e){let t=e.lastActivity??e.startedAt;if(!t)return null;let n=Date.parse(t);return Number.isFinite(n)?n:null}function W9t(e,t=Date.now()){if(e.hasLiveTmuxSession===!0||e.hasLiveTmuxSession===void 0&&(e.status===`running`||e.status===`starting`))return`active`;let n=U9t(e);return H9t.test(e.issueId)&&n!==null&&t-n>6048e5?`orphan_test`:`stopped`}var G9t=new Set([`running`,`active`,`starting`,`thinking`,`working`]),K9t=new Set([`flywheel`,`sequencer`,`knowledge`]);function q9t(e){return G9t.has(e)}function J9t(e){if(e.pausedReason)return`paused: ${e.pausedReason}`;if(e.paused)return`paused`;if(e.troubled){let t=e.consecutiveFailures;return`troubled (${t} failure${t===1?``:`s`})`}return e.stoppedByUser?`stopped by operator`:`stopped cleanly`}function Y9t(e){window.location.pathname!==e&&window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function X9t(e){Y9t(`/issues/${encodeURIComponent(e)}`)}function Z9t(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Q9t({agent:e,title:t,contextLine:n,onNavigate:r}){return(0,B.jsxs)(`button`,{type:`button`,className:`block w-full rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-accent`,onClick:()=>{e.issueId&&!K9t.has(e.role??``)?X9t(e.issueId):Y9t(`/agents`),r?.()},children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-foreground`,children:e.issueId??e.id}),t&&(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,title:t,children:t}),e.role&&(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground`,children:e.role})]}),(0,B.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-muted-foreground`,children:n})]})}var $9t=new Set([`plan`,`review`,`test`,`ship`]),een=new Set([`in_review`,`verifying_on_main`,`done`,`canceled`,`merged`,`closed`]);function ten({variant:e=`banner`}={}){let t=Q(cS),n=Q(dS),r=new Map,i=new Map;for(let e of n){let t=typeof e.identifier==`string`?e.identifier.toUpperCase():null,n=typeof e.canonicalStatus==`string`?e.canonicalStatus:null,a=typeof e.title==`string`?e.title:null;t&&n&&r.set(t,n),t&&a&&i.set(t,a)}let a=(0,z.useRef)(new Set);(0,z.useEffect)(()=>{let e=new Set(t.filter(e=>e.resolution===`api_error`).map(e=>e.id));for(let n of e)if(!a.current.has(n)){let e=t.find(e=>e.id===n)?.issueId||n;U.warning(`${e}: API error — auto-retry nudge sent`,{duration:8e3})}a.current=e},[t]);let o=new Set([`plan`,`work`,`review`,`test`,`ship`]),s=t.filter(e=>{if(!e.issueId||W9t({issueId:e.issueId,status:e.status,hasLiveTmuxSession:e.hasLiveTmuxSession??e.lifecycle?.hasLiveTmuxSession,lastActivity:e.lastActivity,startedAt:e.startedAt})!==`stopped`||e.runtimeState===`completed`||e.resolution===`completed`||e.resolution===`done`||e.lifecycle?.isCompleted||!e.role||!o.has(e.role))return!1;if($9t.has(e.role)){let t=r.get(e.issueId.toUpperCase());if(t&&een.has(t))return!1}let t=e.lastActivity?new Date(e.lastActivity).getTime():0,n=e.startedAt?new Date(e.startedAt).getTime():0,i=Math.max(t,n);return i>0&&Date.now()-i<6048e5}),c=new Map;for(let e of s){let t=e.issueId||e.id,n=c.get(t);if(!n){c.set(t,e);continue}let r=Math.max(n.lastActivity?new Date(n.lastActivity).getTime():0,n.startedAt?new Date(n.startedAt).getTime():0);Math.max(e.lastActivity?new Date(e.lastActivity).getTime():0,e.startedAt?new Date(e.startedAt).getTime():0)>r&&c.set(t,e)}let l=Array.from(c.values()),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(!1),v=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!g)return;let e=e=>{v.current?.contains(e.target)||_(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]);let y=(0,z.useCallback)(async()=>{if(f)return;p(!0),h(null);let e=[],t=!1;for(let n of l)if(n.issueId)try{let r={issueId:n.issueId},i=r,a=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}));if(a.status===409&&o.requiresAcknowledgement){if(!window.confirm((o.guardrails?.warnings??[]).map(e=>`• ${e.message}`).join(`
|
|
858
858
|
`))){e.push({issueId:n.issueId,success:!1,error:`Agent start canceled`});continue}i={...r,guardrailAcknowledged:!0},a=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}))}if(a.ok)o.guardrails?.warnings?.length&&U.success(`${n.issueId}: started after acknowledging system health warnings`,{duration:8e3}),e.push({issueId:n.issueId,success:!0});else{if($vt(a,o)){Yvt(i),e.push({issueId:n.issueId,success:!1,error:o.hint||o.error||`Codex authentication expired — re-authenticate to continue`});continue}let r=a.status===409?aL(o):null;if(r){t||=(rL.getState().openRecovery({...r,issueId:n.issueId}),!0),e.push({issueId:n.issueId,success:!1,error:`Needs your choice — Resume or Start fresh`});continue}e.push({issueId:n.issueId,success:!1,error:o.error||o.hint||a.statusText})}}catch(t){e.push({issueId:n.issueId,success:!1,error:t instanceof Error?t.message:String(t)})}h(e),p(!1)},[f,l]),b=(0,z.useCallback)(()=>{d(!0)},[]),x=(0,z.useCallback)(()=>{h(null),d(!1)},[]),S=m?.filter(e=>e.success).length??0,C=m?.filter(e=>!e.success).length??0;if(e===`pill`)return l.length===0?null:(0,B.jsxs)(`div`,{className:`relative`,ref:v,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),"aria-expanded":g,className:`inline-flex items-center gap-1.5 rounded-full border border-warning/40 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning-foreground transition-colors hover:bg-warning/20`,"data-testid":`stopped-agents-pill`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),l.length,` stopped`]}),g&&(0,B.jsxs)(`div`,{"data-testid":`stopped-agents-popover`,className:`absolute right-0 top-full z-50 mt-1.5 w-80 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs font-semibold text-warning-foreground`,children:[(0,B.jsx)(il,{className:`h-3.5 w-3.5`}),l.length,` stopped · pipeline agents, last 7 days`]}),(0,B.jsx)(`div`,{className:`mb-3 max-h-64 overflow-y-auto`,children:l.map(e=>{let t=e.lastActivity?Date.parse(e.lastActivity):0,n=e.startedAt?Date.parse(e.startedAt):0,r=new Date(Math.max(t,n)).toISOString();return(0,B.jsx)(Q9t,{agent:e,title:e.issueId?i.get(e.issueId.toUpperCase()):void 0,contextLine:`${J9t(e)} · ${Z9t(r,Date.now())}`,onNavigate:()=>_(!1)},e.id)})}),m&&(0,B.jsxs)(`div`,{className:`mb-2 text-xs`,children:[S>0&&(0,B.jsxs)(`span`,{className:`text-success`,children:[`✓ `,S,` restarted`]}),C>0&&(0,B.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`✕ `,C,` failed`]})]}),(0,B.jsxs)(`button`,{onClick:y,disabled:f,className:`flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,"data-testid":`pill-restart-all`,children:[f?(0,B.jsx)(gc,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(Ac,{className:`h-3 w-3`}),f?`Restarting…`:`Restart all`]})]})]});if(u||l.length===0)return u&&l.length>0?(0,B.jsxs)(`div`,{className:`bg-card/40 border-b border-border px-4 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l.length,` agent`,l.length>1?`s`:``,` stopped`]}),(0,B.jsx)(`button`,{onClick:x,className:`text-xs text-primary hover:text-primary/80 underline`,children:`Show`})]}):null;let w=m?.filter(e=>e.success).length??0,T=m?.filter(e=>!e.success).length??0;return(0,B.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-3 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,B.jsx)(il,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,B.jsxs)(`span`,{className:`text-warning-foreground text-xs font-semibold`,children:[l.length,` stopped`]}),(0,B.jsxs)(`span`,{className:`text-warning-foreground/70 text-xs truncate`,children:[l.map(e=>e.issueId||e.id).join(`, `),l.some(e=>e.lastActivity)&&(0,B.jsxs)(`span`,{className:`ml-1`,children:[`(`,Math.max(...l.map(e=>e.lastActivity?Date.now()-new Date(e.lastActivity).getTime():0))/6e4|0,`m ago)`]})]}),m&&(0,B.jsxs)(`span`,{className:`text-xs ml-1`,children:[w>0&&(0,B.jsxs)(`span`,{className:`text-success inline-flex items-center gap-0.5`,children:[(0,B.jsx)(gs,{className:`w-3 h-3`}),` `,w]}),T>0&&(0,B.jsxs)(`span`,{className:`text-destructive inline-flex items-center gap-0.5 ml-1`,children:[(0,B.jsx)(sl,{className:`w-3 h-3`}),` `,T]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[(0,B.jsxs)(`button`,{onClick:y,disabled:f,className:`flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,"data-testid":`banner-restart-all`,children:[f?(0,B.jsx)(gc,{className:`w-3 h-3 animate-spin`}):(0,B.jsx)(Ac,{className:`w-3 h-3`}),f?`Restarting...`:`Restart All`]}),(0,B.jsx)(`button`,{onClick:b,disabled:f,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0 disabled:opacity-50`,title:`Dismiss`,"data-testid":`banner-dismiss`,children:(0,B.jsx)(sl,{className:`w-3.5 h-3.5`})})]})]})}function nen(){let e=Q(cS),t=Q(dS),[n,r]=(0,z.useState)(!1),i=(0,z.useRef)(null),a=(0,z.useMemo)(()=>e.filter(e=>q9t(e.status)).sort((e,t)=>{let n=Date.parse(e.lastActivity??e.startedAt);return Date.parse(t.lastActivity??t.startedAt)-n}),[e]),o=(0,z.useMemo)(()=>new Map(t.map(e=>[e.identifier.toUpperCase(),e.title])),[t]);return(0,z.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),a.length===0?null:(0,B.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":`${a.length} running agent${a.length===1?``:`s`} — click to view`,"data-testid":`running-agents-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-600 transition-colors hover:bg-emerald-500/20 dark:text-emerald-400`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),a.length,` agent`,a.length===1?``:`s`]}),n&&(0,B.jsxs)(`div`,{"data-testid":`running-agents-popover`,className:`absolute right-0 top-full z-50 mt-1.5 w-80 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,B.jsxs)(`div`,{className:`mb-2 text-xs font-semibold text-foreground`,children:[a.length,` running now`]}),(0,B.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:a.map(e=>{let t=e.lastActivity??e.startedAt;return(0,B.jsx)(Q9t,{agent:e,title:e.issueId?o.get(e.issueId.toUpperCase()):void 0,contextLine:`${e.model} · ${Z9t(t,Date.now())}`,onNavigate:()=>r(!1)},e.id)})})]})]})}function ren(){let e=Q(cS),[t,n]=(0,z.useState)(!1),r=e.filter(e=>e.issueId?W9t({issueId:e.issueId,status:e.status,hasLiveTmuxSession:e.hasLiveTmuxSession??e.lifecycle?.hasLiveTmuxSession,lastActivity:e.lastActivity,startedAt:e.startedAt})===`orphan_test`:!1);if(r.length===0)return null;let i=e=>{navigator.clipboard?.writeText(`pan wipe ${e}`)};return(0,B.jsxs)(`div`,{className:`bg-muted/35 border-b border-border px-3 py-1.5 shrink-0`,"data-testid":`orphan-test-agents-surface`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`orphan-test-toggle`,children:[t?(0,B.jsx)(ds,{className:`w-3.5 h-3.5`}):(0,B.jsx)(ps,{className:`w-3.5 h-3.5`}),(0,B.jsxs)(`span`,{className:`font-medium`,children:[r.length,` residual test agent`,r.length===1?``:`s`]}),(0,B.jsx)(`span`,{className:`truncate`,children:`Residue from prior test runs; cleanup is manual via pan wipe.`})]}),t&&(0,B.jsx)(`div`,{className:`mt-1.5 grid gap-1 pl-5`,"data-testid":`orphan-test-agent-list`,children:r.map(e=>{let t=e.issueId??e.id;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-border/70 bg-background/60 px-2 py-1 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(t),className:`ml-auto inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,B.jsx)(Hie,{className:`w-3 h-3`}),"Copy `pan wipe ",t,"`"]})]},e.id)})})]})}function ien(){let{data:e}=MQ(),[t,n]=(0,z.useState)(!1);return!e||e.status!==`expired`&&e.status!==`burned`?null:(0,B.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,B.jsx)(il,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,B.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Codex authentication `,e.status,` — Codex-routed agents (gpt-5.x, o3, o4-mini) will fail.`,e.email&&(0,B.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`(`,(0,B.jsx)(X2,{value:e.email,className:`text-sm`}),`)`]}),e.affectedAgents&&e.affectedAgents.length>0&&(0,B.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`— `,e.affectedAgents.length,` agent`,e.affectedAgents.length===1?``:`s`,` wedged on a revoked token`]})]}),(0,B.jsx)(`button`,{onClick:async()=>{n(!0);try{let e=await fetch(`/api/settings/codex-reauth`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to spawn re-auth session (${e.status})`)}let{sessionName:t,statusToken:n}=await e.json();Xvt(t,n),U.success(`Re-authentication session started — opening terminal…`),AMt(t,`Codex re-authentication`)}catch(e){U.error(e instanceof Error?e.message:`Failed to start re-authentication`)}finally{n(!1)}},disabled:t,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`,children:t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(gc,{className:`w-3.5 h-3.5 animate-spin`}),`Starting…`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Is,{className:`w-3.5 h-3.5`}),`Re-authenticate`]})})]})}async function aen(){let e=await fetch(`/api/settings/conversation-search/status`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch conversation search status (${e.status}): ${t}`)}return e.json()}function oen(){return V({queryKey:[`conversation-search-status`],queryFn:aen,refetchInterval:6e4,staleTime:3e4})}function sen(){let{data:e}=oen();if(!e?.enabled)return null;let t=e.health,n=t?.lastErrorAt!=null&&(t.lastSuccessAt==null||t.lastErrorAt>t.lastSuccessAt);if(e.available&&!n)return null;let r=e.available?t?.lastErrorReason??`recent embedding failures`:e.unavailableReason??`embedding provider unavailable`,i=/credit|billing|quota|insufficient/i.test(r);return(0,B.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,B.jsx)(il,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,B.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1 min-w-0 [&_span]:break-words`,children:[`Conversation search is not working: `,(0,B.jsx)(`span`,{className:`font-normal`,children:r}),(0,B.jsx)(`span`,{className:`font-normal ml-1 opacity-80`,children:`— Ctrl+K conversation hits and transcript indexing are unavailable until this is fixed.`})]}),i&&(0,B.jsxs)(`a`,{href:`https://platform.openai.com/settings/organization/billing/`,target:`_blank`,rel:`noreferrer`,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors shrink-0 flex items-center gap-1.5`,children:[(0,B.jsx)(Is,{className:`w-3.5 h-3.5`}),`OpenAI billing`]})]})}var Y9=`echo 'fs.inotify.max_user_watches = 2097152' | sudo tee /etc/sysctl.d/99-inotify.conf && sudo sysctl --system`;function cen(){let{data:e}=a1(),t=e?.host.reasons.find(e=>e.code.startsWith(`host.linux.inotify_watches.`));if(!e||!t)return null;let n=t.code===`host.linux.inotify_watches.critical`,r=e.host.metrics.inotifyWatchesUsed,i=e.host.metrics.inotifyWatchesMax,a=r!=null&&i!=null?`${r.toLocaleString()} of ${i.toLocaleString()} file watchers in use`:`file-watcher usage is near the limit`,o=t.observed==null?``:` (${Math.round(t.observed)}%)`;return(0,B.jsxs)(`div`,{className:`${n?`bg-destructive/10`:`bg-warning/10`} flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`inotify-pressure-banner`,children:[(0,B.jsx)(il,{className:`w-3.5 h-3.5 shrink-0 ${n?`text-destructive`:`text-warning-foreground`}`}),(0,B.jsxs)(`p`,{className:`flex-1 truncate text-xs ${n?`text-destructive`:`text-warning-foreground`}`,title:`inotify watches are a per-user kernel budget shared by every process and container on this host. When it is exhausted, new file-watching dev servers fail to start with ENOSPC. ${a}${o}. Raise and persist the limit with: ${Y9}`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:n?`File watchers exhausted`:`File watchers running low`}),` — `,a,o,`; new dev servers `,n?`will`:`may`,` fail with ENOSPC`]}),(0,B.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(Y9),U.success(`Fix command copied — run it in a terminal to raise and persist the limit`)}catch{U.error(`Copy failed — run: ${Y9}`)}},className:`h-[26px] shrink-0 rounded-sm px-[10px] text-[11px] font-medium ${n?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-warning/20 text-warning-foreground hover:bg-warning/30`}`,children:`Copy fix`})]})}async function len(){let e=await fetch(`/api/linear-mcp-auth`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch Linear MCP auth status (${e.status}): ${t}`)}return e.json()}function uen(){return V({queryKey:[`linear-mcp-auth`],queryFn:len,refetchInterval:e=>e.state.data?.status===`none`?3e4:5e3})}function den(){let{data:e}=uen(),[t,n]=(0,z.useState)(``),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!1);if(!e||e.status===`none`)return null;let s=e.blockedAgents??[];return(0,B.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex flex-col gap-2 shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(il,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,B.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Linear authentication required — `,s.length,` agent`,s.length===1?``:`s`,` blocked on Linear MCP OAuth.`]}),e.authUrl&&e.status===`active`&&(0,B.jsxs)(`a`,{href:e.authUrl,target:`_blank`,rel:`noreferrer`,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors shrink-0 flex items-center gap-1.5`,children:[(0,B.jsx)(Is,{className:`w-3.5 h-3.5`}),`Open Linear authorization`,e.authUrlAgentId?` (from ${e.authUrlAgentId})`:``]}),(0,B.jsx)(`button`,{onClick:async()=>{o(!0);try{let e=await fetch(`/api/linear-mcp-auth/complete`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to mark Linear auth completed (${e.status})`)}U.success(`Marked Linear authentication healthy — blocked agents are being woken to re-check.`)}catch(e){U.error(e instanceof Error?e.message:`Failed to mark Linear auth completed`)}finally{o(!1)}},disabled:a,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`,children:a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(gc,{className:`w-3.5 h-3.5 animate-spin`}),`Marking…`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_s,{className:`w-3.5 h-3.5`}),`Mark completed`]})})]}),s.length>0&&(0,B.jsx)(`ul`,{className:`text-warning-foreground text-sm pl-8 flex flex-col gap-0.5`,children:s.map(e=>{let t=e.issueUrl??(e.issueId?TO(e.issueId):null);return(0,B.jsxs)(`li`,{children:[e.conversationUrl?(0,B.jsx)(`a`,{href:e.conversationUrl,className:`font-semibold underline hover:opacity-80`,children:e.agentId}):(0,B.jsx)(`span`,{className:`font-semibold`,children:e.agentId}),e.issueId&&(0,B.jsxs)(B.Fragment,{children:[` — `,t?(0,B.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`underline hover:opacity-80`,children:e.issueId}):e.issueId]}),e.notifiedAt&&(0,B.jsx)(`span`,{className:`opacity-80`,children:` (woken, re-checking)`})]},e.agentId)})}),e.status===`expired`?(0,B.jsx)(`p`,{className:`text-warning-foreground text-sm pl-8 opacity-80`,children:`This authorization link expired — it refreshes automatically when a blocked agent generates a fresh one.`}):e.authUrl?null:(0,B.jsx)(`p`,{className:`text-warning-foreground text-sm pl-8 opacity-80`,children:`Waiting for a blocked agent to produce an authorization URL — it appears here as soon as one does.`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 pl-8`,children:[(0,B.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`Paste the localhost callback URL here`,className:`flex-1 max-w-xl px-2 py-1.5 text-sm rounded-md bg-background border border-warning/40 text-foreground placeholder:text-muted-foreground`}),(0,B.jsx)(`button`,{onClick:async()=>{i(!0);try{let e=await fetch(`/api/linear-mcp-auth/callback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({callbackUrl:t})}),r=await e.json().catch(()=>({}));if(!e.ok)throw Error(r.error||`Failed to relay callback URL (${e.status})`);U.success(`Callback URL relayed to ${r.relayedTo??`the blocked agent`} — it will finish the OAuth flow.`),n(``)}catch(e){U.error(e instanceof Error?e.message:`Failed to relay callback URL`)}finally{i(!1)}},disabled:r||t.trim()===``,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:r?`Relaying…`:`Submit callback URL`})]}),(0,B.jsxs)(`p`,{className:`text-warning-foreground text-xs pl-8 opacity-80`,children:[`After authorizing in your browser, Linear redirects to a localhost URL. On a remote session the callback page fails to load — copy the URL from the address bar and paste it above; it is relayed to the blocked agent to finish the flow. If you authorized another way (e.g. `,(0,B.jsx)(`code`,{children:`claude mcp login linear`}),`), use Mark completed: blocked agents will be woken to re-check Linear access, and this banner returns if authentication is still broken.`]})]})}var fen=8e3,pen={waiting:{strip:`bg-warning/10`,text:`text-warning-foreground`},working:{strip:`bg-info/10`,text:`text-info-foreground`},settled:{strip:`bg-muted/40`,text:`text-muted-foreground`}};function X9({tone:e,icon:t,title:n,children:r,action:i}){let a=pen[e];return(0,B.jsxs)(`div`,{className:`${a.strip} flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`restart-approval-banner`,children:[(0,B.jsx)(t,{className:`w-3.5 h-3.5 ${a.text} shrink-0`}),(0,B.jsx)(`p`,{className:`flex-1 truncate text-xs ${a.text}`,title:n,children:r}),i]})}function men(){let e=Q(JNe),t=e?.lastOutcome?.type===`pruned-unclaimed`?e.lastOutcome.at:null,[n,r]=(0,z.useState)(!1);(0,z.useEffect)(()=>{if(!t)return;let e=fen-(Date.now()-Date.parse(t));if(e<=0){r(!0);return}r(!1);let n=setTimeout(()=>r(!0),e);return()=>clearTimeout(n)},[t]);let i=Mt({mutationFn:async()=>{let e=await fetch(`/api/restart-gate/approve`,{method:`POST`,headers:await sb()}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to approve the restart`);return t},onSuccess:e=>{let t=e.pendingCount??0;U.success(t>0?`Restart approved — ${t} waiting request${t===1?``:`s`} will be satisfied by one restart`:`Nothing left to restart for — every waiting request had already given up`)},onError:e=>U.error(e instanceof Error?e.message:`Failed to approve the restart`)});if(!e)return null;let a=e.pending.length,o=e.pending.map(e=>e.reason||e.kind).join(`; `);if(e.status===`pending`&&a>0)return(0,B.jsxs)(X9,{tone:`waiting`,icon:zie,title:`${a} process${a===1?``:`es`} asked to restart the dashboard and ${a===1?`is`:`are`} waiting for you. Nothing restarts until you approve, and one approval covers every request listed here — they are satisfied by a single restart. Approve here, or run \`pan restart approve\` in a terminal. Waiting: ${o}`,action:(0,B.jsx)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`h-[26px] shrink-0 rounded-sm bg-warning/20 px-[10px] text-[11px] font-medium text-warning-foreground hover:bg-warning/30 disabled:opacity-50`,children:i.isPending?`Approving…`:`Restart now`}),children:[(0,B.jsx)(`span`,{className:`font-medium`,children:a===1?`A dashboard restart is waiting for your approval`:`${a} dashboard restarts are waiting for your approval`}),` — `,o]});if(e.status===`approved`){let t=e.pending.map(e=>e.requesterId).join(`, `)||`the requester`;return(0,B.jsxs)(X9,{tone:`working`,icon:Fc,title:`The restart is approved. ${t} performs it on the next poll — nothing else is waiting on you.`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Approved`}),` — waiting for `,t,` to restart…`]})}return e.status===`claimed`?(0,B.jsxs)(X9,{tone:`working`,icon:Fc,title:`A requester is restarting the dashboard now. This page loses its connection for a moment and reconnects on its own.`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Restarting…`}),` — the dashboard reconnects on its own in a moment`]}):t&&!n?(0,B.jsx)(X9,{tone:`settled`,icon:lc,title:`Every process waiting on that approval had already exited, so the approval had nothing left to restart. Restart again from a terminal if you still want one.`,children:`The requester(s) went away without restarting — nothing was restarted.`}):null}var hen=`overdeck-setup-checklist-dismissed`;function gen(e,t){return t===`darwin`?e.install.mac:t===`win32`?e.install.win:e.install.linux}function _en({command:e}){return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,B.jsx)(`code`,{className:`font-mono text-xs bg-card-2 border border-border rounded-sm px-1.5 py-0.5 truncate`,children:e}),(0,B.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(e).then(()=>U.success(`Copied`),()=>U.error(`Copy failed`))},className:`p-1 rounded-sm text-muted-foreground hover:text-foreground hover:bg-card-2 shrink-0`,"aria-label":`Copy install command for ${e}`,title:`Copy`,children:(0,B.jsx)(ks,{className:`w-3.5 h-3.5`})})]})}function ven({check:e,platform:t}){return(0,B.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5 min-w-0`,children:[e.found?(0,B.jsx)(us,{className:`w-4 h-4 text-muted-foreground shrink-0`,"aria-label":`installed`}):e.required?(0,B.jsx)(il,{className:`w-4 h-4 text-warning-foreground shrink-0`,"aria-label":`missing — required`}):(0,B.jsx)(`span`,{className:`w-4 h-4 text-muted-foreground text-center shrink-0`,"aria-label":`missing — optional`,children:`·`}),(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),!e.required&&(0,B.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:`optional`}),(0,B.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.purpose})]}),e.found?(0,B.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground truncate max-w-48`,children:e.version}):(0,B.jsx)(_en,{command:gen(e,t)})]})}function yen(){let[e,t]=(0,z.useState)(!1),[n,r]=(0,z.useState)(()=>localStorage.getItem(hen)??``),{data:i,refetch:a,isFetching:o}=V({queryKey:[`prerequisites`],queryFn:async()=>{let e=await fetch(`/api/prerequisites`);if(!e.ok)throw Error(`Failed to check prerequisites`);return e.json()},staleTime:5*6e4,retry:1}),s=(0,z.useMemo)(()=>(i?.checks??[]).filter(e=>e.required&&!e.found),[i]),c=s.map(e=>e.id).sort().join(`,`);if(!i||s.length===0||!e&&n===c)return null;let l=()=>{localStorage.setItem(hen,c),r(c),t(!1)},u=async()=>{try{let e=await fetch(`/api/diagnostics/setup`);if(!e.ok)throw Error(`Diagnostics request failed`);let t=await e.json();if(!t.markdown)throw Error(`Diagnostics report was empty`);await navigator.clipboard.writeText(t.markdown),U.success(`Diagnostics copied`)}catch{U.error(`Could not copy diagnostics`)}};return(0,B.jsxs)(`div`,{className:`bg-warning/8 border-b border-warning/32 shrink-0`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 flex items-center gap-3`,children:[(0,B.jsx)(il,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,B.jsxs)(`p`,{className:`text-sm font-medium text-warning-foreground flex-1 min-w-0`,children:[`Finish setting up Overdeck — missing required `,s.length===1?`tool`:`tools`,`:`,` `,(0,B.jsx)(`span`,{className:`font-mono`,children:s.map(e=>e.id).join(`, `)}),`. Agents cannot start until `,s.length===1?`it is`:`they are`,` installed.`]}),(0,B.jsx)(`button`,{onClick:()=>t(e=>!e),className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-warning/8 border border-warning/32 text-warning-foreground hover:bg-warning/16 shrink-0`,children:e?`Hide checklist`:`Show checklist`}),(0,B.jsx)(`button`,{onClick:l,className:`p-1.5 rounded-sm text-muted-foreground hover:text-foreground hover:bg-card-2 shrink-0`,"aria-label":`Dismiss setup checklist`,title:`Dismiss (reappears if the missing set changes)`,children:(0,B.jsx)(sl,{className:`w-4 h-4`})})]}),e&&(0,B.jsxs)(`div`,{className:`px-4 pb-3`,children:[(0,B.jsx)(`div`,{className:`bg-card border border-border rounded-sm px-4 py-2 divide-y divide-border`,children:i.checks.map(e=>(0,B.jsx)(ven,{check:e,platform:i.platform},e.id))}),(0,B.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,B.jsxs)(`button`,{onClick:()=>void a(),disabled:o,className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 disabled:opacity-50 inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Mc,{className:`w-3.5 h-3.5 ${o?`animate-spin`:``}`}),`Re-check`]}),(0,B.jsxs)(`button`,{onClick:()=>void u(),className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 inline-flex items-center gap-1.5`,children:[(0,B.jsx)(ks,{className:`w-3.5 h-3.5`}),`Copy diagnostics`]}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Run the commands in a terminal, then re-check. Install commands are for this machine (`,i.platform===`darwin`?`macOS`:i.platform===`win32`?`Windows`:`Linux`,`).`]})]})]})]})}function ben(){let e=V({queryKey:[`sync-status`],queryFn:async()=>{let e=await fetch(`/api/sync-status`);if(!e.ok)throw Error(`Failed to check Overdeck sync status`);return e.json()},refetchInterval:6e4}),t=Mt({mutationFn:async()=>{let e=await fetch(`/api/system/sync`,{method:`POST`,headers:await sb()}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`pan sync failed`)},onSuccess:async()=>{U.success(`Overdeck context, hooks, and skills are up to date`),await e.refetch()},onError:e=>U.error(e instanceof Error?e.message:`pan sync failed`)});return e.data?.needed?(0,B.jsxs)(`div`,{className:`bg-primary/10 flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`sync-required-banner`,children:[(0,B.jsx)(Mc,{className:`w-3.5 h-3.5 text-primary shrink-0 ${t.isPending?`animate-spin`:``}`}),(0,B.jsxs)(`p`,{className:`flex-1 truncate text-xs text-primary`,title:`Sync the latest context rules, lifecycle hooks, and skills before starting new agents.`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Setup changed`}),` — sync context, hooks, and skills`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>t.mutate(),disabled:t.isPending,className:`h-[26px] shrink-0 rounded-sm bg-primary px-[10px] text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:t.isPending?`Syncing…`:`Sync now`})]}):null}function xen(e,t){let n=ul(),r=yt(),i=Mt({mutationFn:async()=>{if(!e)throw Error(`No agent to kill`);let t=await fetch(`/api/agents/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to kill agent`);return t.json()},onSuccess:async()=>{await nL(r),t?.onSuccess?.()}});return{killMutation:i,confirmAndKill:async()=>{if(!e)return!1;let t=await n({title:`Kill Agent`,message:`Kill agent ${e}?`,variant:`destructive`,confirmLabel:`Kill`});return t&&i.mutate(),t},isPending:i.isPending}}function Sen(e){return[...e.host.reasons.filter(e=>e.severity===`info`),...e.admission.reasons.filter(e=>e.severity===`info`),...e.agents.flatMap(e=>e.reasons).filter(e=>e.severity===`info`),...e.services.flatMap(e=>e.reasons).filter(e=>e.severity===`info`)]}function Z9(e,t){switch(t.code){case`admission.memory_available.soft`:return`spawn headroom tight`;case`admission.memory_available.blocked`:return e.admission.availableMemoryBytes==null?`spawn admission blocked`:`${Q9(e.admission.availableMemoryBytes)} available`;case`host.linux.psi_some.warning`:case`host.linux.psi_full.critical`:case`host.darwin.memory_pressure.warning`:case`host.darwin.memory_pressure.critical`:return`memory pressure detected`;case`host.linux.swap_activity.warning`:case`host.linux.swap_activity.critical`:return t.observed==null?`swap activity detected`:`${Q9(t.observed)} swap activity/min`;case`host.linux.inotify_watches.warning`:return`file-watcher budget low`;case`host.linux.inotify_watches.critical`:return`file-watcher budget exhausted`;case`agent.context.saturated`:return`agent context exhausted`;case`agent.tmux.missing`:return`agent session missing`;case`agent.kickoff.not_delivered`:return`agent kickoff stalled`;case`agent.runtime.inactive.warning`:case`agent.runtime.inactive.stalled`:return`agent activity stalled`;case`service.smee_relay.stopped`:return`webhook relay stopped`;case`service.smee_relay.unavailable`:return`webhook relay unavailable`;case`system.health_snapshot.unavailable`:case`host.current_pressure.unavailable`:case`host.sampler.collection_failed`:case`agent.persisted_state.unavailable`:return`Retry`;default:return null}}function Q9(e){let t=e/1024**3;return t>=1?`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function Cen(e){let t=new Map;for(let n of e.topConsumers){if(n.type===`container`)continue;let e=n.killTarget?.kind===`agent`?n.killTarget.agentId??n.id:n.id;t.has(e)||t.set(e,n)}let n=[];e.host.reasons.filter(e=>e.severity!==`info`).forEach(e=>{n.push({reason:e})}),e.admission.reasons.filter(e=>e.severity!==`info`).forEach(e=>{n.push({reason:e})}),e.services.flatMap(e=>e.reasons.filter(e=>e.severity!==`info`).map(e=>({reason:e}))).forEach(e=>{n.push(e)}),e.agents.forEach(e=>{e.reasons.filter(e=>e.severity!==`info`).forEach(r=>{n.push({reason:r,target:{agentId:e.id,issueId:e.issueId,killConsumer:t.get(e.id)}})})});let r=new Map;for(let e of n){let t=e.reason.code;r.has(t)||r.set(t,[]),r.get(t).push(e)}let i=[];for(let[t,n]of r){let r=n[0],a=r.reason;if(t.startsWith(`agent.`)&&n.length>1){let r=n.map(e=>e.target).filter(e=>e!==void 0),o=r.map(e=>e.agentId),s=o.slice(0,2).join(`, `)+(o.length>2?` +${o.length-2} more`:``);i.push({severity:wen(a.code,a.severity),code:t,title:Z9(e,a)??t,sub:`${o.length}× agents: ${s}`,agents:o,targets:r})}else{let n=r.target,o=n?.agentId,s=n?.issueId,c=o?s?`${o} · ${s}`:o:Z9(e,a)??t,l=o?`${o} has produced `:void 0,u=l&&a.message.startsWith(l)?a.message.slice(l.length):a.message;i.push({severity:wen(a.code,a.severity),code:t,title:c,sub:u,agents:o?[o]:[],targets:n?[n]:[],agentId:o,issueId:s,killConsumer:n?.killConsumer})}}return i.sort((e,t)=>{if(e.severity!==t.severity)return e.severity===`critical`?-1:1;let n=e.code===`agent.runtime.inactive.stalled`;return n===(t.code===`agent.runtime.inactive.stalled`)?0:n?-1:1}),i}function wen(e,t){return e===`agent.runtime.inactive.stalled`||t===`critical`?`critical`:`warning`}function Ten(e,t){let n=t.filter(e=>e.code===`agent.runtime.inactive.stalled`).reduce((e,t)=>e+t.agents.length,0),r=t.filter(e=>e.code===`agent.runtime.inactive.warning`).reduce((e,t)=>e+t.agents.length,0),i=t.filter(e=>e.severity===`warning`).length,a=t.filter(e=>e.severity===`critical`).length,o=Sen(e).length,s=e.host.metrics.memoryUsedPercent==null?`memory unavailable`:`memory at ${e.host.metrics.memoryUsedPercent.toFixed(1)}%`,c=e.admission.availableMemoryBytes==null?`spawn headroom unavailable`:`${Q9(e.admission.availableMemoryBytes)} spawn headroom`,l=e.summary.smeeRelay.configured?e.summary.smeeRelay.running?`relay running`:`relay stopped`:`relay not configured`,u=[`${n} stalled agent${n===1?``:`s`}`,`${r} idle agent${r===1?``:`s`}`,s,c,`${o} context note${o===1?``:`s`}`].join(` · `);return t.length===0?`All clear · ${s} · ${c} · ${l} · ${n} stalled agents · ${r} idle agents · ${o} context note${o===1?``:`s`}`:a>0?`Action required: ${a} critical issue${a===1?``:`s`} · ${u}`:`Attention needed: ${i} warning${i===1?``:`s`} · ${u}`}var Een=`system-health-popover`,Den=`system-health-popover-title`;function $9(e){let t=e/1024**3;return t>=1?`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function Oen(e){switch(e){case`critical`:return`border-destructive/50 bg-destructive/10 text-destructive motion-safe:animate-pulse`;case`warning`:return`border-warning/40 bg-warning/10 text-warning-foreground`;case`unavailable`:return`border-border bg-muted text-muted-foreground`;case`measuring`:return`border-info/40 bg-info/10 text-info`;case`healthy`:return`border-success/40 bg-success/10 text-success`}}function ken(e){switch(e){case`critical`:return`bg-destructive`;case`warning`:return`bg-warning`;case`unavailable`:return`bg-muted-foreground`;case`measuring`:return`bg-info`;case`healthy`:return`bg-success`}}function Aen(e){return e.issueId?`${e.label} · ${e.issueId}`:e.currentIssue?`${e.label} · ${e.currentIssue}`:e.label}function jen(e){switch(e.type){case`agent`:return`Agent`;case`specialist`:return`Specialist`;case`container`:return`Container`}}function Men(e){return[...e.host.reasons,...e.admission.reasons,...e.agents.flatMap(e=>e.reasons),...e.services.flatMap(e=>e.reasons)]}function Nen(e,t){for(let n of t){let t=Z9(e,n);if(t)return t}return null}function Pen(e,t){switch(e.state){case`measuring`:return`Measuring system health…`;case`healthy`:return e.admission.availableMemoryBytes==null?`Healthy`:`Healthy · ${$9(e.admission.availableMemoryBytes)} available`;case`warning`:return`Warning · ${Nen(e,t)??`attention required`}`;case`critical`:return`Critical · ${Nen(e,t)??`action required`}`;case`unavailable`:return`Health unavailable · Retry`}}function Fen({state:e}){switch(e){case`measuring`:return(0,B.jsx)(gc,{"data-health-icon":`measuring`,"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`});case`healthy`:return(0,B.jsx)(_s,{"data-health-icon":`healthy`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`warning`:return(0,B.jsx)(il,{"data-health-icon":`warning`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`critical`:return(0,B.jsx)(Jc,{"data-health-icon":`critical`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`unavailable`:return(0,B.jsx)(vs,{"data-health-icon":`unavailable`,"aria-hidden":`true`,className:`h-3.5 w-3.5`})}}function Ien({consumer:e,onSelectLeaked:t}){let n=ul(),r=yt(),{confirmAndKill:i,isPending:a}=xen(e.killTarget?.kind===`agent`?e.killTarget.agentId:void 0,{onSuccess:()=>{e.leaked&&t()}}),o=Mt({mutationFn:async()=>{let t=e.killTarget;if(!t)throw Error(`No kill target available`);if(t.kind===`container`){if(!t.containerId)throw Error(`Missing container id`);let e=await fetch(`/api/resources/docker/container/${t.containerId}`,{method:`DELETE`});if(!e.ok)throw Error(`Failed to remove container`);return e.json()}if(t.kind===`specialist`){if(!t.projectKey||!t.issueId||!t.specialistType)throw Error(`Missing specialist target`);let e=await fetch(`/api/specialists/${t.projectKey}/${t.issueId}/${t.specialistType}/kill`,{method:`POST`});if(!e.ok)throw Error(`Failed to kill specialist`);return e.json()}throw Error(`Unsupported kill target`)},onSuccess:async()=>{await nL(r),await r.invalidateQueries({queryKey:[`system-health`]}),e.leaked&&t()}}),s=a||o.isPending,c=e.killTarget;if(!c)return null;let l=c.kind===`container`?`Remove container ${e.label}`:c.kind===`specialist`?`Kill specialist ${e.label}`:`Kill ${e.label}`,u=async()=>{if(c.kind===`agent`){await i();return}await n({title:c.kind===`container`?`Remove Container`:`Kill Specialist`,message:c.kind===`container`?`Remove Docker container ${e.label}?`:`Kill specialist ${e.label}?`,variant:`destructive`,confirmLabel:c.kind===`container`?`Remove`:`Kill`})&&o.mutate()};return(0,B.jsx)(`button`,{onClick:()=>void u(),disabled:s,className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50`,title:l,children:s?`Killing…`:c.kind===`container`?`Remove`:`Kill`})}function Len({target:e,onOpen:t,onSelectLeaked:n}){return!e.issueId&&!e.killConsumer?null:(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[e.issueId&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>t(e.issueId),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Open ${e.issueId}`,children:`Open`}),e.killConsumer&&(0,B.jsx)(Ien,{consumer:e.killConsumer,onSelectLeaked:n})]})}function Ren({compact:e=!1}){let{data:t,isLoading:n,error:r}=a1(),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(!1),c=(0,z.useRef)(null),l=(0,z.useRef)(null),u=(0,z.useRef)(null),d=(0,z.useCallback)((e=!0)=>{s(!1),a(!1),e&&requestAnimationFrame(()=>u.current?.focus())},[]),f=(0,z.useCallback)(e=>{Q.getState().openIssue(e),d()},[d]);(0,z.useEffect)(()=>{if(!i)return;let e=e=>{document.querySelector(`[role="alertdialog"]`)||l.current&&!l.current.contains(e.target)&&d()},t=e=>{e.key===`Escape`&&d()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[d,i]);let p=(0,z.useMemo)(()=>t?Men(t):[],[t]),m=t?Pen(t,p):`Health unavailable · Retry`,h=(0,z.useMemo)(()=>t?Cen(t):[],[t]),g=(0,z.useMemo)(()=>t?Ten(t,h):``,[t,h]),_=(0,z.useMemo)(()=>t?Sen(t):[],[t]);(0,z.useEffect)(()=>{if(!t)return;let n=c.current;c.current=t.state,!(e||n==null||n===t.state||t.state!==`critical`)&&U.error(`System health is critical`,{description:p[0]?.message??`Open the health panel to inspect top consumers and agent health.`,duration:1e4,action:{label:`Open`,onClick:()=>{s(t.topConsumers.some(e=>e.leaked)),a(!0)}}})},[e,t,p]);let v=(0,z.useMemo)(()=>{let e=[...t?.topConsumers??[]].sort((e,t)=>Number(t.leaked??!1)-Number(e.leaked??!1));if(!o)return e;let n=e.filter(e=>e.leaked);return n.length>0?n:e},[t?.topConsumers,o]),y=(0,z.useMemo)(()=>v.reduce((e,t)=>Math.max(e,t.memoryGb),1),[v]);if(n)return(0,B.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,"aria-label":`Loading system health`,children:[(0,B.jsx)(gc,{"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`}),!e&&(0,B.jsx)(`span`,{children:`Health`})]});if(r||!t)return(0,B.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,title:r?.message??`Failed to load system health`,"aria-label":`Health unavailable`,children:[(0,B.jsx)(vs,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),!e&&(0,B.jsx)(`span`,{children:`Health unavailable · Retry`})]});let b=t.services.find(e=>e.id===`smee-relay`||e.id===`webhook-relay`),x=b?.status??t.summary.smeeRelay.status,S=x!==`not_configured`&&(t.summary.smeeRelay.configured||b!==void 0)?x===`running`?{label:`Running`,classes:`border-success/40 bg-success/10`,dotClass:`bg-success`}:{label:x===`unavailable`?`Unavailable`:`Stopped`,classes:`border-destructive/50 bg-destructive/10`,dotClass:`bg-destructive`}:{label:`Not configured`,classes:`border-border bg-muted/40`,dotClass:`bg-muted-foreground`};return(0,B.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,B.jsxs)(`button`,{ref:u,type:`button`,onClick:()=>{s(!1),a(e=>!e)},className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-xs transition-colors hover:bg-accent ${Oen(t.state)} ${e?`justify-center px-1.5`:`justify-between`}`,"data-testid":`system-health-pill`,"aria-label":m,"aria-expanded":i,"aria-controls":Een,"aria-haspopup":`dialog`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(Fen,{state:t.state}),!e&&(0,B.jsx)(`span`,{children:m})]}),!e&&(0,B.jsx)(ds,{"aria-hidden":`true`,className:`h-3.5 w-3.5 transition-transform ${i?`rotate-180`:``}`})]}),i&&!e&&(0,B.jsxs)(`div`,{id:Een,role:`dialog`,"aria-labelledby":Den,className:`absolute right-0 top-full z-[200] mt-2 w-[min(22rem,calc(100vw-1rem))] max-h-[calc(100vh-1rem)] overflow-auto rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,B.jsx)(`span`,{id:Den,className:`font-semibold text-foreground`,children:`System health`}),(0,B.jsxs)(`span`,{role:`status`,"aria-label":`${t.state} system health`,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize ${Oen(t.state)}`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex h-2 w-2 rounded-full ${ken(t.state)}`}),t.state]})]}),(0,B.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Updated `,Math.round((Date.now()-Date.parse(t.updatedAt))/1e3),`s ago`]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Close system health`,children:(0,B.jsx)(sl,{"aria-hidden":`true`,className:`h-4 w-4`})})]}),(0,B.jsx)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/30 p-2 text-sm`,children:(0,B.jsx)(`div`,{className:`text-foreground`,children:g})}),(0,B.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:`CPU`}),(0,B.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.cpuPercent==null?`Unavailable`:`${t.host.metrics.cpuPercent.toFixed(1)}%`}),(0,B.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Load/core `,t.host.metrics.loadPerCore1m==null?`Unavailable`:t.host.metrics.loadPerCore1m.toFixed(2)]}),t.host.metrics.cpuPercent!=null&&(0,B.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{role:`meter`,"aria-label":`CPU usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.cpuPercent,className:`h-full ${t.host.metrics.cpuPercent<60?`bg-success`:t.host.metrics.cpuPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.cpuPercent)}%`}})})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:`Memory`}),(0,B.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.usedMemoryBytes==null||t.host.metrics.totalMemoryBytes==null?`Unavailable`:`${$9(t.host.metrics.usedMemoryBytes)} / ${$9(t.host.metrics.totalMemoryBytes)}`}),(0,B.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Avail `,t.host.metrics.availableMemoryBytes==null?`Unavailable`:$9(t.host.metrics.availableMemoryBytes)]}),t.host.metrics.memoryUsedPercent!=null&&(0,B.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{role:`meter`,"aria-label":`Memory usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.memoryUsedPercent,className:`h-full ${t.host.metrics.memoryUsedPercent<60?`bg-success`:t.host.metrics.memoryUsedPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.memoryUsedPercent)}%`}})})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:`Overdeck`}),(0,B.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:$9(t.summary.overdeckMemoryBytes)}),(0,B.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[t.summary.overdeckMemoryPercent.toFixed(1),`% of host RAM`]}),(0,B.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{role:`meter`,"aria-label":`Overdeck memory share`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.summary.overdeckMemoryPercent,className:`h-full bg-info`,style:{width:`${Math.min(100,t.summary.overdeckMemoryPercent)}%`}})})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,B.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Swap `,(0,B.jsx)(`span`,{className:`text-[11px]`,children:`historical · not live pressure`})]}),(0,B.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.swapUsedPercent==null?`Unavailable`:`${t.host.metrics.swapUsedPercent.toFixed(1)}%`}),t.host.metrics.swapUsedPercent!=null&&(0,B.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{role:`meter`,"aria-label":`Swap usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.swapUsedPercent,className:`h-full ${t.host.metrics.swapUsedPercent<60?`bg-success`:t.host.metrics.swapUsedPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.swapUsedPercent)}%`}})}),(0,B.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Overcommit `,t.host.metrics.virtualCommitmentPercent==null?`Unavailable`:`${t.host.metrics.virtualCommitmentPercent.toFixed(1)}%`]})]})]}),(0,B.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,B.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-foreground`,"aria-label":`Admitted work agents: ${t.admission.admittedWorkAgentCount}`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Admitted work agents`}),(0,B.jsx)(`span`,{children:t.admission.admittedWorkAgentCount})]}),(0,B.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-foreground`,"aria-label":`Containers: ${t.summary.containerCount}`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Containers`}),(0,B.jsx)(`span`,{children:t.summary.containerCount})]}),(0,B.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border px-2 py-1 text-xs text-foreground ${S.classes}`,"aria-label":`Webhook relay: ${S.label}`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 rounded-full ${S.dotClass}`}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Webhook relay`}),(0,B.jsx)(`span`,{children:S.label})]})]}),(0,B.jsxs)(`div`,{className:`mb-3`,children:[h.length>0?(0,B.jsx)(`div`,{className:`space-y-1 rounded-lg border border-border p-2`,children:h.map(e=>{let t=e.targets.length===1?e.targets[0]:void 0;return(0,B.jsx)(`div`,{className:`text-xs`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{role:`img`,className:`inline-block h-2 w-2 rounded-full ${e.severity===`critical`?`bg-destructive`:`bg-warning`}`,"aria-label":`${e.severity} attention`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`text-foreground`,children:[e.title,e.agents.length>1&&(0,B.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.agents.length]})]}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:e.sub})]})]}),t&&(0,B.jsx)(Len,{target:t,onOpen:f,onSelectLeaked:()=>s(!0)})]})},`${e.code}-${e.agents.join(`,`)}`)})}):(0,B.jsx)(`div`,{className:`rounded-lg border border-border p-2 text-xs text-foreground`,children:`No active pressure signals.`}),_.length>0&&(0,B.jsxs)(`details`,{className:`mt-2 cursor-pointer text-xs`,children:[(0,B.jsxs)(`summary`,{className:`text-muted-foreground hover:text-foreground`,children:[_.length,` context note`,_.length===1?``:`s`,` — background, not pressure signals`]}),(0,B.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg border border-border p-2`,children:_.map((e,t)=>(0,B.jsxs)(`div`,{className:`text-muted-foreground`,children:[`• `,e.message]},`${e.code}-${t}`))})]})]}),(0,B.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Top consumers`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o&&t.summary.leakedSpecialistCount>0&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Show all`}),(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.summary.leakedSpecialistCount>0?`⚠ ${t.summary.leakedSpecialistCount} leaked specialist${t.summary.leakedSpecialistCount===1?``:`s`}`:`No leaks`})]})]}),(0,B.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto pr-1`,children:v.map(e=>{let t=e.memoryGb/y*100;return(0,B.jsx)(`div`,{className:`rounded-lg border p-2 ${e.leaked?`border-warning/40 bg-warning/10`:`border-border`}`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:Aen(e)}),(0,B.jsx)(`span`,{role:`note`,className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,"aria-label":`Consumer kind: ${jen(e)}`,children:jen(e)}),e.leaked&&(0,B.jsx)(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:`LEAKED`})]}),(0,B.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.memoryGb.toFixed(2),` GB`,e.cpuPercent==null?``:` · ${e.cpuPercent.toFixed(1)}% CPU`]}),t>0&&(0,B.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{role:`meter`,"aria-label":`${e.label} memory share: ${t.toFixed(1)}%`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(t.toFixed(1)),className:`h-full bg-info`,style:{width:`${t}%`}})})]}),(0,B.jsx)(Ien,{consumer:e,onSelectLeaked:()=>s(!0)})]})},e.id)})})]})]})}async function zen(){let e=await fetch(`/api/deploy/staleness`);if(!e.ok)throw Error(`Failed to fetch deploy staleness`);let t=await e.json();return jm(lg(Tg(oCe))(t))}function Ben(){return V({queryKey:[`deploy-staleness`],queryFn:zen,refetchInterval:6e4})}function Ven(e){return e?.slice(0,8)||`unknown`}function Hen(){let{data:e}=Ben();return e?.status!==`stale`||(e.behindBuildInputs??0)<1?null:(0,B.jsxs)(`span`,{className:`text-[11px] font-medium text-warning-foreground`,title:[`Running build ${Ven(e.buildCommit)}`,`origin/main ${Ven(e.originMainSha)}`,`${e.behindTotal??`unknown`} total commit(s) behind`].join(` · `),children:[`build stale ×`,e.behindBuildInputs]})}function Uen({activeTab:e,selectedProjectKey:t,runningAgentCount:n,dashboardLifecycle:r,showRestartBanner:i,bannerState:a,missingKeyTrackers:o,trackerBannerDismissed:s,showCliproxyBanner:c,isRestartBackendPending:l,isRestartCliproxyPending:u,isSessionFeedSidebarOpen:d,onSearchOpen:f,onOpenSettings:p,onNavigateOpenQuestions:m,onDismissTrackerBanner:h,onRestartBackend:g,onRestartCliproxy:_,onToggleSessionFeedSidebar:v}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-component":`system-notices-row`,className:`flex flex-wrap items-stretch border-b border-border`,children:[(0,B.jsx)(w9t,{}),(0,B.jsx)(ren,{}),(0,B.jsx)(men,{}),(0,B.jsx)(yen,{}),(0,B.jsx)(ben,{}),(0,B.jsx)(ien,{}),(0,B.jsx)(sen,{}),(0,B.jsx)(cen,{}),(0,B.jsx)(den,{})]}),i&&(0,B.jsxs)(`div`,{className:`bg-primary/15 border-b-2 border-primary/40 px-4 py-3 flex items-center gap-3 shrink-0 overflow-hidden animate-slide-down-banner`,children:[(0,B.jsx)(Mc,{className:`w-5 h-5 text-primary shrink-0 animate-spin`}),(0,B.jsxs)(`p`,{className:`text-primary text-sm font-semibold flex-1`,children:[`Dashboard is restarting`,r.issueId&&(0,B.jsxs)(B.Fragment,{children:[` — `,(0,B.jsx)(`span`,{className:`font-mono`,children:r.issueId})]}),r.reason&&(0,B.jsxs)(`span`,{className:`font-normal ml-1 text-primary/70`,children:[`(`,r.reason,`)`]})]}),(0,B.jsx)(`span`,{className:`text-primary/60 text-xs shrink-0 animate-pulse`,children:`● Restarting…`})]}),a===`down`&&!i&&(0,B.jsxs)(`div`,{className:`bg-destructive/15 border-b-2 border-destructive/50 px-4 py-3 flex items-center gap-3 shrink-0 overflow-hidden animate-slide-down-banner`,children:[(0,B.jsx)(il,{className:`w-5 h-5 text-destructive shrink-0`}),(0,B.jsx)(`p`,{className:`text-destructive text-sm font-semibold flex-1`,children:`Backend is unreachable — waiting for it to come back.`}),(0,B.jsx)(`span`,{className:`text-destructive/60 text-xs shrink-0 animate-pulse`,children:`● Retrying…`}),(0,B.jsx)(`button`,{onClick:g,disabled:l,className:`px-4 py-1.5 bg-destructive/20 hover:bg-destructive/30 text-destructive text-sm font-bold rounded-md border border-destructive/40 transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:l?`Restarting…`:`Force Restart`})]}),a===`recovering`&&!i&&(0,B.jsxs)(`div`,{className:`bg-warning/15 border-b-2 border-warning/50 px-4 py-3 flex items-center gap-3 shrink-0 overflow-hidden animate-slide-down-banner`,children:[(0,B.jsx)(_s,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,B.jsx)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:`Backend is back up.`})]}),o.length>0&&!s&&(0,B.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-4 py-2 flex items-center gap-3 shrink-0`,children:[(0,B.jsx)(il,{className:`w-4 h-4 text-warning-foreground shrink-0`}),(0,B.jsxs)(`p`,{className:`text-warning-foreground text-sm flex-1`,children:[(0,B.jsxs)(`span`,{className:`font-semibold`,children:[`Missing API key`,o.length>1?`s`:``,`:`]}),` `,o.map(e=>(0,B.jsxs)(`span`,{children:[e.name,` (`,(0,B.jsx)(`code`,{className:`font-mono text-xs bg-warning/20 px-1 rounded`,children:e.envVar}),`)`]},e.type)).reduce((e,t,n)=>n===0?[t]:[...e,`, `,t],[]),`.`,` `,(0,B.jsx)(`button`,{onClick:p,className:`underline hover:opacity-80 font-semibold`,children:`Configure in Settings`})]}),(0,B.jsx)(`button`,{onClick:h,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0`,title:`Dismiss`,children:`✕`})]}),c&&(0,B.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,B.jsx)(il,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,B.jsx)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:`CLIProxy is down — GPT subscription agents will fail.`}),(0,B.jsx)(`button`,{onClick:_,disabled:u,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:u?`Restarting…`:`Restart CLIProxy`})]}),(0,B.jsxs)(`div`,{className:`relative flex h-12 shrink-0 items-center gap-3 border-b border-border bg-background px-3`,children:[(0,B.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 text-sm font-semibold text-foreground`,children:t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`h-3.5 w-3.5 rounded-[4px] bg-primary/40`,"aria-hidden":`true`}),t]}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`All projects`})}),(0,B.jsxs)(`button`,{type:`button`,onClick:f,className:`mx-auto flex w-full min-w-0 max-w-md items-center gap-2 rounded-lg border border-border px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent`,title:`Search`,children:[(0,B.jsx)(Vc,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`truncate`,children:t?`Search ${t}…`:`Search issues, conversations, commands…`}),(0,B.jsx)(`kbd`,{className:`ml-auto rounded border border-border px-1.5 text-[11px]`,children:`/`})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,B.jsx)(YYt,{compact:!0}),(0,B.jsx)(nen,{}),n>0&&(0,B.jsxs)(`button`,{type:`button`,onClick:ACe,title:`Emergency stop — kill all agents and freeze auto-resume (${kCe})`,"aria-label":`Emergency stop all agents`,className:`inline-flex items-center gap-1.5 rounded-full border border-destructive/40 bg-destructive/10 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/20 transition-colors`,children:[(0,B.jsx)(ys,{className:`h-3.5 w-3.5`}),` Stop all`]}),(0,B.jsx)(ten,{variant:`pill`}),(0,B.jsx)(E9t,{onOpenSettings:p}),(0,B.jsx)(Hen,{}),(0,B.jsx)(Ren,{}),(0,B.jsx)(O9t,{}),(0,B.jsx)(A9t,{onActivate:m}),(0,B.jsx)(V9t,{onOpenSettings:p}),e!==`command-deck`&&(0,B.jsx)(`button`,{type:`button`,"aria-label":`Toggle activity feed`,"aria-pressed":d,title:`Activity Feed`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,onClick:v,children:(0,B.jsx)(sc,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]})]})}function Wen({agents:e,issues:t}){let n=yt(),r=Q(FNe),i=Q(INe),a=Q(LNe),o=eO(e=>e.resolvedPlanToolUseIds),s=eO(e=>e.dismissedPlanSubjectIds),c=eO(e=>e.markPlanResolved),l=eO(e=>e.unmarkPlanResolved),u=eO(e=>e.markPlanDismissed),d=eO(e=>e.undismissPlan),f=eO(e=>e.reconcilePlanResolved),p=eO(e=>e.reconcilePlanDismissed),[m,h]=(0,z.useState)(null),g=eO(e=>e.answeredToolUseIds),_=eO(e=>e.dismissedSubjectIds),v=eO(e=>e.markAnswered),y=eO(e=>e.unmarkAnswered),b=eO(e=>e.markDismissed),x=eO(e=>e.undismiss),S=eO(e=>e.reconcileAnswered),C=eO(e=>e.reconcileDismissed),w=eO(e=>e.reopenId),T=eO(e=>e.reopenNonce),E=eO(e=>e.requestReopen),[D,O]=(0,z.useState)(new Set),[k,A]=(0,z.useState)(null),[j,M]=(0,z.useState)(null),N=(0,z.useRef)([]);(0,z.useEffect)(()=>{if(!w)return;let e=Q.getState().agentsById[w],t=e!=null,n=N.current.find(e=>e.name===w),r=e?.pendingAskUserQuestion!=null||n?.pendingAskUserQuestion!=null,i=e?.pendingProposedPlan!=null||n?.pendingProposedPlan!=null;if(!r&&i){d(w),h(w);return}let a=(e?.pendingInputKinds?.length??0)>0||zNe(e),o=e?.pendingAskUserQuestion!=null||a;x(w),A(w),t&&!o?U.info(`That question is no longer waiting`,{description:`The agent stopped or already received an answer.`}):t&&e?.pendingAskUserQuestion==null&&a&&U.info(`This agent is blocked on a terminal dialog`,{description:`Open its terminal to answer (e.g. a tool-permission, rate-limit, or session-resume prompt) — it cannot be answered from here yet.`})},[T]);let P=r.filter(e=>!D.has(e.requestId))[0]??null,F=P?.issueId??e.find(e=>e.id===P?.agentId)?.issueId,{data:I=[]}=V({queryKey:[`conv-ask-user-question`],queryFn:async({signal:e})=>{let t=await vl(`/api/conversations/pending-input`,{signal:e});return t.ok?t.json():[]},refetchInterval:4e3,refetchIntervalInBackground:!0});N.current=I;let L=[...a.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Agent`,title:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,pendingProposedPlan:e.pendingProposedPlan,askedAt:e.pendingProposedPlan?.askedAt??``})),...I.filter(e=>e.pendingProposedPlan).map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Conversation`,title:e.title??null,pendingProposedPlan:e.pendingProposedPlan,askedAt:e.pendingProposedPlan?.askedAt??``}))];L.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let ee=L.filter(e=>{let t=e.pendingProposedPlan?.toolUseId;return!(!t||o.has(t)||s.has(e.id))}),R=(m?ee.find(e=>e.id===m):void 0)??ee[0]??null,te=[...i.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Agent`,title:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``})),...I.map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Conversation`,title:e.title??null,harness:e.harness??null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``}))];te.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let ne=te.filter(e=>{let t=e.pendingAskUserQuestion?.toolUseId;return!(!t||g.has(t)||_.has(e.id))}),re=(k?ne.find(e=>e.id===k):void 0)??ne[0]??null;(0,z.useEffect)(()=>{O(e=>{let t=new Set,n=new Set(r.map(e=>e.requestId));for(let r of e)n.has(r)&&t.add(r);return t.size===e.size&&Array.from(t).every(t=>e.has(t))?e:t})},[r]);let{data:ie=[]}=V({queryKey:[`confirmations`],queryFn:syt,refetchInterval:1e4});(0,z.useEffect)(()=>{ie.length>0&&!j&&M(ie[0])},[ie,j]),(0,z.useEffect)(()=>{if(!(typeof window>`u`)&&`Notification`in window&&Notification.permission===`default`){let e=()=>{Notification.requestPermission().catch(()=>{}),window.removeEventListener(`pointerdown`,e)};return window.addEventListener(`pointerdown`,e,{once:!0}),()=>{window.removeEventListener(`pointerdown`,e)}}},[]);let ae=(0,z.useRef)(new Set);(0,z.useEffect)(()=>{let e=(e,t,n,r)=>{let i=e;if(ae.current.has(i))return;ae.current.add(i);let a=()=>E(t);if(U.info(n,{description:r,duration:12e3,action:{label:`Answer`,onClick:a}}),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`)try{let e=new Notification(n,{body:r,tag:i});e.onclick=()=>{window.focus(),a(),e.close()}}catch{}};for(let n of i){let r=n.pendingAskUserQuestion?.toolUseId;if(!r)continue;let i=n.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,a=(n.issueId?t.find(e=>e.id===n.issueId)?.title:void 0)??n.issueId??n.id;e(`agent::${n.id}::${r}`,n.id,`${a} is waiting on you`,i)}for(let t of I){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=t.title??t.name;e(`conv::${t.name}::${n}`,t.name,`"${i}" is waiting on you`,r)}for(let n of a){let r=n.pendingProposedPlan?.toolUseId;if(!r)continue;let i=(n.issueId?t.find(e=>e.id===n.issueId)?.title:void 0)??n.issueId??n.id;e(`agent-plan::${n.id}::${r}`,n.id,`${i} has a plan awaiting approval`,`Review and approve the plan to start implementation.`)}for(let t of I){let n=t.pendingProposedPlan?.toolUseId;if(!n)continue;let r=t.title??t.name;e(`conv-plan::${t.name}::${n}`,t.name,`"${r}" has a plan awaiting approval`,`Review and approve the plan to start implementation.`)}let n=new Set;for(let e of i){let t=e.pendingAskUserQuestion?.toolUseId;t&&n.add(`agent::${e.id}::${t}`)}for(let e of I){let t=e.pendingAskUserQuestion?.toolUseId;t&&n.add(`conv::${e.name}::${t}`);let r=e.pendingProposedPlan?.toolUseId;r&&n.add(`conv-plan::${e.name}::${r}`)}for(let e of a){let t=e.pendingProposedPlan?.toolUseId;t&&n.add(`agent-plan::${e.id}::${t}`)}for(let e of ae.current)n.has(e)||ae.current.delete(e)},[i,a,I,t]);let oe=Mt({mutationFn:async({kind:e,id:t,answers:n,questions:r,harness:i,toolUseId:a})=>{if(e===`agent`){let e=await vl(`/api/agents/${encodeURIComponent(t)}/answer-question`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}if(i===`ohmypi`||i===`pi`){let e=await vl(`/api/conversations/${encodeURIComponent(t)}/pi-ask-answer`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({toolUseId:a,answers:n})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}let o=[],s=r??[];for(let e=0;e<n.length&&e<s.length;e++){let t=s[e]?.question??`Question ${e+1}`;o.push(`Q: ${t}\nA: ${n[e]}`)}let c=`Operator answered the pending question${n.length>1?`s`:``}:\n\n${o.join(`
|
|
859
859
|
|
|
860
860
|
`)}`,l=await vl(`/api/conversations/${encodeURIComponent(t)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:c})});if(!l.ok){let e=`Failed to deliver answer (${l.status})`;try{let t=await l.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return l.json()},onMutate:e=>{let t=re?.pendingAskUserQuestion?.toolUseId;return t&&v(t),{subjectId:e.id,toolUseId:t}},onSuccess:(e,t)=>{U.success(`Answer delivered to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&y(n.toolUseId),U.error(`Failed to deliver answer: ${e.message}`)}}),se=Mt({mutationFn:async({id:e,optionNumber:t,toolUseId:n})=>{let r=await vl(`/api/conversations/${encodeURIComponent(e)}/codex-approval`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({optionNumber:t,toolUseId:n})});if(!r.ok){let e=`Failed to send approval (${r.status})`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return r.json()},onMutate:({toolUseId:e})=>(e&&v(e),{toolUseId:e}),onSuccess:(e,t)=>{U.success(`Approval sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&y(n.toolUseId),U.error(`Failed to send approval: ${e.message}`)}}),ce=(0,z.useCallback)(e=>{if(!re)return;let t=re,n=t.pendingAskUserQuestion?.toolUseId;if(n?.startsWith(`codex-approval:`)){let r=/^\s*(\d+)/.exec(e[0]??``),i=r?Number(r[1]):NaN;if(!Number.isInteger(i)){U.error(`Could not determine which option was selected`);return}se.mutate({id:t.id,optionNumber:i,label:t.title?.trim()||t.id,toolUseId:n});return}oe.mutate({kind:t.kind??`agent`,id:t.id,label:t.title?.trim()||t.id,answers:e,questions:t.pendingAskUserQuestion?.questions,harness:t.harness??null,toolUseId:t.pendingAskUserQuestion?.toolUseId})},[oe,se,re]),le=(0,z.useCallback)(()=>{re&&b(re.id)},[re,b]),ue=Mt({mutationFn:async({kind:e,id:t,action:n,feedback:r})=>{let i=await vl(e===`agent`?`/api/agents/${encodeURIComponent(t)}/plan-action`:`/api/conversations/${encodeURIComponent(t)}/plan-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:n,feedback:r})});if(!i.ok){let e=`Failed to deliver plan action (${i.status})`;try{let t=await i.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return i.json()},onMutate:({toolUseId:e})=>(e&&c(e),{toolUseId:e}),onSuccess:(e,t)=>{U.success(t.action===`approve-manual`?`Plan approved for ${t.label?.trim()||t.id}`:`Plan feedback sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&l(n.toolUseId),U.error(`Plan action failed: ${e.message}`)}}),de=(0,z.useCallback)(()=>{if(!R)return;let e=R;ue.mutate({kind:e.kind,id:e.id,label:e.title?.trim()||e.issueId||e.id,action:`approve-manual`,toolUseId:e.pendingProposedPlan?.toolUseId})},[R,ue]),fe=(0,z.useCallback)(e=>{if(!R)return;let t=R;ue.mutate({kind:t.kind,id:t.id,label:t.title?.trim()||t.issueId||t.id,action:`reject-feedback`,feedback:e,toolUseId:t.pendingProposedPlan?.toolUseId})},[R,ue]),pe=(0,z.useCallback)(()=>{R&&(u(R.id),h(e=>e===R.id?null:e))},[R,u]);(0,z.useEffect)(()=>{let e=i.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`),t=I.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`);S(new Set([...e,...t]));let n=new Set([...i.map(e=>e.id),...I.map(e=>e.name)]);C(n),A(e=>e&&n.has(e)?e:null),f(new Set([...a.map(e=>e.pendingProposedPlan?.toolUseId).filter(e=>typeof e==`string`),...I.map(e=>e.pendingProposedPlan?.toolUseId).filter(e=>typeof e==`string`)]));let r=new Set([...a.map(e=>e.id),...I.filter(e=>e.pendingProposedPlan).map(e=>e.name)]);p(r),h(e=>e&&r.has(e)?e:null)},[i,a,I,S,C,f,p]);let me=Mt({mutationFn:({agentId:e,requestId:t,behavior:n})=>lyt(e,t,n),onMutate:async e=>{O(t=>{let n=new Set(t);return n.add(e.requestId),n})},onSuccess:async(e,t)=>{await nL(n),U.success(t.behavior===`allow`?`Allowed ${t.agentId} to continue`:`Denied permission request for ${t.agentId}`)},onError:(e,t)=>{O(e=>{if(!e.has(t.requestId))return e;let n=new Set(e);return n.delete(t.requestId),n}),U.error(`Permission response failed: ${e.message}`)}}),he=(0,z.useCallback)(async()=>{if(j)try{await cyt(j.id,!0),M(null)}catch(e){console.error(`Failed to confirm:`,e)}},[j]),ge=(0,z.useCallback)(async()=>{if(j)try{await cyt(j.id,!1),M(null)}catch(e){console.error(`Failed to deny:`,e)}},[j]),_e=(0,z.useCallback)(()=>{P&&me.mutate({agentId:P.agentId,requestId:P.requestId,behavior:`allow`})},[me,P]),ve=(0,z.useCallback)(()=>{P&&me.mutate({agentId:P.agentId,requestId:P.requestId,behavior:`deny`})},[me,P]),ye=(0,z.useCallback)(()=>{M(null)},[]);return{currentChannelPermissionRequest:P,currentChannelPermissionIssueId:F,isChannelPermissionSubmitting:me.isPending,handleAllowChannelPermission:_e,handleDenyChannelPermission:ve,currentAskUserQuestionSubject:re,isAskUserQuestionSubmitting:oe.isPending||se.isPending,handleSubmitAskUserQuestion:ce,handleDismissAskUserQuestion:le,currentPlanApprovalSubject:R,isPlanActionSubmitting:ue.isPending,handleApprovePlan:de,handleRequestPlanChanges:fe,handleDismissPlanApproval:pe,currentConfirmation:j,handleConfirm:he,handleDeny:ge,handleCloseConfirmation:ye}}function Gen(){let e=Q(e=>e.recentActivity),t=(0,z.useRef)(new Set),n=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(Array.isArray(e)){if(!n.current){for(let n of e)n?.id&&t.current.add(n.id);n.current=!0;return}for(let n of e)if(!(!n?.desktop||!n.id||t.current.has(n.id))&&(t.current.add(n.id),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`))try{let e=new Notification(`Overdeck`,{body:n.message??`Overdeck notification`,tag:n.id});e.onclick=()=>{window.focus(),e.close()}}catch{}}},[e])}var Ken=`overdeck.ui.sessionFeedSidebarOpen`;function qen(){if(typeof window>`u`)return!0;let e=window.localStorage.getItem(Ken);return e===null?!0:e===`true`}function Jen(){let e=Q(e=>e.tasksViewerIssueId),t=Q(e=>e.closeTasksViewer);return e?(0,B.jsx)(zvt,{issueId:e,isOpen:!0,onClose:t}):null}function Yen(){let e=Q(e=>e.prdViewerIssueId),t=Q(e=>e.closePrdViewer);return e?(0,B.jsx)(Bvt,{issueId:e,onClose:t}):null}function Xen(){(0,z.useEffect)(()=>{},[]);let e=window.location.pathname,t=new URLSearchParams(window.location.search).get(`terminal`);if(e.startsWith(`/terminal/`)||t)return(0,B.jsx)(Pyt,{sessionName:e.startsWith(`/terminal/`)?e.replace(`/terminal/`,``):t,token:new URLSearchParams(window.location.search).get(`token`)??void 0});if(e===`/popout/flywheel-conversation`)return(0,B.jsx)(Fyt,{});let n=e.match(/^\/popout\/conversation\/([^/]+)$/);if(n)return(0,B.jsx)(Iyt,{conversationId:n[1]});if(e===`/popout/diff`)return(0,B.jsx)(Lyt,{});let[r,i]=(0,z.useState)(()=>BQ().tab),[,a]=(0,z.useState)(()=>{let e=window.location.hash;return e.startsWith(`#agent=`)?decodeURIComponent(e.slice(7)):null}),o=(0,z.useCallback)(e=>{a(e),e?window.history.replaceState(null,``,`${window.location.pathname}#agent=${encodeURIComponent(e)}`):window.history.replaceState(null,``,window.location.pathname)},[]);RQ(),(0,z.useEffect)(()=>{let e=()=>{let e=window.location.hash;e.startsWith(`#agent=`)&&a(decodeURIComponent(e.slice(7)))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=BQ(),c=_yt(),l=vyt(),u=Syt(),[d,f]=(0,z.useState)(()=>s.convId),[p,m]=(0,z.useState)(()=>c?.project??l),[h,g]=(0,z.useState)(()=>s.viewMode),[_,v]=(0,z.useState)(()=>s.viewModes),[y,b]=(0,z.useState)(()=>c),[x,S]=(0,z.useState)(()=>yyt()),C=(0,z.useRef)(c?`/command-deck/${encodeURIComponent(c.project)}/${encodeURIComponent(c.issue)}`:l?`/command-deck/${encodeURIComponent(l)}`:`/command-deck`),w=(0,z.useCallback)((e,t=`conversation`)=>{f(e),g(e?t:`conversation`),v(n=>{let r={...n};return e&&t===`terminal`?r[e]=`terminal`:e&&delete r[e],window.history.replaceState(null,``,e?Eyt(e,t,n):C.current),r})},[]),T=(0,z.useCallback)(e=>{w(e,e?_[e]??`conversation`:`conversation`)},[_,w]),E=(0,z.useCallback)(e=>{w(d,e)},[d,w]),D=yt(),O=Q(e=>e.recentActivity??[]),[k,A]=(0,z.useState)(!1),j=(0,z.useCallback)(()=>A(!0),[]),M=(0,z.useCallback)(e=>{D.invalidateQueries({queryKey:[`command-deck-projects`]}),D.invalidateQueries({queryKey:[`registered-projects`]}),m(e.key),i(`command-deck`);let t=`/command-deck/${encodeURIComponent(e.key)}`;C.current=t,window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e.key},``,t),w(null),cO.getState().ensureHome(e.key)},[D,w]),N=(0,z.useRef)(new Set);(0,z.useEffect)(()=>{for(let e of O.slice(0,10)){let t=typeof e.id==`string`?e.id:null,n=typeof e.issueId==`string`?e.issueId:null,r=typeof e.message==`string`?e.message:``;!t||!n||N.current.has(t)||/^Rebuild stack for\b/.test(r)&&(N.current.add(t),D.invalidateQueries({queryKey:[`workspace`,n]}))}},[D,O]);let[P,F]=(0,z.useState)(null),[I,L]=(0,z.useState)(!1),[ee,R]=(0,z.useState)(!1),[te,ne]=(0,z.useState)(null),[re,ie]=(0,z.useState)(!1),[ae,oe]=(0,z.useState)(`all`),[se,ce]=(0,z.useState)(null),[le,ue]=(0,z.useState)(qen),[de,fe]=(0,z.useState)(!1),pe=Q(e=>e.drawer.issueId)!==null,me=Q(e=>e.openIssue),he=Q(e=>e.openIssueFromRoute),ge=Q(e=>e.syncDrawerFromUrl),_e=Q(GNe),{isError:ve,failureCount:ye}=V({queryKey:[`backend-health`],queryFn:ryt,refetchInterval:5e3,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),be=(0,z.useRef)(null),[xe,Se]=(0,z.useState)(null);(0,z.useEffect)(()=>{ve?(be.current&&=(clearTimeout(be.current),null),ye>=2&&Se(`down`)):xe===`down`&&(Se(`recovering`),be.current=setTimeout(()=>{Se(null),be.current=null},2500))},[ve,ye,xe]),(0,z.useEffect)(()=>()=>{be.current&&clearTimeout(be.current)},[]);let Ce=_e.active,{data:we}=V({queryKey:[`tracker-status`],queryFn:oyt,refetchInterval:6e4,retry:!1}),Te=we?.configured.filter(e=>!e.hasKey)||[],{data:Ee}=V({queryKey:[`cliproxy-status`],queryFn:uyt,refetchInterval:1e4,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),De=Ee&&!Ee.running,{data:Oe}=V({queryKey:[`settings`,`experimental-features`],queryFn:ZGe,staleTime:3e4}),ke=Oe===!0||Oe===!1,Ae=Mt({mutationFn:dyt,onSuccess:()=>{D.invalidateQueries({queryKey:[`cliproxy-status`]}),U.success(`CLIProxy restarted successfully`)},onError:e=>{U.error(`Failed to restart CLIProxy: `+e.message)}}),je=Mt({mutationFn:async()=>{let e=window.overdeckBridge;if(e?.restartDashboard){await e.restartDashboard();return}try{if((await fetch(`/api/system/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(3e3)})).ok)return}catch{}let t=nyt();if(!t)throw Error(`Dashboard is unreachable and supervisor URL is unknown — try restarting from the CLI.`);let n=await fetch(`${t}/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(5e3)});if(!n.ok)throw Error(`Supervisor returned ${n.status}`)},onSuccess:()=>{U.success(`Restart requested — reconnecting…`)},onError:e=>{U.error(`Restart failed: `+e.message)}}),Me=(0,z.useCallback)(e=>{let t=ke&&!Oe&&gO(e)?`home`:e;i(t),ts(`dashboard_tab_viewed`,{tab:t});let n=zQ[t];window.location.pathname!==n&&window.history.pushState({tab:t},``,n)},[Oe,ke]);(0,z.useEffect)(()=>{ke&&!Oe&&gO(r)&&Me(`home`)},[r,Oe,ke,Me]),(0,z.useEffect)(()=>{if(!(typeof window>`u`))try{window.localStorage.setItem(fyt,r)}catch{}},[r]);let Ne=(0,z.useCallback)(()=>{let e=gyt();if(!e)return;if(X8.getState().mode===`simple`){r!==`home`&&i(`home`),X8.getState().openSimpleIssue(e);return}let t=myt()??`pipeline`;r!==t&&i(t),he(e,zQ[t],window.location.pathname)},[r,he]);(0,z.useEffect)(()=>{Ne()},[Ne]);let Pe=(0,z.useCallback)((e,t)=>{if(e&&t){let n=`/command-deck/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;C.current=n,window.location.pathname!==n&&window.history.replaceState({tab:`command-deck`},``,n)}else if(e){let t=`/command-deck/${encodeURIComponent(e)}`;C.current=t,window.location.pathname!==t&&window.history.replaceState({tab:`command-deck`,project:e},``,t)}else C.current=`/command-deck`,window.location.pathname.startsWith(`/command-deck/`)&&window.history.replaceState({tab:`command-deck`},``,`/command-deck`)},[]),Fe=(0,z.useCallback)(e=>{i(`workspace`),S(e);let t=`/workspace/${encodeURIComponent(e)}`;window.location.pathname!==t&&window.history.pushState({tab:`workspace`},``,t)},[]),Ie=(0,z.useCallback)(e=>{let t=e?`/workspaces/new?project=${encodeURIComponent(e)}`:`/workspaces/new`;i(`workspace-new`),window.history.pushState({tab:`workspace-new`},``,t)},[]),Le=(0,z.useCallback)(()=>{S(null),Me(`home`)},[Me]),Re=(0,z.useCallback)(e=>{D.invalidateQueries({queryKey:[`workspace-registry`]}),(async()=>{try{await vl(`/api/workspace-registry/${encodeURIComponent(e)}/activate`,{method:`POST`,credentials:`include`,headers:await sb()})}catch{}})(),Fe(e)},[Fe,D]),ze=(0,z.useCallback)(async e=>{let t=e.conversationId||e.sessionId,n=e.projectKey||`__no-project__`;try{let r=await iyt(t,e.byteOffset),i=Date.now();ce({conversationName:t,messageId:r.messageId,messageIndex:r.messageIndex,nonce:i,label:e.label||`Agent`}),Me(`command-deck`),m(n),w(t,`conversation`);let a=cO.getState();a.ensureHome(n);let o=a.addPane(n,{paneType:`agent`,label:e.label||`Agent`,conversationId:t,viewMode:`conversation`});cO.getState().updatePane(n,o,{viewMode:`conversation`,targetMessageId:r.messageId,targetMessageIndex:r.messageIndex,targetMessageNonce:i})}catch(t){U.error(ayt(e,t))}},[Me,w]),Be=(0,z.useCallback)(e=>{ue(e),window.localStorage.setItem(Ken,String(e))},[]),Ve=(0,z.useCallback)((e,t)=>{if(m(e),i(`command-deck`),t?.updateUrl!==!1){let t=e?`/command-deck/${encodeURIComponent(e)}`:`/command-deck`;C.current=t,window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e},``,t),w(null)}if(e){cO.getState().ensureHome(e);let t=cO.getState(),n=(t.panesByWorkspace[e]??[]).find(e=>e.paneType===`home`);n&&t.setActivePane(e,n.paneId)}},[w]);(0,z.useEffect)(()=>{let e=()=>{let e=BQ();i(e.tab),f(e.convId),g(e.viewMode),v(e.viewModes);let t=_yt();b(t),S(yyt());let n=t?.project??vyt();C.current=t?`/command-deck/${encodeURIComponent(t.project)}/${encodeURIComponent(t.issue)}`:n?`/command-deck/${encodeURIComponent(n)}`:`/command-deck`,n?m(n):window.location.pathname===`/command-deck`&&m(null),ge(),Ne()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ge,Ne]);let He=Q(cS),Ue=(0,z.useMemo)(()=>He.filter(e=>q9t(e.status)).length,[He]),We=Q(dS),{currentChannelPermissionRequest:Ge,currentChannelPermissionIssueId:Ke,isChannelPermissionSubmitting:qe,handleAllowChannelPermission:Je,handleDenyChannelPermission:Ye,currentAskUserQuestionSubject:Xe,isAskUserQuestionSubmitting:Ze,handleSubmitAskUserQuestion:Qe,handleDismissAskUserQuestion:$e,currentPlanApprovalSubject:et,isPlanActionSubmitting:tt,handleApprovePlan:nt,handleRequestPlanChanges:rt,handleDismissPlanApproval:it,currentConfirmation:at,handleConfirm:ot,handleDeny:st,handleCloseConfirmation:ct}=Wen({agents:He,issues:We});Gen();let lt=(0,z.useRef)({prefix:null,timer:null});(0,z.useEffect)(()=>{let e=e=>{let t=navigator.platform.includes(`Mac`)?e.metaKey:e.ctrlKey,n=e.target,r=n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable;if(!r&&!re){if(e.key===`g`){e.preventDefault(),lt.current.prefix=`g`,lt.current.timer&&clearTimeout(lt.current.timer),lt.current.timer=setTimeout(()=>{lt.current.prefix=null,lt.current.timer=null},1500);return}if(lt.current.prefix===`g`){lt.current.timer&&clearTimeout(lt.current.timer),lt.current.timer=null,lt.current.prefix=null;let t=e.key===`p`?`pipeline`:e.key===`b`?`kanban`:e.key===`a`?`agents`:e.key===`c`?`command-deck`:null;t&&(e.preventDefault(),Me(t));return}}e.key===`/`&&!r?(e.preventDefault(),L(!0)):e.key===`k`&&t&&!e.shiftKey?(e.preventDefault(),oe(`all`),ie(e=>!e)):e.key===`j`&&t&&!e.shiftKey&&(e.preventDefault(),oe(`conversations`),ie(!0))};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),lt.current.timer&&clearTimeout(lt.current.timer)}},[re,Me,L,ie]),(0,z.useEffect)(()=>{let e=window.overdeckBridge;if(e)return e.onMenuAction(e=>{if(e===`open-settings`)Me(`settings`);else if(e.startsWith(`open-workspace:`)){let t=e.slice(15);Me(`kanban`),t&&me(t)}else if(e.startsWith(`auto-start-nag:`)){ie(!1);let t=e.split(`:`);ut(parseInt(t[1]??`0`,10),parseInt(t[2]??`5`,10))}else e===`open-updater`&&R(!0)})},[me,Me]);function ut(e,t){let n=[`Auto-start means never missing an agent asking for help.`,`Your agents could be waiting for you right now.`,`Overdeck works best when it's always watching.`,`One click enables auto-start. You can disable it anytime.`];U(`Reminder ${e} of ${t} — ${n[(e-2)%n.length]??n[0]}`,{duration:8e3,action:{label:`Enable`,onClick:()=>{window.overdeckBridge?.updateDesktopSetting(`autoStart.enabled`,!0)}}})}let dt=(0,z.useCallback)(e=>{Me(`kanban`),me(e)},[me,Me]),{data:ft=[]}=V({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);return e.json()},staleTime:6e4}),pt=(0,z.useCallback)(e=>{let t=We.find(t=>t.identifier===e),n=t?.sourceRepo||t?.project?.name||``,r=n.includes(`/`)?n.split(`/`).pop():n,i=ft.find(e=>e.key===r||e.name===r||e.key===n||e.name===n);return i?i.name??i.key:p??null},[We,ft,p]),mt=(0,z.useCallback)((e,t)=>{let n=We.find(t=>t.identifier===e);if(t===`browser`){let t=e.replace(/^[A-Za-z]+-/,``),r=n?.project?.name,i=n?.url||(r&&r.includes(`/`)?`https://github.com/${r}/issues/${t}`:null);if(!i){me(e);return}window.open(i,`_blank`,`noopener,noreferrer`);return}if(t===`modal`){me(e);return}let r=pt(e);if(!r){me(e);return}Me(`command-deck`),b({project:r,issue:e}),Pe(r,e)},[We,me,pt,Me,Pe]),ht=(0,z.useCallback)(e=>{Me(`kanban`),me(e)},[me,Me]);return(0,B.jsxs)(`div`,{className:`h-screen flex flex-row overflow-hidden bg-background`,children:[(0,B.jsx)(SS,{}),(0,B.jsx)(Lvt,{isOpen:k,onClose:()=>A(!1),onCreated:M}),(0,B.jsx)(mWe,{}),(0,B.jsx)(cKe,{activeTab:r,onTabChange:Me,onSearchOpen:()=>L(!0),selectedProject:p,onSelectProject:Ve,onNewProject:j,onNewWorkspace:()=>Ie(p??void 0),onOpenUpdater:()=>R(!0),onSelectWorkspace:Fe}),(0,B.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden min-w-0`,children:[(0,B.jsx)(Uen,{activeTab:r,selectedProjectKey:p,runningAgentCount:Ue,dashboardLifecycle:_e,showRestartBanner:Ce,bannerState:xe,missingKeyTrackers:Te,trackerBannerDismissed:de,showCliproxyBanner:De,isRestartBackendPending:je.isPending,isRestartCliproxyPending:Ae.isPending,isSessionFeedSidebarOpen:le,onSearchOpen:()=>L(!0),onOpenSettings:()=>Me(`settings`),onNavigateOpenQuestions:()=>Me(`flywheel`),onDismissTrackerBanner:()=>fe(!0),onRestartBackend:()=>je.mutate(),onRestartCliproxy:()=>Ae.mutate(),onToggleSessionFeedSidebar:()=>Be(!le)}),(0,B.jsxs)(`div`,{className:`min-h-0 flex flex-1 overflow-hidden`,children:[(0,B.jsx)(`main`,{"data-drawer-open":pe?`true`:void 0,className:`relative flex-1 flex overflow-hidden data-[drawer-open=true]:before:pointer-events-none data-[drawer-open=true]:before:absolute data-[drawer-open=true]:before:inset-0 data-[drawer-open=true]:before:z-[80] data-[drawer-open=true]:before:bg-primary/[0.04] data-[drawer-open=true]:before:backdrop-blur-[2px]`,children:(0,B.jsx)(u9t,{backendDown:xe===`down`,restarting:Ce,activeTab:r,issues:We,selectedConvId:d,conversationViewMode:h,selectedProjectKey:p,pendingConversationTarget:se,cockpitRoute:y,workspaceRouteId:x,onWorkspaceViewBack:Le,onWorkspaceCreated:Re,initialSessionKey:u,onOpenWorkspaceHome:ht,onNewProject:j,onSelectProject:Ve,onOpenSettings:()=>Me(`settings`),onConvIdChange:T,onConversationViewModeChange:E,onPendingConversationTargetConsumed:()=>ce(null),onProjectPrefixChange:ne,onCockpitChange:Pe,onSearchOpen:()=>L(!0),onTabChange:Me,onOpenIssue:me,onPlanDialogChange:F,onSelectAgent:o,onBacklogIssueAction:mt,keyboardShortcutsDisabled:I||re})}),le&&![`command-deck`,`backlog`,`god-view`].includes(r)&&(0,B.jsx)(Evt,{onClose:()=>Be(!1)})]})]}),(0,B.jsx)(E_t,{}),(0,B.jsx)(Gvt,{}),(0,B.jsx)(Jen,{}),(0,B.jsx)(Yen,{}),(0,B.jsx)(A_t,{}),(0,B.jsx)(M_t,{}),(0,B.jsx)(Rvt,{isOpen:ee,runningAgentCount:Ue,onClose:()=>R(!1)}),(0,B.jsx)(NCe,{request:Ge,issueId:Ke,isOpen:!!Ge,isSubmitting:qe,onAllow:Je,onDeny:Ye}),(0,B.jsx)(PCe,{subject:Xe,isOpen:!!Xe&&!Ge,isSubmitting:Ze,onSubmit:Qe,onDismiss:$e}),(0,B.jsx)(dNe,{subject:et,isOpen:!!et&&!Ge&&!Xe,isSubmitting:tt,onApprove:nt,onRequestChanges:rt,onDismiss:it}),(0,B.jsx)(DCe,{request:at,isOpen:!!at,onConfirm:ot,onDeny:st,onClose:ct}),(0,B.jsx)(DLe,{isOpen:I,onClose:()=>L(!1),onSelectIssue:dt,cycleFilter:`current`,includeCompletedFilter:!1,projectPrefix:r===`command-deck`?te:null}),(0,B.jsx)(DKe,{isOpen:re,initialScope:ae,onClose:()=>ie(!1),onNavigate:(e,t)=>{Me(e),t&&me(t)},onOpenConversationHit:ze,onSelectWorkspace:Fe,onNewWorkspace:()=>Ie()}),(0,B.jsx)(MCe,{}),(0,B.jsx)(poe,{})]})}_ie(),HP.getState().reconcileFromServer(),sPe();function Zen(e){if(e instanceof TypeError){let t=e.message.toLowerCase();return t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)}return!1}var Qen=new _t({defaultOptions:{queries:{refetchInterval:6e4,staleTime:3e4,refetchIntervalInBackground:!1,retry:(e,t)=>Zen(t)&&e<3},mutations:{retry:(e,t)=>Zen(t)&&e<3,retryDelay:e=>Math.min(1e3*2**e,8e3)}}});aee.createRoot(document.getElementById(`root`)).render((0,B.jsx)(z.StrictMode,{children:(0,B.jsx)(cPe,{children:(0,B.jsx)(bt,{client:Qen,children:(0,B.jsx)(Hae,{children:(0,B.jsx)(Xen,{})})})})})),window.__panMounted=!0;export{ox as $,q6 as A,YF as B,Z6 as C,J6 as D,lqt as E,g6 as F,HF as G,JF as H,h6 as I,tS as J,uC as K,$F as L,QKt as M,O6 as N,Q6 as O,PKt as P,XDe as Q,XF as R,$6 as S,Y6 as T,ZF as U,qF as V,KF as W,Cx as X,zx as Y,gOe as Z,a8 as _,gqt as a,ewe as at,e8 as b,s8 as c,GCe as ct,mqt as d,VDe as et,vqt as f,dqt as g,i8 as h,d8 as i,Sb as it,iqt as j,uqt as k,hqt as l,FCe as lt,xqt as m,p8 as n,nx as nt,fqt as o,pb as ot,l8 as p,aC as q,u8 as r,GEe as rt,_qt as s,mb as st,f8 as t,ax as tt,pqt as u,n8 as v,X6 as w,t8 as x,r8 as y,QF as z};
|