yepanywhere 0.9.1 → 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__/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/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/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/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/package.json +1 -1
- package/client-dist/assets/{AboutSettings-CHsaLshd.js → AboutSettings-CCzudbSj.js} +1 -1
- package/client-dist/assets/{ActivityPage-CBVcBckm.js → ActivityPage-Bn0LbMgE.js} +1 -1
- package/client-dist/assets/{AgentContextSettings-DLLaiwUX.js → AgentContextSettings-DI8jQVIx.js} +1 -1
- package/client-dist/assets/{AgentsPage-C3_U9MGs.js → AgentsPage-Ci_iJt8T.js} +1 -1
- package/client-dist/assets/App-rFnK5pnF.js +2 -0
- package/client-dist/assets/AppearanceSettings-DTYVt0W5.js +2 -0
- package/client-dist/assets/{AppsSettings-B1BIWKaz.js → AppsSettings-hbh_sguk.js} +1 -1
- package/client-dist/assets/{AttachmentChip-CQTl9l1O.js → AttachmentChip-BFve3lTD.js} +1 -1
- package/client-dist/assets/{AuthContext-BQK10GgC.js → AuthContext-DmXjW0be.js} +1 -1
- package/client-dist/assets/{BangCommandDisplayObject-BDGW0BZN.js → BangCommandDisplayObject-BH2KRGnc.js} +1 -1
- package/client-dist/assets/{BangCommandsPage-C1-n2iHi.js → BangCommandsPage-MfkuL8yS.js} +1 -1
- package/client-dist/assets/{BrowserDebugToolbarButton-CRE47FFy.js → BrowserDebugToolbarButton-BPghQu17.js} +1 -1
- package/client-dist/assets/{CacheMissBillingSettings-BspB12sl.js → CacheMissBillingSettings-rUgC-_DD.js} +1 -1
- package/client-dist/assets/{CodexUpdatePrompt-BXTqvclk.js → CodexUpdatePrompt-mT9K-f1e.js} +1 -1
- package/client-dist/assets/{CommittedRangeInput-bK7EXtAc.js → CommittedRangeInput-BwuV6Q6c.js} +1 -1
- package/client-dist/assets/{CommittedRangeNumberInput-bGOjN2Xv.js → CommittedRangeNumberInput-C5YSVltB.js} +1 -1
- package/client-dist/assets/{ComputerControlSettings-BLA4wsEA.js → ComputerControlSettings-MWIdP7SS.js} +1 -1
- package/client-dist/assets/{ConversationPreviewPage-rxHQQOck.js → ConversationPreviewPage-B47r7mUF.js} +2 -2
- package/client-dist/assets/{DevelopmentSettings-CFo3ctnP.js → DevelopmentSettings-BEAy_xq-.js} +1 -1
- package/client-dist/assets/{DevicesSettings-DPdJOmEQ.js → DevicesSettings-DKQOZkRN.js} +1 -1
- package/client-dist/assets/{EmulatorPage-RPHDvihL.js → EmulatorPage-DlsPq3nR.js} +1 -1
- package/client-dist/assets/{EmulatorSettings-8dHy0xqk.js → EmulatorSettings-C6Ye1k_Y.js} +1 -1
- package/client-dist/assets/{EnvironmentSettings-DaFyodJV.js → EnvironmentSettings-ou8UNqTa.js} +1 -1
- package/client-dist/assets/{FilePage-BwbKyIGF.js → FilePage-Cw2PaO5H.js} +1 -1
- package/client-dist/assets/{FilterDropdown-BiB5gAUh.js → FilterDropdown-CACc6ysA.js} +1 -1
- package/client-dist/assets/{FloatingActionButton-DEiaqWhv.js → FloatingActionButton-Bl1Eumxh.js} +1 -1
- package/client-dist/assets/{GitStatusPage-CSXr__tv.js → GitStatusPage-CLTkgnDI.js} +1 -1
- package/client-dist/assets/{GlobalSessionsPage-C-CbcZjC.js → GlobalSessionsPage-Bvzs4zmW.js} +1 -1
- package/client-dist/assets/{HeartbeatTextArea-DWZZh0eE.js → HeartbeatTextArea-CtP5kx9R.js} +1 -1
- package/client-dist/assets/{HostIdentityContext-DbEx7dor.js → HostIdentityContext-DA7dMF-y.js} +1 -1
- package/client-dist/assets/{HostsPage-BRlkrB-8.js → HostsPage-CBOYGC2-.js} +1 -1
- package/client-dist/assets/{InboxContext-DtjKccKZ.js → InboxContext-8PXoTbK1.js} +1 -1
- package/client-dist/assets/{InboxPage-DFaLlFm5.js → InboxPage-DWl7uzdw.js} +1 -1
- package/client-dist/assets/{IssueSettings-CHjLBTZK.js → IssueSettings-BVljRpuD.js} +1 -1
- package/client-dist/assets/{IssuesPage-CfYD-jwK.js → IssuesPage-BFxgsMkf.js} +1 -1
- package/client-dist/assets/{LifecycleWebhooksSettings-Ir3_1MvY.js → LifecycleWebhooksSettings-Qw_dN3F3.js} +1 -1
- package/client-dist/assets/{LocalAccessSettings-BVh3wBDY.js → LocalAccessSettings-SWirs75o.js} +1 -1
- package/client-dist/assets/LocalMediaModal-B3KXtyEB.css +1 -0
- package/client-dist/assets/LocalMediaModal-B9eHVx6y.js +14 -0
- package/client-dist/assets/{LoginPage-irZxKYu1.js → LoginPage-CYWqVJ95.js} +1 -1
- package/client-dist/assets/{MessageAge-CKdiBg7K.js → MessageAge-CaPpa1nH.js} +1 -1
- package/client-dist/assets/{MessageDeliverySettings-BJ6Hgu1F.js → MessageDeliverySettings-BUSuGKlc.js} +1 -1
- package/client-dist/assets/MessageInput-a13ZPAHv.js +3 -0
- package/client-dist/assets/{MessageInputToolbar-CvUMMGJv.js → MessageInputToolbar-CQGTnVea.js} +3 -3
- package/client-dist/assets/MessageList-C7kAuWKg.js +4 -0
- package/client-dist/assets/{Modal-DOzUIhWU.js → Modal-ClSjJagX.js} +2 -2
- package/client-dist/assets/{ModelSettings-SWaaTKgm.js → ModelSettings-Dnd4yzmI.js} +1 -1
- package/client-dist/assets/{NavigationLayout-D8BMwd7T.js → NavigationLayout-BTFsWVtE.js} +2 -2
- package/client-dist/assets/{NewSessionPage-BBFzYBNs.js → NewSessionPage-BfiAS-Mo.js} +1 -1
- package/client-dist/assets/{NotificationsSettings-0iotA0wy.js → NotificationsSettings-B1ugQIp-.js} +1 -1
- package/client-dist/assets/{PageHeader-Ca3PbaMb.js → PageHeader-BjwH2pWD.js} +1 -1
- package/client-dist/assets/{PerformanceSettings-BgDJMjlN.js → PerformanceSettings-jJYF9SPY.js} +1 -1
- package/client-dist/assets/{ProjectSessionDefaultsModal-LEaPwpSM.js → ProjectSessionDefaultsModal-G_0uxJEv.js} +1 -1
- package/client-dist/assets/{ProjectTemplatesSettings-fPlh8ZpJ.js → ProjectTemplatesSettings-BQTCV3-3.js} +1 -1
- package/client-dist/assets/{ProjectsPage-CiQ3rBB_.js → ProjectsPage-suTd8s9l.js} +1 -1
- package/client-dist/assets/ProviderBadge-P0VTI71n.js +1 -0
- package/client-dist/assets/{ProviderChildSessionDetail-CSAbaZtr.js → ProviderChildSessionDetail-D0472EW8.js} +13 -13
- package/client-dist/assets/ProviderChildSessionPage-9__sgY14.js +1 -0
- package/client-dist/assets/{ProvidersSettings-B327MdUT.js → ProvidersSettings-Bwzy73Rk.js} +1 -1
- package/client-dist/assets/{RecapAfterSecondsControl-DWG9fB4u.js → RecapAfterSecondsControl-CxuXyFSr.js} +1 -1
- package/client-dist/assets/{RelayProtocol-DOWXVB0k.js → RelayProtocol-BpdH0COG.js} +1 -1
- package/client-dist/assets/{RemoteAccessSettings-CBSIP-qP.js → RemoteAccessSettings-Dn7KB5nK.js} +1 -1
- package/client-dist/assets/{RemoteExecutorsSettings-DDAqEB42.js → RemoteExecutorsSettings-Cjl4Y2rB.js} +1 -1
- package/client-dist/assets/{SchemaValidationContext-DLNGXai_.js → SchemaValidationContext-57RCj4c4.js} +1 -1
- package/client-dist/assets/{SearchPreview-BCP67hKg.js → SearchPreview-OzVFWPJZ.js} +1 -1
- package/client-dist/assets/{SessionHeader.module-CHO2T3eQ.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-BWF_CyTI.js → SettingsItem-C9Vh5p7F.js} +1 -1
- package/client-dist/assets/{SettingsSection-DbOwfvBD.js → SettingsSection-BaPzETK6.js} +1 -1
- package/client-dist/assets/{SourceControlSettings-BopLkzc6.js → SourceControlSettings-DnqLg0db.js} +1 -1
- package/client-dist/assets/{SourceFileHeaderActions-HoUciheJ.js → SourceFileHeaderActions-PjhUGnn6.js} +1 -1
- package/client-dist/assets/SpeechControlMenu-BYVdEa3C.js +2 -0
- package/client-dist/assets/{SpeechSettings-B4mB2LIj.js → SpeechSettings-B6LkqfSK.js} +1 -1
- package/client-dist/assets/{SpeechSmartTurnControls-tb5zP_85.js → SpeechSmartTurnControls-LPq9wBaM.js} +1 -1
- package/client-dist/assets/{StorageSettings-B5A0CtTo.js → StorageSettings-DtsJnYaz.js} +1 -1
- package/client-dist/assets/{ThinkingControls-BEweLRqu.js → ThinkingControls-DXbxdJRi.js} +1 -1
- package/client-dist/assets/{ToolbarSettings-CJbxOope.js → ToolbarSettings-Nb2BKpnk.js} +1 -1
- package/client-dist/assets/{UsersSettings-NWqRSGov.js → UsersSettings-BdvqmyqK.js} +1 -1
- package/client-dist/assets/ViewerModePage-DzRIpuYF.js +1 -0
- package/client-dist/assets/{VoiceInputButton-0BzvkjjK.js → VoiceInputButton-CCgovfyf.js} +1 -1
- package/client-dist/assets/{WorkstreamsPage-oM6jTLsK.js → WorkstreamsPage-dlEUllSL.js} +1 -1
- package/client-dist/assets/{YaServerProvider-BNTM9_P9.js → YaServerProvider-CN3tC5UL.js} +1 -1
- package/client-dist/assets/{YepAnywhereLogo-C4H1sg3q.js → YepAnywhereLogo-5zFKWjQq.js} +1 -1
- package/client-dist/assets/{abnfDiagram-VCTEODGH-DIBSwOuB.js → abnfDiagram-VCTEODGH-BWHUBcV3.js} +1 -1
- package/client-dist/assets/{arc-Blz12Cef.js → arc-DKsIJWGD.js} +1 -1
- package/client-dist/assets/{architectureDiagram-5GKGNRK7-CtTnQhBI.js → architectureDiagram-5GKGNRK7-BuLImqW3.js} +1 -1
- package/client-dist/assets/{attachmentFileNames-DwaA5IPB.js → attachmentFileNames-CBV_5g65.js} +1 -1
- package/client-dist/assets/{blockDiagram-I7D4REHJ-BanTkGM6.js → blockDiagram-I7D4REHJ-CJ4Gh6sL.js} +1 -1
- package/client-dist/assets/{c4Diagram-7LVT6UL2-C4p1KgTp.js → c4Diagram-7LVT6UL2-WR43XvCI.js} +1 -1
- package/client-dist/assets/channel-PV8AAsuo.js +1 -0
- package/client-dist/assets/{chunk-2Q5K7J3B-CJSvy8go.js → chunk-2Q5K7J3B-CiP4m_EA.js} +1 -1
- package/client-dist/assets/{chunk-5VM5RSS4-BVg02Giz.js → chunk-5VM5RSS4-BUAhj1h9.js} +1 -1
- package/client-dist/assets/{chunk-F27PBJKO-f_VOUJ8l.js → chunk-F27PBJKO-BUZNwiGx.js} +1 -1
- package/client-dist/assets/{chunk-IMKFNOWR-P5H0uE4d.js → chunk-IMKFNOWR-CX1a0BCE.js} +1 -1
- package/client-dist/assets/{chunk-JWPE2WC7-BpEGNu2X.js → chunk-JWPE2WC7-C6tL-mLF.js} +1 -1
- package/client-dist/assets/{chunk-POPQ4Y6H-oZudgMt7.js → chunk-POPQ4Y6H-BzijGGWv.js} +1 -1
- package/client-dist/assets/{chunk-SVP7TREG-dMWNgoWs.js → chunk-SVP7TREG-CsZImJKI.js} +1 -1
- package/client-dist/assets/{chunk-TICWLB2K-D8VqJUFw.js → chunk-TICWLB2K-TwCtuDc1.js} +1 -1
- package/client-dist/assets/{chunk-XXDRQBXY-ZwkKkcDz.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-D_ikArFV.js → client-Ci_HPGfl.js} +1 -1
- package/client-dist/assets/{compactSettingsControls-CzgNQCH3.js → compactSettingsControls-C9mLZh5H.js} +1 -1
- package/client-dist/assets/{cose-bilkent-JH36ORCC-DrtmDj3A.js → cose-bilkent-JH36ORCC-CmbEx2jT.js} +1 -1
- package/client-dist/assets/{cynefin-OW5HDTMX-CYhxgFq5.js → cynefin-OW5HDTMX-BSQHHXFU.js} +1 -1
- package/client-dist/assets/{cynefinDiagram-5FMLGOSQ-BXvBp5eq.js → cynefinDiagram-5FMLGOSQ-C-62JZJD.js} +1 -1
- package/client-dist/assets/{dagre-GXQ25YYZ-CdvzhCPS.js → dagre-GXQ25YYZ-BBERQe_A.js} +1 -1
- package/client-dist/assets/{diagram-S7CK7UJ4-DSGzzHN1.js → diagram-S7CK7UJ4-muw11lmG.js} +1 -1
- package/client-dist/assets/{diagram-UQ7AKVKN-Bk4fbl1S.js → diagram-UQ7AKVKN-DpePWzAe.js} +1 -1
- package/client-dist/assets/{diagram-VSXAHHWV-BAOCj4oX.js → diagram-VSXAHHWV-DHX6AHUY.js} +1 -1
- package/client-dist/assets/{diagram-VX7I27RA-KHmeuEjq.js → diagram-VX7I27RA-DYmR6NH_.js} +1 -1
- package/client-dist/assets/{diagram-Z3DM3KII-D6GpIAdx.js → diagram-Z3DM3KII-BC1SenHB.js} +1 -1
- package/client-dist/assets/{ebnfDiagram-PWID7BFC-Bm_JuhNL.js → ebnfDiagram-PWID7BFC-EVpri6Ma.js} +1 -1
- package/client-dist/assets/{erDiagram-RLTQ6QDP-u5Ryj9Z_.js → erDiagram-RLTQ6QDP-DthztUaa.js} +1 -1
- package/client-dist/assets/{flowDiagram-HODETNUW-C9A7e1yC.js → flowDiagram-HODETNUW-DEpC5nMx.js} +1 -1
- package/client-dist/assets/{frontendReload-DN8qVYjF.js → frontendReload-CBdyvvdy.js} +1 -1
- package/client-dist/assets/{ganttDiagram-EL5Y4UJY-BEIN_FhZ.js → ganttDiagram-EL5Y4UJY-Csqji8t1.js} +1 -1
- package/client-dist/assets/{gitGraphDiagram-WWUBYQGX-Cu5ow6Ls.js → gitGraphDiagram-WWUBYQGX-DVX1SDIE.js} +1 -1
- package/client-dist/assets/{hostStorage-C37tOOJa.js → hostStorage-D1KAm3U1.js} +1 -1
- package/client-dist/assets/{index-_2WVhpKj.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-YAR5D3xY.js → index-CoR-vzsb.js} +1 -1
- package/client-dist/assets/index-Cv3tQXyE.js +1 -0
- package/client-dist/assets/{index-LT-lzpNS.js → index-DSFMItgO.js} +1 -1
- package/client-dist/assets/index-umZg0LZ6.js +81 -0
- package/client-dist/assets/{infoDiagram-27XIBGKW-ILfv0Qu_.js → infoDiagram-27XIBGKW-CHm3qsd2.js} +1 -1
- package/client-dist/assets/{ishikawaDiagram-5VMMS53U-D1P8nenz.js → ishikawaDiagram-5VMMS53U-tBRZwz-_.js} +1 -1
- package/client-dist/assets/{journeyDiagram-3NMN7TZE-CXP61NqX.js → journeyDiagram-3NMN7TZE-EJic7nqD.js} +1 -1
- package/client-dist/assets/{kanban-definition-UXKFOSKX-2x79Nimu.js → kanban-definition-UXKFOSKX-DtzL6eeO.js} +1 -1
- package/client-dist/assets/{layout-D7AfOq-G.js → layout-gb-Axsoq.js} +1 -1
- package/client-dist/assets/{linear-B_4Bripc.js → linear-CAe4xGbR.js} +1 -1
- package/client-dist/assets/{mermaid.core-y_avJe8E.js → mermaid.core-BCu1nv8H.js} +5 -5
- package/client-dist/assets/{mindmap-definition-YA3MSWOX-DwMJuV6d.js → mindmap-definition-YA3MSWOX-C7-KSPtJ.js} +1 -1
- package/client-dist/assets/{pegDiagram-XKGWAZYB-43LaxzRF.js → pegDiagram-XKGWAZYB-iWVH9rbY.js} +1 -1
- package/client-dist/assets/{pieDiagram-E7YTZNPT-DAOi_afd.js → pieDiagram-E7YTZNPT-VKD6PLHa.js} +1 -1
- package/client-dist/assets/{providerChildSessions-BpJF5D9s.css → providerChildSessions-Cd7oK6KQ.css} +1 -1
- package/client-dist/assets/providerChildSessions-DbLFSybt.js +77 -0
- package/client-dist/assets/{quadrantDiagram-AXDQQJYC-BRPBWWpv.js → quadrantDiagram-AXDQQJYC-AXFugcFl.js} +1 -1
- package/client-dist/assets/{railroadDiagram-O6MQD6OU-xAuDG62P.js → railroadDiagram-O6MQD6OU-D6oZy6Al.js} +1 -1
- package/client-dist/assets/{recentProjectPathLinks-B6pQxzWg.js → recentProjectPathLinks-D0Dx6YXT.js} +1 -1
- package/client-dist/assets/{registerServiceWorker-fKJh5dWO.js → registerServiceWorker-B8K2KVOY.js} +1 -1
- package/client-dist/assets/{relayEndpoints-DRyKx83V.js → relayEndpoints-BTq9xppf.js} +1 -1
- package/client-dist/assets/{remoteRoutePaths-BxKY1U2z.js → remoteRoutePaths-D8htA0xa.js} +1 -1
- package/client-dist/assets/{requirementDiagram-BXWQKSXE-BJvybhuU.js → requirementDiagram-BXWQKSXE-Eqtb74It.js} +1 -1
- package/client-dist/assets/{sankeyDiagram-P5KCCOFB-aAAflmwo.js → sankeyDiagram-P5KCCOFB-CxvDiZ1R.js} +1 -1
- package/client-dist/assets/{sequenceDiagram-WJ2MYXX4-CP3BPtU-.js → sequenceDiagram-WJ2MYXX4-BbpkgW2L.js} +1 -1
- package/client-dist/assets/{sessionNavigationState-MSOOrZi4.js → sessionNavigationState-BXejf2ZW.js} +1 -1
- package/client-dist/assets/sessionRouteLayer-D9T2QT8G.js +1 -0
- package/client-dist/assets/{sizeCapture-INFHLROL-BwAQ5zb3.js → sizeCapture-INFHLROL-DcuwWD5r.js} +1 -1
- package/client-dist/assets/{sourceControlNavigationState-t_nQLZvO.js → sourceControlNavigationState-BJbTzWTE.js} +1 -1
- package/client-dist/assets/{speechDraftTransaction-8sgF4uer.js → speechDraftTransaction-WhqFE1h9.js} +1 -1
- package/client-dist/assets/{stateDiagram-D77RDMKH-B8llvNN3.js → stateDiagram-D77RDMKH-Cidpq73w.js} +1 -1
- package/client-dist/assets/stateDiagram-v2-MP3YSRHH-DFqKXxjz.js +1 -0
- package/client-dist/assets/{swimlanes-42K2YHIH-qqdgDD32.js → swimlanes-42K2YHIH-Ba8C7MwG.js} +1 -1
- package/client-dist/assets/swimlanesDiagram-VR7AAH4N-3pW2TcAt.js +8 -0
- package/client-dist/assets/{timeline-definition-24CTP7MA-EBxDGVBl.js → timeline-definition-24CTP7MA-CKefGvUK.js} +1 -1
- package/client-dist/assets/{useAcliCommentarySetting-JMx-BSAu.js → useAcliCommentarySetting-CBKAl7qr.js} +2 -2
- package/client-dist/assets/{useActivityBusState-CnG-LXsr.js → useActivityBusState-C0dor9p7.js} +1 -1
- package/client-dist/assets/{useBackgroundRevalidation-7vLWDD_M.js → useBackgroundRevalidation-C79HAUP3.js} +1 -1
- package/client-dist/assets/{useCodexUpdateStatus-CAR1HkyO.js → useCodexUpdateStatus-CEZO_f2Y.js} +1 -1
- package/client-dist/assets/{useConnectedDevices-DxgKt21O.js → useConnectedDevices-Ds-DuUDc.js} +1 -1
- package/client-dist/assets/{useDocumentTitle-bldu9XOq.js → useDocumentTitle-Xz5t-nlB.js} +1 -1
- package/client-dist/assets/{useEmulators-BPiSdRjQ.js → useEmulators-qS_cCZ3I.js} +1 -1
- package/client-dist/assets/{useFileActivity-D0JXhEz7.js → useFileActivity-BoW4X3DY.js} +1 -1
- package/client-dist/assets/{useFloatingActionButtonEnabled-Dp_hZuYb.js → useFloatingActionButtonEnabled-2_hw7nSa.js} +1 -1
- package/client-dist/assets/{useForkSummaryAutoOpen-Cty_gTm1.js → useForkSummaryAutoOpen-CS33Irpf.js} +1 -1
- package/client-dist/assets/{useGeneratedTitleLength-BpbPYGRf.js → useGeneratedTitleLength-D856ktVg.js} +1 -1
- package/client-dist/assets/{useKeepMobileKeyboardOpenAfterDelivery-BWCiVVkU.js → useKeepMobileKeyboardOpenAfterDelivery-Ba77SbWF.js} +1 -1
- package/client-dist/assets/{useModelSettings-CeABGid0.js → useModelSettings-BdlYk1DT.js} +1 -1
- package/client-dist/assets/{useNotifyInApp-CuUBcZeR.js → useNotifyInApp-DcWe3dh4.js} +1 -1
- package/client-dist/assets/{useOnboarding-BDCBf2Fp.js → useOnboarding-CoE3WF8a.js} +1 -1
- package/client-dist/assets/{useProviders-45TZLkhy.js → useProviders-CeN1PclA.js} +1 -1
- package/client-dist/assets/{useQuestionAsideSetting-B0bjoe-z.js → useQuestionAsideSetting-CPFw1u0y.js} +1 -1
- package/client-dist/assets/{useRecentSessions-COrEGQJH.js → useRecentSessions-ieTzzJu4.js} +1 -1
- package/client-dist/assets/{useRelativeNow-XM1dKxcx.js → useRelativeNow-Ca6QGcPa.js} +1 -1
- package/client-dist/assets/{useReloadNotifications-JBj22syT.js → useReloadNotifications-Dm1jmdIb.js} +1 -1
- package/client-dist/assets/{useRemoteExecutors-Bzvi8gRe.js → useRemoteExecutors-zBAQnQXH.js} +1 -1
- package/client-dist/assets/{useSidebarWidth-CITe0sSV.js → useSidebarWidth-CBCcbSLg.js} +1 -1
- package/client-dist/assets/{useSourceControlCleanLanding-B-8NTKPa.js → useSourceControlCleanLanding-VDlft5tr.js} +1 -1
- package/client-dist/assets/{useStableToolPreviewRendering-CeH1PY9S.js → useStableToolPreviewRendering-hbVp38Jd.js} +1 -1
- package/client-dist/assets/{useStreamingEnabled-C535nHwb.js → useStreamingEnabled-hU1g8i7_.js} +1 -1
- package/client-dist/assets/{useTabTitleActivityPreference-NekVdSEZ.js → useTabTitleActivityPreference-DhREY7m2.js} +1 -1
- package/client-dist/assets/{useVhostAccess-CHT40zJ3.js → useVhostAccess-DUtn_sH1.js} +1 -1
- package/client-dist/assets/{useWorkflowTags-Bl7Czynw.js → useWorkflowTags-DxbEBqtf.js} +1 -1
- package/client-dist/assets/{vennDiagram-4TSXK5OY-BRLuM0pk.js → vennDiagram-4TSXK5OY-CSGBq-Ur.js} +1 -1
- package/client-dist/assets/{wardleyDiagram-VM6X3IG4-D5cPV-h-.js → wardleyDiagram-VM6X3IG4-DIMvcaMb.js} +1 -1
- package/client-dist/assets/{xychartDiagram-S5SC5T6Z-M2QslymW.js → xychartDiagram-S5SC5T6Z-TYXSqT3w.js} +1 -1
- package/client-dist/index.html +3 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +19 -10
- package/dist/app.js.map +1 -1
- package/dist/artifacts/ArtifactServer.d.ts +0 -1
- package/dist/artifacts/ArtifactServer.d.ts.map +1 -1
- package/dist/artifacts/ArtifactServer.js +41 -9
- 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 +4 -1
- package/dist/routes/file-edit.d.ts.map +1 -1
- package/dist/routes/file-edit.js +22 -6
- package/dist/routes/file-edit.js.map +1 -1
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/files.js +19 -5
- 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/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/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/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/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 +7 -2
- package/dist/sdk/providers/codex.d.ts.map +1 -1
- package/dist/sdk/providers/codex.js +21 -20
- package/dist/sdk/providers/codex.js.map +1 -1
- package/dist/services/ArtifactRebuildService.d.ts +11 -14
- package/dist/services/ArtifactRebuildService.d.ts.map +1 -1
- package/dist/services/ArtifactRebuildService.js +15 -7
- package/dist/services/ArtifactRebuildService.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/package.json +3 -3
- package/client-dist/assets/App-DYWU2-wq.js +0 -2
- package/client-dist/assets/AppearanceSettings-Ci0wlAx3.js +0 -2
- package/client-dist/assets/LocalMediaModal-DOcizK52.css +0 -1
- package/client-dist/assets/LocalMediaModal-DyDpC0dk.js +0 -12
- package/client-dist/assets/MessageInput-leX__dbU.js +0 -3
- package/client-dist/assets/MessageList-DDA4Q_Gj.js +0 -4
- package/client-dist/assets/ProviderBadge-BKZVllDn.js +0 -1
- package/client-dist/assets/ProviderChildSessionPage-vpu5u3YA.js +0 -1
- package/client-dist/assets/SessionPage-BJ5qaa-G.js +0 -50
- package/client-dist/assets/SessionPage-BiV0X3n1.css +0 -1
- package/client-dist/assets/SpeechControlMenu-DEDIWl9h.js +0 -2
- package/client-dist/assets/ViewerModePage-Dyq_I7ws.js +0 -1
- package/client-dist/assets/channel-DwT-nHaK.js +0 -1
- package/client-dist/assets/classDiagram-ZZMXUADV-DdlhZ-2W.js +0 -1
- package/client-dist/assets/classDiagram-v2-VYDZK3BY-DdlhZ-2W.js +0 -1
- package/client-dist/assets/index-BY-TgOY-.js +0 -81
- package/client-dist/assets/index-BgkZrNQv.js +0 -1
- package/client-dist/assets/index-BrCZcBcO.js +0 -2
- package/client-dist/assets/index-wA2zlxt-.css +0 -1
- package/client-dist/assets/providerChildSessions-DVWCZpC4.js +0 -78
- package/client-dist/assets/stateDiagram-v2-MP3YSRHH-CD7vRqY6.js +0 -1
- package/client-dist/assets/swimlanesDiagram-VR7AAH4N-NBdWyLIY.js +0 -8
- 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
|
@@ -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-BY-TgOY-.js";import{u as Ie,l as Ne}from"./hostStorage-C37tOOJa.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-BxKY1U2z.js";import{T as Fe,R as De,d as He,B as P,i as Ve,f as $e}from"./RelayProtocol-DOWXVB0k.js";import{r as We}from"./relayEndpoints-DRyKx83V.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-_2WVhpKj.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};
|
package/client-dist/assets/{DevelopmentSettings-CFo3ctnP.js → DevelopmentSettings-BEAy_xq-.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as V,r as g,j as e,L as _}from"./index-
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,u as x,j as s}from"./index-
|
|
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};
|
|
@@ -1 +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-BY-TgOY-.js";import{a as Z}from"./client-D_ikArFV.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-BPiSdRjQ.js";import{P as se}from"./PageHeader-Ca3PbaMb.js";import{b as ie,e as ae}from"./Modal-DOzUIhWU.js";import{MainContent as U}from"./index-BgkZrNQv.js";import{u as ce}from"./NavigationLayout-D8BMwd7T.js";import"./react-runtime-D-UPQ57m.js";import"./RelayProtocol-DOWXVB0k.js";import"./LocalMediaModal-DyDpC0dk.js";import"./newSessionPrefill-DKcy0abh.js";import"./appHref-ByaEnJGJ.js";import"./SessionHeader.module-CHO2T3eQ.js";import"./HostIdentityContext-DbEx7dor.js";import"./frontendReload-DN8qVYjF.js";import"./remoteRoutePaths-BxKY1U2z.js";import"./useSidebarWidth-CITe0sSV.js";import"./useFileActivity-D0JXhEz7.js";import"./providerChildSessions-DVWCZpC4.js";import"./katex-Dv2p4YRM.js";import"./index-YAR5D3xY.js";import"./relay-url-j3kYm5KO.js";import"./ProviderBadge-BKZVllDn.js";import"./YepAnywhereLogo-C4H1sg3q.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};
|
|
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};
|