ryco-cli 0.1.29 → 0.1.31
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/README.md +37 -0
- package/dist/{AcpAdapter-8CSe4HK7.cjs → AcpAdapter-ByUp9-wk.cjs} +74 -54
- package/dist/{AcpAdapter-CG1wRWcf.mjs → AcpAdapter-CY_ANTKu.mjs} +74 -54
- package/dist/{AcpNativeLogging-B6TtnnKL.mjs → AcpNativeLogging-C7PC6imv.mjs} +30 -4
- package/dist/{AcpNativeLogging-DbjnRnTf.cjs → AcpNativeLogging-OQeAya9d.cjs} +33 -1
- package/dist/{AcpRegistryDriver-16ZTxUs3.cjs → AcpRegistryDriver-CD9GN7rI.cjs} +3 -3
- package/dist/{AcpRegistryDriver-DZFasKaz.mjs → AcpRegistryDriver-DMZ5VBWJ.mjs} +4 -4
- package/dist/AzureDevOpsSourceControlProvider-5giVYoNi.mjs +2053 -0
- package/dist/AzureDevOpsSourceControlProvider-BKMXEUaN.cjs +2055 -0
- package/dist/{BitbucketSourceControlProvider-DplKc8Wo.mjs → BitbucketSourceControlProvider-BVUBsEUF.mjs} +63 -23
- package/dist/{BitbucketSourceControlProvider-B-ZwKj72.cjs → BitbucketSourceControlProvider-BWnnrbch.cjs} +62 -22
- package/dist/{BunPTY-Dcl1Lp62.mjs → BunPTY-CMbDQ1Xb.mjs} +1 -1
- package/dist/{ClaudeDriver-r0lJ9vmE.cjs → ClaudeDriver-DCrqouOR.cjs} +1376 -194
- package/dist/{ClaudeDriver-0gGVop27.mjs → ClaudeDriver-DVOss8cC.mjs} +1377 -195
- package/dist/{CodexDriver-bJAbhSwY.cjs → CodexDriver-CBQPHJqU.cjs} +259 -29
- package/dist/{CodexDriver-baT02xVb.mjs → CodexDriver-DJoTky7Z.mjs} +261 -31
- package/dist/{CodexTextGeneration-Dwp6X3dq.mjs → CodexTextGeneration-BSgNgfZv.mjs} +6 -6
- package/dist/{CodexTextGeneration-DFZ5y4gj.cjs → CodexTextGeneration-C9MDQmZm.cjs} +7 -7
- package/dist/{CopilotDriver-C0OhnSB1.mjs → CopilotDriver-CUkdPXcH.mjs} +78 -20
- package/dist/{CopilotDriver-B_jEqfYQ.cjs → CopilotDriver-DbaMDH16.cjs} +76 -18
- package/dist/{CursorDriver-DinXkGP9.mjs → CursorDriver-B-ZilXJB.mjs} +115 -98
- package/dist/{CursorDriver-BBFEW7ZI.cjs → CursorDriver-DKQqPbKH.cjs} +116 -99
- package/dist/{ForgejoSourceControlProvider-iG9o7aZB.cjs → ForgejoSourceControlProvider-CgpjFECj.cjs} +94 -60
- package/dist/{ForgejoSourceControlProvider-Dr0fxfud.mjs → ForgejoSourceControlProvider-DemMYUye.mjs} +95 -61
- package/dist/{GitHubSourceControlProvider-L1yFpep4.cjs → GitHubSourceControlProvider-C4un6hOK.cjs} +218 -119
- package/dist/{GitHubSourceControlProvider-CnIu0n2Y.mjs → GitHubSourceControlProvider-CRSDYcjc.mjs} +206 -108
- package/dist/GitLabSourceControlProvider-D8W1ZLPh.cjs +2260 -0
- package/dist/GitLabSourceControlProvider-DpWkJ0M3.mjs +2258 -0
- package/dist/{GrokDriver-D_Ylzh5z.cjs → GrokDriver-BQ6G_7ZZ.cjs} +11 -12
- package/dist/{GrokDriver-pX-N6HGS.mjs → GrokDriver-Buvas9-q.mjs} +7 -8
- package/dist/{Metrics-BjqGlIP4.mjs → Metrics-C3vLS9rz.mjs} +1264 -1151
- package/dist/{Metrics-Bf96NJ4j.cjs → Metrics-DjRPLE98.cjs} +1295 -1134
- package/dist/{NodePTY-D7tFWuQe.mjs → NodePTY-DgnuBruq.mjs} +1 -1
- package/dist/{NodeSqliteClient-BGg70C7Q.cjs → NodeSqliteClient-D8bzGgPN.cjs} +1 -1
- package/dist/{OpenCodeDriver-Byu1pf_i.mjs → OpenCodeDriver-BWEZD841.mjs} +184 -50
- package/dist/{OpenCodeDriver-BFEw5t09.cjs → OpenCodeDriver-qUiX0RLH.cjs} +185 -51
- package/dist/{SideQuestionIsolation-81IoAuoi.mjs → SideQuestionIsolation-B1T-DsR0.mjs} +1 -1
- package/dist/{SideQuestionIsolation-CMPkCUP0.cjs → SideQuestionIsolation-BPC-Bxsz.cjs} +1 -1
- package/dist/bin.cjs +50689 -15659
- package/dist/bin.mjs +50578 -15585
- package/dist/client/assets/AccountSettings-B88Q_w9Y.js +1 -0
- package/dist/client/assets/AiFocusSettings-Bb0TrCPn.js +1 -0
- package/dist/client/assets/{AnimatedHeight-BNg7wnTK.js → AnimatedHeight-epXOsgdm.js} +1 -1
- package/dist/client/assets/AppearanceSettings-XS9WRVPU.js +1 -0
- package/dist/client/assets/AutomationsDialog-bZckh4Y3.js +1 -0
- package/dist/client/assets/AutomationsSummary-wPFZCF49.js +1 -0
- package/dist/client/assets/BranchToolbar.logic-DjzLKbbB.js +3 -0
- package/dist/client/assets/BrowserPanel-CdBLnnfz.js +1 -0
- package/dist/client/assets/ChatRightPanel-BCINd0vP.js +34 -0
- package/dist/client/assets/ChatThreadRouteView-BFZ0Si-l.js +1 -0
- package/dist/client/assets/ColorSwatchPicker-CGyo99o0.js +1 -0
- package/dist/client/assets/CommandPalette.logic-BIOMtnEQ.js +1 -0
- package/dist/client/assets/CommandPaletteDialog-Db4LH--z.js +2 -0
- package/dist/client/assets/CompositeRoot-DtnwMJKj.js +1 -0
- package/dist/client/assets/ComputerUseSettings-CkqCqDsU.js +1 -0
- package/dist/client/assets/ConnectionsSettings-B9mxExdG.js +7 -0
- package/dist/client/assets/CreatePullRequestDialog-CJ7pNCue.js +1 -0
- package/dist/client/assets/CreatePullRequestDialogHost-n4ZjdSr4.js +1 -0
- package/dist/client/assets/DiagnosticsSettings-f9rFG9re.js +2 -0
- package/dist/client/assets/DiagnosticsSettings.logic-Byf-Bu4S.js +1 -0
- package/dist/client/assets/DialogHandle-C0c_rK3I.js +1 -0
- package/dist/client/assets/{DialogPopup-DdZlhHuQ.js → DialogPopup-BKW1PEEa.js} +1 -1
- package/dist/client/assets/DialogRoot-BIubqrv0.js +1 -0
- package/dist/client/assets/DialogTitle-BAX_FLoG.js +1 -0
- package/dist/client/assets/{DialogViewport-BwuqbGLY.js → DialogViewport-C2iOUx0O.js} +1 -1
- package/dist/client/assets/DiffPanel-BkqDt_SS.js +25 -0
- package/dist/client/assets/DisclosureRegion-B8556yU0.js +1 -0
- package/dist/client/assets/DraftChatThreadRouteView-BKgRKJ2w.js +1 -0
- package/dist/client/assets/{ExternalIdentityWeb.logic-DsTJQkg-.js → ExternalIdentityWeb.logic-Cu6suNrN.js} +1 -1
- package/dist/client/assets/GlassSurface-DLYYzRdP.js +1 -0
- package/dist/client/assets/HostedConnectionControls-CoVqtnrK.js +1 -0
- package/dist/client/assets/HostedHubRoot-CM2CwPUr.js +2 -0
- package/dist/client/assets/{HostedNativeAuthorizationRoute-BSq_AlY2.js → HostedNativeAuthorizationRoute-Bizmqrh_.js} +2 -2
- package/dist/client/assets/HostedNodeRenameDialog-SXWMsTO0.js +1 -0
- package/dist/client/assets/HostedRelayTrustNotice-BfTyrBi5.js +1 -0
- package/dist/client/assets/InboxStatusGlyph-BPTqzp7l.js +1 -0
- package/dist/client/assets/IntegrationsSettingsPanel-DAPvkV4i.js +1 -0
- package/dist/client/assets/KeybindingsSettings-B8g-YI2O.js +1 -0
- package/dist/client/assets/LazyBrowserPanel-Ds9cdOC_.js +2 -0
- package/dist/client/assets/McpServersSettings-Dw6G3ff3.js +6 -0
- package/dist/client/assets/MobileSheet-DfgXNWbd.js +1 -0
- package/dist/client/assets/ModelTuningDial-DQBAbuNL.js +1 -0
- package/dist/client/assets/NewWorktreeDialog-CDZAJmK6.js +4 -0
- package/dist/client/assets/NodeSecuritySettings-3MELA9ru.js +1 -0
- package/dist/client/assets/NullStore-gT_6_xZE.js +1 -0
- package/dist/client/assets/OnboardingDialog-CAAtNnJf.js +1 -0
- package/dist/client/assets/OpinionatedPluginsSettings-AiDB0Vl4.js +1 -0
- package/dist/client/assets/{PdfAttachmentPreview-CTo1AyZs.js → PdfAttachmentPreview-BFNW2wjN.js} +2 -2
- package/dist/client/assets/{PhoneGetAppInterstitial-DwopOWnQ.js → PhoneGetAppInterstitial-D8fwZ8E9.js} +1 -1
- package/dist/client/assets/PhoneHome-YHgHljA0.js +1 -0
- package/dist/client/assets/PhoneSettingsSurface-BVxJppvK.js +2 -0
- package/dist/client/assets/PreviewPanel-BYcEnkv9.js +643 -0
- package/dist/client/assets/ProjectScriptDialog-K34K2Kzm.js +1 -0
- package/dist/client/assets/ProjectsPage-DXnMYLjb.js +1 -0
- package/dist/client/assets/PromoteChatDialog-CAY7_wJ-.js +1 -0
- package/dist/client/assets/ProviderLimitWindow-CK04BSkM.js +1 -0
- package/dist/client/assets/ProviderUpdateLaunchNotification.logic-BMBrDDOC.js +1 -0
- package/dist/client/assets/ProvidersSettingsPanel-C85PX9Es.js +1 -0
- package/dist/client/assets/PullRequestsPage-C0rgfGwB.js +1 -0
- package/dist/client/assets/{QuitShortcutFeedback-eCvP_MNj.js → QuitShortcutFeedback-DSkKqETs.js} +1 -1
- package/dist/client/assets/RedactedSensitiveText-DQ0YveQd.js +1 -0
- package/dist/client/assets/RollingText-BzvpP5fa.js +1 -0
- package/dist/client/assets/RootAppShell-BYQ-eGNT.js +6 -0
- package/dist/client/assets/{Separator-BiINUUQl.js → Separator-DpiW19Vw.js} +1 -1
- package/dist/client/assets/SettingsPage-BCFN7Ju2.js +2 -0
- package/dist/client/assets/SettingsPanels-CP6z2b1x.js +3 -0
- package/dist/client/assets/SettingsPanels.editor-D8U-TWWG.js +1 -0
- package/dist/client/assets/SettingsSelect-DEhNaz3E.js +1 -0
- package/dist/client/assets/Sidebar.logic-D_ODfSpl.js +1 -0
- package/dist/client/assets/SimulatorPanel-DCT6fZ0X.js +1 -0
- package/dist/client/assets/SourceControlSettings-DxUtvPMK.js +1 -0
- package/dist/client/assets/StatisticsPage-C9SrwtM4.js +1 -0
- package/dist/client/assets/StatisticsPanel-BMYLETs0.js +1 -0
- package/dist/client/assets/ThreadLinkList-BN5z5EpS.js +169 -0
- package/dist/client/assets/ThreadTerminalDrawer-CgIFOlR-.js +18 -0
- package/dist/client/assets/ThreadWorkspacePanel-DvXoqQPF.js +3 -0
- package/dist/client/assets/ToolbarRootContext-8FsV9Cpj.js +1 -0
- package/dist/client/assets/TraitsPicker-DcrpJahy.js +1 -0
- package/dist/client/assets/Virtualizer-CwXeUPla.js +1345 -0
- package/dist/client/assets/WorkspacePullRequestPanel-3mlcJn9G.js +1 -0
- package/dist/client/assets/WorkspaceReview-UGbCgXeK.js +2 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DAmGykdr.js → abnfDiagram-N423BO3Z-DVEM6Scc.js} +1 -1
- package/dist/client/assets/{activity-DRZlu-MC.js → activity-DVCuAejY.js} +1 -1
- package/dist/client/assets/{alert-CwrDisFU.js → alert-FV7ZIit_.js} +1 -1
- package/dist/client/assets/alert-dialog-CgXR9tED.js +1 -0
- package/dist/client/assets/app-window-3xtwqZgI.js +1 -0
- package/dist/client/assets/appChrome-COCz-T7w.js +1 -0
- package/dist/client/assets/{appearancePreferences-nFx4MHoI.js → appearancePreferences-NnsvXwBe.js} +1 -1
- package/dist/client/assets/architecture-7GRP2DOG-DXXb_0_g.js +1 -0
- package/dist/client/assets/{architectureDiagram-T3A2C74G-DypU2ERW.js → architectureDiagram-T3A2C74G-B6pcKiCj.js} +1 -1
- package/dist/client/assets/{arrow-left-XhcJWpRy.js → arrow-left-Blu3LSE2.js} +1 -1
- package/dist/client/assets/{arrow-right-BBs6iTUL.js → arrow-right-CO3CH0ne.js} +1 -1
- package/dist/client/assets/arrow-up-B69gV2Bq.js +1 -0
- package/dist/client/assets/{arrow-up-right-CJ9Vq7nK.js → arrow-up-right-BbPGFOLA.js} +1 -1
- package/dist/client/assets/authorization-Ob6YwWiI.js +1 -0
- package/dist/client/assets/autocomplete-RVpjsrDv.js +1 -0
- package/dist/client/assets/ban-BIm2PVkE.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-B9MhR9hY.js → blockDiagram-VBNYF7ZC-WNerGp9V.js} +1 -1
- package/dist/client/assets/{bot-D5wgL7pu.js → bot-C9nWtaWq.js} +1 -1
- package/dist/client/assets/browserState-jt47YsqD.js +1 -0
- package/dist/client/assets/{c4Diagram-5PPSVZJV-C22FWSoE.js → c4Diagram-5PPSVZJV-wp1ioOoM.js} +1 -1
- package/dist/client/assets/camera-C13VoW3c.js +1 -0
- package/dist/client/assets/capabilities-CfOhq009.js +1 -0
- package/dist/client/assets/channel-56r2qL2v.js +1 -0
- package/dist/client/assets/{chart-column-D6Lnkklk.js → chart-column-DRv0YtL_.js} +1 -1
- package/dist/client/assets/checkbox-CIIIY9FA.js +1 -0
- package/dist/client/assets/checks-Dw022Bvy.js +1 -0
- package/dist/client/assets/{chunk-2GRJ4B5K-D1tZuCzA.js → chunk-2GRJ4B5K-DRl3ILpc.js} +1 -1
- package/dist/client/assets/{chunk-4I5QYGJK-Clf86zK0.js → chunk-4I5QYGJK-CYTRl4bo.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-B36N5RYZ.js → chunk-5RXB4S5H-VCNwRsOa.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-IAxdzsQJ.js → chunk-6Q2QTUOP-DnSeKGPG.js} +1 -1
- package/dist/client/assets/{chunk-7Z6QIM7H-Ctqebv_4.js → chunk-7Z6QIM7H-Cjilh9TF.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-CAfciJae.js → chunk-GF5L2VYU-CGR7AW0t.js} +1 -1
- package/dist/client/assets/{chunk-I66GZJ75-BZ7XtZf4.js → chunk-I66GZJ75-CXSn8dDu.js} +1 -1
- package/dist/client/assets/{chunk-JQJVKLGR-DVuZCWnv.js → chunk-JQJVKLGR-Dro-75lU.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-DtWbzsRm.js → chunk-KBJHAD2P-BDqN2kVf.js} +1 -1
- package/dist/client/assets/{chunk-NSK5VX7P-BVMz_Hc4.js → chunk-NSK5VX7P-DGo5UczH.js} +1 -1
- package/dist/client/assets/{chunk-QR6OTTB3-DWitTCy-.js → chunk-QR6OTTB3-RWuyWnBI.js} +1 -1
- package/dist/client/assets/{chunk-UBXNYLIW-BuxXXP2s.js → chunk-UBXNYLIW-BPRzeB0w.js} +1 -1
- package/dist/client/assets/{chunk-W5SLKNZC-Bnf3sQl4.js → chunk-W5SLKNZC-DYWocTFi.js} +1 -1
- package/dist/client/assets/{chunk-WRU74C26-xu-KDOon.js → chunk-WRU74C26-ChbB1jY3.js} +1 -1
- package/dist/client/assets/circle-stop-D8B4hRpY.js +1 -0
- package/dist/client/assets/circle-x-CNLfrTqR.js +1 -0
- package/dist/client/assets/classDiagram-JCYQIIEL-DGvmFev3.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-DGvmFev3.js +1 -0
- package/dist/client/assets/{clipboard-copy-oDSkUUg4.js → clipboard-copy-DGi8FKNO.js} +1 -1
- package/dist/client/assets/clock-3-DmJ4_XPI.js +1 -0
- package/dist/client/assets/clock-DZIuPtNG.js +1 -0
- package/dist/client/assets/color-picker-BdBXje-a.js +1 -0
- package/dist/client/assets/columns-2-CWlMOClK.js +1 -0
- package/dist/client/assets/combobox-Dtjtf7AB.js +1 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-DGNyiNSf.js → cynefin-OW5HDTMX-TuShvMuM.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-_ctibv4i.js → cynefinDiagram-MW4NZA55-B0Edt2Em.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-Bo-bS1Y0.js → dagre-VZM6K2ZE-D-eiuqHx.js} +1 -1
- package/dist/client/assets/{data-list-DLsM39Hp.js → data-list-BAx6jBY1.js} +1 -1
- package/dist/client/assets/desktopUpdateAtoms-BjrLa3tl.js +1 -0
- package/dist/client/assets/desktopWorkspace-C2wXVBhc.js +1 -0
- package/dist/client/assets/{deviceName-z0ZWSq0z.js → deviceName-B4youG0v.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-DSjtw1SY.js → diagram-7IWD3JNH-DgM6lMlR.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-B7fWEvIa.js → diagram-B4RE2ZJO-CyHNDjzV.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-trRYCE5d.js → diagram-LBJQPF4R-DDzuLIN5.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-_DYcRggk.js → diagram-Q27KOJAE-BaBvK9QB.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-BkMzOHX8.js → diagram-UB23O5K3-CzZ2ewuZ.js} +1 -1
- package/dist/client/assets/dialogWords-Cg0YkJVg.js +1 -0
- package/dist/client/assets/diffRouteSearch-D2MKN_ah.js +1 -0
- package/dist/client/assets/disclosureMotion-cbMJn5-z.js +1 -0
- package/dist/client/assets/{download-CHdS3R_v.js → download-TvtXS4hE.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-DubiOMCG.js → ebnfDiagram-BXEA7PRR-CL1vdOKi.js} +1 -1
- package/dist/client/assets/editorPreferences-DqKyA-2Z.js +1 -0
- package/dist/client/assets/ellipsis-CDK1dNFZ.js +1 -0
- package/dist/client/assets/ellipsis-vertical-CwzEUTwV.js +1 -0
- package/dist/client/assets/{empty-BlBl_Vvw.js → empty-BovKoxbn.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-CFDiNfSJ.js → erDiagram-JOGREHBK-DmQR2if6.js} +1 -1
- package/dist/client/assets/eventmodeling-NTZA5JFV-D272GIcY.js +1 -0
- package/dist/client/assets/external-link-CJeVJZ7s.js +1 -0
- package/dist/client/assets/eye-BUmrXqzg.js +1 -0
- package/dist/client/assets/file-diff-BWc3mYsz.js +1 -0
- package/dist/client/assets/flowDiagram-UKHOOZJN-DLyS38Mm.js +1 -0
- package/dist/client/assets/folder-git-2-CPxg5wKP.js +1 -0
- package/dist/client/assets/folder-open-DcMymvp1.js +1 -0
- package/dist/client/assets/formatCount-B4KLI651.js +1 -0
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-DT2XhE-m.js → ganttDiagram-PKOTCBZU-1q2nUL92.js} +1 -1
- package/dist/client/assets/git-pull-request-BFPwpm3c.js +1 -0
- package/dist/client/assets/{gitGraph-4MIJSDKK-BI5UGiqb.js → gitGraph-4MIJSDKK-COtwmv2S.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-CzAB97Rd.js → gitGraphDiagram-DS77QQ5N-ChsvaxX4.js} +1 -1
- package/dist/client/assets/{group-DZJuSiJL.js → group-DWWn0dTx.js} +1 -1
- package/dist/client/assets/hammer-BXo-EU88.js +1 -0
- package/dist/client/assets/hostedConnectionCoordinator-BkAE-RhA.js +1 -0
- package/dist/client/assets/hostedPairing-5n5srRC9.js +1 -0
- package/dist/client/assets/{index-BAJdq3TK.js → index-DARIYokI.js} +2 -2
- package/dist/client/assets/{info-A6RAGUB7-DdGYYgLX.js → info-A6RAGUB7-CI2qZ9wW.js} +1 -1
- package/dist/client/assets/{infoDiagram-6WML65LV-zhUpER6a.js → infoDiagram-6WML65LV-BPmgcTPH.js} +1 -1
- package/dist/client/assets/{input-CzU08wbL.js → input-CCie4mm1.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-BQLkqykE.js → ishikawaDiagram-WSZJBQD7-LyS9p3Yg.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-DBgsbKOF.js → journeyDiagram-NVQOT4AX-BYaAmN65.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-DF-Rr-xs.js → kanban-definition-27J2QSJJ-D-pwzqFt.js} +1 -1
- package/dist/client/assets/{key-round-CvyrSjb2.js → key-round-BlrUTfxB.js} +1 -1
- package/dist/client/assets/keyboard-DlBdq6sz.js +1 -0
- package/dist/client/assets/label-ChtVI9lp.js +1 -0
- package/dist/client/assets/layers-BB-ruGvd.js +1 -0
- package/dist/client/assets/lifecycleSuggestionPolicy-0ERe_O53.js +1 -0
- package/dist/client/assets/list-checks-BkM_ZRsj.js +1 -0
- package/dist/client/assets/loader-3vQnfqIT.js +1 -0
- package/dist/client/assets/{log-out-D3rICSt5.js → log-out-CKq9YiLY.js} +1 -1
- package/dist/client/assets/{logging-C6tXZlGQ.js → logging-CCg76rgn.js} +1 -1
- package/dist/client/assets/main-Ch0bwS-M.js +9 -0
- package/dist/client/assets/main-Di0isH9D.css +2 -0
- package/dist/client/assets/{mermaid-parser.core-BiGKtilP.js → mermaid-parser.core-RK9ah5RM.js} +2 -2
- package/dist/client/assets/{mermaidEngine-Cjfgf3Bg.js → mermaidEngine-Dr8UsPhH.js} +3 -3
- package/dist/client/assets/message-circle-dashed-BrjwqS7-.js +1 -0
- package/dist/client/assets/messageQueueDrain-B7R7Qmq6.js +1 -0
- package/dist/client/assets/messages-square-cDTkDJv_.js +1 -0
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-SiU9JwWJ.js → mindmap-definition-FAOFIHXS-DVudWasx.js} +1 -1
- package/dist/client/assets/{packet-AYTQ26CC-F-HuW5Dr.js → packet-AYTQ26CC-DnkTsVhD.js} +1 -1
- package/dist/client/assets/{pairingUrl-rQM9kSGT.js → pairingUrl-Dn1e2CVw.js} +1 -1
- package/dist/client/assets/panels-top-left-B7jZiLth.js +1 -0
- package/dist/client/assets/path-text-3Rfu6lt8.js +1 -0
- package/dist/client/assets/{pegDiagram-VL7TDLO6-cC-QUd7I.js → pegDiagram-VL7TDLO6-Do5PIp8B.js} +1 -1
- package/dist/client/assets/pencil-Bzg-nc6d.js +1 -0
- package/dist/client/assets/{pie-WAS4IAKB-BI3XUcLN.js → pie-WAS4IAKB-B_nNQOzn.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-BP4gJ4ZK.js → pieDiagram-7S7Q4E2Y-D_IG4xwA.js} +1 -1
- package/dist/client/assets/{play-BJZrOx6T.js → play-DpXXQ1qB.js} +1 -1
- package/dist/client/assets/popover-OWEv6cQz.js +48 -0
- package/dist/client/assets/presentationTier-DPVAxTK4.js +1 -0
- package/dist/client/assets/previewRouteSearch-BjZdTuSf.js +1 -0
- package/dist/client/assets/primary-Cf-xJExj.js +4 -0
- package/dist/client/assets/primitives-CxTBN7D4.js +1 -0
- package/dist/client/assets/projectCheckouts.logic-DUT4AxXr.js +1 -0
- package/dist/client/assets/projectPaths-B8aVmOZX.js +1 -0
- package/dist/client/assets/projectPreferences-CzWBItFj.js +1 -0
- package/dist/client/assets/providerCapabilities-B2YOPsLN.js +1 -0
- package/dist/client/assets/providerDriverMeta-BHHL9uw0.js +1 -0
- package/dist/client/assets/providerModels-v9PYbzRE.js +1 -0
- package/dist/client/assets/providerStatus-CDPaqb0S.js +1 -0
- package/dist/client/assets/pullRequestsModel.logic-Dv_om_C4.js +1 -0
- package/dist/client/assets/{qr-code-BFO8lV1M.js → qr-code-BlbiBIwH.js} +1 -1
- package/dist/client/assets/{qr-code-Cmfz5JKf.js → qr-code-DywzVgQC.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-DO-N1m-q.js → quadrantDiagram-CIZ2JOQS-DY6fJyrM.js} +1 -1
- package/dist/client/assets/{radar-RG4KPBEZ-CfayXQ5F.js → radar-RG4KPBEZ-D9689I5m.js} +1 -1
- package/dist/client/assets/radio-group-DVwD6Cuy.js +1 -0
- package/dist/client/assets/{railroad-74A4TZTK-CT6f-etT.js → railroad-74A4TZTK-DVzWbQnl.js} +1 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-C_2P6umA.js +1 -0
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-aGlR3R3z.js +1 -0
- package/dist/client/assets/railroad-peg-WCYAUIDC-DCB9oE8y.js +1 -0
- package/dist/client/assets/{railroadDiagram-AXF67PYL-DC8egbob.js → railroadDiagram-AXF67PYL-D1oJ6Jtl.js} +1 -1
- package/dist/client/assets/readCache-B7cDPz2O.js +1 -0
- package/dist/client/assets/{refresh-cw-K_hU8_ld.js → refresh-cw-CRUTivd6.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-DJMzcLk_.js → requirementDiagram-LRYGKXZP-7RM8iREp.js} +1 -1
- package/dist/client/assets/rotate-ccw-BE2ZCwL6.js +1 -0
- package/dist/client/assets/roving-radio-group-NMPWrDqe.js +1 -0
- package/dist/client/assets/rows-2-DDS4dGTX.js +1 -0
- package/dist/client/assets/runtime-DjjjAcTE.js +18 -0
- package/dist/client/assets/safePolygon-C1AzMRS4.js +1 -0
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-YR6aIYLj.js → sankeyDiagram-W5VNT64P-C1tKAPGN.js} +1 -1
- package/dist/client/assets/{save-Mh-PA_2P.js → save-OZdkPs_y.js} +1 -1
- package/dist/client/assets/scroll-area-80P7vbjw.js +1 -0
- package/dist/client/assets/{scrollEdges-Zcpuz3un.js → scrollEdges-C0Oc-5qi.js} +1 -1
- package/dist/client/assets/select-Cb9FUPHD.js +1 -0
- package/dist/client/assets/separator-CO8bC7Wc.js +1 -0
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-BVeSqWDA.js → sequenceDiagram-SI44F4Z6-DGVpb7jL.js} +1 -1
- package/dist/client/assets/settings-2-PrRDu6Lc.js +1 -0
- package/dist/client/assets/settingsLayout-CRFNCk_D.js +1 -0
- package/dist/client/assets/sheet-C5DW7qVO.js +1 -0
- package/dist/client/assets/{shield-i098Bm_B.js → shield-CBHYqlkR.js} +1 -1
- package/dist/client/assets/{shield-alert-CXmR7fM9.js → shield-alert-Dc2cGwyR.js} +1 -1
- package/dist/client/assets/{shield-check-CdFhWT_o.js → shield-check-_wl7R4Js.js} +1 -1
- package/dist/client/assets/sidebar-0BBaFNm3.js +1 -0
- package/dist/client/assets/sidebarProjectFolders-BjWzbt8C.js +3 -0
- package/dist/client/assets/sidebarProjectGrouping-nQRStWrZ.js +1 -0
- package/dist/client/assets/sidebarStatusText-BBKuNies.js +1 -0
- package/dist/client/assets/sidebarUndo-Dfq1lvyF.js +1 -0
- package/dist/client/assets/{skeleton-BwFgUtuE.js → skeleton-DfUe6VV_.js} +1 -1
- package/dist/client/assets/sliders-horizontal-BGXkwvKv.js +1 -0
- package/dist/client/assets/sliding-tabs-BnDSjRU3.js +39 -0
- package/dist/client/assets/{smartphone-DGfizz51.js → smartphone-OEAQOTdv.js} +1 -1
- package/dist/client/assets/spinner-lHRJWsym.js +1 -0
- package/dist/client/assets/square-B05NKv3e.js +1 -0
- package/dist/client/assets/{star-J3x3fktG.js → star-C8mHmfZu.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-DoIZN669.js → stateDiagram-OKZ733FA-CCOAegCG.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-D60qqBed.js +1 -0
- package/dist/client/assets/storeSelectors-BichCKDC.js +1 -0
- package/dist/client/assets/surfaceMorph-BTRijmlU.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-BoFLigyK.js → swimlanes-SLNWSIFB-CFsLYT4h.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-D0SaJgSn.js +8 -0
- package/dist/client/assets/switch-oQc7Ifbl.js +1 -0
- package/dist/client/assets/text-wrap-DSRdSfDm.js +1 -0
- package/dist/client/assets/textarea-VyiIZ0wQ.js +1 -0
- package/dist/client/assets/threadPriorityRefreshRuntime-H656C1J_.js +1 -0
- package/dist/client/assets/ticker-CPutfhZ4.js +1 -0
- package/dist/client/assets/{timeline-definition-Z64GVDOM-D65EmNWc.js → timeline-definition-Z64GVDOM-B4agmO7R.js} +1 -1
- package/dist/client/assets/toggle-DFqtCPt-.js +1 -0
- package/dist/client/assets/toggle-group-C5ICmqkI.js +1 -0
- package/dist/client/assets/{tokenModePresentation-C0-NgmX5.js → tokenModePresentation-umDRm4k1.js} +1 -1
- package/dist/client/assets/tooltip-DbqhseXd.js +1 -0
- package/dist/client/assets/{treeView-Q6P3EWNA-C2S-OPgI.js → treeView-Q6P3EWNA-C_S3udFB.js} +1 -1
- package/dist/client/assets/{treemap-WGGIJYW6-6Ovsu9iH.js → treemap-WGGIJYW6-B-kUSAkE.js} +1 -1
- package/dist/client/assets/undo-2-lyluTGMW.js +1 -0
- package/dist/client/assets/{unplug-BEfcl9Ht.js → unplug-D6iu-qlh.js} +1 -1
- package/dist/client/assets/usage-ClF-eUmy.js +1 -0
- package/dist/client/assets/useActiveIndicator-R5NWu8Fg.js +1 -0
- package/dist/client/assets/useAppSidebarCollapsed-BbMxfio5.js +1 -0
- package/dist/client/assets/useAppearancePreference-Ix13pMKy.js +1 -0
- package/dist/client/assets/useAtlassian-BYDCc9lv.js +0 -0
- package/dist/client/assets/useCheckoutResolution-CR-oOp5-.js +1 -0
- package/dist/client/assets/useDesktopRelaunchGuard-Jmh615iZ.js +1 -0
- package/dist/client/assets/useDiffFileNavigation-DeuzdD5E.js +15 -0
- package/dist/client/assets/useDiffLayout-DhcXwhBL.js +1 -0
- package/dist/client/assets/useEnvironmentSettingsTarget-DM6BRDT7.js +1 -0
- package/dist/client/assets/useFocus-CV0KIZwg.js +1 -0
- package/dist/client/assets/useGit-CUcs7h5_.js +1 -0
- package/dist/client/assets/useGitBranchSearch-CeKFtnCL.js +1 -0
- package/dist/client/assets/useHostedDraftExecutionTarget-DvQU5UOq.js +1 -0
- package/dist/client/assets/useLabelableId-CEgCRi6q.js +1 -0
- package/dist/client/assets/useLandingFlash-BfOOlFtW.js +1 -0
- package/dist/client/assets/useLogicalProjectSnapshots-CRNZke74.js +1 -0
- package/dist/client/assets/useNavigate-sQZthdyT.js +1 -0
- package/dist/client/assets/usePageLeadingInsetClass-Bf4nUvx4.js +1 -0
- package/dist/client/assets/usePhoneThreadActions-VaQ-mZex.js +1 -0
- package/dist/client/assets/usePopupHandleStore-DimKo2Yy.js +1 -0
- package/dist/client/assets/usePopupViewport-YeqX_UM3.js +1 -0
- package/dist/client/assets/usePresentationTier-B9kCQ4YH.js +1 -0
- package/dist/client/assets/useProject-Kt74Z12J.js +1 -0
- package/dist/client/assets/useProviderOptionsUpdater-CTzNh2B7.js +2 -0
- package/dist/client/assets/usePullRequestFilesViewed-D5Snmzys.js +1 -0
- package/dist/client/assets/usePullRequestsModel-DJL5HHbP.js +40 -0
- package/dist/client/assets/useScrollLock-CLZ31xsK.js +1 -0
- package/dist/client/assets/useSidebarThreadActions-n6EkLATf.js +6 -0
- package/dist/client/assets/{useStatistics-D55-xLMz.js → useStatistics-DD0mYS4J.js} +14 -14
- package/dist/client/assets/{useTheme-B441xg4F.js → useTheme-Bdy-BDs-.js} +1 -1
- package/dist/client/assets/useValueChanged-DoumqMnV.js +1 -0
- package/dist/client/assets/{user-round-C-U7TZKG.js → user-round-BPDXr8Gq.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-fZAexcYr.js → vennDiagram-T6HMQDX7-B1UEn_j_.js} +1 -1
- package/dist/client/assets/{vscode-icons-BYX6fBsM.js → vscode-icons-Ccy-gzFN.js} +1 -1
- package/dist/client/assets/{wardley-WFR3VGLG-gdYWSMxK.js → wardley-WFR3VGLG-gPdyDc-7.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-iDJxQb70.js → wardleyDiagram-T6FBY63Y-2aDcwOA4.js} +1 -1
- package/dist/client/assets/workspaceLifecycle-OJ1aKksw.js +3 -0
- package/dist/client/assets/workspaceMetadataProjection-CyEyJhUa.js +1 -0
- package/dist/client/assets/workspaceRouteSearch-CCavUdbH.js +1 -0
- package/dist/client/assets/{wrench-D79uBUSl.js → wrench-CPUCA_rn.js} +1 -1
- package/dist/client/assets/wsTransport-C88seBPA.js +15 -0
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-B4cfMwpJ.js → xychartDiagram-ELKLHX3M-C1_7Q-1i.js} +1 -1
- package/dist/client/favicon.svg +1 -1
- package/dist/client/index.html +1 -1
- package/dist/collectUint8StreamText-BsLSgI8i.mjs +710 -0
- package/dist/collectUint8StreamText-D5olwfpM.cjs +757 -0
- package/dist/{deviceHostWorker-L8C9wy38.mjs → deviceHostWorker-B-Dn-6An.mjs} +1 -1
- package/dist/{deviceHostWorker-CYnrwfrv.cjs → deviceHostWorker-D4HauWIV.cjs} +1 -1
- package/dist/{makeManagedServerProvider-CUwxc0Pn.cjs → makeManagedServerProvider-B5tP7tvg.cjs} +2 -2
- package/dist/{makeManagedServerProvider-B_lPFNpL.mjs → makeManagedServerProvider-B65ipCxM.mjs} +2 -2
- package/dist/resource-monitor/linux-arm64/ryco-resource-monitor +0 -0
- package/dist/resource-monitor/ryco-resource-monitor +0 -0
- package/dist/resource-monitor/ryco-resource-monitor.exe +0 -0
- package/dist/resource-monitor/win32-arm64/ryco-resource-monitor.exe +0 -0
- package/dist/resource-monitor/win32-x64/ryco-resource-monitor.exe +0 -0
- package/dist/{rolldown-runtime-LGfotAqq.cjs → rolldown-runtime-HbSU0i7K.cjs} +7 -0
- package/dist/{runtimeSession-V3RIy8Ao.mjs → runtimeSession-D_BZ-wRH.mjs} +1 -1
- package/dist/{src-BzVJd3Me.cjs → src-FmeCeBJ9.cjs} +3408 -308
- package/dist/{src-7E1M4gTQ.mjs → src-VTj60bUm.mjs} +2154 -140
- package/package.json +1 -1
- package/dist/AzureDevOpsSourceControlProvider-DmJD1-WL.cjs +0 -190
- package/dist/AzureDevOpsSourceControlProvider-d5Ogsspk.mjs +0 -188
- package/dist/GitLabSourceControlProvider-BZdwXdJl.mjs +0 -186
- package/dist/GitLabSourceControlProvider-CrcBR6KQ.cjs +0 -188
- package/dist/client/assets/AccountSettings-FN7pwqYA.js +0 -1
- package/dist/client/assets/AiFocusSettings-xcDAMaqH.js +0 -1
- package/dist/client/assets/AppearanceSettings-BvsvAOsG.js +0 -1
- package/dist/client/assets/BranchToolbar.logic-DFsXV3Qs.js +0 -3
- package/dist/client/assets/BrowserPanel-D-g_xDZs.js +0 -1
- package/dist/client/assets/ChatRightPanel-Bm906qNi.js +0 -201
- package/dist/client/assets/ChatThreadRouteView-CATwakjI.js +0 -1
- package/dist/client/assets/CommandPaletteDialog-Obv1bvxj.js +0 -1
- package/dist/client/assets/CompositeRoot-CfkIdky8.js +0 -1
- package/dist/client/assets/ComputerUseSettings-ljYmTHea.js +0 -1
- package/dist/client/assets/ConnectionsSettings-CIXs7x_E.js +0 -7
- package/dist/client/assets/ContextHandoffEndpointLabel-BzI4Wi1i.js +0 -4
- package/dist/client/assets/DiagnosticsSettings-DGX_2T2M.js +0 -2
- package/dist/client/assets/DialogHandle-CTtSYpsC.js +0 -1
- package/dist/client/assets/DialogRoot-k2_0SNKA.js +0 -1
- package/dist/client/assets/DialogTitle-Du7CAbaO.js +0 -1
- package/dist/client/assets/DialogTrigger-VpFh8Xza.js +0 -1
- package/dist/client/assets/DraftChatThreadRouteView-Cmc5HpWf.js +0 -1
- package/dist/client/assets/GlassSurface-BlWIlQ0s.js +0 -1
- package/dist/client/assets/HostedConnectionControls-ySHqwr4K.js +0 -1
- package/dist/client/assets/HostedHubRoot-Caz8PElK.js +0 -2
- package/dist/client/assets/HostedNodeRenameDialog-ChxJdr-Z.js +0 -1
- package/dist/client/assets/HostedRelayTrustNotice-DPVrIfj_.js +0 -1
- package/dist/client/assets/IntegrationsSettingsPanel-eAq5h-D5.js +0 -2
- package/dist/client/assets/KeybindingsSettings-D1XaEVGH.js +0 -7
- package/dist/client/assets/LazyBrowserPanel-B6POLJh3.js +0 -2
- package/dist/client/assets/McpServersSettings-DqLA6n5v.js +0 -6
- package/dist/client/assets/MobileSheet-CtQIYRlY.js +0 -1
- package/dist/client/assets/NodeSecuritySettings-Skm7GQDl.js +0 -1
- package/dist/client/assets/NullStore-b8PhjwPZ.js +0 -1
- package/dist/client/assets/OnboardingDialog-8-fKvY5H.js +0 -1
- package/dist/client/assets/OpinionatedPluginsSettings-BIJfJ34L.js +0 -1
- package/dist/client/assets/PhoneHome-CUzxhhR4.js +0 -1
- package/dist/client/assets/PhoneSettingsSurface-BK2RHmYJ.js +0 -2
- package/dist/client/assets/ProvidersSettingsPanel-DPxL7AsR.js +0 -1
- package/dist/client/assets/RedactedSensitiveText-DH4mWpB6.js +0 -1
- package/dist/client/assets/RootAppShell-DwiWD4Cy.js +0 -7
- package/dist/client/assets/SettingsDialog-CE8qy0qL.js +0 -2
- package/dist/client/assets/SettingsPanels-BYknk6GO.js +0 -3
- package/dist/client/assets/SettingsPanels.editor-64bM0lhg.js +0 -2
- package/dist/client/assets/SourceControlSettings-BbveiAj3.js +0 -1
- package/dist/client/assets/StatisticsPage-CAO_tCeC.js +0 -1
- package/dist/client/assets/StatisticsPanel-SNlgMv2o.js +0 -1
- package/dist/client/assets/StatisticsSettingsLink-BpkNubL2.js +0 -1
- package/dist/client/assets/ThreadTerminalDrawer-9x_kqQPy.js +0 -18
- package/dist/client/assets/ThreadWorkspacePanel-BXE17C4x.js +0 -2073
- package/dist/client/assets/appChrome-B_VWWDFj.js +0 -1
- package/dist/client/assets/architecture-7GRP2DOG-CQNNG5gU.js +0 -1
- package/dist/client/assets/authorization-BugIGt5e.js +0 -1
- package/dist/client/assets/badge-BswOCwph.js +0 -1
- package/dist/client/assets/capabilities-Bj_X9FZ-.js +0 -1
- package/dist/client/assets/channel-BtX-w3CK.js +0 -1
- package/dist/client/assets/chevron-right-Ddq5gL-L.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BgDa3HFl.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BgDa3HFl.js +0 -1
- package/dist/client/assets/compiler-runtime-C4g8XhC5.js +0 -1
- package/dist/client/assets/desktopWorkspace-Ocqt625W.js +0 -1
- package/dist/client/assets/editorPreferences-DVhg0CXd.js +0 -1
- package/dist/client/assets/eventmodeling-NTZA5JFV-DpzGHjmu.js +0 -1
- package/dist/client/assets/flowDiagram-UKHOOZJN-CaDVMm72.js +0 -1
- package/dist/client/assets/hostedConnectionCoordinator-BztHfGNt.js +0 -1
- package/dist/client/assets/hostedPairing-CqhLPQqG.js +0 -1
- package/dist/client/assets/hubRoutes-DExWSvVE.js +0 -1
- package/dist/client/assets/kbd-DKuvGqFP.js +0 -1
- package/dist/client/assets/layers-CwP65mnC.js +0 -1
- package/dist/client/assets/liquidGlass-CA2o_Cq0.js +0 -1
- package/dist/client/assets/liquidGlass.worker-icvLJKHf.js +0 -1
- package/dist/client/assets/main-BqSANuAs.css +0 -2
- package/dist/client/assets/main-RFllWEko.js +0 -9
- package/dist/client/assets/motion-C9rN_t9p.js +0 -1
- package/dist/client/assets/palette-gaqgtube.js +0 -1
- package/dist/client/assets/perfInstrumentation-BT27w4tn.js +0 -1
- package/dist/client/assets/presentationTier-xlIjcFab.js +0 -1
- package/dist/client/assets/primary-CQh_KHGG.js +0 -5
- package/dist/client/assets/providerDriverMeta-LJ2vJxm-.js +0 -1
- package/dist/client/assets/providerStatus-DBGvvkyF.js +0 -1
- package/dist/client/assets/radio-group-BueX1AVO.js +0 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-B890iayj.js +0 -1
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-C079Tzw6.js +0 -1
- package/dist/client/assets/railroad-peg-WCYAUIDC-DxvOX5Rh.js +0 -1
- package/dist/client/assets/runtime-OM-uAtaj.js +0 -18
- package/dist/client/assets/scroll-area-BC-LB_zE.js +0 -1
- package/dist/client/assets/separator-yx1r9ZDw.js +0 -1
- package/dist/client/assets/settingsLayout-BbjDM-p0.js +0 -1
- package/dist/client/assets/sheet-CpEwjOWn.js +0 -1
- package/dist/client/assets/sidebar-DayQTDZp.js +0 -1
- package/dist/client/assets/sidebarProjectFolders-DXqx3OlZ.js +0 -4
- package/dist/client/assets/sidebarStatusText-kdA6QMZS.js +0 -1
- package/dist/client/assets/sidebarUndo-BHFfJj0k.js +0 -1
- package/dist/client/assets/square-Cd2WS1gv.js +0 -1
- package/dist/client/assets/src-DHNjfMxR.js +0 -14
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-BnzsGHaN.js +0 -1
- package/dist/client/assets/storeSelectors-D60AAN01.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-BnA-oDvU.js +0 -8
- package/dist/client/assets/switch-D9inWKdd.js +0 -48
- package/dist/client/assets/toggle-group-YNqzWsK0.js +0 -1
- package/dist/client/assets/toggle-wMq3LLn1.js +0 -1
- package/dist/client/assets/tooltip-mwOCSCXF.js +0 -1
- package/dist/client/assets/usage-DF8oQrsy.js +0 -1
- package/dist/client/assets/useAppSidebarCollapsed-C0jpPtER.js +0 -1
- package/dist/client/assets/useAppearancePreference-Dlh9P8iu.js +0 -1
- package/dist/client/assets/useBaseUiId-Bz8dcyjd.js +0 -1
- package/dist/client/assets/useLabelableId-C8bc9a0F.js +0 -1
- package/dist/client/assets/useNavigate-01O5dMQe.js +0 -1
- package/dist/client/assets/usePhoneThreadActions-BIdh81kF.js +0 -1
- package/dist/client/assets/usePopupViewport-DYYZwfTW.js +0 -1
- package/dist/client/assets/usePresentationTier-hxB7Yv_Q.js +0 -1
- package/dist/client/assets/useScrollLock-BO185DkJ.js +0 -1
- package/dist/client/assets/useTriggerFocusGuards-CMLVr18J.js +0 -1
- package/dist/client/assets/useValueChanged-DSyRHPje.js +0 -1
- package/dist/client/assets/workspaceMetadataProjection-So9-wSEZ.js +0 -1
- package/dist/collectUint8StreamText-BAUF-vzz.mjs +0 -37
- package/dist/collectUint8StreamText-vagpNUMJ.cjs +0 -42
- package/dist/git-BKwGfw8A.mjs +0 -132
- package/dist/git-Dn5wrgFY.cjs +0 -218
- package/dist/sourceControl-B0D1Op29.cjs +0 -253
- package/dist/sourceControl-BiEBxN01.mjs +0 -224
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$n as e,$r as t,$t as n,An as r,Ar as i,Bi as a,Bn as o,Br as s,Ci as c,Cn as l,Cr as u,Di as d,Dn as f,Dr as p,Ei as m,En as h,Er as g,Fa as _,Fn as v,Fr as ee,Ga as y,Gn as te,Gr as b,Gt as x,Ha as S,Hn as C,Hr as w,Ii as T,In as E,Ir as D,Jn as O,Jr as k,Jt as A,Kn as j,Kr as M,Kt as ne,Li as re,Ln as ie,Lr as ae,Mn as oe,Mr as se,Nn as ce,Nr as le,On as ue,Or as de,Pi as fe,Pn as pe,Pr as me,Qn as he,Qr as ge,Qs as _e,Qt as ve,Rn as ye,Rr as be,Si as xe,Sn as Se,Sr as Ce,T as we,Ti as Te,Tn as Ee,Tr as De,Ua as Oe,Un as ke,Ur as Ae,Vi as je,Vn as Me,Vr as Ne,Wn as Pe,Wr as Fe,Wt as Ie,Xn as Le,Xr as Re,Xt as ze,Yn as Be,Yr as Ve,Yt as He,Za as Ue,Zn as We,Zr as Ge,Zt as Ke,_n as qe,_r as Je,ai as Ye,an as Xe,ar as Ze,bn as Qe,br as $e,ci as et,cn as tt,cr as nt,ct as rt,di as it,dn as at,do as ot,dr as st,ei as ct,en as lt,er as ut,fi as dt,fo as ft,fr as pt,ft as N,gn as mt,go as ht,gr as gt,gt as _t,hn as vt,hr as yt,ht as bt,ii as xt,in as St,io as Ct,ir as wt,jn as Tt,jr as Et,ki as Dt,kn as Ot,kr as kt,l as P,li as At,ln as jt,lr as Mt,mi as Nt,mn as Pt,mr as Ft,ni as It,nn as Lt,no as Rt,nr as zt,o as Bt,oi as Vt,on as Ht,or as Ut,pi as Wt,pn as Gt,po as Kt,pr as qt,qa as Jt,qn as Yt,qr as Xt,qt as Zt,r as Qt,ri as $t,rn as en,rr as tn,s as nn,si as rn,sn as an,sr as on,ti as sn,tn as cn,tr as ln,ui as un,un as dn,ur as fn,vn as pn,vo as mn,vr as hn,wn as gn,wr as _n,x as F,xn as vn,xr as yn,yn as bn,yr as xn,za as Sn,zn as Cn,zr as wn}from"./wsTransport-C88seBPA.js";function Tn(e){if(!/^[A-Za-z0-9_-]+$/u.test(e))throw Error(`Invalid encoded material.`);let t=e.replace(/-/gu,`+`).replace(/_/gu,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n;try{n=atob(t)}catch{throw Error(`Invalid encoded material.`)}let r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r}function En(e){let t=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/gu,`-`).replace(/\//gu,`_`).replace(/=+$/gu,``)}var Dn=1e6,On=_t.check(ht(e=>e.projects.length<=2e3&&(e.worktrees?.length??0)<=1e4&&e.threads.length<=1e4,{message:`Thread read cache shell exceeds its row limits`})),kn=Jt({id:re,role:bt,text:y,createdAt:T,completedAt:mn(T),turnId:mn(S(je))}),An=Jt({messages:_(kn).check(ot(150))}).check(ht(e=>e.messages.reduce((e,t)=>e+t.text.length,0)<=1e6&&new Set(e.messages.map(e=>e.id)).size===e.messages.length,{message:`Thread read cache content exceeds its text limit or repeats message IDs`})),jn=Oe.check(ht(e=>Number.isSafeInteger(e)&&e>=0)),Mn={protocolVersion:Sn(1),generation:jn,revision:jn,storedAt:jn},Nn=Jt({...Mn,snapshot:On}),Pn=Jt({...Mn,threadId:a,snapshot:An}),Fn=Jt({nodeId:Dt,protocolMajor:jn,protocolMinor:jn,nonce:y.check(Kt(/^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/)),signature:y.check(Kt(/^[A-Za-z0-9_-]{85}[AQgw]$/))});Jt({proof:Fn}),Jt({protocolVersion:Sn(1),generation:jn});var In=Ue([Jt({kind:Sn(`shell`),revision:jn,snapshot:On}),Jt({kind:Sn(`thread`),threadId:a,revision:jn,snapshot:An}),Jt({kind:Sn(`deleted`),threadId:a,revision:jn})]);Jt({proof:Fn,generation:jn,items:_(In).check(ft(1),ot(16))});var Ln=BigInt(2**32-1),Rn=BigInt(32);function zn(e,t=!1){return t?{h:Number(e&Ln),l:Number(e>>Rn&Ln)}:{h:Number(e>>Rn&Ln)|0,l:Number(e&Ln)|0}}function Bn(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=zn(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var Vn=e=>e/2**32|0,Hn=e=>e>>>0;function Un(e,t,n,r){let i=Vn(n),a=Hn(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}var Wn=(e,t,n)=>e>>>n,Gn=(e,t,n)=>e<<32-n|t>>>n,Kn=(e,t,n)=>e>>>n|t<<32-n,qn=(e,t,n)=>e<<32-n|t>>>n,Jn=(e,t,n)=>e<<64-n|t>>>n-32,Yn=(e,t,n)=>e>>>n-32|t<<64-n;function Xn(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Zn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Qn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,$n=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),er=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,tr=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),nr=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0;function rr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var ir=e=>e?`"${e}" `:``;function ar(e,t=``){if(typeof e!=`number`)throw TypeError(ir(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(ir(t)+`expected integer >= 0, got `+e);return e}function or(e,t,n=``){if(rr(e)&&(t===void 0||e.length===t))return e;t!==void 0&&ar(t,`length`);let r=rr(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=ir(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function sr(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(ar(e.outputLen),ar(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var cr=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)};function lr(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function ur(e,t){or(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function dr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function fr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function pr(e,t){return e<<32-t|e>>>t}var mr=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,hr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function gr(e){if(or(e),mr)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=hr[e[n]];return t}function _r(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function vr(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(mr)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=_r(e.charCodeAt(i)),a=_r(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function yr(e){if(typeof e!=`string`)throw TypeError(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function br(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];or(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function xr(e,t,n=`opts`){return cr(e,`defaults`),t!==void 0&&cr(t,n),Object.assign(e,t)}function Sr(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=xr({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Cr(e=32){ar(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var wr=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Tr(e,t,n){return e&t^~e&n}function Er(e,t,n){return e&t^e&n^t&n}var Dr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=fr(this.buffer)}update(e){lr(this),or(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=fr(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){lr(this),ur(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),Un(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:fr(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}},Or=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),kr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ar=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),jr=new Uint32Array(64),Mr=class extends Dr{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)jr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=jr[e-15],n=jr[e-2],r=pr(t,7)^pr(t,18)^t>>>3,i=pr(n,17)^pr(n,19)^n>>>10;jr[e]=i+jr[e-7]+r+jr[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=pr(o,6)^pr(o,11)^pr(o,25),u=l+t+Tr(o,s,c)+Ar[e]+jr[e]|0,d=(pr(n,2)^pr(n,13)^pr(n,22))+Er(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){dr(jr)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),dr(this.buffer)}},Nr=class extends Mr{constructor(){super(32,Or)}},Pr=Bn(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Fr=Pr[0],Ir=Pr[1],Lr=new Uint32Array(80),Rr=new Uint32Array(80),zr=class extends Dr{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(e,t){super(128,e,16,!1),this.Ah=t[0]|0,this.Al=t[1]|0,this.Bh=t[2]|0,this.Bl=t[3]|0,this.Ch=t[4]|0,this.Cl=t[5]|0,this.Dh=t[6]|0,this.Dl=t[7]|0,this.Eh=t[8]|0,this.El=t[9]|0,this.Fh=t[10]|0,this.Fl=t[11]|0,this.Gh=t[12]|0,this.Gl=t[13]|0,this.Hh=t[14]|0,this.Hl=t[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)Lr[n]=e.getUint32(t),Rr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Lr[e-15]|0,n=Rr[e-15]|0,r=Kn(t,n,1)^Kn(t,n,8)^Wn(t,n,7),i=qn(t,n,1)^qn(t,n,8)^Gn(t,n,7),a=Lr[e-2]|0,o=Rr[e-2]|0,s=Kn(a,o,19)^Jn(a,o,61)^Wn(a,o,6),c=$n(i,qn(a,o,19)^Yn(a,o,61)^Gn(a,o,6),Rr[e-7],Rr[e-16]),l=er(c,r,s,Lr[e-7],Lr[e-16]);Lr[e]=l|0,Rr[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Kn(u,d,14)^Kn(u,d,18)^Jn(u,d,41),v=qn(u,d,14)^qn(u,d,18)^Yn(u,d,41),ee=u&f^~u&m,y=d&p^~d&h,te=tr(_,v,y,Ir[e],Rr[e]),b=nr(te,g,t,ee,Fr[e],Lr[e]),x=te|0,S=Kn(n,r,28)^Jn(n,r,34)^Jn(n,r,39),C=qn(n,r,28)^Yn(n,r,34)^Yn(n,r,39),w=n&i^n&o^i&o,T=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Xn(c|0,l|0,b|0,x|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let E=Zn(x,C,T);n=Qn(E,b,S,w),r=E|0}({h:n,l:r}=Xn(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Xn(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Xn(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Xn(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Xn(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Xn(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Xn(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Xn(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){dr(Lr,Rr)}destroy(){this.destroyed=!0,dr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Br=class extends zr{constructor(){super(64,kr)}},I=Sr(()=>new Nr,wr(1)),Vr=Sr(()=>new Br,wr(3)),Hr=[`Object`,`RegExp`,`Date`,`Error`,`Map`,`Set`,`WeakMap`,`WeakSet`,`ArrayBuffer`,`SharedArrayBuffer`,`DataView`,`Promise`,`URL`,`HTMLElement`,`Int8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`,`Tagged`];function Ur(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(e===!0||e===!1)return`boolean`;let t=typeof e;return t===`string`||t===`number`||t===`bigint`||t===`symbol`?t:t===`function`?`Function`:Array.isArray(e)?`Array`:e instanceof Uint8Array?`Uint8Array`:e.constructor===Object?`Object`:Wr(e)||`Object`}function Wr(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Hr.includes(t))return t}var L=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:+(this.major>e.major)}static equals(e,t){return e===t||e.major===t.major&&e.name===t.name}};L.uint=new L(0,`uint`,!0),L.negint=new L(1,`negint`,!0),L.bytes=new L(2,`bytes`,!0),L.string=new L(3,`string`,!0),L.array=new L(4,`array`,!1),L.map=new L(5,`map`,!1),L.tag=new L(6,`tag`,!1),L.float=new L(7,`float`,!0),L.false=new L(7,`false`,!0),L.true=new L(7,`true`,!0),L.null=new L(7,`null`,!0),L.undefined=new L(7,`undefined`,!0),L.break=new L(7,`break`,!0);var R=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}},Gr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer==`function`,Kr=new TextEncoder;function qr(e){return Gr&&globalThis.Buffer.isBuffer(e)}function Jr(e){return e instanceof Uint8Array?qr(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Yr=24,Xr=200,Zr=Gr?e=>e.length>=Yr?globalThis.Buffer.from(e):ri(e):e=>e.length>=Xr?Kr.encode(e):ri(e),Qr=e=>Uint8Array.from(e),$r=Gr?(e,t,n)=>qr(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),ei=Gr?(e,t)=>(e=e.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Jr(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let t of e)r+t.length>n.length&&(t=t.subarray(0,n.length-r)),n.set(t,r),r+=t.length;return n},ti=Gr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ni(e,t){if(qr(e)&&qr(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function ri(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(i>=55296&&i<=57343&&(i=65533),t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}var ii=256,ai=class{constructor(e=ii){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}pushByte(e){let t=this.chunks[this.chunks.length-1];this.cursor>this.maxCursor&&(t=ti(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t));let n=t.length-(this.maxCursor-this.cursor)-1;t[n]=e,this.cursor++}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let n=t.length-(this.maxCursor-this.cursor)-1;t.set(e,n)}else{if(t){let e=t.length-(this.maxCursor-this.cursor)-1;e<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,e),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=ti(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=$r(n,0,this.cursor)}else t=ei(this.chunks,this.cursor);return e&&this.reset(),t}},oi=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}pushByte(e){if(this.cursor>=this.dest.length)throw Error(`write out of bounds, destination buffer is too small`);this.dest[this.cursor++]=e}push(e){if(this.cursor+e.length>this.dest.length)throw Error(`write out of bounds, destination buffer is too small`);this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let t=this.dest.subarray(0,this.cursor);return e&&this.reset(),t}},z=`CBOR decode error:`,si=`CBOR encode error:`;function ci(e,t,n){if(e.length-t<n)throw Error(`${z} not enough data for type`)}var li=[24,256,65536,4294967296,BigInt(`18446744073709551616`)];function ui(e,t,n){ci(e,t,1);let r=e[t];if(n.strict===!0&&r<li[0])throw Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function di(e,t,n){ci(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<li[1])throw Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function fi(e,t,n){ci(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<li[2])throw Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function pi(e,t,n){ci(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],a=(BigInt(r)<<BigInt(32))+BigInt(i);if(n.strict===!0&&a<li[3])throw Error(`${z} integer encoded in more bytes than necessary (strict decode)`);if(a<=2**53-1)return Number(a);if(n.allowBigInt===!0)return a;throw Error(`${z} integers outside of the safe integer range are not supported`)}function mi(e,t,n,r){return new R(L.uint,ui(e,t+1,r),2)}function hi(e,t,n,r){return new R(L.uint,di(e,t+1,r),3)}function gi(e,t,n,r){return new R(L.uint,fi(e,t+1,r),5)}function _i(e,t,n,r){return new R(L.uint,pi(e,t+1,r),9)}function vi(e,t){return yi(e,0,t.value)}function yi(e,t,n){if(n<li[0]){let r=Number(n);e.pushByte(t|r)}else if(n<li[1]){let r=Number(n);e.push([t|24,r])}else if(n<li[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<li[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<li[4]){let n=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),a=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=i&255,i>>=8,n[7]=i&255,i>>=8,n[6]=i&255,i>>=8,n[5]=i&255,n[4]=a&255,a>>=8,n[3]=a&255,a>>=8,n[2]=a&255,a>>=8,n[1]=a&255,e.push(n)}else throw Error(`${z} encountered BigInt larger than allowable range`)}}vi.encodedSize=function(e){return yi.encodedSize(e.value)},yi.encodedSize=function(e){return e<li[0]?1:e<li[1]?2:e<li[2]?3:e<li[3]?5:9},vi.compareTokens=function(e,t){return e.value<t.value?-1:+(e.value>t.value)};function bi(e,t,n,r){return new R(L.negint,-1-ui(e,t+1,r),2)}function xi(e,t,n,r){return new R(L.negint,-1-di(e,t+1,r),3)}function Si(e,t,n,r){return new R(L.negint,-1-fi(e,t+1,r),5)}var Ci=BigInt(-1),wi=BigInt(1);function Ti(e,t,n,r){let i=pi(e,t+1,r);if(typeof i!=`bigint`){let e=-1-i;if(e>=-(2**53-1))return new R(L.negint,e,9)}if(r.allowBigInt!==!0)throw Error(`${z} integers outside of the safe integer range are not supported`);return new R(L.negint,Ci-BigInt(i),9)}function Ei(e,t){let n=t.value,r=typeof n==`bigint`?n*Ci-wi:n*-1-1;yi(e,t.type.majorEncoded,r)}Ei.encodedSize=function(e){let t=e.value,n=typeof t==`bigint`?t*Ci-wi:t*-1-1;return n<li[0]?1:n<li[1]?2:n<li[2]?3:n<li[3]?5:9},Ei.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Di(e,t,n,r){ci(e,t,n+r);let i=e.slice(t+n,t+n+r);return new R(L.bytes,i,n+r)}function Oi(e,t,n,r){return Di(e,t,1,n)}function ki(e,t,n,r){return Di(e,t,2,ui(e,t+1,r))}function Ai(e,t,n,r){return Di(e,t,3,di(e,t+1,r))}function ji(e,t,n,r){return Di(e,t,5,fi(e,t+1,r))}function Mi(e,t,n,r){let i=pi(e,t+1,r);if(typeof i==`bigint`)throw Error(`${z} 64-bit integer bytes lengths not supported`);return Di(e,t,9,i)}function Ni(e){return e.encodedBytes===void 0&&(e.encodedBytes=L.equals(e.type,L.string)?Zr(e.value):e.value),e.encodedBytes}function Pi(e,t){let n=Ni(t);yi(e,t.type.majorEncoded,n.length),e.push(n)}Pi.encodedSize=function(e){let t=Ni(e);return yi.encodedSize(t.length)+t.length},Pi.compareTokens=function(e,t){return Fi(Ni(e),Ni(t))};function Fi(e,t){return e.length<t.length?-1:e.length>t.length?1:ni(e,t)}var Ii=new TextDecoder,Li=32;function Ri(e,t,n){if(n-t<Li){let r=``;for(let i=t;i<n;i++){let a=e[i];if(a&128)return Ii.decode(e.subarray(t,n));r+=String.fromCharCode(a)}return r}return Ii.decode(e.subarray(t,n))}function zi(e,t,n,r,i){let a=n+r;ci(e,t,a);let o=new R(L.string,Ri(e,t+n,t+a),a);return i.retainStringBytes===!0&&(o.byteValue=e.slice(t+n,t+a)),o}function Bi(e,t,n,r){return zi(e,t,1,n,r)}function Vi(e,t,n,r){return zi(e,t,2,ui(e,t+1,r),r)}function Hi(e,t,n,r){return zi(e,t,3,di(e,t+1,r),r)}function Ui(e,t,n,r){return zi(e,t,5,fi(e,t+1,r),r)}function Wi(e,t,n,r){let i=pi(e,t+1,r);if(typeof i==`bigint`)throw Error(`${z} 64-bit integer string lengths not supported`);return zi(e,t,9,i,r)}var Gi=Pi;function Ki(e,t,n,r){return new R(L.array,r,n)}function qi(e,t,n,r){return Ki(e,t,1,n)}function Ji(e,t,n,r){return Ki(e,t,2,ui(e,t+1,r))}function Yi(e,t,n,r){return Ki(e,t,3,di(e,t+1,r))}function Xi(e,t,n,r){return Ki(e,t,5,fi(e,t+1,r))}function Zi(e,t,n,r){let i=pi(e,t+1,r);if(typeof i==`bigint`)throw Error(`${z} 64-bit integer array lengths not supported`);return Ki(e,t,9,i)}function Qi(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${z} indefinite length items not allowed`);return Ki(e,t,1,1/0)}function $i(e,t){yi(e,L.array.majorEncoded,t.value)}$i.compareTokens=vi.compareTokens,$i.encodedSize=function(e){return yi.encodedSize(e.value)};function ea(e,t,n,r){return new R(L.map,r,n)}function ta(e,t,n,r){return ea(e,t,1,n)}function na(e,t,n,r){return ea(e,t,2,ui(e,t+1,r))}function ra(e,t,n,r){return ea(e,t,3,di(e,t+1,r))}function ia(e,t,n,r){return ea(e,t,5,fi(e,t+1,r))}function aa(e,t,n,r){let i=pi(e,t+1,r);if(typeof i==`bigint`)throw Error(`${z} 64-bit integer map lengths not supported`);return ea(e,t,9,i)}function oa(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${z} indefinite length items not allowed`);return ea(e,t,1,1/0)}function sa(e,t){yi(e,L.map.majorEncoded,t.value)}sa.compareTokens=vi.compareTokens,sa.encodedSize=function(e){return yi.encodedSize(e.value)};function ca(e,t,n,r){return new R(L.tag,n,1)}function la(e,t,n,r){return new R(L.tag,ui(e,t+1,r),2)}function ua(e,t,n,r){return new R(L.tag,di(e,t+1,r),3)}function da(e,t,n,r){return new R(L.tag,fi(e,t+1,r),5)}function fa(e,t,n,r){return new R(L.tag,pi(e,t+1,r),9)}function pa(e,t){yi(e,L.tag.majorEncoded,t.value)}pa.compareTokens=vi.compareTokens,pa.encodedSize=function(e){return yi.encodedSize(e.value)};function ma(e,t,n,r){if(r.allowUndefined===!1)throw Error(`${z} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new R(L.null,null,1):new R(L.undefined,void 0,1)}function ha(e,t,n,r){if(r.allowIndefinite===!1)throw Error(`${z} indefinite length items not allowed`);return new R(L.break,void 0,1)}function ga(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw Error(`${z} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw Error(`${z} Infinity values are not supported`)}return new R(L.float,e,t)}function _a(e,t,n,r){return ga(Ta(e,t+1),3,r)}function va(e,t,n,r){return ga(Da(e,t+1),5,r)}function ya(e,t,n,r){return ga(ka(e,t+1),9,r)}function ba(e,t,n){let r=t.value;if(r===!1)e.pushByte(L.float.majorEncoded|20);else if(r===!0)e.pushByte(L.float.majorEncoded|21);else if(r===null)e.pushByte(L.float.majorEncoded|22);else if(r===void 0)e.pushByte(L.float.majorEncoded|23);else{let t,i=!1;(!n||n.float64!==!0)&&(wa(r),t=Ta(Ca,1),r===t||Number.isNaN(r)?(Ca[0]=249,e.push(Ca.slice(0,3)),i=!0):(Ea(r),t=Da(Ca,1),r===t&&(Ca[0]=250,e.push(Ca.slice(0,5)),i=!0))),i||(Oa(r),t=ka(Ca,1),Ca[0]=251,e.push(Ca.slice(0,9)))}}ba.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n==null)return 1;if(!t||t.float64!==!0){wa(n);let e=Ta(Ca,1);if(n===e||Number.isNaN(n))return 3;if(Ea(n),e=Da(Ca,1),n===e)return 5}return 9};var xa=new ArrayBuffer(9),Sa=new DataView(xa,1),Ca=new Uint8Array(xa,0);function wa(e){if(e===1/0)Sa.setUint16(0,31744,!1);else if(e===-1/0)Sa.setUint16(0,64512,!1);else if(Number.isNaN(e))Sa.setUint16(0,32256,!1);else{Sa.setFloat32(0,e);let t=Sa.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)Sa.setUint16(0,31744,!1);else if(n===0)Sa.setUint16(0,(t&2147483648)>>16|r>>13,!1);else{let e=n-127;e<-24?Sa.setUint16(0,0):e<-14?Sa.setUint16(0,(t&2147483648)>>16|1<<24+e,!1):Sa.setUint16(0,(t&2147483648)>>16|e+15<<10|r>>13,!1)}}}function Ta(e,t){if(e.length-t<2)throw Error(`${z} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,i=n&1023,a;return a=r===0?i*2**-24:r===31?i===0?1/0:NaN:(i+1024)*2**(r-25),n&32768?-a:a}function Ea(e){Sa.setFloat32(0,e,!1)}function Da(e,t){if(e.length-t<4)throw Error(`${z} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function Oa(e){Sa.setFloat64(0,e,!1)}function ka(e,t){if(e.length-t<8)throw Error(`${z} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function Aa(e,t){let n=e.value;if(n===!1)return Uint8Array.of(L.float.majorEncoded|20);if(n===!0)return Uint8Array.of(L.float.majorEncoded|21);if(n===null)return Uint8Array.of(L.float.majorEncoded|22);if(n===void 0)return Uint8Array.of(L.float.majorEncoded|23);if(!t){if(wa(n),n===Ta(Ca,1)||Number.isNaN(n))return Ca[0]=249,Ca.slice(0,3);if(Ea(n),n===Da(Ca,1))return Ca[0]=250,Ca.slice(0,5)}return Oa(n),Ca[0]=251,Ca.slice(0,9)}function ja(e,t){let n=e,r=t?.float64===!0,i=r?n._keyBytesFloat64:n._keyBytes;if(i!==void 0)return i;let a=Aa(e,r);return r?n._keyBytesFloat64=a:n._keyBytes=a,a}ba.compareTokens=function(e,t,n){let r=ja(e,n),i=ja(t,n);return r.length===i.length?ni(r,i):r.length<i.length?-1:1};function B(e,t,n){throw Error(`${z} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function Ma(e){return()=>{throw Error(`${z} ${e}`)}}var V=[];for(let e=0;e<=23;e++)V[e]=B;V[24]=mi,V[25]=hi,V[26]=gi,V[27]=_i,V[28]=B,V[29]=B,V[30]=B,V[31]=B;for(let e=32;e<=55;e++)V[e]=B;V[56]=bi,V[57]=xi,V[58]=Si,V[59]=Ti,V[60]=B,V[61]=B,V[62]=B,V[63]=B;for(let e=64;e<=87;e++)V[e]=Oi;V[88]=ki,V[89]=Ai,V[90]=ji,V[91]=Mi,V[92]=B,V[93]=B,V[94]=B,V[95]=Ma(`indefinite length bytes/strings are not supported`);for(let e=96;e<=119;e++)V[e]=Bi;V[120]=Vi,V[121]=Hi,V[122]=Ui,V[123]=Wi,V[124]=B,V[125]=B,V[126]=B,V[127]=Ma(`indefinite length bytes/strings are not supported`);for(let e=128;e<=151;e++)V[e]=qi;V[152]=Ji,V[153]=Yi,V[154]=Xi,V[155]=Zi,V[156]=B,V[157]=B,V[158]=B,V[159]=Qi;for(let e=160;e<=183;e++)V[e]=ta;V[184]=na,V[185]=ra,V[186]=ia,V[187]=aa,V[188]=B,V[189]=B,V[190]=B,V[191]=oa;for(let e=192;e<=215;e++)V[e]=ca;V[216]=la,V[217]=ua,V[218]=da,V[219]=fa,V[220]=B,V[221]=B,V[222]=B,V[223]=B;for(let e=224;e<=243;e++)V[e]=Ma(`simple values are not supported`);V[244]=B,V[245]=B,V[246]=B,V[247]=ma,V[248]=Ma(`simple values are not supported`),V[249]=_a,V[250]=va,V[251]=ya,V[252]=B,V[253]=B,V[254]=B,V[255]=ha;var Na=[];for(let e=0;e<24;e++)Na[e]=new R(L.uint,e,1);for(let e=-1;e>=-24;e--)Na[31-e]=new R(L.negint,e,1);Na[64]=new R(L.bytes,new Uint8Array,1),Na[96]=new R(L.string,``,1),Na[128]=new R(L.array,0,1),Na[160]=new R(L.map,0,1),Na[244]=new R(L.false,!1,1),Na[245]=new R(L.true,!0,1),Na[246]=new R(L.null,null,1);function Pa(e){switch(e.type){case L.false:return Qr([244]);case L.true:return Qr([245]);case L.null:return Qr([246]);case L.bytes:return e.value.length?void 0:Qr([64]);case L.string:return e.value===``?Qr([96]):void 0;case L.array:return e.value===0?Qr([128]):void 0;case L.map:return e.value===0?Qr([160]):void 0;case L.uint:return e.value<24?Qr([Number(e.value)]):void 0;case L.negint:if(e.value>=-24)return Qr([31-Number(e.value)])}}var Fa={float64:!1,mapSorter:Ga,quickEncodeToken:Pa},Ia=Object.freeze({mapSorter:Ka,quickEncodeToken:Pa});function La(){let e=[];return e[L.uint.major]=vi,e[L.negint.major]=Ei,e[L.bytes.major]=Pi,e[L.string.major]=Gi,e[L.array.major]=$i,e[L.map.major]=sa,e[L.tag.major]=pa,e[L.float.major]=ba,e}var Ra=La(),za=new ai,Ba=class e{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw Error(`${si} object contains circular references`);return new e(n,t)}},Va={null:new R(L.null,null),undefined:new R(L.undefined,void 0),true:new R(L.true,!0),false:new R(L.false,!1),emptyArray:new R(L.array,0),emptyMap:new R(L.map,0)},Ha={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new R(L.float,e):e>=0?new R(L.uint,e):new R(L.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new R(L.uint,e):new R(L.negint,e)},Uint8Array(e,t,n,r){return new R(L.bytes,e)},string(e,t,n,r){return new R(L.string,e)},boolean(e,t,n,r){return e?Va.true:Va.false},null(e,t,n,r){return Va.null},undefined(e,t,n,r){return Va.undefined},ArrayBuffer(e,t,n,r){return new R(L.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new R(L.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[Va.emptyArray,new R(L.break)]:Va.emptyArray;r=Ba.createCheck(r,e);let i=[],a=0;for(let t of e)i[a++]=Ua(t,n,r);return n.addBreakTokens?[new R(L.array,e.length),i,new R(L.break)]:[new R(L.array,e.length),i]},Object(e,t,n,r){let i=t!==`Object`,a=i?e.keys():Object.keys(e),o=i?e.size:a.length,s;if(o){s=Array(o),r=Ba.createCheck(r,e);let t=!i&&n.ignoreUndefinedProperties,c=0;for(let o of a){let a=i?e.get(o):e[o];t&&a===void 0||(s[c++]=[Ua(o,n,r),Ua(a,n,r)])}c<o&&(s.length=c)}return s?.length?(Wa(s,n),n.addBreakTokens?[new R(L.map,s.length),s,new R(L.break)]:[new R(L.map,s.length),s]):n.addBreakTokens===!0?[Va.emptyMap,new R(L.break)]:Va.emptyMap},Tagged(e,t,n,r){return[new R(L.tag,e.tag),Ua(e.value,n,r)]}};Ha.Map=Ha.Object,Ha.Buffer=Ha.Uint8Array;for(let e of`Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64`.split(` `))Ha[`${e}Array`]=Ha.DataView;function Ua(e,t={},n){let r=Ur(e),i=t&&t.typeEncoders&&t.typeEncoders[r]||Ha[r];if(typeof i==`function`){let a=i(e,r,t,n);if(a!=null)return a}let a=Ha[r];if(!a)throw Error(`${si} unsupported type: ${r}`);return a(e,r,t,n)}function Wa(e,t){let n=t.mapSorter;n&&e.sort((e,r)=>n(e,r,t))}function Ga(e,t,n){let r=Array.isArray(e[0])?e[0][0]:e[0],i=Array.isArray(t[0])?t[0][0]:t[0];if(r.type.major!==i.type.major)return r.type.compare(i.type);let a=Ra[r.type.major].compareTokens(r,i,n);return a===0&&console.warn(`WARNING: complex key types used, CBOR key sorting guarantees are gone`),a}function Ka(e,t){if(e[0]instanceof R&&t[0]instanceof R){let n=e[0],r=t[0];return n._keyBytes||=qa(n.value),r._keyBytes||=qa(r.value),ni(n._keyBytes,r._keyBytes)}throw Error(`rfc8949MapSorter: complex key types are not supported yet`)}function qa(e){return fo(e,Ra,Ia)}function Ja(e,t,n,r){if(Array.isArray(t))for(let i of t)Ja(e,i,n,r);else n[t.type.major](e,t,r)}var Ya=L.uint.majorEncoded,Xa=L.negint.majorEncoded,Za=L.bytes.majorEncoded,Qa=L.string.majorEncoded,$a=L.array.majorEncoded,eo=L.map.majorEncoded,to=L.float.majorEncoded|20,no=L.float.majorEncoded|21,ro=L.float.majorEncoded|22,io=L.float.majorEncoded|23,ao=BigInt(-1),oo=BigInt(1);function so(e,t,n){n<24?e.pushByte(t|Number(n)):yi(e,t,n)}function co(e){return e.addBreakTokens!==!0}function lo(e,t,n,r,i){let a=n===`Map`,o=a?t.keys():Object.keys(t),s=a?t.size:o.length;if(!s){e.pushByte(eo);return}i=Ba.createCheck(i,t);let c=!a&&r.ignoreUndefinedProperties,l=Array(s),u=0;for(let e of o){let n=a?t.get(e):t[e];c&&n===void 0||(l[u++]=[Ua(e,r,i),n])}if(u===0){e.pushByte(eo);return}u<s&&(l.length=u),l.sort((e,t)=>Ga(e,t,r)),so(e,eo,u);for(let[t,n]of l)Ja(e,t,Ra,r),uo(e,n,r,i)}function uo(e,t,n,r){let i=Ur(t),a=n.typeEncoders&&n.typeEncoders[i];if(a){let o=a(t,i,n,r);if(o!=null){Ja(e,o,Ra,n);return}}switch(i){case`null`:e.pushByte(ro);return;case`undefined`:e.pushByte(io);return;case`boolean`:e.pushByte(t?no:to);return;case`number`:!Number.isInteger(t)||!Number.isSafeInteger(t)?ba(e,new R(L.float,t),n):t>=0?so(e,Ya,t):so(e,Xa,t*-1-1);return;case`bigint`:t>=BigInt(0)?so(e,Ya,t):so(e,Xa,t*ao-oo);return;case`string`:{let n=Zr(t);so(e,Qa,n.length),e.push(n);return}case`Uint8Array`:so(e,Za,t.length),e.push(t);return;case`Array`:if(!t.length){e.pushByte($a);return}r=Ba.createCheck(r,t),so(e,$a,t.length);for(let i of t)uo(e,i,n,r);return;case`Object`:case`Map`:n.mapSorter===Ga?lo(e,t,i,n,r):Ja(e,Ha.Object(t,i,n,r),Ra,n);return;default:{let a=Ha[i];if(!a)throw Error(`${si} unsupported type: ${i}`);Ja(e,a(t,i,n,r),Ra,n)}}}function fo(e,t,n,r){let i=r instanceof Uint8Array,a=i?new oi(r):za,o=Ua(e,n);if(!Array.isArray(o)&&n.quickEncodeToken){let e=n.quickEncodeToken(o);if(e)return i?(a.push(e),a.toBytes()):e;let r=t[o.type.major];if(r.encodedSize){let e=r.encodedSize(o,n);if(i||(a=new ai(e)),r(a,o,n),a.chunks.length!==1)throw Error(`Unexpected error: pre-calculated length for ${o} was wrong`);return i?a.toBytes():Jr(a.chunks[0])}}return a.reset(),Ja(a,o,t,n),a.toBytes(!0)}function po(e,t){return t=Object.assign({},Fa,t),co(t)?(za.reset(),uo(za,e,t,void 0),za.toBytes(!0)):fo(e,Ra,t)}var mo={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ho=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=Na[e];if(t===void 0){let n=V[e];if(!n)throw Error(`${z} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,`0`)})`);let r=e&31;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}},go=Symbol.for(`DONE`),_o=Symbol.for(`BREAK`);function vo(e,t,n){let r=[];for(let i=0;i<e.value;i++){let a=So(t,n);if(a===_o){if(e.value===1/0)break;throw Error(`${z} got unexpected break to lengthed array`)}if(a===go)throw Error(`${z} found array but not enough entries (got ${i}, expected ${e.value})`);r[i]=a}return r}function yo(e,t,n){let r=n.useMaps===!0,i=n.rejectDuplicateMapKeys===!0,a=r?void 0:{},o=r?new Map:void 0;for(let s=0;s<e.value;s++){let c=So(t,n);if(c===_o){if(e.value===1/0)break;throw Error(`${z} got unexpected break to lengthed map`)}if(c===go)throw Error(`${z} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(!r&&typeof c!=`string`)throw Error(`${z} non-string keys not supported (got ${typeof c})`);if(i&&(r&&o.has(c)||!r&&Object.hasOwn(a,c)))throw Error(`${z} found repeat map key "${c}"`);let l=So(t,n);if(l===go)throw Error(`${z} found map but not enough entries (got ${s} [no value], expected ${e.value})`);r?o.set(c,l):c===`__proto__`?Object.defineProperty(a,c,{value:l,configurable:!0,enumerable:!0,writable:!0}):a[c]=l}return r?o:a}function*bo(e,t,n){for(let r=0;r<e.value;r++){let i=So(t,n);if(i===_o){if(e.value===1/0)break;throw Error(`${z} got unexpected break to lengthed map`)}if(i===go)throw Error(`${z} found map but not enough entries (got ${r} [no key], expected ${e.value})`);let a=So(t,n);if(a===go)throw Error(`${z} found map but not enough entries (got ${r} [no value], expected ${e.value})`);yield[i,a]}}function xo(e,t){let n=function(){if(n._called)throw Error(`${z} tag decode() may only be called once`);n._called=!0;let r=So(e,t);if(r===go)throw Error(`${z} tag content missing`);if(r===_o)throw Error(`${z} got unexpected break in tag content`);return r};return n.entries=function(){if(n._called)throw Error(`${z} tag decode() may only be called once`);n._called=!0;let r=e.next();if(!L.equals(r.type,L.map))throw Error(`${z} entries() requires map content, got ${r.type.name}`);let i=[];for(let n of bo(r,e,t))i.push(n);return i},n._called=!1,n}function So(e,t){if(e.done())return go;let n=e.next();if(L.equals(n.type,L.break))return _o;if(n.type.terminal)return n.value;if(L.equals(n.type,L.array))return vo(n,e,t);if(L.equals(n.type,L.map))return yo(n,e,t);if(L.equals(n.type,L.tag)){if(t.tags&&typeof t.tags[n.value]==`function`){let r=xo(e,t),i=t.tags[n.value](r);if(!r._called)throw Error(`${z} tag decoder must call decode() or entries()`);return i}throw Error(`${z} tag not supported (${n.value})`)}throw Error(`unsupported`)}function Co(e,t){if(!(e instanceof Uint8Array))throw Error(`${z} data to decode must be a Uint8Array`);t=Object.assign({},mo,t);let n=Jr(e),r=t.tokenizer||new ho(n,t),i=So(r,t);if(i===go)throw Error(`${z} did not find any content to decode`);if(i===_o)throw Error(`${z} got unexpected break`);return[i,e.subarray(r.pos())]}function wo(e,t){let[n,r]=Co(e,t);if(r.length>0)throw Error(`${z} too many terminals, data makes no sense`);return n}Object.defineProperty(class e{constructor(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<0)throw TypeError(`Tagged: tag must be a non-negative integer`);this.tag=e,this.value=t}static decoder(t){return n=>new e(t,n())}static preserve(...t){let n={};for(let r of t)n[r]=e.decoder(r);return n}}.prototype,Symbol.toStringTag,{value:`Tagged`});var To=Uint8Array.from([32,9,13,10,32,9,13,10]);function Eo(e){return e.byteLength>=8&&e[0]===0}function Do(e){if(e.byteLength<To.byteLength)return!1;for(let t=0;t<To.byteLength;t+=1)if(e[t]!==To[t])return!1;return!0}function Oo(e){return Do(e)?{advertised:!0,message:e.subarray(To.byteLength)}:{advertised:!1,message:e}}function ko(e,t,n){e[0]=0,e[1]=1,e[2]=+!!n,e[3]=0,e[4]=t>>>24&255,e[5]=t>>>16&255,e[6]=t>>>8&255,e[7]=t&255}function Ao(e){return(e[4]<<24>>>0)+(e[5]<<16>>>0)+(e[6]<<8>>>0)+e[7]}function jo(e,t){if(e.byteLength<=t)return[e];let n=t-8;if(n<=0)throw Error(`Relay chunk limit is too small to carry a chunk header.`);let r=[];for(let t=0;t<e.byteLength;t+=n){let i=e.subarray(t,Math.min(t+n,e.byteLength)),a=new Uint8Array(8+i.byteLength);ko(a,e.byteLength,t+i.byteLength>=e.byteLength),a.set(i,8),r.push(a)}return r}function Mo(e,t){if(!Number.isSafeInteger(t.maxChunkBytes)||t.maxChunkBytes<=0||!Number.isSafeInteger(t.maxMessageBytes)||t.maxMessageBytes<0||!Number.isSafeInteger(e)||e<0)throw TypeError(`Relay chunk limits must be positive and message limits non-negative safe integers.`);if(e>t.maxMessageBytes)return{kind:`error`,reason:`message_too_large`};if(e<=t.maxChunkBytes){let n=e+To.byteLength<=t.maxChunkBytes;return{kind:`ready`,advertised:n,chunked:!1,payloadBytes:[n?To.byteLength+e:e]}}if(!t.peerSupportsChunking)return{kind:`error`,reason:`peer_unsupported`};let n=t.maxChunkBytes-8;if(n<=0)throw Error(`Relay chunk limit is too small to carry a chunk header.`);let r=[];for(let t=0;t<e;t+=n)r.push(8+Math.min(n,e-t));return{kind:`ready`,advertised:!1,chunked:!0,payloadBytes:r}}function No(e,t){let n=Mo(e.byteLength,t);if(n.kind===`error`)return n;if(n.chunked)return{kind:`ready`,payloads:jo(e,t.maxChunkBytes)};if(!n.advertised)return{kind:`ready`,payloads:[e]};let r=new Uint8Array(To.byteLength+e.byteLength);return r.set(To),r.set(e,To.byteLength),{kind:`ready`,payloads:[r]}}var Po=class{#e=[];#t=0;#n=0;#r=!1;get heldBytes(){return this.#t}get incompleteMessage(){return this.#n!==0}get peerSupportsChunking(){return this.#r}push(e){if(!Eo(e)){if(this.#n!==0)return this.reset(),{kind:`error`,reason:`interleaved_legacy`};let t=Oo(e);return t.advertised&&(this.#r=!0),{kind:`done`,message:t.message}}if(e[1]!==1||e[2]&-2||e[3]!==0)return this.reset(),{kind:`error`,reason:`bad_header`};let t=Ao(e),n=e.subarray(8),r=!!(e[2]&1);if(n.byteLength===0)return this.reset(),{kind:`error`,reason:`bad_header`};if(this.#n===0){if(t>4194304||t===0)return{kind:`error`,reason:`message_too_large`};this.#n=t,this.#t=0}else if(t!==this.#n)return this.reset(),{kind:`error`,reason:`total_mismatch`};if(this.#t+n.byteLength>this.#n)return this.reset(),{kind:`error`,reason:`overflow`};this.#r=!0;let i=Uint8Array.from(n);if(n.fill(0),this.#e.push(i),this.#t+=n.byteLength,!r)return{kind:`pending`};if(this.#t!==this.#n)return this.reset(),{kind:`error`,reason:`truncated`};let a=new Uint8Array(this.#n),o=0;for(let e of this.#e)a.set(e,o),o+=e.byteLength,e.fill(0);return this.#e=[],this.#t=0,this.#n=0,{kind:`done`,message:a}}reset(){for(let e of this.#e)e.fill(0);this.#e=[],this.#t=0,this.#n=0,this.#r=!1}},Fo=4096,Io=8192,Lo=ze;function Ro(e){return e.maxQueuedBytes-e.maxControlFrameBytes}function zo(e){let t=Math.min(c,e.maxQueuedBytes-e.maxControlFrameBytes),n=t-32;return{effectiveMessageCeiling:t,plaintextCeiling:n,establishable:n>0}}var Bo=1500,Vo=3e3,Ho=3e3,Uo=1500,Wo=1e3,Go=4294967295n,Ko=18446744073709551615n,qo={digits:60,groups:12,digitsPerGroup:5,separator:` `},Jo={chars:8,groups:2,charsPerGroup:4,separator:`-`},Yo=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;To.byteLength;var Xo=8e3;function Zo(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}var H=(e,t,n)=>or(e,t,n),Qo=ar;function $o(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function es(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function ts(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var ns=gr,rs=(...e)=>br(...e),is=e=>vr(e),as=rr,os=e=>Cr(e),ss=BigInt(0),cs=BigInt(1),ls=e=>e?`"${e}" `:``;function us(e,t=``){if(typeof e!=`boolean`)throw TypeError(ls(t)+`expected boolean, got type=`+typeof e);return e}function ds(e){if(typeof e==`bigint`){if(!bs(e))throw RangeError(`positive bigint expected, got `+e)}else Qo(e);return e}function fs(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function ps(e){let t=ds(e).toString(16);return t.length&1?`0`+t:t}function ms(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?ss:BigInt(`0x`+e)}function hs(e){return ms(gr(e))}function gs(e){return ms(gr(ys(or(e)).reverse()))}function _s(e,t){if(ar(t),t===0)throw Error(`zero output length is invalid`);e=ds(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return vr(r.padStart(n,`0`))}function vs(e,t){return _s(e,t).reverse()}function ys(e){return Uint8Array.from(H(e))}function bs(e){return typeof e==`bigint`&&ss<=e}function xs(e,t,n){return bs(e)&&bs(t)&&bs(n)&&t<=e&&e<n}function Ss(e,t,n,r){if(!xs(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Cs(e){if(e<ss)throw Error(`expected non-negative bigint, got `+e);return e===ss?0:e.toString(2).length}var ws=e=>(fs(e,`n`),(cs<<BigInt(e))-cs);function Ts(e,t,n){if(ar(e,`hashLen`),ar(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,rs(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return rs(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function Es(e,t={},n={},r=`object`){es(e,r),es(t,`fields`),es(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var Ds=BigInt(0),U=BigInt(1),Os=BigInt(2),ks=BigInt(3),As=BigInt(4),js=BigInt(5),Ms=BigInt(7),Ns=BigInt(8),Ps=BigInt(9),Fs=BigInt(15),Is=BigInt(16),Ls=BigInt(`0x10000000000000000`);function W(e,t){if(t<=Ds)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=Ds?n:t+n}function Rs(e,t,n){if(n<=U)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<Ds)throw Error(`invalid exponent, negatives unsupported`);if(t===Ds)return U;if(t===U)return e;let r=e%n;if(r<Ds&&(r+=n),t<Ls){let e=U;for(;t>Ds;)t&U&&(e=e*r%n),r=r*r%n,t>>=U;return e}let i=[];for(;t>Ds;)i.push(Number(t&Fs)),t>>=As;let a=Array(16);a[0]=U,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function zs(e,t,n){if(n<=U)throw Error(`pow2: expected modulus > 1, got `+n);if(t<Ds)throw Error(`pow2: expected non-negative exponent, got `+t);let r=e;for(;t-->Ds;)r*=r,r%=n;return r}function Bs(e,t){if(e===Ds)throw Error(`invert: expected non-zero number`);if(t<=U)throw Error(`invert: expected modulus > 1, got `+t);let n=W(e,t),r=t,i=Ds,a=U;for(;n!==Ds;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==U)throw Error(`invert: does not exist`);return W(i,t)}function Vs(e,t){if(t<=U)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=W(e,t);if(n===Ds)throw Error(`invertCt: expected non-zero number`);let r=Rs(n,t-Os,t);if(W(n*r,t)!==U)throw Error(`invertCt: does not exist`);return r}function Hs(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Us(e,t){if((e&U)===Ds)throw Error(t+`: expected odd modulus, got `+e)}function Ws(e,t){let n=e,r=(n.ORDER+U)/As,i=n.pow(t,r);return Hs(n,i,t),i}function Gs(e,t){let n=e,r=(n.ORDER-js)/Ns,i=n.mul(t,Os),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Os),a),c=n.mul(o,n.sub(s,n.ONE));return Hs(n,c,t),c}function Ks(e){let t=rc(e),n=qs(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Ms)/Is;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return Hs(n,m,t),m})}function qs(e){if(e<ks)throw Error(`sqrt is not defined for small field`);Us(e,`tonelliShanks`);let t=e-U,n=0;for(;t%Os===Ds;)t/=Os,n++;let r=Os,i=rc(e);for(;$s(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Ws;let a=i.pow(r,t),o=(t+U)/Os;return function(e,r){let i=e;if(i.is0(r))return r;if($s(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=U<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function Js(e){return Us(e,`Fp.sqrt`),e%As===ks?Ws:e%Ns===js?Gs:e%Is===Ps?Ks(e):qs(e)}var Ys=(e,t)=>(W(e,t)&U)===U,Xs=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Zs(e){if(es(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);fs(e.BYTES,`BYTES`),fs(e.BITS,`BITS`);for(let t of Xs)ts(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=U)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function Qs(e,t,n=!1){Zs(e),Zo(t,`nums`),us(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function $s(e,t){Zs(e);let n=e;Us(n.ORDER,`FpLegendre`);let r=(n.ORDER-U)/Os,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function ec(e,t){if(t!==void 0&&Qo(t),e<=Ds)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Cs(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var tc=new WeakMap,nc=class{ORDER;BITS;BYTES;isLE;ZERO=Ds;ONE=U;_lengths;_mod;constructor(e,t={}){if(e<=U)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=ec(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return W(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return Ds<=e&&e<this.ORDER}is0(e){return e===Ds}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&U)===U}neg(e){return W(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return W(e*e,this.ORDER)}add(e,t){return W(e+t,this.ORDER)}sub(e,t){return W(e-t,this.ORDER)}mul(e,t){return W(e*t,this.ORDER)}pow(e,t){return Rs(e,t,this.ORDER)}div(e,t){return W(e*Bs(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return Bs(e,this.ORDER)}sqrt(e){let t=tc.get(this);return t||tc.set(this,t=Js(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?vs(e,this.BYTES):_s(e,this.BYTES)}fromBytes(e,t=!1){H(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?gs(e):hs(e);if(o&&(s=W(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return Qs(this,e,!0)}cmov(e,t,n){return us(n,`condition`),n?t:e}};function rc(e,t={}){return Object.freeze(nc.prototype),new nc(e,t)}function ic(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=U)throw Error(`field order must be greater than 1`);let t=Cs(e-U);return Math.ceil(t/8)}function ac(e){let t=ic(e);return t+Math.ceil(t/2)}function oc(e,t,n=!1){H(e);let r=e.length,i=ic(t),a=Math.max(ac(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=W(n?gs(e):hs(e),t-U)+U;return n?vs(o,i):_s(o,i)}var sc=BigInt(0),cc=BigInt(1),lc=BigInt(4),uc=16,dc=128,fc=5,pc=2**31;function mc(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);ts(t.fromAffine,`Point.fromAffine`),ts(t.fromBytes,`Point.fromBytes`),ts(t.fromHex,`Point.fromHex`),es(t.BASE,`Point.BASE`),es(t.ZERO,`Point.ZERO`),Zs(t.Fp),Zs(t.Fn)}function hc(e,t){mc(e),yc(t,e);let n=Qs(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function gc(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function _c(e,t){let n=e*(4*t+128);if(n>pc)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+pc/2**20+` MiB`)}function vc(e,t){if(e!==void 0){ts(e,`randomBytes`);try{let n=e(t);if(!as(n)||n.length!==t)return}catch{return}return e}}function yc(e,t){Zo(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function bc(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):bs(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var xc=new WeakMap;function Sc(e){return xc.get(e)||1}function Cc(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function wc(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>sc;){let t=0;e&cc&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=cc}return a}function Tc(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=cc),s.push(t)}if(e!==sc)throw Error(`invalid wnaf`);return s}function Ec(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var Dc=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){mc(e),this.randomBytes=vc(t,uc),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=Tc(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!xs(t,cc,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Sc(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+dc,i=this.randomBytes(uc);if(!as(i)||i.length!==uc)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+hs(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=fc,i=ws(r),a=Array(32);a[0]=this.ZERO;for(let t=1;t<32;t++)a[t]=a[t-1].add(e);let o=Math.ceil(n/r),s=this.ZERO;for(let e=o-1;e>=0;e--){if(e!==o-1)for(let e=0;e<r;e++)s=s.double();let n=Number(t>>BigInt(e*r)&i),c=a[0];for(let e=1;e<32;e++)c=e===n?a[e]:c;s=s.add(c)}return{p:s,f:s}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===cc||e===this.BASE&&(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!bs(t))throw Error(`invalid scalar`);let r=Sc(e);if(r===1||t>=this.Point.Fn.ORDER)return Oc(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),gc(t,this.bits),_c((Math.ceil((this.bits+dc)/t)+1)*2**(t-1),this.Point.Fp.BYTES),xc.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Sc(e)!==1}};function Oc(e,t,n,r=!1){if(mc(e),yc(t,e),us(r,`allowOversized`),bc(n,e.Fn,r?e.Fn.ORDER**lc:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Cc(e,4)),a=n.map(e=>wc(e,4));return Ec(e.ZERO,i,a)}function kc(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Zs(t),t}return rc(e,{isLE:n})}function Ac(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Es(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(bs(n)&&n!==sc))throw Error(`CURVE.${e} must be positive bigint`)}let i=kc(t.p,n.Fp,r),a=kc(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function jc(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Mc=BigInt(0),Nc=BigInt(1),Pc=BigInt(2),Fc=BigInt(4),Ic=BigInt(8);function Lc(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function Rc(e,t={}){Es(t,{},{},`extraOpts`);let n=t,r=Ac(`edwards`,e,n,n.FpFnLE),{Fp:i,Fn:a}=r,o=r.CURVE,{h:s}=o;if($s(i,o.a)!==1)throw Error(`edwards: CURVE.a must be a square in Fp for complete addition formulas`);if($s(i,o.d)!==-1)throw Error(`edwards: CURVE.d must be a non-square in Fp for complete addition formulas`);Es(n,{},{uvRatio:`function`,randomBytes:`function`});let c=n.randomBytes===void 0?os:n.randomBytes,l=Pc<<BigInt(i.BYTES*8)-Nc;function u(e){if(!i.isOdd)throw Error(`Field does not have .isOdd()`);return i.isOdd(e)}let d=n.uvRatio===void 0?(e,t)=>{try{return{isValid:!0,value:i.sqrt(i.div(e,t))}}catch{return{isValid:!1,value:Mc}}}:n.uvRatio;if(!Lc(i,o,o.Gx,o.Gy))throw Error(`bad curve params: generator point`);let f=i.eql(o.a,i.neg(i.ONE))?e=>i.neg(e):i.eql(o.a,i.ONE)?e=>e:e=>i.mul(o.a,e);function p(e,t,n=!1){let r=n?Nc:Mc;return Ss(`coordinate `+e,t,r,l),t}function m(e){if(!(e instanceof h))throw Error(`EdwardsPoint expected`)}class h{static BASE=new h(o.Gx,o.Gy,i.ONE,i.mul(o.Gx,o.Gy));static ZERO=new h(i.ZERO,i.ONE,i.ONE,i.ZERO);static Fp=i;static Fn=a;X;Y;Z;T;constructor(e,t,n,r){this.X=p(`x`,e),this.Y=p(`y`,t),this.Z=p(`z`,n,!0),this.T=p(`t`,r),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){if(e instanceof h)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return p(`x`,t),p(`y`,n),new h(t,n,i.ONE,i.mul(t,n))}static fromBytes(e,t=!1){let n=i.BYTES,{a:r,d:a}=o;e=ys(H(e,n,`point`)),us(t,`zip215`);let s=ys(e),c=e[n-1];s[n-1]=c&-129;let f=gs(s);Ss(`point.y`,f,Mc,t?l:i.ORDER);let p=i.sqr(f),m=i.sub(p,i.ONE),g=i.sub(i.mulN(a,p),r),{isValid:_,value:v}=d(m,g);if(!_)throw Error(`bad point: invalid y coordinate`);let ee=u(v),y=!!(c&128);if(!t&&i.is0(v)&&y)throw Error(`bad point: x=0 and x_0=1`);return y!==ee&&(v=i.neg(v)),h.fromAffine({x:v,y:f})}static fromHex(e,t=!1){return h.fromBytes(is(e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return _.setWindowSize(this,e),t||this.multiply(Pc),this}assertValidity(){let e=this,{a:t,d:n}=o;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:a,Z:s,T:c}=e,l=i.sqr(r),u=i.sqr(a),d=i.sqr(s),f=i.sqr(d),p=i.mul(l,t),m=i.mul(i.add(p,u),d),h=i.add(f,i.mul(n,i.mul(l,u)));if(!i.eql(m,h))throw Error(`bad point: equation left != right (1)`);let g=i.mul(r,a),_=i.mul(s,c);if(!i.eql(g,_))throw Error(`bad point: equation left != right (2)`)}equals(e){m(e);let{X:t,Y:n,Z:r}=this,{X:a,Y:o,Z:s}=e,c=i.mul(t,s),l=i.mul(a,r),u=i.mul(n,s),d=i.mul(o,r);return i.eql(c,l)&&i.eql(u,d)}is0(){return this.equals(h.ZERO)}negate(){return new h(i.neg(this.X),this.Y,this.Z,i.neg(this.T))}double(){let{X:e,Y:t,Z:n}=this,r=i.sqr(e),a=i.sqr(t),o=i.mul(i.sqr(n),Pc),s=f(r),c=i.addN(e,t),l=i.sub(i.subN(i.sqr(c),r),a),u=i.addN(s,a),d=i.subN(u,o),p=i.subN(s,a),m=i.mul(l,d),g=i.mul(u,p),_=i.mul(l,p),v=i.mul(d,u);return new h(m,g,v,_)}add(e){m(e);let{d:t}=o,{X:n,Y:r,Z:a,T:s}=this,{X:c,Y:l,Z:u,T:d}=e,p=i.mul(n,c),g=i.mul(r,l),_=i.mul(i.mulN(s,t),d),v=i.mul(a,u),ee=i.sub(i.subN(i.mulN(i.addN(n,r),i.addN(c,l)),p),g),y=i.subN(v,_),te=i.addN(v,_),b=i.sub(g,f(p)),x=i.mul(ee,y),S=i.mul(te,b),C=i.mul(ee,b),w=i.mul(y,te);return new h(x,S,w,C)}subtract(e){return m(e),this.add(e.negate())}multiply(e){if(!a.isValidNot0(e))throw RangeError(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=_.mulSecret(this,e,s,g);return g([t,n])[0]}multiplyUnsafe(e){if(!a.isValid(e))throw RangeError(`invalid scalar: expected 0 <= sc < curve.n`);return e===Mc?h.ZERO:this.is0()||e===Nc?this:_.mulUnsafe(this,e,g)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return _.mulUnsafe(this,o.n).is0()}toAffine(e){let t=this,n=e;if(n!=null&&typeof n!=`bigint`)throw TypeError(`"invertedZ" expected bigint, got type=`+typeof n);let{X:r,Y:a,Z:o}=t,s=t.is0();n??=s?i.create(Ic):i.inv(o);let c=i.mul(r,n),l=i.mul(a,n),u=i.mul(o,n);if(s)return{x:i.ZERO,y:i.ONE};if(!i.eql(u,i.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}clearCofactor(){return s===Nc?this:s===Pc?this.double():s===Fc?this.double().double():s===Ic?this.double().double().double():this.multiplyUnsafe(s)}toBytes(){let{x:e,y:t}=this.toAffine(),n=i.toBytes(t);return n[n.length-1]|=u(e)?128:0,n}toHex(){return ns(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let g=e=>hc(h,e),_=new Dc(h,c);return _.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function zc(e,t,n={}){if(mc(e),typeof t!=`function`)throw Error(`"hash" function param is required`);let r=t,i=n;Es(i,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,zip215:`boolean`,mapToCurve:`function`,toMontgomery:`function`,toMontgomerySecret:`function`});let{prehash:a}=i,{BASE:o,Fp:s,Fn:c}=e,l=r.outputLen,u=2*s.BYTES;if(l!==void 0&&(fs(l,`hash.outputLen`),l!==u))throw Error(`hash.outputLen must be ${u}, got ${l}`);let d=i.randomBytes===void 0?os:i.randomBytes,f=i.toMontgomery,p=i.toMontgomerySecret,m=i.adjustScalarBytes===void 0?e=>e:i.adjustScalarBytes,h=i.domain===void 0?(e,t,n)=>{if(us(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e}:i.domain;function g(e){return c.create(gs(e))}function _(e){let t=C.secretKey;H(e,C.secretKey,`secretKey`);let n=H(r(e),2*t,`hashedSecretKey`),i=m(n.slice(0,t));return{head:i,prefix:n.slice(t,2*t),scalar:g(i)}}function v(e){let{head:t,prefix:n,scalar:r}=_(e),i=o.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}}function ee(e){return v(e).pointBytes}function y(e=Uint8Array.of(),...t){let n=rs(...t);return g(r(h(n,H(e,void 0,`context`),!!a)))}function te(e,t,n={}){Es(n,{},{},`options`),e=H(e,void 0,`message`),a&&(e=a(e));let{prefix:r,scalar:i,pointBytes:s}=v(t),l=y(n.context,r,e),u=o.multiply(l).toBytes(),d=y(n.context,u,s,e),f=c.create(l+d*i);if(!c.isValid(f))throw Error(`sign failed: invalid s`);return H(rs(u,c.toBytes(f)),C.signature,`result`)}let b={zip215:i.zip215};function x(t,n,r,i=b){Es(i);let{context:s}=i,c=i.zip215===void 0?!!b.zip215:i.zip215,l=C.signature;t=H(t,l,`signature`),n=H(n,void 0,`message`),r=H(r,C.publicKey,`publicKey`),c!==void 0&&us(c,`zip215`),a&&(n=a(n));let u=l/2,d=t.subarray(0,u),f=gs(t.subarray(u,l)),p,m,h;try{p=e.fromBytes(r,c),m=e.fromBytes(d,c),h=o.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let g=y(s,d,r,n);return m.add(p.multiplyUnsafe(g)).subtract(h).clearCofactor().is0()}let S=s.BYTES,C={secretKey:S,publicKey:S,signature:2*S,seed:S};function w(e){return e=e===void 0?d(C.seed):e,H(e,C.seed,`seed`)}function T(e){return as(e)&&e.length===C.secretKey}function E(t,n){try{return!!e.fromBytes(t,n===void 0?b.zip215:n)}catch{return!1}}let D={getExtendedPublicKey:v,randomSecretKey:w,isValidSecretKey:T,isValidPublicKey:E,toMontgomery(t){if(f===void 0)throw Error(`Montgomery conversion is not supported for this curve`);return f(e.fromBytes(t))},toMontgomerySecret(e){if(p===void 0)throw Error(`Montgomery conversion is not supported for this curve`);return p(e)}};return Object.freeze(C),Object.freeze(D),Object.freeze({keygen:jc(w,ee),getPublicKey:ee,sign:te,verify:x,utils:D,Point:e,lengths:C})}var Bc=BigInt(0),Vc=BigInt(1),Hc=BigInt(2);function Uc(e,t){return e+t-(t>>Vc<<Vc)}function Wc(e){let t=BigInt(6)*e;return(n,r,i)=>{let a=r+i,o=((t+i-r)*n+r)%e;return{x_2:o,x_3:a-o}}}function Gc(e){return Es(e,{P:`bigint`,type:`string`,adjustScalarBytes:`function`,powPminus2:`function`},{randomBytes:`function`,scalarMultBase:`function`}),Object.freeze({...e})}function Kc(e){let t=Gc(e),{P:n,type:r,adjustScalarBytes:i,powPminus2:a,randomBytes:o}=t,s=t.scalarMultBase,c=r===`x25519`;if(!c&&r!==`x448`)throw Error(`invalid type`);let l=o===void 0?os:o,u=c?255:448,d=Wc(n),f=c?32:56,p=BigInt(c?9:5),m=BigInt(c?121665:39081),h=c?Hc**BigInt(254):Hc**BigInt(447),g=h+(c?BigInt(8)*(Hc**BigInt(251)-Vc):BigInt(4)*(Hc**BigInt(445)-Vc))+Vc,_=e=>W(e,n),v=ee(p);function ee(e){return vs(_(e),f)}function y(e){let t=ys(H(e,f,`uCoordinate`));return c&&(t[31]&=127),_(gs(t))}function te(e){return gs(i(ys(H(e,f,`scalar`))))}let b=new Set(c?[Bc,Vc,n-Vc,BigInt(`325606250916557431795983626356110631294008115727848805560023387167927233504`),BigInt(`39382357235489614581723060781553021112529911719440698176882885853963445705823`)]:[Bc,Vc,n-Vc]);function x(e,t){let n=y(t);if(b.has(n))throw Error(`invalid private or public key received`);let r=T(n,te(e));if(r===Bc)throw Error(`invalid private or public key received`);return ee(r)}function S(e){if(s===void 0)return x(e,v);let t=te(e);Ss(`scalar`,t,h,g);let n=_(s(t));if(n===Bc)throw Error(`invalid private or public key received`);return ee(n)}let C=S,w=x;function T(e,t){Ss(`u`,e,Bc,n),Ss(`scalar`,t,h,g);let r=t,i=e,o=Vc,s=Bc,c=e,l=Vc,f=r^r>>Vc;for(let e=BigInt(u-1);e>=Bc;e--){let t=Uc(n,f>>e);({x_2:o,x_3:c}=d(t,o,c)),{x_2:s,x_3:l}=d(t,s,l);let r=o+s,a=_(r*r),u=o-s,p=_(u*u),h=a-p,g=c+l,v=c-l,ee=_(v*r),y=_(g*u),te=ee+y,b=ee-y;c=_(te*te),l=_(i*_(b*b)),o=_(a*p),s=_(h*(a+_(m*h)))}let p=Uc(n,r);({x_2:o,x_3:c}=d(p,o,c)),{x_2:s,x_3:l}=d(p,s,l);let v=a(s);return _(o*v)}let E={secretKey:f,publicKey:f,seed:f},D=e=>(e=e===void 0?l(f):e,H(e,E.seed,`seed`),e),O={randomSecretKey:D};return Object.freeze(E),Object.freeze(O),Object.freeze({keygen:jc(D,C),getSharedSecret:w,getPublicKey:C,scalarMult:x,scalarMultBase:S,utils:O,GuBytes:v.slice(),lengths:E})}var qc=BigInt(0),Jc=BigInt(1),Yc=BigInt(2),Xc=BigInt(3),Zc=BigInt(5),Qc=BigInt(8),$c=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),el={p:$c,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:Qc,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function tl(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=$c,o=e*e%a*e%a,s=zs(zs(o,Yc,a)*o%a,Jc,a)*e%a,c=zs(s,Zc,a)*s%a,l=zs(c,t,a)*c%a,u=zs(l,n,a)*l%a,d=zs(u,r,a)*u%a;return{pow_p_5_8:zs(zs(zs(zs(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Yc,a)*e%a,b2:o}}function nl(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var rl=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function il(e,t){let n=$c,r=W(t*t*t,n),i=tl(e*W(r*r*t,n)).pow_p_5_8,a=W(e*r*i,n),o=W(t*a*a,n),s=a,c=W(a*rl,n),l=o===e,u=o===W(-e,n),d=o===W(-e*rl,n);return l&&(a=s),(u||d)&&(a=c),Ys(a,n)&&(a=W(-a,n)),{isValid:l||u,value:a}}var al=Rc(el,{uvRatio:il}),ol=al.Fp;function sl(e){let{y:t}=e;return ol.toBytes(ol.div(Jc+t,Jc-t))}function cl(e){let t=al.Fp.BYTES;return or(e,t),nl(Vr(e.subarray(0,t))).subarray(0,t)}function ll(e){return zc(al,Vr,Object.assign({adjustScalarBytes:nl,toMontgomery:sl,toMontgomerySecret:cl,zip215:!0},e))}var ul=ll({}),dl=(()=>{let e=$c,t=t=>{let{pow_p_5_8:n,b2:r}=tl(t);return W(zs(n,Xc,e)*r,e)};return Kc({P:e,type:`x25519`,powPminus2:t,adjustScalarBytes:nl,scalarMultBase:n=>{let r=W(n,al.Fn.ORDER);if(r===qc)return qc;let i=al.BASE.multiply(r);return W((i.Z+i.Y)*t(W(i.Z-i.Y,e)),e)}})})(),fl=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(sr(e),or(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),dr(r)}update(e){return lr(this),this.iHash.update(e),this}digestInto(e){lr(this),ur(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},pl=(()=>{let e=((e,t,n)=>new fl(e,t).update(n).digest());return e.create=(e,t)=>new fl(e,t),e})(),ml=BigInt(0),hl={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=hl;if(fs(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if($o(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=ps(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?ps(i.length/2|128):``;return ps(e)+a+i+t},decode(e,t){let{Err:n}=hl;t=H(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=hl;if(ds(e),e<ml)throw new t(`integer: negative integers are not allowed`);let n=ps(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=hl;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return hs(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=hl,i=H(e,void 0,`signature`),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=hl;Es(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},gl=(Object.freeze(hl._tlv),Object.freeze(hl._int),Object.freeze(hl)),_l=(e,t)=>(e+(e>=0?t:-t)/Cl)/t;function vl(e,t,n){Ss(`scalar`,e,xl,n);let[[r,i],[a,o]]=t,s=_l(o*e,n),c=_l(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<xl,f=u<xl;d&&(l=-l),f&&(u=-u);let p=ws(Math.ceil(Cs(n)/2))+Sl;if(l<xl||l>=p||u<xl||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function yl(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function bl(e,t){Es(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return us(n.lowS,`lowS`),us(n.prehash,`prehash`),n.format!==void 0&&yl(n.format),n}var xl=BigInt(0),Sl=BigInt(1),Cl=BigInt(2),wl=BigInt(3),Tl=BigInt(4);function El(e,t={}){let n=Ac(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;Es(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l}=t,u=t.randomBytes===void 0?os:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let d=Ol(r,i);function f(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function p(e,t,n){if(l&&t.is0())return Uint8Array.of(0);let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return us(n,`isCompressed`),n?(f(),rs(Dl(!r.isOdd(a)),o)):rs(Uint8Array.of(4),o,r.toBytes(a))}function m(e){H(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=d,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=ee(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}f();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!y(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let h=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes,_=r.mul(a.b,wl),v=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function ee(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function y(e,t){let n=r.sqr(t),i=ee(e);return r.eql(n,i)}if(!y(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let te=r.mul(r.pow(a.a,wl),Tl),b=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(te,b)))throw Error(`bad curve params: a or b`);function x(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function S(e){if(!(e instanceof E))throw Error(`Weierstrass Point expected`)}function C(e){if(!c||!c.basises)throw Error(`no endo`);return vl(e,c.basises,i.ORDER)}function w(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(c){let{k1neg:i,k1:o,k2neg:s,k2:l}=C(a),u=new E(r.mul(n.X,c.beta),n.Y,n.Z);e.push(i?n.negate():n,s?u.negate():u),t.push(o,l)}else e.push(n),t.push(a)}let T=new WeakSet;class E{static BASE=new E(a.Gx,a.Gy,r.ONE);static ZERO=new E(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=x(`x`,e),this.Y=x(`y`,t,!0),this.Z=x(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof E)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?E.ZERO:new E(t,n,r.ONE)}static fromBytes(e){let t=E.fromAffine(g(H(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return E.fromBytes(is(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return O.setWindowSize(this,e),t||this.multiply(wl),this}assertValidity(){let e=this;if(e.is0()){if(t.allowInfinityPoint&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(T.has(e))return;let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!y(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);T.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){S(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new E(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=v(o),a=r.mul(_,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(_,o),l=v(l),u=r.sub(s,l),u=v(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new E(i,a,o)}add(e){S(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=v(h),c=r.mul(_,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=v(p),h=r.mul(_,h),f=r.add(f,p),p=r.sub(d,p),p=v(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new E(c,l,u)}subtract(e){return S(e),this.add(e.negate())}is0(){return this.equals(E.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=O.mulSecret(this,e,o,D);return D([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===xl||t.is0())return E.ZERO;if(n===Sl)return t;if(O.hasWindowSize(this))return O.mulUnsafe(t,n,D);let r=[],a=[];return w(r,a,t,n),Oc(E,r,a)}mulAddUnsafe(e,t,n){S(t);let r=[],i=[];return w(r,i,this,e),w(r,i,t,n),Oc(E,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){let{isTorsionFree:e}=t;return o===Sl?!0:e?e(E,this):O.mulUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Sl?this:e?e(E,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Sl?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return us(e,`isCompressed`),this.assertValidity(),h(E,this,e)}toHex(e=!0){return ns(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let D=e=>hc(E,e),O=new Dc(E,u);return O.bits>=6&&E.BASE.precompute(6),Object.freeze(E.prototype),Object.freeze(E),E}function Dl(e){return Uint8Array.of(e?2:3)}function Ol(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function kl(e,t={}){mc(e);let{Fn:n}=e,r=t.randomBytes===void 0?os:t.randomBytes,i=Object.assign(Ol(e.Fp,n),{seed:Math.max(ac(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,oc(H(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!as(e))return;let s=H(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t);return e.fromBytes(r).multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=jc(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function Al(e,t,n={}){mc(e);let r=t;sr(r),Es(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?os:i.randomBytes,o=i.hmac===void 0?(e,t)=>pl(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=ac(l),f=vc(a,d),{keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_}=kl(e,i),v={prehash:!0,lowS:typeof i.lowS!=`boolean`||i.lowS,format:`compact`,extraEntropy:!1},ee=l*Cl+Sl<s.ORDER;function y(e){return e>l>>Sl}function te(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function b(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function x(e,t,n){return b(),(e===n?0:2)|Number(s.isOdd(t))}function S(){if(ee)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function C(e,t){yl(t);let n=_.signature;return H(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class w{r;s;recovery;constructor(e,t,n){if(this.r=te(`r`,e),this.s=te(`s`,t),n!=null){if(S(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=v.format){C(e,t);let n;if(t===`der`){let{r:t,s:n}=gl.toSig(H(e));return new w(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=_.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new w(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(is(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(rs(Dl(!(i&1)),o)),d=c.inv(a),f=E(H(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return y(this.s)}toBytes(e=v.format){if(yl(e),e===`der`)return is(gl.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(S(),rs(Uint8Array.of(this.assertRecovery()),r,i)):rs(r,i)}toHex(e){return ns(this.toBytes(e))}}Object.freeze(w.prototype),Object.freeze(w);let T=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=hs(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,E=i.bits2int_modN===void 0?function(e){return c.create(T(e))}:i.bits2int_modN,D=ws(u);function O(e){return Ss(`num < 2^`+u,e,xl,D),c.toBytes(e)}function k(e,t){return H(e,void 0,`message`),t?H(r(e),void 0,`prehashed message`):e}function A(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=bl(r,v);t=k(t,o);let u=E(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[O(p),O(u)];if(s!=null&&s!==!1){let e=s===!0?a(_.secretKey):s;m.push(H(e,void 0,`extraEntropy`))}let h=rs(...m),g=u;function te(t){let n=T(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===xl)return;let o;if(f!==void 0){let e=hs(oc(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=Vs(n,l);o=c.create(e*c.create(g+a*p))}if(o===xl)return;let s=x(r.x,r.y,a),u=o;return i&&y(o)&&(u=c.neg(o),s^=1),new w(a,u,ee?void 0:s)}return{seed:h,k2sig:te}}function j(e,t,n={}){let{seed:i,k2sig:a}=A(e,t,n);return Ts(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function M(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=bl(i,v);if(r=H(r,void 0,`publicKey`),n=k(n,o),!as(t)){let e=t instanceof w?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}C(t,s);try{let i=w.fromBytes(t,s),o=e.fromBytes(r);if(a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=E(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==x(g.x,g.y,l))}catch{return!1}}function ne(e,t,n={}){let{prehash:r}=bl(n,v);return t=k(t,r),w.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_,Point:e,sign:j,verify:M,recoverPublicKey:ne,Signature:w,hash:r})}var jl=Al(El({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),I),Ml=class extends Error{code=`invalid_relay_e2ee_input`;constructor(){super(`Relay E2EE input is invalid.`),this.name=`RelayE2eeValidationError`}};function G(){throw new Ml}function Nl(e){return I(e)}var Pl=`ryco.node-key.v1`,Fl=`ryco.client-key.v1`,Il=`ryco.e2ee-agreement-key.v1`,Ll=`ed25519`,Rl=`p256`,zl=`x25519`,Bl={"node-identity":Pl,"client-identity":Fl,agreement:Il},Vl={"node-identity":Ll,"client-identity":Rl,agreement:zl};function Hl(e,t){return(!(e instanceof Uint8Array)||e.byteLength!==t)&&G(),Uint8Array.from(e)}function Ul(e){let t=0n;for(let n=0;n<e.byteLength;n+=1)t=t<<8n|BigInt(e[n]);return t}function Wl(e){let t=Hl(e,32);return ul.utils.isValidPublicKey(t,!1)||G(),t}function Gl(e){let t=Hl(e,65);t[0]!==4&&G();let n=jl.Point.Fp.ORDER,r=Ul(t.subarray(1,33)),i=Ul(t.subarray(33));(r>=n||i>=n)&&G();try{jl.Point.fromBytes(t).is0()&&G()}catch{return G()}return t}function Kl(e){return Hl(e,32)}function ql(e,t){switch(e){case`node-identity`:return Wl(t);case`client-identity`:return Gl(t);case`agreement`:return Kl(t);default:return G()}}function Jl(e){return Hl(e,64)}function Yl(e){let t=Hl(e,64),n=jl.Point.Fn.ORDER,r=Ul(t.subarray(0,32)),i=Ul(t.subarray(32));return(r<1n||r>=n||i<1n||i>=n)&&G(),t}function Xl(e,t){let n=ql(e,t);return I(po([Bl[e],Vl[e],n],Ia))}function Zl(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function Ql(e){try{if(e.algorithm===`ed25519`){let t=Wl(e.publicKey),n=Jl(e.signature);return ul.verify(n,e.message,t,{zip215:!1})}if(e.algorithm===`p256`){let t=Gl(e.publicKey),n=Yl(e.signature);return jl.verify(n,I(e.message),t,{prehash:!1,lowS:!1,format:`compact`})}return!1}catch{return!1}}function $l(e){return e===1||e===2}function eu(e){return e===`c2n`||e===`n2c`}function tu(e){return e===1||e===2||e===3||e===4}function nu(e){return e===1||e===2||e===3}function ru(e){switch(e){case 1:return{maxBytes:Fo,exact:!1};case 2:return{maxBytes:Io,exact:!1};case 3:return{maxBytes:64,exact:!0}}}var iu=123,au=91,ou=Object.freeze({kind:`envelope`}),su=Object.freeze({kind:`negotiation`}),cu=Object.freeze({kind:`legacy-json`}),lu=Object.freeze({kind:`other`,reason:`empty`}),uu=Object.freeze({kind:`other`,reason:`unknown_discriminator`});function du(e){if(e.byteLength===0)return lu;let t=e[0];return t===1?ou:t===2?su:t===iu||t===au?cu:uu}var fu=1,pu=2,mu=3,hu=7,gu=17;function _u(e,t){if(typeof e!=`bigint`||e<0n||e>4294967295n)throw TypeError(`E2EE envelope epoch must be a bigint within the uint32 field range.`);if(typeof t!=`bigint`||t<0n||t>18446744073709551615n)throw TypeError(`E2EE envelope counter must be a bigint within the uint64 field range.`)}function vu(e,t,n,r){let i=r;for(let r=n-1;r>=0;--r)e[t+r]=Number(i&255n),i>>=8n}function yu(e,t,n){let r=0n;for(let i=0;i<n;i+=1)r=r<<8n|BigInt(e[t+i]);return r}function bu(e,t){if(!$l(t.suite))throw TypeError(`E2EE envelope suite must be a registered suite id.`);_u(t.epoch,t.counter),e[0]=1,e[fu]=1,e[pu]=t.suite,vu(e,mu,4,t.epoch),vu(e,hu,8,t.counter)}function xu(e){let t=new Uint8Array(15);return bu(t,e),t}function Su(e){if(e.ciphertext.byteLength<gu)throw TypeError(`E2EE envelope ciphertext must cover the inner type byte and the tag.`);let t=new Uint8Array(15+e.ciphertext.byteLength);return bu(t,e),t.set(e.ciphertext,15),t}function Cu(e){if(e.byteLength===0||e[0]!==1)return{kind:`error`,reason:`bad_discriminator`};if(e.byteLength<32)return{kind:`error`,reason:`truncated`};if(e[fu]!==1)return{kind:`error`,reason:`unsupported_version`};let t=e[pu];return $l(t)?{kind:`ok`,value:{version:1,suite:t,epoch:yu(e,mu,4),counter:yu(e,hu,8),header:e.subarray(0,15),ciphertext:e.subarray(15)}}:{kind:`error`,reason:`unsupported_suite`}}function wu(e,t){_u(e,t);let n=new Uint8Array(12);return vu(n,0,4,e),vu(n,4,8,t),n}function Tu(e){if(e.byteLength!==15)throw TypeError(`E2EE AEAD nonce requires the exact envelope header.`);return e.subarray(mu,15)}function Eu(e){if(e.header.byteLength!==15)throw TypeError(`E2EE AAD requires the exact envelope header.`);if(e.sessionBindingHash.byteLength!==32)throw TypeError(`E2EE AAD requires a full-length session binding hash.`);let t=new Uint8Array(50);return t.set(e.header),t.set(e.sessionBindingHash,15),t.set(Du(e.direction),47),t}function Du(e){if(!eu(e))throw TypeError(`E2EE direction must be a registered direction label.`);let t=new Uint8Array(3);for(let n=0;n<3;n+=1)t[n]=e.charCodeAt(n);return t}function Ou(e,t){if(!tu(e))throw TypeError(`E2EE inner record type must be a registered type.`);let n=new Uint8Array(1+t.byteLength);return n[0]=e,n.set(t,1),n}function ku(e){if(e.byteLength<1)return{kind:`error`,reason:`truncated`};let t=e[0];return tu(t)?{kind:`ok`,value:{innerType:t,body:e.subarray(1)}}:{kind:`error`,reason:`reserved_inner_type`}}var Au=2,ju=po(new Uint8Array(60),Ia);function Mu(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function Nu(e,t){if(!nu(e))throw TypeError(`E2EE negotiation record type must be a registered type.`);let n=Au+t.byteLength,r=ru(e);if(r.exact?n!==r.maxBytes:n>r.maxBytes)throw RangeError(`E2EE negotiation record exceeds the bound its type fixes.`);if(e===3&&!Mu(t,ju))throw TypeError(`E2EE handshake reject records are byte-identical; this body is not.`);let i=new Uint8Array(n);return i[0]=2,i[1]=e,i.set(t,Au),i}function Pu(e){if(e.byteLength===0||e[0]!==2)return{kind:`error`,reason:`bad_discriminator`};if(e.byteLength<Au)return{kind:`error`,reason:`truncated`};let t=e[1];if(!nu(t))return{kind:`error`,reason:`reserved_record_type`};let n=ru(t);if(e.byteLength>n.maxBytes)return{kind:`error`,reason:`too_large`};if(n.exact&&e.byteLength!==n.maxBytes)return{kind:`error`,reason:`length_mismatch`};let r=e.subarray(Au);return t===3&&!Mu(r,ju)?{kind:`error`,reason:`non_canonical_reject`}:{kind:`ok`,value:{recordType:t,body:r}}}var Fu=[`_tag`,`statement`],Iu=new TextDecoder,Lu=new TextEncoder;function Ru(e){if(e.byteLength===0||e[0]!==iu)return{kind:`error`,reason:`not_carrier`};let t;try{t=JSON.parse(Iu.decode(e))}catch{return{kind:`error`,reason:`not_carrier`}}if(typeof t!=`object`||!t||Array.isArray(t))return{kind:`error`,reason:`not_carrier`};let n=t;if(n._tag!==`ryco.e2ee.capability.v1`)return{kind:`error`,reason:`not_carrier`};if(e.byteLength>6969)return{kind:`error`,reason:`malformed`};let r=Object.keys(n);if(r.length!==Fu.length||Fu.some((e,t)=>r[t]!==e))return{kind:`error`,reason:`malformed`};let i=n.statement;if(typeof i!=`string`||i.length===0||!Mu(Lu.encode(JSON.stringify({_tag:`ryco.e2ee.capability.v1`,statement:i})),e))return{kind:`error`,reason:`malformed`};let a=Bu(i);return a===void 0?{kind:`error`,reason:`malformed`}:{kind:`ok`,value:a}}var zu=new Map([...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`].map((e,t)=>[e,t]));function Bu(e){if(e.length%4==1)return;let t=new Uint8Array(Math.floor(e.length*3/4)),n=0,r=0,i=0;for(let a of e){let e=zu.get(a);if(e===void 0)return;n=n<<6|e,r+=6,r>=8&&(r-=8,t[i]=n>>r&255,n&=(1<<r)-1,i+=1)}if(!(r>0&&n&(1<<r)-1))return t}var Vu=`ryco.node-e2ee-prekey.v1`,Hu=`ryco.client-e2ee-prekey.v1`,Uu=`ryco.node-e2ee-capability-digest.v1`,Wu=`ryco.relay-e2ee.context.v1`,Gu=`ryco.relay-e2ee.account-context.v1`,Ku=`ryco.relay-e2ee.prologue.v1`,qu=`25519`,Ju=`SHA256`;function Yu(e){return e===`native`?`IK`:`NX`}function Xu(e){return e?[`IK`]:[`IK`,`NX`]}var Zu={allowIndefinite:!1,allowUndefined:!1,allowInfinity:!1,allowNaN:!1,allowBigInt:!1,strict:!0,useMaps:!0,rejectDuplicateMapKeys:!0,tags:{}};function Qu(e){let t=new ho(e,Zu);for(;!t.done();)if(L.equals(t.next().type,L.float))return!0;return!1}function $u(e){if(!(e instanceof Uint8Array)||e.byteLength===0)return{kind:`error`,reason:`malformed`};let t;try{t=wo(e,Zu)}catch{try{if(!Zl(po(wo(e,{...Zu,strict:!1}),Ia),e))return{kind:`error`,reason:`non_canonical`}}catch{}return{kind:`error`,reason:`malformed`}}if(Qu(e))return{kind:`error`,reason:`float_forbidden`};let n;try{n=po(t,Ia)}catch{return{kind:`error`,reason:`non_canonical`}}return Zl(n,e)?{kind:`ok`,value:t}:{kind:`error`,reason:`non_canonical`}}function ed(e){return Uint8Array.from(po(e,Ia))}var td=`[A-Za-z0-9_-]{22}`,nd=RegExp(`^node_${td}$`),rd=RegExp(`^nkey_${td}$`),id=RegExp(`^epk_${td}$`),ad=RegExp(`^nct_${td}$`),od=new Set([`localhost`,`127.0.0.1`,`[::1]`]),sd=new TextEncoder,cd=Rt(Te),ld=Rt(d),ud=Rt(m),dd=Rt(Ke);function fd(e,t){return(typeof e!=`string`||!t.test(e))&&G(),e}function pd(e){return(!Number.isSafeInteger(e)||e<0)&&G(),e}function md(e){return(!Number.isSafeInteger(e)||e<0||e>65535)&&G(),e}function hd(e){(typeof e!=`string`||e.length===0||e.length>512)&&G();let t;try{t=new URL(e)}catch{return G()}let n=t.protocol===`http:`&&od.has(t.hostname);return(t.protocol!==`https:`&&!n||t.username!==``||t.password!==``||t.pathname!==`/`||t.search!==``||t.hash!==``||e!==t.origin)&&G(),sd.encode(t.origin).byteLength>128&&G(),t.origin}function gd(e){(typeof e!=`string`||e.length===0)&&G();let t=sd.encode(e).byteLength;return(t===0||t>256)&&G(),e}function _d(e){return _e(cd(e))&&G(),e}function vd(e){return _e(ld(e))&&G(),e}function yd(e){return _e(ud(e))&&G(),e}function bd(e){return $l(e)||G(),e}function xd(e){return(!(e instanceof Uint8Array)||e.byteLength!==32)&&G(),Uint8Array.from(e)}function Sd(e){return e.byteLength>1024&&G(),e}function Cd(e,t){let n=hd(e.hubOrigin),r=fd(e.nodeId,nd),i=fd(e.identityKeyId,rd),a=fd(e.prekeyId,id),o=Wl(e.identityPublicKey);return Sd(ed([Vu,n,r,Ll,i,a,o,t===void 0?Xl(`node-identity`,o):xd(t),Kl(e.agreementPublicKey),qu,Ju,pd(e.createdAt),pd(e.expiresAt)]))}function wd(e){let t=hd(e.hubOrigin),n=gd(e.accountId),r=Gl(e.identityPublicKey);return Sd(ed([Hu,t,n,Rl,r,Xl(`client-identity`,r),Kl(e.agreementPublicKey),qu,Ju,pd(e.createdAt),pd(e.expiresAt)]))}var Td=13;function Ed(e){return typeof e==`string`}function Dd(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Od(e,t){return e instanceof Uint8Array&&e.byteLength===t}function kd(e){let t=$u(e);if(t.kind===`error`)return t;let n=t.value;if(!Array.isArray(n)||n.length!==Td)return{kind:`error`,reason:`malformed`};let[r,i,a,o,s,c,l,u,d,f,p,m,h]=n;if(r!==`ryco.node-identity-continuity.v1`||s!==`ed25519`||d!==`ed25519`||!Ed(i)||!Ed(a)||!Dd(o)||!Ed(c)||!Ed(f)||!Od(l,32)||!Od(u,32)||!Od(p,32)||!Od(m,32)||!Dd(h)||!rd.test(c)||!rd.test(f)||!ad.test(a)||o<1)return{kind:`error`,reason:`malformed`};let g,_;try{g=Xl(`node-identity`,l),_=Xl(`node-identity`,p)}catch{return{kind:`error`,reason:`malformed`}}return!Zl(g,u)||!Zl(_,m)?{kind:`error`,reason:`malformed`}:{kind:`ok`,value:{hubOrigin:i,continuityId:a,generation:o,oldKeyId:c,oldPublicKey:l,oldFingerprint:u,newKeyId:f,newPublicKey:p,newFingerprint:m,createdAt:h}}}function Ad(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.transcript instanceof Uint8Array&&t.signature instanceof Uint8Array&&t.signature.byteLength===64}function jd(e){if(!Array.isArray(e.chain))return{kind:`error`,failure:`malformed_entry`};if(e.chain.length>8)return{kind:`error`,failure:`chain_too_long`};let t,n;try{t=Wl(e.identityPublicKey),n=Xl(`node-identity`,t)}catch{return{kind:`error`,failure:`invalid_identity_key`}}let r=[],i;for(let t of e.chain){if(!Ad(t))return{kind:`error`,failure:`malformed_entry`};let n=kd(t.transcript);if(n.kind===`error`)return{kind:`error`,failure:`malformed_entry`};let a=n.value;if(a.hubOrigin!==e.hubOrigin)return{kind:`error`,failure:`hub_origin_mismatch`};if(a.continuityId!==e.continuityId)return{kind:`error`,failure:`continuity_id_mismatch`};if(i!==void 0){if(a.generation!==i.generation+1)return{kind:`error`,failure:`generation_not_consecutive`};if(!Zl(a.oldPublicKey,i.newPublicKey)||!Zl(a.oldFingerprint,i.newFingerprint))return{kind:`error`,failure:`link_mismatch`}}if(!Ql({algorithm:`ed25519`,publicKey:a.oldPublicKey,message:t.transcript,signature:t.signature}))return{kind:`error`,failure:`invalid_signature`};r.push(a),i=a}if(i!==void 0&&!Zl(i.newPublicKey,t))return{kind:`error`,failure:`identity_key_mismatch`};let a=e.pinnedIdentityFingerprint;return a===void 0?{kind:`ok`,certificates:r}:Zl(a,n)?{kind:`ok`,certificates:r,pinnedFingerprintUnchanged:!0}:r.some(e=>Zl(e.oldFingerprint,a))?{kind:`ok`,certificates:r,pinnedFingerprintUnchanged:!1}:{kind:`error`,failure:`pin_not_reached`}}var Md=2,Nd=19,Pd=6,Fd=2,Id=255;function Ld(e){return e===`non_canonical`?`statement_non_canonical`:e===`float_forbidden`?`statement_float_forbidden`:`statement_malformed`}function Rd(e){return e===`non_canonical`?`transcript_non_canonical`:e===`float_forbidden`?`transcript_float_forbidden`:`transcript_malformed`}function zd(e){return{kind:`error`,failure:e}}function Bd(e){return Dd(e)&&e<=65535}function Vd(e){if(!Array.isArray(e)||e.length!==Pd)return;let[t,n,r,i,a,o]=e;if(Ed(t)&&id.test(t)&&Od(n,32)&&Od(r,64)&&Od(i,32)&&Dd(a)&&Dd(o))return{prekeyId:t,agreementPublicKey:n,crossSignature:r,agreementFingerprint:i,createdAt:a,expiresAt:o}}function Hd(e){if(!Array.isArray(e)||e.length!==Fd)return;let[t,n]=e;if(!(!(t instanceof Uint8Array)||t.byteLength===0||t.byteLength>1024||!Od(n,64)))return{transcript:t,signature:n}}function Ud(e){if(!(e instanceof Uint8Array))return zd(`statement_malformed`);if(e.byteLength>5190)return zd(`statement_too_large`);let t=$u(e);if(t.kind===`error`)return zd(Ld(t.reason));if(!Array.isArray(t.value)||t.value.length!==Md)return zd(`statement_malformed`);let[n,r]=t.value;if(!(n instanceof Uint8Array)||n.byteLength===0)return zd(`statement_malformed`);if(n.byteLength>5120)return zd(`transcript_too_large`);if(!Od(r,64))return zd(`statement_malformed`);let i=$u(n);if(i.kind===`error`)return zd(Rd(i.reason));if(!Array.isArray(i.value)||i.value.length!==Nd)return zd(`transcript_malformed`);let[a,o,s,c,l,u,d,f,p,m,h,g,_,v,ee,y,te,b,x]=i.value;if(a!==`ryco.node-e2ee-capability.v1`||c!==`ed25519`||!Ed(o)||!Ed(s)||!nd.test(s)||!Ed(l)||!rd.test(l)||!Od(u,32)||!Od(d,32)||!Bd(f)||!Bd(p)||typeof _!=`boolean`||typeof v!=`boolean`||!Dd(y)||!Dd(te)||!Dd(b)||!Ed(x)||!ad.test(x))return zd(`transcript_malformed`);if(sd.encode(o).byteLength>128)return zd(`hub_origin_too_long`);try{hd(o)}catch{return zd(`transcript_malformed`)}if(!Array.isArray(m)||m.length===0)return zd(`transcript_malformed`);if(m.length>8)return zd(`suite_registry_too_large`);if(!m.every(e=>Dd(e)&&e<=Id)||!Array.isArray(g))return zd(`transcript_malformed`);if(g.length>8)return zd(`continuity_chain_too_long`);let S=[];for(let e of g){let t=Hd(e);if(t===void 0)return zd(`transcript_malformed`);S.push(t)}let C=Vd(h);if(C===void 0)return zd(`transcript_malformed`);let w=Xu(v);return!Array.isArray(ee)||ee.length!==w.length||!w.every((e,t)=>ee[t]===e)?zd(`transcript_malformed`):{kind:`ok`,value:{transcript:n,signature:r,hubOrigin:o,nodeId:s,identityKeyId:l,identityPublicKey:u,identityFingerprint:d,e2eeVersionMin:f,e2eeVersionMax:p,suiteRegistry:m,prekeyCertificate:C,continuityChain:S,requireE2EE:_,requireApprovedClientE2EE:v,admittedPatterns:w,policyGeneration:y,issuedAt:te,expiresAt:b,continuityId:x}}}function Wd(e){(!(e instanceof Uint8Array)||e.byteLength===0||e.byteLength>5120)&&G();let t=I(e);t.byteLength!==32&&G();let n=ed([Uu,t]);return n.byteLength!==72&&G(),n}function Gd(e,t){let n=hd(e.hubOrigin),r=yd(e.channelId),i=md(e.relayProtocolMajor),a=md(e.relayProtocolMinor);e.e2eeVersion!==1&&G();let o=bd(e.suiteId),s=fd(e.nodeId,nd),c=xd(e.nodeIdentityFingerprint),l=_d(e.clientIntendedCapability),u=vd(e.clientIntendedRole),d=_d(e.channelOpenCapability),f=vd(e.channelOpenEffectiveRole),p=fd(e.nodeContinuityId,ad);(!Array.isArray(e.nodeContinuityChainTranscripts)||e.nodeContinuityChainTranscripts.length>8)&&G();let m=[xd(e.nodeAgreementFingerprint)];for(let t of e.nodeContinuityChainTranscripts)(!(t instanceof Uint8Array)||t.byteLength===0)&&G(),m.push(I(t));return[t,n,r,i,a,1,o,s,Ll,c,e.client.tier===`native`?gd(e.client.accountId):``,l,u,d,f,m,e.client.tier===`native`?[xd(e.client.identityFingerprint),xd(e.client.agreementFingerprint)]:[],p]}function Kd(e){return e.suiteId!==1&&G(),ed(Gd(e,Wu))}function qd(e){(e.suiteId!==2||e.relayProtocolMajor!==1||e.relayProtocolMinor<3)&&G();let t=dd(e.grant);_e(t)&&G();let n=t.value,r=xd(e.nodeAgreementFingerprint),i=xd(e.deviceGrantDigest);return(n.suiteId!==e.suiteId||n.issuerHubOrigin!==e.hubOrigin||n.nodeId!==e.nodeId||n.accountId!==e.client.accountId||n.nodeContinuityId!==e.nodeContinuityId||!Zl(n.nodeIdentityFingerprint,e.nodeIdentityFingerprint)||!Zl(n.nodeAgreementFingerprint,r)||!Zl(n.deviceIdentityFingerprint,e.client.identityFingerprint)||!Zl(n.deviceAgreementFingerprint,e.client.agreementFingerprint))&&G(),ed([...Gd(e,Gu),i,n.relayTicketId,n.nodeCapabilityStatementDigest,n.clientPrekeyCertificateDigest,n.enrollmentId,n.enrollmentRevision,n.accountAuthEpoch,n.deviceAuthEpoch,n.maximumRole,[...n.capabilities],n.nonce])}function Jd(e,t){return(!(e instanceof Uint8Array)||e.byteLength===0||e.byteLength>1024)&&G(),ed([Uint8Array.from(e),Yl(t)])}function Yd(e){(!(e instanceof Uint8Array)||e.byteLength===0)&&G();let t=I(e);return t.byteLength!==32&&G(),t}function Xd(e){let t=hd(e.hubOrigin),n=yd(e.channelId),r=md(e.relayProtocolMajor),i=md(e.relayProtocolMinor);e.e2eeVersion!==1&&G();let a=bd(e.suiteId),o=fd(e.nodeId,nd);return(!(e.contextCommitment instanceof Uint8Array)||e.contextCommitment.byteLength!==32)&&G(),ed([Ku,t,n,r,i,1,a,o,Uint8Array.from(e.contextCommitment)])}function Zd(e){let t;try{if(t=Cd({hubOrigin:e.hubOrigin,nodeId:e.nodeId,identityKeyId:e.identityKeyId,prekeyId:e.prekeyCertificate.prekeyId,identityPublicKey:e.identityPublicKey,agreementPublicKey:e.prekeyCertificate.agreementPublicKey,createdAt:e.prekeyCertificate.createdAt,expiresAt:e.prekeyCertificate.expiresAt},e.identityFingerprint),!Zl(Xl(`node-identity`,e.identityPublicKey),e.identityFingerprint)||!Zl(Xl(`agreement`,e.prekeyCertificate.agreementPublicKey),e.prekeyCertificate.agreementFingerprint))return!1}catch{return!1}return Ql({algorithm:Ll,publicKey:e.identityPublicKey,message:t,signature:e.prekeyCertificate.crossSignature})}var Qd=new Set([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]);function $d(){throw Error(`Invalid passkey options.`)}function ef(e){return(typeof e!=`object`||!e||Array.isArray(e))&&$d(),e}function tf(e){return(typeof e!=`string`||e.length===0)&&$d(),e}function nf(e){if(e!==void 0)return(typeof e!=`number`||!Number.isSafeInteger(e)||e<0)&&$d(),e}function rf(e){try{return Tn(tf(e))}catch{return $d()}}function af(e){if(e!==void 0)return Array.isArray(e)||$d(),e.map(e=>{let t=ef(e);t.type!==`public-key`&&$d();let n=t.transports;return n!==void 0&&!Array.isArray(n)&&$d(),Array.isArray(n)&&n.some(e=>typeof e!=`string`||!Qd.has(e))&&$d(),{id:rf(t.id),type:`public-key`,...Array.isArray(n)?{transports:n}:{}}})}function of(e){if(e!==void 0)return e===`discouraged`||e===`preferred`||e===`required`?e:$d()}function sf(e){if(e!==void 0)return ef(e)}function cf(e){let t=ef(e),n={challenge:rf(t.challenge)},r=nf(t.timeout),i=t.rpId===void 0?void 0:tf(t.rpId),a=af(t.allowCredentials),o=of(t.userVerification),s=sf(t.extensions);return r!==void 0&&(n.timeout=r),i!==void 0&&(n.rpId=i),a!==void 0&&(n.allowCredentials=a),o!==void 0&&(n.userVerification=o),s!==void 0&&(n.extensions=s),n}function lf(e){let t=ef(e),n=ef(t.rp),r=ef(t.user);(!Array.isArray(t.pubKeyCredParams)||t.pubKeyCredParams.length===0)&&$d();let i=t.pubKeyCredParams.map(e=>{let t=ef(e);return(t.type!==`public-key`||typeof t.alg!=`number`||!Number.isSafeInteger(t.alg))&&$d(),{type:`public-key`,alg:t.alg}}),a={challenge:rf(t.challenge),rp:{name:tf(n.name),...n.id===void 0?{}:{id:tf(n.id)}},user:{id:rf(r.id),name:tf(r.name),displayName:tf(r.displayName)},pubKeyCredParams:i},o=nf(t.timeout),s=af(t.excludeCredentials),c=ff(t.authenticatorSelection),l=pf(t.attestation),u=sf(t.extensions);return o!==void 0&&(a.timeout=o),s!==void 0&&(a.excludeCredentials=s),c!==void 0&&(a.authenticatorSelection=c),l!==void 0&&(a.attestation=l),u!==void 0&&(a.extensions=u),a}function uf(e){return cf(e)}function df(e){return lf(e)}function ff(e){if(e===void 0)return;let t=ef(e),n=t.authenticatorAttachment,r=t.residentKey,i=t.requireResidentKey,a=of(t.userVerification);return n!==void 0&&n!==`platform`&&n!==`cross-platform`&&$d(),r!==void 0&&r!==`discouraged`&&r!==`preferred`&&r!==`required`&&$d(),i!==void 0&&typeof i!=`boolean`&&$d(),{...n===void 0?{}:{authenticatorAttachment:n},...r===void 0?{}:{residentKey:r},...i===void 0?{}:{requireResidentKey:i},...a===void 0?{}:{userVerification:a}}}function pf(e){if(e!==void 0)return e===`none`||e===`indirect`||e===`direct`||e===`enterprise`?e:$d()}var mf={authorization_rejected:`The Hub authorization request could not be verified.`,callback_rejected:`The browser response could not be verified.`,cancelled:`Authorization was cancelled.`,expired:`The authorization request expired. Try again.`,platform_invalid:`Secure browser authorization is unavailable on this device.`,superseded:`A newer authorization request replaced this one.`},hf=6e4,gf=class extends Error{code;constructor(e){super(mf[e]),this.name=e===`cancelled`||e===`superseded`?`AbortError`:`NativeHandoffError`,this.code=e}},_f=new Map;function vf(e,t){return Ct(e)(t,{onExcessProperty:`error`})}function yf(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n);return t}async function bf(e){let t=await e.randomBytes(32);if(!(t instanceof Uint8Array)||t.byteLength!==32)throw new gf(`platform_invalid`);return Uint8Array.from(t)}function xf(e,t){let n=Math.max(e.length,t.length),r=e.length^t.length;for(let i=0;i<n;i+=1)r|=(e.charCodeAt(i)||0)^(t.charCodeAt(i)||0);return r===0}function Sf(e,t){let n=_f.get(e);n&&(n.superseded=!0),n?.controller.abort();let r={generation:(n?.generation??0)+1,controller:new AbortController,superseded:!1};_f.set(e,r);let i=()=>r.controller.abort();return t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0}),{active:r,isCurrent:()=>_f.get(e)===r&&!r.controller.signal.aborted,cleanup:()=>{t?.removeEventListener(`abort`,i),_f.get(e)===r&&_f.delete(e)}}}function Cf(e,t){if(!t())throw new gf(e.superseded?`superseded`:`cancelled`)}function wf(e,t){let n=e-t;if(n<-6e4)throw new gf(`expired`);if(n>3e5+hf)throw new gf(`authorization_rejected`)}function Tf(e,t){if(t-e>hf)throw new gf(`expired`)}function Ef(e,t){let n;try{n=new URL(e)}catch{throw new gf(`callback_rejected`)}if(n.searchParams.has(`error`)){try{vf(vt,{redirectUri:e})}catch{throw new gf(`callback_rejected`)}let r=n.searchParams.get(`state`)??``,i=n.searchParams.get(`handoff_id`)??``;throw!xf(r,t.state)||!xf(i,t.handoffId)?new gf(`callback_rejected`):new gf(`cancelled`)}try{vf(Gt,{redirectUri:e})}catch{throw new gf(`callback_rejected`)}let r=`${n.protocol}//${n.host}${n.pathname}`,i=n.searchParams.get(`state`)??``,a=n.searchParams.get(`handoff_id`)??``;if(r!==t.callbackUri||!xf(i,t.state)||!xf(a,t.handoffId))throw new gf(`callback_rejected`);return{code:n.searchParams.get(`code`)}}async function Df(e){let t;try{t=vf(Pt,e.callbackUri())}catch{throw new gf(`callback_rejected`)}let n=e.deviceLabel().trim();if(n.length===0||Array.from(n).length>64)throw new gf(`platform_invalid`);let r=En(await bf(e)),i=En(await bf(e)),a=await e.sha256(yf(i));if(!(a instanceof Uint8Array)||a.byteLength!==32)throw new gf(`platform_invalid`);let o={callbackUri:t,codeChallenge:En(a),codeVerifier:i,deviceLabel:n,state:r};try{vf(Se,{redirectUri:o.callbackUri,codeChallenge:o.codeChallenge,codeChallengeMethod:`S256`,state:o.state,deviceLabel:o.deviceLabel})}catch{throw new gf(`platform_invalid`)}return o}async function Of(e){let{active:t,isCurrent:n,cleanup:r}=Sf(e.coordinatorKey??e.origin,e.signal),i=e.now??Date.now;try{Cf(t,n);let r=await Df(e.platform);Cf(t,n);let a=vf(Se,{redirectUri:r.callbackUri,codeChallenge:r.codeChallenge,codeChallengeMethod:`S256`,state:r.state,deviceLabel:r.deviceLabel,...e.purpose?{purpose:e.purpose}:{}}),o;try{o=vf(l,await e.start(a,t.controller.signal))}catch(e){throw n()||Cf(t,n),e instanceof gf?e:new gf(`authorization_rejected`)}let s=i(),c;try{c=new URL(o.authorizationUrl)}catch{throw new gf(`authorization_rejected`)}if(c.origin!==new URL(e.origin).origin)throw new gf(`authorization_rejected`);wf(o.expiresAt,s);let u=await e.platform.openSystemBrowser(o.authorizationUrl,r.callbackUri,t.controller.signal);if(Cf(t,n),u.type!==`success`)throw new gf(u.type===`locked`?`authorization_rejected`:`cancelled`);Tf(o.expiresAt,i());let{code:d}=Ef(u.url,{callbackUri:r.callbackUri,state:r.state,handoffId:o.handoffId});Cf(t,n);let f;try{f=vf(e.redeemResponseSchema,await e.redeem(vf(e.redeemRequestSchema,e.buildRedeemRequest(vf(Qe,{handoffId:o.handoffId,code:d,codeVerifier:r.codeVerifier}))),t.controller.signal))}catch(e){throw n()||Cf(t,n),e}return Cf(t,n),f}finally{r()}}async function kf(e){return Of({...e,redeemRequestSchema:Qe,redeemResponseSchema:vn,buildRedeemRequest:e=>e})}var Af={accept:`application/json`,"content-type":`application/json`},jf=4096,Mf=256,Nf=256,Pf=100,Ff=/^node_[A-Za-z0-9_-]{22,43}$/,If=/^[a-z0-9._-]{1,64}$/,Lf=256,Rf=512,zf=/^[A-Za-z0-9_-]{1,512}$/,Bf=/^pkey_[A-Za-z0-9_-]{22}$/,Vf=256,Hf=256,Uf=2048,Wf=254,Gf=256,Kf=16,qf=128,Jf=/^[A-Za-z0-9_-]{43}$/,Yf=`otpauth://`,Xf=3e4,Zf=[`/api/auth/native/bootstrap/registration/`,`/api/auth/native/invitations/registration/`];function Qf(e){let t=e.toLowerCase();return Zf.some(e=>t.startsWith(e))}var $f=new Set([`set-password`,`remove-password`,`revoke-totp`,`request-email-verification`,`add-passkey`,`regenerate-recovery-codes`,`connect-external-identity`,`disconnect-external-identity`]),ep=new Set([`begin-totp-enrollment`,`confirm-totp-enrollment`]),tp=`step_up_required`,np=`passkey_session_required`;function rp(e,t,n){let r={code:e,wire:e,inferred:!1};return!n||e!==`forbidden`||t===void 0?r:$f.has(t)?{code:tp,wire:e,inferred:!0}:ep.has(t)?{code:np,wire:e,inferred:!0}:r}var K=class extends Error{code;status;retryAfterMs;intent;wireCode;inferred;reason;constructor(e,t,n,r,i,a){super(a?ap(a).message:sp(e,r)),this.name=`HostedHubApiError`,this.code=e,this.status=t,this.retryAfterMs=n,this.intent=r,this.wireCode=i??e,this.inferred=i!==void 0&&i!==e,this.reason=a??null}},ip={"missing-signer":{reason:`missing-signer`,title:`Secure session unavailable`,message:`Secure session signing is unavailable on this device. Restart the app, then try again.`,recovery:`restart-app`},"missing-token":{reason:`missing-token`,title:`Sign in again`,message:`This device no longer has its secure Hub session. Sign in again to continue.`,recovery:`sign-in`},"proof-signing-failed":{reason:`proof-signing-failed`,title:`Secure session could not be verified`,message:`This device could not verify its secure Hub session. Unlock the device and try again; if it continues, sign in again.`,recovery:`retry`},"token-invalidated":{reason:`token-invalidated`,title:`Session no longer valid`,message:`Your secure Hub session is no longer valid. Sign in again to continue.`,recovery:`sign-in`},"request-timeout":{reason:`request-timeout`,title:`Hub did not respond`,message:`The Hub did not respond in time. Check your connection and try again.`,recovery:`retry`},"transport-unavailable":{reason:`transport-unavailable`,title:`Hub could not be reached`,message:`Ryco could not reach the Hub. Check your connection and try again.`,recovery:`retry`}};function ap(e){return ip[e]}function op(e,t){if(e===`conflict`)switch(t){case`set-password`:return`That password has appeared in a known breach. Choose a different one.`;case`revoke-passkey`:return`That is the only passkey left on this account. Add another before removing it.`;case`begin-totp-enrollment`:return`Two-factor authentication is already set up on this account.`;case`confirm-totp-enrollment`:return`This setup is no longer in progress. Start again.`;case`request-email-verification`:return`That email address is already in use.`;case`disconnect-external-identity`:return`GitHub is the only sign-in method on this account. Add another before disconnecting it.`;default:return null}return e===`authentication_failed`&&t===`confirm-totp-enrollment`||e===`authentication_failed`&&(t===`connect-external-identity`||t===`disconnect-external-identity`)?`That code is not correct. Check your authenticator app and try again.`:e===`not_found`&&t===`revoke-passkey`?`That passkey is no longer on this account.`:null}function sp(e,t){let n=t===void 0?null:op(e,t);if(n!==null)return n;switch(e){case tp:return`Enter a current code from your authenticator app to confirm this change.`;case np:return`Sign in with a passkey on this device to change two-factor settings.`;case`invalid_credential_id`:return`That passkey could not be identified.`;case`external_provider_unavailable`:return`GitHub sign-in is temporarily unavailable.`;case`external_authorization_cancelled`:return`GitHub authorization was cancelled.`;case`external_authorization_expired`:return`GitHub authorization expired. Try again.`;case`external_authorization_rejected`:return`GitHub could not authorize this request.`;case`external_identity_already_linked`:return`That GitHub account is already connected.`;case`external_identity_email_conflict`:return`Sign in another way, then connect GitHub from account settings.`;case`external_identity_verified_email_required`:return`GitHub must have a verified primary email to create an account.`;case`signup_disabled`:return`New account signup is currently closed.`;case`username_unavailable`:return`That username is unavailable.`;case`last_primary_credential`:return`Add another sign-in method before disconnecting GitHub.`;case`native_authorization_unavailable`:return`Secure browser authorization is unavailable on this device.`;case`timeout`:return`The request took too long. Check your connection and try again.`;case`authentication_failed`:return`The passkey could not be verified.`;case`registration_unavailable`:return`The invitation or registration challenge is unavailable or expired.`;case`session_invalid`:case`unauthorized`:return`Your Hub session has expired.`;case`csrf_rejected`:return`The request could not be verified. Refresh and try again.`;case`forbidden`:case`authorization_failed`:return`You are not authorized to perform this action.`;case`not_found`:return`The requested item is no longer available.`;case`conflict`:case`ticket_consumed`:return`The request has already been used.`;case`rate_limited`:case`node_rate_limited`:return`Too many attempts. Wait briefly and try again.`;case`enrollment_unavailable`:return`The node enrollment is unavailable or expired.`;case`node_offline`:return`The selected node is offline.`;case`server_draining`:return`Hub is temporarily draining relay connections.`;case`unsupported_version`:return`The selected node or Hub uses an incompatible relay version.`;case`invalid_request`:return`The response was malformed or expired.`;case`browser_only_transport`:return`This action is only available in a browser.`;case`native_only_transport`:return`This action is only available in the native app.`;default:return`Hub is temporarily unavailable.`}}function cp(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new K(`invalid_response`,502);return e}function q(e,t,n){try{return Ct(e)(t,{onExcessProperty:`error`})}catch{throw new K(n,n===`invalid_request`?400:502)}}function lp(e){if(typeof e!=`string`)throw new K(`invalid_response`,502);try{return gd(e)}catch{throw new K(`invalid_response`,502)}}function up(e){return e===null||typeof e==`number`&&Number.isSafeInteger(e)}function dp(e){return e===`viewer`||e===`operator`||e===`owner`}function fp(e){return e===`darwin`||e===`linux`||e===`windows`||e===`unknown`}function pp(e){return e===`arm64`||e===`x64`||e===`other`}function mp(e){return typeof e==`string`&&e.length>0&&e.length<=jf?e:null}function hp(e){return!Array.isArray(e)||e.some(e=>typeof e!=`string`)?null:e}function gp(e){let t=hp(e);return!t||t.length===0||t.length>Lf||t.some(e=>e.length===0||e.length>Rf)?null:t}function _p(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;return typeof t.id!=`string`||!zf.test(t.id)?null:{id:t.id,label:typeof t.label==`string`&&t.label.length<=Mf?t.label:null,createdAt:up(t.createdAt)?t.createdAt:null,lastUsedAt:up(t.lastUsedAt)?t.lastUsedAt:null,backupEligible:typeof t.backupEligible==`boolean`?t.backupEligible:null,backupState:typeof t.backupState==`boolean`?t.backupState:null,revokedAt:up(t.revokedAt)?t.revokedAt:null,revocationReasonCode:typeof t.revocationReasonCode==`string`&&t.revocationReasonCode.length>0&&t.revocationReasonCode.length<=Vf?t.revocationReasonCode:null}}function vp(e){try{return Ct(Pe)(e,{onExcessProperty:`error`})}catch{return null}}function yp(e){let t=e?.totpCode;return typeof t==`string`&&t.trim().length>0?{totpCode:t}:{}}function bp(e,t){if(typeof e!=`string`||e.length===0||e.length>t)throw new K(`invalid_request`,400);return e}function xp(e){return e==null||e===``?{}:{totpCode:bp(e,Kf)}}function Sp(e){let t=bp(e,64);if(!Jf.test(t))throw new K(`invalid_request`,400);return t}function Cp(e){return typeof e==`string`&&e.length>0&&e.length<=Hf?e:null}function wp(e){return typeof e==`string`&&e.length<=Uf&&e.toLowerCase().startsWith(Yf)?e:null}var Tp=/^[a-z][a-z0-9_]{0,63}$/;function Ep(e){return typeof e==`string`&&Tp.test(e)?e:`unavailable`}async function Dp(e,t,n){let r;try{r=await e.json()}catch{throw new K(`invalid_response`,e.status,void 0,t)}let i=cp(r);if(!e.ok){let r=typeof i.retryAfterMs==`number`&&Number.isSafeInteger(i.retryAfterMs)&&i.retryAfterMs>=0&&i.retryAfterMs<=3e5?i.retryAfterMs:void 0,a=rp(Ep(i.error),t,n);throw new K(a.code,e.status,r,t,a.wire)}return i}var Op=class{#e;#t;#n;#r;#i;#a;#o=null;constructor(e){if(this.#e=e.endpoint,this.#t=e.httpClient,this.#n=e.passkeyCeremony,this.#r=e.sessionCredentials,this.#i=e.dpopSigner,this.#a=e.nativeAuthorization,this.#r.mode===`bearer`){if(!this.#i)throw new K(`native_session_unavailable`,0,void 0,void 0,void 0,`missing-signer`);if(!this.#r.readBearerToken||!this.#r.writeBearerToken)throw new K(`native_session_unavailable`,0,void 0,void 0,void 0,`missing-token`)}}get#s(){return this.#r.mode===`bearer`}#c(){return this.#r.readBearerToken?.()??null}#l(e){this.#r.writeBearerToken?.(e)}get hasSessionMaterial(){return this.#s?this.#c()!==null:this.#r.readCsrfToken()!==null}clearSessionMaterial(){this.#o=null,this.#s?this.#l(null):this.#r.writeCsrfToken(null)}async getBootstrapAvailability(e){let t=await this.#E(`/api/auth/bootstrap-status`,{dpop:`mint`,...e?{signal:e}:{}});if(Object.keys(t).length!==1||typeof t.available!=`boolean`)throw new K(`invalid_response`,502);return t.available}async getPublicSignupConfiguration(e){return this.#m(),q($t,await this.#E(w,e?{signal:e}:{}),`invalid_response`)}async getExternalIdentityConfiguration(e){return q(v,await this.#E(Ot,{...this.#s?{dpop:`mint`}:{},...e?{signal:e}:{}}),`invalid_response`)}async startExternalIdentityAuthorization(e,t){this.#m();let n=q(ce,e,`invalid_request`);return q(pe,await this.#E(oe,{method:`POST`,body:n,...n.intent===`link`?{csrf:!0,intent:`connect-external-identity`}:{},...t?{signal:t}:{}}),`invalid_response`)}async getPendingExternalIdentity(e){return this.#m(),q(ye,await this.#E(r,e?{signal:e}:{}),`invalid_response`)}async finishExternalIdentitySignup(e,t){this.#m();let n=q(o,e,`invalid_request`),r=q(Me,await this.#E(Tt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(r.identity.csrfToken),r}async restoreSession(e){let t=await this.#E(`/api/auth/session`,e?{signal:e}:{});if(this.#s)return this.#b(t);let n=this.#w(t);return this.#r.writeCsrfToken(n.csrfToken),n}async signIn(e){if(this.#s&&this.#a){let t=await kf({origin:this.#e.origin(),platform:this.#a,...e?{signal:e}:{},start:(e,t)=>this.#u(e,t),redeem:(e,t)=>this.#d(e,t)}),n=this.#C(t);return this.#l(t.token),n}let t=this.#s?`/api/auth/native/passkey`:`/api/auth/passkey`,n=await this.#E(`${t}/options`,{method:`POST`,body:{},dpop:`mint`,...e?{signal:e}:{}}),r=await this.#n.authenticate(uf(n.options),e);return this.#y(await this.#E(`${t}/verify`,{method:`POST`,body:{response:r},dpop:`mint`,...e?{signal:e}:{}}))}async signInWithExternalProvider(e,t){this.#h();let n=q(Cn,e,`invalid_request`),r=this.#a;if(!r)throw new K(`native_authorization_unavailable`,400);let i=await Of({origin:this.#e.origin(),platform:r,purpose:{kind:`sign_in`,providerHint:n},redeemRequestSchema:Qe,redeemResponseSchema:vn,buildRedeemRequest:e=>e,...t?{signal:t}:{},start:(e,t)=>this.#u(e,t),redeem:(e,t)=>this.#d(e,t)}),a=this.#C(i);return this.#l(i.token),a}async connectExternalIdentity(e,t,n){this.#h();let r=q(Cn,e,`invalid_request`),i=this.#a;if(!i)throw new K(`native_authorization_unavailable`,400);let a=this.#o;if(a&&a.expiresAt<Date.now())this.#o=null;else if(a?.provider===r){let e=q(mt,{...a.request,...yp(t)},`invalid_request`);try{let t=await this.#f(e,n);return this.#o=null,t.externalIdentity}catch(e){throw this.#p(e)||(this.#o=null),e}}let o=null;try{return(await Of({origin:this.#e.origin(),coordinatorKey:`${this.#e.origin()}:connect:${r}`,platform:i,purpose:{kind:`connect_external_identity`,provider:r},redeemRequestSchema:mt,redeemResponseSchema:qe,buildRedeemRequest:e=>({...e,purpose:{kind:`connect_external_identity`,provider:r},...yp(t)}),...n?{signal:n}:{},start:(e,t)=>this.#u(e,t),redeem:(e,t)=>(o=e,this.#f(e,t))})).externalIdentity}catch(e){throw o&&this.#p(e)&&(this.#o={provider:r,request:o,expiresAt:Date.now()+tt}),e}}cancelExternalIdentityConnection(e){let t=q(Cn,e,`invalid_request`);this.#o?.provider===t&&(this.#o=null)}async signInWithNativePasskey(e){this.#h();let t=`/api/auth/native/passkey`,n=await this.#E(`${t}/options`,{method:`POST`,body:{},dpop:`mint`,...e?{signal:e}:{}}),r=await this.#n.authenticate(uf(n.options),e),i=await this.#E(`${t}/verify`,{method:`POST`,body:{response:r},dpop:`mint`,...e?{signal:e}:{}}),a=this.#T(i);return{session:a.response,token:a.token}}async startPublicSignup(e,t){this.#m();let n=q(At,e,`invalid_request`);return q(un,await this.#E(M,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async verifyPublicSignup(e,t){this.#m();let n=q(it,e,`invalid_request`);return q(dt,await this.#E(Xt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async finishPublicSignupWithPasskey(e,t){this.#m();let n=q(Ye,{...e,response:{}},`invalid_request`),r=q(Vt,{attemptId:n.attemptId,activationSecret:n.activationSecret},`invalid_request`),i=q(rn,await this.#E(Fe,{method:`POST`,body:r,...t?{signal:t}:{}}),`invalid_response`),a=await this.#n.register(df(i.options),t),o=q(Ye,{...n,response:a},`invalid_request`),s=q(xt,await this.#E(Ae,{method:`POST`,body:o,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(s.identity.csrfToken),s}async finishPublicSignupWithPassword(e,t){this.#m();let n=q(et,e,`invalid_request`),r=q(xt,await this.#E(b,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(r.identity.csrfToken),r}async startPasswordLogin(e,t){this.#m();let n=q(Ve,e,`invalid_request`);return q(Re,await this.#E(be,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async finishPasswordLogin(e,t){this.#m();let n=q(k,e,`invalid_request`),r=q(te,await this.#E(ae,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.#r.writeCsrfToken(r.csrfToken),r}async requestPasswordReset(e,n){this.#m();let r=q(t,e,`invalid_request`);return q(ct,await this.#E(s,{method:`POST`,body:r,...n?{signal:n}:{}}),`invalid_response`)}async verifyPasswordReset(e,t){this.#m();let n=q(sn,e,`invalid_request`);return q(It,await this.#E(Ne,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`)}async finishPasswordReset(e,t){this.#m();let n=q(Ge,e,`invalid_request`),r=q(ge,await this.#E(wn,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`);return this.clearSessionMaterial(),r}async startNativeIdentityEmail(e,t){return this.#g(O,fn,st,e,t)}async verifyNativeIdentityEmail(e,t){return this.#g(Be,pt,qt,e,t)}async claimNativeIdentityUsername(e,t){return this.#g(Ze,Et,se,e,t)}async finishNativeIdentitySignupWithPasskey(e,t){this.#h();let n=q(p,{...e,response:{}},`invalid_request`),r=q(de,{attemptId:n.attemptId,activationSecret:n.activationSecret},`invalid_request`),i=await this.#g(tn,de,kt,r,t),a=await this.#n.register(df(i.options),t);return this.#g(zt,p,g,{...n,response:a},t)}async finishNativeIdentitySignupWithPassword(e,t){return this.#g(wt,i,g,e,t)}async startNativeIdentityPasswordLogin(e,t){return this.#g(ut,yn,Ce,e,t)}async finishNativeIdentityPasswordLogin(e,t){return this.#g(Le,Ft,De,e,t)}async signInNativeIdentityWithRecoveryCode(e,t){return this.#g(ln,u,_n,e,t)}async requestNativeIdentityPasswordReset(e,t){return this.#g(he,Je,hn,e,t)}async verifyNativeIdentityPasswordReset(t,n){return this.#g(e,xn,$e,t,n)}async finishNativeIdentityPasswordReset(e,t){return this.#g(We,yt,gt,e,t)}async cancelNativeIdentityAttempt(e,t){return this.#g(Yt,nt,Mt,e,t)}async switchActiveSpace(e,t){let n=q(Ee,e,`invalid_request`);return q(h,await this.#E(gn,{method:`POST`,body:n,csrf:!0,dpop:`session`,...t?{signal:t}:{}}),`invalid_response`)}async startNativeNodeClaim(e,t){this.#h();let n=q(ee,e,`invalid_request`);return q(D,await this.#E(on,{method:`POST`,body:n,dpop:`session`,...t?{signal:t}:{}}),`invalid_response`)}async finishNativeNodeClaim(e,t){this.#h();let n=q(le,e,`invalid_request`);return q(me,await this.#E(Ut,{method:`POST`,body:n,dpop:`session`,...t?{signal:t}:{}}),`invalid_response`)}async signInWithPassword(e,t){return this.#m(),this.#y(await this.#E(`/api/auth/password`,{method:`POST`,body:{email:bp(e.email,Wf),password:bp(e.password,Gf),...xp(e.totpCode)},...t?{signal:t}:{}}))}async signInWithRecoveryCode(e,t){return this.#m(),this.#y(await this.#E(`/api/auth/recovery`,{method:`POST`,body:{code:bp(e,qf)},...t?{signal:t}:{}}))}async requestEmailRecovery(e,t){this.#m();let n=await this.#E(`/api/auth/recovery/email/request`,{method:`POST`,body:{email:bp(e,Wf)},...t?{signal:t}:{}});if(Object.keys(n).length!==1||n.ok!==!0)throw new K(`invalid_response`,502)}async confirmEmailRecovery(e,t){return this.#m(),this.#y(await this.#E(`/api/auth/recovery/email/confirm`,{method:`POST`,body:{token:Sp(e.token),...xp(e.totpCode)},...t?{signal:t}:{}}))}async confirmEmailVerification(e,t){this.#m();let n=await this.#E(`/api/auth/email/verify`,{method:`POST`,body:{token:Sp(e)},...t?{signal:t}:{}});if(Object.keys(n).length!==1||n.ok!==!0)throw new K(`invalid_response`,502)}async startNativeHandoff(e,t){return this.#u(e,t)}async#u(e,t){if(!this.#s)throw new K(`browser_only_transport`,400);let n=q(Se,e,`invalid_request`),r=n.purpose?.kind===`connect_external_identity`;return q(l,await this.#E(at,{method:`POST`,body:n,dpop:r?`session`:`mint`,...r?{intent:`connect-external-identity`}:{},...t?{signal:t}:{}}),`invalid_response`)}async redeemNativeHandoff(e,t){let n=await this.#d(e,t),r=this.#C(n);return this.#l(n.token),r}async#d(e,t){if(!this.#s)throw new K(`browser_only_transport`,400);let n=q(Qe,e,`invalid_request`);return q(vn,await this.#E(dn,{method:`POST`,body:n,dpop:`mint`,...t?{signal:t}:{}}),`invalid_response`)}async#f(e,t){this.#h();let n=q(mt,e,`invalid_request`);return q(qe,await this.#E(dn,{method:`POST`,body:n,dpop:`session`,intent:`connect-external-identity`,...t?{signal:t}:{}}),`invalid_response`)}#p(e){return e instanceof K&&(e.code===`step_up_required`||e.code===`authentication_failed`||e.code===`forbidden`)}async getNativeHandoffPresentation(e,t){this.#m();let n=q(pn,e,`invalid_request`);return q(bn,await this.#E(`${jt}${n}`,t?{signal:t}:{}),`invalid_response`)}async approveNativeHandoff(e,t){this.#m();let n=q(pn,e,`invalid_request`);return q(Gt,await this.#E(`${jt}${n}${Ht}`,{method:`POST`,body:{},csrf:!0,...t?{signal:t}:{}}),`invalid_response`)}async cancelNativeHandoff(e,t){this.#m();let n=q(pn,e,`invalid_request`);return q(vt,await this.#E(`${jt}${n}${an}`,{method:`POST`,body:{},csrf:!0,...t?{signal:t}:{}}),`invalid_response`)}#m(){if(this.#s)throw new K(`browser_only_transport`,400)}#h(){if(!this.#s)throw new K(`native_only_transport`,400)}async#g(e,t,n,r,i){this.#h();let a=q(t,r,`invalid_request`);return q(n,await this.#E(e,{method:`POST`,body:a,dpop:`mint`,...i?{signal:i}:{}}),`invalid_response`)}async redeemInvitation(e,t){let n=this.#s?`/api/auth/native/invitations/registration`:`/api/auth/invitations/registration`;return this.#v(`${n}/options`,`${n}/verify`,e,{authenticated:!1,...t?{signal:t}:{},finish:e=>this.#y(e)})}async bootstrapOwner(e,t){let n=this.#s?`/api/auth/native/bootstrap/registration`:`/api/auth/bootstrap/registration`;return this.#v(`${n}/options`,`${n}/verify`,e,{authenticated:!1,...t?{signal:t}:{},finish:e=>this.#y(e)})}async listPasskeys(e){let t=await this.#E(`/api/account/passkeys`,e?{signal:e}:{});if(!Array.isArray(t.passkeys)||t.passkeys.length>Nf)throw new K(`invalid_response`,502);return t.passkeys.map(e=>{let t=_p(e);if(!t)throw new K(`invalid_response`,502);return t})}async getAccountSecurity(e){let t=vp(await this.#E(`/api/account/security`,e?{signal:e}:{}));if(!t)throw new K(`invalid_response`,502);return t}async finishBrowserExternalIdentityConnection(e,t,n){this.#m(),q(Cn,e,`invalid_request`);let r=q(f,yp(t),`invalid_request`);return q(ue,await this.#E(C,{method:`POST`,body:r,csrf:!0,intent:`connect-external-identity`,...n?{signal:n}:{}}),`invalid_response`)}async disconnectExternalIdentity(e,t,n){q(Cn,e,`invalid_request`);let r=q(E,yp(t),`invalid_request`),i=q(ie,await this.#E(ke,{method:`POST`,body:r,csrf:!0,intent:`disconnect-external-identity`,...n?{signal:n}:{}}),`invalid_response`);return i.signedOut&&this.clearSessionMaterial(),i}async addPasskey(e,t){let n=typeof e.passkeyLabel==`string`?e.passkeyLabel.trim():null;return this.#v(`/api/account/passkeys/registration/options`,`/api/account/passkeys/registration/verify`,{label:n===null||n.length===0?null:n},{authenticated:!0,intent:`add-passkey`,verifyExtra:yp(e),...t?{signal:t}:{},finish:e=>this.#S(e)})}async regenerateRecoveryCodes(e,t){let n=await this.#E(`/api/account/recovery-codes`,{method:`POST`,body:yp(e),csrf:!0,intent:`regenerate-recovery-codes`,...t?{signal:t}:{}}),r=gp(n.recoveryCodes);if(!r)throw new K(`invalid_response`,502);return this.#x(n),r}async setPassword(e,t){await this.#_(`/api/account/password`,{password:e.password,...yp(e)},t,`set-password`)}async removePassword(e,t){await this.#_(`/api/account/password/remove`,yp(e),t,`remove-password`)}async beginTotpEnrollment(e){let t=await this.#E(`/api/account/totp/enrollment/options`,{method:`POST`,body:{},csrf:!0,intent:`begin-totp-enrollment`,...e?{signal:e}:{}}),n=Cp(t.secretBase32),r=wp(t.provisioningUri);if(!n||!r)throw new K(`invalid_response`,502);return{secretBase32:n,provisioningUri:r}}async confirmTotpEnrollment(e,t){await this.#_(`/api/account/totp/enrollment/verify`,{code:e.code},t,`confirm-totp-enrollment`)}async revokeTotp(e,t){await this.#_(`/api/account/totp/revoke`,yp(e),t,`revoke-totp`)}async requestEmailVerification(e,t){await this.#_(`/api/account/email/verification`,{email:e.email,...yp(e)},t,`request-email-verification`)}async revokePasskey(e,t){if(!Bf.test(e))throw new K(`invalid_credential_id`,400);await this.#_(`/api/account/passkeys/${e}/revoke`,{},t,`revoke-passkey`)}async#_(e,t,n,r){let i=await this.#E(e,{method:`POST`,body:t,csrf:!0,intent:r,...n?{signal:n}:{}});if(Object.keys(i).length!==1||i.ok!==!0)throw new K(`invalid_response`,502,void 0,r)}async#v(e,t,n,r){let i={csrf:r.authenticated,...r.authenticated?{}:{dpop:`mint`},...r.intent?{intent:r.intent}:{},...r.signal?{signal:r.signal}:{}},a=await this.#E(e,{method:`POST`,body:n,...i,narrowForbidden:!1}),o=await this.#n.register(df(a.options),r.signal);return r.finish(await this.#E(t,{method:`POST`,body:{response:o,...r.verifyExtra},...i}))}#y(e){if(this.#s){let{response:t,token:n}=this.#T(e);return this.#l(n),t}let t=this.#w(e);return this.#r.writeCsrfToken(t.csrfToken),t}#b(e){let t=this.#C(e),n=mp(e.token);return n&&this.#l(n),t}#x(e){if(this.#s){let{token:t}=this.#T(e);this.#l(t);return}this.#r.writeCsrfToken(this.#w(e).csrfToken)}#S(e){this.#x(e);let t=_p(e.passkey);return{passkey:t,confirmed:t!==null}}async signOut(e){await this.#E(`/api/auth/logout`,{method:`POST`,body:{},csrf:!0,...e?{signal:e}:{}}),this.clearSessionMaterial()}async readThreadCacheShell(e,t){if(!Ff.test(e))throw new K(`invalid_request`,400);return q(Nn,await this.#E(`/api/nodes/${e}/thread-cache/shell`,t?{signal:t}:{}),`invalid_response`)}async readThreadCacheThread(e,t,n){if(!Ff.test(e)||!/^[A-Za-z0-9_-]{1,128}$/u.test(t))throw new K(`invalid_request`,400);return q(Pn,await this.#E(`/api/nodes/${e}/thread-cache/threads/${t}`,n?{signal:n}:{}),`invalid_response`)}async listNodes(e){let t=await this.#E(`/api/nodes`,e?{signal:e}:{});if(!Array.isArray(t.nodes))throw new K(`invalid_response`,502);return t.nodes.map(e=>{let t=cp(e),n=cp(t.grant),r=cp(t.presence),i=t.capabilities===void 0?null:cp(t.capabilities),a=q(Dt,t.id,`invalid_response`);if(typeof t.environmentId!=`string`||typeof t.label!=`string`||!fp(t.platformOs)||!pp(t.platformArch)||typeof t.clientVersion!=`string`||!up(t.createdAt)||t.createdAt===null||!up(t.updatedAt)||t.updatedAt===null||!up(t.lastAuthenticatedAt)||!up(t.revokedAt)||t.revocationReasonCode!==null&&typeof t.revocationReasonCode!=`string`||typeof n.id!=`string`||!dp(n.role)||!dp(t.effectiveRole)||typeof r.online!=`boolean`||!up(r.lastHeartbeatAt)||i!==null&&(typeof i.repositoryIdentity!=`boolean`||typeof i.nativeClientRequired!=`boolean`||i.threadSettlement!==void 0&&typeof i.threadSettlement!=`boolean`))throw new K(`invalid_response`,502);let o={id:a,environmentId:fe.make(t.environmentId),label:t.label,platformOs:t.platformOs,platformArch:t.platformArch,clientVersion:t.clientVersion,createdAt:t.createdAt,updatedAt:t.updatedAt,lastAuthenticatedAt:t.lastAuthenticatedAt,revokedAt:t.revokedAt,revocationReasonCode:t.revocationReasonCode,grant:{id:n.id,role:n.role},effectiveRole:t.effectiveRole,presence:{online:r.online,lastHeartbeatAt:r.lastHeartbeatAt}};return i?Object.assign(o,{capabilities:{repositoryIdentity:i.repositoryIdentity,nativeClientRequired:i.nativeClientRequired,...typeof i.threadSettlement==`boolean`?{threadSettlement:i.threadSettlement}:{}}}):o})}async renameNode(e,t,n){let r=t.trim();if(!Ff.test(e)||r.length===0||r.length>Pf)throw new K(`invalid_request`,400);let i=await this.#E(`/api/admin/nodes/${encodeURIComponent(e)}/rename`,{method:`POST`,body:{label:r},csrf:!0,...n?{signal:n}:{}});if(Object.keys(i).length!==1||i.ok!==!0)throw new K(`invalid_response`,502)}async revokeNode(e,t,n){if(!Ff.test(e)||!If.test(t))throw new K(`invalid_request`,400);let r=await this.#E(`/api/admin/nodes/${encodeURIComponent(e)}/revoke`,{method:`POST`,body:{reasonCode:t},csrf:!0,...n?{signal:n}:{}});if(Object.keys(r).length!==1||r.ok!==!0)throw new K(`invalid_response`,502)}async lookupNodeEnrollment(e,t){let n=cp((await this.#E(`/api/admin/node-enrollments/lookup`,{method:`POST`,body:{deviceCode:e},csrf:!0,...t?{signal:t}:{}})).enrollment);if(typeof n.id!=`string`||!/^enr_[A-Za-z0-9_-]{22}$/.test(n.id)||typeof n.label!=`string`||n.label.length<1||n.label.length>100||!fp(n.platformOs)||!pp(n.platformArch)||typeof n.clientVersion!=`string`||n.clientVersion.length<1||n.clientVersion.length>64||n.algorithm!==`ed25519`||typeof n.fingerprint!=`string`||!/^SHA256:[A-Za-z0-9_-]{43}$/.test(n.fingerprint)||!Number.isSafeInteger(n.createdAt)||!Number.isSafeInteger(n.expiresAt)||Number(n.expiresAt)<=Number(n.createdAt))throw new K(`invalid_response`,502);return{id:n.id,label:n.label,platformOs:n.platformOs,platformArch:n.platformArch,clientVersion:n.clientVersion,algorithm:n.algorithm,fingerprint:n.fingerprint,createdAt:n.createdAt,expiresAt:n.expiresAt}}async approveNodeEnrollment(e,t){let n=await this.#E(`/api/admin/node-enrollments/approve`,{method:`POST`,body:{deviceCode:e},csrf:!0,...t?{signal:t}:{}}),r=cp(n.node),i=cp(n.grant);if(typeof r.id!=`string`||!Ff.test(r.id)||typeof r.environmentId!=`string`||!/^env_[A-Za-z0-9_-]{22}$/.test(r.environmentId)||typeof i.id!=`string`||!/^grant_[A-Za-z0-9_-]{22}$/.test(i.id)||i.role!==`owner`)throw new K(`invalid_response`,502)}async denyNodeEnrollment(e,t){let n=await this.#E(`/api/admin/node-enrollments/deny`,{method:`POST`,body:{deviceCode:e},csrf:!0,...t?{signal:t}:{}});if(Object.keys(n).length!==1||n.ok!==!0)throw new K(`invalid_response`,502)}async issueRelayTicket(e,t){let n=q(Dt,e,`invalid_request`),r=e=>this.#E(`/api/relay/tickets`,{method:`POST`,body:{nodeId:n,capability:`ryco.rpc`,protocolMajor:1,protocolMinor:e},csrf:!0,...t?{signal:t}:{}}),i=3,a;try{a=await r(i)}catch(e){if(!(e instanceof K)||e.status!==400||e.code!==`invalid_request`)throw e;i=2,a=await r(i)}if(Object.keys(a).length!==4||typeof a.ticket!=`string`||!Number.isSafeInteger(a.expiresAt)||a.protocolMajor!==1||a.protocolMinor!==2&&a.protocolMinor!==3||a.protocolMinor>i)throw new K(`invalid_response`,502);return{ticket:a.ticket,expiresAt:a.expiresAt,protocolMajor:1,protocolMinor:a.protocolMinor}}async upsertE2eeDeviceEnrollment(e,t){this.#h();let n=q(St,e,`invalid_request`);if(n.hubOrigin!==this.#e.origin())throw new K(`invalid_request`,400);return q(Xe,await this.#E(lt,{method:`POST`,body:n,...t?{signal:t}:{}}),`invalid_response`).enrollment}async getE2eeGrantVerificationKeys(e){return this.#h(),q(ve,await this.#E(cn,e?{signal:e}:{}),`invalid_response`)}async issueAccountGrantRelayTicket(e,t){this.#h();let r=q(Lt,e,`invalid_request`);return q(en,await this.#E(n,{method:`POST`,body:r,...t?{signal:t}:{}}),`invalid_response`)}async listE2eeDevices(e){return q(ne,await this.#E(Ie,e?{signal:e}:{}),`invalid_response`).devices}async renameE2eeDevice(e,t,n){let r=q(Nt,e,`invalid_request`),i=q(A,t,`invalid_request`);return q(Zt,await this.#E(`${x}/${encodeURIComponent(r)}/rename`,{method:`POST`,body:i,csrf:!0,...n?{signal:n}:{}}),`invalid_response`).enrollment}async revokeE2eeDevice(e,t,n){let r=q(Nt,e,`invalid_request`),i=q(He,t,`invalid_request`);return q(Zt,await this.#E(`${x}/${encodeURIComponent(r)}/revoke`,{method:`POST`,body:i,csrf:!0,...n?{signal:n}:{}}),`invalid_response`).enrollment}#C(e){let t=cp(e.account),n=cp(e.session),r=lp(t.id),i=lp(n.accountId),a=n.activeSpaceId===void 0?void 0:q(j,n.activeSpaceId,`invalid_response`),o=e.recoveryCodes===void 0?void 0:hp(e.recoveryCodes);if(typeof t.displayName!=`string`||!dp(t.role)||!Number.isSafeInteger(t.createdAt)||!up(t.disabledAt)||typeof n.id!=`string`||!Number.isSafeInteger(n.createdAt)||!Number.isSafeInteger(n.expiresAt)||!Number.isSafeInteger(n.lastSeenAt)||!up(n.revokedAt)||n.revocationReasonCode!==null&&typeof n.revocationReasonCode!=`string`||o===null)throw new K(`invalid_response`,502);if(t.disabledAt!==null||n.revokedAt!==null||i!==r)throw new K(`session_invalid`,401);return{account:{id:r,displayName:t.displayName,role:t.role,createdAt:t.createdAt,disabledAt:t.disabledAt},session:{id:n.id,accountId:i,...a===void 0?{}:{activeSpaceId:a},createdAt:n.createdAt,expiresAt:n.expiresAt,lastSeenAt:n.lastSeenAt,revokedAt:n.revokedAt,revocationReasonCode:n.revocationReasonCode},...o===void 0?{}:{recoveryCodes:o}}}#w(e){if(typeof e.csrfToken!=`string`||e.csrfToken.length===0)throw new K(`invalid_response`,502);return{...this.#C(e),csrfToken:e.csrfToken}}#T(e){let t=mp(e.token);if(!t)throw new K(`invalid_response`,502);return{response:this.#C(e),token:t}}async#E(e,t){let n=new URL(e,this.#e.origin());if(n.origin!==this.#e.origin()||n.search||n.hash||n.pathname.includes(`%`))throw new K(`invalid_request`,400,void 0,t.intent);if(this.#s&&Qf(n.pathname))throw new K(`browser_only_transport`,400,void 0,t.intent);let r=t.method??`GET`,i={...Af},a,o;if(this.#s){let e=this.#i;if(!e)throw new K(`native_session_unavailable`,0,void 0,t.intent,void 0,`missing-signer`);let s=n.toString(),c;if(t.dpop!==`mint`&&(c=this.#c()??void 0,!c))throw new K(`session_invalid`,401,void 0,t.intent,void 0,`missing-token`);try{i.DPoP=await e.sign({method:r,url:s,...c?{token:c}:{}})}catch{throw new K(`native_session_unavailable`,0,void 0,t.intent,void 0,`proof-signing-failed`)}c&&(i.Authorization=`DPoP ${c}`),a=s,o=`omit`}else{if(t.csrf){let e=this.#r.readCsrfToken();if(!e)throw new K(`session_invalid`,401,void 0,t.intent);i[`X-Ryco-CSRF`]=e}a=n.pathname,o=`same-origin`}let s=new AbortController,c=!1,l=setTimeout(()=>{c=!0,s.abort()},Xf),u=t.signal,d=()=>s.abort();u?.aborted?s.abort():u?.addEventListener(`abort`,d);let f;try{return f=await this.#t.fetch(a,{method:r,credentials:o,cache:`no-store`,headers:i,...t.body===void 0?{}:{body:JSON.stringify(t.body)},signal:s.signal}),await Dp(f,t.intent,t.narrowForbidden!==!1)}catch(e){if(c)throw new K(`timeout`,0,void 0,t.intent,void 0,`request-timeout`);if(s.signal.aborted){let e=Error(`The Hub request was cancelled.`);throw e.name=`AbortError`,e}throw typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?e:f===void 0?new K(`unavailable`,0,void 0,t.intent,void 0,`transport-unavailable`):this.#s&&t.dpop!==`mint`&&e instanceof K&&e.code===`session_invalid`?new K(e.code,e.status,e.retryAfterMs,e.intent,e.wireCode,`token-invalidated`):e}finally{clearTimeout(l),u?.removeEventListener(`abort`,d)}}},kp=null,Ap=null,jp=null;function Mp(e){jp=e}function Np(){if(kp||!jp)return;let e=jp;jp=null,e()}function Pp(e,t){jp=null,kp=e,Ap=t??new Op(e)}function J(){if(Np(),!kp)throw Error(`Hosted runtime has not been configured.`);return kp}function Y(){if(Np(),!Ap)throw Error(`Hosted runtime has not been configured.`);return Ap}var Fp=12e4,Ip=`The connection dropped before this machine confirmed the action. Check the thread before sending it again.`,Lp=class extends Error{constructor(){super(Ip),this.name=`HostedDispatchUnconfirmedError`}};function Rp(e){return e.accountStatus!==`authenticated`||!e.account?null:e.account.id}function zp(e,t){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===t}var Bp=`All fibers interrupted without error`;function Vp(e){return zp(e,`RpcClientError`)||e instanceof Qt||e instanceof Error&&e.message===Bp}function Hp(e,t){return e instanceof Bt||zp(e,`OrchestrationDispatchCommandError`)||zp(e,`AuthRpcError`)?!1:t||Vp(e)}function Up(e,t){return zp(t,`OrchestrationDispatchCommandError`)?e.type!==`thread.turn.start`||e.bootstrap===void 0:!1}var Wp={kind:`ended`},Gp={kind:`expired`};function Kp(e,t){return e.lineage===t.lineage&&e.accountSession===t.accountSession&&e.visit===t.visit}var qp=class{#e;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#a=0;constructor(e){this.#e=e}attach(e){let{environmentId:t}=e,n={lineage:e.lineage,accountSession:this.#a,visit:this.#o(t),dispatch:e.dispatch,markUncertain:e.markUncertain,losses:0};this.#t.set(t,n),this.#d(t,e=>Kp(e.origin,n)?void 0:Wp);let r=()=>{n.losses+=1};return{dispatch:e=>this.#c(t,n,e),lost:r,detach:()=>{r(),this.#t.get(t)===n&&this.#t.delete(t)}}}markReady(e){let t=(this.#n.get(e)??0)+1;this.#n.set(e,t);let n=this.#t.get(e);this.#d(e,e=>{if(n)return Kp(n,e.origin)?t>e.readyAfter?{kind:`ready`,attempt:n}:void 0:Wp})}end(e){this.#i.set(e,this.#o(e)+1),this.#d(e,()=>Wp)}endAccountSession(){this.#a+=1;for(let e of Array.from(this.#r.keys()))this.end(e);this.#t.clear()}resetForTests(){this.endAccountSession(),this.#n.clear(),this.#i.clear()}#o(e){return this.#i.get(e)??0}#s(e,t){return t.accountSession!==this.#a||t.visit!==this.#o(e)}async#c(e,t,n){let r=this.#e().now()+Fp,i=t.losses;try{return await t.dispatch(n)}catch(e){if(!Hp(e,t.losses!==i))throw e}let a=this.#n.get(e)??0;for(;;){let i=await this.#u(e,t,a,r);if(i.kind===`ended`)throw new Lp;if(i.kind===`expired`)return this.#l(e,t);a=this.#n.get(e)??0;try{return await i.attempt.dispatch(n)}catch(r){if(nn(r))continue;if(Up(n,r))throw r;return this.#l(e,t)}}}#l(e,t){if(this.#s(e,t))throw new Lp;try{t.markUncertain()}catch{}throw new Lp}#u(e,t,n,r){if(this.#s(e,t))return Promise.resolve(Wp);let i=this.#t.get(e);if(i&&!Kp(i,t))return Promise.resolve(Wp);let a=this.#e(),o=r-a.now();return o<=0?Promise.resolve(Gp):new Promise(r=>{let i=this.#r.get(e)??new Set,s={origin:t,readyAfter:n,settle:t=>{a.clearTimeout(c),i.delete(s),i.size===0&&this.#r.get(e)===i&&this.#r.delete(e),r(t)}},c=a.setTimeout(()=>s.settle(Gp),o);i.add(s),this.#r.set(e,i)})}#d(e,t){let n=this.#r.get(e);if(n)for(let e of Array.from(n)){let n=t(e);n!==void 0&&e.settle(n)}}},Jp=null;function Yp(){return Jp??=new qp(()=>J().timers),Jp}function Xp(e){let t=null;return{ownsReceiptedRequests:()=>t!==null,connectionLost:()=>t?.lost(),wrap:n=>{let{environmentId:r,lineage:i}=e;if(t!==null||r===null||i===null)return n;let a=(e.replay??Yp()).attach({environmentId:r,lineage:i,dispatch:n.orchestration.dispatchCommand,markUncertain:e.markUncertain});return t=a,{...n,dispose:async()=>{a.detach(),await n.dispose()},reconnect:async()=>{a.lost(),await n.reconnect()},orchestration:{...n.orchestration,dispatchCommand:a.dispatch}}}}}var Zp=class{#e;#t;#n;#r;#i;#a;#o=0;#s=null;constructor(e={}){this.#e=e.baseDelayMs??1e3,this.#t=e.maxDelayMs??6e4,this.#n=e.stableIntervalMs??6e4,this.#r=e.jitterRatio??.2,this.#i=e.random??Math.random,this.#a=e.now??Date.now}opened(){this.#s=this.#a()}closed(){this.#s!==null&&this.#a()-this.#s>=this.#n&&(this.#o=0),this.#s=null}nextDelay(e){let t=Math.min(this.#o,30);this.#o+=1;let n=Math.min(this.#t,this.#e*2**t),r=Math.max(0,Math.min(1,this.#i())),i=1-this.#r+2*this.#r*r,a=Math.max(250,Math.min(this.#t,Math.round(n*i)));return Math.min(xe,Math.max(a,Math.max(0,Math.min(xe,Math.round(e??0)))))}reset(){this.#o=0,this.#s=null}};function Qp(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var $p=e=>e?`"${e}" `:``;function em(e,t=``){if(typeof e!=`boolean`)throw TypeError($p(t)+`expected boolean, got type=`+typeof e);return e}function tm(e,t=``){if(typeof e!=`number`)throw TypeError($p(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError($p(t)+`expected integer >= 0, got `+e);return e}function nm(e,t,n=``){if(Qp(e)&&(t===void 0||e.length===t))return e;t!==void 0&&tm(t,`length`);let r=Qp(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=$p(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var rm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`)};function im(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function am(e,t){nm(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function om(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function sm(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function cm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var lm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function um(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function dm(e){for(let t=0;t<e.length;t++)e[t]=um(e[t]);return e}var fm=lm?e=>e:dm;function pm(e,t){return rm(e,`defaults`),rm(t,`opts`),Object.assign(e,t)}function mm(e,t){if(e=nm(e),t=nm(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function hm(e,t,n){let r=t,i=n||(()=>[]),a=(e,t)=>r(t,...i(e)).update(e).digest(),o=r(new Uint8Array(e),...i(new Uint8Array));return a.outputLen=o.outputLen,a.blockLen=o.blockLen,a.create=(e,...t)=>r(e,...t),a}var gm=(e,t)=>{function n(n,...r){if(nm(n,void 0,`key`),e.nonceLength!==void 0){let t=r[0];nm(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength,a=e.nonceLength===void 0?0:1;if(!e.withAAD){for(let e=a;e<r.length;e++)if(Qp(r[e]))throw Error(`AAD not supported`)}e.withAAD&&r[a]!==void 0&&nm(r[a],void 0,`AAD`);let o=t(n,...r),s=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);nm(t,void 0,`output`)}},c=!1;return{encrypt(e,t){if(c)throw Error(`cannot encrypt() twice with same key + nonce`);return c=!0,nm(e,void 0,`data`),s(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(nm(e,void 0,`data`),i&&e.length<i)throw Error(`"ciphertext" expected length >= tagLength=`+i);return s(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(n,e),n};function _m(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(nm(t,e,`output`),n&&!ym(t))throw Error(`invalid output, must be aligned`);return t}function vm(e,t,n){tm(e),tm(t),em(n);let r=new Uint8Array(16),i=cm(r);return i.setBigUint64(0,BigInt(t),n),i.setBigUint64(8,BigInt(e),n),r}function ym(e){return e.byteOffset%4==0}function bm(e){return Uint8Array.from(nm(e))}var xm=e=>Uint8Array.from(e.split(``),e=>e.charCodeAt(0)),Sm=fm(om(xm(`expand 16-byte k`))),Cm=fm(om(xm(`expand 32-byte k`)));function X(e,t){return e<<t|e>>>32-t}var wm=64,Tm=16,Em=2**32-1,Dm=Uint32Array.of();function Om(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(wm),u=om(l),d=lm&&ym(i)&&ym(a),f=d?om(i):Dm,p=d?om(a):Dm;if(!lm){for(let d=0;d<c;o++){if(e(t,n,r,u,o,s),fm(u),o>=Em)throw Error(`arx: counter overflow`);let f=Math.min(wm,c-d);for(let e=0,t;e<f;e++)t=d+e,a[t]=i[t]^l[e];d+=f}return}for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=Em)throw Error(`arx: counter overflow`);let h=Math.min(wm,c-m);if(d&&h===wm){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<Tm;t++)n=e+t,p[n]=f[n]^u[t];m+=wm;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function km(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=pm({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return tm(i),tm(o),em(a),em(n),(t,s,c,l,u=0)=>{nm(t,void 0,`key`),nm(s,void 0,`nonce`),nm(c,void 0,`data`);let d=c.length;if(l=_m(d,l,!1),tm(u),u<0||u>=Em)throw Error(`arx: counter overflow`);let f=[],p=t.length,m,h;if(p===32)f.push(m=bm(t)),h=Cm;else if(p===16&&n)m=new Uint8Array(32),m.set(t),m.set(t,16),h=Sm,f.push(m);else throw nm(t,32,`arx key`),Error(`invalid key size`);(!lm||!ym(s))&&f.push(s=bm(s));let g=om(m);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);let e=s.subarray(0,16);if(lm)r(h,g,om(e),g);else{let t=fm(Uint32Array.from(h));r(t,g,om(e),g),sm(t),fm(g)}s=s.subarray(16)}else lm||fm(g);let _=16-i;if(_!==s.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,f.push(s)}let v=fm(om(s));try{return Om(e,h,g,v,c,l,u,o),l}finally{sm(...f)}}}function Am(e,t){return e[t++]&255|(e[t++]&255)<<8}var jm=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=bm(nm(e,32,`key`));let t=Am(e,0),n=Am(e,2),r=Am(e,4),i=Am(e,6),a=Am(e,8),o=Am(e,10),s=Am(e,12),c=Am(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Am(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Am(e,t+0),_=Am(e,t+2),v=Am(e,t+4),ee=Am(e,t+6),y=Am(e,t+8),te=Am(e,t+10),b=Am(e,t+12),x=Am(e,t+14),S=i[0]+(g&8191),C=i[1]+((g>>>13|_<<3)&8191),w=i[2]+((_>>>10|v<<6)&8191),T=i[3]+((v>>>7|ee<<9)&8191),E=i[4]+((ee>>>4|y<<12)&8191),D=i[5]+(y>>>1&8191),O=i[6]+((y>>>14|te<<2)&8191),k=i[7]+((te>>>11|b<<5)&8191),A=i[8]+((b>>>8|x<<8)&8191),j=i[9]+(x>>>5|r),M=0,ne=M+S*o+5*h*C+5*m*w+5*p*T+5*f*E;M=ne>>>13,ne&=8191,ne+=5*d*D+5*u*O+5*l*k+5*c*A+5*s*j,M+=ne>>>13,ne&=8191;let re=M+S*s+C*o+5*h*w+5*m*T+5*p*E;M=re>>>13,re&=8191,re+=5*f*D+5*d*O+5*u*k+5*l*A+5*c*j,M+=re>>>13,re&=8191;let ie=M+S*c+C*s+w*o+5*h*T+5*m*E;M=ie>>>13,ie&=8191,ie+=5*p*D+5*f*O+5*d*k+5*u*A+5*l*j,M+=ie>>>13,ie&=8191;let ae=M+S*l+C*c+w*s+T*o+5*h*E;M=ae>>>13,ae&=8191,ae+=5*m*D+5*p*O+5*f*k+5*d*A+5*u*j,M+=ae>>>13,ae&=8191;let oe=M+S*u+C*l+w*c+T*s+E*o;M=oe>>>13,oe&=8191,oe+=5*h*D+5*m*O+5*p*k+5*f*A+5*d*j,M+=oe>>>13,oe&=8191;let se=M+S*d+C*u+w*l+T*c+E*s;M=se>>>13,se&=8191,se+=D*o+5*h*O+5*m*k+5*p*A+5*f*j,M+=se>>>13,se&=8191;let ce=M+S*f+C*d+w*u+T*l+E*c;M=ce>>>13,ce&=8191,ce+=D*s+O*o+5*h*k+5*m*A+5*p*j,M+=ce>>>13,ce&=8191;let le=M+S*p+C*f+w*d+T*u+E*l;M=le>>>13,le&=8191,le+=D*c+O*s+k*o+5*h*A+5*m*j,M+=le>>>13,le&=8191;let ue=M+S*m+C*p+w*f+T*d+E*u;M=ue>>>13,ue&=8191,ue+=D*l+O*c+k*s+A*o+5*h*j,M+=ue>>>13,ue&=8191;let de=M+S*h+C*m+w*p+T*f+E*d;M=de>>>13,de&=8191,de+=D*u+O*l+k*c+A*s+j*o,M+=de>>>13,de&=8191,M=(M<<2)+M|0,M=M+ne|0,ne=M&8191,M>>>=13,re+=M,i[0]=ne,i[1]=re,i[2]=ie,i[3]=ae,i[4]=oe,i[5]=se,i[6]=ce,i[7]=le,i[8]=ue,i[9]=de}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;sm(n)}update(e){im(this),nm(e),e=bm(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){this.destroyed=!0,sm(this.h,this.r,this.buffer,this.pad)}digestInto(e){im(this),am(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}},Mm=hm(32,e=>new jm(e));function Nm(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,ee=n[0],y=n[1],te=n[2],b=o,x=s,S=c,C=l,w=u,T=d,E=f,D=p,O=m,k=h,A=g,j=_,M=v,ne=ee,re=y,ie=te;for(let e=0;e<a;e+=2)b=b+w|0,M=X(M^b,16),O=O+M|0,w=X(w^O,12),b=b+w|0,M=X(M^b,8),O=O+M|0,w=X(w^O,7),x=x+T|0,ne=X(ne^x,16),k=k+ne|0,T=X(T^k,12),x=x+T|0,ne=X(ne^x,8),k=k+ne|0,T=X(T^k,7),S=S+E|0,re=X(re^S,16),A=A+re|0,E=X(E^A,12),S=S+E|0,re=X(re^S,8),A=A+re|0,E=X(E^A,7),C=C+D|0,ie=X(ie^C,16),j=j+ie|0,D=X(D^j,12),C=C+D|0,ie=X(ie^C,8),j=j+ie|0,D=X(D^j,7),b=b+T|0,ie=X(ie^b,16),A=A+ie|0,T=X(T^A,12),b=b+T|0,ie=X(ie^b,8),A=A+ie|0,T=X(T^A,7),x=x+E|0,M=X(M^x,16),j=j+M|0,E=X(E^j,12),x=x+E|0,M=X(M^x,8),j=j+M|0,E=X(E^j,7),S=S+D|0,ne=X(ne^S,16),O=O+ne|0,D=X(D^O,12),S=S+D|0,ne=X(ne^S,8),O=O+ne|0,D=X(D^O,7),C=C+w|0,re=X(re^C,16),k=k+re|0,w=X(w^k,12),C=C+w|0,re=X(re^C,8),k=k+re|0,w=X(w^k,7);let ae=0;r[ae++]=o+b|0,r[ae++]=s+x|0,r[ae++]=c+S|0,r[ae++]=l+C|0,r[ae++]=u+w|0,r[ae++]=d+T|0,r[ae++]=f+E|0,r[ae++]=p+D|0,r[ae++]=m+O|0,r[ae++]=h+k|0,r[ae++]=g+A|0,r[ae++]=_+j|0,r[ae++]=v+M|0,r[ae++]=ee+ne|0,r[ae++]=y+re|0,r[ae++]=te+ie|0}var Pm=km(Nm,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Fm=new Uint8Array(16),Im=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Fm.subarray(n))},Lm=new Uint8Array(32);function Rm(e,t,n,r,i){i!==void 0&&nm(i,void 0,`AAD`);let a=e(t,n,Lm),o=vm(r.length,i?i.length:0,!0),s=Mm.create(a);i&&Im(s,i),Im(s,r),s.update(o);let c=s.digest();return sm(a,o),c}var zm=gm({blockSize:64,nonceLength:12,tagLength:16,withAAD:!0},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=_m(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Rm(e,t,n,s,r);return a.set(c,o),sm(c),a},decrypt(i,a){a=_m(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Rm(e,t,n,o,r);if(!mm(s,c))throw sm(c),Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),sm(c),a}}))(Pm));function Bm(e,t,n){return sr(e),n===void 0&&(n=new Uint8Array(e.outputLen)),pl(e,n,t)}var Vm=Uint8Array.of(0),Hm=Uint8Array.of();function Um(e,t,n,r=32,i){sr(e),ar(r,`length`),or(t,void 0,`prk`);let a=e.outputLen;if(t.length<a)throw Error(`"prk" must be at least HashLen octets`);if(r>255*a)throw Error(`Length must be <= 255*HashLen`);let o=Math.ceil(r/a);if(n===void 0?n=Hm:or(n,void 0,`info`),!o)return i&&dr(t),new Uint8Array;let s=i&&o===1?t:new Uint8Array(o*a),{iHash:c,oHash:l}=pl.create(e,t),u=i?t:new Uint8Array(a),d=o>1?i?.iHash||e.create():void 0;for(let e=0;e<o-1;e++){Vm[0]=e+1;let t=c._cloneInto(d);e&&t.update(u),t.update(n).update(Vm).digestInto(u),l._cloneInto(d).update(u).digestInto(u),s.set(u,a*e)}if(Vm[0]=o,o>1&&c.update(u),c.update(n).update(Vm).digestInto(u),l.update(u).digestInto(u),s.set(u,a*(o-1)),c.destroy(),l.destroy(),d?.destroy(),u!==s&&dr(u),dr(Vm),r===s.length)return s;let f=s.slice(0,r);return dr(s),f}var Wm=`ryco.relay-e2ee.confirmation-key.v1`,Gm=`ryco.relay-e2ee.aead-key.v1`,Km=`ryco.relay-e2ee.ratchet.v1`,qm=yr(Wm),Jm=yr(Gm),Ym=yr(Km);function Xm(e,t){if(!(e instanceof Uint8Array)||e.byteLength!==32)throw TypeError(`Relay E2EE ${t} must be exactly E2EE_SECRET_BYTES long.`);return e}function Zm(e){if(!eu(e))throw TypeError(`Relay E2EE direction must be a registered direction label.`);return e}function Qm(e,t){return br(e,Du(Zm(t)))}function $m(...e){for(let t of e)if(t instanceof Uint8Array)try{dr(t)}catch{}}function eh(e,t){try{return t()}catch(t){throw $m(...e),t}}function th(e){return Um(I,Xm(e,`exporter secret`),qm,32)}function nh(e,t){return Um(I,Xm(e,`epoch secret`),Qm(Jm,t),32)}function rh(e,t){return Um(I,Xm(e,`epoch secret`),Qm(Ym,t),32)}function ih(e){return eh([e.epochSecretC2N,e.epochSecretN2C,e.exporterSecret],()=>({epochSecretC2N:Xm(e.epochSecretC2N,`epoch secret`),epochSecretN2C:Xm(e.epochSecretN2C,`epoch secret`),exporterSecret:Xm(e.exporterSecret,`exporter secret`),serverConfirmationKey:th(e.exporterSecret)}))}function ah(e){return ih(e.split())}function oh(e){typeof e==`object`&&e&&$m(e.epochSecretC2N,e.epochSecretN2C,e.exporterSecret,e.serverConfirmationKey)}var sh=1+po([new Uint8Array(4),new Uint8Array(8),new Uint8Array(4),new Uint8Array(8),new Uint8Array(32)],Ia).byteLength,ch=17,lh=Object.freeze([...Array.from({length:2},()=>sh),...Array.from({length:1},()=>ch)]),uh=({version:e,suite:t,key:n})=>{if(e!==1||!$l(t))throw TypeError(`Relay E2EE record AEAD selected for an unregistered version or suite.`);return Xm(n,`AEAD key`),{seal:(e,t,r)=>zm(n,e,r).encrypt(t),open:(e,t,r)=>zm(n,e,r).decrypt(t)}},dh=class e{#e;#t;#n;#r;#i;#a;#o;#s=!1;constructor(t,n,r){let i=Zm(t);Xm(n,`epoch secret`);let a=e.#c(r);this.#e=i,this.#r=a.epoch,this.#i=a.counter,this.#a=a.epochRecords,this.#o=a.epochBytes,this.#n=nh(n,i),this.#t=n}static#c(e){let t=e?.epoch??0n,n=e?.counter??0n,r=e?.epochRecords??0,i=e?.epochBytes??0;if(typeof t!=`bigint`||t<0n||t>4294967295n)throw RangeError(`Synthetic relay E2EE epoch must be a bigint in the uint32 range.`);if(typeof n!=`bigint`||n<0n||n>18446744073709551615n)throw RangeError(`Synthetic relay E2EE counter must be a bigint in the uint64 range.`);if(!Number.isInteger(r)||r<0||r>=65536)throw RangeError(`Synthetic relay E2EE epoch record count must leave the epoch live.`);if(!Number.isInteger(i)||i<0||i>=268435456)throw RangeError(`Synthetic relay E2EE epoch byte count must leave the epoch live.`);return{epoch:t,counter:n,epochRecords:r,epochBytes:i}}get direction(){return this.#e}get exhausted(){return this.#s}get epoch(){return this.#r}get counter(){return this.#i}get state(){return{epoch:this.#s?void 0:this.#r,counter:this.#s?void 0:this.#i,epochRecords:this.#a,epochBytes:this.#o,exhausted:this.#s}}get aeadKey(){let e=this.#n;if(e===void 0)throw TypeError(`Relay E2EE directional AEAD key is unavailable.`);return e}static#l(e,t){return e>=65536||t>=268435456}capacityFor(t){if(this.#s)return!1;let n=this.#r,r=this.#a,i=this.#o;for(let a of t){if(e.#l(r,i)){if(n>=4294967295n)return!1;n+=1n,r=0,i=0}r+=1,i+=a}return!0}advance(t){if(this.#s)throw TypeError(`Relay E2EE direction is exhausted; no record may advance it.`);if(this.#a+=1,this.#o+=t,!e.#l(this.#a,this.#o))return this.#i>=18446744073709551615n?(this.#u(),{epochCompleted:!1}):(this.#i+=1n,{epochCompleted:!1});if(this.#r>=4294967295n)return this.#u(),{epochCompleted:!0};let n=this.#t,r=this.#n;if(n===void 0)throw TypeError(`Relay E2EE epoch secret is unavailable.`);let i=rh(n,this.#e),a=eh([i],()=>nh(i,this.#e));return $m(n,r),this.#t=i,this.#n=a,this.#r+=1n,this.#i=0n,this.#a=0,this.#o=0,{epochCompleted:!0}}#u(){this.#s=!0,this.erase()}erase(){$m(this.#t,this.#n),this.#t=void 0,this.#n=void 0}};function fh(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`sent`||t.kind===`failed`&&(t.delivery===`none`||t.delivery===`ambiguous`)}function ph(e){let t,n;try{if(!$l(e.suite))throw TypeError(`Relay E2EE session suite must be a registered suite id.`);if(!(e.sessionBindingHash instanceof Uint8Array)||e.sessionBindingHash.byteLength!==32)throw TypeError(`Relay E2EE session requires a full-length session binding hash.`);if(!Number.isInteger(e.plaintextCeiling)||e.plaintextCeiling<=0)throw RangeError(`Relay E2EE session requires a positive plaintext ceiling.`);let r=Zm(e.sendDirection),i=r===`c2n`?`n2c`:`c2n`,a=r===`c2n`?e.secrets.epochSecretC2N:e.secrets.epochSecretN2C,o=r===`c2n`?e.secrets.epochSecretN2C:e.secrets.epochSecretC2N;return t=new dh(r,a,e.testOnlySyntheticSendState),n=new dh(i,o,e.testOnlySyntheticReceiveState),{suite:e.suite,sessionBindingHash:Uint8Array.from(e.sessionBindingHash),plaintextCeiling:e.plaintextCeiling,aeadFactory:e.testOnlyAeadFactory??uh,secrets:e.secrets,send:t,receive:n}}catch(r){throw t?.erase(),n?.erase(),oh(e.secrets),r}}var mh=class{#e=1;#t;#n;#r;#i;#a;#o;#s;#c=`open`;#l=!1;#u=!1;#d=Promise.resolve();constructor(e){let t=ph(e);this.#t=t.suite,this.#n=t.sessionBindingHash,this.#r=t.plaintextCeiling,this.#i=t.aeadFactory,this.#a=t.secrets,this.#o=t.send,this.#s=t.receive}get suite(){return this.#t}get version(){return this.#e}get sendDirection(){return this.#o.direction}get receiveDirection(){return this.#s.direction}get sendState(){return this.#o.state}get receiveState(){return this.#s.state}get postApplicationReserveHeld(){return this.#o.capacityFor(lh)}get sendPathUsable(){return!this.#u&&this.#c!==`unusable`&&this.#c!==`spent`}#f(e,t,n){if(e!==this.#e||t!==this.#t)throw TypeError(`Relay E2EE AEAD selection requires the established version and suite.`);return this.#i({version:e,suite:t,key:n})}async protect(e){if(this.#y(),!tu(e.innerType))throw TypeError(`Relay E2EE inner record type must be a registered type.`);if(!(e.body instanceof Uint8Array))throw TypeError(`Relay E2EE inner record body must be a Uint8Array.`);if(typeof e.admit!=`function`||typeof e.transmit!=`function`)throw TypeError(`Relay E2EE sends require an admission and a transmit callback.`);let t=this.#d.then(()=>this.#p(e),()=>this.#p(e));return this.#d=t.then(()=>void 0,()=>void 0),t}async#p(e){if(this.#u)return{kind:`unavailable`,reason:`session_erased`};let t=this.#h(e.innerType);if(t!==void 0)return{kind:`unavailable`,reason:t};if(e.body.byteLength>this.#r)return{kind:`refused`,reason:`e2ee_message_too_large`};let n=1+e.body.byteLength;if(e.innerType===1){if(!this.#o.capacityFor([n,...lh]))return{kind:`close_required`}}else if(!this.#o.capacityFor([n]))return{kind:`exhausted`};let r=32+e.body.byteLength;if(!await e.admit(r))return{kind:`refused`,reason:`e2ee_send_unavailable`};if(this.#u)return{kind:`unavailable`,reason:`session_erased`};let i=this.#o.epoch,a=this.#o.counter,o=xu({suite:this.#t,epoch:i,counter:a}),s=o[1],c=o[2];if(s!==this.#e||!$l(c)||c!==this.#t)throw TypeError(`Relay E2EE envelope header disagrees with the established session.`);let l=this.#f(s,c,this.#o.aeadKey);try{return await this.#m(e,{epoch:i,counter:a,plaintextBytes:n,aead:l,header:o})}catch{return this.#c=`unusable`,{kind:`send_failed`,epoch:i,counter:a,delivery:`ambiguous`,sendPathUsable:!1,mayEmitError:!1}}}async#m(e,t){let{epoch:n,counter:r,plaintextBytes:i,aead:a,header:o}=t,s=Tu(o),c=Eu({header:o,sessionBindingHash:this.#n,direction:this.#o.direction}),l=Ou(e.innerType,e.body),u;try{let e=a.seal(s,l,c);u=Su({suite:this.#t,epoch:n,counter:r,ciphertext:e})}catch{u=void 0}finally{$m(l)}let{epochCompleted:d}=this.#o.advance(i);if(u===void 0)return this.#c=`unusable`,{kind:`send_failed`,epoch:n,counter:r,delivery:`none`,sendPathUsable:!1,mayEmitError:!1};this.#g(e.innerType);let f;try{let t=await e.transmit(u);f=fh(t)?t:{kind:`failed`,delivery:`ambiguous`}}catch{f={kind:`failed`,delivery:`ambiguous`}}return f.kind===`sent`?{kind:`protected`,epoch:n,counter:r,plaintextBytes:i,envelopeBytes:u.byteLength,epochCompleted:d}:f.delivery===`none`?(this.#c=`unusable`,{kind:`send_failed`,epoch:n,counter:r,delivery:`none`,sendPathUsable:!1,mayEmitError:!1}):{kind:`send_failed`,epoch:n,counter:r,delivery:`ambiguous`,sendPathUsable:this.sendPathUsable,mayEmitError:this.sendPathUsable}}#h(e){switch(this.#c){case`unusable`:return`send_path_unusable`;case`spent`:return`terminal_record_protected`;case`closing`:return e===1?`application_phase_closed`:void 0;case`open`:return}}#g(e){if(e===3){this.#c=`spent`;return}(e===2||e===4)&&this.#c===`open`&&(this.#c=`closing`)}unprotect(e){if(this.#y(),!(e instanceof Uint8Array))throw TypeError(`Relay E2EE payloads must be a Uint8Array.`);if(this.#l)return this.#v(`receive_terminated`);try{return this.#_(e)}catch(e){throw this.#l=!0,e}}#_(e){let t=Cu(e);if(t.kind===`error`)switch(t.reason){case`unsupported_version`:return this.#v(`version_mismatch`);case`unsupported_suite`:return this.#v(`suite_mismatch`);default:return this.#v(`malformed_envelope`)}let n=t.value;if(n.version!==this.#e)return this.#v(`version_mismatch`);if(n.suite!==this.#t)return this.#v(`suite_mismatch`);if(this.#s.exhausted||n.epoch!==this.#s.epoch||n.counter!==this.#s.counter)return this.#v(`sequence_mismatch`);let r=this.#f(n.version,n.suite,this.#s.aeadKey),i=Tu(n.header),a=Eu({header:n.header,sessionBindingHash:this.#n,direction:this.#s.direction}),o;try{o=r.open(i,n.ciphertext,a)}catch{return this.#v(`authentication_failed`)}let s;try{s=ku(o)}catch(e){throw $m(o),e}if(s.kind===`error`)return $m(o),this.#v(s.reason===`truncated`?`malformed_record`:`reserved_inner_type`);let c=n.epoch,l=n.counter,{epochCompleted:u}=eh([o],()=>this.#s.advance(o.byteLength));return{kind:`authenticated`,innerType:s.value.innerType,body:s.value.body,epoch:c,counter:l,plaintextBytes:o.byteLength,epochCompleted:u}}#v(e){return this.#l=!0,{kind:`fatal`,reason:e}}erase(){this.#u||(this.#u=!0,this.#o.erase(),this.#s.erase(),oh(this.#a))}get erased(){return this.#u}#y(){if(this.#u)throw TypeError(`Relay E2EE session has been erased; it is never resumed.`)}},hh=`Noise_IK_25519_ChaChaPoly_SHA256`,gh=`Noise_NX_25519_ChaChaPoly_SHA256`,_h=`ryco.relay-e2ee.exporter.v1`;function vh(e){return e===`IK`?hh:gh}var yh=I.outputLen,bh=32,xh=32,Sh=16,Ch=65535,wh=18446744073709551615n,Th=yr(_h),Eh=new Uint8Array,Dh=class extends Error{code=`relay_e2ee_noise_handshake_failed`;reason;constructor(e){super(`Relay E2EE Noise handshake failed.`),this.name=`E2eeNoiseHandshakeError`,this.reason=e}};function Oh(e){throw new Dh(e)}function kh(e,t){(!(e instanceof Uint8Array)||e.byteLength!==t)&&Oh(`invalid_key_material`)}function Ah(e,t){return kh(e,t),Uint8Array.from(e)}function jh(...e){for(let t of e)if(t instanceof Uint8Array)try{dr(t)}catch{}}function Mh(e,t){let n=Bm(I,t,e),r,i;try{r=Um(I,n,void 0,2*yh),i=r.slice(0,yh);let e=r.slice(yh);return[i,e]}catch(e){throw jh(i),e}finally{jh(n,r)}}function Nh(e){(typeof e!=`bigint`||e<0n)&&Oh(`invalid_options`),e>=wh&&Oh(`nonce_exhausted`);let t=new Uint8Array(12),n=e;for(let e=4;e<12;e+=1)t[e]=Number(n&255n),n>>=8n;return t}function Ph(e){return(!(e instanceof Uint8Array)||e.byteLength!==yh)&&Oh(`invalid_key_material`),Um(I,e,Th,32)}var Fh=class{#e=void 0;#t=0n;initializeKey(e){e.byteLength!==xh&&Oh(`invalid_key_material`),jh(this.#e),this.#e=e,this.#t=0n}get hasKey(){return this.#e!==void 0}encryptWithAd(e,t){let n=this.#e;if(n===void 0)return t;let r=Nh(this.#t),i=zm(n,r,e).encrypt(t);return dr(r),this.#t+=1n,i}decryptWithAd(e,t){let n=this.#e;if(n===void 0)return t;let r=Nh(this.#t),i=zm(n,r,e).decrypt(t);return dr(r),this.#t+=1n,i}erase(){jh(this.#e),this.#e=void 0,this.#t=0n}},Ih=class{#e;#t;#n=new Fh;constructor(e){let t=yr(e),n=new Uint8Array(yh);t.byteLength<=yh?n.set(t):n.set(I(t)),this.#t=n,this.#e=Uint8Array.from(n)}get hasKey(){return this.#n.hasKey}get handshakeHash(){return Uint8Array.from(this.#t)}mixKey(e){let[t,n]=Mh(this.#e,e);try{jh(this.#e),this.#e=t,this.#n.initializeKey(n)}catch(e){throw jh(n),e}}mixHash(e){let t=I(br(this.#t,e));jh(this.#t),this.#t=t}encryptAndHash(e){let t=this.#n.encryptWithAd(this.#t,e);return this.mixHash(t),t}decryptAndHash(e){let t=this.#n.decryptWithAd(this.#t,e);return this.mixHash(e),t}splitAndExport(){let[e,t]=Mh(this.#e,Eh),n;try{return n=Ph(this.#e),this.erase(),{epochSecretC2N:e,epochSecretN2C:t,exporterSecret:n}}catch(r){throw jh(e,t,n),r}}erase(){jh(this.#e,this.#t),this.#n.erase()}},Lh={IK:[[`e`,`es`,`s`,`ss`],[`e`,`ee`,`se`]],NX:[[`e`],[`e`,`ee`,`s`,`es`]]},Rh=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=0;#u;constructor(e){let t=e.pattern;t!==`IK`&&t!==`NX`&&Oh(`invalid_options`);let n=e.role;n!==`initiator`&&n!==`responder`&&Oh(`invalid_options`),e.prologue instanceof Uint8Array||Oh(`invalid_options`);let r=t===`IK`||n===`responder`,i=t===`IK`&&n===`initiator`;r!==(e.staticSecretKey!==void 0)&&Oh(`invalid_options`),i!==(e.remoteStaticPublicKey!==void 0)&&Oh(`invalid_options`);let a=e.staticSecretKey;a!==void 0&&kh(a,bh);let o=e.testOnlyEphemeralSecretKey;o!==void 0&&kh(o,bh);let s=e.remoteStaticPublicKey===void 0?void 0:Ah(e.remoteStaticPublicKey,bh);this.#e=n,this.#t=Lh[t],this.#a=s;let c=new Ih(vh(t));c.mixHash(e.prologue);let l=a===void 0?void 0:dl.getPublicKey(a);t===`IK`&&c.mixHash(n===`initiator`?s:l),this.#n=c,a!==void 0&&(this.#r={secretKey:Uint8Array.from(a),publicKey:l}),this.#c=o,this.#u=n===`initiator`?`awaiting_write`:`awaiting_read`}get status(){return this.#u}get remoteStaticPublicKey(){return this.#a===void 0?void 0:Uint8Array.from(this.#a)}get remoteEphemeralPublicKey(){return this.#o===void 0?void 0:Uint8Array.from(this.#o)}get localEphemeralPublicKey(){return this.#s===void 0?void 0:Uint8Array.from(this.#s)}get testOnlyHandshakeHash(){let e=this.#n.handshakeHash;if(!e.every(e=>e===0))return e}writeMessage(e){this.#d(`awaiting_write`),e instanceof Uint8Array||Oh(`invalid_options`);try{let t=[];for(let e of this.#t[this.#l])switch(e){case`e`:{let e=this.#p();this.#i=e,this.#e===`initiator`&&(this.#s=Uint8Array.from(e.publicKey)),t.push(e.publicKey),this.#n.mixHash(e.publicKey);break}case`s`:this.#r===void 0&&Oh(`out_of_sequence`),t.push(this.#n.encryptAndHash(this.#r.publicKey));break;default:this.#m(e)}t.push(this.#n.encryptAndHash(e));let n=br(...t);return n.byteLength>Ch&&Oh(`message_too_large`),this.#f(),n}catch(e){throw this.destroy(),e}}readMessage(e){this.#d(`awaiting_read`),e instanceof Uint8Array||Oh(`invalid_options`);try{e.byteLength>Ch&&Oh(`message_too_large`);let t=0,n=n=>{t+n>e.byteLength&&Oh(`malformed_message`);let r=e.subarray(t,t+n);return t+=n,r};for(let e of this.#t[this.#l])switch(e){case`e`:{let e=Uint8Array.from(n(bh));this.#o=e,this.#n.mixHash(e);break}case`s`:{let e=n(this.#n.hasKey?bh+Sh:bh),t=this.#n.decryptAndHash(e);t.byteLength!==bh&&Oh(`malformed_message`),this.#a=t;break}default:this.#m(e)}let r=this.#n.decryptAndHash(e.subarray(t));return this.#f(),r}catch(e){throw this.destroy(),e}}split(){this.#d(`awaiting_split`);let e;try{return e=this.#n.splitAndExport(),this.#h(),this.#u=`complete`,e}catch(t){throw e!==void 0&&jh(e.epochSecretC2N,e.epochSecretN2C,e.exporterSecret),this.destroy(),t}}destroy(){this.#u!==`complete`&&this.#u!==`destroyed`&&(this.#n.erase(),this.#h(),this.#u=`destroyed`)}#d(e){(this.#u===`complete`||this.#u===`destroyed`)&&Oh(`handshake_consumed`),this.#u!==e&&Oh(`out_of_sequence`)}#f(){if(this.#l+=1,this.#l>=this.#t.length){this.#u=`awaiting_split`;return}this.#u=this.#u===`awaiting_write`?`awaiting_read`:`awaiting_write`}#p(){let e=this.#c;if(e!==void 0){let t=dl.getPublicKey(e);return this.#c=void 0,{secretKey:e,publicKey:t}}let t=dl.keygen();return{secretKey:t.secretKey,publicKey:t.publicKey}}#m(e){let t=this.#e===`initiator`,n,r;switch(e){case`ee`:n=this.#i,r=this.#o;break;case`es`:n=t?this.#i:this.#r,r=t?this.#a:this.#o;break;case`se`:n=t?this.#r:this.#i,r=t?this.#o:this.#a;break;case`ss`:n=this.#r,r=this.#a}(n===void 0||r===void 0)&&Oh(`out_of_sequence`);let i=dl.getSharedSecret(n.secretKey,r);try{this.#n.mixKey(i)}finally{jh(i)}}#h(){jh(this.#i?.secretKey,this.#r?.secretKey,this.#c),this.#i=void 0,this.#r=void 0,this.#c=void 0}},zh=Rt(Ke);Rt(Wt);function Bh(e){return{version:e[1],suiteId:e[2],issuerHubOrigin:e[3],keyId:e[4],grantId:e[5],accountId:e[6],accountAuthEpoch:e[7],enrollmentId:e[8],enrollmentRevision:e[9],deviceAuthEpoch:e[10],deviceIdentityAlgorithm:e[11],deviceIdentityPublicKey:e[12],deviceIdentityFingerprint:e[13],deviceAgreementAlgorithm:e[14],deviceAgreementPublicKey:e[15],deviceAgreementFingerprint:e[16],clientPrekeyCertificateDigest:e[17],nodeId:e[18],nodeIdentityAlgorithm:e[19],nodeIdentityPublicKey:e[20],nodeIdentityFingerprint:e[21],nodeAgreementAlgorithm:e[22],nodeAgreementPublicKey:e[23],nodeAgreementFingerprint:e[24],nodeContinuityId:e[25],nodePolicyGeneration:e[26],nodeCapabilityStatementDigest:e[27],relayTicketId:e[28],maximumRole:e[29],capabilities:e[30],issuedAt:e[31],notBefore:e[32],expiresAt:e[33],nonce:e[34]}}function Vh(e){try{return Gl(e.deviceIdentityPublicKey),Kl(e.deviceAgreementPublicKey),Wl(e.nodeIdentityPublicKey),Kl(e.nodeAgreementPublicKey),Zl(e.deviceIdentityFingerprint,Xl(`client-identity`,e.deviceIdentityPublicKey))&&Zl(e.deviceAgreementFingerprint,Xl(`agreement`,e.deviceAgreementPublicKey))&&Zl(e.nodeIdentityFingerprint,Xl(`node-identity`,e.nodeIdentityPublicKey))&&Zl(e.nodeAgreementFingerprint,Xl(`agreement`,e.nodeAgreementPublicKey))}catch{return!1}}function Hh(e){return e===`non_canonical`?`grant_non_canonical`:`grant_malformed`}function Uh(e){if(!(e instanceof Uint8Array))return{kind:`error`,reason:`grant_malformed`};if(e.byteLength>Lo)return{kind:`error`,reason:`grant_oversize`};let t=$u(e);if(t.kind===`error`)return{kind:`error`,reason:Hh(t.reason)};if(!Array.isArray(t.value)||t.value.length!==2||!(t.value[0]instanceof Uint8Array)||!(t.value[1]instanceof Uint8Array)||t.value[1].byteLength!==64)return{kind:`error`,reason:`grant_malformed`};let n=t.value[0],r=t.value[1],i=$u(n);if(i.kind===`error`)return{kind:`error`,reason:Hh(i.reason)};if(!Array.isArray(i.value)||i.value.length!==35)return{kind:`error`,reason:`grant_malformed`};if(i.value[0]!==`ryco.hub-device-grant-claims.v1`||i.value[1]!==1||i.value[2]!==2)return{kind:`error`,reason:`grant_version`};let a=zh(Bh(i.value));if(_e(a))return{kind:`error`,reason:`grant_malformed`};try{if(hd(a.value.issuerHubOrigin)!==a.value.issuerHubOrigin)return{kind:`error`,reason:`grant_malformed`}}catch{return{kind:`error`,reason:`grant_malformed`}}return Vh(a.value)?{kind:`ok`,claims:a.value,envelope:Uint8Array.from(e),claimsBytes:Uint8Array.from(n),signature:Uint8Array.from(r),grantDigest:I(e)}:{kind:`error`,reason:`grant_binding`}}var Wh=`ryco.relay-e2ee.confirmation.v1`,Gh=`ryco.relay-e2ee.session.v1`;function Kh(e,t){return!(e instanceof Uint8Array)||!(t instanceof Uint8Array)?!1:mm(e,t)}function qh(e){return Uint8Array.from(po(e,Ia))}function Jh(e){return typeof e==`string`}function Yh(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Xh(e,t){return e instanceof Uint8Array?t===void 0||e.byteLength===t:!1}function Zh(e){return Uint8Array.from(e)}var Qh={viewer:0,operator:1,owner:2};function $h(e){let t=Qh[vd(e)];return t===void 0&&G(),t}function eg(e,t){return $h(e)<=$h(t)}function tg(e){return e.trustSource??(e.tier===`native`?`locally-verified`:`web-unsigned`)}function ng(e,t,n){return e===2?t===`native`&&n===`account-enrolled`:t===`web`?n===`web-unsigned`:n===`locally-verified`}function rg(e){if((!Array.isArray(e.advertisedSuiteRegistry)||e.advertisedSuiteRegistry.length===0||e.advertisedSuiteRegistry.length>8||!Array.isArray(e.localSuitePreference)||e.localSuitePreference.length===0)&&G(),!Number.isSafeInteger(e.advertisedVersionMin)||!Number.isSafeInteger(e.advertisedVersionMax)||e.advertisedVersionMin>e.advertisedVersionMax||e.advertisedVersionMin>1||1>e.advertisedVersionMax)return{kind:`unusable`,reason:`protocol_version_out_of_range`};let t=Yu(e.tier);if(!e.advertisedAdmittedPatterns.includes(t))return{kind:`unusable`,reason:`pattern_not_admitted`};let n=tg(e),r=e.localSuitePreference.find(t=>$l(t)&&ng(t,e.tier,n)&&e.advertisedSuiteRegistry.includes(t));return r===void 0||!$l(r)?{kind:`unusable`,reason:`empty_suite_intersection`}:{kind:`usable`,selectedSuite:r}}function ig(e){return $l(e)||G(),{dh:qu,hash:Ju}}var ag=5,og=3;function sg(e){return e===`native`||e===`web`}function cg(e){return sg(e.tier)||G(),$l(e.selectedSuite)||G(),(!Array.isArray(e.offeredSuites)||e.offeredSuites.length===0||e.offeredSuites.length>8||!e.offeredSuites.every(Yh)||!e.offeredSuites.includes(e.selectedSuite))&&G(),Xh(e.clientNonce,32)||G(),Xh(e.contextCommitment,32)||G(),(!Xh(e.noiseMessage1)||e.noiseMessage1.byteLength===0)&&G(),Nu(1,qh([1,e.tier,e.selectedSuite,[...e.offeredSuites],Zh(e.clientNonce),Zh(e.contextCommitment),Zh(e.noiseMessage1)]))}function lg(e){(!Xh(e.clientPrekeyTranscript)||e.clientPrekeyTranscript.length===0)&&G();let t=Yl(e.clientPrekeySignature);return qh([Zh(e.clientPrekeyTranscript),t,gd(e.accountId),_d(e.intendedCapability),vd(e.intendedRole)])}function ug(e){(!Xh(e.hubDeviceGrant)||e.hubDeviceGrant.byteLength===0||e.hubDeviceGrant.byteLength>Lo)&&G();let t=$u(lg(e));return(t.kind!==`ok`||!Array.isArray(t.value))&&G(),qh([...t.value,Zh(e.hubDeviceGrant)])}var dg=new Uint8Array;function fg(e){$l(e.acceptedSuite)||G(),(!Jh(e.nodePrekeyId)||e.nodePrekeyId.length===0)&&G(),Xh(e.contextCommitment,32)||G(),(!Xh(e.noiseMessage2)||e.noiseMessage2.byteLength===0)&&G()}function pg(e){return fg(e),Nu(2,qh([e.acceptedSuite,e.nodePrekeyId,Zh(e.contextCommitment),Zh(e.noiseMessage2)]))}function mg(e){let t=Pu(e);if(t.kind===`error`||t.value.recordType!==2)return{kind:`error`,reason:`bad_record`};let n=$u(t.value.body);if(n.kind===`error`)return{kind:`error`,reason:`malformed_body`};let r=n.value;if(!Array.isArray(r)||r.length!==ag)return{kind:`error`,reason:`malformed_body`};let[i,a,o,s,c]=r;return!Yh(i)||!Jh(a)||a.length===0||!Xh(o,32)||!Xh(s)||s.byteLength===0||!Xh(c,32)?{kind:`error`,reason:`malformed_body`}:{kind:`ok`,value:{acceptedSuite:i,nodePrekeyId:a,contextCommitment:o,noiseMessage2:s,serverConfirmation:c}}}function hg(e){let t=$u(e);if(t.kind===`error`)return{kind:`error`,reason:`malformed_body`};let n=t.value;if(!Array.isArray(n)||n.length!==og)return{kind:`error`,reason:`malformed_body`};let[r,i,a]=n;return!Jh(r)||!Jh(i)||!Xh(a,32)?{kind:`error`,reason:`malformed_body`}:{kind:`ok`,value:{channelOpenCapability:r,channelOpenEffectiveRole:i,nodeAgreementKeyFingerprint:a}}}function gg(e){let t=$u(e);return(t.kind===`error`||!Array.isArray(t.value))&&G(),t.value}function _g(e){return(!Xh(e.clientHelloWireBytes)||e.clientHelloWireBytes.byteLength===0||!Xh(e.serverAcceptTbsWireBytes)||e.serverAcceptTbsWireBytes.byteLength===0)&&G(),I(qh([Wh,Zh(e.clientHelloWireBytes),Zh(e.serverAcceptTbsWireBytes),gg(e.contextBlock)]))}function vg(e,t){return(!Xh(e)||!Xh(t,32))&&G(),pl(I,e,t)}function yg(e){(!Xh(e.clientHelloWireBytes)||e.clientHelloWireBytes.byteLength===0||!Xh(e.serverAcceptWireBytes)||e.serverAcceptWireBytes.byteLength===0)&&G();let t=I(qh([Gh,Zh(e.clientHelloWireBytes),Zh(e.serverAcceptWireBytes),gg(e.contextBlock)]));return t.byteLength!==32&&G(),t}var bg=11;function xg(e){let t=$u(e.transcript);if(t.kind===`error`)return{kind:`error`,failure:`malformed`};let n=t.value;if(!Array.isArray(n)||n.length!==bg)return{kind:`error`,failure:`malformed`};let[,r,i,a,o,s,c,l,u,d,f]=n;if(!Jh(r)||!Jh(i)||a!==`p256`||!Xh(o,65)||!Xh(s,32)||!Xh(c,32)||!Jh(l)||!Jh(u)||!Yh(d)||!Yh(f))return{kind:`error`,failure:`malformed`};let p,m;try{Gl(o),Kl(c),Yl(e.signature),p=wd({hubOrigin:r,accountId:i,identityPublicKey:o,agreementPublicKey:c,createdAt:d,expiresAt:f}),m=Xl(`agreement`,c)}catch{return{kind:`error`,failure:`malformed`}}if(!Kh(p,e.transcript))return{kind:`error`,failure:`malformed`};if(r!==e.hubOrigin)return{kind:`error`,failure:`hub_origin_mismatch`};let h=ig(e.suite);return l!==h.dh||u!==h.hash?{kind:`error`,failure:`usage_mismatch`}:Ql({algorithm:`p256`,publicKey:o,message:e.transcript,signature:e.signature})?f<=d||f-d>2592e6||e.now+3e5<d||e.now-3e5>f?{kind:`error`,failure:`expired`}:{kind:`ok`,certificate:{hubOrigin:r,accountId:i,identityPublicKey:o,identityFingerprint:s,agreementPublicKey:c,agreementFingerprint:m,createdAt:d,expiresAt:f}}:{kind:`error`,failure:`invalid_signature`}}function Sg(e,t){return{kind:`fatal`,row:e,reason:t}}function Cg(e){return e.tier===`native`&&e.trustSource===`account-enrolled`}function wg(e,t){return e===`web`?`web-unsigned`:t===2?`account-enrolled`:`locally-verified`}function Tg(e){let t=Kd({hubOrigin:e.channel.hubOrigin,channelId:e.channel.channelId,relayProtocolMajor:e.channel.relayProtocolMajor,relayProtocolMinor:e.channel.relayProtocolMinor,e2eeVersion:1,suiteId:e.suite,nodeId:e.advertised.nodeId,nodeIdentityFingerprint:e.advertised.nodeIdentityFingerprint,clientIntendedCapability:e.intendedCapability,clientIntendedRole:e.intendedRole,channelOpenCapability:e.channel.channelOpenCapability,channelOpenEffectiveRole:e.channel.channelOpenEffectiveRole,nodeAgreementFingerprint:Xl(`agreement`,e.advertised.agreementPublicKey),nodeContinuityChainTranscripts:e.advertised.continuityChainTranscripts,nodeContinuityId:e.advertised.continuityId,client:e.client});return{block:t,commitment:Yd(t)}}function Eg(e){let{channel:t,advertised:n,grant:r,certificate:i}=e,a=r.claims,o=t.accountGrantContext,s=n.capabilityStatementDigest,c=n.policyGeneration;return t.relayProtocolMajor===1&&t.relayProtocolMinor>=3&&o!==void 0&&s instanceof Uint8Array&&Number.isSafeInteger(c)&&c!==void 0&&a.suiteId===2&&a.issuerHubOrigin===t.hubOrigin&&a.accountId===i.accountId&&a.nodeId===n.nodeId&&a.nodeContinuityId===n.continuityId&&a.nodePolicyGeneration===c&&a.relayTicketId===o.relayTicketId&&a.capabilities.some(t=>t===e.intendedCapability)&&eg(e.intendedRole,a.maximumRole)&&Kh(r.grantDigest,I(r.envelope))&&Kh(r.grantDigest,o.deviceGrantDigest)&&Kh(a.nodeCapabilityStatementDigest,o.nodeCapabilityStatementDigest)&&Kh(a.nodeCapabilityStatementDigest,s)&&Kh(a.clientPrekeyCertificateDigest,e.certificateDigest)&&Kh(a.deviceIdentityPublicKey,i.identityPublicKey)&&Kh(a.deviceIdentityFingerprint,i.identityFingerprint)&&Kh(a.deviceAgreementPublicKey,i.agreementPublicKey)&&Kh(a.deviceAgreementFingerprint,i.agreementFingerprint)&&Kh(a.nodeIdentityFingerprint,n.nodeIdentityFingerprint)&&Kh(a.nodeAgreementPublicKey,n.agreementPublicKey)&&Kh(a.nodeAgreementFingerprint,Xl(`agreement`,n.agreementPublicKey))}function Dg(e){Eg(e)||G();let t=qd({hubOrigin:e.channel.hubOrigin,channelId:e.channel.channelId,relayProtocolMajor:e.channel.relayProtocolMajor,relayProtocolMinor:e.channel.relayProtocolMinor,e2eeVersion:1,suiteId:2,nodeId:e.advertised.nodeId,nodeIdentityFingerprint:e.advertised.nodeIdentityFingerprint,clientIntendedCapability:e.intendedCapability,clientIntendedRole:e.intendedRole,channelOpenCapability:e.channel.channelOpenCapability,channelOpenEffectiveRole:e.channel.channelOpenEffectiveRole,nodeAgreementFingerprint:Xl(`agreement`,e.advertised.agreementPublicKey),nodeContinuityChainTranscripts:e.advertised.continuityChainTranscripts,nodeContinuityId:e.advertised.continuityId,client:{tier:`native`,accountId:e.certificate.accountId,identityFingerprint:e.certificate.identityFingerprint,agreementFingerprint:e.certificate.agreementFingerprint},grant:e.grant.claims,deviceGrantDigest:e.grant.grantDigest});return{block:t,commitment:Yd(t)}}function Og(e,t,n){return t===e.channelOpenCapability&&n===e.channelOpenEffectiveRole}function kg(e){return e+Ho}var Ag=class{#e;#t;#n=`created`;#r;#i;#a;#o;#s;constructor(e){if(!$l(e.selectedSuite))throw TypeError(`Relay E2EE client handshake requires a registered suite selection.`);let t=e.selectedSuite===2;if(t!==Cg(e.credentials)||t&&(e.credentials.tier!==`native`||e.channel.relayProtocolMajor!==1||e.channel.relayProtocolMinor<3||e.channel.accountGrantContext===void 0)||!t&&e.channel.accountGrantContext!==void 0)throw TypeError(`Relay E2EE suite, trust source, and channel context do not agree.`);this.#e=e,this.#t=e.credentials.tier}get tier(){return this.#t}get state(){return this.#n}get deadlineAt(){return this.#s}deadlineExpired(e){return this.#s!==void 0&&e>this.#s}createHello(e){if(this.#n!==`created`)return this.#u(Sg(`P4`,`handshake_spent`));let t;try{return this.#c(e,e=>{t=e})}catch(e){throw t?.destroy(),this.destroy(),e}}#c(e,t){let n=this.#e,r=n.credentials;if(!Og(n.channel,n.intendedCapability,n.intendedRole))return this.#u(Sg(`P13`,`context_mismatch`));let i;if(Cg(r)){let t=Jd(r.prekeyTranscript,r.prekeySignature),a=xg({transcript:r.prekeyTranscript,signature:r.prekeySignature,hubOrigin:n.channel.hubOrigin,suite:n.selectedSuite,now:e}),o=Uh(r.deviceGrant.envelope);if(a.kind===`error`||o.kind===`error`||!Kh(o.claimsBytes,r.deviceGrant.claimsBytes)||!Kh(o.signature,r.deviceGrant.signature)||!Kh(o.grantDigest,r.deviceGrant.grantDigest)||a.certificate.accountId!==r.accountId||!Kh(a.certificate.identityPublicKey,r.identityPublicKey)||!Kh(a.certificate.agreementPublicKey,r.agreementPublicKey))throw TypeError(`Relay E2EE account grant does not match the client certificate.`);i={certificate:a.certificate,digest:I(t),grant:o}}let a=Cg(r)&&i!==void 0?Dg({channel:n.channel,advertised:n.advertised,grant:i.grant,certificate:i.certificate,certificateDigest:i.digest,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole}):r.tier===`native`?Tg({channel:n.channel,advertised:n.advertised,suite:n.selectedSuite,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole,client:{tier:`native`,accountId:r.accountId,identityFingerprint:Xl(`client-identity`,r.identityPublicKey),agreementFingerprint:Xl(`agreement`,r.agreementPublicKey)}}):Tg({channel:n.channel,advertised:n.advertised,suite:n.selectedSuite,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole,client:{tier:`web`}}),o=Xd({hubOrigin:n.channel.hubOrigin,channelId:n.channel.channelId,relayProtocolMajor:n.channel.relayProtocolMajor,relayProtocolMinor:n.channel.relayProtocolMinor,e2eeVersion:1,suiteId:n.selectedSuite,nodeId:n.advertised.nodeId,contextCommitment:a.commitment}),s;if(r.tier===`native`){if(!Kh(dl.getPublicKey(r.agreementSecretKey),r.agreementPublicKey))throw TypeError(`Relay E2EE client agreement secret key does not match its certificate key.`);let e={clientPrekeyTranscript:r.prekeyTranscript,clientPrekeySignature:r.prekeySignature,accountId:r.accountId,intendedCapability:n.intendedCapability,intendedRole:n.intendedRole};s=Cg(r)?ug({...e,hubDeviceGrant:i.grant.envelope}):lg(e)}else s=dg;let c=new Rh({pattern:Yu(this.#t),role:`initiator`,prologue:o,staticSecretKey:r.tier===`native`?r.agreementSecretKey:void 0,remoteStaticPublicKey:r.tier===`native`?n.advertised.agreementPublicKey:void 0,testOnlyEphemeralSecretKey:n.testOnlyEphemeralSecretKey});t(c);let l;try{l=c.writeMessage(s)}catch{return c.destroy(),this.#u(Sg(`P10`,`noise`))}let u=cg({tier:this.#t,selectedSuite:n.selectedSuite,offeredSuites:n.offeredSuites,clientNonce:n.testOnlyClientNonce??Cr(32),contextCommitment:a.commitment,noiseMessage1:l});return this.#r=c,this.#i=u,this.#a=a.block,this.#o=a.commitment,this.#s=kg(e),this.#n=`hello_sent`,{kind:`hello`,record:u,contextBlock:a.block,contextCommitment:a.commitment,prologue:o,deadlineAt:this.#s}}receiveServerAccept(e,t){if(this.#n!==`hello_sent`)return this.#u(Sg(`P16`,`handshake_spent`));let n=this.#r,r=this.#i,i=this.#a,a=this.#o;if(n===void 0||r===void 0||i===void 0||a===void 0)return this.#u(Sg(`P16`,`handshake_spent`));if(this.deadlineExpired(t))return this.#u(Sg(`P20`,`handshake_deadline`));let o;try{return this.#l({payload:e,noise:n,helloRecord:r,contextBlock:i,contextCommitment:a,holdSecrets:e=>{o=e}})}catch(e){throw o!==void 0&&oh(o),this.destroy(),e}}#l(e){let{payload:t,noise:n,helloRecord:r,contextBlock:i,contextCommitment:a}=e,o=mg(t);if(o.kind===`error`)return this.#u(o.reason===`bad_record`?Sg(`P3`,`record_bounds`):Sg(`P16`,`accept_mismatch`));let s=o.value;if(s.acceptedSuite!==this.#e.selectedSuite||s.nodePrekeyId!==this.#e.advertised.prekeyId)return this.#u(Sg(`P16`,`accept_mismatch`));if(!Kh(s.contextCommitment,a))return this.#u(Sg(`P13`,`context_mismatch`));let c;try{c=n.readMessage(s.noiseMessage2)}catch{return this.#u(Sg(`P10`,`noise`))}let l=n.remoteStaticPublicKey;if(l===void 0||!Kh(l,this.#e.advertised.agreementPublicKey))return this.#u(Sg(`P16`,`accept_mismatch`));let u=hg(c);if(u.kind===`error`)return this.#u(Sg(`P16`,`accept_mismatch`));let d=u.value;if(d.channelOpenCapability!==this.#e.channel.channelOpenCapability||d.channelOpenEffectiveRole!==this.#e.channel.channelOpenEffectiveRole||!Kh(d.nodeAgreementKeyFingerprint,Xl(`agreement`,this.#e.advertised.agreementPublicKey)))return this.#u(Sg(`P13`,`context_mismatch`));let f;try{f=ah(n)}catch{return this.#u(Sg(`P10`,`noise`))}e.holdSecrets(f);let p=pg({acceptedSuite:this.#e.selectedSuite,nodePrekeyId:s.nodePrekeyId,contextCommitment:s.contextCommitment,noiseMessage2:s.noiseMessage2}),m=_g({clientHelloWireBytes:r,serverAcceptTbsWireBytes:p,contextBlock:i});if(!Kh(vg(f.serverConfirmationKey,m),s.serverConfirmation))return oh(f),this.#u(Sg(`P16`,`confirmation_mismatch`));let h=yg({clientHelloWireBytes:r,serverAcceptWireBytes:t,contextBlock:i}),g;if(this.#e.credentials.tier===`web`&&(g=n.localEphemeralPublicKey,g===void 0))throw TypeError(`Relay E2EE client handshake has no local ephemeral.`);return this.#n=`established`,this.#r=void 0,{kind:`established`,sessionBindingHash:h,secrets:f,suite:this.#e.selectedSuite,trustSource:wg(this.#t,this.#e.selectedSuite),contextBlock:i,serverAcceptTbs:p,confirmationTranscript:m,...g===void 0?{}:{webEphemeralPublicKey:g}}}destroy(){this.#r?.destroy(),this.#r=void 0,this.#n!==`established`&&(this.#n=`failed`)}#u(e){return this.destroy(),e}};function jg(e){return{kind:`invalid`,reason:e}}var Mg=new TextEncoder;function Ng(e){let t;try{t=hd(e.connectedHubOrigin)}catch{return jg(`connected_hub_origin_invalid`)}if(e.accountId!==void 0){let t=Mg.encode(e.accountId).byteLength;if(t===0||t>256)return jg(`account_scope_invalid`)}let n=Ud(e.statement);if(n.kind===`error`)return jg(n.failure);let r=n.value,i;try{i=Wd(r.transcript)}catch{return jg(`identity_signature_invalid`)}if(!Ql({algorithm:`ed25519`,publicKey:r.identityPublicKey,message:i,signature:r.signature}))return jg(`identity_signature_invalid`);if(!Zl(Xl(`node-identity`,r.identityPublicKey),r.identityFingerprint))return jg(`identity_fingerprint_mismatch`);if(!Zl(Xl(`agreement`,r.prekeyCertificate.agreementPublicKey),r.prekeyCertificate.agreementFingerprint))return jg(`agreement_fingerprint_mismatch`);if(r.expiresAt<r.issuedAt)return jg(`validity_interval_inverted`);if(r.expiresAt-r.issuedAt>6e5)return jg(`validity_interval_too_long`);if(r.issuedAt>e.now+3e5)return jg(`issued_at_in_future`);if(r.expiresAt<e.now-3e5)return jg(`statement_expired`);if(r.hubOrigin!==t)return jg(`hub_origin_mismatch`);let a=r.prekeyCertificate;if(a.expiresAt<=a.createdAt)return jg(`prekey_lifetime_inverted`);if(a.expiresAt-a.createdAt>2592e6)return jg(`prekey_lifetime_too_long`);if(e.now+3e5<a.createdAt)return jg(`prekey_not_yet_valid`);if(a.expiresAt<e.now-3e5)return jg(`prekey_expired`);if(!Zd({hubOrigin:r.hubOrigin,nodeId:r.nodeId,identityKeyId:r.identityKeyId,identityPublicKey:r.identityPublicKey,identityFingerprint:r.identityFingerprint,prekeyCertificate:a}))return jg(`prekey_cross_signature_invalid`);if(e.pin!==void 0&&r.continuityId!==e.pin.continuityId)return{kind:`identity-event`,event:{reason:`pinned_continuity_id`},statement:r};let o=jd({chain:r.continuityChain,hubOrigin:r.hubOrigin,continuityId:r.continuityId,identityPublicKey:r.identityPublicKey,...e.pin===void 0?{}:{pinnedIdentityFingerprint:e.pin.identityFingerprint}});if(o.kind===`error`)return e.pin===void 0||o.failure===`malformed_entry`?{kind:`invalid`,reason:`continuity_chain_invalid`,chainFailure:o.failure}:{kind:`identity-event`,event:{reason:`continuity_chain`,failure:o.failure},statement:r};if(e.acceptedPolicyGeneration!==void 0&&r.policyGeneration<e.acceptedPolicyGeneration)return jg(`policy_generation_regressed`);let s=rg({tier:e.tier,...e.trustSource===void 0?{}:{trustSource:e.trustSource},localSuitePreference:e.localSuitePreference,advertisedSuiteRegistry:r.suiteRegistry,advertisedVersionMin:r.e2eeVersionMin,advertisedVersionMax:r.e2eeVersionMax,advertisedAdmittedPatterns:r.admittedPatterns});return s.kind===`unusable`?{kind:`unusable`,reason:s.reason,statement:r}:{kind:`verified`,statement:r,selectedSuite:s.selectedSuite,anchor:o.pinnedFingerprintUnchanged===void 0?`none`:o.pinnedFingerprintUnchanged?`pin-unchanged`:`pin-updated`}}var Pg={[P.serverGetProjectPreferences]:`viewer`,[P.storageScan]:`owner`,[P.storagePreview]:`owner`,[P.storageExecute]:`owner`,[P.sessionImportSources]:`owner`,[P.sessionImportReconcile]:`owner`,[P.sessionImportAdopt]:`owner`,[P.sessionImportDiscover]:`owner`,[P.sessionImportRun]:`owner`,[F.automationCentre]:`owner`,[F.automationCommand]:`owner`,[we.read]:`viewer`,[we.subscribeEvents]:`viewer`,[we.lifecycle]:`owner`,[we.input]:`owner`,[we.app]:`owner`,[we.recording]:`owner`,[F.acceptProposal]:`owner`,[F.getProposal]:`owner`,[F.listProposals]:`owner`,[F.rejectProposal]:`owner`,[F.subscribeProposals]:`owner`,[F.listIntegrations]:`owner`,[F.createIntegration]:`owner`,[F.updateIntegration]:`owner`,[F.resumeIntegrationPairing]:`owner`,[F.revokeIntegration]:`owner`,[F.deleteIntegration]:`owner`,[F.listMcpInstallations]:`owner`,[F.connectMcpInstallation]:`owner`,[F.repairMcpInstallation]:`owner`,[F.disconnectMcpInstallation]:`owner`,[P.atlassianDisconnect]:`owner`,[P.atlassianGetProjectLink]:`owner`,[P.atlassianListConnections]:`owner`,[P.atlassianListResources]:`owner`,[P.atlassianRefresh]:`owner`,[P.atlassianSaveManualBitbucketToken]:`owner`,[P.atlassianSaveManualJiraToken]:`owner`,[P.atlassianSaveProjectLink]:`owner`,[P.atlassianStartOAuth]:`owner`,[P.chatAttachmentsCreateFileUpload]:`operator`,[P.chatAttachmentsReadChunk]:`viewer`,[P.filesystemBrowse]:`operator`,[P.gitArchiveWorktree]:`operator`,[P.gitCreateWorktreeForProject]:`operator`,[P.gitDeleteWorktree]:`operator`,[P.lifecycleListWorkspaces]:`operator`,[P.lifecyclePreviewWorkspace]:`operator`,[P.lifecycleApplyWorkspace]:`operator`,[P.lifecycleSuggestions]:`operator`,[P.lifecycleListTrash]:`viewer`,[P.gitFindWorktreeForOrigin]:`operator`,[P.gitPreparePullRequestThread]:`operator`,[P.gitResolvePullRequest]:`operator`,[P.gitRestoreWorktree]:`operator`,[P.gitRunStackedAction]:`operator`,[P.keybindingsReplaceCustom]:`owner`,[P.mcpListServers]:`owner`,[P.mcpListWorkspaces]:`owner`,[P.mcpReloadServers]:`owner`,[P.mcpRemoveServer]:`owner`,[P.mcpSetServerEnabled]:`owner`,[P.mcpStartOauthLogin]:`owner`,[P.mcpUpsertServer]:`owner`,[N.dispatchCommand]:`operator`,[N.getFullThreadDiff]:`viewer`,[N.getTurnDiff]:`viewer`,[N.getTaskOutput]:`operator`,[N.getThreadHistoryPage]:`viewer`,[N.getThreadWindow]:`viewer`,[N.getWorkflowScript]:`operator`,[N.stopBackgroundTask]:`operator`,[N.replayEvents]:`viewer`,[N.replayEventsPage]:`viewer`,[N.searchThreadMessages]:`viewer`,[N.subscribeShell]:`viewer`,[N.subscribeThread]:`viewer`,[N.subscribeThreadWindow]:`viewer`,[rt.getInspectionSummary]:`viewer`,[rt.listInspectionEntries]:`viewer`,[rt.readRawPayloadChunk]:`viewer`,[rt.readExportChunk]:`viewer`,[P.projectsAdd]:`operator`,[P.projectsInitializeGit]:`operator`,[P.projectsPromoteChatPreview]:`operator`,[P.projectsPromoteChat]:`operator`,[P.projectsDeleteChatFolder]:`operator`,[P.projectsList]:`viewer`,[P.projectsListEntries]:`operator`,[P.projectsReadFile]:`operator`,[P.projectsReadIcon]:`viewer`,[P.projectsReadFileBinary]:`operator`,[P.projectsRemove]:`operator`,[P.projectsSearchEntries]:`operator`,[P.projectsStageFileReference]:`operator`,[P.projectsWriteFile]:`operator`,[P.serverCheckOpinionatedPlugins]:`owner`,[P.serverDiscoverSourceControl]:`owner`,[P.serverGetAdvertisedEndpoints]:`viewer`,[P.serverGetConfig]:`viewer`,[P.serverGetDiagnosticsMetrics]:`owner`,[P.serverGetDiagnosticsSnapshot]:`owner`,[P.serverSignalDiagnosticProcess]:`owner`,[P.serverGetResourceTelemetryHistory]:`owner`,[P.serverRetryResourceTelemetry]:`owner`,[P.serverGetSettings]:`viewer`,[P.serverGetStatistics]:`owner`,[P.serverGetUsageSummary]:`owner`,[P.serverInstallOpinionatedPlugin]:`owner`,[P.serverListOpinionatedPlugins]:`owner`,[P.serverSearchAcpRegistry]:`viewer`,[P.serverInstallAcpRegistry]:`owner`,[P.serverGetAcpRegistryAuthMethods]:`owner`,[P.serverAuthenticateAcpRegistry]:`owner`,[P.serverReadCodexResetCredits]:`owner`,[P.serverConsumeCodexResetCredit]:`owner`,[P.serverListLocalTasks]:`owner`,[P.serverGetLocalTask]:`owner`,[P.serverCreateLocalTask]:`owner`,[P.serverUpdateLocalTask]:`owner`,[P.serverDeleteLocalTask]:`owner`,[P.serverDelegateLocalTask]:`owner`,[P.serverGetDailyRecap]:`owner`,[P.notesList]:`viewer`,[P.notesCommand]:`operator`,[P.serverRefreshProviders]:`owner`,[P.serverUpdateProvider]:`owner`,[P.serverUpdateSettings]:`owner`,[P.serverUpsertKeybinding]:`owner`,[P.shellOpenInEditor]:`operator`,[P.sourceControlAddChangeRequestComment]:`operator`,[P.sourceControlAddChangeRequestCommentReaction]:`operator`,[P.sourceControlAddIssueComment]:`operator`,[P.sourceControlAddIssueCommentReaction]:`operator`,[P.sourceControlCloneRepository]:`operator`,[P.sourceControlCreateIssue]:`operator`,[P.sourceControlGetChangeRequestDetail]:`operator`,[P.sourceControlGetChangeRequestFilesViewed]:`operator`,[P.sourceControlSetChangeRequestFileViewed]:`operator`,[P.sourceControlGetChangeRequestDiff]:`operator`,[P.sourceControlGetIssue]:`operator`,[P.sourceControlGetWorkflowJobLog]:`operator`,[P.sourceControlGetWorkflowRunJobs]:`operator`,[P.sourceControlListChangeRequests]:`operator`,[P.sourceControlListIssueAssignees]:`operator`,[P.sourceControlListIssueLabels]:`operator`,[P.sourceControlListIssues]:`operator`,[P.sourceControlListWorkflowRuns]:`operator`,[P.sourceControlLookupRepository]:`operator`,[P.sourceControlMergeChangeRequest]:`operator`,[P.sourceControlPublishRepository]:`operator`,[P.sourceControlRerunWorkflow]:`operator`,[P.sourceControlGetChangeRequestActivity]:`operator`,[P.sourceControlGetChangeRequestFileContents]:`operator`,[P.sourceControlSubmitChangeRequestReview]:`operator`,[P.sourceControlReplyToReviewThread]:`operator`,[P.sourceControlSetReviewThreadResolved]:`operator`,[P.sourceControlUpdateChangeRequestComment]:`operator`,[P.sourceControlUpdateChangeRequest]:`operator`,[P.sourceControlCreateChangeRequest]:`operator`,[P.sourceControlSearchChangeRequests]:`operator`,[P.sourceControlSearchIssues]:`operator`,[P.sourceControlSearchRepositories]:`operator`,[P.subscribeAuthAccess]:`direct_owner`,[P.subscribeServerConfig]:`viewer`,[P.subscribeServerLifecycle]:`viewer`,[P.subscribeTerminalEvents]:`operator`,[P.subscribeVcsStatus]:`operator`,[P.terminalClear]:`operator`,[P.terminalClose]:`operator`,[P.terminalOpen]:`operator`,[P.terminalResize]:`operator`,[P.terminalRestart]:`operator`,[P.terminalWrite]:`operator`,[P.textGenerationAskSideQuestion]:`operator`,[P.textGenerationCancelSideQuestion]:`operator`,[P.textGenerationGenerateBranchName]:`operator`,[P.textGenerationGenerateIssueContent]:`operator`,[P.threadPriorityEnsureCurrent]:`operator`,[P.searchThreadMessages]:`owner`,[P.threadsSetManualBucket]:`operator`,[P.threadsSetManualPosition]:`operator`,[P.vcsCreateRef]:`operator`,[P.vcsCreateWorktree]:`operator`,[P.vcsInit]:`operator`,[P.vcsListRefs]:`operator`,[P.vcsReadLineBlame]:`operator`,[P.vcsReadImageBlob]:`operator`,[P.vcsReadLocalChanges]:`operator`,[P.vcsApplyIndexPatch]:`operator`,[P.vcsReadComparison]:`operator`,[P.vcsPull]:`operator`,[P.vcsRefreshStatus]:`operator`,[P.vcsRemoveWorktree]:`operator`,[P.vcsSwitchRef]:`operator`,[P.workItemsAddComment]:`operator`,[P.workItemsEditComment]:`operator`,[P.workItemsGet]:`viewer`,[P.workItemsList]:`viewer`,[P.workItemsListProjects]:`viewer`,[P.workItemsListTransitions]:`viewer`,[P.workItemsSearch]:`viewer`,[P.workItemsTransition]:`operator`,[P.workItemsUpdate]:`operator`,[P.worktreesSetManualPosition]:`operator`};function Fg(e){if(!Object.hasOwn(Pg,e))throw Error(`RPC method has no explicit access classification.`);return Pg[e]}var Ig={[P.serverGetProjectPreferences]:`read`,[P.storageScan]:`read`,[P.storagePreview]:`read`,[P.storageExecute]:`mutation`,[P.sessionImportSources]:`read`,[P.sessionImportReconcile]:`mutation`,[P.sessionImportAdopt]:`mutation`,[P.sessionImportDiscover]:`read`,[P.sessionImportRun]:`mutation`,[F.automationCentre]:`read`,[F.automationCommand]:`mutation`,[we.read]:`read`,[we.subscribeEvents]:`read`,[we.lifecycle]:`mutation`,[we.input]:`mutation`,[we.app]:`mutation`,[we.recording]:`mutation`,[F.acceptProposal]:`mutation`,[F.getProposal]:`read`,[F.listProposals]:`read`,[F.rejectProposal]:`mutation`,[F.subscribeProposals]:`read`,[F.listIntegrations]:`read`,[F.createIntegration]:`mutation`,[F.updateIntegration]:`mutation`,[F.resumeIntegrationPairing]:`mutation`,[F.revokeIntegration]:`mutation`,[F.deleteIntegration]:`mutation`,[F.listMcpInstallations]:`read`,[F.connectMcpInstallation]:`mutation`,[F.repairMcpInstallation]:`mutation`,[F.disconnectMcpInstallation]:`mutation`,[P.atlassianDisconnect]:`mutation`,[P.atlassianGetProjectLink]:`read`,[P.atlassianListConnections]:`read`,[P.atlassianListResources]:`read`,[P.atlassianRefresh]:`mutation`,[P.atlassianSaveManualBitbucketToken]:`mutation`,[P.atlassianSaveManualJiraToken]:`mutation`,[P.atlassianSaveProjectLink]:`mutation`,[P.atlassianStartOAuth]:`mutation`,[P.chatAttachmentsCreateFileUpload]:`mutation`,[P.chatAttachmentsReadChunk]:`read`,[P.filesystemBrowse]:`read`,[P.gitArchiveWorktree]:`mutation`,[P.gitCreateWorktreeForProject]:`mutation`,[P.gitDeleteWorktree]:`mutation`,[P.lifecycleListWorkspaces]:`read`,[P.lifecyclePreviewWorkspace]:`read`,[P.lifecycleApplyWorkspace]:`mutation`,[P.lifecycleSuggestions]:`read`,[P.lifecycleListTrash]:`read`,[P.gitFindWorktreeForOrigin]:`read`,[P.gitPreparePullRequestThread]:`mutation`,[P.gitResolvePullRequest]:`read`,[P.gitRestoreWorktree]:`mutation`,[P.gitRunStackedAction]:`mutation`,[P.keybindingsReplaceCustom]:`mutation`,[P.mcpListServers]:`read`,[P.mcpListWorkspaces]:`read`,[P.mcpReloadServers]:`mutation`,[P.mcpRemoveServer]:`mutation`,[P.mcpSetServerEnabled]:`mutation`,[P.mcpStartOauthLogin]:`mutation`,[P.mcpUpsertServer]:`mutation`,[N.dispatchCommand]:`receipted`,[N.getFullThreadDiff]:`read`,[N.getTurnDiff]:`read`,[N.getTaskOutput]:`read`,[N.getThreadHistoryPage]:`read`,[N.getThreadWindow]:`read`,[N.getWorkflowScript]:`read`,[N.stopBackgroundTask]:`mutation`,[N.replayEvents]:`read`,[N.replayEventsPage]:`read`,[N.searchThreadMessages]:`read`,[N.subscribeShell]:`read`,[N.subscribeThread]:`read`,[N.subscribeThreadWindow]:`read`,[rt.getInspectionSummary]:`read`,[rt.listInspectionEntries]:`read`,[rt.readRawPayloadChunk]:`read`,[rt.readExportChunk]:`read`,[P.projectsAdd]:`mutation`,[P.projectsInitializeGit]:`mutation`,[P.projectsPromoteChatPreview]:`read`,[P.projectsPromoteChat]:`mutation`,[P.projectsDeleteChatFolder]:`mutation`,[P.projectsList]:`read`,[P.projectsListEntries]:`read`,[P.projectsReadFile]:`read`,[P.projectsReadIcon]:`read`,[P.projectsReadFileBinary]:`read`,[P.projectsRemove]:`mutation`,[P.projectsSearchEntries]:`read`,[P.projectsStageFileReference]:`mutation`,[P.projectsWriteFile]:`mutation`,[P.serverCheckOpinionatedPlugins]:`read`,[P.serverDiscoverSourceControl]:`read`,[P.serverGetAdvertisedEndpoints]:`read`,[P.serverGetConfig]:`read`,[P.serverGetDiagnosticsMetrics]:`read`,[P.serverGetDiagnosticsSnapshot]:`read`,[P.serverSignalDiagnosticProcess]:`mutation`,[P.serverGetResourceTelemetryHistory]:`read`,[P.serverRetryResourceTelemetry]:`mutation`,[P.serverGetSettings]:`read`,[P.serverGetStatistics]:`read`,[P.serverGetUsageSummary]:`read`,[P.serverInstallOpinionatedPlugin]:`mutation`,[P.serverListOpinionatedPlugins]:`read`,[P.serverSearchAcpRegistry]:`read`,[P.serverInstallAcpRegistry]:`mutation`,[P.serverGetAcpRegistryAuthMethods]:`read`,[P.serverAuthenticateAcpRegistry]:`mutation`,[P.serverReadCodexResetCredits]:`read`,[P.serverConsumeCodexResetCredit]:`mutation`,[P.serverListLocalTasks]:`read`,[P.serverGetLocalTask]:`read`,[P.serverCreateLocalTask]:`mutation`,[P.serverUpdateLocalTask]:`mutation`,[P.serverDeleteLocalTask]:`mutation`,[P.serverDelegateLocalTask]:`mutation`,[P.serverGetDailyRecap]:`read`,[P.notesList]:`read`,[P.notesCommand]:`mutation`,[P.serverRefreshProviders]:`read`,[P.serverUpdateProvider]:`mutation`,[P.serverUpdateSettings]:`mutation`,[P.serverUpsertKeybinding]:`mutation`,[P.shellOpenInEditor]:`mutation`,[P.sourceControlAddChangeRequestComment]:`mutation`,[P.sourceControlAddChangeRequestCommentReaction]:`mutation`,[P.sourceControlAddIssueComment]:`mutation`,[P.sourceControlAddIssueCommentReaction]:`mutation`,[P.sourceControlCloneRepository]:`mutation`,[P.sourceControlCreateIssue]:`mutation`,[P.sourceControlGetChangeRequestDetail]:`read`,[P.sourceControlGetChangeRequestFilesViewed]:`read`,[P.sourceControlSetChangeRequestFileViewed]:`mutation`,[P.sourceControlGetChangeRequestDiff]:`read`,[P.sourceControlGetIssue]:`read`,[P.sourceControlGetWorkflowJobLog]:`read`,[P.sourceControlGetWorkflowRunJobs]:`read`,[P.sourceControlListChangeRequests]:`read`,[P.sourceControlListIssueAssignees]:`read`,[P.sourceControlListIssueLabels]:`read`,[P.sourceControlListIssues]:`read`,[P.sourceControlListWorkflowRuns]:`read`,[P.sourceControlLookupRepository]:`read`,[P.sourceControlMergeChangeRequest]:`mutation`,[P.sourceControlPublishRepository]:`mutation`,[P.sourceControlRerunWorkflow]:`mutation`,[P.sourceControlGetChangeRequestActivity]:`read`,[P.sourceControlGetChangeRequestFileContents]:`read`,[P.sourceControlSubmitChangeRequestReview]:`mutation`,[P.sourceControlReplyToReviewThread]:`mutation`,[P.sourceControlSetReviewThreadResolved]:`mutation`,[P.sourceControlUpdateChangeRequestComment]:`mutation`,[P.sourceControlUpdateChangeRequest]:`mutation`,[P.sourceControlCreateChangeRequest]:`mutation`,[P.sourceControlSearchChangeRequests]:`read`,[P.sourceControlSearchIssues]:`read`,[P.sourceControlSearchRepositories]:`read`,[P.subscribeAuthAccess]:`read`,[P.subscribeServerConfig]:`read`,[P.subscribeServerLifecycle]:`read`,[P.subscribeTerminalEvents]:`read`,[P.subscribeVcsStatus]:`read`,[P.terminalClear]:`mutation`,[P.terminalClose]:`mutation`,[P.terminalOpen]:`mutation`,[P.terminalResize]:`mutation`,[P.terminalRestart]:`mutation`,[P.terminalWrite]:`mutation`,[P.textGenerationAskSideQuestion]:`mutation`,[P.textGenerationCancelSideQuestion]:`mutation`,[P.textGenerationGenerateBranchName]:`read`,[P.textGenerationGenerateIssueContent]:`read`,[P.threadPriorityEnsureCurrent]:`read`,[P.searchThreadMessages]:`read`,[P.threadsSetManualBucket]:`mutation`,[P.threadsSetManualPosition]:`mutation`,[P.vcsCreateRef]:`mutation`,[P.vcsCreateWorktree]:`mutation`,[P.vcsInit]:`mutation`,[P.vcsListRefs]:`read`,[P.vcsReadLineBlame]:`read`,[P.vcsReadImageBlob]:`read`,[P.vcsReadLocalChanges]:`read`,[P.vcsApplyIndexPatch]:`mutation`,[P.vcsReadComparison]:`read`,[P.vcsPull]:`mutation`,[P.vcsRefreshStatus]:`read`,[P.vcsRemoveWorktree]:`mutation`,[P.vcsSwitchRef]:`mutation`,[P.workItemsAddComment]:`mutation`,[P.workItemsEditComment]:`mutation`,[P.workItemsGet]:`read`,[P.workItemsList]:`read`,[P.workItemsListProjects]:`read`,[P.workItemsListTransitions]:`read`,[P.workItemsSearch]:`read`,[P.workItemsTransition]:`mutation`,[P.workItemsUpdate]:`mutation`,[P.worktreesSetManualPosition]:`mutation`};function Lg(e){return Object.hasOwn(Ig,e)?Ig[e]:`mutation`}var Rg={viewer:1,operator:2,owner:3};function zg(e,t,n=!0){if(!e||!n)return!1;let r=Fg(t);return r===`authenticated`||r===`direct_owner`?!1:Rg[e]>=Rg[r]}function Bg(e,t){return e.sessionStatus===`ready`||e.sessionStatus===`delivery-unknown`&&e.sessionRecoveredAfterUnknown&&Lg(t)===`read`}function Vg(e){return e.hosted?!e.fresh||e.browserCurrent===!1||e.sessionReady===!1?{hosted:!0,allowed:!1,reason:`This action is unavailable while Hub authorization or the relay is stale.`}:zg(e.role,e.method,!0)?{hosted:!0,allowed:!0,reason:null}:{hosted:!0,allowed:!1,reason:`This action is unavailable for your role on the selected node.`}:{hosted:!1,allowed:!0,reason:null}}function Hg(e){return{environmentId:e.environmentId,label:e.label,platform:{os:e.platformOs,arch:e.platformArch},serverVersion:e.clientVersion,capabilities:{repositoryIdentity:!1,threadSettlement:!1,threadPriorityRanking:!1}}}function Ug(e){J().nodeLifecycle.clearNodeScopedState(e)}var Wg=null,Gg=!1,Kg=Promise.resolve();function qg(e){let t=Kg.catch(()=>void 0).then(e);return Kg=t.catch(()=>void 0),t}async function Jg(e){let t=J().nodeLifecycle;J().resetRelayAttemptFactory(),Yp().end(e),await t.disconnectPrimaryEnvironment(),Ug(e),t.writePrimaryEnvironmentDescriptor(null),Wg===e&&(Wg=null),Gg=!1}async function Yg(e){await qg(async()=>{await Jg(Wg??e)})}async function Xg(e){await qg(async()=>{(Wg??e)!==e||Gg||(Gg=!0,J().resetRelayAttemptFactory(),await J().nodeLifecycle.disconnectPrimaryEnvironment())})}async function Zg(e,t,n){await qg(async()=>{if(n?.aborted)return;let r=Wg??t;if(r===e.environmentId){if(Gg||(J().resetRelayAttemptFactory(),await J().nodeLifecycle.disconnectPrimaryEnvironment()),n?.aborted)return}else if(r&&(await Jg(r),n?.aborted))return;let i=J().nodeLifecycle;i.writePrimaryEnvironmentDescriptor(Hg(e)),i.setActiveEnvironmentId(e.environmentId),Wg=e.environmentId,Gg=!1,i.connectPrimaryEnvironment()})}var Qg={bootstrapAvailable:!1,accountStatus:`signed-out`,account:null,session:null,directoryStatus:`idle`,nodes:[],selectedNode:null,selectionStatus:`none`,effectiveRole:null,transportStatus:`idle`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,browserStatus:`current`,recoveryCodes:[],totpEnrollment:null,errorMessage:null,errorReason:null,accessRecoveryPending:!1,generation:0},$g={externalIdentityConfiguration:null,externalIdentityConfigurationStatus:`idle`,passkeys:[],passkeysStatus:`idle`,e2eeDevices:[],e2eeDevicesStatus:`idle`,security:null,securityStatus:`idle`,actionStatus:`idle`,errorMessage:null,errorCode:null,errorCodeInferred:!1};function e_(e){let t=e,n=new Set,r=()=>n.forEach(e=>e());return{getState:()=>t,getInitialState:()=>e,setState:(e,n=!1)=>{t=n?e:{...t,...e},r()},subscribe:e=>(n.add(e),()=>n.delete(e))}}var Z=e_(Qg),t_=e_($g),n_=e_({leased:!1});function Q(e){let t=Object.prototype.hasOwnProperty.call(e,`errorMessage`)&&!Object.prototype.hasOwnProperty.call(e,`errorReason`);Z.setState(t?{...e,errorReason:null}:e)}function $(e){t_.setState(e)}function r_(e){return e instanceof K?e.message:e instanceof gf?e.code===`cancelled`||e.code===`superseded`?``:e.message:typeof e==`object`&&e&&`name`in e&&e.name===`NotAllowedError`?`The passkey request was cancelled or denied.`:typeof e==`object`&&e&&`name`in e&&e.name===`AbortError`?``:`Hub is temporarily unavailable.`}function i_(e){return{errorMessage:r_(e)||null,errorReason:e instanceof K?e.reason:null}}function a_(e){let t=r_(e)||null;return e instanceof K?{errorMessage:t,errorCode:e.code,errorCodeInferred:e.inferred}:{errorMessage:t,errorCode:null,errorCodeInferred:!1}}function o_(e){return{errorMessage:e,errorCode:null,errorCodeInferred:!1}}var s_={errorMessage:null,errorCode:null,errorCodeInferred:!1};function c_(e,t){return t instanceof K?{status:`refused`,reason:e,errorCode:t.code,wireErrorCode:t.wireCode,inferredErrorCode:t.inferred,errorMessage:t.message||null}:{status:`refused`,reason:e,errorCode:null,wireErrorCode:null,inferredErrorCode:!1,errorMessage:t===void 0?null:r_(t)||null}}function l_(e,t){return{status:`refused`,reason:e,errorCode:null,wireErrorCode:null,inferredErrorCode:!1,errorMessage:t}}function u_(e){return e instanceof K&&e.code!==`invalid_response`&&(e.status===401||e.code===`session_invalid`)}function d_(e){return!(e instanceof K)||e.code===`invalid_response`||e.status===0||e.status===408||e.status===429||e.status>=500}function f_(e){return e===`authenticated`||e===`unavailable`}function p_(e){return e.accountStatus===`unavailable`||e.accountStatus===`authenticated`&&e.browserStatus===`stale`}function m_(){let e=0;return{bump:()=>{e+=1},issue:()=>{let t=e;return()=>t===e}}}var h_=2e4,g_=12e4,__=5e3,v_=6e4,y_=3e4,b_=`Ryco state could not be synchronized.`,x_=`Another account change is still in progress.`,S_=`Sign in to change your account settings.`,C_=`The passkey could not be confirmed. Check your passkeys before relying on it.`,w_=`Your recovery codes were replaced but could not be shown. Your previous codes no longer work — generate a new set and save them.`,T_=`Two-factor setup started but its key could not be shown. Remove two-factor authentication and set it up again.`,E_=class{#e=null;#t=null;#n=null;#r=null;#i=0;#a=new Map;#o=null;#s=null;#c=null;#l=null;#u=null;#d=null;#f=null;#p=null;#m=null;#h=0;#g=new Zp({random:()=>Math.random()});#_=null;#v=null;#y=m_();#b=m_();#x=new Set;#S=!1;#C=null;#w=null;#T=null;#E=null;#D=null;#O=null;#k=null;#A=null;#j=0;#M=null;bootstrap(){if(this.#c)return this.#c;let e=this.#$(),t=this.#N(e).finally(()=>{this.#e===e&&(this.#e=null),this.#c===t&&(this.#c=null)});return this.#c=t,t}adoptSessionCredential(e){let t=this.#$();this.#g.reset();let n=!1,r=e().catch(()=>!1).then(e=>{if(n=e,!t.signal.aborted)return this.#N(t)}).finally(()=>{this.#e===t&&(this.#e=null),this.#c===r&&(this.#c=null)});return this.#c=r,r.then(()=>n)}async signInWithRecoveryCode(e){let t=null;if(!await this.adoptSessionCredential(async()=>{try{return await Y().signInWithRecoveryCode(e),!0}catch(e){return t=e,!1}}))throw t}#N(e){return Y().restoreSession(e.signal).then(async t=>{e.signal.aborted||(this.#re(),Q({accountStatus:`authenticated`,account:t.account,session:t.session,errorMessage:null}),await this.refreshDirectory())}).catch(t=>{if(e.signal.aborted)return;if(u_(t))return Y().clearSessionMaterial(),Y().getBootstrapAvailability(e.signal).catch(()=>!1).then(t=>{e.signal.aborted||Q({...Qg,bootstrapAvailable:t})});let n=this.#ee(t);Q({...Qg,accountStatus:`unavailable`,...i_(t),accessRecoveryPending:n})})}recoverAfterConnectivity(){let e=Z.getState();return e.accountStatus===`unavailable`?this.bootstrap():e.accountStatus===`authenticated`?e.directoryStatus===`ready`&&(e.browserStatus===`current`||e.browserStatus===`synchronizing`)&&(e.selectedNode===null||e.selectedNode.presence.online&&e.transportStatus!==`idle`&&e.transportStatus!==`reconnecting`&&e.transportStatus!==`draining`&&e.transportStatus!==`terminal-failure`&&(e.sessionStatus===`ready`||e.sessionStatus===`synchronizing`))?Promise.resolve():this.resumeBrowser():Promise.resolve()}async signIn(){let e=this.#$();Q({accountStatus:`authenticating`,errorMessage:null,recoveryCodes:[],totpEnrollment:null});try{let t=await Y().signIn(e.signal);this.#re(),Q({accountStatus:`authenticated`,account:t.account,session:t.session}),await this.refreshDirectory()}catch(t){if(e.signal.aborted)return;Q({accountStatus:`signed-out`,...i_(t)})}finally{this.#e===e&&(this.#e=null)}}async signInWithExternalProvider(e){let t=this.#$();Q({accountStatus:`authenticating`,errorMessage:null,recoveryCodes:[],totpEnrollment:null});try{let n=await Y().signInWithExternalProvider(e,t.signal);this.#re(),Q({accountStatus:`authenticated`,account:n.account,session:n.session}),await this.refreshDirectory()}catch(e){if(t.signal.aborted)return;Q({accountStatus:`signed-out`,...i_(e)})}finally{this.#e===t&&(this.#e=null)}}async redeemInvitation(e){return this.#P(t=>Y().redeemInvitation(e,t))}async bootstrapOwner(e){return this.#P(t=>Y().bootstrapOwner(e,t))}async adoptPublicBrowserIdentity(e,t=[]){this.#e?.abort(),this.#e=null,this.#y.bump(),this.#b.bump(),this.#re(),Q({accountStatus:`authenticated`,account:{id:e.account.id,displayName:e.account.displayName,role:e.activeSpace.role,createdAt:e.account.createdAt,disabledAt:e.account.disabledAt},session:{id:e.session.id,accountId:e.session.accountId,activeSpaceId:e.session.activeSpaceId,createdAt:e.session.createdAt,expiresAt:e.session.expiresAt,lastSeenAt:e.session.lastSeenAt,revokedAt:e.session.revokedAt,revocationReasonCode:e.session.revocationReasonCode},recoveryCodes:[...t],totpEnrollment:null,bootstrapAvailable:!1,errorMessage:null}),await this.refreshDirectory()}async#P(e){let t=this.#$();Q({accountStatus:`authenticating`,errorMessage:null,recoveryCodes:[],totpEnrollment:null});try{let n=await e(t.signal);this.#re(),Q({accountStatus:`authenticated`,account:n.account,session:n.session,recoveryCodes:n.recoveryCodes??[],bootstrapAvailable:!1}),await this.refreshDirectory()}catch(e){if(t.signal.aborted)return;Q({accountStatus:`signed-out`,...i_(e)})}finally{this.#e===t&&(this.#e=null)}}cancelAuthentication(){this.#e?.abort(),this.#e=null,this.#y.bump(),this.#b.bump(),Q({accountStatus:`signed-out`,errorMessage:null,recoveryCodes:[],totpEnrollment:null})}leaseRecoveryCodeDisplay(){let e=Symbol(`hosted-recovery-code-display-lease`);return this.#x.add(e),this.#F(),()=>{this.#x.delete(e)&&this.#I()}}#F(){let e=this.#x.size>0;n_.getState().leased!==e&&n_.setState({leased:e})}#I(){this.#S||(this.#S=!0,Promise.resolve().then(()=>{this.#S=!1,this.#F()}))}dismissRecoveryCodes(){Q({recoveryCodes:[]})}dismissTotpEnrollment(){this.#y.bump(),Q({totpEnrollment:null})}invalidateNativeE2eeAuthorization(){let e=Z.getState();e.accountStatus===`authenticated`&&(J().resetRelayAttemptFactory(),Q({generation:e.generation+1,effectiveRole:null,transportStatus:`reconnecting`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1}))}refreshPasskeys(e){let t=e?.force===!0;if(this.#w&&!t)return this.#w;let n=Z.getState();if(n.accountStatus!==`authenticated`)return Promise.resolve();t&&(this.#C?.abort(),this.#w=null);let r=new AbortController;this.#C=r;let i=this.#L(r,n.session?.id??null).finally(()=>{this.#C===r&&(this.#C=null),this.#w===i&&(this.#w=null)});return this.#w=i,t_.getState().passkeys.length===0&&$({passkeysStatus:`loading`}),i}async#L(e,t){try{let n=await Y().listPasskeys(e.signal);if(e.signal.aborted)return;if(!this.#K(e.signal,t)){this.#z();return}$({passkeys:n,passkeysStatus:`ready`,...s_})}catch(n){if(e.signal.aborted)return;if(u_(n)){await this.#R(n);return}if(!this.#K(e.signal,t)){this.#z();return}$({passkeysStatus:`stale`,...a_(n)})}}async#R(e){await this.expireSession(e).catch(()=>void 0)}#z(){$({passkeys:[],passkeysStatus:`idle`})}refreshE2eeDevices(e){let t=e?.force===!0;if(this.#E&&!t)return this.#E;let n=Z.getState();if(n.accountStatus!==`authenticated`)return Promise.resolve();t&&(this.#T?.abort(),this.#E=null);let r=new AbortController;this.#T=r;let i=this.#B(r,n.session?.id??null).finally(()=>{this.#T===r&&(this.#T=null),this.#E===i&&(this.#E=null)});return this.#E=i,(t_.getState().e2eeDevices?.length??0)===0&&$({e2eeDevicesStatus:`loading`}),i}async#B(e,t){try{let n=await Y().listE2eeDevices(e.signal);if(e.signal.aborted)return;if(!this.#K(e.signal,t)){this.#V();return}$({e2eeDevices:n,e2eeDevicesStatus:`ready`,...s_})}catch(n){if(e.signal.aborted)return;if(u_(n)){await this.#R(n);return}if(!this.#K(e.signal,t)){this.#V();return}$({e2eeDevicesStatus:`stale`,...a_(n)})}}#V(){$({e2eeDevices:[],e2eeDevicesStatus:`idle`})}refreshExternalIdentityConfiguration(e){let t=e?.force===!0;if(this.#A&&!t)return this.#A;t&&(this.#k?.abort(),this.#A=null);let n=this.#j,r=new AbortController;this.#k=r,t_.getState().externalIdentityConfiguration===null&&$({externalIdentityConfigurationStatus:`loading`});let i=Y().getExternalIdentityConfiguration(r.signal).then(e=>{r.signal.aborted||n!==this.#j||$({externalIdentityConfiguration:e,externalIdentityConfigurationStatus:`ready`})}).catch(()=>{r.signal.aborted||n!==this.#j||$({externalIdentityConfigurationStatus:`stale`})}).finally(()=>{this.#k===r&&(this.#k=null),this.#A===i&&(this.#A=null)});return this.#A=i,i}refreshAccountSecurity(e){let t=e?.force===!0;if(this.#O&&!t)return this.#O;let n=Z.getState();if(n.accountStatus!==`authenticated`)return Promise.resolve();t&&(this.#D?.abort(),this.#O=null);let r=new AbortController;this.#D=r;let i=this.#H(r,n.session?.id??null).finally(()=>{this.#D===r&&(this.#D=null),this.#O===i&&(this.#O=null)});return this.#O=i,t_.getState().security===null&&$({securityStatus:`loading`}),i}async#H(e,t){try{let n=await Y().getAccountSecurity(e.signal);if(e.signal.aborted)return;if(!this.#K(e.signal,t)){this.#U();return}$({security:n,securityStatus:`ready`})}catch(n){if(e.signal.aborted)return;if(u_(n)){await this.#R(n);return}if(!this.#K(e.signal,t)){this.#U();return}$({securityStatus:`stale`})}}#U(){$({security:null,securityStatus:`idle`})}async addPasskey(e){let t={result:null},n=t_.getState().passkeys.length,r=await this.#G(`adding-passkey`,async n=>{let r=await Y().addPasskey(e,n);return()=>{t.result=r}});if(r.status!==`committed`)return r;let i=t.result?.passkey??null;await this.refreshPasskeys({force:!0});let a=t_.getState();return a.passkeysStatus===`ready`?(i?a.passkeys.some(e=>e.id===i.id):a.passkeys.length>n)?{status:`committed`,confirmation:`confirmed`,passkey:i}:($(o_(C_)),{status:`committed`,confirmation:`missing`,passkey:i}):{status:`committed`,confirmation:`unverified`,passkey:i}}async regenerateRecoveryCodes(e){let t=this.#b.issue(),n=this.#x.size>0,r=!1,i=!1,a=await this.#G(`regenerating-recovery-codes`,async a=>{let o=await Y().regenerateRecoveryCodes(e,a);return r=!0,()=>{n&&t()&&(i=!0,Q({recoveryCodes:o}))}},`account`);return r&&!i&&this.#W(w_),a.status===`committed`?{status:`committed`,displayed:i}:a}#W(e){Z.getState().accountStatus===`authenticated`&&$(o_(e))}async revokePasskey(e){let t=await this.#G(`revoking-passkey`,async t=>(await Y().revokePasskey(e,t),()=>void 0));return t.status===`committed`&&await this.refreshPasskeys({force:!0}),t}async renameE2eeDevice(e,t){let n=await this.#G(`renaming-e2ee-device`,async n=>(await Y().renameE2eeDevice(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshE2eeDevices({force:!0}),n}async revokeE2eeDevice(e,t){let n=await this.#G(`revoking-e2ee-device`,async n=>(await Y().revokeE2eeDevice(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshE2eeDevices({force:!0}),n}async setPassword(e){let t=await this.#G(`setting-password`,async t=>(await Y().setPassword(e,t),()=>void 0));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async removePassword(e){let t=await this.#G(`removing-password`,async t=>(await Y().removePassword(e,t),()=>void 0));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async beginTotpEnrollment(){let e=this.#y.issue(),t=!1,n=!1,r=await this.#G(`enrolling-totp`,async r=>{let i=await Y().beginTotpEnrollment(r);return t=!0,()=>{e()&&(n=!0,Q({totpEnrollment:i}))}},`account`);return t&&!n&&this.#W(T_),r.status===`committed`?{status:`committed`,displayed:n}:r}async confirmTotpEnrollment(e){let t=await this.#G(`confirming-totp`,async t=>(await Y().confirmTotpEnrollment(e,t),()=>{this.#y.bump(),Q({totpEnrollment:null})}));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async revokeTotp(e){let t=await this.#G(`revoking-totp`,async t=>(await Y().revokeTotp(e,t),()=>{this.#y.bump(),Q({totpEnrollment:null})}));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async requestEmailVerification(e){let t=await this.#G(`requesting-email-verification`,async t=>(await Y().requestEmailVerification(e,t),()=>void 0));return t.status===`committed`&&await this.refreshAccountSecurity({force:!0}),t}async connectExternalIdentity(e,t){let n=await this.#G(`connecting-external-identity`,async n=>(await Y().connectExternalIdentity(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshAccountSecurity({force:!0}),n}cancelExternalIdentityConnection(e){this.cancelAccountAction(),Y().cancelExternalIdentityConnection(e)}async finishBrowserExternalIdentityConnection(e,t){let n=await this.#G(`connecting-external-identity`,async n=>(await Y().finishBrowserExternalIdentityConnection(e,t,n),()=>void 0));return n.status===`committed`&&await this.refreshAccountSecurity({force:!0}),n}async disconnectExternalIdentity(e,t){let n=!1,r=await this.#G(`disconnecting-external-identity`,async r=>{let i=await Y().disconnectExternalIdentity(e,t,r);return()=>{n=i.signedOut}});return r.status===`committed`&&(n?await this.clearAccount(`signed-out`):await this.refreshAccountSecurity({force:!0})),r}cancelAccountAction(){this.#M&&(this.#M.abort(),this.#M=null,$({actionStatus:`idle`,...s_}))}async#G(e,t,n=`session`){if(t_.getState().actionStatus!==`idle`)return $(o_(x_)),l_(`busy`,x_);let r=Z.getState();if(r.accountStatus!==`authenticated`)return $(o_(S_)),l_(`signed-out`,S_);let i=r.session?.id??null,a=r.account?.id??null,o=new AbortController;this.#M=o,$({actionStatus:e,...s_});try{let e=await t(o.signal);return(n===`account`?this.#q(o.signal,a):this.#K(o.signal,i))?(e(),$(s_),{status:`committed`}):l_(o.signal.aborted?`cancelled`:`superseded`,null)}catch(e){return o.signal.aborted?l_(`cancelled`,null):u_(e)?(await this.#R(e),c_(`session-expired`,e)):this.#K(o.signal,i)?($(a_(e)),c_(`request-failed`,e)):c_(`superseded`,e)}finally{this.#M===o&&(this.#M=null,t_.getState().actionStatus===e&&$({actionStatus:`idle`}))}}#K(e,t){let n=Z.getState();return!e.aborted&&n.accountStatus===`authenticated`&&(n.session?.id??null)===t}#q(e,t){let n=Z.getState();return!e.aborted&&n.accountStatus===`authenticated`&&(n.account?.id??null)===t}#J(){this.#j+=1,this.#k?.abort(),this.#k=null,this.#A=null,this.#y.bump(),this.#b.bump(),this.#C?.abort(),this.#C=null,this.#w=null,this.#T?.abort(),this.#T=null,this.#E=null,this.#D?.abort(),this.#D=null,this.#O=null,this.#M?.abort(),this.#M=null,t_.setState($g,!0)}resetForTests(){this.#e?.abort(),this.#e=null,this.#ae(),this.#i=0,this.#a.clear(),this.#o?.abort(),this.#o=null,this.#s=null,this.#r=null,this.#c=null,this.#se(),this.#u?.abort(),this.#u=null,this.#d=null,this.#f?.abort(),this.#f=null,this.#p=null,this.#m=null,this.#h+=1,this.#re(),this.#J(),this.#x.clear(),this.#F(),Yp().resetForTests(),Y().clearSessionMaterial(),Z.setState(Qg,!0)}async signOut(){let e=this.#$();Q({accountStatus:`signing-out`,errorMessage:null});try{await Y().signOut(e.signal)}catch{if(e.signal.aborted)return;Y().clearSessionMaterial()}finally{this.#e===e&&(this.#e=null)}await this.clearAccount(`signed-out`)}async expireSession(e){Y().clearSessionMaterial(),await this.clearAccount(`session-expired`),e instanceof K&&e.reason!==null&&Q(i_(e))}suspendBrowser(e){let t=Z.getState();if(t.accountStatus===`authenticated`&&(this.#h+=1,this.#f?.abort(),this.#f=null,this.#p=null,this.#ne(),this.#u?.abort(),this.#se(),this.#ae(),this.#o?.abort(),this.#o=null,this.#s=null,this.#r=null,Q({browserStatus:e===`offline`?`offline`:`suspended`,sessionStatus:t.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,sessionRecoveredAfterUnknown:!1,generation:t.generation+1}),t.selectedNode&&!this.#m)){let e=t.selectedNode.environmentId,n=Xg(e).catch(()=>void 0).finally(()=>{this.#m===n&&(this.#m=null)});this.#m=n}}resumeBrowser(){if(this.#p)return this.#p;let e=new AbortController;this.#f=e;let t=this.#Y(e).finally(()=>{this.#p===t&&(this.#p=null),this.#f===e&&(this.#f=null)});return this.#p=t,t}async#Y(e){let t=Z.getState();if(t.accountStatus!==`authenticated`)return;let n=this.#h+1;this.#h=n;let r=t.account?.id??null;Q({browserStatus:`checking-access`,errorMessage:null});try{let t=await Y().restoreSession(e.signal);if(e.signal.aborted||this.#h!==n)return;if(Z.getState().accountStatus!==`authenticated`||t.account.id!==r){await this.expireSession();return}if(this.#re(),Q({account:t.account,session:t.session}),await this.refreshDirectory(),this.#h!==n)return;let i=Z.getState();if(i.accountStatus!==`authenticated`)return;if(i.directoryStatus!==`ready`){Q({browserStatus:`stale`});return}if(!i.selectedNode){Q({browserStatus:`current`});return}Q({browserStatus:`synchronizing`}),await this.#Q(e.signal)}catch(t){if(e.signal.aborted||this.#h!==n)return;if(u_(t)){await this.expireSession(t);return}let r=this.#ee(t);Q({browserStatus:`stale`,...i_(t),accessRecoveryPending:r})}}async clearAccount(e){this.#h+=1,this.#re(),this.#f?.abort(),this.#f=null,this.#p=null,this.#u?.abort(),this.#u=null,this.#d=null,this.#ae(),this.#se(),this.#o?.abort(),this.#o=null,this.#s=null,this.#r=null,this.#e?.abort(),this.#e=null,this.#c=null,this.#J(),Yp().endAccountSession();let t=Z.getState().selectedNode?.environmentId??null;Q({...Qg,accountStatus:e,generation:Z.getState().generation+1}),t&&await Yg(t)}refreshDirectory(){if(this.#s)return this.#s;let e=new AbortController;this.#o=e;let t=this.#Z(e).finally(()=>{this.#o===e&&(this.#o=null),this.#s===t&&(this.#s=null)});return this.#s=t,t}notifyDirectoryInvalidated(){let e=Z.getState();if(e.accountStatus!==`authenticated`||this.#i>0||e.browserStatus===`offline`||e.browserStatus===`suspended`)return;let t=this.#s;if(!t){this.refreshDirectory();return}if(this.#r===t)return;this.#r=t;let n=e.account?.id,r=e.session?.id;t.then(()=>{if(this.#r!==t)return;this.#r=null;let e=Z.getState();e.accountStatus!==`authenticated`||e.account?.id!==n||e.session?.id!==r||this.#i>0||e.browserStatus===`offline`||e.browserStatus===`suspended`||this.refreshDirectory()})}watchDirectoryPresence(){let e=Symbol(`hosted-directory-presence-watch`),t=this.#X();return this.#a.set(e,J().timers.now()),!t&&this.#t!==null&&this.#i===0&&!J().hasLiveHubSubscription?.()&&this.#ie(__),()=>{this.#a.delete(e)}}#X(){if(this.#a.size===0)return!1;let e=J().timers.now();for(let t of this.#a.values())if(e-t<3e5)return!0;return!1}async#Z(e){let t=Z.getState();if(t.accountStatus!==`authenticated`)return;let n=t.session?.id??null;this.#ae(),Q({directoryStatus:t.nodes.length===0?`loading`:t.directoryStatus});try{let t=await Y().listNodes(e.signal),r=Z.getState();if(e.signal.aborted||r.accountStatus!==`authenticated`||r.session?.id!==n)return;this.#i=0;let i=Z.getState(),a=i.browserStatus===`stale`,o=i.selectedNode,s=o?t.find(e=>e.id===o.id&&e.environmentId===o.environmentId)??null:null;if(o&&(!s||s.revokedAt!==null)){let e=i.generation+1;Q({nodes:t,directoryStatus:`ready`,selectionStatus:s&&s.revokedAt!==null?`revoked`:`authorization-removed`,effectiveRole:null,generation:e}),await this.#le(o.environmentId,e)}else Q({nodes:t,directoryStatus:`ready`,...s?{selectedNode:s,selectionStatus:s.presence.online?`online`:`offline`,effectiveRole:s.effectiveRole}:{}});this.#ie(J().hasLiveHubSubscription?.()?g_:this.#X()?__:h_),a&&J().timers.queueMicrotask(()=>{let e=Z.getState();e.accountStatus===`authenticated`&&e.directoryStatus===`ready`&&e.browserStatus===`stale`&&this.resumeBrowser()})}catch(t){if(e.signal.aborted)return;if(u_(t)){await this.expireSession(t);return}this.#i+=1,Q({directoryStatus:`stale`,effectiveRole:null,...i_(t)});let n=Math.min(v_,1e3*2**Math.min(this.#i,6));this.#ie(n)}}async selectNode(e){let t=Z.getState();if(t.accountStatus!==`authenticated`||t.directoryStatus!==`ready`||t.browserStatus!==`current`&&t.browserStatus!==`synchronizing`)return;let n=t.nodes.find(t=>t.id===e);if(!n||n.revokedAt||t.selectedNode?.id===n.id&&t.selectedNode.environmentId===n.environmentId)return;this.#h+=1,this.#f?.abort(),this.#f=null,this.#p=null,this.#u?.abort(),this.#u=null,this.#d=null;let r=t.generation+1;Q({selectedNode:n,selectionStatus:n.presence.online?`online`:`offline`,effectiveRole:n.effectiveRole,transportStatus:`idle`,sessionStatus:`synchronizing`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,errorMessage:null,generation:r}),this.#oe(r);try{await Zg(n,t.selectedNode?.environmentId??null)}catch{this.#ce(r)}}async returnToDirectory(e){let t=Z.getState(),n=t.selectedNode;if(!n)return;let r=e?.preserveTerminalSelection===!0;this.#h+=1,this.#f?.abort(),this.#f=null,this.#p=null,this.#u?.abort(),this.#u=null,this.#d=null,this.#se();let i=t.browserStatus===`checking-access`;Q({selectedNode:null,selectionStatus:r?t.selectionStatus:`none`,effectiveRole:null,transportStatus:`idle`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,browserStatus:t.browserStatus===`synchronizing`?`current`:i?`stale`:t.browserStatus,errorMessage:r?t.errorMessage:null,errorReason:r?t.errorReason??null:null,generation:t.generation+1}),i&&this.resumeBrowser(),await Yg(n.environmentId)}retrySelectedNode(){if(this.#d)return this.#d;let e=new AbortController;this.#u=e;let t=this.#Q(e.signal).finally(()=>{this.#u===e&&(this.#u=null),this.#d===t&&(this.#d=null)});return this.#d=t,t}async#Q(e){if(e.aborted||(await this.#m,e.aborted))return;let t=Z.getState(),n=t.selectedNode;if(!n||n.revokedAt!==null||t.accountStatus!==`authenticated`||t.directoryStatus!==`ready`||(t=Z.getState(),e.aborted||t.selectedNode?.id!==n.id||t.selectedNode.environmentId!==n.environmentId||t.selectedNode.revokedAt!==null||t.accountStatus!==`authenticated`||t.directoryStatus!==`ready`))return;let r=t.sessionStatus===`delivery-unknown`||J().hasPendingRelayRequests(),i=t.generation+1;this.#se(),Q({selectionStatus:n.presence.online?`online`:`offline`,effectiveRole:n.effectiveRole,transportStatus:`idle`,sessionStatus:r?`delivery-unknown`:`synchronizing`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,errorMessage:null,generation:i}),this.#oe(i);try{await Zg(n,n.environmentId,e)}catch{if(e.aborted)return;this.#ce(i)}}transportStatus(e,t){Z.getState().generation===e&&Q({transportStatus:t})}sessionStatus(e,t){let n=Z.getState();if(n.generation===e){if(n.sessionStatus===`delivery-unknown`&&t!==`closed`){Q({sessionRecoveredAfterUnknown:!1});return}Q({sessionStatus:t,sessionRecoveredAfterUnknown:!1})}}role(e,t){let n=Z.getState();n.generation===e&&Q({effectiveRole:n.directoryStatus===`ready`?t:null})}failure(e,t){let n=Z.getState();if(n.generation!==e)return;let r=t.kind===`revoked`?`revoked`:t.kind===`authorization-removed`?`authorization-removed`:t.kind===`incompatible`?`incompatible`:n.selectedNode?.presence.online?n.selectionStatus:`offline`;t.retryable||this.#se(),Q({selectionStatus:r,effectiveRole:t.retryable?n.effectiveRole:null,transportStatus:t.retryable?`reconnecting`:`terminal-failure`,sessionStatus:n.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,browserStatus:!t.retryable&&n.browserStatus===`synchronizing`?`current`:n.browserStatus,errorMessage:D_(t)})}markDeliveryUnknown(e){Z.getState().generation===e&&Q({sessionStatus:`delivery-unknown`,sessionRecoveredAfterUnknown:!1})}markEnvironmentDeliveryUnknown(e){let t=Z.getState();t.selectedNode?.environmentId===e&&t.sessionStatus!==`delivery-unknown`&&Q({sessionStatus:`delivery-unknown`,sessionRecoveredAfterUnknown:t.sessionStatus===`ready`})}connectionClosed(e){let t=Z.getState();t.generation===e&&t.transportStatus!==`terminal-failure`&&Q({transportStatus:`reconnecting`,sessionStatus:t.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,sessionRecoveredAfterUnknown:!1})}markSessionReady(e){let t=Z.getState();if(t.selectedNode?.environmentId===e){if(this.#se(),t.sessionStatus===`delivery-unknown`){Q({sessionEstablished:!0,sessionRecoveredAfterUnknown:!0,browserStatus:t.browserStatus===`synchronizing`?`current`:t.browserStatus});return}Q({sessionStatus:`ready`,sessionEstablished:!0,sessionRecoveredAfterUnknown:!1,browserStatus:t.browserStatus===`synchronizing`?`current`:t.browserStatus}),Yp().markReady(e)}}markSessionReplaying(e){let t=Z.getState();if(t.selectedNode?.environmentId===e){if(t.sessionStatus===`delivery-unknown`){Q({sessionRecoveredAfterUnknown:!1});return}Q({sessionStatus:`replaying`,browserStatus:t.browserStatus===`current`||t.browserStatus===`synchronizing`?`synchronizing`:t.browserStatus})}}reportShellSnapshotFailure(e){let t=Z.getState();if(t.selectedNode?.environmentId===e){if(t.sessionEstablished){console.warn(`hosted_snapshot_reconciliation_failed`);return}this.#ce(t.generation)}}acknowledgeDeliveryUnknown(){let e=Z.getState();e.sessionStatus===`delivery-unknown`&&e.sessionRecoveredAfterUnknown&&(Q({sessionStatus:`ready`,sessionRecoveredAfterUnknown:!1}),e.selectedNode&&Yp().markReady(e.selectedNode.environmentId))}#$(){this.#e?.abort(),this.#ne();let e=new AbortController;return this.#e=e,e}#ee(e){if(this.#ne(),!d_(e))return!1;let t=this.#g.nextDelay(e instanceof K?e.retryAfterMs:void 0);return this.#_=J().timers.setTimeout(()=>{this.#_=null,this.#te()},t),!0}#te(){if(!p_(Z.getState()))return;let e=J();if(!e.isForeground()){let t=null;t=e.subscribeForeground(()=>{this.#v===t&&(this.#ne(),this.#te())}),this.#v=t;return}this.recoverAfterConnectivity()}#ne(){this.#_&&J().timers.clearTimeout(this.#_),this.#_=null;let e=this.#v;this.#v=null,e?.()}#re(){this.#ne(),this.#g.reset(),Z.getState().accessRecoveryPending&&Q({accessRecoveryPending:!1})}#ie(e){this.#ae();let t=J();if(!t.isForeground()){let e=()=>{t.isForeground()&&(this.#ae(),this.refreshDirectory())};this.#n=t.subscribeForeground(e);return}this.#t=t.timers.setTimeout(()=>void this.refreshDirectory(),e)}#ae(){let e=this.#n;this.#n=null,e?.(),this.#t&&J().timers.clearTimeout(this.#t),this.#t=null}#oe(e){this.#se();let t=Z.getState();t.generation!==e||t.sessionEstablished||(this.#l=J().timers.setTimeout(()=>this.#ce(e),y_))}#se(){this.#l&&J().timers.clearTimeout(this.#l),this.#l=null}#ce(e){let t=Z.getState();t.generation!==e||t.sessionEstablished||(this.#se(),Q({transportStatus:`terminal-failure`,sessionStatus:t.sessionStatus===`delivery-unknown`?`delivery-unknown`:`stale`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1,browserStatus:t.browserStatus===`synchronizing`?`current`:t.browserStatus,errorMessage:b_}))}async#le(e,t){this.#se(),await Yg(e),Z.getState().generation===t&&Q({selectedNode:null,transportStatus:`idle`,sessionStatus:`closed`,sessionEstablished:!1,sessionRecoveredAfterUnknown:!1})}};function D_(e){switch(e.kind){case`offline`:return`The selected node is offline. Ryco will reconnect when it becomes available.`;case`revoked`:return`Access to the selected node was revoked.`;case`authorization-removed`:return`Your authorization for the selected node was removed.`;case`incompatible`:return`The selected node uses an incompatible relay protocol version.`;case`draining`:return`Hub is draining connections. Ryco will retry shortly.`;case`slow-consumer`:return`The relay closed a slow connection. Ryco will reconnect.`;case`authentication`:return`The relay authentication attempt expired or was rejected.`;case`rate-limited`:return`Relay attempts are temporarily rate limited.`;default:return e.retryable?`The relay connection was interrupted. Ryco is reconnecting.`:`The relay connection could not be established.`}}var O_=new E_;function k_(e,t){Z.getState().generation===t&&O_.markSessionReady(e)}function A_(e,t){Z.getState().generation===t&&O_.markSessionReplaying(e)}function j_(e,t){Z.getState().generation===t&&O_.reportShellSnapshotFailure(e)}var M_={idle:`idle`,"requesting-ticket":`requesting ticket`,connecting:`connecting`,authenticating:`authenticating`,"opening-channel":`opening channel`,online:`online`,reconnecting:`Unavailable`,draining:`draining`,"terminal-failure":`terminal failure`},N_={unavailable:`Online`,negotiating:`Securing`,verified:`Encrypted · Verified locally`,"account-trusted":`Encrypted · Account trusted`,unverified:`Not verified`,"web-unsigned":`Encrypted web`,legacy:`Legacy connection`};function P_(e){let{browserStatus:t,sessionStatus:n,selectionStatus:r,transportStatus:i}=e,a=e.e2eeStatus??`unavailable`;return t===`offline`?`Offline`:t===`checking-access`?`Checking access`:t===`synchronizing`?`Synchronizing`:t===`suspended`||t===`stale`?`Stale`:n===`delivery-unknown`?`Delivery unknown`:r===`authorization-removed`?`Authorization removed`:r===`revoked`?`Revoked`:r===`incompatible`?`Incompatible`:e.nativeDeviceSecurityStatus===`revoked`?`Device removed`:e.nativeDeviceSecurityStatus===`securing`?`Securing this device`:e.nativeDeviceSecurityStatus===`unavailable`?`Device encryption unavailable`:i===`online`&&n===`ready`?N_[a]:i===`reconnecting`?`Unavailable`:r===`offline`?`Offline`:M_[i]}var F_={Offline:{shortLabel:`Offline`,connected:!1,guarantee:`none`},"Checking access":{shortLabel:`Checking`,connected:!1,guarantee:`none`},Synchronizing:{shortLabel:`Syncing`,connected:!1,guarantee:`none`},Stale:{shortLabel:`Stale`,connected:!1,guarantee:`none`},"Delivery unknown":{shortLabel:`Unconfirmed`,connected:!1,guarantee:`none`},"Authorization removed":{shortLabel:`No access`,connected:!1,guarantee:`none`},Revoked:{shortLabel:`Revoked`,connected:!1,guarantee:`none`},Incompatible:{shortLabel:`Incompatible`,connected:!1,guarantee:`none`},Online:{shortLabel:`Online`,connected:!0,guarantee:`none`},"Encrypted · Verified locally":{shortLabel:`Verified`,connected:!0,guarantee:`e2ee`},"Encrypted · Account trusted":{shortLabel:`Acct trusted`,connected:!0,guarantee:`account`},"Encrypted web":{shortLabel:`Web E2EE`,connected:!0,guarantee:`web`},"Legacy connection":{shortLabel:`Legacy`,connected:!0,guarantee:`legacy`},"Not verified":{shortLabel:`Not verified`,connected:!1,guarantee:`none`},Securing:{shortLabel:`Securing`,connected:!1,guarantee:`none`},"Securing this device":{shortLabel:`Device setup`,connected:!1,guarantee:`none`},"Device encryption unavailable":{shortLabel:`No E2EE key`,connected:!1,guarantee:`none`},"Device removed":{shortLabel:`Removed`,connected:!1,guarantee:`none`},Unavailable:{shortLabel:`Unavailable`,connected:!1,guarantee:`none`},idle:{shortLabel:`Idle`,connected:!1,guarantee:`none`},"requesting ticket":{shortLabel:`Preparing`,connected:!1,guarantee:`none`},connecting:{shortLabel:`Connecting`,connected:!1,guarantee:`none`},authenticating:{shortLabel:`Verifying`,connected:!1,guarantee:`none`},"opening channel":{shortLabel:`Opening`,connected:!1,guarantee:`none`},online:{shortLabel:`Not ready`,connected:!1,guarantee:`none`},draining:{shortLabel:`Closing`,connected:!1,guarantee:`none`},"terminal failure":{shortLabel:`Failed`,connected:!1,guarantee:`none`}};Object.keys(F_);function I_(e){return F_[P_(e)]}Ct(St),Ct(Lt);export{Yo as $,K as A,Pu as B,Xp as C,J as D,Y as E,uf as F,Ll as G,eu as H,df as I,G as J,Zl as K,$u as L,tp as M,ap as N,Mp as O,Qd as P,Ko as Q,du as R,Zp as S,En as St,Pp as T,tu as U,wu as V,zl as W,Wl as X,Kl as Y,Fo as Z,Ag as _,Ia as _t,t_ as a,Uo as at,Um as b,Dn as bt,n_ as c,Vo as ct,j_ as d,To as dt,Go as et,Bg as f,Po as ft,Ng as g,po as gt,Lg as h,wo as ht,f_ as i,Bo as it,np as j,Op as k,k_ as l,zo as lt,zg as m,No as mt,P_ as n,Jo as nt,O_ as o,Wo as ot,Vg as p,Mo as pt,Nl as q,b_ as r,Xo as rt,Z as s,Ho as st,I_ as t,qo as tt,A_ as u,Ro as ut,mh as v,I as vt,Rp as w,Bm as x,Tn as xt,oh as y,yr as yt,Ru as z};
|