@acedatacloud/nexior 3.362.4 → 3.362.6
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/dist/assets/{ApiCodeButton-BA7mDSbv.js → ApiCodeButton-CE_3dTKv.js} +1 -1
- package/dist/assets/{ApiCodeDialog-BsRU8WFT.js → ApiCodeDialog-DS-qo21c.js} +2 -2
- package/dist/assets/{Artifacts-DJBH37uq.js → Artifacts-9ieQ3Qem.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-DjYhfs68.js → AskUserQuestionCard-BJPTyd6G.js} +1 -1
- package/dist/assets/{AudioPreview-4SXEbJja.js → AudioPreview-B1g4dbrH.js} +1 -1
- package/dist/assets/{Auth-BOif7xOO.js → Auth-DRUyBkIK.js} +1 -1
- package/dist/assets/{Bare-B5Gm4K8P.js → Bare-Bx-zDwLA.js} +1 -1
- package/dist/assets/{BotPlaceholder-C--FHvts.js → BotPlaceholder-BvZp_nGe.js} +1 -1
- package/dist/assets/{BottomFooter-Diy1dxTR.js → BottomFooter-UFm8DUHu.js} +1 -1
- package/dist/assets/{BrowseConnectors-BfZCwj7s.js → BrowseConnectors-Y_9juoXJ.js} +1 -1
- package/dist/assets/{BrowserPairingDialog-CwcFHrVH.js → BrowserPairingDialog-B3Cujdos.js} +1 -1
- package/dist/assets/{Callback-DUubRo9v.js → Callback-B65AaJuR.js} +1 -1
- package/dist/assets/{CodeSnippet-B0neSlgP.js → CodeSnippet-BVSUZgl2.js} +1 -1
- package/dist/assets/ConnectorUtil-CEBYBGCR.js +1 -0
- package/dist/assets/{Console-D8pv2zPD.js → Console-B8JVXKxg.js} +1 -1
- package/dist/assets/ConstantsUtil-CM7Z7qJI.js +884 -0
- package/dist/assets/{Consumption-BK4nImFR.js → Consumption-B8Aoy3S9.js} +1 -1
- package/dist/assets/{Conversation-Cv9VbfEe.js → Conversation-DfcpbC5-.js} +1 -1
- package/dist/assets/{Conversation-BXtScsLN.js → Conversation-DiIcFh0M.js} +1 -1
- package/dist/assets/{CopyToClipboard-AvaqCeXT.js → CopyToClipboard-BWMbyEe8.js} +1 -1
- package/dist/assets/Detail-B2RHER-w.js +2 -0
- package/dist/assets/{Detail-BbDnDZ62.css → Detail-DMI9op2Z.css} +1 -1
- package/dist/assets/Extra-C1xhTX1S.js +1 -0
- package/dist/assets/{FilePreview-BNtZwLa2.js → FilePreview-DJNOTisa.js} +1 -1
- package/dist/assets/{Hailuo-CUHHmlNz.js → Hailuo-eKt1lI2M.js} +1 -1
- package/dist/assets/{History-BrR8Yf_Z.js → History-Cy1EnaCx.js} +1 -1
- package/dist/assets/{ImagePreview-DPhaVe-K.js → ImagePreview-3n2g823_.js} +1 -1
- package/dist/assets/{ImageWrapper-DwDvvMD7.js → ImageWrapper-Zf-ml_fL.js} +1 -1
- package/dist/assets/{Index-BadgGV7L.js → Index--3tUnerd.js} +1 -1
- package/dist/assets/{Index-DlofPOmV.js → Index-0HZhlO5T.js} +1 -1
- package/dist/assets/Index-1R3UjWko.js +1 -0
- package/dist/assets/{Index-ChX8EfQ8.js → Index-B3lcvGOC.js} +1 -1
- package/dist/assets/{Index-B1Kw72wN.js → Index-BB1bDlkg.js} +1 -1
- package/dist/assets/{Index-BgP1xjT5.js → Index-BDP7PGtI.js} +1 -1
- package/dist/assets/{Index-B83b9_wi.js → Index-BFvPdO-u.js} +1 -1
- package/dist/assets/{Index-BmXYFehz.js → Index-BPGjUAl0.js} +1 -1
- package/dist/assets/{Index-CMSWNfN_.js → Index-BbFvn7Z-.js} +1 -1
- package/dist/assets/{Index-BhVRicE6.js → Index-BbwwdeD2.js} +1 -1
- package/dist/assets/{Index-DWCDjaXA.js → Index-Be4NPAQ_.js} +1 -1
- package/dist/assets/{Index-0tDHczbM.js → Index-BhhD5gr9.js} +1 -1
- package/dist/assets/{Index-7fi1vULC2.js → Index-BjL4FbG62.js} +1 -1
- package/dist/assets/{Index-DbsIgIEX.js → Index-C3ikCwp-.js} +1 -1
- package/dist/assets/{Index-D948p6ES.js → Index-CEvPCkn9.js} +1 -1
- package/dist/assets/Index-CJJhQn0t.js +1 -0
- package/dist/assets/{Index-D8Y03OtA.js → Index-CJR760ks.js} +1 -1
- package/dist/assets/{Index-CGEzzwMb.js → Index-CouiG6eX.js} +1 -1
- package/dist/assets/{Index-D-kQkhOh.js → Index-D1QBQi1h.js} +1 -1
- package/dist/assets/{Index-Bm_crXl-.js → Index-D3OXfvMY.js} +1 -1
- package/dist/assets/Index-DAYPwZIs.js +1 -0
- package/dist/assets/Index-DL2EoTNV.js +1 -0
- package/dist/assets/Index-DUdRx1Bc.js +1 -0
- package/dist/assets/{Index-BIccEBEN.js → Index-D_gLtR0N.js} +1 -1
- package/dist/assets/Index-DhsEyroJ.js +1 -0
- package/dist/assets/{Index-DKrXlrk-.js → Index-DkWBqyko.js} +1 -1
- package/dist/assets/Index-DmTr-_VQ.js +1 -0
- package/dist/assets/{Index-CaIBqmIZ.js → Index-Dqxyoetu.js} +1 -1
- package/dist/assets/{Index-OwzwOsGt.js → Index-Eu8X5f3d.js} +1 -1
- package/dist/assets/{Index-DvmQuJd4.js → Index-MTJitVkG.js} +1 -1
- package/dist/assets/{Index-BthkIMLu.js → Index-ib-vKI7O.js} +1 -1
- package/dist/assets/{Index-CMu0wO8E.js → Index-kBhq5F_C.js} +2 -2
- package/dist/assets/Index-nJ3nXUmG.js +1 -0
- package/dist/assets/{Index-CTZWRaZt.js → Index-qY3svjvY.js} +1 -1
- package/dist/assets/{Index-BXnU9Nhc.js → Index-twLqOP1D.js} +2 -2
- package/dist/assets/{Invitees-DL1P2x5O.js → Invitees-BJIrcNI6.js} +1 -1
- package/dist/assets/List-B-N6yusv.js +1 -0
- package/dist/assets/{List-B7gE17Uu.js → List-CZ7l3Wax.js} +1 -1
- package/dist/assets/List-_-dQIH5k.js +1 -0
- package/dist/assets/{LocalTools-Dw-cSEm5.js → LocalTools-CUogyUSK.js} +1 -1
- package/dist/assets/LocalTools-Di2tl3Hu.js +5 -0
- package/dist/assets/{Logo-B5pb3LXw.js → Logo-BBnNBDj-.js} +1 -1
- package/dist/assets/{Main-gugFahba.js → Main-BbG-g4fC.js} +1 -1
- package/dist/assets/{Message-C0-5k24c.js → Message-YmiY6z2o.js} +2 -2
- package/dist/assets/{Model-DSVl1m8-.js → Model-DAH6d39D.js} +1 -1
- package/dist/assets/Navigator-BWwXDF0d.css +1 -0
- package/dist/assets/{Navigator-B-NGLAVz.js → Navigator-CRlUIJeI.js} +4 -4
- package/dist/assets/{NotFound-Bp7eiYNh.js → NotFound-Bv4oqgfG.js} +1 -1
- package/dist/assets/{PageHeader-5PIb-pRr.js → PageHeader-BBHZISMg.js} +1 -1
- package/dist/assets/Pay-MEi3wA51.js +1 -0
- package/dist/assets/{Player-BDjTM_TZ.js → Player-ByUiLBZ1.js} +1 -1
- package/dist/assets/{Poivelle-CATRUvJM.js → Poivelle-CrpCCg_p.js} +1 -1
- package/dist/assets/{RealtimeCall-4hZrsGbX.js → RealtimeCall-BRiInG4T.js} +1 -1
- package/dist/assets/{ReportButton-D07ABYgs.js → ReportButton-DX9HrIMC.js} +1 -1
- package/dist/assets/{ReportDialog-CZ_kBqmh.js → ReportDialog-DA_Yn-7b.js} +1 -1
- package/dist/assets/{ScenarioPaymentMode-DHx-gf_J.js → ScenarioPaymentMode-DyQODbhi.js} +1 -1
- package/dist/assets/{ScheduledTasks-BTdAj5bj.js → ScheduledTasks-C6Uqgv8w.js} +2 -2
- package/dist/assets/{SolanaWalletPickerDialog-Dyf4OrtZ.js → SolanaWalletPickerDialog-ZsnFesYl.js} +1 -1
- package/dist/assets/Status-CtIUekSt.js +1 -0
- package/dist/assets/{Status-7DGGTrl_.css → Status-DWcgs63d.css} +1 -1
- package/dist/assets/{Subscribe-Qqvq4kcb.js → Subscribe-Cu_waTQq.js} +1 -1
- package/dist/assets/{TabSwitcher-SRPkuCQO.js → TabSwitcher-Bx9b8MWc.js} +1 -1
- package/dist/assets/{Tts-CiW_3IBs.js → Tts-CnJ65kmy.js} +1 -1
- package/dist/assets/{VideoPlayer-89YYttvk.js → VideoPlayer-CBlsHZPm.js} +1 -1
- package/dist/assets/{VideoPreview-BlX_PPPl.js → VideoPreview-BqGUxBJp.js} +1 -1
- package/dist/assets/__vite-browser-external-Wme9VPc1.js +1 -0
- package/dist/assets/arrow-down-BwrcDSVc.js +1 -0
- package/dist/assets/{arrow-down-wide-narrow-DaI6Uvy0.js → arrow-down-wide-narrow-btm_oBSR.js} +1 -1
- package/dist/assets/arrow-left-iV7WcLY8.js +1 -0
- package/dist/assets/arrow-right-SxARbRc8.js +1 -0
- package/dist/assets/arrow-up-Bmmr5eqn.js +1 -0
- package/dist/assets/authorizeFlow-Dujmgp0X.js +1 -0
- package/dist/assets/{avatar-C6N1pFHe.js → avatar-Bt5ewMHJ.js} +1 -1
- package/dist/assets/{basic-CPefaDNi.js → basic-CyaHz3wQ.js} +102 -102
- package/dist/assets/{book-open-DAATULmD.js → book-open-CDxQI3yG.js} +1 -1
- package/dist/assets/{box-BShXku0x.js → box-Ru8CN_WA.js} +1 -1
- package/dist/assets/{boxes-OOy_NK7l.js → boxes-foONptLm.js} +1 -1
- package/dist/assets/{brain-Cu-lPJz-.js → brain-BB6Lt1en.js} +1 -1
- package/dist/assets/{chart-no-axes-combined-cFmOkyoL.js → chart-no-axes-combined-BRbG9Cw3.js} +1 -1
- package/dist/assets/{chat-2mnC6M1U.js → chat-9JinPdmu.js} +1 -1
- package/dist/assets/check-D129wUsG.js +1 -0
- package/dist/assets/chevron-down-SmsJAa7D.js +1 -0
- package/dist/assets/chevron-right-CXS1sjHz.js +1 -0
- package/dist/assets/circle-check-CicxfNPX.js +1 -0
- package/dist/assets/{circle-question-mark-ChtLUjT_.js → circle-question-mark-JDwWgK6t.js} +1 -1
- package/dist/assets/{clipboard-list-BYEYDrSf.js → clipboard-list-Bp6XIaej.js} +1 -1
- package/dist/assets/clock-CJP1L4iF.js +1 -0
- package/dist/assets/code-B8mbkWch.js +1 -0
- package/dist/assets/{codingBridge-DSl0gsJ9.js → codingBridge-BorG_XQj.js} +2 -2
- package/dist/assets/codingBridgeNotify-PSvybEiZ.js +2 -0
- package/dist/assets/{coins-DwMmRk4F.js → coins-ze5vlvFY.js} +1 -1
- package/dist/assets/{collapse-GpKda_4j.js → collapse-DuU6GFQ5.js} +1 -1
- package/dist/assets/{common-BKsvEmV6.js → common--c1slE1u.js} +1 -1
- package/dist/assets/{common-BqAdpno_.js → common-1y1xR6Hq.js} +1 -1
- package/dist/assets/{common-0gFKvUbv.js → common-5CGWhWTi.js} +1 -1
- package/dist/assets/{common-37ohr-XT.js → common-BBDXNloB.js} +1 -1
- package/dist/assets/{common-DZSi3Hh_.js → common-BF5e88UD.js} +1 -1
- package/dist/assets/{common-B4An_YTm.js → common-BJk75FxQ.js} +1 -1
- package/dist/assets/{common-xxhDQiia.js → common-BWLoKbl8.js} +1 -1
- package/dist/assets/{common-DUhRMhh_.js → common-Bd6DEYvm.js} +1 -1
- package/dist/assets/{common-DRbsZfM1.js → common-BoO0zCSB.js} +1 -1
- package/dist/assets/{common-jvlgniqw.js → common-C-XfsW3T.js} +1 -1
- package/dist/assets/{common-MsalCK0u.js → common-CJWEoJSY.js} +1 -1
- package/dist/assets/{common-CWaCL-rT.js → common-CJzTDJqS.js} +1 -1
- package/dist/assets/{common-B651gMfj.js → common-DoY46wUe.js} +1 -1
- package/dist/assets/{common-CFrdR7cP.js → common-WBrc34-3.js} +1 -1
- package/dist/assets/{common-CDAa_Wy3.js → common-fo0L07YJ.js} +1 -1
- package/dist/assets/{common-CRdaMls6.js → common-gCVhIaMo.js} +1 -1
- package/dist/assets/{common-OrWJ1sIs.js → common-lwxg-JGj.js} +1 -1
- package/dist/assets/{common-BPYnF8a5.js → common-m8zExVQB.js} +1 -1
- package/dist/assets/{constants-COIxBjYU.js → constants-DB14FZRU.js} +1 -1
- package/dist/assets/{copy-BCep57w1.js → copy-BdCOeTdw.js} +1 -1
- package/dist/assets/{createTaskActions-BXMbF95s.js → createTaskActions-D6qXHcvI.js} +1 -1
- package/dist/assets/{digitalhuman-Bnx1V9mB.js → digitalhuman-CwKgKGbn.js} +1 -1
- package/dist/assets/{dist-BTKWrJnG.js → dist-DQBaVIej.js} +1 -1
- package/dist/assets/{dollar-sign--p8_eDBy.js → dollar-sign-DkOtt1dI.js} +1 -1
- package/dist/assets/{download-Dt0wWdpW.js → download-BI2mDYwL.js} +1 -1
- package/dist/assets/{drawer-BUv2WEZF.js → drawer-LnmmvO3L.js} +1 -1
- package/dist/assets/{dropdown-UTgACN7Q.js → dropdown-BBb4svFZ.js} +1 -1
- package/dist/assets/{dropdown-CBx7fAAp.js → dropdown-CnJ3QdOV.js} +1 -1
- package/dist/assets/{ellipsis-yuDcWrJ4.js → ellipsis-4Z3lDqKY.js} +1 -1
- package/dist/assets/esm-B3VUurFj.js +2 -0
- package/dist/assets/esm-CKnrzlAu.js +1 -0
- package/dist/assets/{esm-Bme5NiGB.js → esm-D-5GXt9s.js} +1 -1
- package/dist/assets/{esm-lz8LG3c9.js → esm-D2u5tK9d.js} +2 -2
- package/dist/assets/{esm-DkEgJOIk.js → esm-Dr_IIEG1.js} +1 -1
- package/dist/assets/{esm--389sWkC.js → esm-H1SE-ruA.js} +1 -1
- package/dist/assets/esm-Og-lQZNt.js +18 -0
- package/dist/assets/{external-link-CYfNxhR8.js → external-link-IrmfutNb.js} +1 -1
- package/dist/assets/{eye-oDfmxiDV.js → eye-tnSE8Qno.js} +1 -1
- package/dist/assets/{file-tjfJc6_R.js → file-e9ByTl0U.js} +1 -1
- package/dist/assets/{file-output-XcBh5O_y.js → file-output-rDweV78w.js} +1 -1
- package/dist/assets/{file-text-DkDLGLgh.js → file-text-Y2G9vk0T.js} +1 -1
- package/dist/assets/{fish-Cx9f10Gm.js → fish-DR2Hlgd-.js} +1 -1
- package/dist/assets/{flux-Bmcbakjy.js → flux-sTLxixZP.js} +1 -1
- package/dist/assets/{folder-DAsfhav6.js → folder-BZzAP02K.js} +1 -1
- package/dist/assets/gauge-DuH-eSYd.js +1 -0
- package/dist/assets/{globe-v5rghgGg.js → globe-YZgVDgdE.js} +1 -1
- package/dist/assets/{grokvideo-C8TWPKxr.js → grokvideo-Dn7GBg1u.js} +1 -1
- package/dist/assets/{pika-CxjINjjD.js → hailuo-DzDrm7SG.js} +1 -1
- package/dist/assets/{headphones-B3pskUHm.js → headphones-mstr7_Lr.js} +1 -1
- package/dist/assets/{history-BZjtFlQ0.js → history-1SsNQiZ6.js} +1 -1
- package/dist/assets/{house-f-R5K_9D.js → house-D6QUY5v4.js} +1 -1
- package/dist/assets/{i18n-DBTdUKZz.js → i18n-xBtzqNWD.js} +1 -1
- package/dist/assets/{image-CR04SjVv.js → image-B4PLmQaF.js} +1 -1
- package/dist/assets/{imageRequests-CLSZhX1d.js → imageRequests-BqaDdLsP.js} +1 -1
- package/dist/assets/index-CcjQxvfb.js +570 -0
- package/dist/assets/index.browser.esm-BbYKZd7a.js +2 -0
- package/dist/assets/{index.es-DB6BDgPr.js → index.es-CNanbZ5D.js} +1 -1
- package/dist/assets/index.es-LzqQdC6F.js +13 -0
- package/dist/assets/{info-zYDWDLVP.js → info-SrHD5DCZ.js} +1 -1
- package/dist/assets/{input-number-B0xcuDnW.js → input-number-DF98nbHf.js} +1 -1
- package/dist/assets/{key-round-BX8FPmcu.js → key-round-C1K7fn2E.js} +1 -1
- package/dist/assets/{kling-tUEGRRxO.js → kling-BXeHpToC.js} +1 -1
- package/dist/assets/{languages-DKKUB3AY.js → languages-B8TIA7Bw.js} +1 -1
- package/dist/assets/{laptop-DSbqbKpY.js → laptop-BOU462cS.js} +1 -1
- package/dist/assets/{lightbulb-NABKBXyu.js → lightbulb-DDWWETX_.js} +1 -1
- package/dist/assets/{link-ByjYUxSr.js → link-BWBJ8c5K.js} +1 -1
- package/dist/assets/loader-circle-BZ57jq7N.js +1 -0
- package/dist/assets/{lock-gJ6pDfMu.js → lock-B1SIzp4d.js} +1 -1
- package/dist/assets/{luma-CfpOdZqb.js → luma-fSxLK8fH.js} +1 -1
- package/dist/assets/{maestro-yRubvEFE.js → maestro-BXindK0f.js} +1 -1
- package/dist/assets/{maestroLanguages-B0F58ijw.js → maestroLanguages-CtrBBaF5.js} +1 -1
- package/dist/assets/{mail-DZpi5J9I.js → mail-BJ1dF_RX.js} +1 -1
- package/dist/assets/{message-circle-D8K26AlF.js → message-circle-KEvtWA2g.js} +1 -1
- package/dist/assets/{mic-DKCR-fiK.js → mic-ZaRjoWSM.js} +1 -1
- package/dist/assets/{midjourney-DM-JhLuX.js → midjourney-t5oJPwWU.js} +1 -1
- package/dist/assets/{minimax-DxlvMTWd.js → minimax-DGMAIlVy.js} +1 -1
- package/dist/assets/{mobileLocalExec-IQ4ZYo9T.js → mobileLocalExec-x8iwdykS.js} +2 -2
- package/dist/assets/{models-DAfyWAqc.js → models-BoFv4bCY.js} +1 -1
- package/dist/assets/{monitor-dn1EyIUV.js → monitor-BX3mTRdr.js} +1 -1
- package/dist/assets/{mouse-pointer-2-C7O4LVbr.js → mouse-pointer-2-ZqhneKIA.js} +1 -1
- package/dist/assets/music-2-C-F9f7u2.js +1 -0
- package/dist/assets/{nanobanana-CxpWeSUn.js → nanobanana-p3gH3Z3F.js} +1 -1
- package/dist/assets/{omni-DxA9Ux8Y.js → omni-CWPmqCiU.js} +1 -1
- package/dist/assets/{openaiimage-DlDGJtH4.js → openaiimage-CkVJ0fOE.js} +1 -1
- package/dist/assets/{pagination-DMwQC4ut.js → pagination-7uZSahOA.js} +1 -1
- package/dist/assets/{pagination-NMff1SYZ.js → pagination-D3ecBdTD.js} +1 -1
- package/dist/assets/{pagination-C5hWM-uh.js → pagination-rZnKw6Dv.js} +1 -1
- package/dist/assets/{palette-CRW1qOCG.js → palette-CTBc55zB.js} +1 -1
- package/dist/assets/{paperclip-HA2RNkmq.js → paperclip-8SUIS4V6.js} +1 -1
- package/dist/assets/{pause-09GpN31S.js → pause-BrUxrvme.js} +1 -1
- package/dist/assets/{pencil-CD6MLBSx.js → pencil-DTlLX3aI.js} +1 -1
- package/dist/assets/{sora-DFX7Ridx.js → pika-D2ELR1BJ.js} +1 -1
- package/dist/assets/{hailuo-C1kObLTr.js → pixverse-YAmSFszN.js} +1 -1
- package/dist/assets/play-C_SfEt6Z.js +1 -0
- package/dist/assets/{plug-D6wUveI9.js → plug-BQgbxZvJ.js} +1 -1
- package/dist/assets/plus-DEuZTkzF.js +1 -0
- package/dist/assets/{poivelle-ChqnXNHp.js → poivelle-CJbGaDtU.js} +1 -1
- package/dist/assets/{popover-8bFfKyEx.js → popover-Cw22vTM3.js} +1 -1
- package/dist/assets/{producer-CZdiq23k.js → producer-BmVHJgip.js} +1 -1
- package/dist/assets/{qrart-T4a6zkdJ.js → qrart-g92I07IG.js} +1 -1
- package/dist/assets/realtime-h2ivlZjk.js +1 -0
- package/dist/assets/{refresh-cw-3eBUX5Ea.js → refresh-cw-DGY8Nssp.js} +1 -1
- package/dist/assets/rotate-ccw-ChqfNZzp.js +1 -0
- package/dist/assets/rotate-cw-BowoSSk7.js +1 -0
- package/dist/assets/{row-BQUMxfsY.js → row-BlMc5HGF.js} +1 -1
- package/dist/assets/search-J1q7Xaee.js +1 -0
- package/dist/assets/secp256k1-xksC0Kmy.js +1 -0
- package/dist/assets/{seedance-DWR0aqWj.js → seedance-DOO9kPWi.js} +1 -1
- package/dist/assets/{seedream-CMXDmAzS.js → seedream-DEg6XNwp.js} +1 -1
- package/dist/assets/{select-C0yzkTif.js → select-BODA2jf6.js} +1 -1
- package/dist/assets/{serp-Dt_PQkXV.js → serp-BtvzKdAE.js} +1 -1
- package/dist/assets/{shield-wdrqyAOI.js → shield-QlgNfgLj.js} +1 -1
- package/dist/assets/{shuffle-Bqjf3c86.js → shuffle-DYCgQitM.js} +1 -1
- package/dist/assets/{slider-BDLlDUDz.js → slider-DkOO6w7v.js} +1 -1
- package/dist/assets/solana-Bn9cyhqr.js +2 -0
- package/dist/assets/solana-wallets-DuUXJVr7.js +2 -0
- package/dist/assets/{solana-wallets-vue-B8MVw466.js → solana-wallets-vue-CvwzSqOW.js} +1 -1
- package/dist/assets/{pixverse-CzR8RnTd.js → sora-C1VhpFhj.js} +1 -1
- package/dist/assets/{sparkles-BoTKvrNO.js → sparkles-B6l3pe4D.js} +1 -1
- package/dist/assets/square-DqvXq--P.js +1 -0
- package/dist/assets/{store-B3O9u73-.js → store-BTMIDGvm.js} +1 -1
- package/dist/assets/{suno-DCe2XW0B.js → suno-Dn9tmBWw.js} +1 -1
- package/dist/assets/{switch-C7dNKdGq.js → switch-DO_m4tjD.js} +1 -1
- package/dist/assets/{table-UhquZYel.js → table-D6bwWTTA.js} +1 -1
- package/dist/assets/{tabs-BwvMWaWZ.js → tabs-CxRafyJg.js} +1 -1
- package/dist/assets/{tag-BJxLMPQ4.js → tag-RZW53z8C.js} +1 -1
- package/dist/assets/terminal-DhTdw-wQ.js +1 -0
- package/dist/assets/{time-picker-DoJ_mwqy.js → time-picker-DoXQpdJv.js} +1 -1
- package/dist/assets/{tooltip-CY9KP5TS.js → tooltip-Ck3eIRCt.js} +1 -1
- package/dist/assets/{trash-2-B1wBangj.js → trash-2-BrR9MfiV.js} +1 -1
- package/dist/assets/{triangle-alert-CAuu6B-W.js → triangle-alert-BOFNM383.js} +1 -1
- package/dist/assets/{upload-D_4LkjOW.js → upload-D5utuckf.js} +1 -1
- package/dist/assets/{upload-D6AM_V-z.js → upload-KvU-H2Pn.js} +1 -1
- package/dist/assets/user-Cse7zZa3.js +1 -0
- package/dist/assets/{veo-W71kXy0Z.js → veo-VkkgFc00.js} +1 -1
- package/dist/assets/{video-DVgqKgsY.js → video-CdClpytA.js} +1 -1
- package/dist/assets/{volume-2-DocaJU2F.js → volume-2-1ocI-qzO.js} +1 -1
- package/dist/assets/{w3m-modal-CcAeUAZf.js → w3m-modal-BXg-8Jr5.js} +26 -26
- package/dist/assets/{wallet-RBRJCWek.js → wallet-DgphXG1K.js} +1 -1
- package/dist/assets/{wan-CgXklc_4.js → wan-Cj2ZSym0.js} +1 -1
- package/dist/assets/{wand-sparkles-CJH0v5L4.js → wand-sparkles-RkL6p2k8.js} +1 -1
- package/dist/assets/{web-nUZelD8c.js → web-BCC6qgJS.js} +1 -1
- package/dist/assets/{web-DRJhyBh_.js → web-B_clN23Y.js} +1 -1
- package/dist/assets/{web-9nZX65Vh.js → web-BkYDAxsa.js} +1 -1
- package/dist/assets/{web-D29bO3g4.js → web-JJHCetdA.js} +1 -1
- package/dist/assets/{web-BjNw9wT3.js → web-WjQTyOKD.js} +1 -1
- package/dist/assets/{webextrator-C1x7ltX3.js → webextrator-CZbaFhxj.js} +1 -1
- package/dist/assets/{wui-text-IdpNh4yv.js → wui-text-Cn4Xd1Sh.js} +1 -1
- package/dist/assets/{zap-Bo8Pzpwk.js → zap-B1VAKgJ8.js} +1 -1
- package/dist/index.html +6 -5
- package/package.json +2 -1
- package/dist/assets/ConnectorUtil-BNHqGaBo.js +0 -1
- package/dist/assets/ConstantsUtil-CiJQ7E9o.js +0 -885
- package/dist/assets/Detail-BynbMCsg.js +0 -2
- package/dist/assets/Extra-Dy27Xepl.js +0 -1
- package/dist/assets/Index-2pUrfZDO.js +0 -1
- package/dist/assets/Index-B2gSKiZ3.js +0 -1
- package/dist/assets/Index-BneErBTq.js +0 -1
- package/dist/assets/Index-CLKH3TKM.js +0 -1
- package/dist/assets/Index-CqRMg-uH.js +0 -1
- package/dist/assets/Index-Crdhl-Vx.js +0 -1
- package/dist/assets/Index-DMQ9DZGa.js +0 -1
- package/dist/assets/Index-DaePlNci.js +0 -1
- package/dist/assets/List-By1Vg7U3.js +0 -1
- package/dist/assets/List-ByRoWUqS.js +0 -1
- package/dist/assets/LocalTools-C0CsQekj.js +0 -5
- package/dist/assets/Navigator-DJAPAK_Y.css +0 -1
- package/dist/assets/Pay-BXFjGCjg.js +0 -1
- package/dist/assets/Status-BAOOm7Y6.js +0 -1
- package/dist/assets/arrow-down-M2F1qebD.js +0 -1
- package/dist/assets/arrow-left-D_2mJNNF.js +0 -1
- package/dist/assets/arrow-right-abRRWNmS.js +0 -1
- package/dist/assets/arrow-up-DMpA1IsJ.js +0 -1
- package/dist/assets/authorizeFlow-CujA2Sko.js +0 -1
- package/dist/assets/check-TtZdHrlm.js +0 -1
- package/dist/assets/chevron-down-DMXTi49q.js +0 -1
- package/dist/assets/chevron-right-DIQNv_0r.js +0 -1
- package/dist/assets/circle-check-DKBPWCH5.js +0 -1
- package/dist/assets/clock-D5NbflY9.js +0 -1
- package/dist/assets/code-wKSqPZcq.js +0 -1
- package/dist/assets/codingBridgeNotify-kOlSTgx4.js +0 -2
- package/dist/assets/esm-BgUDy7vB.js +0 -1
- package/dist/assets/esm-C9MRpvkK.js +0 -28
- package/dist/assets/esm-D4Ha2HnB.js +0 -2
- package/dist/assets/gauge-DP9sk0Fe.js +0 -1
- package/dist/assets/index-CTn7SLTr.js +0 -570
- package/dist/assets/index.browser.esm-BuWinGJ1.js +0 -2
- package/dist/assets/loader-circle-r7o2cOdj.js +0 -1
- package/dist/assets/music-2-UxfKU68J.js +0 -1
- package/dist/assets/play-1r8M6tGa.js +0 -1
- package/dist/assets/plus-Dzhx2WdR.js +0 -1
- package/dist/assets/realtime-C0bVe3k2.js +0 -1
- package/dist/assets/rotate-ccw-DFETd1JJ.js +0 -1
- package/dist/assets/rotate-cw-BLViYEn3.js +0 -1
- package/dist/assets/search-CiYRAPUv.js +0 -1
- package/dist/assets/secp256k1-CBKdYWfq.js +0 -1
- package/dist/assets/solana-CLOcWury.js +0 -2
- package/dist/assets/solana-wallets-C-BcnEbE.js +0 -2
- package/dist/assets/square-B9lxDeHX.js +0 -1
- package/dist/assets/terminal-C5ne2YRf.js +0 -1
- package/dist/assets/user-B3wTOjwB.js +0 -1
- package/dist/assets/utils-CGq_Culp.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime--c01j_DQ.js";import{t as a}from"./__vite-browser-external-Wme9VPc1.js";import{t as o}from"./buffer-CnhyIITQ.js";import{n as s}from"./eventemitter3-CwKRT-4Q.js";var c=o(),l=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function u(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function d(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function f(e,...t){if(!u(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function p(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);d(e.outputLen),d(e.blockLen)}function m(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function h(e,t){f(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function g(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function _(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function v(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function y(e,t){return e<<32-t|e>>>t}var b=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function x(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ee(e){for(let t=0;t<e.length;t++)e[t]=x(e[t]);return e}var S=b?e=>e:ee,C=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,w=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function T(e){if(f(e),C)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=w[e[n]];return t}var E={_0:48,_9:57,A:65,F:70,a:97,f:102};function D(e){if(e>=E._0&&e<=E._9)return e-E._0;if(e>=E.A&&e<=E.F)return e-(E.A-10);if(e>=E.a&&e<=E.f)return e-(E.a-10)}function O(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(C)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`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=D(e.charCodeAt(i)),a=D(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function te(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function ne(e){return typeof e==`string`&&(e=te(e)),f(e),e}function k(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];f(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}var A=class{};function re(e){let t=t=>e().update(ne(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ie(e=32){if(l&&typeof l.getRandomValues==`function`)return l.getRandomValues(new Uint8Array(e));if(l&&typeof l.randomBytes==`function`)return Uint8Array.from(l.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}function ae(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function oe(e,t,n){return e&t^~e&n}function se(e,t,n){return e&t^e&n^t&n}var ce=class extends A{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=v(this.buffer)}update(e){m(this),e=ne(e),f(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=v(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){m(this),h(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,_(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;ae(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=v(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);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}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},le=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),j=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ue=BigInt(2**32-1),de=BigInt(32);function fe(e,t=!1){return t?{h:Number(e&ue),l:Number(e>>de&ue)}:{h:Number(e>>de&ue)|0,l:Number(e&ue)|0}}function pe(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}=fe(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var me=(e,t,n)=>e>>>n,he=(e,t,n)=>e<<32-n|t>>>n,ge=(e,t,n)=>e>>>n|t<<32-n,_e=(e,t,n)=>e<<32-n|t>>>n,ve=(e,t,n)=>e<<64-n|t>>>n-32,ye=(e,t,n)=>e>>>n-32|t<<64-n,be=(e,t,n)=>e<<n|t>>>32-n,xe=(e,t,n)=>t<<n|e>>>32-n,Se=(e,t,n)=>t<<n-32|e>>>64-n,Ce=(e,t,n)=>e<<n-32|t>>>64-n;function M(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var we=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Te=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Ee=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),De=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Oe=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),ke=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,Ae=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]),je=new Uint32Array(64),Me=class extends ce{constructor(e=32){super(64,e,8,!1),this.A=le[0]|0,this.B=le[1]|0,this.C=le[2]|0,this.D=le[3]|0,this.E=le[4]|0,this.F=le[5]|0,this.G=le[6]|0,this.H=le[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}process(e,t){for(let n=0;n<16;n++,t+=4)je[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=je[e-15],n=je[e-2],r=y(t,7)^y(t,18)^t>>>3;je[e]=(y(n,17)^y(n,19)^n>>>10)+je[e-7]+r+je[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=y(o,6)^y(o,11)^y(o,25),u=l+t+oe(o,s,c)+Ae[e]+je[e]|0,d=(y(n,2)^y(n,13)^y(n,22))+se(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(){_(je)}destroy(){this.set(0,0,0,0,0,0,0,0),_(this.buffer)}},Ne=pe(`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))),Pe=Ne[0],Fe=Ne[1],N=new Uint32Array(80),Ie=new Uint32Array(80),Le=class extends ce{constructor(e=64){super(128,e,16,!1),this.Ah=j[0]|0,this.Al=j[1]|0,this.Bh=j[2]|0,this.Bl=j[3]|0,this.Ch=j[4]|0,this.Cl=j[5]|0,this.Dh=j[6]|0,this.Dl=j[7]|0,this.Eh=j[8]|0,this.El=j[9]|0,this.Fh=j[10]|0,this.Fl=j[11]|0,this.Gh=j[12]|0,this.Gl=j[13]|0,this.Hh=j[14]|0,this.Hl=j[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}process(e,t){for(let n=0;n<16;n++,t+=4)N[n]=e.getUint32(t),Ie[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=N[e-15]|0,n=Ie[e-15]|0,r=ge(t,n,1)^ge(t,n,8)^me(t,n,7),i=_e(t,n,1)^_e(t,n,8)^he(t,n,7),a=N[e-2]|0,o=Ie[e-2]|0,s=ge(a,o,19)^ve(a,o,61)^me(a,o,6),c=Ee(i,_e(a,o,19)^ye(a,o,61)^he(a,o,6),Ie[e-7],Ie[e-16]);N[e]=De(c,r,s,N[e-7],N[e-16])|0,Ie[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=ge(u,d,14)^ge(u,d,18)^ve(u,d,41),v=_e(u,d,14)^_e(u,d,18)^ye(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=Oe(_,v,b,Fe[e],Ie[e]),ee=ke(x,g,t,y,Pe[e],N[e]),S=x|0,C=ge(n,r,28)^ve(n,r,34)^ve(n,r,39),w=_e(n,r,28)^ye(n,r,34)^ye(n,r,39),T=n&i^n&o^i&o,E=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}=M(c|0,l|0,ee|0,S|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let D=we(S,w,E);n=Te(D,ee,C,T),r=D|0}({h:n,l:r}=M(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=M(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=M(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=M(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=M(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=M(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=M(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=M(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(){_(N,Ie)}destroy(){_(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Re=re(()=>new Me),ze=re(()=>new Le),Be=BigInt(0),Ve=BigInt(1);function He(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}"`;throw Error(n+`expected boolean, got type=`+typeof e)}return e}function Ue(e,t,n=``){let r=u(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function We(e){let t=e.toString(16);return t.length&1?`0`+t:t}function Ge(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return e===``?Be:BigInt(`0x`+e)}function Ke(e){return Ge(T(e))}function qe(e){return f(e),Ge(T(Uint8Array.from(e).reverse()))}function Je(e,t){return O(e.toString(16).padStart(t*2,`0`))}function Ye(e,t){return Je(e,t).reverse()}function P(e,t,n){let r;if(typeof t==`string`)try{r=O(t)}catch(t){throw Error(e+` must be hex string or Uint8Array, cause: `+t)}else if(u(t))r=Uint8Array.from(t);else throw Error(e+` must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(e+` of length `+n+` expected, got `+i);return r}function Xe(e,t){if(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 Ze(e){return Uint8Array.from(e)}var Qe=e=>typeof e==`bigint`&&Be<=e;function $e(e,t,n){return Qe(e)&&Qe(t)&&Qe(n)&&t<=e&&e<n}function et(e,t,n,r){if(!$e(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function tt(e){let t;for(t=0;e>Be;e>>=Ve,t+=1);return t}var nt=e=>(Ve<<BigInt(e))-Ve;function rt(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e),a=r(e),o=r(e),s=0,c=()=>{a.fill(1),o.fill(0),s=0},l=(...e)=>n(o,a,...e),u=(e=r(0))=>{o=l(i(0),e),a=l(),e.length!==0&&(o=l(i(1),e),a=l())},d=()=>{if(s++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){a=l();let t=a.slice();n.push(t),e+=a.length}return k(...n)};return(e,t)=>{c(),u(e);let n;for(;!(n=t(d()));)u();return c(),n}}function it(e,t,n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}var at=()=>{throw Error(`not implemented`)};function ot(e){let t=new WeakMap;return(n,...r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e(n,...r);return t.set(n,a),a}}var st=BigInt(0),ct=BigInt(1),lt=BigInt(2),ut=BigInt(3),dt=BigInt(4),ft=BigInt(5),pt=BigInt(7),mt=BigInt(8),ht=BigInt(9),gt=BigInt(16);function _t(e,t){let n=e%t;return n>=st?n:t+n}function vt(e,t,n){let r=e;for(;t-- >st;)r*=r,r%=n;return r}function yt(e,t){if(e===st)throw Error(`invert: expected non-zero number`);if(t<=st)throw Error(`invert: expected positive modulus, got `+t);let n=_t(e,t),r=t,i=st,a=ct,o=ct,s=st;for(;n!==st;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==ct)throw Error(`invert: does not exist`);return _t(i,t)}function bt(e,t,n){if(!e.eql(e.sqr(t),n))throw Error(`Cannot find square root`)}function xt(e,t){let n=(e.ORDER+ct)/dt,r=e.pow(t,n);return bt(e,r,t),r}function St(e,t){let n=(e.ORDER-ft)/mt,r=e.mul(t,lt),i=e.pow(r,n),a=e.mul(t,i),o=e.mul(e.mul(a,lt),i),s=e.mul(a,e.sub(o,e.ONE));return bt(e,s,t),s}function Ct(e){let t=Nt(e),n=wt(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+pt)/gt;return(e,t)=>{let n=e.pow(t,o),s=e.mul(n,r),c=e.mul(n,i),l=e.mul(n,a),u=e.eql(e.sqr(s),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,s,u),s=e.cmov(l,c,d);let f=e.eql(e.sqr(s),t),p=e.cmov(n,s,f);return bt(e,p,t),p}}function wt(e){if(e<ut)throw Error(`sqrt is not defined for small field`);let t=e-ct,n=0;for(;t%lt===st;)t/=lt,n++;let r=lt,i=Nt(e);for(;jt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return xt;let a=i.pow(r,t),o=(t+ct)/lt;return function(e,r){if(e.is0(r))return r;if(jt(e,r)!==1)throw Error(`Cannot find square root`);let i=n,s=e.mul(e.ONE,a),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw Error(`Cannot find square root`);let r=ct<<BigInt(i-t-1),a=e.pow(s,r);i=t,s=e.sqr(a),c=e.mul(c,s),l=e.mul(l,a)}return l}}function Tt(e){return e%dt===ut?xt:e%mt===ft?St:e%gt===ht?Ct(e):wt(e)}var Et=(e,t)=>(_t(e,t)&ct)===ct,Dt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Ot(e){return it(e,Dt.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`number`,BITS:`number`})),e}function kt(e,t,n){if(n<st)throw Error(`invalid exponent, negatives unsupported`);if(n===st)return e.ONE;if(n===ct)return t;let r=e.ONE,i=t;for(;n>st;)n&ct&&(r=e.mul(r,i)),i=e.sqr(i),n>>=ct;return r}function At(e,t,n=!1){let r=Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),a=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),a),r}function jt(e,t){let n=(e.ORDER-ct)/lt,r=e.pow(t,n),i=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!i&&!a&&!o)throw Error(`invalid Legendre symbol result`);return i?1:a?0:-1}function Mt(e,t){t!==void 0&&d(t);let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Nt(e,t,n=!1,r={}){if(e<=st)throw Error(`invalid field: expected ORDER > 0, got `+e);let i,a,o=!1,s;if(typeof t==`object`&&t){if(r.sqrt||n)throw Error(`cannot specify opts in two arguments`);let e=t;e.BITS&&(i=e.BITS),e.sqrt&&(a=e.sqrt),typeof e.isLE==`boolean`&&(n=e.isLE),typeof e.modFromBytes==`boolean`&&(o=e.modFromBytes),s=e.allowedLengths}else typeof t==`number`&&(i=t),r.sqrt&&(a=r.sqrt);let{nBitLength:c,nByteLength:l}=Mt(e,i);if(l>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);let u,d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:nt(c),ZERO:st,ONE:ct,allowedLengths:s,create:t=>_t(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`invalid field element: expected bigint, got `+typeof t);return st<=t&&t<e},is0:e=>e===st,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&ct)===ct,neg:t=>_t(-t,e),eql:(e,t)=>e===t,sqr:t=>_t(t*t,e),add:(t,n)=>_t(t+n,e),sub:(t,n)=>_t(t-n,e),mul:(t,n)=>_t(t*n,e),pow:(e,t)=>kt(d,e,t),div:(t,n)=>_t(t*yt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>yt(t,e),sqrt:a||(t=>(u||=Tt(e),u(d,t))),toBytes:e=>n?Ye(e,l):Je(e,l),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>l)throw Error(`Field.fromBytes: expected `+s+` bytes, got `+t.length);let e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw Error(`Field.fromBytes: expected `+l+` bytes, got `+t.length);let i=n?qe(t):Ke(t);if(o&&(i=_t(i,e)),!r&&!d.isValid(i))throw Error(`invalid field element: outside of range 0..ORDER`);return i},invertBatch:e=>At(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function Pt(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function Ft(e){let t=Pt(e);return t+Math.ceil(t/2)}function It(e,t,n=!1){let r=e.length,i=Pt(t),a=Ft(t);if(r<16||r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=_t(n?qe(e):Ke(e),t-ct)+ct;return n?Ye(o,i):Je(o,i)}var Lt=BigInt(0),Rt=BigInt(1);function zt(e,t){let n=t.negate();return e?n:t}function Bt(e,t){let n=At(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Vt(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function Ht(e,t){Vt(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:nt(e),maxNumber:i,shiftBy:BigInt(e)}}function Ut(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=Rt);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}function Wt(e,t){if(!Array.isArray(e))throw Error(`array expected`);e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Gt(e,t){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,n)=>{if(!t.isValid(e))throw Error(`invalid scalar at index `+n)})}var Kt=new WeakMap,qt=new WeakMap;function Jt(e){return qt.get(e)||1}function Yt(e){if(e!==Lt)throw Error(`invalid wNAF`)}var Xt=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Lt;)t&Rt&&(n=n.add(r)),r=r.double(),t>>=Rt;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=Ht(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=Ht(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=Ut(n,e,a);n=o,c?i=i.add(zt(u,t[d])):r=r.add(zt(l,t[s]))}return Yt(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=Ht(e,this.bits);for(let e=0;e<i.windows&&n!==Lt;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=Ut(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return Yt(n),r}getPrecomputes(e,t,n){let r=Kt.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),Kt.set(t,r))),r}cached(e,t,n){let r=Jt(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=Jt(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){Vt(t,this.bits),qt.set(e,t),Kt.delete(e)}hasCache(e){return Jt(e)!==1}};function Zt(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>Lt||r>Lt;)n&Rt&&(a=a.add(i)),r&Rt&&(o=o.add(i)),i=i.double(),n>>=Rt,r>>=Rt;return{p1:a,p2:o}}function Qt(e,t,n,r){Wt(n,e),Gt(r,t);let i=n.length,a=r.length;if(i!==a)throw Error(`arrays of points and scalars must have equal length`);let o=e.ZERO,s=tt(BigInt(i)),c=1;s>12?c=s-3:s>4?c=s-2:s>0&&(c=2);let l=nt(c),u=Array(Number(l)+1).fill(o),d=Math.floor((t.BITS-1)/c)*c,f=o;for(let e=d;e>=0;e-=c){u.fill(o);for(let t=0;t<a;t++){let i=r[t],a=Number(i>>BigInt(e)&l);u[a]=u[a].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(f=f.add(t),e!==0)for(let e=0;e<c;e++)f=f.double()}return f}function $t(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Ot(t),t}else return Nt(e,{isLE:n})}function en(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>Lt))throw Error(`CURVE.${e} must be positive bigint`)}let i=$t(t.p,n.Fp,r),a=$t(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}}var tn=BigInt(0),nn=BigInt(1),rn=BigInt(2),an=BigInt(8);function on(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 sn(e,t={}){let n=en(`edwards`,e,t,t.FpFnLE),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o}=a;it(t,{},{uvRatio:`function`});let s=rn<<BigInt(i.BYTES*8)-nn,c=e=>r.create(e),l=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch{return{isValid:!1,value:tn}}});if(!on(r,a,a.Gx,a.Gy))throw Error(`bad curve params: generator point`);function u(e,t,n=!1){let r=n?nn:tn;return et(`coordinate `+e,t,r,s),t}function d(e){if(!(e instanceof m))throw Error(`ExtendedPoint expected`)}let f=ot((e,t)=>{let{X:n,Y:i,Z:a}=e,o=e.is0();t??=o?an:r.inv(a);let s=c(n*t),l=c(i*t),u=r.mul(a,t);if(o)return{x:tn,y:nn};if(u!==nn)throw Error(`invZ was invalid`);return{x:s,y:l}}),p=ot(e=>{let{a:t,d:n}=a;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:i,Z:o,T:s}=e,l=c(r*r),u=c(i*i),d=c(o*o),f=c(d*d);if(c(d*c(c(l*t)+u))!==c(f+c(n*c(l*u))))throw Error(`bad point: equation left != right (1)`);if(c(r*i)!==c(o*s))throw Error(`bad point: equation left != right (2)`);return!0});class m{constructor(e,t,n,r){this.X=u(`x`,e),this.Y=u(`y`,t),this.Z=u(`z`,n,!0),this.T=u(`t`,r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){if(e instanceof m)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return u(`x`,t),u(`y`,n),new m(t,n,nn,c(t*n))}static fromBytes(e,t=!1){let n=r.BYTES,{a:i,d:o}=a;e=Ze(Ue(e,n,`point`)),He(t,`zip215`);let u=Ze(e),d=e[n-1];u[n-1]=d&-129;let f=qe(u);et(`point.y`,f,tn,t?s:r.ORDER);let p=c(f*f),{isValid:h,value:g}=l(c(p-nn),c(o*p-i));if(!h)throw Error(`bad point: invalid y coordinate`);let _=(g&nn)===nn,v=(d&128)!=0;if(!t&&g===tn&&v)throw Error(`bad point: x=0 and x_0=1`);return v!==_&&(g=c(-g)),m.fromAffine({x:g,y:f})}static fromHex(e,t=!1){return m.fromBytes(P(`point`,e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return h.createCache(this,e),t||this.multiply(rn),this}assertValidity(){p(this)}equals(e){d(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=e,s=c(t*o),l=c(i*r),u=c(n*o),f=c(a*r);return s===l&&u===f}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:e}=a,{X:t,Y:n,Z:r}=this,i=c(t*t),o=c(n*n),s=c(rn*c(r*r)),l=c(e*i),u=t+n,d=c(c(u*u)-i-o),f=l+o,p=f-s,h=l-o,g=c(d*p),_=c(f*h),v=c(d*h);return new m(g,_,c(p*f),v)}add(e){d(e);let{a:t,d:n}=a,{X:r,Y:i,Z:o,T:s}=this,{X:l,Y:u,Z:f,T:p}=e,h=c(r*l),g=c(i*u),_=c(s*n*p),v=c(o*f),y=c((r+i)*(l+u)-h-g),b=v-_,x=v+_,ee=c(g-t*h),S=c(y*b),C=c(x*ee),w=c(y*ee);return new m(S,C,c(b*x),w)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw Error(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=h.cached(this,e,e=>Bt(m,e));return Bt(m,[t,n])[0]}multiplyUnsafe(e,t=m.ZERO){if(!i.isValid(e))throw Error(`invalid scalar: expected 0 <= sc < curve.n`);return e===tn?m.ZERO:this.is0()||e===nn?this:h.unsafe(this,e,e=>Bt(m,e),t)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return h.unsafe(this,a.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return o===nn?this:this.multiplyUnsafe(o)}toBytes(){let{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&nn?128:0,n}toHex(){return T(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return Bt(m,e)}static msm(e,t){return Qt(m,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}m.BASE=new m(a.Gx,a.Gy,nn,c(a.Gx*a.Gy)),m.ZERO=new m(tn,nn,nn,tn),m.Fp=r,m.Fn=i;let h=new Xt(m,i.BITS);return m.BASE.precompute(8),m}var cn=class{constructor(e){this.ep=e}static fromBytes(e){at()}static fromHex(e){at()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return T(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}};function ln(e,t,n={}){if(typeof t!=`function`)throw Error(`"hash" function param is required`);it(n,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,mapToCurve:`function`});let{prehash:r}=n,{BASE:i,Fp:a,Fn:o}=e,s=n.randomBytes||ie,c=n.adjustScalarBytes||(e=>e),l=n.domain||((e,t,n)=>{if(He(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e});function d(e){return o.create(qe(e))}function f(e){let n=b.secretKey;e=P(`private key`,e,n);let r=P(`hashed private key`,t(e),2*n),i=c(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:d(i)}}function p(e){let{head:t,prefix:n,scalar:r}=f(e),a=i.multiply(r);return{head:t,prefix:n,scalar:r,point:a,pointBytes:a.toBytes()}}function m(e){return p(e).pointBytes}function h(e=Uint8Array.of(),...n){return d(t(l(k(...n),P(`context`,e),!!r)))}function g(e,t,n={}){e=P(`message`,e),r&&(e=r(e));let{prefix:a,scalar:s,pointBytes:c}=p(t),l=h(n.context,a,e),u=i.multiply(l).toBytes(),d=h(n.context,u,c,e),f=o.create(l+d*s);if(!o.isValid(f))throw Error(`sign failed: invalid s`);return Ue(k(u,o.toBytes(f)),b.signature,`result`)}let _={zip215:!0};function v(t,n,a,o=_){let{context:s,zip215:c}=o,l=b.signature;t=P(`signature`,t,l),n=P(`message`,n),a=P(`publicKey`,a,b.publicKey),c!==void 0&&He(c,`zip215`),r&&(n=r(n));let u=l/2,d=t.subarray(0,u),f=qe(t.subarray(u,l)),p,m,g;try{p=e.fromBytes(a,c),m=e.fromBytes(d,c),g=i.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let v=h(s,m.toBytes(),p.toBytes(),n);return m.add(p.multiplyUnsafe(v)).subtract(g).clearCofactor().is0()}let y=a.BYTES,b={secretKey:y,publicKey:y,signature:2*y,seed:y};function x(e=s(b.seed)){return Ue(e,b.seed,`seed`)}function ee(e){let t=w.randomSecretKey(e);return{secretKey:t,publicKey:m(t)}}function S(e){return u(e)&&e.length===o.BYTES}function C(t,n){try{return!!e.fromBytes(t,n)}catch{return!1}}let w={getExtendedPublicKey:p,randomSecretKey:x,isValidSecretKey:S,isValidPublicKey:C,toMontgomery(t){let{y:n}=e.fromBytes(t),r=b.publicKey,i=r===32;if(!i&&r!==57)throw Error(`only defined for 25519 and 448`);let o=i?a.div(nn+n,nn-n):a.div(n-nn,n+nn);return a.toBytes(o)},toMontgomerySecret(e){let n=b.secretKey;return Ue(e,n),c(t(e.subarray(0,n))).subarray(0,n)},randomPrivateKey:x,precompute(t=8,n=e.BASE){return n.precompute(t,!1)}};return Object.freeze({keygen:ee,getPublicKey:m,sign:g,verify:v,utils:w,Point:e,lengths:b})}function un(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:Nt(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}function dn(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function fn(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=un(e);return dn(e,ln(sn(t,n),r,i))}var pn=BigInt(0),mn=BigInt(1),hn=BigInt(2),gn=BigInt(5),_n=BigInt(8),vn=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),yn={p:vn,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:_n,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function bn(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=vn,o=e*e%a*e%a,s=vt(vt(o,hn,a)*o%a,mn,a)*e%a,c=vt(s,gn,a)*s%a,l=vt(c,t,a)*c%a,u=vt(l,n,a)*l%a,d=vt(u,r,a)*u%a;return{pow_p_5_8:vt(vt(vt(vt(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,hn,a)*e%a,b2:o}}function xn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Sn=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function Cn(e,t){let n=vn,r=_t(t*t*t,n),i=bn(e*_t(r*r*t,n)).pow_p_5_8,a=_t(e*r*i,n),o=_t(t*a*a,n),s=a,c=_t(a*Sn,n),l=o===e,u=o===_t(-e,n),d=o===_t(-e*Sn,n);return l&&(a=s),(u||d)&&(a=c),Et(a,n)&&(a=_t(-a,n)),{isValid:l||u,value:a}}var wn=Nt(yn.p,{isLE:!0}),Tn=Nt(yn.n,{isLE:!0}),En=fn({...yn,Fp:wn,hash:ze,adjustScalarBytes:xn,uvRatio:Cn}),Dn=Sn,On=BigInt(`25063068953384623474111414158702152701244531502492656460079210482610430750235`),kn=BigInt(`54469307008909316920995813868745141605393597292927456921205312896311721017578`),An=BigInt(`1159843021668779879193775521855586647937357759715417654439879720876111806838`),jn=BigInt(`40440834346308536858101042469323190826248399146238708352240133220865137265952`),Mn=e=>Cn(mn,e),Nn=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),Pn=e=>En.Point.Fp.create(qe(e)&Nn);function Fn(e){let{d:t}=yn,n=vn,r=e=>wn.create(e),i=r(Dn*e*e),a=r((i+mn)*An),o=BigInt(-1),s=r((o-t*i)*r(i+t)),{isValid:c,value:l}=Cn(a,s),u=r(l*e);Et(u,n)||(u=r(-u)),c||(l=u),c||(o=i);let d=r(o*(i-mn)*jn-s),f=l*l,p=r((l+l)*s),m=r(d*On),h=r(mn-f),g=r(mn+f);return new En.Point(r(p*g),r(h*m),r(m*g),r(p*h))}function In(e){f(e,64);let t=Fn(Pn(e.subarray(0,32))),n=Fn(Pn(e.subarray(32,64)));return new Ln(t.add(n))}var Ln=class e extends cn{constructor(e){super(e)}static fromAffine(t){return new e(En.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw Error(`RistrettoPoint expected`)}init(t){return new e(t)}static hashToCurve(e){return In(P(`ristrettoHash`,e,64))}static fromBytes(t){f(t,32);let{a:n,d:r}=yn,i=vn,a=e=>wn.create(e),o=Pn(t);if(!Xe(wn.toBytes(o),t)||Et(o,i))throw Error(`invalid ristretto255 encoding 1`);let s=a(o*o),c=a(mn+n*s),l=a(mn-n*s),u=a(c*c),d=a(l*l),p=a(n*r*u-d),{isValid:m,value:h}=Mn(a(p*d)),g=a(h*l),_=a(h*g*p),v=a((o+o)*g);Et(v,i)&&(v=a(-v));let y=a(c*_),b=a(v*y);if(!m||Et(b,i)||y===pn)throw Error(`invalid ristretto255 encoding 2`);return new e(new En.Point(v,y,mn,b))}static fromHex(t){return e.fromBytes(P(`ristrettoHex`,t,32))}static msm(t,n){return Qt(e,En.Point.Fn,t,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep,i=vn,a=e=>wn.create(e),o=a(a(n+t)*a(n-t)),s=a(e*t),{value:c}=Mn(a(o*a(s*s))),l=a(c*o),u=a(c*s),d=a(l*u*r),f;if(Et(r*d,i)){let n=a(t*Dn),r=a(e*Dn);e=n,t=r,f=a(l*kn)}else f=u;Et(e*d,i)&&(t=a(-t));let p=a((n-t)*f);return Et(p,i)&&(p=a(-p)),wn.toBytes(p)}equals(e){this.assertSame(e);let{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,a=e=>wn.create(e),o=a(t*i)===a(n*r),s=a(n*i)===a(t*r);return o||s}is0(){return this.equals(e.ZERO)}};Ln.BASE=new Ln(En.Point.BASE),Ln.ZERO=new Ln(En.Point.ZERO),Ln.Fp=wn,Ln.Fn=Tn;var Rn=i(((e,t)=>{(function(e,t){function n(e,t){if(!e)throw Error(t||`Assertion failed`)}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,e!==null&&((t===`le`||t===`be`)&&(n=t,t=10),this._init(e||0,t||10,n||`be`))}typeof e==`object`?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{o=typeof window<`u`&&window.Buffer!==void 0?window.Buffer:a().Buffer}catch{}i.isBN=function(e){return e instanceof i?!0:typeof e==`object`&&!!e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(typeof e==`number`)return this._initNumber(e,t,r);if(typeof e==`object`)return this._initArray(e,t,r);t===`hex`&&(t=16),n(t===(t|0)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,``);var i=0;e[0]===`-`&&(i++,this.negative=1),i<e.length&&(t===16?this._parseHex(e,i,r):(this._parseBase(e,t,i),r===`le`&&this._initArray(this.toArray(),t,r)))},i.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),r===`le`&&this._initArray(this.toArray(),t,r)},i.prototype._initArray=function(e,t,r){if(n(typeof e.length==`number`),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if(r===`be`)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);else if(r===`le`)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);return this._strip()};function s(e,t){var r=e.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;n(!1,`Invalid character in `+e)}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i=0,a=0,o;if(n===`be`)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()};function l(e,t,r,i){for(var a=0,o=0,s=Math.min(e.length,r),c=t;c<s;c++){var l=e.charCodeAt(c)-48;a*=i,o=l>=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&o<i,`Invalid character`),a+=o}return a}i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var a=e.length-n,o=a%r,s=Math.min(a,a-o)+n,c=0,u=n;u<s;u+=r)c=l(e,u,u+r,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(o!==0){var d=1;for(c=l(e,u,e.length,t),u=0;u<o;u++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red};function u(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(i.prototype._move=function(e){u(e,this)},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<`u`&&typeof Symbol.for==`function`)try{i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=d}catch{i.prototype.inspect=d}else i.prototype.inspect=d;function d(){return(this.red?`<BN-R: `:`<BN: `)+this.toString(16)+`>`}var f=`.0.00.000.0000.00000.000000.0000000.00000000.000000000.0000000000.00000000000.000000000000.0000000000000.00000000000000.000000000000000.0000000000000000.00000000000000000.000000000000000000.0000000000000000000.00000000000000000000.000000000000000000000.0000000000000000000000.00000000000000000000000.000000000000000000000000.0000000000000000000000000`.split(`.`),p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(e,t){e||=10,t=t|0||1;var r;if(e===16||e===`hex`){r=``;for(var i=0,a=0,o=0;o<this.length;o++){var s=this.words[o],c=((s<<i|a)&16777215).toString(16);a=s>>>24-i&16777215,i+=2,i>=26&&(i-=26,o--),r=a!==0||o!==this.length-1?f[6-c.length]+c+r:c+r}for(a!==0&&(r=a.toString(16)+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}if(e===(e|0)&&e>=2&&e<=36){var l=p[e],u=m[e];r=``;var d=this.clone();for(d.negative=0;!d.isZero();){var h=d.modrn(u).toString(e);d=d.idivn(u),r=d.isZero()?h+r:f[l-h.length]+h+r}for(this.isZero()&&(r=`0`+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}n(!1,`Base should be between 2 and 36`)},i.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,`Number can only safely store up to 53 bits`),this.negative===0?e:-e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};var h=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)};i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,`byte array longer than desired length`),n(a>0,`Requested array length <= 0`);var o=h(e,a),s=t===`le`?`LE`:`BE`;return this[`_toArrayLike`+s](o,i),o},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n++]=o&255,n<e.length&&(e[n++]=o>>8&255),n<e.length&&(e[n++]=o>>16&255),a===6?(n<e.length&&(e[n++]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},i.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n--]=o&255,n>=0&&(e[n--]=o>>8&255),n>=0&&(e[n--]=o>>16&255),a===6?(n>=0&&(e[n--]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(e===0)return 26;var t=e,n=0;return t&8191||(n+=13,t>>>=13),t&127||(n+=7,t>>>=7),t&15||(n+=4,t>>>=4),t&3||(n+=2,t>>>=2),t&1||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return(this.length-1)*26+t};function g(e){for(var t=Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,n!==26)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return this.negative===0?this.clone():this.abs().inotn(e).iaddn(1)},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},i.prototype.ior=function(e){return n((this.negative|e.negative)===0),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){for(var t=this.length>e.length?e:this,n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},i.prototype.iand=function(e){return n((this.negative|e.negative)===0),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},i.prototype.ixor=function(e){return n((this.negative|e.negative)===0),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(typeof e==`number`&&e>=0);var t=Math.ceil(e/26)|0,r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=~this.words[i]&67108863;return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(typeof e==`number`&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),t?this.words[r]=this.words[r]|1<<i:this.words[r]=this.words[r]&~(1<<i),this._strip()},i.prototype.iadd=function(e){var t;if(this.negative!==0&&e.negative===0)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();var n,r;this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)t=(n.words[a]|0)+(r.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;for(;i!==0&&a<n.length;a++)t=(n.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;if(this.length=n.length,i!==0)this.words[this.length]=i,this.length++;else if(n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this},i.prototype.add=function(e){var t;return e.negative!==0&&this.negative===0?(e.negative=0,t=this.sub(e),e.negative^=1,t):e.negative===0&&this.negative!==0?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var r,i;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,o=0;o<i.length;o++)t=(r.words[o]|0)-(i.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;for(;a!==0&&o<r.length;o++)t=(r.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;if(a===0&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(e){return this.clone().isub(e)};function _(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=e.words[0]|0,a=t.words[0]|0,o=i*a,s=o&67108863,c=o/67108864|0;n.words[0]=s;for(var l=1;l<r;l++){for(var u=c>>>26,d=c&67108863,f=Math.min(l,t.length-1),p=Math.max(0,l-e.length+1);p<=f;p++){var m=l-p|0;i=e.words[m]|0,a=t.words[p]|0,o=i*a+d,u+=o/67108864|0,d=o&67108863}n.words[l]=d|0,c=u|0}return c===0?n.length--:n.words[l]=c|0,n._strip()}var v=function(e,t,n){var r=e.words,i=t.words,a=n.words,o=0,s,c,l,u=r[0]|0,d=u&8191,f=u>>>13,p=r[1]|0,m=p&8191,h=p>>>13,g=r[2]|0,_=g&8191,v=g>>>13,y=r[3]|0,b=y&8191,x=y>>>13,ee=r[4]|0,S=ee&8191,C=ee>>>13,w=r[5]|0,T=w&8191,E=w>>>13,D=r[6]|0,O=D&8191,te=D>>>13,ne=r[7]|0,k=ne&8191,A=ne>>>13,re=r[8]|0,ie=re&8191,ae=re>>>13,oe=r[9]|0,se=oe&8191,ce=oe>>>13,le=i[0]|0,j=le&8191,ue=le>>>13,de=i[1]|0,fe=de&8191,pe=de>>>13,me=i[2]|0,he=me&8191,ge=me>>>13,_e=i[3]|0,ve=_e&8191,ye=_e>>>13,be=i[4]|0,xe=be&8191,Se=be>>>13,Ce=i[5]|0,M=Ce&8191,we=Ce>>>13,Te=i[6]|0,Ee=Te&8191,De=Te>>>13,Oe=i[7]|0,ke=Oe&8191,Ae=Oe>>>13,je=i[8]|0,Me=je&8191,Ne=je>>>13,Pe=i[9]|0,Fe=Pe&8191,N=Pe>>>13;n.negative=e.negative^t.negative,n.length=19,s=Math.imul(d,j),c=Math.imul(d,ue),c=c+Math.imul(f,j)|0,l=Math.imul(f,ue);var Ie=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,s=Math.imul(m,j),c=Math.imul(m,ue),c=c+Math.imul(h,j)|0,l=Math.imul(h,ue),s=s+Math.imul(d,fe)|0,c=c+Math.imul(d,pe)|0,c=c+Math.imul(f,fe)|0,l=l+Math.imul(f,pe)|0;var Le=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Le>>>26)|0,Le&=67108863,s=Math.imul(_,j),c=Math.imul(_,ue),c=c+Math.imul(v,j)|0,l=Math.imul(v,ue),s=s+Math.imul(m,fe)|0,c=c+Math.imul(m,pe)|0,c=c+Math.imul(h,fe)|0,l=l+Math.imul(h,pe)|0,s=s+Math.imul(d,he)|0,c=c+Math.imul(d,ge)|0,c=c+Math.imul(f,he)|0,l=l+Math.imul(f,ge)|0;var Re=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Re>>>26)|0,Re&=67108863,s=Math.imul(b,j),c=Math.imul(b,ue),c=c+Math.imul(x,j)|0,l=Math.imul(x,ue),s=s+Math.imul(_,fe)|0,c=c+Math.imul(_,pe)|0,c=c+Math.imul(v,fe)|0,l=l+Math.imul(v,pe)|0,s=s+Math.imul(m,he)|0,c=c+Math.imul(m,ge)|0,c=c+Math.imul(h,he)|0,l=l+Math.imul(h,ge)|0,s=s+Math.imul(d,ve)|0,c=c+Math.imul(d,ye)|0,c=c+Math.imul(f,ve)|0,l=l+Math.imul(f,ye)|0;var ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(ze>>>26)|0,ze&=67108863,s=Math.imul(S,j),c=Math.imul(S,ue),c=c+Math.imul(C,j)|0,l=Math.imul(C,ue),s=s+Math.imul(b,fe)|0,c=c+Math.imul(b,pe)|0,c=c+Math.imul(x,fe)|0,l=l+Math.imul(x,pe)|0,s=s+Math.imul(_,he)|0,c=c+Math.imul(_,ge)|0,c=c+Math.imul(v,he)|0,l=l+Math.imul(v,ge)|0,s=s+Math.imul(m,ve)|0,c=c+Math.imul(m,ye)|0,c=c+Math.imul(h,ve)|0,l=l+Math.imul(h,ye)|0,s=s+Math.imul(d,xe)|0,c=c+Math.imul(d,Se)|0,c=c+Math.imul(f,xe)|0,l=l+Math.imul(f,Se)|0;var Be=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,s=Math.imul(T,j),c=Math.imul(T,ue),c=c+Math.imul(E,j)|0,l=Math.imul(E,ue),s=s+Math.imul(S,fe)|0,c=c+Math.imul(S,pe)|0,c=c+Math.imul(C,fe)|0,l=l+Math.imul(C,pe)|0,s=s+Math.imul(b,he)|0,c=c+Math.imul(b,ge)|0,c=c+Math.imul(x,he)|0,l=l+Math.imul(x,ge)|0,s=s+Math.imul(_,ve)|0,c=c+Math.imul(_,ye)|0,c=c+Math.imul(v,ve)|0,l=l+Math.imul(v,ye)|0,s=s+Math.imul(m,xe)|0,c=c+Math.imul(m,Se)|0,c=c+Math.imul(h,xe)|0,l=l+Math.imul(h,Se)|0,s=s+Math.imul(d,M)|0,c=c+Math.imul(d,we)|0,c=c+Math.imul(f,M)|0,l=l+Math.imul(f,we)|0;var Ve=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,s=Math.imul(O,j),c=Math.imul(O,ue),c=c+Math.imul(te,j)|0,l=Math.imul(te,ue),s=s+Math.imul(T,fe)|0,c=c+Math.imul(T,pe)|0,c=c+Math.imul(E,fe)|0,l=l+Math.imul(E,pe)|0,s=s+Math.imul(S,he)|0,c=c+Math.imul(S,ge)|0,c=c+Math.imul(C,he)|0,l=l+Math.imul(C,ge)|0,s=s+Math.imul(b,ve)|0,c=c+Math.imul(b,ye)|0,c=c+Math.imul(x,ve)|0,l=l+Math.imul(x,ye)|0,s=s+Math.imul(_,xe)|0,c=c+Math.imul(_,Se)|0,c=c+Math.imul(v,xe)|0,l=l+Math.imul(v,Se)|0,s=s+Math.imul(m,M)|0,c=c+Math.imul(m,we)|0,c=c+Math.imul(h,M)|0,l=l+Math.imul(h,we)|0,s=s+Math.imul(d,Ee)|0,c=c+Math.imul(d,De)|0,c=c+Math.imul(f,Ee)|0,l=l+Math.imul(f,De)|0;var He=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(He>>>26)|0,He&=67108863,s=Math.imul(k,j),c=Math.imul(k,ue),c=c+Math.imul(A,j)|0,l=Math.imul(A,ue),s=s+Math.imul(O,fe)|0,c=c+Math.imul(O,pe)|0,c=c+Math.imul(te,fe)|0,l=l+Math.imul(te,pe)|0,s=s+Math.imul(T,he)|0,c=c+Math.imul(T,ge)|0,c=c+Math.imul(E,he)|0,l=l+Math.imul(E,ge)|0,s=s+Math.imul(S,ve)|0,c=c+Math.imul(S,ye)|0,c=c+Math.imul(C,ve)|0,l=l+Math.imul(C,ye)|0,s=s+Math.imul(b,xe)|0,c=c+Math.imul(b,Se)|0,c=c+Math.imul(x,xe)|0,l=l+Math.imul(x,Se)|0,s=s+Math.imul(_,M)|0,c=c+Math.imul(_,we)|0,c=c+Math.imul(v,M)|0,l=l+Math.imul(v,we)|0,s=s+Math.imul(m,Ee)|0,c=c+Math.imul(m,De)|0,c=c+Math.imul(h,Ee)|0,l=l+Math.imul(h,De)|0,s=s+Math.imul(d,ke)|0,c=c+Math.imul(d,Ae)|0,c=c+Math.imul(f,ke)|0,l=l+Math.imul(f,Ae)|0;var Ue=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,s=Math.imul(ie,j),c=Math.imul(ie,ue),c=c+Math.imul(ae,j)|0,l=Math.imul(ae,ue),s=s+Math.imul(k,fe)|0,c=c+Math.imul(k,pe)|0,c=c+Math.imul(A,fe)|0,l=l+Math.imul(A,pe)|0,s=s+Math.imul(O,he)|0,c=c+Math.imul(O,ge)|0,c=c+Math.imul(te,he)|0,l=l+Math.imul(te,ge)|0,s=s+Math.imul(T,ve)|0,c=c+Math.imul(T,ye)|0,c=c+Math.imul(E,ve)|0,l=l+Math.imul(E,ye)|0,s=s+Math.imul(S,xe)|0,c=c+Math.imul(S,Se)|0,c=c+Math.imul(C,xe)|0,l=l+Math.imul(C,Se)|0,s=s+Math.imul(b,M)|0,c=c+Math.imul(b,we)|0,c=c+Math.imul(x,M)|0,l=l+Math.imul(x,we)|0,s=s+Math.imul(_,Ee)|0,c=c+Math.imul(_,De)|0,c=c+Math.imul(v,Ee)|0,l=l+Math.imul(v,De)|0,s=s+Math.imul(m,ke)|0,c=c+Math.imul(m,Ae)|0,c=c+Math.imul(h,ke)|0,l=l+Math.imul(h,Ae)|0,s=s+Math.imul(d,Me)|0,c=c+Math.imul(d,Ne)|0,c=c+Math.imul(f,Me)|0,l=l+Math.imul(f,Ne)|0;var We=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(We>>>26)|0,We&=67108863,s=Math.imul(se,j),c=Math.imul(se,ue),c=c+Math.imul(ce,j)|0,l=Math.imul(ce,ue),s=s+Math.imul(ie,fe)|0,c=c+Math.imul(ie,pe)|0,c=c+Math.imul(ae,fe)|0,l=l+Math.imul(ae,pe)|0,s=s+Math.imul(k,he)|0,c=c+Math.imul(k,ge)|0,c=c+Math.imul(A,he)|0,l=l+Math.imul(A,ge)|0,s=s+Math.imul(O,ve)|0,c=c+Math.imul(O,ye)|0,c=c+Math.imul(te,ve)|0,l=l+Math.imul(te,ye)|0,s=s+Math.imul(T,xe)|0,c=c+Math.imul(T,Se)|0,c=c+Math.imul(E,xe)|0,l=l+Math.imul(E,Se)|0,s=s+Math.imul(S,M)|0,c=c+Math.imul(S,we)|0,c=c+Math.imul(C,M)|0,l=l+Math.imul(C,we)|0,s=s+Math.imul(b,Ee)|0,c=c+Math.imul(b,De)|0,c=c+Math.imul(x,Ee)|0,l=l+Math.imul(x,De)|0,s=s+Math.imul(_,ke)|0,c=c+Math.imul(_,Ae)|0,c=c+Math.imul(v,ke)|0,l=l+Math.imul(v,Ae)|0,s=s+Math.imul(m,Me)|0,c=c+Math.imul(m,Ne)|0,c=c+Math.imul(h,Me)|0,l=l+Math.imul(h,Ne)|0,s=s+Math.imul(d,Fe)|0,c=c+Math.imul(d,N)|0,c=c+Math.imul(f,Fe)|0,l=l+Math.imul(f,N)|0;var Ge=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,s=Math.imul(se,fe),c=Math.imul(se,pe),c=c+Math.imul(ce,fe)|0,l=Math.imul(ce,pe),s=s+Math.imul(ie,he)|0,c=c+Math.imul(ie,ge)|0,c=c+Math.imul(ae,he)|0,l=l+Math.imul(ae,ge)|0,s=s+Math.imul(k,ve)|0,c=c+Math.imul(k,ye)|0,c=c+Math.imul(A,ve)|0,l=l+Math.imul(A,ye)|0,s=s+Math.imul(O,xe)|0,c=c+Math.imul(O,Se)|0,c=c+Math.imul(te,xe)|0,l=l+Math.imul(te,Se)|0,s=s+Math.imul(T,M)|0,c=c+Math.imul(T,we)|0,c=c+Math.imul(E,M)|0,l=l+Math.imul(E,we)|0,s=s+Math.imul(S,Ee)|0,c=c+Math.imul(S,De)|0,c=c+Math.imul(C,Ee)|0,l=l+Math.imul(C,De)|0,s=s+Math.imul(b,ke)|0,c=c+Math.imul(b,Ae)|0,c=c+Math.imul(x,ke)|0,l=l+Math.imul(x,Ae)|0,s=s+Math.imul(_,Me)|0,c=c+Math.imul(_,Ne)|0,c=c+Math.imul(v,Me)|0,l=l+Math.imul(v,Ne)|0,s=s+Math.imul(m,Fe)|0,c=c+Math.imul(m,N)|0,c=c+Math.imul(h,Fe)|0,l=l+Math.imul(h,N)|0;var Ke=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,s=Math.imul(se,he),c=Math.imul(se,ge),c=c+Math.imul(ce,he)|0,l=Math.imul(ce,ge),s=s+Math.imul(ie,ve)|0,c=c+Math.imul(ie,ye)|0,c=c+Math.imul(ae,ve)|0,l=l+Math.imul(ae,ye)|0,s=s+Math.imul(k,xe)|0,c=c+Math.imul(k,Se)|0,c=c+Math.imul(A,xe)|0,l=l+Math.imul(A,Se)|0,s=s+Math.imul(O,M)|0,c=c+Math.imul(O,we)|0,c=c+Math.imul(te,M)|0,l=l+Math.imul(te,we)|0,s=s+Math.imul(T,Ee)|0,c=c+Math.imul(T,De)|0,c=c+Math.imul(E,Ee)|0,l=l+Math.imul(E,De)|0,s=s+Math.imul(S,ke)|0,c=c+Math.imul(S,Ae)|0,c=c+Math.imul(C,ke)|0,l=l+Math.imul(C,Ae)|0,s=s+Math.imul(b,Me)|0,c=c+Math.imul(b,Ne)|0,c=c+Math.imul(x,Me)|0,l=l+Math.imul(x,Ne)|0,s=s+Math.imul(_,Fe)|0,c=c+Math.imul(_,N)|0,c=c+Math.imul(v,Fe)|0,l=l+Math.imul(v,N)|0;var qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(qe>>>26)|0,qe&=67108863,s=Math.imul(se,ve),c=Math.imul(se,ye),c=c+Math.imul(ce,ve)|0,l=Math.imul(ce,ye),s=s+Math.imul(ie,xe)|0,c=c+Math.imul(ie,Se)|0,c=c+Math.imul(ae,xe)|0,l=l+Math.imul(ae,Se)|0,s=s+Math.imul(k,M)|0,c=c+Math.imul(k,we)|0,c=c+Math.imul(A,M)|0,l=l+Math.imul(A,we)|0,s=s+Math.imul(O,Ee)|0,c=c+Math.imul(O,De)|0,c=c+Math.imul(te,Ee)|0,l=l+Math.imul(te,De)|0,s=s+Math.imul(T,ke)|0,c=c+Math.imul(T,Ae)|0,c=c+Math.imul(E,ke)|0,l=l+Math.imul(E,Ae)|0,s=s+Math.imul(S,Me)|0,c=c+Math.imul(S,Ne)|0,c=c+Math.imul(C,Me)|0,l=l+Math.imul(C,Ne)|0,s=s+Math.imul(b,Fe)|0,c=c+Math.imul(b,N)|0,c=c+Math.imul(x,Fe)|0,l=l+Math.imul(x,N)|0;var Je=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Je>>>26)|0,Je&=67108863,s=Math.imul(se,xe),c=Math.imul(se,Se),c=c+Math.imul(ce,xe)|0,l=Math.imul(ce,Se),s=s+Math.imul(ie,M)|0,c=c+Math.imul(ie,we)|0,c=c+Math.imul(ae,M)|0,l=l+Math.imul(ae,we)|0,s=s+Math.imul(k,Ee)|0,c=c+Math.imul(k,De)|0,c=c+Math.imul(A,Ee)|0,l=l+Math.imul(A,De)|0,s=s+Math.imul(O,ke)|0,c=c+Math.imul(O,Ae)|0,c=c+Math.imul(te,ke)|0,l=l+Math.imul(te,Ae)|0,s=s+Math.imul(T,Me)|0,c=c+Math.imul(T,Ne)|0,c=c+Math.imul(E,Me)|0,l=l+Math.imul(E,Ne)|0,s=s+Math.imul(S,Fe)|0,c=c+Math.imul(S,N)|0,c=c+Math.imul(C,Fe)|0,l=l+Math.imul(C,N)|0;var Ye=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,s=Math.imul(se,M),c=Math.imul(se,we),c=c+Math.imul(ce,M)|0,l=Math.imul(ce,we),s=s+Math.imul(ie,Ee)|0,c=c+Math.imul(ie,De)|0,c=c+Math.imul(ae,Ee)|0,l=l+Math.imul(ae,De)|0,s=s+Math.imul(k,ke)|0,c=c+Math.imul(k,Ae)|0,c=c+Math.imul(A,ke)|0,l=l+Math.imul(A,Ae)|0,s=s+Math.imul(O,Me)|0,c=c+Math.imul(O,Ne)|0,c=c+Math.imul(te,Me)|0,l=l+Math.imul(te,Ne)|0,s=s+Math.imul(T,Fe)|0,c=c+Math.imul(T,N)|0,c=c+Math.imul(E,Fe)|0,l=l+Math.imul(E,N)|0;var P=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(P>>>26)|0,P&=67108863,s=Math.imul(se,Ee),c=Math.imul(se,De),c=c+Math.imul(ce,Ee)|0,l=Math.imul(ce,De),s=s+Math.imul(ie,ke)|0,c=c+Math.imul(ie,Ae)|0,c=c+Math.imul(ae,ke)|0,l=l+Math.imul(ae,Ae)|0,s=s+Math.imul(k,Me)|0,c=c+Math.imul(k,Ne)|0,c=c+Math.imul(A,Me)|0,l=l+Math.imul(A,Ne)|0,s=s+Math.imul(O,Fe)|0,c=c+Math.imul(O,N)|0,c=c+Math.imul(te,Fe)|0,l=l+Math.imul(te,N)|0;var Xe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Xe>>>26)|0,Xe&=67108863,s=Math.imul(se,ke),c=Math.imul(se,Ae),c=c+Math.imul(ce,ke)|0,l=Math.imul(ce,Ae),s=s+Math.imul(ie,Me)|0,c=c+Math.imul(ie,Ne)|0,c=c+Math.imul(ae,Me)|0,l=l+Math.imul(ae,Ne)|0,s=s+Math.imul(k,Fe)|0,c=c+Math.imul(k,N)|0,c=c+Math.imul(A,Fe)|0,l=l+Math.imul(A,N)|0;var Ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,s=Math.imul(se,Me),c=Math.imul(se,Ne),c=c+Math.imul(ce,Me)|0,l=Math.imul(ce,Ne),s=s+Math.imul(ie,Fe)|0,c=c+Math.imul(ie,N)|0,c=c+Math.imul(ae,Fe)|0,l=l+Math.imul(ae,N)|0;var Qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,s=Math.imul(se,Fe),c=Math.imul(se,N),c=c+Math.imul(ce,Fe)|0,l=Math.imul(ce,N);var $e=(o+s|0)+((c&8191)<<13)|0;return o=(l+(c>>>13)|0)+($e>>>26)|0,$e&=67108863,a[0]=Ie,a[1]=Le,a[2]=Re,a[3]=ze,a[4]=Be,a[5]=Ve,a[6]=He,a[7]=Ue,a[8]=We,a[9]=Ge,a[10]=Ke,a[11]=qe,a[12]=Je,a[13]=Ye,a[14]=P,a[15]=Xe,a[16]=Ze,a[17]=Qe,a[18]=$e,o!==0&&(a[19]=o,n.length++),n};Math.imul||(v=_);function y(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,a=0;a<n.length-1;a++){var o=i;i=0;for(var s=r&67108863,c=Math.min(a,t.length-1),l=Math.max(0,a-e.length+1);l<=c;l++){var u=a-l,d=(e.words[u]|0)*(t.words[l]|0),f=d&67108863;o=o+(d/67108864|0)|0,f=f+s|0,s=f&67108863,o=o+(f>>>26)|0,i+=o>>>26,o&=67108863}n.words[a]=s,r=o,o=i}return r===0?n.length--:n.words[a]=r,n._strip()}function b(e,t,n){return y(e,t,n)}i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=this.length===10&&e.length===10?v(this,e,t):r<63?_(this,e,t):r<1024?y(this,e,t):b(this,e,t),n};function x(e,t){this.x=e,this.y=t}x.prototype.makeRBT=function(e){for(var t=Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},x.prototype.revBin=function(e,t,n){if(e===0||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(e&1)<<t-i-1,e>>=1;return r},x.prototype.permute=function(e,t,n,r,i,a){for(var o=0;o<a;o++)r[o]=t[e[o]],i[o]=n[e[o]]},x.prototype.transform=function(e,t,n,r,i,a){this.permute(a,e,t,n,r,i);for(var o=1;o<i;o<<=1)for(var s=o<<1,c=Math.cos(2*Math.PI/s),l=Math.sin(2*Math.PI/s),u=0;u<i;u+=s)for(var d=c,f=l,p=0;p<o;p++){var m=n[u+p],h=r[u+p],g=n[u+p+o],_=r[u+p+o],v=d*g-f*_;_=d*_+f*g,g=v,n[u+p]=m+g,r[u+p]=h+_,n[u+p+o]=m-g,r[u+p+o]=h-_,p!==s&&(v=c*d-l*f,f=c*f+l*d,d=v)}},x.prototype.guessLen13b=function(e,t){var n=Math.max(t,e)|1,r=n&1,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},x.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},x.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=Math.round(e[2*r+1]/t)*8192+Math.round(e[2*r]/t)+n;e[r]=i&67108863,n=i<67108864?0:i/67108864|0}return e},x.prototype.convert13b=function(e,t,r,i){for(var a=0,o=0;o<t;o++)a+=e[o]|0,r[2*o]=a&8191,a>>>=13,r[2*o+1]=a&8191,a>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(a===0),n((a&-8192)==0)},x.prototype.stub=function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=0;return t},x.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),a=this.stub(r),o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=Array(r),d=Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,o,r),this.convert13b(t.words,t.length,l,r),this.transform(o,a,s,c,r,i),this.transform(l,a,u,d,r,i);for(var p=0;p<r;p++){var m=s[p]*u[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*u[p],s[p]=m}return this.conjugate(s,c,r),this.transform(s,c,f,a,r,i),this.conjugate(f,a,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=Array(this.length+e.length),b(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(typeof e==`number`),n(e<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*e,o=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=o>>>26,this.words[i]=o&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=e===0?1:this.length,t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=g(e);if(t.length===0)return new i(1);for(var n=this,r=0;r<t.length&&t[r]===0;r++,n=n.sqr());if(++r<t.length)for(var a=n.sqr();r<t.length;r++,a=a.sqr())t[r]!==0&&(n=n.mul(a));return n},i.prototype.iushln=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=67108863>>>26-t<<26-t,a;if(t!==0){var o=0;for(a=0;a<this.length;a++){var s=this.words[a]&i,c=(this.words[a]|0)-s<<t;this.words[a]=c|o,o=s>>>26-t}o&&(this.words[a]=o,this.length++)}if(r!==0){for(a=this.length-1;a>=0;a--)this.words[a+r]=this.words[a];for(a=0;a<r;a++)this.words[a]=0;this.length+=r}return this._strip()},i.prototype.ishln=function(e){return n(this.negative===0),this.iushln(e)},i.prototype.iushrn=function(e,t,r){n(typeof e==`number`&&e>=0);var i=t?(t-t%26)/26:0,a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<<a,c=r;if(i-=o,i=Math.max(0,i),c){for(var l=0;l<o;l++)c.words[l]=this.words[l];c.length=o}if(o!==0)if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var u=0;for(l=this.length-1;l>=0&&(u!==0||l>=i);l--){var d=this.words[l]|0;this.words[l]=u<<26-a|d>>>a,u=d&s}return c&&u!==0&&(c.words[c.length++]=u),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(this.negative===0),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return this.length<=r?!1:!!(this.words[r]&i)},i.prototype.imaskn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26;if(n(this.negative===0,`imaskn works only with positive numbers`),this.length<=r)return this;if(t!==0&&r++,this.length=Math.min(r,this.length),t!==0){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return n(typeof e==`number`),n(e<67108864),e<0?this.isubn(-e):this.negative===0?this._iaddn(e):this.length===1&&(this.words[0]|0)<=e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(typeof e==`number`),n(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,--this.words[t+1];return this._strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,r){var i=e.length+r,a;this._expand(i);var o,s=0;for(a=0;a<e.length;a++){o=(this.words[a+r]|0)+s;var c=(e.words[a]|0)*t;o-=c&67108863,s=(o>>26)-(c/67108864|0),this.words[a+r]=o&67108863}for(;a<this.length-r;a++)o=(this.words[a+r]|0)+s,s=o>>26,this.words[a+r]=o&67108863;if(s===0)return this._strip();for(n(s===-1),s=0,a=0;a<this.length;a++)o=-(this.words[a]|0)+s,s=o>>26,this.words[a]=o&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=this.length-e.length,r=this.clone(),a=e,o=a.words[a.length-1]|0;n=26-this._countBits(o),n!==0&&(a=a.ushln(n),r.iushln(n),o=a.words[a.length-1]|0);var s=r.length-a.length,c;if(t!==`mod`){c=new i(null),c.length=s+1,c.words=Array(c.length);for(var l=0;l<c.length;l++)c.words[l]=0}var u=r.clone()._ishlnsubmul(a,1,s);u.negative===0&&(r=u,c&&(c.words[s]=1));for(var d=s-1;d>=0;d--){var f=(r.words[a.length+d]|0)*67108864+(r.words[a.length+d-1]|0);for(f=Math.min(f/o|0,67108863),r._ishlnsubmul(a,f,d);r.negative!==0;)f--,r.negative=0,r._ishlnsubmul(a,1,d),r.isZero()||(r.negative^=1);c&&(c.words[d]=f)}return c&&c._strip(),r._strip(),t!==`div`&&n!==0&&r.iushrn(n),{div:c||null,mod:r}},i.prototype.divmod=function(e,t,r){if(n(!e.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var a,o,s;return this.negative!==0&&e.negative===0?(s=this.neg().divmod(e,t),t!==`mod`&&(a=s.div.neg()),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.iadd(e)),{div:a,mod:o}):this.negative===0&&e.negative!==0?(s=this.divmod(e.neg(),t),t!==`mod`&&(a=s.div.neg()),{div:a,mod:s.mod}):(this.negative&e.negative)===0?e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:e.length===1?t===`div`?{div:this.divn(e.words[0]),mod:null}:t===`mod`?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t):(s=this.neg().divmod(e.neg(),t),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.isub(e)),{div:s.div,mod:o})},i.prototype.div=function(e){return this.divmod(e,`div`,!1).div},i.prototype.mod=function(e){return this.divmod(e,`mod`,!1).mod},i.prototype.umod=function(e){return this.divmod(e,`mod`,!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=t.div.negative===0?t.mod:t.mod.isub(e),r=e.ushrn(1),i=e.andln(1),a=n.cmp(r);return a<0||i===1&&a===0?t.div:t.div.negative===0?t.div.iaddn(1):t.div.isubn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/e|0,r=a%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=new i(0),c=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var u=r.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;(t.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(u),o.isub(d)),a.iushrn(1),o.iushrn(1);for(var m=0,h=1;(r.words[0]&h)===0&&m<26;++m,h<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(u),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s),o.isub(c)):(r.isub(t),s.isub(a),c.isub(o))}return{a:s,b:c,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;(t.words[0]&l)===0&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var u=0,d=1;(r.words[0]&d)===0&&u<26;++u,d<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(o)):(r.isub(t),o.isub(a))}var f=t.cmpn(1)===0?a:o;return f.cmpn(0)<0&&f.iadd(e),f},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);do{for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var a=t;t=n,n=a}else if(i===0||n.cmpn(1)===0)break;t.isub(n)}while(!0);return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return(this.words[0]&1)==0},i.prototype.isOdd=function(){return(this.words[0]&1)==1},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(typeof e==`number`);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var a=i,o=r;a!==0&&o<this.length;o++){var s=this.words[o]|0;s+=a,a=s>>>26,s&=67108863,this.words[o]=s}return a!==0&&(this.words[o]=a,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(e){var t=e<0;if(this.negative!==0&&!t)return-1;if(this.negative===0&&t)return 1;this._strip();var r;if(this.length>1)r=1;else{t&&(e=-e),n(e<=67108863,`Number is too big`);var i=this.words[0]|0;r=i===e?0:i<e?-1:1}return this.negative===0?r:-r|0},i.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var t=this.ucmp(e);return this.negative===0?t:-t|0},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=this.words[n]|0,i=e.words[n]|0;if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},i.prototype.gtn=function(e){return this.cmpn(e)===1},i.prototype.gt=function(e){return this.cmp(e)===1},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return this.cmpn(e)===-1},i.prototype.lt=function(e){return this.cmp(e)===-1},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return this.cmpn(e)===0},i.prototype.eq=function(e){return this.cmp(e)===0},i.red=function(e){return new D(e)},i.prototype.toRed=function(e){return n(!this.red,`Already a number in reduction context`),n(this.negative===0,`red works only with positives`),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,`fromRed works only with numbers in reduction context`),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,`Already a number in reduction context`),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,`redAdd works only with red numbers`),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,`redIAdd works only with red numbers`),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,`redSub works only with red numbers`),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,`redISub works only with red numbers`),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,`redShl works only with red numbers`),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,`redSqr works only with red numbers`),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,`redISqr works only with red numbers`),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,`redSqrt works only with red numbers`),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,`redInvm works only with red numbers`),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,`redNeg works only with red numbers`),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,`redPow(normalNum)`),this.red._verify1(this),this.red.pow(this,e)};var ee={k256:null,p224:null,p192:null,p25519:null};function S(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}S.prototype._tmp=function(){var e=new i(null);return e.words=Array(Math.ceil(this.n/13)),e},S.prototype.ireduce=function(e){var t=e,n;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),n=t.bitLength();while(n>this.n);var r=n<this.n?-1:t.ucmp(this.p);return r===0?(t.words[0]=0,t.length=1):r>0?t.isub(this.p):t.strip===void 0?t._strip():t.strip(),t},S.prototype.split=function(e,t){e.iushrn(this.n,0,t)},S.prototype.imulK=function(e){return e.imul(this.k)};function C(){S.call(this,`k256`,`ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f`)}r(C,S),C.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9){e.words[0]=0,e.length=1;return}var a=e.words[9];for(t.words[t.length++]=a&n,i=10;i<e.length;i++){var o=e.words[i]|0;e.words[i-10]=(o&n)<<4|a>>>22,a=o}a>>>=22,e.words[i-10]=a,a===0&&e.length>10?e.length-=10:e.length-=9},C.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=e.words[n]|0;t+=r*977,e.words[n]=t&67108863,t=r*64+(t/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function w(){S.call(this,`p224`,`ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001`)}r(w,S);function T(){S.call(this,`p192`,`ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff`)}r(T,S);function E(){S.call(this,`25519`,`7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed`)}r(E,S),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=(e.words[n]|0)*19+t,i=r&67108863;r>>>=26,e.words[n]=i,t=r}return t!==0&&(e.words[e.length++]=t),e},i._prime=function(e){if(ee[e])return ee[e];var t;if(e===`k256`)t=new C;else if(e===`p224`)t=new w;else if(e===`p192`)t=new T;else if(e===`p25519`)t=new E;else throw Error(`Unknown prime `+e);return ee[e]=t,t};function D(e){if(typeof e==`string`){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),`modulus must be greater than 1`),this.m=e,this.prime=null}D.prototype._verify1=function(e){n(e.negative===0,`red works only with positives`),n(e.red,`red works only with red numbers`)},D.prototype._verify2=function(e,t){n((e.negative|t.negative)===0,`red works only with positives`),n(e.red&&e.red===t.red,`red works only with red numbers`)},D.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},D.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},D.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},D.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},D.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},D.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},D.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},D.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},D.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},D.prototype.isqr=function(e){return this.imul(e,e.clone())},D.prototype.sqr=function(e){return this.mul(e,e)},D.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),t===3){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&a.andln(1)===0;)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),c=s.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,l).cmp(c)!==0;)u.redIAdd(c);for(var d=this.pow(u,a),f=this.pow(e,a.addn(1).iushrn(1)),p=this.pow(e,a),m=o;p.cmp(s)!==0;){for(var h=p,g=0;h.cmp(s)!==0;g++)h=h.redSqr();n(g<m);var _=this.pow(d,new i(1).iushln(m-g-1));f=f.redMul(_),d=_.redSqr(),p=p.redMul(d),m=g}return f},D.prototype.invm=function(e){var t=e._invmp(this.m);return t.negative===0?this.imod(t):(t.negative=0,this.imod(t).redNeg())},D.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(t.cmpn(1)===0)return e.clone();var n=4,r=Array(1<<n);r[0]=new i(1).toRed(this),r[1]=e;for(var a=2;a<r.length;a++)r[a]=this.mul(r[a-1],e);var o=r[0],s=0,c=0,l=t.bitLength()%26;for(l===0&&(l=26),a=t.length-1;a>=0;a--){for(var u=t.words[a],d=l-1;d>=0;d--){var f=u>>d&1;if(o!==r[0]&&(o=this.sqr(o)),f===0&&s===0){c=0;continue}s<<=1,s|=f,c++,!(c!==n&&(a!==0||d!==0))&&(o=this.mul(o,r[s]),c=0,s=0)}l=26}return o},D.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},D.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)};function O(e){D.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}r(O,D),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=n.isub(r).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(t===void 0||t,e)})),zn=i(((e,t)=>{var n=o(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),Bn=i(((e,t)=>{var n=zn().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),Vn=i(((e,t)=>{t.exports=Bn()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),Hn=n(Rn()),Un=n(Vn()),Wn=Re,Gn=i(((e,t)=>{var n=zn().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),Kn=i(((e,t)=>{t.exports=Gn()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),qn=r({TextDecoder:()=>nr,TextEncoder:()=>rr});function Jn(e,t,n){return t<=e&&e<=n}function Yn(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function Xn(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}r+=1}return i}function Zn(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function Qn(e){this.tokens=[].slice.call(e)}function $n(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function er(){}function tr(){}function nr(e,t){if(!(this instanceof nr))return new nr(e,t);if(e=e===void 0?cr:String(e).toLowerCase(),e!==cr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=Yn(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function rr(e,t){if(!(this instanceof rr))return new rr(e,t);if(e=e===void 0?cr:String(e).toLowerCase(),e!==cr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=Yn(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function ir(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===or&&i!==0)return i=0,$n(t);if(s===or)return sr;if(i===0){if(Jn(s,0,127))return s;if(Jn(s,194,223))i=1,n=s-192;else if(Jn(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(Jn(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return $n(t);return n<<=6*i,null}if(!Jn(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),$n(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function ar(e){e.fatal,this.handler=function(e,t){if(t===or)return sr;if(Jn(t,0,127))return t;var n,r;Jn(t,128,2047)?(n=1,r=192):Jn(t,2048,65535)?(n=2,r=224):Jn(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var or,sr,cr,lr=t((()=>{or=-1,Qn.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():or},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},sr=-1,er.prototype={handler:function(e,t){}},tr.prototype={handler:function(e,t){}},cr=`utf-8`,nr.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=Yn(t),this._streaming||(this._decoder=new ir({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new Qn(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==sr);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===sr)break;if(a===null)continue;Array.isArray(a)?i.push.apply(i,a):i.push(a)}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),Zn(i)}},rr.prototype={encode:function(e,t){e=e?String(e):``,t=Yn(t),this._streaming||(this._encoder=new ar(this._options)),this._streaming=!!t.stream;for(var n=[],r=new Qn(Xn(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==sr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==sr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),ur=i((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeUnchecked=t.deserialize=t.serialize=t.BinaryReader=t.BinaryWriter=t.BorshError=t.baseDecode=t.baseEncode=void 0;var s=o(Rn()),c=o(Kn()),l=a((lr(),e(qn))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=Buffer.from(e,`utf8`)),c.default.encode(Buffer.from(e))}t.baseEncode=d;function f(e){return Buffer.from(c.default.decode(e))}t.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};t.BorshError=m;var h=class{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};t.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),t.BinaryReader=_;function v(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y(e,t,n,r,i){try{if(typeof r==`string`)i[`write${v(r)}`](n);else if(r instanceof Array)if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)y(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{y(e,t,n,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),y(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{y(e,t,a,r.key,i),y(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else b(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function b(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{y(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),y(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function x(e,t,n=h){let r=new n;return b(e,t,r),r.toArray()}t.serialize=x;function ee(e,t,n,r){try{if(typeof n==`string`)return r[`read${v(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(ee(e,null,n[0],r));return t}else return r.readArray(()=>ee(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?ee(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=ee(e,t,n.key,r),o=ee(e,t,n.value,r);i.set(a,o)}return i}return S(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function S(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=ee(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=ee(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function C(e,t,n,r=_){let i=new r(n),a=S(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}t.deserialize=C;function w(e,t,n,r=_){return S(e,t,new r(n))}t.deserializeUnchecked=w})),dr=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=o();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function s(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=s;var c=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=c;var l=class extends c{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=l;var u=class extends c{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof d||this.layout instanceof f}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=p;var m=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=m;var h=2**32;function g(e){let t=Math.floor(e/h);return{hi32:t,lo32:e-t*h}}function _(e,t){return e*h+t}var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return _(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return _(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=y;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return _(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=b;var x=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return _(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=x;var ee=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=ee;var S=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=S;var C=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=C;var w=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=w;var T=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof c&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof c)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof c&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof c&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof c&&this.count.encode(e.length,t,n),i}};e.Sequence=T;var E=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=E;var D=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=D;var O=class extends D{constructor(e,t){if(!(e instanceof c&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=O;var te=class extends i{constructor(e,t,n){let r;if(e instanceof d||e instanceof f)r=new O(new u(e));else if(e instanceof c&&e.isCount())r=new O(e);else if(e instanceof D)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof d||e instanceof f)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof d||e instanceof f,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new ne(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=te;var ne=class extends i{constructor(e,t,n,r){if(!(e instanceof te))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=ne;function k(e){return 0>e&&(e+=4294967296),e}var A=class extends i{constructor(e,t,n){if(!(e instanceof d||e instanceof f))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=k(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new re(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new ie(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=A;var re=class{constructor(e,t,n){if(!(e instanceof A))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=k(this.valueMask<<this.start),this.property=n}decode(e,t){return k(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==k(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=k(e<<this.start);this.container._packedSetValue(k(t&~this.wordMask)|n)}};e.BitField=re;var ie=class extends re{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=ie;var ae=class extends i{constructor(e,t){if(!(e instanceof c&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof c||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof c&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof c&&this.length.encode(i,t,n),i}};e.Blob=ae;var oe=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=oe;var se=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=se;var ce=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=ce,e.greedy=((e,t)=>new l(e,t)),e.offset=((e,t,n)=>new u(e,t,n)),e.u8=(e=>new d(1,e)),e.u16=(e=>new d(2,e)),e.u24=(e=>new d(3,e)),e.u32=(e=>new d(4,e)),e.u40=(e=>new d(5,e)),e.u48=(e=>new d(6,e)),e.nu64=(e=>new v(e)),e.u16be=(e=>new f(2,e)),e.u24be=(e=>new f(3,e)),e.u32be=(e=>new f(4,e)),e.u40be=(e=>new f(5,e)),e.u48be=(e=>new f(6,e)),e.nu64be=(e=>new y(e)),e.s8=(e=>new p(1,e)),e.s16=(e=>new p(2,e)),e.s24=(e=>new p(3,e)),e.s32=(e=>new p(4,e)),e.s40=(e=>new p(5,e)),e.s48=(e=>new p(6,e)),e.ns64=(e=>new b(e)),e.s16be=(e=>new m(2,e)),e.s24be=(e=>new m(3,e)),e.s32be=(e=>new m(4,e)),e.s40be=(e=>new m(5,e)),e.s48be=(e=>new m(6,e)),e.ns64be=(e=>new x(e)),e.f32=(e=>new ee(e)),e.f32be=(e=>new S(e)),e.f64=(e=>new C(e)),e.f64be=(e=>new w(e)),e.struct=((e,t,n)=>new E(e,t,n)),e.bits=((e,t,n)=>new A(e,t,n)),e.seq=((e,t,n)=>new T(e,t,n)),e.union=((e,t,n)=>new te(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new O(e,t)),e.blob=((e,t)=>new ae(e,t)),e.cstr=(e=>new oe(e)),e.utf8=((e,t)=>new se(e,t)),e.constant=((e,t)=>new ce(e,t))})),fr=ur(),F=n(dr()),pr=8078e3,mr=8078001,hr=8078004,gr=8078005,_r=8078006,vr=8078011;function yr(e){return Array.isArray(e)?`%5B`+e.map(yr).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function br([e,t]){return`${e}=${yr(t)}`}function xr(e){let t=Object.entries(e).map(br).join(`&`);return btoa(t)}function Sr(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${xr(t)}'`),`${n}\``}}var Cr=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=Sr(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}};function wr(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function Tr(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(wr(t,e));return e.write(t,n,0),n}})}function Er(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function Dr(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function Or(e,t){if(Dr(e)!==Dr(t))throw new Cr(hr);if(Dr(e)&&Dr(t)&&e.fixedSize!==t.fixedSize)throw new Cr(gr,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!Dr(e)&&!Dr(t)&&e.maxSize!==t.maxSize)throw new Cr(_r,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function kr(e,t,n=0){if(t.length-n<=0)throw new Cr(pr,{codecDescription:e})}function Ar(e,t,n,r=0){let i=n.length-r;if(i<t)throw new Cr(mr,{bytesLength:i,codecDescription:e,expected:t})}function jr(e,t,n,r){if(r<t||r>n)throw new Cr(vr,{codecDescription:e,max:n,min:t,value:r})}function Mr(e){return e?.endian!==1}function Nr(e){return Tr({fixedSize:e.size,write(t,n,r){e.range&&jr(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Mr(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function Pr(e){return Er({fixedSize:e.size,read(t,n=0){kr(e.name,t,n),Ar(e.name,e.size,t,n);let r=new DataView(Fr(t,n,e.size));return[e.get(r,Mr(e.config)),n+e.size]}})}function Fr(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var Ir=(e={})=>Nr({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),Lr=(e={})=>Pr({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),Rr=(e={})=>Or(Ir(e),Lr(e)),zr=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}};function Br(e){return Vr(e)&&typeof e[Symbol.iterator]==`function`}function Vr(e){return typeof e==`object`&&!!e}function Hr(e){return Vr(e)&&!Array.isArray(e)}function Ur(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function Wr(e){let{done:t,value:n}=e.next();return t?void 0:n}function Gr(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${Ur(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*Kr(e,t,n,r){Br(e)||(e=[e]);for(let i of e){let e=Gr(i,t,n,r);e&&(yield e)}}function*qr(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=qr(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):Vr(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}var Jr=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,r?this.validator=(e,t)=>Kr(r(e,t),t,this,e):this.validator=()=>[],i?this.refiner=(e,t)=>Kr(i(e,t),t,this,e):this.refiner=()=>[]}assert(e,t){return Yr(e,this,t)}create(e,t){return I(e,this,t)}is(e){return Zr(e,this)}mask(e,t){return Xr(e,this,t)}validate(e,t={}){return Qr(e,this,t)}};function Yr(e,t,n){let r=Qr(e,t,{message:n});if(r[0])throw r[0]}function I(e,t,n){let r=Qr(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function Xr(e,t,n){let r=Qr(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Zr(e,t){return!Qr(e,t)[0]}function Qr(e,t,n={}){let r=qr(e,t,n),i=Wr(r);return i[0]?[new zr(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function $r(e,t){return new Jr({type:e,schema:null,validator:t})}function ei(){return $r(`any`,()=>!0)}function L(e){return new Jr({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Ur(e)}`}})}function ti(){return $r(`boolean`,e=>typeof e==`boolean`)}function ni(e){return $r(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${Ur(t)}`)}function ri(e){let t=Ur(e),n=typeof e;return new Jr({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${Ur(n)}`}})}function ii(){return $r(`never`,()=>!1)}function R(e){return new Jr({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function z(){return $r(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${Ur(e)}`)}function B(e){return new Jr({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function ai(e,t){return new Jr({type:`record`,schema:null,*entries(n){if(Vr(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return Hr(e)||`Expected an object, but received: ${Ur(e)}`},coercer(e){return Hr(e)?{...e}:e}})}function V(){return $r(`string`,e=>typeof e==`string`||`Expected a string, but received: ${Ur(e)}`)}function oi(e){let t=ii();return new Jr({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Ur(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function H(e){let t=Object.keys(e);return new Jr({type:`type`,schema:e,*entries(n){if(Vr(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return Hr(e)||`Expected an object, but received: ${Ur(e)}`},coercer(e){return Hr(e)?{...e}:e}})}function si(e){let t=e.map(e=>e.type).join(` | `);return new Jr({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=qr(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Ur(n)}`,...i]}})}function ci(){return $r(`unknown`,()=>!0)}function li(e,t,n){return new Jr({...e,coercer:(r,i)=>Zr(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function ui(){if(!di&&(di=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!di))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return di(fi)}var di,fi,pi=t((()=>{fi=new Uint8Array(16)})),mi,hi=t((()=>{mi=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}));function gi(e){return typeof e==`string`&&mi.test(e)}var _i=t((()=>{hi()}));function vi(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(yi[e[t+0]]+yi[e[t+1]]+yi[e[t+2]]+yi[e[t+3]]+`-`+yi[e[t+4]]+yi[e[t+5]]+`-`+yi[e[t+6]]+yi[e[t+7]]+`-`+yi[e[t+8]]+yi[e[t+9]]+`-`+yi[e[t+10]]+yi[e[t+11]]+yi[e[t+12]]+yi[e[t+13]]+yi[e[t+14]]+yi[e[t+15]]).toLowerCase();if(!gi(n))throw TypeError(`Stringified UUID is invalid`);return n}var yi,bi,xi=t((()=>{for(_i(),yi=[],bi=0;bi<256;++bi)yi.push((bi+256).toString(16).substr(1))}));function Si(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||Ci,o=e.clockseq===void 0?wi:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||ui)();a??=Ci=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=wi=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?Ei+1:e.nsecs,u=c-Ti+(l-Ei)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>Ti)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);Ti=c,Ei=l,wi=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||vi(i)}var Ci,wi,Ti,Ei,Di=t((()=>{pi(),xi(),Ti=0,Ei=0}));function Oi(e){if(!gi(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var ki=t((()=>{_i()}));function Ai(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function ji(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Ai(e)),typeof r==`string`&&(r=Oi(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return vi(o)}try{r.name=e}catch{}return r.DNS=Mi,r.URL=Ni,r}var Mi,Ni,Pi=t((()=>{xi(),ki(),Mi=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Ni=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function Fi(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return Ii(Ri(zi(e),e.length*8))}function Ii(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function Li(e){return(e+64>>>9<<4)+14+1}function Ri(e,t){e[t>>5]|=128<<t%32,e[Li(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=Ui(n,r,i,a,e[o],7,-680876936),a=Ui(a,n,r,i,e[o+1],12,-389564586),i=Ui(i,a,n,r,e[o+2],17,606105819),r=Ui(r,i,a,n,e[o+3],22,-1044525330),n=Ui(n,r,i,a,e[o+4],7,-176418897),a=Ui(a,n,r,i,e[o+5],12,1200080426),i=Ui(i,a,n,r,e[o+6],17,-1473231341),r=Ui(r,i,a,n,e[o+7],22,-45705983),n=Ui(n,r,i,a,e[o+8],7,1770035416),a=Ui(a,n,r,i,e[o+9],12,-1958414417),i=Ui(i,a,n,r,e[o+10],17,-42063),r=Ui(r,i,a,n,e[o+11],22,-1990404162),n=Ui(n,r,i,a,e[o+12],7,1804603682),a=Ui(a,n,r,i,e[o+13],12,-40341101),i=Ui(i,a,n,r,e[o+14],17,-1502002290),r=Ui(r,i,a,n,e[o+15],22,1236535329),n=Wi(n,r,i,a,e[o+1],5,-165796510),a=Wi(a,n,r,i,e[o+6],9,-1069501632),i=Wi(i,a,n,r,e[o+11],14,643717713),r=Wi(r,i,a,n,e[o],20,-373897302),n=Wi(n,r,i,a,e[o+5],5,-701558691),a=Wi(a,n,r,i,e[o+10],9,38016083),i=Wi(i,a,n,r,e[o+15],14,-660478335),r=Wi(r,i,a,n,e[o+4],20,-405537848),n=Wi(n,r,i,a,e[o+9],5,568446438),a=Wi(a,n,r,i,e[o+14],9,-1019803690),i=Wi(i,a,n,r,e[o+3],14,-187363961),r=Wi(r,i,a,n,e[o+8],20,1163531501),n=Wi(n,r,i,a,e[o+13],5,-1444681467),a=Wi(a,n,r,i,e[o+2],9,-51403784),i=Wi(i,a,n,r,e[o+7],14,1735328473),r=Wi(r,i,a,n,e[o+12],20,-1926607734),n=Gi(n,r,i,a,e[o+5],4,-378558),a=Gi(a,n,r,i,e[o+8],11,-2022574463),i=Gi(i,a,n,r,e[o+11],16,1839030562),r=Gi(r,i,a,n,e[o+14],23,-35309556),n=Gi(n,r,i,a,e[o+1],4,-1530992060),a=Gi(a,n,r,i,e[o+4],11,1272893353),i=Gi(i,a,n,r,e[o+7],16,-155497632),r=Gi(r,i,a,n,e[o+10],23,-1094730640),n=Gi(n,r,i,a,e[o+13],4,681279174),a=Gi(a,n,r,i,e[o],11,-358537222),i=Gi(i,a,n,r,e[o+3],16,-722521979),r=Gi(r,i,a,n,e[o+6],23,76029189),n=Gi(n,r,i,a,e[o+9],4,-640364487),a=Gi(a,n,r,i,e[o+12],11,-421815835),i=Gi(i,a,n,r,e[o+15],16,530742520),r=Gi(r,i,a,n,e[o+2],23,-995338651),n=Ki(n,r,i,a,e[o],6,-198630844),a=Ki(a,n,r,i,e[o+7],10,1126891415),i=Ki(i,a,n,r,e[o+14],15,-1416354905),r=Ki(r,i,a,n,e[o+5],21,-57434055),n=Ki(n,r,i,a,e[o+12],6,1700485571),a=Ki(a,n,r,i,e[o+3],10,-1894986606),i=Ki(i,a,n,r,e[o+10],15,-1051523),r=Ki(r,i,a,n,e[o+1],21,-2054922799),n=Ki(n,r,i,a,e[o+8],6,1873313359),a=Ki(a,n,r,i,e[o+15],10,-30611744),i=Ki(i,a,n,r,e[o+6],15,-1560198380),r=Ki(r,i,a,n,e[o+13],21,1309151649),n=Ki(n,r,i,a,e[o+4],6,-145523070),a=Ki(a,n,r,i,e[o+11],10,-1120210379),i=Ki(i,a,n,r,e[o+2],15,718787259),r=Ki(r,i,a,n,e[o+9],21,-343485551),n=Bi(n,s),r=Bi(r,c),i=Bi(i,l),a=Bi(a,u)}return[n,r,i,a]}function zi(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(Li(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function Bi(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function Vi(e,t){return e<<t|e>>>32-t}function Hi(e,t,n,r,i,a){return Bi(Vi(Bi(Bi(t,e),Bi(r,a)),i),n)}function Ui(e,t,n,r,i,a,o){return Hi(t&n|~t&r,e,t,i,a,o)}function Wi(e,t,n,r,i,a,o){return Hi(t&r|n&~r,e,t,i,a,o)}function Gi(e,t,n,r,i,a,o){return Hi(t^n^r,e,t,i,a,o)}function Ki(e,t,n,r,i,a,o){return Hi(n^(t|~r),e,t,i,a,o)}var qi=t((()=>{})),Ji,Yi=t((()=>{Pi(),qi(),Ji=ji(`v3`,48,Fi)}));function Xi(e,t,n){e||={};var r=e.random||(e.rng||ui)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return vi(r)}var Zi=t((()=>{pi(),xi()}));function Qi(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function $i(e,t){return e<<t|e>>>32-t}function ea(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=$i(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],b=0;b<80;++b){var x=Math.floor(b/20),ee=$i(h,5)+Qi(x,g,_,v)+y+t[x]+f[b]>>>0;y=v,v=_,_=$i(g,30)>>>0,g=h,h=ee}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var ta=t((()=>{})),na,ra=t((()=>{Pi(),ta(),na=ji(`v5`,80,ea)})),ia,aa=t((()=>{ia=`00000000-0000-0000-0000-000000000000`}));function oa(e){if(!gi(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var sa=t((()=>{_i()})),ca=r({NIL:()=>ia,parse:()=>Oi,stringify:()=>vi,v1:()=>Si,v3:()=>Ji,v4:()=>Xi,v5:()=>na,validate:()=>gi,version:()=>oa}),la=t((()=>{Di(),Yi(),Zi(),ra(),aa(),sa(),_i(),xi(),ki()})),ua=i(((t,n)=>{var r=(la(),e(ca)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),da=n(i(((t,n)=>{var r=(la(),e(ca)).v4,i=ua(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`?t.notificationIdNull:!1},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a){r(e);return}throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){r(e);return}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t){n();return}let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){n(e);return}if(n.length===3)if(Array.isArray(r)){let e=function(e){return e.error!==void 0};n(null,r.filter(e),r.filter(function(t){return!e(t)}));return}else{n(null,r.error,r.result);return}n(null,r)}}))()),fa=class extends s.default{socket;constructor(e,t){super(),this.socket=new window.WebSocket(e,t.protocols),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function pa(e,t){return new fa(e,t)}var ma=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},ha=class extends s.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),c?this.dataPack=c:this.dataPack=new ma,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket&&this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=c.Buffer.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit(`max_reconnects_reached`,n,r),1))})}},ga=BigInt(0),_a=BigInt(1),va=BigInt(2),ya=BigInt(7),ba=BigInt(256),xa=BigInt(113),Sa=[],Ca=[],wa=[];for(let e=0,t=_a,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Sa.push(2*(5*r+n)),Ca.push((e+1)*(e+2)/2%64);let i=ga;for(let e=0;e<7;e++)t=(t<<_a^(t>>ya)*xa)%ba,t&va&&(i^=_a<<(_a<<BigInt(e))-_a);wa.push(i)}var Ta=pe(wa,!0),Ea=Ta[0],Da=Ta[1],Oa=(e,t,n)=>n>32?Se(e,t,n):be(e,t,n),ka=(e,t,n)=>n>32?Ce(e,t,n):xe(e,t,n);function Aa(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Oa(a,o,1)^n[r],c=ka(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Ca[n],a=Oa(t,i,r),o=ka(t,i,r),s=Sa[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=Ea[r],e[1]^=Da[r]}_(n)}var ja=class e extends A{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,d(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=g(this.state)}clone(){return this._cloneInto()}keccak(){S(this.state32),Aa(this.state32,this.rounds),S(this.state32),this.posOut=0,this.pos=0}update(e){m(this),e=ne(e),f(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){m(this,!1),f(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return d(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(h(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,_(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Ma=((e,t,n)=>re(()=>new ja(t,e,n)))(1,136,256/8),Na=class extends A{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,p(e);let n=ne(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),_(i)}update(e){return m(this),this.iHash.update(e),this}digestInto(e){m(this),f(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),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}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,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()}},Pa=(e,t,n)=>new Na(e,t).update(n).digest();Pa.create=(e,t)=>new Na(e,t);var Fa=(e,t)=>(e+(e>=0?t:-t)/Ha)/t;function Ia(e,t,n){let[[r,i],[a,o]]=t,s=Fa(o*e,n),c=Fa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Ba,f=u<Ba;d&&(l=-l),f&&(u=-u);let p=nt(Math.ceil(tt(n)/2))+Va;if(l<Ba||l>=p||u<Ba||u>=p)throw Error(`splitScalar (endomorphism): failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function La(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Ra(e,t){let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return He(n.lowS,`lowS`),He(n.prehash,`prehash`),n.format!==void 0&&La(n.format),n}var za={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=za;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=We(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?We(i.length/2|128):``;return We(e)+a+i+t},decode(e,t){let{Err:n}=za,r=0;if(e<0||e>256)throw new n(`tlv.encode: 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}=za;if(e<Ba)throw new t(`integer: negative integers are not allowed`);let n=We(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}=za;if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Ke(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=za,i=P(`signature`,e),{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}=za,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Ba=BigInt(0),Va=BigInt(1),Ha=BigInt(2),Ua=BigInt(3),Wa=BigInt(4);function Ga(e,t){let{BYTES:n}=e,r;if(typeof t==`bigint`)r=t;else{let i=P(`private key`,t);try{r=e.fromBytes(i)}catch{throw Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw Error(`invalid private key: out of range [1..N-1]`);return r}function Ka(e,t={}){let n=en(`weierstrass`,e,t),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o,n:s}=a;it(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,wrapPrivateKey:`boolean`});let{endo:c}=t;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 l=Ja(r,i);function u(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function d(e,t,n){let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return He(n,`isCompressed`),n?(u(),k(qa(!r.isOdd(a)),o)):k(Uint8Array.of(4),o,r.toBytes(a))}function f(e){Ue(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=l,i=e.length,a=e[0],o=e.subarray(1);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=h(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)}u();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else 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(!g(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let p=t.toBytes||d,m=t.fromBytes||f;function h(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 g(e,t){let n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!g(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let _=r.mul(r.pow(a.a,Ua),Wa),v=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(_,v)))throw Error(`bad curve params: a or b`);function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof w))throw Error(`ProjectivePoint expected`)}function x(e){if(!c||!c.basises)throw Error(`no endo`);return Ia(e,c.basises,i.ORDER)}let ee=ot((e,t)=>{let{X:n,Y:i,Z:a}=e;if(r.eql(a,r.ONE))return{x:n,y:i};let o=e.is0();t??=o?r.ONE:r.inv(a);let s=r.mul(n,t),c=r.mul(i,t),l=r.mul(a,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw Error(`invZ was invalid`);return{x:s,y:c}}),S=ot(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw Error(`bad point: ZERO`)}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(!g(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);return!0});function C(e,t,n,i,a){return n=new w(r.mul(n.X,e),n.Y,n.Z),t=zt(i,t),n=zt(a,n),t.add(n)}class w{constructor(e,t,n){this.X=y(`x`,e),this.Y=y(`y`,t,!0),this.Z=y(`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 w)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?w.ZERO:new w(t,n,r.ONE)}static fromBytes(e){let t=w.fromAffine(m(Ue(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return w.fromBytes(P(`pointHex`,e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return D.createCache(this,e),t||this.multiply(Ua),this}assertValidity(){S(this)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){b(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 w(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,Ua),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new w(c,l,u)}add(e){b(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,Ua),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new w(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(w.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw Error(`invalid scalar: out of range`);let r,a,o=e=>D.cached(this,e,e=>Bt(w,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=x(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=C(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return Bt(w,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this;if(!i.isValid(e))throw Error(`invalid scalar: out of range`);if(e===Ba||r.is0())return w.ZERO;if(e===Va)return r;if(D.hasCache(this))return this.multiply(e);if(n){let{k1neg:t,k1:i,k2neg:a,k2:o}=x(e),{p1:s,p2:c}=Zt(w,r,i,o);return C(n.beta,s,c,t,a)}else return D.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){let r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return ee(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return o===Va?!0:e?e(w,this):D.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Va?this:e?e(w,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return He(e,`isCompressed`),this.assertValidity(),p(w,this,e)}toHex(e=!0){return T(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Bt(w,e)}static msm(e,t){return Qt(w,i,e,t)}static fromPrivateKey(e){return w.BASE.multiply(Ga(i,e))}}w.BASE=new w(a.Gx,a.Gy,r.ONE),w.ZERO=new w(r.ZERO,r.ONE,r.ZERO),w.Fp=r,w.Fn=i;let E=i.BITS,D=new Xt(w,t.endo?Math.ceil(E/2):E);return w.BASE.precompute(8),w}function qa(e){return Uint8Array.of(e?2:3)}function Ja(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ya(e,t={}){let{Fn:n}=e,r=t.randomBytes||ie,i=Object.assign(Ja(e.Fp,n),{seed:Ft(n.ORDER)});function a(e){try{return!!Ga(n,e)}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=r(i.seed)){return It(Ue(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(Ga(n,t)).toBytes(r)}function l(e){let t=s(e);return{secretKey:t,publicKey:c(t)}}function u(t){if(typeof t==`bigint`)return!1;if(t instanceof e)return!0;let{secretKey:r,publicKey:a,publicKeyUncompressed:o}=i;if(n.allowedLengths||r===a)return;let s=P(`key`,t).length;return s===a||s===o}function d(t,r,i=!0){if(u(t)===!0)throw Error(`first arg must be private key`);if(u(r)===!1)throw Error(`second arg must be public key`);let a=Ga(n,t);return e.fromHex(r).multiply(a).toBytes(i)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:e,utils:{isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s,isValidPrivateKey:a,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ga(n,e),precompute(t=8,n=e.BASE){return n.precompute(t,!1)}},lengths:i})}function Xa(e,t,n={}){p(t),it(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let r=n.randomBytes||ie,i=n.hmac||((e,...n)=>Pa(t,e,k(...n))),{Fp:a,Fn:o}=e,{ORDER:s,BITS:c}=o,{keygen:l,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=Ya(e,n),g={prehash:!1,lowS:typeof n.lowS==`boolean`?n.lowS:!1,format:void 0,extraEntropy:!1},_=`compact`;function v(e){return e>s>>Va}function y(e,t){if(!o.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function b(e,t){La(t);let n=h.signature;return Ue(e,t===`compact`?n:t===`recovered`?n+1:void 0,`${t} signature`)}class x{constructor(e,t,n){this.r=y(`r`,e),this.s=y(`s`,t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=_){b(e,t);let n;if(t===`der`){let{r:t,s:n}=za.toSig(Ue(e));return new x(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=o.BYTES,i=e.subarray(0,r),a=e.subarray(r,r*2);return new x(o.fromBytes(i),o.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(O(e),t)}addRecoveryBit(e){return new x(this.r,this.s,e)}recoverPublicKey(t){let n=a.ORDER,{r,s:i,recovery:c}=this;if(c==null||![0,1,2,3].includes(c))throw Error(`recovery id invalid`);if(s*Ha<n&&c>1)throw Error(`recovery id is ambiguous for h>1 curve`);let l=c===2||c===3?r+s:r;if(!a.isValid(l))throw Error(`recovery id 2 or 3 invalid`);let u=a.toBytes(l),d=e.fromBytes(k(qa((c&1)==0),u)),f=o.inv(l),p=S(P(`msgHash`,t)),m=o.create(-p*f),h=o.create(i*f),g=e.BASE.multiplyUnsafe(m).add(d.multiplyUnsafe(h));if(g.is0())throw Error(`point at infinify`);return g.assertValidity(),g}hasHighS(){return v(this.s)}toBytes(e=_){if(La(e),e===`der`)return O(za.hexFromSig(this));let t=o.toBytes(this.r),n=o.toBytes(this.s);if(e===`recovered`){if(this.recovery==null)throw Error(`recovery bit must be present`);return k(Uint8Array.of(this.recovery),t,n)}return k(t,n)}toHex(e){return T(this.toBytes(e))}assertValidity(){}static fromCompact(e){return x.fromBytes(P(`sig`,e),`compact`)}static fromDER(e){return x.fromBytes(P(`sig`,e),`der`)}normalizeS(){return this.hasHighS()?new x(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes(`der`)}toDERHex(){return T(this.toBytes(`der`))}toCompactRawBytes(){return this.toBytes(`compact`)}toCompactHex(){return T(this.toBytes(`compact`))}}let ee=n.bits2int||function(e){if(e.length>8192)throw Error(`input is too large`);let t=Ke(e),n=e.length*8-c;return n>0?t>>BigInt(n):t},S=n.bits2int_modN||function(e){return o.create(ee(e))},C=nt(c);function w(e){return et(`num < 2^`+c,e,Ba,C),o.toBytes(e)}function E(e,n){return Ue(e,void 0,`message`),n?Ue(t(e),void 0,`prehashed message`):e}function D(t,n,i){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{lowS:a,prehash:s,extraEntropy:c}=Ra(i,g);t=E(t,s);let l=S(t),u=Ga(o,n),d=[w(u),w(l)];if(c!=null&&c!==!1){let e=c===!0?r(h.secretKey):c;d.push(P(`extraEntropy`,e))}let f=k(...d),p=l;function m(t){let n=ee(t);if(!o.isValidNot0(n))return;let r=o.inv(n),i=e.BASE.multiply(n).toAffine(),s=o.create(i.x);if(s===Ba)return;let c=o.create(r*o.create(p+s*u));if(c===Ba)return;let l=(i.x===s?0:2)|Number(i.y&Va),d=c;return a&&v(c)&&(d=o.neg(c),l^=1),new x(s,d,l)}return{seed:f,k2sig:m}}function te(e,n,r={}){e=P(`message`,e);let{seed:a,k2sig:s}=D(e,n,r);return rt(t.outputLen,o.BYTES,i)(a,s)}function ne(e){let t,n=typeof e==`string`||u(e),r=!n&&typeof e==`object`&&!!e&&typeof e.r==`bigint`&&typeof e.s==`bigint`;if(!n&&!r)throw Error(`invalid signature, expected Uint8Array, hex string or Signature instance`);if(r)t=new x(e.r,e.s);else if(n){try{t=x.fromBytes(P(`sig`,e),`der`)}catch(e){if(!(e instanceof za.Err))throw e}if(!t)try{t=x.fromBytes(P(`sig`,e),`compact`)}catch{return!1}}return t||!1}function A(t,n,r,i={}){let{lowS:a,prehash:s,format:c}=Ra(i,g);if(r=P(`publicKey`,r),n=E(P(`message`,n),s),`strict`in i)throw Error(`options.strict was renamed to lowS`);let l=c===void 0?ne(t):x.fromBytes(P(`sig`,t),c);if(l===!1)return!1;try{let t=e.fromBytes(r);if(a&&l.hasHighS())return!1;let{r:i,s}=l,c=S(n),u=o.inv(s),d=o.create(c*u),f=o.create(i*u),p=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));return p.is0()?!1:o.create(p.x)===i}catch{return!1}}function re(e,t,n={}){let{prehash:r}=Ra(n,g);return t=E(t,r),x.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:l,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:te,verify:A,recoverPublicKey:re,Signature:x,hash:t})}function Za(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Nt(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function Qa(e){let{CURVE:t,curveOpts:n}=Za(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function $a(e,t){let n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Mt(n.Fn.ORDER,n.Fn.BITS))})}function eo(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Qa(e);return $a(e,Xa(Ka(t,n),r,i))}function to(e,t){let n=t=>eo({...e,hash:t});return{...n(t),create:n}}var no={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},ro={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},io=BigInt(2);function ao(e){let t=no.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=vt(vt(vt(u,n,t)*u%t,n,t)*u%t,io,t)*l%t,f=vt(d,i,t)*d%t,p=vt(f,a,t)*f%t,m=vt(p,s,t)*p%t,h=vt(vt(vt(vt(vt(vt(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,io,t);if(!oo.eql(oo.sqr(h),e))throw Error(`Cannot find square root`);return h}var oo=Nt(no.p,{sqrt:ao}),so=to({...no,Fp:oo,lowS:!0,endo:ro},Re),co=r({Account:()=>So,AddressLookupTableAccount:()=>Ps,AddressLookupTableInstruction:()=>Ml,AddressLookupTableProgram:()=>Nl,Authorized:()=>Zl,BLOCKHASH_CACHE_TIMEOUT_MS:()=>Vs,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>Co,BPF_LOADER_PROGRAM_ID:()=>ys,BpfLoader:()=>bs,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>Fl,ComputeBudgetInstruction:()=>Pl,ComputeBudgetProgram:()=>Il,Connection:()=>kl,Ed25519Program:()=>Vl,Enum:()=>_o,EpochSchedule:()=>ks,FeeCalculatorLayout:()=>us,Keypair:()=>Al,LAMPORTS_PER_SOL:()=>bu,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>jl,Loader:()=>vs,Lockup:()=>Ql,MAX_SEED_LENGTH:()=>32,Message:()=>Uo,MessageAccountKeys:()=>ko,MessageV0:()=>Wo,NONCE_ACCOUNT_LENGTH:()=>fs,NonceAccount:()=>ps,PACKET_DATA_SIZE:()=>wo,PUBLIC_KEY_LENGTH:()=>32,PublicKey:()=>W,SIGNATURE_LENGTH_IN_BYTES:()=>64,SOLANA_SCHEMA:()=>vo,STAKE_CONFIG_ID:()=>Xl,STAKE_INSTRUCTION_LAYOUTS:()=>eu,SYSTEM_INSTRUCTION_LAYOUTS:()=>Q,SYSVAR_CLOCK_PUBKEY:()=>Zo,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>Qo,SYSVAR_INSTRUCTIONS_PUBKEY:()=>$o,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>es,SYSVAR_RENT_PUBKEY:()=>ts,SYSVAR_REWARDS_PUBKEY:()=>ns,SYSVAR_SLOT_HASHES_PUBKEY:()=>rs,SYSVAR_SLOT_HISTORY_PUBKEY:()=>is,SYSVAR_STAKE_HISTORY_PUBKEY:()=>as,Secp256k1Program:()=>Jl,SendTransactionError:()=>os,SolanaJSONRPCError:()=>Y,SolanaJSONRPCErrorCode:()=>ss,StakeAuthorizationLayout:()=>tu,StakeInstruction:()=>$l,StakeProgram:()=>nu,Struct:()=>go,SystemInstruction:()=>hs,SystemProgram:()=>gs,Transaction:()=>J,TransactionExpiredBlockheightExceededError:()=>Eo,TransactionExpiredNonceInvalidError:()=>Oo,TransactionExpiredTimeoutError:()=>Do,TransactionInstruction:()=>q,TransactionMessage:()=>Jo,TransactionStatus:()=>Ko,VALIDATOR_INFO_KEY:()=>cu,VERSION_PREFIX_MASK:()=>127,VOTE_PROGRAM_ID:()=>du,ValidatorInfo:()=>uu,VersionedMessage:()=>Go,VersionedTransaction:()=>Yo,VoteAccount:()=>pu,VoteAuthorizationLayout:()=>ou,VoteInit:()=>ru,VoteInstruction:()=>iu,VoteProgram:()=>su,clusterApiUrl:()=>vu,sendAndConfirmRawTransaction:()=>yu,sendAndConfirmTransaction:()=>cs}),lo=En.utils.randomPrivateKey,uo=()=>{let e=En.utils.randomPrivateKey(),t=fo(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},fo=En.getPublicKey;function po(e){try{return En.ExtendedPoint.fromHex(e),!0}catch{return!1}}var mo=(e,t)=>En.sign(e,t.slice(0,32)),ho=En.verify,U=e=>c.Buffer.isBuffer(e)?e:e instanceof Uint8Array?c.Buffer.from(e.buffer,e.byteOffset,e.byteLength):c.Buffer.from(e),go=class{constructor(e){Object.assign(this,e)}encode(){return c.Buffer.from((0,fr.serialize)(vo,this))}static decode(e){return(0,fr.deserialize)(vo,this,e)}static decodeUnchecked(e){return(0,fr.deserializeUnchecked)(vo,this,e)}},_o=class extends go{constructor(e){if(super(e),this.enum=``,Object.keys(e).length!==1)throw Error(`Enum can only take single value`);Object.keys(e).map(e=>{this.enum=e})}},vo=new Map,yo;function bo(e){return e._bn!==void 0}var xo=1,W=class e extends go{constructor(e){if(super({}),this._bn=void 0,bo(e))this._bn=e._bn;else{if(typeof e==`string`){let t=Un.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new Hn.default(t)}else this._bn=new Hn.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(xo);return xo+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Un.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(c.Buffer);if(e.length===32)return e;let t=c.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){return new e(Wn(c.Buffer.concat([t.toBuffer(),c.Buffer.from(n),r.toBuffer()])))}static createProgramAddressSync(t,n){let r=c.Buffer.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=c.Buffer.concat([r,U(e)])}),r=c.Buffer.concat([r,n.toBuffer(),c.Buffer.from(`ProgramDerivedAddress`)]);let i=Wn(r);if(po(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(c.Buffer.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return po(new e(t).toBytes())}};yo=W,W.default=new yo(`11111111111111111111111111111111`),vo.set(W,{kind:`struct`,fields:[[`_bn`,`u256`]]});var So=class{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=U(e);if(e.length!==64)throw Error(`bad secret key size`);this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=U(lo()),this._publicKey=U(fo(this._secretKey))}get publicKey(){return new W(this._publicKey)}get secretKey(){return c.Buffer.concat([this._secretKey,this._publicKey],64)}},Co=new W(`BPFLoader1111111111111111111111111111111111`),wo=1232,To=64,Eo=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Eo.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`});var Do=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Do.prototype,"name",{value:`TransactionExpiredTimeoutError`});var Oo=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Oo.prototype,"name",{value:`TransactionExpiredNonceInvalidError`});var ko=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},G=(e=`publicKey`)=>F.blob(32,e),Ao=(e=`signature`)=>F.blob(64,e),jo=(e=`string`)=>{let t=F.struct([F.u32(`length`),F.u32(`lengthPadding`),F.blob(F.offset(F.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>r({chars:c.Buffer.from(e,`utf8`)},t,n),i.alloc=e=>F.u32().span+F.u32().span+c.Buffer.from(e,`utf8`).length,i},Mo=(e=`authorized`)=>F.struct([G(`staker`),G(`withdrawer`)],e),No=(e=`lockup`)=>F.struct([F.ns64(`unixTimestamp`),F.ns64(`epoch`),G(`custodian`)],e),Po=(e=`voteInit`)=>F.struct([G(`nodePubkey`),G(`authorizedVoter`),G(`authorizedWithdrawer`),F.u8(`commission`)],e),Fo=(e=`voteAuthorizeWithSeedArgs`)=>F.struct([F.u32(`voteAuthorizationType`),G(`currentAuthorityDerivedKeyOwnerPubkey`),jo(`currentAuthorityDerivedKeySeed`),G(`newAuthorized`)],e);function Io(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return Io({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function Lo(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function Ro(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}else t|=128,e.push(t)}}function K(e,t){if(!e)throw Error(t||`Assertion failed`)}var zo=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];K(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{K(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];K(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new W(e)),...n.map(([e])=>new W(e)),...r.map(([e])=>new W(e)),...i.map(([e])=>new W(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(!(t.length===0&&r.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new W(i),a=e.findIndex(e=>e.equals(t));a>=0&&(K(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},Bo=`Reached end of buffer unexpectedly`;function Vo(e){if(e.length===0)throw Error(Bo);return e.shift()}function Ho(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(Bo);return e.splice(...t)}var Uo=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new W(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Un.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new ko(this.staticAccountKeys)}static compile(t){let[n,r]=zo.compile(t.instructions,t.payerKey).getMessageComponents(),i=new ko(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Un.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Ro(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(Un.default.decode(e.data)),i=[];Ro(i,t.length);let a=[];return Ro(a,r.length),{programIdIndex:n,keyIndicesCount:c.Buffer.from(i),keyIndices:t,dataLength:c.Buffer.from(a),data:r}}),r=[];Ro(r,n.length);let i=c.Buffer.alloc(wo);c.Buffer.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=F.struct([F.u8(`programIdIndex`),F.blob(e.keyIndicesCount.length,`keyIndicesCount`),F.seq(F.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),F.blob(e.dataLength.length,`dataLength`),F.seq(F.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=F.struct([F.blob(1,`numRequiredSignatures`),F.blob(1,`numReadonlySignedAccounts`),F.blob(1,`numReadonlyUnsignedAccounts`),F.blob(t.length,`keyCount`),F.seq(G(`key`),e,`keys`),G(`recentBlockhash`)]),s={numRequiredSignatures:c.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:c.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:c.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:c.Buffer.from(t),keys:this.accountKeys.map(e=>U(e.toBytes())),recentBlockhash:Un.default.decode(this.recentBlockhash)},l=c.Buffer.alloc(2048),u=o.encode(s,l);return i.copy(l,u),l.slice(0,u+i.length)}static from(t){let n=[...t],r=Vo(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=Vo(n),a=Vo(n),o=Lo(n),s=[];for(let e=0;e<o;e++){let e=Ho(n,0,32);s.push(new W(c.Buffer.from(e)))}let l=Ho(n,0,32),u=Lo(n),d=[];for(let e=0;e<u;e++){let e=Vo(n),t=Ho(n,0,Lo(n)),r=Ho(n,0,Lo(n)),i=Un.default.encode(c.Buffer.from(r));d.push({programIdIndex:e,accounts:t,data:i})}return new e({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:Un.default.encode(c.Buffer.from(l)),accountKeys:s,instructions:d})}},Wo=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new ko(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=zo.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new ko(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];Ro(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];Ro(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];Ro(i,this.addressTableLookups.length);let a=F.struct([F.u8(`prefix`),F.struct([F.u8(`numRequiredSignatures`),F.u8(`numReadonlySignedAccounts`),F.u8(`numReadonlyUnsignedAccounts`)],`header`),F.blob(e.length,`staticAccountKeysLength`),F.seq(G(),this.staticAccountKeys.length,`staticAccountKeys`),G(`recentBlockhash`),F.blob(n.length,`instructionsLength`),F.blob(t.length,`serializedInstructions`),F.blob(i.length,`addressTableLookupsLength`),F.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(wo),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:Un.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(wo);for(let n of this.compiledInstructions){let r=[];Ro(r,n.accountKeyIndexes.length);let i=[];Ro(i,n.data.length);let a=F.struct([F.u8(`programIdIndex`),F.blob(r.length,`encodedAccountKeyIndexesLength`),F.seq(F.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),F.blob(i.length,`encodedDataLength`),F.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(wo);for(let n of this.addressTableLookups){let r=[];Ro(r,n.writableIndexes.length);let i=[];Ro(i,n.readonlyIndexes.length);let a=F.struct([G(`accountKey`),F.blob(r.length,`encodedWritableIndexesLength`),F.seq(F.u8(),n.writableIndexes.length,`writableIndexes`),F.blob(i.length,`encodedReadonlyIndexesLength`),F.seq(F.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=Vo(n),i=r&127;K(r!==i,`Expected versioned message but received legacy message`);let a=i;K(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:Vo(n),numReadonlySignedAccounts:Vo(n),numReadonlyUnsignedAccounts:Vo(n)},s=[],c=Lo(n);for(let e=0;e<c;e++)s.push(new W(Ho(n,0,32)));let l=Un.default.encode(Ho(n,0,32)),u=Lo(n),d=[];for(let e=0;e<u;e++){let e=Vo(n),t=Ho(n,0,Lo(n)),r=Lo(n),i=new Uint8Array(Ho(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=Lo(n),p=[];for(let e=0;e<f;e++){let e=new W(Ho(n,0,32)),t=Ho(n,0,Lo(n)),r=Ho(n,0,Lo(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},Go={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=Go.deserializeMessageVersion(e);if(t===`legacy`)return Uo.from(e);if(t===0)return Wo.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},Ko=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),qo=c.Buffer.alloc(64).fill(0),q=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=c.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},J=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new q(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length<1&&console.warn(`No instructions provided`);let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new W(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0,console.warn(`Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release.`));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:Un.default.encode(t)}});return p.forEach(e=>{K(e.programIdIndex>=0),e.accounts.forEach(e=>K(e>=0))}),new Uo({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return t.has(n)?!1:(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=mo(n,e.secretKey);this._addSignature(e.publicKey,U(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){K(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=c.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):ho(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];Ro(n,t.length);let r=n.length+t.length*64+e.length,i=c.Buffer.alloc(r);return K(t.length<256),c.Buffer.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(K(e.length===64,`signature has invalid length`),c.Buffer.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),K(i.length<=wo,`Transaction too large: ${i.length} > ${wo}`),i}get keys(){return K(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return K(this.instructions.length===1),this.instructions[0].programId}get data(){return K(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=Lo(n),i=[];for(let e=0;e<r;e++){let e=Ho(n,0,64);i.push(Un.default.encode(c.Buffer.from(e)))}return e.populate(Uo.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==Un.default.encode(qo)?null:Un.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new q({keys:n,programId:t.accountKeys[e.programIdIndex],data:Un.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},Jo=class e{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(t,n){let{header:r,compiledInstructions:i,recentBlockhash:a}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:c}=r,l=o-s;K(l>0,`Message header is invalid`);let u=t.staticAccountKeys.length-o-c;K(u>=0,`Message header is invalid`);let d=t.getAccountKeys(n),f=d.get(0);if(f===void 0)throw Error(`Failed to decompile message because no account keys were found`);let p=[];for(let e of i){let t=[];for(let n of e.accountKeyIndexes){let e=d.get(n);if(e===void 0)throw Error(`Failed to find key for account key index ${n}`);let i=n<o,a;a=i?n<l:n<d.staticAccountKeys.length?n-o<u:n-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,t.push({pubkey:e,isSigner:n<r.numRequiredSignatures,isWritable:a})}let n=d.get(e.programIdIndex);if(n===void 0)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);p.push(new q({programId:n,data:U(e.data),keys:t}))}return new e({payerKey:f,instructions:p,recentBlockhash:a})}compileToLegacyMessage(){return Uo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Wo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}},Yo=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)K(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];Ro(t,this.signatures.length);let n=F.struct([F.blob(t.length,`encodedSignaturesLength`),F.seq(Ao(),this.signatures.length,`signatures`),F.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=Lo(n);for(let e=0;e<i;e++)r.push(new Uint8Array(Ho(n,0,64)));return new e(Go.deserialize(new Uint8Array(n)),r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));K(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=mo(t,r.secretKey)}}addSignature(e,t){K(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));K(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},Xo=1e3/(160/64),Zo=new W(`SysvarC1ock11111111111111111111111111111111`),Qo=new W(`SysvarEpochSchedu1e111111111111111111111111`),$o=new W(`Sysvar1nstructions1111111111111111111111111`),es=new W(`SysvarRecentB1ockHashes11111111111111111111`),ts=new W(`SysvarRent111111111111111111111111111111111`),ns=new W(`SysvarRewards111111111111111111111111111111`),rs=new W(`SysvarS1otHashes111111111111111111111111111`),is=new W(`SysvarS1otHistory11111111111111111111111111`),as=new W(`SysvarStakeHistory1111111111111111111111111`),os=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},ss={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},Y=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}};async function cs(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new os({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function ls(e){return new Promise(t=>setTimeout(t,e))}function X(e,t){let n=e.layout.span>=0?e.layout.span:Io(e,t),r=c.Buffer.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function Z(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.instruction!==e.index)throw Error(`invalid instruction; instruction index mismatch ${n.instruction} != ${e.index}`);return n}var us=F.nu64(`lamportsPerSignature`),ds=F.struct([F.u32(`version`),F.u32(`state`),G(`authorizedPubkey`),G(`nonce`),F.struct([us],`feeCalculator`)]),fs=ds.span,ps=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=ds.decode(U(t),0);return new e({authorizedPubkey:new W(n.authorizedPubkey),nonce:new W(n.nonce).toString(),feeCalculator:n.feeCalculator})}};function ms(e){let t=(0,F.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=Rr();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>r(a.encode(e),t,n),i}var hs=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=F.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(Q))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a SystemInstruction`);return n}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t,space:n,programId:r}=Z(Q.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new W(r)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=Z(Q.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:n,programId:r}=Z(Q.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new W(r)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=Z(Q.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,space:r,programId:i}=Z(Q.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new W(t),seed:n,space:r,programId:new W(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=Z(Q.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new W(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,programId:r}=Z(Q.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new W(t),seed:n,programId:new W(r)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:n,lamports:r,space:i,programId:a}=Z(Q.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new W(t),seed:n,lamports:r,space:i,programId:new W(a)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=Z(Q.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new W(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Z(Q.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Z(Q.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=Z(Q.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new W(t)}}static checkProgramId(e){if(!e.equals(gs.programId))throw Error(`invalid instruction; programId is not SystemProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},Q=Object.freeze({Create:{index:0,layout:F.struct([F.u32(`instruction`),F.ns64(`lamports`),F.ns64(`space`),G(`programId`)])},Assign:{index:1,layout:F.struct([F.u32(`instruction`),G(`programId`)])},Transfer:{index:2,layout:F.struct([F.u32(`instruction`),ms(`lamports`)])},CreateWithSeed:{index:3,layout:F.struct([F.u32(`instruction`),G(`base`),jo(`seed`),F.ns64(`lamports`),F.ns64(`space`),G(`programId`)])},AdvanceNonceAccount:{index:4,layout:F.struct([F.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:F.struct([F.u32(`instruction`),F.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:F.struct([F.u32(`instruction`),G(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:F.struct([F.u32(`instruction`),G(`authorized`)])},Allocate:{index:8,layout:F.struct([F.u32(`instruction`),F.ns64(`space`)])},AllocateWithSeed:{index:9,layout:F.struct([F.u32(`instruction`),G(`base`),jo(`seed`),F.ns64(`space`),G(`programId`)])},AssignWithSeed:{index:10,layout:F.struct([F.u32(`instruction`),G(`base`),jo(`seed`),G(`programId`)])},TransferWithSeed:{index:11,layout:F.struct([F.u32(`instruction`),ms(`lamports`),jo(`seed`),G(`programId`)])},UpgradeNonceAccount:{index:12,layout:F.struct([F.u32(`instruction`)])}}),gs=class e{constructor(){}static createAccount(e){let t=Q.Create,n=X(t,{lamports:e.lamports,space:e.space,programId:U(e.programId.toBuffer())});return new q({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=Q.TransferWithSeed;t=X(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=Q.Transfer;t=X(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new q({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=Q.AssignWithSeed;t=X(r,{base:U(e.basePubkey.toBuffer()),seed:e.seed,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Q.Assign;t=X(r,{programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new q({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=Q.CreateWithSeed,n=X(t,{base:U(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:U(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new q({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new J;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:fs,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:fs,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=Q.InitializeNonceAccount,n=X(t,{authorized:U(e.authorizedPubkey.toBuffer())});return new q({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1},{pubkey:ts,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static nonceAdvance(e){let t=Q.AdvanceNonceAccount,n=X(t);return new q({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceWithdraw(e){let t=Q.WithdrawNonceAccount,n=X(t,{lamports:e.lamports});return new q({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=Q.AuthorizeNonceAccount,n=X(t,{authorized:U(e.newAuthorizedPubkey.toBuffer())});return new q({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=Q.AllocateWithSeed;t=X(r,{base:U(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Q.Allocate;t=X(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new q({keys:n,programId:this.programId,data:t})}};gs.programId=new W(`11111111111111111111111111111111`);var _s=wo-300,vs=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return console.error(`Program load failed, account is already executable`),!1;o.data.length!==a.length&&(s||=new J,s.add(gs.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new J,s.add(gs.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new J,s.add(gs.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new J().add(gs.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await cs(t,s,[n,r],{commitment:`confirmed`})}let o=F.struct([F.u32(`instruction`),F.u32(`offset`),F.u32(`bytesLength`),F.u32(`bytesLengthPadding`),F.seq(F.u8(`byte`),F.offset(F.u32(),-8),`bytes`)]),s=e.chunkSize,l=0,u=a,d=[];for(;u.length>0;){let e=u.slice(0,s),a=c.Buffer.alloc(s+16);o.encode({instruction:0,offset:l,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let f=new J().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});d.push(cs(t,f,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await ls(1e3/4),l+=s,u=u.slice(s)}await Promise.all(d);{let e=F.struct([F.u32(`instruction`)]),a=c.Buffer.alloc(e.span);e.encode({instruction:1},a);let o=new J().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,l=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:u,value:d}=await t.confirmTransaction({signature:l,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(d.err)throw Error(`Transaction ${l} failed (${JSON.stringify(d)})`);for(;;){try{if(await t.getSlot({commitment:s})>u.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(Xo/2)))}}return!0}};vs.chunkSize=_s;var ys=new W(`BPFLoader2111111111111111111111111111111111`),bs=class{static getMinNumSignatures(e){return vs.getMinNumSignatures(e)}static load(e,t,n,r,i){return vs.load(e,t,n,i,r)}};function xs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Ss,Cs;function ws(){if(Cs)return Ss;Cs=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}else if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}else return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ss=function(e){var t=n(e,!1);if(t!==void 0)return``+t},Ss}var Ts=xs(ws()),Es=32;function Ds(e){let t=0;for(;e>1;)e/=2,t++;return t}function Os(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}var ks=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=Ds(Os(e+Es+1))-Ds(Es)-1;return[t,e-(this.getSlotsInEpoch(t)-Es)]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Es:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+Ds(Es)):this.slotsPerEpoch}},As=globalThis.fetch,js=class extends ha{constructor(e,t,n){super(e=>{let n=pa(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}};function Ms(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}var Ns=56,Ps=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=Ms(Fs,e),n=e.length-Ns;K(n>=0,`lookup table is invalid`),K(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=F.struct([F.seq(G(),r,`addresses`)]).decode(e.slice(Ns));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new W(t.authority[0]),addresses:i.map(e=>new W(e))}}},Fs={index:1,layout:F.struct([F.u32(`typeIndex`),ms(`deactivationSlot`),F.nu64(`lastExtendedSlot`),F.u8(`lastExtendedStartIndex`),F.u8(),F.seq(G(),F.offset(F.u8(),-1),`authority`)])},Is=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Ls(e){let t=e.match(Is);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}var Rs=li(ni(W),V(),e=>new W(e)),zs=oi([V(),ri(`base64`)]),Bs=li(ni(c.Buffer),zs,e=>c.Buffer.from(e[0],`base64`)),Vs=30*1e3;function Hs(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Us(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Ws(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function Gs(e){return si([H({jsonrpc:ri(`2.0`),id:V(),result:e}),H({jsonrpc:ri(`2.0`),id:V(),error:H({code:ci(),message:V(),data:B(ei())})})])}var Ks=Gs(ci());function $(e){return li(Gs(e),Ks,t=>`error`in t?t:{...t,result:I(t.result,e)})}function qs(e){return $(H({context:H({slot:z()}),value:e}))}function Js(e){return H({context:H({slot:z()}),value:e})}function Ys(e,t){return e===0?new Wo({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new W(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Un.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Uo(t)}var Xs=H({foundation:z(),foundationTerm:z(),initial:z(),taper:z(),terminal:z()}),Zs=$(L(R(H({epoch:z(),effectiveSlot:z(),amount:z(),postBalance:z(),commission:B(R(z()))})))),Qs=L(H({slot:z(),prioritizationFee:z()})),$s=H({total:z(),validator:z(),foundation:z(),epoch:z()}),ec=H({epoch:z(),slotIndex:z(),slotsInEpoch:z(),absoluteSlot:z(),blockHeight:B(z()),transactionCount:B(z())}),tc=H({slotsPerEpoch:z(),leaderScheduleSlotOffset:z(),warmup:ti(),firstNormalEpoch:z(),firstNormalSlot:z()}),nc=ai(V(),L(z())),rc=R(si([H({}),V()])),ic=H({err:rc}),ac=ri(`receivedSignature`),oc=H({"solana-core":V(),"feature-set":B(z())}),sc=H({program:V(),programId:Rs,parsed:ci()}),cc=H({programId:Rs,accounts:L(Rs),data:V()}),lc=qs(H({err:R(si([H({}),V()])),logs:R(L(V())),accounts:B(R(L(R(H({executable:ti(),owner:V(),lamports:z(),data:L(V()),rentEpoch:B(z())}))))),unitsConsumed:B(z()),returnData:B(R(H({programId:V(),data:oi([V(),ri(`base64`)])}))),innerInstructions:B(R(L(H({index:z(),instructions:L(si([sc,cc]))}))))})),uc=qs(H({byIdentity:ai(V(),L(z())),range:H({firstSlot:z(),lastSlot:z()})}));function dc(e,t,n,r,i,a){let o=n||As;a!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let s;return r&&(s=async(e,t)=>await o(...await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}}))),new da.default(async(n,r)=>{let a={method:`POST`,body:n,agent:void 0,headers:Object.assign({"Content-Type":`application/json`},t||{},Ol)};try{let t=5,n,c=500;for(;n=s?await s(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)console.error(`Server responded with ${n.status} ${n.statusText}. Retrying after ${c}ms delay...`),await ls(c),c*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function fc(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function pc(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}var mc=$(Xs),hc=$($s),gc=$(Qs),_c=$(ec),vc=$(tc),yc=$(nc),bc=$(z()),xc=qs(H({total:z(),circulating:z(),nonCirculating:z(),nonCirculatingAccounts:L(Rs)})),Sc=H({amount:V(),uiAmount:R(z()),decimals:z(),uiAmountString:B(V())}),Cc=qs(L(H({address:Rs,amount:V(),uiAmount:R(z()),decimals:z(),uiAmountString:B(V())}))),wc=qs(L(H({pubkey:Rs,account:H({executable:ti(),owner:Rs,lamports:z(),data:Bs,rentEpoch:z()})}))),Tc=H({program:V(),parsed:ci(),space:z()}),Ec=qs(L(H({pubkey:Rs,account:H({executable:ti(),owner:Rs,lamports:z(),data:Tc,rentEpoch:z()})}))),Dc=qs(L(H({lamports:z(),address:Rs}))),Oc=H({executable:ti(),owner:Rs,lamports:z(),data:Bs,rentEpoch:z()}),kc=H({pubkey:Rs,account:Oc}),Ac=li(si([ni(c.Buffer),Tc]),si([zs,Tc]),e=>Array.isArray(e)?I(e,Bs):e),jc=H({executable:ti(),owner:Rs,lamports:z(),data:Ac,rentEpoch:z()}),Mc=H({pubkey:Rs,account:jc}),Nc=H({state:si([ri(`active`),ri(`inactive`),ri(`activating`),ri(`deactivating`)]),active:z(),inactive:z()}),Pc=$(L(H({signature:V(),slot:z(),err:rc,memo:R(V()),blockTime:B(R(z()))}))),Fc=$(L(H({signature:V(),slot:z(),err:rc,memo:R(V()),blockTime:B(R(z()))}))),Ic=H({subscription:z(),result:Js(Oc)}),Lc=H({pubkey:Rs,account:Oc}),Rc=H({subscription:z(),result:Js(Lc)}),zc=H({parent:z(),slot:z(),root:z()}),Bc=H({subscription:z(),result:zc}),Vc=si([H({type:si([ri(`firstShredReceived`),ri(`completed`),ri(`optimisticConfirmation`),ri(`root`)]),slot:z(),timestamp:z()}),H({type:ri(`createdBank`),parent:z(),slot:z(),timestamp:z()}),H({type:ri(`frozen`),slot:z(),timestamp:z(),stats:H({numTransactionEntries:z(),numSuccessfulTransactions:z(),numFailedTransactions:z(),maxTransactionsPerEntry:z()})}),H({type:ri(`dead`),slot:z(),timestamp:z(),err:V()})]),Hc=H({subscription:z(),result:Vc}),Uc=H({subscription:z(),result:Js(si([ic,ac]))}),Wc=H({subscription:z(),result:z()}),Gc=H({pubkey:V(),gossip:R(V()),tpu:R(V()),rpc:R(V()),version:R(V())}),Kc=H({votePubkey:V(),nodePubkey:V(),activatedStake:z(),epochVoteAccount:ti(),epochCredits:L(oi([z(),z(),z()])),commission:z(),lastVote:z(),rootSlot:R(z())}),qc=$(H({current:L(Kc),delinquent:L(Kc)})),Jc=si([ri(`processed`),ri(`confirmed`),ri(`finalized`)]),Yc=qs(L(R(H({slot:z(),confirmations:R(z()),err:rc,confirmationStatus:B(Jc)})))),Xc=$(z()),Zc=H({accountKey:Rs,writableIndexes:L(z()),readonlyIndexes:L(z())}),Qc=H({signatures:L(V()),message:H({accountKeys:L(V()),header:H({numRequiredSignatures:z(),numReadonlySignedAccounts:z(),numReadonlyUnsignedAccounts:z()}),instructions:L(H({accounts:L(z()),data:V(),programIdIndex:z()})),recentBlockhash:V(),addressTableLookups:B(L(Zc))})}),$c=H({pubkey:Rs,signer:ti(),writable:ti(),source:B(si([ri(`transaction`),ri(`lookupTable`)]))}),el=H({accountKeys:L($c),signatures:L(V())}),tl=H({parsed:ci(),program:V(),programId:Rs}),nl=H({accounts:L(Rs),data:V(),programId:Rs}),rl=li(si([nl,tl]),si([H({parsed:ci(),program:V(),programId:V()}),H({accounts:L(V()),data:V(),programId:V()})]),e=>`accounts`in e?I(e,nl):I(e,tl)),il=H({signatures:L(V()),message:H({accountKeys:L($c),instructions:L(rl),recentBlockhash:V(),addressTableLookups:B(R(L(Zc)))})}),al=H({accountIndex:z(),mint:V(),owner:B(V()),programId:B(V()),uiTokenAmount:Sc}),ol=H({writable:L(Rs),readonly:L(Rs)}),sl=H({err:rc,fee:z(),innerInstructions:B(R(L(H({index:z(),instructions:L(H({accounts:L(z()),data:V(),programIdIndex:z()}))})))),preBalances:L(z()),postBalances:L(z()),logMessages:B(R(L(V()))),preTokenBalances:B(R(L(al))),postTokenBalances:B(R(L(al))),loadedAddresses:B(ol),computeUnitsConsumed:B(z()),costUnits:B(z())}),cl=H({err:rc,fee:z(),innerInstructions:B(R(L(H({index:z(),instructions:L(rl)})))),preBalances:L(z()),postBalances:L(z()),logMessages:B(R(L(V()))),preTokenBalances:B(R(L(al))),postTokenBalances:B(R(L(al))),loadedAddresses:B(ol),computeUnitsConsumed:B(z()),costUnits:B(z())}),ll=si([ri(0),ri(`legacy`)]),ul=H({pubkey:V(),lamports:z(),postBalance:R(z()),rewardType:R(V()),commission:B(R(z()))}),dl=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),transactions:L(H({transaction:Qc,meta:R(sl),version:B(ll)})),rewards:B(L(ul)),blockTime:R(z()),blockHeight:R(z())}))),fl=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),rewards:B(L(ul)),blockTime:R(z()),blockHeight:R(z())}))),pl=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),transactions:L(H({transaction:el,meta:R(sl),version:B(ll)})),rewards:B(L(ul)),blockTime:R(z()),blockHeight:R(z())}))),ml=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),transactions:L(H({transaction:il,meta:R(cl),version:B(ll)})),rewards:B(L(ul)),blockTime:R(z()),blockHeight:R(z())}))),hl=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),transactions:L(H({transaction:el,meta:R(cl),version:B(ll)})),rewards:B(L(ul)),blockTime:R(z()),blockHeight:R(z())}))),gl=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),rewards:B(L(ul)),blockTime:R(z()),blockHeight:R(z())}))),_l=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),transactions:L(H({transaction:Qc,meta:R(sl)})),rewards:B(L(ul)),blockTime:R(z())}))),vl=$(R(H({blockhash:V(),previousBlockhash:V(),parentSlot:z(),signatures:L(V()),blockTime:R(z())}))),yl=$(R(H({slot:z(),meta:R(sl),blockTime:B(R(z())),transaction:Qc,version:B(ll)}))),bl=$(R(H({slot:z(),transaction:il,meta:R(cl),blockTime:B(R(z())),version:B(ll)}))),xl=qs(H({blockhash:V(),lastValidBlockHeight:z()})),Sl=qs(ti()),Cl=$(L(H({slot:z(),numTransactions:z(),numSlots:z(),samplePeriodSecs:z()}))),wl=qs(R(H({feeCalculator:H({lamportsPerSignature:z()})}))),Tl=$(V()),El=$(V()),Dl=H({result:Js(H({err:rc,logs:L(V()),signature:V()})),subscription:z()}),Ol={"solana-client":`js/1.0.0-maintenance`},kl=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Us(t),i=this._buildArgs([],n,void 0,r),a=Ts(i);return e[a]=e[a]??(async()=>{try{let e=I(await this._rpcRequest(`getBlockHeight`,i),$(z()));if(`error`in e)throw new Y(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Hs(e),this._rpcWsEndpoint=n||Ls(e),this._rpcClient=dc(e,r,i,a,o,s),this._rpcRequest=fc(this._rpcClient),this._rpcBatchRequest=pc(this._rpcClient),this._rpcWebSocket=new js(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=I(await this._rpcRequest(`getBalance`,i),qs(z()));if(`error`in a)throw new Y(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=I(await this._rpcRequest(`getBlockTime`,[e]),$(R(z())));if(`error`in t)throw new Y(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=I(await this._rpcRequest(`minimumLedgerSlot`,[]),$(z()));if(`error`in e)throw new Y(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=I(await this._rpcRequest(`getFirstAvailableBlock`,[]),bc);if(`error`in e)throw new Y(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=I(await this._rpcRequest(`getSupply`,[t]),xc);if(`error`in n)throw new Y(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=I(await this._rpcRequest(`getTokenSupply`,n),qs(Sc));if(`error`in r)throw new Y(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=I(await this._rpcRequest(`getTokenAccountBalance`,n),qs(Sc));if(`error`in r)throw new Y(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Us(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=I(await this._rpcRequest(`getTokenAccountsByOwner`,o),wc);if(`error`in s)throw new Y(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=I(await this._rpcRequest(`getTokenAccountsByOwner`,i),Ec);if(`error`in a)throw new Y(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=I(await this._rpcRequest(`getLargestAccounts`,n),Dc);if(`error`in r)throw new Y(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=I(await this._rpcRequest(`getTokenLargestAccounts`,n),Cc);if(`error`in r)throw new Y(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=I(await this._rpcRequest(`getAccountInfo`,i),qs(R(Oc)));if(`error`in a)throw new Y(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=I(await this._rpcRequest(`getAccountInfo`,i),qs(R(jc)));if(`error`in a)throw new Y(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=I(await this._rpcRequest(`getMultipleAccounts`,a),qs(L(R(jc))));if(`error`in o)throw new Y(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=I(await this._rpcRequest(`getMultipleAccounts`,a),qs(L(R(Oc))));if(`error`in o)throw new Y(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Us(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=I(await this._rpcRequest(`getStakeActivation`,a),$(Nc));if(`error`in o)throw new Y(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Us(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Ws(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=L(kc),l=a.withContext===!0?I(s,qs(c)):I(s,$(c));if(`error`in l)throw new Y(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=I(await this._rpcRequest(`getProgramAccounts`,i),$(L(Mc)));if(`error`in a)throw new Y(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=Un.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return K(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:Ko.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null)if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return;break;case`processed`:case`recent`:}i=!0,a({__type:Ko.PROCESSED,response:{context:r,value:c}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await ls(1e3),i||(e=await r(),i))return;t({__type:Ko.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===Ko.PROCESSED)l=e.response;else throw new Eo(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:Ko.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await ls(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===Ko.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await ls(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new Oo(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new Oo(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new Oo(a);break;default:(e=>{})(t)}d={context:r.context,value:{err:r.value.err}}}else throw new Oo(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||60*1e3;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||30*1e3;break}n=setTimeout(()=>t({__type:Ko.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===Ko.PROCESSED)o=e.response;else throw new Do(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=I(await this._rpcRequest(`getClusterNodes`,[]),$(L(Gc)));if(`error`in e)throw new Y(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=I(await this._rpcRequest(`getVoteAccounts`,t),qc);if(`error`in n)throw new Y(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=I(await this._rpcRequest(`getSlot`,r),$(z()));if(`error`in i)throw new Y(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=I(await this._rpcRequest(`getSlotLeader`,r),$(V()));if(`error`in i)throw new Y(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=I(await this._rpcRequest(`getSlotLeaders`,n),$(L(Rs)));if(`error`in r)throw new Y(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return K(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=I(await this._rpcRequest(`getSignatureStatuses`,n),Yc);if(`error`in r)throw new Y(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=I(await this._rpcRequest(`getTransactionCount`,r),$(z()));if(`error`in i)throw new Y(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=I(await this._rpcRequest(`getInflationGovernor`,t),mc);if(`error`in n)throw new Y(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Us(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=I(await this._rpcRequest(`getInflationReward`,a),Zs);if(`error`in o)throw new Y(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=I(await this._rpcRequest(`getInflationRate`,[]),hc);if(`error`in e)throw new Y(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=I(await this._rpcRequest(`getEpochInfo`,r),_c);if(`error`in i)throw new Y(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=I(await this._rpcRequest(`getEpochSchedule`,[]),vc);if(`error`in e)throw new Y(e.error,`failed to get epoch schedule`);let t=e.result;return new ks(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=I(await this._rpcRequest(`getLeaderSchedule`,[]),yc);if(`error`in e)throw new Y(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=I(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Xc);return`error`in r?(console.warn(`Unable to fetch minimum balance for rent exemption`),0):r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=I(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Cl);if(`error`in t)throw new Y(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=I(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),wl);if(`error`in r)throw new Y(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=U(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=I(await this._rpcRequest(`getFeeForMessage`,r),qs(R(z())));if(`error`in i)throw new Y(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=I(await this._rpcRequest(`getRecentPrioritizationFees`,n),gc);if(`error`in r)throw new Y(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=I(await this._rpcRequest(`getLatestBlockhash`,r),xl);if(`error`in i)throw new Y(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e],n,void 0,r),a=I(await this._rpcRequest(`isBlockhashValid`,i),Sl);if(`error`in a)throw new Y(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=I(await this._rpcRequest(`getVersion`,[]),$(oc));if(`error`in e)throw new Y(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=I(await this._rpcRequest(`getGenesisHash`,[]),$(V()));if(`error`in e)throw new Y(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=I(a,pl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=I(a,fl);if(`error`in e)throw e.error;return e.result}default:{let e=I(a,dl);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Ys(n,e.message)},version:n}))}:null}}}catch(e){throw new Y(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=I(a,hl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=I(a,gl);if(`error`in e)throw e.error;return e.result}default:{let e=I(a,ml);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new Y(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=I(await this._rpcRequest(`getBlockProduction`,r),uc);if(`error`in i)throw new Y(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=I(await this._rpcRequest(`getTransaction`,i),yl);if(`error`in a)throw new Y(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Ys(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=I(await this._rpcRequest(`getTransaction`,i),bl);if(`error`in a)throw new Y(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=I(e,bl);if(`error`in t)throw new Y(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=I(e,yl);if(`error`in t)throw new Y(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Ys(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=I(await this._rpcRequest(`getBlock`,n),_l);if(`error`in r)throw new Y(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new Uo(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:J.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=I(await this._rpcRequest(`getBlocks`,r),$(L(z())));if(`error`in i)throw new Y(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=I(await this._rpcRequest(`getBlock`,n),vl);if(`error`in r)throw new Y(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=I(await this._rpcRequest(`getBlock`,n),vl);if(`error`in r)throw new Y(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=I(await this._rpcRequest(`getTransaction`,n),yl);if(`error`in r)throw new Y(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new Uo(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:J.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=I(await this._rpcRequest(`getTransaction`,n),bl);if(`error`in r)throw new Y(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=I(e,bl);if(`error`in t)throw new Y(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=I(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),Pc);if(`error`in i)throw new Y(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=I(await this._rpcRequest(`getSignaturesForAddress`,r),Fc);if(`error`in i)throw new Y(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new Ps({key:e,state:Ps.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=ps.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=I(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),Tl);if(`error`in n)throw new Y(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await ls(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Vs;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await ls(Xo/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,`base64`,n),i=I(await this._rpcRequest(`getStakeMinimumDelegation`,r),qs(z()));if(`error`in i)throw new Y(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=c.Buffer.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=I(await this._rpcRequest(`simulateTransaction`,o),lc);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof J){let t=e;r=new J,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=J.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}else e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),l={encoding:`base64`,commitment:this.commitment};n&&(l.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(l.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(l.innerInstructions=t.innerInstructions);let u=[s,l],d=I(await this._rpcRequest(`simulateTransaction`,u),lc);if(`error`in d){let e;if(`data`in d.error&&(e=d.error.data.logs,e&&Array.isArray(e))){let t=`
|
|
2
|
+
`,n=t+e.join(t);console.error(d.error.message,n)}throw new os({action:`simulate`,signature:``,transactionMessage:d.error.message,logs:e})}return d.result}async sendTransaction(e,t,n){if(`version`in e){if(t&&Array.isArray(t))throw Error(`Invalid arguments`);let n=e.serialize();return await this.sendRawTransaction(n,t)}if(t===void 0||!Array.isArray(t))throw Error(`Invalid arguments`);let r=t;if(e.nonceInfo)e.sign(...r);else{let t=this._disableBlockhashCaching;for(;;){let n=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=n.lastValidBlockHeight,e.recentBlockhash=n.blockhash,e.sign(...r),!e.signature)throw Error(`!signature`);let i=e.signature.toString(`base64`);if(this._blockhashInfo.transactionSignatures.includes(i))t=!0;else{this._blockhashInfo.transactionSignatures.push(i);break}}}let i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=U(e).toString(`base64`);return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:`base64`},r=t&&t.skipPreflight,i=r===!0?`processed`:t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);let a=[e,n],o=I(await this._rpcRequest(`sendTransaction`,a),El);if(`error`in o){let e;throw`data`in o.error&&(e=o.error.data.logs),new os({action:r?`send`:`simulate`,signature:``,transactionMessage:o.error.message,logs:e})}return o.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify(`ping`)}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error(`ws error:`,e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%(2**53-1),this._rpcWebSocketIdleTimeout&&=(clearTimeout(this._rpcWebSocketIdleTimeout),null),this._rpcWebSocketHeartbeat&&=(clearInterval(this._rpcWebSocketHeartbeat),null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:`pending`})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let n=this._subscriptionStateChangeCallbacksByHash[e];n&&n.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(t),()=>{r.delete(t),r.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let n=this._subscriptionsByHash[e];if(n!==void 0)switch(n.state){case`pending`:case`unsubscribed`:if(n.callbacks.size===0){delete this._subscriptionsByHash[e],n.state===`unsubscribed`&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:r,method:i}=n;try{this._setSubscription(e,{...n,state:`subscribing`});let t=await this._rpcWebSocket.call(i,r);this._setSubscription(e,{...n,serverSubscriptionId:t,state:`subscribed`}),this._subscriptionCallbacksByServerSubscriptionId[t]=n.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?``:`JSON-RPC `}error calling \`${i}\``,{args:r,error:a}),!t())return;this._setSubscription(e,{...n,state:`pending`}),await this._updateSubscriptions()}})();break;case`subscribed`:n.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(e,{...n,state:`unsubscribing`}),this._setSubscription(e,{...n,state:`unsubscribing`});try{await this._rpcWebSocket.call(i,[r])}catch(r){if(r instanceof Error&&console.error(`${i} error:`,r.message),!t())return;this._setSubscription(e,{...n,state:`subscribed`}),await this._updateSubscriptions();return}}this._setSubscription(e,{...n,state:`unsubscribed`}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=I(e,Ic);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,r=Ts([e.method,t]),i=this._subscriptionsByHash[r];return i===void 0?this._subscriptionsByHash[r]={...e,args:t,callbacks:new Set([e.callback]),state:`pending`}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let t=this._subscriptionsByHash[r];K(t!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:r,config:i}=Us(n),a=this._buildArgs([e.toBase58()],r||this._commitment||`finalized`,`base64`,i);return this._makeSubscription({callback:t,method:`accountSubscribe`,unsubscribeMethod:`accountUnsubscribe`},a)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`account change`)}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=I(e,Rc);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){let{commitment:i,config:a}=Us(n),o=this._buildArgs([e.toBase58()],i||this._commitment||`finalized`,`base64`,a||(r?{filters:Ws(r)}:void 0));return this._makeSubscription({callback:t,method:`programSubscribe`,unsubscribeMethod:`programUnsubscribe`},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`program account change`)}onLogs(e,t,n){let r=this._buildArgs([typeof e==`object`?{mentions:[e.toString()]}:e],n||this._commitment||`finalized`);return this._makeSubscription({callback:t,method:`logsSubscribe`,unsubscribeMethod:`logsUnsubscribe`},r)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,`logs`)}_wsOnLogsNotification(e){let{result:t,subscription:n}=I(e,Dl);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=I(e,Bc);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:`slotSubscribe`,unsubscribeMethod:`slotUnsubscribe`},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,`slot change`)}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=I(e,Hc);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:`slotsUpdatesSubscribe`,unsubscribeMethod:`slotsUpdatesUnsubscribe`},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,`slot update`)}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,r){let i=t||this._commitment;if(i||n||r){let t={};n&&(t.encoding=n),i&&(t.commitment=i),r&&(t=Object.assign(t,r)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,n,r){let i=t||this._commitment;if(i&&![`confirmed`,`finalized`].includes(i))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,r)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=I(e,Uc);t.value!==`receivedSignature`&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value===`receivedSignature`?[{type:`received`},t.context]:[{type:`status`,result:t.value},t.context])}onSignature(e,t,n){let r=this._buildArgs([e],n||this._commitment||`finalized`),i=this._makeSubscription({callback:(e,n)=>{if(e.type===`status`){t(e.result,n);try{this.removeSignatureListener(i)}catch{}}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},r);return i}onSignatureWithOptions(e,t,n){let{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||`finalized`},a=this._buildArgs([e],r,void 0,i),o=this._makeSubscription({callback:(e,n)=>{t(e,n);try{this.removeSignatureListener(o)}catch{}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},a);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,`signature result`)}_wsOnRootNotification(e){let{result:t,subscription:n}=I(e,Wc);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:`rootSubscribe`,unsubscribeMethod:`rootUnsubscribe`},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,`root change`)}},Al=class e{constructor(e){this._keypair=void 0,this._keypair=e??uo()}static generate(){return new e(uo())}static fromSecretKey(t,n){if(t.byteLength!==64)throw Error(`bad secret key size`);let r=t.slice(32,64);if(!n||!n.skipValidation){let e=fo(t.slice(0,32));for(let t=0;t<32;t++)if(r[t]!==e[t])throw Error(`provided secretKey is invalid`)}return new e({publicKey:r,secretKey:t})}static fromSeed(t){let n=fo(t),r=new Uint8Array(64);return r.set(t),r.set(n,32),new e({publicKey:n,secretKey:r})}get publicKey(){return new W(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},jl=Object.freeze({CreateLookupTable:{index:0,layout:F.struct([F.u32(`instruction`),ms(`recentSlot`),F.u8(`bumpSeed`)])},FreezeLookupTable:{index:1,layout:F.struct([F.u32(`instruction`)])},ExtendLookupTable:{index:2,layout:F.struct([F.u32(`instruction`),ms(),F.seq(G(),F.offset(F.u32(),-8),`addresses`)])},DeactivateLookupTable:{index:3,layout:F.struct([F.u32(`instruction`)])},CloseLookupTable:{index:4,layout:F.struct([F.u32(`instruction`)])}}),Ml=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=F.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(jl))if(r.index==t){n=e;break}if(!n)throw Error(`Invalid Instruction. Should be a LookupTable Instruction`);return n}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);let{recentSlot:t}=Z(jl.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);let{addresses:t}=Z(jl.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(e=>new W(e))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Nl.programId))throw Error(`invalid instruction; programId is not AddressLookupTable Program`)}static checkKeysLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},Nl=class{constructor(){}static createLookupTable(e){let[t,n]=W.findProgramAddressSync([e.authority.toBuffer(),Ir().encode(e.recentSlot)],this.programId),r=jl.CreateLookupTable,i=X(r,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gs.programId,isSigner:!1,isWritable:!1}];return[new q({programId:this.programId,keys:a,data:i}),t]}static freezeLookupTable(e){let t=jl.FreezeLookupTable,n=X(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new q({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){let t=jl.ExtendLookupTable,n=X(t,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gs.programId,isSigner:!1,isWritable:!1}),new q({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){let t=jl.DeactivateLookupTable,n=X(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new q({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){let t=jl.CloseLookupTable,n=X(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new q({programId:this.programId,keys:r,data:n})}};Nl.programId=new W(`AddressLookupTab1e1111111111111111111111111`);var Pl=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=F.u8(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(Fl))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a ComputeBudgetInstruction`);return n}static decodeRequestUnits(e){this.checkProgramId(e.programId);let{units:t,additionalFee:n}=Z(Fl.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);let{bytes:t}=Z(Fl.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);let{units:t}=Z(Fl.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);let{microLamports:t}=Z(Fl.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Il.programId))throw Error(`invalid instruction; programId is not ComputeBudgetProgram`)}},Fl=Object.freeze({RequestUnits:{index:0,layout:F.struct([F.u8(`instruction`),F.u32(`units`),F.u32(`additionalFee`)])},RequestHeapFrame:{index:1,layout:F.struct([F.u8(`instruction`),F.u32(`bytes`)])},SetComputeUnitLimit:{index:2,layout:F.struct([F.u8(`instruction`),F.u32(`units`)])},SetComputeUnitPrice:{index:3,layout:F.struct([F.u8(`instruction`),ms(`microLamports`)])}}),Il=class{constructor(){}static requestUnits(e){let t=Fl.RequestUnits,n=X(t,e);return new q({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Fl.RequestHeapFrame,n=X(t,e);return new q({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Fl.SetComputeUnitLimit,n=X(t,e);return new q({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Fl.SetComputeUnitPrice,n=X(t,{microLamports:BigInt(e.microLamports)});return new q({keys:[],programId:this.programId,data:n})}};Il.programId=new W(`ComputeBudget111111111111111111111111111111`);var Ll=64,Rl=32,zl=64,Bl=F.struct([F.u8(`numSignatures`),F.u8(`padding`),F.u16(`signatureOffset`),F.u16(`signatureInstructionIndex`),F.u16(`publicKeyOffset`),F.u16(`publicKeyInstructionIndex`),F.u16(`messageDataOffset`),F.u16(`messageDataSize`),F.u16(`messageInstructionIndex`)]),Vl=class e{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,instructionIndex:a}=t;K(n.length===Rl,`Public Key must be ${Rl} bytes but received ${n.length} bytes`),K(i.length===zl,`Signature must be ${zl} bytes but received ${i.length} bytes`);let o=Bl.span,s=o+n.length,l=s+i.length,u=c.Buffer.alloc(l+r.length),d=a??65535;return Bl.encode({numSignatures:1,padding:0,signatureOffset:s,signatureInstructionIndex:d,publicKeyOffset:o,publicKeyInstructionIndex:d,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:d},u),u.fill(n,o),u.fill(i,s),u.fill(r,l),new q({keys:[],programId:e.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;K(t.length===Ll,`Private key must be ${Ll} bytes but received ${t.length} bytes`);try{let e=Al.fromSecretKey(t),i=e.publicKey.toBytes(),a=mo(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Vl.programId=new W(`Ed25519SigVerify111111111111111111111111111`);var Hl=(e,t)=>{let n=so.sign(e,t);return[n.toCompactRawBytes(),n.recovery]};so.utils.isValidPrivateKey;var Ul=so.getPublicKey,Wl=32,Gl=20,Kl=64,ql=F.struct([F.u8(`numSignatures`),F.u16(`signatureOffset`),F.u8(`signatureInstructionIndex`),F.u16(`ethAddressOffset`),F.u8(`ethAddressInstructionIndex`),F.u16(`messageDataOffset`),F.u16(`messageDataSize`),F.u8(`messageInstructionIndex`),F.blob(20,`ethAddress`),F.blob(64,`signature`),F.u8(`recoveryId`)]),Jl=class e{constructor(){}static publicKeyToEthAddress(e){K(e.length===Kl,`Public key must be ${Kl} bytes but received ${e.length} bytes`);try{return c.Buffer.from(Ma(U(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,recoveryId:a,instructionIndex:o}=t;return e.createInstructionWithEthAddress({ethAddress:e.publicKeyToEthAddress(n),message:r,signature:i,recoveryId:a,instructionIndex:o})}static createInstructionWithEthAddress(t){let{ethAddress:n,message:r,signature:i,recoveryId:a,instructionIndex:o=0}=t,s;s=typeof n==`string`?n.startsWith(`0x`)?c.Buffer.from(n.substr(2),`hex`):c.Buffer.from(n,`hex`):n,K(s.length===Gl,`Address must be ${Gl} bytes but received ${s.length} bytes`);let l=12+s.length,u=l+i.length+1,d=c.Buffer.alloc(ql.span+r.length);return ql.encode({numSignatures:1,signatureOffset:l,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:o,signature:U(i),ethAddress:U(s),recoveryId:a},d),d.fill(U(r),ql.span),new q({keys:[],programId:e.programId,data:d})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;K(t.length===Wl,`Private key must be ${Wl} bytes but received ${t.length} bytes`);try{let e=U(t),i=Ul(e,!1).slice(1),[a,o]=Hl(c.Buffer.from(Ma(U(n))),e);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,recoveryId:o,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Jl.programId=new W(`KeccakSecp256k11111111111111111111111111111`);var Yl,Xl=new W(`StakeConfig11111111111111111111111111111111`),Zl=class{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}},Ql=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}};Yl=Ql,Ql.default=new Yl(0,0,W.default);var $l=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=F.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(eu))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a StakeInstruction`);return n}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t,lockup:n}=Z(eu.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new Zl(new W(t.staker),new W(t.withdrawer)),lockup:new Ql(n.unixTimestamp,n.epoch,new W(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),Z(eu.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,stakeAuthorizationType:n}=Z(eu.Authorize,e.data),r={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new W(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(r.custodianPubkey=e.keys[3].pubkey),r}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:r,authorityOwner:i}=Z(eu.AuthorizeWithSeed,e.data),a={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:r,authorityOwner:new W(i),newAuthorizedPubkey:new W(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(a.custodianPubkey=e.keys[3].pubkey),a}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=Z(eu.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Z(eu.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Z(eu.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Z(eu.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(nu.programId))throw Error(`invalid instruction; programId is not StakeProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},eu=Object.freeze({Initialize:{index:0,layout:F.struct([F.u32(`instruction`),Mo(),No()])},Authorize:{index:1,layout:F.struct([F.u32(`instruction`),G(`newAuthorized`),F.u32(`stakeAuthorizationType`)])},Delegate:{index:2,layout:F.struct([F.u32(`instruction`)])},Split:{index:3,layout:F.struct([F.u32(`instruction`),F.ns64(`lamports`)])},Withdraw:{index:4,layout:F.struct([F.u32(`instruction`),F.ns64(`lamports`)])},Deactivate:{index:5,layout:F.struct([F.u32(`instruction`)])},Merge:{index:7,layout:F.struct([F.u32(`instruction`)])},AuthorizeWithSeed:{index:8,layout:F.struct([F.u32(`instruction`),G(`newAuthorized`),F.u32(`stakeAuthorizationType`),jo(`authoritySeed`),G(`authorityOwner`)])}}),tu=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),nu=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:r}=e,i=r||Ql.default,a=eu.Initialize,o=X(a,{authorized:{staker:U(n.staker.toBuffer()),withdrawer:U(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:U(i.custodian.toBuffer())}});return new q({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1}],programId:this.programId,data:o})}static createAccountWithSeed(e){let t=new J;t.add(gs.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(e){let t=new J;t.add(gs.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:r}=e,i=eu.Delegate,a=X(i);return new J().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:as,isSigner:!1,isWritable:!1},{pubkey:Xl,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:a}=e,o=eu.Authorize,s=X(o,{newAuthorized:U(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zo,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new J().add({keys:c,programId:this.programId,data:s})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:a,stakeAuthorizationType:o,custodianPubkey:s}=e,c=eu.AuthorizeWithSeed,l=X(c,{newAuthorized:U(a.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:U(i.toBuffer())}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Zo,isSigner:!1,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new J().add({keys:u,programId:this.programId,data:l})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,a=eu.Split,o=X(a,{lamports:i});return new q({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(e,t){let n=new J;return n.add(gs.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:a,seed:o,lamports:s}=e,c=new J;return c.add(gs.allocate({accountPubkey:i,basePubkey:a,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(gs.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:s}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:r}=e,i=eu.Merge,a=X(i);return new J().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:as,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:a}=e,o=eu.Withdraw,s=X(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:as,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new J().add({keys:c,programId:this.programId,data:s})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,r=eu.Deactivate,i=X(r);return new J().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};nu.programId=new W(`Stake11111111111111111111111111111111111111`),nu.space=200;var ru=class{constructor(e,t,n,r){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=r}},iu=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=F.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(au))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a VoteInstruction`);return n}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);let{voteInit:t}=Z(au.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new ru(new W(t.nodePubkey),new W(t.authorizedVoter),new W(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,voteAuthorizationType:n}=Z(au.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new W(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:r,voteAuthorizationType:i}}=Z(au.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new W(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new W(r),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=Z(au.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(su.programId))throw Error(`invalid instruction; programId is not VoteProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},au=Object.freeze({InitializeAccount:{index:0,layout:F.struct([F.u32(`instruction`),Po()])},Authorize:{index:1,layout:F.struct([F.u32(`instruction`),G(`newAuthorized`),F.u32(`voteAuthorizationType`)])},Withdraw:{index:3,layout:F.struct([F.u32(`instruction`),F.ns64(`lamports`)])},UpdateValidatorIdentity:{index:4,layout:F.struct([F.u32(`instruction`)])},AuthorizeWithSeed:{index:10,layout:F.struct([F.u32(`instruction`),Fo()])}}),ou=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),su=class e{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=au.InitializeAccount,a=X(i,{voteInit:{nodePubkey:U(r.nodePubkey.toBuffer()),authorizedVoter:U(r.authorizedVoter.toBuffer()),authorizedWithdrawer:U(r.authorizedWithdrawer.toBuffer()),commission:r.commission}});return new q({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static createAccount(e){let t=new J;return t.add(gs.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=e,a=au.Authorize,o=X(a,{newAuthorized:U(r.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new J().add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:a,votePubkey:o}=e,s=au.AuthorizeWithSeed,c=X(s,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:U(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:U(i.toBuffer()),voteAuthorizationType:a.index}}),l=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:Zo,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new J().add({keys:l,programId:this.programId,data:c})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,a=au.Withdraw,o=X(a,{lamports:r}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new J().add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,n,r){if(t.lamports>n-r)throw Error(`Withdraw will leave vote account with insufficient funds.`);return e.withdraw(t)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=au.UpdateValidatorIdentity,a=X(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new J().add({keys:o,programId:this.programId,data:a})}};su.programId=new W(`Vote111111111111111111111111111111111111111`),su.space=3762;var cu=new W(`Va1idator1nfo111111111111111111111111111111`),lu=H({name:V(),website:B(V()),details:B(V()),iconUrl:B(V()),keybaseUsername:B(V())}),uu=class e{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(t){let n=[...t];if(Lo(n)!==2)return null;let r=[];for(let e=0;e<2;e++){let e=new W(Ho(n,0,32)),t=Vo(n)===1;r.push({publicKey:e,isSigner:t})}if(r[0].publicKey.equals(cu)&&r[1].isSigner){let t=jo().decode(c.Buffer.from(n)),i=JSON.parse(t);return Yr(i,lu),new e(r[1].publicKey,i)}return null}},du=new W(`Vote111111111111111111111111111111111111111`),fu=F.struct([G(`nodePubkey`),G(`authorizedWithdrawer`),F.u8(`commission`),F.nu64(),F.seq(F.struct([F.nu64(`slot`),F.u32(`confirmationCount`)]),F.offset(F.u32(),-8),`votes`),F.u8(`rootSlotValid`),F.nu64(`rootSlot`),F.nu64(),F.seq(F.struct([F.nu64(`epoch`),G(`authorizedVoter`)]),F.offset(F.u32(),-8),`authorizedVoters`),F.struct([F.seq(F.struct([G(`authorizedPubkey`),F.nu64(`epochOfLastAuthorizedSwitch`),F.nu64(`targetEpoch`)]),32,`buf`),F.nu64(`idx`),F.u8(`isEmpty`)],`priorVoters`),F.nu64(),F.seq(F.struct([F.nu64(`epoch`),F.nu64(`credits`),F.nu64(`prevCredits`)]),F.offset(F.u32(),-8),`epochCredits`),F.struct([F.nu64(`slot`),F.nu64(`timestamp`)],`lastTimestamp`)]),pu=class e{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(t){let n=fu.decode(U(t),4),r=n.rootSlot;return n.rootSlotValid||(r=null),new e({nodePubkey:new W(n.nodePubkey),authorizedWithdrawer:new W(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:r,authorizedVoters:n.authorizedVoters.map(mu),priorVoters:gu(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}};function mu({authorizedVoter:e,epoch:t}){return{epoch:t,authorizedVoter:new W(e)}}function hu({authorizedPubkey:e,epochOfLastAuthorizedSwitch:t,targetEpoch:n}){return{authorizedPubkey:new W(e),epochOfLastAuthorizedSwitch:t,targetEpoch:n}}function gu({buf:e,idx:t,isEmpty:n}){return n?[]:[...e.slice(t+1).map(hu),...e.slice(0,t).map(hu)]}var _u={http:{devnet:`http://api.devnet.solana.com`,testnet:`http://api.testnet.solana.com`,"mainnet-beta":`http://api.mainnet-beta.solana.com/`},https:{devnet:`https://api.devnet.solana.com`,testnet:`https://api.testnet.solana.com`,"mainnet-beta":`https://api.mainnet-beta.solana.com/`}};function vu(e,t){let n=t===!1?`http`:`https`;if(!e)return _u[n].devnet;let r=_u[n][e];if(!r)throw Error(`Unknown ${n} cluster: ${e}`);return r}async function yu(e,t,n,r){let i,a;n&&Object.prototype.hasOwnProperty.call(n,`lastValidBlockHeight`)||n&&Object.prototype.hasOwnProperty.call(n,`nonceValue`)?(i=n,a=r):a=n;let o=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},s=await e.sendRawTransaction(t,o),c=a&&a.commitment,l=(await(i?e.confirmTransaction(i,c):e.confirmTransaction(s,c))).value;if(l.err)throw s==null?Error(`Raw transaction ${s} failed (${JSON.stringify(l)})`):new os({action:o?.skipPreflight?`send`:`simulate`,signature:s,transactionMessage:`Status: (${JSON.stringify(l)})`});return s}var bu=1e9;export{J as a,Yo as c,gs as i,co as l,W as n,q as o,To as r,Go as s,kl as t};
|