@camera.ui/server 2.1.14 → 2.1.15
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/interface/assets/{404-DRo8zW0F.js → 404-DwgMdXqW.js} +1 -1
- package/dist/interface/assets/{About-DMjE0Qte.js → About-REFUgZk_.js} +1 -1
- package/dist/interface/assets/{Automation-BLolxsX8.js → Automation-DThD-djr.js} +3 -3
- package/dist/interface/assets/{AutomationImport-C_rR9kDq.js → AutomationImport-CHKkZqA4.js} +2 -2
- package/dist/interface/assets/{AutomationStore-whk_TeCG.js → AutomationStore-Aon4kqZU.js} +2 -2
- package/dist/interface/assets/{AutomationStoreDetail-BDDgg3zY.js → AutomationStoreDetail-CfZ45tLW.js} +2 -2
- package/dist/interface/assets/{Automations-sEIWIfdE.js → Automations-BkRuMd-d.js} +2 -2
- package/dist/interface/assets/{Camera-l1DApD8b.js → Camera-G6xTnRAk.js} +2 -2
- package/dist/interface/assets/{CameraConsole-CP_kwVq7.js → CameraConsole-S61HjIGA.js} +1 -1
- package/dist/interface/assets/{Cameras-Bp6P5eQC.js → Cameras-57rPP3Y_.js} +1 -1
- package/dist/interface/assets/{Camview-CWS3VJ1A.js → Camview-BjCuw7nI.js} +1 -1
- package/dist/interface/assets/{CertificateUpload-CA2PrWb3.js → CertificateUpload-CBSLHn_I.js} +1 -1
- package/dist/interface/assets/{Config-C02ndytC.js → Config-BTXb1LHN.js} +1 -1
- package/dist/interface/assets/{ConfigActionCameraControl-BODp6yd4.js → ConfigActionCameraControl-B7KwK7vb.js} +1 -1
- package/dist/interface/assets/{ConfigActionDelay-ChQOPeXL.js → ConfigActionDelay-DwTGfeP4.js} +1 -1
- package/dist/interface/assets/{ConfigActionHttp-BVeQKfLN.js → ConfigActionHttp-idm-FKXM.js} +1 -1
- package/dist/interface/assets/{ConfigActionImageInput-B99__kdP.js → ConfigActionImageInput-C-v-_UEM.js} +1 -1
- package/dist/interface/assets/{ConfigActionMqtt-D595Lo5y.js → ConfigActionMqtt-CG1o9_6A.js} +1 -1
- package/dist/interface/assets/{ConfigActionNotification-DxzLPmUf.js → ConfigActionNotification-DtoP3c7I.js} +1 -1
- package/dist/interface/assets/{ConfigActionNotificationControl-Bp4yWebz.js → ConfigActionNotificationControl-BvHIqHE7.js} +1 -1
- package/dist/interface/assets/{ConfigActionOutput-Di3KaQ_P.js → ConfigActionOutput-BQvDZGKV.js} +1 -1
- package/dist/interface/assets/{ConfigActionPlugin-B7vbDV9n.js → ConfigActionPlugin-C7mcZ0Kz.js} +1 -1
- package/dist/interface/assets/{ConfigActionSensor-Qj0c8MZq.js → ConfigActionSensor-BFnb75FI.js} +1 -1
- package/dist/interface/assets/{ConfigActionSnapshot-159QrEMJ.js → ConfigActionSnapshot-BfzPScY6.js} +1 -1
- package/dist/interface/assets/{ConfigActionVariable-Bodvejrx.js → ConfigActionVariable-CjIeZnOV.js} +1 -1
- package/dist/interface/assets/{ConfigConditionIfElse-BMI_mgi3.js → ConfigConditionIfElse-Dgcqs9QP.js} +1 -1
- package/dist/interface/assets/{ConfigConditionSensorState-DkwjHr31.js → ConfigConditionSensorState-DtLt1AvW.js} +1 -1
- package/dist/interface/assets/{ConfigConditionSwitch-ZlqOfRQE.js → ConfigConditionSwitch-C6BfIozf.js} +1 -1
- package/dist/interface/assets/{ConfigConditionTime-B2igg9Tb.js → ConfigConditionTime-NcjSe4RM.js} +1 -1
- package/dist/interface/assets/{ConfigSensorValueInput-DMnkNDC_.js → ConfigSensorValueInput-DuvBl4YL.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerDetection-C_ujxraC.js → ConfigTriggerDetection-DsVb-Svo.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerGeofence-DnYSaLPb.js → ConfigTriggerGeofence-DLuNWaN6.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerManual-BVIiZfOj.js → ConfigTriggerManual-vG37zALd.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerMqtt-B7Tf1jOh.js → ConfigTriggerMqtt-BPl_Puje.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerSchedule-CcvA02N3.js → ConfigTriggerSchedule-Bn2drGV5.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerSensor-CHCDeFmR.js → ConfigTriggerSensor-DP0CXRLo.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerSystem-0SeQnHSX.js → ConfigTriggerSystem-DQikAjbB.js} +1 -1
- package/dist/interface/assets/{ConfigTriggerWebhook-t0tFjZ7V.js → ConfigTriggerWebhook-Cl7KWuRQ.js} +1 -1
- package/dist/interface/assets/{Console-B3xhLOhl.js → Console-hUeddOJc.js} +1 -1
- package/dist/interface/assets/{CuiAutomationRunsDialog-hZJsv95Y.js → CuiAutomationRunsDialog-D_rNvqan.js} +1 -1
- package/dist/interface/assets/CuiBottomSheet-BGVpKjqe.js +1 -0
- package/dist/interface/assets/{CuiBottomSheet-Cv_fwvYu.js → CuiBottomSheet-DOW6gNj0.js} +1 -1
- package/dist/interface/assets/{CuiCameraPipCard-Bm6wjm6h.js → CuiCameraPipCard-BBMkU-eN.js} +1 -1
- package/dist/interface/assets/{CuiCameraRecordings-4LLV-U85.js → CuiCameraRecordings-h6Yel4J4.js} +1 -1
- package/dist/interface/assets/{CuiCameraShares-DqmX3koT.js → CuiCameraShares-C9Th3jEn.js} +1 -1
- package/dist/interface/assets/{CuiCameraTable-CkAeMqcZ.js → CuiCameraTable-CfXoLbtY.js} +1 -1
- package/dist/interface/assets/CuiCameraTable-Cti7FZma.js +1 -0
- package/dist/interface/assets/{CuiChartTable-CZXvn_Iy.js → CuiChartTable-BWRwoTLX.js} +1 -1
- package/dist/interface/assets/{CuiConsole-CW8Q43cq.js → CuiConsole-Cb3wDLZr.js} +1 -1
- package/dist/interface/assets/{CuiDataTable-cN03N7lr.js → CuiDataTable-aAZV_F3r.js} +1 -1
- package/dist/interface/assets/{CuiLightControl-CA8MAVex.js → CuiLightControl-BhBIiPv-.js} +1 -1
- package/dist/interface/assets/{CuiList-BI488Ne9.js → CuiList-BZYxCLqz.js} +1 -1
- package/dist/interface/assets/{CuiPluginCard-Bj6cUIJ0.js → CuiPluginCard-yYGvVtDJ.js} +2 -2
- package/dist/interface/assets/{CuiPluginCategoryChip-5YBKOVmo.js → CuiPluginCategoryChip-C9trJ_ql.js} +1 -1
- package/dist/interface/assets/{CuiPluginOAuthButton-BmdfXNce.js → CuiPluginOAuthButton-C8VRPoMj.js} +2 -2
- package/dist/interface/assets/{CuiPluginTrustBadge-BFpziu4f.js → CuiPluginTrustBadge-D5gkIhJv.js} +1 -1
- package/dist/interface/assets/{CuiQRCode-CiWTLo9T.js → CuiQRCode-DY5Q-Xel.js} +1 -1
- package/dist/interface/assets/{CuiSchema-DntSkCO2.js → CuiSchema-Dy2eRCu2.js} +1 -1
- package/dist/interface/assets/{CuiTopNavbarItem-DuzCbIZ8.js → CuiTopNavbarItem-Btig8IUi.js} +1 -1
- package/dist/interface/assets/{Faces-Bea5pIop.js → Faces-D5PMl5Bx.js} +1 -1
- package/dist/interface/assets/{FirstSteps-BNbQsYHq.js → FirstSteps-BcjeaLz_.js} +1 -1
- package/dist/interface/assets/{Floorplan-D9zKFQ2q.js → Floorplan-DHl3zibU.js} +1 -1
- package/dist/interface/assets/{Instances-DBphCwLn.js → Instances-DXksjsQR.js} +1 -1
- package/dist/interface/assets/{Logs-Bjyi3BKP.js → Logs-CfYTWOv2.js} +1 -1
- package/dist/interface/assets/{Menu-BQDo_rxR.js → Menu-HzmLhy40.js} +1 -1
- package/dist/interface/assets/{Metrics-Dvnil66d.js → Metrics-BWTImHsV.js} +1 -1
- package/dist/interface/assets/{OAuthDeviceFlow-C-a76FaQ.js → OAuthDeviceFlow-DBac627V.js} +1 -1
- package/dist/interface/assets/{Plugin-1ZS-dcRt.js → Plugin-D5WuhMPO.js} +1 -1
- package/dist/interface/assets/{PluginConsole-B5A04A2x.js → PluginConsole-C5dZgdl9.js} +1 -1
- package/dist/interface/assets/{PluginDetail-SCj7WYL6.js → PluginDetail-3qrahg0_.js} +2 -2
- package/dist/interface/assets/{PluginSchema-BJEOq6im.js → PluginSchema-DJ8NY8hW.js} +1 -1
- package/dist/interface/assets/{PluginSearch-CHeix3n8.js → PluginSearch-D8zmSpkN.js} +2 -2
- package/dist/interface/assets/PluginSearch-D_ba5x-O.js +1 -0
- package/dist/interface/assets/{PluginUpdateProgress-BZ-OtZet.js → PluginUpdateProgress-DgqaTwSS.js} +1 -1
- package/dist/interface/assets/{Plugins-DS-NZusx.js → Plugins-5MzJrkSA.js} +1 -1
- package/dist/interface/assets/{Recordings-Bqb2uV7R.js → Recordings-BuGuUwYE.js} +1 -1
- package/dist/interface/assets/{SensorEdit-CQagiAww.js → SensorEdit-DF4sw0EW.js} +1 -1
- package/dist/interface/assets/{SensorHistory-DIMTRYRa.js → SensorHistory-bCcPH0_I.js} +1 -1
- package/dist/interface/assets/{Sensors-DU0MBnV1.js → Sensors-D6GwAXQ2.js} +2 -2
- package/dist/interface/assets/{Settings-Dn-TJCtd.js → Settings-BZf-ziEZ.js} +1 -1
- package/dist/interface/assets/SettingsAccount--5p79E6E.js +1 -0
- package/dist/interface/assets/{SettingsAccount-Q2sigi3a.js → SettingsAccount-Dlc0Wddo.js} +1 -1
- package/dist/interface/assets/{SettingsAppearance-NpsVIJUO.js → SettingsAppearance-B59zzxu4.js} +1 -1
- package/dist/interface/assets/SettingsAppearance-xPKxmDpp.js +1 -0
- package/dist/interface/assets/{SettingsBackup-D1NER4RI.js → SettingsBackup-CJJ5VBzp.js} +1 -1
- package/dist/interface/assets/{SettingsList-BKyyC2_M.js → SettingsList-Nc7OCZrn.js} +1 -1
- package/dist/interface/assets/{SettingsMqtt-14d54svj.js → SettingsMqtt-DUUAcYuG.js} +1 -1
- package/dist/interface/assets/{SettingsNotifications-kKPcCTLM.js → SettingsNotifications-BH63oRsc.js} +1 -1
- package/dist/interface/assets/{SettingsPermissions-r6wxjmHg.js → SettingsPermissions-BZXAgxUl.js} +1 -1
- package/dist/interface/assets/{SettingsRecordings-GPy1AdjG.js → SettingsRecordings-Biyy3rTF.js} +1 -1
- package/dist/interface/assets/{SettingsRemote-Da_6mcHl.js → SettingsRemote-Dbaxaq5H.js} +1 -1
- package/dist/interface/assets/{SettingsSystem-BpPrajwG.js → SettingsSystem-DzHIleOc.js} +2 -2
- package/dist/interface/assets/{SettingsUsers-CBItOJic.js → SettingsUsers-D5YuEr7c.js} +1 -1
- package/dist/interface/assets/{Terminal-DtvlszuP.js → Terminal-AsI0lb5n.js} +1 -1
- package/dist/interface/assets/{Updates-CV5MWBHg.js → Updates-DnAut-3U.js} +1 -1
- package/dist/interface/assets/{VariableInput-C-f6bNmi.js → VariableInput-__I-FsBF.js} +1 -1
- package/dist/interface/assets/{VariableSuggestions-B4LYkbu5.js → VariableSuggestions-B-7auf15.js} +1 -1
- package/dist/interface/assets/{VersionsHandler-Cxxcwt9W.js → VersionsHandler-BTe1Ev3b.js} +1 -1
- package/dist/interface/assets/{VirtualSensorCreate-CrGmWsI7.js → VirtualSensorCreate-DdLgJECI.js} +1 -1
- package/dist/interface/assets/{Workers-DaHj_0te.js → Workers-6aoL2zvF.js} +1 -1
- package/dist/interface/assets/{api-CD4zuPhg.js → api-84bL4zpk.js} +1 -1
- package/dist/interface/assets/{api-CdT8ZD-n.js → api-BI5TkcMD.js} +3 -3
- package/dist/interface/assets/{auth-W2HVbsrF.js → auth-F2wU_mtw.js} +1 -1
- package/dist/interface/assets/{automations-CY5xtQCF.js → automations-D6fqhxhY.js} +1 -1
- package/dist/interface/assets/{cameraSources-BSFgVwUz.js → cameraSources-C3PFkewy.js} +1 -1
- package/dist/interface/assets/cloudHandoff-B1HA65AZ.js +1 -0
- package/dist/interface/assets/{config-DOFSd8-0.js → config-Jzs6YXbB.js} +1 -1
- package/dist/interface/assets/{flowSchema-Bq6CskDh.js → flowSchema-C1fWwuQa.js} +1 -1
- package/dist/interface/assets/{intercomService-CT_KVjly.js → intercomService-fFto_C1t.js} +1 -1
- package/dist/interface/assets/{main-VmsUT9aF.js → main-C6AqiNZK.js} +2 -2
- package/dist/interface/assets/{mqtt-x7JvjSZ0.js → mqtt-DGNlVikj.js} +1 -1
- package/dist/interface/assets/{notifications-B_hY7DqC.js → notifications-CIJEGR7A.js} +1 -1
- package/dist/interface/assets/{plugins-V5-6e5L7.js → plugins-HYHSAzD-.js} +1 -1
- package/dist/interface/assets/{rooms-iq9Ync9a.js → rooms-DL_uUrGc.js} +1 -1
- package/dist/interface/assets/{sensorIcons-DQIyC9JL.js → sensorIcons-ByPd6LR6.js} +1 -1
- package/dist/interface/assets/{sensors-7R3hMa_s.js → sensors-BgjfSfk6.js} +1 -1
- package/dist/interface/assets/{server-CyCTaiWl.js → server-CIDx_I6S.js} +1 -1
- package/dist/interface/assets/{theme-Cc5MIK4j.js → theme-GSy1mQOB.js} +1 -1
- package/dist/interface/assets/{types-CDVUPFqE.js → types-Dlk_iSoE.js} +1 -1
- package/dist/interface/assets/{types-D9iX7VVJ.js → types-Do9v0d7I.js} +1 -1
- package/dist/interface/assets/{types-Br6AbfXl.js → types-QIK1kdY6.js} +1 -1
- package/dist/interface/assets/{ungrouped-B-_P9Nxn.js → ungrouped-CupkuPIQ.js} +1 -1
- package/dist/interface/assets/{updates-H8lZYYSt.js → updates-73Yq11IN.js} +1 -1
- package/dist/interface/assets/{useAppVersion-DuXhWeJY.js → useAppVersion-B0_bYa9V.js} +1 -1
- package/dist/interface/assets/{useBackupRestore-C9JlDbTt.js → useBackupRestore-jdHT_hab.js} +1 -1
- package/dist/interface/assets/{useCameraOptions-CZvujVuW.js → useCameraOptions-DKeZhfOM.js} +1 -1
- package/dist/interface/assets/{useLogsSocket-DW5Ll9qN.js → useLogsSocket-CmyTTUGN.js} +1 -1
- package/dist/interface/assets/{useNavLayout-Ay4GP0IF.js → useNavLayout-DOFS3269.js} +1 -1
- package/dist/interface/assets/{usePermissions-tvEa1N9y.js → usePermissions-D5I3gACT.js} +1 -1
- package/dist/interface/assets/{usePluginUpdates-C6c7mdBo.js → usePluginUpdates-BWxJ04h7.js} +1 -1
- package/dist/interface/assets/{usePushRegistration-Cp-oFaYU.js → usePushRegistration-DWreQ-Hn.js} +1 -1
- package/dist/interface/assets/{useServerRestart-F0do0_a5.js → useServerRestart-DDW-nw_t.js} +1 -1
- package/dist/interface/assets/{useStreamStatus-Cof0SieK.js → useStreamStatus-COIha2d8.js} +1 -1
- package/dist/interface/assets/{useTabSwipe-CH2JsEKl.js → useTabSwipe-aoMqro29.js} +1 -1
- package/dist/interface/assets/{useUpdateChannel--yUW8uvn.js → useUpdateChannel-CM9MYCZy.js} +1 -1
- package/dist/interface/assets/{useUpdatesSocket-DOHvs02g.js → useUpdatesSocket-DY4i32ml.js} +1 -1
- package/dist/interface/assets/{useUserOptions-CO_I7IAm.js → useUserOptions-DHfprGgA.js} +1 -1
- package/dist/interface/assets/{vendor-cameraui-B96_CDGO.js → vendor-cameraui-BRv7o4zz.js} +1 -1
- package/dist/interface/assets/{vendor-core-DFWGbWRD.js → vendor-core-BUse5adB.js} +1 -1
- package/dist/interface/assets/{vendor-primevue-uo78flP9.js → vendor-primevue-C85v-zl5.js} +1 -1
- package/dist/interface/ha/{404-CvCsIvOn.js → 404-TwTUCqDv.js} +1 -1
- package/dist/interface/ha/{About-Bqb-qrXr.js → About-BeZkyUdW.js} +3 -3
- package/dist/interface/ha/{Automation-AiOadcvh.js → Automation-CL7j0Vgh.js} +25 -25
- package/dist/interface/ha/{AutomationImport-CHs99b96.js → AutomationImport-D7arOHP-.js} +6 -6
- package/dist/interface/ha/{AutomationStore-yTxgRNos.js → AutomationStore-DN0yBk6X.js} +4 -4
- package/dist/interface/ha/{AutomationStoreDetail-CWB-S_Dq.js → AutomationStoreDetail-DUuLEnvx.js} +6 -6
- package/dist/interface/ha/{Automations-ymrcS6zL.js → Automations-Dfbren5V.js} +3 -3
- package/dist/interface/ha/{Camera-gfUjA1cF.js → Camera-BxWpvZM8.js} +3 -3
- package/dist/interface/ha/{CameraConsole-DBM_9sZD.js → CameraConsole-DT7BFGXD.js} +3 -3
- package/dist/interface/ha/{Cameras-BDYtuflZ.js → Cameras-ClmwBeNf.js} +6 -6
- package/dist/interface/ha/{Camview-CyZW6Ccj.js → Camview-CFAKNI6-.js} +3 -3
- package/dist/interface/ha/{Config-Dw11VG_z.js → Config-D83QNz1P.js} +6 -6
- package/dist/interface/ha/{ConfigActionCameraControl-SpfqepU9.js → ConfigActionCameraControl-D-2_gkM-.js} +3 -3
- package/dist/interface/ha/{ConfigActionHttp-DRNiEJwf.js → ConfigActionHttp-CDmzaJOb.js} +2 -2
- package/dist/interface/ha/{ConfigActionImageInput-BKIS7_Az.js → ConfigActionImageInput-7mA-jNIj.js} +1 -1
- package/dist/interface/ha/{ConfigActionMqtt-vcKjYONr.js → ConfigActionMqtt-CGLqAswk.js} +4 -4
- package/dist/interface/ha/{ConfigActionNotification-C8RqA0hp.js → ConfigActionNotification-DyhLsVfe.js} +3 -3
- package/dist/interface/ha/{ConfigActionNotificationControl-DxDU-1LD.js → ConfigActionNotificationControl-C381uizv.js} +2 -2
- package/dist/interface/ha/{ConfigActionOutput-Dd9tqEbp.js → ConfigActionOutput-Cg6IMq5u.js} +1 -1
- package/dist/interface/ha/{ConfigActionPlugin-hZohlF2U.js → ConfigActionPlugin-vFD_OHt8.js} +4 -4
- package/dist/interface/ha/{ConfigActionSensor-CsTZdgpn.js → ConfigActionSensor-B0JYbb-_.js} +4 -4
- package/dist/interface/ha/{ConfigActionSnapshot-CVuRrZog.js → ConfigActionSnapshot-DlYRwdII.js} +2 -2
- package/dist/interface/ha/{ConfigActionVariable-BW0Mfwzv.js → ConfigActionVariable-6HNVpSjs.js} +1 -1
- package/dist/interface/ha/{ConfigConditionIfElse-B8giXSLg.js → ConfigConditionIfElse-b5UhYSf4.js} +3 -3
- package/dist/interface/ha/{ConfigConditionSensorState-SOYmnv38.js → ConfigConditionSensorState-CI1CS9qa.js} +4 -4
- package/dist/interface/ha/{ConfigConditionSwitch-DPYRsgIP.js → ConfigConditionSwitch-DGoKb_ZM.js} +3 -3
- package/dist/interface/ha/{ConfigSensorValueInput-C8uDea7H.js → ConfigSensorValueInput-BGQytgns.js} +2 -2
- package/dist/interface/ha/{ConfigTriggerDetection-DKrNlf4n.js → ConfigTriggerDetection-l_h4kt0X.js} +2 -2
- package/dist/interface/ha/{ConfigTriggerGeofence-BoKYjfEF.js → ConfigTriggerGeofence-Y2Od0L2_.js} +2 -2
- package/dist/interface/ha/{ConfigTriggerMqtt-A0druw9s.js → ConfigTriggerMqtt-DttCVDHe.js} +1 -1
- package/dist/interface/ha/{ConfigTriggerSensor-DnqfzsxM.js → ConfigTriggerSensor-O4mWaXnJ.js} +1 -1
- package/dist/interface/ha/{ConfigTriggerSystem-B8JHImoF.js → ConfigTriggerSystem-C_uWI6kc.js} +2 -2
- package/dist/interface/ha/{ConfigTriggerWebhook-B34dHYln.js → ConfigTriggerWebhook-CY5vDxZe.js} +1 -1
- package/dist/interface/ha/{Console-vTZkA5_c.js → Console-DdOU0_jE.js} +2 -2
- package/dist/interface/ha/{CuiAutomationRunsDialog-D1j6QT1J.js → CuiAutomationRunsDialog-_WF5J4hV.js} +2 -2
- package/dist/interface/ha/{CuiBottomSheet-tJqB2HMb.js → CuiBottomSheet-Bzr2zhm3.js} +1 -1
- package/dist/interface/ha/{CuiCameraRecordings-CbXShYur.js → CuiCameraRecordings-HqWrHpr-.js} +2 -2
- package/dist/interface/ha/{CuiCameraShares-fsCg_eYs.js → CuiCameraShares-Bw1RlqC-.js} +2 -2
- package/dist/interface/ha/{CuiCameraTable-cCH34Rqx.js → CuiCameraTable-DvIlmfmW.js} +2 -2
- package/dist/interface/ha/{CuiChartTable-CMkcRmDL.js → CuiChartTable-C6vRR9ny.js} +3 -3
- package/dist/interface/ha/{CuiConsole-wuBto4Ht.js → CuiConsole-B6fDJfvq.js} +1 -1
- package/dist/interface/ha/{CuiDataTable-yviddz9T.js → CuiDataTable-BLL7vWD1.js} +1 -1
- package/dist/interface/ha/{CuiPluginCard-Dr4cFcve.js → CuiPluginCard-CsJ-dlra.js} +6 -6
- package/dist/interface/ha/{CuiPluginOAuthButton-D4M7piUp.js → CuiPluginOAuthButton-ChNW42ux.js} +2 -2
- package/dist/interface/ha/{CuiPluginTrustBadge-CVwRbaTh.js → CuiPluginTrustBadge-CQtfi3UI.js} +1 -1
- package/dist/interface/ha/{CuiQRCode-CTr0g0fy.js → CuiQRCode-DOj5PJo2.js} +2 -2
- package/dist/interface/ha/{CuiSchema-DtfAoLxQ.js → CuiSchema-Dg43r2Vo.js} +2 -2
- package/dist/interface/ha/{CuiTopNavbarItem-4H6Gg0Pe.js → CuiTopNavbarItem-CMu_hCIP.js} +1 -1
- package/dist/interface/ha/{Faces-DSjPW-A-.js → Faces-Ed0ytbse.js} +2 -2
- package/dist/interface/ha/{FirstSteps-BK_EXlZU.js → FirstSteps-Dkw2Enre.js} +4 -4
- package/dist/interface/ha/{Floorplan-BWRteZjr.js → Floorplan-IdC1tgDr.js} +4 -4
- package/dist/interface/ha/{Instances-Dln03_o7.js → Instances-dvDlInn-.js} +1 -1
- package/dist/interface/ha/{Logs-xwh0fkZV.js → Logs-rUL_mLTJ.js} +6 -6
- package/dist/interface/ha/{Menu-BwzIh1vF.js → Menu-CfMgYCN9.js} +2 -2
- package/dist/interface/ha/{Metrics-CiMXu6rz.js → Metrics-DYNvEdb-.js} +7 -7
- package/dist/interface/ha/{OAuthDeviceFlow-D4IUrYub.js → OAuthDeviceFlow-vgBWOkzP.js} +3 -3
- package/dist/interface/ha/{Plugin-CM5b1Jz4.js → Plugin-PqUW_696.js} +5 -5
- package/dist/interface/ha/{PluginConsole-BJNblZb5.js → PluginConsole-CFJKNhQw.js} +4 -4
- package/dist/interface/ha/{PluginDetail--RFw88FL.js → PluginDetail-cC8nut35.js} +5 -5
- package/dist/interface/ha/{PluginSearch-yzBxy3Zj.js → PluginSearch-BzSs0ibh.js} +4 -4
- package/dist/interface/ha/{PluginUpdateProgress-BaYmaaE7.js → PluginUpdateProgress-CtM7lrl9.js} +3 -3
- package/dist/interface/ha/{Plugins-C-sU0dsj.js → Plugins-CzvlXEaH.js} +7 -7
- package/dist/interface/ha/{Recordings-CXnTN85c.js → Recordings-BtsW8I5D.js} +2 -2
- package/dist/interface/ha/{SensorEdit-ByAfduAA.js → SensorEdit-DMwyTDIG.js} +2 -2
- package/dist/interface/ha/{SensorHistory-Cv1YF7qX.js → SensorHistory-DoJhFbTC.js} +2 -2
- package/dist/interface/ha/{Sensors-DyxXLT1C.js → Sensors-BoRfutfx.js} +3 -3
- package/dist/interface/ha/{Settings-DMBgMUpe.js → Settings-vmfs1rfj.js} +2 -2
- package/dist/interface/ha/{SettingsAccount-CiyVRy4Y.js → SettingsAccount-xJy6kGf6.js} +4 -4
- package/dist/interface/ha/{SettingsAppearance-BfXcGIwE.js → SettingsAppearance-v9zeetcx.js} +3 -3
- package/dist/interface/ha/{SettingsBackup-vsITZfgV.js → SettingsBackup-eO4r8MZe.js} +2 -2
- package/dist/interface/ha/{SettingsList-BTxhjM8J.js → SettingsList-burOi4S6.js} +1 -1
- package/dist/interface/ha/{SettingsMqtt-JHf9BXbp.js → SettingsMqtt-CjZERKR8.js} +2 -2
- package/dist/interface/ha/{SettingsNotifications-Bvay7Ob7.js → SettingsNotifications-QCKfSffa.js} +3 -3
- package/dist/interface/ha/{SettingsRecordings-BAUAhyEd.js → SettingsRecordings-DzsXkzeu.js} +3 -3
- package/dist/interface/ha/{SettingsRemote-DAI3p-gY.js → SettingsRemote-B0HZwZj3.js} +4 -4
- package/dist/interface/ha/{SettingsSystem-D-UQqZyn.js → SettingsSystem-Bc_c8XYh.js} +7 -7
- package/dist/interface/ha/{SettingsUsers-D-_uCeBe.js → SettingsUsers-CxL65q1C.js} +3 -3
- package/dist/interface/ha/{Terminal-BBBP74zZ.js → Terminal-DsX-_5R2.js} +2 -2
- package/dist/interface/ha/{Updates-DDEAqmrt.js → Updates-DG9i-tQu.js} +4 -4
- package/dist/interface/ha/{VariableInput-5aDKaHK6.js → VariableInput-CcevSEwK.js} +1 -1
- package/dist/interface/ha/{VersionsHandler-Z5aUBicW.js → VersionsHandler-5GeFt6Lw.js} +8 -8
- package/dist/interface/ha/{VirtualSensorCreate-DOjwBgbP.js → VirtualSensorCreate-dWN8FANX.js} +1 -1
- package/dist/interface/ha/{Workers-lI-ulBfQ.js → Workers-D1y6eFKT.js} +6 -6
- package/dist/interface/ha/{api-B-1nJvx1.js → api-BgQ9AVgK.js} +1 -1
- package/dist/interface/ha/{api-BU1ot-rQ.js → api-DDUXI4DG.js} +99 -94
- package/dist/interface/ha/{auth-Wr26Jrhr.js → auth-C8Vp1TkJ.js} +1 -1
- package/dist/interface/ha/{automationBlueprint-CjXCYTHX.js → automationBlueprint-DhRjWL2p.js} +1 -1
- package/dist/interface/ha/cameraui-cards.js +1 -1
- package/dist/interface/ha/{cards-DJ8I0DpS.js → cards-BGikU5nh.js} +3 -3
- package/dist/interface/ha/{config--3c2hYeI.js → config-WqhFqx8D.js} +1 -1
- package/dist/interface/ha/{mqtt-CSWN3zrE.js → mqtt-CQopAljB.js} +1 -1
- package/dist/interface/ha/{notifications-B4jziVIo.js → notifications-C4IU7Zbu.js} +1 -1
- package/dist/interface/ha/{plugins-BTBXmJqQ.js → plugins-C2n0mAnr.js} +1 -1
- package/dist/interface/ha/{rooms-BxY9U6db.js → rooms-qqdOrA2J.js} +1 -1
- package/dist/interface/ha/{server-BxPWpMFK.js → server-D6Yglz-z.js} +1 -1
- package/dist/interface/ha/{types-D_Y5r1Yz.js → types-BtcJ7st-.js} +1 -1
- package/dist/interface/ha/{ungrouped-CpcBXTDQ.js → ungrouped-aASsOUNF.js} +1 -1
- package/dist/interface/ha/{updates-Hyzkue_s.js → updates-BuAFU-ZQ.js} +5 -5
- package/dist/interface/ha/{useAppVersion-BME7p9Tn.js → useAppVersion-D0EOwpoO.js} +1 -1
- package/dist/interface/ha/{useLogsSocket-9HYA1tN7.js → useLogsSocket-CCewWMZM.js} +1 -1
- package/dist/interface/ha/{useNavLayout-BP3bvHDX.js → useNavLayout-B_QzdVtJ.js} +1 -1
- package/dist/interface/ha/{useServerRestart-L0gugeHY.js → useServerRestart-B0OMNlwZ.js} +1 -1
- package/dist/interface/ha/{useTabSwipe-DKFPKAuu.js → useTabSwipe-DG6Gx2Md.js} +1 -1
- package/dist/interface/ha/{useUpdateChannel-DgPBMvzK.js → useUpdateChannel-CXDGlWX2.js} +2 -2
- package/dist/interface/ha/{useUpdatesSocket-j4Sl2_YJ.js → useUpdatesSocket-BgCJLp_W.js} +1 -1
- package/dist/interface/ha/{useUserOptions-BIVNeXD9.js → useUserOptions-rirRksyl.js} +1 -1
- package/dist/interface/index.html +25 -25
- package/dist/interface/sw.js +1 -1
- package/dist/server/package.json +1 -1
- package/dist/server/src/manager/types.d.ts +1 -0
- package/dist/server/src/manager/types.js +2 -0
- package/dist/server/src/manager/types.js.map +1 -1
- package/dist/server/src/remote/api/credentialStore.d.ts +1 -0
- package/dist/server/src/remote/api/credentialStore.js +24 -0
- package/dist/server/src/remote/api/credentialStore.js.map +1 -1
- package/package.json +1 -1
- package/dist/interface/assets/CuiBottomSheet-epGdNqA8.js +0 -1
- package/dist/interface/assets/CuiCameraTable-CfyXLqkh.js +0 -1
- package/dist/interface/assets/PluginSearch-CcjGzS5R.js +0 -1
- package/dist/interface/assets/SettingsAccount-CLclTO2m.js +0 -1
- package/dist/interface/assets/SettingsAppearance-Bo61ZncS.js +0 -1
- package/dist/interface/assets/cloudHandoff-RfAVMcZZ.js +0 -1
|
@@ -10,7 +10,7 @@ import{a as e,i as t,n,o as r,r as i,t as a}from"./rolldown-runtime-C0FnF6B9.js"
|
|
|
10
10
|
`)),this.transport.send(ro)}catch(e){this.close(e).catch()}}if(n){let{added:e,deleted:t}=n;this.dispatchStatus({type:`update`,added:e,deleted:t})}t.ldm!==void 0&&t.ldm&&this.dispatchStatus({type:`ldm`,server:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case $i.MSG:{let{msg:t,data:n}=e;this.processMsg(t,n);break}case $i.OK:break;case $i.ERR:this.processError(e.data);break;case $i.PING:this.processPing();break;case $i.PONG:this.processPong();break;case $i.INFO:this.processInfo(e.data)}}sendCommand(e,...t){let n=this.outbound.length(),r;r=typeof e==`string`?nr(e):e,this.outbound.fill(r,...t),n===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,t=ir,n){let r;if(t instanceof Uint8Array)r=t;else if(typeof t==`string`)r=ar.encode(t);else throw TypeError(`payload types can be strings or Uint8Array`);let i=r.length;n||={},n.reply=n.reply||``;let a=ir,o=0;if(n.headers&&(this.info&&!this.info.headers&&lr.format(`headers`,`are not available on this server`),a=n.headers.encode(),o=a.length,i=r.length+o),this.info&&i>this.info.max_payload)throw lr.format(`payload`,`max_payload size exceeded`);this.outBytes+=i,this.outMsgs++;let s;n.headers?(s=n.reply?`HPUB ${e} ${n.reply} ${o} ${i}\r\n`:`HPUB ${e} ${o} ${i}\r\n`,this.sendCommand(s,a,r,ci)):(s=n.reply?`PUB ${e} ${n.reply} ${i}\r\n`:`PUB ${e} ${i}\r\n`,this.sendCommand(s,r,ci))}request(e){return this.initMux(),this.muxSubscriptions.add(e),e}subscribe(e){return this.subscriptions.add(e),this._subunsub(e),e}_sub(e){e.queue?this.sendCommand(`SUB ${e.subject} ${e.queue} ${e.sid}\r\n`):this.sendCommand(`SUB ${e.subject} ${e.sid}\r\n`)}_subunsub(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}unsubscribe(e,t){this.unsub(e,t),(e.max===void 0||e.received>=e.max)&&this.subscriptions.cancel(e)}unsub(e,t){!e||this.isClosed()||(t?this.sendCommand(`UNSUB ${e.sid} ${t}\r\n`):this.sendCommand(`UNSUB ${e.sid}\r\n`),e.max=t)}resub(e,t){!e||this.isClosed()||(this.unsub(e),e.subject=t,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||=Or(),this.pongs.push(e),this.outbound.fill(ro),this.flushPending(),e}sendSubscriptions(){let e=[];this.subscriptions.all().forEach(t=>{let n=t;n.queue?e.push(`SUB ${n.subject} ${n.queue} ${n.sid}\r
|
|
11
11
|
`):e.push(`SUB ${n.subject} ${n.sid}\r
|
|
12
12
|
`)}),e.length&&this.transport.send(nr(e.join(``)))}async close(e){if(this._closed)return;this.whyClosed=Error(`close trace`).stack||``,this.heartbeats.cancel(),this.connectError&&=(this.connectError(e),void 0),this.muxSubscriptions.close(),this.subscriptions.close();let t=[];for(let e=0;e<this.listeners.length;e++){let n=this.listeners[e];n&&(n.push({type:`close`}),n.stop(),t.push(n.iterClosed))}t.length&&await Promise.all(t),this._closed=!0,await this.transport.close(e),this.raceTimer?.cancel(),this.dialDelay?.cancel(),this.closed.resolve(e)}abortClose(e){if(!this._closed){this.whyClosed=Error(`abortClose trace`).stack||``,this._closed=!0,this.abortReconnect=!0,this.heartbeats.cancel(),this.connectError&&=(this.connectError(e),void 0),this.muxSubscriptions.close(),this.subscriptions.close();for(let e=0;e<this.listeners.length;e++){let t=this.listeners[e];t&&(t.push({type:`close`}),t.stop())}this.raceTimer?.cancel(),this.dialDelay?.cancel();try{this.transport?.close(e)}catch{}this.closed.resolve(e)}}isClosed(){return this._closed}async drain(){let e=this.subscriptions.all(),t=[];e.forEach(e=>{t.push(e.drain())});try{await Promise.allSettled(t)}catch{}finally{this.noMorePublishing=!0,await this.flush()}return this.close()}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){let e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){let e=this.muxSubscriptions.init(this.options.inboxPrefix),t=new co(this,`${e}*`);t.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(t),this.subscribe(t)}}selectServer(){let e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}})),po,mo,ho,go=n((()=>{Vr(),Sr(),po=class{token;received;ctx;requestSubject;mux;constructor(e,t,n=!0){this.mux=e,this.requestSubject=t,this.received=0,this.token=Fr(),n&&(this.ctx=new _r)}},mo=class extends po{callback;done;timer;max;opts;constructor(e,t,n={maxWait:1e3}){if(super(e,t),this.opts=n,typeof this.opts.callback!=`function`)throw TypeError(`callback must be a function`);this.callback=this.opts.callback,this.max=typeof n.maxMessages==`number`&&n.maxMessages>0?n.maxMessages:-1,this.done=Or(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},n.maxWait)}cancel(e){e&&this.callback(e,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(e,t){e?(this.ctx&&(e.stack+=`\n\n${this.ctx.stack}`),this.cancel(e)):(this.callback(null,t),this.opts.strategy===`count`&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===`stall`&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.stall||300)),this.opts.strategy===`sentinel`&&t&&t.data.length===0&&this.cancel())}},ho=class extends po{deferred;timer;constructor(e,t,n={timeout:1e3},r=!0){super(e,t,r),this.deferred=Or(),this.timer=Tr(n.timeout,r)}resolver(e,t){this.timer&&this.timer.cancel(),e?(e instanceof vr||(this.ctx?(this.ctx.message=e.message,this.ctx.cause=e,e=this.ctx):e=new xr.RequestError(e.message,{cause:e})),this.deferred.reject(e)):this.deferred.resolve(t),this.cancel()}cancel(e){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(e||new _r(`cancelled`))}}})),_o,vo,yo,bo=n((()=>{Vr(),fo(),sr(),da(),va(),Za(),Li(),go(),Zr(),Sr(),_o=/[ \n\r\t]/,vo=class e{options;protocol;draining;closeListeners;constructor(e){this.draining=!1,this.options=Ga(e)}static connect(t={}){return new Promise((n,r)=>{let i=new e(t);uo.connect(i.options,i).then(e=>{i.protocol=e,n(i)}).catch(e=>{r(e)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}abortClose(e){this.protocol.abortClose(e)}isStale(){return!this.isClosed()&&this.protocol.isStale()}_check(e,t,n){if(this.isClosed())throw new xr.ClosedConnectionError;if(t&&this.isDraining()||n&&this.protocol.noMorePublishing)throw new xr.DrainingConnectionError;if(e||=``,e.length===0||_o.test(e))throw new xr.InvalidSubjectError(e)}publish(e,t,n){if(this._check(e,!1,!0),n?.reply&&this._check(n.reply,!1,!0),typeof n?.traceOnly==`boolean`){let e=n.headers||ca();e.set(`Nats-Trace-Only`,`true`),n.headers=e}if(typeof n?.traceDestination==`string`){let e=n.headers||ca();e.set(`Nats-Trace-Dest`,n.traceDestination),n.headers=e}this.protocol.publish(e,t,n)}publishMessage(e){return this.publish(e.subject,e.data,{reply:e.reply,headers:e.headers})}respondMessage(e){return e.reply?(this.publish(e.reply,e.data,{reply:e.reply,headers:e.headers}),!0):!1}subscribe(e,t={}){this._check(e,!0,!1);let n=new co(this.protocol,e,t);return typeof t.callback!=`function`&&typeof t.slow==`number`&&n.setSlowNotificationFn(t.slow,e=>{this.protocol.dispatchStatus({type:`slowConsumer`,sub:n,pending:e})}),this.protocol.subscribe(n),n}_resub(e,t,n){this._check(t,!0,!1);let r=e;r.max=n,n&&(r.max=n+r.received),this.protocol.resub(r,t)}requestMany(e,t=ir,n={maxWait:1e3,maxMessages:-1}){let r=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(e){return Promise.reject(e)}if(n.strategy=n.strategy||`timer`,n.maxWait=n.maxWait||1e3,n.maxWait<1)return Promise.reject(lr.format(`timeout`,`must be greater than 0`));let i=new Ii;function a(e){i.push(()=>{i.stop(e)})}function o(e,t){e||t===null?a(e===null?void 0:e):i.push(t)}if(n.noMux){let s=r?Error().stack:null,c=typeof n.maxMessages==`number`&&n.maxMessages>0?n.maxMessages:-1,l=this.subscribe(qr(this.options.inboxPrefix),{callback:(t,r)=>{if(r?.data?.length===0&&r?.headers?.status===`503`&&(t=new xr.NoRespondersError(e)),t){s&&(t.stack+=`\n\n${s}`),u(t);return}o(null,r),n.strategy===`count`&&(c--,c===0&&u()),n.strategy===`stall`&&(h(),m=setTimeout(()=>{u()},300)),n.strategy===`sentinel`&&r&&r.data.length===0&&u()}});l.requestSubject=e,l.closed.then(()=>{a()}).catch(e=>{i.stop(e)});let u=e=>{e&&i.push(()=>{throw e}),h(),l.drain().then(()=>{a()}).catch(e=>{a()})};i.iterClosed.then(()=>{h(),l?.unsubscribe()}).catch(e=>{h(),l?.unsubscribe()});let{headers:d,traceDestination:f,traceOnly:p}=n;try{this.publish(e,t,{reply:l.getSubject(),headers:d,traceDestination:f,traceOnly:p})}catch(e){u(e)}let m=setTimeout(()=>{u()},n.maxWait),h=()=>{m&&clearTimeout(m)}}else{let r=n;r.callback=o,i.iterClosed.then(()=>{a.cancel()}).catch(e=>{a.cancel(e)});let a=new mo(this.protocol.muxSubscriptions,e,r);this.protocol.request(a);let{headers:s,traceDestination:c,traceOnly:l}=n;try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${a.token}`,headers:s,traceDestination:c,traceOnly:l})}catch(e){a.cancel(e)}}return Promise.resolve(i)}request(e,t,n={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(e){return Promise.reject(e)}let r=!this.protocol.options.noAsyncTraces;if(n.timeout=n.timeout||1e3,n.timeout<1)return Promise.reject(lr.format(`timeout`,`must be greater than 0`));if(!n.noMux&&n.reply)return Promise.reject(lr.format([`reply`,`noMux`],`are mutually exclusive`));if(n.noMux){let i=n.reply?n.reply:qr(this.options.inboxPrefix),a=Or(),o=r?new xr.RequestError(``):null,s=this.subscribe(i,{max:1,timeout:n.timeout,callback:(t,n)=>{n&&n.data?.length===0&&n.headers?.code===503&&(t=new xr.NoRespondersError(e)),t?(t instanceof vr||(o?(o.message=t.message,o.cause=t,t=o):t=new xr.RequestError(t.message,{cause:t})),a.reject(t),s.unsubscribe()):a.resolve(n)}});return s.requestSubject=e,this.protocol.publish(e,t,{reply:i,headers:n.headers}),a}{let i=new ho(this.protocol.muxSubscriptions,e,n,r);this.protocol.request(i);let{headers:a,traceDestination:o,traceOnly:s}=n;try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${i.token}`,headers:a,traceDestination:o,traceOnly:s})}catch(e){i.cancel(e)}let c=Promise.race([i.timer,i.deferred]);return c.catch(()=>{i.cancel()}),c}}flush(){return this.isClosed()?Promise.reject(new xr.ClosedConnectionError):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(new xr.ClosedConnectionError):this.isDraining()?Promise.reject(new xr.DrainingConnectionError):(this.draining=!0,this.protocol.drain())}async[Symbol.asyncDispose](){if(!this.isClosed()){if(this.isDraining()){await this.closed();return}await this.drain()}}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){let e=this.protocol.getServer();return e?e.listen:``}setServers(e){this.protocol.servers.setServers(e)}getServers(){return this.protocol.servers.snapshot()}status(){let e=new Ii;return e.iterClosed.then(()=>{let t=this.protocol.listeners.indexOf(e);t>-1&&this.protocol.listeners.splice(t,1)}),this.protocol.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request(`$SYS.REQ.USER.INFO`)).json((e,t)=>e===`time`?new Date(Date.parse(t)):t)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}getServerVersion(){let e=this.info;return e?ma(e.version):void 0}async rtt(){if(this.isClosed())throw new xr.ClosedConnectionError;if(!this.protocol.connected)throw new xr.RequestError(`connection disconnected`);let e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}reconnect(){return this.isClosed()?Promise.reject(new xr.ClosedConnectionError):this.isDraining()?Promise.reject(new xr.DrainingConnectionError):this.protocol.reconnect()}forceReconnect(){return this.isClosed()?Promise.reject(new xr.ClosedConnectionError):this.isDraining()?Promise.reject(new xr.DrainingConnectionError):this.protocol.forceReconnect()}addCloseListener(e){this.closeListeners===void 0&&(this.closeListeners=new yo(this.closed())),this.closeListeners.add(e)}removeCloseListener(e){this.closeListeners&&this.closeListeners.remove(e)}},yo=class{listeners;constructor(e){this.listeners=[],e.then(e=>{this.notify(e)})}add(e){this.listeners.push(e)}remove(e){this.listeners=this.listeners.filter(t=>t!==e)}notify(e){this.listeners.forEach(t=>{if(typeof t.connectionClosedCallback==`function`)try{t.connectionClosedCallback(e)}catch{}}),this.listeners=[]}}})),xo=n((()=>{sr()}));function So(e,t){return`${Co(e/t)}/sec`}function Co(e,t=!1){let n=t?1e3:1024,r=t?[`k`,`M`,`G`,`T`,`P`,`E`]:[`K`,`M`,`G`,`T`,`P`,`E`],i=t?`iB`:`B`;if(e<n)return`${e.toFixed(2)} ${i}`;let a=parseInt(Math.log(e)/Math.log(n)+``),o=parseInt(a-1+``);return`${(e/n**+a).toFixed(2)} ${r[o]}${i}`}function wo(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}var To,Eo,Do=n((()=>{xo(),Gr(),Vr(),To=class{name;duration;date;payload;msgs;lang;version;bytes;asyncRequests;min;max;constructor(e,t){this.name=e,this.duration=t,this.date=Date.now(),this.payload=0,this.msgs=0,this.bytes=0}toString(){let e=this.duration/1e3,t=Math.round(this.msgs/e),n=this.asyncRequests?`asyncRequests`:``,r=``;return this.max&&(r=`${this.min}/${this.max}`),`${this.name}${n?` [asyncRequests]`:``} ${wo(t)} msgs/sec - [${e.toFixed(2)} secs] ~ ${So(this.bytes,e)} ${r}`}toCsv(){return`"${this.name}",${new Date(this.date).toISOString()},${this.lang},${this.version},${this.msgs},${this.payload},${this.bytes},${this.duration},${this.asyncRequests?this.asyncRequests:!1}\n`}static header(){return`Test,Date,Lang,Version,Count,MsgPayload,Bytes,Millis,Async
|
|
13
|
-
`}},Eo=class{nc;callbacks;msgs;size;subject;asyncRequests;pub;sub;req;rep;perf;payload;constructor(e,t={msgs:1e5,size:128,subject:``,asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){if(this.nc=e,this.callbacks=t.callbacks||!1,this.msgs=t.msgs||0,this.size=t.size||0,this.subject=t.subject||Wr.nuid.next(),this.asyncRequests=t.asyncRequests||!1,this.pub=t.pub||!1,this.sub=t.sub||!1,this.req=t.req||!1,this.rep=t.rep||!1,this.perf=new Ir,this.payload=this.size?new Uint8Array(this.size):ir,!this.pub&&!this.sub&&!this.req&&!this.rep)throw Error(`no options selected`)}async run(){return this.nc.closed().then(e=>{if(e)throw e}),this.callbacks?await this.runCallbacks():await this.runAsync(),this.processMetrics()}processMetrics(){let{lang:e,version:t}=this.nc.protocol.transport;this.pub&&this.sub&&this.perf.measure(`pubsub`,`pubStart`,`subStop`),this.req&&this.rep&&this.perf.measure(`reqrep`,`reqStart`,`reqStop`);let n=this.perf.getEntries(),r=n.find(e=>e.name===`pubsub`),i=n.find(e=>e.name===`reqrep`),a=n.find(e=>e.name===`req`),o=n.find(e=>e.name===`rep`),s=n.find(e=>e.name===`pub`),c=n.find(e=>e.name===`sub`),l=this.nc.stats(),u=[];if(r){let{name:n,duration:i}=r,a=new To(n,i);a.msgs=this.msgs*2,a.bytes=l.inBytes+l.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,u.push(a)}if(i){let{name:n,duration:r}=i,a=new To(n,r);a.msgs=this.msgs*2,a.bytes=l.inBytes+l.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,u.push(a)}if(s){let{name:n,duration:r}=s,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.outBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}if(c){let{name:n,duration:r}=c,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.inBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}if(o){let{name:n,duration:r}=o,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.inBytes+l.outBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}if(a){let{name:n,duration:r}=a,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.inBytes+l.outBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}return u}async runCallbacks(){let e=[];if(this.sub){let t=Or();e.push(t);let n=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{n++,n===1&&this.perf.mark(`subStart`),n===this.msgs&&(this.perf.mark(`subStop`),this.perf.measure(`sub`,`subStart`,`subStop`),t.resolve())}})}if(this.rep){let t=Or();e.push(t);let n=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(e,r)=>{r.respond(this.payload),n++,n===1&&this.perf.mark(`repStart`),n===this.msgs&&(this.perf.mark(`repStop`),this.perf.measure(`rep`,`repStart`,`repStop`),t.resolve())}})}if(this.pub){let t=(async()=>{this.perf.mark(`pubStart`);for(let e=0;e<this.msgs;e++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark(`pubStop`),this.perf.measure(`pub`,`pubStart`,`pubStop`)})();e.push(t)}if(this.req){let t=(async()=>{if(this.asyncRequests){this.perf.mark(`reqStart`);let e=[];for(let t=0;t<this.msgs;t++)e.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(e),this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}else{this.perf.mark(`reqStart`);for(let e=0;e<this.msgs;e++)await this.nc.request(this.subject);this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}})();e.push(t)}await Promise.all(e)}async runAsync(){let e=[];if(this.rep){let t=!1,n=this.nc.subscribe(this.subject,{max:this.msgs}),r=(async()=>{for await(let e of n)t||=(this.perf.mark(`repStart`),!0),e.respond(this.payload);await this.nc.flush(),this.perf.mark(`repStop`),this.perf.measure(`rep`,`repStart`,`repStop`)})();e.push(r)}if(this.sub){let t=!1,n=this.nc.subscribe(this.subject,{max:this.msgs}),r=(async()=>{for await(let e of n)t||=(this.perf.mark(`subStart`),!0);this.perf.mark(`subStop`),this.perf.measure(`sub`,`subStart`,`subStop`)})();e.push(r)}if(this.pub){let t=(async()=>{this.perf.mark(`pubStart`);for(let e=0;e<this.msgs;e++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark(`pubStop`),this.perf.measure(`pub`,`pubStart`,`pubStop`)})();e.push(t)}if(this.req){let t=(async()=>{if(this.asyncRequests){this.perf.mark(`reqStart`);let e=[];for(let t=0;t<this.msgs;t++)e.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(e),this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}else{this.perf.mark(`reqStart`);for(let e=0;e<this.msgs;e++)await this.nc.request(this.subject);this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}})();e.push(t)}await Promise.all(e)}}})),Oo,ko=n((()=>{Oo=class{interval;maxOut;cancelAfter;timer;autoCancelTimer;last;missed;count;callback;constructor(e,t,n={maxOut:2}){this.interval=e,this.maxOut=n?.maxOut||2,this.cancelAfter=n?.cancelAfter||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=t,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,t=0,n=2){this.interval=e,this.maxOut=n,this.cancelAfter=t,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}})),Ao,jo=n((()=>{Ao=`3.4.0`}));function Mo(e,t){/^(.*:\/\/)(.*)/.test(e)||(e=typeof t==`boolean`?`${t===!0?`https`:`http`}://${e}`:`https://${e}`);let n=new URL(e),r=n.protocol.toLowerCase();r===`ws:`&&(t=!1),r===`wss:`&&(t=!0),r!==`https:`&&r!==`http`&&(e=e.replace(/^(.*:\/\/)(.*)/gm,`$2`),n=new URL(`http://${e}`));let i,a,o=n.hostname,s=n.pathname,c=n.search||``;switch(r){case`http:`:case`ws:`:case`nats:`:a=n.port||`80`,i=`ws:`;break;case`https:`:case`wss:`:case`tls:`:a=n.port||`443`,i=`wss:`;break;default:a=n.port||t===!0?`443`:`80`,i=t===!0?`wss:`:`ws:`}return`${i}//${o}:${a}${s}${c}`}function No(e={}){return ei({defaultPort:443,urlParseFn:Mo,factory:()=>{if(e.tls)throw lr.format(`tls`,`is not configurable on w3c websocket connections`);return new Io}}),vo.connect(e)}var Po,Fo,Io,Lo=n((()=>{Vr(),di(),Za(),$r(),fo(),bo(),jo(),Sr(),Po=Ao,Fo=`nats.ws`,Io=class{version;lang;closeError;connected;done;socket;options;socketClosed;encrypted;peeked;yields;signal;closedNotification;pendingConnect;constructor(){this.version=Po,this.lang=Fo,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=Or(),this.closedNotification=Or(),this.pendingConnect=null}async connect(e,t){let n=Or();this.pendingConnect=n,this.options=t;let r=e.src;if(t.wsFactory){let{socket:n,encrypted:r}=await t.wsFactory(e.src,t);this.socket=n,this.encrypted=r}else this.encrypted=r.indexOf(`wss://`)===0,this.socket=new WebSocket(r);return this.socket.binaryType=`arraybuffer`,this.socket.onopen=()=>{this.done&&this._closed(Error(`aborted`))},this.socket.onmessage=e=>{if(this.done)return;if(this.yields.push(new Uint8Array(e.data)),this.peeked){this.signal.resolve();return}let r=Qr.concat(...this.yields),i=oi(r);if(i!==``){let e=to.exec(i);if(!e){t.debug&&console.error(`!!!`,wr(r)),n.reject(Error(`unexpected response from server`));return}try{Ka(JSON.parse(e[1]),this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),n.resolve()}catch(e){n.reject(e);return}}},this.socket.onclose=e=>{let t;e.code>=4e3&&e.code<=4999?t=Error(e.reason||`close code ${e.code}`):!e.wasClean&&e.reason!==``&&(t=Error(e.reason)),t&&(t.wsCloseCode=e.code),this._closed(t),this._cleanup()},this.socket.onerror=e=>{if(this.done)return;let t=e,r=new xr.ConnectionError(t.message);n.reject(r),this._cleanup()},n}_cleanup(){this.socketClosed===!1&&(this.socketClosed=!0,this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.closedNotification.resolve(this.closeError))}disconnect(){this._closed(void 0,!0)}async _closed(e,t=!0){if(this.pendingConnect?.reject(e??new xr.ConnectionError(`transport closed during handshake`)),this.done){try{this.socket.close()}catch{}return}if(this.closeError=e,!e){let e=Date.now();for(;!this.socketClosed&&this.socket.bufferedAmount>0&&!(Date.now()-e>=3e3);)await Er(100)}this.done=!0;try{this.socket.close()}catch{}return this._cleanup(),this.closedNotification}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.done)return;this.yields.length===0&&await this.signal;let e=this.yields;this.yields=[];for(let t=0;t<e.length;t++)this.options.debug&&console.info(`> ${wr(e[t])}`),yield e[t];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=Or())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.done)try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${wr(e)}`);return}catch(t){this.options.debug&&console.error(`!!! ${wr(e)}: ${t}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}discard(){this.socket?.close()}}})),Ro=i({AuthorizationError:()=>fr,Bench:()=>Eo,ClosedConnectionError:()=>pr,Connect:()=>oo,ConnectionError:()=>hr,DEFAULT_MAX_RECONNECT_ATTEMPTS:()=>10,DataBuffer:()=>Qr,DenoBuffer:()=>Yi,DrainingConnectionError:()=>mr,Empty:()=>ir,Feature:()=>ga,Features:()=>_a,Heartbeat:()=>Bi,INFO:()=>to,IdleHeartbeatMonitor:()=>Oo,InvalidArgumentError:()=>lr,InvalidOperationError:()=>ur,InvalidSubjectError:()=>cr,Kind:()=>$i,MAX_SIZE:()=>Ji,Match:()=>Jr,Metric:()=>To,MsgHdrsImpl:()=>ua,MsgImpl:()=>fa,MuxSubscription:()=>Ri,NatsConnectionImpl:()=>vo,NoRespondersError:()=>yr,Nuid:()=>Wr.Nuid,Parser:()=>ra,PermissionViolationError:()=>br,ProtocolError:()=>gr,ProtocolHandler:()=>uo,QueuedIteratorImpl:()=>Ii,RequestError:()=>_r,RequestOne:()=>ho,Servers:()=>Pi,SimpleMutex:()=>Lr,State:()=>ia,SubscriptionImpl:()=>co,Subscriptions:()=>lo,TD:()=>or,TE:()=>ar,TimeoutError:()=>vr,UserAuthenticationExpiredError:()=>dr,backoff:()=>Mr,buildAuthenticator:()=>Wa,canonicalMIMEHeaderKey:()=>sa,checkOptions:()=>Ka,checkUnsupportedOption:()=>qa,collect:()=>Ar,compare:()=>ha,createInbox:()=>qr,credsAuthenticator:()=>Ba,deadline:()=>Dr,defaultOptions:()=>Ha,deferred:()=>Or,delay:()=>Er,describe:()=>Zi,errors:()=>xr,extend:()=>Cr,extractProtocolMessage:()=>oi,getResolveFn:()=>ii,hasWsProtocol:()=>Ua,headers:()=>ca,ipV4:()=>fi,isIP:()=>pi,isIPV4OrHostname:()=>ki,jwtAuthenticator:()=>za,millis:()=>Pr,nanos:()=>Nr,nkeyAuthenticator:()=>Ra,nkeys:()=>Ma,nuid:()=>Wr.nuid,parseIP:()=>mi,parseOptions:()=>Ga,parseSemVer:()=>ma,protoLen:()=>ai,readAll:()=>Wi,render:()=>wr,setTransportFactory:()=>ei,syncIterator:()=>Kr,timeout:()=>Tr,tokenAuthenticator:()=>La,usernamePasswordAuthenticator:()=>Ia,writeAll:()=>Gi,wsUrlParseFn:()=>Mo,wsconnect:()=>No}),zo=n((()=>{bo(),Gr(),pa(),di(),fo(),Vr(),da(),Vi(),zi(),$r(),Za(),go(),Va(),Na(),Li(),oa(),Xi(),Do(),sr(),Oi(),va(),xo(),Zr(),ko(),Fi(),Lo(),Sr()})),Bo=class{client;channelId;closed=!1;unsubscribe;initialized=!1;subject;requestSubject;handlers=new Map;closeHandlers=new Set;errorHandlers=new Set;subscriptions=[];get isClosed(){return this.closed}get id(){return this.channelId}constructor(e,t){this.client=e,this.channelId=t,this.subject=`channel.${t}`,this.requestSubject=`channel.${t}.request`}async init(){this.initialized||(this.initialized=!0,this.unsubscribe=await this.client.subscribe(this.subject,async e=>{switch(e.type){case`message`:this.emit(`message`,e.data);break;case`close`:this.handleClose();break;case`error`:this.handleError(Error(e.error??`Channel error`))}}))}async send(e){if(this.closed)throw Error(`Channel is closed`);let t={type:`message`,data:e};await this.client.publish(this.subject,t)}async request(e,t=5e3){if(this.closed)throw Error(`Channel is closed`);return this.client.request(this.requestSubject,e,{timeout:t})}async onRequest(e){let t=this.client.onRequest(this.requestSubject,e);return this.subscriptions.push(t),t}on(e,t){e===`close`?this.closeHandlers.add(t):e===`error`?this.errorHandlers.add(t):(this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t))}off(e,t){e===`close`?this.closeHandlers.delete(t):e===`error`?this.errorHandlers.delete(t):this.handlers.get(e)?.delete(t)}async close(){if(!this.closed){this.closed=!0;try{await this.client.publish(this.subject,{type:`close`})}catch{}await this.cleanup()}}handlerChain=Promise.resolve();runHandler(e,t,n){this.handlerChain=this.handlerChain.then(()=>e(t)).catch(e=>console.error(`Error in ${n}:`,e))}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)this.runHandler(e,t,`channel handler`)}handleClose(){if(!this.closed){this.closed=!0;for(let e of this.closeHandlers)this.runHandler(()=>e(),void 0,`close handler`);this.cleanup().catch(console.error)}}handleError(e){for(let t of this.errorHandlers)this.runHandler(t,e,`error handler`)}async cleanup(){if(this.handlers.clear(),this.closeHandlers.clear(),this.errorHandlers.clear(),await Promise.allSettled(this.subscriptions.map(async e=>(await e)())),this.subscriptions=[],this.unsubscribe){try{this.unsubscribe()}catch{}this.unsubscribe=void 0}let e=this._isolatedClient;if(e)try{await e.disconnect()}catch{}}},Vo=class extends Bo{targetClientId;clientId;remoteClientId;privateSubject;privateRequestSubject;get remoteId(){return this.remoteClientId}constructor(e,t,n){super(e,t),this.targetClientId=n;let r=e.options.name??`client-${Date.now()}`;this.clientId=r.replace(/-(channel|private)-.*$/,``);let i=[this.clientId,this.targetClientId].sort();this.privateSubject=`channel.private.${t}.${i.join(`.`)}`,this.privateRequestSubject=`${this.privateSubject}.request`}async init(){if(!this.initialized){this.initialized=!0,this.unsubscribe=await this.client.subscribe(this.privateSubject,async e=>{if(e.sender!==this.clientId&&e.sender===this.targetClientId&&(!this.remoteClientId&&e.sender&&(this.remoteClientId=e.sender),!(this.remoteClientId&&e.sender!==this.remoteClientId)))switch(e.type){case`message`:if(e.data&&typeof e.data==`object`&&`__handshake`in e.data)return;this.emit(`message`,e.data);break;case`close`:this.handleClose();break;case`error`:this.handleError(Error(e.error??`Channel error`))}});try{await this.sendRaw({type:`message`,data:{__handshake:!0},sender:this.clientId})}catch{}}}async send(e){if(this.closed)throw Error(`Channel is closed`);await this.sendRaw({type:`message`,data:e,sender:this.clientId})}async request(e,t=5e3){if(this.closed)throw Error(`Channel is closed`);return this.client.request(this.privateRequestSubject,e,{timeout:t})}async onRequest(e){return this.client.onRequest(this.privateRequestSubject,e)}async close(){if(!this.closed){this.closed=!0;try{await this.sendRaw({type:`close`,sender:this.clientId})}catch{}await this.cleanup()}}isConnectedTo(e){return this.remoteClientId===e}async sendRaw(e){await this.client.publish(this.privateSubject,e)}},Ho;try{Ho=new TextDecoder}catch{}var Y,Uo,X=0,Wo=[],Go=Wo,Ko=0,qo={},Jo,Yo,Xo=0,Zo=0,Qo,$o,es=[],ts,ns={useRecords:!1,mapsAsObjects:!0},rs=class{},is=new rs;is.name=`MessagePack 0xC1`;var as=!1,os=2,ss=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(Y)return Ls(()=>(Rs(),this?this.unpack(t,n):e.prototype.unpack.call(ns,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(Uo=n.end||t.length,X=n.start||0):(X=0,Uo=n>-1?n:t.length),Ko=0,Zo=0,Yo=null,Go=Wo,Qo=null,Y=t;try{ts=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw Y=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(qo=this,this.structures)return Jo=this.structures,cs(n);(!Jo||Jo.length>0)&&(Jo=[])}else qo=ns,(!Jo||Jo.length>0)&&(Jo=[]);return cs(n)}unpackMultiple(e,t){let n,r=0;try{as=!0;let i=e.length,a=this?this.unpack(e,i):Bs.unpack(e,i);if(t){if(t(a,r,X)===!1)return;for(;X<i;)if(r=X,t(cs(),r,X)===!1)return}else{for(n=[a];X<i;)r=X,n.push(cs());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{as=!1,Rs()}}_mergeStructures(e,t){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function cs(e){try{if(!qo.trusted&&!as){let e=Jo.sharedLength||0;e<Jo.length&&(Jo.length=e)}let t;if(qo._readStruct&&Y[X]<64&&Y[X]>=32?(t=qo._readStruct(Y,X,Uo),Y=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),X=Uo):t=us(),Qo&&=(X=Qo.postBundlePosition,null),as&&(Jo.restoreStructures=null),X==Uo)Jo&&Jo.restoreStructures&&ls(),Jo=null,Y=null,$o&&=null;else if(X>Uo)throw Error(`Unexpected end of MessagePack data`);else if(!as){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw Jo&&Jo.restoreStructures&&ls(),Rs(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||X>Uo)&&(e.incomplete=!0),e}}function ls(){for(let e in Jo.restoreStructures)Jo[e]=Jo.restoreStructures[e];Jo.restoreStructures=null}function us(){let e=Y[X++];if(e<160){if(e<128){if(e<64)return e;{let t=Jo[e&63]||qo.getStructures&&ms()[e&63];return t?(t.read||=fs(t,e&63),t.read()):e}}if(e<144){if(e-=128,qo.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=As();e===`__proto__`&&(e=`__proto_`),t[e]=us()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(us(),us());return t}}{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=us();return qo.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(Zo>=X)return Yo.slice(X-Xo,(X+=t)-Xo);if(Zo==0&&Uo<140){let e=t<16?Ts(t):ws(t);if(e!=null)return e}return hs(t)}{let t;switch(e){case 192:return null;case 193:return Qo?(t=us(),t>0?Qo[1].slice(Qo.position1,Qo.position1+=t):Qo[0].slice(Qo.position0,Qo.position0-=t)):is;case 194:return!1;case 195:return!0;case 196:if(t=Y[X++],t===void 0)throw Error(`Unexpected end of buffer`);return Ds(t);case 197:return t=ts.getUint16(X),X+=2,Ds(t);case 198:return t=ts.getUint32(X),X+=4,Ds(t);case 199:return Os(Y[X++]);case 200:return t=ts.getUint16(X),X+=2,Os(t);case 201:return t=ts.getUint32(X),X+=4,Os(t);case 202:if(t=ts.getFloat32(X),qo.useFloat32>2){let e=zs[(Y[X]&127)<<1|Y[X+1]>>7];return X+=4,(e*t+(t>0?.5:-.5)>>0)/e}return X+=4,t;case 203:return t=ts.getFloat64(X),X+=8,t;case 204:return Y[X++];case 205:return t=ts.getUint16(X),X+=2,t;case 206:return t=ts.getUint32(X),X+=4,t;case 207:return qo.int64AsType===`number`?(t=ts.getUint32(X)*4294967296,t+=ts.getUint32(X+4)):qo.int64AsType===`string`?t=ts.getBigUint64(X).toString():qo.int64AsType===`auto`?(t=ts.getBigUint64(X),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ts.getBigUint64(X),X+=8,t;case 208:return ts.getInt8(X++);case 209:return t=ts.getInt16(X),X+=2,t;case 210:return t=ts.getInt32(X),X+=4,t;case 211:return qo.int64AsType===`number`?(t=ts.getInt32(X)*4294967296,t+=ts.getUint32(X+4)):qo.int64AsType===`string`?t=ts.getBigInt64(X).toString():qo.int64AsType===`auto`?(t=ts.getBigInt64(X),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ts.getBigInt64(X),X+=8,t;case 212:if(t=Y[X++],t==114)return Ms(Y[X++]&63);{let e=es[t];if(e)return e.read?(X++,e.read(us())):e.noBuffer?(X++,e()):e(Y.subarray(X,++X));throw Error(`Unknown extension `+t)}case 213:return t=Y[X],t==114?(X++,Ms(Y[X++]&63,Y[X++])):Os(2);case 214:return Os(4);case 215:return Os(8);case 216:return Os(16);case 217:return t=Y[X++],Zo>=X?Yo.slice(X-Xo,(X+=t)-Xo):gs(t);case 218:return t=ts.getUint16(X),X+=2,Zo>=X?Yo.slice(X-Xo,(X+=t)-Xo):_s(t);case 219:return t=ts.getUint32(X),X+=4,Zo>=X?Yo.slice(X-Xo,(X+=t)-Xo):vs(t);case 220:return t=ts.getUint16(X),X+=2,xs(t);case 221:return t=ts.getUint32(X),X+=4,xs(t);case 222:return t=ts.getUint16(X),X+=2,Ss(t);case 223:return t=ts.getUint32(X),X+=4,Ss(t);default:if(e>=224)return e-256;throw e===void 0?bs():Error(`Unknown MessagePack token `+e)}}}var ds=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function fs(e,t){function n(){if(n.count++>os){let r;try{r=e.read=Function(`r`,`return function(){return `+(qo.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:ds.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(us)}catch{return os=1/0,n()}return e.read0=r,e.highByte===0&&(e.read=ps(t,e.read)),r()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=us()}return qo.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?ps(t,n):n}var ps=(e,t)=>function(){let n=Y[X++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=Jo[r]||ms()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=fs(i,e),i.read()};function ms(){let e=Ls(()=>(Y=null,qo.getStructures()));return Jo=qo._mergeStructures(e,Jo)}var hs=ys,gs=ys,_s=ys,vs=ys;function ys(e){let t;if(e<16&&(t=Ts(e)))return t;if(e>64&&Ho)return Ho.decode(Y.subarray(X,X+=e));let n=X+e,r=[];for(t=``;X<n;){let e=Y[X++];if(!(e&128))r.push(e);else if((e&224)==192){if(e<194||X>=n||(Y[X]&192)!=128)r.push(65533);else{let t=Y[X++]&63;r.push((e&31)<<6|t)}}else if((e&240)==224){let t=X<n?Y[X]:0;if(X>=n||(t&192)!=128||e===224&&t<160||e===237&&t>=160)r.push(65533);else if(X++,X>=n||(Y[X]&192)!=128)r.push(65533);else{let n=Y[X++]&63;r.push((e&31)<<12|(t&63)<<6|n)}}else if((e&248)==240){let t=X<n?Y[X]:0;if(e>244||X>=n||(t&192)!=128||e===240&&t<144||e===244&&t>=144)r.push(65533);else if(X++,X>=n||(Y[X]&192)!=128)r.push(65533);else{let i=Y[X++]&63;if(X>=n||(Y[X]&192)!=128)r.push(65533);else{let n=Y[X++]&63,a=(e&7)<<18|(t&63)<<12|i<<6|n;a-=65536,r.push(a>>>10&1023|55296),r.push(56320|a&1023)}}}else r.push(65533);r.length>=4096&&(t+=Cs.apply(String,r),r.length=0)}return r.length>0&&(t+=Cs.apply(String,r)),t}function bs(){let e=Error(`Unexpected end of MessagePack data`);return e.incomplete=!0,e}function xs(e){if(e>Uo-X)throw bs();let t=Array(e);for(let n=0;n<e;n++)t[n]=us();return qo.freezeData?Object.freeze(t):t}function Ss(e){if(e>(Uo-X)/2)throw bs();if(qo.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=As();e===`__proto__`&&(e=`__proto_`),t[e]=us()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(us(),us());return t}}var Cs=String.fromCharCode;function ws(e){let t=X,n=Array(e);for(let r=0;r<e;r++){let e=Y[X++];if((e&128)>0){X=t;return}n[r]=e}return Cs.apply(String,n)}function Ts(e){if(e<4){if(e<2){if(e===0)return``;{let e=Y[X++];if((e&128)>1){--X;return}return Cs(e)}}{let t=Y[X++],n=Y[X++];if((t&128)>0||(n&128)>0){X-=2;return}if(e<3)return Cs(t,n);let r=Y[X++];if((r&128)>0){X-=3;return}return Cs(t,n,r)}}{let t=Y[X++],n=Y[X++],r=Y[X++],i=Y[X++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){X-=4;return}if(e<6){if(e===4)return Cs(t,n,r,i);{let e=Y[X++];if((e&128)>0){X-=5;return}return Cs(t,n,r,i,e)}}if(e<8){let a=Y[X++],o=Y[X++];if((a&128)>0||(o&128)>0){X-=6;return}if(e<7)return Cs(t,n,r,i,a,o);let s=Y[X++];if((s&128)>0){X-=7;return}return Cs(t,n,r,i,a,o,s)}{let a=Y[X++],o=Y[X++],s=Y[X++],c=Y[X++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){X-=8;return}if(e<10){if(e===8)return Cs(t,n,r,i,a,o,s,c);{let e=Y[X++];if((e&128)>0){X-=9;return}return Cs(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=Y[X++],u=Y[X++];if((l&128)>0||(u&128)>0){X-=10;return}if(e<11)return Cs(t,n,r,i,a,o,s,c,l,u);let d=Y[X++];if((d&128)>0){X-=11;return}return Cs(t,n,r,i,a,o,s,c,l,u,d)}{let l=Y[X++],u=Y[X++],d=Y[X++],f=Y[X++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){X-=12;return}if(e<14){if(e===12)return Cs(t,n,r,i,a,o,s,c,l,u,d,f);{let e=Y[X++];if((e&128)>0){X-=13;return}return Cs(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=Y[X++],m=Y[X++];if((p&128)>0||(m&128)>0){X-=14;return}if(e<15)return Cs(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=Y[X++];if((h&128)>0){X-=15;return}return Cs(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Es(){let e=Y[X++],t;if(e<192)t=e-160;else switch(e){case 217:t=Y[X++];break;case 218:t=ts.getUint16(X),X+=2;break;case 219:t=ts.getUint32(X),X+=4;break;default:throw Error(`Expected string`)}return ys(t)}function Ds(e){return qo.copyBuffers?Uint8Array.prototype.slice.call(Y,X,X+=e):Y.subarray(X,X+=e)}function Os(e){let t=Y[X++];if(es[t]){let n;return es[t](Y.subarray(X,n=X+=e),e=>{X=e;try{return us()}finally{X=n}})}throw Error(`Unknown extension type `+t)}var ks=Array(4096);function As(){let e=Y[X++];if(e>=160&&e<192){if(e-=160,Zo>=X)return Yo.slice(X-Xo,(X+=e)-Xo);if(!(Zo==0&&Uo<180))return hs(e)}else return X--,js(us());let t=(e<<5^(e>1?ts.getUint16(X):e>0?Y[X]:0))&4095,n=ks[t],r=X,i=X+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=ts.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=Y[r++],a!=n[o++]){r=1879048192;break}if(r===i)return X=r,n.string;i-=3,r=X}for(n=[],ks[t]=n,n.bytes=e;r<i;)a=ts.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=Y[r++],n.push(a);let s=e<16?Ts(e):ws(e);return s==null?n.string=hs(e):n.string=s}function js(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(qo.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var Ms=(e,t)=>{let n=us().map(js),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=Jo[e];return i&&(i.isShared||as)&&((Jo.restoreStructures||(Jo.restoreStructures=[]))[e]=i),Jo[e]=n,n.read=fs(n,r),(n.read0||n.read)()};es[0]=()=>{},es[0].noBuffer=!0,es[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=BigInt(64),n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var Ns={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};es[101]=()=>{let e=us();if(!Ns[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return Ns[e[0]](e[1],{cause:e[2]})},es[105]=e=>{if(qo.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ts.getUint32(X-4);$o||=new Map;let n=Y[X],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&Y[X+1]===115?new Set:{};let i={target:r};$o.set(t,i);let a=us();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},es[112]=e=>{if(qo.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ts.getUint32(X-4),n=$o.get(t);return n.used=!0,n.target},es[115]=()=>new Set(us());var Ps=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),Fs=typeof globalThis==`object`?globalThis:window;es[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=Ps[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new Fs[r](n)},es[120]=()=>{let e=us();return new RegExp(e[0],e[1])};var Is=[];es[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=X;return X+=t-e.length,Qo=Is,Qo=[Es(),Es()],Qo.position0=0,Qo.position1=0,Qo.postBundlePosition=X,X=n,us()},es[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function Ls(e){qo&&qo._onSaveState&&qo._onSaveState();let t=Uo,n=X,r=Ko,i=Xo,a=Zo,o=Yo,s=Go,c=$o,l=Qo,u=new Uint8Array(Y.slice(0,Uo)),d=Jo,f=Jo.slice(0,Jo.length),p=qo,m=as,h=e();return Uo=t,X=n,Ko=r,Xo=i,Zo=a,Yo=o,Go=s,$o=c,Qo=l,Y=u,as=m,Jo=d,Jo.splice(0,Jo.length,...f),qo=p,ts=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),h}function Rs(){Y=null,$o=null,Jo=null}var zs=Array(147);for(let e=0;e<256;e++)zs[e]=+(`1e`+Math.floor(45.15-e*.30103));var Bs=new ss({useRecords:!1});Bs.unpack,Bs.unpackMultiple,Bs.unpack;var Vs={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4),ss.SUPPORTS_STRUCT_HOOKS=!0;var Hs;try{Hs=new TextEncoder}catch{}var Us,Ws,Gs=typeof Buffer<`u`,Ks=Gs?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,qs=Gs?Buffer:Uint8Array,Js=Gs?4294967296:2144337920,Z,Ys,Xs,Q=0,Zs,Qs=null,$s=21760,ec=/[\u0080-\uFFFF]/,tc=Symbol(`record-id`),nc=class extends ss{constructor(e){super(e),this.offset=0;let t,n,r,i,a=qs.prototype.utf8Write?function(e,t){return Z.utf8Write(e,t,Z.byteLength-t)}:Hs&&Hs.encodeInto?function(e,t){return Hs.encodeInto(e,Z.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(Z||(Z=new Ks(8192),Xs=Z.dataView||(Z.dataView=new DataView(Z.buffer,0,8192)),Q=0),Zs=Z.length-10,Zs-Q<2048?(Z=new Ks(Z.length),Xs=Z.dataView||(Z.dataView=new DataView(Z.buffer,0,Z.length)),Zs=Z.length-10,Q=0):Q=Q+7&2147483640,t=Q,a&2048&&(Q+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(Qs=[],Qs.size=1/0):Qs=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[tc]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o._writeStruct&&e&&typeof e==`object`?e.constructor===Object?w(e):e.constructor!==Map&&!Array.isArray(e)&&!Ws.some(t=>e instanceof t)?w(o.useToJSON!==!1&&e.toJSON?e.toJSON():e):y(e):y(e);let n=Qs;if(Qs&&sc(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(Xs.setUint32(n.position+t,Xs.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&Xs.setUint32(n.position+t,Xs.getUint32(n.position+t)+a),Q+=e.length*6,Q>Zs&&T(Q),o.offset=Q;let s=oc(Z.subarray(t,Q),e);return i=null,s}return o.offset=Q,a&512?(Z.start=t,Z.end=Q,Z):Z.subarray(t,Q)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=Z.subarray(t,Q),s=(o._prepareStructures||cc)(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?(r.uninitialized=!0,o.pack(e,a)):(o.lastNamedStructuresLength=n,Z.length>1073741824&&(Z=null),i)}Z.length>1073741824&&(Z=null),a&1024&&(Q=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][tc]=0;m=[]}},v=e=>{var t=e.length;t<16?Z[Q++]=144|t:t<65536?(Z[Q++]=220,Z[Q++]=t>>8,Z[Q++]=t&255):(Z[Q++]=221,Xs.setUint32(Q,t),Q+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{Q>Zs&&(Z=T(Q));var n=typeof e,r;if(n===`string`){let n=e.length;if(Qs&&n>=4&&n<4096){if((Qs.size+=n)>$s){let e,n=(Qs[0]?Qs[0].length*3+Qs[1].length:0)+10;Q+n>Zs&&(Z=T(Q+n));let r;Qs.position?(r=Qs,Z[Q]=200,Q+=3,Z[Q++]=98,e=Q-t,Q+=4,sc(t,y,0),Xs.setUint16(e+t-3,Q-t-e)):(Z[Q++]=214,Z[Q++]=98,e=Q-t,Q+=4),Qs=[``,``],Qs.previous=r,Qs.size=0,Qs.position=e}let r=ec.test(e);Qs[+!r]+=e,Z[Q++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(Q+o>Zs&&(Z=T(Q+o)),n<64||!a){let t,a,o,s=Q+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?Z[s++]=a:a<2048?(Z[s++]=a>>6|192,Z[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,Z[s++]=a>>18|240,Z[s++]=a>>12&63|128,Z[s++]=a>>6&63|128,Z[s++]=a&63|128):(Z[s++]=a>>12|224,Z[s++]=a>>6&63|128,Z[s++]=a&63|128);r=s-Q-i}else r=a(e,Q+i);r<32?Z[Q++]=160|r:r<256?(i<2&&Z.copyWithin(Q+2,Q+1,Q+1+r),Z[Q++]=217,Z[Q++]=r):r<65536?(i<3&&Z.copyWithin(Q+3,Q+2,Q+2+r),Z[Q++]=218,Z[Q++]=r>>8,Z[Q++]=r&255):(i<5&&Z.copyWithin(Q+5,Q+3,Q+3+r),Z[Q++]=219,Xs.setUint32(Q,r),Q+=4),Q+=r}else if(n===`number`){if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this._writeStruct?Z[Q++]=e:e<256?(Z[Q++]=204,Z[Q++]=e):e<65536?(Z[Q++]=205,Z[Q++]=e>>8,Z[Q++]=e&255):(Z[Q++]=206,Xs.setUint32(Q,e),Q+=4);else if(e>>0===e)e>=-32?Z[Q++]=256+e:e>=-128?(Z[Q++]=208,Z[Q++]=e+256):e>=-32768?(Z[Q++]=209,Xs.setInt16(Q,e),Q+=2):(Z[Q++]=210,Xs.setInt32(Q,e),Q+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){Z[Q++]=202,Xs.setFloat32(Q,e);let n;if(t<4||(n=e*zs[(Z[Q]&127)<<1|Z[Q+1]>>7])>>0===n){Q+=4;return}Q--}Z[Q++]=203,Xs.setFloat64(Q,e),Q+=8}}else if(n===`object`||n===`function`){if(!e)Z[Q++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),Z[Q++]=214,Z[Q++]=112,Xs.setUint32(Q,n.id),Q+=4;return}i.set(e,{offset:Q-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map){if(this.mapAsEmptyObject)Z[Q++]=128;else{r=e.size,r<16?Z[Q++]=128|r:r<65536?(Z[Q++]=222,Z[Q++]=r>>8,Z[Q++]=r&255):(Z[Q++]=223,Xs.setUint32(Q,r),Q+=4);for(let[t,n]of e)y(t),y(n)}}else{for(let t=0,n=Us.length;t<n;t++){let n=Ws[t];if(e instanceof n){let n=Us[t];if(n.write){n.type&&(Z[Q++]=212,Z[Q++]=n.type,Z[Q++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=Z,i=Xs,a=Q;Z=null;let o;try{o=n.pack.call(this,e,e=>(Z=r,r=null,Q+=e,Q>Zs&&T(Q),{target:Z,targetView:Xs,position:Q-e}),y)}finally{r&&(Z=r,Xs=i,Q=a,Zs=Z.length-10)}o&&(o.length+Q>Zs&&T(o.length+Q),Q=ac(o,Z,Q,n.type));return}}if(Array.isArray(e))v(e);else{if(o.useToJSON!==!1&&e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}}else if(n===`boolean`)Z[Q++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)Z[Q++]=211,Xs.setBigInt64(Q,e);else if(e<0x10000000000000000&&e>0)Z[Q++]=207,Xs.setBigUint64(Q,e);else if(this.largeBigIntToFloat)Z[Q++]=203,Xs.setFloat64(Q,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),Gs)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+Q>Zs&&T(n.length+Q),Q=ac(n,Z,Q,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);Q+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?Z[Q++]=192:(Z[Q++]=212,Z[Q++]=0,Z[Q++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?Z[Q++]=128|n:n<65536?(Z[Q++]=222,Z[Q++]=n>>8,Z[Q++]=n&255):(Z[Q++]=223,Xs.setUint32(Q,n),Q+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{Z[Q++]=222;let n=Q-t;Q+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);Z[n+++t]=r>>8,Z[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=Q++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==Q?(Q--,E(i,c,u)):D(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[tc];n?Z[a+t]=n:D(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[tc];a?a>=96&&d?(Z[Q++]=((a-=96)&31)+96,Z[Q++]=a>>5):Z[Q++]=a:E(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let i=o._writeStruct(e,Z,t,Q,r,T,(e,t,r)=>{if(r)return n=!0;Q=t;let i=Z;return y(e),_(),i===Z?Q:{position:Q,targetView:Xs,target:Z}});if(i===0)return C(e);Q=i},T=e=>{let n;if(e>16777216){if(e-t>Js)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(Js,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,Z.length-1)>>12)+1<<12;let r=new Ks(n);return Xs=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,Z.length),Z.copy?Z.copy(r,0,t,e):r.set(Z.slice(t,e)),Q-=t,t=0,Zs=r.length-10,Z=r},E=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[tc]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(Z[Q++]=(a&31)+96,Z[Q++]=o):Z[Q++]=a):(o>=0?(Z[Q++]=213,Z[Q++]=114,Z[Q++]=(a&31)+96,Z[Q++]=o):(Z[Q++]=212,Z[Q++]=114,Z[Q++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[tc]=0),m.push(e),y(t))},D=(e,n,r,i)=>{let a=Z,o=Q,s=Zs,c=t;Z=Ys,Q=0,t=0,Z||(Ys=Z=new Ks(8192)),Zs=Z.length-10,E(e,n,i),Ys=Z;let l=Q;if(Z=a,Q=o,Zs=s,t=c,l>1){let e=Q+l-1;e>Zs&&T(e);let n=r+t;Z.copyWithin(n+l,n+1,Q),Z.set(Ys.slice(0,l),n),Q=e}else Z[r+t]=Ys[0]}}useBuffer(e){Z=e,Z.dataView||(Z.dataView=new DataView(Z.buffer,Z.byteOffset,Z.byteLength)),Xs=Z.dataView,Q=0}set position(e){Q=e}get position(){return Q}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};Ws=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,rs],Us=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?rc(e,16,t):ic(Gs?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==qs&&this.moreTypes?rc(e,Ps.indexOf(n.name),t):ic(e,t)}},{pack(e,t){this.moreTypes?rc(e,17,t):ic(Gs?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function rc(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function ic(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function ac(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function oc(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function sc(e,t,n){if(Qs.length>0){Xs.setUint32(Qs.position+e,Q+n-Qs.position-e),Qs.stringsPosition=Q-e;let r=Qs;Qs=null,t(r[0]),t(r[1])}}function cc(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}nc.SUPPORTS_STRUCT_HOOKS=!0;var lc=new nc({useRecords:!1});lc.pack,lc.pack;var{NEVER:uc,ALWAYS:dc,DECIMAL_ROUND:fc,DECIMAL_FIT:pc}=Vs,mc=new nc({useRecords:!1,bundleStrings:!1,int64AsType:`number`}),hc=new ss({useRecords:!1,bundleStrings:!1,int64AsType:`number`});function gc(e){return mc.pack(e)}function _c(e){return hc.unpack(e)}var vc=[67,85,73,66],yc=8,bc=`__cui_bin__`;function xc(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Sc(e){if(e instanceof Uint8Array)return e.byteLength>=16384?e:void 0;if(e instanceof ArrayBuffer)return e.byteLength>=16384?new Uint8Array(e):void 0}function Cc(e,t){let n=Sc(e);if(n){let e=t.length;return t.push(n),{[bc]:e,l:n.byteLength}}if(Array.isArray(e)){let n;for(let r=0;r<e.length;r++){let i=Cc(e[r],t);i!==e[r]&&(n??=e.slice(),n[r]=i)}return n??e}if(xc(e)){let n;for(let r of Object.keys(e)){let i=Cc(e[r],t);i!==e[r]&&(n??={...e},n[r]=i)}return n??e}return e}function wc(e){if(!xc(e))return!1;let t=e[bc],n=e.l;return!Number.isInteger(t)||t<0||!Number.isInteger(n)||n<0?!1:Object.keys(e).length===2}function Tc(e,t,n){if(wc(e)){if(n.outOfOrder||e[bc]!==n.next)return n.outOfOrder=!0,e;let r=e.l,i=n.offset+r;if(i>t.byteLength)throw Error(`Invalid CUIB frame: segment ${n.next} exceeds payload size ${t.byteLength}`);let a=t.subarray(n.offset,i);return n.offset=i,n.next++,a}if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=Tc(e[r],t,n);return e}if(xc(e)){for(let r of Object.keys(e))e[r]=Tc(e[r],t,n);return e}return e}function Ec(e,t){if(wc(e)){t[e[bc]]=e.l;return}if(Array.isArray(e)){for(let n of e)Ec(n,t);return}if(xc(e))for(let n of Object.keys(e))Ec(e[n],t)}function Dc(e,t){if(wc(e))return t[e[bc]];if(Array.isArray(e)){for(let n=0;n<e.length;n++)e[n]=Dc(e[n],t);return e}if(xc(e)){for(let n of Object.keys(e))e[n]=Dc(e[n],t);return e}return e}function Oc(e,t,n){let r=[];Ec(e,r);let i=Array(r.length),a=n.offset;for(let e=n.next;e<r.length;e++){let n=r[e];if(n===void 0)throw Error(`Invalid CUIB frame: missing placeholder for segment ${e}`);if(a+n>t.byteLength)throw Error(`Invalid CUIB frame: segment ${e} exceeds payload size ${t.byteLength}`);i[e]=t.subarray(a,a+n),a+=n}return n.offset=a,Dc(e,i)}function kc(e){let t=[],n=Cc(e,t);if(t.length===0)return mc.pack(e);let r=mc.pack(n),i=r.byteLength,a=yc+i;for(let e of t)a+=e.byteLength;let o=typeof Buffer<`u`?Buffer.allocUnsafe(a):new Uint8Array(a);o[0]=vc[0],o[1]=vc[1],o[2]=vc[2],o[3]=vc[3],o[4]=i&255,o[5]=i>>>8&255,o[6]=i>>>16&255,o[7]=i>>>24&255,o.set(r,yc);let s=yc+r.byteLength;for(let e of t)o.set(e,s),s+=e.byteLength;return o}function Ac(e){if(e.byteLength<yc||e[0]!==vc[0]||e[1]!==vc[1]||e[2]!==vc[2]||e[3]!==vc[3])return hc.unpack(e);let t=(e[4]|e[5]<<8|e[6]<<16)+e[7]*16777216,n=yc+t;if(n>e.byteLength)throw Error(`Invalid CUIB frame: envelope length ${t} exceeds payload size ${e.byteLength}`);let r=hc.unpack(e.subarray(yc,n)),i={offset:n,next:0,outOfOrder:!1};if(r=Tc(r,e,i),i.outOfOrder&&(r=Oc(r,e,i)),i.offset!==e.byteLength)throw Error(`Invalid CUIB frame: expected payload size ${i.offset}, got ${e.byteLength}`);return r}function*jc(e,t,n){let r=e.length,i=Math.ceil(r/n);for(let a=0;a<i;a++){let o=a*n,s=Math.min(o+n,r),c=e.subarray(o,s);yield{id:t,chunkIndex:a,data:c,isLast:a===i-1}}}var Mc=class{id;buffer;receivedChunks=new Set;totalChunks=0;chunkSize=0;constructor(e,t,n,r){this.id=e,this.totalChunks=n,this.chunkSize=r??Math.ceil(t/n),this.buffer=new Uint8Array(t)}addChunk(e){if(e.id!==this.id)throw Error(`Chunk ID mismatch: expected ${this.id}, got ${e.id}`);let t=e.chunkIndex*this.chunkSize;return this.buffer.set(e.data,t),this.receivedChunks.add(e.chunkIndex),this.isComplete()}isComplete(){return this.receivedChunks.size===this.totalChunks}getData(){if(!this.isComplete())throw Error(`Not all chunks received`);return Ac(this.buffer)}getProgress(){let e=this.receivedChunks.size,t=this.totalChunks;return{received:e,total:t,percentage:t>0?e/t*100:0}}},Nc=class e{static STALE_TRANSFER_TTL_MS=3e4;static SWEEP_INTERVAL_MS=1e3;assemblers=new Map;completedCallbacks=new Map;errorCallbacks=new Map;lastActivity=new Map;lastSweep=0;startReceiving(e,t,n,r,i,a){this.sweepStale();let o=new Mc(e,i,t,a);this.assemblers.set(e,o),this.completedCallbacks.set(e,n),this.errorCallbacks.set(e,r),this.lastActivity.set(e,Date.now())}sweepStale(){if(this.lastActivity.size===0)return;let t=Date.now();if(t-this.lastSweep<e.SWEEP_INTERVAL_MS)return;this.lastSweep=t;let n=t-e.STALE_TRANSFER_TTL_MS;for(let[e,t]of this.lastActivity)if(t<n){let t=this.errorCallbacks.get(e);this.assemblers.delete(e),this.completedCallbacks.delete(e),this.errorCallbacks.delete(e),this.lastActivity.delete(e),t&&t(Error(`Transfer timed out`))}}processChunk(e){this.sweepStale();let t=this.assemblers.get(e.id);if(!t){console.warn(`Received chunk for unknown transfer: ${e.id}`);return}this.lastActivity.set(e.id,Date.now());try{if(t.addChunk(e)){let n=t.getData(),r=this.completedCallbacks.get(e.id);this.assemblers.delete(e.id),this.completedCallbacks.delete(e.id),this.errorCallbacks.delete(e.id),this.lastActivity.delete(e.id),r&&r(n)}}catch(t){let n=this.errorCallbacks.get(e.id);this.assemblers.delete(e.id),this.completedCallbacks.delete(e.id),this.errorCallbacks.delete(e.id),this.lastActivity.delete(e.id),n&&n(t)}}cancel(e){let t=this.errorCallbacks.get(e);this.assemblers.delete(e),this.completedCallbacks.delete(e),this.errorCallbacks.delete(e),this.lastActivity.delete(e),t&&t(Error(`Transfer cancelled`))}getProgress(e){let t=this.assemblers.get(e);return t?t.getProgress():null}};B();var Pc=Symbol(`rpc:methods`),Fc=Symbol(`rpc:nested`),Ic=Symbol(`rpc:exposeAll`);function Lc(e,t=[],n={},r=new WeakSet){if(!e||typeof e!=`object`||r.has(e))return n;r.add(e);let i=Object.getOwnPropertyNames(e),a=[],o=Object.getPrototypeOf(e);for(;o&&o!==Object.prototype;)a.push(...Object.getOwnPropertyNames(o)),o=Object.getPrototypeOf(o);let s=[...new Set([...i,...a])];for(let r of s)if(!(r===`constructor`||r.startsWith(`_`)||r.startsWith(`#`)))try{if(e.constructor&&Object.prototype.hasOwnProperty.call(e.constructor,r))continue;let i=Object.getOwnPropertyDescriptor(e,r);if(!i){let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype&&!i;)i=Object.getOwnPropertyDescriptor(t,r),t=Object.getPrototypeOf(t)}if(i&&(i.get||i.set)&&!i.value){let i=e[r];if(typeof i==`function`){let a=[...t,r].join(`.`);n[a]=i.bind(e)}continue}let a=e[r],o=[...t,r].join(`.`);typeof a==`function`&&(n[o]=a.bind(e))}catch{}return n}function Rc(e,t=[],n={},r=new WeakSet){if(r.has(e))return n;r.add(e);let i=e.constructor===Object||e.constructor===void 0,a=Object.getPrototypeOf(e),o=Reflect.hasMetadata(Pc,e)||Reflect.hasMetadata(Pc,a)||Reflect.hasMetadata(Fc,e)||Reflect.hasMetadata(Fc,a)||Reflect.hasMetadata(Ic,a);if(i&&!o){let i=Object.getOwnPropertyNames(e);for(let a of i)if(!(a===`constructor`||a.startsWith(`_`)))try{let i=e[a],o=[...t,a].join(`.`);typeof i==`function`?n[o]=i.bind(e):typeof i==`object`&&i&&!Array.isArray(i)?Rc(i,[...t,a],n,r):n[o]=async()=>i}catch{}}else{let i=a&&Reflect.getMetadata(Ic,a),o=[...Reflect.getMetadata(Pc,e)??[],...(a&&Reflect.getMetadata(Pc,a))??[]],s=[...Reflect.getMetadata(Fc,e)??[],...(a&&Reflect.getMetadata(Fc,a))??[]],c=Object.getOwnPropertyNames(e);a&&c.push(...Object.getOwnPropertyNames(a).filter(e=>e!==`constructor`));for(let l of c)if(l!==`constructor`)try{let c=e[l]??a?.[l];if(!c)continue;let u=[...t,l].join(`.`);typeof c==`function`?(i&&!l.startsWith(`_`)||o.includes(l))&&(n[u]=c.bind(e)):o.includes(l)?n[u]=async()=>e[l]:typeof c==`object`&&c&&s.includes(l)&&Rc(c,[...t,l],n,r)}catch{}}return n}var zc=class e extends Error{code;data;constructor(e,t,n){super(t),this.name=`RPCException`,this.code=e,this.data=n}static fromJSON(t){return new e(t.code,t.message,t.data)}toJSON(){return{code:this.code,message:this.message,data:this.data}}};function Bc(e,t,n){return new zc(e,t,n)}var Vc={METHOD_NOT_FOUND:`METHOD_NOT_FOUND`,INVALID_PARAMS:`INVALID_PARAMS`,INTERNAL_ERROR:`INTERNAL_ERROR`,TIMEOUT:`TIMEOUT`,CONNECTION_CLOSED:`CONNECTION_CLOSED`,STREAM_ERROR:`STREAM_ERROR`,PAYLOAD_TOO_LARGE:`PAYLOAD_TOO_LARGE`,NOT_FOUND:`NOT_FOUND`},Hc=Symbol.for(`rpc.callbacks`),Uc=Symbol.for(`rpc.callbacks.oneway`);function Wc(e){return!!e&&typeof e==`object`&&e[Hc]===!0}function Gc(e){return e?.[Uc]??[]}function Kc(e){if(e instanceof Promise)return!0;if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.then==`function`&&typeof t.catch==`function`}function qc(e,t,n=[],r=null,i){let a=r,o=e=>{a??=new Set(e)},s=async(t,n,r)=>{let{result:s,methods:c,timing:l}=await e.callWithMeta(t,n,{discover:a===null,timing:i!==void 0});return c&&o(c),l&&i&&i(r??t,l),s};return new Proxy({},{get(r,o){if(o===`then`||o===`catch`||o===`finally`)return;if(typeof o==`symbol`||o===`toString`)return()=>`[RPCProxy ${t}${n.length?`.`+n.join(`.`):``}]`;if(a&&n.length===0&&!a.has(o))return;let c=[...n,o];return new Proxy(function(){},{apply(n,r,i){let a=c.join(`.`),l=`rpc.${t}.${a}`,u=o.toLowerCase().includes(`pull`),d=i.findIndex(e=>Wc(e));if(d!==-1){let t=i[d],n=Gc(t),r=i.filter((e,t)=>t!==d);return e.callPullIteratorWithCallback(l,t,n,...r)}let f=i.findIndex(e=>typeof e==`function`);if(f!==-1){let t=i[f],n=i.filter((e,t)=>t!==f);return e.callWithCallback(l,n,t)}return o.toLowerCase().includes(`generate`)?e.callStream(l,...i):u?e.callPullIterator(l,...i):s(l,i,a)},get(n,r){if(r===`then`||r===`catch`||r===`finally`){let n=c.join(`.`),i=(async()=>(!e.isConnected&&!e.isClosed&&await e.connect(),s(`rpc.${t}.${n}`,[],n)))();return i[r].bind(i)}return qc(e,t,c,a,i)[r]}})}})}function Jc(e,t,n,r=[]){return new Proxy({},{get(i,a){if(a===`then`||a===`catch`||a===`finally`)return;if(typeof a==`symbol`||a===`toString`)return()=>`[ServiceProxy ${t.name}${r.length?`.`+r.join(`.`):``}]`;if(a in i)return i[a];let o=[...r,a],s=o.join(`.`),c=t.endpoints.find(e=>{if(e.subject===s)return!0;let t=e.subject.split(`.`);return t[t.length-1]===a&&t.slice(0,-1).join(`.`)===r.join(`.`)});if(c)return new Proxy(function(){},{apply(t,n,r){let i=a.toLowerCase().includes(`pull`),o=r.findIndex(e=>Wc(e));if(o!==-1){let t=r[o],n=Gc(t),i=r.filter((e,t)=>t!==o);return e.callPullIteratorWithCallback(c.subject,t,n,...i)}let s=r.findIndex(e=>typeof e==`function`);if(s!==-1){let t=r[s],n=r.filter((e,t)=>t!==s);return e.callWithCallback(c.subject,n,t)}return a.toLowerCase().includes(`generate`)?e.callStream(c.subject,...r):i?e.callPullIterator(c.subject,...r):e.call(c.subject,...r)}});let l=s+`.`;if(t.endpoints.some(e=>e.subject.startsWith(l)))return Jc(e,t,n,o)}})}var Yc=36**4,Xc=Math.floor(Math.random()*36**5).toString(36).padStart(5,`0`),Zc=Math.floor(Math.random()*Yc);function Qc(e){Zc=(Zc+1)%Yc;let t=`${Date.now()}-${Xc}${Zc.toString(36).padStart(4,`0`)}`;return e?`${e}.${t}`:t}function $c(){let e,t=globalThis.crypto;if(t?.getRandomValues){let n=new Uint8Array(6);t.getRandomValues(n),e=n.reduce((e,t)=>e*256+t,0)}else e=Math.floor(Math.random()*2**48);return e.toString(36).padStart(10,`0`)}function el(e){return new Promise(t=>setTimeout(t,e))}function tl(e,t){let n=Promise.resolve(),r=0;return{dispatch:i=>{if(r===0){let a;try{a=e(i)}catch(e){t(e);return}Kc(a)&&(r++,n=a.then(()=>{r--},e=>{r--,t(e)}));return}r++,n=n.then(()=>e(i)).then(()=>{r--},e=>{r--,t(e)})},flush:()=>r===0?Promise.resolve():n}}async function nl(e,t,n,r,i){let a,o=e(...t);if(o&&typeof o.then==`function`){let e=await o;if(e&&typeof e[Symbol.asyncIterator]==`function`)a=e;else if(e&&typeof e[Symbol.iterator]==`function`)a=(async function*(){for(let t of e)yield t})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for stream`)}else if(o&&typeof o[Symbol.asyncIterator]==`function`)a=o;else if(o&&typeof o[Symbol.iterator]==`function`)a=(async function*(){for(let e of o)yield e})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for stream`);let s=!1,c=await i.subscribe(`${n}.cancel`,()=>{s=!0});await el(0);try{for await(let e of a){if(s||!i.isConnected)break;let t={id:r,type:`data`,data:e};await i.publish(n,t)}if(!s&&i.isConnected){let e={id:r,type:`end`};await i.publish(n,e)}}catch(e){if(!s&&i.isConnected)try{let t={id:r,type:`error`,error:il(e)};await i.publish(n,t)}catch{}}finally{if(c(),a.return)try{await a.return()}catch{}}}async function rl(e,t){return e(...Array.isArray(t)?t:t==null?[]:[t])}function il(e){return e instanceof zc?e.toJSON():{code:Vc.INTERNAL_ERROR,message:e instanceof Error?e.message:`Internal error`}}async function al(e,t,n,r,i){let a,o=e(...t);if(o&&typeof o.then==`function`){let e=await o;if(e&&typeof e[Symbol.asyncIterator]==`function`)a=e;else if(e&&typeof e[Symbol.iterator]==`function`)a=(async function*(){for(let t of e)yield t})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for pull iterator`)}else if(o&&typeof o[Symbol.asyncIterator]==`function`)a=o;else if(o&&typeof o[Symbol.iterator]==`function`)a=(async function*(){for(let e of o)yield e})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for pull iterator`);let s=`_rpc.iterator.${n}.request`,c=`_rpc.iterator.${n}.response`,l=!0,u,d=()=>{l&&(l=!1,u?.(),i?.())},f=await r.subscribe(s,async e=>{if(l)try{if(e.type===`cancel`){d(),a.return&&await a.return();let e={id:n,type:`done`};r.tryPublishSync(c,e)||await r.publish(c,e)}else if(e.type===`next`){let{value:e,done:t}=await a.next();if(t){d();let e={id:n,type:`done`};r.tryPublishSync(c,e)||await r.publish(c,e)}else{let t={id:n,type:`value`,value:e};r.tryPublishSync(c,t)||await r.publish(c,t)}}}catch(e){d();let t={id:n,type:`error`,error:il(e)};r.tryPublishSync(c,t)||await r.publish(c,t)}});return u=f,async()=>{if(l=!1,f(),a.return)try{await a.return()}catch{}}}async function ol(e,t,n,r,i,a,o,s){let c=new Set(a),l={},u=!0;for(let e of i)l[e]=c.has(e)?(...t)=>{if(!u||!o.isConnected)return;let n={method:e,args:t};try{o.tryPublishSync(r,n)||o.publish(r,n).catch(()=>{})}catch{}}:()=>{throw Bc(Vc.INTERNAL_ERROR,`Request-reply callback '${e}' not supported in v1`)};let d,f=e(...t,l),p=e=>{if(e&&typeof e[Symbol.asyncIterator]==`function`)return e;if(e&&typeof e[Symbol.iterator]==`function`)return(async function*(){for(let t of e)yield t})();throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for pull-callback iterator`)};d=f&&typeof f.then==`function`?p(await f):p(f);let m=`_rpc.iterator.${n}.request`,h=`_rpc.iterator.${n}.response`,g=!0,_,v=()=>{g&&(g=!1,u=!1,_?.(),s?.())},y=await o.subscribe(m,async e=>{if(g)try{if(e.type===`cancel`){v(),d.return&&await d.return();let e={id:n,type:`done`};o.tryPublishSync(h,e)||await o.publish(h,e)}else if(e.type===`next`){let{done:e}=await d.next();if(e){v();let e={id:n,type:`done`};o.tryPublishSync(h,e)||await o.publish(h,e)}else{let e={id:n,type:`value`};o.tryPublishSync(h,e)||await o.publish(h,e)}}}catch(e){v();let t={id:n,type:`error`,error:il(e)};o.tryPublishSync(h,t)||await o.publish(h,t)}});return _=y,async()=>{if(g=!1,u=!1,y(),d.return)try{await d.return()}catch{}}}async function sl(e,t,n,r,i,a){let o=async e=>{if(!i.isConnected)return;let t={id:r,type:`data`,data:e};await i.publish(n,t)},s;try{let n=e(...t,o);n&&typeof n.then==`function`?s=await n:typeof n==`function`&&(s=n)}catch(e){let t={id:r,type:`error`,error:il(e)};throw await i.publish(n,t),e}let c=!1,l=async()=>{c||(c=!0,s&&await s())},u;return u=await i.subscribe(`${n}.cancel`,async()=>{u?.(),a?.(),await l()}),async()=>{u?.(),await l()}}var cl=a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ServiceVerb=e.ServiceError=e.ServiceErrorCodeHeader=e.ServiceErrorHeader=e.ServiceResponseType=void 0,e.ServiceResponseType={STATS:`io.nats.micro.v1.stats_response`,INFO:`io.nats.micro.v1.info_response`,PING:`io.nats.micro.v1.ping_response`},e.ServiceErrorHeader=`Nats-Service-Error`,e.ServiceErrorCodeHeader=`Nats-Service-Error-Code`,e.ServiceError=class t extends Error{code;constructor(e,t){super(t),this.code=e}static isServiceError(e){return t.toServiceError(e)!==null}static toServiceError(n){let r=n?.headers?.get(e.ServiceErrorCodeHeader)||``;if(r!==``){let i=parseInt(r)||400,a=n?.headers?.get(e.ServiceErrorHeader)||``;return new t(i,a.length?a:r)}return null}},e.ServiceVerb={PING:`PING`,STATS:`STATS`,INFO:`INFO`}})),ll=a((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceImpl=t.ServiceGroupImpl=t.ServiceMsgImpl=t.ServiceApiPrefix=void 0;var n=(zo(),e(Ro)),r=cl();function i(e,t=``){if(t===``)throw Error(`${e} name required`);let n=a(t);if(n.length)throw Error(`invalid ${e} name - ${e} name ${n}`)}function a(e=``){if(!e)throw Error(`name required`);let t=/^[-\w]+$/g;if(e.match(t)===null){for(let n of e.split(``))if(n.match(t)===null)return`cannot contain '${n}'`}return``}t.ServiceApiPrefix=`$SRV`;var o=class{msg;constructor(e){this.msg=e}get data(){return this.msg.data}get sid(){return this.msg.sid}get subject(){return this.msg.subject}get reply(){return this.msg.reply||``}get headers(){return this.msg.headers}respond(e,t){return this.msg.respond(e,t)}respondError(e,t,i,a){return a||={},a.headers=a.headers||(0,n.headers)(),a.headers?.set(r.ServiceErrorCodeHeader,`${e}`),a.headers?.set(r.ServiceErrorHeader,t),this.msg.respond(i,a)}json(e){return this.msg.json(e)}string(){return this.msg.string()}};t.ServiceMsgImpl=o;var s=class e{subject;queue;srv;constructor(t,n=``,r=``){n!==``&&l(`service group`,n);let i=``;if(t instanceof u)this.srv=t,i=``;else if(t instanceof e){let e=t;this.srv=e.srv,r===void 0&&(r=e.queue),i=e.subject}else throw Error(`unknown ServiceGroup type`);this.subject=this.calcSubject(i,n),this.queue=r}calcSubject(e,t=``){return t===``?e:e===``?t:`${e}.${t}`}addEndpoint(e=``,t){t||={subject:e};let n=typeof t==`function`?{handler:t,subject:e}:t;i(`endpoint`,e);let{subject:r,handler:a,metadata:o,queue:s}=n;r||=e,s||=this.queue,c(`endpoint subject`,r),r=this.calcSubject(this.subject,r);let l={name:e,subject:r,queue:s,handler:a,metadata:o};return this.srv._addEndpoint(l)}addGroup(t=``,n){return n===void 0&&(n=this.queue),new e(this,t,n)}};t.ServiceGroupImpl=s;function c(e,t){if(t===``)throw Error(`${e} cannot be empty`);if(t.indexOf(` `)!==-1)throw Error(`${e} cannot contain spaces: '${t}'`);let n=t.split(`.`);n.forEach((r,i)=>{if(r===`>`&&i!==n.length-1)throw Error(`${e} cannot have internal '>': '${t}'`)})}function l(e,t){if(t.indexOf(` `)!==-1)throw Error(`${e} cannot contain spaces: '${t}'`);t.split(`.`).forEach(n=>{if(n===`>`)throw Error(`${e} name cannot contain internal '>': '${t}'`)})}var u=class e{nc;_id;config;handlers;internal;_stopped;_done;started;closeListener;static controlSubject(e,n=``,r=``,a){let o=a??t.ServiceApiPrefix;return n===``&&r===``?`${o}.${e}`:(i(`control subject name`,n),r===``?`${o}.${e}.${n}`:(i(`control subject id`,r),`${o}.${e}.${n}.${r}`))}constructor(e,t={name:``,version:``}){this.nc=e,this.config=Object.assign({},t),this.config.queue===void 0&&(this.config.queue=`q`),t.metadata=Object.freeze(t.metadata||{}),i(`name`,this.config.name),this.config.queue&&i(`queue`,this.config.queue),(0,n.parseSemVer)(this.config.version),this._id=n.nuid.next(),this.internal=[],this._done=(0,n.deferred)(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.closeListener={connectionClosedCallback:e=>{this.close(e).catch()}},this.nc.addCloseListener(this.closeListener)}get subjects(){return this.handlers.filter(e=>e.internal===!1).map(e=>e.subject)}get id(){return this._id}get name(){return this.config.name}get description(){return this.config.description??``}get version(){return this.config.version}get metadata(){return this.config.metadata}errorToHeader(e){let t=(0,n.headers)();if(e instanceof r.ServiceError){let n=e;t.set(r.ServiceErrorHeader,n.message),t.set(r.ServiceErrorCodeHeader,`${n.code}`)}else t.set(r.ServiceErrorHeader,e.message),t.set(r.ServiceErrorCodeHeader,`500`);return t}setupHandler(e,t=!1){let r=t?``:e.queue?e.queue:this.config.queue,{name:i,subject:a,handler:s}=e,c=e;c.internal=t,t&&this.internal.push(c),c.stats=new d(i,a,r),c.queue=r;let l=s?(e,t)=>{if(e){this.close(e);return}let r=Date.now();try{s(e,new o(t))}catch(e){c.stats.countError(e),t?.respond(n.Empty,{headers:this.errorToHeader(e)})}finally{c.stats.countLatency(r)}}:void 0;return c.sub=this.nc.subscribe(a,{callback:l,queue:r}),c.sub.closed.then(()=>{this._stopped||this.close(Error(`required subscription ${e.subject} stopped`)).catch()}).catch(t=>{if(!this._stopped){let n=Error(`required subscription ${e.subject} errored: ${t.message}`);n.stack=t.stack,this.close(n).catch()}}),c}info(){return{type:r.ServiceResponseType.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(e=>{let{subject:t,metadata:n,name:r,queue:i}=e;return{subject:t,metadata:n,name:r,queue_group:i}})}async stats(){let e=[];for(let t of this.handlers){if(typeof this.config.statsHandler==`function`)try{t.stats.data=await this.config.statsHandler(t)}catch(e){t.stats.countError(e)}e.push(t.stats.stats(t.qi))}return{type:r.ServiceResponseType.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:e}}addInternalHandler(e,t){let n=`${e}`.toUpperCase();this._doAddInternalHandler(`${n}-all`,e,t),this._doAddInternalHandler(`${n}-kind`,e,t,this.name),this._doAddInternalHandler(`${n}`,e,t,this.name,this.id)}_doAddInternalHandler(t,n,r,i=``,a=``){let o={};o.name=t,o.subject=e.controlSubject(n,i,a),o.handler=r,this.setupHandler(o,!0)}start(){let e=(e,t)=>e?(this.close(e),Promise.reject(e)):this.stats().then(e=>(t?.respond(JSON.stringify(e)),Promise.resolve())),t=(e,t)=>e?(this.close(e),Promise.reject(e)):(t?.respond(JSON.stringify(this.info())),Promise.resolve()),n=JSON.stringify(this.ping());return this.addInternalHandler(r.ServiceVerb.PING,(e,t)=>e?(this.close(e).then().catch(),Promise.reject(e)):(t.respond(n),Promise.resolve())),this.addInternalHandler(r.ServiceVerb.STATS,e),this.addInternalHandler(r.ServiceVerb.INFO,t),this.handlers.forEach(e=>{let{subject:t}=e;typeof t==`string`&&e.handler!==null&&this.setupHandler(e)}),Promise.resolve(this)}close(e){if(this._stopped)return this._done;this._stopped=!0,this.nc.removeCloseListener(this.closeListener);let t=[];return this.nc.isClosed()||(t=this.handlers.concat(this.internal).map(e=>e.sub.drain())),Promise.allSettled(t).then(()=>{this._done.resolve(e||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(e){return this.close(e)}ping(){return{type:r.ServiceResponseType.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(let e of this.handlers)e.stats.reset(e.qi)}addGroup(e,t){return new s(this,e,t)}addEndpoint(e,t){return new s(this).addEndpoint(e,t)}_addEndpoint(e){let t=new n.QueuedIteratorImpl;t.profile=!0,t.noIterator=typeof e.handler==`function`,t.noIterator||(e.handler=(e,n)=>{e?this.stop(e).catch():t.push(new o(n))},t.iterClosed.then(()=>{this.close().catch()}));let r=this.setupHandler(e,!1);return r.sub.closed.then(e=>{e?this.stop(e):t.stop()}),r.qi=t,this.handlers.push(r),t}};t.ServiceImpl=u;var d=class{name;subject;average_processing_time;num_requests;processing_time;num_errors;last_error;data;metadata;queue;constructor(e,t,n=``){this.name=e,this.subject=t,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=n}reset(e){this.num_requests=0,this.processing_time=0,this.average_processing_time=0,this.num_errors=0,this.last_error=void 0,this.data=void 0;let t=e;t&&(t.time=0,t.processed=0)}countLatency(e){this.num_requests++,this.processing_time+=(0,n.nanos)(Date.now()-e),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(e){this.num_errors++,this.last_error=e.message}_stats(){let{name:e,subject:t,average_processing_time:n,num_errors:r,num_requests:i,processing_time:a,last_error:o,data:s,queue:c}=this;return{name:e,subject:t,average_processing_time:n,num_errors:r,num_requests:i,processing_time:a,last_error:o,data:s,queue_group:c}}stats(e){let t=e;return t?.noIterator===!1&&(this.processing_time=(0,n.nanos)(t.time),this.num_requests=t.processed,this.average_processing_time=this.processing_time>0&&this.num_requests>0?this.processing_time/this.num_requests:0),this._stats()}}})),ul=a((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceClientImpl=void 0;var n=(zo(),e(Ro)),r=ll(),i=cl();t.ServiceClientImpl=class{nc;prefix;opts;constructor(e,t={strategy:`stall`,maxWait:2e3},n){this.nc=e,this.prefix=n,this.opts=t}ping(e=``,t=``){return this.q(i.ServiceVerb.PING,e,t)}stats(e=``,t=``){return this.q(i.ServiceVerb.STATS,e,t)}info(e=``,t=``){return this.q(i.ServiceVerb.INFO,e,t)}async q(e,t=``,i=``){let a=new n.QueuedIteratorImpl,o=r.ServiceImpl.controlSubject(e,t,i,this.prefix),s=await this.nc.requestMany(o,n.Empty,this.opts);return(async()=>{for await(let e of s)try{let t=e.json();a.push(t)}catch(e){a.push(()=>{a.stop(e)})}a.push(()=>{a.stop()})})().catch(e=>{a.stop(e)}),a}}})),dl=a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Svcm=e.ServiceVerb=e.ServiceResponseType=e.ServiceErrorHeader=e.ServiceErrorCodeHeader=e.ServiceError=void 0;var t=ll(),n=ul(),r=cl();Object.defineProperty(e,"ServiceError",{enumerable:!0,get:function(){return r.ServiceError}}),Object.defineProperty(e,"ServiceErrorCodeHeader",{enumerable:!0,get:function(){return r.ServiceErrorCodeHeader}}),Object.defineProperty(e,"ServiceErrorHeader",{enumerable:!0,get:function(){return r.ServiceErrorHeader}}),Object.defineProperty(e,"ServiceResponseType",{enumerable:!0,get:function(){return r.ServiceResponseType}}),Object.defineProperty(e,"ServiceVerb",{enumerable:!0,get:function(){return r.ServiceVerb}}),e.Svcm=class{nc;constructor(e){this.nc=e}add(e){try{return new t.ServiceImpl(this.nc,e).start()}catch(e){return Promise.reject(e)}}client(e,t){return new n.ServiceClientImpl(this.nc,e,t)}}})),fl=a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Svcm=e.ServiceVerb=e.ServiceResponseType=e.ServiceErrorHeader=e.ServiceErrorCodeHeader=e.ServiceError=void 0;var t=dl();Object.defineProperty(e,"ServiceError",{enumerable:!0,get:function(){return t.ServiceError}}),Object.defineProperty(e,"ServiceErrorCodeHeader",{enumerable:!0,get:function(){return t.ServiceErrorCodeHeader}}),Object.defineProperty(e,"ServiceErrorHeader",{enumerable:!0,get:function(){return t.ServiceErrorHeader}}),Object.defineProperty(e,"ServiceResponseType",{enumerable:!0,get:function(){return t.ServiceResponseType}}),Object.defineProperty(e,"ServiceVerb",{enumerable:!0,get:function(){return t.ServiceVerb}}),Object.defineProperty(e,"Svcm",{enumerable:!0,get:function(){return t.Svcm}})}))(),pl=class{client;svc;services=[];nc;constructor(e){this.client=e}init(e){this.nc!==e&&(this.nc=e,this.svc=new fl.Svcm(e),this.services=[])}async registerHandler(e,t,n){if(!this.svc)throw Error(`RPCService is not initialized. Call init() first.`);let r=new Map,i=this.client,a=this.svc;if(n?.isolatedConnection){i=this.client.createIsolatedClient({...this.client.options,name:`${this.client.options.name}-service-${e.name}`});let t=await i.connect();a=new fl.Svcm(t)}let o=await a.add(e);this.services.push(o),n?.isolatedConnection&&(o._isolatedClient=i);let s=Rc(t),c=new Map;for(let[e,t]of Object.entries(s)){let n=e.split(`.`),a=n.pop(),s=o;if(n.length>0){let e=n.join(`.`);if(!c.has(e)){let t=o;for(let e of n)t=t.addGroup(e);c.set(e,t)}s=c.get(e)}s.addEndpoint(a,async(e,n)=>{if(e){n.respondError(500,e.message);return}try{let e=n.headers?.get(`x-chunked-transfer`);if(e===`header`){let e=_c(n.data),t=n.headers?.get(`x-chunk-id`);if(!t||e.transferId!==t){console.error(`Invalid chunk header`);return}i.chunkingManager.startReceiving(e.transferId,e.totalChunks,async e=>{await o(e,n)},e=>{console.error(`Error assembling chunks for ${a}:`,e)},e.totalSize,e.chunkSize)}else if(e===`chunk`){let e=n.headers?.get(`x-chunk-id`),t=parseInt(n.headers?.get(`x-chunk-index`)??`0`);if(!e){console.error(`Chunk missing chunk ID`);return}i.chunkingManager.processChunk({id:e,chunkIndex:t,data:n.data,isLast:!1})}else await o(Ac(n.data),n)}catch(e){console.error(`Error processing message for ${a}:`,e)}async function o(e,n){let a={id:e.id};try{if(e.params?.__stream&&e.params?.__streamSubject){let n=e.params.__streamSubject,r=e.params.args??[];await nl(t,r,n,e.id,i)}else if(e.params?.__pullIterator||Array.isArray(e.params)&&e.params[0]?.__pullIterator){let o=e.params?.__pullIterator?e.params:e.params[0],s=o.args??[],c=o.__iteratorId??e.id,l=await al(t,s,c,i,()=>r.delete(c));r.set(c,l),a.result={iteratorId:c};let u=`${n.subject}.reply.${e.id}`;await i.publish(u,a)}else{a.result=await rl(t,e.params);let r=`${n.subject}.reply.${e.id}`;await i.publish(r,a)}}catch(t){a.error=il(t);try{let t=`${n.subject}.reply.${e.id}`;await i.publish(t,a)}catch(e){if(i.isClosed)return;console.error(`Failed to send error response:`,e)}}}})}let l=o;l._pullIteratorCleanups=r;let u=o.stop.bind(o);return o.stop=async e=>(await Promise.allSettled(Array.from(r.values()).map(e=>e())),r.clear(),u(e)),new ml(o)}monitor(){if(!this.svc)throw Error(`RPCService is not initialized. Call init() first.`);return this.svc.client({strategy:`stall`,stall:10,maxWait:2e3})}async stopAll(){await Promise.allSettled(this.services.map(async e=>{await e.stop();let t=e._isolatedClient;t&&await t.disconnect()})),this.services=[]}async stop(e){let t=this.services.find(t=>t.info().name===e);if(t)try{await t.stop();let e=t._isolatedClient;e&&await e.disconnect(),this.services=this.services.filter(e=>e!==t)}catch{}}getAllInfo(){return this.services.map(e=>e.info())}getInfo(e){return this.services.find(t=>t.info().name===e)?.info()}async getAllStats(){return Promise.all(this.services.map(e=>e.stats()))}async getStats(e){return this.services.find(t=>t.info().name===e)?.stats()}},ml=class{natsService;get isStopped(){return this.natsService.isStopped}constructor(e){this.natsService=e}info(){return this.natsService.info()}stats(){return this.natsService.stats()}async stop(e){try{await this.natsService.stop(e)}catch{}}};Lo(),Zr(),Sr(),da();function hl(e){return new _l(e)}function gl(e){return qr(e?`_INBOX.${e}`:void 0)}var _l=class e{options;service=new pl(this);chunkingManager=new Nc;pullIteratorCleanups=new Map;callbackCleanups=new Map;nc;subscriptionSeq=0;subscriptionEntries=new Map;pullIteratorSettles=new Set;replyPrefix;muxEntry;statusHandlers=new Map;_maxPayloadSize=1048576;connectionPromise;closed=!1;isolatedClients=[];pendingRequests=new Map;streamHandlers=new Map;get isConnected(){return this.nc?.isClosed()===!1}get isStale(){return this.nc?.isStale?.()??!1}get isClosed(){return this.closed}get maxPayloadSize(){return this._maxPayloadSize}status(){return this.nc?.status()}async flush(e=5e3){if(!this.nc)throw Bc(Vc.CONNECTION_CLOSED,`Not connected`);let t;try{await Promise.race([this.nc.flush(),new Promise((n,r)=>{t=setTimeout(()=>r(Bc(Vc.TIMEOUT,`flush() timed out after ${e}ms`)),e)})])}finally{t&&clearTimeout(t)}}constructor(e){this.options=e,this.replyPrefix=e.connId??$c()}createIsolatedClient(t){return new e(t)}async connect(e){if(e?.signal?.aborted)throw new DOMException(`Aborted`,`AbortError`);if(this.nc&&!this.nc.isClosed())return this.nc;let t={servers:this.options.servers,user:this.options.auth?.user,pass:this.options.auth?.password,name:this.options.name,inboxPrefix:this.options.connId?`_INBOX.${this.options.connId}`:void 0,reconnect:this.options.reconnect??!0,timeout:this.options.connectTimeout??1e4,maxPingOut:this.options.maxPingOut??2,maxReconnectAttempts:this.options.maxReconnectAttempts??-1,reconnectTimeWait:this.options.reconnectTimeWait??2e3,reconnectJitter:this.options.reconnectJitter??100,reconnectJitterTLS:this.options.reconnectJitterTLS??1e3,ignoreAuthErrorAbort:this.options.ignoreAuthErrorAbort??!1,pingInterval:this.options.pingInterval??12e4,pingTimeout:this.options.pingTimeout??0,reconnectionDelayMax:this.options.reconnectionDelayMax??0,reconnectionRandomizationFactor:this.options.reconnectionRandomizationFactor??0,tls:this.options.tls,debug:this.options.debug??!1,noAsyncTraces:!0,waitOnFirstConnect:this.options.waitOnFirstConnect??!0,signal:e?.signal};this.connectionPromise??=No(t);let n=this.connectionPromise;try{this.nc=await vl(n,e?.signal)}finally{this.connectionPromise=void 0}this.closed=!1,this.service.init(this.nc);try{let e=this.nc.info;this._maxPayloadSize=e?.max_payload??this.options.maxPayloadSize??1048576}catch{this._maxPayloadSize=this.options.maxPayloadSize??1048576}this._maxPayloadSize-=8192,this.ensureMuxSubscription(!1);for(let e of this.subscriptionEntries.values())(!e.sub||e.sub.isClosed())&&this.natsSubscribe(e);return this.nc}async disconnect(){this.closed=!0;for(let[,e]of this.pendingRequests)e.timeout&&clearTimeout(e.timeout),e.cleanup?.(),e.reject(Bc(Vc.CONNECTION_CLOSED,`Connection closed`));this.pendingRequests.clear(),this.statusHandlers.clear();for(let[,e]of this.streamHandlers)try{e.end()}catch{}this.streamHandlers.clear(),this.settlePullIterators(),await Promise.allSettled(Array.from(this.pullIteratorCleanups.values()).map(e=>e())),this.pullIteratorCleanups.clear(),await Promise.allSettled(Array.from(this.callbackCleanups.values()).map(e=>e())),this.callbackCleanups.clear();for(let e of this.subscriptionEntries.values())try{e.sub?.unsubscribe()}catch{}if(this.subscriptionEntries.clear(),this.muxEntry=void 0,this.chunkingManager=new Nc,await Promise.allSettled(this.isolatedClients.map(e=>e.disconnect())),this.isolatedClients=[],this.nc){try{await this.nc.close()}catch{}try{let e=this.options.disconnectTimeout??2e3;await Promise.race([this.nc.closed(),new Promise(t=>setTimeout(t,e))])}catch{}this.nc=void 0}}reconfigure(e){if(this.nc&&!this.nc.isClosed())throw Error(`Cannot reconfigure while connected. Call suspend() first.`);e.servers!==void 0&&(this.options.servers=e.servers),e.auth!==void 0&&(this.options.auth=e.auth);for(let t of this.isolatedClients)t.reconfigure(e)}setServers(e){this.options.servers=e,this.nc&&!this.nc.isClosed()&&this.nc.setServers(e);for(let t of this.isolatedClients)t.setServers(e)}async forceReconnect(){let e=this.nc;if(!(!e||e.isClosed())){try{typeof e.forceReconnect==`function`?await e.forceReconnect():typeof e.reconnect==`function`&&await e.reconnect()}catch{}await Promise.allSettled(this.isolatedClients.map(e=>e.forceReconnect()))}}abortClose(e){this.closed=!0;for(let[,e]of this.pendingRequests)e.timeout&&clearTimeout(e.timeout),e.cleanup?.(),e.reject(Bc(Vc.CONNECTION_CLOSED,`Connection closed`));this.pendingRequests.clear(),this.statusHandlers.clear();for(let[,e]of this.streamHandlers)try{e.end()}catch{}this.streamHandlers.clear(),this.settlePullIterators();for(let e of this.pullIteratorCleanups.values())try{e()}catch{}this.pullIteratorCleanups.clear();for(let e of this.callbackCleanups.values())try{e()}catch{}this.callbackCleanups.clear();for(let t of this.isolatedClients)try{t.abortClose(e)}catch{}this.isolatedClients=[];let t=this.nc;if(t){try{typeof t.abortClose==`function`?t.abortClose(e):t.close().catch(()=>{})}catch{}this.nc=void 0}}async suspend(){for(let[,e]of this.pendingRequests)e.timeout&&clearTimeout(e.timeout),e.cleanup?.(),e.reject(Bc(Vc.CONNECTION_CLOSED,`Connection closed`));this.pendingRequests.clear(),this.statusHandlers.clear();for(let[,e]of this.streamHandlers)try{e.end()}catch{}this.streamHandlers.clear(),this.settlePullIterators(),await Promise.allSettled(Array.from(this.pullIteratorCleanups.values()).map(e=>e())),this.pullIteratorCleanups.clear(),await Promise.allSettled(Array.from(this.callbackCleanups.values()).map(e=>e())),this.callbackCleanups.clear();for(let e of this.subscriptionEntries.values()){try{e.sub?.unsubscribe()}catch{}e.sub=void 0}if(this.chunkingManager=new Nc,await Promise.allSettled(this.isolatedClients.map(e=>e.suspend())),this.nc){try{await this.nc.close()}catch{}try{let e=this.options.disconnectTimeout??2e3;await Promise.race([this.nc.closed(),new Promise(t=>setTimeout(t,e))])}catch{}this.nc=void 0}this.connectionPromise=void 0}async publish(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=kc(t);if(r.length<=this._maxPayloadSize){this.nc.publish(e,r,n);return}let i=Qc(),a={type:`chunked`,transferId:i,totalChunks:Math.ceil(r.length/this._maxPayloadSize),totalSize:r.length,chunkSize:this._maxPayloadSize},o=n?.headers??ca();o.set(`x-chunked-transfer`,`header`),o.set(`x-chunk-id`,i),this.nc.publish(e,gc(a),{headers:o,reply:n?.reply});let s=0;for(let t of jc(r,i,this._maxPayloadSize)){let r=ca();r.set(`x-chunked-transfer`,`chunk`),r.set(`x-chunk-id`,i),r.set(`x-chunk-index`,s.toString()),this.nc.publish(e,t.data,{headers:r,reply:n?.reply}),s>0&&s%50==0&&await el(0),s++}}tryPublishSync(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=kc(t);return r.length>this._maxPayloadSize?!1:(this.nc.publish(e,r,n),!0)}async subscribe(e,t,n){let{unsubscribe:r}=await this.subscribeEntry(e,t,n);return r}async subscribeEntry(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=++this.subscriptionSeq,i={pattern:e,handler:t,options:n};return this.subscriptionEntries.set(r,i),this.natsSubscribe(i),{entry:i,unsubscribe:()=>{try{i.sub?.unsubscribe()}catch{}finally{this.subscriptionEntries.delete(r)}}}}natsSubscribe(e){let{pattern:t}=e;if(e.raw){e.sub=this.nc.subscribe(t,{callback:(n,r)=>{if(n){console.error(`Subscription error for ${t}:`,n);return}try{e.handler(r)}catch(e){console.error(`Error processing message for ${t}:`,e)}}});return}let n=tl(e.handler,e=>console.error(`Error in handler for ${t}:`,e)),r=n.dispatch;e.flush=n.flush;let i=(e,n)=>{if(e){console.error(`Subscription error for ${t}:`,e);return}try{let e=n.headers?.get(`x-chunked-transfer`);if(e===`header`){let e=_c(n.data),i=n.headers?.get(`x-chunk-id`);if(!i||e.transferId!==i){console.error(`Invalid chunk header`);return}this.chunkingManager.startReceiving(e.transferId,e.totalChunks,e=>{r(e)},e=>{console.error(`Error assembling chunks for ${t}:`,e)},e.totalSize,e.chunkSize)}else if(e===`chunk`){let e=n.headers?.get(`x-chunk-id`),t=parseInt(n.headers?.get(`x-chunk-index`)??`0`);if(!e){console.error(`Chunk missing chunk ID`);return}this.chunkingManager.processChunk({id:e,chunkIndex:t,data:n.data,isLast:!1})}else{let e=Ac(n.data);r(e)}}catch(e){console.error(`Error processing message for ${t}:`,e)}};e.sub=this.nc.subscribe(t,{...e.options?.queue?{queue:e.options.queue}:{},callback:i})}ensureMuxSubscription(e=!0){this.muxEntry||(this.muxEntry={pattern:`rpc.reply.${this.replyPrefix}.>`,raw:!0,handler:e=>this.handleMuxMessage(e)},this.subscriptionEntries.set(++this.subscriptionSeq,this.muxEntry)),e&&this.nc&&(!this.muxEntry.sub||this.muxEntry.sub.isClosed())&&this.natsSubscribe(this.muxEntry)}handleMuxMessage(e){if(e.data?.length===0&&e.headers?.code===503){let t=e.subject.slice(10),n=this.statusHandlers.get(t);if(n){this.statusHandlers.delete(t);try{n(new xr.NoRespondersError(t))}catch(e){console.error(`Error in no-responder status handler:`,e)}return}let r=this.pendingRequests.get(t);r&&(this.pendingRequests.delete(t),r.timeout&&clearTimeout(r.timeout),r.reject(new xr.NoRespondersError(r.subject??t)));return}let t=e.headers?.get(`x-chunked-transfer`);if(t===`header`){let t=_c(e.data),n=e.headers?.get(`x-chunk-id`);if(!n||t.transferId!==n){console.error(`Invalid chunk header on reply mux`);return}this.chunkingManager.startReceiving(t.transferId,t.totalChunks,e=>this.routeMuxResponse(e),e=>console.error(`Error assembling chunked RPC response:`,e),t.totalSize,t.chunkSize)}else if(t===`chunk`){let t=e.headers?.get(`x-chunk-id`),n=parseInt(e.headers?.get(`x-chunk-index`)??`0`);if(!t){console.error(`Chunk missing chunk ID on reply mux`);return}this.chunkingManager.processChunk({id:t,chunkIndex:n,data:e.data,isLast:!1})}else this.routeMuxResponse(Ac(e.data))}routeMuxResponse(e){let t=e,n=t?.id;if(!n)return;let r=this.pendingRequests.get(n);r&&(this.pendingRequests.delete(n),r.timeout&&clearTimeout(r.timeout),t.error?r.reject(zc.fromJSON(t.error)):r.resolve({result:t.result,methods:t.__methods,timing:t.__timing}))}settlePullIterators(){for(let e of[...this.pullIteratorSettles])try{e()}catch{}this.pullIteratorSettles.clear()}async request(e,t,n){return this.withNoResponderRetry(()=>this._requestOnce(e,t,n),n?.noResponderRetry)}async _requestOnce(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=n?.timeout??5e3,i=kc(t);try{let t=await this.nc.request(e,i,{timeout:r,headers:n?.headers,noMux:!1});if(t.headers?.get(`Nats-Service-Error-Code`)){let e=t.headers.get(`Nats-Service-Error-Code`)||`500`,n=t.headers.get(`Nats-Service-Error`)||`Service error`,r=null;if(t.data)try{r=Ac(t.data)}catch{}throw Bc(e,n,r)}let a=Ac(t.data);if(a?.error)throw Bc(a.code??Vc.INTERNAL_ERROR,a.error??`Unknown error`,a);return a}catch(t){throw t.code===`503`||t.message?.includes(`no responders`)?Bc(Vc.NOT_FOUND,`No responders available`):t.code===`TIMEOUT`||t.message?.includes(`timeout`)?Bc(Vc.TIMEOUT,`Request to "${e}" timed out after ${r}ms`):t}}async withNoResponderRetry(e,t){let n=t?.maxRetries??this.options.noResponderRetry?.maxRetries??3,r=t?.delays??this.options.noResponderRetry?.delays??[500,1e3,2e3];for(let t=0;;t++)try{return await e()}catch(e){if(!(e instanceof xr.NoRespondersError||e instanceof zc&&e.code===Vc.NOT_FOUND)||t>=n||this.closed)throw e;let i=r[Math.min(t,r.length-1)];await el(i)}}async call(e,...t){let{result:n}=await this.withNoResponderRetry(()=>this._callOnce(e,t));return n}async callWithMeta(e,t=[],n){let r=n?.timing===!0?Date.now():0,{result:i,methods:a,timing:o}=await this.withNoResponderRetry(()=>this._callOnce(e,t,n?.discover===!0,n?.timing===!0));if(!r||!o)return{result:i,methods:a};let s=Date.now()-r,c=Math.max(0,o.end-o.start);return{result:i,methods:a,timing:{totalMs:s,handlerMs:c,transportMs:Math.max(0,s-c)}}}async _callOnce(e,t,n=!1,r=!1){if(!this.isConnected&&!this.isClosed&&await this.connect(),!this.nc)throw Error(`Not connected`);if(!e.startsWith(`rpc.`))return this._callOnceService(e,t);this.ensureMuxSubscription();let i=Qc(this.replyPrefix),a=this.options.timeout??3e4,o=`rpc.reply.${i}`;return new Promise((s,c)=>{let l=setTimeout(()=>{this.pendingRequests.delete(i)&&c(Bc(Vc.TIMEOUT,`RPC call to "${e}" timed out after ${a}ms`))},a);this.pendingRequests.set(i,{resolve:s,reject:c,timeout:l,subject:e,cleanup:()=>{clearTimeout(l),this.pendingRequests.delete(i)}});let u={id:i,method:`call`,params:t};n&&(u.__discover=!0),r&&(u.__timing=!0),this.publish(e,u,{reply:o}).catch(e=>{this.pendingRequests.delete(i)&&(clearTimeout(l),c(e))})})}async _callOnceService(e,t){let n=Qc(this.replyPrefix),r=this.options.timeout??3e4,i=`${e}.reply.${n}`;return new Promise(async(a,o)=>{let s,c,l=async()=>{if(this.pendingRequests.has(n)){let e=this.pendingRequests.get(n);e?.timeout&&clearTimeout(e.timeout),this.pendingRequests.delete(n)}if(s&&!s.isClosed())try{s.unsubscribe()}catch{}c?.()},u=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),l(),o(Bc(Vc.TIMEOUT,`RPC call to "${e}" timed out after ${r}ms`)))},r);this.pendingRequests.set(n,{resolve:a,reject:o,timeout:u,cleanup:()=>l()});let d=async e=>{let t=e;if(t.id===n){let e=this.pendingRequests.get(t.id);e&&(this.pendingRequests.delete(t.id),e.timeout&&clearTimeout(e.timeout),await l(),t.error?e.reject(zc.fromJSON(t.error)):e.resolve({result:t.result,methods:t.__methods,timing:t.__timing}))}},f=(t,n)=>{n&&n.data?.length===0&&n.headers?.code===503?(o(new xr.NoRespondersError(e)),l()):t&&(o(t),l())};try{c=await this.subscribe(i,d);let r=gl(this.options.connId);s=this.nc.subscribe(r,{max:1,callback:f});let a={id:n,method:`call`,params:t};await this.publish(e,a,{reply:r})}catch(e){await l(),o(e)}})}async*callStream(e,...t){let n=this.options.noResponderRetry?.maxRetries??3,r=this.options.noResponderRetry?.delays??[500,1e3,2e3];for(let i=0;;i++)try{yield*this._callStreamOnce(e,...t);return}catch(e){if(!(e instanceof xr.NoRespondersError||e instanceof zc&&e.code===Vc.NOT_FOUND)||i>=n||this.closed)throw e;await el(r[Math.min(i,r.length-1)])}}_callStreamOnce(e,...t){let n=this,r=!1,i=!1,a=!1,o=!1,s=null,c=``,l=``,u,d=[],f=null,p=()=>{let e=f;e&&(f=null,e({value:void 0,done:!0}))},m={push:e=>{if(!o){if(f){let t=f;f=null,t({value:e,done:!1})}else d.push(e)}},end:()=>{o=!0,p()},error:e=>{s=e,o=!0,p()}},h=async()=>{if(!a&&(a=!0,n.streamHandlers.delete(c),n.statusHandlers.delete(c),u?.(),!o)){o=!0;try{await n.publish(`${l}.cancel`,{id:c})}catch{}}},g=async e=>{if(e.id!==c)return;let t=n.streamHandlers.get(e.id);if(t)switch(e.type){case`data`:t.push(e.data);break;case`end`:t.end(),await h();break;case`error`:t.error(zc.fromJSON(e.error)),await h()}},_=async()=>{if(!n.isConnected&&!n.isClosed&&await n.connect(),!n.nc)throw Error(`Not connected`);n.ensureMuxSubscription(),c=Qc(n.replyPrefix),l=`stream.${e}.${c}`,n.streamHandlers.set(c,m),u=await n.subscribe(l,g),n.statusHandlers.set(c,()=>{n.streamHandlers.get(c)?.error(new xr.NoRespondersError(e)),h()});let r={id:c,method:`stream`,params:{__stream:!0,__streamSubject:l,args:t}};await n.publish(e,r,{reply:`rpc.reply.${c}`})},v={async next(){if(i)return{value:void 0,done:!0};if(!r){r=!0;try{await _()}catch(e){throw await h(),e}if(i)return await h(),{value:void 0,done:!0}}if(s)throw await h(),s;if(d.length>0)return{value:d.shift(),done:!1};if(o)return await h(),{value:void 0,done:!0};let e=await new Promise((e,t)=>{if(i){e({value:void 0,done:!0});return}if(o){e({value:void 0,done:!0});return}if(s){t(s);return}f=e});if(i)return await h(),{value:void 0,done:!0};if(e.done){if(s)throw await h(),s;return await h(),{value:void 0,done:!0}}return{value:e.value,done:!1}},async return(e){return i?{value:e,done:!0}:(i=!0,p(),r&&await h(),{value:e,done:!0})},async throw(e){throw i?e:(i=!0,p(),r&&await h(),e)},[Symbol.asyncIterator](){return v},async[Symbol.asyncDispose](){await v.return()}};return v}callPullIterator(e,...t){let n=this,r=!1,i=!1,a=!1,o=!1,s=null,c=``,l=``,u=``,d=``,f,p=[],m=null,h=()=>{let e=m;e&&(m=null,e({id:c,type:`done`}))},g=()=>{o||(o=!0,s=Bc(Vc.CONNECTION_CLOSED,`Connection closed`));let e=m;e&&(m=null,e(s?{id:c,type:`error`,error:s.toJSON?.()??{code:Vc.CONNECTION_CLOSED,message:`Connection closed`}}:{id:c,type:`done`}))},_=async()=>{if(!a&&(a=!0,n.pullIteratorSettles.delete(g),n.statusHandlers.delete(c),f?.(),!o)){o=!0;try{let e={id:c,type:`cancel`};await n.publish(l,e)}catch{}}},v=async()=>{if(!n.isConnected&&!n.isClosed&&await n.connect(),!n.nc)throw Error(`Not connected`);if(n.ensureMuxSubscription(),n.pullIteratorSettles.add(g),c=Qc(n.replyPrefix),l=`_rpc.iterator.${c}.request`,u=`_rpc.iterator.${c}.response`,d=`rpc.reply.${c}`,(await n.call(e,{__pullIterator:!0,__iteratorId:c,args:t}))?.iteratorId!==c)throw Error(`Failed to initialize pull iterator`);f=await n.subscribe(u,e=>{if(e.type===`error`?(s=zc.fromJSON(e.error),o=!0):e.type===`done`&&(o=!0),m){let t=m;m=null,t(e)}else p.push(e)}),n.statusHandlers.set(c,()=>{let t=new xr.NoRespondersError(e);o=!0,s=Bc(`503`,t.message);let n={type:`error`,id:c,error:s.toJSON()};if(m){let e=m;m=null,e(n)}else p.push(n)})},y={async next(){if(i)return{value:void 0,done:!0};if(!r){r=!0;try{await v()}catch(e){throw await _(),e}if(i)return await _(),{value:void 0,done:!0}}let e={id:c,type:`next`};try{await n.publish(l,e,{reply:d})}catch(e){throw await _(),e}let t=await new Promise((e,t)=>{if(i){e({id:c,type:`done`});return}p.length>0?e(p.shift()):o&&s?t(s):o?e({id:c,type:`done`}):m=e});if(i)return await _(),{value:void 0,done:!0};if(t.type===`error`)throw await _(),zc.fromJSON(t.error);return t.type===`done`?(await _(),{value:void 0,done:!0}):{value:t.value,done:!1}},async return(e){return i?{value:e,done:!0}:(i=!0,h(),r&&await _(),{value:e,done:!0})},async throw(e){throw i?e:(i=!0,h(),r&&await _(),e)},[Symbol.asyncIterator](){return y},async[Symbol.asyncDispose](){await y.return()}};return y}callPullIteratorWithCallback(e,t,n,...r){let i=Array.isArray(n)?void 0:n,a=Array.isArray(n)?n:n.onewayMethods,o=i?.prefetch??!1,s=this,c=!1,l=!1,u=!1,d=!1,f=null,p=``,m=``,h=``,g=``,_=``,v,y,b,x=[],S=null,C=Promise.resolve(),w=!1,T=()=>{let e=S;e&&(S=null,e({id:p,type:`done`}))},E=()=>{d||(d=!0,f=Bc(Vc.CONNECTION_CLOSED,`Connection closed`));let e=S;e&&(S=null,e(f?{id:p,type:`error`,error:f.toJSON?.()??{code:Vc.CONNECTION_CLOSED,message:`Connection closed`}}:{id:p,type:`done`}))},D=async()=>{if(!u&&(u=!0,s.pullIteratorSettles.delete(E),s.statusHandlers.delete(p),v?.(),b?.(),!d)){d=!0;try{let e={id:p,type:`cancel`};await s.publish(m,e)}catch{}}},O=async()=>{if(!s.isConnected&&!s.isClosed&&await s.connect(),!s.nc)throw Error(`Not connected`);s.ensureMuxSubscription(),s.pullIteratorSettles.add(E),p=Qc(s.replyPrefix),m=`_rpc.iterator.${p}.request`,h=`_rpc.iterator.${p}.response`,g=`_rpc.cb.${p}`,_=`rpc.reply.${p}`;let n=Object.keys(t).filter(e=>typeof t[e]==`function`),i=await s.subscribeEntry(g,e=>{let n=t[e.method];if(!n){console.error(`[rpc] Pull-callback: unknown method '${e.method}'`);return}C=C.then(async()=>{try{await n(...e.args??[])}catch(t){console.error(`[rpc] Pull-callback handler '${e.method}' threw:`,t)}})});v=i.unsubscribe,y=()=>i.entry.flush?.()??Promise.resolve();let o={__pullCallback:!0,__iteratorId:p,__callbackSubject:g,__callbackMethods:n,__onewayMethods:a,args:r},c;try{c=await s.call(e,o)}catch(e){throw v?.(),v=void 0,e}if(c?.iteratorId!==p)throw v?.(),v=void 0,Error(`Failed to initialize pull-callback iterator`);b=await s.subscribe(h,e=>{if(e.type===`error`?(f=zc.fromJSON(e.error),d=!0):e.type===`done`&&(d=!0),S){let t=S;S=null,t(e)}else x.push(e)}),s.statusHandlers.set(p,()=>{let t=new xr.NoRespondersError(e);d=!0,f=Bc(`503`,t.message);let n={type:`error`,id:p,error:f.toJSON()};if(S){let e=S;S=null,e(n)}else x.push(n)})},k={async next(){if(l)return{value:void 0,done:!0};if(!c){c=!0;try{await O()}catch(e){throw await D(),e}if(l)return await D(),{value:void 0,done:!0}}if(w)w=!1;else{let e={id:p,type:`next`};try{await s.publish(m,e,{reply:_})}catch(e){throw await D(),e}}let e=await new Promise((e,t)=>{if(l){e({id:p,type:`done`});return}x.length>0?e(x.shift()):d&&f?t(f):d?e({id:p,type:`done`}):S=e});if(l)return await D(),{value:void 0,done:!0};if(e.type===`error`)throw await D(),zc.fromJSON(e.error);if(e.type===`done`)return await y?.(),await C,await D(),{value:void 0,done:!0};if(o&&!d&&!l)try{let e={id:p,type:`next`};await s.publish(m,e,{reply:_}),w=!0}catch{w=!1}return await y?.(),await C,{value:void 0,done:!1}},async return(e){return l?{value:e,done:!0}:(l=!0,T(),c&&await D(),{value:e,done:!0})},async throw(e){throw l?e:(l=!0,T(),c&&await D(),e)},[Symbol.asyncIterator](){return k},async[Symbol.asyncDispose](){await k.return()}};return k}async callWithCallback(e,t,n){if(!this.isConnected&&!this.isClosed&&await this.connect(),!this.nc)throw Error(`Not connected`);let r=Qc(this.replyPrefix),i=`rpc.cb.${r}`,a=await this.subscribe(i,async e=>{if(e.type===`data`)try{await n(e.data)}catch(e){console.error(`[rpc] Callback error:`,e)}else e.type===`error`&&console.error(`[rpc] Callback error:`,e.error)}),o={__callback:!0,__callbackSubject:i,args:t};try{await this.call(e,o)}catch(e){throw a(),e}return()=>{this.publish(`${i}.cancel`,{id:r}).catch(()=>{}),a()}}async registerHandler(e,t,n){if(!this.nc&&!n?.isolatedConnection)throw Error(`Not connected`);let r=this;n?.isolatedConnection&&(r=this.createIsolatedClient({...this.options,name:`${this.options.name}-handler-${e}`}),await r.connect(),this.isolatedClients.push(r));let i=[],a=[],o=[],s=n?.withoutDecorators?Lc(t):Rc(t),c=Object.keys(s);for(let[t,l]of Object.entries(s)){let s=`rpc.${e}.${t}`,u=await r.subscribe(s,async e=>{let n={id:e.id};e.__discover===!0&&(n.__methods=c);try{if(e.params?.__stream&&e.params?.__streamSubject){let n=e.params.__streamSubject,i=e.params.args??[];nl(l,i,n,e.id,r).catch(e=>{console.error(`Stream request error for ${t}:`,e)});return}if(e.params?.__pullIterator||Array.isArray(e.params)&&e.params[0]?.__pullIterator){let t=e.params?.__pullIterator?e.params:e.params[0],i=t.args??[],o=t.__iteratorId??e.id,s=await al(l,i,o,r,()=>r.pullIteratorCleanups.delete(o));r.pullIteratorCleanups.set(o,s),a.push(o),n.result={iteratorId:o};let c=`rpc.reply.${e.id}`;await r.publish(c,n)}else if(e.params?.__pullCallback||Array.isArray(e.params)&&e.params[0]?.__pullCallback){let t=e.params?.__pullCallback?e.params:e.params[0],i=t.args??[],o=t.__iteratorId??e.id,s=t.__callbackSubject,c=t.__callbackMethods??[],u=t.__onewayMethods??[],d=await ol(l,i,o,s,c,u,r,()=>r.pullIteratorCleanups.delete(o));r.pullIteratorCleanups.set(o,d),a.push(o),n.result={iteratorId:o};let f=`rpc.reply.${e.id}`;await r.publish(f,n)}else if(e.params&&typeof e.params==`object`&&!Array.isArray(e.params)&&e.params.__callback&&e.params.__callbackSubject||Array.isArray(e.params)&&e.params.length>0&&typeof e.params[0]==`object`&&e.params[0]?.__callback){let t=Array.isArray(e.params)&&e.params[0]?.__callback?e.params[0]:e.params,i=t.__callbackSubject,a=t.args??[],s=await sl(l,a,i,e.id,r,()=>r.callbackCleanups.delete(e.id));r.callbackCleanups.set(e.id,s),o.push(e.id),n.result={ok:!0};let c=`rpc.reply.${e.id}`;await r.publish(c,n)}else{let t=e.__timing===!0,i=t?Date.now():0,a=await rl(l,e.params);t&&(n.__timing={start:i,end:Date.now()}),n.result=a;let o=`rpc.reply.${e.id}`;await r.publish(o,n)}}catch(t){n.error=il(t),n.error.code===Vc.METHOD_NOT_FOUND&&(n.__methods=c);try{let t=`rpc.reply.${e.id}`;await r.publish(t,n)}catch(e){if(r.isClosed)return;console.error(`Failed to send error response:`,e)}}},n?.queue?{queue:n.queue}:void 0);i.push(u)}return async()=>{for(let e of i)e();if(await Promise.allSettled(a.map(e=>{let t=r.pullIteratorCleanups.get(e);return r.pullIteratorCleanups.delete(e),t?t():Promise.resolve()})),await Promise.allSettled(o.map(e=>{let t=r.callbackCleanups.get(e);return r.callbackCleanups.delete(e),t?t():Promise.resolve()})),n?.isolatedConnection){await r.disconnect();let e=this.isolatedClients.indexOf(r);e>=0&&this.isolatedClients.splice(e,1)}}}async onRequest(e,t){if(!this.nc)throw Error(`Not connected`);let n=this.nc.subscribe(e,{callback:(n,r)=>{(async()=>{try{let e=await t(Ac(r.data));if(r.reply){let t=kc(e);r.respond(t)}}catch(t){if(r.reply){let e=kc({error:t instanceof Error?t.message:`Internal error`,code:t instanceof zc?t.code:Vc.INTERNAL_ERROR});r.respond(e)}console.error(`Error in request handler for ${e}:`,t)}})()}});return()=>{n.unsubscribe()}}async channel(e,t){let n;t?.isolatedConnection?(n=this.createIsolatedClient({...this.options,name:`${this.options.name}-channel-${e}`}),this.isolatedClients.push(n),await n.connect()):n=this;let r=new Bo(n,e);return await r.init(),t?.isolatedConnection&&(r._isolatedClient=n),r}async privateChannel(e,t,n){let r;n?.isolatedConnection?(r=this.createIsolatedClient({...this.options,name:`${this.options.name}-private-${e}`}),this.isolatedClients.push(r),await r.connect()):r=this;let i=new Vo(r,e,t);return await i.init(),n?.isolatedConnection&&(i._isolatedClient=r),i}createProxy(e,t){let n;t?.isolatedConnection?(n=this.createIsolatedClient({...this.options,name:`${this.options.name}-proxy-${e}`}),this.isolatedClients.push(n)):n=this;let r=qc(n,e,[],null,t?.onTiming);return t?.isolatedConnection?(r._isolatedClient=n,{proxy:r,close:async()=>{await n.disconnect();let e=this.isolatedClients.indexOf(n);e>=0&&this.isolatedClients.splice(e,1)}}):r}async createServiceProxy(e,t){let n;t?.isolatedConnection?(n=this.createIsolatedClient({...this.options,name:`${this.options.name}-service-${e}`}),this.isolatedClients.push(n),await n.connect()):n=this;let r=n.service.monitor(),i=[];for await(let t of await r.info(e))i.push(t);if(i.length===0){if(t?.isolatedConnection){await n.disconnect();let e=this.isolatedClients.indexOf(n);e>=0&&this.isolatedClients.splice(e,1)}throw Error(`No services found with name: ${e}`)}let a=t?.preferredId?i.find(e=>e.id===t.preferredId)??i[0]:i[0],o=Jc(n,a,t?.timeout);return t?.isolatedConnection?(o._isolatedClient=n,{proxy:o,close:async()=>{await n.disconnect();let e=this.isolatedClients.indexOf(n);e>=0&&this.isolatedClients.splice(e,1)}}):o}};function vl(e,t){return t?t.aborted?(e.then(e=>yl(e)).catch(()=>{}),Promise.reject(new DOMException(`Aborted`,`AbortError`))):new Promise((n,r)=>{let i=!1,a=()=>{i||(i=!0,e.then(e=>yl(e)).catch(()=>{}),r(new DOMException(`Aborted`,`AbortError`)))};t.addEventListener(`abort`,a,{once:!0}),e.then(e=>{if(i){yl(e);return}i=!0,t.removeEventListener(`abort`,a),n(e)},e=>{i||(i=!0,t.removeEventListener(`abort`,a),r(e))})}):e}function yl(e){let t=e;try{typeof t.abortClose==`function`?t.abortClose():e.close().catch(()=>{})}catch{}}var bl={id:`nats`,kind:`persistent`,phaseGating:!0},xl=3e3;function Sl(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();if(e?.getRandomValues){let t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}return`${Date.now()}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`}function Cl(e={}){let t={...bl,...e.spec},n=e.proxyPath??`/api/proxy`,r=e.clientName??`@camera.ui/transport/nats`,i=e.natsUser??`secret`,a=e.natsPassword??`secret`,o=e.reconnectTimeWait??1e3,s=e.reconnectionDelayMax??5e3,c=e.reconnectionRandomizationFactor??.5,l=e.timeout??1e4,u=e.connectTimeout??5e3,d=e.pingInterval??25e3,f=e.pingTimeout??2e4,p=e.maxPingOut??1,m=e.logger,h=e.resolveServers,g=e.resolveRefreshMs??0,_=new an,v=new Set,y=null,b=null,x=null,S={up:!1},C=null,w=!1,T=null,E=0,D=null,O=0,k=!1;function A(e){let t=new URL(e.endpoint.url),r=t.protocol===`https:`?`wss:`:`ws:`,i=t.port||(t.protocol===`https:`?`443`:`80`),a=t.pathname.replace(/\/$/,``),o=new URLSearchParams({token:e.tokens.access});return e.tokens.proxySession&&o.set(`session`,e.tokens.proxySession),T&&o.set(`connId`,T),[`${r}//${t.hostname}:${i}${a}${n}?${o.toString()}`]}async function j(e){let t=A(e);return h?h({target:e,connId:T??``,defaultServers:t}):t}async function M(e){let t=x;if(!(!h||!t||w)&&!(k||Date.now()-O<xl)){k=!0;try{let n=await j(t);b===e&&!w&&e.setServers(n)}catch(e){m?.warn(`server refresh failed: ${wl(e)}`)}finally{k=!1,O=Date.now()}}}function N(){y&&=(clearInterval(y),null)}function P(e){N(),!(!h||g<=0)&&(y=setInterval(()=>M(e),g))}async function F(e){let t=x;if(!b||!t||w)return;m?.debug(`resign (${e})`);let n=++E;te(),N();try{b.abortClose()}catch{}b=null,I(),ee(`signature-expired: ${e}`);try{await B(t,n)}catch{}}function I(){let e=S.up?b:null;for(let t of[...v])try{t(e)}catch{}}function L(){S.up||(S={up:!0},m?.debug(`markUp`),_.emit(`up`,void 0))}function ee(e){!S.up&&S.lastError===e||(S={up:!1,lastError:e},m?.debug(`markDown (${e})`),_.emit(`down`,{reason:e}))}function te(){C?.abort(),C=null}function R(e){te();let t=new AbortController;C=t,(async()=>{let n=e.status();if(n)for await(let r of n){if(t.signal.aborted)break;switch(m?.debug(`status: ${r.type}${`server`in r&&r.server?` server=${String(r.server)}`:``}`),r.type){case`reconnect`:L(),I();break;case`disconnect`:ee(`disconnect`),I(),h&&M(e);break;case`reconnecting`:h&&M(e);break;case`staleConnection`:ee(`staleConnection`),I();break;case`error`:z(r)}}})().catch(()=>{})}function z(e){let t=wl(e.data);if(t.toLowerCase().includes(`permissions violation`)){m?.warn(`permission violation (connection stays up): ${t}`);return}let n=on(typeof e.data==`object`&&e.data!==null?{...e.data,message:t}:t);if(n===`auth-expired`){if(h){F(t);return}_.emit(`auth-error`,{message:t});return}if(n===`forbidden`){m?.warn(`forbidden by server: ${t}`),ee(`forbidden: ${t}`);return}ee(t)}async function B(e,t){m?.debug(`rebuildClient start (epoch=${t})`);let n=Date.now();if(te(),N(),D?.abort(),b){try{b.abortClose()}catch{}b=null,I()}T=Sl();let g;try{g=await j(e)}catch(e){if(w||t!==E)return;let n=wl(e);throw m?.debug(`rebuildClient resolve FAILED: ${n}`),ee(n),e}if(w||t!==E)return;let v=hl({servers:g,name:r,connId:T,auth:{user:i,password:a},reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:o,reconnectionDelayMax:s,reconnectionRandomizationFactor:c,timeout:l,connectTimeout:u,pingInterval:d,pingTimeout:f,maxPingOut:p,ignoreAuthErrorAbort:!0}),y=new AbortController;D=y;try{await v.connect({signal:y.signal})}catch(e){try{v.abortClose()}catch{}if(w||t!==E)return;let r=e instanceof Error?e.message:String(e);throw m?.debug(`rebuildClient connect FAILED after ${Date.now()-n}ms: ${r}`),!h&&on(e instanceof Error?e:r)===`auth-expired`&&_.emit(`auth-error`,{message:r}),ee(r),e}finally{D===y&&(D=null)}if(w||t!==E){try{v.abortClose()}catch{}return}b=v,m?.debug(`rebuildClient connected in ${Date.now()-n}ms`),L(),I(),R(v),P(v)}async function ne(e){if(w)throw Error(`nats-transport disposed`);if(nn(x,e))return;let t=++E,n=rn(x,e);if(x=e,!e){if(te(),N(),D?.abort(),D=null,b){try{b.abortClose()}catch{}b=null,I()}ee(`detached`);return}if(n||!b){try{await B(e,t)}catch(n){throw t===E&&x===e&&(x=null),n}return}let r=b,i=await j(e);b===r&&t===E&&r.setServers(i)}function re(){return S.up&&b?.isStale?{up:!1,lastError:`staleConnection`}:S}function ie(e,t){return _.on(e,t)}async function ae(){if(w=!0,E++,te(),N(),D?.abort(),D=null,b){try{b.abortClose()}catch{}b=null,I()}v.clear(),S={up:!1},_.clear()}function oe(){return S.up?b:null}function se(e){return v.add(e),e(S.up?b:null),()=>v.delete(e)}async function ce(e=5e3){if(!b)throw Error(`nats-transport: no client`);let t=Date.now();try{await b.flush(e),m?.debug(`probeAlive OK in ${Date.now()-t}ms`)}catch(e){throw m?.debug(`probeAlive FAILED after ${Date.now()-t}ms: ${e instanceof Error?e.message:String(e)}`),e}}async function le(){if(!b){m?.debug(`forceReconnect: no client`);return}m?.debug(`forceReconnect: issuing (up=${S.up} stale=${b.isStale})`);let e=Date.now();await b.forceReconnect(),m?.debug(`forceReconnect: returned after ${Date.now()-e}ms (up=${S.up})`)}let ue=null;function de(){return ue||(ue=(async()=>{if(w||!x)return re();if(!b){let e=++E;try{await B(x,e)}catch{}return re()}if(re().up)try{return await ce(3e3),re()}catch{}try{await le()}catch{}return re()})().finally(()=>{ue=null}),ue)}return{spec:t,apply:ne,health:re,on:ie,dispose:ae,getClient:oe,subscribeClient:se,probeAlive:ce,forceReconnect:le,ensureAlive:de}}function wl(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var Tl=3e3,El={id:`socketio`,kind:`persistent`,phaseGating:!0};function Dl(e={}){let t={...El,...e.spec},n=e.path??`/api/socket.io`,r=e.mainNamespace??`/camera.ui`,i=e.reconnection??!0,a=e.reconnectionDelay??1e3,o=e.reconnectionDelayMax??5e3,s=e.timeout??2e4,c=e.logger,l=e.resolveQuery,u=e.resolveRefreshMs??0,f=new an,p=new Map,m=null,h=null,g={},_=null,v=0,y=!1,b={up:!1},x=!1,S=e.staleAfterMs??6e4,C=0;function w(){C=Date.now()}function T(){return C>0&&Date.now()-C>S}function E(e){let t={token:`Bearer ${e.tokens.access}`};return e.tokens.proxySession&&(t.session=e.tokens.proxySession),t}function D(e){let t={};return e.tokens.proxySession&&(t.session=e.tokens.proxySession),t}async function O(e){let t=D(e);return l?l({target:e,path:ee(e),query:t}):t}async function k(){let e=h;if(!(!l||!e||x)&&!(y||Date.now()-v<Tl)){y=!0;try{let t=await O(e);if(h!==e||x)return;g=t;for(let e of p.values())e.io.opts.query=t}catch(e){c?.warn(`query refresh failed: ${e instanceof Error?e.message:String(e)}`)}finally{y=!1,v=Date.now()}}}function A(){_&&=(clearInterval(_),null)}function j(){A(),!(!l||u<=0)&&(_=setInterval(()=>k(),u))}function M(){b.up||(b={up:!0},c?.debug(`markUp`),f.emit(`up`,void 0))}function N(e){!b.up&&b.lastError===e||(b={up:!1,lastError:e},c?.debug(`markDown (${e})`),f.emit(`down`,{reason:e}))}function P(e){return on(e)===`auth-expired`}function F(e){e.on(`connect`,()=>M()),e.on(`disconnect`,e=>{N(e),l&&k()}),e.on(`connect_error`,e=>{let t=e?.message??`connect_error`;if(c?.debug(`connect_error (main): ${t}`),l&&k(),P(t)){f.emit(`auth-error`,{message:t});return}N(t)})}function I(e){e.on(`connect_error`,e=>{let t=e?.message??`connect_error`;P(t)&&f.emit(`auth-error`,{message:t})})}function L(e){return new URL(e.endpoint.url).origin}function ee(e){return`${new URL(e.endpoint.url).pathname.replace(/\/$/,``)}${n}`}function te(e,t){let n=`${L(t)}${e}`,r=lt(n,{path:ee(t),auth:E(t),query:g,reconnection:i,reconnectionDelay:a,reconnectionDelayMax:o,timeout:s,rejectUnauthorized:!1,transports:[`websocket`]});return p.set(e,r),r}async function R(e){A();let t;try{t=await O(e)}catch(e){throw N(e instanceof Error?e.message:String(e)),e}if(h!==e||x)return;z(),g=t,m=new d(L(e),{path:ee(e),autoConnect:!1,reconnection:i,reconnectionDelay:a,reconnectionDelayMax:o,timeout:s,rejectUnauthorized:!1,transports:[`websocket`]});let n=te(r,e);F(n),j(),C=Date.now(),n.io.on(`open`,w),n.io.on(`ping`,w),n.io.on(`packet`,w)}function z(){for(let e of p.values())e.removeAllListeners(),e.disconnect();p.clear(),m&&=(m._close(),null)}function B(e){let t=E(e);for(let e of p.values())e.auth=t,e.connected||e.connect()}async function ne(e){if(x)throw Error(`socketio-transport disposed`);if(nn(h,e))return;let t=rn(h,e);if(h=e,!e){z(),A(),C=0,N(`detached`);return}if(t||!m){await R(e);return}B(e)}function re(){return b.up&&T()?{up:!1,lastError:`staleConnection`}:b}function ie(e,t){return f.on(e,t)}async function ae(){x=!0,z(),A(),h=null,b={up:!1},f.clear()}function oe(e=r){return p.get(e)??null}function se(e){if(!h||!m)return null;let t=p.get(e);return t||(t=te(e,h),I(t)),t}function ce(){if(!h)return;if(b.up&&T()){c?.debug(`reviveDeadSockets: engine stale — forcing reconnect`),C=Date.now(),p.get(r)?.io.engine?.close();return}let e=E(h),t=0;for(let n of p.values())n.connected||(n.auth=e,n.connect(),t++);c?.debug(`reviveDeadSockets: ${t}/${p.size} reconnecting`)}async function le(){return x||!h?re():(l&&await k(),ce(),re())}return{get spec(){return t},get manager(){return m},apply:ne,health:re,on:ie,dispose:ae,socket:oe,ensureSocket:se,reviveDeadSockets:ce,ensureAlive:le}}var Ol={id:`ws`,kind:`per-resource`,phaseGating:!1},kl=4e3,Al=4001,jl=4002,Ml=4003;function Nl(e={}){let t={...Ol,...e.spec},n=e.tokenParam??`token`,r=e.sessionParam??`session`,i=e.webSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0),a=e.resolveUrl,o=e.logger,s=new an,c=new Set,l=new WeakSet,u=null,d={up:!1},f=!1;function p(){if(!i)throw Error(`ws-transport: no WebSocket constructor available; pass webSocketCtor in non-browser environments`);return i}function m(e,t){let i=new URL(e.endpoint.url),a=i.protocol===`https:`?`wss:`:`ws:`,o=i.port||(i.protocol===`https:`?`443`:`80`),s=i.pathname.replace(/\/$/,``),c=new URLSearchParams;for(let[e,n]of Object.entries(t.query??{}))n!=null&&n!==``&&c.set(e,n);return c.set(n,e.tokens.access),e.tokens.proxySession&&c.set(r,e.tokens.proxySession),`${a}//${i.hostname}:${o}${s}${t.path}?${c.toString()}`}function h(e){return on({code:e.code,reason:e.reason})===`auth-expired`}function g(e,t){t.onopen=()=>{if(!(e.disposed||e.ws!==t)){o?.debug(`open ${e.spec.path}`),d.up||(d={up:!0},s.emit(`up`,void 0));for(let t of[...e.listeners.open])t()}},t.onclose=n=>{let r=e.ws===t;if(r&&(e.ws=null,e.url=null),l.has(t)||(l.add(t),!r))return;o?.debug(`close ${e.spec.path} code=${n.code} clean=${n.wasClean}${n.reason?` reason=${n.reason}`:``}`),h(n)&&s.emit(`auth-error`,{message:n.reason||`ws close code ${n.code}`});let i={code:n.code,reason:n.reason,wasClean:n.wasClean};for(let t of[...e.listeners.close])t(i)},t.onmessage=n=>{if(!(e.disposed||e.ws!==t))for(let t of[...e.listeners.message])t(n)},t.onerror=n=>{if(!(e.disposed||e.ws!==t))for(let t of[...e.listeners.error])t(n)}}function _(e,t,n){e.openSeq++;let r=e.ws;if(!r)return;let i=p();if(r.readyState===i.OPEN||r.readyState===i.CONNECTING){try{r.close(t,n)}catch{}return}if(e.ws===r&&(e.ws=null,e.url=null),l.has(r))return;l.add(r);let a={code:t,reason:n,wasClean:!1};for(let t of[...e.listeners.close])t(a)}function v(e,t){let n=new(p())(t,e.spec.protocols);e.spec.binaryType&&(n.binaryType=e.spec.binaryType),e.ws=n,e.url=t,g(e,n)}function y(e){if(e.disposed||!u)return;let t=u,n=m(t,e.spec);if(!a){v(e,n);return}let r=++e.openSeq;a({target:t,spec:e.spec,defaultUrl:n}).then(n=>{e.disposed||r!==e.openSeq||u!==t||v(e,n)},t=>{if(e.disposed||r!==e.openSeq)return;let n=t instanceof Error?t.message:String(t);o?.warn(`resolveUrl failed for ${e.spec.path}: ${n}`);let i={code:Ml,reason:`resolve-failed`,wasClean:!1};for(let t of[...e.listeners.close])t(i)})}function b(e,t){let n=[...c];o?.debug(`recycleAll (${t}) handles=${n.length}`);for(let r of n)_(r,e,t);if(d.up&&(d={up:!1,lastError:t},s.emit(`down`,{reason:t})),u)for(let e of c)e.disposed||y(e)}async function x(e){if(f)throw Error(`ws-transport disposed`);if(nn(u,e))return;let t=rn(u,e);if(u=e,!e){let e=[...c];for(let t of e)_(t,Al,`detached`);d={up:!1},s.emit(`down`,{reason:`detached`});return}t&&b(kl,`endpoint-changed`)}function S(){return d}function C(e,t){return s.on(e,t)}async function w(){f=!0;let e=[...c];for(let t of e)t.disposed=!0,t.listeners.open.clear(),t.listeners.close.clear(),t.listeners.message.clear(),t.listeners.error.clear(),_(t,jl,`disposed`);c.clear(),u=null,d={up:!1},s.clear()}function T(e){if(f)throw Error(`ws-transport disposed`);let t={api:void 0,spec:e,listeners:{open:new Set,close:new Set,message:new Set,error:new Set},ws:null,url:null,disposed:!1,openSeq:0};function n(e){if(t.disposed)throw Error(`ws-handle disposed`);let n=t.ws;if(!n)throw Error(`ws-handle: no active socket`);if(n.readyState!==i.OPEN)throw Error(`ws-handle: socket not open`);n.send(e)}function r(e,n){_(t,e??1e3,n??``)}function a(e,n){let r=t.listeners[e];return r.add(n),()=>{r.delete(n)}}function o(){t.disposed||(t.disposed=!0,t.listeners.open.clear(),t.listeners.close.clear(),t.listeners.message.clear(),t.listeners.error.clear(),_(t,jl,`disposed`),c.delete(t))}return t.api={get readyState(){return t.ws?.readyState??i?.CLOSED??3},get url(){return t.url},send:n,close:r,on:a,dispose:o},c.add(t),u&&y(t),t.api}return{get spec(){return t},get handleCount(){return c.size},apply:x,health:S,on:C,dispose:w,open:T}}function Pl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Fl(e){let t=e.url??``,n=e.baseURL??``;return n&&!Pl(t)?`${n.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`:t}function Il(e){let t;try{t=new URL(e).hostname}catch{return!1}return!t||t===`localhost`||t.endsWith(`.local`)||t.includes(`:`)||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t)?!1:t.includes(`.`)}function Ll(e){return!e.withCredentials&&Il(Fl(e))}function Rl(e){return async t=>{Bl(t.signal);let n=Hl(t.headers);e.extraHeaders&&Object.assign(n,e.extraHeaders);let r=typeof t.timeout==`number`&&t.timeout>0?t.timeout:void 0,i=e.request({url:Fl(t),method:(t.method??`get`).toUpperCase(),headers:n,params:Ul(t.params),data:Wl(t),responseType:Gl(t.responseType),connectTimeout:r,readTimeout:r}),a;try{a=await Vl(i,t.signal)}catch(e){throw e instanceof re?e:new b(e instanceof Error?e.message:`Network Error`,b.ERR_NETWORK,t,i)}let o={data:a.data,status:a.status,statusText:``,headers:R.from(a.headers??{}),config:t,request:i};if(!t.validateStatus||t.validateStatus(a.status))return o;throw new b(`Request failed with status code ${a.status}`,a.status>=500?b.ERR_BAD_RESPONSE:b.ERR_BAD_REQUEST,t,i,o)}}function zl(e,t){if(!t.enabled)return;let n=y.getAdapter(e.defaults.adapter??y.defaults.adapter),r=Rl(t);e.defaults.adapter=e=>Ll(e)?r(e):n(e)}function Bl(e){if(e?.aborted)throw new re(`canceled`)}function Vl(e,t){return!t||typeof t.addEventListener!=`function`?e:t.aborted?Promise.reject(new re(`canceled`)):new Promise((n,r)=>{let i=()=>r(new re(`canceled`));t.addEventListener(`abort`,i,{once:!0});let a=()=>t.removeEventListener?.(`abort`,i);e.then(e=>{a(),n(e)},e=>{a(),r(e)})})}function Hl(e){let t={};if(!e)return t;let n=R.from(e).toJSON();for(let[e,r]of Object.entries(n))r!=null&&(t[e]=Array.isArray(r)?r.join(`, `):String(r));return t}function Ul(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=String(r));return t}function Wl(e){let t=e.data;if(t!=null){if(typeof t!=`string`)return t;if(String(R.from(e.headers).get(`Content-Type`)??``).includes(`application/json`))try{return JSON.parse(t)}catch{}return t}}function Gl(e){switch(e){case`blob`:return`blob`;case`arraybuffer`:return`arraybuffer`;default:return`text`}}function Kl(e={}){function t(e){return typeof e==`function`}let n=t(e)?{mounted:e,updated:e}:e,{mounted:r,unmounted:i}=n;if(!t(r))return e;let a=new WeakMap;return{...n,mounted(e,t,n,i){let o=a.get(e)??F();a.set(e,o),o.run(()=>{r?.(e,t,n,i)})},unmounted(e,n,r,o){var s;(s=a.get(e))==null||s.stop(),a.delete(e),t(i)&&i(e,n,r,o)}}}function ql(e,t){return s()?(Ae(e,t),!0):!1}var Jl=new WeakMap,Yl=(...e)=>{let t=e[0],n=Oe()?.proxy??s();if(n==null&&!et())throw Error(`injectLocal must be called in setup`);return n&&Jl.has(n)&&t in Jl.get(n)?Jl.get(n)[t]:ot(...e)},Xl=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var Zl=e=>e!=null,Ql=Object.prototype.toString,$l=e=>Ql.call(e)===`[object Object]`,eu=()=>{},tu=nu();function nu(){var e,t;return Xl&&!!((e=window)!=null&&(e=e.navigator)!=null&&e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window)==null||(t=t.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function ru(...e){if(e.length!==1)return we(...e);let t=e[0];return typeof t==`function`?Ue(ue(()=>({get:t,set:eu}))):q(t)}function iu(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return`cancel`in e&&Object.assign(n,{cancel:e.cancel,flush:e.flush,isPending:e.isPending}),n}var au=e=>e();function ou(e,t={}){let n,r,i=eu,a=eu,o=J(!1),s=e=>{clearTimeout(e),i(),i=eu},c;return Object.assign(l=>{let u=U(e),d=U(t.maxWait);return n&&s(n),u<=0||d!==void 0&&d<=0?(r&&=(s(r),void 0),o.value=!1,Promise.resolve(l())):(o.value=!0,new Promise((e,f)=>{i=t.rejectOnCancel?f:e,a=e,c=l,d&&!r&&(r=setTimeout(()=>{n&&s(n),r=void 0,o.value=!1,e(c())},d)),n=setTimeout(()=>{r&&s(r),r=void 0,o.value=!1,e(l())},u)}))},{cancel:()=>{n&&=(s(n),void 0),r&&=(s(r),void 0),o.value=!1,a=eu},flush:()=>{if(o.value){n&&=(clearTimeout(n),void 0),r&&=(clearTimeout(r),void 0),o.value=!1;let e=a;i=eu,a=eu,e(c())}},isPending:Ie(o)})}function su(...e){let t=0,n,r=!0,i=eu,a,o,s,c,l;!Ve(e[0])&&typeof e[0]==`object`?{delay:o,trailing:s=!0,leading:c=!0,rejectOnCancel:l=!1}=e[0]:[o,s=!0,c=!0,l=!1]=e;let u=()=>{n&&(clearTimeout(n),n=void 0,i(),i=eu)};return e=>{let d=U(o),f=Date.now()-t,p=()=>a=e();return u(),d<=0?(t=Date.now(),p()):(f>d?(t=Date.now(),(c||!r)&&p()):s&&(a=new Promise((e,a)=>{i=l?a:e,n=setTimeout(()=>{t=Date.now(),r=!0,e(p()),u()},Math.max(0,d-f))})),!c&&!n&&(n=setTimeout(()=>r=!0,d)),r=!1,a)}}function cu(e=au,t={}){let{initialState:n=`active`}=t,r=ru(n===`active`);function i(){r.value=!1}function a(){r.value=!0}return{isActive:Ie(r),pause:i,resume:a,eventFilter:(...t)=>{r.value&&e(...t)}}}function lu(e){let t;function n(){return t||=e(),t}return n.reset=async()=>{let e=t;t=void 0,e&&await e},n}function uu(e){return e.endsWith(`rem`)?Number.parseFloat(e)*16:Number.parseFloat(e)}function du(e){return Array.isArray(e)?e:[e]}function fu(e){let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))}var pu=/-(\w)/g,mu=fu(e=>e.replace(pu,(e,t)=>t?t.toUpperCase():``));function hu(e){return e||Oe()}function gu(e){if(!Xl)return e;let t=0,n,r,i=()=>{--t,r&&t<=0&&(r.stop(),n=void 0,r=void 0)};return((...a)=>(t+=1,r||(r=F(!0),n=r.run(()=>e(...a))),ql(i),n))}function _u(e,t,{enumerable:n=!1,unwrap:r=!0}={}){for(let[i,a]of Object.entries(t))i!==`value`&&(Ve(a)&&r?Object.defineProperty(e,i,{get(){return a.value},set(e){a.value=e},enumerable:n}):Object.defineProperty(e,i,{value:a,enumerable:n}));return e}function vu(e,t){if(typeof Symbol<`u`){let n={...e};return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let e=0;return{next:()=>({value:t[e++],done:e>t.length})}}}),n}return Object.assign([...t],e)}function yu(e){return Ve(e)?he(new Proxy({},{get(t,n,r){return V(Reflect.get(e.value,n,r))},set(t,n,r){return Ve(e.value[n])&&!Ve(r)?e.value[n].value=r:e.value[n]=r,!0},deleteProperty(t,n){return Reflect.deleteProperty(e.value,n)},has(t,n){return Reflect.has(e.value,n)},ownKeys(){return Object.keys(e.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}})):he(e)}function bu(e){return yu(G(e))}function xu(e,...t){let n=t.flat(),r=n[0];return bu(()=>Object.fromEntries(typeof r==`function`?Object.entries(Ge(e)).filter(([e,t])=>!r(U(t),e)):Object.entries(Ge(e)).filter(e=>!n.includes(e[0]))))}function Su(e,t=200,n={}){return iu(ou(t,n),e)}function Cu(e,t=200,n=!1,r=!0,i=!1){return iu(su(t,n,r,i),e)}function wu(e,t={}){let n=e,r,i,a=ue((e,t)=>(r=e,i=t,{get(){return o()},set(e){s(e)}}));function o(e=!0){return e&&r(),n}function s(e,r=!0){var a;if(e===n)return;let o=n;t.onBeforeChange?.call(t,e,o)!==!1&&(n=e,(a=t.onChanged)==null||a.call(t,e,o),r&&i())}return _u(a,{get:o,set:s,untrackedGet:()=>o(!1),silentSet:e=>s(e,!1),peek:()=>o(!1),lay:e=>s(e,!1)},{enumerable:!0})}function Tu(e,t,n={}){let{eventFilter:r=au,...i}=n;return C(e,iu(r,t),i)}function Eu(e,t,n={}){let{eventFilter:r,initialState:i=`active`,...a}=n,{eventFilter:o,pause:s,resume:c,isActive:l}=cu(r,{initialState:i});return{stop:Tu(e,t,{...a,eventFilter:o}),pause:s,resume:c,isActive:l}}function Du(e,t={}){if(!Ve(e))return Ge(e);let n=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(let r in e.value)n[r]=ue(()=>({get(){return e.value[r]},set(n){if(U(t.replaceRef)??!0){if(Array.isArray(e.value)){let t=[...e.value];t[r]=n,e.value=t}else{let t={...e.value,[r]:n};Object.setPrototypeOf(t,Object.getPrototypeOf(e.value)),e.value=t}}else e.value[r]=n}}));return n}function Ou(e,t=!0,n){hu(n)?l(e,n):t?e():rt(e)}function ku(e,t){hu(t)&&Me(e,t)}var Au=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i,ju=/[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;function Mu(e,t,n,r){let i=e<12?`AM`:`PM`;return r&&(i=i.split(``).reduce((e,t)=>e+=`${t}.`,``)),n?i.toLowerCase():i}function Nu(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function Pu(e,t,n={}){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=e.getHours(),s=e.getMinutes(),c=e.getSeconds(),l=e.getMilliseconds(),u=e.getDay(),d=n.customMeridiem??Mu,f=e=>e.split(` `)[1]??``,p={Yo:()=>Nu(r),YY:()=>String(r).slice(-2),YYYY:()=>r,M:()=>i+1,Mo:()=>Nu(i+1),MM:()=>`${i+1}`.padStart(2,`0`),MMM:()=>e.toLocaleDateString(U(n.locales),{month:`short`}),MMMM:()=>e.toLocaleDateString(U(n.locales),{month:`long`}),D:()=>String(a),Do:()=>Nu(a),DD:()=>`${a}`.padStart(2,`0`),H:()=>String(o),Ho:()=>Nu(o),HH:()=>`${o}`.padStart(2,`0`),h:()=>`${o%12||12}`.padStart(1,`0`),ho:()=>Nu(o%12||12),hh:()=>`${o%12||12}`.padStart(2,`0`),m:()=>String(s),mo:()=>Nu(s),mm:()=>`${s}`.padStart(2,`0`),s:()=>String(c),so:()=>Nu(c),ss:()=>`${c}`.padStart(2,`0`),SSS:()=>`${l}`.padStart(3,`0`),d:()=>u,dd:()=>e.toLocaleDateString(U(n.locales),{weekday:`narrow`}),ddd:()=>e.toLocaleDateString(U(n.locales),{weekday:`short`}),dddd:()=>e.toLocaleDateString(U(n.locales),{weekday:`long`}),A:()=>d(o,s),AA:()=>d(o,s,!1,!0),a:()=>d(o,s,!0),aa:()=>d(o,s,!0,!0),z:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`shortOffset`})),zz:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`shortOffset`})),zzz:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`shortOffset`})),zzzz:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`longOffset`}))};return t.replace(ju,(e,t)=>t??p[e]?.call(p)??e)}function Fu(e){if(e===null)return new Date(NaN);if(e===void 0)return new Date;if(e instanceof Date)return new Date(e);if(typeof e==`string`&&!/Z$/i.test(e)){let t=e.match(Au);if(t){let e=t[2]-1||0,n=(t[7]||`0`).substring(0,3);return new Date(t[1],e,t[3]||1,t[4]||0,t[5]||0,t[6]||0,n)}}return new Date(e)}function Iu(e,t=`HH:mm:ss`,n={}){return G(()=>Pu(Fu(U(e)),U(t),n))}function Lu(e,t=1e3,n={}){let{immediate:r=!0,immediateCallback:i=!1}=n,a=null,o=J(!1);function s(){a&&=(clearInterval(a),null)}function c(){o.value=!1,s()}function l(){let n=U(t);n<=0||(o.value=!0,i&&e(),s(),o.value&&(a=setInterval(e,n)))}return r&&Xl&&l(),(Ve(t)||typeof t==`function`)&&ql(C(t,()=>{o.value&&Xl&&l()})),ql(c),{isActive:Ie(o),pause:c,resume:l}}function Ru(e,t,n={}){let{immediate:r=!0,immediateCallback:i=!1}=n,a=J(!1),o;function s(){o&&=(clearTimeout(o),void 0)}function c(){a.value=!1,s()}function l(...n){i&&e(),s(),a.value=!0,o=setTimeout(()=>{a.value=!1,o=void 0,e(...n)},U(t))}return r&&(a.value=!0,Xl&&l()),ql(c),{isPending:Ie(a),start:l,stop:c}}function zu(e,t,n={}){let{debounce:r=0,maxWait:i=void 0,...a}=n;return Tu(e,t,{...a,eventFilter:ou(r,{maxWait:i})})}function Bu(e,t,n){return C(e,t,{...n,immediate:!0})}function Vu(e,t,n){return C(e,t,{...n,once:!0})}function Hu(e,t,n={}){let{throttle:r=0,trailing:i=!0,leading:a=!0,...o}=n;return Tu(e,t,{...o,eventFilter:su(r,i,a)})}function Uu(e,t,n){let r=C(e,(e,i,a)=>{e&&(n?.once&&rt(()=>r()),t(e,i,a))},{...n,once:!1});return r}function Wu(e,t,n){let r;r=Ve(n)?{evaluating:n}:n||{};let{lazy:i=!1,flush:a=`sync`,evaluating:o=void 0,shallow:s=!0,onError:c=globalThis.reportError??eu}=r,l=J(!i),u=s?J(t):q(t),d=0;return qe(async t=>{if(!l.value)return;d++;let n=d,r=!1;o&&Promise.resolve().then(()=>{o.value=!0});try{let i=await e(e=>{t(()=>{o&&(o.value=!1),r||e()})});n===d&&(u.value=i)}catch(e){c(e)}finally{o&&n===d&&(o.value=!1),r=!0}},{flush:a}),i?G(()=>(l.value=!0,u.value)):u}function Gu(e={}){let{inheritAttrs:t=!0,name:n=`ReusableTemplate`}=e,r=J(),i=Re({name:`${n}.define`,setup(e,{slots:t}){return()=>{r.value=t.default}}}),a=Re({inheritAttrs:t,name:`${n}.reuse`,props:e.props,setup(n,{attrs:i,slots:a}){return()=>{if(!r.value)throw Error(`[VueUse] Failed to find the definition of reusable template`);let o=r.value?.call(r,{...e.props==null?Ku(i):n,$slots:a});return t&&o?.length===1?o[0]:o}}});return vu({define:i,reuse:a},[i,a])}function Ku(e){let t={};for(let n in e)t[mu(n)]=e[n];return t}var qu=Xl?window:void 0;Xl&&window.document;var Ju=Xl?window.navigator:void 0;Xl&&window.location;function Yu(e){let t=U(e);return t?.$el??t}function Xu(...e){let t=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),n=G(()=>{let t=du(U(e[0])).filter(e=>e!=null);return t.every(e=>typeof e!=`string`)?t:void 0});return Bu(()=>[n.value?.map(e=>Yu(e))??[qu].filter(e=>e!=null),du(U(n.value?e[1]:e[0])),du(V(n.value?e[2]:e[1])),U(n.value?e[3]:e[2])],([e,n,r,i],a,o)=>{if(!e?.length||!n?.length||!r?.length)return;let s=$l(i)?{...i}:i,c=e.flatMap(e=>n.flatMap(n=>r.map(r=>t(e,n,r,s))));o(()=>{c.forEach(e=>e())})},{flush:`post`})}var Zu=!1;function Qu(e,t,n={}){let{window:r=qu,ignore:i=[],capture:a=!0,detectIframe:o=!1,controls:s=!1}=n;if(!r)return s?{stop:eu,cancel:eu,trigger:eu}:eu;if(tu&&!Zu){Zu=!0;let e={passive:!0};Array.from(r.document.body.children).forEach(t=>t.addEventListener(`click`,eu,e)),r.document.documentElement.addEventListener(`click`,eu,e)}let c=!0,l=e=>U(i).some(t=>{if(typeof t==`string`)return Array.from(r.document.querySelectorAll(t)).some(t=>t===e.target||e.composedPath().includes(t));{let n=Yu(t);return n&&(e.target===n||e.composedPath().includes(n))}});function u(e){let t=U(e);return t&&t.$.subTree.shapeFlag===16}function d(e,t){let n=U(e),r=n.$.subTree&&n.$.subTree.children;return r==null||!Array.isArray(r)?!1:r.some(e=>e.el===t.target||t.composedPath().includes(e.el))}let f=n=>{let r=Yu(e);if(n.target!=null&&!(!(r instanceof Element)&&u(e)&&d(e,n))&&!(!r||r===n.target||n.composedPath().includes(r))){if(`detail`in n&&n.detail===0&&(c=!l(n)),!c){c=!0;return}t(n)}},p=!1,m=[Xu(r,`click`,e=>{p||(p=!0,setTimeout(()=>{p=!1},0),f(e))},{passive:!0,capture:a}),Xu(r,`pointerdown`,t=>{let n=Yu(e);c=!l(t)&&!!(n&&!t.composedPath().includes(n))},{passive:!0}),o&&Xu(r,`blur`,n=>{setTimeout(()=>{let i=Yu(e),a=r.document.activeElement;for(;a?.shadowRoot;)a=a.shadowRoot.activeElement;a?.tagName===`IFRAME`&&!i?.contains(r.document.activeElement)&&t(n)},0)},{passive:!0})].filter(Boolean),h=()=>m.forEach(e=>e());return s?{stop:h,cancel:()=>{c=!1},trigger:e=>{c=!0,f(e),c=!1}}:h}function $u(){let e=J(!1),t=Oe();return t&&l(()=>{e.value=!0},t),e}function ed(e){let t=$u();return G(()=>(t.value,!!e()))}function td(e,t,n={}){let{window:r=qu,...i}=n,a,o=ed(()=>r&&`MutationObserver`in r),s=()=>{a&&=(a.disconnect(),void 0)},c=C(G(()=>{let t=du(U(e)).map(Yu).filter(Zl);return new Set(t)}),e=>{s(),o.value&&e.size&&(a=new MutationObserver(t),e.forEach(e=>a.observe(e,i)))},{immediate:!0,flush:`post`}),l=()=>a?.takeRecords(),u=()=>{c(),s()};return ql(u),{isSupported:o,stop:u,takeRecords:l}}function nd(e,t,n={}){let{window:r=qu,document:i=r?.document,flush:a=`sync`}=n;if(!r||!i)return eu;let o,s=e=>{o?.(),o=e},c=qe(()=>{let n=Yu(e);if(n){let{stop:e}=td(i,e=>{e.map(e=>[...e.removedNodes]).flat().some(e=>e===n||e.contains(n))&&t(e)},{window:r,childList:!0,subtree:!0});s(e)}},{flush:a}),l=()=>{c(),s()};return ql(l),l}function rd(e){return typeof e==`function`?e:typeof e==`string`?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function id(...e){let t,n,r={};e.length===3?(t=e[0],n=e[1],r=e[2]):e.length===2?typeof e[1]==`object`?(t=!0,n=e[0],r=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);let{target:i=qu,eventName:a=`keydown`,passive:o=!1,dedupe:s=!1}=r,c=rd(t);return Xu(i,a,e=>{e.repeat&&U(s)||c(e)&&n(e)},o)}var ad=500,od=10;function sd(e,t,n){var r,i;let a=G(()=>Yu(e)),o,s,c,l=!1;function u(){o&&=(clearTimeout(o),void 0),s=void 0,c=void 0,l=!1}function d(e){let t=n?.delay;return typeof t==`function`?t(e):t??ad}function f(e){var t,r,i;let[o,d,f]=[c,s,l];if(u(),!n?.onMouseUp||!d||!o||n!=null&&(t=n.modifiers)!=null&&t.self&&e.target!==a.value)return;n!=null&&(r=n.modifiers)!=null&&r.prevent&&e.preventDefault(),n!=null&&(i=n.modifiers)!=null&&i.stop&&e.stopPropagation();let p=e.x-d.x,m=e.y-d.y,h=Math.sqrt(p*p+m*m);n.onMouseUp(e.timeStamp-o,h,f,e)}function p(e){var r,i,f;n!=null&&(r=n.modifiers)!=null&&r.self&&e.target!==a.value||(u(),n!=null&&(i=n.modifiers)!=null&&i.prevent&&e.preventDefault(),n!=null&&(f=n.modifiers)!=null&&f.stop&&e.stopPropagation(),s={x:e.x,y:e.y},c=e.timeStamp,o=setTimeout(()=>{l=!0,t(e)},d(e)))}function m(e){var t,r,i;if(n!=null&&(t=n.modifiers)!=null&&t.self&&e.target!==a.value||!s||n?.distanceThreshold===!1)return;n!=null&&(r=n.modifiers)!=null&&r.prevent&&e.preventDefault(),n!=null&&(i=n.modifiers)!=null&&i.stop&&e.stopPropagation();let o=e.x-s.x,c=e.y-s.y;Math.sqrt(o*o+c*c)>=(n?.distanceThreshold??od)&&u()}let h={capture:n==null||(r=n.modifiers)==null?void 0:r.capture,once:n==null||(i=n.modifiers)==null?void 0:i.once},g=[Xu(a,`pointerdown`,p,h),Xu(a,`pointermove`,m,h),Xu(a,[`pointerup`,`pointerleave`],f,h)];return()=>g.forEach(e=>e())}function cd(e,t={}){let{immediate:n=!0,fpsLimit:r=null,window:i=qu,once:a=!1}=t,o=J(!1),s=G(()=>{let e=U(r);return e?1e3/e:null}),c=0,l=null;function u(t){if(!o.value||!i)return;c||=t;let n=t-c;if(s.value&&n<s.value){l=i.requestAnimationFrame(u);return}if(c=t,e({delta:n,timestamp:t}),a){o.value=!1,l=null;return}l=i.requestAnimationFrame(u)}function d(){!o.value&&i&&(o.value=!0,c=0,l=i.requestAnimationFrame(u))}function f(){o.value=!1,l!=null&&i&&(i.cancelAnimationFrame(l),l=null)}return n&&d(),ql(f),{isActive:Ie(o),pause:f,resume:d}}var ld=Symbol(`vueuse-ssr-width`);function ud(){let e=et()?Yl(ld,null):null;return typeof e==`number`?e:void 0}function dd(e,t={}){let{window:n=qu,ssrWidth:r=ud()}=t,i=ed(()=>n&&`matchMedia`in n&&typeof n.matchMedia==`function`),a=J(typeof r==`number`),o=J(),s=J(!1);return qe(()=>{if(a.value){a.value=!i.value;let t=U(e).split(`,`);s.value=t.some(e=>{let t=e.includes(`not all`),n=e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),i=e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),a=!!(n||i);return n&&a&&(a=r>=uu(n[1])),i&&a&&(a=r<=uu(i[1])),t?!a:a});return}i.value&&(o.value=n.matchMedia(U(e)),s.value=o.value.matches)}),Xu(o,`change`,e=>{s.value=e.matches},{passive:!0}),G(()=>s.value)}function fd(e,t={}){let{controls:n=!1,navigator:r=Ju}=t,i=ed(()=>r&&`permissions`in r),a=J(),o=typeof e==`string`?{name:e}:e,s=J(),c=()=>{s.value=a.value?.state??`prompt`};Xu(a,`change`,c,{passive:!0});let l=lu(async()=>{if(i.value){if(!a.value)try{a.value=await r.permissions.query(o)}catch{a.value=void 0}finally{c()}if(n)return be(a.value)}});return l(),n?{state:s,isSupported:i,query:l}:s}function pd(e={}){let{navigator:t=Ju,read:n=!1,source:r,copiedDuring:i=1500,legacy:a=!1}=e,o=ed(()=>t&&`clipboard`in t),s=fd(`clipboard-read`),c=fd(`clipboard-write`),l=G(()=>o.value||a),u=J(``),d=J(!1),f=J(!1),p=Ru(()=>d.value=!1,i,{immediate:!1}),m=0;async function h(){let e=!(o.value&&b(s.value));if(!e)try{u.value=await t.clipboard.readText()}catch{e=!0}e&&(u.value=y())}l.value&&n&&Xu([`copy`,`cut`],h,{passive:!0});async function g(e){let n=e??U(r);if(l.value&&n!=null){f.value=!0;let e=!(o.value&&b(c.value));if(!e)try{let e=_(n);await t.clipboard.write([e])}catch{e=!0}if(e){if(typeof n==`string`)u.value=n,v(n);else{let e=++m,t=await n();t!=null&&e===m&&(u.value=t,v(t))}}d.value=!0,p.start(),f.value=!1}}function _(e){return typeof e==`string`?(u.value=e,new ClipboardItem({"text/plain":e})):new ClipboardItem({"text/plain":e().then((e=``)=>(u.value=e,new Blob([e],{type:`text/plain`})))})}function v(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`absolute`,t.style.opacity=`0`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()}function y(){var e,t;return((e=document)==null||(t=e.getSelection)==null||(t=t.call(e))==null?void 0:t.toString())??``}function b(e){return e===`granted`||e===`prompt`}return{copyPending:Ie(f),isSupported:l,text:Ie(u),copied:Ie(d),copy:g}}var md=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},hd=`__vueuse_ssr_handlers__`,gd=_d();function _d(){return hd in md||(md[hd]=md[hd]||{}),md[hd]}function vd(e,t){return gd[e]||t}function yd(e){return e==null?`any`:e instanceof Set?`set`:e instanceof Map?`map`:e instanceof Date?`date`:typeof e==`boolean`?`boolean`:typeof e==`string`?`string`:typeof e==`object`?`object`:Number.isNaN(e)?`any`:`number`}var bd={boolean:{read:e=>e===`true`,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},xd=`vueuse-storage`;function Sd(e,t,n,r={}){let{flush:i=`pre`,deep:a=!0,listenToStorageChanges:o=!0,writeDefaults:s=!0,mergeDefaults:c=!1,shallow:l,window:u=qu,eventFilter:d,onError:f=e=>{console.error(e)},initOnMounted:p}=r,m=(l?J:q)(typeof t==`function`?t():t),h=G(()=>U(e));if(!n)try{n=vd(`getDefaultStorage`,()=>qu?.localStorage)()}catch(e){f(e)}if(!n)return m;let g=U(t),_=yd(g),v=r.serializer??bd[_],{pause:y,resume:b}=Eu(m,e=>w(e),{flush:i,deep:a,eventFilter:d});C(h,()=>E(),{flush:i});let x=!1;u&&o&&(n instanceof Storage?Xu(u,`storage`,e=>{p&&!x||E(e)},{passive:!0}):Xu(u,xd,e=>{p&&!x||D(e)})),p?Ou(()=>{x=!0,E()}):E();function S(e,t){if(u){let r={key:h.value,oldValue:e,newValue:t,storageArea:n};u.dispatchEvent(n instanceof Storage?new StorageEvent(`storage`,r):new CustomEvent(xd,{detail:r}))}}function w(e){try{let t=n.getItem(h.value);if(e==null)S(t,null),n.removeItem(h.value);else{let r=v.write(e);t!==r&&(n.setItem(h.value,r),S(t,r))}}catch(e){f(e)}}function T(e){let t=e?e.newValue:n.getItem(h.value);if(t==null)return s&&g!=null&&n.setItem(h.value,v.write(g)),g;if(!e&&c){let e=v.read(t);return typeof c==`function`?c(e,g):_===`object`&&!Array.isArray(e)?{...g,...e}:e}return typeof t==`string`?v.read(t):t}function E(e){if(!(e&&e.storageArea!==n)){if(e&&e.key==null){m.value=g;return}if(!(e&&e.key!==h.value)){y();try{let t=v.write(m.value);(e===void 0||e?.newValue!==t)&&(m.value=T(e))}catch(e){f(e)}finally{e?rt(b):b()}}}}function D(e){E(e.detail)}return m}var Cd={speed:2,margin:30,direction:`both`};function wd(e){e.scrollLeft>e.scrollWidth-e.clientWidth&&(e.scrollLeft=Math.max(0,e.scrollWidth-e.clientWidth)),e.scrollTop>e.scrollHeight-e.clientHeight&&(e.scrollTop=Math.max(0,e.scrollHeight-e.clientHeight))}function Td(e,t={}){let{pointerTypes:n,preventDefault:r,stopPropagation:i,exact:a,onMove:o,onEnd:s,onStart:c,initialValue:l,axis:u=`both`,draggingElement:d=qu,containerElement:f,handle:p=e,buttons:m=[0],restrictInView:h,autoScroll:g=!1}=t,_=q(U(l)??{x:0,y:0}),v=q(),y=e=>!n||n.includes(e.pointerType),b=e=>{U(r)&&e.preventDefault(),U(i)&&e.stopPropagation()},x=U(g),S=typeof x==`object`?{speed:U(x.speed)??Cd.speed,margin:U(x.margin)??Cd.margin,direction:x.direction??Cd.direction}:Cd,w=e=>typeof e==`number`?[e,e]:[e.x,e.y],T=(e,t,n)=>{let{clientWidth:r,clientHeight:i,scrollLeft:a,scrollTop:o,scrollWidth:s,scrollHeight:c}=e,[l,u]=w(S.margin),[d,f]=w(S.speed),p=0,m=0;(S.direction===`x`||S.direction===`both`)&&(n.x<l&&a>0?p=-d:n.x+t.width>r-l&&a<s-r&&(p=d)),(S.direction===`y`||S.direction===`both`)&&(n.y<u&&o>0?m=-f:n.y+t.height>i-u&&o<c-i&&(m=f)),(p||m)&&e.scrollBy({left:p,top:m,behavior:`auto`})},E=null,D=()=>{let t=U(f);t&&!E&&(E=setInterval(()=>{let n=U(e).getBoundingClientRect(),{x:r,y:i}=_.value,a={x:r-t.scrollLeft,y:i-t.scrollTop};a.x>=0&&a.y>=0&&(T(t,n,a),a.x+=t.scrollLeft,a.y+=t.scrollTop,_.value=a)},1e3/60))},O=()=>{E&&=(clearInterval(E),null)},k=(e,t,n,r)=>{let[i,a]=typeof n==`number`?[n,n]:[n.x,n.y],{clientWidth:o,clientHeight:s}=t;return e.x<i||e.x+r.width>o-i||e.y<a||e.y+r.height>s-a};U(g)&&C(_,()=>{if(U(t.disabled)||!v.value)return;let n=U(f);if(!n)return;let r=U(e).getBoundingClientRect(),{x:i,y:a}=_.value,o={x:i-n.scrollLeft,y:a-n.scrollTop};k(o,n,S.margin,r)?D():O()});let A=n=>{var r;if(!U(m).includes(n.button)||U(t.disabled)||!y(n)||U(a)&&n.target!==U(e))return;let i=U(f),o=i==null||(r=i.getBoundingClientRect)==null?void 0:r.call(i),s=U(e).getBoundingClientRect(),l={x:n.clientX-(i?s.left-o.left+(g?0:i.scrollLeft):s.left),y:n.clientY-(i?s.top-o.top+(g?0:i.scrollTop):s.top)};c?.(l,n)!==!1&&(v.value=l,b(n))},j=n=>{if(U(t.disabled)||!y(n)||!v.value)return;let r=U(f);r instanceof HTMLElement&&wd(r);let i=U(e).getBoundingClientRect(),{x:a,y:s}=_.value;if((u===`x`||u===`both`)&&(a=n.clientX-v.value.x,r&&(a=Math.min(Math.max(0,a),r.scrollWidth-i.width))),(u===`y`||u===`both`)&&(s=n.clientY-v.value.y,r&&(s=Math.min(Math.max(0,s),r.scrollHeight-i.height))),U(g)&&r&&(E===null&&T(r,i,{x:a,y:s}),a+=r.scrollLeft,s+=r.scrollTop),r&&(h||g)){if(u!==`y`){let e=a-r.scrollLeft;e<0?a=r.scrollLeft:e>r.clientWidth-i.width&&(a=r.clientWidth-i.width+r.scrollLeft)}if(u!==`x`){let e=s-r.scrollTop;e<0?s=r.scrollTop:e>r.clientHeight-i.height&&(s=r.clientHeight-i.height+r.scrollTop)}}_.value={x:a,y:s},o?.(_.value,n),b(n)},M=e=>{U(t.disabled)||!y(e)||v.value&&(v.value=void 0,g&&O(),s?.(_.value,e),b(e))};if(Xl){let e=()=>({capture:t.capture??!0,passive:!U(r)});Xu(p,`pointerdown`,A,e),Xu(d,`pointermove`,j,e),Xu(d,[`pointerup`,`pointercancel`],M,e)}return{...Du(_),position:_,isDragging:G(()=>!!v.value),style:G(()=>`
|
|
13
|
+
`}},Eo=class{nc;callbacks;msgs;size;subject;asyncRequests;pub;sub;req;rep;perf;payload;constructor(e,t={msgs:1e5,size:128,subject:``,asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){if(this.nc=e,this.callbacks=t.callbacks||!1,this.msgs=t.msgs||0,this.size=t.size||0,this.subject=t.subject||Wr.nuid.next(),this.asyncRequests=t.asyncRequests||!1,this.pub=t.pub||!1,this.sub=t.sub||!1,this.req=t.req||!1,this.rep=t.rep||!1,this.perf=new Ir,this.payload=this.size?new Uint8Array(this.size):ir,!this.pub&&!this.sub&&!this.req&&!this.rep)throw Error(`no options selected`)}async run(){return this.nc.closed().then(e=>{if(e)throw e}),this.callbacks?await this.runCallbacks():await this.runAsync(),this.processMetrics()}processMetrics(){let{lang:e,version:t}=this.nc.protocol.transport;this.pub&&this.sub&&this.perf.measure(`pubsub`,`pubStart`,`subStop`),this.req&&this.rep&&this.perf.measure(`reqrep`,`reqStart`,`reqStop`);let n=this.perf.getEntries(),r=n.find(e=>e.name===`pubsub`),i=n.find(e=>e.name===`reqrep`),a=n.find(e=>e.name===`req`),o=n.find(e=>e.name===`rep`),s=n.find(e=>e.name===`pub`),c=n.find(e=>e.name===`sub`),l=this.nc.stats(),u=[];if(r){let{name:n,duration:i}=r,a=new To(n,i);a.msgs=this.msgs*2,a.bytes=l.inBytes+l.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,u.push(a)}if(i){let{name:n,duration:r}=i,a=new To(n,r);a.msgs=this.msgs*2,a.bytes=l.inBytes+l.outBytes,a.lang=e,a.version=t,a.payload=this.payload.length,u.push(a)}if(s){let{name:n,duration:r}=s,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.outBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}if(c){let{name:n,duration:r}=c,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.inBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}if(o){let{name:n,duration:r}=o,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.inBytes+l.outBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}if(a){let{name:n,duration:r}=a,i=new To(n,r);i.msgs=this.msgs,i.bytes=l.inBytes+l.outBytes,i.lang=e,i.version=t,i.payload=this.payload.length,u.push(i)}return u}async runCallbacks(){let e=[];if(this.sub){let t=Or();e.push(t);let n=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{n++,n===1&&this.perf.mark(`subStart`),n===this.msgs&&(this.perf.mark(`subStop`),this.perf.measure(`sub`,`subStart`,`subStop`),t.resolve())}})}if(this.rep){let t=Or();e.push(t);let n=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(e,r)=>{r.respond(this.payload),n++,n===1&&this.perf.mark(`repStart`),n===this.msgs&&(this.perf.mark(`repStop`),this.perf.measure(`rep`,`repStart`,`repStop`),t.resolve())}})}if(this.pub){let t=(async()=>{this.perf.mark(`pubStart`);for(let e=0;e<this.msgs;e++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark(`pubStop`),this.perf.measure(`pub`,`pubStart`,`pubStop`)})();e.push(t)}if(this.req){let t=(async()=>{if(this.asyncRequests){this.perf.mark(`reqStart`);let e=[];for(let t=0;t<this.msgs;t++)e.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(e),this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}else{this.perf.mark(`reqStart`);for(let e=0;e<this.msgs;e++)await this.nc.request(this.subject);this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}})();e.push(t)}await Promise.all(e)}async runAsync(){let e=[];if(this.rep){let t=!1,n=this.nc.subscribe(this.subject,{max:this.msgs}),r=(async()=>{for await(let e of n)t||=(this.perf.mark(`repStart`),!0),e.respond(this.payload);await this.nc.flush(),this.perf.mark(`repStop`),this.perf.measure(`rep`,`repStart`,`repStop`)})();e.push(r)}if(this.sub){let t=!1,n=this.nc.subscribe(this.subject,{max:this.msgs}),r=(async()=>{for await(let e of n)t||=(this.perf.mark(`subStart`),!0);this.perf.mark(`subStop`),this.perf.measure(`sub`,`subStart`,`subStop`)})();e.push(r)}if(this.pub){let t=(async()=>{this.perf.mark(`pubStart`);for(let e=0;e<this.msgs;e++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark(`pubStop`),this.perf.measure(`pub`,`pubStart`,`pubStop`)})();e.push(t)}if(this.req){let t=(async()=>{if(this.asyncRequests){this.perf.mark(`reqStart`);let e=[];for(let t=0;t<this.msgs;t++)e.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(e),this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}else{this.perf.mark(`reqStart`);for(let e=0;e<this.msgs;e++)await this.nc.request(this.subject);this.perf.mark(`reqStop`),this.perf.measure(`req`,`reqStart`,`reqStop`)}})();e.push(t)}await Promise.all(e)}}})),Oo,ko=n((()=>{Oo=class{interval;maxOut;cancelAfter;timer;autoCancelTimer;last;missed;count;callback;constructor(e,t,n={maxOut:2}){this.interval=e,this.maxOut=n?.maxOut||2,this.cancelAfter=n?.cancelAfter||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=t,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,t=0,n=2){this.interval=e,this.maxOut=n,this.cancelAfter=t,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}})),Ao,jo=n((()=>{Ao=`3.4.0`}));function Mo(e,t){/^(.*:\/\/)(.*)/.test(e)||(e=typeof t==`boolean`?`${t===!0?`https`:`http`}://${e}`:`https://${e}`);let n=new URL(e),r=n.protocol.toLowerCase();r===`ws:`&&(t=!1),r===`wss:`&&(t=!0),r!==`https:`&&r!==`http`&&(e=e.replace(/^(.*:\/\/)(.*)/gm,`$2`),n=new URL(`http://${e}`));let i,a,o=n.hostname,s=n.pathname,c=n.search||``;switch(r){case`http:`:case`ws:`:case`nats:`:a=n.port||`80`,i=`ws:`;break;case`https:`:case`wss:`:case`tls:`:a=n.port||`443`,i=`wss:`;break;default:a=n.port||t===!0?`443`:`80`,i=t===!0?`wss:`:`ws:`}return`${i}//${o}:${a}${s}${c}`}function No(e={}){return ei({defaultPort:443,urlParseFn:Mo,factory:()=>{if(e.tls)throw lr.format(`tls`,`is not configurable on w3c websocket connections`);return new Io}}),vo.connect(e)}var Po,Fo,Io,Lo=n((()=>{Vr(),di(),Za(),$r(),fo(),bo(),jo(),Sr(),Po=Ao,Fo=`nats.ws`,Io=class{version;lang;closeError;connected;done;socket;options;socketClosed;encrypted;peeked;yields;signal;closedNotification;pendingConnect;constructor(){this.version=Po,this.lang=Fo,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=Or(),this.closedNotification=Or(),this.pendingConnect=null}async connect(e,t){let n=Or();this.pendingConnect=n,this.options=t;let r=e.src;if(t.wsFactory){let{socket:n,encrypted:r}=await t.wsFactory(e.src,t);this.socket=n,this.encrypted=r}else this.encrypted=r.indexOf(`wss://`)===0,this.socket=new WebSocket(r);return this.socket.binaryType=`arraybuffer`,this.socket.onopen=()=>{this.done&&this._closed(Error(`aborted`))},this.socket.onmessage=e=>{if(this.done)return;if(this.yields.push(new Uint8Array(e.data)),this.peeked){this.signal.resolve();return}let r=Qr.concat(...this.yields),i=oi(r);if(i!==``){let e=to.exec(i);if(!e){t.debug&&console.error(`!!!`,wr(r)),n.reject(Error(`unexpected response from server`));return}try{Ka(JSON.parse(e[1]),this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),n.resolve()}catch(e){n.reject(e);return}}},this.socket.onclose=e=>{let t;e.code>=4e3&&e.code<=4999?t=Error(e.reason||`close code ${e.code}`):!e.wasClean&&e.reason!==``&&(t=Error(e.reason)),t&&(t.wsCloseCode=e.code),this._closed(t),this._cleanup()},this.socket.onerror=e=>{if(this.done)return;let t=e,r=new xr.ConnectionError(t.message);n.reject(r),this._cleanup()},n}_cleanup(){this.socketClosed===!1&&(this.socketClosed=!0,this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.closedNotification.resolve(this.closeError))}disconnect(){this._closed(void 0,!0)}async _closed(e,t=!0){if(this.pendingConnect?.reject(e??new xr.ConnectionError(`transport closed during handshake`)),this.done){try{this.socket.close()}catch{}return}if(this.closeError=e,!e){let e=Date.now();for(;!this.socketClosed&&this.socket.bufferedAmount>0&&!(Date.now()-e>=3e3);)await Er(100)}this.done=!0;try{this.socket.close()}catch{}return this._cleanup(),this.closedNotification}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.done)return;this.yields.length===0&&await this.signal;let e=this.yields;this.yields=[];for(let t=0;t<e.length;t++)this.options.debug&&console.info(`> ${wr(e[t])}`),yield e[t];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=Or())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.done)try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${wr(e)}`);return}catch(t){this.options.debug&&console.error(`!!! ${wr(e)}: ${t}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}discard(){this.socket?.close()}}})),Ro=i({AuthorizationError:()=>fr,Bench:()=>Eo,ClosedConnectionError:()=>pr,Connect:()=>oo,ConnectionError:()=>hr,DEFAULT_MAX_RECONNECT_ATTEMPTS:()=>10,DataBuffer:()=>Qr,DenoBuffer:()=>Yi,DrainingConnectionError:()=>mr,Empty:()=>ir,Feature:()=>ga,Features:()=>_a,Heartbeat:()=>Bi,INFO:()=>to,IdleHeartbeatMonitor:()=>Oo,InvalidArgumentError:()=>lr,InvalidOperationError:()=>ur,InvalidSubjectError:()=>cr,Kind:()=>$i,MAX_SIZE:()=>Ji,Match:()=>Jr,Metric:()=>To,MsgHdrsImpl:()=>ua,MsgImpl:()=>fa,MuxSubscription:()=>Ri,NatsConnectionImpl:()=>vo,NoRespondersError:()=>yr,Nuid:()=>Wr.Nuid,Parser:()=>ra,PermissionViolationError:()=>br,ProtocolError:()=>gr,ProtocolHandler:()=>uo,QueuedIteratorImpl:()=>Ii,RequestError:()=>_r,RequestOne:()=>ho,Servers:()=>Pi,SimpleMutex:()=>Lr,State:()=>ia,SubscriptionImpl:()=>co,Subscriptions:()=>lo,TD:()=>or,TE:()=>ar,TimeoutError:()=>vr,UserAuthenticationExpiredError:()=>dr,backoff:()=>Mr,buildAuthenticator:()=>Wa,canonicalMIMEHeaderKey:()=>sa,checkOptions:()=>Ka,checkUnsupportedOption:()=>qa,collect:()=>Ar,compare:()=>ha,createInbox:()=>qr,credsAuthenticator:()=>Ba,deadline:()=>Dr,defaultOptions:()=>Ha,deferred:()=>Or,delay:()=>Er,describe:()=>Zi,errors:()=>xr,extend:()=>Cr,extractProtocolMessage:()=>oi,getResolveFn:()=>ii,hasWsProtocol:()=>Ua,headers:()=>ca,ipV4:()=>fi,isIP:()=>pi,isIPV4OrHostname:()=>ki,jwtAuthenticator:()=>za,millis:()=>Pr,nanos:()=>Nr,nkeyAuthenticator:()=>Ra,nkeys:()=>Ma,nuid:()=>Wr.nuid,parseIP:()=>mi,parseOptions:()=>Ga,parseSemVer:()=>ma,protoLen:()=>ai,readAll:()=>Wi,render:()=>wr,setTransportFactory:()=>ei,syncIterator:()=>Kr,timeout:()=>Tr,tokenAuthenticator:()=>La,usernamePasswordAuthenticator:()=>Ia,writeAll:()=>Gi,wsUrlParseFn:()=>Mo,wsconnect:()=>No}),zo=n((()=>{bo(),Gr(),pa(),di(),fo(),Vr(),da(),Vi(),zi(),$r(),Za(),go(),Va(),Na(),Li(),oa(),Xi(),Do(),sr(),Oi(),va(),xo(),Zr(),ko(),Fi(),Lo(),Sr()})),Bo=class{client;channelId;closed=!1;unsubscribe;initialized=!1;subject;requestSubject;handlers=new Map;closeHandlers=new Set;errorHandlers=new Set;subscriptions=[];get isClosed(){return this.closed}get id(){return this.channelId}constructor(e,t){this.client=e,this.channelId=t,this.subject=`channel.${t}`,this.requestSubject=`channel.${t}.request`}async init(){this.initialized||(this.initialized=!0,this.unsubscribe=await this.client.subscribe(this.subject,async e=>{switch(e.type){case`message`:this.emit(`message`,e.data);break;case`close`:this.handleClose();break;case`error`:this.handleError(Error(e.error??`Channel error`))}}))}async send(e){if(this.closed)throw Error(`Channel is closed`);let t={type:`message`,data:e};await this.client.publish(this.subject,t)}async request(e,t=5e3){if(this.closed)throw Error(`Channel is closed`);return this.client.request(this.requestSubject,e,{timeout:t})}async onRequest(e){let t=this.client.onRequest(this.requestSubject,e);return this.subscriptions.push(t),t}on(e,t){e===`close`?this.closeHandlers.add(t):e===`error`?this.errorHandlers.add(t):(this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t))}off(e,t){e===`close`?this.closeHandlers.delete(t):e===`error`?this.errorHandlers.delete(t):this.handlers.get(e)?.delete(t)}async close(){if(!this.closed){this.closed=!0;try{await this.client.publish(this.subject,{type:`close`})}catch{}await this.cleanup()}}handlerChain=Promise.resolve();runHandler(e,t,n){this.handlerChain=this.handlerChain.then(()=>e(t)).catch(e=>console.error(`Error in ${n}:`,e))}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)this.runHandler(e,t,`channel handler`)}handleClose(){if(!this.closed){this.closed=!0;for(let e of this.closeHandlers)this.runHandler(()=>e(),void 0,`close handler`);this.cleanup().catch(console.error)}}handleError(e){for(let t of this.errorHandlers)this.runHandler(t,e,`error handler`)}async cleanup(){if(this.handlers.clear(),this.closeHandlers.clear(),this.errorHandlers.clear(),await Promise.allSettled(this.subscriptions.map(async e=>(await e)())),this.subscriptions=[],this.unsubscribe){try{this.unsubscribe()}catch{}this.unsubscribe=void 0}let e=this._isolatedClient;if(e)try{await e.disconnect()}catch{}}},Vo=class extends Bo{targetClientId;clientId;remoteClientId;privateSubject;privateRequestSubject;get remoteId(){return this.remoteClientId}constructor(e,t,n){super(e,t),this.targetClientId=n;let r=e.options.name??`client-${Date.now()}`;this.clientId=r.replace(/-(channel|private)-.*$/,``);let i=[this.clientId,this.targetClientId].sort();this.privateSubject=`channel.private.${t}.${i.join(`.`)}`,this.privateRequestSubject=`${this.privateSubject}.request`}async init(){if(!this.initialized){this.initialized=!0,this.unsubscribe=await this.client.subscribe(this.privateSubject,async e=>{if(e.sender!==this.clientId&&e.sender===this.targetClientId&&(!this.remoteClientId&&e.sender&&(this.remoteClientId=e.sender),!(this.remoteClientId&&e.sender!==this.remoteClientId)))switch(e.type){case`message`:if(e.data&&typeof e.data==`object`&&`__handshake`in e.data)return;this.emit(`message`,e.data);break;case`close`:this.handleClose();break;case`error`:this.handleError(Error(e.error??`Channel error`))}});try{await this.sendRaw({type:`message`,data:{__handshake:!0},sender:this.clientId})}catch{}}}async send(e){if(this.closed)throw Error(`Channel is closed`);await this.sendRaw({type:`message`,data:e,sender:this.clientId})}async request(e,t=5e3){if(this.closed)throw Error(`Channel is closed`);return this.client.request(this.privateRequestSubject,e,{timeout:t})}async onRequest(e){return this.client.onRequest(this.privateRequestSubject,e)}async close(){if(!this.closed){this.closed=!0;try{await this.sendRaw({type:`close`,sender:this.clientId})}catch{}await this.cleanup()}}isConnectedTo(e){return this.remoteClientId===e}async sendRaw(e){await this.client.publish(this.privateSubject,e)}},Ho;try{Ho=new TextDecoder}catch{}var Y,Uo,X=0,Wo=[],Go=Wo,Ko=0,qo={},Jo,Yo,Xo=0,Zo=0,Qo,$o,es=[],ts,ns={useRecords:!1,mapsAsObjects:!0},rs=class{},is=new rs;is.name=`MessagePack 0xC1`;var as=!1,os=2,ss=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(Y)return Ls(()=>(Rs(),this?this.unpack(t,n):e.prototype.unpack.call(ns,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(Uo=n.end||t.length,X=n.start||0):(X=0,Uo=n>-1?n:t.length),Ko=0,Zo=0,Yo=null,Go=Wo,Qo=null,Y=t;try{ts=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw Y=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(qo=this,this.structures)return Jo=this.structures,cs(n);(!Jo||Jo.length>0)&&(Jo=[])}else qo=ns,(!Jo||Jo.length>0)&&(Jo=[]);return cs(n)}unpackMultiple(e,t){let n,r=0;try{as=!0;let i=e.length,a=this?this.unpack(e,i):Bs.unpack(e,i);if(t){if(t(a,r,X)===!1)return;for(;X<i;)if(r=X,t(cs(),r,X)===!1)return}else{for(n=[a];X<i;)r=X,n.push(cs());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{as=!1,Rs()}}_mergeStructures(e,t){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function cs(e){try{if(!qo.trusted&&!as){let e=Jo.sharedLength||0;e<Jo.length&&(Jo.length=e)}let t;if(qo._readStruct&&Y[X]<64&&Y[X]>=32?(t=qo._readStruct(Y,X,Uo),Y=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),X=Uo):t=us(),Qo&&=(X=Qo.postBundlePosition,null),as&&(Jo.restoreStructures=null),X==Uo)Jo&&Jo.restoreStructures&&ls(),Jo=null,Y=null,$o&&=null;else if(X>Uo)throw Error(`Unexpected end of MessagePack data`);else if(!as){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw Jo&&Jo.restoreStructures&&ls(),Rs(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||X>Uo)&&(e.incomplete=!0),e}}function ls(){for(let e in Jo.restoreStructures)Jo[e]=Jo.restoreStructures[e];Jo.restoreStructures=null}function us(){let e=Y[X++];if(e<160){if(e<128){if(e<64)return e;{let t=Jo[e&63]||qo.getStructures&&ms()[e&63];return t?(t.read||=fs(t,e&63),t.read()):e}}if(e<144){if(e-=128,qo.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=As();e===`__proto__`&&(e=`__proto_`),t[e]=us()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(us(),us());return t}}{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=us();return qo.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(Zo>=X)return Yo.slice(X-Xo,(X+=t)-Xo);if(Zo==0&&Uo<140){let e=t<16?Ts(t):ws(t);if(e!=null)return e}return hs(t)}{let t;switch(e){case 192:return null;case 193:return Qo?(t=us(),t>0?Qo[1].slice(Qo.position1,Qo.position1+=t):Qo[0].slice(Qo.position0,Qo.position0-=t)):is;case 194:return!1;case 195:return!0;case 196:if(t=Y[X++],t===void 0)throw Error(`Unexpected end of buffer`);return Ds(t);case 197:return t=ts.getUint16(X),X+=2,Ds(t);case 198:return t=ts.getUint32(X),X+=4,Ds(t);case 199:return Os(Y[X++]);case 200:return t=ts.getUint16(X),X+=2,Os(t);case 201:return t=ts.getUint32(X),X+=4,Os(t);case 202:if(t=ts.getFloat32(X),qo.useFloat32>2){let e=zs[(Y[X]&127)<<1|Y[X+1]>>7];return X+=4,(e*t+(t>0?.5:-.5)>>0)/e}return X+=4,t;case 203:return t=ts.getFloat64(X),X+=8,t;case 204:return Y[X++];case 205:return t=ts.getUint16(X),X+=2,t;case 206:return t=ts.getUint32(X),X+=4,t;case 207:return qo.int64AsType===`number`?(t=ts.getUint32(X)*4294967296,t+=ts.getUint32(X+4)):qo.int64AsType===`string`?t=ts.getBigUint64(X).toString():qo.int64AsType===`auto`?(t=ts.getBigUint64(X),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ts.getBigUint64(X),X+=8,t;case 208:return ts.getInt8(X++);case 209:return t=ts.getInt16(X),X+=2,t;case 210:return t=ts.getInt32(X),X+=4,t;case 211:return qo.int64AsType===`number`?(t=ts.getInt32(X)*4294967296,t+=ts.getUint32(X+4)):qo.int64AsType===`string`?t=ts.getBigInt64(X).toString():qo.int64AsType===`auto`?(t=ts.getBigInt64(X),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ts.getBigInt64(X),X+=8,t;case 212:if(t=Y[X++],t==114)return Ms(Y[X++]&63);{let e=es[t];if(e)return e.read?(X++,e.read(us())):e.noBuffer?(X++,e()):e(Y.subarray(X,++X));throw Error(`Unknown extension `+t)}case 213:return t=Y[X],t==114?(X++,Ms(Y[X++]&63,Y[X++])):Os(2);case 214:return Os(4);case 215:return Os(8);case 216:return Os(16);case 217:return t=Y[X++],Zo>=X?Yo.slice(X-Xo,(X+=t)-Xo):gs(t);case 218:return t=ts.getUint16(X),X+=2,Zo>=X?Yo.slice(X-Xo,(X+=t)-Xo):_s(t);case 219:return t=ts.getUint32(X),X+=4,Zo>=X?Yo.slice(X-Xo,(X+=t)-Xo):vs(t);case 220:return t=ts.getUint16(X),X+=2,xs(t);case 221:return t=ts.getUint32(X),X+=4,xs(t);case 222:return t=ts.getUint16(X),X+=2,Ss(t);case 223:return t=ts.getUint32(X),X+=4,Ss(t);default:if(e>=224)return e-256;throw e===void 0?bs():Error(`Unknown MessagePack token `+e)}}}var ds=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function fs(e,t){function n(){if(n.count++>os){let r;try{r=e.read=Function(`r`,`return function(){return `+(qo.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:ds.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(us)}catch{return os=1/0,n()}return e.read0=r,e.highByte===0&&(e.read=ps(t,e.read)),r()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=us()}return qo.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?ps(t,n):n}var ps=(e,t)=>function(){let n=Y[X++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=Jo[r]||ms()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=fs(i,e),i.read()};function ms(){let e=Ls(()=>(Y=null,qo.getStructures()));return Jo=qo._mergeStructures(e,Jo)}var hs=ys,gs=ys,_s=ys,vs=ys;function ys(e){let t;if(e<16&&(t=Ts(e)))return t;if(e>64&&Ho)return Ho.decode(Y.subarray(X,X+=e));let n=X+e,r=[];for(t=``;X<n;){let e=Y[X++];if(!(e&128))r.push(e);else if((e&224)==192){if(e<194||X>=n||(Y[X]&192)!=128)r.push(65533);else{let t=Y[X++]&63;r.push((e&31)<<6|t)}}else if((e&240)==224){let t=X<n?Y[X]:0;if(X>=n||(t&192)!=128||e===224&&t<160||e===237&&t>=160)r.push(65533);else if(X++,X>=n||(Y[X]&192)!=128)r.push(65533);else{let n=Y[X++]&63;r.push((e&31)<<12|(t&63)<<6|n)}}else if((e&248)==240){let t=X<n?Y[X]:0;if(e>244||X>=n||(t&192)!=128||e===240&&t<144||e===244&&t>=144)r.push(65533);else if(X++,X>=n||(Y[X]&192)!=128)r.push(65533);else{let i=Y[X++]&63;if(X>=n||(Y[X]&192)!=128)r.push(65533);else{let n=Y[X++]&63,a=(e&7)<<18|(t&63)<<12|i<<6|n;a-=65536,r.push(a>>>10&1023|55296),r.push(56320|a&1023)}}}else r.push(65533);r.length>=4096&&(t+=Cs.apply(String,r),r.length=0)}return r.length>0&&(t+=Cs.apply(String,r)),t}function bs(){let e=Error(`Unexpected end of MessagePack data`);return e.incomplete=!0,e}function xs(e){if(e>Uo-X)throw bs();let t=Array(e);for(let n=0;n<e;n++)t[n]=us();return qo.freezeData?Object.freeze(t):t}function Ss(e){if(e>(Uo-X)/2)throw bs();if(qo.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=As();e===`__proto__`&&(e=`__proto_`),t[e]=us()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(us(),us());return t}}var Cs=String.fromCharCode;function ws(e){let t=X,n=Array(e);for(let r=0;r<e;r++){let e=Y[X++];if((e&128)>0){X=t;return}n[r]=e}return Cs.apply(String,n)}function Ts(e){if(e<4){if(e<2){if(e===0)return``;{let e=Y[X++];if((e&128)>1){--X;return}return Cs(e)}}{let t=Y[X++],n=Y[X++];if((t&128)>0||(n&128)>0){X-=2;return}if(e<3)return Cs(t,n);let r=Y[X++];if((r&128)>0){X-=3;return}return Cs(t,n,r)}}{let t=Y[X++],n=Y[X++],r=Y[X++],i=Y[X++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){X-=4;return}if(e<6){if(e===4)return Cs(t,n,r,i);{let e=Y[X++];if((e&128)>0){X-=5;return}return Cs(t,n,r,i,e)}}if(e<8){let a=Y[X++],o=Y[X++];if((a&128)>0||(o&128)>0){X-=6;return}if(e<7)return Cs(t,n,r,i,a,o);let s=Y[X++];if((s&128)>0){X-=7;return}return Cs(t,n,r,i,a,o,s)}{let a=Y[X++],o=Y[X++],s=Y[X++],c=Y[X++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){X-=8;return}if(e<10){if(e===8)return Cs(t,n,r,i,a,o,s,c);{let e=Y[X++];if((e&128)>0){X-=9;return}return Cs(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=Y[X++],u=Y[X++];if((l&128)>0||(u&128)>0){X-=10;return}if(e<11)return Cs(t,n,r,i,a,o,s,c,l,u);let d=Y[X++];if((d&128)>0){X-=11;return}return Cs(t,n,r,i,a,o,s,c,l,u,d)}{let l=Y[X++],u=Y[X++],d=Y[X++],f=Y[X++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){X-=12;return}if(e<14){if(e===12)return Cs(t,n,r,i,a,o,s,c,l,u,d,f);{let e=Y[X++];if((e&128)>0){X-=13;return}return Cs(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=Y[X++],m=Y[X++];if((p&128)>0||(m&128)>0){X-=14;return}if(e<15)return Cs(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=Y[X++];if((h&128)>0){X-=15;return}return Cs(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Es(){let e=Y[X++],t;if(e<192)t=e-160;else switch(e){case 217:t=Y[X++];break;case 218:t=ts.getUint16(X),X+=2;break;case 219:t=ts.getUint32(X),X+=4;break;default:throw Error(`Expected string`)}return ys(t)}function Ds(e){return qo.copyBuffers?Uint8Array.prototype.slice.call(Y,X,X+=e):Y.subarray(X,X+=e)}function Os(e){let t=Y[X++];if(es[t]){let n;return es[t](Y.subarray(X,n=X+=e),e=>{X=e;try{return us()}finally{X=n}})}throw Error(`Unknown extension type `+t)}var ks=Array(4096);function As(){let e=Y[X++];if(e>=160&&e<192){if(e-=160,Zo>=X)return Yo.slice(X-Xo,(X+=e)-Xo);if(!(Zo==0&&Uo<180))return hs(e)}else return X--,js(us());let t=(e<<5^(e>1?ts.getUint16(X):e>0?Y[X]:0))&4095,n=ks[t],r=X,i=X+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=ts.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=Y[r++],a!=n[o++]){r=1879048192;break}if(r===i)return X=r,n.string;i-=3,r=X}for(n=[],ks[t]=n,n.bytes=e;r<i;)a=ts.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=Y[r++],n.push(a);let s=e<16?Ts(e):ws(e);return s==null?n.string=hs(e):n.string=s}function js(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(qo.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var Ms=(e,t)=>{let n=us().map(js),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=Jo[e];return i&&(i.isShared||as)&&((Jo.restoreStructures||(Jo.restoreStructures=[]))[e]=i),Jo[e]=n,n.read=fs(n,r),(n.read0||n.read)()};es[0]=()=>{},es[0].noBuffer=!0,es[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=BigInt(64),n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var Ns={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};es[101]=()=>{let e=us();if(!Ns[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return Ns[e[0]](e[1],{cause:e[2]})},es[105]=e=>{if(qo.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ts.getUint32(X-4);$o||=new Map;let n=Y[X],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&Y[X+1]===115?new Set:{};let i={target:r};$o.set(t,i);let a=us();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},es[112]=e=>{if(qo.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ts.getUint32(X-4),n=$o.get(t);return n.used=!0,n.target},es[115]=()=>new Set(us());var Ps=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),Fs=typeof globalThis==`object`?globalThis:window;es[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=Ps[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new Fs[r](n)},es[120]=()=>{let e=us();return new RegExp(e[0],e[1])};var Is=[];es[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=X;return X+=t-e.length,Qo=Is,Qo=[Es(),Es()],Qo.position0=0,Qo.position1=0,Qo.postBundlePosition=X,X=n,us()},es[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function Ls(e){qo&&qo._onSaveState&&qo._onSaveState();let t=Uo,n=X,r=Ko,i=Xo,a=Zo,o=Yo,s=Go,c=$o,l=Qo,u=new Uint8Array(Y.slice(0,Uo)),d=Jo,f=Jo.slice(0,Jo.length),p=qo,m=as,h=e();return Uo=t,X=n,Ko=r,Xo=i,Zo=a,Yo=o,Go=s,$o=c,Qo=l,Y=u,as=m,Jo=d,Jo.splice(0,Jo.length,...f),qo=p,ts=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),h}function Rs(){Y=null,$o=null,Jo=null}var zs=Array(147);for(let e=0;e<256;e++)zs[e]=+(`1e`+Math.floor(45.15-e*.30103));var Bs=new ss({useRecords:!1});Bs.unpack,Bs.unpackMultiple,Bs.unpack;var Vs={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4),ss.SUPPORTS_STRUCT_HOOKS=!0;var Hs;try{Hs=new TextEncoder}catch{}var Us,Ws,Gs=typeof Buffer<`u`,Ks=Gs?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,qs=Gs?Buffer:Uint8Array,Js=Gs?4294967296:2144337920,Z,Ys,Xs,Q=0,Zs,Qs=null,$s=21760,ec=/[\u0080-\uFFFF]/,tc=Symbol(`record-id`),nc=class extends ss{constructor(e){super(e),this.offset=0;let t,n,r,i,a=qs.prototype.utf8Write?function(e,t){return Z.utf8Write(e,t,Z.byteLength-t)}:Hs&&Hs.encodeInto?function(e,t){return Hs.encodeInto(e,Z.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(Z||(Z=new Ks(8192),Xs=Z.dataView||(Z.dataView=new DataView(Z.buffer,0,8192)),Q=0),Zs=Z.length-10,Zs-Q<2048?(Z=new Ks(Z.length),Xs=Z.dataView||(Z.dataView=new DataView(Z.buffer,0,Z.length)),Zs=Z.length-10,Q=0):Q=Q+7&2147483640,t=Q,a&2048&&(Q+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(Qs=[],Qs.size=1/0):Qs=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[tc]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o._writeStruct&&e&&typeof e==`object`?e.constructor===Object?w(e):e.constructor!==Map&&!Array.isArray(e)&&!Ws.some(t=>e instanceof t)?w(o.useToJSON!==!1&&e.toJSON?e.toJSON():e):y(e):y(e);let n=Qs;if(Qs&&sc(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(Xs.setUint32(n.position+t,Xs.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&Xs.setUint32(n.position+t,Xs.getUint32(n.position+t)+a),Q+=e.length*6,Q>Zs&&T(Q),o.offset=Q;let s=oc(Z.subarray(t,Q),e);return i=null,s}return o.offset=Q,a&512?(Z.start=t,Z.end=Q,Z):Z.subarray(t,Q)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=Z.subarray(t,Q),s=(o._prepareStructures||cc)(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?(r.uninitialized=!0,o.pack(e,a)):(o.lastNamedStructuresLength=n,Z.length>1073741824&&(Z=null),i)}Z.length>1073741824&&(Z=null),a&1024&&(Q=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][tc]=0;m=[]}},v=e=>{var t=e.length;t<16?Z[Q++]=144|t:t<65536?(Z[Q++]=220,Z[Q++]=t>>8,Z[Q++]=t&255):(Z[Q++]=221,Xs.setUint32(Q,t),Q+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{Q>Zs&&(Z=T(Q));var n=typeof e,r;if(n===`string`){let n=e.length;if(Qs&&n>=4&&n<4096){if((Qs.size+=n)>$s){let e,n=(Qs[0]?Qs[0].length*3+Qs[1].length:0)+10;Q+n>Zs&&(Z=T(Q+n));let r;Qs.position?(r=Qs,Z[Q]=200,Q+=3,Z[Q++]=98,e=Q-t,Q+=4,sc(t,y,0),Xs.setUint16(e+t-3,Q-t-e)):(Z[Q++]=214,Z[Q++]=98,e=Q-t,Q+=4),Qs=[``,``],Qs.previous=r,Qs.size=0,Qs.position=e}let r=ec.test(e);Qs[+!r]+=e,Z[Q++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(Q+o>Zs&&(Z=T(Q+o)),n<64||!a){let t,a,o,s=Q+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?Z[s++]=a:a<2048?(Z[s++]=a>>6|192,Z[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,Z[s++]=a>>18|240,Z[s++]=a>>12&63|128,Z[s++]=a>>6&63|128,Z[s++]=a&63|128):(Z[s++]=a>>12|224,Z[s++]=a>>6&63|128,Z[s++]=a&63|128);r=s-Q-i}else r=a(e,Q+i);r<32?Z[Q++]=160|r:r<256?(i<2&&Z.copyWithin(Q+2,Q+1,Q+1+r),Z[Q++]=217,Z[Q++]=r):r<65536?(i<3&&Z.copyWithin(Q+3,Q+2,Q+2+r),Z[Q++]=218,Z[Q++]=r>>8,Z[Q++]=r&255):(i<5&&Z.copyWithin(Q+5,Q+3,Q+3+r),Z[Q++]=219,Xs.setUint32(Q,r),Q+=4),Q+=r}else if(n===`number`){if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this._writeStruct?Z[Q++]=e:e<256?(Z[Q++]=204,Z[Q++]=e):e<65536?(Z[Q++]=205,Z[Q++]=e>>8,Z[Q++]=e&255):(Z[Q++]=206,Xs.setUint32(Q,e),Q+=4);else if(e>>0===e)e>=-32?Z[Q++]=256+e:e>=-128?(Z[Q++]=208,Z[Q++]=e+256):e>=-32768?(Z[Q++]=209,Xs.setInt16(Q,e),Q+=2):(Z[Q++]=210,Xs.setInt32(Q,e),Q+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){Z[Q++]=202,Xs.setFloat32(Q,e);let n;if(t<4||(n=e*zs[(Z[Q]&127)<<1|Z[Q+1]>>7])>>0===n){Q+=4;return}Q--}Z[Q++]=203,Xs.setFloat64(Q,e),Q+=8}}else if(n===`object`||n===`function`){if(!e)Z[Q++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),Z[Q++]=214,Z[Q++]=112,Xs.setUint32(Q,n.id),Q+=4;return}i.set(e,{offset:Q-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map){if(this.mapAsEmptyObject)Z[Q++]=128;else{r=e.size,r<16?Z[Q++]=128|r:r<65536?(Z[Q++]=222,Z[Q++]=r>>8,Z[Q++]=r&255):(Z[Q++]=223,Xs.setUint32(Q,r),Q+=4);for(let[t,n]of e)y(t),y(n)}}else{for(let t=0,n=Us.length;t<n;t++){let n=Ws[t];if(e instanceof n){let n=Us[t];if(n.write){n.type&&(Z[Q++]=212,Z[Q++]=n.type,Z[Q++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=Z,i=Xs,a=Q;Z=null;let o;try{o=n.pack.call(this,e,e=>(Z=r,r=null,Q+=e,Q>Zs&&T(Q),{target:Z,targetView:Xs,position:Q-e}),y)}finally{r&&(Z=r,Xs=i,Q=a,Zs=Z.length-10)}o&&(o.length+Q>Zs&&T(o.length+Q),Q=ac(o,Z,Q,n.type));return}}if(Array.isArray(e))v(e);else{if(o.useToJSON!==!1&&e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}}else if(n===`boolean`)Z[Q++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)Z[Q++]=211,Xs.setBigInt64(Q,e);else if(e<0x10000000000000000&&e>0)Z[Q++]=207,Xs.setBigUint64(Q,e);else if(this.largeBigIntToFloat)Z[Q++]=203,Xs.setFloat64(Q,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),Gs)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+Q>Zs&&T(n.length+Q),Q=ac(n,Z,Q,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);Q+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?Z[Q++]=192:(Z[Q++]=212,Z[Q++]=0,Z[Q++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?Z[Q++]=128|n:n<65536?(Z[Q++]=222,Z[Q++]=n>>8,Z[Q++]=n&255):(Z[Q++]=223,Xs.setUint32(Q,n),Q+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{Z[Q++]=222;let n=Q-t;Q+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);Z[n+++t]=r>>8,Z[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=Q++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==Q?(Q--,E(i,c,u)):D(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[tc];n?Z[a+t]=n:D(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[tc];a?a>=96&&d?(Z[Q++]=((a-=96)&31)+96,Z[Q++]=a>>5):Z[Q++]=a:E(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let i=o._writeStruct(e,Z,t,Q,r,T,(e,t,r)=>{if(r)return n=!0;Q=t;let i=Z;return y(e),_(),i===Z?Q:{position:Q,targetView:Xs,target:Z}});if(i===0)return C(e);Q=i},T=e=>{let n;if(e>16777216){if(e-t>Js)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(Js,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,Z.length-1)>>12)+1<<12;let r=new Ks(n);return Xs=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,Z.length),Z.copy?Z.copy(r,0,t,e):r.set(Z.slice(t,e)),Q-=t,t=0,Zs=r.length-10,Z=r},E=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[tc]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(Z[Q++]=(a&31)+96,Z[Q++]=o):Z[Q++]=a):(o>=0?(Z[Q++]=213,Z[Q++]=114,Z[Q++]=(a&31)+96,Z[Q++]=o):(Z[Q++]=212,Z[Q++]=114,Z[Q++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[tc]=0),m.push(e),y(t))},D=(e,n,r,i)=>{let a=Z,o=Q,s=Zs,c=t;Z=Ys,Q=0,t=0,Z||(Ys=Z=new Ks(8192)),Zs=Z.length-10,E(e,n,i),Ys=Z;let l=Q;if(Z=a,Q=o,Zs=s,t=c,l>1){let e=Q+l-1;e>Zs&&T(e);let n=r+t;Z.copyWithin(n+l,n+1,Q),Z.set(Ys.slice(0,l),n),Q=e}else Z[r+t]=Ys[0]}}useBuffer(e){Z=e,Z.dataView||(Z.dataView=new DataView(Z.buffer,Z.byteOffset,Z.byteLength)),Xs=Z.dataView,Q=0}set position(e){Q=e}get position(){return Q}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};Ws=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,rs],Us=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?rc(e,16,t):ic(Gs?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==qs&&this.moreTypes?rc(e,Ps.indexOf(n.name),t):ic(e,t)}},{pack(e,t){this.moreTypes?rc(e,17,t):ic(Gs?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function rc(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function ic(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function ac(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function oc(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function sc(e,t,n){if(Qs.length>0){Xs.setUint32(Qs.position+e,Q+n-Qs.position-e),Qs.stringsPosition=Q-e;let r=Qs;Qs=null,t(r[0]),t(r[1])}}function cc(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}nc.SUPPORTS_STRUCT_HOOKS=!0;var lc=new nc({useRecords:!1});lc.pack,lc.pack;var{NEVER:uc,ALWAYS:dc,DECIMAL_ROUND:fc,DECIMAL_FIT:pc}=Vs,mc=new nc({useRecords:!1,bundleStrings:!1,int64AsType:`number`}),hc=new ss({useRecords:!1,bundleStrings:!1,int64AsType:`number`});function gc(e){return mc.pack(e)}function _c(e){return hc.unpack(e)}var vc=[67,85,73,66],yc=8,bc=`__cui_bin__`;function xc(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Sc(e){if(e instanceof Uint8Array)return e.byteLength>=16384?e:void 0;if(e instanceof ArrayBuffer)return e.byteLength>=16384?new Uint8Array(e):void 0}function Cc(e,t){let n=Sc(e);if(n){let e=t.length;return t.push(n),{[bc]:e,l:n.byteLength}}if(Array.isArray(e)){let n;for(let r=0;r<e.length;r++){let i=Cc(e[r],t);i!==e[r]&&(n??=e.slice(),n[r]=i)}return n??e}if(xc(e)){let n;for(let r of Object.keys(e)){let i=Cc(e[r],t);i!==e[r]&&(n??={...e},n[r]=i)}return n??e}return e}function wc(e){if(!xc(e))return!1;let t=e[bc],n=e.l;return!Number.isInteger(t)||t<0||!Number.isInteger(n)||n<0?!1:Object.keys(e).length===2}function Tc(e,t,n){if(wc(e)){if(n.outOfOrder||e[bc]!==n.next)return n.outOfOrder=!0,e;let r=e.l,i=n.offset+r;if(i>t.byteLength)throw Error(`Invalid CUIB frame: segment ${n.next} exceeds payload size ${t.byteLength}`);let a=t.subarray(n.offset,i);return n.offset=i,n.next++,a}if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=Tc(e[r],t,n);return e}if(xc(e)){for(let r of Object.keys(e))e[r]=Tc(e[r],t,n);return e}return e}function Ec(e,t){if(wc(e)){t[e[bc]]=e.l;return}if(Array.isArray(e)){for(let n of e)Ec(n,t);return}if(xc(e))for(let n of Object.keys(e))Ec(e[n],t)}function Dc(e,t){if(wc(e))return t[e[bc]];if(Array.isArray(e)){for(let n=0;n<e.length;n++)e[n]=Dc(e[n],t);return e}if(xc(e)){for(let n of Object.keys(e))e[n]=Dc(e[n],t);return e}return e}function Oc(e,t,n){let r=[];Ec(e,r);let i=Array(r.length),a=n.offset;for(let e=n.next;e<r.length;e++){let n=r[e];if(n===void 0)throw Error(`Invalid CUIB frame: missing placeholder for segment ${e}`);if(a+n>t.byteLength)throw Error(`Invalid CUIB frame: segment ${e} exceeds payload size ${t.byteLength}`);i[e]=t.subarray(a,a+n),a+=n}return n.offset=a,Dc(e,i)}function kc(e){let t=[],n=Cc(e,t);if(t.length===0)return mc.pack(e);let r=mc.pack(n),i=r.byteLength,a=yc+i;for(let e of t)a+=e.byteLength;let o=typeof Buffer<`u`?Buffer.allocUnsafe(a):new Uint8Array(a);o[0]=vc[0],o[1]=vc[1],o[2]=vc[2],o[3]=vc[3],o[4]=i&255,o[5]=i>>>8&255,o[6]=i>>>16&255,o[7]=i>>>24&255,o.set(r,yc);let s=yc+r.byteLength;for(let e of t)o.set(e,s),s+=e.byteLength;return o}function Ac(e){if(e.byteLength<yc||e[0]!==vc[0]||e[1]!==vc[1]||e[2]!==vc[2]||e[3]!==vc[3])return hc.unpack(e);let t=(e[4]|e[5]<<8|e[6]<<16)+e[7]*16777216,n=yc+t;if(n>e.byteLength)throw Error(`Invalid CUIB frame: envelope length ${t} exceeds payload size ${e.byteLength}`);let r=hc.unpack(e.subarray(yc,n)),i={offset:n,next:0,outOfOrder:!1};if(r=Tc(r,e,i),i.outOfOrder&&(r=Oc(r,e,i)),i.offset!==e.byteLength)throw Error(`Invalid CUIB frame: expected payload size ${i.offset}, got ${e.byteLength}`);return r}function*jc(e,t,n){let r=e.length,i=Math.ceil(r/n);for(let a=0;a<i;a++){let o=a*n,s=Math.min(o+n,r),c=e.subarray(o,s);yield{id:t,chunkIndex:a,data:c,isLast:a===i-1}}}var Mc=class{id;buffer;receivedChunks=new Set;totalChunks=0;chunkSize=0;constructor(e,t,n,r){this.id=e,this.totalChunks=n,this.chunkSize=r??Math.ceil(t/n),this.buffer=new Uint8Array(t)}addChunk(e){if(e.id!==this.id)throw Error(`Chunk ID mismatch: expected ${this.id}, got ${e.id}`);let t=e.chunkIndex*this.chunkSize;return this.buffer.set(e.data,t),this.receivedChunks.add(e.chunkIndex),this.isComplete()}isComplete(){return this.receivedChunks.size===this.totalChunks}getData(){if(!this.isComplete())throw Error(`Not all chunks received`);return Ac(this.buffer)}getProgress(){let e=this.receivedChunks.size,t=this.totalChunks;return{received:e,total:t,percentage:t>0?e/t*100:0}}},Nc=class e{static STALE_TRANSFER_TTL_MS=3e4;static SWEEP_INTERVAL_MS=1e3;assemblers=new Map;completedCallbacks=new Map;errorCallbacks=new Map;lastActivity=new Map;lastSweep=0;startReceiving(e,t,n,r,i,a){this.sweepStale();let o=new Mc(e,i,t,a);this.assemblers.set(e,o),this.completedCallbacks.set(e,n),this.errorCallbacks.set(e,r),this.lastActivity.set(e,Date.now())}sweepStale(){if(this.lastActivity.size===0)return;let t=Date.now();if(t-this.lastSweep<e.SWEEP_INTERVAL_MS)return;this.lastSweep=t;let n=t-e.STALE_TRANSFER_TTL_MS;for(let[e,t]of this.lastActivity)if(t<n){let t=this.errorCallbacks.get(e);this.assemblers.delete(e),this.completedCallbacks.delete(e),this.errorCallbacks.delete(e),this.lastActivity.delete(e),t&&t(Error(`Transfer timed out`))}}processChunk(e){this.sweepStale();let t=this.assemblers.get(e.id);if(!t){console.warn(`Received chunk for unknown transfer: ${e.id}`);return}this.lastActivity.set(e.id,Date.now());try{if(t.addChunk(e)){let n=t.getData(),r=this.completedCallbacks.get(e.id);this.assemblers.delete(e.id),this.completedCallbacks.delete(e.id),this.errorCallbacks.delete(e.id),this.lastActivity.delete(e.id),r&&r(n)}}catch(t){let n=this.errorCallbacks.get(e.id);this.assemblers.delete(e.id),this.completedCallbacks.delete(e.id),this.errorCallbacks.delete(e.id),this.lastActivity.delete(e.id),n&&n(t)}}cancel(e){let t=this.errorCallbacks.get(e);this.assemblers.delete(e),this.completedCallbacks.delete(e),this.errorCallbacks.delete(e),this.lastActivity.delete(e),t&&t(Error(`Transfer cancelled`))}getProgress(e){let t=this.assemblers.get(e);return t?t.getProgress():null}};B();var Pc=Symbol(`rpc:methods`),Fc=Symbol(`rpc:nested`),Ic=Symbol(`rpc:exposeAll`);function Lc(e,t=[],n={},r=new WeakSet){if(!e||typeof e!=`object`||r.has(e))return n;r.add(e);let i=Object.getOwnPropertyNames(e),a=[],o=Object.getPrototypeOf(e);for(;o&&o!==Object.prototype;)a.push(...Object.getOwnPropertyNames(o)),o=Object.getPrototypeOf(o);let s=[...new Set([...i,...a])];for(let r of s)if(!(r===`constructor`||r.startsWith(`_`)||r.startsWith(`#`)))try{if(e.constructor&&Object.prototype.hasOwnProperty.call(e.constructor,r))continue;let i=Object.getOwnPropertyDescriptor(e,r);if(!i){let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype&&!i;)i=Object.getOwnPropertyDescriptor(t,r),t=Object.getPrototypeOf(t)}if(i&&(i.get||i.set)&&!i.value){let i=e[r];if(typeof i==`function`){let a=[...t,r].join(`.`);n[a]=i.bind(e)}continue}let a=e[r],o=[...t,r].join(`.`);typeof a==`function`&&(n[o]=a.bind(e))}catch{}return n}function Rc(e,t=[],n={},r=new WeakSet){if(r.has(e))return n;r.add(e);let i=e.constructor===Object||e.constructor===void 0,a=Object.getPrototypeOf(e),o=Reflect.hasMetadata(Pc,e)||Reflect.hasMetadata(Pc,a)||Reflect.hasMetadata(Fc,e)||Reflect.hasMetadata(Fc,a)||Reflect.hasMetadata(Ic,a);if(i&&!o){let i=Object.getOwnPropertyNames(e);for(let a of i)if(!(a===`constructor`||a.startsWith(`_`)))try{let i=e[a],o=[...t,a].join(`.`);typeof i==`function`?n[o]=i.bind(e):typeof i==`object`&&i&&!Array.isArray(i)?Rc(i,[...t,a],n,r):n[o]=async()=>i}catch{}}else{let i=a&&Reflect.getMetadata(Ic,a),o=[...Reflect.getMetadata(Pc,e)??[],...(a&&Reflect.getMetadata(Pc,a))??[]],s=[...Reflect.getMetadata(Fc,e)??[],...(a&&Reflect.getMetadata(Fc,a))??[]],c=Object.getOwnPropertyNames(e);a&&c.push(...Object.getOwnPropertyNames(a).filter(e=>e!==`constructor`));for(let l of c)if(l!==`constructor`)try{let c=e[l]??a?.[l];if(!c)continue;let u=[...t,l].join(`.`);typeof c==`function`?(i&&!l.startsWith(`_`)||o.includes(l))&&(n[u]=c.bind(e)):o.includes(l)?n[u]=async()=>e[l]:typeof c==`object`&&c&&s.includes(l)&&Rc(c,[...t,l],n,r)}catch{}}return n}var zc=class e extends Error{code;data;constructor(e,t,n){super(t),this.name=`RPCException`,this.code=e,this.data=n}static fromJSON(t){return new e(t.code,t.message,t.data)}toJSON(){return{code:this.code,message:this.message,data:this.data}}};function Bc(e,t,n){return new zc(e,t,n)}var Vc={METHOD_NOT_FOUND:`METHOD_NOT_FOUND`,INVALID_PARAMS:`INVALID_PARAMS`,INTERNAL_ERROR:`INTERNAL_ERROR`,TIMEOUT:`TIMEOUT`,CONNECTION_CLOSED:`CONNECTION_CLOSED`,STREAM_ERROR:`STREAM_ERROR`,PAYLOAD_TOO_LARGE:`PAYLOAD_TOO_LARGE`,NOT_FOUND:`NOT_FOUND`},Hc=Symbol.for(`rpc.callbacks`),Uc=Symbol.for(`rpc.callbacks.oneway`);function Wc(e){return!!e&&typeof e==`object`&&e[Hc]===!0}function Gc(e){return e?.[Uc]??[]}function Kc(e){if(e instanceof Promise)return!0;if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.then==`function`&&typeof t.catch==`function`}function qc(e,t,n=[],r=null,i){let a=r,o=e=>{a??=new Set(e)},s=async(t,n,r)=>{let{result:s,methods:c,timing:l}=await e.callWithMeta(t,n,{discover:a===null,timing:i!==void 0});return c&&o(c),l&&i&&i(r??t,l),s};return new Proxy({},{get(r,o){if(o===`then`||o===`catch`||o===`finally`)return;if(typeof o==`symbol`||o===`toString`)return()=>`[RPCProxy ${t}${n.length?`.`+n.join(`.`):``}]`;if(a&&n.length===0&&!a.has(o))return;let c=[...n,o];return new Proxy(function(){},{apply(n,r,i){let a=c.join(`.`),l=`rpc.${t}.${a}`,u=o.toLowerCase().includes(`pull`),d=i.findIndex(e=>Wc(e));if(d!==-1){let t=i[d],n=Gc(t),r=i.filter((e,t)=>t!==d);return e.callPullIteratorWithCallback(l,t,n,...r)}let f=i.findIndex(e=>typeof e==`function`);if(f!==-1){let t=i[f],n=i.filter((e,t)=>t!==f);return e.callWithCallback(l,n,t)}return o.toLowerCase().includes(`generate`)?e.callStream(l,...i):u?e.callPullIterator(l,...i):s(l,i,a)},get(n,r){if(r===`then`||r===`catch`||r===`finally`){let n=c.join(`.`),i=(async()=>(!e.isConnected&&!e.isClosed&&await e.connect(),s(`rpc.${t}.${n}`,[],n)))();return i[r].bind(i)}return qc(e,t,c,a,i)[r]}})}})}function Jc(e,t,n,r=[]){return new Proxy({},{get(i,a){if(a===`then`||a===`catch`||a===`finally`)return;if(typeof a==`symbol`||a===`toString`)return()=>`[ServiceProxy ${t.name}${r.length?`.`+r.join(`.`):``}]`;if(a in i)return i[a];let o=[...r,a],s=o.join(`.`),c=t.endpoints.find(e=>{if(e.subject===s)return!0;let t=e.subject.split(`.`);return t[t.length-1]===a&&t.slice(0,-1).join(`.`)===r.join(`.`)});if(c)return new Proxy(function(){},{apply(t,n,r){let i=a.toLowerCase().includes(`pull`),o=r.findIndex(e=>Wc(e));if(o!==-1){let t=r[o],n=Gc(t),i=r.filter((e,t)=>t!==o);return e.callPullIteratorWithCallback(c.subject,t,n,...i)}let s=r.findIndex(e=>typeof e==`function`);if(s!==-1){let t=r[s],n=r.filter((e,t)=>t!==s);return e.callWithCallback(c.subject,n,t)}return a.toLowerCase().includes(`generate`)?e.callStream(c.subject,...r):i?e.callPullIterator(c.subject,...r):e.call(c.subject,...r)}});let l=s+`.`;if(t.endpoints.some(e=>e.subject.startsWith(l)))return Jc(e,t,n,o)}})}var Yc=36**4,Xc=Math.floor(Math.random()*36**5).toString(36).padStart(5,`0`),Zc=Math.floor(Math.random()*Yc);function Qc(e){Zc=(Zc+1)%Yc;let t=`${Date.now()}-${Xc}${Zc.toString(36).padStart(4,`0`)}`;return e?`${e}.${t}`:t}function $c(){let e,t=globalThis.crypto;if(t?.getRandomValues){let n=new Uint8Array(6);t.getRandomValues(n),e=n.reduce((e,t)=>e*256+t,0)}else e=Math.floor(Math.random()*2**48);return e.toString(36).padStart(10,`0`)}function el(e){return new Promise(t=>setTimeout(t,e))}function tl(e,t){let n=Promise.resolve(),r=0;return{dispatch:i=>{if(r===0){let a;try{a=e(i)}catch(e){t(e);return}Kc(a)&&(r++,n=a.then(()=>{r--},e=>{r--,t(e)}));return}r++,n=n.then(()=>e(i)).then(()=>{r--},e=>{r--,t(e)})},flush:()=>r===0?Promise.resolve():n}}async function nl(e,t,n,r,i){let a,o=e(...t);if(o&&typeof o.then==`function`){let e=await o;if(e&&typeof e[Symbol.asyncIterator]==`function`)a=e;else if(e&&typeof e[Symbol.iterator]==`function`)a=(async function*(){for(let t of e)yield t})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for stream`)}else if(o&&typeof o[Symbol.asyncIterator]==`function`)a=o;else if(o&&typeof o[Symbol.iterator]==`function`)a=(async function*(){for(let e of o)yield e})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for stream`);let s=!1,c=await i.subscribe(`${n}.cancel`,()=>{s=!0});await el(0);try{for await(let e of a){if(s||!i.isConnected)break;let t={id:r,type:`data`,data:e};await i.publish(n,t)}if(!s&&i.isConnected){let e={id:r,type:`end`};await i.publish(n,e)}}catch(e){if(!s&&i.isConnected)try{let t={id:r,type:`error`,error:il(e)};await i.publish(n,t)}catch{}}finally{if(c(),a.return)try{await a.return()}catch{}}}async function rl(e,t){return e(...Array.isArray(t)?t:t==null?[]:[t])}function il(e){return e instanceof zc?e.toJSON():{code:Vc.INTERNAL_ERROR,message:e instanceof Error?e.message:`Internal error`}}async function al(e,t,n,r,i){let a,o=e(...t);if(o&&typeof o.then==`function`){let e=await o;if(e&&typeof e[Symbol.asyncIterator]==`function`)a=e;else if(e&&typeof e[Symbol.iterator]==`function`)a=(async function*(){for(let t of e)yield t})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for pull iterator`)}else if(o&&typeof o[Symbol.asyncIterator]==`function`)a=o;else if(o&&typeof o[Symbol.iterator]==`function`)a=(async function*(){for(let e of o)yield e})();else throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for pull iterator`);let s=`_rpc.iterator.${n}.request`,c=`_rpc.iterator.${n}.response`,l=!0,u,d=()=>{l&&(l=!1,u?.(),i?.())},f=await r.subscribe(s,async e=>{if(l)try{if(e.type===`cancel`){d(),a.return&&await a.return();let e={id:n,type:`done`};r.tryPublishSync(c,e)||await r.publish(c,e)}else if(e.type===`next`){let{value:e,done:t}=await a.next();if(t){d();let e={id:n,type:`done`};r.tryPublishSync(c,e)||await r.publish(c,e)}else{let t={id:n,type:`value`,value:e};r.tryPublishSync(c,t)||await r.publish(c,t)}}}catch(e){d();let t={id:n,type:`error`,error:il(e)};r.tryPublishSync(c,t)||await r.publish(c,t)}});return u=f,async()=>{if(l=!1,f(),a.return)try{await a.return()}catch{}}}async function ol(e,t,n,r,i,a,o,s){let c=new Set(a),l={},u=!0;for(let e of i)l[e]=c.has(e)?(...t)=>{if(!u||!o.isConnected)return;let n={method:e,args:t};try{o.tryPublishSync(r,n)||o.publish(r,n).catch(()=>{})}catch{}}:()=>{throw Bc(Vc.INTERNAL_ERROR,`Request-reply callback '${e}' not supported in v1`)};let d,f=e(...t,l),p=e=>{if(e&&typeof e[Symbol.asyncIterator]==`function`)return e;if(e&&typeof e[Symbol.iterator]==`function`)return(async function*(){for(let t of e)yield t})();throw Bc(Vc.INTERNAL_ERROR,`Handler must return a generator for pull-callback iterator`)};d=f&&typeof f.then==`function`?p(await f):p(f);let m=`_rpc.iterator.${n}.request`,h=`_rpc.iterator.${n}.response`,g=!0,_,v=()=>{g&&(g=!1,u=!1,_?.(),s?.())},y=await o.subscribe(m,async e=>{if(g)try{if(e.type===`cancel`){v(),d.return&&await d.return();let e={id:n,type:`done`};o.tryPublishSync(h,e)||await o.publish(h,e)}else if(e.type===`next`){let{done:e}=await d.next();if(e){v();let e={id:n,type:`done`};o.tryPublishSync(h,e)||await o.publish(h,e)}else{let e={id:n,type:`value`};o.tryPublishSync(h,e)||await o.publish(h,e)}}}catch(e){v();let t={id:n,type:`error`,error:il(e)};o.tryPublishSync(h,t)||await o.publish(h,t)}});return _=y,async()=>{if(g=!1,u=!1,y(),d.return)try{await d.return()}catch{}}}async function sl(e,t,n,r,i,a){let o=async e=>{if(!i.isConnected)return;let t={id:r,type:`data`,data:e};await i.publish(n,t)},s;try{let n=e(...t,o);n&&typeof n.then==`function`?s=await n:typeof n==`function`&&(s=n)}catch(e){let t={id:r,type:`error`,error:il(e)};throw await i.publish(n,t),e}let c=!1,l=async()=>{c||(c=!0,s&&await s())},u;return u=await i.subscribe(`${n}.cancel`,async()=>{u?.(),a?.(),await l()}),async()=>{u?.(),await l()}}var cl=a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ServiceVerb=e.ServiceError=e.ServiceErrorCodeHeader=e.ServiceErrorHeader=e.ServiceResponseType=void 0,e.ServiceResponseType={STATS:`io.nats.micro.v1.stats_response`,INFO:`io.nats.micro.v1.info_response`,PING:`io.nats.micro.v1.ping_response`},e.ServiceErrorHeader=`Nats-Service-Error`,e.ServiceErrorCodeHeader=`Nats-Service-Error-Code`,e.ServiceError=class t extends Error{code;constructor(e,t){super(t),this.code=e}static isServiceError(e){return t.toServiceError(e)!==null}static toServiceError(n){let r=n?.headers?.get(e.ServiceErrorCodeHeader)||``;if(r!==``){let i=parseInt(r)||400,a=n?.headers?.get(e.ServiceErrorHeader)||``;return new t(i,a.length?a:r)}return null}},e.ServiceVerb={PING:`PING`,STATS:`STATS`,INFO:`INFO`}})),ll=a((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceImpl=t.ServiceGroupImpl=t.ServiceMsgImpl=t.ServiceApiPrefix=void 0;var n=(zo(),e(Ro)),r=cl();function i(e,t=``){if(t===``)throw Error(`${e} name required`);let n=a(t);if(n.length)throw Error(`invalid ${e} name - ${e} name ${n}`)}function a(e=``){if(!e)throw Error(`name required`);let t=/^[-\w]+$/g;if(e.match(t)===null){for(let n of e.split(``))if(n.match(t)===null)return`cannot contain '${n}'`}return``}t.ServiceApiPrefix=`$SRV`;var o=class{msg;constructor(e){this.msg=e}get data(){return this.msg.data}get sid(){return this.msg.sid}get subject(){return this.msg.subject}get reply(){return this.msg.reply||``}get headers(){return this.msg.headers}respond(e,t){return this.msg.respond(e,t)}respondError(e,t,i,a){return a||={},a.headers=a.headers||(0,n.headers)(),a.headers?.set(r.ServiceErrorCodeHeader,`${e}`),a.headers?.set(r.ServiceErrorHeader,t),this.msg.respond(i,a)}json(e){return this.msg.json(e)}string(){return this.msg.string()}};t.ServiceMsgImpl=o;var s=class e{subject;queue;srv;constructor(t,n=``,r=``){n!==``&&l(`service group`,n);let i=``;if(t instanceof u)this.srv=t,i=``;else if(t instanceof e){let e=t;this.srv=e.srv,r===void 0&&(r=e.queue),i=e.subject}else throw Error(`unknown ServiceGroup type`);this.subject=this.calcSubject(i,n),this.queue=r}calcSubject(e,t=``){return t===``?e:e===``?t:`${e}.${t}`}addEndpoint(e=``,t){t||={subject:e};let n=typeof t==`function`?{handler:t,subject:e}:t;i(`endpoint`,e);let{subject:r,handler:a,metadata:o,queue:s}=n;r||=e,s||=this.queue,c(`endpoint subject`,r),r=this.calcSubject(this.subject,r);let l={name:e,subject:r,queue:s,handler:a,metadata:o};return this.srv._addEndpoint(l)}addGroup(t=``,n){return n===void 0&&(n=this.queue),new e(this,t,n)}};t.ServiceGroupImpl=s;function c(e,t){if(t===``)throw Error(`${e} cannot be empty`);if(t.indexOf(` `)!==-1)throw Error(`${e} cannot contain spaces: '${t}'`);let n=t.split(`.`);n.forEach((r,i)=>{if(r===`>`&&i!==n.length-1)throw Error(`${e} cannot have internal '>': '${t}'`)})}function l(e,t){if(t.indexOf(` `)!==-1)throw Error(`${e} cannot contain spaces: '${t}'`);t.split(`.`).forEach(n=>{if(n===`>`)throw Error(`${e} name cannot contain internal '>': '${t}'`)})}var u=class e{nc;_id;config;handlers;internal;_stopped;_done;started;closeListener;static controlSubject(e,n=``,r=``,a){let o=a??t.ServiceApiPrefix;return n===``&&r===``?`${o}.${e}`:(i(`control subject name`,n),r===``?`${o}.${e}.${n}`:(i(`control subject id`,r),`${o}.${e}.${n}.${r}`))}constructor(e,t={name:``,version:``}){this.nc=e,this.config=Object.assign({},t),this.config.queue===void 0&&(this.config.queue=`q`),t.metadata=Object.freeze(t.metadata||{}),i(`name`,this.config.name),this.config.queue&&i(`queue`,this.config.queue),(0,n.parseSemVer)(this.config.version),this._id=n.nuid.next(),this.internal=[],this._done=(0,n.deferred)(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.closeListener={connectionClosedCallback:e=>{this.close(e).catch()}},this.nc.addCloseListener(this.closeListener)}get subjects(){return this.handlers.filter(e=>e.internal===!1).map(e=>e.subject)}get id(){return this._id}get name(){return this.config.name}get description(){return this.config.description??``}get version(){return this.config.version}get metadata(){return this.config.metadata}errorToHeader(e){let t=(0,n.headers)();if(e instanceof r.ServiceError){let n=e;t.set(r.ServiceErrorHeader,n.message),t.set(r.ServiceErrorCodeHeader,`${n.code}`)}else t.set(r.ServiceErrorHeader,e.message),t.set(r.ServiceErrorCodeHeader,`500`);return t}setupHandler(e,t=!1){let r=t?``:e.queue?e.queue:this.config.queue,{name:i,subject:a,handler:s}=e,c=e;c.internal=t,t&&this.internal.push(c),c.stats=new d(i,a,r),c.queue=r;let l=s?(e,t)=>{if(e){this.close(e);return}let r=Date.now();try{s(e,new o(t))}catch(e){c.stats.countError(e),t?.respond(n.Empty,{headers:this.errorToHeader(e)})}finally{c.stats.countLatency(r)}}:void 0;return c.sub=this.nc.subscribe(a,{callback:l,queue:r}),c.sub.closed.then(()=>{this._stopped||this.close(Error(`required subscription ${e.subject} stopped`)).catch()}).catch(t=>{if(!this._stopped){let n=Error(`required subscription ${e.subject} errored: ${t.message}`);n.stack=t.stack,this.close(n).catch()}}),c}info(){return{type:r.ServiceResponseType.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(e=>{let{subject:t,metadata:n,name:r,queue:i}=e;return{subject:t,metadata:n,name:r,queue_group:i}})}async stats(){let e=[];for(let t of this.handlers){if(typeof this.config.statsHandler==`function`)try{t.stats.data=await this.config.statsHandler(t)}catch(e){t.stats.countError(e)}e.push(t.stats.stats(t.qi))}return{type:r.ServiceResponseType.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:e}}addInternalHandler(e,t){let n=`${e}`.toUpperCase();this._doAddInternalHandler(`${n}-all`,e,t),this._doAddInternalHandler(`${n}-kind`,e,t,this.name),this._doAddInternalHandler(`${n}`,e,t,this.name,this.id)}_doAddInternalHandler(t,n,r,i=``,a=``){let o={};o.name=t,o.subject=e.controlSubject(n,i,a),o.handler=r,this.setupHandler(o,!0)}start(){let e=(e,t)=>e?(this.close(e),Promise.reject(e)):this.stats().then(e=>(t?.respond(JSON.stringify(e)),Promise.resolve())),t=(e,t)=>e?(this.close(e),Promise.reject(e)):(t?.respond(JSON.stringify(this.info())),Promise.resolve()),n=JSON.stringify(this.ping());return this.addInternalHandler(r.ServiceVerb.PING,(e,t)=>e?(this.close(e).then().catch(),Promise.reject(e)):(t.respond(n),Promise.resolve())),this.addInternalHandler(r.ServiceVerb.STATS,e),this.addInternalHandler(r.ServiceVerb.INFO,t),this.handlers.forEach(e=>{let{subject:t}=e;typeof t==`string`&&e.handler!==null&&this.setupHandler(e)}),Promise.resolve(this)}close(e){if(this._stopped)return this._done;this._stopped=!0,this.nc.removeCloseListener(this.closeListener);let t=[];return this.nc.isClosed()||(t=this.handlers.concat(this.internal).map(e=>e.sub.drain())),Promise.allSettled(t).then(()=>{this._done.resolve(e||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(e){return this.close(e)}ping(){return{type:r.ServiceResponseType.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(let e of this.handlers)e.stats.reset(e.qi)}addGroup(e,t){return new s(this,e,t)}addEndpoint(e,t){return new s(this).addEndpoint(e,t)}_addEndpoint(e){let t=new n.QueuedIteratorImpl;t.profile=!0,t.noIterator=typeof e.handler==`function`,t.noIterator||(e.handler=(e,n)=>{e?this.stop(e).catch():t.push(new o(n))},t.iterClosed.then(()=>{this.close().catch()}));let r=this.setupHandler(e,!1);return r.sub.closed.then(e=>{e?this.stop(e):t.stop()}),r.qi=t,this.handlers.push(r),t}};t.ServiceImpl=u;var d=class{name;subject;average_processing_time;num_requests;processing_time;num_errors;last_error;data;metadata;queue;constructor(e,t,n=``){this.name=e,this.subject=t,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=n}reset(e){this.num_requests=0,this.processing_time=0,this.average_processing_time=0,this.num_errors=0,this.last_error=void 0,this.data=void 0;let t=e;t&&(t.time=0,t.processed=0)}countLatency(e){this.num_requests++,this.processing_time+=(0,n.nanos)(Date.now()-e),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(e){this.num_errors++,this.last_error=e.message}_stats(){let{name:e,subject:t,average_processing_time:n,num_errors:r,num_requests:i,processing_time:a,last_error:o,data:s,queue:c}=this;return{name:e,subject:t,average_processing_time:n,num_errors:r,num_requests:i,processing_time:a,last_error:o,data:s,queue_group:c}}stats(e){let t=e;return t?.noIterator===!1&&(this.processing_time=(0,n.nanos)(t.time),this.num_requests=t.processed,this.average_processing_time=this.processing_time>0&&this.num_requests>0?this.processing_time/this.num_requests:0),this._stats()}}})),ul=a((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceClientImpl=void 0;var n=(zo(),e(Ro)),r=ll(),i=cl();t.ServiceClientImpl=class{nc;prefix;opts;constructor(e,t={strategy:`stall`,maxWait:2e3},n){this.nc=e,this.prefix=n,this.opts=t}ping(e=``,t=``){return this.q(i.ServiceVerb.PING,e,t)}stats(e=``,t=``){return this.q(i.ServiceVerb.STATS,e,t)}info(e=``,t=``){return this.q(i.ServiceVerb.INFO,e,t)}async q(e,t=``,i=``){let a=new n.QueuedIteratorImpl,o=r.ServiceImpl.controlSubject(e,t,i,this.prefix),s=await this.nc.requestMany(o,n.Empty,this.opts);return(async()=>{for await(let e of s)try{let t=e.json();a.push(t)}catch(e){a.push(()=>{a.stop(e)})}a.push(()=>{a.stop()})})().catch(e=>{a.stop(e)}),a}}})),dl=a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Svcm=e.ServiceVerb=e.ServiceResponseType=e.ServiceErrorHeader=e.ServiceErrorCodeHeader=e.ServiceError=void 0;var t=ll(),n=ul(),r=cl();Object.defineProperty(e,"ServiceError",{enumerable:!0,get:function(){return r.ServiceError}}),Object.defineProperty(e,"ServiceErrorCodeHeader",{enumerable:!0,get:function(){return r.ServiceErrorCodeHeader}}),Object.defineProperty(e,"ServiceErrorHeader",{enumerable:!0,get:function(){return r.ServiceErrorHeader}}),Object.defineProperty(e,"ServiceResponseType",{enumerable:!0,get:function(){return r.ServiceResponseType}}),Object.defineProperty(e,"ServiceVerb",{enumerable:!0,get:function(){return r.ServiceVerb}}),e.Svcm=class{nc;constructor(e){this.nc=e}add(e){try{return new t.ServiceImpl(this.nc,e).start()}catch(e){return Promise.reject(e)}}client(e,t){return new n.ServiceClientImpl(this.nc,e,t)}}})),fl=a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Svcm=e.ServiceVerb=e.ServiceResponseType=e.ServiceErrorHeader=e.ServiceErrorCodeHeader=e.ServiceError=void 0;var t=dl();Object.defineProperty(e,"ServiceError",{enumerable:!0,get:function(){return t.ServiceError}}),Object.defineProperty(e,"ServiceErrorCodeHeader",{enumerable:!0,get:function(){return t.ServiceErrorCodeHeader}}),Object.defineProperty(e,"ServiceErrorHeader",{enumerable:!0,get:function(){return t.ServiceErrorHeader}}),Object.defineProperty(e,"ServiceResponseType",{enumerable:!0,get:function(){return t.ServiceResponseType}}),Object.defineProperty(e,"ServiceVerb",{enumerable:!0,get:function(){return t.ServiceVerb}}),Object.defineProperty(e,"Svcm",{enumerable:!0,get:function(){return t.Svcm}})}))(),pl=class{client;svc;services=[];nc;constructor(e){this.client=e}init(e){this.nc!==e&&(this.nc=e,this.svc=new fl.Svcm(e),this.services=[])}async registerHandler(e,t,n){if(!this.svc)throw Error(`RPCService is not initialized. Call init() first.`);let r=new Map,i=this.client,a=this.svc;if(n?.isolatedConnection){i=this.client.createIsolatedClient({...this.client.options,name:`${this.client.options.name}-service-${e.name}`});let t=await i.connect();a=new fl.Svcm(t)}let o=await a.add(e);this.services.push(o),n?.isolatedConnection&&(o._isolatedClient=i);let s=Rc(t),c=new Map;for(let[e,t]of Object.entries(s)){let n=e.split(`.`),a=n.pop(),s=o;if(n.length>0){let e=n.join(`.`);if(!c.has(e)){let t=o;for(let e of n)t=t.addGroup(e);c.set(e,t)}s=c.get(e)}s.addEndpoint(a,async(e,n)=>{if(e){n.respondError(500,e.message);return}try{let e=n.headers?.get(`x-chunked-transfer`);if(e===`header`){let e=_c(n.data),t=n.headers?.get(`x-chunk-id`);if(!t||e.transferId!==t){console.error(`Invalid chunk header`);return}i.chunkingManager.startReceiving(e.transferId,e.totalChunks,async e=>{await o(e,n)},e=>{console.error(`Error assembling chunks for ${a}:`,e)},e.totalSize,e.chunkSize)}else if(e===`chunk`){let e=n.headers?.get(`x-chunk-id`),t=parseInt(n.headers?.get(`x-chunk-index`)??`0`);if(!e){console.error(`Chunk missing chunk ID`);return}i.chunkingManager.processChunk({id:e,chunkIndex:t,data:n.data,isLast:!1})}else await o(Ac(n.data),n)}catch(e){console.error(`Error processing message for ${a}:`,e)}async function o(e,n){let a={id:e.id};try{if(e.params?.__stream&&e.params?.__streamSubject){let n=e.params.__streamSubject,r=e.params.args??[];await nl(t,r,n,e.id,i)}else if(e.params?.__pullIterator||Array.isArray(e.params)&&e.params[0]?.__pullIterator){let o=e.params?.__pullIterator?e.params:e.params[0],s=o.args??[],c=o.__iteratorId??e.id,l=await al(t,s,c,i,()=>r.delete(c));r.set(c,l),a.result={iteratorId:c};let u=`${n.subject}.reply.${e.id}`;await i.publish(u,a)}else{a.result=await rl(t,e.params);let r=`${n.subject}.reply.${e.id}`;await i.publish(r,a)}}catch(t){a.error=il(t);try{let t=`${n.subject}.reply.${e.id}`;await i.publish(t,a)}catch(e){if(i.isClosed)return;console.error(`Failed to send error response:`,e)}}}})}let l=o;l._pullIteratorCleanups=r;let u=o.stop.bind(o);return o.stop=async e=>(await Promise.allSettled(Array.from(r.values()).map(e=>e())),r.clear(),u(e)),new ml(o)}monitor(){if(!this.svc)throw Error(`RPCService is not initialized. Call init() first.`);return this.svc.client({strategy:`stall`,stall:10,maxWait:2e3})}async stopAll(){await Promise.allSettled(this.services.map(async e=>{await e.stop();let t=e._isolatedClient;t&&await t.disconnect()})),this.services=[]}async stop(e){let t=this.services.find(t=>t.info().name===e);if(t)try{await t.stop();let e=t._isolatedClient;e&&await e.disconnect(),this.services=this.services.filter(e=>e!==t)}catch{}}getAllInfo(){return this.services.map(e=>e.info())}getInfo(e){return this.services.find(t=>t.info().name===e)?.info()}async getAllStats(){return Promise.all(this.services.map(e=>e.stats()))}async getStats(e){return this.services.find(t=>t.info().name===e)?.stats()}},ml=class{natsService;get isStopped(){return this.natsService.isStopped}constructor(e){this.natsService=e}info(){return this.natsService.info()}stats(){return this.natsService.stats()}async stop(e){try{await this.natsService.stop(e)}catch{}}};Lo(),Zr(),Sr(),da();function hl(e){return new _l(e)}function gl(e){return qr(e?`_INBOX.${e}`:void 0)}var _l=class e{options;service=new pl(this);chunkingManager=new Nc;pullIteratorCleanups=new Map;callbackCleanups=new Map;nc;subscriptionSeq=0;subscriptionEntries=new Map;pullIteratorSettles=new Set;replyPrefix;muxEntry;statusHandlers=new Map;_maxPayloadSize=1048576;connectionPromise;closed=!1;isolatedClients=[];pendingRequests=new Map;streamHandlers=new Map;get isConnected(){return this.nc?.isClosed()===!1}get isStale(){return this.nc?.isStale?.()??!1}get isClosed(){return this.closed}get maxPayloadSize(){return this._maxPayloadSize}status(){return this.nc?.status()}async flush(e=5e3){if(!this.nc)throw Bc(Vc.CONNECTION_CLOSED,`Not connected`);let t;try{await Promise.race([this.nc.flush(),new Promise((n,r)=>{t=setTimeout(()=>r(Bc(Vc.TIMEOUT,`flush() timed out after ${e}ms`)),e)})])}finally{t&&clearTimeout(t)}}constructor(e){this.options=e,this.replyPrefix=e.connId??$c()}createIsolatedClient(t){return new e(t)}async connect(e){if(e?.signal?.aborted)throw new DOMException(`Aborted`,`AbortError`);if(this.nc&&!this.nc.isClosed())return this.nc;let t={servers:this.options.servers,user:this.options.auth?.user,pass:this.options.auth?.password,name:this.options.name,inboxPrefix:this.options.connId?`_INBOX.${this.options.connId}`:void 0,reconnect:this.options.reconnect??!0,timeout:this.options.connectTimeout??1e4,maxPingOut:this.options.maxPingOut??2,maxReconnectAttempts:this.options.maxReconnectAttempts??-1,reconnectTimeWait:this.options.reconnectTimeWait??2e3,reconnectJitter:this.options.reconnectJitter??100,reconnectJitterTLS:this.options.reconnectJitterTLS??1e3,ignoreAuthErrorAbort:this.options.ignoreAuthErrorAbort??!1,pingInterval:this.options.pingInterval??12e4,pingTimeout:this.options.pingTimeout??0,reconnectionDelayMax:this.options.reconnectionDelayMax??0,reconnectionRandomizationFactor:this.options.reconnectionRandomizationFactor??0,tls:this.options.tls,debug:this.options.debug??!1,noAsyncTraces:!0,waitOnFirstConnect:this.options.waitOnFirstConnect??!0,signal:e?.signal};this.connectionPromise??=No(t);let n=this.connectionPromise;try{this.nc=await vl(n,e?.signal)}finally{this.connectionPromise=void 0}this.closed=!1,this.service.init(this.nc);try{let e=this.nc.info;this._maxPayloadSize=e?.max_payload??this.options.maxPayloadSize??1048576}catch{this._maxPayloadSize=this.options.maxPayloadSize??1048576}this._maxPayloadSize-=8192,this.ensureMuxSubscription(!1);for(let e of this.subscriptionEntries.values())(!e.sub||e.sub.isClosed())&&this.natsSubscribe(e);return this.nc}async disconnect(){this.closed=!0;for(let[,e]of this.pendingRequests)e.timeout&&clearTimeout(e.timeout),e.cleanup?.(),e.reject(Bc(Vc.CONNECTION_CLOSED,`Connection closed`));this.pendingRequests.clear(),this.statusHandlers.clear();for(let[,e]of this.streamHandlers)try{e.end()}catch{}this.streamHandlers.clear(),this.settlePullIterators(),await Promise.allSettled(Array.from(this.pullIteratorCleanups.values()).map(e=>e())),this.pullIteratorCleanups.clear(),await Promise.allSettled(Array.from(this.callbackCleanups.values()).map(e=>e())),this.callbackCleanups.clear();for(let e of this.subscriptionEntries.values())try{e.sub?.unsubscribe()}catch{}if(this.subscriptionEntries.clear(),this.muxEntry=void 0,this.chunkingManager=new Nc,await Promise.allSettled(this.isolatedClients.map(e=>e.disconnect())),this.isolatedClients=[],this.nc){try{await this.nc.close()}catch{}try{let e=this.options.disconnectTimeout??2e3;await Promise.race([this.nc.closed(),new Promise(t=>setTimeout(t,e))])}catch{}this.nc=void 0}}reconfigure(e){if(this.nc&&!this.nc.isClosed())throw Error(`Cannot reconfigure while connected. Call suspend() first.`);e.servers!==void 0&&(this.options.servers=e.servers),e.auth!==void 0&&(this.options.auth=e.auth);for(let t of this.isolatedClients)t.reconfigure(e)}setServers(e){this.options.servers=e,this.nc&&!this.nc.isClosed()&&this.nc.setServers(e);for(let t of this.isolatedClients)t.setServers(e)}async forceReconnect(){let e=this.nc;if(!(!e||e.isClosed())){try{typeof e.forceReconnect==`function`?await e.forceReconnect():typeof e.reconnect==`function`&&await e.reconnect()}catch{}await Promise.allSettled(this.isolatedClients.map(e=>e.forceReconnect()))}}abortClose(e){this.closed=!0;for(let[,e]of this.pendingRequests)e.timeout&&clearTimeout(e.timeout),e.cleanup?.(),e.reject(Bc(Vc.CONNECTION_CLOSED,`Connection closed`));this.pendingRequests.clear(),this.statusHandlers.clear();for(let[,e]of this.streamHandlers)try{e.end()}catch{}this.streamHandlers.clear(),this.settlePullIterators();for(let e of this.pullIteratorCleanups.values())try{e()}catch{}this.pullIteratorCleanups.clear();for(let e of this.callbackCleanups.values())try{e()}catch{}this.callbackCleanups.clear();for(let t of this.isolatedClients)try{t.abortClose(e)}catch{}this.isolatedClients=[];let t=this.nc;if(t){try{typeof t.abortClose==`function`?t.abortClose(e):t.close().catch(()=>{})}catch{}this.nc=void 0}}async suspend(){for(let[,e]of this.pendingRequests)e.timeout&&clearTimeout(e.timeout),e.cleanup?.(),e.reject(Bc(Vc.CONNECTION_CLOSED,`Connection closed`));this.pendingRequests.clear(),this.statusHandlers.clear();for(let[,e]of this.streamHandlers)try{e.end()}catch{}this.streamHandlers.clear(),this.settlePullIterators(),await Promise.allSettled(Array.from(this.pullIteratorCleanups.values()).map(e=>e())),this.pullIteratorCleanups.clear(),await Promise.allSettled(Array.from(this.callbackCleanups.values()).map(e=>e())),this.callbackCleanups.clear();for(let e of this.subscriptionEntries.values()){try{e.sub?.unsubscribe()}catch{}e.sub=void 0}if(this.chunkingManager=new Nc,await Promise.allSettled(this.isolatedClients.map(e=>e.suspend())),this.nc){try{await this.nc.close()}catch{}try{let e=this.options.disconnectTimeout??2e3;await Promise.race([this.nc.closed(),new Promise(t=>setTimeout(t,e))])}catch{}this.nc=void 0}this.connectionPromise=void 0}async publish(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=kc(t);if(r.length<=this._maxPayloadSize){this.nc.publish(e,r,n);return}let i=Qc(),a={type:`chunked`,transferId:i,totalChunks:Math.ceil(r.length/this._maxPayloadSize),totalSize:r.length,chunkSize:this._maxPayloadSize},o=n?.headers??ca();o.set(`x-chunked-transfer`,`header`),o.set(`x-chunk-id`,i),this.nc.publish(e,gc(a),{headers:o,reply:n?.reply});let s=0;for(let t of jc(r,i,this._maxPayloadSize)){let r=ca();r.set(`x-chunked-transfer`,`chunk`),r.set(`x-chunk-id`,i),r.set(`x-chunk-index`,s.toString()),this.nc.publish(e,t.data,{headers:r,reply:n?.reply}),s>0&&s%50==0&&await el(0),s++}}tryPublishSync(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=kc(t);return r.length>this._maxPayloadSize?!1:(this.nc.publish(e,r,n),!0)}async subscribe(e,t,n){let{unsubscribe:r}=await this.subscribeEntry(e,t,n);return r}async subscribeEntry(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=++this.subscriptionSeq,i={pattern:e,handler:t,options:n};return this.subscriptionEntries.set(r,i),this.natsSubscribe(i),{entry:i,unsubscribe:()=>{try{i.sub?.unsubscribe()}catch{}finally{this.subscriptionEntries.delete(r)}}}}natsSubscribe(e){let{pattern:t}=e;if(e.raw){e.sub=this.nc.subscribe(t,{callback:(n,r)=>{if(n){console.error(`Subscription error for ${t}:`,n);return}try{e.handler(r)}catch(e){console.error(`Error processing message for ${t}:`,e)}}});return}let n=tl(e.handler,e=>console.error(`Error in handler for ${t}:`,e)),r=n.dispatch;e.flush=n.flush;let i=(e,n)=>{if(e){console.error(`Subscription error for ${t}:`,e);return}try{let e=n.headers?.get(`x-chunked-transfer`);if(e===`header`){let e=_c(n.data),i=n.headers?.get(`x-chunk-id`);if(!i||e.transferId!==i){console.error(`Invalid chunk header`);return}this.chunkingManager.startReceiving(e.transferId,e.totalChunks,e=>{r(e)},e=>{console.error(`Error assembling chunks for ${t}:`,e)},e.totalSize,e.chunkSize)}else if(e===`chunk`){let e=n.headers?.get(`x-chunk-id`),t=parseInt(n.headers?.get(`x-chunk-index`)??`0`);if(!e){console.error(`Chunk missing chunk ID`);return}this.chunkingManager.processChunk({id:e,chunkIndex:t,data:n.data,isLast:!1})}else{let e=Ac(n.data);r(e)}}catch(e){console.error(`Error processing message for ${t}:`,e)}};e.sub=this.nc.subscribe(t,{...e.options?.queue?{queue:e.options.queue}:{},callback:i})}ensureMuxSubscription(e=!0){this.muxEntry||(this.muxEntry={pattern:`rpc.reply.${this.replyPrefix}.>`,raw:!0,handler:e=>this.handleMuxMessage(e)},this.subscriptionEntries.set(++this.subscriptionSeq,this.muxEntry)),e&&this.nc&&(!this.muxEntry.sub||this.muxEntry.sub.isClosed())&&this.natsSubscribe(this.muxEntry)}handleMuxMessage(e){if(e.data?.length===0&&e.headers?.code===503){let t=e.subject.slice(10),n=this.statusHandlers.get(t);if(n){this.statusHandlers.delete(t);try{n(new xr.NoRespondersError(t))}catch(e){console.error(`Error in no-responder status handler:`,e)}return}let r=this.pendingRequests.get(t);r&&(this.pendingRequests.delete(t),r.timeout&&clearTimeout(r.timeout),r.reject(new xr.NoRespondersError(r.subject??t)));return}let t=e.headers?.get(`x-chunked-transfer`);if(t===`header`){let t=_c(e.data),n=e.headers?.get(`x-chunk-id`);if(!n||t.transferId!==n){console.error(`Invalid chunk header on reply mux`);return}this.chunkingManager.startReceiving(t.transferId,t.totalChunks,e=>this.routeMuxResponse(e),e=>console.error(`Error assembling chunked RPC response:`,e),t.totalSize,t.chunkSize)}else if(t===`chunk`){let t=e.headers?.get(`x-chunk-id`),n=parseInt(e.headers?.get(`x-chunk-index`)??`0`);if(!t){console.error(`Chunk missing chunk ID on reply mux`);return}this.chunkingManager.processChunk({id:t,chunkIndex:n,data:e.data,isLast:!1})}else this.routeMuxResponse(Ac(e.data))}routeMuxResponse(e){let t=e,n=t?.id;if(!n)return;let r=this.pendingRequests.get(n);r&&(this.pendingRequests.delete(n),r.timeout&&clearTimeout(r.timeout),t.error?r.reject(zc.fromJSON(t.error)):r.resolve({result:t.result,methods:t.__methods,timing:t.__timing}))}settlePullIterators(){for(let e of[...this.pullIteratorSettles])try{e()}catch{}this.pullIteratorSettles.clear()}async request(e,t,n){return this.withNoResponderRetry(()=>this._requestOnce(e,t,n),n?.noResponderRetry)}async _requestOnce(e,t,n){if(!this.nc)throw Error(`Not connected`);let r=n?.timeout??5e3,i=kc(t);try{let t=await this.nc.request(e,i,{timeout:r,headers:n?.headers,noMux:!1});if(t.headers?.get(`Nats-Service-Error-Code`)){let e=t.headers.get(`Nats-Service-Error-Code`)||`500`,n=t.headers.get(`Nats-Service-Error`)||`Service error`,r=null;if(t.data)try{r=Ac(t.data)}catch{}throw Bc(e,n,r)}let a=Ac(t.data);if(a?.error)throw Bc(a.code??Vc.INTERNAL_ERROR,a.error??`Unknown error`,a);return a}catch(t){throw t.code===`503`||t.message?.includes(`no responders`)?Bc(Vc.NOT_FOUND,`No responders available`):t.code===`TIMEOUT`||t.message?.includes(`timeout`)?Bc(Vc.TIMEOUT,`Request to "${e}" timed out after ${r}ms`):t}}async withNoResponderRetry(e,t){let n=t?.maxRetries??this.options.noResponderRetry?.maxRetries??3,r=t?.delays??this.options.noResponderRetry?.delays??[500,1e3,2e3];for(let t=0;;t++)try{return await e()}catch(e){if(!(e instanceof xr.NoRespondersError||e instanceof zc&&e.code===Vc.NOT_FOUND)||t>=n||this.closed)throw e;let i=r[Math.min(t,r.length-1)];await el(i)}}async call(e,...t){let{result:n}=await this.withNoResponderRetry(()=>this._callOnce(e,t));return n}async callWithMeta(e,t=[],n){let r=n?.timing===!0?Date.now():0,{result:i,methods:a,timing:o}=await this.withNoResponderRetry(()=>this._callOnce(e,t,n?.discover===!0,n?.timing===!0));if(!r||!o)return{result:i,methods:a};let s=Date.now()-r,c=Math.max(0,o.end-o.start);return{result:i,methods:a,timing:{totalMs:s,handlerMs:c,transportMs:Math.max(0,s-c)}}}async _callOnce(e,t,n=!1,r=!1){if(!this.isConnected&&!this.isClosed&&await this.connect(),!this.nc)throw Error(`Not connected`);if(!e.startsWith(`rpc.`))return this._callOnceService(e,t);this.ensureMuxSubscription();let i=Qc(this.replyPrefix),a=this.options.timeout??3e4,o=`rpc.reply.${i}`;return new Promise((s,c)=>{let l=setTimeout(()=>{this.pendingRequests.delete(i)&&c(Bc(Vc.TIMEOUT,`RPC call to "${e}" timed out after ${a}ms`))},a);this.pendingRequests.set(i,{resolve:s,reject:c,timeout:l,subject:e,cleanup:()=>{clearTimeout(l),this.pendingRequests.delete(i)}});let u={id:i,method:`call`,params:t};n&&(u.__discover=!0),r&&(u.__timing=!0),this.publish(e,u,{reply:o}).catch(e=>{this.pendingRequests.delete(i)&&(clearTimeout(l),c(e))})})}async _callOnceService(e,t){let n=Qc(this.replyPrefix),r=this.options.timeout??3e4,i=`${e}.reply.${n}`;return new Promise(async(a,o)=>{let s,c,l=async()=>{if(this.pendingRequests.has(n)){let e=this.pendingRequests.get(n);e?.timeout&&clearTimeout(e.timeout),this.pendingRequests.delete(n)}if(s&&!s.isClosed())try{s.unsubscribe()}catch{}c?.()},u=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),l(),o(Bc(Vc.TIMEOUT,`RPC call to "${e}" timed out after ${r}ms`)))},r);this.pendingRequests.set(n,{resolve:a,reject:o,timeout:u,cleanup:()=>l()});let d=async e=>{let t=e;if(t.id===n){let e=this.pendingRequests.get(t.id);e&&(this.pendingRequests.delete(t.id),e.timeout&&clearTimeout(e.timeout),await l(),t.error?e.reject(zc.fromJSON(t.error)):e.resolve({result:t.result,methods:t.__methods,timing:t.__timing}))}},f=(t,n)=>{n&&n.data?.length===0&&n.headers?.code===503?(o(new xr.NoRespondersError(e)),l()):t&&(o(t),l())};try{c=await this.subscribe(i,d);let r=gl(this.options.connId);s=this.nc.subscribe(r,{max:1,callback:f});let a={id:n,method:`call`,params:t};await this.publish(e,a,{reply:r})}catch(e){await l(),o(e)}})}async*callStream(e,...t){let n=this.options.noResponderRetry?.maxRetries??3,r=this.options.noResponderRetry?.delays??[500,1e3,2e3];for(let i=0;;i++)try{yield*this._callStreamOnce(e,...t);return}catch(e){if(!(e instanceof xr.NoRespondersError||e instanceof zc&&e.code===Vc.NOT_FOUND)||i>=n||this.closed)throw e;await el(r[Math.min(i,r.length-1)])}}_callStreamOnce(e,...t){let n=this,r=!1,i=!1,a=!1,o=!1,s=null,c=``,l=``,u,d=[],f=null,p=()=>{let e=f;e&&(f=null,e({value:void 0,done:!0}))},m={push:e=>{if(!o){if(f){let t=f;f=null,t({value:e,done:!1})}else d.push(e)}},end:()=>{o=!0,p()},error:e=>{s=e,o=!0,p()}},h=async()=>{if(!a&&(a=!0,n.streamHandlers.delete(c),n.statusHandlers.delete(c),u?.(),!o)){o=!0;try{await n.publish(`${l}.cancel`,{id:c})}catch{}}},g=async e=>{if(e.id!==c)return;let t=n.streamHandlers.get(e.id);if(t)switch(e.type){case`data`:t.push(e.data);break;case`end`:t.end(),await h();break;case`error`:t.error(zc.fromJSON(e.error)),await h()}},_=async()=>{if(!n.isConnected&&!n.isClosed&&await n.connect(),!n.nc)throw Error(`Not connected`);n.ensureMuxSubscription(),c=Qc(n.replyPrefix),l=`stream.${e}.${c}`,n.streamHandlers.set(c,m),u=await n.subscribe(l,g),n.statusHandlers.set(c,()=>{n.streamHandlers.get(c)?.error(new xr.NoRespondersError(e)),h()});let r={id:c,method:`stream`,params:{__stream:!0,__streamSubject:l,args:t}};await n.publish(e,r,{reply:`rpc.reply.${c}`})},v={async next(){if(i)return{value:void 0,done:!0};if(!r){r=!0;try{await _()}catch(e){throw await h(),e}if(i)return await h(),{value:void 0,done:!0}}if(s)throw await h(),s;if(d.length>0)return{value:d.shift(),done:!1};if(o)return await h(),{value:void 0,done:!0};let e=await new Promise((e,t)=>{if(i){e({value:void 0,done:!0});return}if(o){e({value:void 0,done:!0});return}if(s){t(s);return}f=e});if(i)return await h(),{value:void 0,done:!0};if(e.done){if(s)throw await h(),s;return await h(),{value:void 0,done:!0}}return{value:e.value,done:!1}},async return(e){return i?{value:e,done:!0}:(i=!0,p(),r&&await h(),{value:e,done:!0})},async throw(e){throw i?e:(i=!0,p(),r&&await h(),e)},[Symbol.asyncIterator](){return v},async[Symbol.asyncDispose](){await v.return()}};return v}callPullIterator(e,...t){let n=this,r=!1,i=!1,a=!1,o=!1,s=null,c=``,l=``,u=``,d=``,f,p=[],m=null,h=()=>{let e=m;e&&(m=null,e({id:c,type:`done`}))},g=()=>{o||(o=!0,s=Bc(Vc.CONNECTION_CLOSED,`Connection closed`));let e=m;e&&(m=null,e(s?{id:c,type:`error`,error:s.toJSON?.()??{code:Vc.CONNECTION_CLOSED,message:`Connection closed`}}:{id:c,type:`done`}))},_=async()=>{if(!a&&(a=!0,n.pullIteratorSettles.delete(g),n.statusHandlers.delete(c),f?.(),!o)){o=!0;try{let e={id:c,type:`cancel`};await n.publish(l,e)}catch{}}},v=async()=>{if(!n.isConnected&&!n.isClosed&&await n.connect(),!n.nc)throw Error(`Not connected`);if(n.ensureMuxSubscription(),n.pullIteratorSettles.add(g),c=Qc(n.replyPrefix),l=`_rpc.iterator.${c}.request`,u=`_rpc.iterator.${c}.response`,d=`rpc.reply.${c}`,(await n.call(e,{__pullIterator:!0,__iteratorId:c,args:t}))?.iteratorId!==c)throw Error(`Failed to initialize pull iterator`);f=await n.subscribe(u,e=>{if(e.type===`error`?(s=zc.fromJSON(e.error),o=!0):e.type===`done`&&(o=!0),m){let t=m;m=null,t(e)}else p.push(e)}),n.statusHandlers.set(c,()=>{let t=new xr.NoRespondersError(e);o=!0,s=Bc(`503`,t.message);let n={type:`error`,id:c,error:s.toJSON()};if(m){let e=m;m=null,e(n)}else p.push(n)})},y={async next(){if(i)return{value:void 0,done:!0};if(!r){r=!0;try{await v()}catch(e){throw await _(),e}if(i)return await _(),{value:void 0,done:!0}}let e={id:c,type:`next`};try{await n.publish(l,e,{reply:d})}catch(e){throw await _(),e}let t=await new Promise((e,t)=>{if(i){e({id:c,type:`done`});return}p.length>0?e(p.shift()):o&&s?t(s):o?e({id:c,type:`done`}):m=e});if(i)return await _(),{value:void 0,done:!0};if(t.type===`error`)throw await _(),zc.fromJSON(t.error);return t.type===`done`?(await _(),{value:void 0,done:!0}):{value:t.value,done:!1}},async return(e){return i?{value:e,done:!0}:(i=!0,h(),r&&await _(),{value:e,done:!0})},async throw(e){throw i?e:(i=!0,h(),r&&await _(),e)},[Symbol.asyncIterator](){return y},async[Symbol.asyncDispose](){await y.return()}};return y}callPullIteratorWithCallback(e,t,n,...r){let i=Array.isArray(n)?void 0:n,a=Array.isArray(n)?n:n.onewayMethods,o=i?.prefetch??!1,s=this,c=!1,l=!1,u=!1,d=!1,f=null,p=``,m=``,h=``,g=``,_=``,v,y,b,x=[],S=null,C=Promise.resolve(),w=!1,T=()=>{let e=S;e&&(S=null,e({id:p,type:`done`}))},E=()=>{d||(d=!0,f=Bc(Vc.CONNECTION_CLOSED,`Connection closed`));let e=S;e&&(S=null,e(f?{id:p,type:`error`,error:f.toJSON?.()??{code:Vc.CONNECTION_CLOSED,message:`Connection closed`}}:{id:p,type:`done`}))},D=async()=>{if(!u&&(u=!0,s.pullIteratorSettles.delete(E),s.statusHandlers.delete(p),v?.(),b?.(),!d)){d=!0;try{let e={id:p,type:`cancel`};await s.publish(m,e)}catch{}}},O=async()=>{if(!s.isConnected&&!s.isClosed&&await s.connect(),!s.nc)throw Error(`Not connected`);s.ensureMuxSubscription(),s.pullIteratorSettles.add(E),p=Qc(s.replyPrefix),m=`_rpc.iterator.${p}.request`,h=`_rpc.iterator.${p}.response`,g=`_rpc.cb.${p}`,_=`rpc.reply.${p}`;let n=Object.keys(t).filter(e=>typeof t[e]==`function`),i=await s.subscribeEntry(g,e=>{let n=t[e.method];if(!n){console.error(`[rpc] Pull-callback: unknown method '${e.method}'`);return}C=C.then(async()=>{try{await n(...e.args??[])}catch(t){console.error(`[rpc] Pull-callback handler '${e.method}' threw:`,t)}})});v=i.unsubscribe,y=()=>i.entry.flush?.()??Promise.resolve();let o={__pullCallback:!0,__iteratorId:p,__callbackSubject:g,__callbackMethods:n,__onewayMethods:a,args:r},c;try{c=await s.call(e,o)}catch(e){throw v?.(),v=void 0,e}if(c?.iteratorId!==p)throw v?.(),v=void 0,Error(`Failed to initialize pull-callback iterator`);b=await s.subscribe(h,e=>{if(e.type===`error`?(f=zc.fromJSON(e.error),d=!0):e.type===`done`&&(d=!0),S){let t=S;S=null,t(e)}else x.push(e)}),s.statusHandlers.set(p,()=>{let t=new xr.NoRespondersError(e);d=!0,f=Bc(`503`,t.message);let n={type:`error`,id:p,error:f.toJSON()};if(S){let e=S;S=null,e(n)}else x.push(n)})},k={async next(){if(l)return{value:void 0,done:!0};if(!c){c=!0;try{await O()}catch(e){throw await D(),e}if(l)return await D(),{value:void 0,done:!0}}if(w)w=!1;else{let e={id:p,type:`next`};try{await s.publish(m,e,{reply:_})}catch(e){throw await D(),e}}let e=await new Promise((e,t)=>{if(l){e({id:p,type:`done`});return}x.length>0?e(x.shift()):d&&f?t(f):d?e({id:p,type:`done`}):S=e});if(l)return await D(),{value:void 0,done:!0};if(e.type===`error`)throw await D(),zc.fromJSON(e.error);if(e.type===`done`)return await y?.(),await C,await D(),{value:void 0,done:!0};if(o&&!d&&!l)try{let e={id:p,type:`next`};await s.publish(m,e,{reply:_}),w=!0}catch{w=!1}return await y?.(),await C,{value:void 0,done:!1}},async return(e){return l?{value:e,done:!0}:(l=!0,T(),c&&await D(),{value:e,done:!0})},async throw(e){throw l?e:(l=!0,T(),c&&await D(),e)},[Symbol.asyncIterator](){return k},async[Symbol.asyncDispose](){await k.return()}};return k}async callWithCallback(e,t,n){if(!this.isConnected&&!this.isClosed&&await this.connect(),!this.nc)throw Error(`Not connected`);let r=Qc(this.replyPrefix),i=`rpc.cb.${r}`,a=await this.subscribe(i,async e=>{if(e.type===`data`)try{await n(e.data)}catch(e){console.error(`[rpc] Callback error:`,e)}else e.type===`error`&&console.error(`[rpc] Callback error:`,e.error)}),o={__callback:!0,__callbackSubject:i,args:t};try{await this.call(e,o)}catch(e){throw a(),e}return()=>{this.publish(`${i}.cancel`,{id:r}).catch(()=>{}),a()}}async registerHandler(e,t,n){if(!this.nc&&!n?.isolatedConnection)throw Error(`Not connected`);let r=this;n?.isolatedConnection&&(r=this.createIsolatedClient({...this.options,name:`${this.options.name}-handler-${e}`}),await r.connect(),this.isolatedClients.push(r));let i=[],a=[],o=[],s=n?.withoutDecorators?Lc(t):Rc(t),c=Object.keys(s);for(let[t,l]of Object.entries(s)){let s=`rpc.${e}.${t}`,u=await r.subscribe(s,async e=>{let n={id:e.id};e.__discover===!0&&(n.__methods=c);try{if(e.params?.__stream&&e.params?.__streamSubject){let n=e.params.__streamSubject,i=e.params.args??[];nl(l,i,n,e.id,r).catch(e=>{console.error(`Stream request error for ${t}:`,e)});return}if(e.params?.__pullIterator||Array.isArray(e.params)&&e.params[0]?.__pullIterator){let t=e.params?.__pullIterator?e.params:e.params[0],i=t.args??[],o=t.__iteratorId??e.id,s=await al(l,i,o,r,()=>r.pullIteratorCleanups.delete(o));r.pullIteratorCleanups.set(o,s),a.push(o),n.result={iteratorId:o};let c=`rpc.reply.${e.id}`;await r.publish(c,n)}else if(e.params?.__pullCallback||Array.isArray(e.params)&&e.params[0]?.__pullCallback){let t=e.params?.__pullCallback?e.params:e.params[0],i=t.args??[],o=t.__iteratorId??e.id,s=t.__callbackSubject,c=t.__callbackMethods??[],u=t.__onewayMethods??[],d=await ol(l,i,o,s,c,u,r,()=>r.pullIteratorCleanups.delete(o));r.pullIteratorCleanups.set(o,d),a.push(o),n.result={iteratorId:o};let f=`rpc.reply.${e.id}`;await r.publish(f,n)}else if(e.params&&typeof e.params==`object`&&!Array.isArray(e.params)&&e.params.__callback&&e.params.__callbackSubject||Array.isArray(e.params)&&e.params.length>0&&typeof e.params[0]==`object`&&e.params[0]?.__callback){let t=Array.isArray(e.params)&&e.params[0]?.__callback?e.params[0]:e.params,i=t.__callbackSubject,a=t.args??[],s=await sl(l,a,i,e.id,r,()=>r.callbackCleanups.delete(e.id));r.callbackCleanups.set(e.id,s),o.push(e.id),n.result={ok:!0};let c=`rpc.reply.${e.id}`;await r.publish(c,n)}else{let t=e.__timing===!0,i=t?Date.now():0,a=await rl(l,e.params);t&&(n.__timing={start:i,end:Date.now()}),n.result=a;let o=`rpc.reply.${e.id}`;await r.publish(o,n)}}catch(t){n.error=il(t),n.error.code===Vc.METHOD_NOT_FOUND&&(n.__methods=c);try{let t=`rpc.reply.${e.id}`;await r.publish(t,n)}catch(e){if(r.isClosed)return;console.error(`Failed to send error response:`,e)}}},n?.queue?{queue:n.queue}:void 0);i.push(u)}return async()=>{for(let e of i)e();if(await Promise.allSettled(a.map(e=>{let t=r.pullIteratorCleanups.get(e);return r.pullIteratorCleanups.delete(e),t?t():Promise.resolve()})),await Promise.allSettled(o.map(e=>{let t=r.callbackCleanups.get(e);return r.callbackCleanups.delete(e),t?t():Promise.resolve()})),n?.isolatedConnection){await r.disconnect();let e=this.isolatedClients.indexOf(r);e>=0&&this.isolatedClients.splice(e,1)}}}async onRequest(e,t){if(!this.nc)throw Error(`Not connected`);let n=this.nc.subscribe(e,{callback:(n,r)=>{(async()=>{try{let e=await t(Ac(r.data));if(r.reply){let t=kc(e);r.respond(t)}}catch(t){if(r.reply){let e=kc({error:t instanceof Error?t.message:`Internal error`,code:t instanceof zc?t.code:Vc.INTERNAL_ERROR});r.respond(e)}console.error(`Error in request handler for ${e}:`,t)}})()}});return()=>{n.unsubscribe()}}async channel(e,t){let n;t?.isolatedConnection?(n=this.createIsolatedClient({...this.options,name:`${this.options.name}-channel-${e}`}),this.isolatedClients.push(n),await n.connect()):n=this;let r=new Bo(n,e);return await r.init(),t?.isolatedConnection&&(r._isolatedClient=n),r}async privateChannel(e,t,n){let r;n?.isolatedConnection?(r=this.createIsolatedClient({...this.options,name:`${this.options.name}-private-${e}`}),this.isolatedClients.push(r),await r.connect()):r=this;let i=new Vo(r,e,t);return await i.init(),n?.isolatedConnection&&(i._isolatedClient=r),i}createProxy(e,t){let n;t?.isolatedConnection?(n=this.createIsolatedClient({...this.options,name:`${this.options.name}-proxy-${e}`}),this.isolatedClients.push(n)):n=this;let r=qc(n,e,[],null,t?.onTiming);return t?.isolatedConnection?(r._isolatedClient=n,{proxy:r,close:async()=>{await n.disconnect();let e=this.isolatedClients.indexOf(n);e>=0&&this.isolatedClients.splice(e,1)}}):r}async createServiceProxy(e,t){let n;t?.isolatedConnection?(n=this.createIsolatedClient({...this.options,name:`${this.options.name}-service-${e}`}),this.isolatedClients.push(n),await n.connect()):n=this;let r=n.service.monitor(),i=[];for await(let t of await r.info(e))i.push(t);if(i.length===0){if(t?.isolatedConnection){await n.disconnect();let e=this.isolatedClients.indexOf(n);e>=0&&this.isolatedClients.splice(e,1)}throw Error(`No services found with name: ${e}`)}let a=t?.preferredId?i.find(e=>e.id===t.preferredId)??i[0]:i[0],o=Jc(n,a,t?.timeout);return t?.isolatedConnection?(o._isolatedClient=n,{proxy:o,close:async()=>{await n.disconnect();let e=this.isolatedClients.indexOf(n);e>=0&&this.isolatedClients.splice(e,1)}}):o}};function vl(e,t){return t?t.aborted?(e.then(e=>yl(e)).catch(()=>{}),Promise.reject(new DOMException(`Aborted`,`AbortError`))):new Promise((n,r)=>{let i=!1,a=()=>{i||(i=!0,e.then(e=>yl(e)).catch(()=>{}),r(new DOMException(`Aborted`,`AbortError`)))};t.addEventListener(`abort`,a,{once:!0}),e.then(e=>{if(i){yl(e);return}i=!0,t.removeEventListener(`abort`,a),n(e)},e=>{i||(i=!0,t.removeEventListener(`abort`,a),r(e))})}):e}function yl(e){let t=e;try{typeof t.abortClose==`function`?t.abortClose():e.close().catch(()=>{})}catch{}}var bl={id:`nats`,kind:`persistent`,phaseGating:!0},xl=3e3;function Sl(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();if(e?.getRandomValues){let t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}return`${Date.now()}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`}function Cl(e={}){let t={...bl,...e.spec},n=e.proxyPath??`/api/proxy`,r=e.clientName??`@camera.ui/transport/nats`,i=e.natsUser??`secret`,a=e.natsPassword??`secret`,o=e.reconnectTimeWait??1e3,s=e.reconnectionDelayMax??5e3,c=e.reconnectionRandomizationFactor??.5,l=e.timeout??1e4,u=e.connectTimeout??5e3,d=e.pingInterval??25e3,f=e.pingTimeout??2e4,p=e.maxPingOut??1,m=e.logger,h=e.resolveServers,g=e.resolveRefreshMs??0,_=new an,v=new Set,y=null,b=null,x=null,S={up:!1},C=null,w=!1,T=null,E=0,D=null,O=0,k=!1;function A(e){let t=new URL(e.endpoint.url),r=t.protocol===`https:`?`wss:`:`ws:`,i=t.port||(t.protocol===`https:`?`443`:`80`),a=t.pathname.replace(/\/$/,``),o=new URLSearchParams({token:e.tokens.access});return e.tokens.proxySession&&o.set(`session`,e.tokens.proxySession),T&&o.set(`connId`,T),[`${r}//${t.hostname}:${i}${a}${n}?${o.toString()}`]}async function j(e){let t=A(e);return h?h({target:e,connId:T??``,defaultServers:t}):t}async function M(e){let t=x;if(!(!h||!t||w)&&!(k||Date.now()-O<xl)){k=!0;try{let n=await j(t);b===e&&!w&&e.setServers(n)}catch(e){m?.warn(`server refresh failed: ${wl(e)}`)}finally{k=!1,O=Date.now()}}}function N(){y&&=(clearInterval(y),null)}function P(e){N(),!(!h||g<=0)&&(y=setInterval(()=>M(e),g))}async function F(e){let t=x;if(!b||!t||w)return;m?.debug(`resign (${e})`);let n=++E;te(),N();try{b.abortClose()}catch{}b=null,I(),ee(`signature-expired: ${e}`);try{await B(t,n)}catch{}}function I(){let e=S.up?b:null;for(let t of[...v])try{t(e)}catch{}}function L(){S.up||(S={up:!0},m?.debug(`markUp`),_.emit(`up`,void 0))}function ee(e){!S.up&&S.lastError===e||(S={up:!1,lastError:e},m?.debug(`markDown (${e})`),_.emit(`down`,{reason:e}))}function te(){C?.abort(),C=null}function R(e){te();let t=new AbortController;C=t,(async()=>{let n=e.status();if(n)for await(let r of n){if(t.signal.aborted)break;switch(m?.debug(`status: ${r.type}${`server`in r&&r.server?` server=${String(r.server)}`:``}`),r.type){case`reconnect`:L(),I();break;case`disconnect`:ee(`disconnect`),I(),h&&M(e);break;case`reconnecting`:h&&M(e);break;case`staleConnection`:ee(`staleConnection`),I();break;case`error`:z(r)}}})().catch(()=>{})}function z(e){let t=wl(e.data);if(t.toLowerCase().includes(`permissions violation`)){m?.warn(`permission violation (connection stays up): ${t}`);return}let n=on(typeof e.data==`object`&&e.data!==null?{...e.data,message:t}:t);if(n===`auth-expired`){if(h){F(t);return}_.emit(`auth-error`,{message:t});return}if(n===`forbidden`){m?.warn(`forbidden by server: ${t}`),ee(`forbidden: ${t}`);return}ee(t)}async function B(e,t){m?.debug(`rebuildClient start (epoch=${t})`);let n=Date.now();if(te(),N(),D?.abort(),b){try{b.abortClose()}catch{}b=null,I()}T=Sl();let g;try{g=await j(e)}catch(e){if(w||t!==E)return;let n=wl(e);throw m?.debug(`rebuildClient resolve FAILED: ${n}`),ee(n),e}if(w||t!==E)return;let v=hl({servers:g,name:r,connId:T,auth:{user:i,password:a},reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:o,reconnectionDelayMax:s,reconnectionRandomizationFactor:c,timeout:l,connectTimeout:u,pingInterval:d,pingTimeout:f,maxPingOut:p,ignoreAuthErrorAbort:!0}),y=new AbortController;D=y;try{await v.connect({signal:y.signal})}catch(e){try{v.abortClose()}catch{}if(w||t!==E)return;let r=e instanceof Error?e.message:String(e);throw m?.debug(`rebuildClient connect FAILED after ${Date.now()-n}ms: ${r}`),!h&&on(e instanceof Error?e:r)===`auth-expired`&&_.emit(`auth-error`,{message:r}),ee(r),e}finally{D===y&&(D=null)}if(w||t!==E){try{v.abortClose()}catch{}return}b=v,m?.debug(`rebuildClient connected in ${Date.now()-n}ms`),L(),I(),R(v),P(v)}async function ne(e){if(w)throw Error(`nats-transport disposed`);if(nn(x,e))return;let t=++E,n=rn(x,e);if(x=e,!e){if(te(),N(),D?.abort(),D=null,b){try{b.abortClose()}catch{}b=null,I()}ee(`detached`);return}if(n||!b){try{await B(e,t)}catch(n){throw t===E&&x===e&&(x=null),n}return}let r=b,i=await j(e);b===r&&t===E&&r.setServers(i)}function re(){return S.up&&b?.isStale?{up:!1,lastError:`staleConnection`}:S}function ie(e,t){return _.on(e,t)}async function ae(){if(w=!0,E++,te(),N(),D?.abort(),D=null,b){try{b.abortClose()}catch{}b=null,I()}v.clear(),S={up:!1},_.clear()}function oe(){return S.up?b:null}function se(e){return v.add(e),e(S.up?b:null),()=>v.delete(e)}async function ce(e=5e3){if(!b)throw Error(`nats-transport: no client`);let t=Date.now();try{await b.flush(e),m?.debug(`probeAlive OK in ${Date.now()-t}ms`)}catch(e){throw m?.debug(`probeAlive FAILED after ${Date.now()-t}ms: ${e instanceof Error?e.message:String(e)}`),e}}async function le(){if(!b){m?.debug(`forceReconnect: no client`);return}m?.debug(`forceReconnect: issuing (up=${S.up} stale=${b.isStale})`);let e=Date.now();await b.forceReconnect(),m?.debug(`forceReconnect: returned after ${Date.now()-e}ms (up=${S.up})`)}let ue=null;function de(){return ue||(ue=(async()=>{if(w||!x)return re();if(!b){let e=++E;try{await B(x,e)}catch{}return re()}if(re().up)try{return await ce(3e3),re()}catch{}try{await le()}catch{}return re()})().finally(()=>{ue=null}),ue)}return{spec:t,apply:ne,health:re,on:ie,dispose:ae,getClient:oe,subscribeClient:se,probeAlive:ce,forceReconnect:le,ensureAlive:de}}function wl(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var Tl=3e3,El={id:`socketio`,kind:`persistent`,phaseGating:!0};function Dl(e={}){let t={...El,...e.spec},n=e.path??`/api/socket.io`,r=e.mainNamespace??`/camera.ui`,i=e.reconnection??!0,a=e.reconnectionDelay??1e3,o=e.reconnectionDelayMax??5e3,s=e.timeout??2e4,c=e.logger,l=e.resolveQuery,u=e.resolveRefreshMs??0,f=new an,p=new Map,m=null,h=null,g={},_=null,v=0,y=!1,b={up:!1},x=!1,S=0,C=e.staleAfterMs??6e4,w=0;function T(){w=Date.now()}function E(){return w>0&&Date.now()-w>C}function D(e){let t={token:`Bearer ${e.tokens.access}`};return e.tokens.proxySession&&(t.session=e.tokens.proxySession),t}function O(e){let t={};return e.tokens.proxySession&&(t.session=e.tokens.proxySession),t}async function k(e){let t=O(e);return l?l({target:e,path:te(e),query:t}):t}async function A(){let e=h;if(!(!l||!e||x)&&!(y||Date.now()-v<Tl)){y=!0;try{let t=await k(e);if(h!==e||x)return;g=t;for(let e of p.values())e.io.opts.query=t}catch(e){c?.warn(`query refresh failed: ${e instanceof Error?e.message:String(e)}`)}finally{y=!1,v=Date.now()}}}function j(){_&&=(clearInterval(_),null)}function M(){j(),!(!l||u<=0)&&(_=setInterval(()=>A(),u))}function N(){b.up||(b={up:!0},c?.debug(`markUp`),f.emit(`up`,void 0))}function P(e){!b.up&&b.lastError===e||(b={up:!1,lastError:e},c?.debug(`markDown (${e})`),f.emit(`down`,{reason:e}))}function F(e){return on(e)===`auth-expired`}function I(e){e.on(`connect`,()=>N()),e.on(`disconnect`,e=>{P(e),l&&A()}),e.on(`connect_error`,e=>{let t=e?.message??`connect_error`;if(c?.debug(`connect_error (main): ${t}`),l&&A(),F(t)){f.emit(`auth-error`,{message:t});return}P(t)})}function L(e){e.on(`connect_error`,e=>{let t=e?.message??`connect_error`;F(t)&&f.emit(`auth-error`,{message:t})})}function ee(e){return new URL(e.endpoint.url).origin}function te(e){return`${new URL(e.endpoint.url).pathname.replace(/\/$/,``)}${n}`}function R(e,t){let n=`${ee(t)}${e}`,r=lt(n,{path:te(t),auth:D(t),query:g,reconnection:i,reconnectionDelay:a,reconnectionDelayMax:o,timeout:s,rejectUnauthorized:!1,transports:[`websocket`]});return p.set(e,r),r}async function z(e){j();let t;try{t=await k(e)}catch(e){throw P(e instanceof Error?e.message:String(e)),e}if(h!==e||x)return;B(),g=t,m=new d(ee(e),{path:te(e),autoConnect:!1,reconnection:i,reconnectionDelay:a,reconnectionDelayMax:o,timeout:s,rejectUnauthorized:!1,transports:[`websocket`]});let n=R(r,e);I(n),M(),w=Date.now(),n.io.on(`open`,T),n.io.on(`ping`,T),n.io.on(`packet`,T)}function B(){for(let e of p.values())e.removeAllListeners(),e.disconnect();p.clear(),m&&=(m._close(),null)}function ne(e){let t=D(e);for(let e of p.values())e.auth=t,e.connected||e.connect()}async function re(e){if(x)throw Error(`socketio-transport disposed`);if(nn(h,e))return;let t=rn(h,e);if(h=e,!e){B(),j(),w=0,P(`detached`);return}if(t||!m){let t=++S;try{await z(e)}catch(n){throw t===S&&h===e&&(h=null),n}return}ne(e)}function ie(){return b.up&&E()?{up:!1,lastError:`staleConnection`}:b}function ae(e,t){return f.on(e,t)}async function oe(){x=!0,B(),j(),h=null,b={up:!1},f.clear()}function se(e=r){return p.get(e)??null}function ce(e){if(!h||!m)return null;let t=p.get(e);return t||(t=R(e,h),L(t)),t}function le(){if(!h)return;if(b.up&&E()){c?.debug(`reviveDeadSockets: engine stale — forcing reconnect`),w=Date.now(),p.get(r)?.io.engine?.close();return}let e=D(h),t=0;for(let n of p.values())n.connected||(n.auth=e,n.connect(),t++);c?.debug(`reviveDeadSockets: ${t}/${p.size} reconnecting`)}async function ue(){return x||!h?ie():(l&&await A(),le(),ie())}return{get spec(){return t},get manager(){return m},apply:re,health:ie,on:ae,dispose:oe,socket:se,ensureSocket:ce,reviveDeadSockets:le,ensureAlive:ue}}var Ol={id:`ws`,kind:`per-resource`,phaseGating:!1},kl=4e3,Al=4001,jl=4002,Ml=4003;function Nl(e={}){let t={...Ol,...e.spec},n=e.tokenParam??`token`,r=e.sessionParam??`session`,i=e.webSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0),a=e.resolveUrl,o=e.logger,s=new an,c=new Set,l=new WeakSet,u=null,d={up:!1},f=!1;function p(){if(!i)throw Error(`ws-transport: no WebSocket constructor available; pass webSocketCtor in non-browser environments`);return i}function m(e,t){let i=new URL(e.endpoint.url),a=i.protocol===`https:`?`wss:`:`ws:`,o=i.port||(i.protocol===`https:`?`443`:`80`),s=i.pathname.replace(/\/$/,``),c=new URLSearchParams;for(let[e,n]of Object.entries(t.query??{}))n!=null&&n!==``&&c.set(e,n);return c.set(n,e.tokens.access),e.tokens.proxySession&&c.set(r,e.tokens.proxySession),`${a}//${i.hostname}:${o}${s}${t.path}?${c.toString()}`}function h(e){return on({code:e.code,reason:e.reason})===`auth-expired`}function g(e,t){t.onopen=()=>{if(!(e.disposed||e.ws!==t)){o?.debug(`open ${e.spec.path}`),d.up||(d={up:!0},s.emit(`up`,void 0));for(let t of[...e.listeners.open])t()}},t.onclose=n=>{let r=e.ws===t;if(r&&(e.ws=null,e.url=null),l.has(t)||(l.add(t),!r))return;o?.debug(`close ${e.spec.path} code=${n.code} clean=${n.wasClean}${n.reason?` reason=${n.reason}`:``}`),h(n)&&s.emit(`auth-error`,{message:n.reason||`ws close code ${n.code}`});let i={code:n.code,reason:n.reason,wasClean:n.wasClean};for(let t of[...e.listeners.close])t(i)},t.onmessage=n=>{if(!(e.disposed||e.ws!==t))for(let t of[...e.listeners.message])t(n)},t.onerror=n=>{if(!(e.disposed||e.ws!==t))for(let t of[...e.listeners.error])t(n)}}function _(e,t,n){e.openSeq++;let r=e.ws;if(!r)return;let i=p();if(r.readyState===i.OPEN||r.readyState===i.CONNECTING){try{r.close(t,n)}catch{}return}if(e.ws===r&&(e.ws=null,e.url=null),l.has(r))return;l.add(r);let a={code:t,reason:n,wasClean:!1};for(let t of[...e.listeners.close])t(a)}function v(e,t){let n=new(p())(t,e.spec.protocols);e.spec.binaryType&&(n.binaryType=e.spec.binaryType),e.ws=n,e.url=t,g(e,n)}function y(e){if(e.disposed||!u)return;let t=u,n=m(t,e.spec);if(!a){v(e,n);return}let r=++e.openSeq;a({target:t,spec:e.spec,defaultUrl:n}).then(n=>{e.disposed||r!==e.openSeq||u!==t||v(e,n)},t=>{if(e.disposed||r!==e.openSeq)return;let n=t instanceof Error?t.message:String(t);o?.warn(`resolveUrl failed for ${e.spec.path}: ${n}`);let i={code:Ml,reason:`resolve-failed`,wasClean:!1};for(let t of[...e.listeners.close])t(i)})}function b(e,t){let n=[...c];o?.debug(`recycleAll (${t}) handles=${n.length}`);for(let r of n)_(r,e,t);if(d.up&&(d={up:!1,lastError:t},s.emit(`down`,{reason:t})),u)for(let e of c)e.disposed||y(e)}async function x(e){if(f)throw Error(`ws-transport disposed`);if(nn(u,e))return;let t=rn(u,e);if(u=e,!e){let e=[...c];for(let t of e)_(t,Al,`detached`);d={up:!1},s.emit(`down`,{reason:`detached`});return}t&&b(kl,`endpoint-changed`)}function S(){return d}function C(e,t){return s.on(e,t)}async function w(){f=!0;let e=[...c];for(let t of e)t.disposed=!0,t.listeners.open.clear(),t.listeners.close.clear(),t.listeners.message.clear(),t.listeners.error.clear(),_(t,jl,`disposed`);c.clear(),u=null,d={up:!1},s.clear()}function T(e){if(f)throw Error(`ws-transport disposed`);let t={api:void 0,spec:e,listeners:{open:new Set,close:new Set,message:new Set,error:new Set},ws:null,url:null,disposed:!1,openSeq:0};function n(e){if(t.disposed)throw Error(`ws-handle disposed`);let n=t.ws;if(!n)throw Error(`ws-handle: no active socket`);if(n.readyState!==i.OPEN)throw Error(`ws-handle: socket not open`);n.send(e)}function r(e,n){_(t,e??1e3,n??``)}function a(e,n){let r=t.listeners[e];return r.add(n),()=>{r.delete(n)}}function o(){t.disposed||(t.disposed=!0,t.listeners.open.clear(),t.listeners.close.clear(),t.listeners.message.clear(),t.listeners.error.clear(),_(t,jl,`disposed`),c.delete(t))}return t.api={get readyState(){return t.ws?.readyState??i?.CLOSED??3},get url(){return t.url},send:n,close:r,on:a,dispose:o},c.add(t),u&&y(t),t.api}return{get spec(){return t},get handleCount(){return c.size},apply:x,health:S,on:C,dispose:w,open:T}}function Pl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Fl(e){let t=e.url??``,n=e.baseURL??``;return n&&!Pl(t)?`${n.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`:t}function Il(e){let t;try{t=new URL(e).hostname}catch{return!1}return!t||t===`localhost`||t.endsWith(`.local`)||t.includes(`:`)||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t)?!1:t.includes(`.`)}function Ll(e){return!e.withCredentials&&Il(Fl(e))}function Rl(e){return async t=>{Bl(t.signal);let n=Hl(t.headers);e.extraHeaders&&Object.assign(n,e.extraHeaders);let r=typeof t.timeout==`number`&&t.timeout>0?t.timeout:void 0,i=e.request({url:Fl(t),method:(t.method??`get`).toUpperCase(),headers:n,params:Ul(t.params),data:Wl(t),responseType:Gl(t.responseType),connectTimeout:r,readTimeout:r}),a;try{a=await Vl(i,t.signal)}catch(e){throw e instanceof re?e:new b(e instanceof Error?e.message:`Network Error`,b.ERR_NETWORK,t,i)}let o={data:a.data,status:a.status,statusText:``,headers:R.from(a.headers??{}),config:t,request:i};if(!t.validateStatus||t.validateStatus(a.status))return o;throw new b(`Request failed with status code ${a.status}`,a.status>=500?b.ERR_BAD_RESPONSE:b.ERR_BAD_REQUEST,t,i,o)}}function zl(e,t){if(!t.enabled)return;let n=y.getAdapter(e.defaults.adapter??y.defaults.adapter),r=Rl(t);e.defaults.adapter=e=>Ll(e)?r(e):n(e)}function Bl(e){if(e?.aborted)throw new re(`canceled`)}function Vl(e,t){return!t||typeof t.addEventListener!=`function`?e:t.aborted?Promise.reject(new re(`canceled`)):new Promise((n,r)=>{let i=()=>r(new re(`canceled`));t.addEventListener(`abort`,i,{once:!0});let a=()=>t.removeEventListener?.(`abort`,i);e.then(e=>{a(),n(e)},e=>{a(),r(e)})})}function Hl(e){let t={};if(!e)return t;let n=R.from(e).toJSON();for(let[e,r]of Object.entries(n))r!=null&&(t[e]=Array.isArray(r)?r.join(`, `):String(r));return t}function Ul(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=String(r));return t}function Wl(e){let t=e.data;if(t!=null){if(typeof t!=`string`)return t;if(String(R.from(e.headers).get(`Content-Type`)??``).includes(`application/json`))try{return JSON.parse(t)}catch{}return t}}function Gl(e){switch(e){case`blob`:return`blob`;case`arraybuffer`:return`arraybuffer`;default:return`text`}}function Kl(e={}){function t(e){return typeof e==`function`}let n=t(e)?{mounted:e,updated:e}:e,{mounted:r,unmounted:i}=n;if(!t(r))return e;let a=new WeakMap;return{...n,mounted(e,t,n,i){let o=a.get(e)??F();a.set(e,o),o.run(()=>{r?.(e,t,n,i)})},unmounted(e,n,r,o){var s;(s=a.get(e))==null||s.stop(),a.delete(e),t(i)&&i(e,n,r,o)}}}function ql(e,t){return s()?(Ae(e,t),!0):!1}var Jl=new WeakMap,Yl=(...e)=>{let t=e[0],n=Oe()?.proxy??s();if(n==null&&!et())throw Error(`injectLocal must be called in setup`);return n&&Jl.has(n)&&t in Jl.get(n)?Jl.get(n)[t]:ot(...e)},Xl=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var Zl=e=>e!=null,Ql=Object.prototype.toString,$l=e=>Ql.call(e)===`[object Object]`,eu=()=>{},tu=nu();function nu(){var e,t;return Xl&&!!((e=window)!=null&&(e=e.navigator)!=null&&e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window)==null||(t=t.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function ru(...e){if(e.length!==1)return we(...e);let t=e[0];return typeof t==`function`?Ue(ue(()=>({get:t,set:eu}))):q(t)}function iu(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return`cancel`in e&&Object.assign(n,{cancel:e.cancel,flush:e.flush,isPending:e.isPending}),n}var au=e=>e();function ou(e,t={}){let n,r,i=eu,a=eu,o=J(!1),s=e=>{clearTimeout(e),i(),i=eu},c;return Object.assign(l=>{let u=U(e),d=U(t.maxWait);return n&&s(n),u<=0||d!==void 0&&d<=0?(r&&=(s(r),void 0),o.value=!1,Promise.resolve(l())):(o.value=!0,new Promise((e,f)=>{i=t.rejectOnCancel?f:e,a=e,c=l,d&&!r&&(r=setTimeout(()=>{n&&s(n),r=void 0,o.value=!1,e(c())},d)),n=setTimeout(()=>{r&&s(r),r=void 0,o.value=!1,e(l())},u)}))},{cancel:()=>{n&&=(s(n),void 0),r&&=(s(r),void 0),o.value=!1,a=eu},flush:()=>{if(o.value){n&&=(clearTimeout(n),void 0),r&&=(clearTimeout(r),void 0),o.value=!1;let e=a;i=eu,a=eu,e(c())}},isPending:Ie(o)})}function su(...e){let t=0,n,r=!0,i=eu,a,o,s,c,l;!Ve(e[0])&&typeof e[0]==`object`?{delay:o,trailing:s=!0,leading:c=!0,rejectOnCancel:l=!1}=e[0]:[o,s=!0,c=!0,l=!1]=e;let u=()=>{n&&(clearTimeout(n),n=void 0,i(),i=eu)};return e=>{let d=U(o),f=Date.now()-t,p=()=>a=e();return u(),d<=0?(t=Date.now(),p()):(f>d?(t=Date.now(),(c||!r)&&p()):s&&(a=new Promise((e,a)=>{i=l?a:e,n=setTimeout(()=>{t=Date.now(),r=!0,e(p()),u()},Math.max(0,d-f))})),!c&&!n&&(n=setTimeout(()=>r=!0,d)),r=!1,a)}}function cu(e=au,t={}){let{initialState:n=`active`}=t,r=ru(n===`active`);function i(){r.value=!1}function a(){r.value=!0}return{isActive:Ie(r),pause:i,resume:a,eventFilter:(...t)=>{r.value&&e(...t)}}}function lu(e){let t;function n(){return t||=e(),t}return n.reset=async()=>{let e=t;t=void 0,e&&await e},n}function uu(e){return e.endsWith(`rem`)?Number.parseFloat(e)*16:Number.parseFloat(e)}function du(e){return Array.isArray(e)?e:[e]}function fu(e){let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))}var pu=/-(\w)/g,mu=fu(e=>e.replace(pu,(e,t)=>t?t.toUpperCase():``));function hu(e){return e||Oe()}function gu(e){if(!Xl)return e;let t=0,n,r,i=()=>{--t,r&&t<=0&&(r.stop(),n=void 0,r=void 0)};return((...a)=>(t+=1,r||(r=F(!0),n=r.run(()=>e(...a))),ql(i),n))}function _u(e,t,{enumerable:n=!1,unwrap:r=!0}={}){for(let[i,a]of Object.entries(t))i!==`value`&&(Ve(a)&&r?Object.defineProperty(e,i,{get(){return a.value},set(e){a.value=e},enumerable:n}):Object.defineProperty(e,i,{value:a,enumerable:n}));return e}function vu(e,t){if(typeof Symbol<`u`){let n={...e};return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let e=0;return{next:()=>({value:t[e++],done:e>t.length})}}}),n}return Object.assign([...t],e)}function yu(e){return Ve(e)?he(new Proxy({},{get(t,n,r){return V(Reflect.get(e.value,n,r))},set(t,n,r){return Ve(e.value[n])&&!Ve(r)?e.value[n].value=r:e.value[n]=r,!0},deleteProperty(t,n){return Reflect.deleteProperty(e.value,n)},has(t,n){return Reflect.has(e.value,n)},ownKeys(){return Object.keys(e.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}})):he(e)}function bu(e){return yu(G(e))}function xu(e,...t){let n=t.flat(),r=n[0];return bu(()=>Object.fromEntries(typeof r==`function`?Object.entries(Ge(e)).filter(([e,t])=>!r(U(t),e)):Object.entries(Ge(e)).filter(e=>!n.includes(e[0]))))}function Su(e,t=200,n={}){return iu(ou(t,n),e)}function Cu(e,t=200,n=!1,r=!0,i=!1){return iu(su(t,n,r,i),e)}function wu(e,t={}){let n=e,r,i,a=ue((e,t)=>(r=e,i=t,{get(){return o()},set(e){s(e)}}));function o(e=!0){return e&&r(),n}function s(e,r=!0){var a;if(e===n)return;let o=n;t.onBeforeChange?.call(t,e,o)!==!1&&(n=e,(a=t.onChanged)==null||a.call(t,e,o),r&&i())}return _u(a,{get:o,set:s,untrackedGet:()=>o(!1),silentSet:e=>s(e,!1),peek:()=>o(!1),lay:e=>s(e,!1)},{enumerable:!0})}function Tu(e,t,n={}){let{eventFilter:r=au,...i}=n;return C(e,iu(r,t),i)}function Eu(e,t,n={}){let{eventFilter:r,initialState:i=`active`,...a}=n,{eventFilter:o,pause:s,resume:c,isActive:l}=cu(r,{initialState:i});return{stop:Tu(e,t,{...a,eventFilter:o}),pause:s,resume:c,isActive:l}}function Du(e,t={}){if(!Ve(e))return Ge(e);let n=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(let r in e.value)n[r]=ue(()=>({get(){return e.value[r]},set(n){if(U(t.replaceRef)??!0){if(Array.isArray(e.value)){let t=[...e.value];t[r]=n,e.value=t}else{let t={...e.value,[r]:n};Object.setPrototypeOf(t,Object.getPrototypeOf(e.value)),e.value=t}}else e.value[r]=n}}));return n}function Ou(e,t=!0,n){hu(n)?l(e,n):t?e():rt(e)}function ku(e,t){hu(t)&&Me(e,t)}var Au=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i,ju=/[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;function Mu(e,t,n,r){let i=e<12?`AM`:`PM`;return r&&(i=i.split(``).reduce((e,t)=>e+=`${t}.`,``)),n?i.toLowerCase():i}function Nu(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function Pu(e,t,n={}){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=e.getHours(),s=e.getMinutes(),c=e.getSeconds(),l=e.getMilliseconds(),u=e.getDay(),d=n.customMeridiem??Mu,f=e=>e.split(` `)[1]??``,p={Yo:()=>Nu(r),YY:()=>String(r).slice(-2),YYYY:()=>r,M:()=>i+1,Mo:()=>Nu(i+1),MM:()=>`${i+1}`.padStart(2,`0`),MMM:()=>e.toLocaleDateString(U(n.locales),{month:`short`}),MMMM:()=>e.toLocaleDateString(U(n.locales),{month:`long`}),D:()=>String(a),Do:()=>Nu(a),DD:()=>`${a}`.padStart(2,`0`),H:()=>String(o),Ho:()=>Nu(o),HH:()=>`${o}`.padStart(2,`0`),h:()=>`${o%12||12}`.padStart(1,`0`),ho:()=>Nu(o%12||12),hh:()=>`${o%12||12}`.padStart(2,`0`),m:()=>String(s),mo:()=>Nu(s),mm:()=>`${s}`.padStart(2,`0`),s:()=>String(c),so:()=>Nu(c),ss:()=>`${c}`.padStart(2,`0`),SSS:()=>`${l}`.padStart(3,`0`),d:()=>u,dd:()=>e.toLocaleDateString(U(n.locales),{weekday:`narrow`}),ddd:()=>e.toLocaleDateString(U(n.locales),{weekday:`short`}),dddd:()=>e.toLocaleDateString(U(n.locales),{weekday:`long`}),A:()=>d(o,s),AA:()=>d(o,s,!1,!0),a:()=>d(o,s,!0),aa:()=>d(o,s,!0,!0),z:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`shortOffset`})),zz:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`shortOffset`})),zzz:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`shortOffset`})),zzzz:()=>f(e.toLocaleDateString(U(n.locales),{timeZoneName:`longOffset`}))};return t.replace(ju,(e,t)=>t??p[e]?.call(p)??e)}function Fu(e){if(e===null)return new Date(NaN);if(e===void 0)return new Date;if(e instanceof Date)return new Date(e);if(typeof e==`string`&&!/Z$/i.test(e)){let t=e.match(Au);if(t){let e=t[2]-1||0,n=(t[7]||`0`).substring(0,3);return new Date(t[1],e,t[3]||1,t[4]||0,t[5]||0,t[6]||0,n)}}return new Date(e)}function Iu(e,t=`HH:mm:ss`,n={}){return G(()=>Pu(Fu(U(e)),U(t),n))}function Lu(e,t=1e3,n={}){let{immediate:r=!0,immediateCallback:i=!1}=n,a=null,o=J(!1);function s(){a&&=(clearInterval(a),null)}function c(){o.value=!1,s()}function l(){let n=U(t);n<=0||(o.value=!0,i&&e(),s(),o.value&&(a=setInterval(e,n)))}return r&&Xl&&l(),(Ve(t)||typeof t==`function`)&&ql(C(t,()=>{o.value&&Xl&&l()})),ql(c),{isActive:Ie(o),pause:c,resume:l}}function Ru(e,t,n={}){let{immediate:r=!0,immediateCallback:i=!1}=n,a=J(!1),o;function s(){o&&=(clearTimeout(o),void 0)}function c(){a.value=!1,s()}function l(...n){i&&e(),s(),a.value=!0,o=setTimeout(()=>{a.value=!1,o=void 0,e(...n)},U(t))}return r&&(a.value=!0,Xl&&l()),ql(c),{isPending:Ie(a),start:l,stop:c}}function zu(e,t,n={}){let{debounce:r=0,maxWait:i=void 0,...a}=n;return Tu(e,t,{...a,eventFilter:ou(r,{maxWait:i})})}function Bu(e,t,n){return C(e,t,{...n,immediate:!0})}function Vu(e,t,n){return C(e,t,{...n,once:!0})}function Hu(e,t,n={}){let{throttle:r=0,trailing:i=!0,leading:a=!0,...o}=n;return Tu(e,t,{...o,eventFilter:su(r,i,a)})}function Uu(e,t,n){let r=C(e,(e,i,a)=>{e&&(n?.once&&rt(()=>r()),t(e,i,a))},{...n,once:!1});return r}function Wu(e,t,n){let r;r=Ve(n)?{evaluating:n}:n||{};let{lazy:i=!1,flush:a=`sync`,evaluating:o=void 0,shallow:s=!0,onError:c=globalThis.reportError??eu}=r,l=J(!i),u=s?J(t):q(t),d=0;return qe(async t=>{if(!l.value)return;d++;let n=d,r=!1;o&&Promise.resolve().then(()=>{o.value=!0});try{let i=await e(e=>{t(()=>{o&&(o.value=!1),r||e()})});n===d&&(u.value=i)}catch(e){c(e)}finally{o&&n===d&&(o.value=!1),r=!0}},{flush:a}),i?G(()=>(l.value=!0,u.value)):u}function Gu(e={}){let{inheritAttrs:t=!0,name:n=`ReusableTemplate`}=e,r=J(),i=Re({name:`${n}.define`,setup(e,{slots:t}){return()=>{r.value=t.default}}}),a=Re({inheritAttrs:t,name:`${n}.reuse`,props:e.props,setup(n,{attrs:i,slots:a}){return()=>{if(!r.value)throw Error(`[VueUse] Failed to find the definition of reusable template`);let o=r.value?.call(r,{...e.props==null?Ku(i):n,$slots:a});return t&&o?.length===1?o[0]:o}}});return vu({define:i,reuse:a},[i,a])}function Ku(e){let t={};for(let n in e)t[mu(n)]=e[n];return t}var qu=Xl?window:void 0;Xl&&window.document;var Ju=Xl?window.navigator:void 0;Xl&&window.location;function Yu(e){let t=U(e);return t?.$el??t}function Xu(...e){let t=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),n=G(()=>{let t=du(U(e[0])).filter(e=>e!=null);return t.every(e=>typeof e!=`string`)?t:void 0});return Bu(()=>[n.value?.map(e=>Yu(e))??[qu].filter(e=>e!=null),du(U(n.value?e[1]:e[0])),du(V(n.value?e[2]:e[1])),U(n.value?e[3]:e[2])],([e,n,r,i],a,o)=>{if(!e?.length||!n?.length||!r?.length)return;let s=$l(i)?{...i}:i,c=e.flatMap(e=>n.flatMap(n=>r.map(r=>t(e,n,r,s))));o(()=>{c.forEach(e=>e())})},{flush:`post`})}var Zu=!1;function Qu(e,t,n={}){let{window:r=qu,ignore:i=[],capture:a=!0,detectIframe:o=!1,controls:s=!1}=n;if(!r)return s?{stop:eu,cancel:eu,trigger:eu}:eu;if(tu&&!Zu){Zu=!0;let e={passive:!0};Array.from(r.document.body.children).forEach(t=>t.addEventListener(`click`,eu,e)),r.document.documentElement.addEventListener(`click`,eu,e)}let c=!0,l=e=>U(i).some(t=>{if(typeof t==`string`)return Array.from(r.document.querySelectorAll(t)).some(t=>t===e.target||e.composedPath().includes(t));{let n=Yu(t);return n&&(e.target===n||e.composedPath().includes(n))}});function u(e){let t=U(e);return t&&t.$.subTree.shapeFlag===16}function d(e,t){let n=U(e),r=n.$.subTree&&n.$.subTree.children;return r==null||!Array.isArray(r)?!1:r.some(e=>e.el===t.target||t.composedPath().includes(e.el))}let f=n=>{let r=Yu(e);if(n.target!=null&&!(!(r instanceof Element)&&u(e)&&d(e,n))&&!(!r||r===n.target||n.composedPath().includes(r))){if(`detail`in n&&n.detail===0&&(c=!l(n)),!c){c=!0;return}t(n)}},p=!1,m=[Xu(r,`click`,e=>{p||(p=!0,setTimeout(()=>{p=!1},0),f(e))},{passive:!0,capture:a}),Xu(r,`pointerdown`,t=>{let n=Yu(e);c=!l(t)&&!!(n&&!t.composedPath().includes(n))},{passive:!0}),o&&Xu(r,`blur`,n=>{setTimeout(()=>{let i=Yu(e),a=r.document.activeElement;for(;a?.shadowRoot;)a=a.shadowRoot.activeElement;a?.tagName===`IFRAME`&&!i?.contains(r.document.activeElement)&&t(n)},0)},{passive:!0})].filter(Boolean),h=()=>m.forEach(e=>e());return s?{stop:h,cancel:()=>{c=!1},trigger:e=>{c=!0,f(e),c=!1}}:h}function $u(){let e=J(!1),t=Oe();return t&&l(()=>{e.value=!0},t),e}function ed(e){let t=$u();return G(()=>(t.value,!!e()))}function td(e,t,n={}){let{window:r=qu,...i}=n,a,o=ed(()=>r&&`MutationObserver`in r),s=()=>{a&&=(a.disconnect(),void 0)},c=C(G(()=>{let t=du(U(e)).map(Yu).filter(Zl);return new Set(t)}),e=>{s(),o.value&&e.size&&(a=new MutationObserver(t),e.forEach(e=>a.observe(e,i)))},{immediate:!0,flush:`post`}),l=()=>a?.takeRecords(),u=()=>{c(),s()};return ql(u),{isSupported:o,stop:u,takeRecords:l}}function nd(e,t,n={}){let{window:r=qu,document:i=r?.document,flush:a=`sync`}=n;if(!r||!i)return eu;let o,s=e=>{o?.(),o=e},c=qe(()=>{let n=Yu(e);if(n){let{stop:e}=td(i,e=>{e.map(e=>[...e.removedNodes]).flat().some(e=>e===n||e.contains(n))&&t(e)},{window:r,childList:!0,subtree:!0});s(e)}},{flush:a}),l=()=>{c(),s()};return ql(l),l}function rd(e){return typeof e==`function`?e:typeof e==`string`?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function id(...e){let t,n,r={};e.length===3?(t=e[0],n=e[1],r=e[2]):e.length===2?typeof e[1]==`object`?(t=!0,n=e[0],r=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);let{target:i=qu,eventName:a=`keydown`,passive:o=!1,dedupe:s=!1}=r,c=rd(t);return Xu(i,a,e=>{e.repeat&&U(s)||c(e)&&n(e)},o)}var ad=500,od=10;function sd(e,t,n){var r,i;let a=G(()=>Yu(e)),o,s,c,l=!1;function u(){o&&=(clearTimeout(o),void 0),s=void 0,c=void 0,l=!1}function d(e){let t=n?.delay;return typeof t==`function`?t(e):t??ad}function f(e){var t,r,i;let[o,d,f]=[c,s,l];if(u(),!n?.onMouseUp||!d||!o||n!=null&&(t=n.modifiers)!=null&&t.self&&e.target!==a.value)return;n!=null&&(r=n.modifiers)!=null&&r.prevent&&e.preventDefault(),n!=null&&(i=n.modifiers)!=null&&i.stop&&e.stopPropagation();let p=e.x-d.x,m=e.y-d.y,h=Math.sqrt(p*p+m*m);n.onMouseUp(e.timeStamp-o,h,f,e)}function p(e){var r,i,f;n!=null&&(r=n.modifiers)!=null&&r.self&&e.target!==a.value||(u(),n!=null&&(i=n.modifiers)!=null&&i.prevent&&e.preventDefault(),n!=null&&(f=n.modifiers)!=null&&f.stop&&e.stopPropagation(),s={x:e.x,y:e.y},c=e.timeStamp,o=setTimeout(()=>{l=!0,t(e)},d(e)))}function m(e){var t,r,i;if(n!=null&&(t=n.modifiers)!=null&&t.self&&e.target!==a.value||!s||n?.distanceThreshold===!1)return;n!=null&&(r=n.modifiers)!=null&&r.prevent&&e.preventDefault(),n!=null&&(i=n.modifiers)!=null&&i.stop&&e.stopPropagation();let o=e.x-s.x,c=e.y-s.y;Math.sqrt(o*o+c*c)>=(n?.distanceThreshold??od)&&u()}let h={capture:n==null||(r=n.modifiers)==null?void 0:r.capture,once:n==null||(i=n.modifiers)==null?void 0:i.once},g=[Xu(a,`pointerdown`,p,h),Xu(a,`pointermove`,m,h),Xu(a,[`pointerup`,`pointerleave`],f,h)];return()=>g.forEach(e=>e())}function cd(e,t={}){let{immediate:n=!0,fpsLimit:r=null,window:i=qu,once:a=!1}=t,o=J(!1),s=G(()=>{let e=U(r);return e?1e3/e:null}),c=0,l=null;function u(t){if(!o.value||!i)return;c||=t;let n=t-c;if(s.value&&n<s.value){l=i.requestAnimationFrame(u);return}if(c=t,e({delta:n,timestamp:t}),a){o.value=!1,l=null;return}l=i.requestAnimationFrame(u)}function d(){!o.value&&i&&(o.value=!0,c=0,l=i.requestAnimationFrame(u))}function f(){o.value=!1,l!=null&&i&&(i.cancelAnimationFrame(l),l=null)}return n&&d(),ql(f),{isActive:Ie(o),pause:f,resume:d}}var ld=Symbol(`vueuse-ssr-width`);function ud(){let e=et()?Yl(ld,null):null;return typeof e==`number`?e:void 0}function dd(e,t={}){let{window:n=qu,ssrWidth:r=ud()}=t,i=ed(()=>n&&`matchMedia`in n&&typeof n.matchMedia==`function`),a=J(typeof r==`number`),o=J(),s=J(!1);return qe(()=>{if(a.value){a.value=!i.value;let t=U(e).split(`,`);s.value=t.some(e=>{let t=e.includes(`not all`),n=e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),i=e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),a=!!(n||i);return n&&a&&(a=r>=uu(n[1])),i&&a&&(a=r<=uu(i[1])),t?!a:a});return}i.value&&(o.value=n.matchMedia(U(e)),s.value=o.value.matches)}),Xu(o,`change`,e=>{s.value=e.matches},{passive:!0}),G(()=>s.value)}function fd(e,t={}){let{controls:n=!1,navigator:r=Ju}=t,i=ed(()=>r&&`permissions`in r),a=J(),o=typeof e==`string`?{name:e}:e,s=J(),c=()=>{s.value=a.value?.state??`prompt`};Xu(a,`change`,c,{passive:!0});let l=lu(async()=>{if(i.value){if(!a.value)try{a.value=await r.permissions.query(o)}catch{a.value=void 0}finally{c()}if(n)return be(a.value)}});return l(),n?{state:s,isSupported:i,query:l}:s}function pd(e={}){let{navigator:t=Ju,read:n=!1,source:r,copiedDuring:i=1500,legacy:a=!1}=e,o=ed(()=>t&&`clipboard`in t),s=fd(`clipboard-read`),c=fd(`clipboard-write`),l=G(()=>o.value||a),u=J(``),d=J(!1),f=J(!1),p=Ru(()=>d.value=!1,i,{immediate:!1}),m=0;async function h(){let e=!(o.value&&b(s.value));if(!e)try{u.value=await t.clipboard.readText()}catch{e=!0}e&&(u.value=y())}l.value&&n&&Xu([`copy`,`cut`],h,{passive:!0});async function g(e){let n=e??U(r);if(l.value&&n!=null){f.value=!0;let e=!(o.value&&b(c.value));if(!e)try{let e=_(n);await t.clipboard.write([e])}catch{e=!0}if(e){if(typeof n==`string`)u.value=n,v(n);else{let e=++m,t=await n();t!=null&&e===m&&(u.value=t,v(t))}}d.value=!0,p.start(),f.value=!1}}function _(e){return typeof e==`string`?(u.value=e,new ClipboardItem({"text/plain":e})):new ClipboardItem({"text/plain":e().then((e=``)=>(u.value=e,new Blob([e],{type:`text/plain`})))})}function v(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`absolute`,t.style.opacity=`0`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()}function y(){var e,t;return((e=document)==null||(t=e.getSelection)==null||(t=t.call(e))==null?void 0:t.toString())??``}function b(e){return e===`granted`||e===`prompt`}return{copyPending:Ie(f),isSupported:l,text:Ie(u),copied:Ie(d),copy:g}}var md=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},hd=`__vueuse_ssr_handlers__`,gd=_d();function _d(){return hd in md||(md[hd]=md[hd]||{}),md[hd]}function vd(e,t){return gd[e]||t}function yd(e){return e==null?`any`:e instanceof Set?`set`:e instanceof Map?`map`:e instanceof Date?`date`:typeof e==`boolean`?`boolean`:typeof e==`string`?`string`:typeof e==`object`?`object`:Number.isNaN(e)?`any`:`number`}var bd={boolean:{read:e=>e===`true`,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},xd=`vueuse-storage`;function Sd(e,t,n,r={}){let{flush:i=`pre`,deep:a=!0,listenToStorageChanges:o=!0,writeDefaults:s=!0,mergeDefaults:c=!1,shallow:l,window:u=qu,eventFilter:d,onError:f=e=>{console.error(e)},initOnMounted:p}=r,m=(l?J:q)(typeof t==`function`?t():t),h=G(()=>U(e));if(!n)try{n=vd(`getDefaultStorage`,()=>qu?.localStorage)()}catch(e){f(e)}if(!n)return m;let g=U(t),_=yd(g),v=r.serializer??bd[_],{pause:y,resume:b}=Eu(m,e=>w(e),{flush:i,deep:a,eventFilter:d});C(h,()=>E(),{flush:i});let x=!1;u&&o&&(n instanceof Storage?Xu(u,`storage`,e=>{p&&!x||E(e)},{passive:!0}):Xu(u,xd,e=>{p&&!x||D(e)})),p?Ou(()=>{x=!0,E()}):E();function S(e,t){if(u){let r={key:h.value,oldValue:e,newValue:t,storageArea:n};u.dispatchEvent(n instanceof Storage?new StorageEvent(`storage`,r):new CustomEvent(xd,{detail:r}))}}function w(e){try{let t=n.getItem(h.value);if(e==null)S(t,null),n.removeItem(h.value);else{let r=v.write(e);t!==r&&(n.setItem(h.value,r),S(t,r))}}catch(e){f(e)}}function T(e){let t=e?e.newValue:n.getItem(h.value);if(t==null)return s&&g!=null&&n.setItem(h.value,v.write(g)),g;if(!e&&c){let e=v.read(t);return typeof c==`function`?c(e,g):_===`object`&&!Array.isArray(e)?{...g,...e}:e}return typeof t==`string`?v.read(t):t}function E(e){if(!(e&&e.storageArea!==n)){if(e&&e.key==null){m.value=g;return}if(!(e&&e.key!==h.value)){y();try{let t=v.write(m.value);(e===void 0||e?.newValue!==t)&&(m.value=T(e))}catch(e){f(e)}finally{e?rt(b):b()}}}}function D(e){E(e.detail)}return m}var Cd={speed:2,margin:30,direction:`both`};function wd(e){e.scrollLeft>e.scrollWidth-e.clientWidth&&(e.scrollLeft=Math.max(0,e.scrollWidth-e.clientWidth)),e.scrollTop>e.scrollHeight-e.clientHeight&&(e.scrollTop=Math.max(0,e.scrollHeight-e.clientHeight))}function Td(e,t={}){let{pointerTypes:n,preventDefault:r,stopPropagation:i,exact:a,onMove:o,onEnd:s,onStart:c,initialValue:l,axis:u=`both`,draggingElement:d=qu,containerElement:f,handle:p=e,buttons:m=[0],restrictInView:h,autoScroll:g=!1}=t,_=q(U(l)??{x:0,y:0}),v=q(),y=e=>!n||n.includes(e.pointerType),b=e=>{U(r)&&e.preventDefault(),U(i)&&e.stopPropagation()},x=U(g),S=typeof x==`object`?{speed:U(x.speed)??Cd.speed,margin:U(x.margin)??Cd.margin,direction:x.direction??Cd.direction}:Cd,w=e=>typeof e==`number`?[e,e]:[e.x,e.y],T=(e,t,n)=>{let{clientWidth:r,clientHeight:i,scrollLeft:a,scrollTop:o,scrollWidth:s,scrollHeight:c}=e,[l,u]=w(S.margin),[d,f]=w(S.speed),p=0,m=0;(S.direction===`x`||S.direction===`both`)&&(n.x<l&&a>0?p=-d:n.x+t.width>r-l&&a<s-r&&(p=d)),(S.direction===`y`||S.direction===`both`)&&(n.y<u&&o>0?m=-f:n.y+t.height>i-u&&o<c-i&&(m=f)),(p||m)&&e.scrollBy({left:p,top:m,behavior:`auto`})},E=null,D=()=>{let t=U(f);t&&!E&&(E=setInterval(()=>{let n=U(e).getBoundingClientRect(),{x:r,y:i}=_.value,a={x:r-t.scrollLeft,y:i-t.scrollTop};a.x>=0&&a.y>=0&&(T(t,n,a),a.x+=t.scrollLeft,a.y+=t.scrollTop,_.value=a)},1e3/60))},O=()=>{E&&=(clearInterval(E),null)},k=(e,t,n,r)=>{let[i,a]=typeof n==`number`?[n,n]:[n.x,n.y],{clientWidth:o,clientHeight:s}=t;return e.x<i||e.x+r.width>o-i||e.y<a||e.y+r.height>s-a};U(g)&&C(_,()=>{if(U(t.disabled)||!v.value)return;let n=U(f);if(!n)return;let r=U(e).getBoundingClientRect(),{x:i,y:a}=_.value,o={x:i-n.scrollLeft,y:a-n.scrollTop};k(o,n,S.margin,r)?D():O()});let A=n=>{var r;if(!U(m).includes(n.button)||U(t.disabled)||!y(n)||U(a)&&n.target!==U(e))return;let i=U(f),o=i==null||(r=i.getBoundingClientRect)==null?void 0:r.call(i),s=U(e).getBoundingClientRect(),l={x:n.clientX-(i?s.left-o.left+(g?0:i.scrollLeft):s.left),y:n.clientY-(i?s.top-o.top+(g?0:i.scrollTop):s.top)};c?.(l,n)!==!1&&(v.value=l,b(n))},j=n=>{if(U(t.disabled)||!y(n)||!v.value)return;let r=U(f);r instanceof HTMLElement&&wd(r);let i=U(e).getBoundingClientRect(),{x:a,y:s}=_.value;if((u===`x`||u===`both`)&&(a=n.clientX-v.value.x,r&&(a=Math.min(Math.max(0,a),r.scrollWidth-i.width))),(u===`y`||u===`both`)&&(s=n.clientY-v.value.y,r&&(s=Math.min(Math.max(0,s),r.scrollHeight-i.height))),U(g)&&r&&(E===null&&T(r,i,{x:a,y:s}),a+=r.scrollLeft,s+=r.scrollTop),r&&(h||g)){if(u!==`y`){let e=a-r.scrollLeft;e<0?a=r.scrollLeft:e>r.clientWidth-i.width&&(a=r.clientWidth-i.width+r.scrollLeft)}if(u!==`x`){let e=s-r.scrollTop;e<0?s=r.scrollTop:e>r.clientHeight-i.height&&(s=r.clientHeight-i.height+r.scrollTop)}}_.value={x:a,y:s},o?.(_.value,n),b(n)},M=e=>{U(t.disabled)||!y(e)||v.value&&(v.value=void 0,g&&O(),s?.(_.value,e),b(e))};if(Xl){let e=()=>({capture:t.capture??!0,passive:!U(r)});Xu(p,`pointerdown`,A,e),Xu(d,`pointermove`,j,e),Xu(d,[`pointerup`,`pointercancel`],M,e)}return{...Du(_),position:_,isDragging:G(()=>!!v.value),style:G(()=>`
|
|
14
14
|
left: ${_.value.x}px;
|
|
15
15
|
top: ${_.value.y}px;
|
|
16
16
|
${g?`text-wrap: nowrap;`:``}
|