yepanywhere 0.9.0 → 0.9.2
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/bundled/@yep-anywhere/shared/dist/__tests__/long-context-effort-warning.test.js +19 -0
- package/bundled/@yep-anywhere/shared/dist/__tests__/long-context-effort-warning.test.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/__tests__/model-prices.test.js +12 -0
- package/bundled/@yep-anywhere/shared/dist/__tests__/model-prices.test.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts +2 -2
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/app-types.js +5 -5
- package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.d.ts +21 -0
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.js +22 -1
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/capability-ids.d.ts +6 -0
- package/bundled/@yep-anywhere/shared/dist/capability-ids.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/capability-ids.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/capability-ids.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts +2 -2
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.d.ts +41 -0
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.js +280 -0
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.d.ts +2 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.d.ts +2 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.js +5 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.js +59 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.d.ts +46 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.js +45 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts +4 -2
- package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/index.js +3 -1
- package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.d.ts +11 -11
- package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.js +26 -9
- package/bundled/@yep-anywhere/shared/dist/long-context-effort-warning.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/model-prices.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/model-prices.js +9 -2
- package/bundled/@yep-anywhere/shared/dist/model-prices.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/pdfjs.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/pdfjs.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/pdfjs.js +7 -0
- package/bundled/@yep-anywhere/shared/dist/pdfjs.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts +20 -0
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.js +22 -0
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/skill-invocations.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/skill-invocations.js +7 -10
- package/bundled/@yep-anywhere/shared/dist/skill-invocations.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/types.js.map +1 -1
- package/bundled/@yep-anywhere/shared/package.json +1 -1
- package/client-dist/assets/AboutSettings-CCzudbSj.js +1 -0
- package/client-dist/assets/{ActivityPage-FgSG_9Sl.js → ActivityPage-Bn0LbMgE.js} +1 -1
- package/client-dist/assets/{AgentContextSettings-BfTCI7qG.js → AgentContextSettings-DI8jQVIx.js} +3 -3
- package/client-dist/assets/AgentsPage-Ci_iJt8T.js +2 -0
- package/client-dist/assets/App-rFnK5pnF.js +2 -0
- package/client-dist/assets/AppearanceSettings-DTYVt0W5.js +2 -0
- package/client-dist/assets/AppsSettings-hbh_sguk.js +1 -0
- package/client-dist/assets/AttachmentChip-BFve3lTD.js +1 -0
- package/client-dist/assets/{AuthContext-CVsoMulX.js → AuthContext-DmXjW0be.js} +1 -1
- package/client-dist/assets/{BangCommandDisplayObject-B8KrHDzH.js → BangCommandDisplayObject-BH2KRGnc.js} +1 -1
- package/client-dist/assets/BangCommandsPage-MfkuL8yS.js +1 -0
- package/client-dist/assets/BrowserDebugToolbarButton-BPghQu17.js +1 -0
- package/client-dist/assets/{CacheMissBillingSettings-Bfqlk9rA.js → CacheMissBillingSettings-rUgC-_DD.js} +2 -2
- package/client-dist/assets/{CodexUpdatePrompt-ChHtbla-.js → CodexUpdatePrompt-mT9K-f1e.js} +1 -1
- package/client-dist/assets/{CommittedRangeInput-C3Z7YUlS.js → CommittedRangeInput-BwuV6Q6c.js} +1 -1
- package/client-dist/assets/{CommittedRangeNumberInput-D497_5ff.js → CommittedRangeNumberInput-C5YSVltB.js} +1 -1
- package/client-dist/assets/ComputerControlSettings-MWIdP7SS.js +1 -0
- package/client-dist/assets/{ConversationPreviewPage-CTWx9N3v.js → ConversationPreviewPage-B47r7mUF.js} +2 -2
- package/client-dist/assets/DevelopmentSettings-BEAy_xq-.js +1 -0
- package/client-dist/assets/DevicesSettings-DKQOZkRN.js +1 -0
- package/client-dist/assets/EmulatorPage-DlsPq3nR.js +1 -0
- package/client-dist/assets/EmulatorSettings-C6Ye1k_Y.js +1 -0
- package/client-dist/assets/EnvironmentSettings-ou8UNqTa.js +1 -0
- package/client-dist/assets/FilePage-Cw2PaO5H.js +1 -0
- package/client-dist/assets/FilterDropdown-CACc6ysA.js +1 -0
- package/client-dist/assets/FilterDropdown-D11gXriH.css +1 -0
- package/client-dist/assets/FloatingActionButton-Bl1Eumxh.js +1 -0
- package/client-dist/assets/{GitStatusPage-879aktqc.js → GitStatusPage-CLTkgnDI.js} +3 -3
- package/client-dist/assets/GlobalSessionsPage-Bvzs4zmW.js +2 -0
- package/client-dist/assets/GlobalSessionsPage-dlTB6crv.css +1 -0
- package/client-dist/assets/{HeartbeatTextArea-CKxL-bdJ.js → HeartbeatTextArea-CtP5kx9R.js} +1 -1
- package/client-dist/assets/HostIdentityContext-DA7dMF-y.js +1 -0
- package/client-dist/assets/HostsPage-CBOYGC2-.js +1 -0
- package/client-dist/assets/{InboxContext-opkOiXDB.js → InboxContext-8PXoTbK1.js} +1 -1
- package/client-dist/assets/InboxPage-DWl7uzdw.js +1 -0
- package/client-dist/assets/IssueSettings-BVljRpuD.js +1 -0
- package/client-dist/assets/IssuesPage-BFxgsMkf.js +1 -0
- package/client-dist/assets/LifecycleWebhooksSettings-Qw_dN3F3.js +1 -0
- package/client-dist/assets/{LocalAccessSettings-BpmNC9pI.js → LocalAccessSettings-SWirs75o.js} +3 -3
- package/client-dist/assets/LocalMediaModal-B3KXtyEB.css +1 -0
- package/client-dist/assets/LocalMediaModal-B9eHVx6y.js +14 -0
- package/client-dist/assets/{LoginPage-Cu7cX9wS.js → LoginPage-CYWqVJ95.js} +1 -1
- package/client-dist/assets/{MessageAge-Cd1C0-Kr.js → MessageAge-CaPpa1nH.js} +1 -1
- package/client-dist/assets/{MessageDeliverySettings-B_9VqCMP.js → MessageDeliverySettings-BUSuGKlc.js} +2 -2
- package/client-dist/assets/MessageInput-a13ZPAHv.js +3 -0
- package/client-dist/assets/MessageInputToolbar-BIL_6i7G.css +1 -0
- package/client-dist/assets/MessageInputToolbar-CQGTnVea.js +58 -0
- package/client-dist/assets/MessageList-C7kAuWKg.js +4 -0
- package/client-dist/assets/MessageList-rD5OPsAJ.css +1 -0
- package/client-dist/assets/Modal-ClSjJagX.js +15 -0
- package/client-dist/assets/ModelSettings-Dnd4yzmI.js +1 -0
- package/client-dist/assets/NavigationLayout-BTFsWVtE.js +2 -0
- package/client-dist/assets/NewSessionPage-BfiAS-Mo.js +1 -0
- package/client-dist/assets/NotificationsSettings-B1ugQIp-.js +1 -0
- package/client-dist/assets/PageHeader-BjwH2pWD.js +1 -0
- package/client-dist/assets/PerformanceSettings-jJYF9SPY.js +1 -0
- package/client-dist/assets/{ProjectSessionDefaultsModal-Dq2_xDka.js → ProjectSessionDefaultsModal-G_0uxJEv.js} +1 -1
- package/client-dist/assets/ProjectTemplatesSettings-BQTCV3-3.js +1 -0
- package/client-dist/assets/ProjectsPage-suTd8s9l.js +1 -0
- package/client-dist/assets/ProviderBadge-P0VTI71n.js +1 -0
- package/client-dist/assets/{ProviderChildSessionDetail-tWrpaB_X.js → ProviderChildSessionDetail-D0472EW8.js} +35 -35
- package/client-dist/assets/ProviderChildSessionPage-9__sgY14.js +1 -0
- package/client-dist/assets/ProvidersSettings-Bwzy73Rk.js +1 -0
- package/client-dist/assets/{RecapAfterSecondsControl-qU0RMrUX.js → RecapAfterSecondsControl-CxuXyFSr.js} +1 -1
- package/client-dist/assets/{RelayProtocol-DjpPJk64.js → RelayProtocol-BpdH0COG.js} +1 -1
- package/client-dist/assets/RemoteAccessSettings-Dn7KB5nK.js +1 -0
- package/client-dist/assets/RemoteExecutorsSettings-Cjl4Y2rB.js +1 -0
- package/client-dist/assets/SchemaValidationContext-57RCj4c4.js +1 -0
- package/client-dist/assets/{SearchPreview-B25ksFLA.js → SearchPreview-OzVFWPJZ.js} +1 -1
- package/client-dist/assets/{SessionHeader.module-Co9s-JR3.js → SessionHeader.module-BpaFAQ-S.js} +1 -1
- package/client-dist/assets/SessionPage-BYthaEfZ.js +50 -0
- package/client-dist/assets/SessionPage-CXXEAwu2.css +1 -0
- package/client-dist/assets/{SettingsItem-B_rM9Vhi.js → SettingsItem-C9Vh5p7F.js} +1 -1
- package/client-dist/assets/{SettingsSection-DOwc_RwX.js → SettingsSection-BaPzETK6.js} +1 -1
- package/client-dist/assets/SourceControlSettings-DnqLg0db.js +1 -0
- package/client-dist/assets/{SourceFileHeaderActions-3_76js_o.js → SourceFileHeaderActions-PjhUGnn6.js} +1 -1
- package/client-dist/assets/SpeechControlMenu-BYVdEa3C.js +2 -0
- package/client-dist/assets/{SpeechSettings-BT4TnSgr.js → SpeechSettings-B6LkqfSK.js} +2 -2
- package/client-dist/assets/{SpeechSmartTurnControls-vIZ8a7Lb.js → SpeechSmartTurnControls-LPq9wBaM.js} +1 -1
- package/client-dist/assets/StorageSettings-DtsJnYaz.js +1 -0
- package/client-dist/assets/{ThinkingControls-CbZcYobp.js → ThinkingControls-DXbxdJRi.js} +1 -1
- package/client-dist/assets/ToolbarSettings-Nb2BKpnk.js +1 -0
- package/client-dist/assets/UsersSettings-BdvqmyqK.js +1 -0
- package/client-dist/assets/ViewerModePage-CfJJA5GL.css +1 -0
- package/client-dist/assets/ViewerModePage-DzRIpuYF.js +1 -0
- package/client-dist/assets/{VoiceInputButton-japn0Kx_.js → VoiceInputButton-CCgovfyf.js} +1 -1
- package/client-dist/assets/WorkstreamsPage-dlEUllSL.js +1 -0
- package/client-dist/assets/{YaServerProvider-OSxrnpr9.js → YaServerProvider-CN3tC5UL.js} +1 -1
- package/client-dist/assets/{YepAnywhereLogo-OH70DoR4.js → YepAnywhereLogo-5zFKWjQq.js} +1 -1
- package/client-dist/assets/{abnfDiagram-VCTEODGH-BK2byNq2.js → abnfDiagram-VCTEODGH-BWHUBcV3.js} +1 -1
- package/client-dist/assets/{arc-BZ7613Gf.js → arc-DKsIJWGD.js} +1 -1
- package/client-dist/assets/{architectureDiagram-5GKGNRK7-WEjy-r-z.js → architectureDiagram-5GKGNRK7-BuLImqW3.js} +1 -1
- package/client-dist/assets/{attachmentFileNames-BfFUuufi.js → attachmentFileNames-CBV_5g65.js} +1 -1
- package/client-dist/assets/{blockDiagram-I7D4REHJ-BOsYYXyW.js → blockDiagram-I7D4REHJ-CJ4Gh6sL.js} +1 -1
- package/client-dist/assets/{c4Diagram-7LVT6UL2-BRrAUZLE.js → c4Diagram-7LVT6UL2-WR43XvCI.js} +1 -1
- package/client-dist/assets/channel-PV8AAsuo.js +1 -0
- package/client-dist/assets/{chunk-2Q5K7J3B-ikUS9MZO.js → chunk-2Q5K7J3B-CiP4m_EA.js} +1 -1
- package/client-dist/assets/{chunk-5VM5RSS4-DqxRtuTQ.js → chunk-5VM5RSS4-BUAhj1h9.js} +1 -1
- package/client-dist/assets/{chunk-F27PBJKO-DQAhMVEw.js → chunk-F27PBJKO-BUZNwiGx.js} +1 -1
- package/client-dist/assets/{chunk-IMKFNOWR-B2QXI9W-.js → chunk-IMKFNOWR-CX1a0BCE.js} +1 -1
- package/client-dist/assets/{chunk-JWPE2WC7-Px4jgxzE.js → chunk-JWPE2WC7-C6tL-mLF.js} +1 -1
- package/client-dist/assets/{chunk-POPQ4Y6H-BTrXHY42.js → chunk-POPQ4Y6H-BzijGGWv.js} +1 -1
- package/client-dist/assets/{chunk-SVP7TREG-DufcbLSM.js → chunk-SVP7TREG-CsZImJKI.js} +1 -1
- package/client-dist/assets/{chunk-TICWLB2K-C6xArrXi.js → chunk-TICWLB2K-TwCtuDc1.js} +1 -1
- package/client-dist/assets/{chunk-XXDRQBXY-CtTuQMK6.js → chunk-XXDRQBXY-C-2EoNns.js} +1 -1
- package/client-dist/assets/classDiagram-ZZMXUADV-DvtSxfma.js +1 -0
- package/client-dist/assets/classDiagram-v2-VYDZK3BY-DvtSxfma.js +1 -0
- package/client-dist/assets/{client-sN_tbfxh.js → client-Ci_HPGfl.js} +2 -2
- package/client-dist/assets/{compactSettingsControls-BjKplkgf.js → compactSettingsControls-C9mLZh5H.js} +1 -1
- package/client-dist/assets/{cose-bilkent-JH36ORCC-Cn15YJGj.js → cose-bilkent-JH36ORCC-CmbEx2jT.js} +1 -1
- package/client-dist/assets/{cynefin-OW5HDTMX-CJkFJ0DX.js → cynefin-OW5HDTMX-BSQHHXFU.js} +1 -1
- package/client-dist/assets/{cynefinDiagram-5FMLGOSQ-CVX2L_eF.js → cynefinDiagram-5FMLGOSQ-C-62JZJD.js} +1 -1
- package/client-dist/assets/{dagre-GXQ25YYZ-BMbYVbaU.js → dagre-GXQ25YYZ-BBERQe_A.js} +1 -1
- package/client-dist/assets/de-Cgdxe5vX.js +6 -0
- package/client-dist/assets/{diagram-S7CK7UJ4-DTZ_P_Fh.js → diagram-S7CK7UJ4-muw11lmG.js} +1 -1
- package/client-dist/assets/{diagram-UQ7AKVKN-C6cgxro0.js → diagram-UQ7AKVKN-DpePWzAe.js} +1 -1
- package/client-dist/assets/{diagram-VSXAHHWV-MzNPAr2n.js → diagram-VSXAHHWV-DHX6AHUY.js} +1 -1
- package/client-dist/assets/{diagram-VX7I27RA-BZN6iloV.js → diagram-VX7I27RA-DYmR6NH_.js} +1 -1
- package/client-dist/assets/{diagram-Z3DM3KII-CtTiorxp.js → diagram-Z3DM3KII-BC1SenHB.js} +1 -1
- package/client-dist/assets/{ebnfDiagram-PWID7BFC-B28XYdqt.js → ebnfDiagram-PWID7BFC-EVpri6Ma.js} +1 -1
- package/client-dist/assets/{erDiagram-RLTQ6QDP-DlMmHWyy.js → erDiagram-RLTQ6QDP-DthztUaa.js} +1 -1
- package/client-dist/assets/es-gyRk85dY.js +6 -0
- package/client-dist/assets/{flowDiagram-HODETNUW-C5mVciwL.js → flowDiagram-HODETNUW-DEpC5nMx.js} +1 -1
- package/client-dist/assets/fr-Dx9lA8u-.js +6 -0
- package/client-dist/assets/{frontendReload-DT6MOpjg.js → frontendReload-CBdyvvdy.js} +1 -1
- package/client-dist/assets/{ganttDiagram-EL5Y4UJY-BTl7ZRTR.js → ganttDiagram-EL5Y4UJY-Csqji8t1.js} +1 -1
- package/client-dist/assets/{gitGraphDiagram-WWUBYQGX-BsG6KEKe.js → gitGraphDiagram-WWUBYQGX-DVX1SDIE.js} +1 -1
- package/client-dist/assets/{hostStorage-BoEdRarg.js → hostStorage-D1KAm3U1.js} +1 -1
- package/client-dist/assets/{index-D7q51uJV.js → index-BESqiBDI.js} +1 -1
- package/client-dist/assets/index-BkOdUxq4.js +2 -0
- package/client-dist/assets/index-CPb-36gi.css +1 -0
- package/client-dist/assets/index-CoR-vzsb.js +2 -0
- package/client-dist/assets/index-Cv3tQXyE.js +1 -0
- package/client-dist/assets/{index-CkZXrIi5.js → index-DSFMItgO.js} +1 -1
- package/client-dist/assets/index-umZg0LZ6.js +81 -0
- package/client-dist/assets/{infoDiagram-27XIBGKW-CkZcthz-.js → infoDiagram-27XIBGKW-CHm3qsd2.js} +1 -1
- package/client-dist/assets/{ishikawaDiagram-5VMMS53U-Cvqitz5U.js → ishikawaDiagram-5VMMS53U-tBRZwz-_.js} +1 -1
- package/client-dist/assets/ja-BOj7smkY.js +6 -0
- package/client-dist/assets/{journeyDiagram-3NMN7TZE-vCw00Cqy.js → journeyDiagram-3NMN7TZE-EJic7nqD.js} +1 -1
- package/client-dist/assets/{kanban-definition-UXKFOSKX-BZGCo-wX.js → kanban-definition-UXKFOSKX-DtzL6eeO.js} +1 -1
- package/client-dist/assets/{layout-D7JRfual.js → layout-gb-Axsoq.js} +1 -1
- package/client-dist/assets/{linear-O9cHRsA5.js → linear-CAe4xGbR.js} +1 -1
- package/client-dist/assets/long-context-effort-warning-C6XHizE1.js +1 -0
- package/client-dist/assets/{mermaid.core-CdC8AeOx.js → mermaid.core-BCu1nv8H.js} +5 -5
- package/client-dist/assets/{mindmap-definition-YA3MSWOX-CczC57z0.js → mindmap-definition-YA3MSWOX-C7-KSPtJ.js} +1 -1
- package/client-dist/assets/newSessionPrefill-DKcy0abh.js +1 -0
- package/client-dist/assets/{pegDiagram-XKGWAZYB-jTm4iBWK.js → pegDiagram-XKGWAZYB-iWVH9rbY.js} +1 -1
- package/client-dist/assets/{pieDiagram-E7YTZNPT-DfkDPuJg.js → pieDiagram-E7YTZNPT-VKD6PLHa.js} +1 -1
- package/client-dist/assets/providerChildSessions-Cd7oK6KQ.css +1 -0
- package/client-dist/assets/providerChildSessions-DbLFSybt.js +77 -0
- package/client-dist/assets/{quadrantDiagram-AXDQQJYC--bBZSIt1.js → quadrantDiagram-AXDQQJYC-AXFugcFl.js} +1 -1
- package/client-dist/assets/{railroadDiagram-O6MQD6OU-gbkMdGN6.js → railroadDiagram-O6MQD6OU-D6oZy6Al.js} +1 -1
- package/client-dist/assets/{recentProjectPathLinks-Ba20jx5b.js → recentProjectPathLinks-D0Dx6YXT.js} +2 -2
- package/client-dist/assets/{registerServiceWorker-CGxgV4Yi.js → registerServiceWorker-B8K2KVOY.js} +1 -1
- package/client-dist/assets/{relayEndpoints-0oIbn4eU.js → relayEndpoints-BTq9xppf.js} +1 -1
- package/client-dist/assets/{remoteRoutePaths-CiDZeM2I.js → remoteRoutePaths-D8htA0xa.js} +1 -1
- package/client-dist/assets/{requirementDiagram-BXWQKSXE-WfLCTewk.js → requirementDiagram-BXWQKSXE-Eqtb74It.js} +1 -1
- package/client-dist/assets/{sankeyDiagram-P5KCCOFB-BhJkx_M1.js → sankeyDiagram-P5KCCOFB-CxvDiZ1R.js} +1 -1
- package/client-dist/assets/{sequenceDiagram-WJ2MYXX4-_S-ZN-hK.js → sequenceDiagram-WJ2MYXX4-BbpkgW2L.js} +1 -1
- package/client-dist/assets/sessionHistorySearch.worker-DCkPlfGO.js +61 -0
- package/client-dist/assets/{sessionNavigationState-DKXD1sTS.js → sessionNavigationState-BXejf2ZW.js} +1 -1
- package/client-dist/assets/sessionRouteLayer-D9T2QT8G.js +1 -0
- package/client-dist/assets/{sizeCapture-INFHLROL-YfaR_7-Y.js → sizeCapture-INFHLROL-DcuwWD5r.js} +1 -1
- package/client-dist/assets/{sourceControlNavigationState-lyZ29oaF.js → sourceControlNavigationState-BJbTzWTE.js} +1 -1
- package/client-dist/assets/{speechDraftTransaction-zyWVCYTF.js → speechDraftTransaction-WhqFE1h9.js} +1 -1
- package/client-dist/assets/{stateDiagram-D77RDMKH-_N9FdD6m.js → stateDiagram-D77RDMKH-Cidpq73w.js} +1 -1
- package/client-dist/assets/stateDiagram-v2-MP3YSRHH-DFqKXxjz.js +1 -0
- package/client-dist/assets/{swimlanes-42K2YHIH-DUl5jFZz.js → swimlanes-42K2YHIH-Ba8C7MwG.js} +1 -1
- package/client-dist/assets/swimlanesDiagram-VR7AAH4N-3pW2TcAt.js +8 -0
- package/client-dist/assets/{timeline-definition-24CTP7MA-DtYzRl63.js → timeline-definition-24CTP7MA-CKefGvUK.js} +1 -1
- package/client-dist/assets/useAcliCommentarySetting-CBKAl7qr.js +9 -0
- package/client-dist/assets/useActivityBusState-C0dor9p7.js +1 -0
- package/client-dist/assets/{useBackgroundRevalidation-CULom4_W.js → useBackgroundRevalidation-C79HAUP3.js} +1 -1
- package/client-dist/assets/{useCodexUpdateStatus-BIDehnvt.js → useCodexUpdateStatus-CEZO_f2Y.js} +1 -1
- package/client-dist/assets/{useConnectedDevices-kBo43kbz.js → useConnectedDevices-Ds-DuUDc.js} +1 -1
- package/client-dist/assets/{useDocumentTitle-C06qawRj.js → useDocumentTitle-Xz5t-nlB.js} +1 -1
- package/client-dist/assets/{useEmulators-Bz8194e3.js → useEmulators-qS_cCZ3I.js} +1 -1
- package/client-dist/assets/{useFileActivity-CwkGwsQt.js → useFileActivity-BoW4X3DY.js} +1 -1
- package/client-dist/assets/{useFloatingActionButtonEnabled-C31rfHtR.js → useFloatingActionButtonEnabled-2_hw7nSa.js} +1 -1
- package/client-dist/assets/{useForkSummaryAutoOpen-D_SvtmbE.js → useForkSummaryAutoOpen-CS33Irpf.js} +1 -1
- package/client-dist/assets/{useGeneratedTitleLength-Cu-SoQ6T.js → useGeneratedTitleLength-D856ktVg.js} +1 -1
- package/client-dist/assets/{useKeepMobileKeyboardOpenAfterDelivery-C-cYLaEU.js → useKeepMobileKeyboardOpenAfterDelivery-Ba77SbWF.js} +1 -1
- package/client-dist/assets/useModelSettings-BdlYk1DT.js +1 -0
- package/client-dist/assets/{useNotifyInApp-BcLZ8ie_.js → useNotifyInApp-DcWe3dh4.js} +1 -1
- package/client-dist/assets/{useOnboarding-CYgE-Xsg.js → useOnboarding-CoE3WF8a.js} +1 -1
- package/client-dist/assets/{useProviders-C6kBPWYX.js → useProviders-CeN1PclA.js} +1 -1
- package/client-dist/assets/{useQuestionAsideSetting-6Excl6Pm.js → useQuestionAsideSetting-CPFw1u0y.js} +1 -1
- package/client-dist/assets/{useRecentSessions-CsmsGemq.js → useRecentSessions-ieTzzJu4.js} +2 -2
- package/client-dist/assets/{useRelativeNow-BdLaPgKO.js → useRelativeNow-Ca6QGcPa.js} +1 -1
- package/client-dist/assets/{useReloadNotifications-B0egr2ys.js → useReloadNotifications-Dm1jmdIb.js} +1 -1
- package/client-dist/assets/{useRemoteExecutors-Bgjgzif1.js → useRemoteExecutors-zBAQnQXH.js} +1 -1
- package/client-dist/assets/{useSidebarWidth-ut6NNk5Y.js → useSidebarWidth-CBCcbSLg.js} +1 -1
- package/client-dist/assets/{useSourceControlCleanLanding-DxrwogwF.js → useSourceControlCleanLanding-VDlft5tr.js} +1 -1
- package/client-dist/assets/{useStableToolPreviewRendering-CcrkchTG.js → useStableToolPreviewRendering-hbVp38Jd.js} +1 -1
- package/client-dist/assets/{useStreamingEnabled-EdvW04Vz.js → useStreamingEnabled-hU1g8i7_.js} +1 -1
- package/client-dist/assets/{useTabTitleActivityPreference-B0suFUHK.js → useTabTitleActivityPreference-DhREY7m2.js} +1 -1
- package/client-dist/assets/{useVhostAccess-2ZKr0Lcl.js → useVhostAccess-DUtn_sH1.js} +1 -1
- package/client-dist/assets/{useWorkflowTags-_4F_41YI.js → useWorkflowTags-DxbEBqtf.js} +1 -1
- package/client-dist/assets/{vennDiagram-4TSXK5OY-26XZDUe6.js → vennDiagram-4TSXK5OY-CSGBq-Ur.js} +1 -1
- package/client-dist/assets/{wardleyDiagram-VM6X3IG4-YvZ37BJ7.js → wardleyDiagram-VM6X3IG4-DIMvcaMb.js} +1 -1
- package/client-dist/assets/{xychartDiagram-S5SC5T6Z-BMT0MEGz.js → xychartDiagram-S5SC5T6Z-TYXSqT3w.js} +1 -1
- package/client-dist/assets/zh-CN-DadySLj9.js +7 -0
- package/client-dist/index.html +3 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +29 -10
- package/dist/app.js.map +1 -1
- package/dist/artifacts/ArtifactServer.d.ts +2 -0
- package/dist/artifacts/ArtifactServer.d.ts.map +1 -1
- package/dist/artifacts/ArtifactServer.js +79 -1
- package/dist/artifacts/ArtifactServer.js.map +1 -1
- package/dist/auth/limitedUserPolicy.d.ts +9 -5
- package/dist/auth/limitedUserPolicy.d.ts.map +1 -1
- package/dist/auth/limitedUserPolicy.js +64 -35
- package/dist/auth/limitedUserPolicy.js.map +1 -1
- package/dist/auth/principal.d.ts +6 -0
- package/dist/auth/principal.d.ts.map +1 -1
- package/dist/auth/principal.js +6 -0
- package/dist/auth/principal.js.map +1 -1
- package/dist/frontend/static.d.ts.map +1 -1
- package/dist/frontend/static.js +2 -1
- package/dist/frontend/static.js.map +1 -1
- package/dist/middleware/authenticated-transport.d.ts +13 -0
- package/dist/middleware/authenticated-transport.d.ts.map +1 -1
- package/dist/middleware/authenticated-transport.js +12 -0
- package/dist/middleware/authenticated-transport.js.map +1 -1
- package/dist/middleware/limited-users.d.ts +9 -5
- package/dist/middleware/limited-users.d.ts.map +1 -1
- package/dist/middleware/limited-users.js +37 -23
- package/dist/middleware/limited-users.js.map +1 -1
- package/dist/routes/file-edit.d.ts +18 -0
- package/dist/routes/file-edit.d.ts.map +1 -0
- package/dist/routes/file-edit.js +244 -0
- package/dist/routes/file-edit.js.map +1 -0
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/files.js +34 -9
- package/dist/routes/files.js.map +1 -1
- package/dist/routes/pdfjs.d.ts +9 -0
- package/dist/routes/pdfjs.d.ts.map +1 -0
- package/dist/routes/pdfjs.js +34 -0
- package/dist/routes/pdfjs.js.map +1 -0
- package/dist/routes/public-file-shares.d.ts +6 -0
- package/dist/routes/public-file-shares.d.ts.map +1 -1
- package/dist/routes/public-file-shares.js +22 -10
- package/dist/routes/public-file-shares.js.map +1 -1
- package/dist/routes/public-shares.d.ts.map +1 -1
- package/dist/routes/public-shares.js +18 -1
- package/dist/routes/public-shares.js.map +1 -1
- package/dist/routes/recents.d.ts +4 -1
- package/dist/routes/recents.d.ts.map +1 -1
- package/dist/routes/recents.js +7 -0
- package/dist/routes/recents.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +4 -0
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/settings.d.ts +7 -2
- package/dist/routes/settings.d.ts.map +1 -1
- package/dist/routes/settings.js +43 -1
- package/dist/routes/settings.js.map +1 -1
- package/dist/routes/version.d.ts.map +1 -1
- package/dist/routes/version.js +1 -0
- package/dist/routes/version.js.map +1 -1
- package/dist/routes/ws-relay-handlers.d.ts +12 -0
- package/dist/routes/ws-relay-handlers.d.ts.map +1 -1
- package/dist/routes/ws-relay-handlers.js +25 -4
- package/dist/routes/ws-relay-handlers.js.map +1 -1
- package/dist/routes/ws-relay.d.ts.map +1 -1
- package/dist/routes/ws-relay.js +8 -0
- package/dist/routes/ws-relay.js.map +1 -1
- package/dist/sdk/providers/agent-self.js +1 -1
- package/dist/sdk/providers/agent-self.js.map +1 -1
- package/dist/sdk/providers/claude.d.ts +1 -0
- package/dist/sdk/providers/claude.d.ts.map +1 -1
- package/dist/sdk/providers/claude.js +7 -0
- package/dist/sdk/providers/claude.js.map +1 -1
- package/dist/sdk/providers/codex-model-catalog.d.ts.map +1 -1
- package/dist/sdk/providers/codex-model-catalog.js +5 -3
- package/dist/sdk/providers/codex-model-catalog.js.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts +4 -1
- package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts +4 -1
- package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/Personality.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/Personality.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.d.ts +2 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.d.ts.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/{ThreadRollbackParams.js → McpAppDisplayMode.js} +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.js.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.d.ts +9 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.d.ts.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/{ThreadRollbackResponse.js → McpAppUi.js} +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.js.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkResponse.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts +6 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeParams.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts +9 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts +9 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartResponse.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/TurnStartParams.d.ts +7 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/TurnStartParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/index.d.ts +0 -2
- package/dist/sdk/providers/codex-protocol/index.d.ts.map +1 -1
- package/dist/sdk/providers/codex.d.ts +23 -2
- package/dist/sdk/providers/codex.d.ts.map +1 -1
- package/dist/sdk/providers/codex.js +55 -22
- package/dist/sdk/providers/codex.js.map +1 -1
- package/dist/sdk/providers/index.d.ts.map +1 -1
- package/dist/sdk/providers/index.js +4 -1
- package/dist/sdk/providers/index.js.map +1 -1
- package/dist/sdk/providers/opencode.d.ts +9 -0
- package/dist/sdk/providers/opencode.d.ts.map +1 -1
- package/dist/sdk/providers/opencode.js +129 -76
- package/dist/sdk/providers/opencode.js.map +1 -1
- package/dist/sdk/providers/provider-session-owner.d.ts +9 -0
- package/dist/sdk/providers/provider-session-owner.d.ts.map +1 -1
- package/dist/sdk/providers/provider-session-owner.js +39 -3
- package/dist/sdk/providers/provider-session-owner.js.map +1 -1
- package/dist/sdk/providers/types.d.ts +13 -0
- package/dist/sdk/providers/types.d.ts.map +1 -1
- package/dist/sdk/providers/types.js.map +1 -1
- package/dist/services/ArtifactRebuildService.d.ts +67 -0
- package/dist/services/ArtifactRebuildService.d.ts.map +1 -0
- package/dist/services/ArtifactRebuildService.js +229 -0
- package/dist/services/ArtifactRebuildService.js.map +1 -0
- package/dist/services/DirtyFileEditorService.d.ts +2 -0
- package/dist/services/DirtyFileEditorService.d.ts.map +1 -1
- package/dist/services/DirtyFileEditorService.js +20 -1
- package/dist/services/DirtyFileEditorService.js.map +1 -1
- package/dist/services/PdfjsAssetCache.d.ts +20 -0
- package/dist/services/PdfjsAssetCache.d.ts.map +1 -0
- package/dist/services/PdfjsAssetCache.js +131 -0
- package/dist/services/PdfjsAssetCache.js.map +1 -0
- package/dist/services/SessionCatalogService.d.ts +27 -0
- package/dist/services/SessionCatalogService.d.ts.map +1 -1
- package/dist/services/SessionCatalogService.js +129 -34
- package/dist/services/SessionCatalogService.js.map +1 -1
- package/dist/sessions/opencode-reader.d.ts +2 -1
- package/dist/sessions/opencode-reader.d.ts.map +1 -1
- package/dist/sessions/opencode-reader.js +30 -1
- package/dist/sessions/opencode-reader.js.map +1 -1
- package/dist/sessions/types.d.ts +6 -0
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/supervisor/Process.d.ts +7 -0
- package/dist/supervisor/Process.d.ts.map +1 -1
- package/dist/supervisor/Process.js +48 -3
- package/dist/supervisor/Process.js.map +1 -1
- package/dist/supervisor/Supervisor.d.ts.map +1 -1
- package/dist/supervisor/Supervisor.js +11 -0
- package/dist/supervisor/Supervisor.js.map +1 -1
- package/dist/supervisor/types.d.ts +3 -1
- package/dist/supervisor/types.d.ts.map +1 -1
- package/dist/supervisor/types.js.map +1 -1
- package/package.json +3 -3
- package/client-dist/assets/AboutSettings-BlEONE7w.js +0 -1
- package/client-dist/assets/AgentsPage-CBku9RWz.js +0 -2
- package/client-dist/assets/App-DWHvFKob.js +0 -2
- package/client-dist/assets/AppearanceSettings-BSEBjSjr.js +0 -2
- package/client-dist/assets/AppsSettings-iDL6Xuaa.js +0 -1
- package/client-dist/assets/AttachmentChip-DHKr4EfG.js +0 -1
- package/client-dist/assets/BangCommandsPage-yX8grXp9.js +0 -1
- package/client-dist/assets/BrowserDebugToolbarButton-B-b7N4cr.js +0 -1
- package/client-dist/assets/ComputerControlSettings-DzRDwfJ1.js +0 -1
- package/client-dist/assets/DevelopmentSettings-Bf9gyeU0.js +0 -1
- package/client-dist/assets/DevicesSettings-dbZHFEEc.js +0 -1
- package/client-dist/assets/EmulatorPage-CKJwVTFq.js +0 -1
- package/client-dist/assets/EmulatorSettings-BV9Bg3Xk.js +0 -1
- package/client-dist/assets/EnvironmentSettings-DmOTuSwm.js +0 -1
- package/client-dist/assets/FilePage-DnPW5Pbc.js +0 -1
- package/client-dist/assets/FilterDropdown-CB_tRt6g.css +0 -1
- package/client-dist/assets/FilterDropdown-DpS1eMEf.js +0 -1
- package/client-dist/assets/FloatingActionButton-DBIoFwff.js +0 -1
- package/client-dist/assets/GlobalSessionsPage-Dbnuis89.css +0 -1
- package/client-dist/assets/GlobalSessionsPage-DcmQcX7q.js +0 -2
- package/client-dist/assets/HostIdentityContext-D5aBdejC.js +0 -1
- package/client-dist/assets/HostsPage-C1ZTrhJv.js +0 -1
- package/client-dist/assets/InboxPage-Cepu8VGM.js +0 -1
- package/client-dist/assets/IssueSettings-xRU8E-xR.js +0 -1
- package/client-dist/assets/IssuesPage-c6PUStFT.js +0 -1
- package/client-dist/assets/LifecycleWebhooksSettings-CZcZATjJ.js +0 -1
- package/client-dist/assets/MessageInput-B0t6b_Hd.js +0 -3
- package/client-dist/assets/MessageInputToolbar-DdP4tB2S.css +0 -1
- package/client-dist/assets/MessageInputToolbar-rhYW1xGJ.js +0 -58
- package/client-dist/assets/MessageList-Dcvfxbeq.css +0 -1
- package/client-dist/assets/MessageList-dH63bflu.js +0 -4
- package/client-dist/assets/Modal-QUinFhBP.js +0 -16
- package/client-dist/assets/ModelSettings-CcWkVSEK.js +0 -1
- package/client-dist/assets/NavigationLayout-BkOsag-J.js +0 -2
- package/client-dist/assets/NewSessionPage-DcZ9YjmC.js +0 -1
- package/client-dist/assets/NotificationsSettings-DoVzfeME.js +0 -1
- package/client-dist/assets/PageHeader-BaYMLVHI.js +0 -1
- package/client-dist/assets/PerformanceSettings-dwoVtUlX.js +0 -1
- package/client-dist/assets/ProjectTemplatesSettings-BlMWq1wb.js +0 -1
- package/client-dist/assets/ProjectsPage-B5VBairc.js +0 -1
- package/client-dist/assets/ProviderChildSessionPage-B3eTTTjF.js +0 -1
- package/client-dist/assets/ProvidersSettings-OUKp5-Hb.js +0 -1
- package/client-dist/assets/RemoteAccessSettings-Bn0ng7s4.js +0 -1
- package/client-dist/assets/RemoteExecutorsSettings-2Qh-9Qv_.js +0 -1
- package/client-dist/assets/SchemaValidationContext-CIAd7icg.js +0 -1
- package/client-dist/assets/SessionPage-B1g1UFEV.js +0 -49
- package/client-dist/assets/SessionPage-BiV0X3n1.css +0 -1
- package/client-dist/assets/SourceControlSettings-BQfC1KbV.js +0 -1
- package/client-dist/assets/SpeechControlMenu-BIv0O1la.js +0 -2
- package/client-dist/assets/StorageSettings-DQcG9Mbq.js +0 -1
- package/client-dist/assets/ToolbarSettings-CmHVAejU.js +0 -1
- package/client-dist/assets/UsersSettings-COgiiV9D.js +0 -1
- package/client-dist/assets/WorkstreamsPage-DKLRDEAp.js +0 -1
- package/client-dist/assets/channel-C-7AVqtf.js +0 -1
- package/client-dist/assets/classDiagram-ZZMXUADV-DkRr8VcO.js +0 -1
- package/client-dist/assets/classDiagram-v2-VYDZK3BY-DkRr8VcO.js +0 -1
- package/client-dist/assets/de-DKHK9Tu3.js +0 -6
- package/client-dist/assets/es-XSkBrKBg.js +0 -6
- package/client-dist/assets/fr-DKUJaPhN.js +0 -6
- package/client-dist/assets/index-BBpZzMBa.js +0 -2
- package/client-dist/assets/index-BUrcmRdN.js +0 -76
- package/client-dist/assets/index-CA-BRFYh.js +0 -1
- package/client-dist/assets/index-wA2zlxt-.css +0 -1
- package/client-dist/assets/ja-BDnQUlyD.js +0 -6
- package/client-dist/assets/long-context-effort-warning-BGls6uvf.js +0 -1
- package/client-dist/assets/newSessionPrefill-DkkSfnYR.js +0 -1
- package/client-dist/assets/providerChildSessions-ClrSXOQr.js +0 -80
- package/client-dist/assets/providerChildSessions-D2O1SLei.css +0 -1
- package/client-dist/assets/sessionHistorySearch.worker-BGlVvPYq.js +0 -60
- package/client-dist/assets/stateDiagram-v2-MP3YSRHH-CBvcZngO.js +0 -1
- package/client-dist/assets/swimlanesDiagram-VR7AAH4N-DKVyQBDp.js +0 -8
- package/client-dist/assets/useAcliCommentarySetting-DxndlmkH.js +0 -9
- package/client-dist/assets/useActivityBusState-CINl9yjP.js +0 -1
- package/client-dist/assets/useModelSettings-DoDJRymT.js +0 -1
- package/client-dist/assets/zh-CN-FVXKSeP_.js +0 -7
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts +0 -14
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts.map +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.js.map +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.d.ts +0 -12
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.d.ts.map +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.js.map +0 -1
- /package/client-dist/assets/{Modal-EC-u4IZ7.css → index-EC-u4IZ7.css} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var ye=Object.defineProperty;var Se=(n,e,t)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var h=(n,e,t)=>Se(n,typeof e!="symbol"?e+"":e,t);import{bb as we,aF as ge,bc as ve,bd as Q,be,bf as Ce,s as le,i as ue,aE as he,bg as K,bh as xe,bi as Ee,bj as Re,aG as _e,r as O,b as de,j as l,u as pe,L as k}from"./index-BUrcmRdN.js";import{u as Ie,l as Ne}from"./hostStorage-BoEdRarg.js";import{D as A,a as Pe,b as Oe,e as z,c as Ae,d as ke,f as Ue,h as Me,j as Z,k as Te,l as je,m as Be,S as ee,n as Le,o as qe}from"./remoteRoutePaths-CiDZeM2I.js";import{T as Fe,R as De,d as He,B as P,i as Ve,f as $e}from"./RelayProtocol-DjpPJk64.js";import{r as We}from"./relayEndpoints-0oIbn4eU.js";import"./react-runtime-D-UPQ57m.js";import"./relay-url-j3kYm5KO.js";function Ke(n){return typeof n=="object"&&n!==null&&n.type==="srp_challenge"}function Je(n){return typeof n=="object"&&n!==null&&n.type==="srp_verify"}function V(n){return typeof n=="object"&&n!==null&&n.type==="srp_error"}function Ye(n){return typeof n=="object"&&n!==null&&n.type==="srp_resume_challenge"}function Ge(n){return typeof n=="object"&&n!==null&&n.type==="srp_resumed"}function Xe(n){return typeof n=="object"&&n!==null&&n.type==="srp_invalid"}function Qe(n){return typeof n=="object"&&n!==null&&Number.isSafeInteger(n.seq)&&n.seq>=0&&"msg"in n}const ze="client-mux-v1",G=1,D=6,J=1;class M extends Error{constructor(e,t){super(e),this.circuitId=t,this.name="RelayMuxFrameError"}}function B(n){return typeof n=="number"&&Number.isSafeInteger(n)&&n>0&&n<=4294967295}function te(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_ready"&&e.protocolVersion===G&&typeof e.maxCircuits=="number"&&Number.isSafeInteger(e.maxCircuits)&&e.maxCircuits>0&&typeof e.maxFrameBytes=="number"&&Number.isSafeInteger(e.maxFrameBytes)&&e.maxFrameBytes>0}function Ze(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_opened"&&B(e.circuitId)}function et(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_error"&&B(e.circuitId)&&(e.reason==="unknown_username"||e.reason==="server_offline"||e.reason==="circuit_limit"||e.reason==="rate_limited"||e.reason==="invalid_request")}function tt(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_closed"&&B(e.circuitId)&&(e.reason==="client_closed"||e.reason==="server_closed"||e.reason==="relay_closed")}function st(n,e,t){if(!B(n))throw new M("Invalid relay mux circuit id");const s=new Uint8Array(D+e.byteLength);return s[0]=G,s[1]=t?J:0,new DataView(s.buffer).setUint32(2,n,!1),s.set(e,D),s}function nt(n){const e=n instanceof Uint8Array?n:new Uint8Array(n);if(e.byteLength<D)throw new M("Relay mux data frame is too short");const s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2,!1);if(e[0]!==G)throw new M("Unsupported relay mux frame version",s||void 0);const o=e[1]??0;if((o&~J)!==0)throw new M("Invalid relay mux frame flags",s||void 0);if(!B(s))throw new M("Invalid relay mux circuit id");return{circuitId:s,isBinary:(o&J)!==0,payload:e.subarray(D)}}function fe(){return new DOMException("Relay connection aborted","AbortError")}function ot(n,e){return new Promise((t,s)=>{var c,p;let o=!1;const r=d=>{var u;o||(o=!0,clearTimeout(a),(u=e.signal)==null||u.removeEventListener("abort",i),d?s(d):t())},i=()=>{n.close(),r(fe())},a=setTimeout(()=>{n.close(),r(new Error("Relay connection timeout"))},e.connectTimeoutMs??15e3);if((c=e.signal)!=null&&c.aborted){i();return}(p=e.signal)==null||p.addEventListener("abort",i,{once:!0}),n.onopen=()=>{var d;(d=e.onOpen)==null||d.call(e),r()},n.onerror=()=>{r(new Error("Failed to connect to relay server"))}})}function rt(n,e){return new Promise((t,s)=>{var c,p;let o=!1;const r=d=>{var u;o||(o=!0,clearTimeout(a),(u=e.signal)==null||u.removeEventListener("abort",i),n.onmessage=null,n.onclose=null,n.onerror=null,d?s(d):t())},i=()=>{n.close(),r(fe())},a=setTimeout(()=>{n.close(),r(new Error("Waiting for server timed out"))},e.serverTimeoutMs??3e4);if((c=e.signal)!=null&&c.aborted){i();return}(p=e.signal)==null||p.addEventListener("abort",i,{once:!0}),n.onmessage=d=>{try{const u=JSON.parse(d.data);Pe(u)?r():Oe(u)?(n.close(),r(new Error(u.reason))):r()}catch{n.close(),r(new Error("Invalid relay response"))}},n.onclose=()=>{r(new Error("Relay connection closed"))},n.onerror=()=>{r(new Error("Relay connection error"))}})}async function H(n){const e=new WebSocket(n.relayUrl);e.binaryType="arraybuffer";try{await ot(e,n);const t=n.channel??A;return e.send(JSON.stringify(t===A?{type:"client_connect",username:n.relayUsername}:{type:"client_connect_channel",username:n.relayUsername,channel:t})),await rt(e,n),e}catch(t){throw e.close(),t}}let $=null;async function se(){return $||($=await we(()=>import("./index-D7q51uJV.js").then(n=>n.i),__vite__mapDeps([0,1,2,3,4,5]))),$}function ne(n){return n.toString(16)}function W(n){return BigInt(`0x${n}`)}class it{constructor(){h(this,"session",null);h(this,"step1Result",null);h(this,"step2Result",null);h(this,"sessionKey",null);h(this,"identity",null)}async generateHello(e,t){const{SRPClientSession:s,SRPParameters:o,SRPRoutines:r}=await se(),i=new o,a=new r(i);return this.session=new s(a),this.identity=e,this.step1Result=await this.session.step1(e,t),{identity:e}}async processChallenge(e,t){if(!this.step1Result)throw new Error("Must call generateHello before processChallenge");const s=W(e),o=W(t);return this.step2Result=await this.step1Result.step2(s,o),{A:ne(this.step2Result.A),M1:ne(this.step2Result.M1)}}async verifyServer(e){if(!this.step2Result)throw new Error("Must call processChallenge before verifyServer");const{bigIntToArrayBuffer:t}=await se(),s=W(e);try{await this.step2Result.step3(s);const o=t(this.step2Result.S);return this.sessionKey=new Uint8Array(o),!0}catch{return!1}}getSessionKey(){return this.sessionKey}isAuthenticated(){return this.sessionKey!==null}getIdentity(){return this.identity}}const oe=5e3,L="resume_incompatible: session resume unsupported by server",U=2,ct=3,at=512*1024,lt=256*1024,ut=16,R=1,ht=3;function dt(n){let e="";for(const t of n)e+=String.fromCharCode(t);return btoa(e)}function pt(n){return new Promise(e=>setTimeout(e,n))}function ft(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}class _{constructor(e,t,s,o={}){h(this,"mode","secure");h(this,"ws",null);h(this,"srpSession",null);h(this,"sessionKey",null);h(this,"sessionId",null);h(this,"connectionState","disconnected");h(this,"connectionPromise",null);h(this,"forceReconnectPromise",null);h(this,"protocol");h(this,"nextOutboundSeq",0);h(this,"lastInboundSeq",null);h(this,"inboundChunks",new Fe);h(this,"pendingResumeClientNonce",null);h(this,"pendingResumeServerNonce",null);h(this,"minimumResumeProtocolVersion",null);h(this,"connectionManager",null);h(this,"externalOnPong");h(this,"username");h(this,"password");h(this,"wsUrl");h(this,"isRelayConnection",!1);h(this,"relayUrl",null);h(this,"relayUsername",null);h(this,"relayChannel",A);h(this,"relaySocketFactory",null);h(this,"storedSession",null);h(this,"onSessionEstablished");h(this,"onDisconnect");h(this,"onAuthenticated");this.wsUrl=e,this.username=t,this.password=s,this.onSessionEstablished=o.onSessionEstablished,this.onDisconnect=o.onDisconnect,this.onAuthenticated=o.onAuthenticated,this.protocol=new De({sendMessage:r=>this.send(r),sendUploadChunk:async(r,i,a)=>{const c=He(r,i,a);if(!this.ws||this.ws.readyState!==R)throw new Error("WebSocket not connected");if(!this.sessionKey)throw new Error("Not authenticated");const p=z(c,P.BINARY_UPLOAD,this.sessionKey);this.ws.send(p),await this.waitForUploadBackpressure()},ensureConnected:()=>this.ensureConnected(),isConnected:()=>{var r;return this.connectionState==="authenticated"&&((r=this.ws)==null?void 0:r.readyState)===R}},{debugEnabled:()=>Ae(),logPrefix:"[SecureConnection]"})}setConnectionManager(e){this.connectionManager=e,this.updateProtocolPongHandler(),this.protocol.setOnInboundEvent(e?t=>{t.eventType==="heartbeat"?e.recordHeartbeat():e.recordEvent()}:void 0),this.protocol.setBeginCriticalOperation(e?t=>e.beginCriticalOperation(t):void 0)}static fromStoredSession(e,t,s={}){const o=new _(e.wsUrl,e.username,t,s);return o.storedSession=e,o.minimumResumeProtocolVersion=e.resumeProtocolVersion??null,o}static forResumeOnly(e,t={}){const s=new _(e.wsUrl,e.username,"",t);return s.storedSession=e,s.password=null,s.minimumResumeProtocolVersion=e.resumeProtocolVersion??null,s}static async forResumeOnlyWithSocket(e,t,s={},o){const r=new _("",t.username,"",s);return r.ws=e,r.storedSession=t,r.password=null,r.minimumResumeProtocolVersion=t.resumeProtocolVersion??null,r.isRelayConnection=!0,o&&(r.relayUrl=o.relayUrl,r.relayUsername=o.relayUsername,r.relayChannel=o.channel??A,r.relaySocketFactory=o.openSocket??null),await r.resumeOnExistingSocket(),r}resumeOnExistingSocket(){return new Promise((e,t)=>{if(!this.ws||this.ws.readyState!==R){t(new Error("WebSocket is not open"));return}if(!this.storedSession){t(new Error("No stored session for resume"));return}if(!this.storedSessionSupportsCurrentResume()){this.connectionState="failed",t(new Error(L)),this.ws.close();return}console.log("[SecureConnection] Resuming session on existing socket"),this.connectionState="connecting";let s=()=>{},o=()=>{};const r=new Promise((d,u)=>{s=d,o=u}),i=this.ws;i.onerror=d=>{console.error("[SecureConnection] Error:",d)},i.onclose=d=>{this.handleSocketClose(d,o)},i.onmessage=d=>{c(),this.handleSrpResumeResponse(d.data,s,o)};let a=null;const c=()=>{a&&clearTimeout(a),a=setTimeout(()=>{this.connectionState!=="srp_resume_init_sent"&&this.connectionState!=="srp_resume_proof_sent"||(this.connectionState="failed",o(new Error(L)),i.close())},oe)},p={type:"srp_resume_init",identity:this.username,sessionId:this.storedSession.sessionId,clientNonce:this.startResumeAttempt()};i.send(JSON.stringify(p)),this.connectionState="srp_resume_init_sent",console.log("[SecureConnection] SRP resume init sent"),c(),r.then(()=>{a&&clearTimeout(a),e()}).catch(d=>{a&&clearTimeout(a),t(d)})})}generateResumeProof(e,t,s){const o=Uint8Array.from(atob(e),p=>p.charCodeAt(0)),r=Date.now(),i=JSON.stringify({timestamp:r,challenge:t,sessionId:s}),{nonce:a,ciphertext:c}=ke(i,o);return JSON.stringify({nonce:a,ciphertext:c})}startResumeAttempt(){return this.pendingResumeClientNonce=dt(Ue()),this.pendingResumeServerNonce=null,this.pendingResumeClientNonce}storedSessionSupportsCurrentResume(){var t;const e=(t=this.storedSession)==null?void 0:t.resumeProtocolVersion;return e===void 0||e>=U}decryptProofEnvelope(e,t){try{const s=JSON.parse(e);return typeof s.nonce!="string"||typeof s.ciphertext!="string"?null:Me(s.nonce,s.ciphertext,t)}catch{return null}}acceptAuthenticatedResumeProtocolVersion(e,t=ct){var o;if(!Number.isSafeInteger(e)||e<t)return!1;const s=Math.max(this.minimumResumeProtocolVersion??0,((o=this.storedSession)==null?void 0:o.resumeProtocolVersion)??0);return s>0&&e<s?!1:(this.minimumResumeProtocolVersion=Math.max(s,e),!0)}verifyResumeServerProof(e){if(!e.serverProof||!e.transportNonce||!this.pendingResumeClientNonce||!this.pendingResumeServerNonce||e.transportNonce!==this.pendingResumeServerNonce)return null;try{const t=this.decryptProofEnvelope(e.serverProof,e.baseSessionKey);if(!t)return null;const s=JSON.parse(t);return s.type==="srp_resume_server_proof"&&s.sessionId===e.sessionId&&s.serverNonce===this.pendingResumeServerNonce&&s.clientNonce===this.pendingResumeClientNonce&&typeof s.resumeProtocolVersion=="number"?s.resumeProtocolVersion:null}catch{return null}}readSrpVerifyServerInfoProof(e){if(!e.serverInfoProof||!e.sessionId||!e.transportNonce)return null;try{const t=this.decryptProofEnvelope(e.serverInfoProof,e.baseSessionKey);if(!t)return null;const s=JSON.parse(t);return s.type!=="srp_verify_server_info"||s.sessionId!==e.sessionId||s.transportNonce!==e.transportNonce||typeof s.resumeProtocolVersion!="number"?null:s.resumeProtocolVersion}catch{return null}}acceptGraceProtocolVersion(e){return this.acceptAuthenticatedResumeProtocolVersion(e,U)}async startFullSrpHandshake(e){var r;if(!this.password)throw new Error("Password required for SRP authentication");this.pendingResumeClientNonce=null,this.pendingResumeServerNonce=null,console.log("[SecureConnection] Starting full SRP handshake"),this.srpSession=new it,await this.srpSession.generateHello(this.username,this.password);const t=ge(),s={origin:window.location.origin,scheme:window.location.protocol.replace(":",""),hostname:window.location.hostname,port:window.location.port?Number.parseInt(window.location.port,10):null,userAgent:navigator.userAgent},o={type:"srp_hello",identity:this.username,browserProfileId:t,originMetadata:s};(r=this.ws)==null||r.send(JSON.stringify(o)),this.connectionState="srp_hello_sent",console.log("[SecureConnection] SRP hello sent")}async handleSrpResumeResponse(e,t,s){var o,r,i,a,c,p,d,u,w,v,S,I,E;try{const y=JSON.parse(e);if(Ye(y)){if(!this.storedSession){s(new Error("No stored session for resumption"));return}if(y.sessionId!==this.storedSession.sessionId){s(new Error("Resume challenge session mismatch")),(o=this.ws)==null||o.close();return}this.pendingResumeServerNonce=y.nonce;const C=this.generateResumeProof(this.storedSession.sessionKey,y.nonce,this.storedSession.sessionId),x={type:"srp_resume",identity:this.username,sessionId:this.storedSession.sessionId,proof:C};(r=this.ws)==null||r.send(JSON.stringify(x)),this.connectionState="srp_resume_proof_sent",console.log("[SecureConnection] SRP resume proof sent");return}if(Ge(y)){if(console.log("[SecureConnection] Session resumed successfully"),!this.storedSession){s(new Error("No stored session for resumption"));return}if(y.sessionId!==this.storedSession.sessionId){s(new Error("Resume response session mismatch")),(i=this.ws)==null||i.close();return}const C=Uint8Array.from(atob(this.storedSession.sessionKey),g=>g.charCodeAt(0));if(!y.transportNonce||y.transportNonce!==this.pendingResumeServerNonce){console.error("[SecureConnection] Resume server proof failed"),this.connectionState="failed",s(new Error("Resume server verification failed")),(a=this.ws)==null||a.close();return}const x=y.transportNonce;let f=U;if(y.serverProof){const g=this.verifyResumeServerProof({serverProof:y.serverProof,baseSessionKey:C,sessionId:this.storedSession.sessionId,transportNonce:x});if(g===null||!this.acceptAuthenticatedResumeProtocolVersion(g)){console.error("[SecureConnection] Resume server proof failed"),this.connectionState="failed",s(new Error("Resume server verification failed")),(c=this.ws)==null||c.close();return}f=g}else if(!this.acceptGraceProtocolVersion(U)){console.error("[SecureConnection] Resume would downgrade authenticated protocol"),this.connectionState="failed",s(new Error("Resume server verification failed")),(p=this.ws)==null||p.close();return}this.sessionKey=Z(C,x),this.sessionId=y.sessionId,this.connectionState="authenticated",this.pendingResumeClientNonce=null,this.pendingResumeServerNonce=null,this.storedSession={...this.storedSession,resumeProtocolVersion:f},this.resetSequenceState(),this.ws&&(this.ws.onmessage=g=>this.handleMessage(g.data)),(d=this.onSessionEstablished)==null||d.call(this,this.storedSession),this.sendCapabilities(),(u=this.connectionManager)==null||u.markConnected(),(w=this.onAuthenticated)==null||w.call(this),t();return}if(Xe(y)){if(!this.password){console.log(`[SecureConnection] Session resume failed: ${y.reason} (no password for fallback)`),this.connectionState="failed",s(new Error(`Session invalid: ${y.reason}`)),(v=this.ws)==null||v.close();return}console.log(`[SecureConnection] Session resume failed: ${y.reason}, falling back to SRP`),this.storedSession=null,await this.startFullSrpHandshake(s);return}if(V(y)){console.error("[SecureConnection] SRP error during resume:",y.message),this.connectionState="failed",s(new Error(`Authentication failed: ${y.message}`)),(S=this.ws)==null||S.close();return}console.warn("[SecureConnection] Unexpected message during resume:",y),this.connectionState="failed",s(new Error(`Unexpected message during resume: ${(y==null?void 0:y.type)??"unknown"}`)),(I=this.ws)==null||I.close()}catch(y){console.error("[SecureConnection] Resume response error:",y),this.connectionState="failed",s(y instanceof Error?y:new Error(String(y))),(E=this.ws)==null||E.close()}}async ensureConnected(){var e;if(!(((e=this.ws)==null?void 0:e.readyState)===R&&this.connectionState==="authenticated")){if(this.connectionPromise)return this.connectionPromise;this.connectionPromise=this.connectAndAuthenticate();try{await this.connectionPromise}finally{this.connectionPromise=null}}}handleSocketClose(e,t){var r,i;console.log("[SecureConnection] Closed:",e.code,e.reason);const s=this.connectionState==="authenticated";this.ws=null,this.sessionKey=null,this.srpSession=null,this.pendingResumeClientNonce=null,this.pendingResumeServerNonce=null,this.resetSequenceState();const o=new ve(e.code,e.reason);s?(this.connectionState="disconnected",(r=this.connectionManager)==null||r.handleClose(o),(i=this.onDisconnect)==null||i.call(this,o)):(this.connectionState="failed",t==null||t(o)),this.protocol.rejectAllPending(o),this.protocol.notifySubscriptionsClosed(o)}connectAndAuthenticate(){return new Promise((e,t)=>{if(this.isRelayConnection){if(this.relayUrl&&this.relayUsername&&this.storedSession){console.log("[SecureConnection] Relay connection dropped, attempting auto-reconnect"),this.reconnectThroughRelay().then(e).catch(u=>{console.error("[SecureConnection] Relay auto-reconnect failed:",u),t(new Q(u instanceof Error?u:new Error(String(u))))});return}console.log("[SecureConnection] Cannot reconnect relay connection (missing config or session)"),t(new Q(new Error("Missing relay config or stored session")));return}console.log("[SecureConnection] Connecting to",this.wsUrl),this.connectionState="connecting";const s=new WebSocket(this.wsUrl);s.binaryType="arraybuffer";let o=()=>{},r=()=>{};const i=new Promise((u,w)=>{o=u,r=w});let a=null;const c=()=>{a&&(clearTimeout(a),a=null)},p=()=>{c(),a=setTimeout(()=>{if(!(this.connectionState!=="srp_resume_init_sent"&&this.connectionState!=="srp_resume_proof_sent")){if(this.password){console.log("[SecureConnection] Session resume timed out, falling back to full SRP"),this.storedSession=null,this.startFullSrpHandshake(r).catch(u=>{this.connectionState="failed",r(u instanceof Error?u:new Error(String(u))),s.close()});return}this.connectionState="failed",r(new Error(L)),s.close()}},oe)};s.onopen=async()=>{console.log("[SecureConnection] WebSocket connected"),this.ws=s;try{if(this.storedSession){if(this.storedSessionSupportsCurrentResume()){console.log("[SecureConnection] Attempting session resumption");const u={type:"srp_resume_init",identity:this.username,sessionId:this.storedSession.sessionId,clientNonce:this.startResumeAttempt()};s.send(JSON.stringify(u)),this.connectionState="srp_resume_init_sent",console.log("[SecureConnection] SRP resume init sent"),p();return}if(!this.password){this.connectionState="failed",r(new Error(L)),s.close();return}console.log("[SecureConnection] Stored session uses an old resume protocol; starting full SRP"),this.storedSession=null}await this.startFullSrpHandshake(r)}catch(u){console.error("[SecureConnection] Connection error:",u),this.connectionState="failed",r(u instanceof Error?u:new Error(String(u))),s.close()}},s.onerror=u=>{console.error("[SecureConnection] Error:",u)},s.onclose=u=>{this.handleSocketClose(u,r)},s.onmessage=async u=>{this.connectionState==="srp_resume_init_sent"||this.connectionState==="srp_resume_proof_sent"?(p(),await this.handleSrpResumeResponse(u.data,o,r)):this.connectionState==="srp_hello_sent"?await this.handleSrpChallenge(u.data,o,r):this.connectionState==="srp_proof_sent"?await this.handleSrpVerify(u.data,o,r):this.connectionState==="authenticated"&&this.handleMessage(u.data)};const d=setTimeout(()=>{this.connectionState!=="authenticated"&&(s.close(),this.connectionState="failed",t(new Error("Connection timeout")))},3e4);i.then(()=>{c(),clearTimeout(d),e()}).catch(u=>{c(),clearTimeout(d),t(u)})})}static async connectRelaySocket(e,t,s=A,o=H){const r=await o({relayUrl:e,relayUsername:t,channel:s,onOpen:()=>{console.log(`[SecureConnection] Relay connected, sending client_connect (${s})`)}});return console.log("[SecureConnection] Relay paired with server"),r}async reconnectThroughRelay(){if(!this.relayUrl||!this.relayUsername||!this.storedSession)throw new Error("Missing relay config or stored session for reconnect");console.log("[SecureConnection] Connecting to relay:",this.relayUrl),this.connectionState="connecting";const e=await _.connectRelaySocket(this.relayUrl,this.relayUsername,this.relayChannel,this.relaySocketFactory??H);console.log("[SecureConnection] Resuming SRP session on new relay socket"),e.onmessage=null,e.onclose=null,e.onerror=null,this.ws=e,await this.resumeOnExistingSocket()}async handleSrpChallenge(e,t,s){var o,r,i,a;try{const c=JSON.parse(e);if(V(c)){console.error("[SecureConnection] SRP error:",c.message),this.connectionState="failed",s(new Error(`Authentication failed: ${c.message}`)),(o=this.ws)==null||o.close();return}if(!Ke(c)){console.warn("[SecureConnection] Unexpected message during SRP challenge:",c),this.connectionState="failed",s(new Error(`Unexpected message during SRP challenge: ${(c==null?void 0:c.type)??"unknown"}`)),(r=this.ws)==null||r.close();return}if(!this.srpSession){s(new Error("No SRP session"));return}console.log("[SecureConnection] Received SRP challenge");const{A:p,M1:d}=await this.srpSession.processChallenge(c.salt,c.B),u={type:"srp_proof",A:p,M1:d};(i=this.ws)==null||i.send(JSON.stringify(u)),this.connectionState="srp_proof_sent",console.log("[SecureConnection] SRP proof sent")}catch(c){console.error("[SecureConnection] SRP challenge error:",c),this.connectionState="failed",s(c instanceof Error?c:new Error(String(c))),(a=this.ws)==null||a.close()}}async handleSrpVerify(e,t,s){var o,r,i,a,c,p,d,u,w,v;try{const S=JSON.parse(e);if(V(S)){console.error("[SecureConnection] SRP error:",S.message),this.connectionState="failed",s(new Error(`Authentication failed: ${S.message}`)),(o=this.ws)==null||o.close();return}if(!Je(S)){console.warn("[SecureConnection] Unexpected message during SRP verify:",S),this.connectionState="failed",s(new Error(`Unexpected message during SRP verify: ${(S==null?void 0:S.type)??"unknown"}`)),(r=this.ws)==null||r.close();return}if(!this.srpSession){s(new Error("No SRP session"));return}if(console.log("[SecureConnection] Received SRP verify"),!await this.srpSession.verifyServer(S.M2)){console.error("[SecureConnection] Server verification failed"),this.connectionState="failed",s(new Error("Server verification failed")),(i=this.ws)==null||i.close();return}const E=this.srpSession.getSessionKey();if(!E){s(new Error("No session key"));return}const y=Te(E);if(!S.sessionId||!S.transportNonce){console.error("[SecureConnection] SRP verify missing required protocol metadata"),this.connectionState="failed",s(new Error("Server protocol verification failed")),(a=this.ws)==null||a.close();return}let C=U;if(S.serverInfoProof){const f=this.readSrpVerifyServerInfoProof({serverInfoProof:S.serverInfoProof,baseSessionKey:y,sessionId:S.sessionId,transportNonce:S.transportNonce});if(typeof f!="number"||!this.acceptAuthenticatedResumeProtocolVersion(f)){console.error("[SecureConnection] SRP server info proof failed"),this.connectionState="failed",s(new Error("Server protocol verification failed")),(c=this.ws)==null||c.close();return}C=f}else if(!this.acceptGraceProtocolVersion(U)){console.error("[SecureConnection] SRP verify would downgrade authenticated protocol"),this.connectionState="failed",s(new Error("Server protocol verification failed")),(p=this.ws)==null||p.close();return}this.sessionKey=Z(y,S.transportNonce),this.sessionId=S.sessionId,this.connectionState="authenticated",this.resetSequenceState();const x=btoa(Array.from(y).map(f=>String.fromCharCode(f)).join(""));this.storedSession={wsUrl:this.wsUrl,username:this.username,sessionId:this.sessionId,sessionKey:x,resumeProtocolVersion:C},(d=this.onSessionEstablished)==null||d.call(this,this.storedSession),this.sendCapabilities(),(u=this.connectionManager)==null||u.markConnected(),(w=this.onAuthenticated)==null||w.call(this),console.log("[SecureConnection] Authentication complete"),t()}catch(S){console.error("[SecureConnection] SRP verify error:",S),this.connectionState="failed",s(S instanceof Error?S:new Error(String(S))),(v=this.ws)==null||v.close()}}async handleMessage(e){var o,r,i,a;if(!this.sessionKey){console.warn("[SecureConnection] No session key for decryption");return}let t=null;if(Ve(e))try{const c=this.inboundChunks.acceptFrame(e);if(!c)return;if(t=await je(c,this.sessionKey),!t){console.warn("[SecureConnection] Failed to decrypt binary envelope");return}}catch(c){console.warn("[SecureConnection] Binary envelope error:",c),c instanceof $e&&((o=this.ws)==null||o.close(4005,"Invalid transport chunk sequence"));return}else if(typeof e=="string"){console.warn("[SecureConnection] Received text message after auth; binary encrypted envelope required"),(r=this.ws)==null||r.close(4005,"Binary encrypted message required");return}else{console.warn("[SecureConnection] Ignoring unknown message type");return}let s;try{const c=JSON.parse(t);if(Qe(c)){if(this.lastInboundSeq!==null&&c.seq<=this.lastInboundSeq){console.warn(`[SecureConnection] Replay/old sequence rejected: seq=${c.seq}, last=${this.lastInboundSeq}`),(i=this.ws)==null||i.close(4004,"Replay detected");return}this.lastInboundSeq=c.seq,s=c.msg}else{console.warn("[SecureConnection] Missing/invalid encrypted sequence"),(a=this.ws)==null||a.close(4004,"Invalid sequence");return}}catch{console.warn("[SecureConnection] Failed to parse decrypted message:",t);return}this.protocol.routeMessage(s)}send(e){if(!this.ws||this.ws.readyState!==R)throw new Error("WebSocket not connected");if(!this.sessionKey)throw new Error("Not authenticated");const t=JSON.stringify({seq:this.nextOutboundSeq,msg:e});this.nextOutboundSeq+=1;const s=Be(t,this.sessionKey);this.ws.send(s)}async openSpeechSocket(){if(!this.relayUrl||!this.relayUsername||!this.storedSession)throw new Error("Speech relay requires an active relayed session");const e=await _.connectRelaySocket(this.relayUrl,this.relayUsername,ee);let t=null;const s=await _.forResumeOnlyWithSocket(e,this.storedSession,{onDisconnect:o=>t==null?void 0:t.handleDisconnect(o)},{relayUrl:this.relayUrl,relayUsername:this.relayUsername,channel:ee});return t=new mt(s),t}sendSpeechControlMessage(e){this.send({type:"speech_control",message:e})}sendSpeechAudioFrame(e){if(!this.ws||this.ws.readyState!==R)throw new Error("WebSocket not connected");if(!this.sessionKey)throw new Error("Not authenticated");const t=z(ft(e),P.SPEECH_AUDIO,this.sessionKey);this.ws.send(t)}onSpeechEvent(e){return this.protocol.onSpeechEvent(e)}getSpeechSocketReadyState(){var e;return((e=this.ws)==null?void 0:e.readyState)??ht}getSpeechSocketBufferedAmount(){var e;return((e=this.ws)==null?void 0:e.bufferedAmount)??0}resetSequenceState(){this.nextOutboundSeq=0,this.lastInboundSeq=null,this.inboundChunks.reset()}sendCapabilities(){const e=[P.JSON,P.BINARY_UPLOAD,P.SPEECH_AUDIO,P.TRANSPORT_CHUNK];Le()&&e.push(P.COMPRESSED_JSON);const t={type:"client_capabilities",version:Ce(),capabilityBits:[],formats:e};console.log(`[SecureConnection] Sending capabilities: formats=${e.map(s=>`0x${s.toString(16).padStart(2,"0")}`).join(", ")}`);try{this.send(t)}catch(s){console.warn("[SecureConnection] Failed to send capabilities:",s)}}async fetch(e,t){return this.protocol.fetch(e,t)}async fetchBlob(e){return this.protocol.fetchBlob(e)}async fetchResponse(e,t){return this.protocol.fetchResponse(e,t)}subscribeConversation(e,t,s){return this.protocol.subscribeConversation(e,t,s)}subscribeSession(e,t,s,o){return this.protocol.subscribeSession(e,t,s,o)}subscribeActivity(e){return this.protocol.subscribeActivity(e)}subscribeGlossary(e,t){return this.protocol.subscribeGlossary(e,t)}subscribeWorktree(e,t,s){return this.protocol.subscribeWorktree(e,t,s)}subscribeSessionWatch(e,t,s){return this.protocol.subscribeSessionWatch(e,t,s)}async upload(e,t,s,o){return this.protocol.upload(e,t,s,o)}async uploadStagedAttachment(e,t){return this.protocol.uploadStagedAttachment(e,t)}sendPing(e){this.protocol.sendPing(e)}setOnPong(e){this.externalOnPong=e,this.updateProtocolPongHandler()}updateProtocolPongHandler(){const e=this.connectionManager,t=this.externalOnPong;this.protocol.setOnPong(e||t?s=>{e==null||e.receivePong(s),t==null||t(s)}:void 0)}sendMessage(e){this.send(e)}onDeviceMessage(e){return this.protocol.onDeviceMessage(e)}async waitForUploadBackpressure(){const e=this.ws;if(!(!e||e.readyState!==R)&&!(e.bufferedAmount<=at)){for(;e.readyState===R&&e.bufferedAmount>lt;)await pt(ut);if(e.readyState!==R)throw new Error("WebSocket not connected")}}close(){this.protocol.close(),this.sessionKey=null,this.srpSession=null,this.connectionState="disconnected",this.resetSequenceState(),this.ws&&(this.ws.close(),this.ws=null)}async forceReconnect(){if(this.forceReconnectPromise)return this.forceReconnectPromise;const e=this.performForceReconnect();this.forceReconnectPromise=e;try{await e}finally{this.forceReconnectPromise===e&&(this.forceReconnectPromise=null)}}async performForceReconnect(){var s;console.log(`[SecureConnection] Force reconnecting... wsState=${(s=this.ws)==null?void 0:s.readyState}, connState=${this.connectionState}, isRelay=${this.isRelayConnection}`);const e=this.connectionPromise;if(e)try{await e;return}catch{}this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws.close(),this.ws=null),this.resetSequenceState();const t=new be;this.protocol.rejectAllPending(t),this.protocol.notifySubscriptionsClosed(t),this.connectionState="disconnected",this.connectionPromise=null,await this.ensureConnected(),console.log(`[SecureConnection] Force reconnect complete, connState=${this.connectionState}`)}isAuthenticated(){return this.connectionState==="authenticated"&&this.sessionKey!==null}static async connectWithExistingSocket(e,t,s,o={},r){const i=new _("",t,s,o);return i.ws=e,i.isRelayConnection=!0,r&&(i.relayUrl=r.relayUrl,i.relayUsername=r.relayUsername,i.relayChannel=r.channel??A,i.relaySocketFactory=r.openSocket??null),e.binaryType="arraybuffer",await i.authenticateOnExistingSocket(),i}authenticateOnExistingSocket(){return new Promise((e,t)=>{if(!this.ws||this.ws.readyState!==R){t(new Error("WebSocket is not open"));return}console.log("[SecureConnection] Authenticating on existing socket"),this.connectionState="connecting";let s=()=>{},o=()=>{};const r=new Promise((c,p)=>{s=c,o=p}),i=this.ws;i.onerror=c=>{console.error("[SecureConnection] Error:",c)},i.onclose=c=>{this.handleSocketClose(c,o)},i.onmessage=async c=>{this.connectionState==="srp_hello_sent"?await this.handleSrpChallenge(c.data,s,o):this.connectionState==="srp_proof_sent"?await this.handleSrpVerify(c.data,s,o):this.connectionState==="authenticated"&&this.handleMessage(c.data)},this.startFullSrpHandshake(o).catch(c=>{console.error("[SecureConnection] SRP handshake error:",c),this.connectionState="failed",o(c instanceof Error?c:new Error(String(c))),i.close()});const a=setTimeout(()=>{this.connectionState!=="authenticated"&&(i.close(),this.connectionState="failed",t(new Error("Authentication timeout")))},3e4);r.then(()=>{clearTimeout(a),e()}).catch(c=>{clearTimeout(a),t(c)})})}}class mt{constructor(e){h(this,"onopen",null);h(this,"onmessage",null);h(this,"onerror",null);h(this,"onclose",null);h(this,"unsubscribeSpeech");h(this,"closed",!1);this.connection=e,this.unsubscribeSpeech=e.onSpeechEvent(t=>{var s;(s=this.onmessage)==null||s.call(this,{data:JSON.stringify(t)})})}get readyState(){return this.connection.getSpeechSocketReadyState()}get bufferedAmount(){return this.connection.getSpeechSocketBufferedAmount()}send(e){var t;if(this.closed)throw new Error("Speech socket is closed");try{if(typeof e=="string"){this.connection.sendSpeechControlMessage(JSON.parse(e));return}this.connection.sendSpeechAudioFrame(e)}catch(s){throw(t=this.onerror)==null||t.call(this,s),s}}close(){var e;this.closed||(this.closed=!0,this.unsubscribeSpeech(),this.connection.close(),(e=this.onclose)==null||e.call(this))}handleDisconnect(e){var t,s;this.closed||(this.closed=!0,this.unsubscribeSpeech(),(t=this.onerror)==null||t.call(this,e),(s=this.onclose)==null||s.call(this))}}function re(n,e){const t=e?`/projects/${encodeURIComponent(e.projectId)}/sessions/${encodeURIComponent(e.id)}`:"";if(n.mode==="local")return t||"/projects";if(n.mode==="relay")return n.relayUsername?`${qe(n.relayUsername)}${t}`:null;if(!n.wsUrl)return null;try{const s=new URL(n.wsUrl);return!["ws:","wss:"].includes(s.protocol)||s.username||s.password||!/\/api\/ws\/?$/.test(s.pathname)?null:(s.protocol=s.protocol==="wss:"?"https:":"http:",s.pathname=`${s.pathname.replace(/\/api\/ws\/?$/,"")}${t||"/"}`,s.search="",s.hash="",s.toString())}catch{return null}}function yt(n){return!le(n,ue.experimentalConversation)||typeof n.experimentalSimpleClientApiRevision!="string"?"update-required":n.experimentalSimpleClientApiRevision===he?"available":"revision-mismatch"}class St{constructor(e,t,s){h(this,"sequence",-1);h(this,"closed",!1);if(this.sourceId=e,this.subscriptionId=t,this.sessionId=s,K.parse(t),K.parse(s),!e)throw new Error("Conversation requires a source binding")}close(){this.closed=!0}accept(e,t){if(this.closed||e!==this.sourceId)return null;const s=xe(t);if(s.subscriptionId!==this.subscriptionId||s.sequence<=this.sequence)return null;if(s.view.kind==="conversation"&&s.view.sessionId!==this.sessionId)throw new Error("Conversation session mismatch");return this.sequence=s.sequence,s}}function wt(n,e){Ee.parse(n),K.parse(e);const t=new URLSearchParams({apiRevision:he,subscriptionId:e,sessionId:n.sessionId,maxMessages:String(n.maxMessages)});return n.anchorMessageId!==null&&t.set("anchorMessageId",n.anchorMessageId),`/api/experimental/conversation?${t}`}class T extends Error{constructor(e){super(e),this.name="MultiHostSignInRequiredError"}}function ie(n){if(n instanceof T)return!0;const t=(n instanceof Error?n.message:String(n)).toLowerCase();return t.includes("authentication")||t.includes("invalid_identity")||t.includes("resume_incompatible")||t.includes("session invalid")||t.includes("session resume")||t.includes("unauthorized")}async function gt(n,e,t,s){e.throwIfAborted();const o=n.session;if(!o)throw new T("A saved session is required");const r={onDisconnect:s,onSessionEstablished:p=>{Ie(n.id,p)}};if(n.mode==="direct"){if(!n.wsUrl)throw new T("The saved direct host has no WebSocket URL");const p=_.forResumeOnly(o,r),d=()=>p.close();e.addEventListener("abort",d,{once:!0});try{return await p.fetch("/auth/status"),e.throwIfAborted(),p}catch(u){throw p.close(),u}finally{e.removeEventListener("abort",d)}}if(!n.relayUrl||!n.relayUsername)throw new T("The saved relay host is incomplete");const a=await(t??H)({relayUrl:n.relayUrl,relayUsername:n.relayUsername,signal:e});e.aborted&&(a.close(),e.throwIfAborted());const c=()=>a.close();e.addEventListener("abort",c,{once:!0});try{const p=await _.forResumeOnlyWithSocket(a,o,r,{relayUrl:n.relayUrl,relayUsername:n.relayUsername,openSocket:t});return await p.fetch("/auth/status"),e.throwIfAborted(),p}catch(p){throw a.close(),p}finally{e.removeEventListener("abort",c)}}const vt=async(n,e)=>{if(n.mode!=="local")throw new Error("Expected a local preview source");e.throwIfAborted();const t=new AbortController,s=new Set,o=()=>{t.abort();for(const r of s)r.close();s.clear(),e.removeEventListener("abort",o)};return e.addEventListener("abort",o,{once:!0}),{close:o,async fetch(r,i){try{return await Re(r,{...i,signal:i!=null&&i.signal?AbortSignal.any([t.signal,i.signal]):t.signal},{onLoginRequired:()=>{}})}catch(a){throw(a==null?void 0:a.status)===401?new T("Authentication required"):a}},subscribeConversation(r,i,a){t.signal.throwIfAborted();const c=wt(i,r).replace("/conversation?","/conversation/subscribe?"),p=new EventSource(c);s.add(p);let d=!1;const u=()=>{d=!0,p.close(),s.delete(p)};return p.onopen=()=>{var w;!d&&!t.signal.aborted&&((w=a.onOpen)==null||w.call(a))},p.addEventListener("snapshot",w=>{var v;if(!(d||t.signal.aborted))try{a.onEvent("snapshot",void 0,JSON.parse(w.data))}catch(S){u(),(v=a.onError)==null||v.call(a,S instanceof Error?S:new Error("Invalid snapshot"))}}),p.onerror=()=>{var w;d||t.signal.aborted||(u(),(w=a.onError)==null||w.call(a,new Error("Conversation stream disconnected")))},{close:u}}}},bt=2e3,Ct=5e3,xt=3e4,Et=2*1024*1024,Rt=8*1024*1024,_t=1024*1024,It=10,Nt=5,ce=0,F=1,ae=2,q=3;class Y extends Error{constructor(e){super(e),this.reason=e,this.name="RelayMuxCircuitOpenError"}}function j(){return new DOMException("Relay connection aborted","AbortError")}function Pt(n){return typeof n=="string"?{bytes:new TextEncoder().encode(n),isBinary:!1}:n instanceof ArrayBuffer?{bytes:new Uint8Array(n),isBinary:!0}:{bytes:new Uint8Array(n.buffer,n.byteOffset,n.byteLength),isBinary:!0}}class Ot{constructor(e,t){h(this,"binaryType","arraybuffer");h(this,"onclose",null);h(this,"onerror",null);h(this,"onmessage",null);h(this,"state",ce);this.physical=e,this.circuitId=t}get bufferedAmount(){return this.physical.bufferedAmount}get readyState(){return this.state}markOpen(){this.state===ce&&(this.state=F)}receive(e,t){var o;if(this.state!==F)return;const s=t?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):new TextDecoder().decode(e);(o=this.onmessage)==null||o.call(this,new MessageEvent("message",{data:s}))}remoteClose(e,t){var s;this.state!==q&&(this.state=q,(s=this.onclose)==null||s.call(this,new CloseEvent("close",{code:e,reason:t,wasClean:e===1e3})))}fail(e){var t;this.state!==q&&((t=this.onerror)==null||t.call(this,new Event("error")),this.physical.closeCircuit(this.circuitId,e))}send(e){if(this.state!==F)throw new DOMException("WebSocket is not open","InvalidStateError");const t=Pt(e);this.physical.sendCircuitData(this.circuitId,t.bytes,t.isBinary)}close(e=1e3,t=""){this.state===ae||this.state===q||(this.state=ae,this.physical.requestCircuitClose(this.circuitId,e,t))}}class X{constructor(e,t){h(this,"circuits",new Map);h(this,"pending",new Map);h(this,"queues",new Map);h(this,"queuedBytesByCircuit",new Map);h(this,"queuedBytes",0);h(this,"circuitOrder",[]);h(this,"drainCursor",0);h(this,"drainScheduled",!1);h(this,"drainTimer",null);h(this,"nextCircuitId",1);h(this,"maxFrameBytes",0);h(this,"maxCircuits",0);h(this,"closed",!1);this.ws=e,this.onPhysicalClose=t}static connect(e,t,s){return new Promise((o,r)=>{const i=t(e);i.binaryType="arraybuffer";const a=new X(i,s);let c=!1;const p=setTimeout(()=>{c||(c=!0,i.close(),r(new Error("Relay mux ready timeout")))},Ct);i.onmessage=d=>{if(!c&&typeof d.data=="string")try{const u=JSON.parse(d.data);if(te(u)){c=!0,clearTimeout(p),a.maxCircuits=u.maxCircuits,a.maxFrameBytes=u.maxFrameBytes,o(a);return}}catch{}a.handleMessage(d)},i.onerror=()=>{c||(c=!0,clearTimeout(p),r(new Error("Failed to connect to relay mux")))},i.onclose=d=>{clearTimeout(p),a.handleClose(d),c||(c=!0,r(new Error("Relay mux closed before ready")))}})}get bufferedAmount(){return this.ws.bufferedAmount}get isOpen(){return!this.closed&&this.ws.readyState===F}async openCircuit(e,t,s){if(!this.isOpen)throw new Error("Relay mux is not connected");if(this.circuits.size+this.pending.size>=this.maxCircuits)throw new Y("circuit_limit");const o=this.allocateCircuitId(),r=new Ot(this,o);return new Promise((i,a)=>{const c=()=>{this.pending.delete(o),clearTimeout(p),this.sendControl({type:"mux_close",circuitId:o}),r.remoteClose(1e3,"Relay connection aborted"),a(j())},p=setTimeout(()=>{this.pending.delete(o),s==null||s.removeEventListener("abort",c),this.sendControl({type:"mux_close",circuitId:o}),r.remoteClose(1006,"Waiting for relay circuit timed out"),a(new Error("Waiting for relay circuit timed out"))},xt),d={socket:r,timeout:p,resolve:u=>{s==null||s.removeEventListener("abort",c),i(u)},reject:u=>{s==null||s.removeEventListener("abort",c),a(u)}};if(this.pending.set(o,d),s!=null&&s.aborted){c();return}s==null||s.addEventListener("abort",c,{once:!0}),this.sendControl({type:"mux_open",circuitId:o,username:e,channel:t})})}sendCircuitData(e,t,s){const o=this.circuits.get(e);if(!o||!this.isOpen)throw new DOMException("WebSocket is not open","InvalidStateError");if(t.byteLength>this.maxFrameBytes)throw o.fail("Relay mux frame is too large"),new DOMException("Relay mux frame is too large","QuotaExceededError");const r=st(e,t,s),i=this.queuedBytesByCircuit.get(e)??0;if(i+r.byteLength>Et||this.queuedBytes+r.byteLength>Rt)throw o.fail("Relay mux queue overflow"),new DOMException("Relay mux queue overflow","QuotaExceededError");let a=this.queues.get(e);a||(a=[],this.queues.set(e,a),this.circuitOrder.push(e)),a.push({bytes:r,circuitId:e}),this.queuedBytesByCircuit.set(e,i+r.byteLength),this.queuedBytes+=r.byteLength,this.scheduleDrain(!1)}requestCircuitClose(e,t,s){if(this.circuits.has(e)){if(!this.isOpen){this.removeCircuit(e,1006,"Relay mux disconnected");return}this.sendControl({type:"mux_close",circuitId:e})}}closeCircuit(e,t){this.circuits.has(e)&&(this.isOpen&&this.sendControl({type:"mux_close",circuitId:e}),this.removeCircuit(e,1008,t))}close(){this.closed||this.ws.close(1e3,"Mux pool disposed")}handleMessage(e){var t;if(typeof e.data=="string"){let s;try{s=JSON.parse(e.data)}catch{this.ws.close(1008,"Invalid relay mux control");return}if(Ze(s)){const o=this.pending.get(s.circuitId);if(!o){this.sendControl({type:"mux_close",circuitId:s.circuitId});return}this.pending.delete(s.circuitId),clearTimeout(o.timeout),o.socket.markOpen(),this.circuits.set(s.circuitId,o.socket),o.resolve(o.socket);return}if(et(s)){const o=this.pending.get(s.circuitId);if(!o)return;this.pending.delete(s.circuitId),clearTimeout(o.timeout),o.socket.remoteClose(1008,s.reason),o.reject(new Y(s.reason));return}if(tt(s)){this.removeCircuit(s.circuitId,1e3,s.reason);return}if(te(s))return;this.ws.close(1008,"Unexpected relay mux control");return}if(!(e.data instanceof ArrayBuffer)){this.ws.close(1008,"Invalid relay mux data");return}try{const s=nt(e.data);if(s.payload.byteLength>this.maxFrameBytes){this.closeCircuit(s.circuitId,"Relay mux frame is too large");return}(t=this.circuits.get(s.circuitId))==null||t.receive(s.payload,s.isBinary)}catch{this.ws.close(1008,"Invalid relay mux data")}}handleClose(e){if(!this.closed){this.closed=!0,this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null);for(const t of this.pending.values())clearTimeout(t.timeout),t.socket.remoteClose(e.code,e.reason),t.reject(new Error(e.reason||"Relay mux disconnected"));this.pending.clear();for(const t of this.circuits.keys())this.removeCircuit(t,e.code||1006,e.reason||"Relay mux disconnected");this.onPhysicalClose()}}removeCircuit(e,t,s){const o=this.circuits.get(e);if(!o)return;this.circuits.delete(e);const r=this.queuedBytesByCircuit.get(e)??0;this.queuedBytes-=r,this.queuedBytesByCircuit.delete(e),this.queues.delete(e),this.circuitOrder=this.circuitOrder.filter(i=>i!==e),o.remoteClose(t,s)}sendControl(e){if(!this.isOpen)throw new Error("Relay mux is not connected");this.ws.send(JSON.stringify(e))}allocateCircuitId(){for(let e=0;e<4294967295;e+=1){const t=this.nextCircuitId;if(this.nextCircuitId=this.nextCircuitId===4294967295?1:this.nextCircuitId+1,!this.pending.has(t)&&!this.circuits.has(t))return t}throw new Error("Relay mux circuit ids exhausted")}scheduleDrain(e){if(!(this.closed||this.drainScheduled||this.drainTimer)){if(e){this.drainTimer=setTimeout(()=>{this.drainTimer=null,this.drain()},It);return}this.drainScheduled=!0,queueMicrotask(()=>{this.drainScheduled=!1,this.drain()})}}drain(){if(this.isOpen){for(;this.queuedBytes>0&&this.ws.bufferedAmount<=_t;){const e=this.nextQueuedFrame();if(!e)break;this.ws.send(e.bytes)}this.queuedBytes>0&&this.scheduleDrain(!0)}}nextQueuedFrame(){if(this.circuitOrder.length===0)return null;for(let e=0;e<this.circuitOrder.length;e+=1){const t=(this.drainCursor+e)%this.circuitOrder.length,s=this.circuitOrder[t];if(s===void 0)continue;const o=this.queues.get(s);if(!o)continue;const r=o.shift();if(!r)continue;this.drainCursor=(t+1)%this.circuitOrder.length;const i=(this.queuedBytesByCircuit.get(s)??r.bytes.byteLength)-r.bytes.byteLength;return this.queuedBytesByCircuit.set(s,i),this.queuedBytes-=r.bytes.byteLength,o.length===0&&(this.queues.delete(s),this.circuitOrder=this.circuitOrder.filter(a=>a!==s)),r}return null}}class At{constructor(e,t){h(this,"discovery",null);h(this,"physical",null);h(this,"physicalOpening",null);h(this,"degraded",!1);h(this,"disposed",!1);h(this,"lifetime",new AbortController);this.endpoints=e,this.options=t}async open(e){if(this.disposed)throw j();const t=this.degraded?!1:await this.discover();if(this.disposed)throw j();if(this.degraded||!t)return this.options.openLegacySocket(e);let s;try{s=await this.ensurePhysical()}catch(o){if(this.disposed||o instanceof DOMException&&o.name==="AbortError")throw o;return this.degraded=!0,this.options.openLegacySocket(e)}try{return await s.openCircuit(e.relayUsername,e.channel??A,e.signal)}catch(o){if(o instanceof Y||o instanceof DOMException&&o.name==="AbortError")throw o;return this.degraded=!0,this.options.openLegacySocket(e)}}dispose(){var e;this.disposed||(this.disposed=!0,this.lifetime.abort(),(e=this.physical)==null||e.close(),this.physical=null)}discover(){return this.discovery?this.discovery:(this.discovery=this.runDiscovery(),this.discovery)}async runDiscovery(){const e=new AbortController,t=setTimeout(()=>e.abort(),bt),s=()=>e.abort();this.lifetime.signal.addEventListener("abort",s,{once:!0});try{const o=await this.options.fetch(this.endpoints.healthUrl,{signal:e.signal});if(!o.ok)return!1;const r=await o.json();return Array.isArray(r.relayCapabilities)&&r.relayCapabilities.includes(ze)}catch{return!1}finally{clearTimeout(t),this.lifetime.signal.removeEventListener("abort",s)}}ensurePhysical(){var o;if((o=this.physical)!=null&&o.isOpen)return Promise.resolve(this.physical);if(this.physicalOpening)return this.physicalOpening;let e=null;const s=X.connect(this.endpoints.muxUrl,this.options.createWebSocket,()=>{this.physical===e&&(this.physical=null)}).then(r=>{if(e=r,this.disposed)throw r.close(),j();return this.physical=r,r}).finally(()=>{this.physicalOpening===s&&(this.physicalOpening=null)});return this.physicalOpening=s,s}}class kt{constructor(e,t={}){h(this,"eligibleHostIds",new Set);h(this,"groups",new Map);h(this,"endpointsByHostId",new Map);h(this,"options");h(this,"disposed",!1);var r;const s=t.fetch??fetch;this.options={createWebSocket:t.createWebSocket??(i=>new WebSocket(i)),fetch:(i,a)=>s(i,a),openLegacySocket:t.openLegacySocket??H};const o=new Map;for(const i of e){if(i.mode!=="relay"||!i.session||!i.relayUrl||!i.relayUsername)continue;const a=We(i.relayUrl);if(!a)continue;let c=o.get(a.key);c||(c=[],o.set(a.key,c)),c.push({endpoints:a,host:i})}for(const[i,a]of o){if(a.length<2)continue;const c=a.slice(0,Nt),p=(r=c[0])==null?void 0:r.endpoints;if(p){this.groups.set(i,new At(p,this.options));for(const{host:d,endpoints:u}of c)this.eligibleHostIds.add(d.id),this.endpointsByHostId.set(d.id,u)}}}createSocketFactory(e){return t=>this.open(e,t)}dispose(){if(!this.disposed){this.disposed=!0;for(const e of this.groups.values())e.dispose();this.groups.clear()}}open(e,t){if(this.disposed)return Promise.reject(j());if(!this.eligibleHostIds.has(e.id))return this.options.openLegacySocket(t);const s=this.endpointsByHostId.get(e.id),o=s?this.groups.get(s.key):void 0;return(o==null?void 0:o.open(t))??this.options.openLegacySocket(t)}}class Ut{constructor(e,t,s=null){h(this,"state");h(this,"listeners",new Set);h(this,"owners",new Map);h(this,"stream");h(this,"binding");h(this,"disposed",!1);h(this,"pool");h(this,"connect");h(this,"getSnapshot",()=>this.state);h(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));this.state={sources:e.map(o=>({host:o,status:"excluded",sessions:[],hasMore:!1,updatedAt:null,issueCoverage:"unsupported"})),selection:s,view:null,conversationStatus:"empty",maxMessages:20,anchorMessageId:null},t||(this.pool=new kt(e.filter(o=>o.mode!=="local"))),this.connect=t??((o,r,i)=>{var a;if(o.mode==="local")throw new Error("Local source requires a local connector");return gt(o,r,o.mode==="relay"?(a=this.pool)==null?void 0:a.createSocketFactory(o):void 0,i)})}publish(e={}){if(!this.disposed){this.state={...this.state,...e};for(const t of this.listeners)t()}}source(e,t){this.publish({sources:this.state.sources.map(s=>s.host.id===e?{...s,...t}:s)})}closeStream(){var t;(t=this.binding)==null||t.close(),this.binding=void 0;const e=this.stream;this.stream=void 0,e==null||e.close()}stopSource(e){var s,o;const t=this.owners.get(e);this.owners.delete(e),t==null||t.abort.abort(),(s=t==null?void 0:t.connection)==null||s.close(),((o=this.state.selection)==null?void 0:o.sourceId)===e&&this.closeStream()}include(e,t){var a,c;if(this.disposed)return;if(this.stopSource(e),!t){this.source(e,{status:"excluded",sessions:[],updatedAt:null}),((a=this.state.selection)==null?void 0:a.sourceId)===e&&this.publish({selection:null,view:null,conversationStatus:"empty"});return}const s=this.state.sources.find(p=>p.host.id===e);if(!s)return;const o={abort:new AbortController};this.owners.set(e,o);const r=()=>!this.disposed&&this.owners.get(e)===o&&!o.abort.signal.aborted,i=p=>{var d;r()&&(this.stopSource(e),this.source(e,{status:ie(p)?"sign-in-required":"offline"}),((d=this.state.selection)==null?void 0:d.sourceId)===e&&this.publish({conversationStatus:"offline"}))};this.source(e,{status:"connecting",issueCoverage:"unsupported"}),((c=this.state.selection)==null?void 0:c.sourceId)===e&&this.publish({conversationStatus:"loading"}),(async()=>{var p,d,u;try{const w=await this.connect(s.host,o.abort.signal,i);if(!r()){w.close();return}o.connection=w;const v=await w.fetch("/version");if(!r())return;const S=yt(v);if(S!=="available"){this.stopSource(e),this.source(e,{status:S}),((p=this.state.selection)==null?void 0:p.sourceId)===e&&this.publish({conversationStatus:"offline"});return}const I=await w.fetch("/sessions?limit=50");if(!r())return;const E=I.sessions.slice(0,50).map(y=>({id:y.id,title:y.customTitle||y.title||y.fullTitle||y.id,projectId:y.projectId,projectName:y.projectName,updatedAt:y.updatedAt,issues:[]}));if(this.source(e,{status:"ready",sessions:E,hasMore:I.hasMore,updatedAt:Date.now()}),((d=this.state.selection)==null?void 0:d.sourceId)===e&&this.openConversation(),le(v,ue.issueSessionAssociations))try{const y=await w.fetch("/issues/settings");if(!r())return;if(!y.settings.enabled){this.source(e,{issueCoverage:"disabled"});return}this.source(e,{issueCoverage:"partial"});let C=0,x=!1;const f=new Map;await Promise.all(Array.from({length:3},async()=>{for(;r()&&!x;){const g=E[C++];if(!g)return;const b=await w.fetch(`/issues?sessionId=${encodeURIComponent(g.id)}&limit=10`).catch(N=>{throw x=!0,N});if(!r())return;f.set(g.id,b.items.map(N=>({id:N.id,key:N.key})))}})),r()&&this.source(e,{sessions:E.map(g=>({...g,issues:f.get(g.id)??[]}))})}catch{r()&&this.source(e,{issueCoverage:"unavailable"})}}catch(w){if(!r())return;this.stopSource(e),this.source(e,{status:ie(w)?"sign-in-required":"offline"}),((u=this.state.selection)==null?void 0:u.sourceId)===e&&this.publish({conversationStatus:"offline"})}})()}select(e,t){this.closeStream(),this.publish({selection:{sourceId:e,sessionId:t},view:null,maxMessages:20,anchorMessageId:null}),this.openConversation()}more(){var t;const e=this.state.view;this.publish({maxMessages:Math.min(100,this.state.maxMessages+20),anchorMessageId:(e==null?void 0:e.kind)==="conversation"?((t=e.messages.at(-1))==null?void 0:t.id)??null:null}),this.openConversation()}latest(){this.publish({anchorMessageId:null}),this.openConversation()}openConversation(){var p;this.closeStream();const e=this.state.selection;if(!e)return;const t=(p=this.owners.get(e.sourceId))==null?void 0:p.connection,s=this.state.sources.find(d=>d.host.id===e.sourceId);if(!t||(s==null?void 0:s.status)!=="ready"){this.publish({conversationStatus:"offline"});return}const o=new St(e.sourceId,_e(),e.sessionId);this.binding=o;const r=()=>this.binding===o&&!this.disposed;this.publish({conversationStatus:"loading"});const i={sessionId:e.sessionId,maxMessages:this.state.maxMessages,anchorMessageId:this.state.anchorMessageId},a=()=>{r()&&(this.closeStream(),this.publish({conversationStatus:"offline"}))},c={onEvent:(d,u,w)=>{if(r()){if(d==="closed"){a();return}if(d==="snapshot")try{const v=o.accept(e.sourceId,JSON.stringify(w));v&&this.publish({view:v.view,conversationStatus:"ready"})}catch{this.closeStream(),this.publish({conversationStatus:"invalid"})}}},onClose:a,onError:a};try{const d=t.subscribeConversation(o.subscriptionId,i,c);r()?this.stream=d:d.close()}catch{a()}}dispose(){var e;if(!this.disposed){this.disposed=!0,this.closeStream();for(const t of[...this.owners.keys()])this.stopSource(t);(e=this.pool)==null||e.dispose(),this.listeners.clear()}}}function Mt(n,e){if(e==="none"){const s=n.filter(r=>r.status!=="excluded").flatMap(r=>r.sessions.map(i=>({source:r,session:i}))),o=r=>{const i=Date.parse(r.session.updatedAt);return Number.isFinite(i)?i:Number.NEGATIVE_INFINITY};return s.sort((r,i)=>o(i)-o(r)||0),s.length?[{id:"none",label:null,sourceName:null,rows:s}]:[]}const t=new Map;for(const s of n)if(s.status!=="excluded")for(const o of s.sessions){const r=e==="issue"&&o.issues.length>0?o.issues.map(i=>({id:JSON.stringify(["issue",i.id]),label:i.key,sourceName:null})):[{id:JSON.stringify([e,s.host.id,e==="project"?o.projectId:null]),label:e==="machine"?s.host.displayName:e==="project"?o.projectName:null,sourceName:e==="machine"?null:s.host.displayName}];for(const i of r){const a=t.get(i.id)??{...i,rows:[]};a.rows.push({source:s,session:o}),t.set(i.id,a)}}return[...t.values()]}const Tt="_page_x41bu_1",jt="_topbar_x41bu_20",Bt="_muted_x41bu_32",Lt="_control_x41bu_37",qt="_session_x41bu_56",Ft="_workspace_x41bu_59",Dt="_sidebar_x41bu_65",Ht="_sources_x41bu_71",Vt="_sectionHeading_x41bu_75",$t="_source_x41bu_71",Wt="_sourceDetail_x41bu_106",Kt="_localSource_x41bu_123",Jt="_groupControl_x41bu_132",Yt="_groups_x41bu_150",Gt="_main_x41bu_200",Xt="_empty_x41bu_206",Qt="_conversationHeader_x41bu_219",zt="_actions_x41bu_233",Zt="_badge_x41bu_244",es="_transcript_x41bu_249",ts="_history_x41bu_256",ss="_message_x41bu_268",ns="_prose_x41bu_284",os="_activity_x41bu_288",rs="_failure_x41bu_298",is="_notice_x41bu_306",cs="_mobileToggle_x41bu_317",m={page:Tt,topbar:jt,muted:Bt,control:Lt,session:qt,workspace:Ft,sidebar:Dt,sources:Ht,sectionHeading:Vt,source:$t,sourceDetail:Wt,localSource:Kt,groupControl:Jt,groups:Yt,main:Gt,empty:Xt,conversationHeader:Qt,actions:zt,badge:Zt,transcript:es,history:ts,message:ss,prose:ns,activity:os,failure:rs,notice:is,mobileToggle:cs},as={excluded:"preview.status.excluded",connecting:"preview.status.connecting",ready:"preview.status.ready",offline:"preview.status.offline","sign-in-required":"preview.status.signIn","update-required":"preview.status.update","revision-mismatch":"preview.status.revision"},me="yep-experimental-preview-sources";function ls({content:n}){const{t:e}=pe();switch(n.kind){case"text":return l.jsx("div",{className:m.prose,children:n.text});case"activity":return l.jsxs("div",{className:m.activity,children:[l.jsx("p",{children:n.summary}),l.jsx("small",{children:e(n.toolCount===1?"preview.toolOne":"preview.tools",{count:n.toolCount,failed:n.failedToolCount})})]});case"failure":return l.jsxs("div",{className:m.failure,children:[l.jsx("strong",{children:n.toolName}),l.jsx("p",{children:n.message})]});case"media":return l.jsx("div",{className:m.activity,children:e("preview.media",{description:n.description||e("preview.attachment")})});default:return l.jsx("p",{className:m.notice,children:e("preview.unknown")})}}function us({controller:n,local:e}){var y,C,x;const{t}=pe(),s=O.useSyncExternalStore(n.subscribe,n.getSnapshot),[o,r]=de(),[i,a]=O.useState(e?"none":"machine"),[c,p]=O.useState(!s.selection),d=O.useMemo(()=>Mt(s.sources,i),[s.sources,i]),u=s.sources.find(f=>{var g;return f.host.id===((g=s.selection)==null?void 0:g.sourceId)}),w=u==null?void 0:u.sessions.find(f=>{var g;return f.id===((g=s.selection)==null?void 0:g.sessionId)}),v=((y=s.view)==null?void 0:y.kind)==="conversation"?s.view:null,S=s.conversationStatus==="loading",I=u?re(u.host,w):null;function E(f,g){n.include(f,g);try{localStorage.setItem(me,JSON.stringify(n.getSnapshot().sources.filter(b=>b.status!=="excluded").map(b=>b.host.id)))}catch{}n.getSnapshot().selection||r({},{replace:!0})}return l.jsxs("div",{className:m.page,children:[l.jsxs("header",{className:m.topbar,children:[l.jsxs("div",{children:[l.jsx("h1",{children:t("preview.title")}),l.jsx("span",{className:m.muted,children:t("preview.subtitle")})]}),l.jsx(k,{className:m.control,to:e?"/projects":"/login",children:t("preview.fullApp")})]}),l.jsx("button",{type:"button",className:`${m.control} ${m.mobileToggle}`,"aria-expanded":c,"aria-controls":"preview-sidebar",onClick:()=>p(!c),children:t(c?"preview.hideSessions":e?"preview.sessions":"preview.showSessions")}),l.jsxs("div",{className:m.workspace,children:[l.jsxs("aside",{id:"preview-sidebar",className:m.sidebar,"data-open":c,"aria-label":t("preview.sessions"),children:[l.jsxs("section",{className:m.sources,children:[l.jsxs("div",{className:m.sectionHeading,children:[l.jsx("h2",{children:t(e?"preview.localServer":"preview.machines")}),!e&&l.jsx(k,{to:"/login",children:t("preview.addMachine")})]}),s.sources.length===0&&l.jsx("p",{className:m.muted,children:t("preview.noMachines")}),s.sources.map(f=>l.jsxs("div",{className:`${m.source} ${e?m.localSource:""}`,"data-testid":"preview-source","data-source-name":f.host.displayName,"data-source-status":f.status,children:[e?l.jsx("strong",{children:f.host.displayName}):l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:f.status!=="excluded",onChange:g=>E(f.host.id,g.target.checked)}),l.jsx("span",{children:f.host.displayName})]}),l.jsxs("div",{className:m.sourceDetail,children:[l.jsx("span",{children:t(as[f.status])}),f.status!=="excluded"&&f.status!=="connecting"&&l.jsx("button",{type:"button",className:m.control,onClick:()=>n.include(f.host.id,!0),children:t("preview.refresh")})]}),f.status==="sign-in-required"&&l.jsx(k,{to:f.host.mode==="local"?"/login":f.host.mode==="relay"?`/login/relay?u=${encodeURIComponent(f.host.relayUsername??"")}&r=${encodeURIComponent(f.host.relayUrl??"")}`:"/login/direct",state:e?{from:`/-/preview${o.size?`?${o}`:""}`}:void 0,children:t("preview.signIn")}),["offline","update-required","revision-mismatch"].includes(f.status)&&l.jsx(k,{className:m.control,to:re(f.host)??(f.host.mode==="relay"?"/login/relay":"/login/direct"),children:t("preview.fullApp")}),i==="issue"&&f.status==="ready"&&l.jsx("p",{className:m.muted,children:t(`preview.issues.${f.issueCoverage}`)}),f.hasMore&&f.status==="ready"&&l.jsx("small",{className:m.muted,children:t("preview.catalogLimit")})]},f.host.id))]}),l.jsxs("label",{className:m.groupControl,children:[t("preview.groupBy"),l.jsxs("select",{value:i,onChange:f=>a(f.target.value),children:[l.jsx("option",{value:"none",children:t("preview.byNone")}),!e&&l.jsx("option",{value:"machine",children:t("preview.byMachine")}),l.jsx("option",{value:"project",children:t("preview.byProject")}),l.jsx("option",{value:"issue",children:t("preview.byIssue")})]})]}),l.jsxs("nav",{"aria-label":t("preview.sessions"),className:m.groups,children:[d.length===0&&l.jsx("p",{className:m.muted,children:t("preview.noSessions")}),d.map(f=>l.jsxs("section",{children:[i!=="none"&&l.jsxs("h3",{children:[f.label??t("preview.noIssueLinks"),l.jsx("small",{children:f.sourceName})]}),f.rows.map(({source:g,session:b})=>{var N;return l.jsxs("button",{type:"button",className:m.session,"aria-current":((N=s.selection)==null?void 0:N.sourceId)===g.host.id&&s.selection.sessionId===b.id?"true":void 0,onClick:()=>{n.select(g.host.id,b.id),r({source:g.host.id,session:b.id},{replace:!0}),p(!1)},children:[l.jsx("span",{children:b.title}),l.jsx("small",{children:e||i==="machine"?b.projectName:g.host.displayName})]},JSON.stringify([g.host.id,b.id]))})]},f.id))]})]}),l.jsx("main",{className:m.main,children:s.selection?l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:m.conversationHeader,children:[l.jsxs("small",{className:m.muted,children:[u==null?void 0:u.host.displayName," · ",w==null?void 0:w.projectName]}),l.jsx("h2",{children:(w==null?void 0:w.title)??s.selection.sessionId}),l.jsxs("div",{className:m.actions,children:[l.jsx("span",{className:m.badge,children:t("preview.readOnlyBadge")}),v&&l.jsx("span",{children:t(`preview.activity.${v.activity}`)}),I?l.jsx(k,{className:m.control,to:I,children:t("preview.openFull")}):l.jsx(k,{className:m.control,to:"/login/direct",children:t("preview.fullApp")})]})]}),l.jsxs("div",{className:m.transcript,"data-testid":"preview-conversation",children:[S&&l.jsx("p",{role:"status",className:m.notice,children:t("preview.loading")}),s.conversationStatus==="offline"&&l.jsxs("div",{role:"status",className:m.notice,children:[l.jsx("p",{children:t("preview.disconnected")}),u&&l.jsx("button",{className:m.control,type:"button",onClick:()=>n.include(u.host.id,!0),children:t("preview.reconnect")})]}),s.conversationStatus==="invalid"&&l.jsx("p",{role:"alert",className:m.notice,children:t("preview.invalid")}),((C=s.view)==null?void 0:C.kind)==="error"&&l.jsx("p",{role:"status",className:m.notice,children:t(`preview.error.${s.view.code}`)}),s.view&&s.view.kind!=="conversation"&&s.view.kind!=="error"&&l.jsx("p",{className:m.notice,children:t("preview.unknown")}),v&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:m.history,children:[l.jsx("span",{children:t(v.coverage.returnedMessages===1?"preview.messageCountOne":"preview.messageCount",{count:v.coverage.returnedMessages})}),l.jsx("button",{type:"button",className:m.control,disabled:S||s.maxMessages>=100||!v.coverage.earlierInScope||(u==null?void 0:u.status)!=="ready",onClick:()=>n.more(),children:t("preview.more")}),l.jsx("button",{type:"button",className:m.control,disabled:S||(u==null?void 0:u.status)!=="ready",onClick:()=>n.latest(),children:t("preview.latest")})]}),s.anchorMessageId&&l.jsx("p",{className:m.muted,children:t("preview.anchored")}),(!v.coverage.completeForRequest||v.coverage.earlierOutsideScope!=="no"||s.maxMessages>=100&&v.coverage.earlierInScope)&&l.jsx("p",{className:m.notice,children:t("preview.coverage")}),v.messages.length===0&&l.jsx("p",{className:m.muted,children:t("preview.emptyConversation")}),v.messages.map(f=>l.jsxs("article",{className:m.message,"data-role":f.role,children:[l.jsxs("header",{children:[l.jsx("strong",{children:t(f.role==="user"?"preview.you":"preview.agent")}),f.state!=="complete"&&l.jsx("small",{children:t(`preview.message.${f.state}`)})]}),f.content.map((g,b)=>l.jsx(ls,{content:g},`${f.id}:${b}`)),f.truncated&&l.jsx("small",{className:m.muted,children:t("preview.truncated")})]},f.id)),v.pendingRequests.map((f,g)=>l.jsxs("section",{className:m.notice,children:[l.jsx("strong",{children:t("preview.needsAttention")}),l.jsx("p",{children:f.kind==="question"?f.prompt:t("preview.unknown")}),l.jsx("small",{children:t("preview.answerInFull")})]},f.kind==="question"?f.id:`unknown:${g}`))]}),((x=s.view)==null?void 0:x.kind)==="error"&&(u==null?void 0:u.status)==="ready"&&l.jsx("button",{type:"button",className:m.control,onClick:()=>n.latest(),children:t("preview.latest")})]})]}):l.jsxs("div",{className:m.empty,children:[l.jsx("h2",{children:t("preview.welcome")}),l.jsx("p",{children:t("preview.chooseSession")}),l.jsx("p",{className:m.muted,children:t("preview.readOnly")})]})})]})]})}function gs({local:n=!1}){const[e,t]=O.useState(null),[s]=de(),[o]=O.useState(()=>(n||s.get("source"))&&s.get("session")?{sourceId:n?"local":s.get("source"),sessionId:s.get("session")}:null);return O.useEffect(()=>{const r=new Ut(n?[{id:"local",mode:"local",displayName:window.location.host}]:Ne().hosts,n?vt:void 0,o);if(t(r),n)return r.include("local",!0),()=>r.dispose();let i=[];try{const a=JSON.parse(localStorage.getItem(me)??"[]");Array.isArray(a)&&(i=a.filter(c=>typeof c=="string"))}catch{}o&&i.push(o.sourceId);for(const a of new Set(i))r.include(a,!0);return()=>r.dispose()},[o,n]),e?l.jsx(us,{controller:e,local:n}):null}export{gs as ConversationPreviewPage,ls as PreviewContent};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BESqiBDI.js","assets/react-runtime-D-UPQ57m.js","assets/remoteRoutePaths-D8htA0xa.js","assets/index-umZg0LZ6.js","assets/index-CPb-36gi.css","assets/RelayProtocol-BpdH0COG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ye=Object.defineProperty;var Se=(n,e,t)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var h=(n,e,t)=>Se(n,typeof e!="symbol"?e+"":e,t);import{bb as we,aF as ge,bc as ve,bd as Q,be,bf as Ce,s as le,i as ue,aE as he,bg as K,bh as xe,bi as Ee,bj as Re,aG as _e,r as O,b as de,j as l,u as pe,L as k}from"./index-umZg0LZ6.js";import{u as Ie,l as Ne}from"./hostStorage-D1KAm3U1.js";import{D as A,d as Pe,e as Oe,f as z,h as Ae,j as ke,k as Ue,l as Me,m as Z,n as Te,o as je,p as Be,S as ee,q as Le,b as qe}from"./remoteRoutePaths-D8htA0xa.js";import{T as Fe,R as De,d as He,B as P,i as Ve,f as $e}from"./RelayProtocol-BpdH0COG.js";import{r as We}from"./relayEndpoints-BTq9xppf.js";import"./react-runtime-D-UPQ57m.js";import"./relay-url-j3kYm5KO.js";function Ke(n){return typeof n=="object"&&n!==null&&n.type==="srp_challenge"}function Je(n){return typeof n=="object"&&n!==null&&n.type==="srp_verify"}function V(n){return typeof n=="object"&&n!==null&&n.type==="srp_error"}function Ye(n){return typeof n=="object"&&n!==null&&n.type==="srp_resume_challenge"}function Ge(n){return typeof n=="object"&&n!==null&&n.type==="srp_resumed"}function Xe(n){return typeof n=="object"&&n!==null&&n.type==="srp_invalid"}function Qe(n){return typeof n=="object"&&n!==null&&Number.isSafeInteger(n.seq)&&n.seq>=0&&"msg"in n}const ze="client-mux-v1",G=1,D=6,J=1;class M extends Error{constructor(e,t){super(e),this.circuitId=t,this.name="RelayMuxFrameError"}}function B(n){return typeof n=="number"&&Number.isSafeInteger(n)&&n>0&&n<=4294967295}function te(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_ready"&&e.protocolVersion===G&&typeof e.maxCircuits=="number"&&Number.isSafeInteger(e.maxCircuits)&&e.maxCircuits>0&&typeof e.maxFrameBytes=="number"&&Number.isSafeInteger(e.maxFrameBytes)&&e.maxFrameBytes>0}function Ze(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_opened"&&B(e.circuitId)}function et(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_error"&&B(e.circuitId)&&(e.reason==="unknown_username"||e.reason==="server_offline"||e.reason==="circuit_limit"||e.reason==="rate_limited"||e.reason==="invalid_request")}function tt(n){const e=n;return typeof n=="object"&&n!==null&&e.type==="mux_closed"&&B(e.circuitId)&&(e.reason==="client_closed"||e.reason==="server_closed"||e.reason==="relay_closed")}function st(n,e,t){if(!B(n))throw new M("Invalid relay mux circuit id");const s=new Uint8Array(D+e.byteLength);return s[0]=G,s[1]=t?J:0,new DataView(s.buffer).setUint32(2,n,!1),s.set(e,D),s}function nt(n){const e=n instanceof Uint8Array?n:new Uint8Array(n);if(e.byteLength<D)throw new M("Relay mux data frame is too short");const s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2,!1);if(e[0]!==G)throw new M("Unsupported relay mux frame version",s||void 0);const o=e[1]??0;if((o&~J)!==0)throw new M("Invalid relay mux frame flags",s||void 0);if(!B(s))throw new M("Invalid relay mux circuit id");return{circuitId:s,isBinary:(o&J)!==0,payload:e.subarray(D)}}function fe(){return new DOMException("Relay connection aborted","AbortError")}function ot(n,e){return new Promise((t,s)=>{var c,p;let o=!1;const r=d=>{var u;o||(o=!0,clearTimeout(a),(u=e.signal)==null||u.removeEventListener("abort",i),d?s(d):t())},i=()=>{n.close(),r(fe())},a=setTimeout(()=>{n.close(),r(new Error("Relay connection timeout"))},e.connectTimeoutMs??15e3);if((c=e.signal)!=null&&c.aborted){i();return}(p=e.signal)==null||p.addEventListener("abort",i,{once:!0}),n.onopen=()=>{var d;(d=e.onOpen)==null||d.call(e),r()},n.onerror=()=>{r(new Error("Failed to connect to relay server"))}})}function rt(n,e){return new Promise((t,s)=>{var c,p;let o=!1;const r=d=>{var u;o||(o=!0,clearTimeout(a),(u=e.signal)==null||u.removeEventListener("abort",i),n.onmessage=null,n.onclose=null,n.onerror=null,d?s(d):t())},i=()=>{n.close(),r(fe())},a=setTimeout(()=>{n.close(),r(new Error("Waiting for server timed out"))},e.serverTimeoutMs??3e4);if((c=e.signal)!=null&&c.aborted){i();return}(p=e.signal)==null||p.addEventListener("abort",i,{once:!0}),n.onmessage=d=>{try{const u=JSON.parse(d.data);Pe(u)?r():Oe(u)?(n.close(),r(new Error(u.reason))):r()}catch{n.close(),r(new Error("Invalid relay response"))}},n.onclose=()=>{r(new Error("Relay connection closed"))},n.onerror=()=>{r(new Error("Relay connection error"))}})}async function H(n){const e=new WebSocket(n.relayUrl);e.binaryType="arraybuffer";try{await ot(e,n);const t=n.channel??A;return e.send(JSON.stringify(t===A?{type:"client_connect",username:n.relayUsername}:{type:"client_connect_channel",username:n.relayUsername,channel:t})),await rt(e,n),e}catch(t){throw e.close(),t}}let $=null;async function se(){return $||($=await we(()=>import("./index-BESqiBDI.js").then(n=>n.i),__vite__mapDeps([0,1,2,3,4,5]))),$}function ne(n){return n.toString(16)}function W(n){return BigInt(`0x${n}`)}class it{constructor(){h(this,"session",null);h(this,"step1Result",null);h(this,"step2Result",null);h(this,"sessionKey",null);h(this,"identity",null)}async generateHello(e,t){const{SRPClientSession:s,SRPParameters:o,SRPRoutines:r}=await se(),i=new o,a=new r(i);return this.session=new s(a),this.identity=e,this.step1Result=await this.session.step1(e,t),{identity:e}}async processChallenge(e,t){if(!this.step1Result)throw new Error("Must call generateHello before processChallenge");const s=W(e),o=W(t);return this.step2Result=await this.step1Result.step2(s,o),{A:ne(this.step2Result.A),M1:ne(this.step2Result.M1)}}async verifyServer(e){if(!this.step2Result)throw new Error("Must call processChallenge before verifyServer");const{bigIntToArrayBuffer:t}=await se(),s=W(e);try{await this.step2Result.step3(s);const o=t(this.step2Result.S);return this.sessionKey=new Uint8Array(o),!0}catch{return!1}}getSessionKey(){return this.sessionKey}isAuthenticated(){return this.sessionKey!==null}getIdentity(){return this.identity}}const oe=5e3,L="resume_incompatible: session resume unsupported by server",U=2,ct=3,at=512*1024,lt=256*1024,ut=16,R=1,ht=3;function dt(n){let e="";for(const t of n)e+=String.fromCharCode(t);return btoa(e)}function pt(n){return new Promise(e=>setTimeout(e,n))}function ft(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}class _{constructor(e,t,s,o={}){h(this,"mode","secure");h(this,"ws",null);h(this,"srpSession",null);h(this,"sessionKey",null);h(this,"sessionId",null);h(this,"connectionState","disconnected");h(this,"connectionPromise",null);h(this,"forceReconnectPromise",null);h(this,"protocol");h(this,"nextOutboundSeq",0);h(this,"lastInboundSeq",null);h(this,"inboundChunks",new Fe);h(this,"pendingResumeClientNonce",null);h(this,"pendingResumeServerNonce",null);h(this,"minimumResumeProtocolVersion",null);h(this,"connectionManager",null);h(this,"externalOnPong");h(this,"username");h(this,"password");h(this,"wsUrl");h(this,"isRelayConnection",!1);h(this,"relayUrl",null);h(this,"relayUsername",null);h(this,"relayChannel",A);h(this,"relaySocketFactory",null);h(this,"storedSession",null);h(this,"onSessionEstablished");h(this,"onDisconnect");h(this,"onAuthenticated");this.wsUrl=e,this.username=t,this.password=s,this.onSessionEstablished=o.onSessionEstablished,this.onDisconnect=o.onDisconnect,this.onAuthenticated=o.onAuthenticated,this.protocol=new De({sendMessage:r=>this.send(r),sendUploadChunk:async(r,i,a)=>{const c=He(r,i,a);if(!this.ws||this.ws.readyState!==R)throw new Error("WebSocket not connected");if(!this.sessionKey)throw new Error("Not authenticated");const p=z(c,P.BINARY_UPLOAD,this.sessionKey);this.ws.send(p),await this.waitForUploadBackpressure()},ensureConnected:()=>this.ensureConnected(),isConnected:()=>{var r;return this.connectionState==="authenticated"&&((r=this.ws)==null?void 0:r.readyState)===R}},{debugEnabled:()=>Ae(),logPrefix:"[SecureConnection]"})}setConnectionManager(e){this.connectionManager=e,this.updateProtocolPongHandler(),this.protocol.setOnInboundEvent(e?t=>{t.eventType==="heartbeat"?e.recordHeartbeat():e.recordEvent()}:void 0),this.protocol.setBeginCriticalOperation(e?t=>e.beginCriticalOperation(t):void 0)}static fromStoredSession(e,t,s={}){const o=new _(e.wsUrl,e.username,t,s);return o.storedSession=e,o.minimumResumeProtocolVersion=e.resumeProtocolVersion??null,o}static forResumeOnly(e,t={}){const s=new _(e.wsUrl,e.username,"",t);return s.storedSession=e,s.password=null,s.minimumResumeProtocolVersion=e.resumeProtocolVersion??null,s}static async forResumeOnlyWithSocket(e,t,s={},o){const r=new _("",t.username,"",s);return r.ws=e,r.storedSession=t,r.password=null,r.minimumResumeProtocolVersion=t.resumeProtocolVersion??null,r.isRelayConnection=!0,o&&(r.relayUrl=o.relayUrl,r.relayUsername=o.relayUsername,r.relayChannel=o.channel??A,r.relaySocketFactory=o.openSocket??null),await r.resumeOnExistingSocket(),r}resumeOnExistingSocket(){return new Promise((e,t)=>{if(!this.ws||this.ws.readyState!==R){t(new Error("WebSocket is not open"));return}if(!this.storedSession){t(new Error("No stored session for resume"));return}if(!this.storedSessionSupportsCurrentResume()){this.connectionState="failed",t(new Error(L)),this.ws.close();return}console.log("[SecureConnection] Resuming session on existing socket"),this.connectionState="connecting";let s=()=>{},o=()=>{};const r=new Promise((d,u)=>{s=d,o=u}),i=this.ws;i.onerror=d=>{console.error("[SecureConnection] Error:",d)},i.onclose=d=>{this.handleSocketClose(d,o)},i.onmessage=d=>{c(),this.handleSrpResumeResponse(d.data,s,o)};let a=null;const c=()=>{a&&clearTimeout(a),a=setTimeout(()=>{this.connectionState!=="srp_resume_init_sent"&&this.connectionState!=="srp_resume_proof_sent"||(this.connectionState="failed",o(new Error(L)),i.close())},oe)},p={type:"srp_resume_init",identity:this.username,sessionId:this.storedSession.sessionId,clientNonce:this.startResumeAttempt()};i.send(JSON.stringify(p)),this.connectionState="srp_resume_init_sent",console.log("[SecureConnection] SRP resume init sent"),c(),r.then(()=>{a&&clearTimeout(a),e()}).catch(d=>{a&&clearTimeout(a),t(d)})})}generateResumeProof(e,t,s){const o=Uint8Array.from(atob(e),p=>p.charCodeAt(0)),r=Date.now(),i=JSON.stringify({timestamp:r,challenge:t,sessionId:s}),{nonce:a,ciphertext:c}=ke(i,o);return JSON.stringify({nonce:a,ciphertext:c})}startResumeAttempt(){return this.pendingResumeClientNonce=dt(Ue()),this.pendingResumeServerNonce=null,this.pendingResumeClientNonce}storedSessionSupportsCurrentResume(){var t;const e=(t=this.storedSession)==null?void 0:t.resumeProtocolVersion;return e===void 0||e>=U}decryptProofEnvelope(e,t){try{const s=JSON.parse(e);return typeof s.nonce!="string"||typeof s.ciphertext!="string"?null:Me(s.nonce,s.ciphertext,t)}catch{return null}}acceptAuthenticatedResumeProtocolVersion(e,t=ct){var o;if(!Number.isSafeInteger(e)||e<t)return!1;const s=Math.max(this.minimumResumeProtocolVersion??0,((o=this.storedSession)==null?void 0:o.resumeProtocolVersion)??0);return s>0&&e<s?!1:(this.minimumResumeProtocolVersion=Math.max(s,e),!0)}verifyResumeServerProof(e){if(!e.serverProof||!e.transportNonce||!this.pendingResumeClientNonce||!this.pendingResumeServerNonce||e.transportNonce!==this.pendingResumeServerNonce)return null;try{const t=this.decryptProofEnvelope(e.serverProof,e.baseSessionKey);if(!t)return null;const s=JSON.parse(t);return s.type==="srp_resume_server_proof"&&s.sessionId===e.sessionId&&s.serverNonce===this.pendingResumeServerNonce&&s.clientNonce===this.pendingResumeClientNonce&&typeof s.resumeProtocolVersion=="number"?s.resumeProtocolVersion:null}catch{return null}}readSrpVerifyServerInfoProof(e){if(!e.serverInfoProof||!e.sessionId||!e.transportNonce)return null;try{const t=this.decryptProofEnvelope(e.serverInfoProof,e.baseSessionKey);if(!t)return null;const s=JSON.parse(t);return s.type!=="srp_verify_server_info"||s.sessionId!==e.sessionId||s.transportNonce!==e.transportNonce||typeof s.resumeProtocolVersion!="number"?null:s.resumeProtocolVersion}catch{return null}}acceptGraceProtocolVersion(e){return this.acceptAuthenticatedResumeProtocolVersion(e,U)}async startFullSrpHandshake(e){var r;if(!this.password)throw new Error("Password required for SRP authentication");this.pendingResumeClientNonce=null,this.pendingResumeServerNonce=null,console.log("[SecureConnection] Starting full SRP handshake"),this.srpSession=new it,await this.srpSession.generateHello(this.username,this.password);const t=ge(),s={origin:window.location.origin,scheme:window.location.protocol.replace(":",""),hostname:window.location.hostname,port:window.location.port?Number.parseInt(window.location.port,10):null,userAgent:navigator.userAgent},o={type:"srp_hello",identity:this.username,browserProfileId:t,originMetadata:s};(r=this.ws)==null||r.send(JSON.stringify(o)),this.connectionState="srp_hello_sent",console.log("[SecureConnection] SRP hello sent")}async handleSrpResumeResponse(e,t,s){var o,r,i,a,c,p,d,u,w,v,S,I,E;try{const y=JSON.parse(e);if(Ye(y)){if(!this.storedSession){s(new Error("No stored session for resumption"));return}if(y.sessionId!==this.storedSession.sessionId){s(new Error("Resume challenge session mismatch")),(o=this.ws)==null||o.close();return}this.pendingResumeServerNonce=y.nonce;const C=this.generateResumeProof(this.storedSession.sessionKey,y.nonce,this.storedSession.sessionId),x={type:"srp_resume",identity:this.username,sessionId:this.storedSession.sessionId,proof:C};(r=this.ws)==null||r.send(JSON.stringify(x)),this.connectionState="srp_resume_proof_sent",console.log("[SecureConnection] SRP resume proof sent");return}if(Ge(y)){if(console.log("[SecureConnection] Session resumed successfully"),!this.storedSession){s(new Error("No stored session for resumption"));return}if(y.sessionId!==this.storedSession.sessionId){s(new Error("Resume response session mismatch")),(i=this.ws)==null||i.close();return}const C=Uint8Array.from(atob(this.storedSession.sessionKey),g=>g.charCodeAt(0));if(!y.transportNonce||y.transportNonce!==this.pendingResumeServerNonce){console.error("[SecureConnection] Resume server proof failed"),this.connectionState="failed",s(new Error("Resume server verification failed")),(a=this.ws)==null||a.close();return}const x=y.transportNonce;let f=U;if(y.serverProof){const g=this.verifyResumeServerProof({serverProof:y.serverProof,baseSessionKey:C,sessionId:this.storedSession.sessionId,transportNonce:x});if(g===null||!this.acceptAuthenticatedResumeProtocolVersion(g)){console.error("[SecureConnection] Resume server proof failed"),this.connectionState="failed",s(new Error("Resume server verification failed")),(c=this.ws)==null||c.close();return}f=g}else if(!this.acceptGraceProtocolVersion(U)){console.error("[SecureConnection] Resume would downgrade authenticated protocol"),this.connectionState="failed",s(new Error("Resume server verification failed")),(p=this.ws)==null||p.close();return}this.sessionKey=Z(C,x),this.sessionId=y.sessionId,this.connectionState="authenticated",this.pendingResumeClientNonce=null,this.pendingResumeServerNonce=null,this.storedSession={...this.storedSession,resumeProtocolVersion:f},this.resetSequenceState(),this.ws&&(this.ws.onmessage=g=>this.handleMessage(g.data)),(d=this.onSessionEstablished)==null||d.call(this,this.storedSession),this.sendCapabilities(),(u=this.connectionManager)==null||u.markConnected(),(w=this.onAuthenticated)==null||w.call(this),t();return}if(Xe(y)){if(!this.password){console.log(`[SecureConnection] Session resume failed: ${y.reason} (no password for fallback)`),this.connectionState="failed",s(new Error(`Session invalid: ${y.reason}`)),(v=this.ws)==null||v.close();return}console.log(`[SecureConnection] Session resume failed: ${y.reason}, falling back to SRP`),this.storedSession=null,await this.startFullSrpHandshake(s);return}if(V(y)){console.error("[SecureConnection] SRP error during resume:",y.message),this.connectionState="failed",s(new Error(`Authentication failed: ${y.message}`)),(S=this.ws)==null||S.close();return}console.warn("[SecureConnection] Unexpected message during resume:",y),this.connectionState="failed",s(new Error(`Unexpected message during resume: ${(y==null?void 0:y.type)??"unknown"}`)),(I=this.ws)==null||I.close()}catch(y){console.error("[SecureConnection] Resume response error:",y),this.connectionState="failed",s(y instanceof Error?y:new Error(String(y))),(E=this.ws)==null||E.close()}}async ensureConnected(){var e;if(!(((e=this.ws)==null?void 0:e.readyState)===R&&this.connectionState==="authenticated")){if(this.connectionPromise)return this.connectionPromise;this.connectionPromise=this.connectAndAuthenticate();try{await this.connectionPromise}finally{this.connectionPromise=null}}}handleSocketClose(e,t){var r,i;console.log("[SecureConnection] Closed:",e.code,e.reason);const s=this.connectionState==="authenticated";this.ws=null,this.sessionKey=null,this.srpSession=null,this.pendingResumeClientNonce=null,this.pendingResumeServerNonce=null,this.resetSequenceState();const o=new ve(e.code,e.reason);s?(this.connectionState="disconnected",(r=this.connectionManager)==null||r.handleClose(o),(i=this.onDisconnect)==null||i.call(this,o)):(this.connectionState="failed",t==null||t(o)),this.protocol.rejectAllPending(o),this.protocol.notifySubscriptionsClosed(o)}connectAndAuthenticate(){return new Promise((e,t)=>{if(this.isRelayConnection){if(this.relayUrl&&this.relayUsername&&this.storedSession){console.log("[SecureConnection] Relay connection dropped, attempting auto-reconnect"),this.reconnectThroughRelay().then(e).catch(u=>{console.error("[SecureConnection] Relay auto-reconnect failed:",u),t(new Q(u instanceof Error?u:new Error(String(u))))});return}console.log("[SecureConnection] Cannot reconnect relay connection (missing config or session)"),t(new Q(new Error("Missing relay config or stored session")));return}console.log("[SecureConnection] Connecting to",this.wsUrl),this.connectionState="connecting";const s=new WebSocket(this.wsUrl);s.binaryType="arraybuffer";let o=()=>{},r=()=>{};const i=new Promise((u,w)=>{o=u,r=w});let a=null;const c=()=>{a&&(clearTimeout(a),a=null)},p=()=>{c(),a=setTimeout(()=>{if(!(this.connectionState!=="srp_resume_init_sent"&&this.connectionState!=="srp_resume_proof_sent")){if(this.password){console.log("[SecureConnection] Session resume timed out, falling back to full SRP"),this.storedSession=null,this.startFullSrpHandshake(r).catch(u=>{this.connectionState="failed",r(u instanceof Error?u:new Error(String(u))),s.close()});return}this.connectionState="failed",r(new Error(L)),s.close()}},oe)};s.onopen=async()=>{console.log("[SecureConnection] WebSocket connected"),this.ws=s;try{if(this.storedSession){if(this.storedSessionSupportsCurrentResume()){console.log("[SecureConnection] Attempting session resumption");const u={type:"srp_resume_init",identity:this.username,sessionId:this.storedSession.sessionId,clientNonce:this.startResumeAttempt()};s.send(JSON.stringify(u)),this.connectionState="srp_resume_init_sent",console.log("[SecureConnection] SRP resume init sent"),p();return}if(!this.password){this.connectionState="failed",r(new Error(L)),s.close();return}console.log("[SecureConnection] Stored session uses an old resume protocol; starting full SRP"),this.storedSession=null}await this.startFullSrpHandshake(r)}catch(u){console.error("[SecureConnection] Connection error:",u),this.connectionState="failed",r(u instanceof Error?u:new Error(String(u))),s.close()}},s.onerror=u=>{console.error("[SecureConnection] Error:",u)},s.onclose=u=>{this.handleSocketClose(u,r)},s.onmessage=async u=>{this.connectionState==="srp_resume_init_sent"||this.connectionState==="srp_resume_proof_sent"?(p(),await this.handleSrpResumeResponse(u.data,o,r)):this.connectionState==="srp_hello_sent"?await this.handleSrpChallenge(u.data,o,r):this.connectionState==="srp_proof_sent"?await this.handleSrpVerify(u.data,o,r):this.connectionState==="authenticated"&&this.handleMessage(u.data)};const d=setTimeout(()=>{this.connectionState!=="authenticated"&&(s.close(),this.connectionState="failed",t(new Error("Connection timeout")))},3e4);i.then(()=>{c(),clearTimeout(d),e()}).catch(u=>{c(),clearTimeout(d),t(u)})})}static async connectRelaySocket(e,t,s=A,o=H){const r=await o({relayUrl:e,relayUsername:t,channel:s,onOpen:()=>{console.log(`[SecureConnection] Relay connected, sending client_connect (${s})`)}});return console.log("[SecureConnection] Relay paired with server"),r}async reconnectThroughRelay(){if(!this.relayUrl||!this.relayUsername||!this.storedSession)throw new Error("Missing relay config or stored session for reconnect");console.log("[SecureConnection] Connecting to relay:",this.relayUrl),this.connectionState="connecting";const e=await _.connectRelaySocket(this.relayUrl,this.relayUsername,this.relayChannel,this.relaySocketFactory??H);console.log("[SecureConnection] Resuming SRP session on new relay socket"),e.onmessage=null,e.onclose=null,e.onerror=null,this.ws=e,await this.resumeOnExistingSocket()}async handleSrpChallenge(e,t,s){var o,r,i,a;try{const c=JSON.parse(e);if(V(c)){console.error("[SecureConnection] SRP error:",c.message),this.connectionState="failed",s(new Error(`Authentication failed: ${c.message}`)),(o=this.ws)==null||o.close();return}if(!Ke(c)){console.warn("[SecureConnection] Unexpected message during SRP challenge:",c),this.connectionState="failed",s(new Error(`Unexpected message during SRP challenge: ${(c==null?void 0:c.type)??"unknown"}`)),(r=this.ws)==null||r.close();return}if(!this.srpSession){s(new Error("No SRP session"));return}console.log("[SecureConnection] Received SRP challenge");const{A:p,M1:d}=await this.srpSession.processChallenge(c.salt,c.B),u={type:"srp_proof",A:p,M1:d};(i=this.ws)==null||i.send(JSON.stringify(u)),this.connectionState="srp_proof_sent",console.log("[SecureConnection] SRP proof sent")}catch(c){console.error("[SecureConnection] SRP challenge error:",c),this.connectionState="failed",s(c instanceof Error?c:new Error(String(c))),(a=this.ws)==null||a.close()}}async handleSrpVerify(e,t,s){var o,r,i,a,c,p,d,u,w,v;try{const S=JSON.parse(e);if(V(S)){console.error("[SecureConnection] SRP error:",S.message),this.connectionState="failed",s(new Error(`Authentication failed: ${S.message}`)),(o=this.ws)==null||o.close();return}if(!Je(S)){console.warn("[SecureConnection] Unexpected message during SRP verify:",S),this.connectionState="failed",s(new Error(`Unexpected message during SRP verify: ${(S==null?void 0:S.type)??"unknown"}`)),(r=this.ws)==null||r.close();return}if(!this.srpSession){s(new Error("No SRP session"));return}if(console.log("[SecureConnection] Received SRP verify"),!await this.srpSession.verifyServer(S.M2)){console.error("[SecureConnection] Server verification failed"),this.connectionState="failed",s(new Error("Server verification failed")),(i=this.ws)==null||i.close();return}const E=this.srpSession.getSessionKey();if(!E){s(new Error("No session key"));return}const y=Te(E);if(!S.sessionId||!S.transportNonce){console.error("[SecureConnection] SRP verify missing required protocol metadata"),this.connectionState="failed",s(new Error("Server protocol verification failed")),(a=this.ws)==null||a.close();return}let C=U;if(S.serverInfoProof){const f=this.readSrpVerifyServerInfoProof({serverInfoProof:S.serverInfoProof,baseSessionKey:y,sessionId:S.sessionId,transportNonce:S.transportNonce});if(typeof f!="number"||!this.acceptAuthenticatedResumeProtocolVersion(f)){console.error("[SecureConnection] SRP server info proof failed"),this.connectionState="failed",s(new Error("Server protocol verification failed")),(c=this.ws)==null||c.close();return}C=f}else if(!this.acceptGraceProtocolVersion(U)){console.error("[SecureConnection] SRP verify would downgrade authenticated protocol"),this.connectionState="failed",s(new Error("Server protocol verification failed")),(p=this.ws)==null||p.close();return}this.sessionKey=Z(y,S.transportNonce),this.sessionId=S.sessionId,this.connectionState="authenticated",this.resetSequenceState();const x=btoa(Array.from(y).map(f=>String.fromCharCode(f)).join(""));this.storedSession={wsUrl:this.wsUrl,username:this.username,sessionId:this.sessionId,sessionKey:x,resumeProtocolVersion:C},(d=this.onSessionEstablished)==null||d.call(this,this.storedSession),this.sendCapabilities(),(u=this.connectionManager)==null||u.markConnected(),(w=this.onAuthenticated)==null||w.call(this),console.log("[SecureConnection] Authentication complete"),t()}catch(S){console.error("[SecureConnection] SRP verify error:",S),this.connectionState="failed",s(S instanceof Error?S:new Error(String(S))),(v=this.ws)==null||v.close()}}async handleMessage(e){var o,r,i,a;if(!this.sessionKey){console.warn("[SecureConnection] No session key for decryption");return}let t=null;if(Ve(e))try{const c=this.inboundChunks.acceptFrame(e);if(!c)return;if(t=await je(c,this.sessionKey),!t){console.warn("[SecureConnection] Failed to decrypt binary envelope");return}}catch(c){console.warn("[SecureConnection] Binary envelope error:",c),c instanceof $e&&((o=this.ws)==null||o.close(4005,"Invalid transport chunk sequence"));return}else if(typeof e=="string"){console.warn("[SecureConnection] Received text message after auth; binary encrypted envelope required"),(r=this.ws)==null||r.close(4005,"Binary encrypted message required");return}else{console.warn("[SecureConnection] Ignoring unknown message type");return}let s;try{const c=JSON.parse(t);if(Qe(c)){if(this.lastInboundSeq!==null&&c.seq<=this.lastInboundSeq){console.warn(`[SecureConnection] Replay/old sequence rejected: seq=${c.seq}, last=${this.lastInboundSeq}`),(i=this.ws)==null||i.close(4004,"Replay detected");return}this.lastInboundSeq=c.seq,s=c.msg}else{console.warn("[SecureConnection] Missing/invalid encrypted sequence"),(a=this.ws)==null||a.close(4004,"Invalid sequence");return}}catch{console.warn("[SecureConnection] Failed to parse decrypted message:",t);return}this.protocol.routeMessage(s)}send(e){if(!this.ws||this.ws.readyState!==R)throw new Error("WebSocket not connected");if(!this.sessionKey)throw new Error("Not authenticated");const t=JSON.stringify({seq:this.nextOutboundSeq,msg:e});this.nextOutboundSeq+=1;const s=Be(t,this.sessionKey);this.ws.send(s)}async openSpeechSocket(){if(!this.relayUrl||!this.relayUsername||!this.storedSession)throw new Error("Speech relay requires an active relayed session");const e=await _.connectRelaySocket(this.relayUrl,this.relayUsername,ee);let t=null;const s=await _.forResumeOnlyWithSocket(e,this.storedSession,{onDisconnect:o=>t==null?void 0:t.handleDisconnect(o)},{relayUrl:this.relayUrl,relayUsername:this.relayUsername,channel:ee});return t=new mt(s),t}sendSpeechControlMessage(e){this.send({type:"speech_control",message:e})}sendSpeechAudioFrame(e){if(!this.ws||this.ws.readyState!==R)throw new Error("WebSocket not connected");if(!this.sessionKey)throw new Error("Not authenticated");const t=z(ft(e),P.SPEECH_AUDIO,this.sessionKey);this.ws.send(t)}onSpeechEvent(e){return this.protocol.onSpeechEvent(e)}getSpeechSocketReadyState(){var e;return((e=this.ws)==null?void 0:e.readyState)??ht}getSpeechSocketBufferedAmount(){var e;return((e=this.ws)==null?void 0:e.bufferedAmount)??0}resetSequenceState(){this.nextOutboundSeq=0,this.lastInboundSeq=null,this.inboundChunks.reset()}sendCapabilities(){const e=[P.JSON,P.BINARY_UPLOAD,P.SPEECH_AUDIO,P.TRANSPORT_CHUNK];Le()&&e.push(P.COMPRESSED_JSON);const t={type:"client_capabilities",version:Ce(),capabilityBits:[],formats:e};console.log(`[SecureConnection] Sending capabilities: formats=${e.map(s=>`0x${s.toString(16).padStart(2,"0")}`).join(", ")}`);try{this.send(t)}catch(s){console.warn("[SecureConnection] Failed to send capabilities:",s)}}async fetch(e,t){return this.protocol.fetch(e,t)}async fetchBlob(e){return this.protocol.fetchBlob(e)}async fetchResponse(e,t){return this.protocol.fetchResponse(e,t)}subscribeConversation(e,t,s){return this.protocol.subscribeConversation(e,t,s)}subscribeSession(e,t,s,o){return this.protocol.subscribeSession(e,t,s,o)}subscribeActivity(e){return this.protocol.subscribeActivity(e)}subscribeGlossary(e,t){return this.protocol.subscribeGlossary(e,t)}subscribeWorktree(e,t,s){return this.protocol.subscribeWorktree(e,t,s)}subscribeSessionWatch(e,t,s){return this.protocol.subscribeSessionWatch(e,t,s)}async upload(e,t,s,o){return this.protocol.upload(e,t,s,o)}async uploadStagedAttachment(e,t){return this.protocol.uploadStagedAttachment(e,t)}sendPing(e){this.protocol.sendPing(e)}setOnPong(e){this.externalOnPong=e,this.updateProtocolPongHandler()}updateProtocolPongHandler(){const e=this.connectionManager,t=this.externalOnPong;this.protocol.setOnPong(e||t?s=>{e==null||e.receivePong(s),t==null||t(s)}:void 0)}sendMessage(e){this.send(e)}onDeviceMessage(e){return this.protocol.onDeviceMessage(e)}async waitForUploadBackpressure(){const e=this.ws;if(!(!e||e.readyState!==R)&&!(e.bufferedAmount<=at)){for(;e.readyState===R&&e.bufferedAmount>lt;)await pt(ut);if(e.readyState!==R)throw new Error("WebSocket not connected")}}close(){this.protocol.close(),this.sessionKey=null,this.srpSession=null,this.connectionState="disconnected",this.resetSequenceState(),this.ws&&(this.ws.close(),this.ws=null)}async forceReconnect(){if(this.forceReconnectPromise)return this.forceReconnectPromise;const e=this.performForceReconnect();this.forceReconnectPromise=e;try{await e}finally{this.forceReconnectPromise===e&&(this.forceReconnectPromise=null)}}async performForceReconnect(){var s;console.log(`[SecureConnection] Force reconnecting... wsState=${(s=this.ws)==null?void 0:s.readyState}, connState=${this.connectionState}, isRelay=${this.isRelayConnection}`);const e=this.connectionPromise;if(e)try{await e;return}catch{}this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws.close(),this.ws=null),this.resetSequenceState();const t=new be;this.protocol.rejectAllPending(t),this.protocol.notifySubscriptionsClosed(t),this.connectionState="disconnected",this.connectionPromise=null,await this.ensureConnected(),console.log(`[SecureConnection] Force reconnect complete, connState=${this.connectionState}`)}isAuthenticated(){return this.connectionState==="authenticated"&&this.sessionKey!==null}static async connectWithExistingSocket(e,t,s,o={},r){const i=new _("",t,s,o);return i.ws=e,i.isRelayConnection=!0,r&&(i.relayUrl=r.relayUrl,i.relayUsername=r.relayUsername,i.relayChannel=r.channel??A,i.relaySocketFactory=r.openSocket??null),e.binaryType="arraybuffer",await i.authenticateOnExistingSocket(),i}authenticateOnExistingSocket(){return new Promise((e,t)=>{if(!this.ws||this.ws.readyState!==R){t(new Error("WebSocket is not open"));return}console.log("[SecureConnection] Authenticating on existing socket"),this.connectionState="connecting";let s=()=>{},o=()=>{};const r=new Promise((c,p)=>{s=c,o=p}),i=this.ws;i.onerror=c=>{console.error("[SecureConnection] Error:",c)},i.onclose=c=>{this.handleSocketClose(c,o)},i.onmessage=async c=>{this.connectionState==="srp_hello_sent"?await this.handleSrpChallenge(c.data,s,o):this.connectionState==="srp_proof_sent"?await this.handleSrpVerify(c.data,s,o):this.connectionState==="authenticated"&&this.handleMessage(c.data)},this.startFullSrpHandshake(o).catch(c=>{console.error("[SecureConnection] SRP handshake error:",c),this.connectionState="failed",o(c instanceof Error?c:new Error(String(c))),i.close()});const a=setTimeout(()=>{this.connectionState!=="authenticated"&&(i.close(),this.connectionState="failed",t(new Error("Authentication timeout")))},3e4);r.then(()=>{clearTimeout(a),e()}).catch(c=>{clearTimeout(a),t(c)})})}}class mt{constructor(e){h(this,"onopen",null);h(this,"onmessage",null);h(this,"onerror",null);h(this,"onclose",null);h(this,"unsubscribeSpeech");h(this,"closed",!1);this.connection=e,this.unsubscribeSpeech=e.onSpeechEvent(t=>{var s;(s=this.onmessage)==null||s.call(this,{data:JSON.stringify(t)})})}get readyState(){return this.connection.getSpeechSocketReadyState()}get bufferedAmount(){return this.connection.getSpeechSocketBufferedAmount()}send(e){var t;if(this.closed)throw new Error("Speech socket is closed");try{if(typeof e=="string"){this.connection.sendSpeechControlMessage(JSON.parse(e));return}this.connection.sendSpeechAudioFrame(e)}catch(s){throw(t=this.onerror)==null||t.call(this,s),s}}close(){var e;this.closed||(this.closed=!0,this.unsubscribeSpeech(),this.connection.close(),(e=this.onclose)==null||e.call(this))}handleDisconnect(e){var t,s;this.closed||(this.closed=!0,this.unsubscribeSpeech(),(t=this.onerror)==null||t.call(this,e),(s=this.onclose)==null||s.call(this))}}function re(n,e){const t=e?`/projects/${encodeURIComponent(e.projectId)}/sessions/${encodeURIComponent(e.id)}`:"";if(n.mode==="local")return t||"/projects";if(n.mode==="relay")return n.relayUsername?`${qe(n.relayUsername)}${t}`:null;if(!n.wsUrl)return null;try{const s=new URL(n.wsUrl);return!["ws:","wss:"].includes(s.protocol)||s.username||s.password||!/\/api\/ws\/?$/.test(s.pathname)?null:(s.protocol=s.protocol==="wss:"?"https:":"http:",s.pathname=`${s.pathname.replace(/\/api\/ws\/?$/,"")}${t||"/"}`,s.search="",s.hash="",s.toString())}catch{return null}}function yt(n){return!le(n,ue.experimentalConversation)||typeof n.experimentalSimpleClientApiRevision!="string"?"update-required":n.experimentalSimpleClientApiRevision===he?"available":"revision-mismatch"}class St{constructor(e,t,s){h(this,"sequence",-1);h(this,"closed",!1);if(this.sourceId=e,this.subscriptionId=t,this.sessionId=s,K.parse(t),K.parse(s),!e)throw new Error("Conversation requires a source binding")}close(){this.closed=!0}accept(e,t){if(this.closed||e!==this.sourceId)return null;const s=xe(t);if(s.subscriptionId!==this.subscriptionId||s.sequence<=this.sequence)return null;if(s.view.kind==="conversation"&&s.view.sessionId!==this.sessionId)throw new Error("Conversation session mismatch");return this.sequence=s.sequence,s}}function wt(n,e){Ee.parse(n),K.parse(e);const t=new URLSearchParams({apiRevision:he,subscriptionId:e,sessionId:n.sessionId,maxMessages:String(n.maxMessages)});return n.anchorMessageId!==null&&t.set("anchorMessageId",n.anchorMessageId),`/api/experimental/conversation?${t}`}class T extends Error{constructor(e){super(e),this.name="MultiHostSignInRequiredError"}}function ie(n){if(n instanceof T)return!0;const t=(n instanceof Error?n.message:String(n)).toLowerCase();return t.includes("authentication")||t.includes("invalid_identity")||t.includes("resume_incompatible")||t.includes("session invalid")||t.includes("session resume")||t.includes("unauthorized")}async function gt(n,e,t,s){e.throwIfAborted();const o=n.session;if(!o)throw new T("A saved session is required");const r={onDisconnect:s,onSessionEstablished:p=>{Ie(n.id,p)}};if(n.mode==="direct"){if(!n.wsUrl)throw new T("The saved direct host has no WebSocket URL");const p=_.forResumeOnly(o,r),d=()=>p.close();e.addEventListener("abort",d,{once:!0});try{return await p.fetch("/auth/status"),e.throwIfAborted(),p}catch(u){throw p.close(),u}finally{e.removeEventListener("abort",d)}}if(!n.relayUrl||!n.relayUsername)throw new T("The saved relay host is incomplete");const a=await(t??H)({relayUrl:n.relayUrl,relayUsername:n.relayUsername,signal:e});e.aborted&&(a.close(),e.throwIfAborted());const c=()=>a.close();e.addEventListener("abort",c,{once:!0});try{const p=await _.forResumeOnlyWithSocket(a,o,r,{relayUrl:n.relayUrl,relayUsername:n.relayUsername,openSocket:t});return await p.fetch("/auth/status"),e.throwIfAborted(),p}catch(p){throw a.close(),p}finally{e.removeEventListener("abort",c)}}const vt=async(n,e)=>{if(n.mode!=="local")throw new Error("Expected a local preview source");e.throwIfAborted();const t=new AbortController,s=new Set,o=()=>{t.abort();for(const r of s)r.close();s.clear(),e.removeEventListener("abort",o)};return e.addEventListener("abort",o,{once:!0}),{close:o,async fetch(r,i){try{return await Re(r,{...i,signal:i!=null&&i.signal?AbortSignal.any([t.signal,i.signal]):t.signal},{onLoginRequired:()=>{}})}catch(a){throw(a==null?void 0:a.status)===401?new T("Authentication required"):a}},subscribeConversation(r,i,a){t.signal.throwIfAborted();const c=wt(i,r).replace("/conversation?","/conversation/subscribe?"),p=new EventSource(c);s.add(p);let d=!1;const u=()=>{d=!0,p.close(),s.delete(p)};return p.onopen=()=>{var w;!d&&!t.signal.aborted&&((w=a.onOpen)==null||w.call(a))},p.addEventListener("snapshot",w=>{var v;if(!(d||t.signal.aborted))try{a.onEvent("snapshot",void 0,JSON.parse(w.data))}catch(S){u(),(v=a.onError)==null||v.call(a,S instanceof Error?S:new Error("Invalid snapshot"))}}),p.onerror=()=>{var w;d||t.signal.aborted||(u(),(w=a.onError)==null||w.call(a,new Error("Conversation stream disconnected")))},{close:u}}}},bt=2e3,Ct=5e3,xt=3e4,Et=2*1024*1024,Rt=8*1024*1024,_t=1024*1024,It=10,Nt=5,ce=0,F=1,ae=2,q=3;class Y extends Error{constructor(e){super(e),this.reason=e,this.name="RelayMuxCircuitOpenError"}}function j(){return new DOMException("Relay connection aborted","AbortError")}function Pt(n){return typeof n=="string"?{bytes:new TextEncoder().encode(n),isBinary:!1}:n instanceof ArrayBuffer?{bytes:new Uint8Array(n),isBinary:!0}:{bytes:new Uint8Array(n.buffer,n.byteOffset,n.byteLength),isBinary:!0}}class Ot{constructor(e,t){h(this,"binaryType","arraybuffer");h(this,"onclose",null);h(this,"onerror",null);h(this,"onmessage",null);h(this,"state",ce);this.physical=e,this.circuitId=t}get bufferedAmount(){return this.physical.bufferedAmount}get readyState(){return this.state}markOpen(){this.state===ce&&(this.state=F)}receive(e,t){var o;if(this.state!==F)return;const s=t?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):new TextDecoder().decode(e);(o=this.onmessage)==null||o.call(this,new MessageEvent("message",{data:s}))}remoteClose(e,t){var s;this.state!==q&&(this.state=q,(s=this.onclose)==null||s.call(this,new CloseEvent("close",{code:e,reason:t,wasClean:e===1e3})))}fail(e){var t;this.state!==q&&((t=this.onerror)==null||t.call(this,new Event("error")),this.physical.closeCircuit(this.circuitId,e))}send(e){if(this.state!==F)throw new DOMException("WebSocket is not open","InvalidStateError");const t=Pt(e);this.physical.sendCircuitData(this.circuitId,t.bytes,t.isBinary)}close(e=1e3,t=""){this.state===ae||this.state===q||(this.state=ae,this.physical.requestCircuitClose(this.circuitId,e,t))}}class X{constructor(e,t){h(this,"circuits",new Map);h(this,"pending",new Map);h(this,"queues",new Map);h(this,"queuedBytesByCircuit",new Map);h(this,"queuedBytes",0);h(this,"circuitOrder",[]);h(this,"drainCursor",0);h(this,"drainScheduled",!1);h(this,"drainTimer",null);h(this,"nextCircuitId",1);h(this,"maxFrameBytes",0);h(this,"maxCircuits",0);h(this,"closed",!1);this.ws=e,this.onPhysicalClose=t}static connect(e,t,s){return new Promise((o,r)=>{const i=t(e);i.binaryType="arraybuffer";const a=new X(i,s);let c=!1;const p=setTimeout(()=>{c||(c=!0,i.close(),r(new Error("Relay mux ready timeout")))},Ct);i.onmessage=d=>{if(!c&&typeof d.data=="string")try{const u=JSON.parse(d.data);if(te(u)){c=!0,clearTimeout(p),a.maxCircuits=u.maxCircuits,a.maxFrameBytes=u.maxFrameBytes,o(a);return}}catch{}a.handleMessage(d)},i.onerror=()=>{c||(c=!0,clearTimeout(p),r(new Error("Failed to connect to relay mux")))},i.onclose=d=>{clearTimeout(p),a.handleClose(d),c||(c=!0,r(new Error("Relay mux closed before ready")))}})}get bufferedAmount(){return this.ws.bufferedAmount}get isOpen(){return!this.closed&&this.ws.readyState===F}async openCircuit(e,t,s){if(!this.isOpen)throw new Error("Relay mux is not connected");if(this.circuits.size+this.pending.size>=this.maxCircuits)throw new Y("circuit_limit");const o=this.allocateCircuitId(),r=new Ot(this,o);return new Promise((i,a)=>{const c=()=>{this.pending.delete(o),clearTimeout(p),this.sendControl({type:"mux_close",circuitId:o}),r.remoteClose(1e3,"Relay connection aborted"),a(j())},p=setTimeout(()=>{this.pending.delete(o),s==null||s.removeEventListener("abort",c),this.sendControl({type:"mux_close",circuitId:o}),r.remoteClose(1006,"Waiting for relay circuit timed out"),a(new Error("Waiting for relay circuit timed out"))},xt),d={socket:r,timeout:p,resolve:u=>{s==null||s.removeEventListener("abort",c),i(u)},reject:u=>{s==null||s.removeEventListener("abort",c),a(u)}};if(this.pending.set(o,d),s!=null&&s.aborted){c();return}s==null||s.addEventListener("abort",c,{once:!0}),this.sendControl({type:"mux_open",circuitId:o,username:e,channel:t})})}sendCircuitData(e,t,s){const o=this.circuits.get(e);if(!o||!this.isOpen)throw new DOMException("WebSocket is not open","InvalidStateError");if(t.byteLength>this.maxFrameBytes)throw o.fail("Relay mux frame is too large"),new DOMException("Relay mux frame is too large","QuotaExceededError");const r=st(e,t,s),i=this.queuedBytesByCircuit.get(e)??0;if(i+r.byteLength>Et||this.queuedBytes+r.byteLength>Rt)throw o.fail("Relay mux queue overflow"),new DOMException("Relay mux queue overflow","QuotaExceededError");let a=this.queues.get(e);a||(a=[],this.queues.set(e,a),this.circuitOrder.push(e)),a.push({bytes:r,circuitId:e}),this.queuedBytesByCircuit.set(e,i+r.byteLength),this.queuedBytes+=r.byteLength,this.scheduleDrain(!1)}requestCircuitClose(e,t,s){if(this.circuits.has(e)){if(!this.isOpen){this.removeCircuit(e,1006,"Relay mux disconnected");return}this.sendControl({type:"mux_close",circuitId:e})}}closeCircuit(e,t){this.circuits.has(e)&&(this.isOpen&&this.sendControl({type:"mux_close",circuitId:e}),this.removeCircuit(e,1008,t))}close(){this.closed||this.ws.close(1e3,"Mux pool disposed")}handleMessage(e){var t;if(typeof e.data=="string"){let s;try{s=JSON.parse(e.data)}catch{this.ws.close(1008,"Invalid relay mux control");return}if(Ze(s)){const o=this.pending.get(s.circuitId);if(!o){this.sendControl({type:"mux_close",circuitId:s.circuitId});return}this.pending.delete(s.circuitId),clearTimeout(o.timeout),o.socket.markOpen(),this.circuits.set(s.circuitId,o.socket),o.resolve(o.socket);return}if(et(s)){const o=this.pending.get(s.circuitId);if(!o)return;this.pending.delete(s.circuitId),clearTimeout(o.timeout),o.socket.remoteClose(1008,s.reason),o.reject(new Y(s.reason));return}if(tt(s)){this.removeCircuit(s.circuitId,1e3,s.reason);return}if(te(s))return;this.ws.close(1008,"Unexpected relay mux control");return}if(!(e.data instanceof ArrayBuffer)){this.ws.close(1008,"Invalid relay mux data");return}try{const s=nt(e.data);if(s.payload.byteLength>this.maxFrameBytes){this.closeCircuit(s.circuitId,"Relay mux frame is too large");return}(t=this.circuits.get(s.circuitId))==null||t.receive(s.payload,s.isBinary)}catch{this.ws.close(1008,"Invalid relay mux data")}}handleClose(e){if(!this.closed){this.closed=!0,this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null);for(const t of this.pending.values())clearTimeout(t.timeout),t.socket.remoteClose(e.code,e.reason),t.reject(new Error(e.reason||"Relay mux disconnected"));this.pending.clear();for(const t of this.circuits.keys())this.removeCircuit(t,e.code||1006,e.reason||"Relay mux disconnected");this.onPhysicalClose()}}removeCircuit(e,t,s){const o=this.circuits.get(e);if(!o)return;this.circuits.delete(e);const r=this.queuedBytesByCircuit.get(e)??0;this.queuedBytes-=r,this.queuedBytesByCircuit.delete(e),this.queues.delete(e),this.circuitOrder=this.circuitOrder.filter(i=>i!==e),o.remoteClose(t,s)}sendControl(e){if(!this.isOpen)throw new Error("Relay mux is not connected");this.ws.send(JSON.stringify(e))}allocateCircuitId(){for(let e=0;e<4294967295;e+=1){const t=this.nextCircuitId;if(this.nextCircuitId=this.nextCircuitId===4294967295?1:this.nextCircuitId+1,!this.pending.has(t)&&!this.circuits.has(t))return t}throw new Error("Relay mux circuit ids exhausted")}scheduleDrain(e){if(!(this.closed||this.drainScheduled||this.drainTimer)){if(e){this.drainTimer=setTimeout(()=>{this.drainTimer=null,this.drain()},It);return}this.drainScheduled=!0,queueMicrotask(()=>{this.drainScheduled=!1,this.drain()})}}drain(){if(this.isOpen){for(;this.queuedBytes>0&&this.ws.bufferedAmount<=_t;){const e=this.nextQueuedFrame();if(!e)break;this.ws.send(e.bytes)}this.queuedBytes>0&&this.scheduleDrain(!0)}}nextQueuedFrame(){if(this.circuitOrder.length===0)return null;for(let e=0;e<this.circuitOrder.length;e+=1){const t=(this.drainCursor+e)%this.circuitOrder.length,s=this.circuitOrder[t];if(s===void 0)continue;const o=this.queues.get(s);if(!o)continue;const r=o.shift();if(!r)continue;this.drainCursor=(t+1)%this.circuitOrder.length;const i=(this.queuedBytesByCircuit.get(s)??r.bytes.byteLength)-r.bytes.byteLength;return this.queuedBytesByCircuit.set(s,i),this.queuedBytes-=r.bytes.byteLength,o.length===0&&(this.queues.delete(s),this.circuitOrder=this.circuitOrder.filter(a=>a!==s)),r}return null}}class At{constructor(e,t){h(this,"discovery",null);h(this,"physical",null);h(this,"physicalOpening",null);h(this,"degraded",!1);h(this,"disposed",!1);h(this,"lifetime",new AbortController);this.endpoints=e,this.options=t}async open(e){if(this.disposed)throw j();const t=this.degraded?!1:await this.discover();if(this.disposed)throw j();if(this.degraded||!t)return this.options.openLegacySocket(e);let s;try{s=await this.ensurePhysical()}catch(o){if(this.disposed||o instanceof DOMException&&o.name==="AbortError")throw o;return this.degraded=!0,this.options.openLegacySocket(e)}try{return await s.openCircuit(e.relayUsername,e.channel??A,e.signal)}catch(o){if(o instanceof Y||o instanceof DOMException&&o.name==="AbortError")throw o;return this.degraded=!0,this.options.openLegacySocket(e)}}dispose(){var e;this.disposed||(this.disposed=!0,this.lifetime.abort(),(e=this.physical)==null||e.close(),this.physical=null)}discover(){return this.discovery?this.discovery:(this.discovery=this.runDiscovery(),this.discovery)}async runDiscovery(){const e=new AbortController,t=setTimeout(()=>e.abort(),bt),s=()=>e.abort();this.lifetime.signal.addEventListener("abort",s,{once:!0});try{const o=await this.options.fetch(this.endpoints.healthUrl,{signal:e.signal});if(!o.ok)return!1;const r=await o.json();return Array.isArray(r.relayCapabilities)&&r.relayCapabilities.includes(ze)}catch{return!1}finally{clearTimeout(t),this.lifetime.signal.removeEventListener("abort",s)}}ensurePhysical(){var o;if((o=this.physical)!=null&&o.isOpen)return Promise.resolve(this.physical);if(this.physicalOpening)return this.physicalOpening;let e=null;const s=X.connect(this.endpoints.muxUrl,this.options.createWebSocket,()=>{this.physical===e&&(this.physical=null)}).then(r=>{if(e=r,this.disposed)throw r.close(),j();return this.physical=r,r}).finally(()=>{this.physicalOpening===s&&(this.physicalOpening=null)});return this.physicalOpening=s,s}}class kt{constructor(e,t={}){h(this,"eligibleHostIds",new Set);h(this,"groups",new Map);h(this,"endpointsByHostId",new Map);h(this,"options");h(this,"disposed",!1);var r;const s=t.fetch??fetch;this.options={createWebSocket:t.createWebSocket??(i=>new WebSocket(i)),fetch:(i,a)=>s(i,a),openLegacySocket:t.openLegacySocket??H};const o=new Map;for(const i of e){if(i.mode!=="relay"||!i.session||!i.relayUrl||!i.relayUsername)continue;const a=We(i.relayUrl);if(!a)continue;let c=o.get(a.key);c||(c=[],o.set(a.key,c)),c.push({endpoints:a,host:i})}for(const[i,a]of o){if(a.length<2)continue;const c=a.slice(0,Nt),p=(r=c[0])==null?void 0:r.endpoints;if(p){this.groups.set(i,new At(p,this.options));for(const{host:d,endpoints:u}of c)this.eligibleHostIds.add(d.id),this.endpointsByHostId.set(d.id,u)}}}createSocketFactory(e){return t=>this.open(e,t)}dispose(){if(!this.disposed){this.disposed=!0;for(const e of this.groups.values())e.dispose();this.groups.clear()}}open(e,t){if(this.disposed)return Promise.reject(j());if(!this.eligibleHostIds.has(e.id))return this.options.openLegacySocket(t);const s=this.endpointsByHostId.get(e.id),o=s?this.groups.get(s.key):void 0;return(o==null?void 0:o.open(t))??this.options.openLegacySocket(t)}}class Ut{constructor(e,t,s=null){h(this,"state");h(this,"listeners",new Set);h(this,"owners",new Map);h(this,"stream");h(this,"binding");h(this,"disposed",!1);h(this,"pool");h(this,"connect");h(this,"getSnapshot",()=>this.state);h(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));this.state={sources:e.map(o=>({host:o,status:"excluded",sessions:[],hasMore:!1,updatedAt:null,issueCoverage:"unsupported"})),selection:s,view:null,conversationStatus:"empty",maxMessages:20,anchorMessageId:null},t||(this.pool=new kt(e.filter(o=>o.mode!=="local"))),this.connect=t??((o,r,i)=>{var a;if(o.mode==="local")throw new Error("Local source requires a local connector");return gt(o,r,o.mode==="relay"?(a=this.pool)==null?void 0:a.createSocketFactory(o):void 0,i)})}publish(e={}){if(!this.disposed){this.state={...this.state,...e};for(const t of this.listeners)t()}}source(e,t){this.publish({sources:this.state.sources.map(s=>s.host.id===e?{...s,...t}:s)})}closeStream(){var t;(t=this.binding)==null||t.close(),this.binding=void 0;const e=this.stream;this.stream=void 0,e==null||e.close()}stopSource(e){var s,o;const t=this.owners.get(e);this.owners.delete(e),t==null||t.abort.abort(),(s=t==null?void 0:t.connection)==null||s.close(),((o=this.state.selection)==null?void 0:o.sourceId)===e&&this.closeStream()}include(e,t){var a,c;if(this.disposed)return;if(this.stopSource(e),!t){this.source(e,{status:"excluded",sessions:[],updatedAt:null}),((a=this.state.selection)==null?void 0:a.sourceId)===e&&this.publish({selection:null,view:null,conversationStatus:"empty"});return}const s=this.state.sources.find(p=>p.host.id===e);if(!s)return;const o={abort:new AbortController};this.owners.set(e,o);const r=()=>!this.disposed&&this.owners.get(e)===o&&!o.abort.signal.aborted,i=p=>{var d;r()&&(this.stopSource(e),this.source(e,{status:ie(p)?"sign-in-required":"offline"}),((d=this.state.selection)==null?void 0:d.sourceId)===e&&this.publish({conversationStatus:"offline"}))};this.source(e,{status:"connecting",issueCoverage:"unsupported"}),((c=this.state.selection)==null?void 0:c.sourceId)===e&&this.publish({conversationStatus:"loading"}),(async()=>{var p,d,u;try{const w=await this.connect(s.host,o.abort.signal,i);if(!r()){w.close();return}o.connection=w;const v=await w.fetch("/version");if(!r())return;const S=yt(v);if(S!=="available"){this.stopSource(e),this.source(e,{status:S}),((p=this.state.selection)==null?void 0:p.sourceId)===e&&this.publish({conversationStatus:"offline"});return}const I=await w.fetch("/sessions?limit=50");if(!r())return;const E=I.sessions.slice(0,50).map(y=>({id:y.id,title:y.customTitle||y.title||y.fullTitle||y.id,projectId:y.projectId,projectName:y.projectName,updatedAt:y.updatedAt,issues:[]}));if(this.source(e,{status:"ready",sessions:E,hasMore:I.hasMore,updatedAt:Date.now()}),((d=this.state.selection)==null?void 0:d.sourceId)===e&&this.openConversation(),le(v,ue.issueSessionAssociations))try{const y=await w.fetch("/issues/settings");if(!r())return;if(!y.settings.enabled){this.source(e,{issueCoverage:"disabled"});return}this.source(e,{issueCoverage:"partial"});let C=0,x=!1;const f=new Map;await Promise.all(Array.from({length:3},async()=>{for(;r()&&!x;){const g=E[C++];if(!g)return;const b=await w.fetch(`/issues?sessionId=${encodeURIComponent(g.id)}&limit=10`).catch(N=>{throw x=!0,N});if(!r())return;f.set(g.id,b.items.map(N=>({id:N.id,key:N.key})))}})),r()&&this.source(e,{sessions:E.map(g=>({...g,issues:f.get(g.id)??[]}))})}catch{r()&&this.source(e,{issueCoverage:"unavailable"})}}catch(w){if(!r())return;this.stopSource(e),this.source(e,{status:ie(w)?"sign-in-required":"offline"}),((u=this.state.selection)==null?void 0:u.sourceId)===e&&this.publish({conversationStatus:"offline"})}})()}select(e,t){this.closeStream(),this.publish({selection:{sourceId:e,sessionId:t},view:null,maxMessages:20,anchorMessageId:null}),this.openConversation()}more(){var t;const e=this.state.view;this.publish({maxMessages:Math.min(100,this.state.maxMessages+20),anchorMessageId:(e==null?void 0:e.kind)==="conversation"?((t=e.messages.at(-1))==null?void 0:t.id)??null:null}),this.openConversation()}latest(){this.publish({anchorMessageId:null}),this.openConversation()}openConversation(){var p;this.closeStream();const e=this.state.selection;if(!e)return;const t=(p=this.owners.get(e.sourceId))==null?void 0:p.connection,s=this.state.sources.find(d=>d.host.id===e.sourceId);if(!t||(s==null?void 0:s.status)!=="ready"){this.publish({conversationStatus:"offline"});return}const o=new St(e.sourceId,_e(),e.sessionId);this.binding=o;const r=()=>this.binding===o&&!this.disposed;this.publish({conversationStatus:"loading"});const i={sessionId:e.sessionId,maxMessages:this.state.maxMessages,anchorMessageId:this.state.anchorMessageId},a=()=>{r()&&(this.closeStream(),this.publish({conversationStatus:"offline"}))},c={onEvent:(d,u,w)=>{if(r()){if(d==="closed"){a();return}if(d==="snapshot")try{const v=o.accept(e.sourceId,JSON.stringify(w));v&&this.publish({view:v.view,conversationStatus:"ready"})}catch{this.closeStream(),this.publish({conversationStatus:"invalid"})}}},onClose:a,onError:a};try{const d=t.subscribeConversation(o.subscriptionId,i,c);r()?this.stream=d:d.close()}catch{a()}}dispose(){var e;if(!this.disposed){this.disposed=!0,this.closeStream();for(const t of[...this.owners.keys()])this.stopSource(t);(e=this.pool)==null||e.dispose(),this.listeners.clear()}}}function Mt(n,e){if(e==="none"){const s=n.filter(r=>r.status!=="excluded").flatMap(r=>r.sessions.map(i=>({source:r,session:i}))),o=r=>{const i=Date.parse(r.session.updatedAt);return Number.isFinite(i)?i:Number.NEGATIVE_INFINITY};return s.sort((r,i)=>o(i)-o(r)||0),s.length?[{id:"none",label:null,sourceName:null,rows:s}]:[]}const t=new Map;for(const s of n)if(s.status!=="excluded")for(const o of s.sessions){const r=e==="issue"&&o.issues.length>0?o.issues.map(i=>({id:JSON.stringify(["issue",i.id]),label:i.key,sourceName:null})):[{id:JSON.stringify([e,s.host.id,e==="project"?o.projectId:null]),label:e==="machine"?s.host.displayName:e==="project"?o.projectName:null,sourceName:e==="machine"?null:s.host.displayName}];for(const i of r){const a=t.get(i.id)??{...i,rows:[]};a.rows.push({source:s,session:o}),t.set(i.id,a)}}return[...t.values()]}const Tt="_page_x41bu_1",jt="_topbar_x41bu_20",Bt="_muted_x41bu_32",Lt="_control_x41bu_37",qt="_session_x41bu_56",Ft="_workspace_x41bu_59",Dt="_sidebar_x41bu_65",Ht="_sources_x41bu_71",Vt="_sectionHeading_x41bu_75",$t="_source_x41bu_71",Wt="_sourceDetail_x41bu_106",Kt="_localSource_x41bu_123",Jt="_groupControl_x41bu_132",Yt="_groups_x41bu_150",Gt="_main_x41bu_200",Xt="_empty_x41bu_206",Qt="_conversationHeader_x41bu_219",zt="_actions_x41bu_233",Zt="_badge_x41bu_244",es="_transcript_x41bu_249",ts="_history_x41bu_256",ss="_message_x41bu_268",ns="_prose_x41bu_284",os="_activity_x41bu_288",rs="_failure_x41bu_298",is="_notice_x41bu_306",cs="_mobileToggle_x41bu_317",m={page:Tt,topbar:jt,muted:Bt,control:Lt,session:qt,workspace:Ft,sidebar:Dt,sources:Ht,sectionHeading:Vt,source:$t,sourceDetail:Wt,localSource:Kt,groupControl:Jt,groups:Yt,main:Gt,empty:Xt,conversationHeader:Qt,actions:zt,badge:Zt,transcript:es,history:ts,message:ss,prose:ns,activity:os,failure:rs,notice:is,mobileToggle:cs},as={excluded:"preview.status.excluded",connecting:"preview.status.connecting",ready:"preview.status.ready",offline:"preview.status.offline","sign-in-required":"preview.status.signIn","update-required":"preview.status.update","revision-mismatch":"preview.status.revision"},me="yep-experimental-preview-sources";function ls({content:n}){const{t:e}=pe();switch(n.kind){case"text":return l.jsx("div",{className:m.prose,children:n.text});case"activity":return l.jsxs("div",{className:m.activity,children:[l.jsx("p",{children:n.summary}),l.jsx("small",{children:e(n.toolCount===1?"preview.toolOne":"preview.tools",{count:n.toolCount,failed:n.failedToolCount})})]});case"failure":return l.jsxs("div",{className:m.failure,children:[l.jsx("strong",{children:n.toolName}),l.jsx("p",{children:n.message})]});case"media":return l.jsx("div",{className:m.activity,children:e("preview.media",{description:n.description||e("preview.attachment")})});default:return l.jsx("p",{className:m.notice,children:e("preview.unknown")})}}function us({controller:n,local:e}){var y,C,x;const{t}=pe(),s=O.useSyncExternalStore(n.subscribe,n.getSnapshot),[o,r]=de(),[i,a]=O.useState(e?"none":"machine"),[c,p]=O.useState(!s.selection),d=O.useMemo(()=>Mt(s.sources,i),[s.sources,i]),u=s.sources.find(f=>{var g;return f.host.id===((g=s.selection)==null?void 0:g.sourceId)}),w=u==null?void 0:u.sessions.find(f=>{var g;return f.id===((g=s.selection)==null?void 0:g.sessionId)}),v=((y=s.view)==null?void 0:y.kind)==="conversation"?s.view:null,S=s.conversationStatus==="loading",I=u?re(u.host,w):null;function E(f,g){n.include(f,g);try{localStorage.setItem(me,JSON.stringify(n.getSnapshot().sources.filter(b=>b.status!=="excluded").map(b=>b.host.id)))}catch{}n.getSnapshot().selection||r({},{replace:!0})}return l.jsxs("div",{className:m.page,children:[l.jsxs("header",{className:m.topbar,children:[l.jsxs("div",{children:[l.jsx("h1",{children:t("preview.title")}),l.jsx("span",{className:m.muted,children:t("preview.subtitle")})]}),l.jsx(k,{className:m.control,to:e?"/projects":"/login",children:t("preview.fullApp")})]}),l.jsx("button",{type:"button",className:`${m.control} ${m.mobileToggle}`,"aria-expanded":c,"aria-controls":"preview-sidebar",onClick:()=>p(!c),children:t(c?"preview.hideSessions":e?"preview.sessions":"preview.showSessions")}),l.jsxs("div",{className:m.workspace,children:[l.jsxs("aside",{id:"preview-sidebar",className:m.sidebar,"data-open":c,"aria-label":t("preview.sessions"),children:[l.jsxs("section",{className:m.sources,children:[l.jsxs("div",{className:m.sectionHeading,children:[l.jsx("h2",{children:t(e?"preview.localServer":"preview.machines")}),!e&&l.jsx(k,{to:"/login",children:t("preview.addMachine")})]}),s.sources.length===0&&l.jsx("p",{className:m.muted,children:t("preview.noMachines")}),s.sources.map(f=>l.jsxs("div",{className:`${m.source} ${e?m.localSource:""}`,"data-testid":"preview-source","data-source-name":f.host.displayName,"data-source-status":f.status,children:[e?l.jsx("strong",{children:f.host.displayName}):l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:f.status!=="excluded",onChange:g=>E(f.host.id,g.target.checked)}),l.jsx("span",{children:f.host.displayName})]}),l.jsxs("div",{className:m.sourceDetail,children:[l.jsx("span",{children:t(as[f.status])}),f.status!=="excluded"&&f.status!=="connecting"&&l.jsx("button",{type:"button",className:m.control,onClick:()=>n.include(f.host.id,!0),children:t("preview.refresh")})]}),f.status==="sign-in-required"&&l.jsx(k,{to:f.host.mode==="local"?"/login":f.host.mode==="relay"?`/login/relay?u=${encodeURIComponent(f.host.relayUsername??"")}&r=${encodeURIComponent(f.host.relayUrl??"")}`:"/login/direct",state:e?{from:`/-/preview${o.size?`?${o}`:""}`}:void 0,children:t("preview.signIn")}),["offline","update-required","revision-mismatch"].includes(f.status)&&l.jsx(k,{className:m.control,to:re(f.host)??(f.host.mode==="relay"?"/login/relay":"/login/direct"),children:t("preview.fullApp")}),i==="issue"&&f.status==="ready"&&l.jsx("p",{className:m.muted,children:t(`preview.issues.${f.issueCoverage}`)}),f.hasMore&&f.status==="ready"&&l.jsx("small",{className:m.muted,children:t("preview.catalogLimit")})]},f.host.id))]}),l.jsxs("label",{className:m.groupControl,children:[t("preview.groupBy"),l.jsxs("select",{value:i,onChange:f=>a(f.target.value),children:[l.jsx("option",{value:"none",children:t("preview.byNone")}),!e&&l.jsx("option",{value:"machine",children:t("preview.byMachine")}),l.jsx("option",{value:"project",children:t("preview.byProject")}),l.jsx("option",{value:"issue",children:t("preview.byIssue")})]})]}),l.jsxs("nav",{"aria-label":t("preview.sessions"),className:m.groups,children:[d.length===0&&l.jsx("p",{className:m.muted,children:t("preview.noSessions")}),d.map(f=>l.jsxs("section",{children:[i!=="none"&&l.jsxs("h3",{children:[f.label??t("preview.noIssueLinks"),l.jsx("small",{children:f.sourceName})]}),f.rows.map(({source:g,session:b})=>{var N;return l.jsxs("button",{type:"button",className:m.session,"aria-current":((N=s.selection)==null?void 0:N.sourceId)===g.host.id&&s.selection.sessionId===b.id?"true":void 0,onClick:()=>{n.select(g.host.id,b.id),r({source:g.host.id,session:b.id},{replace:!0}),p(!1)},children:[l.jsx("span",{children:b.title}),l.jsx("small",{children:e||i==="machine"?b.projectName:g.host.displayName})]},JSON.stringify([g.host.id,b.id]))})]},f.id))]})]}),l.jsx("main",{className:m.main,children:s.selection?l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:m.conversationHeader,children:[l.jsxs("small",{className:m.muted,children:[u==null?void 0:u.host.displayName," · ",w==null?void 0:w.projectName]}),l.jsx("h2",{children:(w==null?void 0:w.title)??s.selection.sessionId}),l.jsxs("div",{className:m.actions,children:[l.jsx("span",{className:m.badge,children:t("preview.readOnlyBadge")}),v&&l.jsx("span",{children:t(`preview.activity.${v.activity}`)}),I?l.jsx(k,{className:m.control,to:I,children:t("preview.openFull")}):l.jsx(k,{className:m.control,to:"/login/direct",children:t("preview.fullApp")})]})]}),l.jsxs("div",{className:m.transcript,"data-testid":"preview-conversation",children:[S&&l.jsx("p",{role:"status",className:m.notice,children:t("preview.loading")}),s.conversationStatus==="offline"&&l.jsxs("div",{role:"status",className:m.notice,children:[l.jsx("p",{children:t("preview.disconnected")}),u&&l.jsx("button",{className:m.control,type:"button",onClick:()=>n.include(u.host.id,!0),children:t("preview.reconnect")})]}),s.conversationStatus==="invalid"&&l.jsx("p",{role:"alert",className:m.notice,children:t("preview.invalid")}),((C=s.view)==null?void 0:C.kind)==="error"&&l.jsx("p",{role:"status",className:m.notice,children:t(`preview.error.${s.view.code}`)}),s.view&&s.view.kind!=="conversation"&&s.view.kind!=="error"&&l.jsx("p",{className:m.notice,children:t("preview.unknown")}),v&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:m.history,children:[l.jsx("span",{children:t(v.coverage.returnedMessages===1?"preview.messageCountOne":"preview.messageCount",{count:v.coverage.returnedMessages})}),l.jsx("button",{type:"button",className:m.control,disabled:S||s.maxMessages>=100||!v.coverage.earlierInScope||(u==null?void 0:u.status)!=="ready",onClick:()=>n.more(),children:t("preview.more")}),l.jsx("button",{type:"button",className:m.control,disabled:S||(u==null?void 0:u.status)!=="ready",onClick:()=>n.latest(),children:t("preview.latest")})]}),s.anchorMessageId&&l.jsx("p",{className:m.muted,children:t("preview.anchored")}),(!v.coverage.completeForRequest||v.coverage.earlierOutsideScope!=="no"||s.maxMessages>=100&&v.coverage.earlierInScope)&&l.jsx("p",{className:m.notice,children:t("preview.coverage")}),v.messages.length===0&&l.jsx("p",{className:m.muted,children:t("preview.emptyConversation")}),v.messages.map(f=>l.jsxs("article",{className:m.message,"data-role":f.role,children:[l.jsxs("header",{children:[l.jsx("strong",{children:t(f.role==="user"?"preview.you":"preview.agent")}),f.state!=="complete"&&l.jsx("small",{children:t(`preview.message.${f.state}`)})]}),f.content.map((g,b)=>l.jsx(ls,{content:g},`${f.id}:${b}`)),f.truncated&&l.jsx("small",{className:m.muted,children:t("preview.truncated")})]},f.id)),v.pendingRequests.map((f,g)=>l.jsxs("section",{className:m.notice,children:[l.jsx("strong",{children:t("preview.needsAttention")}),l.jsx("p",{children:f.kind==="question"?f.prompt:t("preview.unknown")}),l.jsx("small",{children:t("preview.answerInFull")})]},f.kind==="question"?f.id:`unknown:${g}`))]}),((x=s.view)==null?void 0:x.kind)==="error"&&(u==null?void 0:u.status)==="ready"&&l.jsx("button",{type:"button",className:m.control,onClick:()=>n.latest(),children:t("preview.latest")})]})]}):l.jsxs("div",{className:m.empty,children:[l.jsx("h2",{children:t("preview.welcome")}),l.jsx("p",{children:t("preview.chooseSession")}),l.jsx("p",{className:m.muted,children:t("preview.readOnly")})]})})]})]})}function gs({local:n=!1}){const[e,t]=O.useState(null),[s]=de(),[o]=O.useState(()=>(n||s.get("source"))&&s.get("session")?{sourceId:n?"local":s.get("source"),sessionId:s.get("session")}:null);return O.useEffect(()=>{const r=new Ut(n?[{id:"local",mode:"local",displayName:window.location.host}]:Ne().hosts,n?vt:void 0,o);if(t(r),n)return r.include("local",!0),()=>r.dispose();let i=[];try{const a=JSON.parse(localStorage.getItem(me)??"[]");Array.isArray(a)&&(i=a.filter(c=>typeof c=="string"))}catch{}o&&i.push(o.sourceId);for(const a of new Set(i))r.include(a,!0);return()=>r.dispose()},[o,n]),e?l.jsx(us,{controller:e,local:n}):null}export{gs as ConversationPreviewPage,ls as PreviewContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as V,r as g,j as e,L as _}from"./index-umZg0LZ6.js";import{u as q,a as F}from"./SchemaValidationContext-57RCj4c4.js";import{u as K,a as Q}from"./Modal-ClSjJagX.js";import{u as $}from"./remoteRoutePaths-D8htA0xa.js";import{u as z}from"./useReloadNotifications-Dm1jmdIb.js";import{a as G}from"./frontendReload-CBdyvvdy.js";import{d as J,i as f}from"./NavigationLayout-BTFsWVtE.js";import{r as X}from"./relayEndpoints-BTq9xppf.js";import{g as Y,a as Z}from"./hostStorage-D1KAm3U1.js";import{S as n}from"./SettingsItem-C9Vh5p7F.js";import{u as ee,b as se}from"./index-BkOdUxq4.js";import{S as te}from"./SettingsSection-BaPzETK6.js";import"./react-runtime-D-UPQ57m.js";import"./index-CoR-vzsb.js";import"./client-Ci_HPGfl.js";import"./RelayProtocol-BpdH0COG.js";import"./appHref-ByaEnJGJ.js";import"./useSidebarWidth-CBCcbSLg.js";import"./LocalMediaModal-B9eHVx6y.js";import"./newSessionPrefill-DKcy0abh.js";import"./relay-url-j3kYm5KO.js";import"./useFileActivity-BoW4X3DY.js";import"./providerChildSessions-DbLFSybt.js";import"./katex-Dv2p4YRM.js";import"./ProviderBadge-P0VTI71n.js";import"./YepAnywhereLogo-5zFKWjQq.js";import"./PageHeader-BjwH2pWD.js";import"./SessionHeader.module-BpaFAQ-S.js";import"./HostIdentityContext-DA7dMF-y.js";import"./index-Cv3tQXyE.js";const w={"live-tail":"developmentSessionScrollMemoryModeLiveTailDescription","remember-place":"developmentSessionScrollMemoryModeRememberPlaceDescription","no-memory":"developmentSessionScrollMemoryModeNoMemoryDescription"},u={"live-tail":"developmentSessionScrollMemoryModeLiveTail","remember-place":"developmentSessionScrollMemoryModeRememberPlace","no-memory":"developmentSessionScrollMemoryModeNoMemory"};function We(){var C;const{t:s}=V(),I=K(),l=Q(),c=l!=null&&l.connection?l.currentRelayUsername?Y(l.currentRelayUsername):l.currentHostId?Z(l.currentHostId):void 0:void 0,D=(c==null?void 0:c.mode)==="relay"?c.relayUrl:void 0,N=D?(C=X(D))==null?void 0:C.statsUrl:void 0;ee(s("developmentSectionTitle"));const{isManualReloadMode:W,pendingReloads:H,connected:E,reloadBackend:L,unsafeToRestart:v,interruptibleSessionCount:r,queuedSessionMessageCount:i}=z(),{settings:b,setEnabled:h}=q(),{crossHostDelegationEnabled:d,setCrossHostDelegationEnabled:x,relayDebugEnabled:S,setRelayDebugEnabled:j,remoteLogCollectionEnabled:y,setRemoteLogCollectionEnabled:k}=$(),{sessionScrollBehaviorMode:m,setSessionScrollBehaviorMode:M}=J(),{ignoredTools:R,clearIgnoredTools:B}=F(),{settings:o,updateSetting:a}=G(),U=g.useMemo(()=>o?{validationEnabled:b.enabled,crossHostDelegationEnabled:d,relayDebugEnabled:S,remoteLogCollectionEnabled:y,sessionScrollBehaviorMode:m,serviceWorkerEnabled:o.serviceWorkerEnabled??!0,workstreamsEnabled:o.workstreamsEnabled??!1}:null,[b.enabled,d,S,y,o,m]),P=g.useCallback(t=>{h(t.validationEnabled),x(t.crossHostDelegationEnabled),j(t.relayDebugEnabled),k(t.remoteLogCollectionEnabled),M(t.sessionScrollBehaviorMode),a("serviceWorkerEnabled",t.serviceWorkerEnabled),a("workstreamsEnabled",t.workstreamsEnabled)},[h,x,j,k,M,a]);se(U,P);const[p,T]=g.useState(!1);g.useEffect(()=>{p&&E&&T(!1)},[p,E]);const O=async()=>{T(!0),await L()},A=r>0&&i>0?s("developmentInterruptedWarningActiveAndQueued",{activeCount:r,activeSuffix:r!==1?"s":"",queuedCount:i,queuedSuffix:i!==1?"s":""}):i>0?s("developmentInterruptedWarningQueued",{count:i,suffix:i!==1?"s":""}):s("developmentInterruptedWarning",{count:r,suffix:r!==1?"s ":" "});return e.jsxs(te,{children:[e.jsxs("div",{className:"settings-group",children:[e.jsx(n,{label:s("developmentSchemaTitle"),description:s("developmentSchemaDescription"),children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:b.enabled,onChange:t=>h(t.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})}),R.length>0&&e.jsx(n,{label:s("developmentIgnoredToolsTitle"),description:s("developmentIgnoredToolsDescription"),info:e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s("developmentIgnoredToolsTitle")}),e.jsx("p",{children:s("developmentIgnoredToolsDescription")}),e.jsx("div",{className:"ignored-tools-list",children:R.map(t=>e.jsx("span",{className:"ignored-tool-badge",children:t},t))})]}),children:e.jsx("button",{type:"button",className:"settings-button settings-button-secondary",onClick:B,children:s("developmentClearIgnored")})}),e.jsx(n,{label:s("developmentCrossHostDelegationTitle"),description:s("developmentCrossHostDelegationDescription"),className:"settings-item--wide-control",children:e.jsxs("div",{className:"settings-item-actions",children:[d&&e.jsx(_,{className:"settings-button settings-button-secondary",to:`${I}/-/hosts`,children:s("developmentHostsPreviewOpen")}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox","aria-label":s("developmentCrossHostDelegationTitle"),checked:d,onChange:t=>x(t.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]})}),N&&e.jsx(n,{label:s("developmentRelayMonitorTitle"),description:s("developmentRelayMonitorDescription"),children:e.jsx("a",{className:"settings-button settings-button-secondary",href:N,target:"_blank",rel:"noreferrer",children:s("developmentRelayMonitorOpen")})}),e.jsx(n,{label:s("developmentRelayDebugTitle"),description:s("developmentRelayDebugDescription"),children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox","aria-label":s("developmentRelayDebugTitle"),checked:S,onChange:t=>j(t.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})}),e.jsx(n,{label:s("developmentDiagnosticsTitle"),description:s("developmentDiagnosticsDescription"),children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:t=>k(t.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})}),e.jsx(n,{label:s("developmentServiceWorkerTitle"),description:s("developmentServiceWorkerDescription"),children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:(o==null?void 0:o.serviceWorkerEnabled)??!0,onChange:t=>a("serviceWorkerEnabled",t.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})}),e.jsx(n,{label:s("developmentWorkstreamsTitle"),description:s("developmentWorkstreamsDescription"),children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:(o==null?void 0:o.workstreamsEnabled)??!1,onChange:t=>a("workstreamsEnabled",t.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})})]}),e.jsx("div",{className:"settings-group",children:e.jsx(n,{label:s("developmentSessionScrollMemoryTitle"),description:s("developmentSessionScrollMemoryDescription"),keywords:[s("developmentSessionScrollMemoryControlTitle"),s("developmentSessionScrollMemoryKeywords"),...f.flatMap(t=>[s(u[t]),s(w[t])])],valueText:s(u[m]),className:"settings-item--wide-control",info:e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s("developmentSessionScrollMemoryTitle")}),e.jsx("p",{children:s("developmentSessionScrollMemoryDescription")}),e.jsx("ul",{className:"settings-option-description-list",children:f.map(t=>e.jsxs("li",{children:[e.jsx("strong",{children:s(u[t])}),e.jsx("span",{children:s(w[t])})]},t))})]}),children:e.jsx("div",{className:"settings-item-actions",children:e.jsx("select",{className:"settings-select",value:m,onChange:t=>M(t.target.value),"aria-label":s("developmentSessionScrollMemoryControlTitle"),children:f.map(t=>e.jsx("option",{value:t,children:s(u[t])},t))})})})}),W&&e.jsx("div",{className:"settings-group",children:e.jsx(n,{label:s("developmentRestartTitle"),description:s("developmentRestartDescription"),info:e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s("developmentRestartTitle")}),e.jsxs("p",{children:[s("developmentRestartDescription"),H.backend&&e.jsxs("span",{className:"settings-pending",children:[" ",s("developmentChangesPending")]})]}),v&&e.jsx("p",{className:"settings-warning",children:A})]}),children:e.jsx("button",{type:"button",className:`settings-button ${v?"settings-button-danger":""}`,onClick:O,disabled:p,children:s(p?"developmentRestarting":v?"developmentRestartAnyway":"developmentRestart")})})})]})}export{We as DevelopmentSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as d,u as x,j as s}from"./index-umZg0LZ6.js";import{a as f}from"./client-Ci_HPGfl.js";import{u as w}from"./useBackgroundRevalidation-C79HAUP3.js";import{u as j,a as P}from"./useConnectedDevices-Ds-DuUDc.js";import{u as N,H as b}from"./index-BkOdUxq4.js";import{S}from"./SettingsSection-BaPzETK6.js";import{p as D}from"./deviceDetection-BVPclkty.js";import"./react-runtime-D-UPQ57m.js";import"./RelayProtocol-BpdH0COG.js";import"./appHref-ByaEnJGJ.js";import"./PageHeader-BjwH2pWD.js";import"./LocalMediaModal-B9eHVx6y.js";import"./Modal-ClSjJagX.js";import"./remoteRoutePaths-D8htA0xa.js";import"./newSessionPrefill-DKcy0abh.js";import"./relay-url-j3kYm5KO.js";import"./SessionHeader.module-BpaFAQ-S.js";import"./HostIdentityContext-DA7dMF-y.js";import"./frontendReload-CBdyvvdy.js";import"./NavigationLayout-BTFsWVtE.js";import"./useSidebarWidth-CBCcbSLg.js";import"./useFileActivity-BoW4X3DY.js";import"./providerChildSessions-DbLFSybt.js";import"./katex-Dv2p4YRM.js";import"./index-CoR-vzsb.js";import"./ProviderBadge-P0VTI71n.js";import"./YepAnywhereLogo-5zFKWjQq.js";import"./index-Cv3tQXyE.js";function y(){const[r,t]=d.useState({profiles:[],isLoading:!0,error:null}),n=d.useCallback(async()=>{t(e=>({...e,isLoading:!0,error:null}));try{const{profiles:e}=await f.getBrowserProfiles();t({profiles:e,isLoading:!1,error:null})}catch(e){console.error("[useBrowserProfiles] Failed to fetch:",e),t(i=>({...i,isLoading:!1,error:e instanceof Error?e.message:"Failed to load profiles"}))}},[]);d.useEffect(()=>{n()},[n]),w({fetcher:()=>f.getBrowserProfiles().then(e=>e.profiles),current:r.profiles,apply:e=>t(i=>({...i,profiles:e,error:null}))});const a=d.useCallback(async e=>{t(i=>({...i,isLoading:!0,error:null}));try{await f.deleteBrowserProfile(e),await n()}catch(i){console.error("[useBrowserProfiles] Failed to delete:",i),t(c=>({...c,isLoading:!1,error:i instanceof Error?i.message:"Failed to delete profile"}))}},[n]);return{...r,deleteProfile:a,refetch:n}}function u(r,t){const n=new Date(r),e=new Date().getTime()-n.getTime(),i=Math.floor(e/(1e3*60)),c=Math.floor(e/(1e3*60*60)),o=Math.floor(e/(1e3*60*60*24));return i<1?t("devicesJustNow"):i<60?t("devicesMinutesAgo",{count:i,suffix:i===1?"":"s"}):c<24?t("devicesHoursAgo",{count:c,suffix:c===1?"":"s"}):o===1?t("devicesYesterday"):o<7?`${o} days ago`:n.toLocaleDateString()}function se(){const{t:r}=x();N(r("devicesProfilesTitle"));const{profiles:t,isLoading:n,error:a,deleteProfile:e}=y(),{browserProfileId:i}=j(),{connections:c}=P();return s.jsx(S,{description:r("devicesProfilesDescription"),children:s.jsxs(b,{children:[a&&s.jsx("p",{className:"form-error",children:a}),s.jsx("div",{className:"settings-group",children:n?s.jsx("p",{className:"settings-hint",children:r("devicesLoadingProfiles")}):t.length===0?s.jsx("p",{className:"settings-hint",children:r("devicesEmpty")}):s.jsx("div",{className:"device-list",children:t.map(o=>{const p=o.browserProfileId===i,m=c.has(o.browserProfileId),g=o.deviceName||`${o.browserProfileId.slice(0,8)}...`;return s.jsxs("div",{className:"device-list-item device-profile-item",children:[s.jsxs("div",{className:"device-list-info",children:[s.jsxs("strong",{children:[s.jsx("span",{className:`device-status ${m?"device-status-online":"device-status-offline"}`,title:r(m?"devicesConnected":"devicesDisconnected")}),g,p&&s.jsx("span",{className:"device-current-badge",children:r("devicesThisDevice")})]}),s.jsx("div",{className:"device-origins",children:o.origins.map(l=>{const{browser:v,os:h}=D(l.userAgent);return s.jsxs("div",{className:"device-origin",children:[s.jsx("code",{className:"device-origin-url",children:l.origin}),s.jsxs("span",{className:"device-origin-details",children:[v," · ",h]}),s.jsx("span",{className:"device-origin-time",children:r("devicesLastSeen",{date:u(l.lastSeen,r)})})]},l.origin)})}),s.jsx("p",{className:"device-profile-meta",children:r("devicesFirstSeen",{date:u(o.createdAt,r)})})]}),s.jsx("button",{type:"button",className:"settings-button settings-button-danger-subtle",onClick:()=>e(o.browserProfileId),title:r("devicesForgetThisDevice"),children:r("devicesForget")})]},o.browserProfileId)})})})]})})}export{se as DevicesSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as M,j as o,r as d,aG as Q,s as B,aQ as J,aR as z}from"./index-umZg0LZ6.js";import{a as Z}from"./client-Ci_HPGfl.js";import{A as H,c as V,d as F,e as ee,f as te,Q as ne,u as re,a as oe}from"./useEmulators-qS_cCZ3I.js";import{P as se}from"./PageHeader-BjwH2pWD.js";import{b as ie,e as ae}from"./Modal-ClSjJagX.js";import{MainContent as U}from"./index-Cv3tQXyE.js";import{u as ce}from"./NavigationLayout-BTFsWVtE.js";import"./react-runtime-D-UPQ57m.js";import"./RelayProtocol-BpdH0COG.js";import"./LocalMediaModal-B9eHVx6y.js";import"./newSessionPrefill-DKcy0abh.js";import"./relay-url-j3kYm5KO.js";import"./appHref-ByaEnJGJ.js";import"./SessionHeader.module-BpaFAQ-S.js";import"./HostIdentityContext-DA7dMF-y.js";import"./frontendReload-CBdyvvdy.js";import"./remoteRoutePaths-D8htA0xa.js";import"./useSidebarWidth-CBCcbSLg.js";import"./useFileActivity-BoW4X3DY.js";import"./providerChildSessions-DbLFSybt.js";import"./katex-Dv2p4YRM.js";import"./index-CoR-vzsb.js";import"./ProviderBadge-P0VTI71n.js";import"./YepAnywhereLogo-5zFKWjQq.js";const le="_root_1sqe4_1",de="_button_1sqe4_10",L={root:le,button:de};function ue({dataChannel:e,deviceType:t}){const{t:a}=M(),i=t==="emulator"||t==="android";if(!i&&!(t==="ios-simulator"))return null;const _=c=>{(e==null?void 0:e.readyState)==="open"&&e.send(JSON.stringify({type:"key",key:c}))},E=(e==null?void 0:e.readyState)!=="open";return o.jsxs("div",{className:L.root,role:"group","aria-label":a("emulatorDeviceNavigation"),children:[i&&o.jsx("button",{type:"button",className:L.button,onClick:()=>_("GoBack"),disabled:E,title:"Back","aria-label":"Back",children:o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("polyline",{points:"15 18 9 12 15 6"})})}),o.jsx("button",{type:"button",className:L.button,onClick:()=>_("GoHome"),disabled:E,title:"Home","aria-label":"Home",children:o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),i&&o.jsx("button",{type:"button",className:L.button,onClick:()=>_("AppSwitch"),disabled:E,title:"Recents","aria-label":"Recents",children:o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})})]})}function me(e){const t=e.getBoundingClientRect(),a=e.videoWidth,i=e.videoHeight;if(!a||!i)return t;const b=Math.min(t.width/a,t.height/i),_=a*b,E=i*b;return new DOMRect(t.left+(t.width-_)/2,t.top+(t.height-E)/2,_,E)}function j(e){return Math.max(0,Math.min(1,e))}function fe(e,t,a){if(a.width<=0||a.height<=0)return null;const i=(e-a.left)/a.width,b=(t-a.top)/a.height;return i<0||i>1||b<0||b>1?null:{x:j(i),y:j(b)}}function Ee(e,t,a){if(a.width<=0||a.height<=0)return null;const i=(e-a.left)/a.width,b=(t-a.top)/a.height;return{x:j(i),y:j(b)}}const pe={Backspace:"KEYCODE_DEL",Delete:"KEYCODE_FORWARD_DEL",Enter:"KEYCODE_ENTER",Tab:"KEYCODE_TAB",Escape:"KEYCODE_ESCAPE"," ":"KEYCODE_SPACE",ArrowLeft:"KEYCODE_DPAD_LEFT",ArrowRight:"KEYCODE_DPAD_RIGHT",ArrowUp:"KEYCODE_DPAD_UP",ArrowDown:"KEYCODE_DPAD_DOWN",Home:"KEYCODE_MOVE_HOME",End:"KEYCODE_MOVE_END",PageUp:"KEYCODE_PAGE_UP",PageDown:"KEYCODE_PAGE_DOWN",Insert:"KEYCODE_INSERT",".":"KEYCODE_PERIOD",",":"KEYCODE_COMMA","/":"KEYCODE_SLASH","\\":"KEYCODE_BACKSLASH","-":"KEYCODE_MINUS","=":"KEYCODE_EQUALS",";":"KEYCODE_SEMICOLON","'":"KEYCODE_APOSTROPHE","[":"KEYCODE_LEFT_BRACKET","]":"KEYCODE_RIGHT_BRACKET","`":"KEYCODE_GRAVE"},_e={Space:"KEYCODE_SPACE",Enter:"KEYCODE_ENTER",Tab:"KEYCODE_TAB",Escape:"KEYCODE_ESCAPE",Backspace:"KEYCODE_DEL",Delete:"KEYCODE_FORWARD_DEL",ArrowLeft:"KEYCODE_DPAD_LEFT",ArrowRight:"KEYCODE_DPAD_RIGHT",ArrowUp:"KEYCODE_DPAD_UP",ArrowDown:"KEYCODE_DPAD_DOWN",Home:"KEYCODE_MOVE_HOME",End:"KEYCODE_MOVE_END",PageUp:"KEYCODE_PAGE_UP",PageDown:"KEYCODE_PAGE_DOWN",Insert:"KEYCODE_INSERT",Period:"KEYCODE_PERIOD",Comma:"KEYCODE_COMMA",Slash:"KEYCODE_SLASH",Backslash:"KEYCODE_BACKSLASH",Minus:"KEYCODE_MINUS",Equal:"KEYCODE_EQUALS",Semicolon:"KEYCODE_SEMICOLON",Quote:"KEYCODE_APOSTROPHE",BracketLeft:"KEYCODE_LEFT_BRACKET",BracketRight:"KEYCODE_RIGHT_BRACKET",Backquote:"KEYCODE_GRAVE"};function he(e){return e==="emulator"||e==="android"||e==="ios-simulator"}function De(e){if(e.isComposing||e.ctrlKey||e.metaKey||e.altKey)return null;if(e.key.length===1)return e.key;const t=pe[e.key];return t||(e.code.startsWith("Key")&&e.code.length===4?`KEYCODE_${e.code.slice(3).toUpperCase()}`:e.code.startsWith("Digit")&&e.code.length===6?`KEYCODE_${e.code.slice(5)}`:_e[e.code]??null)}const ge=new Set(["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Insert"]);function ye(e){if(e.isComposing||e.ctrlKey||e.metaKey||e.altKey)return null;let t=e.key;return t==="Esc"&&(t="Escape"),t==="Spacebar"&&(t=" "),t===""||t==="Dead"||t==="Unidentified"||t==="Shift"||t==="Control"||t==="Alt"||t==="Meta"?null:t.length===1||ge.has(t)||/^F\d{1,2}$/.test(t)?t:null}function Se(e,t){return t==="emulator"||t==="ios-simulator"?ye(e):De(e)}function ve(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"}function be({stream:e,dataChannel:t,deviceType:a,peerConnection:i,adaptiveFps:b=!1,configuredFps:_=30}){const E=d.useRef(null);d.useEffect(()=>{const s=E.current;if(!s||(s.srcObject=e,!e))return;const $=e.getVideoTracks();console.log(`[DeviceStream] attached stream: ${$.length} video track(s), active=${e.active}`);for(const f of $)console.log(`[DeviceStream] track ${f.id}: readyState=${f.readyState} enabled=${f.enabled} muted=${f.muted}`);let D=-1,S=0,y=0,p=0;const m=setInterval(async()=>{const f=s.currentTime;if(D>=0&&f===D&&!s.paused){S++;let K="";if(i&&i.connectionState!=="closed")try{const u=await i.getStats();for(const n of u.values())if(n.type==="inbound-rtp"&&n.kind==="video"){const r=n.packetsReceived??0,A=n.bytesReceived??0,Y=n.packetsLost??0,X=r-y,q=A-p;y=r,p=A,K=` rtp: +${X}pkts/+${q}bytes (total=${r}, lost=${Y})`}}catch{}if(S===1)console.warn(`[DeviceStream] video stale: currentTime=${f.toFixed(3)} not advancing${K}`);else if(S%6===0){const u=e.getVideoTracks()[0];console.warn(`[DeviceStream] video still stale (${S*5}s): currentTime=${f.toFixed(3)}, track=${(u==null?void 0:u.readyState)??"none"}, streamActive=${e.active}${K}`)}else console.warn(`[DeviceStream] video stale (${S*5}s)${K}`)}else if(S>0&&console.log(`[DeviceStream] video resumed after ${S*5}s stale`),S=0,i&&i.connectionState!=="closed")try{const K=await i.getStats();for(const u of K.values())u.type==="inbound-rtp"&&u.kind==="video"&&(y=u.packetsReceived??0,p=u.bytesReceived??0)}catch{}D=f},5e3),T=f=>{console.warn(`[DeviceStream] stream removetrack: ${f.track.kind} ${f.track.id}`)},h=()=>{console.warn("[DeviceStream] stream became inactive")};return e.addEventListener("removetrack",T),e.addEventListener("inactive",h),()=>{clearInterval(m),e.removeEventListener("removetrack",T),e.removeEventListener("inactive",h)}},[e,i]),d.useEffect(()=>{if(!b||!i||!t)return;let s=0,$=0,D=null;const S=setInterval(async()=>{if(i.connectionState==="closed"||t.readyState!=="open")return;let y=0,p=0;try{const h=await i.getStats();for(const f of h.values())if(f.type==="inbound-rtp"&&f.kind==="video"){const K=f.packetsReceived??0,u=f.packetsLost??0;y=K-s,p=Math.max(0,u-$),s=K,$=u}}catch{return}const m=y+p,T=m>0?p/m:0;T>H?D?D=Date.now():(D=Date.now(),t.send(JSON.stringify({type:"fps_hint",fps:V})),console.warn(`[DeviceStream] adaptive: loss rate ${(T*100).toFixed(1)}% > ${H*100}%, dropping to ${V}fps`)):D!==null&&Date.now()-D>=F*1e3&&(D=null,t.send(JSON.stringify({type:"fps_hint",fps:_})),console.log(`[DeviceStream] adaptive: loss-free for ${F}s, restoring to ${_}fps`))},ee);return()=>clearInterval(S)},[b,i,t,_]);const c=d.useCallback(()=>t&&t.readyState==="open",[t]),k=d.useCallback(s=>{!c()||!t||t.send(JSON.stringify({type:"key",key:s}))},[c,t]);d.useEffect(()=>{if(!he(a))return;const s=$=>{if(!c()||!t||ve($.target))return;const D=Se($,a);D&&($.preventDefault(),k(D))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[c,t,a,k]);const g=d.useCallback((s,$)=>{if(!c()||!t)return;const D=me($),S=s.map(y=>{const p=y.pressure<=0?Ee(y.clientX,y.clientY,D):fe(y.clientX,y.clientY,D);return p?{x:p.x,y:p.y,pressure:y.pressure,id:y.id}:null}).filter(y=>y!==null);S.length!==0&&t.send(JSON.stringify({type:"touch",touches:S}))},[c,t]);d.useEffect(()=>{const s=E.current;if(!s)return;const $=p=>{p.preventDefault(),g(Array.from(p.touches).map(m=>({clientX:m.clientX,clientY:m.clientY,id:m.identifier,pressure:m.force||.5})),s)},D=p=>{p.preventDefault(),g(Array.from(p.touches).map(m=>({clientX:m.clientX,clientY:m.clientY,id:m.identifier,pressure:m.force||.5})),s)},S=p=>{p.preventDefault(),g(Array.from(p.changedTouches).map(m=>({clientX:m.clientX,clientY:m.clientY,id:m.identifier,pressure:0})),s)},y={passive:!1};return s.addEventListener("touchstart",$,y),s.addEventListener("touchmove",D,y),s.addEventListener("touchend",S,y),s.addEventListener("touchcancel",S,y),()=>{s.removeEventListener("touchstart",$),s.removeEventListener("touchmove",D),s.removeEventListener("touchend",S),s.removeEventListener("touchcancel",S)}},[g]);const w=d.useRef(!1),R=d.useCallback(s=>{s.preventDefault(),w.current=!0,g([{clientX:s.clientX,clientY:s.clientY,id:0,pressure:.5}],s.currentTarget)},[g]),x=d.useCallback(s=>{w.current&&(s.preventDefault(),g([{clientX:s.clientX,clientY:s.clientY,id:0,pressure:.5}],s.currentTarget))},[g]),C=d.useCallback(s=>{w.current&&(w.current=!1,s.preventDefault(),g([{clientX:s.clientX,clientY:s.clientY,id:0,pressure:0}],s.currentTarget))},[g]),O=d.useCallback(s=>{w.current&&(w.current=!1,g([{clientX:s.clientX,clientY:s.clientY,id:0,pressure:0}],s.currentTarget))},[g]);return o.jsx("video",{ref:E,className:"emulator-video",autoPlay:!0,playsInline:!0,muted:!0,tabIndex:0,"aria-label":"Device stream",onMouseDown:R,onMouseMove:x,onMouseUp:C,onMouseLeave:O})}const v="[DeviceStream]",$e=8;function we(){typeof window>"u"||(window.__YEP_DEVICE_STREAM_PROFILE_EVENTS__=[])}function ke(e){if(typeof window>"u")return;const t=window,a=t.__YEP_DEVICE_STREAM_PROFILE_EVENTS__??[];a.push(e),t.__YEP_DEVICE_STREAM_PROFILE_EVENTS__=a,window.dispatchEvent(new CustomEvent("yep:device_stream_profile_event",{detail:e}))}function P(e,t){try{return Promise.resolve(e.send(t))}catch(a){return Promise.reject(a)}}function Ce(){const e=ie().transport,t=e.capabilities.device,[a,i]=d.useState(null),[b,_]=d.useState(null),[E,c]=d.useState("idle"),[k,g]=d.useState(null),[w,R]=d.useState(null),[x,C]=d.useState([]),O=d.useRef(null),s=d.useRef(null),$=d.useRef(null),D=d.useRef(null),S=d.useCallback(()=>{const p=s.current;if(console.log(`${v} disconnect() called, session=${p}`),p){const m=$.current;m&&P(m,{type:"device_stream_stop",sessionId:p}).catch(()=>{})}if(O.current){const m=O.current;console.log(`${v} closing RTCPeerConnection (state=${m.connectionState}, ice=${m.iceConnectionState})`),m.close(),O.current=null}D.current&&(D.current(),D.current=null),s.current=null,$.current=null,i(null),_(null),c("idle"),g(null),R(null),C([])},[]),y=d.useCallback(p=>{S();const m=t;if(!m){c("failed"),g("Device streaming is not available for this source");return}const T=Q();s.current=T,$.current=m;const h=T.slice(0,8);console.log(`${v} connect(deviceId=${p.id}, type=${p.type??"unknown"}, session=${h})`),c("connecting"),g(null),R(null),C([]),we();const f=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});O.current=f,f.ontrack=n=>{const r=n.track;console.log(`${v} [${h}] ontrack: kind=${r.kind} id=${r.id} readyState=${r.readyState} muted=${r.muted}`),n.streams[0]&&i(n.streams[0]),r.onmute=()=>console.warn(`${v} [${h}] track MUTED: ${r.id}`),r.onunmute=()=>console.log(`${v} [${h}] track unmuted: ${r.id}`),r.onended=()=>console.warn(`${v} [${h}] track ENDED: ${r.id}`)},f.ondatachannel=n=>{const r=n.channel;console.log(`${v} [${h}] ondatachannel: label=${r.label} id=${r.id}`),r.onopen=()=>{console.log(`${v} [${h}] DataChannel "${r.label}" opened`),_(r)},r.onclose=()=>{console.warn(`${v} [${h}] DataChannel "${r.label}" closed`),_(null)},r.onerror=A=>{console.error(`${v} [${h}] DataChannel "${r.label}" error:`,A)}},f.onconnectionstatechange=()=>{switch(console.log(`${v} [${h}] connectionState: ${f.connectionState}`),f.connectionState){case"connected":c("connected");break;case"disconnected":c("disconnected");break;case"failed":c("failed"),g("WebRTC connection failed");break;case"closed":c("disconnected");break}},f.oniceconnectionstatechange=()=>{console.log(`${v} [${h}] iceConnectionState: ${f.iceConnectionState}`)},f.onicegatheringstatechange=()=>{console.log(`${v} [${h}] iceGatheringState: ${f.iceGatheringState}`)},f.onsignalingstatechange=()=>{console.log(`${v} [${h}] signalingState: ${f.signalingState}`)},f.onicecandidate=n=>{n.candidate?console.log(`${v} [${h}] sending ICE candidate: ${n.candidate.candidate.slice(0,60)}...`):console.log(`${v} [${h}] ICE gathering complete (null candidate)`),P(m,{type:"device_ice_candidate",sessionId:T,candidate:n.candidate?{candidate:n.candidate.candidate,sdpMid:n.candidate.sdpMid,sdpMLineIndex:n.candidate.sdpMLineIndex,usernameFragment:n.candidate.usernameFragment}:null}).catch(r=>{c("failed"),g(`Connection failed: ${r instanceof Error?r.message:String(r)}`)})};const K=m.onMessage(async n=>{if(n.sessionId===T)switch(n.type){case"device_webrtc_offer":{console.log(`${v} [${h}] received SDP offer (${n.sdp.length} bytes)`);try{await f.setRemoteDescription({type:"offer",sdp:n.sdp});const r=await f.createAnswer();await f.setLocalDescription(r),console.log(`${v} [${h}] sent SDP answer (${(r.sdp??"").length} bytes)`),await P(m,{type:"device_webrtc_answer",sessionId:T,sdp:r.sdp??""})}catch(r){console.error(`${v} [${h}] SDP negotiation failed:`,r),c("failed"),g(`WebRTC negotiation failed: ${r instanceof Error?r.message:String(r)}`)}break}case"device_ice_candidate_event":{if(n.candidate){console.log(`${v} [${h}] received remote ICE candidate`);try{await f.addIceCandidate(n.candidate)}catch(r){console.warn(`${v} [${h}] failed to add ICE candidate:`,r)}}else console.log(`${v} [${h}] remote ICE gathering complete`);break}case"device_session_state":{console.log(`${v} [${h}] server session state: ${n.state}${n.error?` error=${n.error}`:""}`),(n.state==="failed"||n.state==="disconnected")&&(c(n.state),n.error&&g(n.error));break}case"device_stream_profile_event":{console.log(`${v} [${h}] stream profile event: ${n.direction} tier=${n.tier}/${n.totalTiers} ${n.width}x${n.height}@${n.fps} bitrate=${n.bitrate}`);const r={...n,receivedAt:Date.now()};R(n),C(A=>[r,...A].slice(0,$e)),ke(n);break}}});D.current=K;const u=async()=>{const{maxFps:n,maxWidth:r,quality:A}=te(),Y=ne[A];console.log(`${v} [${h}] sending device_stream_start fps=${n} width=${r} quality=${A}(crf=${Y})`),await P(m,{type:"device_stream_start",sessionId:T,deviceId:p.id,deviceType:p.type,options:{maxFps:n,maxWidth:r,quality:Y}})};Promise.resolve().then(async()=>{e.status.getSnapshot().state!=="ready"&&await e.reconnect(),await u()}).catch(n=>{console.error(`${v} [${h}] device signaling failed:`,n),c("failed"),g(`Connection failed: ${n instanceof Error?n.message:String(n)}`)})},[t,S,e]);return d.useEffect(()=>{const p=$.current;p&&p!==t&&S()},[t,S]),d.useEffect(()=>()=>{if(O.current&&(O.current.close(),O.current=null),D.current&&(D.current(),D.current=null),s.current){const p=$.current;p&&P(p,{type:"device_stream_stop",sessionId:s.current}).catch(()=>{})}},[]),{remoteStream:a,dataChannel:b,peerConnection:O.current,connectionState:E,error:k,latestProfileEvent:w,profileEventHistory:x,connect:y,disconnect:S}}const Oe="_list_122d7_2",Te="_group_122d7_8",Ae="_groupTitle_122d7_14",Ke="_item_122d7_23",xe="_itemInfo_122d7_33",Re="_itemName_122d7_39",Ye="_itemStatus_122d7_44",Ne="_running_122d7_49",Pe="_stopped_122d7_53",Ie="_itemActions_122d7_57",Le="_btn_122d7_63",je="_btnPrimary_122d7_72",Me="_btnSecondary_122d7_81",Be="_streamView_122d7_91",He="_streamHeader_122d7_98",Ve="_connectionState_122d7_107",Fe="_streamHeaderActions_122d7_114",Ue="_keyboardState_122d7_119",We="_profileState_122d7_127",Ge="_profileTimeline_122d7_135",Xe="_profileTimelineItem_122d7_144",qe="_latest_122d7_154",Qe="_profileTimelineTime_122d7_158",Je="_profileTimelineDetail_122d7_163",ze="_streamContainer_122d7_169",Ze="_loading_122d7_180",et="_empty_122d7_181",tt="_error_122d7_187",nt="_connecting_122d7_196",rt="_downloadPrompt_122d7_203",l={list:Oe,group:Te,groupTitle:Ae,item:Ke,itemInfo:xe,itemName:Re,itemStatus:Ye,running:Ne,stopped:Pe,itemActions:Ie,btn:Le,btnPrimary:je,btnSecondary:Me,streamView:Be,streamHeader:He,connectionState:Ve,streamHeaderActions:Fe,keyboardState:Ue,profileState:We,profileTimeline:Ge,profileTimelineItem:Xe,latest:qe,profileTimelineTime:Qe,profileTimelineDetail:Je,streamContainer:ze,loading:Ze,empty:et,error:tt,connecting:nt,downloadPrompt:rt},W=["emulator","android","chromeos","ios-simulator"];function G(e){return e.label||e.avd||e.id}function ot(e){switch(e){case"emulator":return"Android Emulators";case"android":return"Android Devices";case"chromeos":return"ChromeOS Devices";case"ios-simulator":return"iOS Simulators";default:return"Devices"}}function I(e,t){var a;return(a=e.actions)!=null&&a.length?e.actions.includes(t):t==="stream"?e.state!=="stopped":t==="start"?e.type==="emulator"&&e.state==="stopped":t==="stop"?e.type==="emulator"&&e.state!=="stopped":!1}function N(){return navigator.keyboard}function st({device:e,onConnect:t,onStart:a,onStop:i}){const b=I(e,"stream"),_=I(e,"start"),E=I(e,"stop");return o.jsxs("div",{className:l.item,"data-testid":"device-row",children:[o.jsxs("div",{className:l.itemInfo,children:[o.jsx("span",{className:l.itemName,children:G(e)}),o.jsx("span",{className:`${l.itemStatus} ${e.state==="stopped"?l.stopped:l.running}`,children:e.state})]}),o.jsxs("div",{className:l.itemActions,children:[b&&o.jsx("button",{type:"button",className:`${l.btn} ${l.btnPrimary}`,onClick:()=>t(e),children:"Connect"}),E&&o.jsx("button",{type:"button",className:`${l.btn} ${l.btnSecondary}`,onClick:()=>i(e.id),children:"Stop"}),!E&&_&&o.jsx("button",{type:"button",className:`${l.btn} ${l.btnSecondary}`,onClick:()=>a(e.id),children:"Start"}),!b&&!E&&!_&&o.jsx("span",{className:l.itemStatus,children:"No actions"})]})]})}function it({devices:e,onConnect:t,onStart:a,onStop:i}){const b=d.useMemo(()=>{const _=new Map;for(const E of W)_.set(E,[]);for(const E of e){const c=_.get(E.type);c?c.push(E):_.set(E.type,[E])}return _},[e]);return o.jsx("div",{className:l.list,children:Array.from(b.entries()).map(([_,E])=>E.length===0?null:o.jsxs("section",{className:l.group,"data-testid":"device-group",children:[o.jsx("h3",{className:l.groupTitle,"data-testid":"device-group-title",children:ot(_)}),E.map(c=>o.jsx(st,{device:c,onConnect:t,onStart:a,onStop:i},c.id))]},_))})}function at(e){for(const t of W){const a=e.find(i=>i.type===t&&I(i,"stream"));if(a)return a}return e.find(t=>I(t,"stream"))}function ct({device:e,onBack:t}){var K;const{remoteStream:a,dataChannel:i,peerConnection:b,connectionState:_,error:E,latestProfileEvent:c,profileEventHistory:k,connect:g,disconnect:w}=Ce(),{adaptiveFps:R,maxFps:x}=oe(),C=d.useRef(null),[O,s]=d.useState(!1),[$,D]=d.useState(!1),[S,y]=d.useState(null),m=(e.type==="emulator"||e.type==="android")&&document.fullscreenEnabled&&typeof((K=N())==null?void 0:K.lock)=="function";d.useEffect(()=>(g({id:e.id,type:e.type}),()=>w()),[e.id,e.type,g,w]),d.useEffect(()=>{const u=()=>{var r,A;const n=document.fullscreenElement===C.current;s(n),n||(A=(r=N())==null?void 0:r.unlock)==null||A.call(r)};return document.addEventListener("fullscreenchange",u),()=>{var n,r;document.removeEventListener("fullscreenchange",u),(r=(n=N())==null?void 0:n.unlock)==null||r.call(n)}},[]);const T=d.useCallback(async()=>{var u,n;D(!0),y(null);try{(n=(u=N())==null?void 0:u.unlock)==null||n.call(u),document.fullscreenElement===C.current&&await document.exitFullscreen(),s(!1)}catch(r){y(`Failed to exit immersive keyboard: ${r instanceof Error?r.message:String(r)}`)}finally{D(!1)}},[]),h=d.useCallback(async()=>{var u,n,r,A;if(!(!m||!C.current)){D(!0),y(null);try{document.fullscreenElement!==C.current&&await C.current.requestFullscreen(),await((n=(u=N())==null?void 0:u.lock)==null?void 0:n.call(u)),s(!0)}catch(Y){(A=(r=N())==null?void 0:r.unlock)==null||A.call(r),s(!1),y(`Immersive keyboard failed: ${Y instanceof Error?Y.message:String(Y)}`)}finally{D(!1)}}},[m]),f=()=>{T(),w(),t()};return o.jsxs("div",{className:l.streamView,ref:C,children:[o.jsxs("div",{className:l.streamHeader,children:[o.jsx("button",{type:"button",className:`${l.btn} ${l.btnSecondary}`,onClick:f,children:"Back"}),o.jsxs("span",{className:l.connectionState,"data-testid":"device-connection-state",children:[G(e)," - ",_]}),o.jsx("div",{className:l.streamHeaderActions,children:m&&o.jsx("button",{type:"button",className:`${l.btn} ${l.btnSecondary}`,onClick:()=>{O?T():h()},disabled:$,title:"Request fullscreen and keyboard lock",children:$?"Working...":O?"Exit Immersive Keyboard":"Immersive Keyboard"})})]}),m&&o.jsxs("div",{className:l.keyboardState,children:["Keyboard mode:"," ",O?"immersive (fullscreen)":"standard"]}),S&&o.jsx("div",{className:l.error,children:S}),c&&o.jsxs("div",{className:l.profileState,children:["Profile ",c.direction,": tier ",c.tier,"/",c.totalTiers," (",c.width,"x",c.height,"@",c.fps,"fps,"," ",Math.round(c.bitrate/1e3)," kbps)"]}),k.length>0&&o.jsx("div",{className:l.profileTimeline,"data-testid":"profile-timeline",children:k.map((u,n)=>o.jsxs("div",{className:`${l.profileTimelineItem} ${n===0?l.latest:""}`,children:[o.jsx("span",{className:l.profileTimelineTime,children:new Date(u.receivedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),o.jsxs("span",{className:l.profileTimelineDetail,children:[u.direction," tier ",u.tier,"/",u.totalTiers," (",u.width,"x",u.height,"@",u.fps,")"]})]},`${u.receivedAt}-${u.direction}-${u.tier}-${n}`))}),E&&o.jsx("div",{className:l.error,children:E}),_==="connecting"&&o.jsx("div",{className:l.connecting,children:"Connecting..."}),o.jsx("div",{className:l.streamContainer,children:o.jsx(be,{stream:a,dataChannel:i,deviceType:e.type,peerConnection:b,adaptiveFps:R,configuredFps:x})}),o.jsx(ue,{dataChannel:i,deviceType:e.type})]})}function lt({mode:e,installedVersion:t,latestVersion:a,onDownloaded:i}){const{t:b}=M(),[_,E]=d.useState(!1),[c,k]=d.useState(null),g=async()=>{E(!0),k(null);try{const w=await Z.downloadDeviceBridge();w.ok?i():k(w.error??"Download failed")}catch(w){k(w instanceof Error?w.message:String(w))}finally{E(!1)}};return o.jsxs("div",{className:l.downloadPrompt,children:[o.jsx("p",{children:e==="update"?o.jsxs(o.Fragment,{children:[b("emulatorBridgeUpdateRequired"),t&&a?` Installed: v${t}. Latest: v${a}.`:null]}):b("emulatorBridgeDownloadRequired")}),c&&o.jsx("div",{className:l.error,children:c}),o.jsx("button",{type:"button",className:`${l.btn} ${l.btnPrimary}`,onClick:g,disabled:_,children:_?e==="update"?"Updating...":"Downloading...":e==="update"?"Update Bridge":"Download Bridge"})]})}function Yt(){const{t:e}=M(),{openSidebar:t,isWideScreen:a}=ce(),{version:i,refetch:b}=ae(),_=(i==null?void 0:i.deviceBridgeState)==="update-available"?"update":B(i,J)&&!B(i,z)?"download":null,E=_!==null,{emulators:c,loading:k,error:g,startEmulator:w,stopEmulator:R}=re({enabled:!E}),[x,C]=d.useState(null);return d.useEffect(()=>{if(x||k||E||!new URLSearchParams(window.location.search).has("auto"))return;const s=at(c);s&&C(s)},[c,k,x,E]),x?o.jsx(U,{isWideScreen:a,children:o.jsx(ct,{device:x,onBack:()=>C(null)})}):o.jsxs(U,{isWideScreen:a,children:[o.jsx(se,{title:"Devices",onOpenSidebar:t,isWideScreen:a}),o.jsx("main",{className:"page-scroll-container",children:o.jsx("div",{className:"page-content-inner",children:_?o.jsx(lt,{mode:_,installedVersion:i==null?void 0:i.deviceBridgeVersion,latestVersion:i==null?void 0:i.latestDeviceBridgeVersion,onDownloaded:b}):o.jsxs(o.Fragment,{children:[k&&o.jsx("div",{className:l.loading,children:"Loading..."}),g&&o.jsx("div",{className:l.error,children:g}),!k&&c.length===0&&o.jsx("div",{className:l.empty,children:e("emulatorPageNoDevices")}),c.length>0&&o.jsx(it,{devices:c,onConnect:C,onStart:w,onStop:R})]})})})]})}export{lt as BridgeRuntimePrompt,Yt as EmulatorPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as w,r as u,j as t}from"./index-umZg0LZ6.js";import{u as Q,a as z,E as P,b as M,g as T}from"./useEmulators-qS_cCZ3I.js";import{a as U}from"./frontendReload-CBdyvvdy.js";import{S as c}from"./SettingsItem-C9Vh5p7F.js";import{u as _,b as W,H as A}from"./index-BkOdUxq4.js";import{S as $}from"./SettingsSection-BaPzETK6.js";import"./react-runtime-D-UPQ57m.js";import"./client-Ci_HPGfl.js";import"./RelayProtocol-BpdH0COG.js";import"./Modal-ClSjJagX.js";import"./remoteRoutePaths-D8htA0xa.js";import"./PageHeader-BjwH2pWD.js";import"./LocalMediaModal-B9eHVx6y.js";import"./newSessionPrefill-DKcy0abh.js";import"./relay-url-j3kYm5KO.js";import"./appHref-ByaEnJGJ.js";import"./SessionHeader.module-BpaFAQ-S.js";import"./HostIdentityContext-DA7dMF-y.js";import"./NavigationLayout-BTFsWVtE.js";import"./useSidebarWidth-CBCcbSLg.js";import"./useFileActivity-BoW4X3DY.js";import"./providerChildSessions-DbLFSybt.js";import"./katex-Dv2p4YRM.js";import"./index-CoR-vzsb.js";import"./ProviderBadge-P0VTI71n.js";import"./YepAnywhereLogo-5zFKWjQq.js";import"./index-Cv3tQXyE.js";const Y=["high","medium","low"];function q(s,l,i){return i!=null&&i.length?i.includes("start"):s==="emulator"&&l==="stopped"}function G(s,l,i){return i!=null&&i.length?i.includes("stop"):s==="emulator"&&l!=="stopped"}function fe(){const{t:s}=w();_(s("emulatorSectionTitle"));const{emulators:l,loading:i,error:f,startEmulator:F,stopEmulator:k,refresh:H}=Q(),{maxFps:p,setMaxFps:h,maxWidth:g,setMaxWidth:x,quality:m,setQuality:j,adaptiveFps:b,setAdaptiveFps:N}=z(),{settings:r,isLoading:v,error:y,updateSetting:n}=U(),[E,O]=u.useState(""),[C,o]=u.useState(null),d=(r==null?void 0:r.chromeOsHosts)??[],I=u.useMemo(()=>r?{maxFps:p,maxWidth:g,quality:m,adaptiveFps:b,deviceBridgeEnabled:r.deviceBridgeEnabled??!1,chromeOsHosts:r.chromeOsHosts??[]}:null,[r,p,g,m,b]),R=u.useCallback(e=>{h(e.maxFps),x(e.maxWidth),j(e.quality),N(e.adaptiveFps),n("deviceBridgeEnabled",e.deviceBridgeEnabled),n("chromeOsHosts",e.chromeOsHosts),o(null)},[h,x,j,N,n]);W(I,R);const L=async()=>{const e=E.trim();if(!e){o(s("emulatorHostAliasRequired"));return}if(/\s/.test(e)){o(s("emulatorHostAliasNoSpaces"));return}const S=Array.from(new Set([...d,e]));try{await n("chromeOsHosts",S),O(""),o(null),await H()}catch(a){o(a instanceof Error?a.message:s("emulatorHostAliasSaveFailed"))}},B=async e=>{const S=d.filter(a=>a.toLowerCase()!==e.toLowerCase());try{await n("chromeOsHosts",S),o(null),await H()}catch(a){o(a instanceof Error?a.message:s("emulatorHostAliasRemoveFailed"))}},D=(r==null?void 0:r.deviceBridgeEnabled)??!1;return t.jsxs($,{children:[t.jsx("p",{className:"settings-description",children:s("emulatorSectionDescription")}),t.jsx("div",{className:"settings-group",children:t.jsx(c,{label:s("emulatorEnableTitle"),description:s("emulatorEnableDescription"),children:t.jsxs("label",{className:"toggle-switch",children:[t.jsx("input",{type:"checkbox",checked:D,onChange:e=>{n("deviceBridgeEnabled",e.target.checked)},disabled:v}),t.jsx("span",{className:"toggle-slider"})]})})}),D?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"settings-group",children:[t.jsx("h3",{children:s("emulatorStreamQualityTitle")}),t.jsx("p",{className:"settings-description",children:s("emulatorStreamQualityDescription")}),t.jsx(c,{label:s("emulatorFrameRateTitle"),description:s("emulatorFrameRateDescription"),children:t.jsx("div",{className:"font-size-selector",children:P.map(e=>t.jsxs("button",{type:"button",className:`font-size-option ${p===e?"active":""}`,onClick:()=>h(e),children:[e," fps"]},e))})}),t.jsx(c,{label:s("emulatorResolutionTitle"),description:s("emulatorResolutionDescription"),children:t.jsx("div",{className:"font-size-selector",children:M.map(e=>t.jsxs("button",{type:"button",className:`font-size-option ${g===e?"active":""}`,onClick:()=>x(e),children:[e,"p"]},e))})}),t.jsx(c,{label:s("emulatorQualityTitle"),description:s("emulatorQualityDescription"),valueText:T(m),children:t.jsx("div",{className:"font-size-selector",children:Y.map(e=>t.jsx("button",{type:"button",className:`font-size-option ${m===e?"active":""}`,onClick:()=>j(e),children:T(e)},e))})}),t.jsx(c,{label:s("emulatorAdaptiveFpsTitle"),description:s("emulatorAdaptiveFpsDescription"),children:t.jsxs("label",{className:"toggle-switch",children:[t.jsx("input",{type:"checkbox",checked:b,onChange:e=>N(e.target.checked)}),t.jsx("span",{className:"toggle-slider"})]})})]}),t.jsxs("div",{className:"settings-group",children:[t.jsx("h3",{children:s("emulatorChromeOsHostsTitle")}),t.jsxs("p",{className:"settings-description",children:[s("emulatorChromeOsHostsDescription"),t.jsx("code",{children:" chromeroot"}),s("emulatorChromeOsHostsDescriptionSuffix")]}),t.jsx(c,{label:s("emulatorAddHostAliasTitle"),description:s("emulatorAddHostAliasDescription"),children:t.jsxs("form",{className:"settings-item-actions",onSubmit:e=>{e.preventDefault(),L()},children:[t.jsx("input",{type:"text",name:"chromeosHost",placeholder:s("emulatorHostAliasPlaceholder"),className:"settings-select",autoComplete:"off",value:E,onChange:e=>O(e.target.value)}),t.jsx("button",{type:"submit",className:"settings-button",disabled:v,children:s("projectsAddConfirm")})]})}),t.jsxs(A,{children:[C&&t.jsx("p",{className:"settings-error",children:C}),y&&t.jsx("p",{className:"settings-error",children:y}),d.length===0?t.jsx("p",{className:"settings-muted",children:s("emulatorNoChromeOsHosts")}):d.map(e=>t.jsxs("div",{className:"settings-item",children:[t.jsxs("div",{className:"settings-item-info",children:[t.jsx("span",{className:"settings-item-label",children:e}),t.jsxs("span",{className:"settings-item-description",children:["Device ID: chromeos:",e]})]}),t.jsx("div",{className:"settings-item-action",children:t.jsx("button",{type:"button",className:"settings-button",onClick:()=>{B(e)},disabled:v,children:s("emulatorRemove")})})]},e))]})]}),t.jsx(A,{children:t.jsxs("div",{className:"settings-group",children:[t.jsx("h3",{children:s("emulatorDiscoveredDevicesTitle")}),i&&t.jsx("p",{className:"settings-muted",children:s("projectsLoading")}),f&&t.jsx("p",{className:"settings-error",children:f}),!i&&l.length===0&&t.jsx("p",{className:"settings-muted",children:s("emulatorNoDevicesFound")}),l.map(e=>t.jsxs("div",{className:"settings-item",children:[t.jsxs("div",{className:"settings-item-info",children:[t.jsx("span",{className:"settings-item-label",children:e.label||e.avd||e.id}),t.jsxs("span",{className:"settings-item-description",children:[e.type," - ",e.id," - ",e.state]})]}),t.jsx("div",{className:"settings-item-action",children:G(e.type,e.state,e.actions)?t.jsx("button",{type:"button",className:"settings-button",onClick:()=>k(e.id),children:s("emulatorStop")}):q(e.type,e.state,e.actions)?t.jsx("button",{type:"button",className:"settings-button",onClick:()=>F(e.id),children:s("emulatorStart")}):null})]},e.id))]})})]}):null]})}export{fe as EmulatorSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as m,r as l,j as t}from"./index-umZg0LZ6.js";import{a as f}from"./client-Ci_HPGfl.js";import{S as x}from"./SettingsItem-C9Vh5p7F.js";import{u as j,j as S,H as h}from"./index-BkOdUxq4.js";import{S as N}from"./SettingsSection-BaPzETK6.js";import"./react-runtime-D-UPQ57m.js";import"./RelayProtocol-BpdH0COG.js";import"./PageHeader-BjwH2pWD.js";import"./LocalMediaModal-B9eHVx6y.js";import"./Modal-ClSjJagX.js";import"./remoteRoutePaths-D8htA0xa.js";import"./newSessionPrefill-DKcy0abh.js";import"./relay-url-j3kYm5KO.js";import"./appHref-ByaEnJGJ.js";import"./SessionHeader.module-BpaFAQ-S.js";import"./HostIdentityContext-DA7dMF-y.js";import"./frontendReload-CBdyvvdy.js";import"./NavigationLayout-BTFsWVtE.js";import"./useSidebarWidth-CBCcbSLg.js";import"./useFileActivity-BoW4X3DY.js";import"./providerChildSessions-DbLFSybt.js";import"./katex-Dv2p4YRM.js";import"./index-CoR-vzsb.js";import"./ProviderBadge-P0VTI71n.js";import"./YepAnywhereLogo-5zFKWjQq.js";import"./index-Cv3tQXyE.js";const E="_filter_a5a08_3",w="_group_a5a08_17",b="_groupTitle_a5a08_21",T="_row_a5a08_29",B="_unset_a5a08_36",U="_head_a5a08_40",V="_name_a5a08_47",$="_secretBadge_a5a08_54",A="_value_a5a08_64",C="_valueUnset_a5a08_72",I="_description_a5a08_78",L="_note_a5a08_85",n={filter:E,group:w,groupTitle:b,row:T,unset:B,head:U,name:V,secretBadge:$,value:A,valueUnset:C,description:I,note:L};function M(e){const s=[],i=new Map;for(const r of e){let a=i.get(r.group);a||(a={group:r.group,entries:[]},i.set(r.group,a),s.push(a)),a.entries.push(r)}return s}function pe(){const{t:e}=m();j(e("environmentSectionTitle"));const[s,i]=l.useState(null),[r,a]=l.useState(!1),[c,v]=l.useState(!1),u=S();l.useEffect(()=>{let o=!1;return f.getEnvSettings().then(p=>{o||i(p.entries)}).catch(()=>{o||a(!0)}),()=>{o=!0}},[]);const d=l.useMemo(()=>(s==null?void 0:s.filter(o=>u||c||o.set))??[],[s,u,c]),g=l.useMemo(()=>M(d),[d]),_=(s==null?void 0:s.filter(o=>o.set).length)??0;return t.jsxs(N,{description:e("environmentSectionDescription"),children:[t.jsxs(h,{children:[r&&t.jsx("p",{className:"settings-warning",children:e("environmentLoadError")}),!r&&s===null&&t.jsx("p",{children:e("environmentLoading")}),!r&&s&&t.jsxs("label",{className:n.filter,children:[t.jsx("span",{children:e("environmentShowLabel")}),t.jsxs("select",{className:"settings-select",value:c?"all":"set",onChange:o=>v(o.target.value==="all"),children:[t.jsx("option",{value:"set",children:e("environmentShowSet",{count:_})}),t.jsx("option",{value:"all",children:e("environmentShowAll",{count:s.length})})]})]}),!r&&s&&!c&&g.length===0&&t.jsx("p",{className:"settings-empty",children:e("environmentEmptySet")})]}),g.map(o=>t.jsxs("div",{className:`settings-group ${n.group}`,children:[t.jsx(h,{children:t.jsx("h3",{className:n.groupTitle,children:o.group})}),o.entries.map(p=>t.jsx(H,{entry:p},p.name))]},o.group))]})}function H({entry:e}){const{t:s}=m();return t.jsxs(x,{label:e.name,description:e.description,keywords:[e.group,e.note].filter(i=>!!i),layout:"custom",baseClassName:n.row,className:e.set?void 0:n.unset,children:[t.jsxs("div",{className:n.head,children:[t.jsx("code",{className:n.name,children:e.name}),e.secret&&t.jsx("span",{className:n.secretBadge,children:s("environmentSecretBadge")}),t.jsx(R,{entry:e})]}),t.jsx("p",{className:n.description,children:e.description}),e.note&&t.jsx("p",{className:n.note,children:e.note})]})}function R({entry:e}){const{t:s}=m();return e.set?e.value===""?t.jsx("span",{className:`${n.value} ${n.valueUnset}`,children:s("environmentValueEmpty")}):t.jsx("code",{className:n.value,children:e.value}):t.jsx("span",{className:`${n.value} ${n.valueUnset}`,children:s("environmentValueNotSet")})}export{pe as EnvironmentSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as f,a as j,b as h,j as e,L as o}from"./index-umZg0LZ6.js";import{G as u,F as g,B as x}from"./providerChildSessions-DbLFSybt.js";import{u as v,S as P}from"./NavigationLayout-BTFsWVtE.js";import{u as b}from"./Modal-ClSjJagX.js";import"./react-runtime-D-UPQ57m.js";import"./client-Ci_HPGfl.js";import"./RelayProtocol-BpdH0COG.js";import"./LocalMediaModal-B9eHVx6y.js";import"./newSessionPrefill-DKcy0abh.js";import"./relay-url-j3kYm5KO.js";import"./appHref-ByaEnJGJ.js";import"./katex-Dv2p4YRM.js";import"./remoteRoutePaths-D8htA0xa.js";import"./index-CoR-vzsb.js";import"./ProviderBadge-P0VTI71n.js";import"./frontendReload-CBdyvvdy.js";import"./useSidebarWidth-CBCcbSLg.js";import"./useFileActivity-BoW4X3DY.js";import"./YepAnywhereLogo-5zFKWjQq.js";function q(){const{t:i}=f(),{openSidebar:r}=v(),a=b(),{projectId:s}=j(),[t]=h(),n=t.get("path"),c=l(t.get("line")),d=l(t.get("lineEnd")),p=N(t.get("diff")),m=t.get("view")==="range"?"range":"full";return s?n?e.jsx(u,{projectId:s,children:e.jsx("div",{className:"file-page",children:e.jsx("div",{className:"file-page-content",children:e.jsx(g,{projectId:s,filePath:n,lineNumber:c,lineEnd:d,viewMode:m,diffMode:p,standalone:!0,headerLeading:e.jsxs(e.Fragment,{children:[e.jsx(P,{label:i("actionOpenSidebar"),newSessionLabel:i("sidebarNewSession"),onActivate:r}),e.jsx(o,{to:`${a}/projects/${s}`,className:"file-viewer-action",title:i("fileBackToProject"),"aria-label":i("fileBackToProject"),children:e.jsx(x,{})})]})})})})}):e.jsx("div",{className:"file-page file-page-error",children:e.jsxs("div",{className:"file-page-error-content",children:[e.jsx("h1",{children:i("fileInvalidUrl")}),e.jsx("p",{children:i("fileMissingPath")}),e.jsx(o,{to:`${a}/projects/${s}`,className:"file-page-back-link",children:i("fileGoToProject")})]})}):e.jsx("div",{className:"file-page file-page-error",children:e.jsxs("div",{className:"file-page-error-content",children:[e.jsx("h1",{children:i("fileInvalidUrl")}),e.jsx("p",{children:i("fileMissingProjectId")}),e.jsx(o,{to:`${a}/projects`,className:"file-page-back-link",children:i("fileGoToProjects")})]})})}function N(i){return i==="worktree"||i==="cumulative"?i:void 0}function l(i){if(!i)return;const r=Number(i);if(!(!Number.isInteger(r)||r<1))return r}export{q as FilePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as M,r as c,j as t,ax as T}from"./index-umZg0LZ6.js";const $="_container_1m95j_12",q="_button_1m95j_17",G="_buttonLabel_1m95j_34",H="_chevron_1m95j_41",J="_chip_1m95j_50",Q="_hasSelection_1m95j_48",U="_fullWidth_1m95j_74",V="_optionIcon_1m95j_84",X="_overlay_1m95j_96",Y="_sheet_1m95j_106",Z="_header_1m95j_127",ee="_title_1m95j_135",ne="_options_1m95j_141",te="_option_1m95j_84",se="_selected_1m95j_170",oe="_checkbox_1m95j_174",re="_checked_1m95j_188",ce="_checkboxSpacer_1m95j_194",le="_singleSelect_1m95j_201",ae="_colorDot_1m95j_206",ie="_labelWrapper_1m95j_213",de="_meta_1m95j_221",ue="_label_1m95j_213",he="_description_1m95j_231",_e="_count_1m95j_237",me="_clear_1m95j_245",pe="_divider_1m95j_253",je="_groupLabel_1m95j_259",fe="_dropdown_1m95j_268",be="_model_1m95j_279",xe="_alignRight_1m95j_330",n={container:$,button:q,buttonLabel:G,chevron:H,chip:J,hasSelection:Q,fullWidth:U,optionIcon:V,overlay:X,sheet:Y,header:Z,title:ee,options:ne,option:te,selected:se,checkbox:oe,checked:re,checkboxSpacer:ce,singleSelect:le,colorDot:ae,labelWrapper:ie,meta:de,label:ue,description:he,count:_e,clear:me,divider:pe,groupLabel:je,dropdown:fe,model:be,alignRight:xe},y=769;function a(...l){return l.filter(Boolean).join(" ")}function ke({label:l,options:f,selected:o,onChange:i,multiSelect:u=!0,placeholder:N,placeholderContent:L,triggerContent:S,triggerTitle:v,align:E="left",fullWidth:k=!1,triggerVariant:C="default",panelVariant:D="default",triggerClassName:B,className:g=""}){const{t:h}=M(),[r,p]=c.useState(!1),[d,W]=c.useState(()=>window.innerWidth>=y),j=c.useRef(null),_=c.useRef(null),R=()=>{var e;(e=j.current)==null||e.blur(),p(s=>!s)},I=f.some(e=>e.clearSelection),O=e=>{if(e.disabled)return;if(e.clearSelection){i([]),p(!1);return}const{value:s}=e;u?o.includes(s)?i(o.filter(x=>x!==s)):i([...o,s]):(o.includes(s)?i([]):i([s]),p(!1))},P=()=>{i([])},m=c.useCallback(()=>{p(!1)},[]);c.useEffect(()=>{const e=()=>{W(window.innerWidth>=y)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),c.useEffect(()=>{if(!r)return;const e=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),m())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[r,m]),c.useEffect(()=>{if(!r||!d)return;const e=s=>{_.current&&!_.current.contains(s.target)&&j.current&&!j.current.contains(s.target)&&m()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,d,m]),c.useEffect(()=>{if(r&&!d)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r,d]),c.useEffect(()=>{var e;r&&((e=_.current)==null||e.focus({preventScroll:!0}))},[r]);const F=e=>{e.target===e.currentTarget&&(e.preventDefault(),e.stopPropagation(),m())},z=(()=>{if(o.length===0)return L??N??l;if(o.length===1){const e=f.find(s=>s.value===o[0]);return(e==null?void 0:e.label)||l}return`${l} (${o.length})`})(),b=D==="model",w=t.jsxs(t.Fragment,{children:[u&&o.length>0&&!I&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:a(n.option,n.clear),onClick:P,children:t.jsx("span",{className:n.label,children:h("filterClearAll")})}),t.jsx("div",{className:n.divider})]}),f.map(e=>{const s=e.clearSelection?o.length===0:o.includes(e.value),x=u&&!e.clearSelection;return t.jsxs(c.Fragment,{children:[(e.dividerBefore||e.groupLabelBefore)&&t.jsx("div",{className:n.divider}),e.groupLabelBefore&&t.jsx("div",{className:n.groupLabel,children:e.groupLabelBefore}),t.jsxs("button",{type:"button",className:a(n.option,s&&n.selected,!u&&n.singleSelect,b&&n.model),onClick:()=>O(e),disabled:e.disabled,"aria-pressed":s,children:[x&&t.jsx("span",{className:a(n.checkbox,s&&n.checked),"aria-hidden":"true",children:s&&t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}),u&&e.clearSelection&&t.jsx("span",{className:n.checkboxSpacer,"aria-hidden":"true"}),e.color&&t.jsx("span",{className:n.colorDot,style:{backgroundColor:e.color},"aria-hidden":"true"}),e.icon&&t.jsx("span",{className:a(n.optionIcon,b&&n.model),"aria-hidden":"true",children:e.icon}),t.jsxs("span",{className:n.labelWrapper,children:[t.jsx("span",{className:n.label,children:e.label}),e.description&&t.jsx("span",{className:n.description,children:e.description})]}),e.meta&&t.jsx("span",{className:n.meta,children:e.meta}),e.count!==void 0&&t.jsx("span",{className:n.count,children:e.count})]})]},e.value)})]}),A=r&&!d?T.createPortal(t.jsx("div",{className:n.overlay,onClick:F,onMouseDown:e=>e.stopPropagation(),children:t.jsxs("div",{ref:_,className:a(n.sheet,g),role:"dialog",tabIndex:-1,"aria-label":h("filterByLabel",{label:l}),children:[t.jsx("div",{className:n.header,children:t.jsx("span",{className:n.title,children:l})}),t.jsx("div",{className:n.options,children:w})]})}),document.body):null,K=r&&d?t.jsx("div",{ref:_,className:a(n.dropdown,E==="right"&&n.alignRight,b&&n.model),role:"dialog",tabIndex:-1,"aria-label":h("filterByLabel",{label:l}),children:t.jsx("div",{className:n.options,children:w})}):null;return t.jsxs("div",{className:a(n.container,k&&n.fullWidth,g),children:[t.jsxs("button",{ref:j,type:"button",className:a(n.button,o.length>0&&n.hasSelection,k&&n.fullWidth,C==="chip"&&n.chip,B),onClick:R,title:v??h("filterByLabel",{label:l}),"aria-label":v??h("filterByLabel",{label:l}),"aria-haspopup":"listbox","aria-expanded":r,children:[t.jsx("span",{className:n.buttonLabel,children:S??z}),t.jsx("svg",{className:n.chevron,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),K,A]})}export{ke as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_1m95j_12{position:relative;display:inline-block}._button_1m95j_17{display:flex;align-items:center;gap:var(--space-2);padding:var(--space-2) var(--space-3);background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:var(--radius-md);font-size:var(--font-size-sm);color:var(--text-muted);cursor:pointer;white-space:nowrap;transition:border-color .15s ease,background .15s ease}._buttonLabel_1m95j_34{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis}._chevron_1m95j_41{flex-shrink:0;transition:transform .15s ease}._button_1m95j_17._chip_1m95j_50{padding:2px 4px;background:transparent;border:none}._button_1m95j_17._chip_1m95j_50 ._chevron_1m95j_41{width:10px;height:10px}._button_1m95j_17:hover{background:var(--bg-hover)}._button_1m95j_17._hasSelection_1m95j_48{border-color:var(--app-yep-green);color:var(--text-primary)}._container_1m95j_12._fullWidth_1m95j_74{width:100%}._button_1m95j_17._fullWidth_1m95j_74{width:100%;min-width:0;justify-content:space-between}._optionIcon_1m95j_84{display:inline-flex;align-items:center;justify-content:center}._optionIcon_1m95j_84 svg{width:15px;height:15px;flex-shrink:0}._overlay_1m95j_96{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:10001;display:flex;align-items:flex-end;justify-content:center}._sheet_1m95j_106{background:var(--bg-surface);border-radius:var(--radius-lg) var(--radius-lg) 0 0;width:100%;max-width:500px;max-height:80vh;overflow-y:auto;animation:_slideUp_1m95j_1 .2s ease-out;box-shadow:0 -4px 20px #0000004d;padding-bottom:env(safe-area-inset-bottom,0)}@keyframes _slideUp_1m95j_1{0%{transform:translateY(100%)}to{transform:translateY(0)}}._header_1m95j_127{display:flex;align-items:center;justify-content:center;padding:var(--space-3) var(--space-4);border-bottom:1px solid var(--border-subtle)}._title_1m95j_135{font-size:var(--font-size-base);font-weight:600;color:var(--text-primary)}._options_1m95j_141{display:flex;flex-direction:column;padding:var(--space-2) 0}._option_1m95j_84{display:flex;align-items:center;gap:var(--space-3);padding:var(--space-3) var(--space-4);background:transparent;border:none;cursor:pointer;text-align:left;width:100%;transition:background .15s ease;color:var(--text-primary)}._option_1m95j_84:hover:not(:disabled){background:var(--bg-hover)}._option_1m95j_84:disabled{cursor:not-allowed;opacity:.55}._option_1m95j_84._selected_1m95j_170{background:#d9775714}._checkbox_1m95j_174{width:18px;height:18px;border:2px solid var(--border-color);border-radius:var(--radius-sm);display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:border-color .15s ease,background .15s ease}._checkbox_1m95j_174._checked_1m95j_188{background:var(--app-yep-green);border-color:var(--app-yep-green);color:#fff}._checkboxSpacer_1m95j_194{width:18px;height:18px;flex-shrink:0}._option_1m95j_84._singleSelect_1m95j_201{position:relative;padding-right:var(--space-8)}._colorDot_1m95j_206{width:10px;height:10px;border-radius:50%;flex-shrink:0}._labelWrapper_1m95j_213{flex:1;display:flex;flex-direction:column;gap:2px;min-width:0}._meta_1m95j_221{display:inline-flex;align-items:center;flex-shrink:0}._label_1m95j_213{font-size:var(--font-size-base)}._description_1m95j_231{font-size:var(--font-size-xs);color:var(--text-muted);line-height:1.3}._count_1m95j_237{font-size:var(--font-size-xs);color:var(--text-muted);background:var(--bg-secondary);padding:var(--space-1) var(--space-2);border-radius:var(--radius-sm)}._clear_1m95j_245 ._label_1m95j_213{color:var(--text-muted)}._clear_1m95j_245:hover ._label_1m95j_213{color:var(--text-primary)}._divider_1m95j_253{height:1px;background:var(--border-subtle);margin:var(--space-2) var(--space-4)}._groupLabel_1m95j_259{padding:var(--space-1) var(--space-4);color:var(--text-muted);font-size:var(--font-size-xs);font-weight:600;letter-spacing:.02em;text-transform:uppercase}._dropdown_1m95j_268{display:none}._option_1m95j_84._model_1m95j_279{align-items:flex-start;gap:var(--space-2)}._optionIcon_1m95j_84._model_1m95j_279{justify-content:flex-start;flex-shrink:0;min-width:96px;margin-top:2px}@media(max-width:600px){._container_1m95j_12{width:100%;min-width:0}._button_1m95j_17{width:100%;min-width:0;justify-content:space-between}}@media(min-width:769px){._dropdown_1m95j_268{display:block;position:absolute;top:100%;left:0;margin-top:var(--space-1);background:var(--bg-surface);border:1px solid var(--border-subtle);border-radius:var(--radius-lg);min-width:200px;max-height:min(60vh,480px);overflow-y:auto;overscroll-behavior:contain;box-shadow:0 4px 12px #00000026;z-index:100;animation:_dropdownFadeIn_1m95j_1 .15s ease-out}._dropdown_1m95j_268._alignRight_1m95j_330{left:auto;right:0}._dropdown_1m95j_268 ._options_1m95j_141{padding:var(--space-1) 0}._dropdown_1m95j_268 ._option_1m95j_84{padding:var(--space-2) var(--space-3)}._dropdown_1m95j_268 ._divider_1m95j_253{margin:var(--space-1) var(--space-3)}._dropdown_1m95j_268 ._groupLabel_1m95j_259{padding-inline:var(--space-3)}._dropdown_1m95j_268._model_1m95j_279{width:360px}@keyframes _dropdownFadeIn_1m95j_1{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}._overlay_1m95j_96{display:none}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,u as re,d as Te,e as Ce,j as o,aG as ye}from"./index-umZg0LZ6.js";import{r as Re}from"./types-BHkriVjU.js";import{g as De,a as Pe}from"./newSessionDefaults-C6a9Cpc6.js";import{g as Ee}from"./useModelSettings-BdlYk1DT.js";import{u as Me,b as Ne,c as je}from"./useProviders-CeN1PclA.js";import{a as we}from"./frontendReload-CBdyvvdy.js";import{u as ke,f as ee,c as Be,h as Le}from"./speechDraftTransaction-WhqFE1h9.js";import{D as Ke,a as Fe,S as We,c as Ae,e as _e,s as $e}from"./useSidebarWidth-CBCcbSLg.js";import{u as Ve,V as Oe}from"./VoiceInputButton-CCgovfyf.js";import{u as Ue}from"./useFloatingActionButtonEnabled-2_hw7nSa.js";import{s as He}from"./newSessionPrefill-DKcy0abh.js";import{u as ze}from"./Modal-ClSjJagX.js";import{b as Ge}from"./client-Ci_HPGfl.js";import{g as te,a as qe,b as Xe,c as Je,d as X,e as Qe,t as Ye,m as Ze,f as et,r as ne}from"./YaServerProvider-CN3tC5UL.js";import{P as tt}from"./ProviderBadge-P0VTI71n.js";import"./react-runtime-D-UPQ57m.js";import"./deviceDetection-BVPclkty.js";import"./remoteRoutePaths-D8htA0xa.js";import"./RelayProtocol-BpdH0COG.js";function nt(){const{providers:c,loading:a}=Me(),{settings:p,isLoading:v}=we();return n.useMemo(()=>{if(a||v||c.length===0)return null;const I=new Set(Ne(c).map(T=>T.name)),h=p==null?void 0:p.newSessionDefaults,j=h!=null&&h.provider&&I.has(h.provider)?h.provider:null,x=c.find(T=>T.name===j)??je(c);if(!x)return null;const m=De(h,x.name,{model:x.name==="claude"?Re(Ee()):void 0});return{provider:x.name,modelId:Pe(x.name,x.models??[],m.model)}},[c,a,p,v])}const rt=830,st=100,J=24,it=80;function ot(c,a){const p=c-a,v=Math.min(p,rt);return(p-v)/2}function ct(){const c=Ve();return n.useMemo(()=>{if(c<Ke)return null;const a=Fe(),v=c<a+600?We:a,I=ot(c,v),h=st+J*2;if(I<h)return null;const j=J,x=Math.min(I-J*2,300);return{visible:!0,right:j,bottom:it,maxWidth:x}},[c])}function at(){return`speech-target-${ye()}`}function lt(){const{t:c}=re(),a=nt();return a?o.jsx("span",{className:"composer-model-chip-static",title:c("floatingComposerModelChipTitle"),children:o.jsx(tt,{provider:a.provider,model:a.modelId??void 0})}):null}function Mt(){const{t:c}=re(),a=Te(),p=Ce(),v=ze(),I=Ge(),h=n.useMemo(()=>Ae(I),[I]),j=ct(),{floatingActionButtonEnabled:x}=Ue(),[m,T]=n.useState(!1),[g,se,d]=ke(h),[w,K]=n.useState(""),y=n.useRef(w);y.current=w;const[U,Q]=n.useState(null),A=n.useRef(null),[,_]=n.useState(0),R=n.useRef(null),D=n.useRef(null),H=n.useRef(null),l=n.useRef(null),u=n.useRef(null),S=n.useRef(new Map),P=n.useRef(null),M=n.useRef(null),$=n.useRef(null),z=n.useRef(!1),V=n.useRef(null),F=l.current,O=te(g,w,F),W=F?qe(g,O,F.end,F.replaceEnd??F.end):Xe(g,O,g.length),k=_e(p.pathname);n.useEffect(()=>{k&&$e(k)},[k]),n.useEffect(()=>{var e,t;m&&((e=R.current)==null||e.focus(),(t=D.current)==null||t.prewarm())},[m]),n.useLayoutEffect(()=>{const e=V.current,t=R.current;!e||!t||g!==e.value||t.value!==e.value||(V.current=null,e.restore(t))},[g]),n.useEffect(()=>{if(!m)return;const e=t=>{H.current&&!H.current.contains(t.target)&&T(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m]);const B=n.useCallback(e=>{const t=typeof e=="string"?e:void 0,r=D.current;if(t===void 0&&((r==null?void 0:r.isListening)===!0||A.current!==null)){$.current=Je(d.getDraft(),y.current,l.current),r!=null&&r.isListening&&r.stopAndFinalize();return}const s=(t??g).trim();if(s){if(He(I,s),d.clearDraft(),T(!1),k){a(`${v}/new-session?projectId=${encodeURIComponent(k)}`);return}a(`${v}/new-session`)}},[g,k,a,d,v,I]),ie=e=>{var t;if(!(e.key==="Enter"&&e.nativeEvent.isComposing)){if(e.key==="Escape"&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&(U==="transcribing"||U==="finalizing")){e.preventDefault(),e.stopPropagation(),pe();return}if(e.key==="Escape"&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&((t=D.current)!=null&&t.isListening)){e.preventDefault(),e.stopPropagation(),D.current.toggle();return}e.key==="Enter"&&!e.shiftKey?(e.preventDefault(),B()):e.key==="Escape"&&T(!1)}},oe=n.useCallback(()=>{T(!0)},[]),ce=n.useCallback(()=>{const e=R.current,t=d.getDraft(),r=Math.max(0,Math.min((e==null?void 0:e.selectionStart)??t.length,t.length)),s=Math.max(r,Math.min((e==null?void 0:e.selectionEnd)??r,t.length)),i=at(),f=et(r,s);u.current=i,l.current=f,S.current.set(i,f),V.current=null,P.current=null,z.current=!1,e&&(ee(e),e.setSelectionRange(r,s)),y.current="",K("")},[d]),b=n.useCallback(()=>{const e=M.current;e!==null&&(clearTimeout(e.timer),M.current=null)},[]);n.useEffect(()=>b,[b]);const E=n.useCallback((e,t)=>{var Z;const r=e!==void 0,s=R.current,i=l.current;if(!s||!i)return;const f=s.selectionStart,L=s.selectionEnd,xe=C=>f===L?A.current==="listening"?ne(C,f,L):X(C):C.replaceSelectedAtMs===void 0&&C.end===f&&C.replaceEnd===L?C:ne(C,f,L);f===L&&b();const Ie=y.current.trim().length>0;if(r&&(Ie||P.current!==null)){P.current={draft:t??d.getDraft(),start:f,end:L};return}const q=xe(i);A.current==="listening"&&q!==i&&((Z=D.current)==null||Z.beginInsertionBoundary()),l.current=q,u.current&&S.current.set(u.current,q),_(C=>C+1)},[b,d]),G=n.useCallback(()=>{if(b(),!l.current)return;const e=X(l.current);l.current=e,u.current&&S.current.set(u.current,e),_(t=>t+1)},[b]),ae=n.useCallback(()=>{window.setTimeout(()=>E(!0),0)},[E]),N=n.useCallback((e,t)=>{const r=Be({textareaRef:R,getDraft:d.getDraft,setDraft:d.setDraft,setInterimTranscript:i=>{y.current=i,K(i)},speechInsertionRangeRef:l,activeSpeechTargetIdRef:u,speechInsertionRangesRef:S,pendingTextareaSelectionRef:V,pendingSpeechRetargetRef:P,onInsertionBoundary:()=>{var i;return(i=D.current)==null?void 0:i.beginInsertionBoundary()},onSpeechTargetChanged:()=>_(i=>i+1),onSmartTurnSend:B,composerEditedDuringSpeech:()=>z.current},e,t),s=t==null?void 0:t.speechTargetId;return s&&s!==u.current&&S.current.delete(s)&&_(i=>i+1),r},[d,B]),le=n.useCallback((e,t)=>{const r=t!=null&&t.speechTargetId?S.current.get(t.speechTargetId)??null:l.current,s=t!=null&&t.smartTurnCommand||P.current?0:Qe(r);if(s>0){b();const i=setTimeout(()=>{const f=M.current;!f||f.timer!==i||(M.current=null,N(f.transcript,f.metadata))},s);M.current={timer:i,transcript:e,metadata:t};return}return b(),N(e,t)},[b,N]),Y=n.useCallback(()=>{const e=M.current;e!==null&&(clearTimeout(e.timer),M.current=null,N(e.transcript,e.metadata))},[N]),ue=n.useCallback(()=>{const e=te(d.getDraft(),y.current,l.current);return Y(),e&&N(e),P.current=null,y.current="",K(""),ee(R.current),!!e},[N,d,Y]),de=n.useCallback(e=>{y.current=e,K(e)},[]),fe=n.useCallback((e,t)=>{if(A.current=e,e==="listening"&&E(),e===null){const r=u.current;r&&S.current.delete(r),l.current=null,u.current=null,P.current=null;const s=$.current;$.current=null,t==="completed"&&s!==null&&B(s)}Q(e)},[E,B]),pe=n.useCallback(()=>{var t;(t=D.current)==null||t.cancelProcessing(),b();const e=u.current;e&&S.current.delete(e),l.current=null,u.current=null,P.current=null,$.current=null,Q(null),K("")},[b]),he=n.useCallback(()=>{const e=d.getDraft();return{draftKey:h,speechTargetId:u.current??void 0,textBeforeCursor:Ye(e,l.current,R.current)}},[d,h]),me=/\/sessions\/[^/]+/.test(p.pathname),ge=!x||!j||p.pathname.endsWith("/new-session")||me,{right:be,bottom:Se,maxWidth:ve}=j??{right:24,bottom:80,maxWidth:200};return o.jsxs("div",{ref:H,className:`fab-container ${m?"fab-expanded":"fab-collapsed"}`,style:{right:`${be}px`,bottom:`${Se}px`,width:`${ve}px`,display:ge?"none":void 0},children:[m&&o.jsxs("div",{className:"fab-input-panel",children:[o.jsxs("div",{className:`speech-draft-field ${O?"has-interim":""}`,children:[o.jsxs("div",{className:"speech-draft-inline",children:[O&&o.jsxs("div",{className:"speech-draft-mirror","aria-hidden":"true",children:[o.jsx("span",{children:W.before}),W.separatorBefore,o.jsx("span",{className:"speech-interim-inline",children:W.transcript}),o.jsx("span",{className:"speech-interim-caret"}),W.separatorAfter,o.jsx("span",{children:W.after})]}),o.jsx("textarea",{ref:R,value:g,onChange:e=>{const t=e.target.value;if(b(),S.current.size>0){const r=new Map;for(const[s,i]of S.current)r.set(s,X(Ze(g,t,i)));S.current=r,l.current=u.current!==null?r.get(u.current)??null:null}u.current!==null&&Le(g,t)&&(z.current=!0),E(!0,t),se(t)},onKeyDown:ie,onSelect:E,onPointerUp:E,onClick:ae,onKeyUp:E,onCut:G,onCopy:G,onPaste:G,placeholder:c("fabPlaceholder"),className:"fab-textarea",rows:3})]}),w&&o.jsx("div",{className:"speech-interim-status",role:"status","aria-live":"polite","aria-label":"Tentative speech transcript",children:w})]}),o.jsxs("div",{className:"fab-input-toolbar",children:[o.jsx(lt,{}),o.jsx(Oe,{ref:D,onTranscript:le,onInterimTranscript:de,onListeningStart:ce,onListeningStop:ue,onPendingSpeechChange:fe,getTranscriptionContext:he,className:"toolbar-button"}),o.jsx("button",{type:"button",className:"fab-submit",onClick:B,disabled:!(g.trim()||U!==null||w),"aria-label":c("fabGoToNewSession"),children:"↵"})]})]}),o.jsx("button",{type:"button",className:`fab-button ${m?"fab-button-active":""}`,onClick:m?()=>T(!1):oe,"aria-label":c(m?"fabClose":"fabNewSession"),children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:m?"fab-icon-rotated":"",children:[o.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),o.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]})}export{Mt as FloatingActionButton};
|