@camera.ui/server 0.0.64 → 0.0.65

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.
Files changed (165) hide show
  1. package/README.md +29 -0
  2. package/dist/interface/assets/main.BJSPOiOB.0.0.65.css +1 -0
  3. package/dist/interface/index.html +44 -44
  4. package/dist/interface/js/{@primeuix.BkBDkSvZ.0.0.64.js → @primeuix.bRNqZjQz.0.0.65.js} +43 -43
  5. package/dist/interface/js/{@primevue.CmI9gDHB.0.0.64.js → @primevue.nr37tGdz.0.0.65.js} +8 -8
  6. package/dist/interface/js/@tanstack.BlGunTa7.0.0.65.js +1 -0
  7. package/dist/interface/js/{@vee-validate.C7vvUs8h.0.0.64.js → @vee-validate.CM3rjqgU.0.0.65.js} +1 -1
  8. package/dist/interface/js/{@vueuse.CrzNw-Ap.0.0.64.js → @vueuse.CT4ArM_v.0.0.65.js} +1 -1
  9. package/dist/interface/js/{Adminpanel.Cr9cLAVO.0.0.64.js → Adminpanel.Hao0o9sq.0.0.65.js} +1 -1
  10. package/dist/interface/js/{Camera.PUrVh71A.0.0.64.js → Camera.DlM_BanJ.0.0.65.js} +1 -1
  11. package/dist/interface/js/{Cameras.BOIq1uuW.0.0.64.js → Cameras.Cvg5uMvR.0.0.65.js} +3 -3
  12. package/dist/interface/js/Cammesh.C7rHisuG.0.0.65.js +1 -0
  13. package/dist/interface/js/Camview.BRwFhhGH.0.0.65.js +1 -0
  14. package/dist/interface/js/Config.DD7ZQYIb.0.0.65.js +2 -0
  15. package/dist/interface/js/Console.QIMOqe_j.0.0.65.js +4 -0
  16. package/dist/interface/js/{CuiConsole.IQ_54YIe.0.0.64.js → CuiConsole.DFTuJye2.0.0.65.js} +1 -1
  17. package/dist/interface/js/{CuiPluginCard.Dxq5PA3u.0.0.64.js → CuiPluginCard.DbxiKfJr.0.0.65.js} +2 -2
  18. package/dist/interface/js/{CuiTimeline.Dvg-A_D3.0.0.64.js → CuiTimeline.CoOU089I.0.0.65.js} +1 -1
  19. package/dist/interface/js/{FirstSteps.D21zB4I8.0.0.64.js → FirstSteps.cJvnvd0p.0.0.65.js} +1 -1
  20. package/dist/interface/js/{Plugin.CfcJolDg.0.0.64.js → Plugin.BeWKpCW0.0.0.65.js} +1 -1
  21. package/dist/interface/js/{Plugins.BDGFT4rc.0.0.64.js → Plugins.B2csFQ62.0.0.65.js} +1 -1
  22. package/dist/interface/js/Recordings.QK0SFOP1.0.0.65.js +1 -0
  23. package/dist/interface/js/{Settings.n1QgVCKo.0.0.64.js → Settings.BcPlqzDA.0.0.65.js} +1 -1
  24. package/dist/interface/js/{SettingsAccount.DKOD5pn9.0.0.64.js → SettingsAccount.CT1-o1T3.0.0.65.js} +1 -1
  25. package/dist/interface/js/SettingsAppearance.Ch77J-K9.0.0.65.js +1 -0
  26. package/dist/interface/js/{SettingsAppearance.vue_vue_type_script_setup_true_lang.CdbksPIo.0.0.64.js → SettingsAppearance.vue_vue_type_script_setup_true_lang.Dasx97LK.0.0.65.js} +1 -1
  27. package/dist/interface/js/{SettingsBackup.B6E4lHe4.0.0.64.js → SettingsBackup.Vq3t50X5.0.0.65.js} +1 -1
  28. package/dist/interface/js/SettingsRecordings.BySo0NsX.0.0.65.js +1 -0
  29. package/dist/interface/js/{SettingsRemote.f8St_CxB.0.0.64.js → SettingsRemote.KojIuybJ.0.0.65.js} +1 -1
  30. package/dist/interface/js/{SettingsSystem.DT9sW8Bn.0.0.64.js → SettingsSystem.YAXxE6CS.0.0.65.js} +1 -1
  31. package/dist/interface/js/{SettingsUsers.B4zh8W2n.0.0.64.js → SettingsUsers.CMKXsKiJ.0.0.65.js} +1 -1
  32. package/dist/interface/js/{VersionsHandler.vue_vue_type_script_setup_true_lang.B3uSmbkC.0.0.64.js → VersionsHandler.vue_vue_type_script_setup_true_lang.Cf81Fg_-.0.0.65.js} +1 -1
  33. package/dist/interface/js/{ace-builds.o3mMMRPR.0.0.64.js → ace-builds.BXuWnsHa.0.0.65.js} +57 -56
  34. package/dist/interface/js/ace.config.Ckh2Op_e.0.0.65.js +1 -0
  35. package/dist/interface/js/{backup.DO1-cZ9-.0.0.64.js → backup.DjiTbs1Q.0.0.65.js} +1 -1
  36. package/dist/interface/js/{chart.js.C8Mk0WY-.0.0.64.js → chart.js.COWP81wl.0.0.65.js} +1 -1
  37. package/dist/interface/js/{close-circle.JtgTH15k.0.0.64.js → close-circle.Bt0DolDf.0.0.65.js} +1 -1
  38. package/dist/interface/js/{dnd-core.Bx9xaNPa.0.0.64.js → dnd-core.CIZI_Pnh.0.0.65.js} +1 -1
  39. package/dist/interface/js/{draggabilly.D5Tqj-Pe.0.0.64.js → draggabilly.jXME3Xl7.0.0.65.js} +1 -1
  40. package/dist/interface/js/{engine.io-client.QoXAw3T2.0.0.64.js → engine.io-client.Bwq6EbBZ.0.0.65.js} +1 -1
  41. package/dist/interface/js/{fast-deep-equal.BCDE3b5h.0.0.64.js → fast-deep-equal.wMnqc5nP.0.0.65.js} +1 -1
  42. package/dist/interface/js/{highlight.js.Cl8NtSQj.0.0.64.js → highlight.js.BJ--bJsY.0.0.65.js} +1 -1
  43. package/dist/interface/js/{linkify-it.C7Vybjuw.0.0.64.js → linkify-it.BgSGKsum.0.0.65.js} +1 -1
  44. package/dist/interface/js/main.DteM3Tyw.0.0.65.js +31 -0
  45. package/dist/interface/js/{markdown-it.DORLzL2K.0.0.64.js → markdown-it.CC2C4XG8.0.0.65.js} +1 -1
  46. package/dist/interface/js/{nprogress.CnzttbPh.0.0.64.js → nprogress.Y-YIR5w8.0.0.65.js} +1 -1
  47. package/dist/interface/js/{pinia.9X0kaQsa.0.0.64.js → pinia.B3xyHOOv.0.0.65.js} +2 -2
  48. package/dist/interface/js/primevue.NVdW9OqK.0.0.65.js +142 -0
  49. package/dist/interface/js/{qrcode.JP5fcfb-.0.0.64.js → qrcode.BsXR3CD9.0.0.65.js} +1 -1
  50. package/dist/interface/js/{react-dnd-touch-backend.creckxB4.0.0.64.js → react-dnd-touch-backend.C5TP3QMu.0.0.65.js} +1 -1
  51. package/dist/interface/js/{refresh-rounded.BkvK54dd.0.0.64.js → refresh-rounded.DOZ-DEFG.0.0.65.js} +1 -1
  52. package/dist/interface/js/{rxjs.Bn5s3PW8.0.0.64.js → rxjs.CUmmYmXR.0.0.65.js} +1 -1
  53. package/dist/interface/js/{socket.io-client.DfD_gFzU.0.0.64.js → socket.io-client.Bd1Z4yya.0.0.65.js} +1 -1
  54. package/dist/interface/js/{socket.io-parser.bDxrXN8d.0.0.64.js → socket.io-parser.Brq8Mynw.0.0.65.js} +1 -1
  55. package/dist/interface/js/{system.CyLB9Qia.0.0.64.js → system.Ch6phD20.0.0.65.js} +1 -1
  56. package/dist/interface/js/{trash-fill.DVgSz9-h.0.0.64.js → trash-fill.CK6-EpFr.0.0.65.js} +1 -1
  57. package/dist/interface/js/{unidragger.sbyCyCtI.0.0.64.js → unidragger.BlS0U2Yu.0.0.65.js} +1 -1
  58. package/dist/interface/js/{vee-validate.Y46tSO5P.0.0.64.js → vee-validate.Ba-stGSk.0.0.65.js} +1 -1
  59. package/dist/interface/js/{vue-chartjs.CNgApzKN.0.0.64.js → vue-chartjs._SToXEZB.0.0.65.js} +1 -1
  60. package/dist/interface/js/{vue-i18n.DT9DWshi.0.0.64.js → vue-i18n.Bdweqx4L.0.0.65.js} +1 -1
  61. package/dist/interface/js/{vue-inline-svg.DNIHHt2R.0.0.64.js → vue-inline-svg.dmm7rA4k.0.0.65.js} +1 -1
  62. package/dist/interface/js/{vue-router.Ct6ui15G.0.0.64.js → vue-router.BnioVTWI.0.0.65.js} +1 -1
  63. package/dist/interface/js/vue-zoomable.BYLfof9a.0.0.65.js +1 -0
  64. package/dist/interface/js/{vue3-dnd.DRABWH33.0.0.64.js → vue3-dnd.BltUqrfR.0.0.65.js} +1 -1
  65. package/dist/interface/js/{zoom-out.CTXHwELe.0.0.64.js → zoom-out.B7PvyI4N.0.0.65.js} +1 -1
  66. package/dist/interface/sw.js +1 -1
  67. package/dist/server/package.json +12 -12
  68. package/dist/server/requirements.txt +1 -1
  69. package/dist/server/src/api/controllers/cameras.controller.d.ts +1 -0
  70. package/dist/server/src/api/controllers/cameras.controller.js +27 -0
  71. package/dist/server/src/api/controllers/cameras.controller.js.map +1 -1
  72. package/dist/server/src/api/database/index.js +10 -2
  73. package/dist/server/src/api/database/index.js.map +1 -1
  74. package/dist/server/src/api/go2rtc/api/streams.d.ts +2 -0
  75. package/dist/server/src/api/go2rtc/api/streams.js +44 -0
  76. package/dist/server/src/api/go2rtc/api/streams.js.map +1 -1
  77. package/dist/server/src/api/routes/cameras.routes.js +6 -0
  78. package/dist/server/src/api/routes/cameras.routes.js.map +1 -1
  79. package/dist/server/src/api/schemas/go2rtc.schema.d.ts +8 -0
  80. package/dist/server/src/api/schemas/go2rtc.schema.js +6 -0
  81. package/dist/server/src/api/schemas/go2rtc.schema.js.map +1 -1
  82. package/dist/server/src/api/services/cameras.service.d.ts +1 -0
  83. package/dist/server/src/api/services/cameras.service.js +38 -8
  84. package/dist/server/src/api/services/cameras.service.js.map +1 -1
  85. package/dist/server/src/camera/controller.d.ts +1 -3
  86. package/dist/server/src/camera/controller.js +5 -11
  87. package/dist/server/src/camera/controller.js.map +1 -1
  88. package/dist/server/src/camera/device.d.ts +1 -1
  89. package/dist/server/src/camera/device.js +2 -2
  90. package/dist/server/src/camera/device.js.map +1 -1
  91. package/dist/server/src/camera/frameWorker.js +17 -2
  92. package/dist/server/src/camera/frameWorker.js.map +1 -1
  93. package/dist/server/src/camera/iou.js +13 -14
  94. package/dist/server/src/camera/iou.js.map +1 -1
  95. package/dist/server/src/camera/utils.js.map +1 -1
  96. package/dist/server/src/decoder/wasm/build/decoder.js +4 -4
  97. package/dist/server/src/decoder/wasm/build/decoder.wasm +0 -0
  98. package/dist/server/src/services/config/index.js +11 -0
  99. package/dist/server/src/services/config/index.js.map +1 -1
  100. package/dist/server/src/services/config/types.d.ts +4 -0
  101. package/package.json +12 -12
  102. package/dist/interface/assets/main.B-DXUtPa.0.0.64.css +0 -1
  103. package/dist/interface/assets/mode-json.Br7xisR1.0.0.64.js +0 -275
  104. package/dist/interface/assets/worker-json.DgwNIOck.0.0.64.js +0 -1626
  105. package/dist/interface/js/@tanstack.a3M2yFKp.0.0.64.js +0 -1
  106. package/dist/interface/js/Cammesh.DzbbmpBq.0.0.64.js +0 -1
  107. package/dist/interface/js/Camview.DBZOlAZ1.0.0.64.js +0 -1
  108. package/dist/interface/js/Config.CN7_wXsV.0.0.64.js +0 -2
  109. package/dist/interface/js/Console.BmVLvya9.0.0.64.js +0 -4
  110. package/dist/interface/js/Recordings.i1TKNg0g.0.0.64.js +0 -1
  111. package/dist/interface/js/SettingsAppearance.DC-07_Te.0.0.64.js +0 -1
  112. package/dist/interface/js/SettingsRecordings.DpSe0tNQ.0.0.64.js +0 -1
  113. package/dist/interface/js/ace.config.DPCh40Y7.0.0.64.js +0 -1
  114. package/dist/interface/js/main.Bbw0FMaK.0.0.64.js +0 -31
  115. package/dist/interface/js/primevue.biDzr1tV.0.0.64.js +0 -142
  116. package/dist/interface/js/vue-zoomable.D6Sv0QVL.0.0.64.js +0 -1
  117. package/dist/server/src/camera/session.d.ts +0 -37
  118. package/dist/server/src/camera/session.js +0 -160
  119. package/dist/server/src/camera/session.js.map +0 -1
  120. /package/dist/interface/assets/{@xterm.DYP7pi_n.0.0.64.css → @xterm.DYP7pi_n.0.0.65.css} +0 -0
  121. /package/dist/interface/assets/{Adminpanel.BKek2EMH.0.0.64.css → Adminpanel.BKek2EMH.0.0.65.css} +0 -0
  122. /package/dist/interface/assets/{Cameras.BDWZJqPN.0.0.64.css → Cameras.BDWZJqPN.0.0.65.css} +0 -0
  123. /package/dist/interface/assets/{Camview.Cvhuou6V.0.0.64.css → Camview.Cvhuou6V.0.0.65.css} +0 -0
  124. /package/dist/interface/assets/{CuiConsole.DCYyxdVg.0.0.64.css → CuiConsole.DCYyxdVg.0.0.65.css} +0 -0
  125. /package/dist/interface/assets/{CuiPluginCard.yF8V0SZY.0.0.64.css → CuiPluginCard.yF8V0SZY.0.0.65.css} +0 -0
  126. /package/dist/interface/assets/{CuiTimeline.BkIwlYtw.0.0.64.css → CuiTimeline.BkIwlYtw.0.0.65.css} +0 -0
  127. /package/dist/interface/assets/{Plugin.DJElsAn5.0.0.64.css → Plugin.DJElsAn5.0.0.65.css} +0 -0
  128. /package/dist/interface/assets/{Plugins.BwPlcRrV.0.0.64.css → Plugins.BwPlcRrV.0.0.65.css} +0 -0
  129. /package/dist/interface/assets/{Settings.CkgfRkQr.0.0.64.css → Settings.CkgfRkQr.0.0.65.css} +0 -0
  130. /package/dist/interface/assets/{SettingsAccount.CDZT7gN-.0.0.64.css → SettingsAccount.CDZT7gN-.0.0.65.css} +0 -0
  131. /package/dist/interface/assets/{SettingsBackup.CX0rT0QJ.0.0.64.css → SettingsBackup.CX0rT0QJ.0.0.65.css} +0 -0
  132. /package/dist/interface/assets/{highlight.Ch2EwETz.0.0.64.css → highlight.Ch2EwETz.0.0.65.css} +0 -0
  133. /package/dist/interface/assets/{logo-256.BCQk9H1-.0.0.64.png → logo-256.BCQk9H1-.0.0.65.png} +0 -0
  134. /package/dist/interface/assets/{logo-512.DLKVOU2S.0.0.64.png → logo-512.DLKVOU2S.0.0.65.png} +0 -0
  135. /package/dist/interface/assets/{logo.DmEiRk0z.0.0.64.png → logo.DmEiRk0z.0.0.65.png} +0 -0
  136. /package/dist/interface/assets/{mode-yaml.CIYL8U3d.0.0.64.js → mode-yaml.CIYL8U3d.0.0.65.js} +0 -0
  137. /package/dist/interface/assets/{worker-base.jEXLGV2h.0.0.64.js → worker-base.jEXLGV2h.0.0.65.js} +0 -0
  138. /package/dist/interface/assets/{worker-yaml.B3uUYINB.0.0.64.js → worker-yaml.B3uUYINB.0.0.65.js} +0 -0
  139. /package/dist/interface/js/{@babel.l0sNRNKZ.0.0.64.js → @babel.l0sNRNKZ.0.0.65.js} +0 -0
  140. /package/dist/interface/js/{@intlify.BIbPqCER.0.0.64.js → @intlify.BIbPqCER.0.0.65.js} +0 -0
  141. /package/dist/interface/js/{@kurkle.D8fDXNIl.0.0.64.js → @kurkle.D8fDXNIl.0.0.65.js} +0 -0
  142. /package/dist/interface/js/{@react-dnd.CcwRs9xb.0.0.64.js → @react-dnd.CcwRs9xb.0.0.65.js} +0 -0
  143. /package/dist/interface/js/{@socket.io.Dkula2eQ.0.0.64.js → @socket.io.Dkula2eQ.0.0.65.js} +0 -0
  144. /package/dist/interface/js/{@vue.BxBKarQv.0.0.64.js → @vue.BxBKarQv.0.0.65.js} +0 -0
  145. /package/dist/interface/js/{@xterm.qQMvi5Sq.0.0.64.js → @xterm.tD6mXzBA.0.0.65.js} +0 -0
  146. /package/dist/interface/js/{axios.DHr9lByg.0.0.64.js → axios.DHr9lByg.0.0.65.js} +0 -0
  147. /package/dist/interface/js/{birpc.l0sNRNKZ.0.0.64.js → birpc.l0sNRNKZ.0.0.65.js} +0 -0
  148. /package/dist/interface/js/{compare-versions.DqEOhma6.0.0.64.js → compare-versions.DqEOhma6.0.0.65.js} +0 -0
  149. /package/dist/interface/js/{dijkstrajs.C00ieaqj.0.0.64.js → dijkstrajs.C00ieaqj.0.0.65.js} +0 -0
  150. /package/dist/interface/js/{engine.io-parser.BiEtp6m2.0.0.64.js → engine.io-parser.BiEtp6m2.0.0.65.js} +0 -0
  151. /package/dist/interface/js/{entities.C20TfXL6.0.0.64.js → entities.C20TfXL6.0.0.65.js} +0 -0
  152. /package/dist/interface/js/{ev-emitter.X5f1qa-c.0.0.64.js → ev-emitter.X5f1qa-c.0.0.65.js} +0 -0
  153. /package/dist/interface/js/{get-size.D1dS-IaP.0.0.64.js → get-size.D1dS-IaP.0.0.65.js} +0 -0
  154. /package/dist/interface/js/{hookable.l0sNRNKZ.0.0.64.js → hookable.l0sNRNKZ.0.0.65.js} +0 -0
  155. /package/dist/interface/js/{mdurl.k9Sl0PQj.0.0.64.js → mdurl.k9Sl0PQj.0.0.65.js} +0 -0
  156. /package/dist/interface/js/{perfect-debounce.l0sNRNKZ.0.0.64.js → perfect-debounce.l0sNRNKZ.0.0.65.js} +0 -0
  157. /package/dist/interface/js/{primelocale.Bga3dOQu.0.0.64.js → primelocale.Bga3dOQu.0.0.65.js} +0 -0
  158. /package/dist/interface/js/{punycode.js.Dj65hjkv.0.0.64.js → punycode.js.Dj65hjkv.0.0.65.js} +0 -0
  159. /package/dist/interface/js/{react-dnd-html5-backend.1HQjlkwI.0.0.64.js → react-dnd-html5-backend.1HQjlkwI.0.0.65.js} +0 -0
  160. /package/dist/interface/js/{redux.BFxtlG_c.0.0.64.js → redux.BFxtlG_c.0.0.65.js} +0 -0
  161. /package/dist/interface/js/{tslib.9k7AwCpt.0.0.64.js → tslib.9k7AwCpt.0.0.65.js} +0 -0
  162. /package/dist/interface/js/{uc.micro.kMc2yuuw.0.0.64.js → uc.micro.kMc2yuuw.0.0.65.js} +0 -0
  163. /package/dist/interface/js/{uuid.C6aID195.0.0.64.js → uuid.C6aID195.0.0.65.js} +0 -0
  164. /package/dist/interface/js/{vue.l0sNRNKZ.0.0.64.js → vue.l0sNRNKZ.0.0.65.js} +0 -0
  165. /package/dist/interface/js/{zod.2bfLsWMZ.0.0.64.js → zod.2bfLsWMZ.0.0.65.js} +0 -0
@@ -1,31 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/FirstSteps.D21zB4I8.0.0.64.js","js/primevue.biDzr1tV.0.0.64.js","js/@primeuix.BkBDkSvZ.0.0.64.js","js/@vue.BxBKarQv.0.0.64.js","js/@primevue.CmI9gDHB.0.0.64.js","js/vue-inline-svg.DNIHHt2R.0.0.64.js","js/backup.DO1-cZ9-.0.0.64.js","js/system.CyLB9Qia.0.0.64.js","js/@tanstack.a3M2yFKp.0.0.64.js","js/vue-i18n.DT9DWshi.0.0.64.js","js/@intlify.BIbPqCER.0.0.64.js","js/SettingsAccount.DKOD5pn9.0.0.64.js","js/vee-validate.Y46tSO5P.0.0.64.js","js/pinia.9X0kaQsa.0.0.64.js","js/@vueuse.CrzNw-Ap.0.0.64.js","js/nprogress.CnzttbPh.0.0.64.js","js/@xterm.qQMvi5Sq.0.0.64.js","assets/@xterm.DYP7pi_n.0.0.64.css","js/axios.DHr9lByg.0.0.64.js","js/vue-router.Ct6ui15G.0.0.64.js","js/@vee-validate.C7vvUs8h.0.0.64.js","js/zod.2bfLsWMZ.0.0.64.js","js/uuid.C6aID195.0.0.64.js","js/socket.io-client.DfD_gFzU.0.0.64.js","js/engine.io-client.QoXAw3T2.0.0.64.js","js/engine.io-parser.BiEtp6m2.0.0.64.js","js/@socket.io.Dkula2eQ.0.0.64.js","js/socket.io-parser.bDxrXN8d.0.0.64.js","js/rxjs.Bn5s3PW8.0.0.64.js","js/tslib.9k7AwCpt.0.0.64.js","js/highlight.js.Cl8NtSQj.0.0.64.js","assets/highlight.Ch2EwETz.0.0.64.css","js/markdown-it.DORLzL2K.0.0.64.js","js/mdurl.k9Sl0PQj.0.0.64.js","js/uc.micro.kMc2yuuw.0.0.64.js","js/entities.C20TfXL6.0.0.64.js","js/linkify-it.C7Vybjuw.0.0.64.js","js/punycode.js.Dj65hjkv.0.0.64.js","js/qrcode.JP5fcfb-.0.0.64.js","js/dijkstrajs.C00ieaqj.0.0.64.js","js/draggabilly.D5Tqj-Pe.0.0.64.js","js/get-size.D1dS-IaP.0.0.64.js","js/unidragger.sbyCyCtI.0.0.64.js","js/ev-emitter.X5f1qa-c.0.0.64.js","js/vue-zoomable.D6Sv0QVL.0.0.64.js","js/primelocale.Bga3dOQu.0.0.64.js","assets/SettingsAccount.CDZT7gN-.0.0.64.css","js/SettingsAppearance.vue_vue_type_script_setup_true_lang.CdbksPIo.0.0.64.js","js/Cameras.BOIq1uuW.0.0.64.js","js/refresh-rounded.BkvK54dd.0.0.64.js","js/CuiConsole.IQ_54YIe.0.0.64.js","assets/CuiConsole.DCYyxdVg.0.0.64.css","assets/Cameras.BDWZJqPN.0.0.64.css","js/Camera.PUrVh71A.0.0.64.js","js/CuiTimeline.Dvg-A_D3.0.0.64.js","assets/CuiTimeline.BkIwlYtw.0.0.64.css","js/Camview.DBZOlAZ1.0.0.64.js","js/vue3-dnd.DRABWH33.0.0.64.js","js/dnd-core.Bx9xaNPa.0.0.64.js","js/redux.BFxtlG_c.0.0.64.js","js/@react-dnd.CcwRs9xb.0.0.64.js","js/fast-deep-equal.BCDE3b5h.0.0.64.js","js/react-dnd-html5-backend.1HQjlkwI.0.0.64.js","js/react-dnd-touch-backend.creckxB4.0.0.64.js","assets/Camview.Cvhuou6V.0.0.64.css","js/Recordings.i1TKNg0g.0.0.64.js","js/Config.CN7_wXsV.0.0.64.js","js/zoom-out.CTXHwELe.0.0.64.js","js/Console.BmVLvya9.0.0.64.js","js/Plugins.BDGFT4rc.0.0.64.js","js/CuiPluginCard.Dxq5PA3u.0.0.64.js","js/trash-fill.DVgSz9-h.0.0.64.js","js/VersionsHandler.vue_vue_type_script_setup_true_lang.B3uSmbkC.0.0.64.js","assets/CuiPluginCard.yF8V0SZY.0.0.64.css","assets/Plugins.BwPlcRrV.0.0.64.css","js/Plugin.CfcJolDg.0.0.64.js","js/close-circle.JtgTH15k.0.0.64.js","assets/Plugin.DJElsAn5.0.0.64.css","js/Adminpanel.Cr9cLAVO.0.0.64.js","js/chart.js.C8Mk0WY-.0.0.64.js","js/@kurkle.D8fDXNIl.0.0.64.js","js/vue-chartjs.CNgApzKN.0.0.64.js","assets/Adminpanel.BKek2EMH.0.0.64.css","js/Cammesh.DzbbmpBq.0.0.64.js","js/Settings.n1QgVCKo.0.0.64.js","assets/Settings.CkgfRkQr.0.0.64.css","js/SettingsAppearance.DC-07_Te.0.0.64.js","js/SettingsUsers.B4zh8W2n.0.0.64.js","js/SettingsRecordings.DpSe0tNQ.0.0.64.js","js/SettingsBackup.B6E4lHe4.0.0.64.js","assets/SettingsBackup.CX0rT0QJ.0.0.64.css","js/SettingsRemote.f8St_CxB.0.0.64.js","js/SettingsSystem.DT9sW8Bn.0.0.64.js","js/compare-versions.DqEOhma6.0.0.64.js"])))=>i.map(i=>d[i]);
2
- var S0=Object.defineProperty;var vu=s=>{throw TypeError(s)};var C0=(s,e,t)=>e in s?S0(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var p=(s,e,t)=>C0(s,typeof e!="symbol"?e+"":e,t),La=(s,e,t)=>e.has(s)||vu("Cannot "+t);var An=(s,e,t)=>(La(s,e,"read from private field"),t?t.call(s):e.get(s)),Yn=(s,e,t)=>e.has(s)?vu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),Zr=(s,e,t,n)=>(La(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t),vt=(s,e,t)=>(La(s,e,"access private method"),t);import{u as Ci,a as Bt,b as ut,V as k0}from"./@tanstack.a3M2yFKp.0.0.64.js";import{T as E0,s as A0,a as Lr,b as ys,c as jr,d as Ca,e as ki,f as Ih,g as M0,h as Oh,D as _u,i as Hc,j as po,k as $0,l as fo,m as ka,n as Qc,o as Nh,p as Kc,q as Fh,r as Lh,t as Zc,u as Gc,v as Wc,w as Jc,x as jh,y as qh,z as Dh,A as T0,B as P0,C as R0,E as I0,F as O0,G as N0,H as F0,I as L0,J as j0,K as q0}from"./primevue.biDzr1tV.0.0.64.js";import{F as pe,c as A,d as m,e as g,B as At,r as ae,o as Sn,a4 as Ea,L as Tt,h as c,R as y,P as at,M as j,O as ce,W as ot,z as Ls,k as ne,w as Ge,t as Jt,N as $,Y as Tr,J as Ei,m as et,V as Et,I as me,ac as Vt,f as us,ab as Bh,b as Pr,A as Xs,a7 as go,H as Qt,X as yt,Z as qt,i as mi,a5 as Yc,a0 as D0,Q as Ai,ad as Xc,n as Zs,G as ei,D as yu,_ as zh,S as B0,ae as Kn,af as Rr,$ as lr,ag as z0,a1 as U0,T as Uh,ah as V0}from"./@vue.BxBKarQv.0.0.64.js";import{v as Vh,u as el,a as H0,c as tl,b as Q0,d as K0,e as Hh,o as sl,f as Qh,g as Z0,h as G0,i as W0,r as bu,j as cc,k as J0,l as ri,m as nl,n as Y0,p as fn,q as X0,s as wu,t as ef,w as tf,x as ko,y as sf,z as nf}from"./@vueuse.CrzNw-Ap.0.0.64.js";import{a as rf,A as of}from"./axios.DHr9lByg.0.0.64.js";import{u as js,c as af}from"./vue-i18n.DT9DWshi.0.0.64.js";import{d as Mi,s as Vs,c as cf}from"./pinia.9X0kaQsa.0.0.64.js";import{u as qr,a as $i,c as lf,b as uf}from"./vue-router.Ct6ui15G.0.0.64.js";import{R as Aa}from"./vue-inline-svg.DNIHHt2R.0.0.64.js";import{F as rl,a as Lt,E as jt}from"./vee-validate.Y46tSO5P.0.0.64.js";import{t as Wn}from"./@vee-validate.C7vvUs8h.0.0.64.js";import{v as hn}from"./uuid.C6aID195.0.0.64.js";import{o as bt,c as xs,u as Os,l as we,t as df,n as xn,s as Ke,d as ur,r as il,e as Hn,f as hf,g as xu,h as mf,i as ol,j as Kh,k as Su}from"./zod.2bfLsWMZ.0.0.64.js";import{M as pf}from"./socket.io-client.DfD_gFzU.0.0.64.js";import{O as ff}from"./rxjs.Bn5s3PW8.0.0.64.js";import{H as Gr,t as gf,y as vf,j as _f,p as yf}from"./highlight.js.Cl8NtSQj.0.0.64.js";import{M as bf}from"./markdown-it.DORLzL2K.0.0.64.js";import{q as wf}from"./qrcode.JP5fcfb-.0.0.64.js";import{D as Zh}from"./draggabilly.D5Tqj-Pe.0.0.64.js";import{m as xf}from"./vue-zoomable.D6Sv0QVL.0.0.64.js";import{e as Sf,d as Cf}from"./primelocale.Bga3dOQu.0.0.64.js";import{Y as kf,Z as Ef}from"./@primevue.CmI9gDHB.0.0.64.js";import{a$ as Af,b0 as Mf}from"./@primeuix.BkBDkSvZ.0.0.64.js";import"./nprogress.CnzttbPh.0.0.64.js";import"./@xterm.qQMvi5Sq.0.0.64.js";import"./@intlify.BIbPqCER.0.0.64.js";import"./engine.io-client.QoXAw3T2.0.0.64.js";import"./engine.io-parser.BiEtp6m2.0.0.64.js";import"./@socket.io.Dkula2eQ.0.0.64.js";import"./socket.io-parser.bDxrXN8d.0.0.64.js";import"./tslib.9k7AwCpt.0.0.64.js";import"./mdurl.k9Sl0PQj.0.0.64.js";import"./uc.micro.kMc2yuuw.0.0.64.js";import"./entities.C20TfXL6.0.0.64.js";import"./linkify-it.C7Vybjuw.0.0.64.js";import"./punycode.js.Dj65hjkv.0.0.64.js";import"./dijkstrajs.C00ieaqj.0.0.64.js";import"./get-size.D1dS-IaP.0.0.64.js";import"./unidragger.sbyCyCtI.0.0.64.js";import"./ev-emitter.X5f1qa-c.0.0.64.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();const $f=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Tf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Pf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Rf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),If=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Of=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Nf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Ff=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Lf={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function jf(s,e){return m(),A("svg",Lf,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M5.41 7.41L10 12l-4.59 4.59L4 15.17L7.17 12L4 8.83zm13.18 9.18L14 12l4.59-4.58L20 8.83L16.83 12L20 15.17z"},null,-1)]))}const qf=pe({name:"mdi-unfold-less-vertical",render:jf}),Df={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bf(s,e){return m(),A("svg",Df,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 18.17L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15M12 5.83L15.17 9l1.41-1.41L12 3L7.41 7.59L8.83 9z"},null,-1)]))}const zf=pe({name:"mdi-unfold-more-horizontal",render:Bf}),Uf={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vf(s,e){return m(),A("svg",Uf,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19 13H5v-2h14z"},null,-1)]))}const Hf=pe({name:"mdi-minus",render:Vf}),Qf={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Kf(s,e){return m(),A("svg",Qf,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z"},null,-1)]))}const vo=pe({name:"mdi-close",render:Kf}),Zf={class:"fixed flex flex-row items-center z-[99999] top-0 left-[7px] gap-2 p-2 non-draggable-region"},Gf=At({__name:"CuiWindowButtons",setup(s){const e=ae(!1),t=ae(!1),n=()=>{var a;t.value||(a=window.electron)==null||a.send("change-window","minify")},r=()=>{var a;(a=window.electron)==null||a.send("change-window","close")},i=()=>{var a;(a=window.electron)==null||a.send("change-window","expand")},o=(a,l)=>{t.value=l};return Sn(()=>{var a;(a=window.electron)==null||a.on("fullscreen",o)}),Ea(()=>{var a;(a=window.electron)==null||a.removeListener("fullscreen",o)}),(a,l)=>{const u=vo,d=Hf,h=zf,v=qf;return Tt((m(),A("div",Zf,[g("div",{class:"close-button",onClick:r},[y(u,{color:"#7f050a",width:"100%",height:"100%",class:at(["transition-opacity opacity-0",{"opacity-100":c(e)}])},null,8,["class"])]),g("div",{class:at({"disabled-button":c(t),"minify-button":!c(t)}),onClick:n},[c(t)?ce("",!0):(m(),j(d,{key:0,color:"#995712",width:"100%",height:"100%",class:at(["transition-opacity opacity-0",{"opacity-100":c(e)}])},null,8,["class"]))],2),g("div",{class:"expand-button",style:ot(`${c(t)?"transform: rotate(45deg)":"transform: rotate(-45deg)"}`),onClick:i},[c(t)?(m(),j(v,{key:1,color:"#0d650d",width:"100%",height:"100%",class:at(["transition-opacity opacity-0",{"opacity-100":c(e)}])},null,8,["class"])):(m(),j(h,{key:0,color:"#0d650d",width:"100%",height:"100%",class:at(["transition-opacity opacity-0",{"opacity-100":c(e)}])},null,8,["class"]))],4)])),[[c(Vh),f=>e.value=f]])}}}),qs=(s,e)=>{const t=s.__vccOpts||s;for(const[n,r]of e)t[n]=r;return t},Wf=qs(Gf,[["__scopeId","data-v-8dab6fc2"]]),Jf={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yf(s,e){return m(),A("svg",Jf,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 6a7.75 7.75 0 1 0 10 0m-5-2v8"},null,-1)]))}const Gh=pe({name:"tabler-power",render:Yf}),Xf="/assets/logo-512.DLKVOU2S.0.0.64.png",e1=Object.freeze(Object.defineProperty({__proto__:null,default:Xf},Symbol.toStringTag,{value:"Module"})),t1="/assets/logo-256.BCQk9H1-.0.0.64.png",s1=Object.freeze(Object.defineProperty({__proto__:null,default:t1},Symbol.toStringTag,{value:"Module"})),n1="/assets/logo-512.DLKVOU2S.0.0.64.png",r1=Object.freeze(Object.defineProperty({__proto__:null,default:n1},Symbol.toStringTag,{value:"Module"})),i1="/assets/logo.DmEiRk0z.0.0.64.png",o1=Object.freeze(Object.defineProperty({__proto__:null,default:i1},Symbol.toStringTag,{value:"Module"})),a1="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%20233.63%20233.63'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:url(%23dark_wine);}.cls-2{fill:url(%23light_wine);}.cls-3{fill:none;stroke:%23000;stroke-miterlimit:10;opacity:0;}.cls-4{fill:%23c5c6c8;}.cls-5{fill:%231a1e21;stroke:%233a3a3a;stroke-width:2px;}.cls-6{fill:%23fff;}%3c/style%3e%3clinearGradient%20id='dark_wine'%20x1='87.36'%20y1='158.67'%20x2='87.36'%20y2='59.85'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23730000'/%3e%3cstop%20offset='0.49'%20stop-color='%23a51733'/%3e%3c/linearGradient%3e%3clinearGradient%20id='light_wine'%20x1='113.06'%20y1='197.59'%20x2='113.06'%20y2='80.87'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23f44a6b'/%3e%3cstop%20offset='0.28'%20stop-color='%23df294c'/%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='CameraUI_U'%3e%3cpath%20id='U_Left'%20class='cls-1'%20d='M47.05,119.47s7.58,16,14.12,23.42a45.28,45.28,0,0,0,16.37,11.86A49.46,49.46,0,0,0,99,158.62c9.43-.46,20.55-3.87,29.24-11.86-3.9,2.5-9.87,5.1-15.9,4.77a25.63,25.63,0,0,1-18.38-9.09c-9.39-10.31-7.62-28.35-7.75-32.68-.35-11.42.77-21.92-1.76-36.19-.46-2.64-1.79-5.19-4.55-8-1.83-1.86-8.4-5.75-13.42-5.74-7.31,0-12.95,3.71-15.38,7.84-2,3.41-3.06,4.22-4.23,25.08a217.23,217.23,0,0,0,.22,26.76Z'%20transform='translate(0.5%200.5)'/%3e%3cpath%20id='U_Right'%20class='cls-2'%20d='M144.12,89.6a16.24,16.24,0,0,1,4.06-4.9c4.16-3.4,9-3.67,10.92-3.82a19.7,19.7,0,0,1,12.53,4.58c1.19,1,6.11,5.58,7.13,17.29.73,8.51,3.31,65.93-37,87.14-4.22,2.22-18,9.25-35.66,7.38a62.43,62.43,0,0,1-20.8-6.11,65.8,65.8,0,0,1-18.89-14.23c-20.21-21.67-19.36-57.46-19.36-57.46s7.58,16,14.12,23.42a45.28,45.28,0,0,0,16.37,11.86A49.46,49.46,0,0,0,99,158.62c11.66-.57,25.93-5.64,35-18.32C143.52,126.8,138.46,100.51,144.12,89.6Z'%20transform='translate(0.5%200.5)'/%3e%3c/g%3e%3cg%20id='CameraUI_Lens'%3e%3ccircle%20id='ellipse'%20class='cls-3'%20cx='116.81'%20cy='116.81'%20r='116.31'/%3e%3cg%20id='lens'%3e%3ccircle%20id='lens_bg'%20class='cls-4'%20cx='159.13'%20cy='58.39'%20r='18.66'/%3e%3cpath%20id='lens_inner'%20class='cls-5'%20d='M169.64,58.31a11,11,0,1,1-22,0c0-6.08,4.93-11.86,11-11.86S169.64,52.23,169.64,58.31Z'%20transform='translate(0.5%200.5)'/%3e%3cg%20id='reflections'%3e%3cellipse%20id='dot_1'%20class='cls-6'%20cx='174.36'%20cy='53.69'%20rx='1.84'%20ry='1.42'/%3e%3cellipse%20id='dot_2'%20class='cls-6'%20cx='174.36'%20cy='57.08'%20rx='1.84'%20ry='1.42'/%3e%3cellipse%20id='dot_3'%20class='cls-6'%20cx='174.36'%20cy='60.46'%20rx='1.84'%20ry='1.42'/%3e%3ccircle%20id='dot_4'%20class='cls-6'%20cx='164.09'%20cy='63.77'%20r='1.66'/%3e%3cpath%20id='wide_1'%20class='cls-6'%20d='M156.63,48.9c-1.07-.88-5.52,3.09-6.31,5.43a1.53,1.53,0,0,0,0,1.26c.43.69,1.73.61,2.19.54,2.68-.44,4.71-4.09,4.8-4.37A3.21,3.21,0,0,0,156.63,48.9Z'%20transform='translate(0.5%200.5)'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",c1=Object.freeze(Object.defineProperty({__proto__:null,default:a1},Symbol.toStringTag,{value:"Module"})),l1="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%20132.55%20158.35'%20width='132.5500030517578'%20height='158.35000610351562'%3e%3cdefs%3e%3cstyle%3e.cls-2-1{fill:url(%23dark_wine);}.cls-2-2{fill:url(%23light_wine);}.cls-2-3{fill:%23c5c6c8;}.cls-2-4{fill:%231a1e21;stroke:%233a3a3a;stroke-width:2px;}.cls-2-5{fill:%23fff;}%3c/style%3e%3clinearGradient%20id='dark_wine'%20x1='45.89'%20y1='124.26'%20x2='45.89'%20y2='25.44'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23730000'%3e%3c/stop%3e%3cstop%20offset='0.49'%20stop-color='%23a51733'%3e%3c/stop%3e%3c/linearGradient%3e%3clinearGradient%20id='light_wine'%20x1='71.59'%20y1='163.18'%20x2='71.59'%20y2='46.47'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23f44a6b'%3e%3c/stop%3e%3cstop%20offset='0.28'%20stop-color='%23df294c'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='CameraUI_U'%3e%3cpath%20id='U_Left'%20class='cls-2-1%20svg-elem-1'%20d='M5.58,85.06s7.58,16,14.12,23.42a45.28,45.28,0,0,0,16.37,11.86,49.46,49.46,0,0,0,21.42,3.87c9.43-.46,20.55-3.87,29.24-11.86-3.9,2.5-9.87,5.1-15.9,4.77A25.68,25.68,0,0,1,52.44,108c-9.38-10.31-7.61-28.35-7.74-32.68-.35-11.42.77-21.92-1.76-36.19-.46-2.64-1.79-5.19-4.55-8C36.55,29.33,30,25.43,25,25.44c-7.31,0-12.95,3.72-15.38,7.84-2,3.41-3.07,4.22-4.23,25.08a217.23,217.23,0,0,0,.22,26.76Z'%20transform='translate(-5.05%20-4.82)'%3e%3c/path%3e%3cpath%20id='U_Right'%20class='cls-2-2%20svg-elem-2'%20d='M102.65,55.19a16.24,16.24,0,0,1,4.06-4.9c4.16-3.4,9-3.67,10.92-3.82a19.7,19.7,0,0,1,12.53,4.58c1.19,1,6.11,5.58,7.12,17.29.74,8.51,3.32,65.93-37,87.14-4.22,2.22-18,9.26-35.66,7.38a62.43,62.43,0,0,1-20.8-6.11,65.8,65.8,0,0,1-18.89-14.23C4.73,120.85,5.58,85.06,5.58,85.06s7.58,16,14.12,23.42a45.28,45.28,0,0,0,16.37,11.86,49.46,49.46,0,0,0,21.42,3.87c11.66-.57,25.93-5.64,35-18.32C102.05,92.39,97,66.1,102.65,55.19Z'%20transform='translate(-5.05%20-4.82)'%3e%3c/path%3e%3c/g%3e%3cg%20id='CameraUI_Lens'%3e%3ccircle%20id='lens_bg'%20class='cls-2-3%20svg-elem-3'%20cx='112.11'%20cy='18.66'%20r='18.66'%3e%3c/circle%3e%3cpath%20id='lens_inner'%20class='cls-2-4%20svg-elem-4'%20d='M128.17,23.9a11,11,0,1,1-22,0c0-6.08,4.93-11.86,11-11.86S128.17,17.82,128.17,23.9Z'%20transform='translate(-5.05%20-4.82)'%3e%3c/path%3e%3cg%20id='reflections'%3e%3cellipse%20id='dot_1'%20class='cls-2-5%20svg-elem-5'%20cx='127.34'%20cy='13.96'%20rx='1.84'%20ry='1.42'%3e%3c/ellipse%3e%3cellipse%20id='dot_2'%20class='cls-2-5%20svg-elem-6'%20cx='127.34'%20cy='17.34'%20rx='1.84'%20ry='1.42'%3e%3c/ellipse%3e%3cellipse%20id='dot_3'%20class='cls-2-5%20svg-elem-7'%20cx='127.34'%20cy='20.73'%20rx='1.84'%20ry='1.42'%3e%3c/ellipse%3e%3ccircle%20id='dot_4'%20class='cls-2-5%20svg-elem-8'%20cx='117.07'%20cy='24.04'%20r='1.66'%3e%3c/circle%3e%3cpath%20id='wide_1'%20class='cls-2-5%20svg-elem-9'%20d='M115.16,14.49c-1.07-.88-5.52,3.09-6.31,5.43a1.53,1.53,0,0,0,0,1.26c.43.69,1.73.61,2.18.54,2.69-.44,4.72-4.09,4.81-4.37A3.21,3.21,0,0,0,115.16,14.49Z'%20transform='translate(-5.05%20-4.82)'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e",u1=Object.freeze(Object.defineProperty({__proto__:null,default:l1},Symbol.toStringTag,{value:"Module"})),d1="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='-40%20-30%20300%20300'%3e%3cdefs%3e%3cstyle%3e.cls-3-1%20{fill:%20url(%23dark_wine);}%20.cls-3-2%20{fill:%20url(%23light_wine);}%20.cls-3-3%20{fill:%20none;stroke:%20%23000;stroke-miterlimit:%2010;opacity:%200;}%20.cls-3-4%20{fill:%20%23c5c6c8;}%20.cls-3-5%20{fill:%20%231a1e21;stroke:%20%233a3a3a;stroke-width:%202px;}%20.cls-3-6%20{fill:%20%23fff;}%3c/style%3e%3clinearGradient%20id='dark_wine'%20x1='220.57'%20y1='310.8'%20x2='220.57'%20y2='211.98'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23730000'%20/%3e%3cstop%20offset='0.49'%20stop-color='%23a51733'%20/%3e%3c/linearGradient%3e%3clinearGradient%20id='light_wine'%20x1='246.27'%20y1='349.71'%20x2='246.27'%20y2='233'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23f44a6b'%20/%3e%3cstop%20offset='0.28'%20stop-color='%23df294c'%20/%3e%3c/linearGradient%3e%3c/defs%3e%3cg%20id='CameraUI_U'%20class='cameraLetter'%3e%3cpath%20id='U_Left'%20class='cls-3-1'%20d='M180.26,271.6s7.57,16,14.11,23.42a45.43,45.43,0,0,0,16.38,11.86,49.46,49.46,0,0,0,21.42,3.87c9.42-.46,20.55-3.87,29.24-11.86-3.9,2.5-9.87,5.1-15.9,4.77a25.66,25.66,0,0,1-18.39-9.09c-9.38-10.31-7.61-28.35-7.74-32.68-.35-11.43.77-21.92-1.76-36.2-.47-2.63-1.79-5.18-4.55-8-1.84-1.86-8.41-5.75-13.43-5.74-7.3,0-12.94,3.71-15.38,7.84-2,3.41-3.06,4.22-4.22,25.08a215.27,215.27,0,0,0,.22,26.76Z'%20transform='translate(-132.71%20-151.63)'%20/%3e%3cpath%20id='U_Right'%20class='cls-3-2'%20d='M277.33,241.73a16.41,16.41,0,0,1,4.05-4.91c4.17-3.39,9-3.66,10.92-3.81a19.67,19.67,0,0,1,12.53,4.58c1.2,1,6.12,5.58,7.13,17.29.74,8.51,3.31,65.93-37,87.13-4.23,2.22-18,9.26-35.67,7.39a62.35,62.35,0,0,1-20.79-6.11,65.68,65.68,0,0,1-18.9-14.24c-20.2-21.66-19.35-57.45-19.35-57.45s7.57,16,14.11,23.42a45.43,45.43,0,0,0,16.38,11.86,49.46,49.46,0,0,0,21.42,3.87c11.66-.57,25.92-5.64,35-18.33C276.73,278.93,271.67,252.64,277.33,241.73Z'%20transform='translate(-132.71%20-151.63)'%20/%3e%3c/g%3e%3cg%20id='CameraUI_Lens'%3e%3cg%20id='lens'%20class='cameraLens'%3e%3ccircle%20id='lens_bg'%20class='cls-3-4'%20cx='159.13'%20cy='58.39'%20r='18.66'%20/%3e%3cpath%20id='lens_inner'%20class='cls-3-5'%20d='M302.85,210.44a11,11,0,1,1-22,0c0-6.08,4.93-11.86,11-11.86S302.85,204.36,302.85,210.44Z'%20transform='translate(-132.71%20-151.63)'%20/%3e%3cg%20id='reflections'%3e%3cellipse%20id='dot_1'%20class='cls-3-6'%20cx='174.36'%20cy='53.69'%20rx='1.84'%20ry='1.42'%20/%3e%3cellipse%20id='dot_2'%20class='cls-3-6'%20cx='174.36'%20cy='57.08'%20rx='1.84'%20ry='1.42'%20/%3e%3cellipse%20id='dot_3'%20class='cls-3-6'%20cx='174.36'%20cy='60.46'%20rx='1.84'%20ry='1.42'%20/%3e%3ccircle%20id='dot_4'%20class='cls-3-6'%20cx='164.09'%20cy='63.77'%20r='1.66'%20/%3e%3cpath%20id='wide_1'%20class='cls-3-6'%20d='M289.83,201c-1.07-.88-5.52,3.09-6.3,5.43a1.52,1.52,0,0,0,0,1.26c.43.69,1.72.61,2.18.53,2.68-.43,4.72-4.08,4.8-4.36A3.18,3.18,0,0,0,289.83,201Z'%20transform='translate(-132.71%20-151.63)'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",h1=Object.freeze(Object.defineProperty({__proto__:null,default:d1},Symbol.toStringTag,{value:"Module"}));var Cu={};/*! For license information please see bundle.js.LICENSE.txt */var m1={69:s=>{var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function a(l,u,d,h){var v=u>=1.5*d;return Math.round(l/d)+" "+h+(v?"s":"")}s.exports=function(l,u){u=u||{};var d=typeof l;if(d==="string"&&l.length>0)return function(h){if(!((h=String(h)).length>100)){var v=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(v){var f=parseFloat(v[1]);switch((v[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return f*o;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*t;case"seconds":case"second":case"secs":case"sec":case"s":return f*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}(l);if(d==="number"&&isFinite(l))return u.long?function(h){var v=Math.abs(h);return v>=r?a(h,v,r,"day"):v>=n?a(h,v,n,"hour"):v>=t?a(h,v,t,"minute"):v>=e?a(h,v,e,"second"):h+" ms"}(l):function(h){var v=Math.abs(h);return v>=r?Math.round(h/r)+"d":v>=n?Math.round(h/n)+"h":v>=t?Math.round(h/t)+"m":v>=e?Math.round(h/e)+"s":h+"ms"}(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))}},142:s=>{var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function a(l,u,d,h){var v=u>=1.5*d;return Math.round(l/d)+" "+h+(v?"s":"")}s.exports=function(l,u){u=u||{};var d=typeof l;if(d==="string"&&l.length>0)return function(h){if(!((h=String(h)).length>100)){var v=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(v){var f=parseFloat(v[1]);switch((v[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return f*o;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*t;case"seconds":case"second":case"secs":case"sec":case"s":return f*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}(l);if(d==="number"&&isFinite(l))return u.long?function(h){var v=Math.abs(h);return v>=r?a(h,v,r,"day"):v>=n?a(h,v,n,"hour"):v>=t?a(h,v,t,"minute"):v>=e?a(h,v,e,"second"):h+" ms"}(l):function(h){var v=Math.abs(h);return v>=r?Math.round(h/r)+"d":v>=n?Math.round(h/n)+"h":v>=t?Math.round(h/t)+"m":v>=e?Math.round(h/e)+"s":h+"ms"}(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))}},287:(s,e,t)=>{s.exports=function(n){function r(a){let l,u,d,h=null;function v(...f){if(!v.enabled)return;const b=v,k=Number(new Date),z=k-(l||k);b.diff=z,b.prev=l,b.curr=k,l=k,f[0]=r.coerce(f[0]),typeof f[0]!="string"&&f.unshift("%O");let L=0;f[0]=f[0].replace(/%([a-zA-Z%])/g,(se,K)=>{if(se==="%%")return"%";L++;const N=r.formatters[K];if(typeof N=="function"){const E=f[L];se=N.call(b,E),f.splice(L,1),L--}return se}),r.formatArgs.call(b,f),(b.log||r.log).apply(b,f)}return v.namespace=a,v.useColors=r.useColors(),v.color=r.selectColor(a),v.extend=i,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(u!==r.namespaces&&(u=r.namespaces,d=r.enabled(a)),d),set:f=>{h=f}}),typeof r.init=="function"&&r.init(v),v}function i(a,l){const u=r(this.namespace+(l===void 0?":":l)+a);return u.log=this.log,u}function o(a,l){let u=0,d=0,h=-1,v=0;for(;u<a.length;)if(d<l.length&&(l[d]===a[u]||l[d]==="*"))l[d]==="*"?(h=d,v=u,d++):(u++,d++);else{if(h===-1)return!1;d=h+1,v++,u=v}for(;d<l.length&&l[d]==="*";)d++;return d===l.length}return r.debug=r,r.default=r,r.coerce=function(a){return a instanceof Error?a.stack||a.message:a},r.disable=function(){const a=[...r.names,...r.skips.map(l=>"-"+l)].join(",");return r.enable(""),a},r.enable=function(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];const l=(typeof a=="string"?a:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const u of l)u[0]==="-"?r.skips.push(u.slice(1)):r.names.push(u)},r.enabled=function(a){for(const l of r.skips)if(o(a,l))return!1;for(const l of r.names)if(o(a,l))return!0;return!1},r.humanize=t(142),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(n).forEach(a=>{r[a]=n[a]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(a){let l=0;for(let u=0;u<a.length;u++)l=(l<<5)-l+a.charCodeAt(u),l|=0;return r.colors[Math.abs(l)%r.colors.length]},r.enable(r.load()),r}},288:(s,e,t)=>{e.formatArgs=function(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;r.splice(1,0,i,"color: inherit");let o=0,a=0;r[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(o++,l==="%c"&&(a=o))}),r.splice(a,0,i)},e.save=function(r){try{r?e.storage.setItem("debug",r):e.storage.removeItem("debug")}catch{}},e.load=function(){let r;try{r=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=Cu.DEBUG),r},e.useColors=function(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch{}}(),e.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.log=console.debug||console.log||(()=>{}),s.exports=t(287)(e);const{formatters:n}=s.exports;n.j=function(r){try{return JSON.stringify(r)}catch(i){return"[UnexpectedJSONParseError]: "+i.message}}},413:(s,e,t)=>{e.formatArgs=function(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;r.splice(1,0,i,"color: inherit");let o=0,a=0;r[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(o++,l==="%c"&&(a=o))}),r.splice(a,0,i)},e.save=function(r){try{r?e.storage.setItem("debug",r):e.storage.removeItem("debug")}catch{}},e.load=function(){let r;try{r=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=Cu.DEBUG),r},e.useColors=function(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch{}}(),e.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.log=console.debug||console.log||(()=>{}),s.exports=t(692)(e);const{formatters:n}=s.exports;n.j=function(r){try{return JSON.stringify(r)}catch(i){return"[UnexpectedJSONParseError]: "+i.message}}},672:s=>{const e=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,t=()=>e.now(),n=i=>i===1/0||(o=>o&&o===Math.floor(o)&&o>0&&isFinite(o))(i);class r{constructor({max:o=1/0,ttl:a,updateAgeOnGet:l=!1,checkAgeOnGet:u=!1,noUpdateTTL:d=!1,dispose:h,noDisposeOnSet:v=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,a!==void 0&&!n(a))throw new TypeError("ttl must be positive integer or Infinity if set");if(!n(o))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=a,this.max=o,this.updateAgeOnGet=!!l,this.checkAgeOnGet=!!u,this.noUpdateTTL=!!d,this.noDisposeOnSet=!!v,h!==void 0){if(typeof h!="function")throw new TypeError("dispose must be function if set");this.dispose=h}this.timer=void 0,this.timerExpiration=void 0}setTimer(o,a){if(this.timerExpiration<o)return;this.timer&&clearTimeout(this.timer);const l=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(const u in this.expirations){this.setTimer(u,u-t());break}},a);l.unref&&l.unref(),this.timerExpiration=o,this.timer=l}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){const o=this.dispose!==r.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(const[a,l]of o)this.dispose(l,a,"delete")}setTTL(o,a=this.ttl){const l=this.expirationMap.get(o);if(l!==void 0){const u=this.expirations[l];!u||u.length<=1?delete this.expirations[l]:this.expirations[l]=u.filter(d=>d!==o)}if(a!==1/0){const u=Math.floor(t()+a);this.expirationMap.set(o,u),this.expirations[u]||(this.expirations[u]=[],this.setTimer(u,a)),this.expirations[u].push(o)}else this.expirationMap.set(o,1/0)}set(o,a,{ttl:l=this.ttl,noUpdateTTL:u=this.noUpdateTTL,noDisposeOnSet:d=this.noDisposeOnSet}={}){if(!n(l))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(o)){u||this.setTTL(o,l);const h=this.data.get(o);h!==a&&(this.data.set(o,a),d||this.dispose(h,o,"set"))}else this.setTTL(o,l),this.data.set(o,a);for(;this.size>this.max;)this.purgeToCapacity();return this}has(o){return this.data.has(o)}getRemainingTTL(o){const a=this.expirationMap.get(o);return a===1/0?a:a!==void 0?Math.max(0,Math.ceil(a-t())):0}get(o,{updateAgeOnGet:a=this.updateAgeOnGet,ttl:l=this.ttl,checkAgeOnGet:u=this.checkAgeOnGet}={}){const d=this.data.get(o);if(!u||this.getRemainingTTL(o)!==0)return a&&this.setTTL(o,l),d;this.delete(o)}dispose(o,a){}delete(o){const a=this.expirationMap.get(o);if(a!==void 0){const l=this.data.get(o);this.data.delete(o),this.expirationMap.delete(o);const u=this.expirations[a];return u&&(u.length<=1?delete this.expirations[a]:this.expirations[a]=u.filter(d=>d!==o)),this.dispose(l,o,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(const o in this.expirations){const a=this.expirations[o];if(!(this.size-a.length>=this.max)){const l=this.size-this.max,u=[];for(const d of a.splice(0,l))u.push([d,this.data.get(d)]),this.data.delete(d),this.expirationMap.delete(d);for(const[d,h]of u)this.dispose(h,d,"evict");return}{delete this.expirations[o];const l=[];for(const u of a)l.push([u,this.data.get(u)]),this.data.delete(u),this.expirationMap.delete(u);for(const[u,d]of l)this.dispose(d,u,"evict")}}}get size(){return this.data.size}purgeStale(){const o=Math.ceil(t());for(const a in this.expirations){if(a==="Infinity"||a>o)return;const l=[...this.expirations[a]||[]],u=[];delete this.expirations[a];for(const d of l)u.push([d,this.data.get(d)]),this.data.delete(d),this.expirationMap.delete(d);for(const[d,h]of u)this.dispose(h,d,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(const o in this.expirations)for(const a of this.expirations[o])yield[a,this.data.get(a)]}*keys(){for(const o in this.expirations)for(const a of this.expirations[o])yield a}*values(){for(const o in this.expirations)for(const a of this.expirations[o])yield this.data.get(a)}[Symbol.iterator](){return this.entries()}}s.exports=r},692:(s,e,t)=>{s.exports=function(n){function r(a){let l,u,d,h=null;function v(...f){if(!v.enabled)return;const b=v,k=Number(new Date),z=k-(l||k);b.diff=z,b.prev=l,b.curr=k,l=k,f[0]=r.coerce(f[0]),typeof f[0]!="string"&&f.unshift("%O");let L=0;f[0]=f[0].replace(/%([a-zA-Z%])/g,(se,K)=>{if(se==="%%")return"%";L++;const N=r.formatters[K];if(typeof N=="function"){const E=f[L];se=N.call(b,E),f.splice(L,1),L--}return se}),r.formatArgs.call(b,f),(b.log||r.log).apply(b,f)}return v.namespace=a,v.useColors=r.useColors(),v.color=r.selectColor(a),v.extend=i,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(u!==r.namespaces&&(u=r.namespaces,d=r.enabled(a)),d),set:f=>{h=f}}),typeof r.init=="function"&&r.init(v),v}function i(a,l){const u=r(this.namespace+(l===void 0?":":l)+a);return u.log=this.log,u}function o(a,l){let u=0,d=0,h=-1,v=0;for(;u<a.length;)if(d<l.length&&(l[d]===a[u]||l[d]==="*"))l[d]==="*"?(h=d,v=u,d++):(u++,d++);else{if(h===-1)return!1;d=h+1,v++,u=v}for(;d<l.length&&l[d]==="*";)d++;return d===l.length}return r.debug=r,r.default=r,r.coerce=function(a){return a instanceof Error?a.stack||a.message:a},r.disable=function(){const a=[...r.names,...r.skips.map(l=>"-"+l)].join(",");return r.enable(""),a},r.enable=function(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];const l=(typeof a=="string"?a:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const u of l)u[0]==="-"?r.skips.push(u.slice(1)):r.names.push(u)},r.enabled=function(a){for(const l of r.skips)if(o(a,l))return!1;for(const l of r.names)if(o(a,l))return!0;return!1},r.humanize=t(69),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(n).forEach(a=>{r[a]=n[a]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(a){let l=0;for(let u=0;u<a.length;u++)l=(l<<5)-l+a.charCodeAt(u),l|=0;return r.colors[Math.abs(l)%r.colors.length]},r.enable(r.load()),r}},779:(s,e,t)=>{var n;(function(r){(function(){var i=typeof globalThis=="object"?globalThis:typeof t.g=="object"?t.g:typeof self=="object"?self:typeof this=="object"?this:function(){try{return Function("return this;")()}catch{}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch{}}(),o=a(r);function a(l,u){return function(d,h){Object.defineProperty(l,d,{configurable:!0,writable:!0,value:h}),u&&u(d,h)}}i.Reflect!==void 0&&(o=a(i.Reflect,o)),function(l,u){var d=Object.prototype.hasOwnProperty,h=typeof Symbol=="function",v=h&&Symbol.toPrimitive!==void 0?Symbol.toPrimitive:"@@toPrimitive",f=h&&Symbol.iterator!==void 0?Symbol.iterator:"@@iterator",b=typeof Object.create=="function",k={__proto__:[]}instanceof Array,z=!b&&!k,L={create:b?function(){return ds(Object.create(null))}:k?function(){return ds({__proto__:null})}:function(){return ds({})},has:z?function(R,te){return d.call(R,te)}:function(R,te){return te in R},get:z?function(R,te){return d.call(R,te)?R[te]:void 0}:function(R,te){return R[te]}},se=Object.getPrototypeOf(Function),K=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:As(),N=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:fs(),E=typeof WeakMap=="function"?WeakMap:Ms(),O=h?Symbol.for("@reflect-metadata:registry"):void 0,U=Kt(),S=ps(U);function M(R,te,ve,ke){if(ge(ve)){if(!V(R))throw new TypeError;if(!_e(te))throw new TypeError;return Se(R,te)}if(!V(R))throw new TypeError;if(!wt(te))throw new TypeError;if(!wt(ke)&&!ge(ke)&&!ft(ke))throw new TypeError;return ft(ke)&&(ke=void 0),F(R,te,ve=Ue(ve),ke)}function B(R,te){function ve(ke,st){if(!wt(ke))throw new TypeError;if(!ge(st)&&!ye(st))throw new TypeError;ht(R,te,ke,st)}return ve}function W(R,te,ve,ke){if(!wt(ve))throw new TypeError;return ge(ke)||(ke=Ue(ke)),ht(R,te,ve,ke)}function I(R,te,ve){if(!wt(te))throw new TypeError;return ge(ve)||(ve=Ue(ve)),D(R,te,ve)}function w(R,te,ve){if(!wt(te))throw new TypeError;return ge(ve)||(ve=Ue(ve)),Y(R,te,ve)}function Q(R,te,ve){if(!wt(te))throw new TypeError;return ge(ve)||(ve=Ue(ve)),Pe(R,te,ve)}function J(R,te,ve){if(!wt(te))throw new TypeError;return ge(ve)||(ve=Ue(ve)),He(R,te,ve)}function q(R,te){if(!wt(R))throw new TypeError;return ge(te)||(te=Ue(te)),Mt(R,te)}function oe(R,te){if(!wt(R))throw new TypeError;return ge(te)||(te=Ue(te)),Qe(R,te)}function ue(R,te,ve){if(!wt(te))throw new TypeError;if(ge(ve)||(ve=Ue(ve)),!wt(te))throw new TypeError;ge(ve)||(ve=Ue(ve));var ke=os(te,ve,!1);return!ge(ke)&&ke.OrdinaryDeleteMetadata(R,te,ve)}function Se(R,te){for(var ve=R.length-1;ve>=0;--ve){var ke=(0,R[ve])(te);if(!ge(ke)&&!ft(ke)){if(!_e(ke))throw new TypeError;te=ke}}return te}function F(R,te,ve,ke){for(var st=R.length-1;st>=0;--st){var Ot=(0,R[st])(te,ve,ke);if(!ge(Ot)&&!ft(Ot)){if(!wt(Ot))throw new TypeError;ke=Ot}}return ke}function D(R,te,ve){if(Y(R,te,ve))return!0;var ke=Le(te);return!ft(ke)&&D(R,ke,ve)}function Y(R,te,ve){var ke=os(te,ve,!1);return!ge(ke)&&Xt(ke.OrdinaryHasOwnMetadata(R,te,ve))}function Pe(R,te,ve){if(Y(R,te,ve))return He(R,te,ve);var ke=Le(te);return ft(ke)?void 0:Pe(R,ke,ve)}function He(R,te,ve){var ke=os(te,ve,!1);if(!ge(ke))return ke.OrdinaryGetOwnMetadata(R,te,ve)}function ht(R,te,ve,ke){os(ve,ke,!0).OrdinaryDefineOwnMetadata(R,te,ve,ke)}function Mt(R,te){var ve=Qe(R,te),ke=Le(R);if(ke===null)return ve;var st=Mt(ke,te);if(st.length<=0)return ve;if(ve.length<=0)return st;for(var Ot=new N,Ht=[],Ye=0,Ce=ve;Ye<Ce.length;Ye++){var Oe=Ce[Ye];Ot.has(Oe)||(Ot.add(Oe),Ht.push(Oe))}for(var Fe=0,be=st;Fe<be.length;Fe++)Oe=be[Fe],Ot.has(Oe)||(Ot.add(Oe),Ht.push(Oe));return Ht}function Qe(R,te){var ve=os(R,te,!1);return ve?ve.OrdinaryOwnMetadataKeys(R,te):[]}function ze(R){if(R===null)return 1;switch(typeof R){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return R===null?1:6;default:return 6}}function ge(R){return R===void 0}function ft(R){return R===null}function Yt(R){return typeof R=="symbol"}function wt(R){return typeof R=="object"?R!==null:typeof R=="function"}function zt(R,te){switch(ze(R)){case 0:case 1:case 2:case 3:case 4:case 5:return R}var ve="string",ke=_t(R,v);if(ke!==void 0){var st=ke.call(R,ve);if(wt(st))throw new TypeError;return st}return nt(R)}function nt(R,te){var ve,ke;{var st=R.toString;if(X(st)&&!wt(ke=st.call(R))||X(ve=R.valueOf)&&!wt(ke=ve.call(R)))return ke}throw new TypeError}function Xt(R){return!!R}function Be(R){return""+R}function Ue(R){var te=zt(R);return Yt(te)?te:Be(te)}function V(R){return Array.isArray?Array.isArray(R):R instanceof Object?R instanceof Array:Object.prototype.toString.call(R)==="[object Array]"}function X(R){return typeof R=="function"}function _e(R){return typeof R=="function"}function ye(R){switch(ze(R)){case 3:case 4:return!0;default:return!1}}function fe(R,te){return R===te||R!=R&&te!=te}function _t(R,te){var ve=R[te];if(ve!=null){if(!X(ve))throw new TypeError;return ve}}function Pt(R){var te=_t(R,f);if(!X(te))throw new TypeError;var ve=te.call(R);if(!wt(ve))throw new TypeError;return ve}function he(R){return R.value}function ie(R){var te=R.next();return!te.done&&te}function de(R){var te=R.return;te&&te.call(R)}function Le(R){var te=Object.getPrototypeOf(R);if(typeof R!="function"||R===se||te!==se)return te;var ve=R.prototype,ke=ve&&Object.getPrototypeOf(ve);if(ke==null||ke===Object.prototype)return te;var st=ke.constructor;return typeof st!="function"||st===R?te:st}function rt(){var R,te,ve,ke;ge(O)||u.Reflect===void 0||O in u.Reflect||typeof u.Reflect.defineMetadata!="function"||(R=Zt(u.Reflect));var st=new E,Ot={registerProvider:Ht,getProvider:Ce,setProvider:Fe};return Ot;function Ht(be){if(!Object.isExtensible(Ot))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case R===be:break;case ge(te):te=be;break;case te===be:break;case ge(ve):ve=be;break;case ve===be:break;default:ke===void 0&&(ke=new N),ke.add(be)}}function Ye(be,it){if(!ge(te)){if(te.isProviderFor(be,it))return te;if(!ge(ve)){if(ve.isProviderFor(be,it))return te;if(!ge(ke))for(var _=Pt(ke);;){var x=ie(_);if(!x)return;var C=he(x);if(C.isProviderFor(be,it))return de(_),C}}}if(!ge(R)&&R.isProviderFor(be,it))return R}function Ce(be,it){var _,x=st.get(be);return ge(x)||(_=x.get(it)),ge(_)&&(ge(_=Ye(be,it))||(ge(x)&&(x=new K,st.set(be,x)),x.set(it,_))),_}function Oe(be){if(ge(be))throw new TypeError;return te===be||ve===be||!ge(ke)&&ke.has(be)}function Fe(be,it,_){if(!Oe(_))throw new Error("Metadata provider not registered.");var x=Ce(be,it);if(x!==_){if(!ge(x))return!1;var C=st.get(be);ge(C)&&(C=new K,st.set(be,C)),C.set(it,_)}return!0}}function Kt(){var R;return!ge(O)&&wt(u.Reflect)&&Object.isExtensible(u.Reflect)&&(R=u.Reflect[O]),ge(R)&&(R=rt()),!ge(O)&&wt(u.Reflect)&&Object.isExtensible(u.Reflect)&&Object.defineProperty(u.Reflect,O,{enumerable:!1,configurable:!1,writable:!1,value:R}),R}function ps(R){var te=new E,ve={isProviderFor:function(Oe,Fe){var be=te.get(Oe);return!ge(be)&&be.has(Fe)},OrdinaryDefineOwnMetadata:Ht,OrdinaryHasOwnMetadata:st,OrdinaryGetOwnMetadata:Ot,OrdinaryOwnMetadataKeys:Ye,OrdinaryDeleteMetadata:Ce};return U.registerProvider(ve),ve;function ke(Oe,Fe,be){var it=te.get(Oe),_=!1;if(ge(it)){if(!be)return;it=new K,te.set(Oe,it),_=!0}var x=it.get(Fe);if(ge(x)){if(!be)return;if(x=new K,it.set(Fe,x),!R.setProvider(Oe,Fe,ve))throw it.delete(Fe),_&&te.delete(Oe),new Error("Wrong provider for target.")}return x}function st(Oe,Fe,be){var it=ke(Fe,be,!1);return!ge(it)&&Xt(it.has(Oe))}function Ot(Oe,Fe,be){var it=ke(Fe,be,!1);if(!ge(it))return it.get(Oe)}function Ht(Oe,Fe,be,it){ke(be,it,!0).set(Oe,Fe)}function Ye(Oe,Fe){var be=[],it=ke(Oe,Fe,!1);if(ge(it))return be;for(var _=Pt(it.keys()),x=0;;){var C=ie(_);if(!C)return be.length=x,be;var T=he(C);try{be[x]=T}catch(P){try{de(_)}finally{throw P}}x++}}function Ce(Oe,Fe,be){var it=ke(Fe,be,!1);if(ge(it)||!it.delete(Oe))return!1;if(it.size===0){var _=te.get(Fe);ge(_)||(_.delete(be),_.size===0&&te.delete(_))}return!0}}function Zt(R){var te=R.defineMetadata,ve=R.hasOwnMetadata,ke=R.getOwnMetadata,st=R.getOwnMetadataKeys,Ot=R.deleteMetadata,Ht=new E,Ye={isProviderFor:function(Ce,Oe){var Fe=Ht.get(Ce);return!(ge(Fe)||!Fe.has(Oe))||!!st(Ce,Oe).length&&(ge(Fe)&&(Fe=new N,Ht.set(Ce,Fe)),Fe.add(Oe),!0)},OrdinaryDefineOwnMetadata:te,OrdinaryHasOwnMetadata:ve,OrdinaryGetOwnMetadata:ke,OrdinaryOwnMetadataKeys:st,OrdinaryDeleteMetadata:Ot};return Ye}function os(R,te,ve){var ke=U.getProvider(R,te);if(!ge(ke))return ke;if(ve){if(U.setProvider(R,te,S))return S;throw new Error("Illegal state.")}}function As(){var R={},te=[],ve=function(){function Ye(Ce,Oe,Fe){this._index=0,this._keys=Ce,this._values=Oe,this._selector=Fe}return Ye.prototype["@@iterator"]=function(){return this},Ye.prototype[f]=function(){return this},Ye.prototype.next=function(){var Ce=this._index;if(Ce>=0&&Ce<this._keys.length){var Oe=this._selector(this._keys[Ce],this._values[Ce]);return Ce+1>=this._keys.length?(this._index=-1,this._keys=te,this._values=te):this._index++,{value:Oe,done:!1}}return{value:void 0,done:!0}},Ye.prototype.throw=function(Ce){throw this._index>=0&&(this._index=-1,this._keys=te,this._values=te),Ce},Ye.prototype.return=function(Ce){return this._index>=0&&(this._index=-1,this._keys=te,this._values=te),{value:Ce,done:!0}},Ye}(),ke=function(){function Ye(){this._keys=[],this._values=[],this._cacheKey=R,this._cacheIndex=-2}return Object.defineProperty(Ye.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ye.prototype.has=function(Ce){return this._find(Ce,!1)>=0},Ye.prototype.get=function(Ce){var Oe=this._find(Ce,!1);return Oe>=0?this._values[Oe]:void 0},Ye.prototype.set=function(Ce,Oe){var Fe=this._find(Ce,!0);return this._values[Fe]=Oe,this},Ye.prototype.delete=function(Ce){var Oe=this._find(Ce,!1);if(Oe>=0){for(var Fe=this._keys.length,be=Oe+1;be<Fe;be++)this._keys[be-1]=this._keys[be],this._values[be-1]=this._values[be];return this._keys.length--,this._values.length--,fe(Ce,this._cacheKey)&&(this._cacheKey=R,this._cacheIndex=-2),!0}return!1},Ye.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=R,this._cacheIndex=-2},Ye.prototype.keys=function(){return new ve(this._keys,this._values,st)},Ye.prototype.values=function(){return new ve(this._keys,this._values,Ot)},Ye.prototype.entries=function(){return new ve(this._keys,this._values,Ht)},Ye.prototype["@@iterator"]=function(){return this.entries()},Ye.prototype[f]=function(){return this.entries()},Ye.prototype._find=function(Ce,Oe){if(!fe(this._cacheKey,Ce)){this._cacheIndex=-1;for(var Fe=0;Fe<this._keys.length;Fe++)if(fe(this._keys[Fe],Ce)){this._cacheIndex=Fe;break}}return this._cacheIndex<0&&Oe&&(this._cacheIndex=this._keys.length,this._keys.push(Ce),this._values.push(void 0)),this._cacheIndex},Ye}();return ke;function st(Ye,Ce){return Ye}function Ot(Ye,Ce){return Ce}function Ht(Ye,Ce){return[Ye,Ce]}}function fs(){return function(){function R(){this._map=new K}return Object.defineProperty(R.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),R.prototype.has=function(te){return this._map.has(te)},R.prototype.add=function(te){return this._map.set(te,te),this},R.prototype.delete=function(te){return this._map.delete(te)},R.prototype.clear=function(){this._map.clear()},R.prototype.keys=function(){return this._map.keys()},R.prototype.values=function(){return this._map.keys()},R.prototype.entries=function(){return this._map.entries()},R.prototype["@@iterator"]=function(){return this.keys()},R.prototype[f]=function(){return this.keys()},R}()}function Ms(){var R=16,te=L.create(),ve=ke();return function(){function Ce(){this._key=ke()}return Ce.prototype.has=function(Oe){var Fe=st(Oe,!1);return Fe!==void 0&&L.has(Fe,this._key)},Ce.prototype.get=function(Oe){var Fe=st(Oe,!1);return Fe!==void 0?L.get(Fe,this._key):void 0},Ce.prototype.set=function(Oe,Fe){return st(Oe,!0)[this._key]=Fe,this},Ce.prototype.delete=function(Oe){var Fe=st(Oe,!1);return Fe!==void 0&&delete Fe[this._key]},Ce.prototype.clear=function(){this._key=ke()},Ce}();function ke(){var Ce;do Ce="@@WeakMap@@"+Ye();while(L.has(te,Ce));return te[Ce]=!0,Ce}function st(Ce,Oe){if(!d.call(Ce,ve)){if(!Oe)return;Object.defineProperty(Ce,ve,{value:L.create()})}return Ce[ve]}function Ot(Ce,Oe){for(var Fe=0;Fe<Oe;++Fe)Ce[Fe]=255*Math.random()|0;return Ce}function Ht(Ce){if(typeof Uint8Array=="function"){var Oe=new Uint8Array(Ce);return typeof crypto<"u"?crypto.getRandomValues(Oe):typeof msCrypto<"u"?msCrypto.getRandomValues(Oe):Ot(Oe,Ce),Oe}return Ot(new Array(Ce),Ce)}function Ye(){var Ce=Ht(R);Ce[6]=79&Ce[6]|64,Ce[8]=191&Ce[8]|128;for(var Oe="",Fe=0;Fe<R;++Fe){var be=Ce[Fe];Fe!==4&&Fe!==6&&Fe!==8||(Oe+="-"),be<16&&(Oe+="0"),Oe+=be.toString(16).toLowerCase()}return Oe}}function ds(R){return R.__=void 0,delete R.__,R}l("decorate",M),l("metadata",B),l("defineMetadata",W),l("hasMetadata",I),l("hasOwnMetadata",w),l("getMetadata",Q),l("getOwnMetadata",J),l("getMetadataKeys",q),l("getOwnMetadataKeys",oe),l("deleteMetadata",ue)}(o,i),i.Reflect===void 0&&(i.Reflect=r)})()})(n||(n={}))}},ku={};function tn(s){var e=ku[s];if(e!==void 0)return e.exports;var t=ku[s]={exports:{}};return m1[s](t,t.exports,tn),t.exports}tn.n=s=>{var e=s&&s.__esModule?()=>s.default:()=>s;return tn.d(e,{a:e}),e},tn.d=(s,e)=>{for(var t in e)tn.o(e,t)&&!tn.o(s,t)&&Object.defineProperty(s,t,{enumerable:!0,get:e[t]})},tn.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),tn.o=(s,e)=>Object.prototype.hasOwnProperty.call(s,e);class p1{constructor(e){p(this,"baseURL");p(this,"abortControllers",new Set);this.baseURL=`${e}/api`}async request(e,t,n,r={}){const i=new AbortController;this.abortControllers.add(i);const o=setTimeout(()=>{i.abort(),this.abortControllers.delete(i)},15e3);try{const a=await fetch(`${this.baseURL}${t}`,{method:e,headers:{"Content-Type":"application/json",...r.headers},body:n?JSON.stringify(n):void 0,signal:i.signal,...r});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a}finally{clearTimeout(o),this.abortControllers.delete(i)}}get(e,t){return this.request("GET",e,void 0,t)}post(e,t,n){return this.request("POST",e,t,n)}}const ks={FAILED:"CONNECTION_FAILED",TIMEOUT:"CONNECTION_TIMEOUT",NOT_CONNECTED:"CONNECTION_NOT_CONNECTED",INVALID_STATE:"CONNECTION_INVALID_STATE",INTERNAL_ERROR:"CONNECTION_INTERNAL_ERROR"},Ir={MISSING:"CONFIG_MISSING",INVALID:"CONFIG_INVALID",INTERNAL_ERROR:"CONFIG_INTERNAL_ERROR"},en={INVALID_CREDENTIALS:"AUTH_INVALID_CREDENTIALS",UNAUTHORIZED:"AUTH_UNAUTHORIZED",FORBIDDEN:"AUTH_FORBIDDEN",INTERNAL_ERROR:"AUTH_INTERNAL_ERROR"},$n={REGISTRATION_FAILED:"CLIENT_REGISTRATION_FAILED",UNREGISTRATION_FAILED:"CLIENT_UNREGISTRATION_FAILED",NOT_FOUND:"CLIENT_NOT_FOUND",INVALID_STATE:"CLIENT_INVALID_STATE",INTERNAL_ERROR:"CLIENT_INTERNAL_ERROR"},zn={INVALID_FORMAT:"MESSAGE_INVALID_FORMAT",DELIVERY_FAILED:"MESSAGE_DELIVERY_FAILED",TIMEOUT:"MESSAGE_TIMEOUT",EXECUTION_FAILED:"MESSAGE_EXECUTION_FAILED",INTERNAL_ERROR:"MESSAGE_INTERNAL_ERROR"},rr={METHOD_NOT_FOUND:"RPC_METHOD_NOT_FOUND",INVALID_REQUEST:"RPC_INVALID_REQUEST",INTERNAL_ERROR:"RPC_INTERNAL_ERROR",CONNECTION_FAILED:"RPC_CONNECTION_FAILED"},Wh={INTERNAL_ERROR:"REGISTRY_INTERNAL_ERROR"},sr={JOIN_FAILED:"CLUSTER_JOIN_FAILED",SYNC_FAILED:"CLUSTER_SYNC_FAILED",COMMUNICATION_FAILED:"CLUSTER_COMMUNICATION_FAILED",INVALID_STATE:"CLUSTER_INVALID_STATE",NODE_NOT_FOUND:"CLUSTER_NODE_NOT_FOUND",INSTANCE_NOT_FOUND:"CLUSTER_INSTANCE_NOT_FOUND",INTERNAL_ERROR:"CLUSTER_INTERNAL_ERROR"};class ws extends Error{constructor(t,n,r,i){super(t);p(this,"code");p(this,"details");p(this,"cause");this.code=n,this.details=r,this.cause=i,this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),this.cause&&(this.cause={name:this.cause.name,message:this.cause.message,...this.cause instanceof ws?{code:this.cause.code,details:this.cause.details}:{code:"INTERNAL_ERROR",details:{description:this.cause.message}}})}toJSON(){return{name:this.name,message:this.message,code:this.code,details:this.details,stack:this.stack,cause:this.cause}}static fromJSON(t){return new ws(t.message,t.code,t.details,t.cause?ws.fromJSON(t.cause):void 0)}}class f1 extends ws{constructor(e,t,n){super(e,ks.INTERNAL_ERROR,t,n)}}class g1 extends ws{constructor(e,t,n){super(e,Ir.INTERNAL_ERROR,t,n)}}class v1 extends ws{constructor(e,t,n){super(e,en.INTERNAL_ERROR,t,n)}}class _1 extends ws{constructor(e,t,n){super(e,$n.INTERNAL_ERROR,t,n)}}class y1 extends ws{constructor(e,t,n){super(e,zn.INTERNAL_ERROR,t,n)}}class b1 extends ws{constructor(e,t,n){super(e,rr.INTERNAL_ERROR,t,n)}}class w1 extends ws{constructor(e,t,n){super(e,Wh.INTERNAL_ERROR,t,n)}}class x1 extends ws{constructor(e,t,n){super(e,sr.INTERNAL_ERROR,t,n)}}const lt=class lt{static create(e,t,n,r){if(t instanceof ws)return t;const i=t instanceof Error?t:new Error(String(t)),o=function(a){function l(u){let d=!1;try{typeof Buffer<"u"&&(d=u instanceof Buffer)}catch{d=!1}return u instanceof ArrayBuffer||u instanceof Uint8Array||d||ArrayBuffer.isView(u)?"<binary>":Array.isArray(u)?u.map(l):u&&typeof u=="object"?Object.fromEntries(Object.entries(u).map(([h,v])=>[h,l(v)])):u}return l(a??{})}(r);switch(e){case"connection":return new f1(n,o,i);case"config":return new g1(n,o,i);case"auth":return new v1(n,o,i);case"client":return new _1(n,o,i);case"message":return new y1(n,o,i);case"rpc":return new b1(n,o,i);case"registry":return new w1(n,o,i);case"cluster":return new x1(n,o,i)}}static async handle(e,t,n,r){try{return await e()}catch(i){throw lt.create(t,i,n,r)}}};p(lt,"connection",{connectionFailed:(e,t)=>lt.create("connection",e,"Connection failed",{description:"Failed to establish connection",code:ks.FAILED,...t}),subscribeFailed:(e,t)=>lt.create("connection",e,"Subscription failed",{description:"Failed to subscribe to subject",code:ks.INTERNAL_ERROR,...t}),requestFailed:(e,t)=>lt.create("connection",e,"Request failed",{description:"Failed to send request",code:ks.INTERNAL_ERROR,...t}),timeout:(e,t)=>lt.create("connection",e,"Connection timeout",{description:"Connection attempt timed out",code:ks.TIMEOUT,...t}),notConnected:(e,t)=>lt.create("connection",e,"Not connected",{description:"Connection is not established",code:ks.INTERNAL_ERROR,...t}),invalidState:(e,t)=>lt.create("connection",e,"Invalid connection state",{description:"Connection is in invalid state",code:ks.INVALID_STATE,...t}),internalError:(e,t)=>lt.create("connection",e,"Internal connection error",{description:"Internal connection error",code:ks.INTERNAL_ERROR,...t})}),p(lt,"config",{missing:(e,t)=>lt.create("config",e,"Missing configuration",{description:"Required configuration is missing",code:Ir.MISSING,...t}),invalid:(e,t)=>lt.create("config",e,"Invalid configuration",{description:"Invalid configuration provided",code:Ir.INVALID,...t}),internalError:(e,t)=>lt.create("config",e,"Internal configuration error",{description:"Internal configuration error",code:Ir.INTERNAL_ERROR,...t})}),p(lt,"auth",{unauthorized:(e,t)=>lt.create("auth",e,"Unauthorized",{description:"Authentication failed",code:en.UNAUTHORIZED,...t}),forbidden:(e,t)=>lt.create("auth",e,"Forbidden",{description:"Insufficient permissions",code:en.FORBIDDEN,...t}),internalError:(e,t)=>lt.create("auth",e,"Internal auth error",{description:"Internal auth error",code:en.INTERNAL_ERROR,...t})}),p(lt,"client",{registrationFailed:(e,t)=>lt.create("client",e,"Registration failed",{description:"Failed to register client",code:$n.REGISTRATION_FAILED,...t}),notFound:(e,t)=>lt.create("client",e,"Client not found",{description:"Requested client could not be found",code:$n.NOT_FOUND,...t}),invalidState:(e,t)=>lt.create("client",e,"Invalid client state",{description:"Client is in invalid state",code:$n.INVALID_STATE,...t}),internalError:(e,t)=>lt.create("client",e,"Internal client error",{description:"Internal client error",code:$n.INTERNAL_ERROR,...t})}),p(lt,"message",{invalidFormat:(e,t)=>lt.create("message",e,"Invalid message format",{description:"Failed to parse message",code:zn.INVALID_FORMAT,...t}),deliveryFailed:(e,t)=>lt.create("message",e,"Message delivery failed",{description:"Failed to deliver message",code:zn.DELIVERY_FAILED,...t}),timeout:(e,t)=>lt.create("message",e,"Message timeout",{description:"Message processing timed out",code:zn.TIMEOUT,...t}),executionFailed:(e,t)=>lt.create("message",e,"Message execution failed",{description:"Failed to execute message",code:zn.EXECUTION_FAILED,...t}),internalError:(e,t)=>lt.create("message",e,"Internal message error",{description:"Internal message error",code:zn.INTERNAL_ERROR,...t})}),p(lt,"cluster",{joinFailed:(e,t)=>lt.create("cluster",e,"Failed to join cluster",{description:"Failed to join cluster",code:sr.JOIN_FAILED,...t}),syncFailed:(e,t)=>lt.create("cluster",e,"Failed to sync cluster",{description:"Failed to sync cluster",code:sr.SYNC_FAILED,...t}),nodeNotFound:(e,t)=>lt.create("cluster",e,"Node not found",{description:"Requested node could not be found",code:sr.NODE_NOT_FOUND,...t}),instanceNotFound:(e,t)=>lt.create("cluster",e,"Instance not found",{description:"Requested instance could not be found",code:sr.INSTANCE_NOT_FOUND,...t}),communicationFailed:(e,t)=>lt.create("cluster",e,"Communication failed",{description:"Cluster communication failed",code:sr.COMMUNICATION_FAILED,...t}),invalidState:(e,t)=>lt.create("cluster",e,"Invalid cluster state",{description:"Cluster is in invalid state",code:sr.INVALID_STATE,...t}),internalError:(e,t)=>lt.create("cluster",e,"Internal cluster error",{description:"Internal cluster error",code:sr.INTERNAL_ERROR,...t})}),p(lt,"registry",{internalError:(e,t)=>lt.create("registry",e,"Internal registry error",{description:"Internal registry error",code:Wh.INTERNAL_ERROR,...t})}),p(lt,"rpc",{methodNotFound:(e,t,n)=>lt.create("rpc",t,`Method not found: ${e}`,{description:"Requested method could not be found",code:rr.METHOD_NOT_FOUND,...n}),invalidRequest:(e,t)=>lt.create("rpc",e,"Invalid request",{description:"Invalid RPC request",code:rr.INVALID_REQUEST,...t}),requestFailed:(e,t)=>lt.create("rpc",e,"RPC request failed",{description:"Failed to send RPC request",code:rr.INTERNAL_ERROR,...t}),executionFailed:(e,t)=>lt.create("rpc",e,"RPC execution failed",{description:"Failed to execute RPC request",code:rr.INTERNAL_ERROR,...t}),connectionFailed:(e,t)=>lt.create("rpc",e,"Failed to get RPC connection",{description:"Failed to get RPC connection",code:rr.CONNECTION_FAILED,...t}),internalError:(e,t)=>lt.create("rpc",e,"Internal RPC error",{description:"Internal RPC error",code:rr.INTERNAL_ERROR,...t})});let kt=lt;class ns{static getPluginToPluginSubject(e,t){return this.createRoutingPattern("plugin","plugin",e,t)}static getPluginToServiceSubject(e,t){return this.createRoutingPattern("plugin","service",e,t)}static getServiceToServiceSubject(e,t){return this.createRoutingPattern("service","service",e,t)}static getServiceToPluginSubject(e,t){return this.createRoutingPattern("service","plugin",e,t)}static getPluginToServerSubject(e,t){return this.createRoutingPattern("plugin","server",e,t)}static getServiceToServerSubject(e,t){return this.createRoutingPattern("service","server",e,t)}static getServerToPluginSubject(e,t){return this.createRoutingPattern("server","plugin",e,t)}static getServerToServiceSubject(e,t){return this.createRoutingPattern("server","service",e,t)}static createRoutingMetadata(e,t,n,r){const i={source:{type:e,id:t}};return n&&r&&(i.target={type:n,id:r}),i}static createRoutingPattern(e,t,n,r){return r?`${e}.${t}.${n}.${r}`:`${e}.${t}.${n}.*`}}class _o{static validateMetadata(e){if(!e.id)throw kt.config.invalid(void 0,{description:"Invalid ID in metadata",code:Ir.INVALID,metadata:{metadata:e}});if(!e.name)throw kt.config.invalid(void 0,{description:"Invalid name in metadata",code:Ir.INVALID,metadata:{metadata:e}})}static validateConnectionOptions(e){if(_o.validateMetadata(e.metadata),!e.endpoints||e.endpoints.length===0)throw kt.config.invalid(void 0,{description:"No NATS endpoints provided",code:Ir.INVALID,metadata:{endpoints:e.endpoints}});if(!e.auth)throw kt.config.invalid(void 0,{description:"No authentication configuration provided",code:en.INVALID_CREDENTIALS});if("server"in e.auth){const{server:t,cluster:n}=e.auth;if(!t||typeof t!="object")throw kt.config.invalid(void 0,{description:"Missing server authentication configuration",code:en.INVALID_CREDENTIALS});if(!n||typeof n!="object")throw kt.config.invalid(void 0,{description:"Missing cluster authentication configuration",code:en.INVALID_CREDENTIALS});if(typeof t.user!="string"||t.user.length===0)throw kt.config.invalid(void 0,{description:"Invalid server username provided",code:en.INVALID_CREDENTIALS,metadata:{provided:{user:t.user}}});if(typeof t.password!="string"||t.password.length===0)throw kt.config.invalid(void 0,{description:"Invalid server password provided",code:en.INVALID_CREDENTIALS,metadata:{provided:{password:"***"}}});if(typeof n.user!="string"||n.user.length===0)throw kt.config.invalid(void 0,{description:"Invalid cluster username provided",code:en.INVALID_CREDENTIALS,metadata:{provided:{user:n.user}}});if(typeof n.password!="string"||n.password.length===0)throw kt.config.invalid(void 0,{description:"Invalid cluster password provided",code:en.INVALID_CREDENTIALS,metadata:{provided:{password:"***"}}})}else{const{user:t,password:n}=e.auth;if(typeof t!="string"||t.length===0)throw kt.config.invalid(void 0,{description:"Invalid username provided",code:en.INVALID_CREDENTIALS,metadata:{provided:{user:t}}});if(typeof n!="string"||n.length===0)throw kt.config.invalid(void 0,{description:"Invalid password provided",code:en.INVALID_CREDENTIALS,metadata:{provided:{password:"***"}}})}}}var Ti=tn(288);const rn=new Uint8Array(0),Dr=new TextEncoder,sn=new TextDecoder;function Ki(...s){const e=[];for(let t=0;t<s.length;t++)e.push(Dr.encode(s[t]));return e.length===0?rn:e.length===1?e[0]:function(...t){let n=0;for(let o=0;o<t.length;o++)n+=t[o].length;const r=new Uint8Array(n);let i=0;for(let o=0;o<t.length;o++)r.set(t[o],i),i+=t[o].length;return r}(...e)}function Eu(s){return s&&s.length!==0?sn.decode(s):""}const Au="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";function S1(s){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(s):function(t){for(let n=0;n<t.length;n++)t[n]=Math.floor(255*Math.random())}(s)}const vr=new class{constructor(){p(this,"buf");p(this,"seq");p(this,"inc");p(this,"inited");this.buf=new Uint8Array(22),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(0xcfd41b9100000*Math.random()),this.inc=Math.floor(300*Math.random()+33)}setPre(){const s=new Uint8Array(12);S1(s);for(let e=0;e<12;e++){const t=s[e]%36;this.buf[e]=Au.charCodeAt(t)}}fillSeq(){let s=this.seq;for(let e=21;e>=12;e--)this.buf[e]=Au.charCodeAt(s%36),s=Math.floor(s/36)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}};var Tn,ii,Re;(function(s){s.Disconnect="disconnect",s.Reconnect="reconnect",s.Update="update",s.LDM="ldm",s.Error="error"})(Tn||(Tn={})),function(s){s.Reconnecting="reconnecting",s.PingTimer="pingTimer",s.StaleConnection="staleConnection",s.ClientInitiatedReconnect="client initiated reconnect"}(ii||(ii={})),function(s){s.ApiError="BAD API",s.BadAuthentication="BAD_AUTHENTICATION",s.BadCreds="BAD_CREDS",s.BadHeader="BAD_HEADER",s.BadJson="BAD_JSON",s.BadPayload="BAD_PAYLOAD",s.BadSubject="BAD_SUBJECT",s.Cancelled="CANCELLED",s.ConnectionClosed="CONNECTION_CLOSED",s.ConnectionDraining="CONNECTION_DRAINING",s.ConnectionRefused="CONNECTION_REFUSED",s.ConnectionTimeout="CONNECTION_TIMEOUT",s.Disconnect="DISCONNECT",s.InvalidOption="INVALID_OPTION",s.InvalidPayload="INVALID_PAYLOAD",s.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",s.NoResponders="503",s.NotFunction="NOT_FUNC",s.RequestError="REQUEST_ERROR",s.ServerOptionNotAvailable="SERVER_OPT_NA",s.SubClosed="SUB_CLOSED",s.SubDraining="SUB_DRAINING",s.Timeout="TIMEOUT",s.Tls="TLS",s.Unknown="UNKNOWN_ERROR",s.WssRequired="WSS_REQUIRED",s.JetStreamInvalidAck="JESTREAM_INVALID_ACK",s.JetStream404NoMessages="404",s.JetStream408RequestTimeout="408",s.JetStream409MaxAckPendingExceeded="409",s.JetStream409="409",s.JetStreamNotEnabled="503",s.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",s.AuthorizationViolation="AUTHORIZATION_VIOLATION",s.AuthenticationExpired="AUTHENTICATION_EXPIRED",s.ProtocolError="NATS_PROTOCOL_ERR",s.PermissionsViolation="PERMISSIONS_VIOLATION",s.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",s.AccountExpired="ACCOUNT_EXPIRED"}(Re||(Re={}));class Jh{constructor(){p(this,"messages");this.messages=new Map,this.messages.set(Re.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(Re.BadJson,"Bad JSON"),this.messages.set(Re.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(e){return C1.getMessage(e)}getMessage(e){return this.messages.get(e)||e}}const C1=new Jh;class Ve extends Error{constructor(t,n,r){super(t);p(this,"name");p(this,"message");p(this,"code");p(this,"permissionContext");p(this,"chainedError");p(this,"api_error");this.name="NatsError",this.message=t,this.code=n,this.chainedError=r}static errorForCode(t,n){const r=Jh.getMessage(t);return new Ve(r,t,n)}isAuthError(){return this.code===Re.AuthenticationExpired||this.code===Re.AuthorizationViolation||this.code===Re.AccountExpired}isAuthTimeout(){return this.code===Re.AuthenticationTimeout}isPermissionError(){return this.code===Re.PermissionsViolation}isProtocolError(){return this.code===Re.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var Ys,bn,Zi;(function(s){s[s.Exact=0]="Exact",s[s.CanonicalMIME=1]="CanonicalMIME",s[s.IgnoreCase=2]="IgnoreCase"})(Ys||(Ys={})),function(s){s.Timer="timer",s.Count="count",s.JitterTimer="jitterTimer",s.SentinelMsg="sentinelMsg"}(bn||(bn={})),function(s){s.STATS="io.nats.micro.v1.stats_response",s.INFO="io.nats.micro.v1.info_response",s.PING="io.nats.micro.v1.ping_response"}(Zi||(Zi={}));const na="Nats-Service-Error",ra="Nats-Service-Error-Code";class ia extends Error{constructor(t,n){super(n);p(this,"code");this.code=t}static isServiceError(t){return ia.toServiceError(t)!==null}static toServiceError(t){var r,i;const n=((r=t==null?void 0:t.headers)==null?void 0:r.get(ra))||"";if(n!==""){const o=parseInt(n)||400,a=((i=t==null?void 0:t.headers)==null?void 0:i.get(na))||"";return new ia(o,a.length?a:n)}return null}}function Qn(s=""){if(typeof(s=s||"_INBOX")!="string")throw new Error("prefix must be a string");return s.split(".").forEach(e=>{if(e==="*"||e===">")throw new Error(`inbox prefixes cannot have wildcards '${s}'`)}),`${s}.${vr.next()}`}const lc="127.0.0.1";var dr;function Ma(s,...e){for(let t=0;t<e.length;t++){const n=e[t];Object.keys(n).forEach(function(r){s[r]=n[r]})}return s}function Eo(s){return sn.decode(s).replace(/\n/g,"␊").replace(/\r/g,"␍")}function pi(s,e=!0){const t=e?Ve.errorForCode(Re.Timeout):null;let n,r;const i=new Promise((o,a)=>{n={cancel:()=>{r&&clearTimeout(r)}},r=setTimeout(()=>{a(t===null?Ve.errorForCode(Re.Timeout):t)},s)});return Object.assign(i,n)}function Pi(s=0){let e;const t=new Promise(n=>{const r=setTimeout(()=>{n()},s);e={cancel:()=>{r&&clearTimeout(r)}}});return Object.assign(t,e)}function is(){let s={};const e=new Promise((t,n)=>{s={resolve:t,reject:n}});return Object.assign(e,s)}function Yh(s){for(let e=s.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[s[e],s[t]]=[s[t],s[e]]}return s}(function(s){s.PING="PING",s.STATS="STATS",s.INFO="INFO"})(dr||(dr={}));function al(s=[0,250,250,500,500,3e3,5e3]){Array.isArray(s)||(s=[0,250,250,500,500,3e3,5e3]);const e=s.length-1;return{backoff:t=>function(n){return n===0?0:Math.floor(n/2+Math.random()*n)}(t>e?s[e]:s[t])}}function rs(s){return 1e6*s}function cl(s){return Math.floor(s/1e6)}function Mu(s){let e=!0;const t=new Array(s.length);for(let n=0;n<s.length;n++){let r=s.charCodeAt(n);if(r===58||r<33||r>126)throw new Ve(`'${s[n]}' is not a valid character for a header key`,Re.BadHeader);e&&97<=r&&r<=122?r-=32:!e&&65<=r&&r<=90&&(r+=32),t[n]=r,e=r==45}return String.fromCharCode(...t)}function Zn(s=0,e=""){if(s===0&&e!==""||s>0&&e==="")throw new Error("setting status requires both code and description");return new hr(s,e)}const ja="NATS/1.0";class hr{constructor(e=0,t=""){p(this,"_code");p(this,"headers");p(this,"_description");this._code=e,this._description=t,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[t,n]of this.headers){const r=e.values(t);if(n.length!==r.length)return!1;const i=[...n].sort(),o=[...r].sort();for(let a=0;a<i.length;a++)if(i[a]!==o[a])return!1}return!0}return!1}static decode(e){const t=new hr,n=sn.decode(e).split(`\r
3
- `),r=n[0];if(r!==ja){let i=r.replace(ja,"").trim();if(i.length>0){t._code=parseInt(i,10),isNaN(t._code)&&(t._code=0);const o=t._code.toString();i=i.replace(o,""),t._description=i.trim()}}return n.length>=1&&n.slice(1).map(i=>{if(i){const o=i.indexOf(":");if(o>-1){const a=i.slice(0,o),l=i.slice(o+1).trim();t.append(a,l)}}}),t}toString(){if(this.headers.size===0&&this._code===0)return"";let e=ja;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[t,n]of this.headers)for(let r=0;r<n.length;r++)e=`${e}\r
4
- ${t}: ${n[r]}`;return`${e}\r
5
- \r
6
- `}encode(){return Dr.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw new Ve("invalid header value - \\r and \\n are not allowed.",Re.BadHeader);return e.trim()}keys(){const e=[];for(const t of this.headers.keys())e.push(t);return e}findKeys(e,t=Ys.Exact){const n=this.keys();switch(t){case Ys.Exact:return n.filter(r=>r===e);case Ys.CanonicalMIME:return e=Mu(e),n.filter(r=>r===e);default:{const r=e.toLowerCase();return n.filter(i=>r===i.toLowerCase())}}}get(e,t=Ys.Exact){const n=this.findKeys(e,t);if(n.length){const r=this.headers.get(n[0]);if(r)return Array.isArray(r)?r[0]:r}return""}last(e,t=Ys.Exact){const n=this.findKeys(e,t);if(n.length){const r=this.headers.get(n[0]);if(r)return Array.isArray(r)?r[r.length-1]:r}return""}has(e,t=Ys.Exact){return this.findKeys(e,t).length>0}set(e,t,n=Ys.Exact){this.delete(e,n),this.append(e,t,n)}append(e,t,n=Ys.Exact){const r=Mu(e);n===Ys.CanonicalMIME&&(e=r);const i=this.findKeys(e,n);e=i.length>0?i[0]:e;const o=hr.validHeaderValue(t);let a=this.headers.get(e);a||(a=[],this.headers.set(e,a)),a.push(o)}values(e,t=Ys.Exact){const n=[];return this.findKeys(e,t).forEach(r=>{const i=this.headers.get(r);i&&n.push(...i)}),n}delete(e,t=Ys.Exact){this.findKeys(e,t).forEach(n=>{this.headers.delete(n)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const e={};return this.keys().forEach(t=>{e[t]=this.values(t)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(e){const t=new hr;for(const n in e)t.headers.set(n,e[n]);return t}}function $u(){return{encode:s=>Dr.encode(s),decode:s=>sn.decode(s)}}function wn(s){return{encode(e){try{return e===void 0&&(e=null),Dr.encode(JSON.stringify(e))}catch(t){throw Ve.errorForCode(Re.BadJson,t)}},decode(e){try{return JSON.parse(sn.decode(e),s)}catch(t){throw Ve.errorForCode(Re.BadJson,t)}}}}function Xh(s){var e;return s&&s.data.length===0&&((e=s.headers)==null?void 0:e.code)===503?Ve.errorForCode(Re.NoResponders):null}class ll{constructor(e,t,n){p(this,"_headers");p(this,"_msg");p(this,"_rdata");p(this,"_reply");p(this,"_subject");p(this,"publisher");this._msg=e,this._rdata=t,this.publisher=n}get subject(){return this._subject||(this._subject=sn.decode(this._msg.subject)),this._subject}get reply(){return this._reply||(this._reply=sn.decode(this._msg.reply)),this._reply}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const e=this._rdata.subarray(0,this._msg.hdr);this._headers=hr.decode(e)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(e=rn,t){return!!this.reply&&(this.publisher.publish(this.reply,e,t),!0)}size(){var e;return this._msg.subject.length+(((e=this._msg.reply)==null?void 0:e.length)||0)+(this._msg.size===-1?0:this._msg.size)}json(e){return wn(e).decode(this.data)}string(){return sn.decode(this.data)}requestInfo(){var t;const e=(t=this.headers)==null?void 0:t.get("Nats-Request-Info");return e?JSON.parse(e,function(n,r){return n!=="start"&&n!=="stop"||r===""?r:new Date(Date.parse(r))}):null}}p(ll,"jc");function oi(s){return $a("durable",s)}function zs(s){return $a("stream",s)}function $a(s,e=""){if(e==="")throw Error(`${s} name required`);return[".","*",">","/","\\"," "," ",`
7
- `,"\r"].forEach(t=>{if(e.indexOf(t)!==-1){switch(t){case`
8
- `:t="\\n";break;case"\r":t="\\r";break;case" ":t="\\t"}throw Error(`invalid ${s} name - ${s} name cannot contain '${t}'`)}}),""}function Vi(s,e=""){if(e==="")throw Error(`${s} name required`);const t=function(n=""){if(n==="")throw Error("name required");const r=/^[-\w]+$/g;if(n.match(r)===null){for(const o of n.split(""))if(o.match(r)===null)return`cannot contain '${o}'`}return""}(e);if(t.length)throw new Error(`invalid ${s} name - ${s} name ${t}`)}function uc(s){if(s.data.length>0)return!1;const e=s.headers;return!!e&&e.code>=100&&e.code<200}function dc(s){var e;return uc(s)&&((e=s.headers)==null?void 0:e.description)==="Idle Heartbeat"}function Yr(s){if(s.data.length!==0)return null;const e=s.headers;return e?em(e.code,e.description):null}var un;(function(s){s.MaxBatchExceeded="exceeded maxrequestbatch of",s.MaxExpiresExceeded="exceeded maxrequestexpires of",s.MaxBytesExceeded="exceeded maxrequestmaxbytes of",s.MaxMessageSizeExceeded="message size exceeds maxbytes",s.PushConsumer="consumer is push based",s.MaxWaitingExceeded="exceeded maxwaiting",s.IdleHeartbeatMissed="idle heartbeats missed",s.ConsumerDeleted="consumer deleted"})(un||(un={}));function em(s,e=""){if(s<300)return null;switch(e=e.toLowerCase(),s){case 404:return new Ve(e,Re.JetStream404NoMessages);case 408:return new Ve(e,Re.JetStream408RequestTimeout);case 409:{const t=e.startsWith(un.IdleHeartbeatMissed)?Re.JetStreamIdleHeartBeat:Re.JetStream409;return new Ve(e,t)}case 503:return Ve.errorForCode(Re.JetStreamNotEnabled,new Error(e));default:return e===""&&(e=Re.Unknown),new Ve(e,`${s}`)}}class Es{constructor(){p(this,"inflight");p(this,"processed");p(this,"received");p(this,"noIterator");p(this,"iterClosed");p(this,"done");p(this,"signal");p(this,"yields");p(this,"filtered");p(this,"pendingFiltered");p(this,"ingestionFilterFn");p(this,"protocolFilterFn");p(this,"dispatchedFn");p(this,"ctx");p(this,"_data");p(this,"err");p(this,"time");p(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=is(),this.yields=[],this.iterClosed=is(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(this.done)return;if(typeof e=="function")return this.yields.push(e),void this.signal.resolve();const{ingest:t,protocol:n}=this.ingestionFilterFn?this.ingestionFilterFn(e,this.ctx||this):{ingest:!0,protocol:!1};t&&(n&&(this.filtered++,this.pendingFiltered++),this.yields.push(e),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new Ve("unsupported iterator",Re.ApiError);if(this.yielding)throw new Ve("already yielding",Re.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const e=this.yields;this.inflight=e.length,this.yields=[];for(let t=0;t<e.length;t++){if(typeof e[t]=="function"){const n=e[t];try{n()}catch(r){throw r}if(this.err)throw this.err;continue}if(!this.protocolFilterFn||this.protocolFilterFn(e[t])){this.processed++;const n=Date.now();yield e[t],this.time=Date.now()-n,this.dispatchedFn&&e[t]&&this.dispatchedFn(e[t])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=is())}}finally{this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(e))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class ul{constructor(e,t,n={maxOut:2}){p(this,"interval");p(this,"maxOut");p(this,"cancelAfter");p(this,"timer");p(this,"autoCancelTimer");p(this,"last");p(this,"missed");p(this,"count");p(this,"callback");this.interval=e,this.maxOut=(n==null?void 0:n.maxOut)||2,this.cancelAfter=(n==null?void 0: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)}}var hc,Xi,mc,hs,Cs,ai,_r,oa,Tu,Hs,_n,ti,Pu;(function(s){s.Limits="limits",s.Interest="interest",s.Workqueue="workqueue"})(hc||(hc={})),function(s){s.Old="old",s.New="new"}(Xi||(Xi={})),function(s){s.File="file",s.Memory="memory"}(mc||(mc={})),function(s){s.All="all",s.Last="last",s.New="new",s.StartSequence="by_start_sequence",s.StartTime="by_start_time",s.LastPerSubject="last_per_subject"}(hs||(hs={})),function(s){s.None="none",s.All="all",s.Explicit="explicit",s.NotSet=""}(Cs||(Cs={})),function(s){s.Instant="instant",s.Original="original"}(ai||(ai={})),function(s){s.None="none",s.S2="s2"}(_r||(_r={})),function(s){s.CreateOrUpdate="",s.Update="update",s.Create="create"}(oa||(oa={})),function(s){s.API="api_audit",s.StreamAction="stream_action",s.ConsumerAction="consumer_action",s.SnapshotCreate="snapshot_create",s.SnapshotComplete="snapshot_complete",s.RestoreCreate="restore_create",s.RestoreComplete="restore_complete",s.MaxDeliver="max_deliver",s.Terminated="terminated",s.Ack="consumer_ack",s.StreamLeaderElected="stream_leader_elected",s.StreamQuorumLost="stream_quorum_lost",s.ConsumerLeaderElected="consumer_leader_elected",s.ConsumerQuorumLost="consumer_quorum_lost"}(Tu||(Tu={})),function(s){s.StreamSourceHdr="Nats-Stream-Source",s.LastConsumerSeqHdr="Nats-Last-Consumer",s.LastStreamSeqHdr="Nats-Last-Stream",s.ConsumerStalledHdr="Nats-Consumer-Stalled",s.MessageSizeHdr="Nats-Msg-Size",s.RollupHdr="Nats-Rollup",s.RollupValueSubject="sub",s.RollupValueAll="all",s.PendingMessagesHdr="Nats-Pending-Messages",s.PendingBytesHdr="Nats-Pending-Bytes"}(Hs||(Hs={})),function(s){s.LastValue="",s.AllHistory="history",s.UpdatesOnly="updates"}(_n||(_n={})),function(s){s.Stream="Nats-Stream",s.Sequence="Nats-Sequence",s.TimeStamp="Nats-Time-Stamp",s.Subject="Nats-Subject"}(ti||(ti={})),function(s){s.Stream="Nats-Stream",s.Subject="Nats-Subject",s.Sequence="Nats-Sequence",s.LastSequence="Nats-Last-Sequence",s.Size="Nats-Msg-Size"}(Pu||(Pu={}));const Dn="KV_";class k1{constructor(e){p(this,"config");p(this,"ordered");p(this,"mack");p(this,"stream");p(this,"callbackFn");p(this,"max");p(this,"qname");p(this,"isBind");p(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=function(t,n={}){return Object.assign({name:t,deliver_policy:hs.All,ack_policy:Cs.Explicit,ack_wait:rs(3e4),replay_policy:ai.Instant},n)}("",e||{})}getOpts(){var t;const e={};if(e.config=Object.assign({},this.config),e.config.filter_subject&&(this.filterSubject(e.config.filter_subject),e.config.filter_subject=void 0),e.config.filter_subjects&&((t=e.config.filter_subjects)==null||t.forEach(n=>{this.filterSubject(n)}),e.config.filter_subjects=void 0),e.mack=this.mack,e.stream=this.stream,e.callbackFn=this.callbackFn,e.max=this.max,e.queue=this.qname,e.ordered=this.ordered,e.config.ack_policy=e.ordered?Cs.None:e.config.ack_policy,e.isBind=e.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:e.config.filter_subject=this.filters[0];break;default:e.config.filter_subjects=this.filters}return e}description(e){return this.config.description=e,this}deliverTo(e){return this.config.deliver_subject=e,this}durable(e){return oi(e),this.config.durable_name=e,this}startSequence(e){if(e<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=hs.StartSequence,this.config.opt_start_seq=e,this}startTime(e){return this.config.deliver_policy=hs.StartTime,this.config.opt_start_time=e.toISOString(),this}deliverAll(){return this.config.deliver_policy=hs.All,this}deliverLastPerSubject(){return this.config.deliver_policy=hs.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=hs.Last,this}deliverNew(){return this.config.deliver_policy=hs.New,this}startAtTimeDelta(e){return this.startTime(new Date(Date.now()-e)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=Cs.None,this}ackAll(){return this.config.ack_policy=Cs.All,this}ackExplicit(){return this.config.ack_policy=Cs.Explicit,this}ackWait(e){return this.config.ack_wait=rs(e),this}maxDeliver(e){return this.config.max_deliver=e,this}filterSubject(e){return this.filters=this.filters||[],this.filters.push(e),this}replayInstantly(){return this.config.replay_policy=ai.Instant,this}replayOriginal(){return this.config.replay_policy=ai.Original,this}sample(e){if((e=Math.trunc(e))<0||e>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${e}%`,this}limit(e){return this.config.rate_limit_bps=e,this}maxWaiting(e){return this.config.max_waiting=e,this}maxAckPending(e){return this.config.max_ack_pending=e,this}idleHeartbeat(e){return this.config.idle_heartbeat=rs(e),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(e){return this.queue(e),this}manualAck(){return this.mack=!0,this}maxMessages(e){return this.max=e,this}callback(e){return this.callbackFn=e,this}queue(e){return this.qname=e,this.config.deliver_group=e,this}orderedConsumer(){return this.ordered=!0,this}bind(e,t){return this.stream=e,this.config.durable_name=t,this.isBind=!0,this}bindStream(e){return this.stream=e,this}inactiveEphemeralThreshold(e){return this.config.inactive_threshold=rs(e),this}maxPullBatch(e){return this.config.max_batch=e,this}maxPullRequestExpires(e){return this.config.max_expires=rs(e),this}memory(){return this.config.mem_storage=!0,this}numReplicas(e){return this.config.num_replicas=e,this}consumerName(e){return this.config.name=e,this}}function mr(s){return new k1(s)}function Ru(s){return typeof s.getOpts=="function"}class E1{static encode(e){if(typeof e=="string")return btoa(e);const t=Array.from(e);return btoa(String.fromCharCode(...t))}static decode(e,t=!1){const n=atob(e);return t?Uint8Array.from(n,r=>r.charCodeAt(0)):n}}class ci{static encode(e){return ci.toB64URLEncoding(E1.encode(e))}static decode(e,t=!1){return ci.decode(ci.fromB64URLEncoding(e),t)}static toB64URLEncoding(e){return e.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(e){return e.replace(/_/g,"/").replace(/-/g,"+")}}class fi{constructor(){p(this,"buffers");p(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let t=0;for(let i=0;i<e.length;i++)t+=e[i].length;const n=new Uint8Array(t);let r=0;for(let i=0;i<e.length;i++)n.set(e[i],r),r+=e[i].length;return n}static fromAscii(e){return e||(e=""),Dr.encode(e)}static toAscii(e){return sn.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const e=new Uint8Array(this.byteLength);let t=0;for(let n=0;n<this.buffers.length;n++)e.set(this.buffers[n],t),t+=this.buffers[n].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const t=this.buffers.pop();if(t){const n=this.byteLength;(e===void 0||e>n)&&(e=n);const r=t.subarray(0,e);return n>e&&this.buffers.push(t.subarray(e)),this.byteLength=n-e,r}}return new Uint8Array(0)}fill(e,...t){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let n=0;n<t.length;n++)t[n]&&t[n].length&&(this.buffers.push(t[n]),this.byteLength+=t[n].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}var A1=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Fi=A1.performance||{};Fi.now||Fi.mozNow||Fi.msNow||Fi.oNow||Fi.webkitNow;var Iu={versions:{}},M1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},qa,dl={exports:{}},Ou={},Nu=function(s){if(s.__esModule)return s;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(s).forEach(function(t){var n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return s[t]}})}),e}(function(s,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!=="default"&&!(n in s)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(s)}({__proto__:null,default:Ou},[Ou]));qa=dl,function(){var s="input is invalid type",e=typeof window=="object",t=e?window:{};t.JS_SHA256_NO_WINDOW&&(e=!1);var n=!e&&typeof self=="object",r=!t.JS_SHA256_NO_NODE_JS&&Iu.versions&&Iu.versions.node;r?t=M1:n&&(t=self);var i=!t.JS_SHA256_NO_COMMON_JS&&qa.exports,o=!t.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",a="0123456789abcdef".split(""),l=[-2147483648,8388608,32768,128],u=[24,16,8,0],d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],h=["hex","array","digest","arrayBuffer"],v=[];!t.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),!o||!t.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});var f=function(E,O){return function(U){return new se(O,!0).update(U)[E]()}},b=function(E){var O=f("hex",E);r&&(O=k(O,E)),O.create=function(){return new se(E)},O.update=function(M){return O.create().update(M)};for(var U=0;U<h.length;++U){var S=h[U];O[S]=f(S,E)}return O},k=function(E,O){var U,S=Nu,M=Nu.Buffer,B=O?"sha224":"sha256";return U=M.from&&!t.JS_SHA256_NO_BUFFER_FROM?M.from:function(W){return new M(W)},function(W){if(typeof W=="string")return S.createHash(B).update(W,"utf8").digest("hex");if(W==null)throw new Error(s);return W.constructor===ArrayBuffer&&(W=new Uint8Array(W)),Array.isArray(W)||ArrayBuffer.isView(W)||W.constructor===M?S.createHash(B).update(U(W)).digest("hex"):E(W)}},z=function(E,O){return function(U,S){return new K(U,O,!0).update(S)[E]()}},L=function(E){var O=z("hex",E);O.create=function(M){return new K(M,E)},O.update=function(M,B){return O.create(M).update(B)};for(var U=0;U<h.length;++U){var S=h[U];O[S]=z(S,E)}return O};function se(E,O){O?(v[0]=v[16]=v[1]=v[2]=v[3]=v[4]=v[5]=v[6]=v[7]=v[8]=v[9]=v[10]=v[11]=v[12]=v[13]=v[14]=v[15]=0,this.blocks=v):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],E?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=E}function K(E,O,U){var S,M=typeof E;if(M==="string"){var B,W=[],I=E.length,w=0;for(S=0;S<I;++S)(B=E.charCodeAt(S))<128?W[w++]=B:B<2048?(W[w++]=192|B>>>6,W[w++]=128|63&B):B<55296||B>=57344?(W[w++]=224|B>>>12,W[w++]=128|B>>>6&63,W[w++]=128|63&B):(B=65536+((1023&B)<<10|1023&E.charCodeAt(++S)),W[w++]=240|B>>>18,W[w++]=128|B>>>12&63,W[w++]=128|B>>>6&63,W[w++]=128|63&B);E=W}else{if(M!=="object")throw new Error(s);if(E===null)throw new Error(s);if(o&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!(Array.isArray(E)||o&&ArrayBuffer.isView(E)))throw new Error(s)}E.length>64&&(E=new se(O,!0).update(E).array());var Q=[],J=[];for(S=0;S<64;++S){var q=E[S]||0;Q[S]=92^q,J[S]=54^q}se.call(this,O,U),this.update(J),this.oKeyPad=Q,this.inner=!0,this.sharedMemory=U}se.prototype.update=function(E){if(!this.finalized){var O,U=typeof E;if(U!=="string"){if(U!=="object")throw new Error(s);if(E===null)throw new Error(s);if(o&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!(Array.isArray(E)||o&&ArrayBuffer.isView(E)))throw new Error(s);O=!0}for(var S,M,B=0,W=E.length,I=this.blocks;B<W;){if(this.hashed&&(this.hashed=!1,I[0]=this.block,this.block=I[16]=I[1]=I[2]=I[3]=I[4]=I[5]=I[6]=I[7]=I[8]=I[9]=I[10]=I[11]=I[12]=I[13]=I[14]=I[15]=0),O)for(M=this.start;B<W&&M<64;++B)I[M>>>2]|=E[B]<<u[3&M++];else for(M=this.start;B<W&&M<64;++B)(S=E.charCodeAt(B))<128?I[M>>>2]|=S<<u[3&M++]:S<2048?(I[M>>>2]|=(192|S>>>6)<<u[3&M++],I[M>>>2]|=(128|63&S)<<u[3&M++]):S<55296||S>=57344?(I[M>>>2]|=(224|S>>>12)<<u[3&M++],I[M>>>2]|=(128|S>>>6&63)<<u[3&M++],I[M>>>2]|=(128|63&S)<<u[3&M++]):(S=65536+((1023&S)<<10|1023&E.charCodeAt(++B)),I[M>>>2]|=(240|S>>>18)<<u[3&M++],I[M>>>2]|=(128|S>>>12&63)<<u[3&M++],I[M>>>2]|=(128|S>>>6&63)<<u[3&M++],I[M>>>2]|=(128|63&S)<<u[3&M++]);this.lastByteIndex=M,this.bytes+=M-this.start,M>=64?(this.block=I[16],this.start=M-64,this.hash(),this.hashed=!0):this.start=M}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},se.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,O=this.lastByteIndex;E[16]=this.block,E[O>>>2]|=l[3&O],this.block=E[16],O>=56&&(this.hashed||this.hash(),E[0]=this.block,E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0),E[14]=this.hBytes<<3|this.bytes>>>29,E[15]=this.bytes<<3,this.hash()}},se.prototype.hash=function(){var E,O,U,S,M,B,W,I,w,Q=this.h0,J=this.h1,q=this.h2,oe=this.h3,ue=this.h4,Se=this.h5,F=this.h6,D=this.h7,Y=this.blocks;for(E=16;E<64;++E)O=((M=Y[E-15])>>>7|M<<25)^(M>>>18|M<<14)^M>>>3,U=((M=Y[E-2])>>>17|M<<15)^(M>>>19|M<<13)^M>>>10,Y[E]=Y[E-16]+O+Y[E-7]+U|0;for(w=J&q,E=0;E<64;E+=4)this.first?(this.is224?(B=300032,D=(M=Y[0]-1413257819)-150054599|0,oe=M+24177077|0):(B=704751109,D=(M=Y[0]-210244248)-1521486534|0,oe=M+143694565|0),this.first=!1):(O=(Q>>>2|Q<<30)^(Q>>>13|Q<<19)^(Q>>>22|Q<<10),S=(B=Q&J)^Q&q^w,D=oe+(M=D+(U=(ue>>>6|ue<<26)^(ue>>>11|ue<<21)^(ue>>>25|ue<<7))+(ue&Se^~ue&F)+d[E]+Y[E])|0,oe=M+(O+S)|0),O=(oe>>>2|oe<<30)^(oe>>>13|oe<<19)^(oe>>>22|oe<<10),S=(W=oe&Q)^oe&J^B,F=q+(M=F+(U=(D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7))+(D&ue^~D&Se)+d[E+1]+Y[E+1])|0,O=((q=M+(O+S)|0)>>>2|q<<30)^(q>>>13|q<<19)^(q>>>22|q<<10),S=(I=q&oe)^q&Q^W,Se=J+(M=Se+(U=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(F&D^~F&ue)+d[E+2]+Y[E+2])|0,O=((J=M+(O+S)|0)>>>2|J<<30)^(J>>>13|J<<19)^(J>>>22|J<<10),S=(w=J&q)^J&oe^I,ue=Q+(M=ue+(U=(Se>>>6|Se<<26)^(Se>>>11|Se<<21)^(Se>>>25|Se<<7))+(Se&F^~Se&D)+d[E+3]+Y[E+3])|0,Q=M+(O+S)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+Q|0,this.h1=this.h1+J|0,this.h2=this.h2+q|0,this.h3=this.h3+oe|0,this.h4=this.h4+ue|0,this.h5=this.h5+Se|0,this.h6=this.h6+F|0,this.h7=this.h7+D|0},se.prototype.hex=function(){this.finalize();var E=this.h0,O=this.h1,U=this.h2,S=this.h3,M=this.h4,B=this.h5,W=this.h6,I=this.h7,w=a[E>>>28&15]+a[E>>>24&15]+a[E>>>20&15]+a[E>>>16&15]+a[E>>>12&15]+a[E>>>8&15]+a[E>>>4&15]+a[15&E]+a[O>>>28&15]+a[O>>>24&15]+a[O>>>20&15]+a[O>>>16&15]+a[O>>>12&15]+a[O>>>8&15]+a[O>>>4&15]+a[15&O]+a[U>>>28&15]+a[U>>>24&15]+a[U>>>20&15]+a[U>>>16&15]+a[U>>>12&15]+a[U>>>8&15]+a[U>>>4&15]+a[15&U]+a[S>>>28&15]+a[S>>>24&15]+a[S>>>20&15]+a[S>>>16&15]+a[S>>>12&15]+a[S>>>8&15]+a[S>>>4&15]+a[15&S]+a[M>>>28&15]+a[M>>>24&15]+a[M>>>20&15]+a[M>>>16&15]+a[M>>>12&15]+a[M>>>8&15]+a[M>>>4&15]+a[15&M]+a[B>>>28&15]+a[B>>>24&15]+a[B>>>20&15]+a[B>>>16&15]+a[B>>>12&15]+a[B>>>8&15]+a[B>>>4&15]+a[15&B]+a[W>>>28&15]+a[W>>>24&15]+a[W>>>20&15]+a[W>>>16&15]+a[W>>>12&15]+a[W>>>8&15]+a[W>>>4&15]+a[15&W];return this.is224||(w+=a[I>>>28&15]+a[I>>>24&15]+a[I>>>20&15]+a[I>>>16&15]+a[I>>>12&15]+a[I>>>8&15]+a[I>>>4&15]+a[15&I]),w},se.prototype.toString=se.prototype.hex,se.prototype.digest=function(){this.finalize();var E=this.h0,O=this.h1,U=this.h2,S=this.h3,M=this.h4,B=this.h5,W=this.h6,I=this.h7,w=[E>>>24&255,E>>>16&255,E>>>8&255,255&E,O>>>24&255,O>>>16&255,O>>>8&255,255&O,U>>>24&255,U>>>16&255,U>>>8&255,255&U,S>>>24&255,S>>>16&255,S>>>8&255,255&S,M>>>24&255,M>>>16&255,M>>>8&255,255&M,B>>>24&255,B>>>16&255,B>>>8&255,255&B,W>>>24&255,W>>>16&255,W>>>8&255,255&W];return this.is224||w.push(I>>>24&255,I>>>16&255,I>>>8&255,255&I),w},se.prototype.array=se.prototype.digest,se.prototype.arrayBuffer=function(){this.finalize();var E=new ArrayBuffer(this.is224?28:32),O=new DataView(E);return O.setUint32(0,this.h0),O.setUint32(4,this.h1),O.setUint32(8,this.h2),O.setUint32(12,this.h3),O.setUint32(16,this.h4),O.setUint32(20,this.h5),O.setUint32(24,this.h6),this.is224||O.setUint32(28,this.h7),E},K.prototype=new se,K.prototype.finalize=function(){if(se.prototype.finalize.call(this),this.inner){this.inner=!1;var E=this.array();se.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(E),se.prototype.finalize.call(this)}};var N=b();N.sha256=N,N.sha224=b(!0),N.sha256.hmac=L(),N.sha224.hmac=L(!0),i?qa.exports=N:(t.sha256=N.sha256,t.sha224=N.sha224)}();dl.exports.sha224;var Fu=dl.exports.sha256;function pc(s){return function(e){switch(function(t){return function(n){if(!/^[0-9A-Fa-f]+$/.test(n))return!1;const r=/^[0-9A-F]+$/.test(n),i=/^[0-9a-f]+$/.test(n);return!r&&!i?!1:n.length%2==0}(t)?"hex":function(n){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(n)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(n)}(t)?"b64":""}(e)){case"hex":return function(t){if(t.length%2!=0)throw new Error("hex string must have an even length");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.substring(r,r+2),16);return n}(e);case"b64":return function(t){t=t.replace(/-/g,"+"),t=t.replace(/_/g,"/");const n=atob(t);return Uint8Array.from(n,r=>r.charCodeAt(0))}(e)}return null}(s)}function $1(s,e){const t=typeof s=="string"?pc(s):s,n=typeof e=="string"?pc(e):e;if(t===null||n===null||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r])return!1;return!0}class tm{constructor(e,t,n=!0){p(this,"token");p(this,"received");p(this,"ctx");p(this,"requestSubject");p(this,"mux");this.mux=e,this.requestSubject=t,this.received=0,this.token=vr.next(),n&&(this.ctx=new Error)}}class T1 extends tm{constructor(t,n,r={maxWait:1e3}){super(t,n);p(this,"callback");p(this,"done");p(this,"timer");p(this,"max");p(this,"opts");if(this.opts=r,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof r.maxMessages=="number"&&r.maxMessages>0?r.maxMessages:-1,this.done=is(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},r.maxWait)}cancel(t){t&&this.callback(t,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(t,n){t?(this.ctx&&(t.stack+=`
9
-
10
- ${this.ctx.stack}`),this.cancel(t)):(this.callback(null,n),this.opts.strategy===bn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===bn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===bn.SentinelMsg&&n&&n.data.length===0&&this.cancel())}}class sm extends tm{constructor(t,n,r={timeout:1e3},i=!0){super(t,n,i);p(this,"deferred");p(this,"timer");this.deferred=is(),this.timer=pi(r.timeout,i)}resolver(t,n){this.timer&&this.timer.cancel(),t?(this.ctx&&(t.stack+=`
11
-
12
- ${this.ctx.stack}`),this.deferred.reject(t)):this.deferred.resolve(n),this.cancel()}cancel(t){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(t||Ve.errorForCode(Re.Cancelled))}}class yo{constructor(e,t){p(this,"nc");p(this,"opts");p(this,"prefix");p(this,"timeout");p(this,"jc");this.nc=e,this.opts=function(n){return(n=n||{}).domain&&(n.apiPrefix=`$JS.${n.domain}.API`,delete n.domain),Ma({apiPrefix:"$JS.API",timeout:5e3},n)}(t),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=wn()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let e=this.opts.apiPrefix;if(!e||e.length===0)throw new Error("invalid empty prefix");e[e.length-1]==="."&&(e=e.substr(0,e.length-1)),this.opts.apiPrefix=e}async _request(e,t=null,n){(n=n||{}).timeout=this.timeout;let r=rn;t&&(r=this.jc.encode(t));let{retries:i}=n;i=i||1,i=i===-1?Number.MAX_SAFE_INTEGER:i;const o=al();for(let a=0;a<i;a++)try{const l=await this.nc.request(e,r,n);return this.parseJsResponse(l)}catch(l){const u=l;if(u.code!=="503"&&u.code!==Re.Timeout||!(a+1<i))throw l;await Pi(o.backoff(a))}}async findStream(e){const t={subject:e},n=await this._request(`${this.prefix}.STREAM.NAMES`,t);if(!n.streams||n.streams.length!==1)throw new Error("no stream matches subject");return n.streams[0]}getConnection(){return this.nc}parseJsResponse(e){const t=this.jc.decode(e.data),n=t;if(n.error){const r=em(n.error.code,n.error.description);if(r!==null)throw r.api_error=n.error,r}return t}}class Hi{constructor(e,t,n,r){p(this,"err");p(this,"offset");p(this,"pageInfo");p(this,"subject");p(this,"jsm");p(this,"filter");p(this,"payload");if(!e)throw new Error("subject is required");this.subject=e,this.jsm=n,this.offset=0,this.pageInfo={},this.filter=t,this.payload=r||{}}async next(){if(this.err)return[];if(this.pageInfo&&this.offset>=this.pageInfo.total)return[];const e={offset:this.offset};this.payload&&Object.assign(e,this.payload);try{const t=await this.jsm._request(this.subject,e,{timeout:this.jsm.timeout});this.pageInfo=t;const n=this.countResponse(t);return n===0?[]:(this.offset+=n,this.filter(t))}catch(t){throw this.err=t,t}}countResponse(e){var t,n,r;switch(e==null?void 0:e.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((t=e.streams)==null?void 0:t.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((n=e.consumers)==null?void 0:n.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${e==null?void 0:e.type}`),((r=e.streams)==null?void 0:r.length)||0}return 0}async*[Symbol.asyncIterator](){let e=await this.next();for(;e.length>0;){for(const t of e)yield t;e=await this.next()}}}function Or(s=""){const e=s.match(/(\d+).(\d+).(\d+)/);if(e)return{major:parseInt(e[1]),minor:parseInt(e[2]),micro:parseInt(e[3])};throw new Error(`'${s}' is not a semver value`)}function fc(s,e){return s.major<e.major?-1:s.major>e.major?1:s.minor<e.minor?-1:s.minor>e.minor?1:s.micro<e.micro?-1:s.micro>e.micro?1:0}var Nt;(function(s){s.JS_KV="js_kv",s.JS_OBJECTSTORE="js_objectstore",s.JS_PULL_MAX_BYTES="js_pull_max_bytes",s.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",s.JS_ALLOW_DIRECT="js_allow_direct",s.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",s.JS_SIMPLIFICATION="js_simplification",s.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",s.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",s.JS_STREAM_FIRST_SEQ="js_stream_first_seq",s.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",s.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",s.JS_STREAM_COMPRESSION="js_stream_compression",s.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",s.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Nt||(Nt={}));class P1{constructor(e){p(this,"server");p(this,"features");p(this,"disabled");this.features=new Map,this.disabled=[],this.update(e)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(e){this.disabled.push(e),this.update(this.server)}isDisabled(e){return this.disabled.indexOf(e)!==-1}update(e){typeof e=="string"&&(e=Or(e)),this.server=e,this.set(Nt.JS_KV,"2.6.2"),this.set(Nt.JS_OBJECTSTORE,"2.6.3"),this.set(Nt.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Nt.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Nt.JS_ALLOW_DIRECT,"2.9.0"),this.set(Nt.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Nt.JS_SIMPLIFICATION,"2.9.4"),this.set(Nt.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Nt.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Nt.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Nt.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Nt.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Nt.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Nt.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Nt.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(t=>{this.features.delete(t)})}set(e,t){this.features.set(e,{min:t,ok:fc(this.server,Or(t))>=0})}get(e){return this.features.get(e)||{min:"unknown",ok:!1}}supports(e){var t;return((t=this.get(e))==null?void 0:t.ok)||!1}require(e){return typeof e=="string"&&(e=Or(e)),fc(this.server,e)>=0}}class aa extends yo{constructor(e,t){super(e,t)}async add(e,t,n=oa.Create){if(zs(e),t.deliver_group&&t.flow_control)throw new Error("jetstream flow control is not supported with queue groups");if(t.deliver_group&&t.idle_heartbeat)throw new Error("jetstream idle heartbeat is not supported with queue groups");const r={};r.config=t,r.stream_name=e,r.action=n,r.config.durable_name&&oi(r.config.durable_name);const i=this.nc;let{min:o,ok:a}=i.features.get(Nt.JS_NEW_CONSUMER_CREATE_API);const l=t.name===""?void 0:t.name;if(l&&!a)throw new Error(`consumer 'name' requires server ${o}`);if(l)try{$a("name",l)}catch(h){const v=h.message,f=v.indexOf("cannot contain");throw f!==-1?new Error(`consumer 'name' ${v.substring(f)}`):h}let u,d="";if(Array.isArray(t.filter_subjects)){const{min:h,ok:v}=i.features.get(Nt.JS_MULTIPLE_CONSUMER_FILTER);if(!v)throw new Error(`consumer 'filter_subjects' requires server ${h}`);a=!1}if(t.metadata){const{min:h,ok:v}=i.features.get(Nt.JS_STREAM_CONSUMER_METADATA);if(!v)throw new Error(`consumer 'metadata' requires server ${h}`)}if(a&&(d=t.name??t.durable_name??""),d!==""){let h=t.filter_subject??void 0;h===">"&&(h=void 0),u=h!==void 0?`${this.prefix}.CONSUMER.CREATE.${e}.${d}.${h}`:`${this.prefix}.CONSUMER.CREATE.${e}.${d}`}else u=t.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${e}.${t.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${e}`;return await this._request(u,r)}async update(e,t,n){const r=await this.info(e,t),i=n;return this.add(e,Object.assign(r.config,i),oa.Update)}async info(e,t){return zs(e),oi(t),await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${t}`)}async delete(e,t){return zs(e),oi(t),(await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${t}`)).success}list(e){zs(e);const t=`${this.prefix}.CONSUMER.LIST.${e}`;return new Hi(t,n=>n.consumers,this)}pause(e,t,n){const r=`${this.prefix}.CONSUMER.PAUSE.${e}.${t}`,i={pause_until:n.toISOString()};return this._request(r,i)}resume(e,t){return this.pause(e,t,new Date(0))}}function Wr(s,e,t=!1){if(t===!0&&!s)throw Ve.errorForCode(Re.ApiError,new Error(`${e} is not a function`));if(s&&typeof s!="function")throw Ve.errorForCode(Re.ApiError,new Error(`${e} is not a function`))}class R1 extends Es{constructor(t,n,r){super();p(this,"sub");p(this,"adapter");p(this,"subIterDone");Wr(r.adapter,"adapter",!0),this.adapter=r.adapter,r.callback&&Wr(r.callback,"callback"),this.noIterator=typeof r.callback=="function",r.ingestionFilterFn&&(Wr(r.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=r.ingestionFilterFn),r.protocolFilterFn&&(Wr(r.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=r.protocolFilterFn),r.dispatchedFn&&(Wr(r.dispatchedFn,"dispatchedFn"),this.dispatchedFn=r.dispatchedFn),r.cleanupFn&&Wr(r.cleanupFn,"cleanupFn");let i=(d,h)=>{this.callback(d,h)};if(r.callback){const d=r.callback;i=(h,v)=>{const[f,b]=this.adapter(h,v);if(f)return void d(f,null);const{ingest:k}=this.ingestionFilterFn?this.ingestionFilterFn(b,this):{ingest:!0};k&&(!this.protocolFilterFn||this.protocolFilterFn(b))&&(d(f,b),this.dispatchedFn&&b&&this.dispatchedFn(b))}}const{max:o,queue:a,timeout:l}=r,u={queue:a,timeout:l,callback:i};o&&o>0&&(u.max=o),this.sub=t.subscribe(n,u),r.cleanupFn&&(this.sub.cleanupFn=r.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=is(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async d=>{await d.closed,this.stop()})(this.sub).then().catch()}unsubscribe(t){this.sub.unsubscribe(t)}drain(){return this.sub.drain()}isDraining(){return this.sub.isDraining()}isClosed(){return this.sub.isClosed()}callback(t,n){this.sub.cancelTimeout();const[r,i]=this.adapter(t,n);r&&this.stop(r),i&&this.push(i)}getSubject(){return this.sub.getSubject()}getReceived(){return this.sub.getReceived()}getProcessed(){return this.sub.getProcessed()}getPending(){return this.sub.getPending()}getID(){return this.sub.getID()}getMax(){return this.sub.getMax()}get closed(){return this.sub.closed}}let nn;function nm(){return nn!==void 0&&nn.defaultPort!==void 0?nn.defaultPort:4222}function Da(){return nn!==void 0&&nn.urlParseFn?nn.urlParseFn:void 0}function gc(){return nn!==void 0&&nn.dnsResolveFn?nn.dnsResolveFn:void 0}const Do=`\r
13
- `,ca=fi.fromAscii(Do),I1=new Uint8Array(ca)[0],O1=new Uint8Array(ca)[1];function N1(s){const e=function(t){for(let n=0;n<t.length;n++){const r=n+1;if(t.byteLength>r&&t[n]===I1&&t[r]===O1)return r+1}return 0}(s);if(e>0){const t=new Uint8Array(s).slice(0,e);return sn.decode(t)}return""}function vc(s){return function(e){for(let t=0;t<e.length;t++)switch(e[t]){case".":return rm(e);case":":return F1(e)}}(s)!==void 0}function rm(s){const e=new Uint8Array(4);for(let t=0;t<4;t++){if(s.length===0)return;if(t>0){if(s[0]!==".")return;s=s.substring(1)}const{n,c:r,ok:i}=L1(s);if(!i||n>255)return;s=s.substring(r),e[t]=n}return function(t,n,r,i){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((a,l)=>{o[l]=a}),o[12]=t,o[13]=n,o[14]=r,o[15]=i,o}(e[0],e[1],e[2],e[3])}function F1(s){const e=new Uint8Array(16);let t=-1;if(s.length>=2&&s[0]===":"&&s[1]===":"&&(t=0,(s=s.substring(2)).length===0))return e;let n=0;for(;n<16;){const{n:r,c:i,ok:o}=j1(s);if(!o||r>65535)return;if(i<s.length&&s[i]==="."){if(t<0&&n!=12||n+4>16)return;const a=rm(s);if(a===void 0)return;e[n]=a[12],e[n+1]=a[13],e[n+2]=a[14],e[n+3]=a[15],s="",n+=4;break}if(e[n]=r>>8,e[n+1]=r,n+=2,(s=s.substring(i)).length===0)break;if(s[0]!==":"||s.length==1)return;if((s=s.substring(1))[0]===":"){if(t>=0)return;if(t=n,(s=s.substring(1)).length===0)break}}if(s.length===0){if(n<16){if(t<0)return;const r=16-n;for(let i=n-1;i>=t;i--)e[i+r]=e[i];for(let i=t+r-1;i>=t;i--)e[i]=0}else if(t>=0)return;return e}}function L1(s){let e=0,t=0;for(e=0;e<s.length&&48<=s.charCodeAt(e)&&s.charCodeAt(e)<=57;e++)if(t=10*t+(s.charCodeAt(e)-48),t>=16777215)return{n:16777215,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:t,c:e,ok:!0}}function j1(s){let e=0,t=0;for(t=0;t<s.length;t++){if(48<=s.charCodeAt(t)&&s.charCodeAt(t)<=57)e*=16,e+=s.charCodeAt(t)-48;else if(97<=s.charCodeAt(t)&&s.charCodeAt(t)<=102)e*=16,e+=s.charCodeAt(t)-97+10;else{if(!(65<=s.charCodeAt(t)&&s.charCodeAt(t)<=70))break;e*=16,e+=s.charCodeAt(t)-65+10}if(e>=16777215)return{n:0,c:t,ok:!1}}return t===0?{n:0,c:t,ok:!1}:{n:e,c:t,ok:!0}}function Ba(s){return!function(e){return e.indexOf("[")===-1&&e.indexOf("::")===-1&&(e.indexOf(".")!==-1||e.split(":").length<=2)}(s)}class Gi{constructor(e,t=!1){p(this,"src");p(this,"listen");p(this,"hostname");p(this,"port");p(this,"didConnect");p(this,"reconnects");p(this,"lastConnect");p(this,"gossiped");p(this,"tlsName");p(this,"resolves");this.src=e,this.tlsName="";const n=function(r){(r=r.trim()).match(/^(.*:\/\/)(.*)/m)&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2")),Ba(r=function(u){const d="::FFFF:",h=u.toUpperCase().indexOf(d);if(h!==-1&&u.indexOf(".")!==-1){let v=u.substring(h+7);return v=v.replace("[",""),v.replace("]","")}return u}(r))&&r.indexOf("[")===-1&&(r=`[${r}]`);const i=Ba(r)?r.match(/(]:)(\d+)/):r.match(/(:)(\d+)/),o=i&&i.length===3&&i[1]&&i[2]?parseInt(i[2]):4222,a=new URL(`${o===80?"https":"http"}://${r}`);a.port=`${o}`;let l=a.hostname;return l.charAt(0)==="["&&(l=l.substring(1,l.length-1)),{listen:a.host,hostname:l,port:o}}(e);this.listen=n.listen,this.hostname=n.hostname,this.port=n.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=t}toString(){return this.listen}async resolve(e){if(!e.fn||e.resolve===!1)return[this];const t=[];if(vc(this.hostname))return[this];{const n=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${n.join(",")}`);for(const r of n){const i=this.port===80?"https":"http",o=new URL(`${i}://${Ba(r)?"["+r+"]":r}`);o.port=`${this.port}`;const a=new Gi(o.host,!1);a.tlsName=this.hostname,t.push(a)}}return e.randomize&&Yh(t),this.resolves=t,t}}class q1{constructor(e=[],t={}){p(this,"firstSelect");p(this,"servers");p(this,"currentServer");p(this,"tlsName");p(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=t.randomize||!1;const n=Da();e&&(e.forEach(r=>{r=n?n(r):r,this.servers.push(new Gi(r))}),this.randomize&&(this.servers=Yh(this.servers))),this.servers.length===0&&this.addServer(`${lc}:${nm()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();vc(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(t=>{t.gossiped&&(t.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,t=!1){const n=Da();e=n?n(e):e;const r=new Gi(e,t);vc(r.hostname)&&(r.tlsName=this.tlsName),this.servers.push(r)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const e=this.servers.shift();return e&&(this.servers.push(e),this.currentServer=e),e}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(e){if(e){const t=this.servers.indexOf(e);this.servers.splice(t,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(e,t){const n=[];let r=[];const i=Da(),o=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(l=>{l=i?i(l,t):l;const u=new Gi(l,!0);o.set(l,u)});const a=[];return this.servers.forEach((l,u)=>{const d=l.listen;l.gossiped&&this.currentServer.listen!==d&&o.get(d)===void 0&&a.push(u),o.delete(d)}),a.reverse(),a.forEach(l=>{const u=this.servers.splice(l,1);r=r.concat(u[0].listen)}),o.forEach((l,u)=>{this.servers.push(l),n.push(u)}),{added:n,deleted:r}}}class D1{constructor(){p(this,"baseInbox");p(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${Qn(e)}.`,this.baseInbox}add(e){isNaN(e.received)||(e.received=0),this.reqs.set(e.token,e)}get(e){return this.reqs.get(e)}cancel(e){this.reqs.delete(e.token)}getToken(e){const t=e.subject||"";return t.indexOf(this.baseInbox)===0?t.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,t){if(t&&t.permissionContext){if(e)return this.all().forEach(r=>{r.resolver(t,{})}),!0;const n=t.permissionContext;if(n.operation==="publish"){const r=this.all().find(i=>i.requestSubject===n.subject);if(r)return r.resolver(t,{}),!0}}return!1}dispatcher(){return(e,t)=>{const n=this.getToken(t);if(n){const r=this.get(n);r&&(e===null&&t.headers&&(e=Xh(t)),r.resolver(e,t))}}}close(){const e=Ve.errorForCode(Re.Timeout);this.reqs.forEach(t=>{t.resolver(e,{})})}}class B1{constructor(e,t,n){p(this,"ph");p(this,"interval");p(this,"maxOut");p(this,"timer");p(this,"pendings");this.ph=e,this.interval=t,this.maxOut=n,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:ii.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut)return void this.cancel(!0);const e=is();this.ph.flush(e).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(e),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(e=>(e.resolve(),!1))}}class z1 extends Error{constructor(e){super(e),this.name="AssertionError"}}const za=2**32-2;function Ao(s,e,t=0){const n=e.byteLength-t;return s.byteLength>n&&(s=s.subarray(0,n)),e.set(s,t),s.byteLength}class Ua{constructor(e){p(this,"_buf");p(this,"_off");this._off=0,this._buf=e!=null?new Uint8Array(e):new Uint8Array(0)}bytes(e={copy:!0}){return e.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(e){if(e!==0){if(e<0||e>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+e)}else this.reset()}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(e){const t=this._buf.byteLength;return e<=this.capacity-t?(this._reslice(t+e),t):-1}_reslice(e){(function(t,n="Assertion failed."){if(!t)throw new z1(n)})(e<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,e)}readByte(){const e=new Uint8Array(1);return this.read(e)?e[0]:null}read(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;const t=Ao(this._buf.subarray(this._off),e);return this._off+=t,t}writeByte(e){return this.write(Uint8Array.of(e))}writeString(e){return this.write(Dr.encode(e))}write(e){const t=this._grow(e.byteLength);return Ao(e,this._buf,t)}_grow(e){const t=this.length;t===0&&this._off!==0&&this.reset();const n=this._tryGrowByReslice(e);if(n>=0)return n;const r=this.capacity;if(e<=Math.floor(r/2)-t)Ao(this._buf.subarray(this._off),this._buf);else{if(r+e>za)throw new Error("The buffer cannot be grown beyond the maximum size.");{const i=new Uint8Array(Math.min(2*r+e,za));Ao(this._buf.subarray(this._off),i),this._buf=i}}return this._off=0,this._reslice(Math.min(t+e,za)),t}grow(e){if(e<0)throw Error("Buffer._grow: negative count");const t=this._grow(e);this._reslice(t)}readFrom(e){let t=0;const n=new Uint8Array(32768);for(;;){const r=this.capacity-this.length<32768,i=r?n:new Uint8Array(this._buf.buffer,this.length),o=e.read(i);if(o===null)return t;r?this.write(i.subarray(0,o)):this._reslice(this.length+o),t+=o}}}var Us;function Lu(){return{sid:-1,hdr:-1,size:-1}}(function(s){s[s.OK=0]="OK",s[s.ERR=1]="ERR",s[s.MSG=2]="MSG",s[s.INFO=3]="INFO",s[s.PING=4]="PING",s[s.PONG=5]="PONG"})(Us||(Us={}));class ju{constructor(e){p(this,"dispatcher");p(this,"state");p(this,"as");p(this,"drop");p(this,"hdr");p(this,"ma");p(this,"argBuf");p(this,"msgBuf");this.dispatcher=e,this.state=je.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(e){let t;for(t=0;t<e.length;t++){const n=e[t];switch(this.state){case je.OP_START:switch(n){case qe.M:case qe.m:this.state=je.OP_M,this.hdr=-1,this.ma=Lu();break;case qe.H:case qe.h:this.state=je.OP_H,this.hdr=0,this.ma=Lu();break;case qe.P:case qe.p:this.state=je.OP_P;break;case qe.PLUS:this.state=je.OP_PLUS;break;case qe.MINUS:this.state=je.OP_MINUS;break;case qe.I:case qe.i:this.state=je.OP_I;break;default:throw this.fail(e.subarray(t))}break;case je.OP_H:switch(n){case qe.M:case qe.m:this.state=je.OP_M;break;default:throw this.fail(e.subarray(t))}break;case je.OP_M:switch(n){case qe.S:case qe.s:this.state=je.OP_MS;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MS:switch(n){case qe.G:case qe.g:this.state=je.OP_MSG;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MSG:switch(n){case qe.SPACE:case qe.TAB:this.state=je.OP_MSG_SPC;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MSG_SPC:switch(n){case qe.SPACE:case qe.TAB:continue;default:this.state=je.MSG_ARG,this.as=t}break;case je.MSG_ARG:switch(n){case qe.CR:this.drop=1;break;case qe.NL:{const r=this.argBuf?this.argBuf.bytes():e.subarray(this.as,t-this.drop);this.processMsgArgs(r),this.drop=0,this.as=t+1,this.state=je.MSG_PAYLOAD,t=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(n)}break;case je.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const r=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Us.MSG,msg:this.ma,data:r}),this.argBuf=void 0,this.msgBuf=void 0,this.state=je.MSG_END}else{let r=this.ma.size-this.msgBuf.length;const i=e.length-t;i<r&&(r=i),r>0?(this.msgBuf.write(e.subarray(t,t+r)),t=t+r-1):this.msgBuf.writeByte(n)}else t-this.as>=this.ma.size&&(this.dispatcher.push({kind:Us.MSG,msg:this.ma,data:e.subarray(this.as,t)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=je.MSG_END);break;case je.MSG_END:if(n!==qe.NL)continue;this.drop=0,this.as=t+1,this.state=je.OP_START;break;case je.OP_PLUS:switch(n){case qe.O:case qe.o:this.state=je.OP_PLUS_O;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PLUS_O:switch(n){case qe.K:case qe.k:this.state=je.OP_PLUS_OK;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PLUS_OK:n===qe.NL&&(this.dispatcher.push({kind:Us.OK}),this.drop=0,this.state=je.OP_START);break;case je.OP_MINUS:switch(n){case qe.E:case qe.e:this.state=je.OP_MINUS_E;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MINUS_E:switch(n){case qe.R:case qe.r:this.state=je.OP_MINUS_ER;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MINUS_ER:switch(n){case qe.R:case qe.r:this.state=je.OP_MINUS_ERR;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MINUS_ERR:switch(n){case qe.SPACE:case qe.TAB:this.state=je.OP_MINUS_ERR_SPC;break;default:throw this.fail(e.subarray(t))}break;case je.OP_MINUS_ERR_SPC:switch(n){case qe.SPACE:case qe.TAB:continue;default:this.state=je.MINUS_ERR_ARG,this.as=t}break;case je.MINUS_ERR_ARG:switch(n){case qe.CR:this.drop=1;break;case qe.NL:{let r;this.argBuf?(r=this.argBuf.bytes(),this.argBuf=void 0):r=e.subarray(this.as,t-this.drop),this.dispatcher.push({kind:Us.ERR,data:r}),this.drop=0,this.as=t+1,this.state=je.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(n))}break;case je.OP_P:switch(n){case qe.I:case qe.i:this.state=je.OP_PI;break;case qe.O:case qe.o:this.state=je.OP_PO;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PO:switch(n){case qe.N:case qe.n:this.state=je.OP_PON;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PON:switch(n){case qe.G:case qe.g:this.state=je.OP_PONG;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PONG:n===qe.NL&&(this.dispatcher.push({kind:Us.PONG}),this.drop=0,this.state=je.OP_START);break;case je.OP_PI:switch(n){case qe.N:case qe.n:this.state=je.OP_PIN;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PIN:switch(n){case qe.G:case qe.g:this.state=je.OP_PING;break;default:throw this.fail(e.subarray(t))}break;case je.OP_PING:n===qe.NL&&(this.dispatcher.push({kind:Us.PING}),this.drop=0,this.state=je.OP_START);break;case je.OP_I:switch(n){case qe.N:case qe.n:this.state=je.OP_IN;break;default:throw this.fail(e.subarray(t))}break;case je.OP_IN:switch(n){case qe.F:case qe.f:this.state=je.OP_INF;break;default:throw this.fail(e.subarray(t))}break;case je.OP_INF:switch(n){case qe.O:case qe.o:this.state=je.OP_INFO;break;default:throw this.fail(e.subarray(t))}break;case je.OP_INFO:switch(n){case qe.SPACE:case qe.TAB:this.state=je.OP_INFO_SPC;break;default:throw this.fail(e.subarray(t))}break;case je.OP_INFO_SPC:switch(n){case qe.SPACE:case qe.TAB:continue;default:this.state=je.INFO_ARG,this.as=t}break;case je.INFO_ARG:switch(n){case qe.CR:this.drop=1;break;case qe.NL:{let r;this.argBuf?(r=this.argBuf.bytes(),this.argBuf=void 0):r=e.subarray(this.as,t-this.drop),this.dispatcher.push({kind:Us.INFO,data:r}),this.drop=0,this.as=t+1,this.state=je.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(n)}break;default:throw this.fail(e.subarray(t))}}this.state!==je.MSG_ARG&&this.state!==je.MINUS_ERR_ARG&&this.state!==je.INFO_ARG||this.argBuf||(this.argBuf=new Ua(e.subarray(this.as,t-this.drop))),this.state!==je.MSG_PAYLOAD||this.msgBuf||(this.argBuf||this.cloneMsgArg(),this.msgBuf=new Ua(e.subarray(this.as)))}cloneMsgArg(){const e=this.ma.subject.length,t=this.ma.reply?this.ma.reply.length:0,n=new Uint8Array(e+t);n.set(this.ma.subject),this.ma.reply&&n.set(this.ma.reply,e),this.argBuf=new Ua(n),this.ma.subject=n.subarray(0,e),this.ma.reply&&(this.ma.reply=n.subarray(e))}processMsgArgs(e){if(this.hdr>=0)return this.processHeaderMsgArgs(e);const t=[];let n=-1;for(let r=0;r<e.length;r++)switch(e[r]){case qe.SPACE:case qe.TAB:case qe.CR:case qe.NL:n>=0&&(t.push(e.subarray(n,r)),n=-1);break;default:n<0&&(n=r)}switch(n>=0&&t.push(e.subarray(n)),t.length){case 3:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(t[2]);break;case 4:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=t[2],this.ma.size=this.protoParseInt(t[3]);break;default:throw this.fail(e,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(e,"processMsgArgs Bad or Missing Size Error")}fail(e,t=""){return t=t?`${t} [${this.state}]`:`parse error [${this.state}]`,new Error(`${t}: ${sn.decode(e)}`)}processHeaderMsgArgs(e){const t=[];let n=-1;for(let r=0;r<e.length;r++)switch(e[r]){case qe.SPACE:case qe.TAB:case qe.CR:case qe.NL:n>=0&&(t.push(e.subarray(n,r)),n=-1);break;default:n<0&&(n=r)}switch(n>=0&&t.push(e.subarray(n)),t.length){case 4:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(t[2]),this.ma.size=this.protoParseInt(t[3]);break;case 5:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=t[2],this.ma.hdr=this.protoParseInt(t[3]),this.ma.size=this.protoParseInt(t[4]);break;default:throw this.fail(e,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(e){if(e.length===0)return-1;let t=0;for(let n=0;n<e.length;n++){if(e[n]<48||e[n]>57)return-1;t=10*t+(e[n]-48)}return t}}var je,qe;(function(s){s[s.OP_START=0]="OP_START",s[s.OP_PLUS=1]="OP_PLUS",s[s.OP_PLUS_O=2]="OP_PLUS_O",s[s.OP_PLUS_OK=3]="OP_PLUS_OK",s[s.OP_MINUS=4]="OP_MINUS",s[s.OP_MINUS_E=5]="OP_MINUS_E",s[s.OP_MINUS_ER=6]="OP_MINUS_ER",s[s.OP_MINUS_ERR=7]="OP_MINUS_ERR",s[s.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",s[s.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",s[s.OP_M=10]="OP_M",s[s.OP_MS=11]="OP_MS",s[s.OP_MSG=12]="OP_MSG",s[s.OP_MSG_SPC=13]="OP_MSG_SPC",s[s.MSG_ARG=14]="MSG_ARG",s[s.MSG_PAYLOAD=15]="MSG_PAYLOAD",s[s.MSG_END=16]="MSG_END",s[s.OP_H=17]="OP_H",s[s.OP_P=18]="OP_P",s[s.OP_PI=19]="OP_PI",s[s.OP_PIN=20]="OP_PIN",s[s.OP_PING=21]="OP_PING",s[s.OP_PO=22]="OP_PO",s[s.OP_PON=23]="OP_PON",s[s.OP_PONG=24]="OP_PONG",s[s.OP_I=25]="OP_I",s[s.OP_IN=26]="OP_IN",s[s.OP_INF=27]="OP_INF",s[s.OP_INFO=28]="OP_INFO",s[s.OP_INFO_SPC=29]="OP_INFO_SPC",s[s.INFO_ARG=30]="INFO_ARG"})(je||(je={})),function(s){s[s.CR=13]="CR",s[s.E=69]="E",s[s.e=101]="e",s[s.F=70]="F",s[s.f=102]="f",s[s.G=71]="G",s[s.g=103]="g",s[s.H=72]="H",s[s.h=104]="h",s[s.I=73]="I",s[s.i=105]="i",s[s.K=75]="K",s[s.k=107]="k",s[s.M=77]="M",s[s.m=109]="m",s[s.MINUS=45]="MINUS",s[s.N=78]="N",s[s.n=110]="n",s[s.NL=10]="NL",s[s.O=79]="O",s[s.o=111]="o",s[s.P=80]="P",s[s.p=112]="p",s[s.PLUS=43]="PLUS",s[s.R=82]="R",s[s.r=114]="r",s[s.S=83]="S",s[s.s=115]="s",s[s.SPACE=32]="SPACE",s[s.TAB=9]="TAB"}(qe||(qe={})),function(s){var e=function(_,x){this.hi=0|_,this.lo=0|x},t=function(_){var x,C=new Float64Array(16);if(_)for(x=0;x<_.length;x++)C[x]=_[x];return C},n=function(){throw new Error("no PRNG")},r=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=t(),a=t([1]),l=t([56129,1]),u=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),v=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function b(_,x){return _<<x|_>>>32-x}function k(_,x){var C=255&_[x+3];return(C=(C=C<<8|255&_[x+2])<<8|255&_[x+1])<<8|255&_[x+0]}function z(_,x){var C=_[x]<<24|_[x+1]<<16|_[x+2]<<8|_[x+3],T=_[x+4]<<24|_[x+5]<<16|_[x+6]<<8|_[x+7];return new e(C,T)}function L(_,x,C){var T;for(T=0;T<4;T++)_[x+T]=255&C,C>>>=8}function se(_,x,C){_[x]=C.hi>>24&255,_[x+1]=C.hi>>16&255,_[x+2]=C.hi>>8&255,_[x+3]=255&C.hi,_[x+4]=C.lo>>24&255,_[x+5]=C.lo>>16&255,_[x+6]=C.lo>>8&255,_[x+7]=255&C.lo}function K(_,x,C,T,P){var Z,Me=0;for(Z=0;Z<P;Z++)Me|=_[x+Z]^C[T+Z];return(1&Me-1>>>8)-1}function N(_,x,C,T){return K(_,x,C,T,16)}function E(_,x,C,T){return K(_,x,C,T,32)}function O(_,x,C,T,P){var Z,Me,Te,le=new Uint32Array(16),Ee=new Uint32Array(16),gt=new Uint32Array(16),Xe=new Uint32Array(4);for(Z=0;Z<4;Z++)Ee[5*Z]=k(T,4*Z),Ee[1+Z]=k(C,4*Z),Ee[6+Z]=k(x,4*Z),Ee[11+Z]=k(C,16+4*Z);for(Z=0;Z<16;Z++)gt[Z]=Ee[Z];for(Z=0;Z<20;Z++){for(Me=0;Me<4;Me++){for(Te=0;Te<4;Te++)Xe[Te]=Ee[(5*Me+4*Te)%16];for(Xe[1]^=b(Xe[0]+Xe[3]|0,7),Xe[2]^=b(Xe[1]+Xe[0]|0,9),Xe[3]^=b(Xe[2]+Xe[1]|0,13),Xe[0]^=b(Xe[3]+Xe[2]|0,18),Te=0;Te<4;Te++)le[4*Me+(Me+Te)%4]=Xe[Te]}for(Te=0;Te<16;Te++)Ee[Te]=le[Te]}if(P){for(Z=0;Z<16;Z++)Ee[Z]=Ee[Z]+gt[Z]|0;for(Z=0;Z<4;Z++)Ee[5*Z]=Ee[5*Z]-k(T,4*Z)|0,Ee[6+Z]=Ee[6+Z]-k(x,4*Z)|0;for(Z=0;Z<4;Z++)L(_,4*Z,Ee[5*Z]),L(_,16+4*Z,Ee[6+Z])}else for(Z=0;Z<16;Z++)L(_,4*Z,Ee[Z]+gt[Z]|0)}function U(_,x,C,T){return O(_,x,C,T,!1),0}function S(_,x,C,T){return O(_,x,C,T,!0),0}var M=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function B(_,x,C,T,P,Z,Me){var Te,le,Ee=new Uint8Array(16),gt=new Uint8Array(64);if(!P)return 0;for(le=0;le<16;le++)Ee[le]=0;for(le=0;le<8;le++)Ee[le]=Z[le];for(;P>=64;){for(U(gt,Ee,Me,M),le=0;le<64;le++)_[x+le]=(C?C[T+le]:0)^gt[le];for(Te=1,le=8;le<16;le++)Te=Te+(255&Ee[le])|0,Ee[le]=255&Te,Te>>>=8;P-=64,x+=64,C&&(T+=64)}if(P>0)for(U(gt,Ee,Me,M),le=0;le<P;le++)_[x+le]=(C?C[T+le]:0)^gt[le];return 0}function W(_,x,C,T,P){return B(_,x,null,0,C,T,P)}function I(_,x,C,T,P){var Z=new Uint8Array(32);return S(Z,T,P,M),W(_,x,C,T.subarray(16),Z)}function w(_,x,C,T,P,Z,Me){var Te=new Uint8Array(32);return S(Te,Z,Me,M),B(_,x,C,T,P,Z.subarray(16),Te)}function Q(_,x){var C,T=0;for(C=0;C<17;C++)T=T+(_[C]+x[C]|0)|0,_[C]=255&T,T>>>=8}var J=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function q(_,x,C,T,P,Z){var Me,Te,le,Ee,gt=new Uint32Array(17),Xe=new Uint32Array(17),pt=new Uint32Array(17),ls=new Uint32Array(17),bs=new Uint32Array(17);for(le=0;le<17;le++)Xe[le]=pt[le]=0;for(le=0;le<16;le++)Xe[le]=Z[le];for(Xe[3]&=15,Xe[4]&=252,Xe[7]&=15,Xe[8]&=252,Xe[11]&=15,Xe[12]&=252,Xe[15]&=15;P>0;){for(le=0;le<17;le++)ls[le]=0;for(le=0;le<16&&le<P;++le)ls[le]=C[T+le];for(ls[le]=1,T+=le,P-=le,Q(pt,ls),Te=0;Te<17;Te++)for(gt[Te]=0,le=0;le<17;le++)gt[Te]=gt[Te]+pt[le]*(le<=Te?Xe[Te-le]:320*Xe[Te+17-le]|0)|0;for(Te=0;Te<17;Te++)pt[Te]=gt[Te];for(Ee=0,le=0;le<16;le++)Ee=Ee+pt[le]|0,pt[le]=255&Ee,Ee>>>=8;for(Ee=Ee+pt[16]|0,pt[16]=3&Ee,Ee=5*(Ee>>>2)|0,le=0;le<16;le++)Ee=Ee+pt[le]|0,pt[le]=255&Ee,Ee>>>=8;Ee=Ee+pt[16]|0,pt[16]=Ee}for(le=0;le<17;le++)bs[le]=pt[le];for(Q(pt,J),Me=0|-(pt[16]>>>7),le=0;le<17;le++)pt[le]^=Me&(bs[le]^pt[le]);for(le=0;le<16;le++)ls[le]=Z[le+16];for(ls[16]=0,Q(pt,ls),le=0;le<16;le++)_[x+le]=pt[le];return 0}function oe(_,x,C,T,P,Z){var Me=new Uint8Array(16);return q(Me,0,C,T,P,Z),N(_,x,Me,0)}function ue(_,x,C,T,P){var Z;if(C<32)return-1;for(w(_,0,x,0,C,T,P),q(_,16,_,32,C-32,_),Z=0;Z<16;Z++)_[Z]=0;return 0}function Se(_,x,C,T,P){var Z,Me=new Uint8Array(32);if(C<32||(I(Me,0,32,T,P),oe(x,16,x,32,C-32,Me)!==0))return-1;for(w(_,0,x,0,C,T,P),Z=0;Z<32;Z++)_[Z]=0;return 0}function F(_,x){var C;for(C=0;C<16;C++)_[C]=0|x[C]}function D(_){var x,C;for(C=0;C<16;C++)_[C]+=65536,x=Math.floor(_[C]/65536),_[(C+1)*(C<15?1:0)]+=x-1+37*(x-1)*(C===15?1:0),_[C]-=65536*x}function Y(_,x,C){for(var T,P=~(C-1),Z=0;Z<16;Z++)T=P&(_[Z]^x[Z]),_[Z]^=T,x[Z]^=T}function Pe(_,x){var C,T,P,Z=t(),Me=t();for(C=0;C<16;C++)Me[C]=x[C];for(D(Me),D(Me),D(Me),T=0;T<2;T++){for(Z[0]=Me[0]-65517,C=1;C<15;C++)Z[C]=Me[C]-65535-(Z[C-1]>>16&1),Z[C-1]&=65535;Z[15]=Me[15]-32767-(Z[14]>>16&1),P=Z[15]>>16&1,Z[14]&=65535,Y(Me,Z,1-P)}for(C=0;C<16;C++)_[2*C]=255&Me[C],_[2*C+1]=Me[C]>>8}function He(_,x){var C=new Uint8Array(32),T=new Uint8Array(32);return Pe(C,_),Pe(T,x),E(C,0,T,0)}function ht(_){var x=new Uint8Array(32);return Pe(x,_),1&x[0]}function Mt(_,x){var C;for(C=0;C<16;C++)_[C]=x[2*C]+(x[2*C+1]<<8);_[15]&=32767}function Qe(_,x,C){var T;for(T=0;T<16;T++)_[T]=x[T]+C[T]|0}function ze(_,x,C){var T;for(T=0;T<16;T++)_[T]=x[T]-C[T]|0}function ge(_,x,C){var T,P,Z=new Float64Array(31);for(T=0;T<31;T++)Z[T]=0;for(T=0;T<16;T++)for(P=0;P<16;P++)Z[T+P]+=x[T]*C[P];for(T=0;T<15;T++)Z[T]+=38*Z[T+16];for(T=0;T<16;T++)_[T]=Z[T];D(_),D(_)}function ft(_,x){ge(_,x,x)}function Yt(_,x){var C,T=t();for(C=0;C<16;C++)T[C]=x[C];for(C=253;C>=0;C--)ft(T,T),C!==2&&C!==4&&ge(T,T,x);for(C=0;C<16;C++)_[C]=T[C]}function wt(_,x){var C,T=t();for(C=0;C<16;C++)T[C]=x[C];for(C=250;C>=0;C--)ft(T,T),C!==1&&ge(T,T,x);for(C=0;C<16;C++)_[C]=T[C]}function zt(_,x,C){var T,P,Z=new Uint8Array(32),Me=new Float64Array(80),Te=t(),le=t(),Ee=t(),gt=t(),Xe=t(),pt=t();for(P=0;P<31;P++)Z[P]=x[P];for(Z[31]=127&x[31]|64,Z[0]&=248,Mt(Me,C),P=0;P<16;P++)le[P]=Me[P],gt[P]=Te[P]=Ee[P]=0;for(Te[0]=gt[0]=1,P=254;P>=0;--P)Y(Te,le,T=Z[P>>>3]>>>(7&P)&1),Y(Ee,gt,T),Qe(Xe,Te,Ee),ze(Te,Te,Ee),Qe(Ee,le,gt),ze(le,le,gt),ft(gt,Xe),ft(pt,Te),ge(Te,Ee,Te),ge(Ee,le,Xe),Qe(Xe,Te,Ee),ze(Te,Te,Ee),ft(le,Te),ze(Ee,gt,pt),ge(Te,Ee,l),Qe(Te,Te,gt),ge(Ee,Ee,Te),ge(Te,gt,pt),ge(gt,le,Me),ft(le,Xe),Y(Te,le,T),Y(Ee,gt,T);for(P=0;P<16;P++)Me[P+16]=Te[P],Me[P+32]=Ee[P],Me[P+48]=le[P],Me[P+64]=gt[P];var ls=Me.subarray(32),bs=Me.subarray(16);return Yt(ls,ls),ge(bs,bs,ls),Pe(_,bs),0}function nt(_,x){return zt(_,x,i)}function Xt(_,x){return n(x,32),nt(_,x)}function Be(_,x,C){var T=new Uint8Array(32);return zt(T,C,x),S(_,r,T,M)}var Ue=ue,V=Se;function X(){var _,x,C,T=0,P=0,Z=0,Me=0,Te=65535;for(C=0;C<arguments.length;C++)T+=(_=arguments[C].lo)&Te,P+=_>>>16,Z+=(x=arguments[C].hi)&Te,Me+=x>>>16;return new e((Z+=(P+=T>>>16)>>>16)&Te|(Me+=Z>>>16)<<16,T&Te|P<<16)}function _e(_,x){return new e(_.hi>>>x,_.lo>>>x|_.hi<<32-x)}function ye(){var _,x=0,C=0;for(_=0;_<arguments.length;_++)x^=arguments[_].lo,C^=arguments[_].hi;return new e(C,x)}function fe(_,x){var C,T,P=32-x;return x<32?(C=_.hi>>>x|_.lo<<P,T=_.lo>>>x|_.hi<<P):x<64&&(C=_.lo>>>x|_.hi<<P,T=_.hi>>>x|_.lo<<P),new e(C,T)}function _t(_,x,C){var T=_.hi&x.hi^~_.hi&C.hi,P=_.lo&x.lo^~_.lo&C.lo;return new e(T,P)}function Pt(_,x,C){var T=_.hi&x.hi^_.hi&C.hi^x.hi&C.hi,P=_.lo&x.lo^_.lo&C.lo^x.lo&C.lo;return new e(T,P)}function he(_){return ye(fe(_,28),fe(_,34),fe(_,39))}function ie(_){return ye(fe(_,14),fe(_,18),fe(_,41))}function de(_){return ye(fe(_,1),fe(_,8),_e(_,7))}function Le(_){return ye(fe(_,19),fe(_,61),_e(_,6))}var rt=[new e(1116352408,3609767458),new e(1899447441,602891725),new e(3049323471,3964484399),new e(3921009573,2173295548),new e(961987163,4081628472),new e(1508970993,3053834265),new e(2453635748,2937671579),new e(2870763221,3664609560),new e(3624381080,2734883394),new e(310598401,1164996542),new e(607225278,1323610764),new e(1426881987,3590304994),new e(1925078388,4068182383),new e(2162078206,991336113),new e(2614888103,633803317),new e(3248222580,3479774868),new e(3835390401,2666613458),new e(4022224774,944711139),new e(264347078,2341262773),new e(604807628,2007800933),new e(770255983,1495990901),new e(1249150122,1856431235),new e(1555081692,3175218132),new e(1996064986,2198950837),new e(2554220882,3999719339),new e(2821834349,766784016),new e(2952996808,2566594879),new e(3210313671,3203337956),new e(3336571891,1034457026),new e(3584528711,2466948901),new e(113926993,3758326383),new e(338241895,168717936),new e(666307205,1188179964),new e(773529912,1546045734),new e(1294757372,1522805485),new e(1396182291,2643833823),new e(1695183700,2343527390),new e(1986661051,1014477480),new e(2177026350,1206759142),new e(2456956037,344077627),new e(2730485921,1290863460),new e(2820302411,3158454273),new e(3259730800,3505952657),new e(3345764771,106217008),new e(3516065817,3606008344),new e(3600352804,1432725776),new e(4094571909,1467031594),new e(275423344,851169720),new e(430227734,3100823752),new e(506948616,1363258195),new e(659060556,3750685593),new e(883997877,3785050280),new e(958139571,3318307427),new e(1322822218,3812723403),new e(1537002063,2003034995),new e(1747873779,3602036899),new e(1955562222,1575990012),new e(2024104815,1125592928),new e(2227730452,2716904306),new e(2361852424,442776044),new e(2428436474,593698344),new e(2756734187,3733110249),new e(3204031479,2999351573),new e(3329325298,3815920427),new e(3391569614,3928383900),new e(3515267271,566280711),new e(3940187606,3454069534),new e(4118630271,4000239992),new e(116418474,1914138554),new e(174292421,2731055270),new e(289380356,3203993006),new e(460393269,320620315),new e(685471733,587496836),new e(852142971,1086792851),new e(1017036298,365543100),new e(1126000580,2618297676),new e(1288033470,3409855158),new e(1501505948,4234509866),new e(1607167915,987167468),new e(1816402316,1246189591)];function Kt(_,x,C){var T,P,Z,Me=[],Te=[],le=[],Ee=[];for(P=0;P<8;P++)Me[P]=le[P]=z(_,8*P);for(var gt=0;C>=128;){for(P=0;P<16;P++)Ee[P]=z(x,8*P+gt);for(P=0;P<80;P++){for(Z=0;Z<8;Z++)Te[Z]=le[Z];for(T=X(le[7],ie(le[4]),_t(le[4],le[5],le[6]),rt[P],Ee[P%16]),Te[7]=X(T,he(le[0]),Pt(le[0],le[1],le[2])),Te[3]=X(Te[3],T),Z=0;Z<8;Z++)le[(Z+1)%8]=Te[Z];if(P%16==15)for(Z=0;Z<16;Z++)Ee[Z]=X(Ee[Z],Ee[(Z+9)%16],de(Ee[(Z+1)%16]),Le(Ee[(Z+14)%16]))}for(P=0;P<8;P++)le[P]=X(le[P],Me[P]),Me[P]=le[P];gt+=128,C-=128}for(P=0;P<8;P++)se(_,8*P,Me[P]);return C}var ps=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]);function Zt(_,x,C){var T,P=new Uint8Array(64),Z=new Uint8Array(256),Me=C;for(T=0;T<64;T++)P[T]=ps[T];for(Kt(P,x,C),C%=128,T=0;T<256;T++)Z[T]=0;for(T=0;T<C;T++)Z[T]=x[Me-C+T];for(Z[C]=128,Z[(C=256-128*(C<112?1:0))-9]=0,se(Z,C-8,new e(Me/536870912|0,Me<<3)),Kt(P,Z,C),T=0;T<64;T++)_[T]=P[T];return 0}function os(_,x){var C=t(),T=t(),P=t(),Z=t(),Me=t(),Te=t(),le=t(),Ee=t(),gt=t();ze(C,_[1],_[0]),ze(gt,x[1],x[0]),ge(C,C,gt),Qe(T,_[0],_[1]),Qe(gt,x[0],x[1]),ge(T,T,gt),ge(P,_[3],x[3]),ge(P,P,d),ge(Z,_[2],x[2]),Qe(Z,Z,Z),ze(Me,T,C),ze(Te,Z,P),Qe(le,Z,P),Qe(Ee,T,C),ge(_[0],Me,Te),ge(_[1],Ee,le),ge(_[2],le,Te),ge(_[3],Me,Ee)}function As(_,x,C){var T;for(T=0;T<4;T++)Y(_[T],x[T],C)}function fs(_,x){var C=t(),T=t(),P=t();Yt(P,x[2]),ge(C,x[0],P),ge(T,x[1],P),Pe(_,T),_[31]^=ht(C)<<7}function Ms(_,x,C){var T,P;for(F(_[0],o),F(_[1],a),F(_[2],a),F(_[3],o),P=255;P>=0;--P)As(_,x,T=C[P/8|0]>>(7&P)&1),os(x,_),os(_,_),As(_,x,T)}function ds(_,x){var C=[t(),t(),t(),t()];F(C[0],h),F(C[1],v),F(C[2],a),ge(C[3],h,v),Ms(_,C,x)}function R(_,x,C){var T,P=new Uint8Array(64),Z=[t(),t(),t(),t()];for(C||n(x,32),Zt(P,x,32),P[0]&=248,P[31]&=127,P[31]|=64,ds(Z,P),fs(_,Z),T=0;T<32;T++)x[T+32]=_[T];return 0}var te=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ve(_,x){var C,T,P,Z;for(T=63;T>=32;--T){for(C=0,P=T-32,Z=T-12;P<Z;++P)x[P]+=C-16*x[T]*te[P-(T-32)],C=Math.floor((x[P]+128)/256),x[P]-=256*C;x[P]+=C,x[T]=0}for(C=0,P=0;P<32;P++)x[P]+=C-(x[31]>>4)*te[P],C=x[P]>>8,x[P]&=255;for(P=0;P<32;P++)x[P]-=C*te[P];for(T=0;T<32;T++)x[T+1]+=x[T]>>8,_[T]=255&x[T]}function ke(_){var x,C=new Float64Array(64);for(x=0;x<64;x++)C[x]=_[x];for(x=0;x<64;x++)_[x]=0;ve(_,C)}function st(_,x,C,T){var P,Z,Me=new Uint8Array(64),Te=new Uint8Array(64),le=new Uint8Array(64),Ee=new Float64Array(64),gt=[t(),t(),t(),t()];Zt(Me,T,32),Me[0]&=248,Me[31]&=127,Me[31]|=64;var Xe=C+64;for(P=0;P<C;P++)_[64+P]=x[P];for(P=0;P<32;P++)_[32+P]=Me[32+P];for(Zt(le,_.subarray(32),C+32),ke(le),ds(gt,le),fs(_,gt),P=32;P<64;P++)_[P]=T[P];for(Zt(Te,_,C+64),ke(Te),P=0;P<64;P++)Ee[P]=0;for(P=0;P<32;P++)Ee[P]=le[P];for(P=0;P<32;P++)for(Z=0;Z<32;Z++)Ee[P+Z]+=Te[P]*Me[Z];return ve(_.subarray(32),Ee),Xe}function Ot(_,x,C,T){var P,Z=new Uint8Array(32),Me=new Uint8Array(64),Te=[t(),t(),t(),t()],le=[t(),t(),t(),t()];if(C<64||function(Ee,gt){var Xe=t(),pt=t(),ls=t(),bs=t(),Ii=t(),kn=t(),on=t();return F(Ee[2],a),Mt(Ee[1],gt),ft(ls,Ee[1]),ge(bs,ls,u),ze(ls,ls,Ee[2]),Qe(bs,Ee[2],bs),ft(Ii,bs),ft(kn,Ii),ge(on,kn,Ii),ge(Xe,on,ls),ge(Xe,Xe,bs),wt(Xe,Xe),ge(Xe,Xe,ls),ge(Xe,Xe,bs),ge(Xe,Xe,bs),ge(Ee[0],Xe,bs),ft(pt,Ee[0]),ge(pt,pt,bs),He(pt,ls)&&ge(Ee[0],Ee[0],f),ft(pt,Ee[0]),ge(pt,pt,bs),He(pt,ls)?-1:(ht(Ee[0])===gt[31]>>7&&ze(Ee[0],o,Ee[0]),ge(Ee[3],Ee[0],Ee[1]),0)}(le,T))return-1;for(P=0;P<C;P++)_[P]=x[P];for(P=0;P<32;P++)_[P+32]=T[P];if(Zt(Me,_,C),ke(Me),Ms(Te,le,Me),ds(le,x.subarray(32)),os(Te,le),fs(Z,Te),C-=64,E(x,0,Z,0)){for(P=0;P<C;P++)_[P]=0;return-1}for(P=0;P<C;P++)_[P]=x[P+64];return C}var Ht=16,Ye=64,Ce=32,Oe=64;function Fe(_,x){if(_.length!==32)throw new Error("bad key size");if(x.length!==24)throw new Error("bad nonce size")}function be(){for(var _=0;_<arguments.length;_++)if(!(arguments[_]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function it(_){for(var x=0;x<_.length;x++)_[x]=0}s.lowlevel={crypto_core_hsalsa20:S,crypto_stream_xor:w,crypto_stream:I,crypto_stream_salsa20_xor:B,crypto_stream_salsa20:W,crypto_onetimeauth:q,crypto_onetimeauth_verify:oe,crypto_verify_16:N,crypto_verify_32:E,crypto_secretbox:ue,crypto_secretbox_open:Se,crypto_scalarmult:zt,crypto_scalarmult_base:nt,crypto_box_beforenm:Be,crypto_box_afternm:Ue,crypto_box:function(_,x,C,T,P,Z){var Me=new Uint8Array(32);return Be(Me,P,Z),Ue(_,x,C,T,Me)},crypto_box_open:function(_,x,C,T,P,Z){var Me=new Uint8Array(32);return Be(Me,P,Z),V(_,x,C,T,Me)},crypto_box_keypair:Xt,crypto_hash:Zt,crypto_sign:st,crypto_sign_keypair:R,crypto_sign_open:Ot,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:Ht,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:Ye,crypto_sign_PUBLICKEYBYTES:Ce,crypto_sign_SECRETKEYBYTES:Oe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:u,L:te,pack25519:Pe,unpack25519:Mt,M:ge,A:Qe,S:ft,Z:ze,pow2523:wt,add:os,set25519:F,modL:ve,scalarmult:Ms,scalarbase:ds},s.randomBytes=function(_){var x=new Uint8Array(_);return n(x,_),x},s.secretbox=function(_,x,C){be(_,x,C),Fe(C,x);for(var T=new Uint8Array(32+_.length),P=new Uint8Array(T.length),Z=0;Z<_.length;Z++)T[Z+32]=_[Z];return ue(P,T,T.length,x,C),P.subarray(Ht)},s.secretbox.open=function(_,x,C){be(_,x,C),Fe(C,x);for(var T=new Uint8Array(Ht+_.length),P=new Uint8Array(T.length),Z=0;Z<_.length;Z++)T[Z+Ht]=_[Z];return T.length<32||Se(P,T,T.length,x,C)!==0?null:P.subarray(32)},s.secretbox.keyLength=32,s.secretbox.nonceLength=24,s.secretbox.overheadLength=Ht,s.scalarMult=function(_,x){if(be(_,x),_.length!==32)throw new Error("bad n size");if(x.length!==32)throw new Error("bad p size");var C=new Uint8Array(32);return zt(C,_,x),C},s.scalarMult.base=function(_){if(be(_),_.length!==32)throw new Error("bad n size");var x=new Uint8Array(32);return nt(x,_),x},s.scalarMult.scalarLength=32,s.scalarMult.groupElementLength=32,s.box=function(_,x,C,T){var P=s.box.before(C,T);return s.secretbox(_,x,P)},s.box.before=function(_,x){be(_,x),function(T,P){if(T.length!==32)throw new Error("bad public key size");if(P.length!==32)throw new Error("bad secret key size")}(_,x);var C=new Uint8Array(32);return Be(C,_,x),C},s.box.after=s.secretbox,s.box.open=function(_,x,C,T){var P=s.box.before(C,T);return s.secretbox.open(_,x,P)},s.box.open.after=s.secretbox.open,s.box.keyPair=function(){var _=new Uint8Array(32),x=new Uint8Array(32);return Xt(_,x),{publicKey:_,secretKey:x}},s.box.keyPair.fromSecretKey=function(_){if(be(_),_.length!==32)throw new Error("bad secret key size");var x=new Uint8Array(32);return nt(x,_),{publicKey:x,secretKey:new Uint8Array(_)}},s.box.publicKeyLength=32,s.box.secretKeyLength=32,s.box.sharedKeyLength=32,s.box.nonceLength=24,s.box.overheadLength=s.secretbox.overheadLength,s.sign=function(_,x){if(be(_,x),x.length!==Oe)throw new Error("bad secret key size");var C=new Uint8Array(Ye+_.length);return st(C,_,_.length,x),C},s.sign.open=function(_,x){if(be(_,x),x.length!==Ce)throw new Error("bad public key size");var C=new Uint8Array(_.length),T=Ot(C,_,_.length,x);if(T<0)return null;for(var P=new Uint8Array(T),Z=0;Z<P.length;Z++)P[Z]=C[Z];return P},s.sign.detached=function(_,x){for(var C=s.sign(_,x),T=new Uint8Array(Ye),P=0;P<T.length;P++)T[P]=C[P];return T},s.sign.detached.verify=function(_,x,C){if(be(_,x,C),x.length!==Ye)throw new Error("bad signature size");if(C.length!==Ce)throw new Error("bad public key size");var T,P=new Uint8Array(Ye+_.length),Z=new Uint8Array(Ye+_.length);for(T=0;T<Ye;T++)P[T]=x[T];for(T=0;T<_.length;T++)P[T+Ye]=_[T];return Ot(Z,P,P.length,C)>=0},s.sign.keyPair=function(){var _=new Uint8Array(Ce),x=new Uint8Array(Oe);return R(_,x),{publicKey:_,secretKey:x}},s.sign.keyPair.fromSecretKey=function(_){if(be(_),_.length!==Oe)throw new Error("bad secret key size");for(var x=new Uint8Array(Ce),C=0;C<x.length;C++)x[C]=_[32+C];return{publicKey:x,secretKey:new Uint8Array(_)}},s.sign.keyPair.fromSeed=function(_){if(be(_),_.length!==32)throw new Error("bad seed size");for(var x=new Uint8Array(Ce),C=new Uint8Array(Oe),T=0;T<32;T++)C[T]=_[T];return R(x,C,!0),{publicKey:x,secretKey:C}},s.sign.publicKeyLength=Ce,s.sign.secretKeyLength=Oe,s.sign.seedLength=32,s.sign.signatureLength=Ye,s.hash=function(_){be(_);var x=new Uint8Array(64);return Zt(x,_,_.length),x},s.hash.hashLength=64,s.verify=function(_,x){return be(_,x),_.length!==0&&x.length!==0&&_.length===x.length&&K(_,0,x,0,_.length)===0},s.setPRNG=function(_){n=_},function(){var _=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;_&&_.getRandomValues?s.setPRNG(function(x,C){var T,P=new Uint8Array(C);for(T=0;T<C;T+=65536)_.getRandomValues(P.subarray(T,T+Math.min(C-T,65536)));for(T=0;T<C;T++)x[T]=P[T];it(P)}):typeof require<"u"&&(_=require("crypto"))&&_.randomBytes&&s.setPRNG(function(x,C){var T,P=_.randomBytes(C);for(T=0;T<C;T++)x[T]=P[T];it(P)})}()}(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const Mo=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;Mo.sign.keyPair.fromSeed,Mo.sign.detached,Mo.sign.detached.verify,Mo.randomBytes;var qu,Du;(function(s){s.InvalidPrefixByte="nkeys: invalid prefix byte",s.InvalidKey="nkeys: invalid key",s.InvalidPublicKey="nkeys: invalid public key",s.InvalidSeedLen="nkeys: invalid seed length",s.InvalidSeed="nkeys: invalid seed",s.InvalidEncoding="nkeys: invalid encoded key",s.InvalidSignature="nkeys: signature verification failed",s.CannotSign="nkeys: cannot sign, no private key available",s.PublicKeyOnly="nkeys: no seed or private key available",s.InvalidChecksum="nkeys: invalid checksum",s.SerializationError="nkeys: serialization error",s.ApiError="nkeys: api error",s.ClearedPair="nkeys: pair is cleared"})(qu||(qu={})),function(s){s[s.Seed=144]="Seed",s[s.Private=120]="Private",s[s.Operator=112]="Operator",s[s.Server=104]="Server",s[s.Cluster=16]="Cluster",s[s.Account=0]="Account",s[s.User=160]="User"}(Du||(Du={}));const im=12e4;function U1(s){const e=[];var t,n,r,i;return typeof s.authenticator=="function"&&e.push(s.authenticator),Array.isArray(s.authenticator)&&e.push(...s.authenticator),s.token&&e.push((t=s.token,()=>({auth_token:typeof t=="function"?t():t}))),s.user&&e.push((n=s.user,r=s.pass,()=>({user:typeof n=="function"?n():n,pass:typeof r=="function"?r():r}))),e.length===0?()=>{}:(i=e,o=>{let a={};return i.forEach(l=>{const u=l(o)||{};a=Object.assign(a,u)}),a})}function V1(s){const e=`${lc}:${nm()}`;if((s=s||{servers:[e]}).servers=s.servers||[],typeof s.servers=="string"&&(s.servers=[s.servers]),s.servers.length>0&&s.port)throw new Ve("port and servers options are mutually exclusive",Re.InvalidOption);s.servers.length===0&&s.port&&(s.servers=[`${lc}:${s.port}`]),s.servers&&s.servers.length===0&&(s.servers=[e]);const t=Ma({maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:im,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:2e3,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1},s);if(t.authenticator=U1(t),["reconnectDelayHandler","authenticator"].forEach(n=>{if(t[n]&&typeof t[n]!="function")throw new Ve(`${n} option should be a function`,Re.NotFunction)}),t.reconnectDelayHandler||(t.reconnectDelayHandler=()=>{let n=t.tls?t.reconnectJitterTLS:t.reconnectJitter;return n&&(n++,n=Math.floor(Math.random()*n)),t.reconnectTimeWait+n}),t.inboxPrefix)try{Qn(t.inboxPrefix)}catch(n){throw new Ve(n.message,Re.ApiError)}if(t.resolve===void 0&&(t.resolve=typeof gc()=="function"),t.resolve&&typeof gc()!="function")throw new Ve("'resolve' is not supported on this client",Re.InvalidOption);return t}const H1=/^INFO\s+([^\r\n]+)\r\n/i,Q1=Ki(`PONG\r
14
- `),Bu=Ki(`PING\r
15
- `);class K1{constructor(e,t,n){p(this,"echo");p(this,"no_responders");p(this,"protocol");p(this,"verbose");p(this,"pedantic");p(this,"jwt");p(this,"nkey");p(this,"sig");p(this,"user");p(this,"pass");p(this,"auth_token");p(this,"tls_required");p(this,"name");p(this,"lang");p(this,"version");p(this,"headers");this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=!t.noEcho&&void 0,this.verbose=t.verbose,this.pedantic=t.pedantic,this.tls_required=!!t.tls||void 0,this.name=t.name,Ma(this,(t&&typeof t.authenticator=="function"?t.authenticator(n):{})||{})}}class om extends Es{constructor(t,n,r={}){var o;super();p(this,"sid");p(this,"queue");p(this,"draining");p(this,"max");p(this,"subject");p(this,"drained");p(this,"protocol");p(this,"timer");p(this,"info");p(this,"cleanupFn");p(this,"closed");p(this,"requestSubject");Ma(this,r),this.protocol=t,this.subject=n,this.draining=!1,this.noIterator=typeof r.callback=="function",this.closed=is();const i=!((o=t.options)!=null&&o.noAsyncTraces);r.timeout&&(this.timer=pi(r.timeout,i),this.timer.then(()=>{this.timer=void 0}).catch(a=>{this.stop(a),this.noIterator&&this.callback(a,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(t){if(this.noIterator){const n=this.callback,r=t.ingestionFilterFn?t.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),i=t.protocolFilterFn?t.protocolFilterFn:()=>!0,o=t.dispatchedFn?t.dispatchedFn:()=>{};this.callback=(a,l)=>{const{ingest:u}=r(l);u&&i(l)&&(n(a,l),o(l))}}else this.protocolFilterFn=t.protocolFilterFn,this.dispatchedFn=t.dispatchedFn}callback(t,n){this.cancelTimeout(),t?this.stop(t):this.push(n)}close(){if(!this.isClosed()){this.cancelTimeout();const t=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve()};this.noIterator?t():this.push(t)}}unsubscribe(t){this.protocol.unsubscribe(this,t)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(Ve.errorForCode(Re.ConnectionClosed)):this.isClosed()?Promise.reject(Ve.errorForCode(Re.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(is()).then(()=>{this.protocol.subscriptions.cancel(this)}).catch(()=>{this.protocol.subscriptions.cancel(this)})),this.drained)}isDraining(){return this.draining}isClosed(){return this.done}getSubject(){return this.subject}getMax(){return this.max}getID(){return this.sid}}class Z1{constructor(){p(this,"mux");p(this,"subs");p(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(e){return this.sidCounter++,e.sid=this.sidCounter,this.subs.set(e.sid,e),e}setMux(e){return this.mux=e,e}getMux(){return this.mux}get(e){return this.subs.get(e)}resub(e){return this.sidCounter++,this.subs.delete(e.sid),e.sid=this.sidCounter,this.subs.set(e.sid,e),e}all(){return Array.from(this.subs.values())}cancel(e){e&&(e.close(),this.subs.delete(e.sid))}handleError(e){if(e&&e.permissionContext){const t=e.permissionContext,n=this.all();let r;if(t.operation==="subscription"&&(r=n.find(i=>i.subject===t.subject&&i.queue===t.queue)),t.operation==="publish"&&(r=n.find(i=>i.requestSubject===t.subject)),r)return r.callback(e,{}),r.close(),this.subs.delete(r.sid),r!==this.mux}return!1}close(){this.subs.forEach(e=>{e.close()})}}class la{constructor(e,t){p(this,"connected");p(this,"connectedOnce");p(this,"infoReceived");p(this,"info");p(this,"muxSubscriptions");p(this,"options");p(this,"outbound");p(this,"pongs");p(this,"subscriptions");p(this,"transport");p(this,"noMorePublishing");p(this,"connectError");p(this,"publisher");p(this,"_closed");p(this,"closed");p(this,"listeners");p(this,"heartbeats");p(this,"parser");p(this,"outMsgs");p(this,"inMsgs");p(this,"outBytes");p(this,"inBytes");p(this,"pendingLimit");p(this,"lastError");p(this,"abortReconnect");p(this,"whyClosed");p(this,"servers");p(this,"server");p(this,"features");p(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=32768,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=t,this.subscriptions=new Z1,this.muxSubscriptions=new D1,this.outbound=new fi,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new P1({major:0,minor:0,micro:0}),this.connectPromise=null;const n=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new q1(n,{randomize:!e.noRandomize}),this.closed=is(),this.parser=new ju(this),this.heartbeats=new B1(this,this.options.pingInterval||im,this.options.maxPingOut||2)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const t=Ve.errorForCode(Re.Disconnect);t.stack="",e.forEach(n=>{n.reject(t)}),this.parser=new ju(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(t=>{t.push(e)})}status(){const e=new Es;return this.listeners.push(e),e}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const e=is();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=t=>{e.reject(t)},this.transport=function(){if(!nn||typeof nn.factory!="function")throw new Error("transport fn is not set");return nn.factory()}(),this.transport.closed().then(async t=>{this.connected=!1,this.isClosed()||await this.disconnected(this.transport.closeError||this.lastError)}),e}disconnect(){this.dispatchStatus({type:ii.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:ii.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:Tn.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var t;this.dispatchStatus({type:Tn.Reconnect,data:this.servers.getCurrentServer().toString()}),((t=this.lastError)==null?void 0:t.code)===Re.AuthenticationExpired&&(this.lastError=void 0)}).catch(t=>{this._close(t)}):await this._close(e)}async dial(e){const t=this.prepare();let n;try{n=pi(this.options.timeout||2e4);const r=this.transport.connect(e,this.options);await Promise.race([r,n]),(async()=>{try{for await(const i of this.transport)this.parser.parse(i)}catch(i){console.log("reader closed",i)}})().then()}catch(r){t.reject(r)}try{await Promise.race([n,t]),n&&n.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(r){throw n&&n.cancel(),await this.transport.close(r),r}}async _doDial(e){const{resolve:t}=this.options,n=await e.resolve({fn:gc(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:t});let r=null;for(const i of n)try{return r=null,this.dispatchStatus({type:ii.Reconnecting,data:i.toString()}),void await this.dial(i)}catch(o){r=o}throw r}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let e;for(;;){this._closed&&this.servers.clear();const t=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():2e3;let n=t;const r=this.selectServer();if(!r||this.abortReconnect)throw e||(this.lastError?this.lastError:Ve.errorForCode(Re.ConnectionRefused));const i=Date.now();if(r.lastConnect===0||r.lastConnect+t<=i){r.lastConnect=Date.now();try{await this._doDial(r);break}catch(o){if(e=o,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}r.reconnects++;const a=this.options.maxReconnectAttempts||0;a!==-1&&r.reconnects>=a&&this.servers.removeCurrentServer()}}else n=Math.min(n,r.lastConnect+t-i),await Pi(n)}}static async connect(e,t){const n=new la(e,t);return await n.dialLoop(),n}static toError(e){const t=e?e.toLowerCase():"";if(t.indexOf("permissions violation")!==-1){const n=new Ve(e,Re.PermissionsViolation),r=e.match(/(Publish|Subscription) to "(\S+)"/);if(r){n.permissionContext={operation:r[1].toLowerCase(),subject:r[2],queue:void 0};const i=e.match(/using queue "(\S+)"/);i&&(n.permissionContext.queue=i[1])}return n}return t.indexOf("authorization violation")!==-1?new Ve(e,Re.AuthorizationViolation):t.indexOf("user authentication expired")!==-1?new Ve(e,Re.AuthenticationExpired):t.indexOf("account authentication expired")!=-1?new Ve(e,Re.AccountExpired):t.indexOf("authentication timeout")!==-1?new Ve(e,Re.AuthenticationTimeout):new Ve(e,Re.ProtocolError)}processMsg(e,t){if(this.inMsgs++,this.inBytes+=t.length,!this.subscriptions.sidCounter)return;const n=this.subscriptions.get(e.sid);n&&(n.received+=1,n.callback&&n.callback(null,new ll(e,t,this)),n.max!==void 0&&n.received>=n.max&&n.unsubscribe())}processError(e){const t=Eu(e),n=la.toError(t),r={type:Tn.Error,data:n.code};if(n.isPermissionError()){let i=!1;if(n.permissionContext){r.permissionContext=n.permissionContext;const o=this.subscriptions.getMux();i=(o==null?void 0:o.subject)===n.permissionContext.subject}this.subscriptions.handleError(n),this.muxSubscriptions.handleError(i,n),i&&this.subscriptions.setMux(null)}this.dispatchStatus(r),this.handleError(n)}handleError(e){e.isAuthError()?this.handleAuthError(e):(e.isProtocolError()||e.isAuthTimeout())&&(this.lastError=e),e.isPermissionError()||(this.lastError=e)}handleAuthError(e){this.lastError&&e.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(Q1)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const t=JSON.parse(Eu(e));this.info=t;const n=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(t,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(Or(t.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:r,lang:i}=this.transport;try{const o=new K1({version:r,lang:i},this.options,t.nonce);t.headers&&(o.headers=!0,o.no_responders=!0);const a=JSON.stringify(o);this.transport.send(Ki(`CONNECT ${a}${Do}`)),this.transport.send(Bu)}catch(o){this._close(o)}}n&&this.dispatchStatus({type:Tn.Update,data:n}),t.ldm!==void 0&&t.ldm&&this.dispatchStatus({type:Tn.LDM,data:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case Us.MSG:{const{msg:t,data:n}=e;this.processMsg(t,n);break}case Us.OK:break;case Us.ERR:this.processError(e.data);break;case Us.PING:this.processPing();break;case Us.PONG:this.processPong();break;case Us.INFO:this.processInfo(e.data)}}sendCommand(e,...t){const n=this.outbound.length();let r;r=typeof e=="string"?Ki(e):e,this.outbound.fill(r,...t),n===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,t=rn,n){let r;if(t instanceof Uint8Array)r=t;else{if(typeof t!="string")throw Ve.errorForCode(Re.BadPayload);r=Dr.encode(t)}let i=r.length;(n=n||{}).reply=n.reply||"";let o,a=rn,l=0;if(n.headers){if(this.info&&!this.info.headers)throw new Ve("headers",Re.ServerOptionNotAvailable);a=n.headers.encode(),l=a.length,i=r.length+l}if(this.info&&i>this.info.max_payload)throw Ve.errorForCode(Re.MaxPayloadExceeded);this.outBytes+=i,this.outMsgs++,n.headers?(o=n.reply?`HPUB ${e} ${n.reply} ${l} ${i}\r
16
- `:`HPUB ${e} ${l} ${i}\r
17
- `,this.sendCommand(o,a,r,ca)):(o=n.reply?`PUB ${e} ${n.reply} ${i}\r
18
- `:`PUB ${e} ${i}\r
19
- `,this.sendCommand(o,r,ca))}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
20
- `):this.sendCommand(`SUB ${e.subject} ${e.sid}\r
21
- `)}_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
22
- `):this.sendCommand(`UNSUB ${e.sid}\r
23
- `),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||(e=is()),this.pongs.push(e),this.outbound.fill(Bu),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(t=>{const n=t;n.queue?e.push(`SUB ${n.subject} ${n.queue} ${n.sid}${Do}`):e.push(`SUB ${n.subject} ${n.sid}${Do}`)}),e.length&&this.transport.send(Ki(e.join("")))}async _close(e){this._closed||(this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(e),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(t=>{t.stop()}),this._closed=!0,await this.transport.close(e),await this.closed.resolve(e))}close(){return this._close()}isClosed(){return this._closed}drain(){const e=this.subscriptions.all(),t=[];return e.forEach(n=>{t.push(n.drain())}),Promise.all(t).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(this.infoReceived&&this.connected&&this.outbound.size()){const e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){const e=this.muxSubscriptions.init(this.options.inboxPrefix),t=new om(this,`${e}*`);t.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(t),this.subscribe(t)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}class zu{constructor(e){p(this,"msg");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,n,r){var i,o;return(r=r||{}).headers=r.headers||Zn(),(i=r.headers)==null||i.set(ra,`${e}`),(o=r.headers)==null||o.set(na,t),this.msg.respond(n,r)}json(e){return this.msg.json(e)}string(){return this.msg.string()}}class eo{constructor(e,t="",n=""){p(this,"subject");p(this,"queue");p(this,"srv");t!==""&&function(i,o){if(o.indexOf(" ")!==-1)throw new Error(`${i} cannot contain spaces: '${o}'`);o.split(".").forEach(a=>{if(a===">")throw new Error(`${i} name cannot contain internal '>': '${o}'`)})}("service group",t);let r="";if(e instanceof bo)this.srv=e,r="";else{if(!(e instanceof eo))throw new Error("unknown ServiceGroup type");{const i=e;this.srv=i.srv,n===""&&i.queue!==""&&(n=i.queue),r=i.subject}}this.subject=this.calcSubject(r,t),this.queue=n}calcSubject(e,t=""){return t===""?e:e!==""?`${e}.${t}`:t}addEndpoint(e="",t){const n=typeof(t=t||{subject:e})=="function"?{handler:t,subject:e}:t;Vi("endpoint",e);let{subject:r,handler:i,metadata:o,queue:a}=n;r=r||e,a=a||this.queue,function(u,d){if(d==="")throw new Error(`${u} cannot be empty`);if(d.indexOf(" ")!==-1)throw new Error(`${u} cannot contain spaces: '${d}'`);const h=d.split(".");h.forEach((v,f)=>{if(v===">"&&f!==h.length-1)throw new Error(`${u} cannot have internal '>': '${d}'`)})}("endpoint subject",r),r=this.calcSubject(this.subject,r);const l={name:e,subject:r,queue:a,handler:i,metadata:o};return this.srv._addEndpoint(l)}addGroup(e="",t=""){return new eo(this,e,t)}}class bo{constructor(e,t={name:"",version:""}){p(this,"nc");p(this,"_id");p(this,"config");p(this,"handlers");p(this,"internal");p(this,"_stopped");p(this,"_done");p(this,"started");this.nc=e,this.config=Object.assign({},t),this.config.queue||(this.config.queue="q"),Vi("name",this.config.name),Vi("queue",this.config.queue),Or(this.config.version),this._id=vr.next(),this.internal=[],this._done=is(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(n=>{this.close(n).catch()})}static controlSubject(e,t="",n="",r){const i=r??"$SRV";return t===""&&n===""?`${i}.${e}`:(Vi("control subject name",t),n!==""?(Vi("control subject id",n),`${i}.${e}.${t}.${n}`):`${i}.${e}.${t}`)}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){const t=Zn();if(e instanceof ia){const n=e;t.set(na,n.message),t.set(ra,`${n.code}`)}else t.set(na,e.message),t.set(ra,"500");return t}setupHandler(e,t=!1){const n=t?"":e.queue?e.queue:this.config.queue,{name:r,subject:i,handler:o}=e,a=e;a.internal=t,t&&this.internal.push(a),a.stats=new G1(r,i,n),a.queue=n;const l=o?(u,d)=>{if(u)return void this.close(u);const h=Date.now();try{o(u,new zu(d))}catch(v){a.stats.countError(v),d==null||d.respond(rn,{headers:this.errorToHeader(v)})}finally{a.stats.countLatency(h)}}:void 0;return a.sub=this.nc.subscribe(i,{callback:l,queue:n}),a.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${e.subject} stopped`)).catch()}).catch(u=>{if(!this._stopped){const d=new Error(`required subscription ${e.subject} errored: ${u.message}`);d.stack=u.stack,this.close(d).catch()}}),a}info(){return{type:Zi.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=>{const{subject:t,metadata:n,name:r,queue:i}=e;return{subject:t,metadata:n,name:r,queue_group:i}})}async stats(){const e=[];for(const t of this.handlers){if(typeof this.config.statsHandler=="function")try{t.stats.data=await this.config.statsHandler(t)}catch(n){t.stats.countError(n)}e.push(t.stats.stats(t.qi))}return{type:Zi.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:e}}addInternalHandler(e,t){const 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(e,t,n,r="",i=""){const o={};o.name=e,o.subject=bo.controlSubject(t,r,i),o.handler=n,this.setupHandler(o,!0)}start(){const e=wn(),t=e.encode(this.ping());return this.addInternalHandler(dr.PING,(n,r)=>n?(this.close(n).then().catch(),Promise.reject(n)):(r.respond(t),Promise.resolve())),this.addInternalHandler(dr.STATS,(n,r)=>n?(this.close(n),Promise.reject(n)):this.stats().then(i=>(r==null||r.respond(e.encode(i)),Promise.resolve()))),this.addInternalHandler(dr.INFO,(n,r)=>n?(this.close(n),Promise.reject(n)):(r==null||r.respond(e.encode(this.info())),Promise.resolve())),this.handlers.forEach(n=>{const{subject:r}=n;typeof r=="string"&&n.handler!==null&&this.setupHandler(n)}),Promise.resolve(this)}close(e){if(this._stopped)return this._done;this._stopped=!0;let t=[];return this.nc.isClosed()||(t=this.handlers.concat(this.internal).map(n=>n.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:Zi.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const e of this.handlers)e.stats.reset(e.qi)}addGroup(e,t){return new eo(this,e,t)}addEndpoint(e,t){return new eo(this).addEndpoint(e,t)}_addEndpoint(e){const t=new Es;t.noIterator=typeof e.handler=="function",t.noIterator||(e.handler=(r,i)=>{r?this.stop(r).catch():t.push(new zu(i))},t.iterClosed.then(()=>{this.close().catch()}));const n=this.setupHandler(e,!1);return n.qi=t,this.handlers.push(n),t}}class G1{constructor(e,t,n=""){p(this,"name");p(this,"subject");p(this,"average_processing_time");p(this,"num_requests");p(this,"processing_time");p(this,"num_errors");p(this,"last_error");p(this,"data");p(this,"metadata");p(this,"queue");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;const t=e;t&&(t.time=0,t.processed=0)}countLatency(e){this.num_requests++,this.processing_time+=rs(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(){const{name:e,subject:t,average_processing_time:n,num_errors:r,num_requests:i,processing_time:o,last_error:a,data:l,queue:u}=this;return{name:e,subject:t,average_processing_time:n,num_errors:r,num_requests:i,processing_time:o,last_error:a,data:l,queue_group:u}}stats(e){const t=e;return(t==null?void 0:t.noIterator)===!1&&(this.processing_time=rs(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()}}class W1{constructor(e,t={strategy:bn.JitterTimer,maxWait:2e3},n){p(this,"nc");p(this,"prefix");p(this,"opts");this.nc=e,this.prefix=n,this.opts=t}ping(e="",t=""){return this.q(dr.PING,e,t)}stats(e="",t=""){return this.q(dr.STATS,e,t)}info(e="",t=""){return this.q(dr.INFO,e,t)}async q(e,t="",n=""){const r=new Es,i=wn(),o=bo.controlSubject(e,t,n,this.prefix),a=await this.nc.requestMany(o,rn,this.opts);return(async()=>{for await(const l of a)try{const u=i.decode(l.data);r.push(u)}catch(u){r.push(()=>{r.stop(u)})}r.push(()=>{r.stop()})})().catch(l=>{r.stop(l)}),r}}const ua="KV-Operation",J1=/^[-/=.\w]+$/,Y1=/^[-/=.>*\w]+$/,X1=/^[-\w]+$/;function eg(s){if(s.startsWith(".")||s.endsWith(".")||!J1.test(s))throw new Error(`invalid key: ${s}`)}function tg(s){if(s.startsWith(".")||s.endsWith(".")||!Y1.test(s))throw new Error(`invalid key: ${s}`)}function sg(s){if(s.startsWith(".")||s.endsWith("."))throw new Error(`invalid key: ${s}`);const e=s.split(".");let t=!1;for(let n=0;n<e.length;n++)switch(e[n]){case"*":t=!0;break;case">":if(n!==e.length-1)throw new Error(`invalid key: ${s}`);t=!0}return t}function Bo(s){if(!X1.test(s))throw new Error(`invalid bucket name: ${s}`)}var Pn;(function(s){s.MsgIdHdr="Nats-Msg-Id",s.ExpectedStreamHdr="Nats-Expected-Stream",s.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",s.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",s.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(Pn||(Pn={}));class to{constructor(e,t,n){p(this,"js");p(this,"jsm");p(this,"stream");p(this,"bucket");p(this,"direct");p(this,"codec");p(this,"prefix");p(this,"editPrefix");p(this,"useJsPrefix");p(this,"_prefixLen");p(this,"validateKey",eg);p(this,"validateSearchKey",tg);p(this,"hasWildcards",sg);Bo(e),this.js=t,this.jsm=n,this.bucket=e,this.prefix="$KV",this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(e,t,n={}){Bo(t);const r=await e.jetstreamManager(),i=new to(t,e,r);return await i.init(n),i}static async bind(e,t,n={}){const r=await e.jetstreamManager(),i={config:{allow_direct:n.allow_direct}};Bo(t);const o=new to(t,e,r);return i.config.name=n.streamName??o.bucketName(),Object.assign(o,i),o.stream=i.config.name,o.codec=n.codec||{key:{encode:a=>a,decode:a=>a},value:{encode:a=>a,decode:a=>a}},o.direct=i.config.allow_direct??!1,o.initializePrefixes(i),o}async init(e={}){const t=Object.assign({replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:{key:{encode:h=>h,decode:h=>h},value:{encode:h=>h,decode:h=>h}},storage:mc.File},e);this.codec=t.codec;const n={};this.stream=n.name=e.streamName??this.bucketName(),n.retention=hc.Limits,n.max_msgs_per_subject=t.history,t.maxBucketSize&&(t.max_bytes=t.maxBucketSize),t.max_bytes&&(n.max_bytes=t.max_bytes),n.max_msg_size=t.maxValueSize,n.storage=t.storage;const r=e.placementCluster??"";if(r&&(e.placement={},e.placement.cluster=r,e.placement.tags=[]),e.placement&&(n.placement=e.placement),e.republish&&(n.republish=e.republish),e.description&&(n.description=e.description),e.mirror){const h=Object.assign({},e.mirror);h.name.startsWith(Dn)||(h.name=`${Dn}${h.name}`),n.mirror=h,n.mirror_direct=!0}else if(e.sources){const h=e.sources.map(v=>{const f=Object.assign({},v),b=f.name.startsWith(Dn)?f.name.substring(3):f.name;return f.name.startsWith(Dn)||(f.name=`${Dn}${f.name}`),v.external||b===this.bucket||(f.subject_transforms=[{src:`$KV.${b}.>`,dest:`$KV.${this.bucket}.>`}]),f});n.sources=h,n.subjects=[this.subjectForBucket()]}else n.subjects=[this.subjectForBucket()];e.metadata&&(n.metadata=e.metadata),typeof e.compression=="boolean"&&(n.compression=e.compression?_r.S2:_r.None);const i=this.js.nc,o=i.getServerVersion(),a=!!o&&fc(o,Or("2.7.2"))>=0;n.discard=a?Xi.New:Xi.Old;const{ok:l,min:u}=i.features.get(Nt.JS_ALLOW_DIRECT);if(!l&&e.allow_direct===!0){const h=o?`${o.major}.${o.minor}.${o.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${h} - requires ${u}`))}let d;e.allow_direct=typeof e.allow_direct=="boolean"?e.allow_direct:l,n.allow_direct=e.allow_direct,this.direct=n.allow_direct,n.num_replicas=t.replicas,t.ttl&&(n.max_age=rs(t.ttl)),n.allow_rollup_hdrs=!0;try{d=await this.jsm.streams.info(n.name),d.config.allow_direct||this.direct!==!0||(this.direct=!1)}catch(h){if(h.message!=="stream not found")throw h;d=await this.jsm.streams.add(n)}this.initializePrefixes(d)}initializePrefixes(e){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:t}=e.config;if(t){let n=t.name;if(n.startsWith(Dn)&&(n=n.substring(3)),t.external&&t.external.api!==""){const r=t.name.substring(3);this.useJsPrefix=!1,this.prefix=`$KV.${r}`,this.editPrefix=`${t.external.api}.$KV.${n}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${Dn}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(e,t=!1){const n=[];return t?(this.useJsPrefix&&n.push(this.js.apiPrefix),this.editPrefix!==""?n.push(this.editPrefix):n.push(this.prefix)):this.prefix&&n.push(this.prefix),n.push(e),n.join(".")}fullKeyName(e){return this.prefix!==""?`${this.prefix}.${e}`:`$KV.${this.bucket}.${e}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(e){const t=[];for(const n of e.split("."))switch(n){case">":case"*":t.push(n);break;default:t.push(this.codec.key.encode(n))}return t.join(".")}decodeKey(e){const t=[];for(const n of e.split("."))switch(n){case">":case"*":t.push(n);break;default:t.push(this.codec.key.decode(n))}return t.join(".")}close(){return Promise.resolve()}dataLen(e,t){const n=t&&t.get(Hs.MessageSizeHdr)||"";return n!==""?parseInt(n,10):e.length}smToEntry(e){return new pg(this.bucket,this.prefixLen,e)}jmToEntry(e){const t=this.decodeKey(e.subject.substring(this.prefixLen));return new fg(this.bucket,t,e)}async create(e,t){var i;let n;try{const o=await this.put(e,t,{previousSeq:0});return Promise.resolve(o)}catch(o){if(n=o,((i=o==null?void 0:o.api_error)==null?void 0:i.err_code)!==10071)return Promise.reject(o)}let r=0;try{const o=await this.get(e);return(o==null?void 0:o.operation)==="DEL"||(o==null?void 0:o.operation)==="PURGE"?(r=o!==null?o.revision:0,this.update(e,t,r)):Promise.reject(n)}catch(o){return Promise.reject(o)}}update(e,t,n){if(n<=0)throw new Error("version must be greater than 0");return this.put(e,t,{previousSeq:n})}async put(e,t,n={}){var o,a;const r=this.encodeKey(e);this.validateKey(r);const i={};if(n.previousSeq!==void 0){const l=Zn();i.headers=l,l.set(Pn.ExpectedLastSubjectSequenceHdr,`${n.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(r,!0),t,i)).seq}catch(l){const u=l;return u.isJetStreamError()?(u.message=(o=u.api_error)==null?void 0:o.description,u.code=`${(a=u.api_error)==null?void 0:a.code}`,Promise.reject(u)):Promise.reject(l)}}async get(e,t){const n=this.encodeKey(e);this.validateKey(n);let r,i={last_by_subj:this.subjectForKey(n)};t&&t.revision>0&&(i={seq:t.revision});try{this.direct?r=await this.jsm.direct.getMessage(this.bucketName(),i):r=await this.jsm.streams.getMessage(this.bucketName(),i);const o=this.smToEntry(r);return o.key!==n?null:o}catch(o){if(o.code===Re.JetStream404NoMessages)return null;throw o}}purge(e,t){return this._deleteOrPurge(e,"PURGE",t)}delete(e,t){return this._deleteOrPurge(e,"DEL",t)}async purgeDeletes(e=18e5){const t=is(),n=[],r=await this.watch({key:">",initializedFn:()=>{t.resolve()}});(async()=>{for await(const l of r)l.operation!=="DEL"&&l.operation!=="PURGE"||n.push(l)})().then(),await t,r.stop();const i=Date.now()-e,o=n.map(l=>{const u=this.subjectForKey(l.key);return l.created.getTime()>=i?this.jsm.streams.purge(this.stream,{filter:u,keep:1}):this.jsm.streams.purge(this.stream,{filter:u,keep:0})}),a=await Promise.all(o);return a.unshift({success:!0,purged:0}),a.reduce((l,u)=>(l.purged+=u.purged,l))}async _deleteOrPurge(e,t,n){if(!this.hasWildcards(e))return this._doDeleteOrPurge(e,t,n);const r=await this.keys(e),i=[];for await(const o of r)i.push(this._doDeleteOrPurge(o,t)),i.length===100&&(await Promise.all(i),i.length=0);i.length>0&&await Promise.all(i)}async _doDeleteOrPurge(e,t,n){const r=this.encodeKey(e);this.validateKey(r);const i=Zn();i.set(ua,t),t==="PURGE"&&i.set(Hs.RollupHdr,Hs.RollupValueSubject),n!=null&&n.previousSeq&&i.set(Pn.ExpectedLastSubjectSequenceHdr,`${n.previousSeq}`),await this.js.publish(this.subjectForKey(r,!0),rn,{headers:i})}_buildCC(e,t,n={}){let r,i=(Array.isArray(e)?e:[e]).map(a=>{const l=this.encodeKey(a);return this.validateSearchKey(a),this.fullKeyName(l)}),o=hs.LastPerSubject;return t===_n.AllHistory&&(o=hs.All),t===_n.UpdatesOnly&&(o=hs.New),i.length===1&&(r=i[0],i=void 0),Object.assign({deliver_policy:o,ack_policy:Cs.None,filter_subjects:i,filter_subject:r,flow_control:!0,idle_heartbeat:rs(5e3)},n)}remove(e){return this.purge(e)}async history(e={}){const t=e.key??">",n=new Es,r={};let i;r.headers_only=e.headers_only||!1,i=()=>{n.stop()};let o=0;const a=this._buildCC(t,_n.AllHistory,r),l=a.filter_subject,u=mr(a);u.bindStream(this.stream),u.orderedConsumer(),u.callback((h,v)=>{if(h)n.stop(h);else if(v){const f=this.jmToEntry(v);n.push(f),n.received++,(i&&o>0&&n.received>=o||v.info.pending===0)&&(n.push(i),i=void 0)}});const d=await this.js.subscribe(l,u);if(i){const{info:{last:h}}=d,v=h.num_pending+h.delivered.consumer_seq;if(v===0||n.received>=v)try{i()}catch(f){n.stop(f)}finally{i=void 0}else o=v}return n._data=d,n.iterClosed.then(()=>{d.unsubscribe()}),d.closed.then(()=>{n.stop()}).catch(h=>{n.stop(h)}),n}canSetWatcherName(){const e=this.js.nc,{ok:t}=e.features.get(Nt.JS_NEW_CONSUMER_CREATE_API);return t}async watch(e={}){const t=e.key??">",n=new Es,r={};r.headers_only=e.headers_only||!1;let i=_n.LastValue;e.include===_n.AllHistory?i=_n.AllHistory:e.include===_n.UpdatesOnly&&(i=_n.UpdatesOnly);const o=e.ignoreDeletes===!0;let a=e.initializedFn,l=0;const u=this._buildCC(t,i,r),d=u.filter_subject,h=mr(u);this.canSetWatcherName()&&h.consumerName(vr.next()),h.bindStream(this.stream),e.resumeFromRevision&&e.resumeFromRevision>0&&h.startSequence(e.resumeFromRevision),h.orderedConsumer(),h.callback((f,b)=>{if(f)n.stop(f);else if(b){const k=this.jmToEntry(b);if(o&&k.operation==="DEL")return;n.push(k),n.received++,a&&(l>0&&n.received>=l||b.info.pending===0)&&(n.push(a),a=void 0)}});const v=await this.js.subscribe(d,h);if(a){const{info:{last:f}}=v,b=f.num_pending+f.delivered.consumer_seq;if(b===0||n.received>=b)try{a()}catch(k){n.stop(k)}finally{a=void 0}else l=b}return n._data=v,n.iterClosed.then(()=>{v.unsubscribe()}),v.closed.then(()=>{n.stop()}).catch(f=>{n.stop(f)}),n}async keys(e=">"){const t=new Es,n=this._buildCC(e,_n.LastValue,{headers_only:!0}),r=Array.isArray(e)?">":n.filter_subject,i=mr(n);i.bindStream(this.stream),i.orderedConsumer();const o=await this.js.subscribe(r,i);return(async()=>{var a;for await(const l of o){const u=(a=l.headers)==null?void 0:a.get(ua);if(u!=="DEL"&&u!=="PURGE"){const d=this.decodeKey(l.subject.substring(this.prefixLen));t.push(d)}l.info.pending===0&&o.unsubscribe()}})().then(()=>{t.stop()}).catch(a=>{t.stop(a)}),o.info.last.num_pending===0&&o.unsubscribe(),t}purgeBucket(e){return this.jsm.streams.purge(this.bucketName(),e)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var i;const e=this.js.nc,t=((i=e.info)==null?void 0:i.cluster)??"",n=this.bucketName(),r=await this.jsm.streams.info(n);return new am(r,t)}}class am{constructor(e,t=""){p(this,"si");p(this,"cluster");this.si=e,this.cluster=t}get bucket(){return this.si.config.name.startsWith(Dn)?this.si.config.name.substring(3):this.si.config.name}get values(){return this.si.state.messages}get history(){return this.si.config.max_msgs_per_subject}get ttl(){return cl(this.si.config.max_age)}get bucket_location(){return this.cluster}get backingStore(){return this.si.config.storage}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get description(){return this.si.config.description??""}get maxBucketSize(){return this.si.config.max_bytes}get maxValueSize(){return this.si.config.max_msg_size}get max_bytes(){return this.si.config.max_bytes}get placement(){return this.si.config.placement||{cluster:"",tags:[]}}get placementCluster(){var e;return((e=this.si.config.placement)==null?void 0:e.cluster)??""}get republish(){return this.si.config.republish??{src:"",dest:""}}get streamInfo(){return this.si}get size(){return this.si.state.bytes}get metadata(){return this.si.config.metadata??{}}get compression(){return!!this.si.config.compression&&this.si.config.compression!==_r.None}}const hl="OBJ_",Uu="SHA-256=";class _c{constructor(e){p(this,"si");p(this,"backingStore");this.si=e,this.backingStore="JetStream"}get bucket(){return(e=this.si.config.name).startsWith(hl)?e.substring(4):e;var e}get description(){return this.si.config.description??""}get ttl(){return this.si.config.max_age}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get sealed(){return this.si.config.sealed}get size(){return this.si.state.bytes}get streamInfo(){return this.si}get metadata(){return this.si.config.metadata}get compression(){return!!this.si.config.compression&&this.si.config.compression!==_r.None}}function $o(s){if(s===void 0)return;const{domain:e}=s;if(e===void 0)return s;const t=Object.assign({},s);if(delete t.domain,e==="")return t;if(t.external)throw new Error("domain and external are both set");return t.external={api:`$JS.${e}.API`},t}var cn,Rn,li;(function(s){s[s.Unset=-1]="Unset",s[s.Consume=0]="Consume",s[s.Fetch=1]="Fetch"})(cn||(cn={})),function(s){s.HeartbeatsMissed="heartbeats_missed",s.ConsumerNotFound="consumer_not_found",s.StreamNotFound="stream_not_found",s.ConsumerDeleted="consumer_deleted",s.OrderedConsumerRecreated="ordered_consumer_recreated",s.NoResponders="no_responders"}(Rn||(Rn={})),function(s){s.DebugEvent="debug",s.Discard="discard",s.Reset="reset",s.Next="next"}(li||(li={}));const Vu=Uint8Array.of(43,65,67,75),ng=Uint8Array.of(45,78,65,75),Li=Uint8Array.of(43,87,80,73),rg=Uint8Array.of(43,78,88,84),ig=Uint8Array.of(43,84,69,82,77),og=Uint8Array.of(32);function Qi(s,e=5e3){return new _g(s,e)}class Va extends Es{constructor(t,n,r=!1){super();p(this,"consumer");p(this,"opts");p(this,"sub");p(this,"monitor");p(this,"pending");p(this,"inbox");p(this,"refilling");p(this,"pong");p(this,"callback");p(this,"timeout");p(this,"cleanupHandler");p(this,"listeners");p(this,"statusIterator");p(this,"forOrderedConsumer");p(this,"resetHandler");p(this,"abortOnMissingResource");p(this,"bind");p(this,"inBackOff");this.consumer=t;const i=n;this.opts=this.parseOptions(n,r),this.callback=i.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=r,this.timeout=null,this.inbox=Qn(t.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=i.abort_on_missing_resource===!0,this.bind=i.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:t,max_bytes:n,idle_heartbeat:r,threshold_bytes:i,threshold_messages:o}=this.opts;this.closed().then(l=>{if(this.cleanupHandler)try{this.cleanupHandler(l)}catch{}});const{sub:a}=this;a&&a.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(l,u)=>{var d,h,v,f;if(l)return void this.stop(l);if((d=this.monitor)==null||d.work(),u.subject===this.inbox){if(dc(u))return;const b=(h=u.headers)==null?void 0:h.code,k=((f=(v=u.headers)==null?void 0:v.description)==null?void 0:f.toLowerCase())||"unknown",{msgsLeft:z,bytesLeft:L}=this.parseDiscard(u.headers);if(z>0||L>0)this.pending.msgs-=z,this.pending.bytes-=L,this.pending.requests--,this.notify(li.Discard,{msgsLeft:z,bytesLeft:L});else{if(b===400)return void this.stop(new Ve(k,`${b}`));if(b===409&&k==="consumer deleted"){if(this.notify(Rn.ConsumerDeleted,`${b} ${k}`),!this.refilling||this.abortOnMissingResource){const se=new Ve(k,`${b}`);return void this.stop(se)}}else if(b===503){if(this.notify(Rn.NoResponders,`${b} No Responders`),!this.refilling||this.abortOnMissingResource){const se=new Ve("no responders",`${b}`);return void this.stop(se)}}else this.notify(li.DebugEvent,`${b} ${k}`)}}else this._push(Qi(u,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=u.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(t&&this.pending.msgs<=o||n&&this.pending.bytes<=i){const b=this.pullOptions();this.pull(b)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),r&&(this.monitor=new ul(r,l=>(this.notify(Rn.HeartbeatsMissed,l),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var u;const l=this.consumer.api.nc.status();this.statusIterator=l;for await(const d of l)switch(d.type){case Tn.Disconnect:(u=this.monitor)==null||u.cancel();break;case Tn.Reconnect:this.resetPending().then(h=>{var v;h&&((v=this.monitor)==null||v.restart())}).catch(()=>{})}})(),this.pull(this.pullOptions())}_push(t){if(this.callback){const n=typeof t=="function"?t:null;try{n?n():this.callback(t)}catch(r){this.stop(r)}}else super.push(t)}notify(t,n){this.listeners.length>0&&this.listeners.forEach(r=>{r.done||r.push({type:t,data:n})})}resetPending(){return this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo()}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){if(this.inBackOff)return!1;let t=0,n=0;const r=al([this.opts.expires]);let i=0;for(;;){if(this.done)return!1;if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),this.inBackOff=!1,t=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(o){if(o.message==="stream not found"){if(n++,this.notify(Rn.StreamNotFound,n),!this.refilling||this.abortOnMissingResource)return this.stop(o),!1}else if(o.message==="consumer not found"){if(t++,this.notify(Rn.ConsumerNotFound,t),this.resetHandler)try{this.resetHandler()}catch{}if(!this.refilling||this.abortOnMissingResource)return this.stop(o),!1;if(this.forOrderedConsumer)return!1}else t=0,n=0;this.inBackOff=!0;const a=Pi(r.backoff(i));await Promise.race([a,this.consumer.api.nc.closed()]),a.cancel(),i++}}}pull(t){this.pending.bytes+=t.max_bytes??0,this.pending.msgs+=t.batch??0,this.pending.requests++;const n=this.consumer.api.nc;this._push(()=>{n.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(t),{reply:this.inbox}),this.notify(li.Next,t)})}pullOptions(){return{batch:this.opts.max_messages-this.pending.msgs,max_bytes:this.opts.max_bytes-this.pending.bytes,idle_heartbeat:rs(this.opts.idle_heartbeat),expires:rs(this.opts.expires)}}parseDiscard(t){const n={msgsLeft:0,bytesLeft:0},r=t==null?void 0:t.get(Hs.PendingMessagesHdr);r&&(n.msgsLeft=parseInt(r));const i=t==null?void 0:t.get(Hs.PendingBytesHdr);return i&&(n.bytesLeft=parseInt(i)),n}trackTimeout(t){this.timeout=t}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var t,n;(t=this.monitor)==null||t.cancel(),this.monitor=null,(n=this.timeout)==null||n.cancel(),this.timeout=null}setCleanupHandler(t){this.cleanupHandler=t}stop(t){var n,r;this.done||((n=this.sub)==null||n.unsubscribe(),this.clearTimers(),(r=this.statusIterator)==null||r.stop(),this._push(()=>{super.stop(t),this.listeners.forEach(i=>{i.stop()})}))}parseOptions(t,n=!1){const r=t||{};if(r.max_messages=r.max_messages||0,r.max_bytes=r.max_bytes||0,r.max_messages!==0&&r.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(r.max_messages===0&&(r.max_messages=100),r.expires=r.expires||3e4,r.expires<1e3)throw new Error("expires should be at least 1000ms");if(r.idle_heartbeat=r.idle_heartbeat||r.expires/2,r.idle_heartbeat=r.idle_heartbeat>3e4?3e4:r.idle_heartbeat,n){const i=Math.round(.75*r.max_messages)||1;r.threshold_messages=r.threshold_messages||i;const o=Math.round(.75*r.max_bytes)||1;r.threshold_bytes=r.threshold_bytes||o}return r}status(){const t=new Es;return this.listeners.push(t),Promise.resolve(t)}}class ag extends Es{constructor(){super();p(this,"src");p(this,"listeners");this.listeners=[]}setSource(t){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=t,this.src.setCleanupHandler(n=>{this.stop(n||void 0)}),(async()=>{const n=await this.src.status();for await(const r of n)this.notify(r.type,r.data)})().catch(()=>{})}notify(t,n){this.listeners.length>0&&this.listeners.forEach(r=>{r.done||r.push({type:t,data:n})})}stop(t){var n;this.done||((n=this.src)==null||n.stop(t),super.stop(t),this.listeners.forEach(r=>{r.stop()}))}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}status(){const t=new Es;return this.listeners.push(t),Promise.resolve(t)}}class yc{constructor(e,t){p(this,"api");p(this,"_info");p(this,"stream");p(this,"name");this.api=e,this._info=t,this.stream=t.stream_name,this.name=t.name}consume(e={max_messages:100,expires:3e4}){return Promise.resolve(new Va(this,e,!0))}fetch(e={max_messages:100,expires:3e4}){const t=new Va(this,e,!1),n=pi(Math.round(1.05*t.opts.expires));return t.closed().catch(()=>{}).finally(()=>{n.cancel()}),n.catch(()=>{t.close().catch()}),t.trackTimeout(n),Promise.resolve(t)}next(e={expires:3e4}){const t=is(),n=e;n.max_messages=1;const r=new Va(this,n,!1),i=Math.round(1.05*r.opts.expires);i>=6e4&&(async()=>{for await(const a of await r.status())if(a.type===Rn.HeartbeatsMissed&&a.data>=2){t.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const a of r){t.resolve(a);break}})().catch(()=>{});const o=pi(i);return r.closed().then(a=>{a?t.reject(a):t.resolve(null)}).catch(a=>{t.reject(a)}).finally(()=>{o.cancel()}),o.catch(a=>{t.resolve(null),r.close().catch()}),r.trackTimeout(o),t}delete(){const{stream_name:e,name:t}=this._info;return this.api.delete(e,t)}info(e=!1){if(e)return Promise.resolve(this._info);const{stream_name:t,name:n}=this._info;return this.api.info(t,n).then(r=>(this._info=r,this._info))}}class cg{constructor(e,t,n={}){p(this,"api");p(this,"consumerOpts");p(this,"consumer");p(this,"opts");p(this,"cursor");p(this,"stream");p(this,"namePrefix");p(this,"serial");p(this,"currentConsumer");p(this,"userCallback");p(this,"iter");p(this,"type");p(this,"startSeq");p(this,"maxInitialReset");this.api=e,this.stream=t,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=vr.next(),typeof n.name_prefix=="string"&&($a("name_prefix",n.name_prefix),this.namePrefix=n.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=cn.Unset,this.consumerOpts=n,this.maxInitialReset=30,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(e){this.serial++,e=e===0?1:e;const t={name:`${this.namePrefix}_${this.serial}`,deliver_policy:hs.StartSequence,opt_start_seq:e,ack_policy:Cs.None,inactive_threshold:rs(3e5),num_replicas:1};return this.consumerOpts.headers_only===!0&&(t.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(t.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(t.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(t.replay_policy=this.consumerOpts.replay_policy),e===this.startSeq+1&&(t.deliver_policy=this.consumerOpts.deliver_policy||hs.StartSequence,this.consumerOpts.deliver_policy!==hs.LastPerSubject&&this.consumerOpts.deliver_policy!==hs.New&&this.consumerOpts.deliver_policy!==hs.Last||(delete t.opt_start_seq,t.deliver_policy=this.consumerOpts.deliver_policy),t.deliver_policy===hs.LastPerSubject&&t.filter_subjects===void 0&&t.filter_subject===void 0&&(t.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete t.opt_start_seq,t.deliver_policy=hs.StartTime,t.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(t.inactive_threshold=rs(this.consumerOpts.inactive_threshold))),t}async resetConsumer(e=0){var o,a,l,u,d;vr.next();const t=this.serial===0;(o=this.consumer)==null||o.delete().catch(()=>{}),e=e===0?1:e,this.cursor.deliver_seq=0;const n=this.getConsumerOpts(e);n.max_deliver=1,n.mem_storage=!0;const r=al([((a=this.opts)==null?void 0:a.expires)||3e4]);let i;for(let h=0;;h++)try{i=await this.api.add(this.stream,n),(l=this.iter)==null||l.notify(Rn.OrderedConsumerRecreated,i.name);break}catch(v){if(v.message==="stream not found"&&((u=this.iter)==null||u.notify(Rn.StreamNotFound,h),this.type===cn.Fetch||this.opts.abort_on_missing_resource===!0))return(d=this.iter)==null||d.stop(v),Promise.reject(v);if(t&&h>=this.maxInitialReset)throw v;await Pi(r.backoff(h+1))}return i}internalHandler(e){return t=>{var r;if(this.serial!==e)return;const n=t.info.deliverySequence;n===this.cursor.deliver_seq+1?(this.cursor.deliver_seq=n,this.cursor.stream_seq=t.info.streamSequence,this.userCallback?this.userCallback(t):(r=this.iter)==null||r.push(t)):this.notifyOrderedResetAndReset()}}async reset(e={max_messages:100,expires:3e4},t){var a,l;const n=(t=t||{}).fromFetch||!1,r=t.orderedReset||!1;if(this.type===cn.Fetch&&r)return(a=this.iter)==null||a.src.stop(),await((l=this.iter)==null?void 0:l.closed()),void(this.currentConsumer=null);(this.currentConsumer===null||r)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||n)&&(this.iter=new ag),this.consumer=new yc(this.api,this.currentConsumer),e.callback=this.internalHandler(this.serial);let i=null;this.type===cn.Fetch&&n?i=await this.consumer.fetch(e):this.type===cn.Consume&&(i=await this.consumer.consume(e));const o=i;o.forOrderedConsumer=!0,o.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(o)}notifyOrderedResetAndReset(){var e;(e=this.iter)==null||e.notify(li.Reset,""),this.reset(this.opts,{orderedReset:!0})}async consume(e={max_messages:100,expires:3e4}){if(e.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===cn.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===cn.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:t}=e;return t&&(this.userCallback=t),this.type=cn.Consume,this.opts=e,await this.reset(e),this.iter}async fetch(e={max_messages:100,expires:3e4}){var n;if(e.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===cn.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((n=this.iter)==null?void 0:n.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:t}=e;return t&&(this.userCallback=t),this.type=cn.Fetch,this.opts=e,await this.reset(e,{fromFetch:!0}),this.iter}async next(e={expires:3e4}){const t=e;if(t.bind)return Promise.reject(new Error("bind is not supported"));t.max_messages=1;const n=is();return t.callback=r=>{this.userCallback=null,n.resolve(r)},(await this.fetch(t)).iterClosed.then(r=>{r&&n.reject(r),n.resolve(null)}).catch(r=>{n.reject(r)}),n}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(e=>Promise.resolve(e)).catch(e=>Promise.reject(e)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(e){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.startSeq),Promise.resolve(this.currentConsumer)):e&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}class bc{constructor(e){p(this,"api");p(this,"notified");this.api=e,this.notified=!1}checkVersion(){const e=this.api.nc.features.get(Nt.JS_SIMPLIFICATION);return e.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${e.min} or better`))}getPullConsumerFor(e){if(e.config.deliver_subject!==void 0)throw new Error("push consumer not supported");return new yc(this.api,e)}async get(e,t={}){return typeof t=="object"?this.ordered(e,t):(await this.checkVersion(),this.api.info(e,t).then(n=>n.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new yc(this.api,n)).catch(n=>Promise.reject(n)))}async ordered(e,t){await this.checkVersion();const n=this.api;return new ml(n.nc,n.opts).info(e).then(r=>Promise.resolve(new cg(this.api,e,t))).catch(r=>Promise.reject(r))}}class Ta{constructor(e,t){p(this,"api");p(this,"_info");this.api=e,this._info=t}get name(){return this._info.config.name}alternates(){return this.info().then(e=>e.alternates?e.alternates:[])}async best(){if(await this.info(),this._info.alternates){const e=await this.api.info(this._info.alternates[0].name);return new Ta(this.api,e)}return this}info(e=!1,t){return e?Promise.resolve(this._info):this.api.info(this.name,t).then(n=>(this._info=n,this._info))}getConsumerFromInfo(e){return new bc(new aa(this.api.nc,this.api.opts)).getPullConsumerFor(e)}getConsumer(e){return new bc(new aa(this.api.nc,this.api.opts)).get(this.name,e)}getMessage(e){return this.api.getMessage(this.name,e)}deleteMessage(e,t){return this.api.deleteMessage(this.name,e,t)}}class ml extends yo{constructor(e,t){super(e,t)}checkStreamConfigVersions(e){const t=this.nc;if(e.metadata){const{min:r,ok:i}=t.features.get(Nt.JS_STREAM_CONSUMER_METADATA);if(!i)throw new Error(`stream 'metadata' requires server ${r}`)}if(e.first_seq){const{min:r,ok:i}=t.features.get(Nt.JS_STREAM_FIRST_SEQ);if(!i)throw new Error(`stream 'first_seq' requires server ${r}`)}if(e.subject_transform){const{min:r,ok:i}=t.features.get(Nt.JS_STREAM_SUBJECT_TRANSFORM);if(!i)throw new Error(`stream 'subject_transform' requires server ${r}`)}if(e.compression){const{min:r,ok:i}=t.features.get(Nt.JS_STREAM_COMPRESSION);if(!i)throw new Error(`stream 'compression' requires server ${r}`)}if(e.consumer_limits){const{min:r,ok:i}=t.features.get(Nt.JS_DEFAULT_CONSUMER_LIMITS);if(!i)throw new Error(`stream 'consumer_limits' requires server ${r}`)}function n(r,i){var o;if((((o=i==null?void 0:i.subject_transforms)==null?void 0:o.length)||0)>0){const{min:a,ok:l}=t.features.get(Nt.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!l)throw new Error(`${r} 'subject_transforms' requires server ${a}`)}}e.sources&&e.sources.forEach(r=>{n("stream sources",r)}),e.mirror&&n("stream mirror",e.mirror)}async add(e={}){var n;this.checkStreamConfigVersions(e),zs(e.name),e.mirror=$o(e.mirror),e.sources=(n=e.sources)==null?void 0:n.map($o);const t=await this._request(`${this.prefix}.STREAM.CREATE.${e.name}`,e);return this._fixInfo(t),t}async delete(e){return zs(e),(await this._request(`${this.prefix}.STREAM.DELETE.${e}`)).success}async update(e,t={}){var o;if(typeof e=="object"){const a=e;e=a.name,t=a,console.trace("\x1B[33m >> streams.update(config: StreamConfig) api changed to streams.update(name: string, config: StreamUpdateConfig) - this shim will be removed - update your code. \x1B[0m")}this.checkStreamConfigVersions(t),zs(e);const n=await this.info(e),r=Object.assign(n.config,t);r.mirror=$o(r.mirror),r.sources=(o=r.sources)==null?void 0:o.map($o);const i=await this._request(`${this.prefix}.STREAM.UPDATE.${e}`,r);return this._fixInfo(i),i}async info(e,t){zs(e);const n=`${this.prefix}.STREAM.INFO.${e}`;let r=await this._request(n,t),{total:i,limit:o}=r,a=r.state.subjects?Object.getOwnPropertyNames(r.state.subjects).length:1;if(i&&i>a){const l=[r],u=t||{};let d=0;for(;i>a;){d++,u.offset=o*d;const v=await this._request(n,u);i=v.total,l.push(v);const f=Object.getOwnPropertyNames(v.state.subjects).length;if(a+=f,f<o)break}let h={};for(let v=0;v<l.length;v++)r=l[v],r.state.subjects&&(h=Object.assign(h,r.state.subjects));r.offset=0,r.total=0,r.limit=0,r.state.subjects=h}return this._fixInfo(r),r}list(e=""){const t=e!=null&&e.length?{subject:e}:{},n=`${this.prefix}.STREAM.LIST`;return new Hi(n,r=>{const i=r;return i.streams.forEach(o=>{this._fixInfo(o)}),i.streams},this,t)}_fixInfo(e){e.config.sealed=e.config.sealed||!1,e.config.deny_delete=e.config.deny_delete||!1,e.config.deny_purge=e.config.deny_purge||!1,e.config.allow_rollup_hdrs=e.config.allow_rollup_hdrs||!1}async purge(e,t){if(t){const{keep:n,seq:r}=t;if(typeof n=="number"&&typeof r=="number")throw new Error("can specify one of keep or seq")}return zs(e),await this._request(`${this.prefix}.STREAM.PURGE.${e}`,t)}async deleteMessage(e,t,n=!0){zs(e);const r={seq:t};return n||(r.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${e}`,r)).success}async getMessage(e,t){zs(e);const n=await this._request(`${this.prefix}.STREAM.MSG.GET.${e}`,t);return new cm(n)}find(e){return this.findStream(e)}listKvs(){const e=`${this.prefix}.STREAM.LIST`;return new Hi(e,t=>{var i;const n=t.streams.filter(o=>o.config.name.startsWith(Dn));n.forEach(o=>{this._fixInfo(o)});let r="";return n.length&&(r=((i=this.nc.info)==null?void 0:i.cluster)??""),n.map(o=>new am(o,r))},this)}listObjectStores(){const e=`${this.prefix}.STREAM.LIST`;return new Hi(e,t=>{const n=t.streams.filter(r=>r.config.name.startsWith(hl));return n.forEach(r=>{this._fixInfo(r)}),n.map(r=>new _c(r))},this)}names(e=""){const t=e!=null&&e.length?{subject:e}:{},n=`${this.prefix}.STREAM.NAMES`;return new Hi(n,r=>r.streams,this,t)}async get(e){const t=await this.info(e);return Promise.resolve(new Ta(this,t))}}class lg extends yo{constructor(e,t){super(e,t)}async getMessage(e,t){zs(e);let n=t;const{last_by_subj:r}=n;r&&(n=null);const i=n?this.jc.encode(n):rn,o=this.opts.apiPrefix||"$JS.API",a=r?`${o}.DIRECT.GET.${e}.${r}`:`${o}.DIRECT.GET.${e}`,l=await this.nc.request(a,i,{timeout:this.timeout}),u=Yr(l);if(u)return Promise.reject(u);const d=new wc(l);return Promise.resolve(d)}async getBatch(e,t){zs(e);const n=`${this.opts.apiPrefix||"$JS.API"}.DIRECT.GET.${e}`;if(!Array.isArray(t.multi_last)||t.multi_last.length===0)return Promise.reject("multi_last is required");const r=JSON.stringify(t,(a,l)=>a==="up_to_time"&&l instanceof Date?l.toISOString():l),i=new Es,o=await this.nc.requestMany(n,r,{strategy:bn.SentinelMsg});return(async()=>{var d,h,v;let a,l=!1,u=!1;for await(const f of o){if(!l){l=!0;const b=((d=f.headers)==null?void 0:d.code)||0;if(b!==0&&b<200||b>299){a=(h=f.headers)==null?void 0:h.description.toLowerCase();break}if(((v=f.headers)==null?void 0:v.get("Nats-Num-Pending"))===""){u=!0;break}}if(f.data.length===0)break;i.push(new wc(f))}i.push(()=>{if(u)throw new Error("batch direct get not supported by the server");if(a)throw new Error(`bad request: ${a}`);i.stop()})})(),Promise.resolve(i)}}class wc{constructor(e){p(this,"data");p(this,"header");if(!e.headers)throw new Error("headers expected");this.data=e.data,this.header=e.headers}get subject(){return this.header.last(ti.Subject)}get seq(){const e=this.header.last(ti.Sequence);return typeof e=="string"?parseInt(e):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(ti.TimeStamp)}get stream(){return this.header.last(ti.Stream)}json(e){return wn(e).decode(this.data)}string(){return sn.decode(this.data)}}p(wc,"jc");class ug extends yo{constructor(t,n){super(t,n);p(this,"streams");p(this,"consumers");p(this,"direct");this.streams=new ml(t,n),this.consumers=new aa(t,n),this.direct=new lg(t,n)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const t=new Es;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(n,r)=>{if(n)throw n;try{const i=this.parseJsResponse(r),o=i.type.split("."),a=o[o.length-1];t.push({kind:a,data:i})}catch(i){t.stop(i)}}}),t}}class cm{constructor(e){p(this,"_header");p(this,"smr");this.smr=e}get subject(){return this.smr.message.subject}get seq(){return this.smr.message.seq}get timestamp(){return this.smr.message.time}get time(){return new Date(Date.parse(this.timestamp))}get data(){return this.smr.message.data?this._parse(this.smr.message.data):rn}get header(){if(!this._header)if(this.smr.message.hdrs){const e=this._parse(this.smr.message.hdrs);this._header=hr.decode(e)}else this._header=Zn();return this._header}_parse(e){const t=atob(e),n=t.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=t.charCodeAt(i);return r}json(e){return wn(e).decode(this.data)}string(){return sn.decode(this.data)}}p(cm,"jc");class dg{constructor(e){p(this,"api");this.api=e}get(e){return this.api.info(e).then(t=>new Ta(this.api,t))}}class Ha{constructor(e){p(this,"info");p(this,"hdrs");this.info=e}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=hr.fromRecord(this.info.headers||{})),this.hdrs}get options(){return this.info.options}get bucket(){return this.info.bucket}get chunks(){return this.info.chunks}get deleted(){return this.info.deleted??!1}get digest(){return this.info.digest}get mtime(){return this.info.mtime}get nuid(){return this.info.nuid}get size(){return this.info.size}get revision(){return this.info.revision}get metadata(){return this.info.metadata||{}}isLink(){var e,t;return((e=this.info.options)==null?void 0:e.link)!==void 0&&((t=this.info.options)==null?void 0:t.link)!==null}}function Hu(s){const e={name:s.name,description:s.description??"",options:s.options,metadata:s.metadata};if(s.headers){const t=s.headers;e.headers=t.toRecord()}return e}class Wi{constructor(e,t,n){p(this,"jsm");p(this,"js");p(this,"stream");p(this,"name");this.name=e,this.jsm=t,this.js=n}_checkNotEmpty(e){return e&&e.length!==0?{name:e}:{name:e,error:new Error("name cannot be empty")}}async info(e){const t=await this.rawInfo(e);return t?new Ha(t):null}async list(){const e=[],t=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const n of t){if(n===null)break;e.push(n)}return Promise.resolve(e)}async rawInfo(e){const{name:t,error:n}=this._checkNotEmpty(e);if(n)return Promise.reject(n);const r=this._metaSubject(t);try{const i=await this.jsm.streams.getMessage(this.stream,{last_by_subj:r}),o=wn().decode(i.data);return o.revision=i.seq,o}catch(i){return i.code==="404"?null:Promise.reject(i)}}async _si(e){try{return await this.jsm.streams.info(this.stream,e)}catch(t){return t.code==="404"?null:Promise.reject(t)}}async seal(){let e=await this._si();return e===null?Promise.reject(new Error("object store not found")):(e.config.sealed=!0,e=await this.jsm.streams.update(this.stream,e.config),Promise.resolve(new _c(e)))}async status(e){const t=await this._si(e);return t===null?Promise.reject(new Error("object store not found")):Promise.resolve(new _c(t))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(e,t,n){var N;const r=this.js.getOptions();(n=n||{timeout:r.timeout}).timeout=n.timeout||r.timeout,n.previousRevision=n.previousRevision??void 0;const{timeout:i,previousRevision:o}=n,a=this.js.nc.info,l=(a==null?void 0:a.max_payload)||1024;(e=e||{}).options=e.options||{};let u=((N=e.options)==null?void 0:N.max_chunk_size)||131072;u=u>l?l:u,e.options.max_chunk_size=u;const d=await this.info(e.name),{name:h,error:v}=this._checkNotEmpty(e.name);if(v)return Promise.reject(v);const f=vr.next(),b=this._chunkSubject(f),k=this._metaSubject(h),z=Object.assign({bucket:this.name,nuid:f,size:0,chunks:0},Hu(e)),L=is(),se=[],K=new fi;try{const E=t?t.getReader():null,O=Fu.create();for(;;){const{done:U,value:S}=E?await E.read():{done:!0,value:void 0};if(U){if(K.size()>0){const I=K.drain();O.update(I),z.chunks++,z.size+=I.length,se.push(this.js.publish(b,I,{timeout:i}))}await Promise.all(se),se.length=0,z.mtime=new Date().toISOString();const M=ci.encode(O.digest());z.digest=`${Uu}${M}`,z.deleted=!1;const B=Zn();typeof o=="number"&&B.set(Pn.ExpectedLastSubjectSequenceHdr,`${o}`),B.set(Hs.RollupHdr,Hs.RollupValueSubject);const W=await this.js.publish(k,wn().encode(z),{headers:B,timeout:i});if(z.revision=W.seq,d)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${d.nuid}`})}catch{}L.resolve(new Ha(z));break}if(S)for(K.fill(S);K.size()>u;){z.chunks++,z.size+=u;const M=K.drain(e.options.max_chunk_size);O.update(M),se.push(this.js.publish(b,M,{timeout:i}))}}}catch(E){await this.jsm.streams.purge(this.stream,{filter:b}),L.reject(E)}return L}putBlob(e,t,n){return t===null&&(t=new Uint8Array(0)),this.put(e,function(r){return new ReadableStream({pull(i){i.enqueue(r),i.close()}})}(t),n)}put(e,t,n){var r;return(r=e==null?void 0:e.options)!=null&&r.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(e,t,n)}async getBlob(e){const t=await this.get(e);if(t===null)return Promise.resolve(null);const n=await Promise.all([t.error,async function(r){const i=new fi,o=r.getReader();for(;;){const{done:a,value:l}=await o.read();if(a)return i.drain();l&&l.length&&i.fill(l)}}(t.data)]);return n[0]?Promise.reject(n[0]):Promise.resolve(n[1])}async get(e){const t=await this.rawInfo(e);if(t===null||t.deleted)return Promise.resolve(null);if(t.options&&t.options.link){const h=t.options.link.name||"";if(h==="")throw new Error("link is a bucket");return(t.options.link.bucket!==this.name?await Wi.create(this.js,t.options.link.bucket):this).get(h)}if(!t.digest.startsWith(Uu))return Promise.reject(new Error(`unknown digest type: ${t.digest}`));const n=pc(t.digest.substring(8));if(n===null)return Promise.reject(new Error(`unable to parse digest: ${t.digest}`));const r=is(),i={info:new Ha(t),error:r};if(t.size===0)return i.data=new ReadableStream({pull(h){h.enqueue(new Uint8Array(0)),h.close()}}),r.resolve(null),Promise.resolve(i);let o;const a=mr();a.orderedConsumer();const l=Fu.create(),u=`$O.${this.name}.C.${t.nuid}`,d=await this.js.subscribe(u,a);return(async()=>{for await(const h of d)h.data.length>0&&(l.update(h.data),o.enqueue(h.data)),h.info.pending===0&&($1(n,l.digest())?o.close():o.error(new Error(`received a corrupt object, digests do not match received: ${t.digest} calculated ${n}`)),d.unsubscribe())})().then(()=>{r.resolve()}).catch(h=>{o.error(h),r.reject(h)}),i.data=new ReadableStream({start(h){o=h},cancel(){d.unsubscribe()}}),i}linkStore(e,t){if(!(t instanceof Wi))return Promise.reject("bucket required");const n=t,{name:r,error:i}=this._checkNotEmpty(e);if(i)return Promise.reject(i);const o={name:r,options:{link:{bucket:n.name}}};return this._put(o,null)}async link(e,t){const{name:n,error:r}=this._checkNotEmpty(e);if(r)return Promise.reject(r);if(t.deleted)return Promise.reject(new Error("src object is deleted"));if(t.isLink())return Promise.reject(new Error("src object is a link"));const i=await this.rawInfo(e);if(i!==null&&!i.deleted)return Promise.reject(new Error("an object already exists with that name"));const o={bucket:t.bucket,name:t.name},a={name:n,bucket:t.bucket,options:{link:o}};await this.js.publish(this._metaSubject(e),JSON.stringify(a));const l=await this.info(e);return Promise.resolve(l)}async delete(e){const t=await this.rawInfo(e);if(t===null)return Promise.resolve({purged:0,success:!1});t.deleted=!0,t.size=0,t.chunks=0,t.digest="";const n=wn(),r=Zn();return r.set(Hs.RollupHdr,Hs.RollupValueSubject),await this.js.publish(this._metaSubject(t.name),n.encode(t),{headers:r}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(t.nuid)})}async update(e,t={}){const n=await this.rawInfo(e);if(n===null)return Promise.reject(new Error("object not found"));if(n.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));t.name=t.name??n.name;const{name:r,error:i}=this._checkNotEmpty(t.name);if(i)return Promise.reject(i);if(e!==t.name){const l=await this.info(t.name);if(l&&!l.deleted)return Promise.reject(new Error("an object already exists with that name"))}t.name=r;const o=Object.assign({},n,Hu(t)),a=await this.js.publish(this._metaSubject(o.name),JSON.stringify(o));return e!==t.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(e)}),Promise.resolve(a)}async watch(e={}){e.includeHistory=e.includeHistory??!1,e.ignoreDeletes=e.ignoreDeletes??!1;let t=!1;const n=new Es,r=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:r})}catch(l){l.code==="404"?(n.push(null),t=!0):n.stop(l)}const i=wn(),o=mr();o.orderedConsumer(),e.includeHistory?o.deliverLastPerSubject():(t=!0,o.deliverNew()),o.callback((l,u)=>{var d;if(l)n.stop(l);else if(u!==null){const h=i.decode(u.data);h.deleted&&e.ignoreDeletes===!0||n.push(h),((d=u.info)==null?void 0:d.pending)!==0||t||(t=!0,n.push(null))}});const a=await this.js.subscribe(r,o);return n._data=a,n.iterClosed.then(()=>{a.unsubscribe()}),a.closed.then(()=>{n.stop()}).catch(l=>{n.stop(l)}),n}_chunkSubject(e){return`$O.${this.name}.C.${e}`}_metaSubject(e){return`$O.${this.name}.M.${ci.encode(e)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(e={}){try{this.stream=(Bo(t=this.name),`${hl}${t}`)}catch(i){return Promise.reject(i)}var t;const n=(e==null?void 0:e.ttl)||0;delete e.ttl;const r=Object.assign({max_age:n},e);r.name=this.stream,r.num_replicas=e.replicas??1,r.allow_direct=!0,r.allow_rollup_hdrs=!0,r.discard=Xi.New,r.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],e.placement&&(r.placement=e.placement),e.metadata&&(r.metadata=e.metadata),typeof e.compression=="boolean"&&(r.compression=e.compression?_r.S2:_r.None);try{await this.jsm.streams.info(r.name)}catch(i){i.message==="stream not found"&&await this.jsm.streams.add(r)}}static async create(e,t,n={}){const r=await e.jetstreamManager(),i=new Wi(t,r,e);return await i.init(n),Promise.resolve(i)}}class hg{constructor(e){p(this,"js");this.js=e}kv(e,t={}){const n=this.js,{ok:r,min:i}=n.nc.features.get(Nt.JS_KV);return r?t.bindOnly?to.bind(this.js,e,t):to.create(this.js,e,t):Promise.reject(new Error(`kv is only supported on servers ${i} or better`))}os(e,t={}){var o;if(typeof((o=crypto==null?void 0:crypto.subtle)==null?void 0:o.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const n=this.js,{ok:r,min:i}=n.nc.features.get(Nt.JS_OBJECTSTORE);return r?Wi.create(this.js,e,t):Promise.reject(new Error(`objectstore is only supported on servers ${i} or better`))}}class pl extends yo{constructor(t,n){super(t,n);p(this,"consumers");p(this,"streams");p(this,"consumerAPI");p(this,"streamAPI");this.consumerAPI=new aa(t,n),this.streamAPI=new ml(t,n),this.consumers=new bc(this.consumerAPI),this.streams=new dg(this.streamAPI)}jetstreamManager(t){t===void 0&&(t=this.opts.checkAPI);const n=Object.assign({},this.opts,{checkAPI:t});return this.nc.jetstreamManager(n)}get apiPrefix(){return this.prefix}get views(){return new hg(this)}async publish(t,n=rn,r){(r=r||{}).expect=r.expect||{};const i=(r==null?void 0:r.headers)||Zn();r&&(r.msgID&&i.set(Pn.MsgIdHdr,r.msgID),r.expect.lastMsgID&&i.set(Pn.ExpectedLastMsgIdHdr,r.expect.lastMsgID),r.expect.streamName&&i.set(Pn.ExpectedStreamHdr,r.expect.streamName),typeof r.expect.lastSequence=="number"&&i.set(Pn.ExpectedLastSeqHdr,`${r.expect.lastSequence}`),typeof r.expect.lastSubjectSequence=="number"&&i.set(Pn.ExpectedLastSubjectSequenceHdr,`${r.expect.lastSubjectSequence}`));const o=r.timeout||this.timeout,a={};o&&(a.timeout=o),r&&(a.headers=i);let l,{retries:u,retry_delay:d}=r;u=u||1,d=d||250;for(let v=0;v<u;v++)try{l=await this.nc.request(t,n,a);break}catch(f){if(!(f.code==="503"&&v+1<u))throw f;await Pi(d)}const h=this.parseJsResponse(l);if(h.stream==="")throw Ve.errorForCode(Re.JetStreamInvalidAck);return h.duplicate=!!h.duplicate&&h.duplicate,h}async pull(t,n,r=0){zs(t),oi(n);let i=this.timeout;r>i&&(i=r);const o={batch:1,no_wait:(r=r<0?0:rs(r))===0,expires:r},a=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${t}.${n}`,this.jc.encode(o),{noMux:!0,timeout:i}),l=Yr(a);if(l)throw l;return Qi(a,this.timeout)}fetch(t,n,r={}){zs(t),oi(n);let i=null;const o=(r.max_bytes??0)>0;let a=0;const l=o?r.max_bytes:0;let u=null;const d={};if(d.batch=r.batch||1,l){const se=this.nc.features.get(Nt.JS_PULL_MAX_BYTES);if(!se.ok)throw new Error(`max_bytes is only supported on servers ${se.min} or better`);d.max_bytes=l}d.no_wait=r.no_wait||!1,d.no_wait&&d.expires&&(d.expires=0);const h=r.expires||0;if(h&&(d.expires=rs(h)),h===0&&d.no_wait===!1)throw new Error("expires or no_wait is required");const v=r.idle_heartbeat||0;v&&(d.idle_heartbeat=rs(v),r.delay_heartbeat===!0&&(d.idle_heartbeat=rs(4*v)));const f=new Es,b=d.batch;let k=0;f.protocolFilterFn=(se,K=!1)=>!dc(se.msg)||(u==null||u.work(),!1),f.dispatchedFn=se=>{if(se){if(o&&(a+=se.data.length),k++,i&&se.info.pending===0)return;(f.getPending()===1&&se.info.pending===0||b===k||l>0&&a>=l)&&f.stop()}};const z=Qn(this.nc.options.inboxPrefix),L=this.nc.subscribe(z,{max:r.batch,callback:(se,K)=>{se===null&&(se=Yr(K)),se!==null?(i&&(i.cancel(),i=null),function(N){return typeof N.code=="string"}(se)?f.stop(Qu(se)===null?void 0:se):f.stop(se)):(u==null||u.work(),f.received++,f.push(Qi(K,this.timeout)))}});return h&&(i=pi(h),i.catch(()=>{L.isClosed()||(L.drain().catch(()=>{}),i=null),u&&u.cancel()})),(async()=>{try{v&&(u=new ul(v,se=>(f.push(()=>{f.err=new Ve(`${un.IdleHeartbeatMissed}: ${se}`,Re.JetStreamIdleHeartBeat)}),!0)))}catch{}await L.closed,i!==null&&(i.cancel(),i=null),u&&u.cancel(),f.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${t}.${n}`,this.jc.encode(d),{reply:z}),f}async pullSubscribe(t,n=mr()){const r=await this._processOptions(t,n);if(r.ordered)throw new Error("pull subscribers cannot be be ordered");if(r.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const i=r.config.ack_policy;if(i===Cs.None||i===Cs.All)throw new Error("ack policy for pull consumers must be explicit");const o=this._buildTypedSubscriptionOpts(r),a=new gg(this,r.deliver,o);a.info=r;try{await this._maybeCreateConsumer(r)}catch(l){throw a.unsubscribe(),l}return a}async subscribe(t,n=mr()){const r=await this._processOptions(t,n);if(!r.isBind&&!r.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const i=this._buildTypedSubscriptionOpts(r),o=new lm(this,r.deliver,i);o.info=r;try{await this._maybeCreateConsumer(r)}catch(a){throw o.unsubscribe(),a}return o._maybeSetupHbMonitoring(),o}async _processOptions(t,n=mr()){const r=Ru(n)?n.getOpts():n;if(r.isBind=!!Ru(n)&&n.isBind,r.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},r.ordered){if(r.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},r.config.ack_policy!==Cs.NotSet&&r.config.ack_policy!==Cs.None)throw new Ve("ordered consumer: ack_policy can only be set to 'none'",Re.ApiError);if(r.config.durable_name&&r.config.durable_name.length>0)throw new Ve("ordered consumer: durable_name cannot be set",Re.ApiError);if(r.config.deliver_subject&&r.config.deliver_subject.length>0)throw new Ve("ordered consumer: deliver_subject cannot be set",Re.ApiError);if(r.config.max_deliver!==void 0&&r.config.max_deliver>1)throw new Ve("ordered consumer: max_deliver cannot be set",Re.ApiError);if(r.config.deliver_group&&r.config.deliver_group.length>0)throw new Ve("ordered consumer: deliver_group cannot be set",Re.ApiError);r.config.deliver_subject=Qn(this.nc.options.inboxPrefix),r.config.ack_policy=Cs.None,r.config.max_deliver=1,r.config.flow_control=!0,r.config.idle_heartbeat=r.config.idle_heartbeat||rs(5e3),r.config.ack_wait=rs(792e5),r.config.mem_storage=!0,r.config.num_replicas=1}if(r.config.ack_policy===Cs.NotSet&&(r.config.ack_policy=Cs.All),r.api=this,r.config=r.config||{},r.stream=r.stream?r.stream:await this.findStream(t),r.attached=!1,r.config.durable_name)try{const i=await this.consumerAPI.info(r.stream,r.config.durable_name);if(i){if(i.config.filter_subject&&i.config.filter_subject!==t)throw new Error("subject does not match consumer");const o=r.config.deliver_group??"";if(o===""&&i.push_bound===!0)throw new Error("duplicate subscription");const a=i.config.deliver_group??"";if(o!==a)throw a===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${a}'`);r.last=i,r.config=i.config,r.attached=!0,r.config.durable_name||(r.name=i.name)}}catch(i){if(i.code!=="404")throw i}return r.attached||r.config.filter_subject!==void 0||r.config.filter_subjects!==void 0||(r.config.filter_subject=t),r.deliver=r.config.deliver_subject||Qn(this.nc.options.inboxPrefix),r}_buildTypedSubscriptionOpts(t){const n={};return n.adapter=function(r,i){return r?function(o){return(a,l)=>{if(a)return[a,null];const u=Yr(l);return u!==null?[Qu(u),null]:[null,Qi(l,o)]}}(i):function(o){return(a,l)=>a||(a=Yr(l))?[a,null]:[null,Qi(l,o)]}(i)}(t.callbackFn===void 0,this.timeout),n.ingestionFilterFn=pl.ingestionFn(t.ordered),n.protocolFilterFn=(r,i=!1)=>{const o=r;return!uc(o.msg)||(i||o.msg.respond(),!1)},t.mack||t.config.ack_policy===Cs.None||(n.dispatchedFn=vg),t.callbackFn&&(n.callback=t.callbackFn),n.max=t.max||0,n.queue=t.queue,n}async _maybeCreateConsumer(t){if(t.attached)return;if(t.isBind)throw new Error(`unable to bind - durable consumer ${t.config.durable_name} doesn't exist in ${t.stream}`);t.config=Object.assign({deliver_policy:hs.All,ack_policy:Cs.Explicit,ack_wait:rs(3e4),replay_policy:ai.Instant},t.config);const n=await this.consumerAPI.add(t.stream,t.config);if(Array.isArray(t.config.filter_subjects&&!Array.isArray(n.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");t.name=n.name,t.config=n.config,t.last=n}static ingestionFn(t){return(n,r)=>{var a;const i=r;if(!n)return{ingest:!1,protocol:!1};const o=n;if(Yr(o.msg)||((a=i.monitor)==null||a.work()),dc(o.msg)){const l=!t||i._checkHbOrderConsumer(o.msg);return t||i.info.flow_control.heartbeat_count++,{ingest:l,protocol:!0}}return uc(o.msg)?(i.info.flow_control.fc_count++,{ingest:!0,protocol:!0}):{ingest:!t||i._checkOrderedConsumer(n),protocol:!1}}}}class fl{constructor(e){p(this,"options");p(this,"protocol");p(this,"draining");p(this,"listeners");p(this,"_services");this.draining=!1,this.options=V1(e),this.listeners=[]}static connect(e={}){return new Promise((t,n)=>{const r=new fl(e);la.connect(r.options,r).then(i=>{r.protocol=i,async function(){for await(const o of i.status())r.listeners.forEach(a=>{a.push(o)})}(),t(r)}).catch(i=>{n(i)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,t,n){if(this.isClosed())throw Ve.errorForCode(Re.ConnectionClosed);if(t&&this.isDraining()||n&&this.protocol.noMorePublishing)throw Ve.errorForCode(Re.ConnectionDraining);if((e=e||"").length===0)throw Ve.errorForCode(Re.BadSubject)}publish(e,t,n){this._check(e,!1,!0),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)}subscribe(e,t={}){this._check(e,!0,!1);const n=new om(this.protocol,e,t);return this.protocol.subscribe(n),n}_resub(e,t,n){this._check(t,!0,!1);const r=e;r.max=n,n&&(r.max=n+r.received),this.protocol.resub(r,t)}requestMany(e,t=rn,n={maxWait:1e3,maxMessages:-1}){const r=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(l){return Promise.reject(l)}if(n.strategy=n.strategy||bn.Timer,n.maxWait=n.maxWait||1e3,n.maxWait<1)return Promise.reject(new Ve("timeout",Re.InvalidOption));const i=new Es;function o(l){i.push(()=>{i.stop(l)})}function a(l,u){l||u===null?o(l===null?void 0:l):i.push(u)}if(n.noMux){const l=r?new Error().stack:null;let u=typeof n.maxMessages=="number"&&n.maxMessages>0?n.maxMessages:-1;const d=this.subscribe(Qn(this.options.inboxPrefix),{callback:(b,k)=>{var z,L;if(((z=k==null?void 0:k.data)==null?void 0:z.length)===0&&((L=k==null?void 0:k.headers)==null?void 0:L.status)===Re.NoResponders&&(b=Ve.errorForCode(Re.NoResponders)),b)return l&&(b.stack+=`
24
-
25
- ${l}`),void h(b);a(null,k),n.strategy===bn.Count&&(u--,u===0&&h()),n.strategy===bn.JitterTimer&&(f(),v=setTimeout(()=>{h()},300)),n.strategy===bn.SentinelMsg&&k&&k.data.length===0&&h()}});d.requestSubject=e,d.closed.then(()=>{o()}).catch(b=>{i.stop(b)});const h=b=>{b&&i.push(()=>{throw b}),f(),d.drain().then(()=>{o()}).catch(k=>{o()})};i.iterClosed.then(()=>{f(),d==null||d.unsubscribe()}).catch(b=>{f(),d==null||d.unsubscribe()});try{this.publish(e,t,{reply:d.getSubject()})}catch(b){h(b)}let v=setTimeout(()=>{h()},n.maxWait);const f=()=>{v&&clearTimeout(v)}}else{const l=n;l.callback=a,i.iterClosed.then(()=>{u.cancel()}).catch(d=>{u.cancel(d)});const u=new T1(this.protocol.muxSubscriptions,e,l);this.protocol.request(u);try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:n.headers})}catch(d){u.cancel(d)}}return Promise.resolve(i)}request(e,t,n={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(i){return Promise.reject(i)}const r=!this.protocol.options.noAsyncTraces;if(n.timeout=n.timeout||1e3,n.timeout<1)return Promise.reject(new Ve("timeout",Re.InvalidOption));if(!n.noMux&&n.reply)return Promise.reject(new Ve("reply can only be used with noMux",Re.InvalidOption));if(n.noMux){const i=n.reply?n.reply:Qn(this.options.inboxPrefix),o=is(),a=r?new Error:null,l=this.subscribe(i,{max:1,timeout:n.timeout,callback:(u,d)=>{u?(a&&u.code!==Re.Timeout&&(u.stack+=`
26
-
27
- ${a.stack}`),l.unsubscribe(),o.reject(u)):(u=Xh(d))?(a&&(u.stack+=`
28
-
29
- ${a.stack}`),o.reject(u)):o.resolve(d)}});return l.requestSubject=e,this.protocol.publish(e,t,{reply:i,headers:n.headers}),o}{const i=new sm(this.protocol.muxSubscriptions,e,n,r);this.protocol.request(i);try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${i.token}`,headers:n.headers})}catch(a){i.cancel(a)}const o=Promise.race([i.timer,i.deferred]);return o.catch(()=>{i.cancel()}),o}}flush(){return this.isClosed()?Promise.reject(Ve.errorForCode(Re.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(Ve.errorForCode(Re.ConnectionClosed)):this.isDraining()?Promise.reject(Ve.errorForCode(Re.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Es;return e.iterClosed.then(()=>{const t=this.listeners.indexOf(e);this.listeners.splice(t,1)}),this.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}}async jetstreamManager(e={}){const t=new ug(this,e);if(e.checkAPI!==!1)try{await t.getAccountInfo()}catch(n){const r=n;throw r.code===Re.NoResponders&&(r.code=Re.JetStreamNotEnabled),r}return t}jetstream(e={}){return new pl(this,e)}getServerVersion(){const e=this.info;return e?Or(e.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw Ve.errorForCode(Re.Disconnect);const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}get services(){return this._services||(this._services=new mg(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(Ve.errorForCode(Re.ConnectionClosed)):this.isDraining()?Promise.reject(Ve.errorForCode(Re.ConnectionDraining)):this.protocol.reconnect()}}class mg{constructor(e){p(this,"nc");this.nc=e}add(e){try{return new bo(this.nc,e).start()}catch(t){return Promise.reject(t)}}client(e,t){return new W1(this.nc,e,t)}}class pg{constructor(e,t,n){p(this,"bucket");p(this,"sm");p(this,"prefixLen");this.bucket=e,this.prefixLen=t,this.sm=n}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(ua)||"PUT"}get length(){const e=this.sm.header.get(Hs.MessageSizeHdr)||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class fg{constructor(e,t,n){p(this,"bucket");p(this,"key");p(this,"sm");this.bucket=e,this.key=t,this.sm=n}get value(){return this.sm.data}get created(){return new Date(cl(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var e;return((e=this.sm.headers)==null?void 0:e.get(ua))||"PUT"}get delta(){return this.sm.info.pending}get length(){var t;const e=((t=this.sm.headers)==null?void 0:t.get(Hs.MessageSizeHdr))||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class lm extends R1{constructor(t,n,r){super(t.nc,n,r);p(this,"js");p(this,"monitor");this.js=t,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(t){this.sub.info=t}get info(){return this.sub.info}_resetOrderedConsumer(t){if(this.info===null||this.sub.isClosed())return;const n=Qn(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,n);const r=this.info;r.config.name=vr.next(),r.ordered_consumer_sequence.delivery_seq=0,r.flow_control.heartbeat_count=0,r.flow_control.fc_count=0,r.flow_control.consumer_restarts++,r.deliver=n,r.config.deliver_subject=n,r.config.deliver_policy=hs.StartSequence,r.config.opt_start_seq=t;const i={};i.stream_name=this.info.stream,i.config=r.config;const o=`${r.api.prefix}.CONSUMER.CREATE.${r.stream}`;this.js._request(o,i,{retries:-1}).then(a=>{const l=a;this.sub.info.last=l,this.info.config=l.config,this.info.name=l.name}).catch(a=>{const l=new Ve(`unable to recreate ordered consumer ${r.stream} at seq ${t}`,Re.RequestError,a);this.sub.callback(l,{})})}_maybeSetupHbMonitoring(){var n,r;const t=((r=(n=this.info)==null?void 0:n.config)==null?void 0:r.idle_heartbeat)||0;t&&this._setupHbMonitoring(cl(t))}_setupHbMonitoring(t,n=0){const r={cancelAfter:0,maxOut:2};n&&(r.cancelAfter=n);const i=this.sub;this.monitor=new ul(t,o=>{var u,d,h,v;const a=function(f,b,k){const z=Zn(f,b),L=new ll({hdr:1,sid:0,size:0},rn,{});return L._headers=z,L._subject=k,L}(409,`${un.IdleHeartbeatMissed}: ${o}`,this.sub.subject);if((u=this.info)==null?void 0:u.ordered){if(!this.js.nc.protocol.connected)return!1;const f=((h=(d=this.info)==null?void 0:d.ordered_consumer_sequence)==null?void 0:h.stream_seq)||0;return this._resetOrderedConsumer(f+1),(v=this.monitor)==null||v.restart(),!1}return this.sub.callback(null,a),!i.noIterator},r)}_checkHbOrderConsumer(t){const n=t.headers.get(Hs.ConsumerStalledHdr);n!==""&&this.js.nc.publish(n);const r=parseInt(t.headers.get(Hs.LastConsumerSeqHdr),10),i=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,r!==i.delivery_seq&&this._resetOrderedConsumer(i.stream_seq+1),!1}_checkOrderedConsumer(t){const n=this.info.ordered_consumer_sequence,r=t.info.streamSequence,i=t.info.deliverySequence;return i!=n.delivery_seq+1?(this._resetOrderedConsumer(n.stream_seq+1),!1):(n.delivery_seq=i,n.stream_seq=r,!0)}async destroy(){this.isClosed()||await this.drain();const t=this.sub.info,n=t.config.durable_name||t.name,r=`${t.api.prefix}.CONSUMER.DELETE.${t.stream}.${n}`;await t.api._request(r)}async consumerInfo(){const t=this.sub.info,n=t.config.durable_name||t.name,r=`${t.api.prefix}.CONSUMER.INFO.${t.stream}.${n}`,i=await t.api._request(r);return t.last=i,i}}class gg extends lm{constructor(e,t,n){super(e,t,n)}pull(e={batch:1}){const{stream:t,config:n,name:r}=this.sub.info,i=n.durable_name??r,o={};if(o.batch=e.batch||1,o.no_wait=e.no_wait||!1,(e.max_bytes??0)>0){const u=this.js.nc.features.get(Nt.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);o.max_bytes=e.max_bytes}let a=0;e.expires&&e.expires>0&&(a=e.expires,o.expires=rs(a));let l=0;if(e.idle_heartbeat&&e.idle_heartbeat>0&&(l=e.idle_heartbeat,o.idle_heartbeat=rs(l)),l&&a===0)throw new Error("idle_heartbeat requires expires");if(l>a)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),a&&l&&(this.monitor?this.monitor._change(l,a):this._setupHbMonitoring(l,a));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${t}.${i}`,h=this.sub.subject;u.nc.publish(d,u.jc.encode(o),{reply:h})}}}function Qu(s){if(s!==null)switch(s.code){case Re.JetStream404NoMessages:case Re.JetStream408RequestTimeout:return null;case Re.JetStream409:return function(e){return e.code!==Re.JetStream409?!1:[un.MaxBatchExceeded,un.MaxExpiresExceeded,un.MaxBytesExceeded,un.MaxMessageSizeExceeded,un.PushConsumer,un.IdleHeartbeatMissed,un.ConsumerDeleted].find(t=>e.message.indexOf(t)!==-1)!==void 0}(s)?s:null;default:return s}return null}function vg(s){s&&s.ack()}class _g{constructor(e,t){p(this,"msg");p(this,"di");p(this,"didAck");p(this,"timeout");this.msg=e,this.didAck=!1,this.timeout=t}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=function(e){const t=e.split(".");if(t.length===9&&t.splice(2,0,"_",""),t.length<11||t[0]!=="$JS"||t[1]!=="ACK")throw new Error("not js message");const n={};return n.domain=t[2]==="_"?"":t[2],n.account_hash=t[3],n.stream=t[4],n.consumer=t[5],n.deliveryCount=parseInt(t[6],10),n.redeliveryCount=n.deliveryCount,n.redelivered=n.deliveryCount>1,n.streamSequence=parseInt(t[7],10),n.deliverySequence=parseInt(t[8],10),n.timestampNanos=parseInt(t[9],10),n.pending=parseInt(t[10],10),n}(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===Li[0]&&e[1]===Li[1]&&e[2]===Li[2]&&e[3]===Li[3]}async ackAck(e){var n;(e=e||{}).timeout=e.timeout||this.timeout;const t=is();if(this.didAck)t.resolve(!1);else if(this.didAck=!0,this.msg.reply){const r=this.msg.publisher,i=!((n=r.options)!=null&&n.noAsyncTraces),o=new sm(r.muxSubscriptions,this.msg.reply,{timeout:e.timeout},i);r.request(o);try{r.publish(this.msg.reply,Vu,{reply:`${r.muxSubscriptions.baseInbox}${o.token}`})}catch(a){o.cancel(a)}try{await Promise.race([o.timer,o.deferred]),t.resolve(!0)}catch(a){o.cancel(a),t.reject(a)}}else t.resolve(!1);return t}ack(){this.doAck(Vu)}nak(e){let t=ng;e&&(t=$u().encode(`-NAK ${JSON.stringify({delay:rs(e)})}`)),this.doAck(t)}working(){this.doAck(Li)}next(e,t={batch:1}){const n={};n.batch=t.batch||1,n.no_wait=t.no_wait||!1,t.expires&&t.expires>0&&(n.expires=rs(t.expires));const r=wn().encode(n),i=fi.concat(rg,og,r),o=e?{reply:e}:void 0;this.msg.respond(i,o)}term(e=""){let t=ig;(e==null?void 0:e.length)>0&&(t=$u().encode(`+TERM ${e}`)),this.doAck(t)}json(){return this.msg.json()}string(){return this.msg.string()}}class yg{constructor(){p(this,"version");p(this,"lang");p(this,"closeError");p(this,"connected");p(this,"done");p(this,"socket");p(this,"options");p(this,"socketClosed");p(this,"encrypted");p(this,"peeked");p(this,"yields");p(this,"signal");p(this,"closedNotification");this.version="1.30.3",this.lang="nats.ws",this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=is(),this.closedNotification=is()}async connect(e,t){const n=is();if(t.tls)return n.reject(new Ve("tls",Re.InvalidOption)),n;this.options=t;const r=e.src;if(t.wsFactory){const{socket:i,encrypted:o}=await t.wsFactory(e.src,t);this.socket=i,this.encrypted=o}else this.encrypted=r.indexOf("wss://")===0,this.socket=new WebSocket(r);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=i=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(i.data)),this.peeked)return void this.signal.resolve();const o=fi.concat(...this.yields),a=N1(o);if(a!==""){const l=H1.exec(a);if(!l)return t.debug&&console.error("!!!",Eo(o)),void n.reject(new Error("unexpected response from server"));try{(function(u,d){const{proto:h,tls_required:v,tls_available:f}=u;if((h===void 0||h<1)&&d.noEcho)throw new Ve("noEcho",Re.ServerOptionNotAvailable);const b=v||f||!1;if(d.tls&&!b)throw new Ve("tls",Re.ServerOptionNotAvailable)})(JSON.parse(l[1]),this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),n.resolve()}catch(u){return void n.reject(u)}}},this.socket.onclose=i=>{if(this.isDiscarded())return;let o;this.socketClosed=!0,this.done||(i.wasClean||(o=new Error(i.reason)),this._closed(o))},this.socket.onerror=i=>{if(this.isDiscarded())return;const o=i,a=new Ve(o.message,Re.Unknown,new Error(o.error));n.reject(a)},n}disconnect(){this._closed(void 0,!0)}async _closed(e,t=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await Pi(100);this.done=!0;try{this.socket.close(e?1002:1e3,e?e.message:void 0)}catch{}t&&this.closedNotification.resolve(e)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let t=0;t<e.length;t++)this.options.debug&&console.info(`> ${Eo(e[t])}`),yield e[t];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=is())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.isDiscarded())try{return this.socket.send(e.buffer),void(this.options.debug&&console.info(`< ${Eo(e)}`))}catch(t){this.options.debug&&console.error(`!!! ${Eo(e)}: ${t}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}isDiscarded(){return!!this.done&&(this.discard(),!0)}discard(){var e;this.done=!0;try{(e=this.socket)==null||e.close()}catch{}}}function bg(s,e){/^(.*:\/\/)(.*)/.test(s)||(s=typeof e=="boolean"?`${e===!0?"https":"http"}://${s}`:`https://${s}`);let t=new URL(s);const n=t.protocol.toLowerCase();let r,i;n==="ws:"&&(e=!1),n==="wss:"&&(e=!0),n!=="https:"&&n!=="http"&&(s=s.replace(/^(.*:\/\/)(.*)/gm,"$2"),t=new URL(`http://${s}`));const o=t.hostname,a=t.pathname,l=t.search||"";switch(n){case"http:":case"ws:":case"nats:":i=t.port||"80",r="ws:";break;case"https:":case"wss:":case"tls:":i=t.port||"443",r="wss:";break;default:i=t.port||e===!0?"443":"80",r=e===!0?"wss:":"ws:"}return`${r}//${o}:${i}${a}${l}`}function wg(s={}){return function(e){nn=e}({defaultPort:443,urlParseFn:bg,factory:()=>new yg}),fl.connect(s)}const Bn={HEALTH:{PING:"health.ping",PONG:"health.pong"},SERVER:{STATUS:"server.status",BROADCAST:"server.broadcast"},PLUGIN:{REGISTER:"plugin.register",UNREGISTER:"plugin.unregister",STATUS:"plugin.status"},SERVICE:{REGISTER:"service.register",UNREGISTER:"service.unregister",STATUS:"service.status"},METRICS:{UPDATE:"metrics.update"}},zo="running",xc="stopping",Ji="stopped",ji={REQUEST:"request",RESPONSE:"response",BROADCAST:"broadcast",RPC_REQUEST:"rpcrequest",RPC_RESPONSE:"rpcresponse",RPC_STREAM_REQUEST:"rpcstreamrequest"},Qa={CONNECTION:5e3,REQUEST:5e3,RPC:5e3},xg={METRICS:6e4},Ku={MAX_RECONNECT_ATTEMPTS:-1,DELAY:2e3},Sg={TTL:3e4},Zu={requests:{total:0,active:0,errors:0,timings:new Map,inWindow:{count:0,errors:0,responseTimes:[],startTime:Date.now()}},messages:{published:0,received:0,errors:0},rpc:{total:0,active:0,errors:0},subscriptions:{active:0,messageHandlers:0,requestHandlers:0,rpcHandlers:0}},Xn=Ti("camera:ui:metrics");class Cg{constructor(){p(this,"startTime",Date.now());p(this,"metricsWindow",Sg.TTL);p(this,"metrics",{...Zu})}trackRequestStart(e){Xn("Tracking request start",e),this.metrics.requests.active++,this.metrics.requests.total++,this.metrics.requests.timings.set(e,Date.now()),this.metrics.requests.inWindow.count++}trackRequestEnd(e,t){Xn("Tracking request end",e);const n=this.metrics.requests.timings.get(e);n&&(this.metrics.requests.inWindow.responseTimes.push(Date.now()-n),this.metrics.requests.timings.delete(e)),this.metrics.requests.active--,t&&(this.metrics.requests.errors++,this.metrics.requests.inWindow.errors++)}trackPublish(){Xn("Tracking message publish"),this.metrics.messages.published++}trackReceive(){Xn("Tracking message receive"),this.metrics.messages.received++}trackMessageError(){Xn("Tracking message error"),this.metrics.messages.errors++}trackRPCStart(){Xn("Tracking RPC start"),this.metrics.rpc.active++,this.metrics.rpc.total++}trackRPCEnd(e){Xn("Tracking RPC end"),this.metrics.rpc.active--,e&&this.metrics.rpc.errors++}trackSubscriptionChange(e,t){switch(Xn("Tracking subscription change",e,t),t){case"message":this.metrics.subscriptions.messageHandlers=Math.max(0,this.metrics.subscriptions.messageHandlers+e);break;case"request":this.metrics.subscriptions.requestHandlers=Math.max(0,this.metrics.subscriptions.requestHandlers+e);break;case"rpc":case"generator":this.metrics.subscriptions.rpcHandlers=Math.max(0,this.metrics.subscriptions.rpcHandlers+e)}this.metrics.subscriptions.active=this.metrics.subscriptions.messageHandlers+this.metrics.subscriptions.requestHandlers+this.metrics.subscriptions.rpcHandlers}getMetrics(){this.cleanOldMetrics();const e=Date.now(),t=(e-this.metrics.requests.inWindow.startTime)/1e3,n=t>0?this.metrics.requests.inWindow.count/Math.max(1,t):0,r=this.metrics.requests.inWindow.responseTimes.length>0?this.metrics.requests.inWindow.responseTimes.reduce((i,o)=>i+o,0)/this.metrics.requests.inWindow.responseTimes.length:0;return{timestamp:e,startTime:this.startTime,requests:{total:this.metrics.requests.total,active:this.metrics.requests.active,errors:this.metrics.requests.errors,perSecond:Number.isFinite(n)?n:0,avgResponseTime:r},messages:{published:this.metrics.messages.published,received:this.metrics.messages.received,errors:this.metrics.messages.errors},rpc:{total:this.metrics.rpc.total,active:this.metrics.rpc.active,errors:this.metrics.rpc.errors},subscriptions:{active:this.metrics.subscriptions.active,messageHandlers:this.metrics.subscriptions.messageHandlers,requestHandlers:this.metrics.subscriptions.requestHandlers,rpcHandlers:this.metrics.subscriptions.rpcHandlers}}}resetMetrics(){this.metrics={...Zu}}cleanOldMetrics(){const e=Date.now();e-this.metrics.requests.inWindow.startTime>=this.metricsWindow&&(this.metrics.requests.inWindow={count:0,errors:0,responseTimes:[],startTime:e})}}var Sc,Ne,dn;try{Sc=new TextDecoder}catch{}var H=0,It,cr,Ps,Un,$t,Gt={},ln=0,In=0,Gs=[],Gu={useRecords:!1,mapsAsObjects:!0};class um{}const dm=new um;dm.name="MessagePack 0xC1";var Wu,pr=!1,hm=2;try{new Function("")}catch{hm=1/0}class gi{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||(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(e,t){if(Ne)return _m(()=>(kc(),this?this.unpack(e,t):gi.prototype.unpack.call(Gu,e,t)));e.buffer||e.constructor!==ArrayBuffer||(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(dn=t.end||e.length,H=t.start||0):(H=0,dn=t>-1?t:e.length),In=0,cr=null,Ps=null,Ne=e;try{$t=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Ne=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof gi){if(Gt=this,this.structures)return It=this.structures,To(t);(!It||It.length>0)&&(It=[])}else Gt=Gu,(!It||It.length>0)&&(It=[]);return To(t)}unpackMultiple(e,t){let n,r=0;try{pr=!0;let i=e.length,o=this?this.unpack(e,i):Uo.unpack(e,i);if(!t){for(n=[o];H<i;)r=H,n.push(To());return n}if(t(o,r,H)===!1)return;for(;H<i;)if(r=H,t(To(),r,H)===!1)return}catch(i){throw i.lastPosition=r,i.values=n,i}finally{pr=!1,kc()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,r=e.length;n<r;n++){let i=e[n];i&&(i.isShared=!0,n>=32&&(i.highByte=n-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 To(s){try{if(!Gt.trusted&&!pr){let t=It.sharedLength||0;t<It.length&&(It.length=t)}let e;if(Gt.randomAccessStructure&&Ne[H]<64&&Ne[H]>=32&&Wu?(e=Wu(Ne,H,dn,Gt),Ne=null,s&&s.lazy||!e||(e=e.toJSON()),H=dn):e=ms(),Ps&&(H=Ps.postBundlePosition,Ps=null),pr&&(It.restoreStructures=null),H==dn)It&&It.restoreStructures&&Ju(),It=null,Ne=null,Un&&(Un=null);else{if(H>dn)throw new Error("Unexpected end of MessagePack data");if(!pr){let t;try{t=JSON.stringify(e,(n,r)=>typeof r=="bigint"?`${r}n`:r).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw It&&It.restoreStructures&&Ju(),kc(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||H>dn)&&(e.incomplete=!0),e}}function Ju(){for(let s in It.restoreStructures)It[s]=It.restoreStructures[s];It.restoreStructures=null}function ms(){let s=Ne[H++];if(s<160){if(s<128){if(s<64)return s;{let e=It[63&s]||Gt.getStructures&&mm()[63&s];return e?(e.read||(e.read=gl(e,63&s)),e.read()):s}}if(s<144){if(s-=128,Gt.mapsAsObjects){let e={};for(let t=0;t<s;t++){let n=fm();n==="__proto__"&&(n="__proto_"),e[n]=ms()}return e}{let e=new Map;for(let t=0;t<s;t++)e.set(ms(),ms());return e}}{s-=144;let e=new Array(s);for(let t=0;t<s;t++)e[t]=ms();return Gt.freezeData?Object.freeze(e):e}}if(s<192){let e=s-160;if(In>=H)return cr.slice(H-ln,(H+=e)-ln);if(In==0&&dn<140){let t=e<16?vl(e):pm(e);if(t!=null)return t}return Cc(e)}{let e;switch(s){case 192:return null;case 193:return Ps?(e=ms(),e>0?Ps[1].slice(Ps.position1,Ps.position1+=e):Ps[0].slice(Ps.position0,Ps.position0-=e)):dm;case 194:return!1;case 195:return!0;case 196:if(e=Ne[H++],e===void 0)throw new Error("Unexpected end of buffer");return Ka(e);case 197:return e=$t.getUint16(H),H+=2,Ka(e);case 198:return e=$t.getUint32(H),H+=4,Ka(e);case 199:return xr(Ne[H++]);case 200:return e=$t.getUint16(H),H+=2,xr(e);case 201:return e=$t.getUint32(H),H+=4,xr(e);case 202:if(e=$t.getFloat32(H),Gt.useFloat32>2){let t=_l[(127&Ne[H])<<1|Ne[H+1]>>7];return H+=4,(t*e+(e>0?.5:-.5)|0)/t}return H+=4,e;case 203:return e=$t.getFloat64(H),H+=8,e;case 204:return Ne[H++];case 205:return e=$t.getUint16(H),H+=2,e;case 206:return e=$t.getUint32(H),H+=4,e;case 207:return Gt.int64AsType==="number"?(e=4294967296*$t.getUint32(H),e+=$t.getUint32(H+4)):Gt.int64AsType==="string"?e=$t.getBigUint64(H).toString():Gt.int64AsType==="auto"?(e=$t.getBigUint64(H),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=$t.getBigUint64(H),H+=8,e;case 208:return $t.getInt8(H++);case 209:return e=$t.getInt16(H),H+=2,e;case 210:return e=$t.getInt32(H),H+=4,e;case 211:return Gt.int64AsType==="number"?(e=4294967296*$t.getInt32(H),e+=$t.getUint32(H+4)):Gt.int64AsType==="string"?e=$t.getBigInt64(H).toString():Gt.int64AsType==="auto"?(e=$t.getBigInt64(H),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=$t.getBigInt64(H),H+=8,e;case 212:if(e=Ne[H++],e==114)return nd(63&Ne[H++]);{let t=Gs[e];if(t)return t.read?(H++,t.read(ms())):t.noBuffer?(H++,t()):t(Ne.subarray(H,++H));throw new Error("Unknown extension "+e)}case 213:return e=Ne[H],e==114?(H++,nd(63&Ne[H++],Ne[H++])):xr(2);case 214:return xr(4);case 215:return xr(8);case 216:return xr(16);case 217:return e=Ne[H++],In>=H?cr.slice(H-ln,(H+=e)-ln):Eg(e);case 218:return e=$t.getUint16(H),In>=(H+=2)?cr.slice(H-ln,(H+=e)-ln):Ag(e);case 219:return e=$t.getUint32(H),In>=(H+=4)?cr.slice(H-ln,(H+=e)-ln):Mg(e);case 220:return e=$t.getUint16(H),H+=2,Xu(e);case 221:return e=$t.getUint32(H),H+=4,Xu(e);case 222:return e=$t.getUint16(H),H+=2,ed(e);case 223:return e=$t.getUint32(H),H+=4,ed(e);default:if(s>=224)return s-256;if(s===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+s)}}}const kg=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function gl(s,e){function t(){if(t.count++>hm){let r=s.read=new Function("r","return function(){return "+(Gt.freezeData?"Object.freeze":"")+"({"+s.map(i=>i==="__proto__"?"__proto_:r()":kg.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"})}")(ms);return s.highByte===0&&(s.read=Yu(e,s.read)),r()}let n={};for(let r=0,i=s.length;r<i;r++){let o=s[r];o==="__proto__"&&(o="__proto_"),n[o]=ms()}return Gt.freezeData?Object.freeze(n):n}return t.count=0,s.highByte===0?Yu(e,t):t}const Yu=(s,e)=>function(){let t=Ne[H++];if(t===0)return e();let n=s<32?-(s+(t<<5)):s+(t<<5),r=It[n]||mm()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=gl(r,s)),r.read()};function mm(){let s=_m(()=>(Ne=null,Gt.getStructures()));return It=Gt._mergeStructures(s,It)}var Cc=wo,Eg=wo,Ag=wo,Mg=wo;function wo(s){let e;if(s<16&&(e=vl(s)))return e;if(s>64&&Sc)return Sc.decode(Ne.subarray(H,H+=s));const t=H+s,n=[];for(e="";H<t;){const r=Ne[H++];if(128&r)if((224&r)==192){const i=63&Ne[H++];n.push((31&r)<<6|i)}else if((240&r)==224){const i=63&Ne[H++],o=63&Ne[H++];n.push((31&r)<<12|i<<6|o)}else if((248&r)==240){let i=(7&r)<<18|(63&Ne[H++])<<12|(63&Ne[H++])<<6|63&Ne[H++];i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i)}else n.push(r);else n.push(r);n.length>=4096&&(e+=Ss.apply(String,n),n.length=0)}return n.length>0&&(e+=Ss.apply(String,n)),e}function Xu(s){let e=new Array(s);for(let t=0;t<s;t++)e[t]=ms();return Gt.freezeData?Object.freeze(e):e}function ed(s){if(Gt.mapsAsObjects){let e={};for(let t=0;t<s;t++){let n=fm();n==="__proto__"&&(n="__proto_"),e[n]=ms()}return e}{let e=new Map;for(let t=0;t<s;t++)e.set(ms(),ms());return e}}var Ss=String.fromCharCode;function pm(s){let e=H,t=new Array(s);for(let n=0;n<s;n++){const r=Ne[H++];if((128&r)>0)return void(H=e);t[n]=r}return Ss.apply(String,t)}function vl(s){if(s<4){if(s<2){if(s===0)return"";{let e=Ne[H++];return(128&e)>1?void(H-=1):Ss(e)}}{let e=Ne[H++],t=Ne[H++];if((128&e)>0||(128&t)>0)return void(H-=2);if(s<3)return Ss(e,t);let n=Ne[H++];return(128&n)>0?void(H-=3):Ss(e,t,n)}}{let e=Ne[H++],t=Ne[H++],n=Ne[H++],r=Ne[H++];if((128&e)>0||(128&t)>0||(128&n)>0||(128&r)>0)return void(H-=4);if(s<6){if(s===4)return Ss(e,t,n,r);{let i=Ne[H++];return(128&i)>0?void(H-=5):Ss(e,t,n,r,i)}}if(s<8){let i=Ne[H++],o=Ne[H++];if((128&i)>0||(128&o)>0)return void(H-=6);if(s<7)return Ss(e,t,n,r,i,o);let a=Ne[H++];return(128&a)>0?void(H-=7):Ss(e,t,n,r,i,o,a)}{let i=Ne[H++],o=Ne[H++],a=Ne[H++],l=Ne[H++];if((128&i)>0||(128&o)>0||(128&a)>0||(128&l)>0)return void(H-=8);if(s<10){if(s===8)return Ss(e,t,n,r,i,o,a,l);{let u=Ne[H++];return(128&u)>0?void(H-=9):Ss(e,t,n,r,i,o,a,l,u)}}if(s<12){let u=Ne[H++],d=Ne[H++];if((128&u)>0||(128&d)>0)return void(H-=10);if(s<11)return Ss(e,t,n,r,i,o,a,l,u,d);let h=Ne[H++];return(128&h)>0?void(H-=11):Ss(e,t,n,r,i,o,a,l,u,d,h)}{let u=Ne[H++],d=Ne[H++],h=Ne[H++],v=Ne[H++];if((128&u)>0||(128&d)>0||(128&h)>0||(128&v)>0)return void(H-=12);if(s<14){if(s===12)return Ss(e,t,n,r,i,o,a,l,u,d,h,v);{let f=Ne[H++];return(128&f)>0?void(H-=13):Ss(e,t,n,r,i,o,a,l,u,d,h,v,f)}}{let f=Ne[H++],b=Ne[H++];if((128&f)>0||(128&b)>0)return void(H-=14);if(s<15)return Ss(e,t,n,r,i,o,a,l,u,d,h,v,f,b);let k=Ne[H++];return(128&k)>0?void(H-=15):Ss(e,t,n,r,i,o,a,l,u,d,h,v,f,b,k)}}}}}function td(){let s,e=Ne[H++];if(e<192)s=e-160;else switch(e){case 217:s=Ne[H++];break;case 218:s=$t.getUint16(H),H+=2;break;case 219:s=$t.getUint32(H),H+=4;break;default:throw new Error("Expected string")}return wo(s)}function Ka(s){return Gt.copyBuffers?Uint8Array.prototype.slice.call(Ne,H,H+=s):Ne.subarray(H,H+=s)}function xr(s){let e=Ne[H++];if(Gs[e]){let t;return Gs[e](Ne.subarray(H,t=H+=s),n=>{H=n;try{return ms()}finally{H=t}})}throw new Error("Unknown extension type "+e)}var sd=new Array(4096);function fm(){let s=Ne[H++];if(!(s>=160&&s<192))return H--,gm(ms());if(s-=160,In>=H)return cr.slice(H-ln,(H+=s)-ln);if(!(In==0&&dn<180))return Cc(s);let e,t=4095&(s<<5^(s>1?$t.getUint16(H):s>0?Ne[H]:0)),n=sd[t],r=H,i=H+s-3,o=0;if(n&&n.bytes==s){for(;r<i;){if(e=$t.getUint32(r),e!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(e=Ne[r++],e!=n[o++]){r=1879048192;break}if(r===i)return H=r,n.string;i-=3,r=H}for(n=[],sd[t]=n,n.bytes=s;r<i;)e=$t.getUint32(r),n.push(e),r+=4;for(i+=3;r<i;)e=Ne[r++],n.push(e);let a=s<16?vl(s):pm(s);return n.string=a??Cc(s)}function gm(s){if(typeof s=="string")return s;if(typeof s=="number"||typeof s=="boolean"||typeof s=="bigint")return s.toString();if(s==null)return s+"";if(Gt.allowArraysInMapKeys&&Array.isArray(s)&&s.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return s.flat().toString();throw new Error("Invalid property type for record: "+typeof s)}const nd=(s,e)=>{let t=ms().map(gm),n=s;e!==void 0&&(s=s<32?-((e<<5)+s):(e<<5)+s,t.highByte=e);let r=It[s];return r&&(r.isShared||pr)&&((It.restoreStructures||(It.restoreStructures=[]))[s]=r),It[s]=t,t.read=gl(t,n),t.read()};Gs[0]=()=>{},Gs[0].noBuffer=!0,Gs[66]=s=>{let e=s.length,t=BigInt(128&s[0]?s[0]-256:s[0]);for(let n=1;n<e;n++)t<<=BigInt(8),t+=BigInt(s[n]);return t};let $g={Error,TypeError,ReferenceError};Gs[101]=()=>{let s=ms();return($g[s[0]]||Error)(s[1],{cause:s[2]})},Gs[105]=s=>{if(Gt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=$t.getUint32(H-4);Un||(Un=new Map);let t,n=Ne[H];t=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)&&Ne[H+1]===115?new Set:{};let r={target:t};Un.set(e,r);let i=ms();if(!r.used)return r.target=i;if(Object.assign(t,i),t instanceof Map)for(let[o,a]of i.entries())t.set(o,a);if(t instanceof Set)for(let o of Array.from(i))t.add(o);return t},Gs[112]=s=>{if(Gt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=$t.getUint32(H-4),t=Un.get(e);return t.used=!0,t.target},Gs[115]=()=>new Set(ms());const vm=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(s=>s+"Array");let Tg=typeof globalThis=="object"?globalThis:window;Gs[116]=s=>{let e=s[0],t=Uint8Array.prototype.slice.call(s,1).buffer,n=vm[e];if(!n){if(e===16)return t;if(e===17)return new DataView(t);throw new Error("Could not find typed array for code "+e)}return new Tg[n](t)},Gs[120]=()=>{let s=ms();return new RegExp(s[0],s[1])};const Pg=[];function _m(s){let e=dn,t=H,n=ln,r=In,i=cr,o=Un,a=Ps,l=new Uint8Array(Ne.slice(0,dn)),u=It,d=It.slice(0,It.length),h=Gt,v=pr,f=s();return dn=e,H=t,ln=n,In=r,cr=i,Un=o,Ps=a,Ne=l,pr=v,(It=u).splice(0,It.length,...d),Gt=h,$t=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),f}function kc(){Ne=null,Un=null,It=null}Gs[98]=s=>{let e=(s[0]<<24)+(s[1]<<16)+(s[2]<<8)+s[3],t=H;return H+=e-s.length,Ps=Pg,(Ps=[td(),td()]).position0=0,Ps.position1=0,Ps.postBundlePosition=H,H=t,ms()},Gs[255]=s=>s.length==4?new Date(1e3*(16777216*s[0]+(s[1]<<16)+(s[2]<<8)+s[3])):s.length==8?new Date(((s[0]<<22)+(s[1]<<14)+(s[2]<<6)+(s[3]>>2))/1e6+1e3*(4294967296*(3&s[3])+16777216*s[4]+(s[5]<<16)+(s[6]<<8)+s[7])):s.length==12?new Date(((s[0]<<24)+(s[1]<<16)+(s[2]<<8)+s[3])/1e6+1e3*((128&s[4]?-281474976710656:0)+1099511627776*s[6]+4294967296*s[7]+16777216*s[8]+(s[9]<<16)+(s[10]<<8)+s[11])):new Date("invalid");const _l=new Array(147);for(let s=0;s<256;s++)_l[s]=+("1e"+Math.floor(45.15-.30103*s));var Uo=new gi({useRecords:!1});Uo.unpack,Uo.unpackMultiple,Uo.unpack;let Vo,Ec,ym,Rg=new Float32Array(1);new Uint8Array(Rg.buffer,0,4);try{Vo=new TextEncoder}catch{}const so=typeof Buffer<"u",Po=so?function(s){return Buffer.allocUnsafeSlow(s)}:Uint8Array,bm=so?Buffer:Uint8Array,rd=so?4294967296:2144337920;let re,qi,ts,Ds,Ig,G=0,cs=null;const Og=/[\u0080-\uFFFF]/,Jr=Symbol("record-id");class wm extends gi{constructor(e){let t,n,r,i;super(e),this.offset=0;let o=bm.prototype.utf8Write?function(w,Q){return re.utf8Write(w,Q,re.byteLength-Q)}:!(!Vo||!Vo.encodeInto)&&function(w,Q){return Vo.encodeInto(w,re.subarray(Q)).written},a=this;e||(e={});let l=e&&e.sequential,u=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=u?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let h=e.maxOwnStructures;h==null&&(h=u?32:64),this.structures||e.useRecords==0||(this.structures=[]);let v=d>32||h+d>64,f=d+64,b=d+h+64;if(b>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let k=[],z=0,L=0;this.pack=this.encode=function(w,Q){if(re||(re=new Po(8192),ts=re.dataView||(re.dataView=new DataView(re.buffer,0,8192)),G=0),Ds=re.length-10,Ds-G<2048?(re=new Po(re.length),ts=re.dataView||(re.dataView=new DataView(re.buffer,0,re.length)),Ds=re.length-10,G=0):G=G+7&2147483640,t=G,Q&qg&&(G+=255&Q),i=a.structuredClone?new Map:null,a.bundleStrings&&typeof w!="string"?(cs=[],cs.size=1/0):cs=null,r=a.structures,r){r.uninitialized&&(r=a._mergeStructures(a.getStructures()));let q=r.sharedLength||0;if(q>d)throw new 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 oe=0;oe<q;oe++){let ue=r[oe];if(!ue)continue;let Se,F=r.transitions;for(let D=0,Y=ue.length;D<Y;D++){let Pe=ue[D];Se=F[Pe],Se||(Se=F[Pe]=Object.create(null)),F=Se}F[Jr]=oe+64}this.lastNamedStructuresLength=q}l||(r.nextId=q+64)}let J;n&&(n=!1);try{a.randomAccessStructure&&w&&w.constructor&&w.constructor===Object?I(w):N(w);let q=cs;if(cs&&id(t,N,0),i&&i.idsToInsert){let oe=i.idsToInsert.sort((D,Y)=>D.offset>Y.offset?1:-1),ue=oe.length,Se=-1;for(;q&&ue>0;){let D=oe[--ue].offset+t;D<q.stringsPosition+t&&Se===-1&&(Se=0),D>q.position+t?Se>=0&&(Se+=6):(Se>=0&&(ts.setUint32(q.position+t,ts.getUint32(q.position+t)+Se),Se=-1),q=q.previous,ue++)}Se>=0&&q&&ts.setUint32(q.position+t,ts.getUint32(q.position+t)+Se),G+=6*oe.length,G>Ds&&M(G),a.offset=G;let F=function(D,Y){let Pe,He=6*Y.length,ht=D.length-He;for(;Pe=Y.pop();){let Mt=Pe.offset,Qe=Pe.id;D.copyWithin(Mt+He,Mt,ht),He-=6;let ze=Mt+He;D[ze++]=214,D[ze++]=105,D[ze++]=Qe>>24,D[ze++]=Qe>>16&255,D[ze++]=Qe>>8&255,D[ze++]=255&Qe,ht=Mt}return D}(re.subarray(t,G),oe);return i=null,F}return a.offset=G,Q&Lg?(re.start=t,re.end=G,re):re.subarray(t,G)}catch(q){throw J=q,q}finally{if(r&&(se(),n&&a.saveStructures)){let q=r.sharedLength||0,oe=re.subarray(t,G),ue=Fg(r,a);if(!J)return a.saveStructures(ue,ue.isCompatible)===!1?a.pack(w,Q):(a.lastNamedStructuresLength=q,re.length>1073741824&&(re=null),oe)}re.length>1073741824&&(re=null),Q&jg&&(G=t)}};const se=()=>{L<10&&L++;let w=r.sharedLength||0;if(r.length>w&&!l&&(r.length=w),z>1e4)r.transitions=null,L=0,z=0,k.length>0&&(k=[]);else if(k.length>0&&!l){for(let Q=0,J=k.length;Q<J;Q++)k[Q][Jr]=0;k=[]}},K=w=>{var Q=w.length;Q<16?re[G++]=144|Q:Q<65536?(re[G++]=220,re[G++]=Q>>8,re[G++]=255&Q):(re[G++]=221,ts.setUint32(G,Q),G+=4);for(let J=0;J<Q;J++)N(w[J])},N=w=>{G>Ds&&(re=M(G));var Q,J=typeof w;if(J==="string"){let q,oe=w.length;if(cs&&oe>=4&&oe<4096){if((cs.size+=oe)>21760){let F,D,Y=(cs[0]?3*cs[0].length+cs[1].length:0)+10;G+Y>Ds&&(re=M(G+Y)),cs.position?(D=cs,re[G]=200,G+=3,re[G++]=98,F=G-t,G+=4,id(t,N,0),ts.setUint16(F+t-3,G-t-F)):(re[G++]=214,re[G++]=98,F=G-t,G+=4),cs=["",""],cs.previous=D,cs.size=0,cs.position=F}let Se=Og.test(w);return cs[Se?0:1]+=w,re[G++]=193,void N(Se?-oe:oe)}q=oe<32?1:oe<256?2:oe<65536?3:5;let ue=3*oe;if(G+ue>Ds&&(re=M(G+ue)),oe<64||!o){let Se,F,D,Y=G+q;for(Se=0;Se<oe;Se++)F=w.charCodeAt(Se),F<128?re[Y++]=F:F<2048?(re[Y++]=F>>6|192,re[Y++]=63&F|128):(64512&F)==55296&&(64512&(D=w.charCodeAt(Se+1)))==56320?(F=65536+((1023&F)<<10)+(1023&D),Se++,re[Y++]=F>>18|240,re[Y++]=F>>12&63|128,re[Y++]=F>>6&63|128,re[Y++]=63&F|128):(re[Y++]=F>>12|224,re[Y++]=F>>6&63|128,re[Y++]=63&F|128);Q=Y-G-q}else Q=o(w,G+q);Q<32?re[G++]=160|Q:Q<256?(q<2&&re.copyWithin(G+2,G+1,G+1+Q),re[G++]=217,re[G++]=Q):Q<65536?(q<3&&re.copyWithin(G+3,G+2,G+2+Q),re[G++]=218,re[G++]=Q>>8,re[G++]=255&Q):(q<5&&re.copyWithin(G+5,G+3,G+3+Q),re[G++]=219,ts.setUint32(G,Q),G+=4),G+=Q}else if(J==="number")if(w>>>0===w)w<32||w<128&&this.useRecords===!1||w<64&&!this.randomAccessStructure?re[G++]=w:w<256?(re[G++]=204,re[G++]=w):w<65536?(re[G++]=205,re[G++]=w>>8,re[G++]=255&w):(re[G++]=206,ts.setUint32(G,w),G+=4);else if((w|0)===w)w>=-32?re[G++]=256+w:w>=-128?(re[G++]=208,re[G++]=w+256):w>=-32768?(re[G++]=209,ts.setInt16(G,w),G+=2):(re[G++]=210,ts.setInt32(G,w),G+=4);else{let q;if((q=this.useFloat32)>0&&w<4294967296&&w>=-2147483648){let oe;if(re[G++]=202,ts.setFloat32(G,w),q<4||((oe=w*_l[(127&re[G])<<1|re[G+1]>>7])|0)===oe)return void(G+=4);G--}re[G++]=203,ts.setFloat64(G,w),G+=8}else if(J==="object"||J==="function")if(w){if(i){let oe=i.get(w);if(oe){if(!oe.id){let ue=i.idsToInsert||(i.idsToInsert=[]);oe.id=ue.push(oe)}return re[G++]=214,re[G++]=112,ts.setUint32(G,oe.id),void(G+=4)}i.set(w,{offset:G-t})}let q=w.constructor;if(q===Object)S(w);else if(q===Array)K(w);else if(q===Map)if(this.mapAsEmptyObject)re[G++]=128;else{(Q=w.size)<16?re[G++]=128|Q:Q<65536?(re[G++]=222,re[G++]=Q>>8,re[G++]=255&Q):(re[G++]=223,ts.setUint32(G,Q),G+=4);for(let[oe,ue]of w)N(oe),N(ue)}else{for(let oe=0,ue=Ec.length;oe<ue;oe++)if(w instanceof ym[oe]){let Se=Ec[oe];if(Se.write){Se.type&&(re[G++]=212,re[G++]=Se.type,re[G++]=0);let He=Se.write.call(this,w);return void(He===w?Array.isArray(w)?K(w):S(w):N(He))}let F,D=re,Y=ts,Pe=G;re=null;try{F=Se.pack.call(this,w,He=>(re=D,D=null,G+=He,G>Ds&&M(G),{target:re,targetView:ts,position:G-He}),N)}finally{D&&(re=D,ts=Y,G=Pe,Ds=re.length-10)}return void(F&&(F.length+G>Ds&&M(F.length+G),G=Ng(F,re,G,Se.type)))}if(Array.isArray(w))K(w);else{if(w.toJSON){const oe=w.toJSON();if(oe!==w)return N(oe)}if(J==="function")return N(this.writeFunction&&this.writeFunction(w));S(w)}}}else re[G++]=192;else if(J==="boolean")re[G++]=w?195:194;else if(J==="bigint"){if(w<9223372036854776e3&&w>=-9223372036854776e3)re[G++]=211,ts.setBigInt64(G,w);else if(w<18446744073709552e3&&w>0)re[G++]=207,ts.setBigUint64(G,w);else{if(!this.largeBigIntToFloat){if(this.largeBigIntToString)return N(w.toString());if((this.useBigIntExtension||this.moreTypes)&&w<BigInt(2)**BigInt(1023)&&w>-(BigInt(2)**BigInt(1023))){re[G++]=199,G++,re[G++]=66;let q,oe=[];do{let ue=w&BigInt(255);q=(ue&BigInt(128))===(w<BigInt(0)?BigInt(128):BigInt(0)),oe.push(ue),w>>=BigInt(8)}while(w!==BigInt(0)&&w!==BigInt(-1)||!q);re[G-2]=oe.length;for(let ue=oe.length;ue>0;)re[G++]=Number(oe[--ue]);return}throw new RangeError(w+" 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")}re[G++]=203,ts.setFloat64(G,Number(w))}G+=8}else{if(J!=="undefined")throw new Error("Unknown type: "+J);this.encodeUndefinedAsNil?re[G++]=192:(re[G++]=212,re[G++]=0,re[G++]=0)}},E=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?w=>{let Q;if(this.skipValues){Q=[];for(let oe in w)typeof w.hasOwnProperty=="function"&&!w.hasOwnProperty(oe)||this.skipValues.includes(w[oe])||Q.push(oe)}else Q=Object.keys(w);let J,q=Q.length;if(q<16?re[G++]=128|q:q<65536?(re[G++]=222,re[G++]=q>>8,re[G++]=255&q):(re[G++]=223,ts.setUint32(G,q),G+=4),this.coercibleKeyAsNumber)for(let oe=0;oe<q;oe++){J=Q[oe];let ue=Number(J);N(isNaN(ue)?J:ue),N(w[J])}else for(let oe=0;oe<q;oe++)N(J=Q[oe]),N(w[J])}:w=>{re[G++]=222;let Q=G-t;G+=2;let J=0;for(let q in w)(typeof w.hasOwnProperty!="function"||w.hasOwnProperty(q))&&(N(q),N(w[q]),J++);if(J>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');re[Q+++t]=J>>8,re[Q+t]=255&J},O=this.useRecords===!1?E:e.progressiveRecords&&!v?w=>{let Q,J,q=r.transitions||(r.transitions=Object.create(null)),oe=G++-t;for(let ue in w)if(typeof w.hasOwnProperty!="function"||w.hasOwnProperty(ue)){if(Q=q[ue],Q)q=Q;else{let Se=Object.keys(w),F=q;q=r.transitions;let D=0;for(let Y=0,Pe=Se.length;Y<Pe;Y++){let He=Se[Y];Q=q[He],Q||(Q=q[He]=Object.create(null),D++),q=Q}oe+t+1==G?(G--,B(q,Se,D)):W(q,Se,oe,D),J=!0,q=F[ue]}N(w[ue])}if(!J){let ue=q[Jr];ue?re[oe+t]=ue:W(q,Object.keys(w),oe,0)}}:w=>{let Q,J=r.transitions||(r.transitions=Object.create(null)),q=0;for(let ue in w)(typeof w.hasOwnProperty!="function"||w.hasOwnProperty(ue))&&(Q=J[ue],Q||(Q=J[ue]=Object.create(null),q++),J=Q);let oe=J[Jr];oe?oe>=96&&v?(re[G++]=96+(31&(oe-=96)),re[G++]=oe>>5):re[G++]=oe:B(J,J.__keys__||Object.keys(w),q);for(let ue in w)(typeof w.hasOwnProperty!="function"||w.hasOwnProperty(ue))&&N(w[ue])},U=typeof this.useRecords=="function"&&this.useRecords,S=U?w=>{U(w)?O(w):E(w)}:O,M=w=>{let Q;if(w>16777216){if(w-t>rd)throw new Error("Packed buffer would be larger than maximum buffer size");Q=Math.min(rd,4096*Math.round(Math.max((w-t)*(w>67108864?1.25:2),4194304)/4096))}else Q=1+(Math.max(w-t<<2,re.length-1)>>12)<<12;let J=new Po(Q);return ts=J.dataView||(J.dataView=new DataView(J.buffer,0,Q)),w=Math.min(w,re.length),re.copy?re.copy(J,0,t,w):J.set(re.slice(t,w)),G-=t,t=0,Ds=J.length-10,re=J},B=(w,Q,J)=>{let q=r.nextId;q||(q=64),q<f&&this.shouldShareStructure&&!this.shouldShareStructure(Q)?(q=r.nextOwnId,q<b||(q=f),r.nextOwnId=q+1):(q>=b&&(q=f),r.nextId=q+1);let oe=Q.highByte=q>=96&&v?q-96>>5:-1;w[Jr]=q,w.__keys__=Q,r[q-64]=Q,q<f?(Q.isShared=!0,r.sharedLength=q-63,n=!0,oe>=0?(re[G++]=96+(31&q),re[G++]=oe):re[G++]=q):(oe>=0?(re[G++]=213,re[G++]=114,re[G++]=96+(31&q),re[G++]=oe):(re[G++]=212,re[G++]=114,re[G++]=q),J&&(z+=L*J),k.length>=h&&(k.shift()[Jr]=0),k.push(w),N(Q))},W=(w,Q,J,q)=>{let oe=re,ue=G,Se=Ds,F=t;re=qi,G=0,t=0,re||(qi=re=new Po(8192)),Ds=re.length-10,B(w,Q,q),qi=re;let D=G;if(re=oe,G=ue,Ds=Se,t=F,D>1){let Y=G+D-1;Y>Ds&&M(Y);let Pe=J+t;re.copyWithin(Pe+D,Pe+1,G),re.set(qi.slice(0,D),Pe),G=Y}else re[J+t]=qi[0]},I=w=>{let Q=Ig(w,re,t,G,r,M,(J,q,oe)=>{if(oe)return n=!0;G=q;let ue=re;return N(J),se(),ue!==re?{position:G,targetView:ts,target:re}:G},this);if(Q===0)return S(w);G=Q}}useBuffer(e){re=e,re.dataView||(re.dataView=new DataView(re.buffer,re.byteOffset,re.byteLength)),G=0}set position(e){G=e}get position(){return G}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}function Za(s,e,t,n){let r=s.byteLength;if(r+1<256){var{target:i,position:o}=t(4+r);i[o++]=199,i[o++]=r+1}else if(r+1<65536){var{target:i,position:o}=t(5+r);i[o++]=200,i[o++]=r+1>>8,i[o++]=r+1&255}else{var{target:i,position:o,targetView:a}=t(7+r);i[o++]=201,a.setUint32(o,r+1),o+=4}i[o++]=116,i[o++]=e,s.buffer||(s=new Uint8Array(s)),i.set(new Uint8Array(s.buffer,s.byteOffset,s.byteLength),o)}function Ga(s,e){let t=s.byteLength;var n,r;if(t<256){var{target:n,position:r}=e(t+2);n[r++]=196,n[r++]=t}else if(t<65536){var{target:n,position:r}=e(t+3);n[r++]=197,n[r++]=t>>8,n[r++]=255&t}else{var{target:n,position:r,targetView:i}=e(t+5);n[r++]=198,i.setUint32(r,t),r+=4}n.set(s,r)}function Ng(s,e,t,n){let r=s.length;switch(r){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:r<256?(e[t++]=199,e[t++]=r):r<65536?(e[t++]=200,e[t++]=r>>8,e[t++]=255&r):(e[t++]=201,e[t++]=r>>24,e[t++]=r>>16&255,e[t++]=r>>8&255,e[t++]=255&r)}return e[t++]=n,e.set(s,t),t+=r}function id(s,e,t){if(cs.length>0){ts.setUint32(cs.position+s,G+t-cs.position-s),cs.stringsPosition=G-s;let n=cs;cs=null,e(n[0]),e(n[1])}}function Fg(s,e){return s.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},s}ym=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,um],Ec=[{pack(s,e,t){let n=s.getTime()/1e3;if((this.useTimestamp32||s.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:i,position:o}=e(6);r[o++]=214,r[o++]=255,i.setUint32(o,n)}else if(n>0&&n<4294967296){let{target:r,targetView:i,position:o}=e(10);r[o++]=215,r[o++]=255,i.setUint32(o,4e6*s.getMilliseconds()+(n/1e3/4294967296|0)),i.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:r,targetView:i,position:o}=e(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:i,position:o}=e(15);r[o++]=199,r[o++]=12,r[o++]=255,i.setUint32(o,1e6*s.getMilliseconds()),i.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(s,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(s),{target:r,position:i}=e(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=115,r[i++]=0),t(n)}},{pack(s,e,t){let{target:n,position:r}=e(this.moreTypes?3:0);this.moreTypes&&(n[r++]=212,n[r++]=101,n[r++]=0),t([s.name,s.message,s.cause])}},{pack(s,e,t){let{target:n,position:r}=e(this.moreTypes?3:0);this.moreTypes&&(n[r++]=212,n[r++]=120,n[r++]=0),t([s.source,s.flags])}},{pack(s,e){this.moreTypes?Za(s,16,e):Ga(so?Buffer.from(s):new Uint8Array(s),e)}},{pack(s,e){let t=s.constructor;t!==bm&&this.moreTypes?Za(s,vm.indexOf(t.name),e):Ga(s,e)}},{pack(s,e){this.moreTypes?Za(s,17,e):Ga(so?Buffer.from(s):new Uint8Array(s),e)}},{pack(s,e){let{target:t,position:n}=e(1);t[n]=193}}];let od=new wm({useRecords:!1});od.pack,od.pack;const Lg=512,jg=1024,qg=2048,Dg=new wm({useRecords:!1,encodeUndefinedAsNil:!0,int64AsType:"number"}),Bg=new gi({useRecords:!1,int64AsType:"number"});class zg{constructor(e,t,n){p(this,"subject");p(this,"handlerId");p(this,"unsubscribeFn");this.subject=e,this.handlerId=t,this.unsubscribeFn=n}unsubscribe(){try{this.unsubscribeFn(this.subject,this.handlerId)}catch{}}}let Ar=256;const xm=[];let Ro;for(;Ar--;)xm[Ar]=(Ar+256).toString(16).substring(1);function yn(s){let e=0;const t=11;if(!Ro||Ar+t>512)for(Ro="",Ar=0;e<256;e++)Ro+=xm[256*Math.random()|0];return Ro.substring(Ar,Ar+++t)}const Ut=Ti("camera:ui:connection");class Yi{constructor(e,t){p(this,"type");p(this,"options");p(this,"connection",null);p(this,"connectionPromise");p(this,"subscriptionGroups",new Map);p(this,"metricsTracker");p(this,"isDisconnected",!1);this.type=e,this.options=t,_o.validateConnectionOptions(t),this.metricsTracker=new Cg}async connect(){this.isConnected()||(this.connectionPromise?await this.connectionPromise:(Ut(`[${this.options.metadata.id}] Establishing connection...`),this.connectionPromise=this.establishConnection(),await this.connectionPromise,Ut(`[${this.options.metadata.id}] Connection established successfully.`)))}async disconnect(){this.isDisconnected=!0,Ut(`[${this.options.metadata.id}] Disconnecting...`),await this.drainConnection(),this.connection=null,Ut(`[${this.options.metadata.id}] Disconnected.`)}isConnected(){return this.connection!==null&&!this.connection.isClosed()&&!this.connection.isDraining()}isClosed(){return this.connection===null||this.connection.isClosed()||this.connection.isDraining()}getConnection(){if(!this.isConnected())throw kt.connection.invalidState(void 0,{description:"Connection is not established",code:ks.INVALID_STATE});return this.connection}publish(e,t,n,r){if(this.isClosed())throw Ut(`[${this.options.metadata.id}] Publish skipped: Connection closed or draining`),kt.connection.notConnected(void 0,{description:"Failed to publish message: Connection closed or draining",code:ks.NOT_CONNECTED,subject:e});const i={id:yn(),type:ji.BROADCAST,data:t,metadata:this.options.metadata,timestamp:Date.now(),routing:r,error:n};try{this.getConnection().publish(e,this.packMessage(i)),this.metricsTracker.trackPublish(),Ut("Published message to",e,i.id)}catch(o){throw this.metricsTracker.trackMessageError(),kt.message.deliveryFailed(o,{description:"Failed to publish message",code:zn.DELIVERY_FAILED,subject:e})}}async request(e,t,n,r){if(this.isClosed())throw Ut(`[${this.options.metadata.id}] Request skipped: Connection closed or draining. Subject: ${e}`),kt.connection.notConnected(void 0,{description:"Failed to send request: Connection closed or draining",code:ks.NOT_CONNECTED,subject:e});const i=yn(),o={id:i,type:ji.REQUEST,subject:e,data:t,metadata:this.options.metadata,timestamp:Date.now(),routing:r};this.metricsTracker.trackRequestStart(i);try{const a=await this.getConnection().request(e,this.packMessage(o),{timeout:n??this.getTimeoutOptions().request}),l=this.unpackMessage(a);if(this.metricsTracker.trackRequestEnd(i,!!l.error),l.error)throw ws.fromJSON(l.error);return l}catch(a){throw this.metricsTracker.trackRequestEnd(i,!0),a instanceof ws?a:kt.connection.requestFailed(a,{description:"Failed to send request or process response",code:"CONNECTION_REQUEST_FAILED",subject:e})}}async requestRPC(e,t,n){if(this.isClosed())throw Ut(`[${this.options.metadata.id}] RPC Request skipped: Connection closed or draining. Subject: ${e}`),kt.connection.notConnected(void 0,{description:"Failed to send RPC request: Connection closed or draining",code:ks.NOT_CONNECTED,subject:e});const r={id:yn(),type:ji.RPC_REQUEST,subject:e,data:t,metadata:this.options.metadata,timestamp:Date.now()};this.metricsTracker.trackRPCStart();try{const i=await this.getConnection().request(e,this.packMessage(r),{timeout:n??this.getTimeoutOptions().rpc}),o=this.unpackMessage(i);if(this.metricsTracker.trackRPCEnd(!!o.error),o.error)throw ws.fromJSON(o.error);return o}catch(i){throw this.metricsTracker.trackRPCEnd(!0),i instanceof ws?i:kt.rpc.requestFailed(i,{description:"Failed to send RPC request or process response",code:"RPC_REQUEST_FAILED",subject:e})}}handleRequest(e,t){return this.subscribe(e,t,void 0,"request")}subscribe(e,t,n=yn(),r="message"){if(this.isClosed())throw Ut(`[${this.options.metadata.id}] Subscribe skipped: Connection closed or draining. Subject: ${e}`),kt.connection.notConnected(void 0,{description:"Failed to subscribe: Connection closed or draining",code:ks.NOT_CONNECTED,subject:e});let i=this.subscriptionGroups.get(e);if(i){if(i.type!==r)throw new Error(`Cannot mix on subject ${e}`);if((r==="request"||r==="rpc"||r==="generator")&&i.handlers.size>0)throw new Error(`Request/RPC/Generator handler already registered for subject ${e}`)}else{let o;try{o=this.getConnection().subscribe(e)}catch(a){throw kt.connection.subscribeFailed(a,{description:`Failed to create NATS subscription for subject ${e}`,code:"CONNECTION_SUBSCRIBE_FAILED",subject:e,metadata:{type:r}})}i={subscription:o,handlers:new Map,type:r,refCount:0},this.subscriptionGroups.set(e,i),this.handleSubscription(o,e,i),Ut(`[${this.options.metadata.id}] Created subscription group for %s`,e)}return i.handlers.has(n)&&Ut(`[${this.options.metadata.id}] Handler %s already registered for subject %s`,n,e),i.handlers.set(n,t),i.refCount++,this.metricsTracker.trackSubscriptionChange(1,r),Ut(`[${this.options.metadata.id}] Subscribed to %s (handler: %s, type: %s, refCount: %d)`,e,n,r,i.refCount),new zg(e,n,this.unsubscribe.bind(this))}unsubscribe(e,t){const n=this.subscriptionGroups.get(e);if(n&&n.handlers.delete(t)&&(n.refCount--,this.metricsTracker.trackSubscriptionChange(-1,n.type),n.refCount<=0))try{n.subscription.unsubscribe(),this.subscriptionGroups.delete(e)}catch{this.subscriptionGroups.delete(e)}}getMetrics(){return this.metricsTracker.getMetrics()}async establishConnection(){try{this.isDisconnected=!1;const e=this.getTimeoutOptions(),{waitForServer:t}=this.getConnectOptions(),{maxAttempts:n,delay:r,enabled:i}=this.getReconnectOptions();let o=0;for(;!this.isDisconnected;){o++;try{Ut(`[${this.options.metadata.id}] Connection attempt ${o}...`);const a=await wg({...this.getNatsAuthOptions(),name:this.options.metadata.id,servers:this.options.endpoints,tls:this.options.tls,timeout:e.connection,maxReconnectAttempts:i?n:0,reconnect:i,reconnectTimeWait:r,noEcho:!0,noAsyncTraces:!0,waitOnFirstConnect:!0});return Ut(`[${this.options.metadata.id}] NATS connect() successful.`),(async()=>{for await(const l of a.status())l.type===Tn.Reconnect&&Ut(`[${this.options.metadata.id}] Connection reconnected.`)})().catch(l=>{Ut(`[${this.options.metadata.id}] Error in status monitoring:`,l)}),a.closed().then(l=>{Ut(`[${this.options.metadata.id}] Connection closed:`,l),this.subscriptionGroups.clear(),this.metricsTracker.resetMetrics(),this.isDisconnected=!0,this.connection=null}),void(this.connection=a)}catch(a){if(this.isDisconnected)return;if(!t)throw Ut(`[${this.options.metadata.id}] Connection attempt ${o} failed:`,a),kt.connection.connectionFailed(a,{description:"Failed to connect to NATS server",code:ks.FAILED,metadata:{attempts:o}});Ut(`[${this.options.metadata.id}] Connection attempt ${o} failed:`,a),await new Promise(l=>setTimeout(l,r))}}}finally{this.connectionPromise=void 0}}async drainConnection(){if(this.connection&&!this.connection.isClosed())try{await this.connection.drain()}catch(e){Ut("Error draining connection:",e)}}async handleSubscription(e,t,n){Ut(`[${this.options.metadata.id}] Starting message loop for subscription ${t}`);for await(const r of e){if(!this.subscriptionGroups.has(t)){Ut(`[${this.options.metadata.id}] Message loop for ${t} exiting: Group removed.`);break}let i;try{i=this.unpackMessage(r);const o={subject:r.subject,timestamp:Date.now(),id:i.id};switch(this.metricsTracker.trackReceive(),n.type){case"request":this.handleRequestMessage(r,i,n);break;case"rpc":this.handleRPCMessage(r,i,n);break;case"generator":this.handleGeneratorInitiationMessage(r,i,n);break;default:this.handleNormalMessage(i,o,n)}}catch(o){this.metricsTracker.trackMessageError(),Ut(`[${this.options.metadata.id}] Error processing message for ${t}:`,o)}}Ut(`[${this.options.metadata.id}] Message loop for subscription ${t} terminated.`),this.subscriptionGroups.has(t)&&this.subscriptionGroups.delete(t)}async handleRequestMessage(e,t,n){const r=n.handlers.values().next().value;if(r)try{const i=await r(t);this.respondTo(e,i,t.id)}catch(i){this.metricsTracker.trackMessageError();const o=kt.message.executionFailed(i,{description:"Handler execution failed"});this.respondTo(e,null,t.id,o.toJSON())}}async handleRPCMessage(e,t,n){const r=n.handlers.values().next().value;if(r)try{const i=Array.isArray(t.data)?t.data:t.data!==void 0?[t.data]:[],o=await r(...i);this.respondToRPC(e,o,t.id)}catch(i){this.metricsTracker.trackMessageError();const o=kt.rpc.executionFailed(i,{description:"RPC handler execution failed"});this.respondToRPC(e,null,t.id,void 0,!0,o.toJSON())}}async handleGeneratorInitiationMessage(e,t,n){const r=n.handlers.values().next().value;if(r)try{await r(t)}catch(i){this.metricsTracker.trackMessageError(),Ut("Error processing generator request:",i)}}async handleNormalMessage(e,t,n){const r=Array.from(n.handlers.values());if(r.length===0)return;const i=[];for(const o of r)try{const a=o(e);a instanceof Promise&&i.push(a.catch(this.metricsTracker.trackMessageError.bind(this)))}catch(a){this.metricsTracker.trackMessageError(),Ut("Error in sync handler:",a)}await Promise.allSettled(i)}respondTo(e,t,n,r){try{if(this.isClosed())throw Ut(`[${this.options.metadata.id}] Respond skipped: Connection closed or draining. Subject: ${e.subject}`),kt.connection.notConnected(void 0,{description:"Failed to respond: Connection closed or draining",code:ks.NOT_CONNECTED,subject:e.subject});const i={id:yn(),type:ji.RESPONSE,requestId:n,data:t,metadata:this.options.metadata,error:r,timestamp:Date.now()};e.respond(this.packMessage(i))}catch(i){this.metricsTracker.trackMessageError(),Ut("Error sending request response:",i)}}respondToRPC(e,t,n,r,i,o){try{if(this.isClosed())throw Ut(`[${this.options.metadata.id}] RPC Respond skipped: Connection closed or draining. Subject: ${e.subject}`),kt.connection.notConnected(void 0,{description:"Failed to respond: Connection closed or draining",code:ks.NOT_CONNECTED,subject:e.subject});const a={id:yn(),type:ji.RPC_RESPONSE,requestId:n,data:t,metadata:this.options.metadata,streamId:r,done:i,error:o,timestamp:Date.now()};e.respond(this.packMessage(a))}catch(a){this.metricsTracker.trackMessageError(),Ut("Error sending RPC response:",a)}}packMessage(e){try{return t=e,Dg.pack(t)}catch(n){throw this.metricsTracker.trackMessageError(),kt.message.invalidFormat(n,{description:"Failed to pack message",code:zn.INVALID_FORMAT,metadata:{raw:e}})}var t}unpackMessage(e){try{return t=e.data,Bg.unpack(t)}catch{throw kt.message.invalidFormat(void 0,{description:"Failed to parse message",code:zn.INVALID_FORMAT,subject:e.subject,metadata:{raw:e.data}})}var t}getNatsAuthOptions(){return"server"in this.options.auth?{user:this.options.auth.server.user,pass:this.options.auth.server.password}:{user:this.options.auth.user,pass:this.options.auth.password}}getConnectOptions(){return{waitForServer:!1,...this.options.connect}}getReconnectOptions(){return{enabled:!1,maxAttempts:Ku.MAX_RECONNECT_ATTEMPTS,delay:Ku.DELAY,...this.options.reconnect}}getTimeoutOptions(){return{rpc:Qa.RPC,request:Qa.REQUEST,connection:Qa.CONNECTION,...this.options.timeout}}}class Ug{constructor(){}publish(e,t,n){this.getConnectionManager().publish(e,t,void 0,n)}async request(e,t,n,r){return this.getConnectionManager().request(e,t,n,r)}handleRequest(e,t){return this.getConnectionManager().handleRequest(e,t)}subscribe(e,t){return this.getConnectionManager().subscribe(e,t)}unsubscribe(e,t){return this.getConnectionManager().unsubscribe(e,t)}}tn(779);function Wa(s={name:void 0,public:!0}){return function(e,t){const n=typeof t=="object"?t.name:t,r=s.name??n.toString();if(typeof t=="object"){const i=e;return Reflect.defineMetadata("rpc:config",{name:r,public:s.public??!0},i,n),i}{const i=e[n];Reflect.defineMetadata("rpc:config",{name:r,public:s.public??!0},e,n),Object.defineProperty(e,n,{value:function(...o){return i.apply(this,o)},enumerable:!0,configurable:!0})}}}class Er{static extractMethods(e){const t={},n=(o,a)=>{if(!((u,d)=>typeof d=="function"&&!u.startsWith("_")&&!u.startsWith("#")&&u!=="constructor"&&!Object.prototype.hasOwnProperty.call(Object.prototype,u))(o,a))return;const l=Reflect.getMetadata("rpc:config",Object.getPrototypeOf(e),o)??Reflect.getMetadata("rpc:config",a,o);l!=null&&l.public&&(t[l.name]={name:l.name,public:!0,type:Er.getMethodType(a),method:a})};let r=e;const i=new Set;for(;r&&r!==Object.prototype;)Object.getOwnPropertyNames(r).forEach(o=>{if(!i.has(o)){i.add(o);const a=e[o];n(o,a)}}),r=Object.getPrototypeOf(r);return t._discover={name:"_discover",public:!0,type:"async",method:async()=>Object.entries(Er.extractMethods(e)).reduce((o,[a,l])=>(o[a]={name:a,type:l.type},o),{})},t}static isAsyncFunction(e){return!!e&&(e.constructor?e.constructor.name==="AsyncFunction":e.toString().includes("async ")&&!e.toString().includes("async*"))}static isGeneratorFunction(e){return!!e&&(e.constructor?e.constructor.name==="GeneratorFunction":e.toString().includes("function*"))}static isAsyncGeneratorFunction(e){return!!e&&(e.constructor?e.constructor.name==="AsyncGeneratorFunction":e.toString().includes("async*"))}static getMethodType(e){return Er.isAsyncGeneratorFunction(e)||Er.isGeneratorFunction(e)?"asyncGenerator":(Er.isAsyncFunction(e),"async")}}const Ft=Ti("camera:ui:rpc:generator");class Vg{constructor(e,t,n){p(this,"namespace");p(this,"mainConnection");p(this,"options");p(this,"MAX_QUEUE_SIZE",100);p(this,"pendingReadySignals",new Map);p(this,"consumerGeneratorStates",new Map);p(this,"producerGeneratorStates",new Map);p(this,"handlerSubscriptions",new Map);this.namespace=e,this.mainConnection=t,this.options=n}async*createGenerator(e,...t){var u;const n=yn(),r=`${this.namespace}.${e}.generator`,i=`${r}.stream.${n}`,o=`${r}.control.${n}`;Ft(`[C:${n}] Starting generator stream for ${e}`);let a=null,l=null;try{Ft(`[C:${n}] Creating dedicated consumer connection...`),a=new Yi(this.mainConnection.type,{...this.options,metadata:{...this.options.metadata,id:`${this.options.metadata.id}-cg-${n.substring(0,8)}`},bundledConnection:!1,timeout:this.options.timeout}),await a.connect(),Ft(`[C:${n}] Dedicated consumer connection established.`);const d=a.subscribe(i,h=>this.handleStreamMessage(n,h),yn(),"generator");for(Ft(`[C:${n}] Subscribed to data stream: ${i}`),l={messageQueue:[],resolveNext:null,error:void 0,isDone:!1,streamSubscription:d,controlSubject:o,lastProcessedTime:Date.now(),isProcessing:!1,dedicatedConnection:a},this.consumerGeneratorStates.set(n,l),Ft(`[C:${n}] Sending initiation request via main connection to ${r}`),this.mainConnection.publish(r,{streamId:n,args:t});!l.isDone;){if(l.error)throw l.error;if(l.messageQueue.length>0){const v=l.messageQueue.shift();l.isProcessing=!0;try{yield v.value}finally{l.isProcessing=!1,l.lastProcessedTime=Date.now(),this.sendReadySignal(n,l.controlSubject,l.dedicatedConnection)}continue}l.isProcessing=!1;const h=await new Promise(v=>{const f=this.consumerGeneratorStates.get(n);f?f.resolveNext=v:v({done:!0,value:void 0})});if(h.done||(u=this.consumerGeneratorStates.get(n))!=null&&u.isDone)break;l=this.consumerGeneratorStates.get(n),l.isProcessing=!0;try{yield h.value.value}finally{l.isProcessing=!1,l.lastProcessedTime=Date.now(),this.sendReadySignal(n,l.controlSubject,l.dedicatedConnection)}}Ft(`[C:${n}] Consumption loop finished.`)}finally{Ft(`[C:${n}] Cleaning up consumer side...`);const d=this.consumerGeneratorStates.get(n);if(d)await this.cleanupConsumerGenerator(n,d);else if(a&&!a.isClosed()){const h=`${this.namespace}.${e}.generator.control.${n}`;await this.cleanupConsumerConnection(n,a,h)}this.consumerGeneratorStates.delete(n),Ft(`[C:${n}] Consumer cleanup finished.`)}}async handleGenerator(e,t){var i;const n=`${this.namespace}.${e}.generator`;Ft(`[P] Setting up generator handler for: ${n}`),(i=this.handlerSubscriptions.get(n))==null||i.unsubscribe();const r=this.mainConnection.subscribe(n,async o=>{var a;try{await this.handleGeneratorRequest(e,t,o)}catch(l){Ft(`[P:${((a=o.data)==null?void 0:a.streamId)||"unknown"}] Critical error setting up generator handler for ${e}:`,l)}},yn(),"generator");this.handlerSubscriptions.set(n,r)}async handleGeneratorRequest(e,t,n){var h;const r=(h=n.data)==null?void 0:h.streamId;if(!r)return void Ft(`[P:unknown] Received generator request for ${e} without streamId. Discarding.`);const i=`${this.namespace}.${e}.generator`,o=`${i}.stream.${r}`,a=`${i}.control.${r}`;Ft(`[P:${r}] Received generator request for ${e}`);let l=null,u=null,d=null;try{Ft(`[P:${r}] Creating dedicated producer connection...`),l=new Yi(this.mainConnection.type,{...this.options,metadata:{...this.options.metadata,id:`${this.options.metadata.id}-pg-${r.substring(0,8)}`},bundledConnection:!1,timeout:this.options.timeout}),await l.connect(),Ft(`[P:${r}] Dedicated producer connection established.`),this.pendingReadySignals.has(r)||this.pendingReadySignals.set(r,new Set);const v=l.subscribe(a,b=>this.handleControlMessage(r,b),yn(),"generator");Ft(`[P:${r}] Subscribed to control subject: ${a}`),d=t(...n.data.args?Array.isArray(n.data.args)?n.data.args:[n.data.args]:[]),u={streamSubject:o,controlSubject:a,requestId:n.id,streamId:r,generator:d,isWaitingForClient:!1,lastSentTime:Date.now(),dedicatedConnection:l,controlSubscription:v},this.producerGeneratorStates.set(r,u),Ft(`[P:${r}] Generator handler invoked. Processing frames...`);let f=await d.next();for(;;){if(this.producerGeneratorStates.get(r)!==u){Ft(`[P:${r}] Producer state removed. Aborting loop.`);break}if(f.done){l.publish(o,{requestId:n.id,streamId:r,done:!0}),Ft(`[P:${r}] Generator completed normally.`);break}l.publish(o,{requestId:n.id,streamId:r,value:f.value,done:!1}),u.lastSentTime=Date.now(),u.isWaitingForClient=!0;const b=new Promise(L=>{var se;return(se=this.pendingReadySignals.get(r))==null?void 0:se.add(L)});let k;const z=new Promise(L=>{k=setTimeout(()=>{Ft(`[P:${r}] Ready signal timeout.`),L()},1e4)});if(await Promise.race([b.finally(()=>clearTimeout(k)),z]),clearTimeout(k),this.producerGeneratorStates.get(r)!==u){Ft(`[P:${r}] Producer state changed during wait. Aborting loop.`);break}f=await d.next()}}catch(v){if(Ft(`[P:${r}] Error during generator execution:`,v),l&&this.producerGeneratorStates.has(r)){const f=kt.rpc.internalError(v,{description:"Error processing generator request"});try{l.publish(o,{requestId:n.id,streamId:r,done:!0,error:f.toJSON()})}catch(b){Ft(`[P:${r}] Error sending error message:`,b)}}}finally{Ft(`[P:${r}] Cleaning up producer side...`);const v=this.producerGeneratorStates.get(r);v?await this.cleanupProducerGenerator(r,v):l&&!l.isClosed()&&await this.cleanupProducerConnection(l,null),this.producerGeneratorStates.delete(r),this.pendingReadySignals.delete(r),Ft(`[P:${r}] Producer side cleanup finished.`)}}async dispose(){Ft("Disposing RPCGeneratorManager..."),await Promise.allSettled([...Array.from(this.consumerGeneratorStates.entries()).map(([e,t])=>this.cleanupConsumerGenerator(e,t)),...Array.from(this.producerGeneratorStates.entries()).map(([e,t])=>this.cleanupProducerGenerator(e,t))]),this.consumerGeneratorStates.clear(),this.producerGeneratorStates.clear(),this.pendingReadySignals.clear(),this.handlerSubscriptions.forEach(e=>e.unsubscribe()),this.handlerSubscriptions.clear(),Ft("RPCGeneratorManager disposed.")}handleStreamMessage(e,t){const n=this.consumerGeneratorStates.get(e);if(n)return t.error?(n.error=ws.fromJSON(t.error),n.isDone=!0,void(n.resolveNext&&(n.resolveNext({done:!0,value:void 0}),n.resolveNext=null))):t.data.done?(n.isDone=!0,void(n.resolveNext&&(n.resolveNext({done:!0,value:t.data}),n.resolveNext=null))):void(n.resolveNext?(n.resolveNext({done:!1,value:t.data}),n.resolveNext=null):(n.messageQueue.length>=this.MAX_QUEUE_SIZE&&n.messageQueue.shift(),n.messageQueue.push(t.data)))}handleControlMessage(e,t){const n=this.producerGeneratorStates.get(e);if(n){if(t.data.type==="return"||t.data.type==="throw")this.cleanupProducerGenerator(e,n).catch(()=>{});else if(t.data.type==="ready"){n.isWaitingForClient=!1;const r=this.pendingReadySignals.get(e);r&&(r.forEach(i=>i()),r.clear())}}}sendReadySignal(e,t,n){n.isClosed()||n.publish(t,{type:"ready"})}async cleanupConsumerGenerator(e,t){this.consumerGeneratorStates.has(e)&&(this.consumerGeneratorStates.delete(e),Ft(`[C:${e}] Cleaning up consumer generator...`),t.streamSubscription.unsubscribe(),await this.cleanupConsumerConnection(e,t.dedicatedConnection,t.controlSubject))}async cleanupConsumerConnection(e,t,n){if(Ft(`[C:${e}] Cleaning up consumer connection...`),n&&!t.isClosed())try{t.publish(n,{type:"return"})}catch{}t.isClosed()||await t.disconnect().catch(r=>Ft(`[C:${e}] Error disconnecting consumer connection:`,r))}async cleanupProducerGenerator(e,t){this.producerGeneratorStates.has(e)&&(this.producerGeneratorStates.delete(e),this.pendingReadySignals.delete(e),Ft(`[P:${e}] Cleaning up producer generator...`),await t.generator.return(void 0).catch(()=>{}),await this.cleanupProducerConnection(t.dedicatedConnection,t.controlSubscription))}async cleanupProducerConnection(e,t){var r,i;const n=((i=(r=e==null?void 0:e.options)==null?void 0:r.metadata)==null?void 0:i.id)||"unknown-producer";Ft(`[P:${n}] Cleaning up producer connection...`),t==null||t.unsubscribe(),e&&!e.isClosed()&&await e.disconnect().catch(o=>Ft(`[P:${n}] Error disconnecting producer connection:`,o))}}const Bs=Ti("camera:ui:rpc");class ad{constructor(e,t,n,r){p(this,"namespace");p(this,"connection");p(this,"options");p(this,"rpcOptions");p(this,"generatorManager");p(this,"handlers",new Map);p(this,"remoteMethodTypes",new Map);this.namespace=e,this.connection=t,this.options=n,this.rpcOptions=r,this.generatorManager=new Vg(this.namespace,this.connection,this.options)}async connect(){if(this.options.bundledConnection)Bs(`[${this.namespace}] Main connection is bundled, skipping connect.`);else try{await this.connection.connect(),Bs(`[${this.namespace}] Main connection established.`)}catch(e){throw Bs(`[${this.namespace}] Failed to establish main connection:`,e),e}}async disconnect(){if(Bs(`[${this.namespace}] Disconnecting RPCConnection...`),await this.dispose(),this.options.bundledConnection)Bs(`[${this.namespace}] Skipping disconnect of bundled main connection.`);else{if(!this.connection.isClosed())try{await this.connection.disconnect(),Bs(`[${this.namespace}] Main connection disconnected.`)}catch(e){Bs(`[${this.namespace}] Error disconnecting main connection:`,e)}Bs(`[${this.namespace}] RPCConnection disconnected.`)}}isConnected(){return this.connection.isConnected()}registerHandler(e){const t=Er.extractMethods(e);Object.entries(t).forEach(([n,r])=>{const i=r.name||n;if(this.handlers.has(i))return void Bs(`[${this.namespace}] Handler for method '${i}' already registered.`);const o={handler:e,subscriptions:[]};if(this.handlers.set(i,o),Bs(`[${this.namespace}] Registering handler for method: ${i} (${r.type})`),r.type==="asyncGenerator")this.generatorManager.handleGenerator(i,r.method.bind(e));else{const a=`${this.namespace}.${i}`,l=yn();try{this.connection.subscribe(a,r.method.bind(e),l,"rpc"),o.subscriptions.push({subject:a,handlerId:l})}catch(u){Bs(`[${this.namespace}] Failed to register handler for method: "${i}":`,u),this.handlers.delete(i)}}})}async call(e,...t){var r;const n=`${this.namespace}.${e}`;return this.connection.requestRPC(n,t,(r=this.rpcOptions)==null?void 0:r.timeout).then(i=>i.data)}callGenerator(e,...t){return this.generatorManager.createGenerator(e,...t)}createProxy(){const e=new Set(["toString","toJSON","valueOf","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","then","catch","finally"]);return new Proxy({},{get:(t,n)=>{if(typeof n!="symbol"&&!e.has(n))return(...r)=>{var o,a;return((o=r[0])==null?void 0:o.isGenerator)?(Bs("Creating generator proxy for:",n),this.callGenerator(n,...r.slice(1))):(Bs("Creating async proxy for:",n),this.connection.requestRPC(`${this.namespace}.${n}`,r,(a=this.rpcOptions)==null?void 0:a.timeout).then(l=>l.data))}}})}getConnectionManager(){return this.connection}async dispose(){Bs(`[${this.namespace}] Disposing RPCConnection resources...`),this.generatorManager&&await this.generatorManager.dispose();const e=[];this.handlers.forEach(t=>{t.subscriptions.forEach(({subject:n,handlerId:r})=>{e.push(new Promise(i=>{try{this.connection.unsubscribe(n,r)}finally{i()}}))})}),await Promise.allSettled(e),this.handlers.clear(),this.remoteMethodTypes.clear(),Bs(`[${this.namespace}] Finished disposing RPCConnection resources.`)}}class Hg extends Ug{constructor(t,n){super();p(this,"type");p(this,"options");p(this,"rpcManagers",new Map);p(this,"remoteRpcManagers",new Map);p(this,"connection");this.type=t,this.options=n,_o.validateConnectionOptions(n),this.connection=new Yi(this.type,n)}sendToPlugin(t,n){const r=ns.createRoutingMetadata(this.type,this.options.metadata.id,"plugin",t);this.publish(this.getPluginSubject(t),n,r)}sendToService(t,n){const r=ns.createRoutingMetadata(this.type,this.options.metadata.id,"service",t);this.publish(this.getServiceSubject(t),n,r)}async requestFromPlugin(t,n,r){const i=ns.createRoutingMetadata(this.type,this.options.metadata.id,"plugin",t);return this.request(this.getPluginSubject(t),n,r,i)}async requestFromService(t,n,r){const i=ns.createRoutingMetadata(this.type,this.options.metadata.id,"service",t);return this.request(this.getServiceSubject(t),n,r,i)}onPluginMessage(t="*",n){const r=this.type==="plugin"?ns.getPluginToPluginSubject(t,this.options.metadata.id):this.type==="service"?ns.getPluginToServiceSubject(t,this.options.metadata.id):ns.getPluginToServerSubject(t,this.options.metadata.id);return this.handleRequest(r,async i=>await n(i.data))}onServiceMessage(t="*",n){const r=this.type==="plugin"?ns.getServiceToPluginSubject(t,this.options.metadata.id):this.type==="service"?ns.getServiceToServiceSubject(t,this.options.metadata.id):ns.getServiceToServerSubject(t,this.options.metadata.id);return this.handleRequest(r,async i=>await n(i.data))}async registerRPCHandler(t,n,r){let i=this.rpcManagers.get(t);if(i)return;const o=this.options.bundledConnection??!0?this.connection:new Yi(this.type,this.options);i=new ad(t,o,this.options,r),await i.connect(),i.registerHandler(n),this.rpcManagers.set(t,i)}async unregisterRPCHandler(t){const n=this.rpcManagers.get(t);await(n==null?void 0:n.disconnect()),this.rpcManagers.delete(t)}async createRPCProxy(t,n){return(await this.createRPCConnection(t,n)).createProxy()}async createRPCConnection(t,n){try{let r=this.remoteRpcManagers.get(t);if(!r){const i=this.options.bundledConnection??!0?this.connection:new Yi(this.type,this.options);r=new ad(t,i,this.options,n),await r.connect(),this.remoteRpcManagers.set(t,r)}return r}catch(r){throw kt.rpc.connectionFailed(r,{description:"Failed to connect to remote RPC",code:rr.CONNECTION_FAILED,metadata:{namespace:t,rpcOptions:n}})}}async disconnectRPCConnection(t){const n=this.remoteRpcManagers.get(t);await(n==null?void 0:n.disconnect()),this.remoteRpcManagers.delete(t)}async cleanup(){await this.cleanupRPCConnections(),await this.cleanupRemoteRPCConnections()}async cleanupRPCConnections(t){if(t){const n=this.rpcManagers.get(t);await(n==null?void 0:n.disconnect()),this.rpcManagers.delete(t)}else await Promise.allSettled([...this.rpcManagers.values()].map(n=>n.disconnect())),this.rpcManagers.clear()}async cleanupRemoteRPCConnections(t){if(t){const n=this.remoteRpcManagers.get(t);await(n==null?void 0:n.disconnect()),this.remoteRpcManagers.delete(t)}else await Promise.allSettled([...this.remoteRpcManagers.values()].map(n=>n.disconnect())),this.remoteRpcManagers.clear()}getPluginSubject(t){return this.type==="plugin"?ns.getPluginToPluginSubject(this.options.metadata.id,t):this.type==="service"?ns.getServiceToPluginSubject(this.options.metadata.id,t):ns.getServerToPluginSubject(this.options.metadata.id,t)}getServiceSubject(t){return this.type==="plugin"?ns.getPluginToServiceSubject(this.options.metadata.id,t):this.type==="service"?ns.getServiceToServiceSubject(this.options.metadata.id,t):ns.getServerToServiceSubject(this.options.metadata.id,t)}}const Io=Ti("camera:ui:client");class Qg extends Hg{constructor(t,n,r=!1){super(t,n);p(this,"type");p(this,"options");p(this,"isProxy");p(this,"serverStatus",Ji);p(this,"registered",!1);p(this,"serverMetadata");this.type=t,this.options=n,this.isProxy=r}async connect(){await this.initialize(),this.setupSubscriptions(),Io("Connected successfully")}async disconnect(){await super.cleanup(),await this.connection.disconnect(),this.registered=!1,Io("Disconnected from NATS")}sendToServer(t){if(!this.serverMetadata)throw kt.client.invalidState(void 0,{description:"Server metadata is not available",code:$n.INVALID_STATE});const n=this.type==="plugin"?ns.getPluginToServerSubject(this.options.metadata.id,this.serverMetadata.id):ns.getServiceToServerSubject(this.options.metadata.id,this.serverMetadata.id),r=ns.createRoutingMetadata(this.type,this.options.metadata.id,"server",this.serverMetadata.id);this.publish(n,t,r)}async requestFromServer(t,n){if(!this.serverMetadata)throw kt.client.invalidState(void 0,{description:"Server metadata is not available",code:$n.INVALID_STATE});const r=this.type==="plugin"?ns.getPluginToServerSubject(this.options.metadata.id,this.serverMetadata.id):ns.getServiceToServerSubject(this.options.metadata.id,this.serverMetadata.id),i=ns.createRoutingMetadata(this.type,this.options.metadata.id,"server",this.serverMetadata.id);return this.request(r,t,n,i)}onServerMessage(t){if(!this.serverMetadata)throw kt.client.invalidState(void 0,{description:"Server metadata is not available",code:$n.INVALID_STATE});const n=this.type==="plugin"?ns.getServerToPluginSubject(this.serverMetadata.id,this.options.metadata.id):ns.getServerToServiceSubject(this.serverMetadata.id,this.options.metadata.id);return this.handleRequest(n,async r=>await t(r.data))}isServerRunning(){return this.serverStatus==="running"}isConnected(){return this.connection.isConnected()}isRegistered(){return this.registered}async createRPCProxy(t,n){return super.createRPCProxy(t,n)}createRPCConnection(t,n){return super.createRPCConnection(t,n)}disconnectRPCConnection(t){return super.disconnectRPCConnection(t)}getConnectionManager(){return this.connection}getRPCConnectionManagers(){const t=Array.from(this.rpcManagers.values()).map(n=>n.getConnectionManager());return[this.connection,...t]}async initialize(){await this.connection.connect(),await this.register()}setupSubscriptions(){this.isProxy||this.handleRequest(`${Bn.HEALTH.PING}.${this.options.metadata.id}`,async()=>({clientId:this.options.metadata.id})),this.subscribe(Bn.SERVER.STATUS,async t=>{Io("Server status update:",t),this.serverStatus=t.data,this.serverStatus===xc||this.serverStatus===Ji?this.registered=!1:this.serverStatus!==zo||this.isRegistered()||(this.isProxy?(this.registered=!0,this.serverStatus="running"):await this.register())})}async register(){if(this.isRegistered()||this.isProxy)return;const t=this.type.toUpperCase(),n=Bn[t].REGISTER;try{const r=await this.request(n,this.options.metadata);if(r.error)throw ws.fromJSON(r.error);if(!r.data.success)throw kt.client.registrationFailed(void 0,{description:"Failed to register client",subject:n,code:$n.REGISTRATION_FAILED,metadata:{response:r,isProxy:this.isProxy,registered:this.registered,type:this.type,metadata:this.options.metadata}});this.serverMetadata=r.data.serverMetadata,this.registered=!0,this.serverStatus="running",Io("Registration successful")}catch(r){throw this.registered=!1,kt.client.registrationFailed(r,{description:"Failed to register client",code:$n.REGISTRATION_FAILED,subject:n,metadata:{isProxy:this.isProxy,registered:this.registered,type:this.type,metadata:this.options.metadata}})}}}Ti("camera:ui:connection:state");const er=tn(413)("camera:ui:client:instance");class Kg extends Qg{constructor(t,n){super(t,n);p(this,"type");p(this,"options");p(this,"status",Ji);p(this,"error");p(this,"metricsInterval");this.type=t,this.options=n,_o.validateConnectionOptions(n)}async start(){try{if(this.status===zo)return;await this.connect(),this.setupSubscriptions(),this.options.metrics&&this.startMetricsInterval(),this.updateStatus(zo),this.onStart(),er(`Client ${this.options.metadata.id} started successfully`)}catch(t){throw kt.connection.connectionFailed(t,{description:"Failed to start client",code:ks.FAILED,metadata:{type:this.type,metadata:this.options.metadata}})}}async stop(){var t;try{if(this.status===Ji||this.status===xc)return;this.stopMetricsInterval(),this.updateStatus(xc),await((t=this.onBeforeStop)==null?void 0:t.call(this)),this.updateStatus(Ji),await this.disconnect();try{await async function(n,r,i,o){let a;const l=new Promise((u,d)=>{a=setTimeout(()=>{i==null||i(),d(new Error(o??`Operation timed out after ${r}ms`))},r)});try{const u=typeof n=="function"?n:()=>n;return await Promise.race([u(),l])}finally{clearTimeout(a)}}(this.onStop(),3e3,void 0,"Failed to stop client")}catch{}er(`Client ${this.options.metadata.name} stopped successfully`)}catch(n){throw kt.connection.connectionFailed(n,{description:"Failed to stop client",code:ks.FAILED,metadata:{type:this.type,metadata:this.options.metadata}})}}getStatus(){return{id:this.options.metadata.id,type:this.type,state:this.status,error:this.error,metadata:this.options.metadata}}isRunning(){return this.status===zo}setupSubscriptions(){this.subscribe(`${Bn.HEALTH.PING}.${this.type}.${this.options.metadata.id}`,async()=>{const t=this.type==="plugin"?Bn.PLUGIN.STATUS:Bn.SERVICE.STATUS;this.publish(`${t}.${this.options.metadata.id}`,this.getStatus().state)})}updateStatus(t,n){if(this.status!==t){this.status=t,this.error=n,er(`Client ${this.options.metadata.name} state changed to ${t}`);try{if(this.isConnected()){const r=this.type==="plugin"?Bn.PLUGIN.STATUS:Bn.SERVICE.STATUS;this.publish(`${r}.${this.options.metadata.id}`,this.getStatus().state)}else er("Skipping status update: Not connected to server")}catch(r){er("Failed to update state:",r)}}}startMetricsInterval(){this.stopMetricsInterval(),this.metricsInterval=setInterval(()=>{try{const t=this.aggregateMetrics(),n=`${Bn.METRICS.UPDATE}.${this.type}.${this.options.metadata.id}`;this.publish(n,t),er(`Published metrics for ${this.options.metadata.id}:`,t)}catch(t){er(`Failed to publish metrics for ${this.options.metadata.id}:`,t)}},xg.METRICS)}stopMetricsInterval(){this.metricsInterval&&(clearInterval(this.metricsInterval),this.metricsInterval=void 0)}aggregateMetrics(){const t=this.getRPCConnectionManagers();er(`Aggregating metrics from connection managers: ${t.length}`);const n={timestamp:Date.now(),startTime:Math.min(...t.map(o=>o.getMetrics().startTime)),requests:{total:0,active:0,errors:0,perSecond:0,avgResponseTime:0},messages:{published:0,received:0,errors:0},rpc:{total:0,active:0,errors:0},subscriptions:{active:0,messageHandlers:0,requestHandlers:0,rpcHandlers:0}};let r=0,i=0;for(const o of t){const a=o.getMetrics();n.requests.total+=a.requests.total,n.requests.active+=a.requests.active,n.requests.errors+=a.requests.errors;const l=a.requests.total;l>0&&(r+=l,i+=a.requests.avgResponseTime*l,n.requests.perSecond+=a.requests.perSecond),n.messages.published+=a.messages.published,n.messages.received+=a.messages.received,n.messages.errors+=a.messages.errors,n.rpc.total+=a.rpc.total,n.rpc.active+=a.rpc.active,n.rpc.errors+=a.rpc.errors,n.subscriptions.active+=a.subscriptions.active,n.subscriptions.messageHandlers+=a.subscriptions.messageHandlers,n.subscriptions.requestHandlers+=a.subscriptions.requestHandlers,n.subscriptions.rpcHandlers+=a.subscriptions.rpcHandlers}return r>0&&(n.requests.avgResponseTime=i/r),n.requests.perSecond=n.requests.perSecond/t.length,n}}class Zg extends Kg{constructor(e){super("service",e)}async onStart(){console.log("Proxy started")}async onStop(){console.log("Proxy stopped")}}class Gg{constructor(){p(this,"subscriptions",[]);p(this,"additionalSubscriptions",[])}addSubscriptions(...e){this.subscriptions.push(...e)}addAdditionalSubscriptions(...e){this.additionalSubscriptions.push(...e)}unsubscribe(){this.subscriptions.forEach(e=>e.unsubscribe())}unsubscribeAdditional(){this.additionalSubscriptions.forEach(e=>e.unsubscribe())}}function ui(s,e,t=!1){if(s===e)return!0;if((s===void 0||e===void 0||s===null||e===null)&&(s||e))return!1;const n=s==null?void 0:s.constructor.name,r=e==null?void 0:e.constructor.name;if(n!==r)return!1;if(n==="Array"&&r==="Array"){if(s.length!==e.length)return!1;if(t){const i=[...e];return s.every(o=>{const a=i.findIndex(l=>ui(o,l,t));return a!==-1&&(i.splice(a,1),!0)})}{let i=!0;for(let o=0;o<s.length;o++)if(!ui(s[o],e[o],t)){i=!1;break}return i}}if(n==="Object"&&r==="Object"){let i=!0;const o=Object.keys(s),a=Object.keys(e);if(o.length!==a.length)return!1;for(let l=0;l<o.length;l++)if(s[o[l]]&&e[o[l]]){if(s[o[l]]===e[o[l]])continue;if(!s[o[l]]||s[o[l]].constructor.name!=="Array"&&s[o[l]].constructor.name!=="Object"){if(s[o[l]]!==e[o[l]]){i=!1;break}}else if(i=ui(s[o[l]],e[o[l]],t),!i)break}else if(s[o[l]]&&!e[o[l]]||!s[o[l]]&&e[o[l]]){i=!1;break}return i}return s===e}function Ks(s){return JSON.parse(JSON.stringify(s))}var Wt,cd,ld;(function(s){s.MotionSensor="MotionSensor",s.MotionDetector="MotionDetector",s.AudioSensor="AudioSensor",s.ObjectSensor="ObjectSensor",s.ObjectDetector="ObjectDetector",s.Light="Light",s.Siren="Siren",s.Doorbell="Doorbell",s.Battery="Battery",s.PTZ="PTZ",s.PTZZoom="PTZZoom",s.PTZHome="PTZHome",s.PTZPresets="PTZPresets",s.Snapshot="Snapshot",s.StreamUrl="StreamUrl",s.Reboot="Reboot"})(Wt||(Wt={})),function(s){s.Opened="Opened",s.Closed="Closed",s.Jammed="Jammed",s.Unknown="Unknown"}(cd||(cd={})),function(s){s.MotionDetector="MotionDetector",s.ObjectDetector="ObjectDetector",s.AudioDetector="AudioDetector"}(ld||(ld={}));var Wg=tn(672),Jg=tn.n(Wg),Ac=function(s,e){return Ac=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},Ac(s,e)};function Br(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=s}Ac(s,e),s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Yg(s,e,t,n){return new(t||(t=Promise))(function(r,i){function o(u){try{l(n.next(u))}catch(d){i(d)}}function a(u){try{l(n.throw(u))}catch(d){i(d)}}function l(u){var d;u.done?r(u.value):(d=u.value,d instanceof t?d:new t(function(h){h(d)})).then(o,a)}l((n=n.apply(s,[])).next())})}function Sm(s,e){var t,n,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(u){return function(d){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,d[0]&&(i=0)),i;)try{if(t=1,n&&(r=2&d[0]?n.return:d[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,d[1])).done)return r;switch(n=0,r&&(d=[2&d[0],r.value]),d[0]){case 0:case 1:r=d;break;case 4:return i.label++,{value:d[1],done:!1};case 5:i.label++,n=d[1],d=[0];continue;case 7:d=i.ops.pop(),i.trys.pop();continue;default:if(r=i.trys,!((r=r.length>0&&r[r.length-1])||d[0]!==6&&d[0]!==2)){i=0;continue}if(d[0]===3&&(!r||d[1]>r[0]&&d[1]<r[3])){i.label=d[1];break}if(d[0]===6&&i.label<r[1]){i.label=r[1],r=d;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(d);break}r[2]&&i.ops.pop(),i.trys.pop();continue}d=e.call(s,i)}catch(h){d=[6,h],n=0}finally{t=r=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}([l,u])}}}function no(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],n=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&n>=s.length&&(s=void 0),{value:s&&s[n++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function da(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n,r,i=t.call(s),o=[];try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(a){r={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return o}function ha(s,e,t){if(arguments.length===2)for(var n,r=0,i=e.length;r<i;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return s.concat(n||Array.prototype.slice.call(e))}function di(s){return this instanceof di?(this.v=s,this):new di(s)}function Xg(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,r=t.apply(s,e||[]),i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(h){return function(v){return Promise.resolve(v).then(h,u)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(h,v){r[h]&&(n[h]=function(f){return new Promise(function(b,k){i.push([h,f,b,k])>1||a(h,f)})},v&&(n[h]=v(n[h])))}function a(h,v){try{(function(f){f.value instanceof di?Promise.resolve(f.value.v).then(l,u):d(i[0][2],f)})(r[h](v))}catch(f){d(i[0][3],f)}}function l(h){a("next",h)}function u(h){a("throw",h)}function d(h,v){h(v),i.shift(),i.length&&a(i[0][0],i[0][1])}}function ev(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,t=s[Symbol.asyncIterator];return t?t.call(s):(s=no(s),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=s[r]&&function(i){return new Promise(function(o,a){(function(l,u,d,h){Promise.resolve(h).then(function(v){l({value:v,done:d})},u)})(o,a,(i=s[r](i)).done,i.value)})}}}function Is(s){return typeof s=="function"}function Cm(s){var e=s(function(t){Error.call(t),t.stack=new Error().stack});return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Ja=Cm(function(s){return function(e){s(this),this.message=e?e.length+` errors occurred during unsubscription:
30
- `+e.map(function(t,n){return n+1+") "+t.toString()}).join(`
31
- `):"",this.name="UnsubscriptionError",this.errors=e}});function Mc(s,e){if(s){var t=s.indexOf(e);0<=t&&s.splice(t,1)}}var Pa=function(){function s(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var e;return s.prototype.unsubscribe=function(){var t,n,r,i,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var l=no(a),u=l.next();!u.done;u=l.next())u.value.remove(this)}catch(k){t={error:k}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}else a.remove(this);var d=this.initialTeardown;if(Is(d))try{d()}catch(k){o=k instanceof Ja?k.errors:[k]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var v=no(h),f=v.next();!f.done;f=v.next()){var b=f.value;try{ud(b)}catch(k){o=o??[],k instanceof Ja?o=ha(ha([],da(o)),da(k.errors)):o.push(k)}}}catch(k){r={error:k}}finally{try{f&&!f.done&&(i=v.return)&&i.call(v)}finally{if(r)throw r.error}}}if(o)throw new Ja(o)}},s.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ud(t);else{if(t instanceof s){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},s.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},s.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},s.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&Mc(n,t)},s.prototype.remove=function(t){var n=this._finalizers;n&&Mc(n,t),t instanceof s&&t._removeParent(this)},s.EMPTY=((e=new s).closed=!0,e),s}(),km=Pa.EMPTY;function Em(s){return s instanceof Pa||s&&"closed"in s&&Is(s.remove)&&Is(s.add)&&Is(s.unsubscribe)}function ud(s){Is(s)?s():s.unsubscribe()}var tv={Promise:void 0},sv={setTimeout:function(s,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,ha([s,e],da(t)))},clearTimeout:function(s){return clearTimeout(s)},delegate:void 0};function Am(s){sv.setTimeout(function(){throw s})}function dd(){}function Ho(s){s()}var yl=function(s){function e(t){var n=s.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Em(t)&&t.add(n)):n.destination=rv,n}return Br(e,s),e.create=function(t,n,r){return new ro(t,n,r)},e.prototype.next=function(t){this.isStopped?void 0:this._next(t)},e.prototype.error=function(t){this.isStopped?void 0:(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?void 0:(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,s.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Pa),nv=function(){function s(e){this.partialObserver=e}return s.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){Oo(n)}},s.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Oo(n)}else Oo(e)},s.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Oo(t)}},s}(),ro=function(s){function e(t,n,r){var i,o=s.call(this)||this;return Is(t)||!t?i={next:t??void 0,error:n??void 0,complete:r??void 0}:i=t,o.destination=new nv(i),o}return Br(e,s),e}(yl);function Oo(s){Am(s)}var rv={closed:!0,next:dd,error:function(s){throw s},complete:dd},$c=typeof Symbol=="function"&&Symbol.observable||"@@observable";function Mm(s){return s}function iv(s){return s.length===0?Mm:s.length===1?s[0]:function(e){return s.reduce(function(t,n){return n(t)},e)}}var or=function(){function s(e){e&&(this._subscribe=e)}return s.prototype.lift=function(e){var t=new s;return t.source=this,t.operator=e,t},s.prototype.subscribe=function(e,t,n){var r,i=this,o=(r=e)&&r instanceof yl||function(a){return a&&Is(a.next)&&Is(a.error)&&Is(a.complete)}(r)&&Em(r)?e:new ro(e,t,n);return Ho(function(){var a=i,l=a.operator,u=a.source;o.add(l?l.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},s.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},s.prototype.forEach=function(e,t){var n=this;return new(t=hd(t))(function(r,i){var o=new ro({next:function(a){try{e(a)}catch(l){i(l),o.unsubscribe()}},error:i,complete:r});n.subscribe(o)})},s.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},s.prototype[$c]=function(){return this},s.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return iv(e)(this)},s.prototype.toPromise=function(e){var t=this;return new(e=hd(e))(function(n,r){var i;t.subscribe(function(o){return i=o},function(o){return r(o)},function(){return n(i)})})},s.create=function(e){return new s(e)},s}();function hd(s){var e;return(e=s??tv.Promise)!==null&&e!==void 0?e:Promise}var ov=Cm(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ra=function(s){function e(){var t=s.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return Br(e,s),e.prototype.lift=function(t){var n=new md(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new ov},e.prototype.next=function(t){var n=this;Ho(function(){var r,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=no(n.currentObservers),a=o.next();!a.done;a=o.next())a.value.next(t)}catch(l){r={error:l}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}})},e.prototype.error=function(t){var n=this;Ho(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var r=n.observers;r.length;)r.shift().error(t)}})},e.prototype.complete=function(){var t=this;Ho(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),s.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,r=this,i=r.hasError,o=r.isStopped,a=r.observers;return i||o?km:(this.currentObservers=null,a.push(t),new Pa(function(){n.currentObservers=null,Mc(a,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,r=n.hasError,i=n.thrownError,o=n.isStopped;r?t.error(i):o&&t.complete()},e.prototype.asObservable=function(){var t=new or;return t.source=this,t},e.create=function(t,n){return new md(t,n)},e}(or),md=function(s){function e(t,n){var r=s.call(this)||this;return r.destination=t,r.source=n,r}return Br(e,s),e.prototype.next=function(t){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.next)===null||r===void 0||r.call(n,t)},e.prototype.error=function(t){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.error)===null||r===void 0||r.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,r;return(r=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&r!==void 0?r:km},e}(Ra),gn=function(s){function e(t){var n=s.call(this)||this;return n._value=t,n}return Br(e,s),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=s.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,r=t.thrownError,i=t._value;if(n)throw r;return this._throwIfClosed(),i},e.prototype.next=function(t){s.prototype.next.call(this,this._value=t)},e}(Ra),$m={now:function(){return($m.delegate||Date).now()},delegate:void 0},No=function(s){function e(t,n,r){t===void 0&&(t=1/0),n===void 0&&(n=1/0),r===void 0&&(r=$m);var i=s.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return Br(e,s),e.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,o=n._infiniteTimeWindow,a=n._timestampProvider,l=n._windowTime;r||(i.push(t),!o&&i.push(a.now()+l)),this._trimBuffer(),s.prototype.next.call(this,t)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),r=this._infiniteTimeWindow,i=this._buffer.slice(),o=0;o<i.length&&!t.closed;o+=r?1:2)t.next(i[o]);return this._checkFinalizedStatuses(t),n},e.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,r=t._timestampProvider,i=t._buffer,o=t._infiniteTimeWindow,a=(o?1:2)*n;if(n<1/0&&a<i.length&&i.splice(0,i.length-a),!o){for(var l=r.now(),u=0,d=1;d<i.length&&i[d]<=l;d+=2)u=d;u&&i.splice(0,u+1)}},e}(Ra);function Ri(s){return function(e){if(function(t){return Is(t==null?void 0:t.lift)}(e))return e.lift(function(t){try{return s(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function vi(s,e,t,n,r){return new av(s,e,t,n,r)}var av=function(s){function e(t,n,r,i,o,a){var l=s.call(this,t)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=n?function(u){try{n(u)}catch(d){t.error(d)}}:s.prototype._next,l._error=i?function(u){try{i(u)}catch(d){t.error(d)}finally{this.unsubscribe()}}:s.prototype._error,l._complete=r?function(){try{r()}catch(u){t.error(u)}finally{this.unsubscribe()}}:s.prototype._complete,l}return Br(e,s),e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;s.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(yl);function Ya(){return Ri(function(s,e){var t,n=!1;s.subscribe(vi(e,function(r){var i=t;t=r,n&&e.next([i,r]),n=!0}))})}function Xa(s,e){return Ri(function(t,n){var r=0;t.subscribe(vi(n,function(i){return s.call(e,i,r++)&&n.next(i)}))})}function Tc(s,e){return Ri(function(t,n){var r=0;t.subscribe(vi(n,function(i){n.next(s.call(e,i,r++))}))})}var cv=typeof Symbol=="function"&&Symbol.iterator?Symbol.iterator:"@@iterator";function ma(s){if(s instanceof or)return s;if(s!=null){if(function(o){return Is(o[$c])}(s))return i=s,new or(function(o){var a=i[$c]();if(Is(a.subscribe))return a.subscribe(o);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(function(o){return o&&typeof o.length=="number"&&typeof o!="function"}(s))return r=s,new or(function(o){for(var a=0;a<r.length&&!o.closed;a++)o.next(r[a]);o.complete()});if(Is((n=s)==null?void 0:n.then))return t=s,new or(function(o){t.then(function(a){o.closed||(o.next(a),o.complete())},function(a){return o.error(a)}).then(null,Am)});if(function(o){return Symbol.asyncIterator&&Is(o==null?void 0:o[Symbol.asyncIterator])}(s))return pd(s);if(function(o){return Is(o==null?void 0:o[cv])}(s))return e=s,new or(function(o){var a,l;try{for(var u=no(e),d=u.next();!d.done;d=u.next()){var h=d.value;if(o.next(h),o.closed)return}}catch(v){a={error:v}}finally{try{d&&!d.done&&(l=u.return)&&l.call(u)}finally{if(a)throw a.error}}o.complete()});if(function(o){return Is(o==null?void 0:o.getReader)}(s))return pd(function(o){return Xg(this,arguments,function(){var a,l,u;return Sm(this,function(d){switch(d.label){case 0:a=o.getReader(),d.label=1;case 1:d.trys.push([1,,9,10]),d.label=2;case 2:return[4,di(a.read())];case 3:return l=d.sent(),u=l.value,l.done?[4,di(void 0)]:[3,5];case 4:return[2,d.sent()];case 5:return[4,di(u)];case 6:return[4,d.sent()];case 7:return d.sent(),[3,2];case 8:return[3,10];case 9:return a.releaseLock(),[7];case 10:return[2]}})})}(s))}var e,t,n,r,i;throw function(o){return new TypeError("You provided "+(o!==null&&typeof o=="object"?"an invalid object":"'"+o+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(s)}function pd(s){return new or(function(e){(function(t,n){var r,i,o,a;return Yg(this,void 0,void 0,function(){var l,u;return Sm(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),r=ev(t),d.label=1;case 1:return[4,r.next()];case 2:if((i=d.sent()).done)return[3,4];if(l=i.value,n.next(l),n.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=d.sent(),o={error:u},[3,11];case 6:return d.trys.push([6,,9,10]),i&&!i.done&&(a=r.return)?[4,a.call(r)]:[3,8];case 7:d.sent(),d.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(s,e).catch(function(t){return e.error(t)})})}function Fo(s){s===void 0&&(s={});var e=s.connector,t=e===void 0?function(){return new Ra}:e,n=s.resetOnError,r=n===void 0||n,i=s.resetOnComplete,o=i===void 0||i,a=s.resetOnRefCountZero,l=a===void 0||a;return function(u){var d,h,v,f=0,b=!1,k=!1,z=function(){h==null||h.unsubscribe(),h=void 0},L=function(){z(),d=v=void 0,b=k=!1},se=function(){var K=d;L(),K==null||K.unsubscribe()};return Ri(function(K,N){f++,k||b||z();var E=v=v??t();N.add(function(){--f!==0||k||b||(h=ec(se,l))}),E.subscribe(N),!d&&f>0&&(d=new ro({next:function(O){return E.next(O)},error:function(O){k=!0,z(),h=ec(L,r,O),E.error(O)},complete:function(){b=!0,z(),h=ec(L,o),E.complete()}}),ma(K).subscribe(d))})(u)}}function ec(s,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];if(e!==!0){if(e!==!1){var r=new ro({next:function(){r.unsubscribe(),s()}});return ma(e.apply(void 0,ha([],da(t)))).subscribe(r)}}else s()}function Tm(s,e,t){return t===void 0&&(t=1/0),Is(e)?Tm(function(n,r){return Tc(function(i,o){return e(n,i,r,o)})(ma(s(n,r)))},t):(typeof e=="number"&&(t=e),Ri(function(n,r){return function(i,o,a,l,u,d,h,v){var f=[],b=0,k=0,z=!1,L=function(){!z||f.length||b||o.complete()},se=function(N){return b<l?K(N):f.push(N)},K=function(N){d&&o.next(N),b++;var E=!1;ma(a(N,k++)).subscribe(vi(o,function(O){u==null||u(O),d?se(O):o.next(O)},function(){E=!0},void 0,function(){if(E)try{b--;for(var O=function(){var U=f.shift();h?function(S,M,B,W,I){W===void 0&&(W=0),I===void 0&&(I=!1);var w=M.schedule(function(){B(),I?S.add(this.schedule(null,W)):this.unsubscribe()},W);S.add(w)}(o,h,function(){return K(U)}):K(U)};f.length&&b<l;)O();L()}catch(U){o.error(U)}}))};return i.subscribe(vi(o,se,function(){z=!0,L()})),function(){v==null||v()}}(n,r,s,t)}))}function lv(s,e){return s===e}const uv=s=>s==="person"?"person":s==="motion"?"motion":new Set(["bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","teddy bear"]).has(s)?"animal":new Set(["bicycle","car","motorcycle","airplane","bus","train","truck","boat"]).has(s)?"vehicle":"other";function fd(s){return s.map(e=>({...e,label:uv(e.label)}))}class dv{constructor(e=100){p(this,"cells",new Map);p(this,"cellSize");this.cellSize=e}getCellsForBox(e,t=0){const n=Math.floor((e[0]-t)/this.cellSize),r=Math.floor((e[1]-t)/this.cellSize),i=Math.floor((e[2]+t)/this.cellSize),o=Math.floor((e[3]+t)/this.cellSize),a=[];for(let l=n;l<=i;l++)for(let u=r;u<=o;u++)a.push(`${l},${u}`);return a}insert(e){const t=e.boundingBox,n=this.getCellsForBox(t);for(const r of n)this.cells.has(r)||this.cells.set(r,[]),this.cells.get(r).push(e)}search(e,t=0){const n=this.getCellsForBox(e,t),r=new Set;for(const i of n){const o=this.cells.get(i)??[];for(const a of o)r.add(a)}return Array.from(r)}}function hv(s,e){const t=Math.max(s[0],e[0]),n=Math.max(s[1],e[1]),r=Math.min(s[2],e[2]),i=Math.min(s[3],e[3]);if(r<t||i<n)return 0;const o=(r-t)*(i-n);return o/((s[2]-s[0])*(s[3]-s[1])+(e[2]-e[0])*(e[3]-e[1])-o)}function gd(s){return s[0]<s[2]&&s[1]<s[3]}function vd(s,e=.01,t=100){if(s.length===0)return[];const n=new dv(t),r=new Set,i=[],o=s.map(l=>({...l,id:l.id??Math.random().toString(36).slice(2,9)}));for(const l of o)n.insert(l);for(const l of o){if(r.has(l.id))continue;const u={...l};let d=u.confidence;const h=[u.boundingBox],v=Math.max(t,10),f=n.search(u.boundingBox,v);for(const b of f){if(b.id===u.id||r.has(b.id)||b.label!==u.label)continue;const k=hv(u.boundingBox,b.boundingBox),z=Math.abs(u.boundingBox[0]-b.boundingBox[0])<=t&&Math.abs(u.boundingBox[1]-b.boundingBox[1])<=t;(k>e||z)&&(h.push(b.boundingBox),r.add(b.id),d=Math.max(d,b.confidence))}if(h.length>1){const b=(a=h,[Math.max(0,Math.round(Math.min(...a.map(k=>k[0])))),Math.max(0,Math.round(Math.min(...a.map(k=>k[1])))),Math.min(1e3,Math.round(Math.max(...a.map(k=>k[2])))),Math.min(1e3,Math.round(Math.max(...a.map(k=>k[3]))))]);gd(b)&&(u.boundingBox=b,u.confidence=d)}gd(u.boundingBox)&&i.push(u),r.add(u.id)}var a;return i}function _d(s,e){return[[s[0],s[1]],[s[2],s[1]],[s[2],s[3]],[s[0],s[3]]].every(t=>bl(t,e))}function mv(s,e){const t=[[s[0],s[1]],[s[2],s[1]],[s[2],s[3]],[s[0],s[3]]];return!Pm(s,e)&&t.every(n=>!bl(n,e))}function bl(s,e){const[t,n]=s;let r=!1;for(let i=0;i<e.length;i++){const o=(i+1)%e.length,[a,l]=e[i],[u,d]=e[o];if(t>=Math.min(a,u)&&t<=Math.max(a,u)&&n>=Math.min(l,d)&&n<=Math.max(l,d))if(Math.abs(a-u)<1e-6){if(Math.abs(t-a)<1e-6)return!0}else{const h=(d-l)/(u-a),v=h*t+(l-h*a);if(Math.abs(n-v)<1e-6)return!0}l>n!=d>n&&t<(u-a)*(n-l)/(d-l)+a&&(r=!r)}return r}function pv(s,e,t,n){const r=(n[1]-t[1])*(e[0]-s[0])-(n[0]-t[0])*(e[1]-s[1]);if(r===0)return!1;const i=((n[0]-t[0])*(s[1]-t[1])-(n[1]-t[1])*(s[0]-t[0]))/r,o=((e[0]-s[0])*(s[1]-t[1])-(e[1]-s[1])*(s[0]-t[0]))/r;return i>=0&&i<=1&&o>=0&&o<=1}function Pm(s,e){const t=[[s[0],s[1]],[s[2],s[1]],[s[2],s[3]],[s[0],s[3]],[s[0],s[1]]];if(t.some(n=>bl(n,e))||e.some(n=>n[0]>=s[0]&&n[0]<=s[2]&&n[1]>=s[1]&&n[1]<=s[3]))return!0;for(let n=0;n<t.length-1;n++)for(let r=0;r<e.length-1;r++)if(pv(t[n],t[n+1],e[r],e[r+1]))return!0;return!1}const yd=(s,e)=>{const{origWidth:t,origHeight:n}=e,r=s.points.map(([a,l])=>[a*t/100,l*n/100]);var i,o;return r.length>0&&(i=r[0],o=r[r.length-1],i[0]!==o[0]||i[1]!==o[1])&&r.push(r[0]),{...s,points:r}},bd=(s,e,t)=>{if(e.length===0)return[];if(s.length===0)return[];const n=new Set;for(const r of e)r.classes.length>0&&r.classes.forEach(i=>n.add(i));return s.filter(r=>{if(r.confidence<t.object.confidence||!n.has(r.label))return!1;const i=(l=>{const{origWidth:u,origHeight:d,inputWidth:h,inputHeight:v}=l;let[f,b,k,z]=l.boundingBox;return f=f*u/h,b=b*d/v,k=k*u/h,z=z*d/v,f=Math.max(0,Math.min(f,u)),b=Math.max(0,Math.min(b,d)),k=Math.max(0,Math.min(k,u)),z=Math.max(0,Math.min(z,d)),{...l,boundingBox:[f,b,k,z]}})(r);for(const l of e){if(!l.isPrivacyMask)continue;const u=yd(l,i);if(_d(i.boundingBox,u.points))return!1}let o=!1,a=!1;for(const l of e){if(l.isPrivacyMask||!l.classes.includes(r.label))continue;const u=yd(l,i),d=Pm(i.boundingBox,u.points),h=_d(i.boundingBox,u.points);if(l.filter==="include"){if(o=!0,l.type==="contain"&&h||l.type==="intersect"&&(d||h)){a=!0;break}}else if(l.type==="contain"){if(!mv(i.boundingBox,u.points))return!1}else if(d||h)return!1}return!o||a})};var tt,Qo,Ko,Zo,Go,Wo,Jo,Yo,Pc,nr,Mn;class fv extends Gg{constructor(t,n){super();Yn(this,tt);p(this,"logger");p(this,"snapshotCache");p(this,"cameraSubject");p(this,"cameraState",new gn(!1));p(this,"frameWorkerState",new gn(!1));p(this,"lightState",new gn(vt(this,tt,Wo).call(this,{state:!1},!0)));p(this,"motionState",new gn(vt(this,tt,Ko).call(this,{detections:[],state:!1},!0)));p(this,"audioState",new gn(vt(this,tt,Qo).call(this,{state:!1,db:0},!0)));p(this,"objectState",new gn(vt(this,tt,Zo).call(this,{detections:[]},!0)));p(this,"doorbellState",new gn(vt(this,tt,Go).call(this,{state:!1},!0)));p(this,"sirenState",new gn(vt(this,tt,Jo).call(this,{state:!1,level:0},!0)));p(this,"batteryState",new gn(vt(this,tt,Yo).call(this,{level:100,charging:!1,lowBattery:!1},!0)));p(this,"capabilities",new gn([]));p(this,"onConnected",vt(this,tt,Mn).call(this,this.cameraState));p(this,"onFrameWorkerConnected",vt(this,tt,Mn).call(this,this.frameWorkerState));p(this,"onLightSwitched",vt(this,tt,Mn).call(this,this.lightState));p(this,"onMotionDetected",vt(this,tt,Mn).call(this,this.motionState));p(this,"onAudioDetected",vt(this,tt,Mn).call(this,this.audioState));p(this,"onObjectDetected",vt(this,tt,Mn).call(this,this.objectState));p(this,"onDoorbellPressed",vt(this,tt,Mn).call(this,this.doorbellState));p(this,"onSirenDetected",vt(this,tt,Mn).call(this,this.sirenState));p(this,"onBatteryChanged",vt(this,tt,Mn).call(this,this.batteryState));this.logger=n,this.cameraSubject=new gn(t),this.snapshotCache=new(Jg())({max:100,ttl:1e3*this.snapshotTTL}),t.pluginInfo||this.cameraState.next(!0)}get cameraObject(){return Ks(this.cameraSubject.getValue())}get id(){return this.cameraSubject.getValue()._id}get nativeId(){return this.cameraSubject.getValue().nativeId}get pluginInfo(){return this.cameraSubject.getValue().pluginInfo}get connected(){return this.cameraState.getValue()}get frameWorkerConnected(){return this.frameWorkerState.getValue()}get disabled(){return this.cameraSubject.getValue().disabled}get name(){return this.cameraSubject.getValue().name}get type(){return this.cameraSubject.getValue().type}get info(){return Ks(this.cameraSubject.getValue().info)}get isCloud(){return this.cameraSubject.getValue().isCloud}get hasLight(){return this.hasCapability(Wt.Light)}get hasSiren(){return this.hasCapability(Wt.Siren)}get hasDoorbell(){return this.hasCapability(Wt.Doorbell)}get hasBattery(){return this.hasCapability(Wt.Battery)}get hasAudioDetector(){return this.hasCapability(Wt.AudioSensor)}get hasMotionDetector(){return this.hasCapability(Wt.MotionSensor)||this.hasCapability(Wt.MotionDetector)}get hasObjectDetector(){return this.hasCapability(Wt.ObjectSensor)||this.hasCapability(Wt.ObjectDetector)}get hasPtz(){return this.hasCapability(Wt.PTZ)}get snapshotTTL(){return this.cameraSubject.getValue().snapshotTTL}get detectionZones(){return Ks(this.cameraSubject.getValue().detectionZones)}get detectionSettings(){return Ks(this.cameraSubject.getValue().detectionSettings)}get frameWorkerSettings(){return Ks(this.cameraSubject.getValue().frameWorkerSettings)}get streamSource(){return this.highResolutionSource??this.midResolutionSource??this.lowResolutionSource}get snapshotSource(){return this.sources.find(t=>t.role=="snapshot")??this.sources.find(t=>t.useForSnapshot)}get highResolutionSource(){return this.sources.find(t=>t.role==="high-resolution")}get midResolutionSource(){return this.sources.find(t=>t.role==="mid-resolution")}get lowResolutionSource(){return this.sources.find(t=>t.role==="low-resolution")}get interfaces(){return this.cameraInterfaces}getCapabilities(){return Ks(this.capabilities.getValue().map(t=>t.capabilities).flat())}hasCapability(t){return this.getCapabilities().some(n=>n===t)}getValue(t){switch(t){case"light":return Ks(this.lightState.getValue());case"motion":return Ks(this.motionState.getValue());case"audio":return Ks(this.audioState.getValue());case"object":return Ks(this.objectState.getValue());case"doorbell":return Ks(this.doorbellState.getValue());case"siren":return Ks(this.sirenState.getValue());case"battery":return Ks(this.batteryState.getValue());default:throw new Error(`Unknown state: ${t}`)}}onStateChange(t){return this[`${t}State`].pipe(Ya(),Xa(([n,r])=>this.stateChanged(n,r,t)),Tc(([n,r])=>({oldState:n,newState:r})),Fo({connector:()=>new No(1)}))}onPropertyChange(t){return this.cameraSubject.pipe(Ya(),Tm(([n,r])=>(Array.isArray(t)?t:[t]).map(i=>({property:i,oldData:n[i],newData:r[i]}))),Xa(({oldData:n,newData:r})=>!ui(n,r,!0)),Fo({connector:()=>new No(1)}))}onCapabilitiesChange(){return this.capabilities.pipe(Ya(),Xa(([t,n])=>!ui(t,n,!0)),Tc(([t,n])=>({oldCapabilities:t.map(r=>r.capabilities).flat(),newCapabilities:n.map(r=>r.capabilities).flat()})),Fo({connector:()=>new No(1)}))}removeAllListeners(){this.lightState.complete(),this.motionState.complete(),this.audioState.complete(),this.objectState.complete(),this.doorbellState.complete(),this.sirenState.complete(),this.batteryState.complete(),this.cameraSubject.complete(),this.cameraState.complete(),this.frameWorkerState.complete(),this.capabilities.complete(),this.snapshotCache.clear()}updateCamera(t){t.snapshotTTL!==this.snapshotTTL&&this.snapshotCache.clear(),this.cameraSubject.next(t)}updateCameraState(t){this.cameraState.next(t)}updateFrameWorkerState(t){this.frameWorkerState.next(t)}updateCapabilities(t){this.capabilities.next(t)}updateStateInternal(t,n,r,i){let o,a=!1;if(r)a=!0,o=n;else{const l=this.checkStateInternal(t,n,i);a=l.changed,o=l.event}if(a)switch(t){case"light":this.lightState.next(vt(this,tt,Wo).call(this,o));break;case"motion":this.motionState.next(vt(this,tt,Ko).call(this,o));break;case"audio":this.audioState.next(vt(this,tt,Qo).call(this,o));break;case"object":this.objectState.next(vt(this,tt,Zo).call(this,o));break;case"doorbell":this.doorbellState.next(vt(this,tt,Go).call(this,o));break;case"siren":this.sirenState.next(vt(this,tt,Jo).call(this,o));break;case"battery":this.batteryState.next(vt(this,tt,Yo).call(this,o))}}checkStateInternal(t,n,r){let i,o=!1;switch(t){case"audio":const a=n;i=vt(this,tt,Qo).call(this,a),o=this.stateChanged(this.getValue("audio"),i,"audio");break;case"light":const l=n;i=vt(this,tt,Wo).call(this,l),o=this.stateChanged(this.getValue("light"),i,"light");break;case"motion":const u=n;if(u.state||(u.detections=[]),!r&&u.detections){const b=u.detections.length>0;u.detections=fd(u.detections),u.detections=vd(u.detections),u.detections=bd(u.detections,this.detectionZones,this.detectionSettings),b&&u.detections.length===0&&(u.state=!1)}i=vt(this,tt,Ko).call(this,u),o=this.stateChanged(this.getValue("motion"),i,"motion");break;case"object":const d=n;r||(d.detections=fd(d.detections),d.detections=vd(d.detections),d.detections=bd(d.detections,this.detectionZones,this.detectionSettings)),i=vt(this,tt,Zo).call(this,d),o=this.stateChanged(this.getValue("object"),i,"object");break;case"doorbell":const h=n;i=vt(this,tt,Go).call(this,h),o=this.stateChanged(this.getValue("doorbell"),i,"doorbell");break;case"siren":const v=n;i=vt(this,tt,Jo).call(this,v),o=this.stateChanged(this.getValue("siren"),i,"siren");break;case"battery":const f=n;i=vt(this,tt,Yo).call(this,f),o=this.stateChanged(this.getValue("battery"),i,"battery");break;default:throw new Error(`Unknown state: ${t}`)}return{changed:o,event:i}}stateChanged(t,n,r){return t===void 0||n===void 0||r===void 0||r==="audio"&&!this.hasAudioDetector||r==="motion"&&!this.hasMotionDetector||r==="object"&&!this.hasObjectDetector||r==="siren"&&!this.hasSiren||r==="battery"&&!this.hasBattery||r==="doorbell"&&!this.hasDoorbell||r==="light"&&!this.hasLight?!1:!ui(vt(this,tt,Pc).call(this,t),vt(this,tt,Pc).call(this,n),!0)}}tt=new WeakSet,Qo=function(t,n=!1){let r,i;if(n||(r=this.getValue("audio"),r&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t))i=t;else{const o={...t,timestamp:Date.now()};i={...o,db:o.db??(r==null?void 0:r.db)??0,lastEvent:r}}return i},Ko=function(t,n=!1){let r,i;return n||(r=this.getValue("motion"),r!=null&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t)?i=t:i={...t,timestamp:Date.now(),lastEvent:r},i},Zo=function(t,n=!1){let r,i;return n||(r=this.getValue("object"),r&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t)?i=t:i={...t,timestamp:Date.now(),lastEvent:r},i},Go=function(t,n=!1){let r,i;return n||(r=this.getValue("doorbell"),r&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t)?i=t:i={...t,timestamp:Date.now(),lastEvent:r},i},Wo=function(t,n=!1){let r,i;return n||(r=this.getValue("light"),r&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t)?i=t:i={...t,timestamp:Date.now(),lastEvent:r},i},Jo=function(t,n=!1){let r,i;if(n||(r=this.getValue("siren"),r&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t))i=t;else{const o={...t,timestamp:Date.now()};i={...o,level:o.level??(r==null?void 0:r.level)??0,lastEvent:r}}return i},Yo=function(t,n=!1){let r,i;return n||(r=this.getValue("battery"),r&&r.lastEvent&&delete r.lastEvent),vt(this,tt,nr).call(this,t)?i=t:i={...t,timestamp:Date.now(),charging:t.charging??(r==null?void 0:r.charging)??!1,lowBattery:t.lowBattery??(r==null?void 0:r.lowBattery)??!1,lastEvent:r},i},Pc=function(t){const n=Ks(t);return"timestamp"in n&&delete n.timestamp,"lastEvent"in n&&delete n.lastEvent,n},nr=function(t){return"timestamp"in t},Mn=function(t){return t.pipe((r===void 0&&(r=Mm),n=n??lv,Ri(function(i,o){var a,l=!0;i.subscribe(vi(o,function(u){var d=r(u);!l&&n(a,d)||(l=!1,a=d,o.next(u))}))})),Fo({connector:()=>new No(1)}));var n,r};class io{static coreManagerNamespaces(){return{coreManagerSubject:"coreManager.subscriber",coreManagerRpc:"coreManager.rpc"}}static deviceManagerNamespaces(){return{deviceManagerSubject:"deviceManager.subscriber",deviceManagerRpc:"deviceManager.rpc"}}static frameWorkerNamespaces(e){return{frameWorkerChildRpc:`camera.${e}.frameWorker.child.rpc`,frameWorkerChild:`camera.${e}.frameWorker.child`}}static pluginNamespaces(e){return{pluginDeviceManagerSubject:`plugin.${e}.deviceManager.subscriber`,pluginChildRpc:`plugin.${e}.child.rpc`,pluginChild:`plugin.${e}.child`,pluginStorageRpc:`plugin.${e}.storage.rpc`}}static cameraNamespaces(e){return{cameraSubject:`camera.${e}.subscriber`,cameraMotionFrameSubject:`camera.${e}.motionFrame.subscriber`,cameraControllerRpc:`camera.${e}.controller.rpc`}}static pluginCameraNamespaces(e,t){return{cameraInterfacesRpc:`plugin.${e}.camera.${t}.cameraInterfaces.rpc`,cameraStorageRpc:`plugin.${e}.camera.${t}.cameraStorage.rpc`}}}var tc=function(s,e,t,n){var r,i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,t,n);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(o=(i<3?r(o):i>3?r(e,t,o):r(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o},jn=function(s,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,e)},uo,Mr,ho,mo,$r,hi,ea;class Xo{constructor(e,t,n,r){Yn(this,hi);p(this,"interfaces");Yn(this,uo);Yn(this,Mr);Yn(this,ho);Yn(this,mo);Yn(this,$r,[]);Zr(this,uo,e),Zr(this,Mr,t),Zr(this,ho,n),Zr(this,mo,r)}async streamUrl(e){const t=An(this,Mr).getValue().find(n=>n.capabilities.some(r=>r===Wt.StreamUrl));if(!t)throw new Error("No capability found for streamUrl");return this.interfaces&&"streamUrl"in this.interfaces?this.interfaces.streamUrl(e):(await vt(this,hi,ea).call(this,t.pluginId)).streamUrl(e)}async snapshot(e,t){const n=An(this,Mr).getValue().find(r=>r.capabilities.some(i=>i===Wt.Snapshot));if(!n)throw new Error("No capability found for snapshot");return this.interfaces&&"snapshot"in this.interfaces?this.interfaces.snapshot(e,t):(await vt(this,hi,ea).call(this,n.pluginId)).snapshot(e,t)}async ptzCommand(e){const t=An(this,Mr).getValue().find(n=>n.capabilities.some(r=>r===Wt.PTZ));if(!t)throw new Error("No capability found for PTZ");return this.interfaces&&"ptzCommand"in this.interfaces?this.interfaces.ptzCommand(e):(await vt(this,hi,ea).call(this,t.pluginId)).ptzCommand(e)}async disconnect(){await Promise.allSettled(An(this,$r).map(e=>e.connection.disconnect())),Zr(this,$r,[])}}uo=new WeakMap,Mr=new WeakMap,ho=new WeakMap,mo=new WeakMap,$r=new WeakMap,hi=new WeakSet,ea=async function(e){var r;if(e===((r=An(this,mo))==null?void 0:r.id))throw new Error("Can not create camera proxy for the same plugin");const t=io.pluginCameraNamespaces(e,An(this,ho)).cameraInterfacesRpc,n=await An(this,uo).createRPCConnection(t);return An(this,$r).some(i=>i.namespace===t)||An(this,$r).push({namespace:t,connection:n}),n.createProxy()};tc([Wa({public:!0}),jn("design:type",Function),jn("design:paramtypes",[String]),jn("design:returntype",Promise)],Xo.prototype,"streamUrl",null),tc([Wa({public:!0}),jn("design:type",Function),jn("design:paramtypes",[String,Boolean]),jn("design:returntype",Promise)],Xo.prototype,"snapshot",null),tc([Wa({public:!0}),jn("design:type",Function),jn("design:paramtypes",[Object]),jn("design:returntype",Promise)],Xo.prototype,"ptzCommand",null);const wd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let sc;const gv=new Uint8Array(16),Ts=[];for(let s=0;s<256;++s)Ts.push((s+256).toString(16).slice(1));function vv(s,e=0){return(Ts[s[e+0]]+Ts[s[e+1]]+Ts[s[e+2]]+Ts[s[e+3]]+"-"+Ts[s[e+4]]+Ts[s[e+5]]+"-"+Ts[s[e+6]]+Ts[s[e+7]]+"-"+Ts[s[e+8]]+Ts[s[e+9]]+"-"+Ts[s[e+10]]+Ts[s[e+11]]+Ts[s[e+12]]+Ts[s[e+13]]+Ts[s[e+14]]+Ts[s[e+15]]).toLowerCase()}const mn=function(s,e,t){var r;if(wd.randomUUID&&!s)return wd.randomUUID();const n=(s=s||{}).random??((r=s.rng)==null?void 0:r.call(s))??function(){if(!sc){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sc=crypto.getRandomValues.bind(crypto)}return sc(gv)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,vv(n)};var Dt,xd;(function(s){s.assertEqual=e=>{},s.assertIs=function(e){},s.assertNever=function(e){throw new Error},s.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},s.getValidEnumValues=e=>{const t=s.objectKeys(e).filter(r=>typeof e[e[r]]!="number"),n={};for(const r of t)n[r]=e[r];return s.objectValues(n)},s.objectValues=e=>s.objectKeys(e).map(function(t){return e[t]}),s.objectKeys=typeof Object.keys=="function"?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},s.find=(e,t)=>{for(const n of e)if(t(n))return n},s.isInteger=typeof Number.isInteger=="function"?e=>Number.isInteger(e):e=>typeof e=="number"&&Number.isFinite(e)&&Math.floor(e)===e,s.joinValues=function(e,t=" | "){return e.map(n=>typeof n=="string"?`'${n}'`:n).join(t)},s.jsonStringifyReplacer=(e,t)=>typeof t=="bigint"?t.toString():t})(Dt||(Dt={})),function(s){s.mergeShapes=(e,t)=>({...e,...t})}(xd||(xd={}));const Ze=Dt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ir=s=>{switch(typeof s){case"undefined":return Ze.undefined;case"string":return Ze.string;case"number":return Number.isNaN(s)?Ze.nan:Ze.number;case"boolean":return Ze.boolean;case"function":return Ze.function;case"bigint":return Ze.bigint;case"symbol":return Ze.symbol;case"object":return Array.isArray(s)?Ze.array:s===null?Ze.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?Ze.promise:typeof Map<"u"&&s instanceof Map?Ze.map:typeof Set<"u"&&s instanceof Set?Ze.set:typeof Date<"u"&&s instanceof Date?Ze.date:Ze.object;default:return Ze.unknown}},$e=Dt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Gn extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},n={_errors:[]},r=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let a=n,l=0;for(;l<o.path.length;){const u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(t(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return r(this),n}static assert(e){if(!(e instanceof Gn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Dt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Gn.create=s=>new Gn(s);const Rc=(s,e)=>{let t;switch(s.code){case $e.invalid_type:t=s.received===Ze.undefined?"Required":`Expected ${s.expected}, received ${s.received}`;break;case $e.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,Dt.jsonStringifyReplacer)}`;break;case $e.unrecognized_keys:t=`Unrecognized key(s) in object: ${Dt.joinValues(s.keys,", ")}`;break;case $e.invalid_union:t="Invalid input";break;case $e.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Dt.joinValues(s.options)}`;break;case $e.invalid_enum_value:t=`Invalid enum value. Expected ${Dt.joinValues(s.options)}, received '${s.received}'`;break;case $e.invalid_arguments:t="Invalid function arguments";break;case $e.invalid_return_type:t="Invalid function return type";break;case $e.invalid_date:t="Invalid date";break;case $e.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:Dt.assertNever(s.validation):t=s.validation!=="regex"?`Invalid ${s.validation}`:"Invalid";break;case $e.too_small:t=s.type==="array"?`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:"Invalid input";break;case $e.too_big:t=s.type==="array"?`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:"Invalid input";break;case $e.custom:t="Invalid input";break;case $e.invalid_intersection_types:t="Intersection results could not be merged";break;case $e.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case $e.not_finite:t="Number must be finite";break;default:t=e.defaultError,Dt.assertNever(s)}return{message:t}};let _v=Rc;function yv(){return _v}const bv=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,i=[...t,...r.path||[]],o={...r,path:i};if(r.message!==void 0)return{...r,path:i,message:r.message};let a="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)a=u(o,{data:e,defaultError:a}).message;return{...r,path:i,message:a}};function De(s,e){const t=yv(),n=bv({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Rc?void 0:Rc].filter(r=>!!r)});s.common.issues.push(n)}class Qs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return mt;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t){const i=await r.key,o=await r.value;n.push({key:i,value:o})}return Qs.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return mt;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value==="__proto__"||o.value===void 0&&!r.alwaysSet||(n[i.value]=o.value)}return{status:e.value,value:n}}}const mt=Object.freeze({status:"aborted"}),Ic=s=>({status:"dirty",value:s}),pn=s=>({status:"valid",value:s}),Sd=s=>s.status==="aborted",Cd=s=>s.status==="dirty",_i=s=>s.status==="valid",pa=s=>typeof Promise<"u"&&s instanceof Promise;var Je;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Je||(Je={}));class Nn{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const kd=(s,e)=>{if(_i(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Gn(s.common.issues);return this._error=t,this._error}}};function Ct(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{const{message:a}=s;return i.code==="invalid_enum_value"?{message:a??o.defaultError}:o.data===void 0?{message:a??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:a??t??o.defaultError}},description:r}}class Rt{get description(){return this._def.description}_getType(e){return ir(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ir(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Qs,ctx:{common:e.parent.common,data:e.data,parsedType:ir(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(pa(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ir(e)},r=this._parseSync({data:e,path:n.path,parent:n});return kd(n,r)}"~validate"(e){var n,r;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ir(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return _i(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(r=(n=i==null?void 0:i.message)==null?void 0:n.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>_i(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ir(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(pa(r)?r:Promise.resolve(r));return kd(n,i)}refine(e,t){const n=r=>typeof t=="string"||t===void 0?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,i)=>{const o=e(r),a=()=>i.addIssue({code:$e.custom,...n(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>!!l||(a(),!1)):!!o||(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>!!e(n)||(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new si({schema:this,typeName:dt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return gr.create(this,this._def)}nullable(){return wi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return On.create(this)}promise(){return _a.create(this,this._def)}or(e){return ga.create([this,e],this._def)}and(e){return va.create(this,e,this._def)}transform(e){return new si({...Ct(this._def),schema:this,typeName:dt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Lc({...Ct(this._def),innerType:this,defaultValue:t,typeName:dt.ZodDefault})}brand(){return new Dv({typeName:dt.ZodBranded,type:this,...Ct(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new jc({...Ct(this._def),innerType:this,catchValue:t,typeName:dt.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return xl.create(this,e)}readonly(){return qc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wv=/^c[^\s-]{8,}$/i,xv=/^[0-9a-z]+$/,Sv=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Cv=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,kv=/^[a-z0-9_-]{21}$/i,Ev=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Av=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let nc;const $v=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tv=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Pv=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Rv=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Iv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ov=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Rm="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Nv=new RegExp(`^${Rm}$`);function Im(s){let e="[0-5]\\d";return s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${e})${s.precision?"+":"?"}`}function Fv(s){let e=`${Rm}T${Im(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Lv(s,e){if(!Ev.test(s))return!1;try{const[t]=s.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(n));return typeof r=="object"&&r!==null&&(!("typ"in r)||(r==null?void 0:r.typ)==="JWT")&&!!r.alg&&(!e||r.alg===e)}catch{return!1}}function jv(s,e){return!(e!=="v4"&&e||!Tv.test(s))||!(e!=="v6"&&e||!Rv.test(s))}class Vn extends Rt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ze.string){const o=this._getOrReturnCtx(e);return De(o,{code:$e.invalid_type,expected:Ze.string,received:o.parsedType}),mt}const t=new Qs;let n;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(n=this._getOrReturnCtx(e,n),De(n,{code:$e.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if(o.kind==="max")e.data.length>o.value&&(n=this._getOrReturnCtx(e,n),De(n,{code:$e.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if(o.kind==="length"){const a=e.data.length>o.value,l=e.data.length<o.value;(a||l)&&(n=this._getOrReturnCtx(e,n),a?De(n,{code:$e.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):l&&De(n,{code:$e.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),t.dirty())}else if(o.kind==="email")Mv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"email",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="emoji")nc||(nc=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),nc.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"emoji",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="uuid")Cv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"uuid",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="nanoid")kv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"nanoid",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="cuid")wv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"cuid",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="cuid2")xv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"cuid2",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="ulid")Sv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"ulid",code:$e.invalid_string,message:o.message}),t.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),De(n,{validation:"url",code:$e.invalid_string,message:o.message}),t.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"regex",code:$e.invalid_string,message:o.message}),t.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(e,n),De(n,{code:$e.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),t.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(n=this._getOrReturnCtx(e,n),De(n,{code:$e.invalid_string,validation:{startsWith:o.value},message:o.message}),t.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(n=this._getOrReturnCtx(e,n),De(n,{code:$e.invalid_string,validation:{endsWith:o.value},message:o.message}),t.dirty()):o.kind==="datetime"?Fv(o).test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{code:$e.invalid_string,validation:"datetime",message:o.message}),t.dirty()):o.kind==="date"?Nv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{code:$e.invalid_string,validation:"date",message:o.message}),t.dirty()):o.kind==="time"?new RegExp(`^${Im(o)}$`).test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{code:$e.invalid_string,validation:"time",message:o.message}),t.dirty()):o.kind==="duration"?Av.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"duration",code:$e.invalid_string,message:o.message}),t.dirty()):o.kind==="ip"?(r=e.data,((i=o.version)!=="v4"&&i||!$v.test(r))&&(i!=="v6"&&i||!Pv.test(r))&&(n=this._getOrReturnCtx(e,n),De(n,{validation:"ip",code:$e.invalid_string,message:o.message}),t.dirty())):o.kind==="jwt"?Lv(e.data,o.alg)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"jwt",code:$e.invalid_string,message:o.message}),t.dirty()):o.kind==="cidr"?jv(e.data,o.version)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"cidr",code:$e.invalid_string,message:o.message}),t.dirty()):o.kind==="base64"?Iv.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"base64",code:$e.invalid_string,message:o.message}),t.dirty()):o.kind==="base64url"?Ov.test(e.data)||(n=this._getOrReturnCtx(e,n),De(n,{validation:"base64url",code:$e.invalid_string,message:o.message}),t.dirty()):Dt.assertNever(o);var r,i;return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:$e.invalid_string,...Je.errToObj(n)})}_addCheck(e){return new Vn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Je.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Je.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Je.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Je.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Je.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Je.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Je.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Je.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Je.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Je.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Je.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Je.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Je.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Je.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,...Je.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Je.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Je.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Je.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Je.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Je.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Je.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Je.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Je.errToObj(t)})}nonempty(e){return this.min(1,Je.errToObj(e))}trim(){return new Vn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Vn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Vn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}function qv(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n;return Number.parseInt(s.toFixed(r).replace(".",""))%Number.parseInt(e.toFixed(r).replace(".",""))/10**r}Vn.create=s=>new Vn({checks:[],typeName:dt.ZodString,coerce:(s==null?void 0:s.coerce)??!1,...Ct(s)});class yi extends Rt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Ze.number){const r=this._getOrReturnCtx(e);return De(r,{code:$e.invalid_type,expected:Ze.number,received:r.parsedType}),mt}let t;const n=new Qs;for(const r of this._def.checks)r.kind==="int"?Dt.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),De(t,{code:$e.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),De(t,{code:$e.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),De(t,{code:$e.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?qv(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),De(t,{code:$e.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),De(t,{code:$e.not_finite,message:r.message}),n.dirty()):Dt.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Je.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Je.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Je.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Je.toString(t))}setLimit(e,t,n,r){return new yi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Je.toString(r)}]})}_addCheck(e){return new yi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Je.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Je.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Je.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Je.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Je.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Je.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Je.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Je.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Je.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Dt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}yi.create=s=>new yi({checks:[],typeName:dt.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...Ct(s)});class oo extends Rt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Ze.bigint)return this._getInvalidInput(e);let t;const n=new Qs;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),De(t,{code:$e.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),De(t,{code:$e.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),De(t,{code:$e.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Dt.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.bigint,received:t.parsedType}),mt}gte(e,t){return this.setLimit("min",e,!0,Je.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Je.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Je.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Je.toString(t))}setLimit(e,t,n,r){return new oo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Je.toString(r)}]})}_addCheck(e){return new oo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Je.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Je.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Je.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Je.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Je.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}oo.create=s=>new oo({checks:[],typeName:dt.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,...Ct(s)});class Oc extends Rt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ze.boolean){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.boolean,received:t.parsedType}),mt}return pn(e.data)}}Oc.create=s=>new Oc({typeName:dt.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...Ct(s)});class fa extends Rt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ze.date){const r=this._getOrReturnCtx(e);return De(r,{code:$e.invalid_type,expected:Ze.date,received:r.parsedType}),mt}if(Number.isNaN(e.data.getTime()))return De(this._getOrReturnCtx(e),{code:$e.invalid_date}),mt;const t=new Qs;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),De(n,{code:$e.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),De(n,{code:$e.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):Dt.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new fa({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Je.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Je.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}fa.create=s=>new fa({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:dt.ZodDate,...Ct(s)});class Ed extends Rt{_parse(e){if(this._getType(e)!==Ze.symbol){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.symbol,received:t.parsedType}),mt}return pn(e.data)}}Ed.create=s=>new Ed({typeName:dt.ZodSymbol,...Ct(s)});class Ad extends Rt{_parse(e){if(this._getType(e)!==Ze.undefined){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.undefined,received:t.parsedType}),mt}return pn(e.data)}}Ad.create=s=>new Ad({typeName:dt.ZodUndefined,...Ct(s)});class Md extends Rt{_parse(e){if(this._getType(e)!==Ze.null){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.null,received:t.parsedType}),mt}return pn(e.data)}}Md.create=s=>new Md({typeName:dt.ZodNull,...Ct(s)});class ao extends Rt{constructor(){super(...arguments),this._any=!0}_parse(e){return pn(e.data)}}ao.create=s=>new ao({typeName:dt.ZodAny,...Ct(s)});class $d extends Rt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pn(e.data)}}$d.create=s=>new $d({typeName:dt.ZodUnknown,...Ct(s)});class fr extends Rt{_parse(e){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.never,received:t.parsedType}),mt}}fr.create=s=>new fr({typeName:dt.ZodNever,...Ct(s)});class Td extends Rt{_parse(e){if(this._getType(e)!==Ze.undefined){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.void,received:t.parsedType}),mt}return pn(e.data)}}Td.create=s=>new Td({typeName:dt.ZodVoid,...Ct(s)});class On extends Rt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Ze.array)return De(t,{code:$e.invalid_type,expected:Ze.array,received:t.parsedType}),mt;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,a=t.data.length<r.exactLength.value;(o||a)&&(De(t,{code:o?$e.too_big:$e.too_small,minimum:a?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(De(t,{code:$e.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(De(t,{code:$e.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>r.type._parseAsync(new Nn(t,o,t.path,a)))).then(o=>Qs.mergeArray(n,o));const i=[...t.data].map((o,a)=>r.type._parseSync(new Nn(t,o,t.path,a)));return Qs.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new On({...this._def,minLength:{value:e,message:Je.toString(t)}})}max(e,t){return new On({...this._def,maxLength:{value:e,message:Je.toString(t)}})}length(e,t){return new On({...this._def,exactLength:{value:e,message:Je.toString(t)}})}nonempty(e){return this.min(1,e)}}function Xr(s){if(s instanceof _s){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=gr.create(Xr(n))}return new _s({...s._def,shape:()=>e})}return s instanceof On?new On({...s._def,type:Xr(s.element)}):s instanceof gr?gr.create(Xr(s.unwrap())):s instanceof wi?wi.create(Xr(s.unwrap())):s instanceof Nr?Nr.create(s.items.map(e=>Xr(e))):s}On.create=(s,e)=>new On({type:s,minLength:null,maxLength:null,exactLength:null,typeName:dt.ZodArray,...Ct(e)});class _s extends Rt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Dt.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Ze.object){const l=this._getOrReturnCtx(e);return De(l,{code:$e.invalid_type,expected:Ze.object,received:l.parsedType}),mt}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof fr&&this._def.unknownKeys==="strip"))for(const l in n.data)i.includes(l)||o.push(l);const a=[];for(const l of i){const u=r[l],d=n.data[l];a.push({key:{status:"valid",value:l},value:u._parse(new Nn(n,d,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof fr){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of o)a.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")o.length>0&&(De(n,{code:$e.unrecognized_keys,keys:o}),t.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of o){const d=n.data[u];a.push({key:{status:"valid",value:u},value:l._parse(new Nn(n,d,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of a){const d=await u.key,h=await u.value;l.push({key:d,value:h,alwaysSet:u.alwaysSet})}return l}).then(l=>Qs.mergeObjectSync(t,l)):Qs.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return Je.errToObj,new _s({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,o;const r=((o=(i=this._def).errorMap)==null?void 0:o.call(i,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:Je.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new _s({...this._def,unknownKeys:"strip"})}passthrough(){return new _s({...this._def,unknownKeys:"passthrough"})}extend(e){return new _s({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new _s({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:dt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new _s({...this._def,catchall:e})}pick(e){const t={};for(const n of Dt.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new _s({...this._def,shape:()=>t})}omit(e){const t={};for(const n of Dt.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new _s({...this._def,shape:()=>t})}deepPartial(){return Xr(this)}partial(e){const t={};for(const n of Dt.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}return new _s({...this._def,shape:()=>t})}required(e){const t={};for(const n of Dt.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof gr;)r=r._def.innerType;t[n]=r}return new _s({...this._def,shape:()=>t})}keyof(){return Om(Dt.objectKeys(this.shape))}}_s.create=(s,e)=>new _s({shape:()=>s,unknownKeys:"strip",catchall:fr.create(),typeName:dt.ZodObject,...Ct(e)}),_s.strictCreate=(s,e)=>new _s({shape:()=>s,unknownKeys:"strict",catchall:fr.create(),typeName:dt.ZodObject,...Ct(e)}),_s.lazycreate=(s,e)=>new _s({shape:s,unknownKeys:"strip",catchall:fr.create(),typeName:dt.ZodObject,...Ct(e)});class ga extends Rt{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async r=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(function(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new Gn(o.ctx.common.issues));return De(t,{code:$e.invalid_union,unionErrors:i}),mt});{let r;const i=[];for(const a of n){const l={...t,common:{...t.common,issues:[]},parent:null},u=a._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status!=="dirty"||r||(r={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(a=>new Gn(a));return De(t,{code:$e.invalid_union,unionErrors:o}),mt}}get options(){return this._def.options}}ga.create=(s,e)=>new ga({options:s,typeName:dt.ZodUnion,...Ct(e)});function Nc(s,e){const t=ir(s),n=ir(e);if(s===e)return{valid:!0,data:s};if(t===Ze.object&&n===Ze.object){const r=Dt.objectKeys(e),i=Dt.objectKeys(s).filter(a=>r.indexOf(a)!==-1),o={...s,...e};for(const a of i){const l=Nc(s[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}if(t===Ze.array&&n===Ze.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let i=0;i<s.length;i++){const o=Nc(s[i],e[i]);if(!o.valid)return{valid:!1};r.push(o.data)}return{valid:!0,data:r}}return t===Ze.date&&n===Ze.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class va extends Rt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(i,o)=>{if(Sd(i)||Sd(o))return mt;const a=Nc(i.value,o.value);return a.valid?((Cd(i)||Cd(o))&&t.dirty(),{status:t.value,value:a.data}):(De(n,{code:$e.invalid_intersection_types}),mt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}va.create=(s,e,t)=>new va({left:s,right:e,typeName:dt.ZodIntersection,...Ct(t)});class Nr extends Rt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ze.array)return De(n,{code:$e.invalid_type,expected:Ze.array,received:n.parsedType}),mt;if(n.data.length<this._def.items.length)return De(n,{code:$e.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&n.data.length>this._def.items.length&&(De(n,{code:$e.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((i,o)=>{const a=this._def.items[o]||this._def.rest;return a?a._parse(new Nn(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(r).then(i=>Qs.mergeArray(t,i)):Qs.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Nr({...this._def,rest:e})}}Nr.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr({items:s,typeName:dt.ZodTuple,rest:null,...Ct(e)})};class wl extends Rt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ze.object)return De(n,{code:$e.invalid_type,expected:Ze.object,received:n.parsedType}),mt;const r=[],i=this._def.keyType,o=this._def.valueType;for(const a in n.data)r.push({key:i._parse(new Nn(n,a,n.path,a)),value:o._parse(new Nn(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Qs.mergeObjectAsync(t,r):Qs.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new wl(t instanceof Rt?{keyType:e,valueType:t,typeName:dt.ZodRecord,...Ct(n)}:{keyType:Vn.create(),valueType:e,typeName:dt.ZodRecord,...Ct(t)})}}class Pd extends Rt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ze.map)return De(n,{code:$e.invalid_type,expected:Ze.map,received:n.parsedType}),mt;const r=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,l],u)=>({key:r._parse(new Nn(n,a,n.path,[u,"key"])),value:i._parse(new Nn(n,l,n.path,[u,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const u=await l.key,d=await l.value;if(u.status==="aborted"||d.status==="aborted")return mt;u.status!=="dirty"&&d.status!=="dirty"||t.dirty(),a.set(u.value,d.value)}return{status:t.value,value:a}})}{const a=new Map;for(const l of o){const u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return mt;u.status!=="dirty"&&d.status!=="dirty"||t.dirty(),a.set(u.value,d.value)}return{status:t.value,value:a}}}}Pd.create=(s,e,t)=>new Pd({valueType:e,keyType:s,typeName:dt.ZodMap,...Ct(t)});class co extends Rt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ze.set)return De(n,{code:$e.invalid_type,expected:Ze.set,received:n.parsedType}),mt;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(De(n,{code:$e.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(De(n,{code:$e.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function o(l){const u=new Set;for(const d of l){if(d.status==="aborted")return mt;d.status==="dirty"&&t.dirty(),u.add(d.value)}return{status:t.value,value:u}}const a=[...n.data.values()].map((l,u)=>i._parse(new Nn(n,l,n.path,u)));return n.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,t){return new co({...this._def,minSize:{value:e,message:Je.toString(t)}})}max(e,t){return new co({...this._def,maxSize:{value:e,message:Je.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}co.create=(s,e)=>new co({valueType:s,minSize:null,maxSize:null,typeName:dt.ZodSet,...Ct(e)});class Rd extends Rt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Rd.create=(s,e)=>new Rd({getter:s,typeName:dt.ZodLazy,...Ct(e)});class Fc extends Rt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return De(t,{received:t.data,code:$e.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Om(s,e){return new bi({values:s,typeName:dt.ZodEnum,...Ct(e)})}Fc.create=(s,e)=>new Fc({value:s,typeName:dt.ZodLiteral,...Ct(e)});class bi extends Rt{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return De(t,{expected:Dt.joinValues(n),received:t.parsedType,code:$e.invalid_type}),mt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return De(t,{received:t.data,code:$e.invalid_enum_value,options:n}),mt}return pn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return bi.create(e,{...this._def,...t})}exclude(e,t=this._def){return bi.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}bi.create=Om;class Id extends Rt{_parse(e){const t=Dt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Ze.string&&n.parsedType!==Ze.number){const r=Dt.objectValues(t);return De(n,{expected:Dt.joinValues(r),received:n.parsedType,code:$e.invalid_type}),mt}if(this._cache||(this._cache=new Set(Dt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=Dt.objectValues(t);return De(n,{received:n.data,code:$e.invalid_enum_value,options:r}),mt}return pn(e.data)}get enum(){return this._def.values}}Id.create=(s,e)=>new Id({values:s,typeName:dt.ZodNativeEnum,...Ct(e)});class _a extends Rt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ze.promise&&t.common.async===!1)return De(t,{code:$e.invalid_type,expected:Ze.promise,received:t.parsedType}),mt;const n=t.parsedType===Ze.promise?t.data:Promise.resolve(t.data);return pn(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}_a.create=(s,e)=>new _a({type:s,typeName:dt.ZodPromise,...Ct(e)});class si extends Rt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===dt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:o=>{De(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){const o=r.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return mt;const l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return l.status==="aborted"?mt:l.status==="dirty"||t.value==="dirty"?Ic(l.value):l});{if(t.value==="aborted")return mt;const a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?mt:a.status==="dirty"||t.value==="dirty"?Ic(a.value):a}}if(r.type==="refinement"){const o=a=>{const l=r.refinement(a,i);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?mt:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?mt:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(r.type==="transform"){if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_i(o))return mt;const a=r.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>_i(o)?Promise.resolve(r.transform(o.value,i)).then(a=>({status:t.value,value:a})):mt)}Dt.assertNever(r)}}si.create=(s,e,t)=>new si({schema:s,typeName:dt.ZodEffects,effect:e,...Ct(t)}),si.createWithPreprocess=(s,e,t)=>new si({schema:e,effect:{type:"preprocess",transform:s},typeName:dt.ZodEffects,...Ct(t)});class gr extends Rt{_parse(e){return this._getType(e)===Ze.undefined?pn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gr.create=(s,e)=>new gr({innerType:s,typeName:dt.ZodOptional,...Ct(e)});class wi extends Rt{_parse(e){return this._getType(e)===Ze.null?pn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wi.create=(s,e)=>new wi({innerType:s,typeName:dt.ZodNullable,...Ct(e)});class Lc extends Rt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Ze.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Lc.create=(s,e)=>new Lc({innerType:s,typeName:dt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});class jc extends Rt{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pa(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Gn(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Gn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}jc.create=(s,e)=>new jc({innerType:s,typeName:dt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ct(e)});class Od extends Rt{_parse(e){if(this._getType(e)!==Ze.nan){const t=this._getOrReturnCtx(e);return De(t,{code:$e.invalid_type,expected:Ze.nan,received:t.parsedType}),mt}return{status:"valid",value:e.data}}}Od.create=s=>new Od({typeName:dt.ZodNaN,...Ct(s)});class Dv extends Rt{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class xl extends Rt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?mt:r.status==="dirty"?(t.dirty(),Ic(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?mt:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new xl({in:e,out:t,typeName:dt.ZodPipeline})}}class qc extends Rt{_parse(e){const t=this._def.innerType._parse(e),n=r=>(_i(r)&&(r.value=Object.freeze(r.value)),r);return pa(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}}function Nd(s,e){const t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function qn(s,e={},t){return s?ao.create().superRefine((n,r)=>{const i=s(n);if(i instanceof Promise)return i.then(o=>{if(!o){const a=Nd(e,n),l=a.fatal??t??!0;r.addIssue({code:"custom",...a,fatal:l})}});if(!i){const o=Nd(e,n),a=o.fatal??t??!0;r.addIssue({code:"custom",...o,fatal:a})}}):ao.create()}qc.create=(s,e)=>new qc({innerType:s,typeName:dt.ZodReadonly,...Ct(e)});var dt;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(dt||(dt={}));const We=Vn.create,Fn=yi.create,Rs=Oc.create,Di=ao.create,xt=(fr.create,On.create,_s.create),Ns=ga.create,Bv=(va.create,Nr.create),Dc=wl.create,xe=Fc.create,zv=(bi.create,_a.create,gr.create);wi.create;function Fd(s){const e=["kasa://","nest:","ring:","tapo://"];return s.some(t=>e.some(n=>t.startsWith(n)))}const Ld=xt({enabled:Rs().default(!1)}).strict(),Uv=Ns([xe("animal"),xe("person"),xe("vehicle"),xe("other"),xe("motion")]),Sl=Bv([Fn(),Fn()]),jd=xt({name:We().trim().min(1,"Zone Name is required"),points:Sl.array().min(3,"At least 3 points are required"),type:Ns([xe("intersect"),xe("contain")]),filter:Ns([xe("include"),xe("exclude")]),classes:Uv.array(),isPrivacyMask:Rs(),color:We().trim().regex(/^#([0-9A-Fa-f]{3}){1,2}$/,"Must be a valid hex color (e.g. #FF0000 or #F00)").default("#df2a4c")}).array(),qd=xt({motion:xt({timeout:Fn().min(10,"Minimum 10 seconds")}),object:xt({confidence:Fn().min(.3,"Minimum 0.3").max(1,"Maximum 1")})}),Nm=Ns([xe("high-resolution"),xe("mid-resolution"),xe("low-resolution"),xe("snapshot")]),Vv=Ns([xe("high-resolution"),xe("mid-resolution"),xe("low-resolution"),xe("auto")]),Hv=Ns([xe("bubble://"),xe("cui://"),xe("doorbird://"),xe("dvrip://"),xe("echo:"),xe("eseecloud://"),xe("exec:"),xe("expr:"),xe("ffmpeg:"),xe("flussonic://"),xe("gopro://"),xe("hass:"),xe("homekit://"),xe("http://"),xe("https://"),xe("httpx://"),xe("isapi://"),xe("ivideon:"),xe("kasa://"),xe("nest:"),xe("onvif://"),xe("ring:"),xe("roborock://"),xe("rtmp://"),xe("rtsp://"),xe("rtspx://"),xe("tapo://"),xe("tcp://"),xe("tuya://"),xe("webrtc:"),xe("webtorrent:")]).options.map(s=>s.value),Qv=new RegExp(`^(${Hv.join("|")})`),Fm=We().refine(s=>{if(!Qv.test(s))return!1;try{return new URL(s),!0}catch{return!1}},{message:"Invalid URL format or unsupported protocol"}),Kv=xt({_id:We().default(mn()).transform(()=>mn()),name:We().trim().min(1,"Camera Source Name is required").transform(s=>s.replace(/ /g,"_").toLowerCase()),role:Nm,useForSnapshot:Rs().default(!1),hotMode:Rs().default(!1),urls:Fm.array().min(1,"At least one valid URL is required")}).strict(),Zv=xt({_id:We().default(mn()).transform(()=>mn()),name:We().trim().min(1,"Camera Source Name is required").transform(s=>s.replace(/ /g,"_").toLowerCase()),role:Nm,useForSnapshot:Rs().default(!1),hotMode:Rs().default(!1),urls:Fm.array().min(1,"At least one valid URL is required")}).strict(),Sr=xt({id:We(),name:We().trim()}),Dd=xt({hub:Sr.array().optional(),cameraController:Sr.optional(),motionDetection:Sr.optional(),audioDetection:Sr.optional(),objectDetection:Sr.optional(),ptz:Sr.optional(),plugins:Sr.array()}).strict(),Gv=Ns([xe("auto"),xe("mse"),xe("webrtc"),xe("webrtc/tcp")]),Wv=Ns([xe("16:9"),xe("8:3"),xe("4:3"),xe("auto")]),Bd=xt({decoder:Ns([xe("pillow"),xe("wasm"),xe("rust"),xe("gpu")]),fps:Fn().min(0,"Minimum 0 fps").max(30,"Maximum 30 fps"),resolution:Ns([xe("640x480"),xe("640x360"),xe("320x240"),xe("320x180")])}),zd=Ns([xe("camera"),xe("doorbell")]),Ud=xt({streamingMode:Gv,streamingSource:Vv,aspectRatio:Wv}),Vd=xt({model:We().trim().optional(),manufacturer:We().trim().optional(),hardware:We().trim().optional(),serialNumber:We().trim().optional(),firmwareVersion:We().trim().optional(),supportUrl:We().trim().optional()}),Jv=(xt({name:We().trim().min(1,"Camera name is required"),url:We().trim().url().min(1,"Camera URL is required"),type:Ns([xe("Google"),xe("Ring"),xe("HomeKit"),xe("Onvif"),xe("Hass"),xe("GoPro"),xe("Roborock"),xe("FFmpeg"),xe("DVRip"),xe("Webtorrent")]),username:We().trim().optional(),email:We().trim().email().optional(),password:We().trim().optional(),pin:We().trim().length(8,{message:"PIN must be 8 characters long"}).optional(),clientId:We().trim().optional(),clientSecret:We().trim().optional(),refreshToken:We().trim().optional(),projectId:We().trim().optional()}).strict().refine(s=>s.type!=="HomeKit"||!!s.pin,{message:"PIN is required for HomeKit cameras",path:["pin"]}).refine(s=>s.type!=="Google"||!!s.clientId,{message:"Client ID is required for Google cameras",path:["clientId"]}).refine(s=>s.type!=="Google"||!!s.clientSecret,{message:"Client Secret is required for Google cameras",path:["clientSecret"]}).refine(s=>s.type!=="Google"||!!s.projectId,{message:"Project ID is required for Google cameras",path:["projectId"]}).refine(s=>s.type!=="Google"||!!s.refreshToken,{message:"Refresh Token is required for Google cameras",path:["refreshToken"]}).refine(s=>s.type!=="Ring"||!!s.email,{message:"Email is required",path:["email"]}).refine(s=>s.type!=="Roborock"||!!s.username,{message:"Username is required",path:["username"]}).refine(s=>s.type!=="Roborock"&&s.type!=="Ring"||!!s.password,{message:"Password is required",path:["password"]}),xt({id:We(),name:We()}).strict()),Yv=(xt({_id:We().default(mn()).transform(()=>mn()),nativeId:We().trim().optional(),pluginInfo:Jv.optional(),disabled:Rs().default(!1),name:We().trim().min(1,"Camera name is required"),type:zd.default("camera"),isCloud:Rs().default(!1),snapshotTTL:Fn().min(30,"Minimum cache time must be 30").default(600),info:Vd.default({model:"IP Camera",manufacturer:"camera.ui",hardware:"Camera",serialNumber:"Unknown",firmwareVersion:"Unknown",supportUrl:"Unknown"}),sources:Kv.array().refine(s=>s.some(e=>e.role==="high-resolution"||e.role==="mid-resolution"||e.role==="low-resolution"),{path:["sources[].role"],message:'One of the roles "high-resolution", "mid-resolution" or "low-resolution" is required'}).refine(s=>s.filter(e=>e.useForSnapshot).length<=1,{message:"Only one source can be used for snapshot",path:["sources"]}).refine(s=>s.filter(e=>e.role==="snapshot").every(e=>!e.useForSnapshot),{message:"Snapshot source can not be used with useForSnapshot",path:["sources"]}).refine(s=>s.filter(e=>e.role==="snapshot").every(e=>!e.hotMode),{message:"Snapshot source can not be used with hotMode"}),extensions:Dd.default({hub:[],plugins:[]}),recording:Ld.default({enabled:!1}),interface:Ud.default({streamingMode:"auto",streamingSource:"auto",aspectRatio:"16:9"}),detectionZones:jd.default([]),detectionSettings:qd.default({motion:{timeout:60},object:{confidence:.7}}),frameWorkerSettings:Bd.default({decoder:"rust",fps:10,resolution:"320x180"})}).strict().transform(s=>{const e=s.sources.flatMap(t=>t.urls);return s.isCloud||Fd(e)?{...s,isCloud:!0}:s}),xt({disabled:Rs().optional(),type:zd.optional(),name:We().trim().min(1,"Camera name is required").optional(),isCloud:Rs().optional(),snapshotTTL:Fn().min(30,"Minimum cache time must be 30").optional(),info:Vd.partial().optional(),sources:Zv.array().refine(s=>s.some(e=>e.role==="high-resolution"||e.role==="mid-resolution"||e.role==="low-resolution"),{path:["sources[].role"],message:'One of the roles "high-resolution", "mid-resolution" or "low-resolution" is required'}).refine(s=>s.filter(e=>e.useForSnapshot).length<=1,{message:"Only one source can be used for snapshot",path:["sources"]}).refine(s=>s.filter(e=>e.role==="snapshot").every(e=>!e.useForSnapshot),{message:"Snapshot source can not be used with useForSnapshot",path:["sources"]}).refine(s=>s.filter(e=>e.role==="snapshot").every(e=>!e.hotMode),{message:"Snapshot source can not be used with hotMode"}).optional(),extensions:Dd.partial().optional(),interface:Ud.partial().optional(),recording:Ld.partial().optional(),detectionZones:jd.optional(),detectionSettings:qd.partial().optional(),frameWorkerSettings:Bd.partial().optional()}).strict().transform(s=>{if(s.sources){const e=s.sources.flatMap(t=>t.urls);if(s.isCloud===!0||Fd(e))return{...s,isCloud:!0}}return s}),xt({url:We().trim()}).strict(),/^((@[\w-.]*)\/)?(camera-ui-[\w-]*)$/);var Hd,Qd;(function(s){s.READY="ready",s.STARTING="starting",s.STARTED="started",s.STOPPING="stopping",s.STOPPED="stopped",s.ERROR="error",s.UNKNOWN="unknown",s.DISABLED="disabled"})(Hd||(Hd={})),function(s){s.START="start",s.STOP="stop"}(Qd||(Qd={}));const Kd=["image/jpeg","image/png"],Zd=2097152,Gd=["video/mp4","video/quicktime"],Wd=10485760,Jd=["audio/mpeg","audio/wav","audio/ogg"],Yd=2097152,Xv=(xt({pluginname:We().trim().refine(s=>Yv.test(s),"Not a valid plugin name"),pluginversion:We().trim().optional().default("latest")}).strict(),xt({actionId:We(),payload:Di()}).strict(),Dc(Di(),Di()),xt({upload:qn().refine(s=>(e=>e.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=Zd:s.size<=Zd,"Max file size is 2 MB").refine(s=>(e=>e.mimetype!==void 0)(s)?Kd.includes(s.mimetype):Kd.includes(s.type),".jpeg and .png files are accepted"),metadata:qn().transform(s=>JSON.parse(s.value)),config:qn().transform(s=>JSON.parse(s.value))}),xt({upload:qn().refine(s=>(e=>e.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=Yd:s.size<=Yd,"Max file size is 2 MB").refine(s=>(e=>e.mimetype!==void 0)(s)?Jd.includes(s.mimetype):Jd.includes(s.type),".mp3, .wav and .ogg files are accepted"),metadata:qn().transform(s=>JSON.parse(s.value)),config:qn().transform(s=>JSON.parse(s.value))}),xt({upload:qn().refine(s=>(e=>e.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=Wd:s.size<=Wd,"Max file size is 5 MB").refine(s=>(e=>e.mimetype!==void 0)(s)?Gd.includes(s.mimetype):Gd.includes(s.type),".mp4 files are accepted"),config:qn().transform(s=>JSON.parse(s.value))}),Dc(We(),Di()),xt({key:We()}).strict(),xt({key:We(),payload:Di()}).strict(),xt({version:We().trim().optional().default("latest")}).strict(),xt({mode:Ns([xe("disabled"),xe("port-forward"),xe("router-forward"),xe("cloudflare"),xe("custom-domain")]).default("disabled"),cloudflare:xt({tunnelToken:We().trim(),customDomain:We().trim(),tunnelUrl:We().trim(),tunnelCredentials:xt({username:We().trim(),password:We().trim()}).partial()}).partial().strict(),customDomain:xt({url:We().trim().optional()}).partial().strict()}).strict()),Xd=(xt({serverAddresses:We().trim().ip().array().default([]),remoteAccess:Xv}).strict(),["image/jpeg","image/jpg","image/png"]),eh=5242880,Lm=xt({index:Fn(),cameraId:We()}),jm=Ns([xe(1),xe(4),xe(6),xe(7),xe(9),xe(10),xe(12),xe(13),xe(15),xe(16),xe(20),xe(26)]),e_=Ns([xe("dnd"),xe("view")]),t_=xt({_id:We().default(mn()).transform(()=>mn()),name:We().trim().min(1,"Layout name is required"),viewSize:jm,cameras:Lm.array(),type:e_}),s_=(xt({name:We().trim().min(1,"Layout name is required"),viewSize:jm,cameras:Lm.array()}).partial().optional(),xt({views:t_.array()})),n_=xt({_id:We().default(mn()).transform(()=>mn()),cameraId:We(),points:Sl}),r_=(xt({cameraId:We(),points:Sl}).partial().optional(),xt({shortcuts:n_.array()})),th=xt({camview:s_,cameras:Dc(We().trim(),r_)});xt({_id:We().default(mn()).transform(()=>mn()),username:We().trim().min(1,"Username is required"),password:We().trim().min(10,"Password must be at least 10 characters long").regex(/[A-Z]/,"Password must contain at least one uppercase letter").regex(/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,`Password must contain at least one special character (!@#$%^&*()_+-=[]{};:'"\\|,.<>/?)`).max(32,"Password cannot be more than 32 characters"),passwordConfirm:We().trim().min(1,"Please confirm your password"),role:Ns([xe("admin"),xe("user")]),sessionTimer:Fn().min(3600,"Session timer must not be less than 3600 seconds (1h)").max(86400,"Session timer must not be greater than 86400 seconds (24h)").default(14400),rememberMe:Rs().default(!1),singleSession:Rs().default(!1),firstLogin:Rs().default(!0),preferences:th.default({camview:{views:[]},cameras:{}})}).strict().refine(s=>s.password===s.passwordConfirm,{path:["passwordConfirm"],message:"Passwords do not match"}),xt({username:We().trim().min(1,"Username is required"),password:We().trim().min(1,"Password is required"),rememberMe:Rs().default(!1)}).strict(),xt({username:We().trim().min(1,"Username is required").optional(),password:We().trim().min(10,"Password must be at least 10 characters long").regex(/[A-Z]/,"Password must contain at least one uppercase letter").regex(/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,`Password must contain at least one special character (!@#$%^&*()_+-=[]{};:'"\\|,.<>/?)`).max(32,"Password cannot be more than 32 characters").optional(),passwordConfirm:We().trim().optional(),role:Ns([xe("admin"),xe("user")]).optional(),sessionTimer:Fn().min(3600,"Session timer must not be less than 3600 seconds (1h)").max(86400,"Session timer must not be greater than 86400 seconds (24h)").optional(),upload:zv(qn().refine(s=>(e=>e.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=eh:s.size<=eh,"Max file size is 5MB.").refine(s=>(e=>e.mimetype!==void 0)(s)?Xd.includes(s.mimetype):Xd.includes(s.type),".jpg, .jpeg, .png files are accepted.")),rememberMe:Rs().optional(),singleSession:Rs().optional(),firstLogin:Rs().optional(),preferences:th.partial().optional()}).strict().refine(s=>s.password===s.passwordConfirm,{path:["passwordConfirm"],message:"Passwords do not match"});var sh;(function(s){s.READY="ready",s.RESTARTING="restarting",s.STARTING="starting",s.STARTED="started",s.STOPPED="stopped",s.ERROR="error",s.UNKNOWN="unknown"})(sh||(sh={}));class i_ extends EventTarget{constructor(t,n,r,i,o){super();p(this,"cameraDevice");p(this,"logger");p(this,"config");p(this,"token");p(this,"initialOptions");p(this,"videoPlayer");p(this,"CONFIG",{WEBRTC:{RECONNECT_TIMER:1e3,TIMEOUT_TIMER:1e4,ICE_SERVERS:[{urls:"stun:stun.l.google.com:19302"}]},QUALITY:{METRICS_INTERVAL:5e3,METRICS_WINDOW:6e4,STABILITY_PERIOD:3e4,PACKET_LOSS_THRESHOLD:.05,FRAME_DROP_THRESHOLD:.1,QUALITY_CHANGE_COOLDOWN:5e3},MEDIA:{BUFFER_SIZE:2097152,DEFAULT_CODECS:["avc1.640029","avc1.64002A","avc1.640033","hvc1.1.6.L153.B0","mp4a.40.2","mp4a.40.5","flac","opus"]}});p(this,"ws");p(this,"pc",null);p(this,"micTransceiver",null);p(this,"mediaSource",null);p(this,"sourceBuffer",null);p(this,"buf",new Uint8Array(0));p(this,"bufLen",0);p(this,"codecList");p(this,"streamProbe");p(this,"metrics",[]);p(this,"metricsInterval");p(this,"lastQualityChange",0);p(this,"isMonitoring",!1);p(this,"wsReconnectTimer");p(this,"wsReconnectTimeout");p(this,"webrtcConnectTimeout");p(this,"webrtcReconnectTimeout");p(this,"firstFrameReceived",!1);p(this,"animationFrameId");p(this,"userRequestedMode");p(this,"internalMode");p(this,"activeMode");p(this,"isAutoSwitchingInProgress",!1);p(this,"_closed",!0);p(this,"_hasBackchannel",!1);p(this,"_hasAudio",!0);p(this,"_hasVideo",!0);p(this,"_finishLoading",!1);p(this,"userRequestedRole");p(this,"effectiveRole");p(this,"_streamingSource");this.cameraDevice=t,this.config=n,this.token=r,this.logger=i,this.initialOptions={...o},this.videoPlayer=o.videoElement,this.CONFIG.WEBRTC.RECONNECT_TIMER=o.webrtcConnectTimeout??this.CONFIG.WEBRTC.RECONNECT_TIMER,this.userRequestedMode=o.mode,this.userRequestedRole=o.role,this.internalMode=o.mode,this.activeMode=o.mode==="auto"?"webrtc":o.mode,this.setActiveMode(this.activeMode,!0),this.effectiveRole=o.role==="auto"?"low-resolution":o.role,this.buf=new Uint8Array(this.CONFIG.MEDIA.BUFFER_SIZE),this.codecList=this.createCodecsList()}get streamingSource(){return this._streamingSource}get closed(){return this._closed}get hasBackchannel(){return this._hasBackchannel}get hasAudio(){return this._hasAudio}get hasVideo(){return this._hasVideo}get finishLoading(){return this._finishLoading}get mode(){return this.userRequestedMode}get currentMode(){return this.activeMode}get currentResolution(){return this.effectiveRole}get logPrefix(){const t=new Date,n=t.toLocaleTimeString()+"."+t.getMilliseconds().toString().padStart(3,"0");return this.userRequestedMode==="auto"?`[${n}] [${this.cameraDevice.name}] [auto→${this.activeMode}]`:`[${n}] [${this.cameraDevice.name}] [${this.activeMode}]`}get wsUrl(){const t=new URL(this.config.endpoint),n=t.port!=="",r=t.protocol==="https:"?"wss:":"ws:",i=n?t.port:t.protocol==="https:"?"443":"80";return`${r}//${t.hostname}:${i}/go2rtc?src=${this.createWsSourceName()}&token=${this.token}`}async start(t){console.log(this.logPrefix,"Starting session..."),this.reset(),this._closed=!1,this.videoPlayer.addEventListener("loadeddata",this.onLoadedData.bind(this)),t&&(this.userRequestedMode=t,this.internalMode=t,this.setActiveMode(t==="auto"?"webrtc":t)),await this.initializeStreamingSource(),this.streamProbe=await this.probeStream(),this.streamProbe&&this.userRequestedMode==="auto"&&this.selectInitialMode(),this.connectWs()}close(){this._closed||(console.log(this.logPrefix,"Closing session..."),this._closed=!0,this.stopQualityMonitoring(),this.reset(),this.disconnectWs())}async restart(t,n=!1){console.log(this.logPrefix,"Restarting session..."),n?this.dispatchEvent(new Event("onSourceChange")):this.dispatchEvent(new Event("reconnect")),this.close(),await new Promise(r=>setTimeout(r,1e3)),await this.start(t)}async toggleMicrophone(t){if(this.micTransceiver)try{await this.micTransceiver.sender.replaceTrack(t)}catch(n){if(!this.micTransceiver||!t)return;console.error(this.logPrefix,"Microphone error:",n)}}async toggleRole(t){var n;if(this.userRequestedRole!==t)if(console.log(this.logPrefix,`Switching source resolution to "${t}"...`),this.userRequestedRole=t,t==="auto")await this.initializeAdaptiveStreaming();else{this.effectiveRole=t;const{source:r}=this.getSourceForResolution(t);((n=this._streamingSource)==null?void 0:n._id)!==r._id&&(this._streamingSource=r,await this.restart(void 0,!0))}}async toggleMode(t){this.userRequestedMode!==t&&(console.log(this.logPrefix,`Switching transport mode to "${t}"...`),this.userRequestedMode=t,this.internalMode=t,this.setActiveMode(t==="auto"?"webrtc":t),await this.restart())}async initializeStreamingSource(){if(this.userRequestedRole==="auto")await this.initializeAdaptiveStreaming();else{const{source:t}=this.getSourceForResolution(this.userRequestedRole);if(this._streamingSource=t,this.userRequestedMode==="auto"&&t){const n=await this.probeStream();n&&(this.checkWebRTCCompatibility(n).compatible||(console.log(`${this.logPrefix} Source not compatible with WebRTC, starting with MSE...`),this.setActiveMode("mse")))}}}checkWebRTCCompatibility(t){const n=t.audio.filter(u=>u.direction==="sendonly"),r=t.video.filter(u=>u.direction==="sendonly"),i=n.some(u=>this.isWebRtcCompatibleAudioCodec(u.codec)),o=r.some(u=>this.isWebRtcCompatibleVideoCodec(u.codec)),a=n.length>0,l=r.length>0;return{compatible:(!a||i)&&(!l||o),audioCompatible:i,videoCompatible:o}}async initializeAdaptiveStreaming(){this.userRequestedRole==="auto"&&(await this.setStreamResolution(this.effectiveRole,void 0,!0),this.startQualityMonitoring())}selectInitialMode(){if(!this.streamProbe||this.userRequestedMode!=="auto")return;const t=this.checkWebRTCCompatibility(this.streamProbe);if(t.compatible)this.internalMode="auto";else{if(t.videoCompatible){if(!t.audioCompatible){const n=this.streamProbe.audio.filter(r=>r.direction==="sendonly");console.warn(this.logPrefix,`Incompatible audio codec(s): "${n.map(r=>r.codec).join(", ")}" - Using MSE directly`)}}else{const n=this.streamProbe.video.filter(r=>r.direction==="sendonly");console.warn(this.logPrefix,`Incompatible video codec(s): "${n.map(r=>r.codec).join(", ")}" - Using MSE directly`)}this.setActiveMode("mse")}}connectWs(){this.ws=new WebSocket(this.wsUrl),this.ws.binaryType="arraybuffer",this.ws.addEventListener("open",this.onWsOpen.bind(this)),this.ws.addEventListener("close",this.onWsClose.bind(this)),this.ws.addEventListener("message",this.onWsMessage.bind(this))}disconnectWs(){this.ws&&(this.ws.removeEventListener("open",this.onWsOpen.bind(this)),this.ws.removeEventListener("close",this.onWsClose.bind(this)),this.ws.removeEventListener("message",this.onWsMessage.bind(this)),this.ws.close(),this.ws=void 0)}reset(){var t;(t=this.videoPlayer)==null||t.removeEventListener("loadeddata",this.onLoadedData.bind(this)),clearTimeout(this.wsReconnectTimeout),clearTimeout(this.webrtcConnectTimeout),clearTimeout(this.webrtcReconnectTimeout),this._finishLoading=!1,this.firstFrameReceived=!1,this.isAutoSwitchingInProgress=!1,this.micTransceiver&&(this.micTransceiver.sender.replaceTrack(null).catch(()=>{}),this.micTransceiver=null),this.pc&&(this.pc.getTransceivers().forEach(n=>{var r,i;return(i=(r=n.sender)==null?void 0:r.track)==null?void 0:i.stop()}),this.pc.close(),this.pc=null),this.videoPlayer.srcObject=null,this.videoPlayer.src="",this.videoPlayer.poster="",this.animationFrameId!==void 0&&("cancelVideoFrameCallback"in this.videoPlayer?this.videoPlayer.cancelVideoFrameCallback(this.animationFrameId):cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}onWsOpen(){switch(this.internalMode){case"webrtc":case"webrtc/tcp":console.log(this.logPrefix,"Requesting WebRTC session..."),this.requestWebrtc();break;case"mse":console.log(this.logPrefix,"Requesting MSE session..."),this.requestMse();break;case"auto":console.log(this.logPrefix,"Requesting auto session (both WebRTC and MSE)..."),this.requestAuto();break;default:console.error(this.logPrefix,"Unknown mode!"),this.dispatchEvent(new ErrorEvent("error",{message:"Unknown mode!"}))}}onWsClose(){this._closed||this.wsReconnectTimer===void 0||(clearTimeout(this.wsReconnectTimeout),this.wsReconnectTimeout=setTimeout(()=>{this.restart()},this.wsReconnectTimer))}onWsMessage(t){if(typeof t.data=="string"){const n=JSON.parse(t.data);if(n.type)switch(n.type){case"mse":this.onMseData(n);break;case"webrtc/candidate":case"webrtc/answer":this.onWebrtcData(n);break;case"error":this.handleStreamError(n)}}else this.onMseBuffer(t.data),this.onFirstFrame()}handleStreamError(t){this.isAutoSwitchingInProgress||this.internalMode==="auto"||(this.dispatchEvent(new ErrorEvent("error",{error:t,message:t.value})),this.close())}async requestWebrtc(t){t||this.reset(),t&&this.mediaSource||(this.webrtcConnectTimeout=setTimeout(()=>{if(console.log(this.logPrefix,"WebRTC connection timeout"),this.pc&&this.pc.connectionState!=="connected")if(this.pc.close(),this.pc=null,this.userRequestedMode==="auto"){if(this.mediaSource&&this.sourceBuffer&&this._finishLoading)return console.log(this.logPrefix,"WebRTC timed out but MSE is working - staying with MSE"),this.setActiveMode("mse"),void(this.isAutoSwitchingInProgress=!1);this.setActiveMode("mse"),this.requestMse()}else this.userRequestedMode==="webrtc"?this.restart("mse"):this.restart()},this.CONFIG.WEBRTC.TIMEOUT_TIMER)),this.pc=new RTCPeerConnection({bundlePolicy:"max-bundle",iceServers:[{urls:"stun:stun.l.google.com:19302"}],sdpSemantics:"unified-plan"}),this.pc.onicecandidate=r=>{var o,a;if(this.activeMode==="webrtc/tcp"&&((o=r.candidate)==null?void 0:o.protocol)==="udp")return;const i=((a=r.candidate)==null?void 0:a.toJSON().candidate)??"";i&&this.send({type:"webrtc/candidate",value:i})},this.pc.onconnectionstatechange=async()=>{var r,i,o,a;if(console.log(this.logPrefix,"onconnectionstatechange:",(r=this.pc)==null?void 0:r.connectionState),((i=this.pc)==null?void 0:i.connectionState)==="connected"){clearTimeout(this.webrtcConnectTimeout);const l=new MediaStream(this.pc.getTransceivers().filter(d=>d.currentDirection==="recvonly").map(d=>d.receiver.track)),u=l.getVideoTracks().length>0;this.userRequestedMode==="auto"?this.mediaSource&&this.sourceBuffer&&this._finishLoading&&this.activeMode==="mse"?u?(console.log(this.logPrefix,"WebRTC connected successfully - switching from MSE to WebRTC"),await this.switchToWebRTC(l)):console.log(this.logPrefix,"WebRTC connected but no video - staying with MSE"):u?(this.setActiveMode("webrtc"),this.videoPlayer.srcObject=l,this.onFinishLoading(void 0,"webrtc"),this.onFirstFrameWebrtc(l)):console.log(this.logPrefix,"WebRTC connected but no video - waiting for MSE"):(this.videoPlayer.srcObject=l,this.onFinishLoading(void 0,"webrtc"),this.onFirstFrameWebrtc(l))}else((o=this.pc)==null?void 0:o.connectionState)!=="failed"&&((a=this.pc)==null?void 0:a.connectionState)!=="disconnected"||(clearTimeout(this.webrtcConnectTimeout),clearTimeout(this.webrtcReconnectTimeout),this.webrtcReconnectTimeout=setTimeout(()=>{var l,u,d;if(((l=this.pc)==null?void 0:l.connectionState)==="failed"||((u=this.pc)==null?void 0:u.connectionState)==="disconnected"){if(this.userRequestedMode==="auto"&&this.mediaSource&&this.sourceBuffer&&this._finishLoading)return console.log(this.logPrefix,"WebRTC failed but MSE is working - staying with MSE"),this.setActiveMode("mse"),(d=this.pc)==null||d.close(),this.pc=null,void(this.isAutoSwitchingInProgress=!1);this.userRequestedMode==="auto"?(console.warn(this.logPrefix,"WebRTC failed - switching to MSE"),this.setActiveMode("mse"),this.restart()):this.activeMode==="webrtc"?(console.warn(this.logPrefix,"WebRTC failed - switching to MSE fallback"),this.restart("mse")):this.restart()}},this.CONFIG.WEBRTC.RECONNECT_TIMER))},this.pc.oniceconnectionstatechange=()=>{var r;console.log(this.logPrefix,"iceconnectionstatechange",(r=this.pc)==null?void 0:r.iceConnectionState)},this.pc.onicecandidateerror=r=>{console.log(this.logPrefix,"onicecandidateerror",r)},this.pc.onsignalingstatechange=()=>{var r;console.log(this.logPrefix,"onsignalingstatechange",(r=this.pc)==null?void 0:r.signalingState)},this.pc.onicegatheringstatechange=()=>{var r;console.log(this.logPrefix,"onicegatheringstatechange",(r=this.pc)==null?void 0:r.iceGatheringState)},this.pc.onnegotiationneeded=r=>{console.log(this.logPrefix,"onnegotiationneeded",r)},this.pc.addTransceiver("video",{direction:"recvonly"}),this.pc.addTransceiver("audio",{direction:"recvonly"}),this.micTransceiver=this.pc.addTransceiver("audio",{direction:"sendonly"});const n=await this.pc.createOffer();await this.pc.setLocalDescription(n),console.log(this.logPrefix,"Offer:",{type:n.type,sdp:n.sdp}),n.sdp?this.send({type:"webrtc/offer",value:n.sdp}):this.dispatchEvent(new ErrorEvent("error",{message:"Failed to create offer"}))}async onWebrtcData(t){var n,r;try{switch(t.type){case"webrtc/candidate":if(!t.value||this.activeMode==="webrtc/tcp"&&t.value.indexOf(" udp ")>0)return;await((n=this.pc)==null?void 0:n.addIceCandidate({candidate:t.value,sdpMid:"0"}));break;case"webrtc/answer":console.log(this.logPrefix,"Answer:",{type:"answer",sdp:t.value}),await((r=this.pc)==null?void 0:r.setRemoteDescription({type:"answer",sdp:t.value}))}}catch(i){this.dispatchEvent(new ErrorEvent("error",{error:i,message:i.message}))}}requestMse(){this.userRequestedMode==="auto"&&this.pc||this.reset();const t="ManagedMediaSource"in window;let n;if(t)n=window.ManagedMediaSource;else{if(!("MediaSource"in window))return void this.dispatchEvent(new ErrorEvent("error",{message:"MediaSource not supported"}));n=window.MediaSource}this.mediaSource=new n,this.mediaSource.addEventListener("sourceopen",()=>{t||URL.revokeObjectURL(this.videoPlayer.src),this.send({type:"mse",value:this.parseCodecs(n.isTypeSupported.bind(this))})},{once:!0}),t?(this.videoPlayer.disableRemotePlayback=!0,this.videoPlayer.srcObject=this.mediaSource):(this.videoPlayer.src=URL.createObjectURL(this.mediaSource),this.videoPlayer.srcObject=null),this.play()}onMseData(t){if(this.mediaSource&&this.mediaSource.readyState==="open")if(this.userRequestedMode==="auto"&&this.pc&&this.pc.connectionState!=="failed"||this.setActiveMode("mse"),this.bufLen=0,this.buf=new Uint8Array(this.CONFIG.MEDIA.BUFFER_SIZE),this.sourceBuffer=this.mediaSource.addSourceBuffer(t.value),this.sourceBuffer.mode="segments",this.sourceBuffer.addEventListener("updateend",()=>{var n,r;if(this.sourceBuffer&&!this.sourceBuffer.updating&&this.bufLen>0)try{const i=this.buf.slice(0,this.bufLen);this.sourceBuffer.appendBuffer(i),this.bufLen=0}catch{}if(this.sourceBuffer&&!this.sourceBuffer.updating&&((n=this.sourceBuffer.buffered)!=null&&n.length)){const i=this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1),o=i-5,a=this.sourceBuffer.buffered.start(0);o>a&&(this.sourceBuffer.remove(a,o),(r=this.mediaSource)==null||r.setLiveSeekableRange(o,i)),this.videoPlayer.currentTime<o&&(this.videoPlayer.currentTime=o);const l=i-this.videoPlayer.currentTime;this.videoPlayer.playbackRate=l>.1?l:.1}}),this.userRequestedMode==="auto"){if(this.pc&&this.pc.connectionState==="connected")return void console.log(this.logPrefix,"MSE ready but WebRTC already connected");console.log(this.logPrefix,"MSE ready - using while waiting for WebRTC"),this.setActiveMode("mse"),this.onFinishLoading(void 0,"mse")}else this.onFinishLoading(void 0,"mse")}async onMseBuffer(t){var n,r,i;if(((n=this.mediaSource)==null?void 0:n.readyState)!=="closed")if((r=this.sourceBuffer)!=null&&r.updating||this.bufLen>0){const o=new Uint8Array(t);this.buf.set(o,this.bufLen),this.bufLen+=o.byteLength}else try{(i=this.sourceBuffer)==null||i.appendBuffer(t)}catch{}else this._closed||this.internalMode==="auto"||(this.dispatchEvent(new ErrorEvent("error",{message:"MediaSource closed"})),this.userRequestedMode==="auto"?(this.setActiveMode("webrtc"),this.restart()):this.restart("webrtc"))}requestAuto(){if(this.isAutoSwitchingInProgress=!0,this.streamProbe&&!this.checkWebRTCCompatibility(this.streamProbe).compatible)return console.log(this.logPrefix,"Stream not compatible with WebRTC, using MSE only"),void this.requestMse();console.log(this.logPrefix,"Starting both WebRTC and MSE transports in parallel"),this.requestMse(),this.requestWebrtc(!0)}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(t))}async switchToWebRTC(t){this.setActiveMode("webrtc"),this.videoPlayer.srcObject=t,this.play(),this.onFinishLoading(!0,"webrtc"),this.onFirstFrameWebrtc(t),this.mediaSource&&(this.mediaSource.readyState==="open"&&this.mediaSource.endOfStream(),this.mediaSource=null,this.sourceBuffer=null),this.disconnectWs()}async play(){try{await this.videoPlayer.play()}catch(t){if(!this.videoPlayer.muted)return this.videoPlayer.muted=!0,this.play();this.logger.warn(this.cameraDevice.name,t)}}startQualityMonitoring(){this.isMonitoring||this.userRequestedRole!=="auto"||(clearInterval(this.metricsInterval),this.isMonitoring=!0,this.metrics=[],this.metricsInterval=setInterval(async()=>{if(this._closed)return void this.stopQualityMonitoring();const t=await this.gatherMetrics();if(t){this.metrics.push(t);const n=Date.now()-this.CONFIG.QUALITY.METRICS_WINDOW;this.metrics=this.metrics.filter(r=>r.timestamp>n),this.userRequestedRole==="auto"&&this.analyzeAndAdaptQuality()}},this.CONFIG.QUALITY.METRICS_INTERVAL))}stopQualityMonitoring(){clearInterval(this.metricsInterval),this.metricsInterval=void 0,this.isMonitoring=!1,this.metrics=[]}async gatherMetrics(){if(this._closed)return null;if(this.pc&&this.activeMode==="webrtc")try{const t=await this.pc.getStats(),n={packetsLost:0,packetsReceived:0,framesDropped:0,framesReceived:0,timestamp:Date.now()};for(const[,r]of t.entries())r.type==="inbound-rtp"&&r.kind==="video"?(n.packetsLost=r.packetsLost,n.packetsReceived=r.packetsReceived):r.type==="media-source"&&r.kind==="video"&&(n.framesDropped=r.framesDropped,n.framesReceived=r.framesReceived);return n}catch(t){return console.warn(`${this.logPrefix} Error gathering WebRTC metrics:`,t),null}else if(this.activeMode==="mse"&&this.videoPlayer)try{const t=this.videoPlayer.getVideoPlaybackQuality();return{packetsLost:0,packetsReceived:0,framesDropped:t.droppedVideoFrames,framesReceived:t.totalVideoFrames,timestamp:Date.now()}}catch(t){return console.warn(`${this.logPrefix} Error gathering MSE metrics:`,t),null}return null}analyzeQualityMetrics(){if(Date.now()-this.lastQualityChange<this.CONFIG.QUALITY.QUALITY_CHANGE_COOLDOWN)return{packetLossRate:0,frameDropRate:0,isStable:!0};if(this.metrics.length<2)return{packetLossRate:0,frameDropRate:0,isStable:!0};const t=this.metrics[this.metrics.length-1],n=this.metrics[0],r=(t.packetsLost-n.packetsLost)/Math.max(t.packetsReceived-n.packetsReceived,1),i=(t.framesDropped-n.framesDropped)/Math.max(t.framesReceived-n.framesReceived,1);return{packetLossRate:r,frameDropRate:i,isStable:r<this.CONFIG.QUALITY.PACKET_LOSS_THRESHOLD&&i<this.CONFIG.QUALITY.FRAME_DROP_THRESHOLD}}async analyzeAndAdaptQuality(){if(this.userRequestedRole!=="auto"||this._closed)return;const t=this.analyzeQualityMetrics(),n=Date.now()-this.lastQualityChange;if(t.isStable){if(t.isStable&&n>this.CONFIG.QUALITY.STABILITY_PERIOD){const r=t.packetLossRate,i=t.frameDropRate;r<this.CONFIG.QUALITY.PACKET_LOSS_THRESHOLD/2&&i<this.CONFIG.QUALITY.FRAME_DROP_THRESHOLD/2&&(this.effectiveRole==="low-resolution"?await this.setStreamResolution("mid-resolution","upgrade"):this.effectiveRole==="mid-resolution"&&await this.setStreamResolution("high-resolution","upgrade"))}}else this.effectiveRole==="high-resolution"?await this.setStreamResolution("mid-resolution","downgrade"):this.effectiveRole==="mid-resolution"&&await this.setStreamResolution("low-resolution","downgrade")}async setStreamResolution(t,n,r){var l;if(this._closed)return;const{source:i,sourceResolution:o,isRequestedSource:a}=this.getSourceForResolution(t);if(i._id!==((l=this._streamingSource)==null?void 0:l._id)){if(n==="upgrade"?console.log(`${this.logPrefix} Quality stable, upgrading to "${t}" source...`):n==="downgrade"&&console.log(`${this.logPrefix} Quality unstable, downgrading to "${t}" source...`),console.log(a||r?`${this.logPrefix} Switching to "${o}" source...`:`${this.logPrefix} Source "${t}" not available, switching to next best available: ${o}`),this.effectiveRole=o,this._streamingSource=i,this.lastQualityChange=Date.now(),!r&&this.userRequestedMode==="auto"){const u=await this.probeStream();if(u){const d=this.checkWebRTCCompatibility(u);if(this.activeMode.startsWith("webrtc")&&!d.compatible)return console.log(`${this.logPrefix} New source not compatible with WebRTC, switching to MSE...`),this.isAutoSwitchingInProgress=!0,void await this.restart("mse",!0);if(this.activeMode==="mse"&&d.compatible)return console.log(`${this.logPrefix} New source compatible with WebRTC, switching back...`),this.isAutoSwitchingInProgress=!0,void await this.restart("webrtc",!0)}}r||await this.restart(this.activeMode,!0)}else this.effectiveRole=r||a?o:t}getSourceForResolution(t){const n=["high-resolution","mid-resolution","low-resolution"],r=this.cameraDevice.sources.map(u=>u.role).filter(u=>n.includes(u)),i=r.reduce((u,d)=>n.indexOf(u)>n.indexOf(d)?u:d,"low-resolution"),o=this.cameraDevice.sources.find(u=>u.role===t),a=this.cameraDevice.sources.find(u=>u.role===i),l=o??a??this.cameraDevice.streamSource;if(this._streamingSource){if(this._streamingSource.role===t)return{source:this._streamingSource,sourceResolution:t,isRequestedSource:!0};const u=n.indexOf(t);if(u===-1)return{source:l,sourceResolution:l.role,isRequestedSource:!0};for(let d=u;d<n.length;d++){const h=n[d],v=`${h.split("-")[0]}ResolutionSource`,f=this.cameraDevice[v];if(f)return f._id===this._streamingSource._id?{source:this._streamingSource,sourceResolution:this._streamingSource.role,isRequestedSource:this._streamingSource.role===t}:{source:f,sourceResolution:h,isRequestedSource:h===t}}}return{source:l,sourceResolution:l.role,isRequestedSource:!1}}onFirstFrameWebrtc(t){const n=this.isAutoSwitchingInProgress,r=t.getVideoTracks()[0];if((!this.firstFrameReceived||n)&&r)if("requestVideoFrameCallback"in this.videoPlayer)this.animationFrameId=this.videoPlayer.requestVideoFrameCallback(()=>{this.onFirstFrame(n)});else{const i=()=>{this.videoPlayer.readyState>=2&&this.videoPlayer.videoWidth>0?this.onFirstFrame(n):this.animationFrameId=requestAnimationFrame(i)};this.animationFrameId=requestAnimationFrame(i)}}setActiveMode(t,n){(this.activeMode!==t||n)&&(this.activeMode=t,this.dispatchEvent(new Event("onModeChange")))}onFirstFrame(t){this.firstFrameReceived&&!t||(console.log(this.logPrefix,"First frame received"),this.firstFrameReceived=!0,this.dispatchEvent(new Event("onFirstFrame")))}onLoadedData(){console.log(this.logPrefix,"Loaded data"),this.dispatchEvent(new Event("onLoadedData"))}onFinishLoading(t,n){this._finishLoading&&!t||(this._finishLoading=!0,this.dispatchEvent(new Event("onFinishLoading"))),n&&n!=="auto"&&this.setActiveMode(n)}createCodecsList(){const t=[...this.CONFIG.MEDIA.DEFAULT_CODECS],n=typeof window>"u"?null:/Version\/(\d+).+Safari/.exec(navigator.userAgent);if(n!=null&&n[1]){const r=n[1]<"13"?"mp4a.40.2":n[1]<"14"?"flac":"opus";t.splice(t.indexOf(r))}return t}parseCodecs(t){return this.codecList.filter(n=>["video","audio","microphone"].includes(n.indexOf("vc1")>0?"video":"audio")).filter(n=>t(`video/mp4; codecs="${n}"`)).join()}async probeStream(){try{if(!this.streamingSource)throw new Error("No streaming source set");const t=await this.cameraDevice.probeStream(this.streamingSource._id,{video:!0,audio:["pcma","opus"],microphone:!0});return console.log(this.logPrefix,"Stream probe:",t),t&&(this._hasBackchannel=t.audio.some(n=>n.direction==="recvonly"),this._hasAudio=t.audio.filter(n=>n.direction==="sendonly").length>0,this._hasVideo=t.video.filter(n=>n.direction==="sendonly").length>0,this.dispatchEvent(new Event("onStreamProbe"))),t}catch(t){return void console.error("Error probing stream",t)}}isWebRtcCompatibleAudioCodec(t){return["opus","G722","PCMU","PCMA"].includes(t)}isWebRtcCompatibleVideoCodec(t){return["H264","VP8","VP9"].includes(t)||t==="H265"&&this.isWebRTCH265Supported()}createWsSourceName(){if(!this.cameraDevice||!this.streamingSource)throw new Error("Camera device or streaming source not set");return`${this.cameraDevice.name.replace(/ /g,"_").toLowerCase()}_${this.streamingSource.name.replace(/ /g,"_").toLowerCase()}`}isWebRTCH265Supported(){var t;try{console.log(this.logPrefix,"Checking for H.265 support...",RTCRtpSender==null?void 0:RTCRtpSender.getCapabilities("video"));const n=(t=RTCRtpSender==null?void 0:RTCRtpSender.getCapabilities("video"))==null?void 0:t.codecs;return!!n&&n.some(r=>r.mimeType.toLowerCase().includes("h265")||r.mimeType.toLowerCase().includes("hevc"))}catch{return!1}}}class o_ extends fv{constructor(t,n,r,i,o){super(i,o);p(this,"proxy");p(this,"config");p(this,"token");p(this,"subscription");p(this,"namespaces");p(this,"cameraInterfaces");this.proxy=t,this.config=n,this.token=r,this.namespaces=io.cameraNamespaces(this.id),this.cameraInterfaces=new Xo(this.proxy,this.capabilities,this.id)}get sources(){return JSON.parse(JSON.stringify(this.cameraSubject.getValue().sources)).map(t=>({...t,snapshot:async n=>this.snapshot(t._id,n),probeStream:async(n,r=!1)=>this.probeStream(t._id,n,r)}))}async init(){var t;(t=this.subscription)==null||t.unsubscribe(),this.subscription=this.proxy.subscribe(this.namespaces.cameraSubject,this.onEventMessage.bind(this)),await this.refreshStates()}async close(){await this.cleanup()}createWebRTCSession(t){return new i_(this,this.config,this.token,this.logger,t)}async refreshStates(){const t=await this.cameraControllerProxy(),n=await t.refreshStates();super.updateCamera(n.camera),super.updateCameraState(n.cameraState),super.updateFrameWorkerState(n.frameWorkerState),super.updateCapabilities(n.capabilities);for(const[r,i]of Object.entries(n.states))super.updateStateInternal(r,i,!0)}async cleanup(){var t;this.removeAllListeners(),this.unsubscribe(),(t=this.subscription)==null||t.unsubscribe(),this.subscription=void 0,await this.disconnectRpc()}async snapshot(t,n){const r=this.snapshotCache.get(t);if(!n&&r)return r;const i=await this.cameraControllerProxy(),o=await i.snapshot(t,n);return o&&o.byteLength>0?(this.snapshotCache.set(t,o),o):void 0}async probeStream(t,n,r=!1){return(await this.cameraControllerProxy()).probeStream(t,n,r)}async onEventMessage(t){const n=t.data;if("type"in n)switch(n.type){case"removed":this.cleanup();break;case"updated":super.updateCamera(n.data);break;case"cameraState":super.updateCameraState(n.data);break;case"frameWorkerState":super.updateFrameWorkerState(n.data);break;case"capabilities":super.updateCapabilities(n.data)}else{const r=n.stateName,i=n.data.newEvent;super.updateStateInternal(r,i,!0)}}async cameraControllerProxy(){return await this.proxy.createRPCProxy(this.namespaces.cameraControllerRpc,{timeout:1e4})}async disconnectRpc(){await this.proxy.disconnectRPCConnection(this.namespaces.cameraControllerRpc),await this.cameraInterfaces.disconnect()}}class a_{constructor(e){p(this,"proxy");p(this,"namespaces");p(this,"rpcConnections",new Map);this.proxy=e,this.namespaces=io.coreManagerNamespaces()}async connectToPlugin(e){const t=await this.coreManagerProxy(),n=await t.getPlugin(e);if(n){const r=io.pluginNamespaces(n.id);try{let i;return this.rpcConnections.has(r.pluginChildRpc)?(i=this.rpcConnections.get(r.pluginChildRpc),await i.connect()):(i=await this.proxy.createRPCConnection(r.pluginChildRpc),this.rpcConnections.set(r.pluginChildRpc,i)),i.createProxy()}catch{return}}}async getFFmpegPath(){return await(await this.coreManagerProxy()).getFFmpegPath()}async getHwaccelInfo(e){return await(await this.coreManagerProxy()).getHwaccelInfo(e)}async getServerAddresses(){return await(await this.coreManagerProxy()).getServerAddresses()}async getIceServers(){return await(await this.coreManagerProxy()).getIceServers()}async coreManagerProxy(){return await this.proxy.createRPCProxy(this.namespaces.coreManagerRpc)}}class c_{constructor(e,t,n,r){p(this,"proxy");p(this,"config");p(this,"token");p(this,"logger");p(this,"namespaces");this.proxy=e,this.config=t,this.token=n,this.logger=r,this.namespaces=io.deviceManagerNamespaces()}async getCamera(e){const t=await this.deviceManagerProxy(),n=await t.getCamera(e,"@camera.ui/client");if(n){const r=new o_(this.proxy,this.config,this.token,n,this.logger);return await r.init(),r}}async deviceManagerProxy(){return await this.proxy.createRPCProxy(this.namespaces.deviceManagerRpc)}}class l_{constructor(e){p(this,"interceptor");p(this,"config");p(this,"logger");p(this,"proxy");p(this,"token");p(this,"_api");this.config=e,this.logger=e.logger??{...console,attention:console.warn,success:console.log},this.interceptor=new p1(e.endpoint)}get api(){return this._api}async connect(){if(this._api)return this._api;this.token=await this.login(),this.proxy=new Zg({endpoints:this.getNatsEndpoint(this.token),tls:void 0,auth:{user:"secret",password:"secret"},metadata:{id:"@camera-ui/browser-client",name:"@camera-ui/browser-client"},connect:{waitForServer:!0},reconnect:{enabled:!0},metrics:!1,bundledConnection:!0}),await this.proxy.start();const e=new a_(this.proxy),t=new c_(this.proxy,this.config,this.token,this.logger);return this._api={coreManager:e,deviceManager:t},this._api}async disconnect(){var e;if(await((e=this.proxy)==null?void 0:e.stop()),this.token)try{await this.interceptor.post("/auth/logout",void 0,{headers:{Authorization:`Bearer ${this.token}`}})}catch{}this._api=void 0,this.token=void 0}async updateCredentials(e){this.config={...this.config,...e}}async login(){if(this.config.username&&this.config.password)try{return(await(await this.interceptor.post("/auth/login",{username:this.config.username,password:this.config.password})).json()).access_token}catch(e){throw new Error(`Invalid credentials: ${e.message}`)}else{if(this.config.skipCheck)return this.config.token;try{return await this.interceptor.get("/auth/check",{headers:{Authorization:`Bearer ${this.config.token}`}}),this.config.token}catch(e){throw new Error(`Invalid token: ${e.message}`)}}}getNatsEndpoint(e){const t=new URL(this.config.endpoint),n=t.port!=="",r=t.protocol==="https:"?"wss:":"ws:",i=n?t.port:t.protocol==="https:"?"443":"80";return[`${r}//${t.hostname}:${i}/proxy?token=${e}`]}}const Ie=rf.create({baseURL:`${location.origin}/api`});Ie.interceptors.request.use(s=>{const{accessToken:e}=Fs();return e&&(s.headers.Authorization=`Bearer ${e}`),s},s=>Promise.reject(s));Ie.interceptors.response.use(s=>s,async s=>{var n,r,i,o,a,l;const e=s.config,t=((r=(n=s.response)==null?void 0:n.data)==null?void 0:r.message)==="Token expired"||((a=(o=(i=s.response)==null?void 0:i.data)==null?void 0:o.message)==null?void 0:a.name)==="TokenExpiredError";if(((l=s.response)==null?void 0:l.status)===401&&t&&!e._retry){e._retry=!0;try{const{refreshToken:u}=Fs();return await u(),Ie(e)}catch(u){return Promise.reject(u)}}return Promise.reject(s)});const Cn=()=>({add:e=>{E0.emit("add",e)}}),qm=async s=>(await Ie.get("/auth/check",{signal:s})).data,u_=async({parameter:s,signal:e})=>(await Ie.get("/auth/tokens",{params:s,signal:e})).data,Dm=async({loginInformation:s})=>(await Ie.post("/auth/login",s)).data,Bm=async()=>(await Ie.post("/auth/logout")).data,d_=async({id:s,access_token:e})=>(await Ie.post(`/auth/logout/${s}`,null,{params:{token:e}})).data,zm=async({refresh_token:s})=>(await Ie.post("/auth/refresh",{refresh_token:s})).data;class n9{constructor(){p(this,"_queryClient",Ci());p(this,"authStore",Fs());p(this,"t",js().t);p(this,"toast",Cn());p(this,"queryActivator",ae([{name:"checkQuery",enabled:!0},{name:"listQuery",enabled:!0}]))}get queryClient(){return this._queryClient}checkQuery(){var e;return Bt({queryKey:["auth",(e=this.authStore.user)==null?void 0:e.username],queryFn:({signal:t})=>qm(t),enabled:()=>this.queryActivator.value.some(t=>t.name==="checkQuery"&&t.enabled)})}listQuery(e){return Bt({queryKey:["tokensList",e],queryFn:({signal:t})=>u_({parameter:c(e),signal:t}),placeholderData:t=>t,enabled:()=>this.queryActivator.value.some(t=>t.name==="listQuery"&&t.enabled)})}loginQuery(){return ut({mutationFn:Dm})}logoutQuery(){return ut({mutationFn:Bm})}logoutTokenQuery(){return ut({mutationFn:d_,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["tokensList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.user_logged_out"),life:3e3})}})}refreshQuery(){return ut({mutationFn:zm})}toggleQueryActivator(e,t){const n=this.queryActivator.value.find(r=>r.name===e);n&&(n.enabled=t)}}const h_=async({userData:s})=>(await Ie.post("/users",s)).data,m_=async({username:s,signal:e})=>(await Ie.get(`/users/${s}`,{signal:e})).data,p_=async({parameter:s,signal:e})=>(await Ie.get("/users",{params:s,signal:e})).data,ya=async({username:s,userData:e})=>(await Ie.patch(`/users/${s}`,e)).data,f_=async({username:s})=>(await Ie.delete(`/users/${s}`)).data,g_=async()=>(await Ie.delete("/users")).data,v_=async({username:s,cameraname:e,shortcutData:t})=>(await Ie.post(`/users/${s}/preferences/cameras/${e}/shortcuts`,t)).data,__=async({username:s,cameraname:e,shortcutid:t,signal:n})=>(await Ie.get(`/users/${s}/preferences/cameras/${e}/shortcuts/${t}`,{signal:n})).data,y_=async({username:s,cameraname:e,signal:t})=>(await Ie.get(`/users/${s}/preferences/cameras/${e}/shortcuts`,{signal:t})).data,b_=async({username:s,cameraname:e,shortcutid:t,shortcutData:n})=>(await Ie.patch(`/users/${s}/preferences/cameras/${e}/shortcuts/${t}`,n)).data,w_=async({username:s,cameraname:e,shortcutid:t})=>(await Ie.delete(`/users/${s}/preferences/cameras/${e}/shortcuts/${t}`)).data,x_=async({username:s,cameraname:e})=>(await Ie.delete(`/users/${s}/preferences/cameras/${e}/shortcuts`)).data,S_=async({username:s,viewData:e})=>(await Ie.post(`/users/${s}/preferences/camview/views`,e)).data,C_=async({username:s,viewid:e,signal:t})=>(await Ie.get(`/users/${s}/preferences/camview/views/${e}`,{signal:t})).data,k_=async({username:s,parameter:e,signal:t})=>(await Ie.get(`/users/${s}/preferences/camview/views`,{params:e,signal:t})).data,nh=async({username:s,viewid:e,viewData:t})=>(await Ie.patch(`/users/${s}/preferences/camview/views/${e}`,t)).data,E_=async({username:s,viewid:e})=>(await Ie.delete(`/users/${s}/preferences/camview/views/${e}`)).data,A_=async({username:s})=>(await Ie.delete(`/users/${s}/preferences/camview/views`)).data;class M_{constructor(){p(this,"_queryClient",Ci());p(this,"t",js().t);p(this,"toast",Cn());p(this,"queryActivator",ae([{name:"getUserQuery",enabled:!0},{name:"getUsersQuery",enabled:!0},{name:"getShortcutQuery",enabled:!0},{name:"getShortcutsQuery",enabled:!0},{name:"getViewQuery",enabled:!0},{name:"getViewsQuery",enabled:!0}]))}get queryClient(){return this._queryClient}createUserQuery(){return ut({mutationFn:h_,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["usersList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.user_added"),life:3e3})}})}getUserQuery(e){return Bt({queryKey:["users",e],queryFn:({signal:t})=>m_({username:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getUserQuery"&&t.enabled)})}getUsersQuery(e){return Bt({queryKey:["usersList",e],queryFn:({signal:t})=>p_({parameter:c(e),signal:t}),placeholderData:t=>t,enabled:()=>this.queryActivator.value.some(t=>t.name==="getUsersQuery"&&t.enabled)})}patchUserQuery(){return ut({mutationFn:async({username:e,userData:t,formData:n})=>{await ya({username:e,userData:t}),n&&await ya({username:e,userData:n})},onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["users",t.username]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.user_updated"),life:3e3})}})}removeUserQuery(){return ut({mutationFn:f_,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["usersList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.user_removed"),life:3e3})}})}removeUsersQuery(){return ut({mutationFn:g_,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["usersList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.users_removed"),life:3e3})}})}createShortcutQuery(){return ut({mutationFn:v_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["shortcutsList",t.username]})}})}getShortcutQuery(e,t,n){return Bt({queryKey:["shortcutsList",e,t,n],queryFn:({signal:r})=>__({username:c(e),cameraname:c(t),shortcutid:c(n),signal:r}),enabled:()=>this.queryActivator.value.some(r=>r.name==="getShortcutQuery"&&r.enabled)})}getShortcutsQuery(e,t){return Bt({queryKey:["shortcutsList",e,t],queryFn:({signal:n})=>y_({username:c(e),cameraname:c(t),signal:n}),placeholderData:n=>n,enabled:()=>this.queryActivator.value.some(n=>n.name==="getShortcutsQuery"&&n.enabled)})}patchShortcutQuery(){return ut({mutationFn:b_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["shortcutsList",t.username]})},onError:e=>{console.log(e),this.toast.add({severity:"error",summary:this.t("components.toast.title_error"),detail:this.t("components.toast.error_see_console"),life:3e3})}})}removeShortcutQuery(){return ut({mutationFn:w_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["shortcutsList",t.username]})},onError:e=>{console.log(e),this.toast.add({severity:"error",summary:this.t("components.toast.title_error"),detail:this.t("components.toast.error_see_console"),life:3e3})}})}removeShortcutsQuery(){return ut({mutationFn:x_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["shortcutsList",t.username]})},onError:e=>{console.log(e),this.toast.add({severity:"error",summary:this.t("components.toast.title_error"),detail:this.t("components.toast.error_see_console"),life:3e3})}})}createViewQuery(){return ut({mutationFn:S_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["viewsList",t.username]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.view_added"),life:3e3})}})}getViewQuery(e,t){return Bt({queryKey:["viewsList",e],queryFn:({signal:n})=>C_({username:c(e),viewid:c(t),signal:n}),enabled:()=>this.queryActivator.value.some(n=>n.name==="getUserQuery"&&n.enabled)})}getViewsQuery(e,t){return Bt({queryKey:["viewsList",e,t],queryFn:({signal:n})=>k_({username:c(e),parameter:c(t),signal:n}),placeholderData:n=>n,enabled:()=>this.queryActivator.value.some(n=>n.name==="getViewsQuery"&&n.enabled)})}patchViewQuery(){return ut({mutationFn:nh,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["viewsList",t.username]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.view_updated"),life:3e3})}})}patchViewQuerySilent(){return ut({mutationFn:nh,onSuccess:async(e,t)=>{await this._queryClient.invalidateQueries({queryKey:["viewsList",t.username]})}})}removeViewQuery(){return ut({mutationFn:E_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["viewsList",t.username]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.view_removed"),life:3e3})}})}removeViewsQuery(){return ut({mutationFn:A_,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["viewsList",t.username]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.views_removed"),life:3e3})}})}toggleQueryActivator(e,t){const n=this.queryActivator.value.find(r=>r.name===e);n&&(n.enabled=t)}}function Cl(s,e,t,n=[]){if(Array.isArray(s)&&Array.isArray(e)){const r=t?t(s,e,void 0,s,e,n):void 0;return r!==void 0?r:[...s,...e]}if(typeof e!="object")return s;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=s[r],o=e[r];n.push({key:r,sourceObject:s,targetObject:e}),Array.isArray(i)&&Array.isArray(o)?s[r]=[...i,...o]:typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null?s[r]=Cl({...i},o,t,n):s[r]=o,n.pop()}return s}function $_(s){return new Promise(e=>setTimeout(e,s))}function ta(s,e,t=!1){if(s===e)return!0;if((s===void 0||e===void 0||s===null||e===null)&&(s||e))return!1;const n=s==null?void 0:s.constructor.name,r=e==null?void 0:e.constructor.name;if(n!==r)return!1;if(n==="Array"&&r==="Array"){if(s.length!==e.length)return!1;if(t){const i=[...e];return s.every(o=>{const a=i.findIndex(l=>ta(o,l,t));return a===-1?!1:(i.splice(a,1),!0)})}else{let i=!0;for(let o=0;o<s.length;o++)if(!ta(s[o],e[o],t)){i=!1;break}return i}}if(n==="Object"&&r==="Object"){let i=!0;const o=Object.keys(s),a=Object.keys(e);if(o.length!==a.length)return!1;for(let l=0;l<o.length;l++)if(s[o[l]]&&e[o[l]]){if(s[o[l]]===e[o[l]])continue;if(s[o[l]]&&(s[o[l]].constructor.name==="Array"||s[o[l]].constructor.name==="Object")){if(i=ta(s[o[l]],e[o[l]],t),!i)break}else if(s[o[l]]!==e[o[l]]){i=!1;break}}else if(s[o[l]]&&!e[o[l]]||!s[o[l]]&&e[o[l]]){i=!1;break}return i}return s===e}const Fs=Mi("auth",()=>{const s=$i(),e=qr(),t=el("user",null,{serializer:{read:K=>K?JSON.parse(K):null,write:K=>JSON.stringify(K)}}),n=Ls(null),r=Ls(null),i=Ls(null),o=ae(!1),a=ae(!1),l=ae(!1),u=ne(()=>t.value!==null),d=ne(()=>r.value!==null&&!i.value&&!o.value),h=ne(()=>{var K;return((K=t.value)==null?void 0:K.access_token)??null});Ge(s,()=>{a.value=!1},{deep:!0}),Ge(t,K=>{!a.value&&!ta(K,t.value)&&k()},{deep:!0});const v=async K=>{if(r.value)return r.value;o.value=!0,i.value=null;try{n.value||(n.value=new l_({endpoint:window.origin,token:K,skipCheck:!0,logger:{...console,attention:console.warn,success:console.log}}));const N=await n.value.connect();return r.value=N,N}catch(N){const E=N instanceof Error?N:new Error(String(N));throw i.value=E,E}finally{o.value=!1}},f=async()=>{n.value&&(await n.value.disconnect(),n.value=null,r.value=null,i.value=null,o.value=!1)},b=async K=>{if(!u.value){l.value=!1,a.value=!0;try{const N=await Dm({loginInformation:K});t.value=N,await v(N.access_token),e.push("/cameras")}finally{a.value=!1}}},k=async()=>{!u.value||l.value||(l.value=!0,a.value=!0,await f(),L(),await Bm(),t.value=null,e.push("/"),window.location.reload(),a.value=!1)},z=async()=>{if(!t.value)return;const K=await zm({refresh_token:t.value.refresh_token});n.value&&await n.value.updateCredentials({endpoint:window.origin,token:K.access_token}),t.value.access_token=K.access_token},L=async()=>{try{if("serviceWorker"in navigator){const N=await(await navigator.serviceWorker.ready).pushManager.getSubscription();N&&await N.unsubscribe()}}catch{}},se=async(K,N)=>{t.value&&(K&&await ya({username:t.value.username,userData:K}),N&&await ya({username:t.value.username,userData:N}))};return u.value&&h.value&&v(h.value).catch(K=>{console.error("Error initializing API:",K)}),{isLoggedIn:u,isApiReady:d,loginLoading:a,api:r,apiError:i,accessToken:h,user:t,login:b,logout:k,refreshToken:z,updateUser:se,initializeApi:v,disconnectApi:f}}),Bi=(s,e="ddd., D. MMM. YY")=>(typeof s=="number"&&(s=new Date(s)),H0(s,e).value),Fr=(s="logo-512.png")=>{var r,i,o,a;if(s.startsWith("data:")||s.startsWith("blob:")||s.startsWith("http:")||s.startsWith("https:"))return s;if(s.startsWith(location.origin))return location.origin+s;if((s==="ERROR"||s==="")&&(s="logo-256.png"),s==="avatar"){const l=Fs(),u=(r=l.user)==null?void 0:r.avatar,d=(i=l.user)==null?void 0:i._id,h=(o=l.user)==null?void 0:o.access_token;if(h&&u)return`${location.origin}/api/files/${d}_avatar.jpeg?token=${h}`;s="logo-256.png"}if(s.includes("avatar")){const u=(a=Fs().user)==null?void 0:a.access_token;if(u)return`${location.origin}/api/files/${s}?token=${u}`;s="logo-256.png"}const t=`/src/assets/images/${s}`,n=Object.assign({"/src/assets/css/extras.css":Tf,"/src/assets/css/inter.css":Pf,"/src/assets/css/main.css":Rf,"/src/assets/css/markdown.css":If,"/src/assets/css/tailwind.css":$f,"/src/assets/css/theme.css":Of,"/src/assets/css/transitions.css":Nf,"/src/assets/css/utils.css":Ff,"/src/assets/images/error-256.png":e1,"/src/assets/images/logo-256.png":s1,"/src/assets/images/logo-512.png":r1,"/src/assets/images/logo.png":o1,"/src/assets/images/logo.svg":c1,"/src/assets/images/logo_animated.svg":u1,"/src/assets/images/logo_loading_circle.svg":h1});return n[t]?n[t].default:""},r9=async s=>new Promise(e=>{var n;s.preventDefault();const t=(n=s.target)==null?void 0:n.files;if(t){const r=t[0],i=new FileReader;r?(i.onload=o=>{var l,u;const a=(l=o.target)!=null&&l.result?(u=o.target)==null?void 0:u.result:void 0;e(a)},i.readAsDataURL(r)):e(void 0)}}),T_=(s=10)=>{const e=()=>Math.floor(Math.random()*25+10).toString(36);return Array.from({length:s},e).join("")};function xi(s,e=new WeakMap){if(typeof s!="object"||s===null)return s;if(e.has(s))return e.get(s);if(Array.isArray(s)){const n=[];return e.set(s,n),s.forEach((r,i)=>{n[i]=xi(r,e)}),n}const t={};return e.set(s,t),Object.keys(s).forEach(n=>{t[n]=xi(s[n],e)}),t}const Um=s=>{switch(s){case"error":return"error";case"info":return"info";case"success":return"success";case"warning":return"warn";default:return"info"}},i9=s=>{s||(s=new Date);const e=new Date(s);return e.setMilliseconds(0),e},o9=s=>{s||(s=new Date);const e=new Date(s);return e.setSeconds(0,0),e.setMilliseconds(0),e},P_=["src","alt"],R_=["src","alt","width","height"],I_=At({__name:"CuiImage",props:{src:{},alt:{default:"Image"},width:{default:"100%"},height:{default:"100%"},aspectRatio:{},cover:{type:Boolean},imageContainerClass:{},imageContainerStyle:{}},setup(s){const e=s,{src:t,width:n,height:r,aspectRatio:i,cover:o,imageContainerClass:a,imageContainerStyle:l}=Jt(e),u=ae(!1),d=ae(!1),h=ne(()=>d.value?Fr():Fr(t.value)),v=()=>{u.value=!0,d.value=!1},f=()=>{u.value=!1,d.value=!0},b=k=>k?typeof k=="number"?`${k}px`:k:"auto";return(k,z)=>{const L=Lr,se=A0;return m(),j(se,{alt:k.alt,class:"w-full h-full flex items-center justify-center"},{image:$(()=>[!c(u)&&!c(d)?(m(),j(L,{key:0,"stroke-width":"6",class:"w-[50%] h-[50%] max-w-[30px] max-h-[30px]"})):ce("",!0),Tt(g("div",{class:at(c(a)),style:ot(c(l))},[c(d)?ce("",!0):Tt((m(),A("img",{key:0,src:c(h),alt:k.alt,style:ot({width:b(c(n)),height:b(c(r)),aspectRatio:c(i),objectFit:c(o)?"cover":"contain"}),onLoad:v,onError:f},null,44,P_)),[[Tr,c(u)]]),c(d)?(m(),A("img",{key:1,src:c(h),alt:k.alt,width:c(n),height:c(r),class:"contain",style:ot({aspectRatio:c(i)})},null,12,R_)):ce("",!0)],6),[[Tr,c(u)||c(d)]])]),_:1},8,["alt"])}}}),Ia=qs(I_,[["__scopeId","data-v-6696d637"]]),O_=At({__name:"CuiAvatar",props:{src:{},showBorder:{type:Boolean,default:!0},size:{default:22}},setup(s){const e=s,{showBorder:t,size:n,src:r}=Jt(e);return(i,o)=>{const a=Ia;return m(),A("div",{class:at(["bg-neutral-900 overflow-hidden rounded-full",{"avatar-border":c(t)}])},[y(a,{src:c(r),height:c(n),width:c(n),cover:"","image-container-class":"w-full h-full"},null,8,["src","height","width"])],2)}}}),Vm=qs(O_,[["__scopeId","data-v-82af9e29"]]),N_={class:"flex items-center justify-center absolute left-3 h-full"},F_={key:0,class:"flex items-center shrink-0"},L_={key:1,class:"shrink-0"},j_={key:2,class:"shrink-0"},q_={key:0,class:"overflow-hidden flex-1 ml-10"},D_={class:"flex flex-row items-center justify-between"},B_={class:"text-start flex-1"},z_={key:0,class:"text-xs text-muted"},U_=At({__name:"CuiNavItem",props:{label:{},to:{},expanded:{type:Boolean},description:{},icon:{},iconSize:{default:24},iconClass:{},labelClass:{},activeIcon:{},avatar:{},avatarSize:{default:24},showLogout:{type:Boolean},darkMode:{type:Boolean},buttonProps:{},showTooltip:{type:Boolean},fallbackActivePath:{}},setup(s){const e=Fs(),t=$i(),n=s,{icon:r,iconSize:i,iconClass:o,activeIcon:a,avatarSize:l,avatar:u,labelClass:d,label:h,description:v,expanded:f,to:b,showLogout:k,darkMode:z,buttonProps:L,showTooltip:se,fallbackActivePath:K}=Jt(n),N=ne(()=>t.path===b.value||b.value!=="/"&&(t.path.startsWith(b.value+"/")||t.path.startsWith((K.value??b.value)+"/"))),E=()=>{e.logout()};return(O,U)=>{const S=Vm,M=Gh,B=ys,W=Ei("RouterLink"),I=jr;return m(),j(W,{to:c(b)},{default:$(({isActive:w})=>[Tt((m(),j(B,et({text:"",severity:"secondary",class:["cui-button navitem-button w-full h-full flex items-center relative",{"dark-mode":c(z),"!text-primary navitem-active":(w||c(N))&&!c(u),"hover:!text-color active:!text-color focus:!text-color":!w&&!c(N)}],fluid:""},c(L)),{default:$(()=>[g("div",N_,[c(u)?(m(),A("div",F_,[y(S,{src:c(Fr)(c(u)),size:c(l),style:ot({width:`${c(l)}px`,height:`${c(l)}px`})},null,8,["src","size","style"])])):c(r)&&!w&&!c(N)||!c(a)?(m(),A("div",L_,[y(c(r),{class:at(c(o)),style:ot({width:`${c(i)}px`,height:`${c(i)}px`})},null,8,["class","style"])])):c(a)&&(w||c(N))?(m(),A("div",j_,[y(c(a),{style:ot({width:`${c(i)}px`,height:`${c(i)}px`})},null,8,["style"])])):ce("",!0)]),y(Et,{name:"fade"},{default:$(()=>[c(f)?(m(),A("div",q_,[g("div",D_,[g("div",B_,[g("div",{class:at(["text-sm max-w-100 truncate font-semibold",[c(d),{"text-color font-bold":c(u)}]])},me(c(h)),3),c(v)?(m(),A("div",z_,me(c(v)),1)):ce("",!0)]),c(k)?(m(),j(B,{key:0,text:"",rounded:"",class:"dark-mode cui-icon-md",onClick:E},{icon:$(()=>[y(M,{width:"100%",height:"100%"})]),_:1})):ce("",!0)])])):ce("",!0)]),_:1})]),_:2},1040,["class"])),[[I,{value:c(se)&&!c(f)?c(h):"",pt:{root:{class:"dark-mode"}}}]])]),_:1},8,["to"])}}}),Hm=qs(U_,[["__scopeId","data-v-13c365f7"]]),V_="modulepreload",H_=function(s){return"/"+s},rh={},vs=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let o=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=o(t.map(u=>{if(u=H_(u),u in rh)return;rh[u]=!0;const d=u.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":V_,d||(v.as="script"),v.crossOrigin="",v.href=u,l&&v.setAttribute("nonce",l),document.head.appendChild(v),d)return new Promise((f,b)=>{v.addEventListener("load",f),v.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},Q_={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function K_(s,e){return m(),A("svg",Q_,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m4 10l-.707.707L2.586 10l.707-.707zm17 8a1 1 0 1 1-2 0zM8.293 15.707l-5-5l1.414-1.414l5 5zm-5-6.414l5-5l1.414 1.414l-5 5zM4 9h10v2H4zm17 7v2h-2v-2zm-7-7a7 7 0 0 1 7 7h-2a5 5 0 0 0-5-5z"},null,-1)]))}const Z_=pe({name:"lets-icons-back",render:K_}),G_={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function W_(s,e){return m(),A("svg",G_,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8z"},null,-1)]))}const J_=pe({name:"mdi-home",render:W_}),Y_={class:"relative flex items-center justify-center draggable-region"},X_={class:"container mx-auto px-6 relative z-10"},ey={class:"text-center"},ty={class:"text-8xl font-bold mb-4 relative flex items-center justify-center"},sy={class:"relative w-24 h-24 mx-2 group"},ny={class:"relative z-1 scale-150 non-draggable-region"},ry={class:"text-muted max-w-md mx-auto mb-8"},iy={class:"flex items-center justify-center gap-4"},oy={class:"text-white"},ay=At({__name:"404",setup(s){return(e,t)=>{const n=J_,r=ys,i=Ei("RouterLink"),o=Z_;return m(),A("div",Y_,[g("div",X_,[g("div",ey,[g("h1",ty,[t[1]||(t[1]=g("span",null,"4",-1)),g("div",sy,[g("div",ny,[y(c(Aa),{src:c(Fr)("logo_animated.svg"),width:"95px",height:"80px",title:"camera.ui","aria-label":"camera.ui",class:"transform transition-transform duration-300 group-hover:scale-110"},null,8,["src"])])]),t[2]||(t[2]=g("span",null,"4",-1))]),t[3]||(t[3]=g("h2",{class:"text-3xl font-semibold mb-4"},"Oops!",-1)),g("p",ry,me(e.$t("views.404.error_message")),1),g("div",iy,[y(i,{to:"/"},{default:$(()=>[y(r,{class:"cui-button flex items-center gap-2 non-draggable-region"},{default:$(()=>[y(n,{class:"text-white"}),g("span",oy,me(e.$t("components.form.button.home")),1)]),_:1})]),_:1}),y(r,{severity:"secondary",class:"cui-button flex items-center gap-2 non-draggable-region",onClick:t[0]||(t[0]=a=>e.$router.back())},{default:$(()=>[y(o,{class:"text-muted"}),g("span",null,me(e.$t("components.form.button.back")),1)]),_:1})])])])])}}}),cy={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ly(s,e){return m(),A("svg",cy,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19.27 5.33C17.94 4.71 16.5 4.26 15 4a.1.1 0 0 0-.07.03c-.18.33-.39.76-.53 1.09a16.1 16.1 0 0 0-4.8 0c-.14-.34-.35-.76-.54-1.09c-.01-.02-.04-.03-.07-.03c-1.5.26-2.93.71-4.27 1.33c-.01 0-.02.01-.03.02c-2.72 4.07-3.47 8.03-3.1 11.95c0 .02.01.04.03.05c1.8 1.32 3.53 2.12 5.24 2.65c.03.01.06 0 .07-.02c.4-.55.76-1.13 1.07-1.74c.02-.04 0-.08-.04-.09c-.57-.22-1.11-.48-1.64-.78c-.04-.02-.04-.08-.01-.11c.11-.08.22-.17.33-.25c.02-.02.05-.02.07-.01c3.44 1.57 7.15 1.57 10.55 0c.02-.01.05-.01.07.01c.11.09.22.17.33.26c.04.03.04.09-.01.11c-.52.31-1.07.56-1.64.78c-.04.01-.05.06-.04.09c.32.61.68 1.19 1.07 1.74c.03.01.06.02.09.01c1.72-.53 3.45-1.33 5.25-2.65c.02-.01.03-.03.03-.05c.44-4.53-.73-8.46-3.1-11.95c-.01-.01-.02-.02-.04-.02M8.52 14.91c-1.03 0-1.89-.95-1.89-2.12s.84-2.12 1.89-2.12c1.06 0 1.9.96 1.89 2.12c0 1.17-.84 2.12-1.89 2.12m6.97 0c-1.03 0-1.89-.95-1.89-2.12s.84-2.12 1.89-2.12c1.06 0 1.9.96 1.89 2.12c0 1.17-.83 2.12-1.89 2.12"},null,-1)]))}const uy=pe({name:"ic-baseline-discord",render:ly}),dy={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function hy(s,e){return m(),A("svg",dy,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2"},null,-1)]))}const my=pe({name:"mdi-github",render:hy});function Qm(s){const e=["kasa://","nest:","ring:","tapo://"];return s.some(t=>e.some(n=>t.startsWith(n)))}const Km=bt({enabled:xs().default(!1)}).strict(),py=Os([we("animal"),we("person"),we("vehicle"),we("other"),we("motion")]),kl=df([xn(),xn()]),El=bt({name:Ke().trim().min(1,"Zone Name is required"),points:kl.array().min(3,"At least 3 points are required"),type:Os([we("intersect"),we("contain")]),filter:Os([we("include"),we("exclude")]),classes:py.array(),isPrivacyMask:xs(),color:Ke().trim().regex(/^#([0-9A-Fa-f]{3}){1,2}$/,"Must be a valid hex color (e.g. #FF0000 or #F00)").default("#df2a4c")}).array(),Zm=bt({motion:bt({timeout:xn().min(10,"Minimum 10 seconds")}),object:bt({confidence:xn().min(.3,"Minimum 0.3").max(1,"Maximum 1")})}),Al=Os([we("high-resolution"),we("mid-resolution"),we("low-resolution"),we("snapshot")]),fy=Os([we("high-resolution"),we("mid-resolution"),we("low-resolution"),we("auto")]),Gm=Os([we("bubble://"),we("cui://"),we("doorbird://"),we("dvrip://"),we("echo:"),we("eseecloud://"),we("exec:"),we("expr:"),we("ffmpeg:"),we("flussonic://"),we("gopro://"),we("hass:"),we("homekit://"),we("http://"),we("https://"),we("httpx://"),we("isapi://"),we("ivideon:"),we("kasa://"),we("nest:"),we("onvif://"),we("ring:"),we("roborock://"),we("rtmp://"),we("rtsp://"),we("rtspx://"),we("tapo://"),we("tcp://"),we("tuya://"),we("webrtc:"),we("webtorrent:")]),gy=Gm.options.map(s=>s.value),vy=new RegExp(`^(${gy.join("|")})`),Wm=Ke().refine(s=>{if(!vy.test(s))return!1;try{return new URL(s),!0}catch{return!1}},{message:"Invalid URL format or unsupported protocol"}),_y=bt({_id:Ke().default(hn()).transform(()=>hn()),name:Ke().trim().min(1,"Camera Source Name is required").transform(s=>s.replace(/ /g,"_").toLowerCase()),role:Al,useForSnapshot:xs().default(!1),hotMode:xs().default(!1),urls:Wm.array().min(1,"At least one valid URL is required")}).strict(),yy=bt({_id:Ke().default(hn()).transform(()=>hn()),name:Ke().trim().min(1,"Camera Source Name is required").transform(s=>s.replace(/ /g,"_").toLowerCase()),role:Al,useForSnapshot:xs().default(!1),hotMode:xs().default(!1),urls:Wm.array().min(1,"At least one valid URL is required")}).strict(),Cr=bt({id:Ke(),name:Ke().trim()}),Jm=bt({hub:Cr.array().optional(),cameraController:Cr.optional(),motionDetection:Cr.optional(),audioDetection:Cr.optional(),objectDetection:Cr.optional(),ptz:Cr.optional(),plugins:Cr.array()}).strict(),by=Os([we("auto"),we("mse"),we("webrtc"),we("webrtc/tcp")]),wy=Os([we("16:9"),we("8:3"),we("4:3"),we("auto")]),Ym=bt({decoder:Os([we("pillow"),we("wasm"),we("rust"),we("gpu")]),fps:xn().min(0,"Minimum 0 fps").max(30,"Maximum 30 fps"),resolution:Os([we("640x480"),we("640x360"),we("320x240"),we("320x180")])}),Xm=Os([we("camera"),we("doorbell")]),ep=bt({streamingMode:by,streamingSource:fy,aspectRatio:wy}),tp=bt({model:Ke().trim().optional(),manufacturer:Ke().trim().optional(),hardware:Ke().trim().optional(),serialNumber:Ke().trim().optional(),firmwareVersion:Ke().trim().optional(),supportUrl:Ke().trim().optional()}),xy=bt({name:Ke().trim().min(1,"Camera name is required"),url:Ke().trim().url().min(1,"Camera URL is required"),type:Os([we("Google"),we("Ring"),we("HomeKit"),we("Onvif"),we("Hass"),we("GoPro"),we("Roborock"),we("FFmpeg"),we("DVRip"),we("Webtorrent")]),username:Ke().trim().optional(),email:Ke().trim().email().optional(),password:Ke().trim().optional(),pin:Ke().trim().length(8,{message:"PIN must be 8 characters long"}).optional(),clientId:Ke().trim().optional(),clientSecret:Ke().trim().optional(),refreshToken:Ke().trim().optional(),projectId:Ke().trim().optional()}).strict().refine(s=>s.type==="HomeKit"?!!s.pin:!0,{message:"PIN is required for HomeKit cameras",path:["pin"]}).refine(s=>s.type==="Google"?!!s.clientId:!0,{message:"Client ID is required for Google cameras",path:["clientId"]}).refine(s=>s.type==="Google"?!!s.clientSecret:!0,{message:"Client Secret is required for Google cameras",path:["clientSecret"]}).refine(s=>s.type==="Google"?!!s.projectId:!0,{message:"Project ID is required for Google cameras",path:["projectId"]}).refine(s=>s.type==="Google"?!!s.refreshToken:!0,{message:"Refresh Token is required for Google cameras",path:["refreshToken"]}).refine(s=>s.type==="Ring"?!!s.email:!0,{message:"Email is required",path:["email"]}).refine(s=>s.type==="Roborock"?!!s.username:!0,{message:"Username is required",path:["username"]}).refine(s=>s.type==="Roborock"||s.type==="Ring"?!!s.password:!0,{message:"Password is required",path:["password"]}),Sy=bt({id:Ke(),name:Ke()}).strict(),Cy=bt({_id:Ke().default(hn()).transform(()=>hn()),nativeId:Ke().trim().optional(),pluginInfo:Sy.optional(),disabled:xs().default(!1),name:Ke().trim().min(1,"Camera name is required"),type:Xm.default("camera"),isCloud:xs().default(!1),snapshotTTL:xn().min(30,"Minimum cache time must be 30").default(600),info:tp.default({model:"IP Camera",manufacturer:"camera.ui",hardware:"Camera",serialNumber:"Unknown",firmwareVersion:"Unknown",supportUrl:"Unknown"}),sources:_y.array().refine(s=>s.some(e=>e.role==="high-resolution"||e.role==="mid-resolution"||e.role==="low-resolution"),{path:["sources[].role"],message:'One of the roles "high-resolution", "mid-resolution" or "low-resolution" is required'}).refine(s=>s.filter(t=>t.useForSnapshot).length<=1,{message:"Only one source can be used for snapshot",path:["sources"]}).refine(s=>s.filter(t=>t.role==="snapshot").every(t=>!t.useForSnapshot),{message:"Snapshot source can not be used with useForSnapshot",path:["sources"]}).refine(s=>s.filter(t=>t.role==="snapshot").every(t=>!t.hotMode),{message:"Snapshot source can not be used with hotMode"}),extensions:Jm.default({hub:[],plugins:[]}),recording:Km.default({enabled:!1}),interface:ep.default({streamingMode:"auto",streamingSource:"auto",aspectRatio:"16:9"}),detectionZones:El.default([]),detectionSettings:Zm.default({motion:{timeout:60},object:{confidence:.7}}),frameWorkerSettings:Ym.default({decoder:"rust",fps:10,resolution:"320x180"})}).strict().transform(s=>{const e=s.sources.flatMap(t=>t.urls);return s.isCloud||Qm(e)?{...s,isCloud:!0}:s}),ky=bt({disabled:xs().optional(),type:Xm.optional(),name:Ke().trim().min(1,"Camera name is required").optional(),isCloud:xs().optional(),snapshotTTL:xn().min(30,"Minimum cache time must be 30").optional(),info:tp.partial().optional(),sources:yy.array().refine(s=>s.some(e=>e.role==="high-resolution"||e.role==="mid-resolution"||e.role==="low-resolution"),{path:["sources[].role"],message:'One of the roles "high-resolution", "mid-resolution" or "low-resolution" is required'}).refine(s=>s.filter(t=>t.useForSnapshot).length<=1,{message:"Only one source can be used for snapshot",path:["sources"]}).refine(s=>s.filter(t=>t.role==="snapshot").every(t=>!t.useForSnapshot),{message:"Snapshot source can not be used with useForSnapshot",path:["sources"]}).refine(s=>s.filter(t=>t.role==="snapshot").every(t=>!t.hotMode),{message:"Snapshot source can not be used with hotMode"}).optional(),extensions:Jm.partial().optional(),interface:ep.partial().optional(),recording:Km.partial().optional(),detectionZones:El.optional(),detectionSettings:Zm.partial().optional(),frameWorkerSettings:Ym.partial().optional()}).strict().transform(s=>{if(s.sources){const e=s.sources.flatMap(t=>t.urls);if(s.isCloud===!0||Qm(e))return{...s,isCloud:!0}}return s});bt({url:Ke().trim()}).strict();const Ey=/^((@[\w-.]*)\/)?(camera-ui-[\w-]*)$/;var Ay=(s=>(s.READY="ready",s.STARTING="starting",s.STARTED="started",s.STOPPING="stopping",s.STOPPED="stopped",s.ERROR="error",s.UNKNOWN="unknown",s.DISABLED="disabled",s))(Ay||{});const ih=["image/jpeg","image/png"],oh=1024*1024*2,ah=["video/mp4","video/quicktime"],ch=1024*1024*10,lh=["audio/mpeg","audio/wav","audio/ogg"],uh=1024*1024*2;bt({pluginname:Ke().trim().refine(s=>Ey.test(s),"Not a valid plugin name"),pluginversion:Ke().trim().optional().default("latest")}).strict();bt({actionId:Ke(),payload:ur()}).strict();il(ur(),ur());bt({upload:Hn().refine(s=>(t=>t.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=oh:s.size<=oh,"Max file size is 2 MB").refine(s=>(t=>t.mimetype!==void 0)(s)?ih.includes(s.mimetype):ih.includes(s.type),".jpeg and .png files are accepted"),metadata:Hn().transform(s=>JSON.parse(s.value)),config:Hn().transform(s=>JSON.parse(s.value))});bt({upload:Hn().refine(s=>(t=>t.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=uh:s.size<=uh,"Max file size is 2 MB").refine(s=>(t=>t.mimetype!==void 0)(s)?lh.includes(s.mimetype):lh.includes(s.type),".mp3, .wav and .ogg files are accepted"),metadata:Hn().transform(s=>JSON.parse(s.value)),config:Hn().transform(s=>JSON.parse(s.value))});bt({upload:Hn().refine(s=>(t=>t.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=ch:s.size<=ch,"Max file size is 5 MB").refine(s=>(t=>t.mimetype!==void 0)(s)?ah.includes(s.mimetype):ah.includes(s.type),".mp4 files are accepted"),config:Hn().transform(s=>JSON.parse(s.value))});il(Ke(),ur());bt({key:Ke()}).strict();bt({key:Ke(),payload:ur()}).strict();bt({version:Ke().trim().optional().default("latest")}).strict();const My=bt({mode:Os([we("disabled"),we("port-forward"),we("router-forward"),we("cloudflare"),we("custom-domain")]).default("disabled"),cloudflare:bt({tunnelToken:Ke().trim(),customDomain:Ke().trim(),tunnelUrl:Ke().trim(),tunnelCredentials:bt({username:Ke().trim(),password:Ke().trim()}).partial()}).partial().strict(),customDomain:bt({url:Ke().trim().optional()}).partial().strict()}).strict(),a9=bt({serverAddresses:Ke().trim().ip().array().default([]),remoteAccess:My}).strict(),dh=["image/jpeg","image/jpg","image/png"],hh=1024*1024*5,sp=bt({index:xn(),cameraId:Ke()}),np=Os([we(1),we(4),we(6),we(7),we(9),we(10),we(12),we(13),we(15),we(16),we(20),we(26)]),$y=Os([we("dnd"),we("view")]),rp=bt({_id:Ke().default(hn()).transform(()=>hn()),name:Ke().trim().min(1,"Layout name is required"),viewSize:np,cameras:sp.array(),type:$y});bt({name:Ke().trim().min(1,"Layout name is required"),viewSize:np,cameras:sp.array()}).partial().optional();const Ty=bt({views:rp.array()}),Py=bt({_id:Ke().default(hn()).transform(()=>hn()),cameraId:Ke(),points:kl});bt({cameraId:Ke(),points:kl}).partial().optional();const Ry=bt({shortcuts:Py.array()}),ip=bt({camview:Ty,cameras:il(Ke().trim(),Ry)}),Iy=bt({_id:Ke().default(hn()).transform(()=>hn()),username:Ke().trim().min(1,"Username is required"),password:Ke().trim().min(10,"Password must be at least 10 characters long").regex(/[A-Z]/,"Password must contain at least one uppercase letter").regex(/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,`Password must contain at least one special character (!@#$%^&*()_+-=[]{};:'"\\|,.<>/?)`).max(32,"Password cannot be more than 32 characters"),passwordConfirm:Ke().trim().min(1,"Please confirm your password"),role:Os([we("admin"),we("user")]),sessionTimer:xn().min(3600,"Session timer must not be less than 3600 seconds (1h)").max(86400,"Session timer must not be greater than 86400 seconds (24h)").default(14400),rememberMe:xs().default(!1),singleSession:xs().default(!1),firstLogin:xs().default(!0),preferences:ip.default({camview:{views:[]},cameras:{}})}).strict().refine(s=>s.password===s.passwordConfirm,{path:["passwordConfirm"],message:"Passwords do not match"}),Oy=bt({username:Ke().trim().min(1,"Username is required"),password:Ke().trim().min(1,"Password is required"),rememberMe:xs().default(!1)}).strict(),Ny=bt({username:Ke().trim().min(1,"Username is required").optional(),password:Ke().trim().min(10,"Password must be at least 10 characters long").regex(/[A-Z]/,"Password must contain at least one uppercase letter").regex(/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,`Password must contain at least one special character (!@#$%^&*()_+-=[]{};:'"\\|,.<>/?)`).max(32,"Password cannot be more than 32 characters").optional(),passwordConfirm:Ke().trim().optional(),role:Os([we("admin"),we("user")]).optional(),sessionTimer:xn().min(3600,"Session timer must not be less than 3600 seconds (1h)").max(86400,"Session timer must not be greater than 86400 seconds (24h)").optional(),upload:hf(Hn().refine(s=>(t=>t.mimetype!==void 0)(s)?Buffer.byteLength(s._buf)<=hh:s.size<=hh,"Max file size is 5MB.").refine(s=>(t=>t.mimetype!==void 0)(s)?dh.includes(s.mimetype):dh.includes(s.type),".jpg, .jpeg, .png files are accepted.")),rememberMe:xs().optional(),singleSession:xs().optional(),firstLogin:xs().optional(),preferences:ip.partial().optional()}).strict().refine(s=>s.password===s.passwordConfirm,{path:["passwordConfirm"],message:"Passwords do not match"});function sa(s,e,t=!1){if(s===e)return!0;if((s===void 0||e===void 0||s===null||e===null)&&(s||e))return!1;const n=s==null?void 0:s.constructor.name,r=e==null?void 0:e.constructor.name;if(n!==r)return!1;if(n==="Array"&&r==="Array"){if(s.length!==e.length)return!1;if(t){const i=[...e];return s.every(o=>{const a=i.findIndex(l=>sa(o,l,t));return a===-1?!1:(i.splice(a,1),!0)})}else{let i=!0;for(let o=0;o<s.length;o++)if(!sa(s[o],e[o],t)){i=!1;break}return i}}if(n==="Object"&&r==="Object"){let i=!0;const o=Object.keys(s),a=Object.keys(e);if(o.length!==a.length)return!1;for(let l=0;l<o.length;l++)if(s[o[l]]&&e[o[l]]){if(s[o[l]]===e[o[l]])continue;if(s[o[l]]&&(s[o[l]].constructor.name==="Array"||s[o[l]].constructor.name==="Object")){if(i=sa(s[o[l]],e[o[l]],t),!i)break}else if(s[o[l]]!==e[o[l]]){i=!1;break}}else if(s[o[l]]&&!e[o[l]]||!s[o[l]]&&e[o[l]]){i=!1;break}return i}return s===e}const ar=s=>s.type==="string"&&!("enum"in s),mh=s=>s.type==="number",ph=s=>s.type==="boolean",ba=s=>s.type==="string"&&"enum"in s,fh=s=>s.type==="array",zr=s=>s.type==="button",Ur=s=>s.type==="submit",Fy=s=>ar(s)&&(!s.format||s.format!=="qrCode"&&s.format!=="image"),Ly=(s,e)=>{if(!s||Object.keys(s).length===0)return!0;const t=e.filter(n=>!zr(n)&&!Ur(n));for(const n of t){const r=ni(s,n.key),i=Ml(n);if(r!==void 0&&!sa(r,i,!0))return!1}return!0},Ml=s=>{if("defaultValue"in s&&s.defaultValue!==void 0)return s.defaultValue;switch(s.type){case"string":return ba(s)?s.multiple?[]:s.required?s.enum[0]:"":"";case"number":return 0;case"boolean":return!1;case"array":return[];default:return}},jy=s=>{const e={};for(const t of s)zr(t)||Ur(t)||(e[t.key]=Ml(t));return e},ni=(s={},e)=>{if(!e.includes(".")&&!e.includes("["))return s[e];const t=e.split(".").reduce((r,i)=>{if(i.includes("[")){const[o,a]=i.split("[");r.push(o,a.slice(0,-1))}else r.push(i);return r},[]);let n=s;for(const r of t){if(n==null)return;n=n[r]}return n},rc=(s,e,t)=>{if(!e.includes(".")&&!e.includes("[")){s[e]=t;return}const n=e.split(".").reduce((o,a)=>{if(a.includes("[")){const[l,u]=a.split("[");o.push(l,u.slice(0,-1))}else o.push(a);return o},[]),r=n.pop();if(!r)return;let i=s;for(const o of n){if(i[o]===void 0||i[o]===null){const a=n[n.indexOf(o)+1];i[o]=isNaN(Number(a))?{}:[]}i=i[o]}i[r]=t},c9=(s,e)=>{const t={};for(const n of s)if("store"in n&&n.store&&!zr(n)&&!Ur(n)){const r=ni(e,n.key);r!==void 0&&(t[n.key]=r)}return t},op=(s,e)=>e?s.filter(t=>"group"in t&&t.group===e):s,qy=(s,e)=>{const t=op(s,e);return t.length>0&&t.every(n=>"readonly"in n&&n.readonly)},Dy=(s,e)=>{const t=op(s,e);return t.length>0&&t.some(n=>"store"in n&&n.store)},By=(s,e)=>{if(!e)return!0;const t={"date-time":n=>/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d+)?(Z|[+-]\d{2}:\d{2})?$/.test(n),date:n=>/^\d{4}-\d{2}-\d{2}$/.test(n),time:n=>/^([01]?[0-9]|2[0-3]):([0-5][0-9])(:([0-5][0-9]))?$/.test(n),email:n=>/^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b$/.test(n),uuid:n=>/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/.test(n),ipv4:n=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(n),ipv6:n=>/^\s*([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4})\s*$/.test(n)};return e in t?t[e](s):!0},ap=s=>{if(zr(s)||Ur(s))return ur();switch(s.type){case"string":if(ba(s))if(s.multiple){let i=xu(Ke().trim().refine(o=>s.enum.includes(o),{message:"Invalid selection"}));return s.required&&(i=i.min(1,{message:"Required"})),s.required?i:i.optional()}else{const i=mf(s.enum);return s.required?i:i.optional()}let e=Ke().trim();return s.required&&(e=e.nonempty("Required")),s.minLength!==void 0&&(e=e.min(s.minLength)),s.maxLength!==void 0&&(e=e.max(s.maxLength)),s.format&&(e=e.refine(i=>!i||i.trim()===""||By(i,s.format),{message:`Invalid ${s.format} format`})),s.required?e:e.optional();case"number":let t=xn();return s.minimum!==void 0&&(t=t.min(s.minimum)),s.maximum!==void 0&&(t=t.max(s.maximum)),s.required&&(t=t.refine(i=>i!=null,{message:"Required"})),s.required?t:t.optional();case"boolean":return s.required?xs():xs().optional();case"array":const n=ap(s.items),r=xu(n);return s.required?r:r.optional();default:return s.required?ur():ur().optional()}},zy=s=>{const e={};return s.forEach(t=>{!zr(t)&&!Ur(t)&&(e[t.key]=ap(t))}),bt(e)},Uy=Wn(Oy),l9=Wn(Iy),u9=Wn(Ny),d9=Wn(rp),Vy={class:"flex justify-center items-center draggable-region"},Hy={class:"card-background border-color relative w-full md:w-[400px] rounded-none md:rounded-2xl md:border-[1px] shadow-none md:shadow-xl h-full md:h-auto md:my-4"},Qy={class:"flex flex-col h-full p-10 non-draggable-region"},Ky={class:"flex flex-col items-center justify-center mb-10"},Zy={class:"flex flex-col gap-10 md:gap-6 w-full mt-10 md:mt-0"},Gy={for:"username",class:"cui-label"},Wy={for:"password",class:"cui-label"},Jy={class:"flex flex-col gap-6 mt-10"},Yy={class:"flex items-center field-checkbox-gap"},Xy={for:"rememberMe",class:"cui-label-checkbox"},e2={class:"flex justify-end items-center gap-1"},t2=At({__name:"Login",setup(s){const e=Cn(),t=Fs(),{t:n}=js(),{loginLoading:r}=Vs(t),i=Vt("formRef"),o=ae(""),a=ae(""),l=ae(!1),u=async()=>{var h;const d=await((h=i.value)==null?void 0:h.validate());if(d!=null&&d.valid&&d.values)try{await t.login({username:o.value,password:a.value,rememberMe:l.value})}catch(v){console.error(v),e.add({severity:"error",summary:n("components.toast.title_error"),detail:v.message,life:3e3}),r.value=!1}};return(d,h)=>{const v=ki,f=Ih,b=M0,k=ys,z=Ca,L=my,se=uy;return m(),A("div",Vy,[g("div",Hy,[g("div",Qy,[g("div",Ky,[y(c(Aa),{src:c(Fr)("logo_animated.svg"),height:"60px",title:"camera.ui","aria-label":"camera.ui",class:"hover:scale-105 active:scale-105 focus:scale-105 transition-all"},null,8,["src"]),h[3]||(h[3]=g("span",{class:"text-2xl ml-3 mt-2 font-bold text-color"},"camera.ui",-1))]),y(c(rl),{ref_key:"formRef",ref:i,"validation-schema":c(Uy),class:"flex flex-col h-full",onSubmit:u},{default:$(()=>[g("div",Zy,[y(c(Lt),{modelValue:c(o),"onUpdate:modelValue":h[0]||(h[0]=K=>us(o)?o.value=K:null),modelModifiers:{trim:!0},name:"username",as:"div",class:"flex flex-col field-gap"},{default:$(({field:K,errors:N})=>[g("label",Gy,me(d.$t("components.form.label.username")),1),y(v,et({invalid:N.length>0,type:"text",size:"large",loading:c(r),fluid:""},K),null,16,["invalid","loading"]),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"username",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{modelValue:c(a),"onUpdate:modelValue":h[1]||(h[1]=K=>us(a)?a.value=K:null),name:"password",as:"div",class:"flex flex-col field-gap"},{default:$(({field:K,errors:N})=>[g("label",Wy,me(d.$t("components.form.label.password")),1),y(f,et({invalid:N.length>0,size:"large",loading:c(r),feedback:!1,"toggle-mask":"",fluid:""},K),null,16,["invalid","loading"]),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"password",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"])]),g("div",Jy,[y(c(Lt),{"model-value":c(l),name:"rememberMe",type:"checkbox","checked-value":!0,"unchecked-value":!1,as:"div",class:"flex flex-col field-gap"},{default:$(({field:K,errors:N})=>[g("div",Yy,[y(b,et({"model-value":c(l)},K,{invalid:N.length>0,class:"mr-2",binary:"",loading:c(r),onValueChange:h[2]||(h[2]=E=>l.value=E)}),null,16,["model-value","invalid","loading"]),g("label",Xy,me(d.$t("components.form.label.remember_me")),1)]),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"rememberMe",class:"cui-input-checkbox-error"})]),_:1})]),_:1},8,["model-value"]),y(k,{type:"submit",class:"text-white font-semibold cui-button-large",loading:c(r),label:d.$t("components.form.button.login"),fluid:""},null,8,["loading","label"])])]),_:1},8,["validation-schema"]),y(z,{class:"mt-15"}),g("div",e2,[y(k,{severity:"secondary",class:"cui-icon-md",text:"",rounded:""},{icon:$(()=>[y(L,{class:"text-muted",width:"100%",height:"100%"})]),_:1}),y(k,{severity:"secondary",class:"cui-icon-md",text:"",rounded:""},{icon:$(()=>[y(se,{class:"text-muted",width:"100%",height:"100%"})]),_:1})])]),h[4]||(h[4]=g("div",{class:"bg-primary-500 opacity-0 md:opacity-100 absolute blur-3xl w-[200px] h-[30px] left-[50%] -translate-x-[50%] bottom-0 -z-1"},null,-1))])])}}}),cp=Mi("loading",()=>({routerLoading:ae(!1)})),s2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function n2(s,e){return m(),A("svg",s2,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M9 13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2zm10 0a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2zM9 3a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm10 0a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"})],-1)]))}const gh=pe({name:"mingcute-grid-fill",render:n2}),r2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function i2(s,e){return m(),A("svg",r2,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M9 13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2zm10 0a2 2 0 0 1 1.995 1.85L21 15v4a2 2 0 0 1-1.85 1.995L19 21h-4a2 2 0 0 1-1.995-1.85L13 19v-4a2 2 0 0 1 1.85-1.995L15 13zM9 15H5v4h4zm10 0h-4v4h4zm0-12a2 2 0 0 1 1.995 1.85L21 5v4a2 2 0 0 1-1.85 1.995L19 11h-4a2 2 0 0 1-1.995-1.85L13 9V5a2 2 0 0 1 1.85-1.995L15 3zM9 3a2 2 0 0 1 1.995 1.85L11 5v4a2 2 0 0 1-1.85 1.995L9 11H5a2 2 0 0 1-1.995-1.85L3 9V5a2 2 0 0 1 1.85-1.995L5 3zm10 2h-4v4h4zM9 5H5v4h4z"})],-1)]))}const vh=pe({name:"mingcute-grid-line",render:i2}),o2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function a2(s,e){return m(),A("svg",o2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M20.916 9.564a1 1 0 0 0-.513-1.316L7.328 2.492c-.995-.438-2.22.051-2.645 1.042l-2.21 5.154a2 2 0 0 0 1.052 2.624L9.563 13.9L8.323 17H4v-3H2v8h2v-3h4.323c.823 0 1.552-.494 1.856-1.258l1.222-3.054l5.205 2.23a1 1 0 0 0 1.31-.517l.312-.71l1.701.68l2-5l-1.536-.613zm-4.434 5.126L4.313 9.475l2.208-5.152l12.162 5.354z"},null,-1)]))}const _h=pe({name:"bx-cctv",render:a2}),c2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function l2(s,e){return m(),A("svg",c2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M18.618 7.462L6.403 2.085a1 1 0 0 0-.77-.016a1 1 0 0 0-.552.537l-3 7a1 1 0 0 0 .525 1.313L9.563 13.9L8.323 17H4v-3H2v8h2v-3h4.323c.823 0 1.552-.494 1.856-1.258l1.222-3.054l3.419 1.465a1 1 0 0 0 1.311-.518l3-6.857a1 1 0 0 0-.513-1.316m1.312 8.91l-1.858-.742l1.998-5l1.858.741z"},null,-1)]))}const Bc=pe({name:"bxs-cctv",render:l2}),u2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d2(s,e){return m(),A("svg",u2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M21 10V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 0 0 2 2h6v-1.87l8.39-8.39c.44-.44 1-.68 1.61-.74m-7-5.5l5.5 5.5H14zm8.85 9.69l-.98.98l-2.04-2.04l.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72m-3.72-.36l2.04 2.04L15.04 22H13v-2.04z"},null,-1)]))}const yh=pe({name:"mdi-note-edit",render:d2}),h2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function m2(s,e){return m(),A("svg",h2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 0 0 2 2h6v-1.87l.13-.13H5V5h7v7zM14 4.5l5.5 5.5H14zm5.13 9.33l2.04 2.04L15.04 22H13v-2.04zm3.72.36l-.98.98l-2.04-2.04l.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72"},null,-1)]))}const bh=pe({name:"mdi-note-edit-outline",render:m2}),p2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function f2(s,e){return m(),A("svg",p2,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 7h3a1 1 0 0 0 1-1V5a2 2 0 0 1 4 0v1a1 1 0 0 0 1 1h3a1 1 0 0 1 1 1v3a1 1 0 0 0 1 1h1a2 2 0 0 1 0 4h-1a1 1 0 0 0-1 1v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-1a2 2 0 0 0-4 0v1a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a2 2 0 0 0 0-4H4a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1"},null,-1)]))}const wh=pe({name:"tabler-puzzle",render:f2}),g2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function v2(s,e){return m(),A("svg",g2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M10 2a3 3 0 0 1 2.995 2.824L13 5v1h3a2 2 0 0 1 1.995 1.85L18 8v3h1a3 3 0 0 1 .176 5.995L19 17h-1v3a2 2 0 0 1-1.85 1.995L16 22h-3a2 2 0 0 1-1.995-1.85L11 20v-1a1 1 0 0 0-1.993-.117L9 19v1a2 2 0 0 1-1.85 1.995L7 22H4a2 2 0 0 1-1.995-1.85L2 20v-3a2 2 0 0 1 1.85-1.995L4 15h1a1 1 0 0 0 .117-1.993L5 13H4a2 2 0 0 1-1.995-1.85L2 11V8a2 2 0 0 1 1.85-1.995L4 6h3V5a3 3 0 0 1 3-3"},null,-1)]))}const zc=pe({name:"tabler-puzzle-filled",render:v2}),_2={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function y2(s,e){return m(),A("svg",_2,e[0]||(e[0]=[g("g",{fill:"none",stroke:"currentColor","stroke-linejoin":"round","stroke-width":"4"},[g("rect",{width:"40",height:"32",x:"4",y:"8",rx:"2"}),g("path",{"stroke-linecap":"round",d:"m12 18l7 6l-7 6m11 2h13"})],-1)]))}const xh=pe({name:"icon-park-outline-terminal",render:y2}),b2={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"},w2=["id"],x2=["mask"];function S2(s,e){return m(),A("svg",b2,[g("defs",null,[g("mask",{id:s.idMap.ipSTerminal0},e[0]||(e[0]=[g("g",{fill:"none","stroke-linejoin":"round","stroke-width":"4"},[g("rect",{width:"40",height:"32",x:"4",y:"8",fill:"#fff",stroke:"#fff",rx:"2"}),g("path",{stroke:"#000","stroke-linecap":"round",d:"m12 18l7 6l-7 6m11 2h13"})],-1)]),8,w2)]),g("path",{fill:"currentColor",d:"M0 0h48v48H0z",mask:"url(#"+s.idMap.ipSTerminal0+")"},null,8,x2)])}const Sh=pe({name:"icon-park-solid-terminal",render:S2,setup(){return{idMap:{ipSTerminal0:"uicons-"+Math.random().toString(36).substr(2,10)}}}}),C2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function k2(s,e){return m(),A("svg",C2,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M5 3a3 3 0 0 0-3 3v10a2 2 0 0 0 2 2V6a1 1 0 0 1 1-1h14a2 2 0 0 0-2-2zm0 5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2v11.333a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2zm15 0H7v7.848L10.848 12a1.25 1.25 0 0 1 1.768 0l3.241 3.24l.884-.883a1.25 1.25 0 0 1 1.768 0L20 15.848zm-2 3a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0"})],-1)]))}const ic=pe({name:"mingcute-photo-album-fill",render:k2}),E2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function A2(s,e){return m(),A("svg",E2,e[0]||(e[0]=[g("g",{fill:"none"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M20 6a2 2 0 0 1 2 2v11.333a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2zm-8.268 7.944L7.136 18.54l-.066.06l-.07.054v.68h13v-.68l-.07-.053l-.066-.06l-2.24-2.24l-.353.354l.055.055a1 1 0 0 1-1.32 1.497l-.094-.083zM17 3a2 2 0 0 1 1.995 1.85L19 5H5a1 1 0 0 0-.993.883L4 6v12a2 2 0 0 1-1.995-1.85L2 16V6a3 3 0 0 1 2.824-2.995L5 3zm3 5H7v7.848L10.848 12a1.25 1.25 0 0 1 1.768 0l3.241 3.24l.884-.883a1.25 1.25 0 0 1 1.768 0L20 15.848zm-3.5 1.5a1.5 1.5 0 1 1 0 3a1.5 1.5 0 0 1 0-3"})],-1)]))}const oc=pe({name:"mingcute-photo-album-line",render:A2}),M2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $2(s,e){return m(),A("svg",M2,e[0]||(e[0]=[g("path",{fill:"currentColor","fill-rule":"evenodd",d:"M3.464 3.464C2 4.93 2 7.286 2 12s0 7.071 1.464 8.535C4.93 22 7.286 22 12 22s7.071 0 8.535-1.465C22 19.072 22 16.714 22 12s0-7.071-1.465-8.536C19.072 2 16.714 2 12 2S4.929 2 3.464 3.464m14.112 7.016a.75.75 0 0 0-1.152-.96l-1.797 2.156c-.37.445-.599.716-.786.885a.8.8 0 0 1-.163.122l-.011.005l-.008-.004l-.003-.001a.8.8 0 0 1-.164-.122c-.187-.17-.415-.44-.786-.885l-.292-.35c-.328-.395-.625-.75-.901-1c-.301-.272-.68-.514-1.18-.514s-.878.242-1.18.514c-.276.25-.572.605-.9 1l-1.83 2.194a.75.75 0 1 0 1.153.96l1.797-2.156c.37-.445.599-.716.786-.885a.8.8 0 0 1 .163-.122l.007-.003l.004-.002l.011.005a.8.8 0 0 1 .164.122c.187.17.415.44.786.885l.292.35c.329.395.625.75.901 1c.301.272.68.514 1.18.514s.878-.242 1.18-.514c.276-.25.572-.605.9-1z","clip-rule":"evenodd"},null,-1)]))}const Ch=pe({name:"solar-graph-bold",render:$2}),T2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function P2(s,e){return m(),A("svg",T2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M17.576 10.48a.75.75 0 0 0-1.152-.96l-1.797 2.156c-.37.445-.599.716-.786.885a.8.8 0 0 1-.163.122l-.011.005l-.011-.005a.8.8 0 0 1-.164-.122c-.187-.17-.415-.44-.786-.885l-.292-.35c-.328-.395-.625-.75-.901-1c-.301-.272-.68-.514-1.18-.514s-.878.242-1.18.514c-.276.25-.572.605-.9 1l-1.83 2.194a.75.75 0 1 0 1.153.96l1.797-2.156c.37-.445.599-.716.786-.885a.8.8 0 0 1 .163-.122l.011-.005l.011.005a.8.8 0 0 1 .164.122c.187.17.415.44.786.885l.292.35c.329.395.625.75.901 1c.301.272.68.514 1.18.514s.878-.242 1.18-.514c.276-.25.572-.605.9-1z"},null,-1),g("path",{fill:"currentColor","fill-rule":"evenodd",d:"M11.943 1.25c-2.309 0-4.118 0-5.53.19c-1.444.194-2.584.6-3.479 1.494c-.895.895-1.3 2.035-1.494 3.48c-.19 1.411-.19 3.22-.19 5.529v.114c0 2.309 0 4.118.19 5.53c.194 1.444.6 2.584 1.494 3.479c.895.895 2.035 1.3 3.48 1.494c1.411.19 3.22.19 5.529.19h.114c2.309 0 4.118 0 5.53-.19c1.444-.194 2.584-.6 3.479-1.494c.895-.895 1.3-2.035 1.494-3.48c.19-1.411.19-3.22.19-5.529v-.114c0-2.309 0-4.118-.19-5.53c-.194-1.444-.6-2.584-1.494-3.479c-.895-.895-2.035-1.3-3.48-1.494c-1.411-.19-3.22-.19-5.529-.19zM3.995 3.995c.57-.57 1.34-.897 2.619-1.069c1.3-.174 3.008-.176 5.386-.176s4.086.002 5.386.176c1.279.172 2.05.5 2.62 1.069c.569.57.896 1.34 1.068 2.619c.174 1.3.176 3.008.176 5.386s-.002 4.086-.176 5.386c-.172 1.279-.5 2.05-1.069 2.62c-.57.569-1.34.896-2.619 1.068c-1.3.174-3.008.176-5.386.176s-4.086-.002-5.386-.176c-1.279-.172-2.05-.5-2.62-1.069c-.569-.57-.896-1.34-1.068-2.619c-.174-1.3-.176-3.008-.176-5.386s.002-4.086.176-5.386c.172-1.279.5-2.05 1.069-2.62","clip-rule":"evenodd"},null,-1)]))}const kh=pe({name:"solar-graph-outline",render:P2}),R2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function I2(s,e){return m(),A("svg",R2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19 3c-1.654 0-3 1.346-3 3c0 .502.136.968.354 1.385l-1.116 1.302A4 4 0 0 0 13 8c-.739 0-1.425.216-2.02.566L9.566 7.152A3.45 3.45 0 0 0 10 5.5C10 3.57 8.43 2 6.5 2S3 3.57 3 5.5S4.57 9 6.5 9c.601 0 1.158-.166 1.652-.434L9.566 9.98A3.97 3.97 0 0 0 9 12c0 .997.38 1.899.985 2.601l-1.692 1.692l.025.025A2.96 2.96 0 0 0 7 16c-1.654 0-3 1.346-3 3s1.346 3 3 3s3-1.346 3-3c0-.476-.121-.919-.318-1.318l.025.025l1.954-1.954c.421.15.867.247 1.339.247c2.206 0 4-1.794 4-4a3.96 3.96 0 0 0-.439-1.785l1.253-1.462c.364.158.764.247 1.186.247c1.654 0 3-1.346 3-3s-1.346-3-3-3M7 20a1 1 0 1 1 0-2a1 1 0 0 1 0 2M5 5.5C5 4.673 5.673 4 6.5 4S8 4.673 8 5.5S7.327 7 6.5 7S5 6.327 5 5.5m8 8.5c-1.103 0-2-.897-2-2s.897-2 2-2s2 .897 2 2s-.897 2-2 2m6-7a1 1 0 1 1 0-2a1 1 0 0 1 0 2"},null,-1)]))}const Eh=pe({name:"bx-network-chart",render:I2}),O2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function N2(s,e){return m(),A("svg",O2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19.5 3A2.5 2.5 0 0 0 17 5.5c0 .357.078.696.214 1.005l-1.955 2.199A4 4 0 0 0 13 8c-.74 0-1.424.216-2.019.566L8.707 6.293l-.023.023C8.88 5.918 9 5.475 9 5a3 3 0 1 0-3 3c.475 0 .917-.12 1.316-.316l-.023.023L9.567 9.98A3.96 3.96 0 0 0 9 12c0 .997.38 1.899.985 2.601l-2.577 2.576A2.5 2.5 0 0 0 6.5 17C5.122 17 4 18.121 4 19.5S5.122 22 6.5 22S9 20.879 9 19.5c0-.321-.066-.626-.177-.909l2.838-2.838c.421.15.867.247 1.339.247c2.206 0 4-1.794 4-4c0-.636-.163-1.229-.428-1.764l2.117-2.383c.256.088.526.147.811.147C20.879 8 22 6.879 22 5.5S20.879 3 19.5 3M13 14c-1.103 0-2-.897-2-2s.897-2 2-2s2 .897 2 2s-.897 2-2 2"},null,-1)]))}const Ah=pe({name:"bxs-network-chart",render:N2}),F2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function L2(s,e){return m(),A("svg",F2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 15.5A3.5 3.5 0 0 1 8.5 12A3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5a3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.64.07-.97s-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1s.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64z"},null,-1)]))}const wa=pe({name:"mdi-cog",render:L2}),j2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function q2(s,e){return m(),A("svg",j2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 8a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 2a2 2 0 0 0-2 2a2 2 0 0 0 2 2a2 2 0 0 0 2-2a2 2 0 0 0-2-2m-2 12c-.25 0-.46-.18-.5-.42l-.37-2.65c-.63-.25-1.17-.59-1.69-.99l-2.49 1.01c-.22.08-.49 0-.61-.22l-2-3.46a.493.493 0 0 1 .12-.64l2.11-1.66L4.5 12l.07-1l-2.11-1.63a.493.493 0 0 1-.12-.64l2-3.46c.12-.22.39-.31.61-.22l2.49 1c.52-.39 1.06-.73 1.69-.98l.37-2.65c.04-.24.25-.42.5-.42h4c.25 0 .46.18.5.42l.37 2.65c.63.25 1.17.59 1.69.98l2.49-1c.22-.09.49 0 .61.22l2 3.46c.13.22.07.49-.12.64L19.43 11l.07 1l-.07 1l2.11 1.63c.19.15.25.42.12.64l-2 3.46c-.12.22-.39.31-.61.22l-2.49-1c-.52.39-1.06.73-1.69.98l-.37 2.65c-.04.24-.25.42-.5.42zm1.25-18l-.37 2.61c-1.2.25-2.26.89-3.03 1.78L5.44 7.35l-.75 1.3L6.8 10.2a5.55 5.55 0 0 0 0 3.6l-2.12 1.56l.75 1.3l2.43-1.04c.77.88 1.82 1.52 3.01 1.76l.37 2.62h1.52l.37-2.61c1.19-.25 2.24-.89 3.01-1.77l2.43 1.04l.75-1.3l-2.12-1.55c.4-1.17.4-2.44 0-3.61l2.11-1.55l-.75-1.3l-2.41 1.04a5.42 5.42 0 0 0-3.03-1.77L12.75 4z"},null,-1)]))}const Uc=pe({name:"mdi-cog-outline",render:q2}),D2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function B2(s,e){return m(),A("svg",D2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 19.2c-2.5 0-4.71-1.28-6-3.2c.03-2 4-3.1 6-3.1s5.97 1.1 6 3.1a7.23 7.23 0 0 1-6 3.2M12 5a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3m0-3A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10c0-5.53-4.5-10-10-10"},null,-1)]))}const z2=pe({name:"mdi-account-circle",render:B2}),U2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function V2(s,e){return m(),A("svg",U2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2M7.07 18.28c.43-.9 3.05-1.78 4.93-1.78s4.5.88 4.93 1.78A7.9 7.9 0 0 1 12 20c-1.86 0-3.57-.64-4.93-1.72m11.29-1.45c-1.43-1.74-4.9-2.33-6.36-2.33s-4.93.59-6.36 2.33A7.93 7.93 0 0 1 4 12c0-4.41 3.59-8 8-8s8 3.59 8 8c0 1.82-.62 3.5-1.64 4.83M12 6c-1.94 0-3.5 1.56-3.5 3.5S10.06 13 12 13s3.5-1.56 3.5-3.5S13.94 6 12 6m0 5a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 12 8a1.5 1.5 0 0 1 1.5 1.5A1.5 1.5 0 0 1 12 11"},null,-1)]))}const H2=pe({name:"mdi-account-circle-outline",render:V2}),Q2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function K2(s,e){return m(),A("svg",Q2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M20.97 7.27a.996.996 0 0 0 0-1.41l-2.83-2.83a.996.996 0 0 0-1.41 0l-4.49 4.49l-3.89-3.89c-.78-.78-2.05-.78-2.83 0l-1.9 1.9c-.78.78-.78 2.05 0 2.83l3.89 3.89L3 16.76V21h4.24l4.52-4.52l3.89 3.89c.95.95 2.23.6 2.83 0l1.9-1.9c.78-.78.78-2.05 0-2.83l-3.89-3.89zM5.04 6.94l1.89-1.9L8.2 6.31L7.02 7.5l1.41 1.41l1.19-1.19l1.2 1.2l-1.9 1.9zm11.23 7.44l-1.19 1.19l1.41 1.41l1.19-1.19l1.27 1.27l-1.9 1.9l-3.89-3.89l1.9-1.9zM6.41 19H5v-1.41l9.61-9.61l1.3 1.3l.11.11zm9.61-12.44l1.41-1.41l1.41 1.41l-1.41 1.41z"},null,-1)]))}const Z2=pe({name:"ic-outline-design-services",render:K2}),G2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function W2(s,e){return m(),A("svg",G2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m16.24 11.51l1.57-1.57l-3.75-3.75l-1.57 1.57l-4.14-4.13c-.78-.78-2.05-.78-2.83 0l-1.9 1.9c-.78.78-.78 2.05 0 2.83l4.13 4.13l-4.6 4.61q-.15.15-.15.36v3.04c0 .28.22.5.5.5h3.04c.13 0 .26-.05.35-.15l4.62-4.62l4.13 4.13c1.32 1.32 2.76.07 2.83 0l1.9-1.9c.78-.78.78-2.05 0-2.83zm-7.06-.44L5.04 6.94l1.89-1.9L8.2 6.31l-.47.49a.996.996 0 1 0 1.41 1.41l.48-.48l1.45 1.45zm7.88 7.89l-4.13-4.13l1.9-1.9l1.45 1.45l-.48.48a.996.996 0 1 0 1.41 1.41l.48-.48l1.27 1.27zm3.65-11.92a.996.996 0 0 0 0-1.41l-2.34-2.34c-.47-.47-1.12-.29-1.41 0l-1.83 1.83l3.75 3.75z"},null,-1)]))}const J2=pe({name:"ic-round-design-services",render:W2}),Y2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function X2(s,e){return m(),A("svg",Y2,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M16 17v2H2v-2s0-4 7-4s7 4 7 4m-3.5-9.5A3.5 3.5 0 1 0 9 11a3.5 3.5 0 0 0 3.5-3.5m3.44 5.5A5.32 5.32 0 0 1 18 17v2h4v-2s0-3.63-6.06-4M15 4a3.4 3.4 0 0 0-1.93.59a5 5 0 0 1 0 5.82A3.4 3.4 0 0 0 15 11a3.5 3.5 0 0 0 0-7"},null,-1)]))}const eb=pe({name:"mdi-users",render:X2}),tb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sb(s,e){return m(),A("svg",tb,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M13.07 10.41a5 5 0 0 0 0-5.82A3.4 3.4 0 0 1 15 4a3.5 3.5 0 0 1 0 7a3.4 3.4 0 0 1-1.93-.59M5.5 7.5A3.5 3.5 0 1 1 9 11a3.5 3.5 0 0 1-3.5-3.5m2 0A1.5 1.5 0 1 0 9 6a1.5 1.5 0 0 0-1.5 1.5M16 17v2H2v-2s0-4 7-4s7 4 7 4m-2 0c-.14-.78-1.33-2-5-2s-4.93 1.31-5 2m11.95-4A5.32 5.32 0 0 1 18 17v2h4v-2s0-3.63-6.06-4Z"},null,-1)]))}const nb=pe({name:"mdi-users-outline",render:sb}),rb={viewBox:"0 0 36 36",width:"1.2em",height:"1.2em"};function ib(s,e){return m(),A("svg",rb,e[0]||(e[0]=[Bh('<path fill="currentColor" d="M6 22h24v2H6z" class="clr-i-outline clr-i-outline-path-1"></path><path fill="currentColor" d="M26 26h4v2h-4z" class="clr-i-outline clr-i-outline-path-2"></path><path fill="currentColor" d="M13 9.92L17 6v13a1 1 0 1 0 2 0V6l4 3.95a1 1 0 1 0 1.38-1.45L18 2.16L11.61 8.5A1 1 0 0 0 13 9.92" class="clr-i-outline clr-i-outline-path-3"></path><path fill="currentColor" d="M30.84 13.37A1.94 1.94 0 0 0 28.93 12H21v2h7.95c1.05 2.94 2.77 7.65 3.05 8.48V30H4v-7.52C4.28 21.65 7.05 14 7.05 14H15v-2H7.07a1.92 1.92 0 0 0-1.9 1.32C2 22 2 22.1 2 22.33V30a2 2 0 0 0 2 2h28a2 2 0 0 0 2-2v-7.67c0-.23 0-.33-3.16-8.96" class="clr-i-outline clr-i-outline-path-4"></path><path fill="none" d="M0 0h36v36H0z"></path>',5)]))}const ob=pe({name:"clarity-backup-restore-line",render:ib}),ab={viewBox:"0 0 36 36",width:"1.2em",height:"1.2em"};function cb(s,e){return m(),A("svg",ab,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M2 24v6a2 2 0 0 0 2 2h28a2 2 0 0 0 2-2v-6Zm28 5h-4v-2h4Z",class:"clr-i-solid clr-i-solid-path-1"},null,-1),g("path",{fill:"currentColor",d:"M30.84 13.37A1.94 1.94 0 0 0 28.93 12H21v6a3 3 0 1 1-6 0v-6H7.07a1.92 1.92 0 0 0-1.9 1.32c-2.31 6.36-2.93 8.11-3.1 8.68h31.86c-.16-.57-.79-2.31-3.09-8.63",class:"clr-i-solid clr-i-solid-path-2"},null,-1),g("path",{fill:"currentColor",d:"M13 9.92L17 6v12a1 1 0 1 0 2 0V6l4 3.95a1 1 0 1 0 1.38-1.45L18 2.16L11.61 8.5A1 1 0 0 0 13 9.92",class:"clr-i-solid clr-i-solid-path-3"},null,-1),g("path",{fill:"none",d:"M0 0h36v36H0z"},null,-1)]))}const lb=pe({name:"clarity-backup-restore-solid",render:cb}),ub={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function db(s,e){return m(),A("svg",ub,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M6.5 20q-2.275 0-3.887-1.575T1 14.575q0-1.95 1.175-3.475T5.25 9.15q.625-2.3 2.5-3.725T12 4q2.925 0 4.963 2.038T19 11q1.725.2 2.863 1.488T23 15.5q0 1.875-1.312 3.188T18.5 20z"},null,-1)]))}const hb=pe({name:"material-symbols-cloud",render:db}),mb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function pb(s,e){return m(),A("svg",mb,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M6.5 20q-2.275 0-3.887-1.575T1 14.575q0-1.95 1.175-3.475T5.25 9.15q.625-2.3 2.5-3.725T12 4q2.925 0 4.963 2.038T19 11q1.725.2 2.863 1.488T23 15.5q0 1.875-1.312 3.188T18.5 20zm0-2h12q1.05 0 1.775-.725T21 15.5t-.725-1.775T18.5 13H17v-2q0-2.075-1.463-3.538T12 6T8.463 7.463T7 11h-.5q-1.45 0-2.475 1.025T3 14.5t1.025 2.475T6.5 18m5.5-6"},null,-1)]))}const fb=pe({name:"material-symbols-cloud-outline",render:pb}),gb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function vb(s,e){return m(),A("svg",gb,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M18.5 4a1.5 1.5 0 0 0-3 0v.5H4a1.5 1.5 0 1 0 0 3h11.5V8a1.5 1.5 0 0 0 3 0v-.5H20a1.5 1.5 0 0 0 0-3h-1.5zM4 10.5a1.5 1.5 0 0 0 0 3h1.5v.5a1.5 1.5 0 0 0 3 0v-.5H20a1.5 1.5 0 0 0 0-3H8.5V10a1.5 1.5 0 1 0-3 0v.5zM2.5 18A1.5 1.5 0 0 1 4 16.5h11.5V16a1.5 1.5 0 0 1 3 0v.5H20a1.5 1.5 0 0 1 0 3h-1.5v.5a1.5 1.5 0 0 1-3 0v-.5H4A1.5 1.5 0 0 1 2.5 18"})],-1)]))}const _b=pe({name:"mingcute-settings-2-fill",render:vb}),yb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function bb(s,e){return m(),A("svg",yb,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M18 4a1 1 0 1 0-2 0v1H4a1 1 0 0 0 0 2h12v1a1 1 0 1 0 2 0V7h2a1 1 0 1 0 0-2h-2zM4 11a1 1 0 1 0 0 2h2v1a1 1 0 1 0 2 0v-1h12a1 1 0 1 0 0-2H8v-1a1 1 0 0 0-2 0v1zm-1 7a1 1 0 0 1 1-1h12v-1a1 1 0 1 1 2 0v1h2a1 1 0 1 1 0 2h-2v1a1 1 0 1 1-2 0v-1H4a1 1 0 0 1-1-1"})],-1)]))}const wb=pe({name:"mingcute-settings-2-line",render:bb}),xb=tl(K0),Sb=tl(Q0);function Vr(){const{angle:s}=xb(),e=Sb({listenOrientation:!0}),t=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d<=360}),n=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d<=450}),r=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d<640}),i=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d<768}),o=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d>768&&d<1024}),a=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d>=1024}),l=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d>=1280}),u=ne(()=>{let d=e.width.value;return s.value>0&&(screen.height>screen.width?d=screen.height:d=screen.width),d>=1536});return{xxsBreakpoint:t,xsBreakpoint:n,smBreakpoint:r,mdBreakpoint:i,xmdBreakpoint:o,lgBreakpoint:a,xlBreakpoint:l,xxlBreakpoint:u}}const{mdBreakpoint:$s,smBreakpoint:ac}=Vr(),lo=[{name:"NotFound",path:"/:pathMatch(.*)*",component:ay,meta:{name:"notfound",auth:{requiresAuth:!1,role:"none"}}},{name:"Login",path:"/login",alias:"/",component:t2,meta:{name:"login",auth:{requiresAuth:!1,role:"none"},ui:{background:ne(()=>$s.value?"var(--card-background)":void 0)}}},{name:"FirstSteps",path:"/first-steps",component:()=>vs(()=>import("./FirstSteps.D21zB4I8.0.0.64.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])),meta:{name:"firststeps",auth:{requiresAuth:!0,role:"user"}}},{name:"Cameras",path:"/cameras",component:()=>vs(()=>import("./Cameras.BOIq1uuW.0.0.64.js"),__vite__mapDeps([48,1,2,3,4,49,14,15,16,17,50,51,12,9,10,13,8,18,19,5,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,52])),meta:{name:"cameras",auth:{requiresAuth:!0,role:"user"},ui:{containerSettings:{showTitle:!0,padding:ne(()=>!ac.value),fullwidth:ne(()=>ac.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"top",icon:{default:_h,active:Bc}},bottombar:{icon:{default:_h,active:Bc}}}},{name:"Camera",path:"/cameras/:cameraname",component:()=>vs(()=>import("./Camera.PUrVh71A.0.0.64.js"),__vite__mapDeps([53,54,1,2,3,4,9,10,14,15,16,17,55,19,8,18,13,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"camera",auth:{requiresAuth:!0,role:"user"},ui:{containerSettings:{disableScroll:ne(()=>$s.value),ignoreSafeAreaBottom:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:ne(()=>!$s.value)}}},{name:"Camview",path:"/camview",component:()=>vs(()=>import("./Camview.DBZOlAZ1.0.0.64.js"),__vite__mapDeps([56,1,2,3,4,54,9,10,14,15,16,17,55,57,58,59,60,61,62,63,13,12,8,18,19,5,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,64])),meta:{name:"camview",auth:{requiresAuth:!0,role:"user"},ui:{containerSettings:{disableScroll:ne(()=>!ac.value)},background:"#000000",showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"top",icon:{default:vh,active:gh}},bottombar:{icon:{default:vh,active:gh}}}},{name:"Recordings",path:"/recordings",component:()=>vs(()=>import("./Recordings.i1TKNg0g.0.0.64.js"),__vite__mapDeps([65,3,8,1,2,4,14,15,16,17,18,9,10,13,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"recordings",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{showTitle:!0,padding:!0,fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"top",icon:{default:oc,active:ic}},bottombar:{icon:{default:oc,active:ic}}}},{name:"Config",path:"/config",component:()=>vs(()=>import("./Config.CN7_wXsV.0.0.64.js"),__vite__mapDeps([66,1,2,3,4,13,14,15,16,17,67,8,9,10,7,18,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"config",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{disableScroll:!0},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"top",icon:{default:bh,active:yh}},profileMenu:{icon:{default:bh,active:yh}}}},{name:"Console",path:"/console",component:()=>vs(()=>import("./Console.BmVLvya9.0.0.64.js"),__vite__mapDeps([68,1,2,3,4,67,7,8,9,10,50,16,17,14,15,51,13,18,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"console",auth:{requiresAuth:!0,role:"admin"},ui:{background:"#000000",containerSettings:{disableScroll:!0},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"top",icon:{default:xh,active:Sh}},profileMenu:{icon:{default:xh,active:Sh}}}},{name:"Plugins",path:"/plugins",component:()=>vs(()=>import("./Plugins.BDGFT4rc.0.0.64.js"),__vite__mapDeps([69,1,2,3,4,49,70,71,50,16,17,14,15,51,72,30,31,32,33,34,35,36,37,7,8,9,10,19,73,18,13,5,12,20,21,22,23,24,25,26,27,28,29,38,39,40,41,42,43,44,45,74])),meta:{name:"plugins",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{showTitle:!0,padding:!0,fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"top",icon:{default:wh,active:zc}},profileMenu:{icon:{default:wh,active:zc}}}},{name:"ScopedPlugin",path:"/plugins/:scope/:pluginname",component:()=>vs(()=>import("./Plugin.CfcJolDg.0.0.64.js"),__vite__mapDeps([75,1,2,3,4,76,9,10,70,71,50,16,17,14,15,51,72,30,31,32,33,34,35,36,37,7,8,19,73,18,13,5,12,20,21,22,23,24,25,26,27,28,29,38,39,40,41,42,43,44,45,77])),meta:{name:"plugin",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{padding:!0,fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0}}},{name:"Plugin",path:"/plugins/:pluginname",component:()=>vs(()=>import("./Plugin.CfcJolDg.0.0.64.js"),__vite__mapDeps([75,1,2,3,4,76,9,10,70,71,50,16,17,14,15,51,72,30,31,32,33,34,35,36,37,7,8,19,73,18,13,5,12,20,21,22,23,24,25,26,27,28,29,38,39,40,41,42,43,44,45,77])),meta:{name:"plugin",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{padding:!0,fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0}}},{name:"Adminpanel",path:"/admin",component:()=>vs(()=>import("./Adminpanel.Cr9cLAVO.0.0.64.js"),__vite__mapDeps([78,1,2,3,4,79,80,81,13,8,9,10,7,14,15,16,17,18,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,82])),meta:{name:"adminpanel",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{showTitle:!0,padding:!0,fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"bottom",icon:{default:kh,active:Ch}},profileMenu:{icon:{default:kh,active:Ch}}}},{name:"Cammesh",path:"/cammesh",component:()=>vs(()=>import("./Cammesh.DzbbmpBq.0.0.64.js"),__vite__mapDeps([83,3,8,1,2,4,14,15,16,17,18,9,10,13,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"cammesh",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{showTitle:!0,padding:!0,fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},navbar:{position:"bottom",icon:{default:Eh,active:Ah}},profileMenu:{icon:{default:Eh,active:Ah}}}},{name:"Settings",path:"/settings",component:()=>vs(()=>import("./Settings.n1QgVCKo.0.0.64.js"),__vite__mapDeps([84,1,2,3,4,19,14,15,16,17,8,18,9,10,13,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,85])),meta:{name:"settings",path:"/settings/account",auth:{requiresAuth:!0,role:"user"},navbar:{position:"bottom",icon:{default:Uc,active:wa}},bottombar:{icon:{default:Uc,active:wa}}},children:[{name:"SettingsAccount",path:"account",component:()=>vs(()=>import("./SettingsAccount.DKOD5pn9.0.0.64.js"),__vite__mapDeps([11,1,2,3,4,12,9,10,13,8,14,15,16,17,18,19,5,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46])),meta:{name:"account",description:"account_description",auth:{requiresAuth:!0,role:"user"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:H2,active:z2}}}},{name:"SettingsAppearance",path:"appearance",component:()=>vs(()=>import("./SettingsAppearance.DC-07_Te.0.0.64.js"),__vite__mapDeps([86,47,1,2,3,4,13,8,14,15,16,17,18,9,10,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"appearance",description:"appearance_description",auth:{requiresAuth:!0,role:"user"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:Z2,active:J2}}}},{name:"SettingsUsers",path:"user",component:()=>vs(()=>import("./SettingsUsers.B4zh8W2n.0.0.64.js"),__vite__mapDeps([87,1,2,3,4,71,12,9,10,8,14,15,16,17,18,13,19,5,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"user",description:"user_description",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:nb,active:eb}}}},{name:"SettingsRecordings",path:"recordings",component:()=>vs(()=>import("./SettingsRecordings.DpSe0tNQ.0.0.64.js"),__vite__mapDeps([88,3,8,1,2,4,14,15,16,17,18,9,10,13,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"recordings",description:"recordings_description",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:oc,active:ic}}}},{name:"SettingsBackup",path:"backup",component:()=>vs(()=>import("./SettingsBackup.B6E4lHe4.0.0.64.js"),__vite__mapDeps([89,1,2,3,4,76,6,7,8,9,10,14,15,16,17,18,13,19,5,12,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,90])),meta:{name:"backup",description:"backup_description",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:ob,active:lb}}}},{name:"SettingsRemote",path:"remote",component:()=>vs(()=>import("./SettingsRemote.f8St_CxB.0.0.64.js"),__vite__mapDeps([91,1,2,3,4,12,7,8,9,10,20,21,14,15,16,17,18,13,19,5,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])),meta:{name:"remote",description:"remote_access_description",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:fb,active:hb}}}},{name:"SettingsSystem",path:"system",component:()=>vs(()=>import("./SettingsSystem.DT9sW8Bn.0.0.64.js"),__vite__mapDeps([92,1,2,3,4,8,7,9,10,72,50,16,17,14,15,51,30,31,32,33,34,35,36,37,93,18,13,19,5,12,20,21,22,23,24,25,26,27,28,29,38,39,40,41,42,43,44,45])),meta:{name:"system",description:"system_description",auth:{requiresAuth:!0,role:"admin"},ui:{containerSettings:{fullwidth:ne(()=>$s.value)},showNavbar:!0,showTopbar:!0,showBottombar:!0},settingsBar:{icon:{default:wb,active:_b}}}}]}],Oa=lf({history:uf("/"),routes:lo,scrollBehavior:async()=>(await $_(10),{top:0,left:0,behavior:"smooth"})});Oa.absUrl=(s="#",e=!0)=>{const t=document.createElement("a");t.href=s,t.target=e&&s!=="#"?"_blank":"",e&&(t.rel="noopener noreferrer"),t.click()};Oa.beforeEach(async(s,e,t)=>{var l;const n=Ci(),r=Fs(),i=cp(),o=s.name.toLowerCase(),a=localStorage.getItem("lastPage");if(i.routerLoading=!0,r.user){await n.cancelQueries(void 0,{revert:!1});try{s.path!=="/settings"&&await qm()}catch(u){console.error(u),await r.logout();return}r.user.firstLogin&&s.path!=="/first-steps"?t("/first-steps"):!r.user.firstLogin&&s.path==="/first-steps"||(l=s.meta.auth)!=null&&l.requiresAuth&&s.meta.auth.role&&r.user.role!==s.meta.auth.role&&r.user.role!=="admin"&&r.user.role!=="master"?t("/cameras"):o==="login"&&a&&a!=="/"?t(a):s.path==="/settings"?t("/settings/account"):t()}else o!=="login"?t("/"):t();i.routerLoading=!1});Oa.afterEach(s=>{const e=["login","notfound","firststeps"],t=s.name.toLowerCase();e.includes(t)||localStorage.setItem("lastPage",s.path)});const Sa=class Sa{constructor(){}static get manager(){return this._manager||this.createManager(),this._manager}static createManager(){Sa._manager=new pf(window.origin,{reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,randomizationFactor:.5,timeout:2e4,autoConnect:!0,transports:["websocket","polling"],rejectUnauthorized:!1,secure:!0})}};p(Sa,"_manager");let Vc=Sa;const $l=Mi("socket",()=>{const s=ae(new Map),e=ae(!1),t=ae(!0),n=()=>{const h=Fs(),v=s.value.get("/camera.ui");return v||i("/camera.ui",h)},r=h=>{const v=Fs(),f=s.value.get(h);return f||i(h,v)},i=(h,v)=>{const f=Ls(a(h,v));return o(f.value,h,v),s.value.set(h,f.value),f.value},o=(h,v,f)=>{h.socket.on("connect",()=>{var b;(b=h.connected)==null||b.next()}),v==="/camera.ui"&&(h.socket.on("connect",()=>{t.value?(e.value=!0,t.value=!1):d()}),h.socket.on("disconnect",()=>{e.value=!1}),h.socket.on("unauthenticated",()=>{e.value=!1,f.logout()}),h.socket.on("invalidToken",b=>{f.accessToken===b&&(e.value=!1,f.logout())})),h.end=b=>{var k;v==="/camera.ui"&&(e.value=!1),h.socket.emit("end",b),h.socket.removeAllListeners(),(k=h.connected)==null||k.complete()},h.disconnect=b=>{var k;v==="/camera.ui"&&(e.value=!1),(k=h.end)==null||k.call(h,b),h.socket.disconnect(),s.value.delete(v)}},a=(h,v)=>{const f=`Bearer ${v.accessToken}`,b=Vc.manager.socket(h,{auth:{token:f}});return{socket:b,request:(z,L)=>new ff(se=>{b.emit(z,L,K=>{typeof K=="object"&&K.error?se.error(K):se.next(K),se.complete()})})}},l=ne(()=>h=>s.value.get(h)),u=h=>{s.value.forEach(v=>{var f;(f=v.disconnect)==null||f.call(v,h)}),e.value=!1},d=()=>{window.location.reload()};return{isConnected:e,namespaceConnectionCache:s,connect:n,connectToNamespace:r,getExistingNamespace:l,disconnect:u}}),h9=["account","appearance","user","recordings","backup","system"],Tl=Mi("ui",()=>{const s=el("ui",{cameras:{showEvents:!0},camview:{dragDisabled:!1},config:{zoom:12},console:{zoom:12},interface:{showBottomBarOnMobile:!0,selectedSettingsView:"account",navbarStayCollapsed:!1}});return s.value.cameras||(s.value.cameras={showEvents:!0}),s.value.cameras.showEvents===void 0&&(s.value.cameras.showEvents=!0),s.value.camview||(s.value.camview={dragDisabled:!1}),s.value.camview.dragDisabled===void 0&&(s.value.camview.dragDisabled=!1),s.value.config||(s.value.config={zoom:12}),s.value.console.zoom===void 0&&(s.value.console.zoom=12),s.value.console||(s.value.console={zoom:12}),s.value.interface.showBottomBarOnMobile===void 0&&(s.value.interface.showBottomBarOnMobile=!0),s.value.interface||(s.value.interface={showBottomBarOnMobile:!0,selectedSettingsView:"account",navbarStayCollapsed:!1}),!s.value.interface.showBottomBarOnMobile===void 0&&(s.value.interface.showBottomBarOnMobile=!0),s.value.interface.selectedSettingsView||(s.value.interface.selectedSettingsView="account"),s.value.interface.navbarStayCollapsed||(s.value.interface.navbarStayCollapsed=!1),{uiSettings:s}}),vn={CLOSED:0,MINIFIED:80,EXPANDED:288},Cb=Symbol("cui-app-bus"),zi=Pr({navbarState:void 0,subbarState:void 0}),Pl=()=>{const s=Hh(Cb);return s.on(({subbarState:e,navbarState:t})=>{e&&e!==zi.subbarState&&(zi.subbarState=e),t&&t!==zi.navbarState&&(zi.navbarState=t)}),{state:zi,bus:s}},Na=()=>{const s=Tl(),e=$i(),{state:t}=Pl(),{mdBreakpoint:n,xsBreakpoint:r,xlBreakpoint:i}=Vr(),{uiSettings:o}=Vs(s),a=ne(()=>u.value?o.value.interface.navbarStayCollapsed&&t.navbarState!=="opened"?n.value?"closed":"minified":i.value?"opened":t.navbarState?t.navbarState:n.value?"closed":"minified":void 0),l=ne(()=>e.path.includes("/settings")?i.value?"opened":t.subbarState?t.subbarState:"closed":void 0),u=ne(()=>{var v;return!!Xs((v=e.meta.ui)==null?void 0:v.showNavbar)}),d=ne(()=>{var v;return!!(Xs((v=e.meta.ui)==null?void 0:v.showBottombar)&&o.value.interface.showBottomBarOnMobile&&r.value)}),h=ne(()=>{var v;return!!Xs((v=e.meta.ui)==null?void 0:v.showTopbar)});return{navbarState:a,subbarState:l,showBottombar:d,showNavbar:u,showTopbar:h}},Si=(s,e,t)=>{var a,l,u,d,h;s=s??$i();const{user:n}=Vs(Fs()),r=!((a=s==null?void 0:s.meta)!=null&&a.auth)||((l=s==null?void 0:s.meta)==null?void 0:l.auth.requiresAuth)===!1,i=e??((d=(u=s.meta)==null?void 0:u.auth)==null?void 0:d.role)??"user",o=((h=n.value)==null?void 0:h.role)??"user";return r||i==="none"?!0:i==="user"?t?o==="user":o==="user"||o==="admin"||o==="master":i==="admin"?o==="admin"||o==="master":i==="master"?o==="master":!1},kb={class:"pl-safe pt-safe h-full flex flex-col"},Eb={class:"overflow-hidden w-full pr-4"},Ab={key:0,class:"ml-2 w-full flex flex-row items-center"},Mb={class:"flex flex-col flex-1 my-4 px-[0.9rem]"},$b={class:"flex flex-col space-y-1"},Tb={class:"flex flex-col space-y-1 pb-safe"},Pb={key:0,class:"dark-mode text-muted pl-3 uppercase text-xs font-bold"},Rb=At({__name:"CuiNavbar",setup(s,{expose:e}){const t=qr(),n=Fs(),r=Tl(),i=$l(),{bus:o}=Pl(),{mdBreakpoint:a,xlBreakpoint:l}=Vr(),{navbarState:u}=Na(),{uiSettings:d}=Vs(r),{user:h}=Vs(n),v=Vt("navbarRef"),f=ae("closed"),b=Ls(),k=ae(!1),z=ae(!1),L=ae(!1),se=ae(!1);sl(v,I=>{const w=I.target,Q=w.closest("#menu-icon"),J=w.closest("#submenu-icon"),q=w.closest("#navbar-icon");!Q&&!J&&!q&&S()});const K=ne(()=>d.value.interface.selectedSettingsView),N=ne(()=>lo.filter(I=>{var w,Q;return((Q=(w=I.meta)==null?void 0:w.navbar)==null?void 0:Q.position)==="top"&&I.meta&&Si(I)})),E=ne(()=>lo.filter(I=>{var w,Q;return((Q=(w=I.meta)==null?void 0:w.navbar)==null?void 0:Q.position)==="bottom"&&Si(I)})),O=ne(()=>d.value.interface.navbarStayCollapsed&&f.value!=="opened"?"closed":l.value?"opened":f.value),U=ne(()=>O.value==="closed"?a.value?vn.CLOSED:vn.MINIFIED:vn.EXPANDED);Ge(u,I=>{I&&I!==f.value&&(f.value=I==="minified"||I==="closed"?"closed":"opened")}),Ge(t.currentRoute,(I,w)=>{I.path!==w.path&&S()}),Ge(h,()=>{var I,w,Q,J;((I=h.value)==null?void 0:I.role)==="admin"||((w=h.value)==null?void 0:w.role)==="master"?(b.value=i.connectToNamespace("/server"),b.value.socket.on("plugin-updates",q=>{z.value=q.length>0||!1}),b.value.socket.on("server-updates",q=>{k.value=q.updateAvailable||q.betaUpdateAvailable||!1}),b.value.request("get-updates").subscribe(q=>{z.value=q.plugins.length>0||!1,k.value=q.server.updateAvailable||q.server.betaUpdateAvailable||!1})):(J=(Q=b.value)==null?void 0:Q.disconnect)==null||J.call(Q)},{deep:!0,immediate:!0}),Ge(L,I=>{I&&B()});const S=()=>{o.emit({navbarState:"closed"})},M=(I,w)=>{L.value&&w.channel==="update-check"&&w.status==="available"&&(k.value=!0)},B=async()=>{if(L.value){window.electron.removeListener("app-status",M),window.electron.on("app-status",M),window.electron.send("check-for-updates");try{const I=await window.electron.invoke("get-update-available");k.value=I.isUpdateAvailable}catch{}}},W=()=>{const I=document.querySelector('meta[name="electron-server"]'),w=I!==null&&I.getAttribute("content")==="true";L.value=window.electron!==void 0,se.value=w,setTimeout(()=>{L.value=window.electron!==void 0,se.value=w},100)};return Sn(()=>{W()}),go(()=>{var I;(I=window.electron)==null||I.removeListener("app-status",M)}),e({navbarState:O}),(I,w)=>{var Se,F;const Q=Ei("RouterLink"),J=vo,q=ys,oe=Oh,ue=Hm;return m(),A("nav",{ref_key:"navbarRef",ref:v,class:at(["navbar-background fixed h-full transition-[width] duration-300 overflow-x-hidden overflow-y-scroll shadow-black/50 overflow-hidden border-r-[1px] border-base-color",{"shadow-xl":c(a)&&c(U)===c(vn).EXPANDED}]),style:ot({left:c(U)===0?"-1px":"0px",width:`calc(${c(U)}px + env(safe-area-inset-left, 0px))`,clipPath:"inset(0)"})},[w[3]||(w[3]=g("div",{class:"fixed blur-2xl h-[20px] w-full -z-1 opacity-70 bg-primary-500"},null,-1)),g("div",kb,[g("div",{class:at(["w-full flex items-center shrink-0 h-[60px]",{"mt-[25px]":c(L)}])},[y(Q,{to:"/cameras",class:"pl-6"},{default:$(()=>[y(c(Aa),{src:c(Fr)("logo_animated.svg"),width:"32px",height:"32px",title:"camera.ui","aria-label":"camera.ui",class:"hover:scale-105 active:scale-105 focus:scale-105 transition-all"},null,8,["src"])]),_:1}),g("div",Eb,[y(Et,{name:"fade"},{default:$(()=>[c(U)===c(vn).EXPANDED?(m(),A("div",Ab,[y(Q,{to:"/cameras",class:"text-white font-bold text-lg text-shadow"},{default:$(()=>w[0]||(w[0]=[Qt("camera.ui")])),_:1,__:[0]}),c(O)==="opened"&&c(a)?(m(),j(q,{key:0,id:"navbar-icon",class:"dark-mode ml-auto cui-icon-md text-white",text:"",rounded:"",onClick:S},{icon:$(()=>[y(J,{width:"100%",height:"100%"})]),_:1})):ce("",!0)])):ce("",!0)]),_:1})])],2),g("div",Mb,[g("div",$b,[(m(!0),A(yt,null,qt(c(N),D=>(m(),A("div",{key:D.name,class:"w-full h-[50px] relative"},[c(z)&&D.name==="Plugins"?(m(),j(oe,{key:0,class:"absolute min-w-[8px] w-[8px] h-[8px] left-[31px] top-[10px] z-1"})):ce("",!0),y(ue,{icon:D.meta.navbar.icon.default,"active-icon":D.meta.navbar.icon.active,to:D.path,label:I.$t(`navigation.${D.name.toLowerCase()}`),expanded:c(U)===c(vn).EXPANDED,"dark-mode":"","show-tooltip":"","icon-size":22,"button-props":{style:{color:"#a4a4a4"}},class:at(["w-[50px] h-[50px]",{"w-full":c(U)===c(vn).EXPANDED}])},null,8,["icon","active-icon","to","label","expanded","class"])]))),128))]),w[2]||(w[2]=g("div",{class:"flex-1 mt-10"},null,-1)),g("div",Tb,[y(Et,{name:"fade"},{default:$(()=>[c(O)==="opened"?(m(),A("span",Pb,me(I.$t("navigation.extras")),1)):ce("",!0)]),_:1}),(m(!0),A(yt,null,qt(c(E),D=>(m(),A("div",{key:D.name,class:"w-full h-[50px] relative"},[c(k)&&D.name==="Settings"?(m(),j(oe,{key:0,class:"absolute min-w-[8px] w-[8px] h-[8px] left-[31px] top-[10px] z-1"})):ce("",!0),y(ue,{icon:D.meta.navbar.icon.default,"active-icon":D.meta.navbar.icon.active,to:D.path==="/settings"?`/settings/${c(K)}`:D.path,"fallback-active-path":D.path,label:I.$t(`navigation.${D.name.toLowerCase()}`),expanded:c(U)===c(vn).EXPANDED,"dark-mode":"","show-tooltip":"","icon-size":22,"button-props":{style:{color:"#a4a4a4"}},class:at(["w-[50px] h-[50px]",{"w-full":c(U)===c(vn).EXPANDED}])},null,8,["icon","active-icon","to","fallback-active-path","label","expanded","class"])]))),128)),w[1]||(w[1]=g("div",{class:"my-2",style:{borderTop:"1px solid #313131"}},null,-1)),y(ue,{avatar:"avatar",label:((Se=c(h))==null?void 0:Se.username)??"unknown",description:((F=c(h))==null?void 0:F.role)??"unknown",expanded:c(U)===c(vn).EXPANDED,"show-logout":"",to:"/settings/account","dark-mode":"","avatar-size":22,class:at(["w-[50px] h-[50px]",{"w-full":c(U)===c(vn).EXPANDED}])},null,8,["label","description","expanded","class"])])])])],6)}}}),Ib={HEIGHT:60},Ob={class:"px-2 h-full pb-safe-offset-1 flex items-center justify-around"},Nb=At({__name:"CuiBottombar",setup(s,{expose:e}){const t=Vt("bottombarRef"),n=ne(()=>lo.filter(r=>{var i;return((i=r.meta)==null?void 0:i.bottombar)&&r.meta.auth&&Si(r)}));return e({bottombarRef:t}),(r,i)=>{const o=Hm;return m(),A("nav",{ref_key:"bottombarRef",ref:t,class:"cui-bottombar bottombar-background fixed bottom-0 left-0 right-0 border-t-[1px] border-color bottombar-background",style:ot({height:`calc(${c(Ib).HEIGHT}px + env(safe-area-inset-bottom, 0px))`})},[g("div",Ob,[(m(!0),A(yt,null,qt(c(n),a=>(m(),j(o,{key:a.name,icon:a.meta.bottombar.icon.default,"active-icon":a.meta.bottombar.icon.active,to:a.path,label:"",expanded:!1,"icon-class":"text-color",class:"w-[50px] h-[50px] transition-all duration-300"},null,8,["icon","active-icon","to"]))),128))]),i[0]||(i[0]=g("div",{class:"fixed blur-2xl h-[20px] w-full opacity-70 bg-primary-500",style:{bottom:"calc(env(safe-area-inset-bottom, 0px) - 40px)"}},null,-1))],4)}}}),Fb=qs(Nb,[["__scopeId","data-v-78d01fd3"]]),Lb={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function jb(s,e){return m(),A("svg",Lb,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 6h18m-2 0v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6m3 0V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2m-6 5v6m4-6v6"},null,-1)]))}const qb=pe({name:"lucide-trash2",render:jb}),Db={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bb(s,e){return m(),A("svg",Db,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M8.352 20.242A4.63 4.63 0 0 0 12 22a4.63 4.63 0 0 0 3.648-1.758a27.2 27.2 0 0 1-7.296 0M18.75 9v.704c0 .845.24 1.671.692 2.374l1.108 1.723c1.011 1.574.239 3.713-1.52 4.21a25.8 25.8 0 0 1-14.06 0c-1.759-.497-2.531-2.636-1.52-4.21l1.108-1.723a4.4 4.4 0 0 0 .693-2.374V9c0-3.866 3.022-7 6.749-7s6.75 3.134 6.75 7"},null,-1)]))}const zb=pe({name:"solar-bell-bold",render:Bb}),Ub={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vb(s,e){return m(),A("svg",Ub,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m12 13.4l-4.9 4.9q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7l4.9-4.9l-4.9-4.9q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l4.9 4.9l4.9-4.9q.275-.275.7-.275t.7.275t.275.7t-.275.7L13.4 12l4.9 4.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275z"},null,-1)]))}const Hb=pe({name:"material-symbols-close-rounded",render:Vb}),Qb={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function Kb(s,e){return m(),A("svg",Qb,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M9.78 12.78a.75.75 0 0 1-1.06 0L4.47 8.53a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.042.018a.75.75 0 0 1 .018 1.042L6.06 8l3.72 3.72a.75.75 0 0 1 0 1.06"},null,-1)]))}const Zb=pe({name:"octicon-chevron-left16",render:Kb}),lp=Symbol("DialogStepper");function Gb(s){const e=ae(s),t=ae(void 0),n={},r=(f,b)=>{n[f]||(n[f]=[]),n[f].push(b)},i=(f,b)=>{const k=n[f];if(k){const z=k.indexOf(b);z!==-1&&k.splice(z,1)}},o=(f,b)=>{const k=n[f];k&&k.forEach(z=>{z(b)})},a=ne(()=>!t.value),v={currentTab:t,tabs:e,isMainTab:a,goToTab:f=>{const b=e.value.find(k=>k.id===f);b&&(t.value=f,o("tabChange",b))},goToMainTab:()=>{t.value=void 0,o("tabChange",void 0)},registerTab:f=>{e.value.some(b=>b.id===f.id)||e.value.push(f)},updateTabConfig:(f,b)=>{const k=e.value.findIndex(z=>z.id===f);k!==-1&&(e.value[k]={...e.value[k],...b},b.title&&o("updateTabTitle",{tabId:f,title:b.title}))},on:r,off:i,emit:o};return Yc(lp,v),v}function m9(){const s=mi(lp);if(!s)throw new Error("useCuiDialogStepperContext must be used within a dialog that uses useCuiDialogStepper");return s}const Wb={class:"p-dialog-header justify-start gap-1"},Jb={key:0,class:"p-dialog-header-actions"},Yb={class:"p-dialog-title"},Xb={class:"p-dialog-header-actions ml-auto"},e5={key:0},t5=["innerHTML"],s5={class:"flex items-center justify-center shrink-0 w-full p-5 not-md:pb-safe-offset-5 mt-5 self-end",style:{background:"var(--border-color)"}},n5=At({__name:"CuiDialog",setup(s){Gr.registerLanguage("typescript",gf),Gr.registerLanguage("yaml",vf),Gr.registerLanguage("json",_f),Gr.registerLanguage("python",yf);const e=Cn(),{t}=js(),n=mi("dialogRef"),r=Jt(n.value.data),{contentText:i,contentProps:o,loading:a,disabled:l,cancelButtonProps:u,confirmButtonProps:d,hideCancelButton:h,hideConfirmButton:v,dialogContentClass:f,dialogContentStyle:b,cancelText:k,confirmText:z,stayActive:L,src:se,title:K,fullscreen:N,tabs:E,markdown:O}=r;Yc("dialogRefProps",r);const U=ae(!1),S=ae(null),M=ae(!1),B=ae(K.value);let W;const I=n.value.options.templates,w=ne(()=>{var Y;return!!(U.value||a!=null&&a.value||Xs((Y=S.value)==null?void 0:Y.isLoading))}),Q=ne(()=>E.value!==void 0&&E.value.length>0),J=ne(()=>k!=null&&k.value?k.value:t("components.form.button.close")),q=ne(()=>z!=null&&z.value?z.value:t("components.form.button.save")),oe=ne(()=>({...u==null?void 0:u.value,label:J.value,loading:void 0,size:"small",severity:u!=null&&u.value&&"severity"in u.value?u.value.severity:"secondary",class:void 0})),ue=ne(()=>({...d==null?void 0:d.value,label:q.value,loading:void 0,size:"small",severity:d!=null&&d.value&&"severity"in d.value?d.value.severity:"success",class:"ml-auto",disabled:l.value}));Q.value&&(W=Gb(E.value??[]),Ge(W.isMainTab,Y=>{M.value=!Y},{immediate:!0}),W.on("updateTabTitle",({tabId:Y,title:Pe})=>{(W==null?void 0:W.currentTab.value)===Y&&(K!=null&&K.value)&&(B.value=Pe)}),W.on("tabChange",Y=>{B.value=(Y==null?void 0:Y.title)??K.value}));const Se=bf("commonmark",{highlight(Y,Pe){if(Pe&&Gr.getLanguage(Pe))try{return'<pre><code class="hljs">'+Gr.highlight(Y,{language:Pe,ignoreIllegals:!0}).value+"</code></pre>"}catch{}return'<pre><code class="hljs">'+Se.utils.escapeHtml(Y)+"</code></pre>"}}),F=async()=>{var Y,Pe;try{U.value=!0;const He=await((Pe=(Y=S.value)==null?void 0:Y.onCancel)==null?void 0:Pe.call(Y));n.value.close({status:"cancel",data:He})}catch(He){console.error(He),e.add({severity:"error",summary:t("components.toast.title_error"),detail:He.message,life:3e3})}finally{U.value=!1}},D=async()=>{var Y,Pe,He,ht;try{U.value=!0;const Mt=await((Pe=(Y=S.value)==null?void 0:Y.onConfirm)==null?void 0:Pe.call(Y));if(Mt===null)return;L!=null&&L.value?(ht=(He=n.value.options).onConfirm)==null||ht.call(He,Mt):n.value.close({status:"confirm",data:Mt})}catch(Mt){console.error(Mt),e.add({severity:"error",summary:t("components.toast.title_error"),detail:Mt.message,life:3e3})}finally{U.value=!1}};return(Y,Pe)=>{var ze;const He=Zb,ht=ys,Mt=Hb,Qe=Ia;return m(),A(yt,null,[g("div",Wb,[y(Et,{name:"slide-left"},{default:$(()=>{var ge;return[c(M)?(m(),A("div",Jb,[y(ht,{severity:"secondary",text:"",rounded:"",class:"p-dialog-back-button",onClick:(ge=c(W))==null?void 0:ge.goToMainTab},{icon:$(()=>[y(He,{width:"100%",height:"100%"})]),_:1},8,["onClick"])])):ce("",!0)]}),_:1}),g("span",Yb,me(c(B)),1),g("div",Xb,[y(ht,{severity:"secondary",text:"",rounded:"",class:"p-dialog-close-button",onClick:c(n).close},{icon:$(()=>[y(Mt,{width:"100%",height:"100%"})]),_:1},8,["onClick"])])]),g("div",{class:at(["flex justify-center w-full overflow-y-auto px-5 text-balance",{"h-full":c(N)},c(f)]),style:ot(c(b))},[c(i)&&!c(O)?(m(),A("span",e5,me(c(i)),1)):c(i)&&c(O)?(m(),A("div",{key:1,class:"w-full markdown-body",innerHTML:c(Se).render(c(i))},null,8,t5)):c(se)?(m(),j(Qe,{key:2,src:c(se),"image-container-class":"w-full h-full"},null,8,["src"])):(m(),j(Ai((ze=c(I))==null?void 0:ze.content),et({key:3,ref_key:"componentRef",ref:S,class:"w-full h-full relative"},c(o),D0(c(n).options.events||{})),null,16))],6),Pe[1]||(Pe[1]=g("div",{class:"mt-auto"},null,-1)),g("div",s5,[c(h)?ce("",!0):(m(),j(ht,et({key:0},c(oe),{class:"cui-button-medium",onClick:F}),null,16)),Pe[0]||(Pe[0]=g("div",{class:"ml-auto"},null,-1)),c(v)?ce("",!0):(m(),j(ht,et({key:1},c(ue),{loading:c(w),disabled:c(l),class:"cui-button-medium",onClick:D}),null,16,["loading","disabled"]))])],64)}}}),Ui={modal:!0,closable:!0,blockScroll:!0,draggable:!1,dismissableMask:!0,baseZIndex:1100,showHeader:!1},Lo={pt:{root:{class:"p-dialog-maximized pt-safe border-none"}}},jo={pt:{root:{class:"shadow-xl shadow-black/30 overflow-hidden"}}},tr={mobile:{textDialog:{style:{maxWidth:"100%",maxHeight:"100%"},...Lo},imageDialog:{style:{maxWidth:"100%",maxHeight:"100%"},...Lo},componentDialog:{style:{maxWidth:"100%",maxHeight:"100%"},...Lo},stepperDialog:{style:{maxWidth:"100%",maxHeight:"100%"},...Lo}},desktop:{textDialog:{style:{maxWidth:"70vw",maxHeight:"90vh",width:"auto"},...jo},imageDialog:{style:{maxWidth:"70vw",maxHeight:"90vh",width:"70vw"},...jo},componentDialog:{style:{maxWidth:"70vw",maxHeight:"90vh",width:"70vw"},...jo},stepperDialog:{style:{maxWidth:"70vw",maxHeight:"90vh",width:"70vw"},...jo}}};function r5(){return{open:(e,t)=>{const n={content:e&&pe(e),options:t||{},data:t&&t.data,close:r=>{_u.emit("close",{instance:n,params:r})}};return _u.emit("open",{instance:n}),n}}}function Rl(){const s=r5(),{mdBreakpoint:e}=Vr(),t=(u,d)=>{const h=Pr({...u});Cl(h.options.props,d)},n=(u,d)=>(Ge(e,h=>{if(h)switch(d){case"text":t(u,tr.mobile.textDialog);break;case"image":t(u,tr.mobile.imageDialog);break;case"component":t(u,tr.mobile.componentDialog);break;case"stepper":t(u,tr.mobile.stepperDialog);break}else switch(d){case"text":t(u,tr.desktop.textDialog);break;case"image":t(u,tr.desktop.imageDialog);break;case"component":t(u,tr.desktop.componentDialog);break;case"stepper":t(u,tr.desktop.stepperDialog);break}},{immediate:!0}),u);function r(u,d,h){const{component:v,data:f,onConfirm:b,onCancel:k,onSettled:z,events:L,...se}=d,K={content:v?pe(v):void 0},N=s.open(n5,{data:Jt(Pr({confirmText:f.confirmText??void 0,cancelText:f.cancelText??void 0,hideConfirmButton:f.hideConfirmButton??!1,hideCancelButton:f.hideCancelButton??!1,loading:f.loading??!1,disabled:f.disabled??!1,confirmButtonProps:f.confirmButtonProps??void 0,cancelButtonProps:f.cancelButtonProps??void 0,dialogContentClass:f.dialogContentClass??void 0,dialogContentStyle:f.dialogContentStyle??void 0,stayActive:f.stayActive??!1,fullscreen:f.fullscreen??!1,contentText:f.contentText??void 0,src:f.src??void 0,markdown:f.markdown??!1,contentProps:f.contentProps??void 0,tabs:f.tabs??void 0,...f})),props:h,templates:K,...se,events:L,onConfirm:b,onCancel:k,onClose:E=>{var O,U;if(((O=E==null?void 0:E.data)==null?void 0:O.status)==="confirm"){const{status:S,...M}=E.data;b==null||b((M==null?void 0:M.data)??M)}else k==null||k();z==null||z(((U=E==null?void 0:E.data)==null?void 0:U.data)??(E==null?void 0:E.data))}});return f.fullscreen?N:n(N,u)}function i(u){const{data:d,...h}=u,v=structuredClone(Ui);return v.style={...Ui.style,width:"auto",minWidth:"400px"},d.fullscreen&&(v.style={...v.style,maxWidth:"none",maxHeight:"none"},v.pt={root:{class:"p-dialog-maximized pt-safe border-none"}}),r("text",{data:d,...h},v)}function o(u){const{data:d,...h}=u,v=structuredClone(Ui);return d.fullscreen&&(v.style={...v.style,maxWidth:"none",maxHeight:"none"},v.pt={root:{class:"p-dialog-maximized pt-safe border-none"}}),r("image",{data:d,...h},v)}function a(u,d){const{data:h,...v}=d,f=structuredClone(Ui);return h.fullscreen&&(f.style={...f.style,maxWidth:"none",maxHeight:"none"},f.pt={root:{class:"p-dialog-maximized pt-safe border-none"}}),r("component",{component:u,data:h,...v},f)}function l(u,d){const{data:h,...v}=d,f=structuredClone(Ui);return h.fullscreen&&(f.style={...f.style,maxWidth:"none",maxHeight:"none"},f.pt={root:{class:"p-dialog-maximized pt-safe border-none"}}),r("stepper",{component:u,data:h,...v},f)}return{openTextDialog:i,openImageDialog:o,openComponentDialog:a,openStepperDialog:l}}const i5=tl(Qh);function Il(){const s=ne(()=>typeof window>"u"?!1:[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i].some(k=>navigator.userAgent.match(k))),e=ne(()=>typeof window>"u"?!1:[/Android/i].some(k=>navigator.userAgent.match(k))),t=ne(()=>typeof window>"u"?!1:n.value||r.value),n=ne(()=>typeof window>"u"?!1:[/iPhone/i].some(k=>navigator.userAgent.match(k))),r=ne(()=>typeof window>"u"?!1:[/Macintosh/i].some(k=>navigator.userAgent.match(k)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1)),i=ne(()=>{var k;if(typeof window>"u")return[0,0];const b=/OS [\d_]+/i;return n.value?((k=navigator.userAgent.match(b))==null?void 0:k[0].substr(3).split("_").map(z=>parseInt(z)))||[0,0]:[0,0]}),o=ne(()=>typeof window>"u"?!1:[/Safari/i].some(k=>navigator.userAgent.match(k))),a=ne(()=>{if(typeof window>"u")return null;const b=/Version\/(\d+).+Safari/;return navigator.userAgent.match(b)}),l=ne(()=>typeof window>"u"?!1:[/Firefox/i].some(k=>navigator.userAgent.match(k))),u=ne(()=>typeof window>"u"?!1:[/Chrome/i].some(k=>navigator.userAgent.match(k))),d=ne(()=>{let b=!1;if("maxTouchPoints"in navigator)b=navigator.maxTouchPoints>0;else if("msMaxTouchPoints"in navigator)navigator!==null&&(b=navigator.msMaxTouchPoints>0);else{const k=matchMedia("(pointer:coarse)");if(k&&k.media==="(pointer:coarse)")b=!!k.matches;else if("orientation"in window)b=!0;else{const z=navigator.userAgent;b=/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(z)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(z)}}return b}),h=ne(()=>i5("(display-mode: standalone)").value||window.navigator.standalone||document.referrer.includes("android-app://")),v=ne(()=>{const b=typeof document.body.requestFullscreen<"u"||typeof document.body.mozRequestFullScreen<"u"||typeof document.body.webkitRequestFullscreen<"u"||typeof document.body.msRequestFullscreen<"u"||typeof document.exitFullscreen<"u"||typeof document.mozCancelFullScreen<"u"||typeof document.webkitExitFullscreen<"u",[k,z]=i.value,L=k&&k>=17&&z&&z>=2;return!!(b||!n.value||n.value&&L)}),f=ne(()=>{const b="pictureInPictureEnabled"in document;return t.value&&h.value?!1:b});return{isPWA:h,isMobile:s,isAndroid:e,isIos:t,isIphone:n,isIpad:r,iosVersion:i,isSafari:o,safariVersion:a,isFirefox:l,isChrome:u,isTouch:d,isPipSupported:f,isFsSupported:v}}const o5={class:"flex justify-between items-center mb-4 h-9"},a5={class:"flex items-center gap-2"},c5={class:"text-base font-semibold"},l5={class:"overflow-y-auto",style:{maxHeight:"234px"}},u5={class:"flex gap-3"},d5={class:"flex-1 min-w-0"},h5={class:"flex justify-between items-center"},m5={class:"font-semibold text-sm text-color truncate max-w-[200px]"},p5={class:"text-xs text-muted shrink-0"},f5={class:"text-xs text-muted mt-1 text-left line-clamp-2 overflow-hidden"},g5={key:0,class:"text-center py-8 text-muted text-sm"},v5=At({__name:"CuiNotificationMenu",setup(s){const{t:e}=js(),t=qr(),n=$l(),r=Rl(),{isTouch:i}=Il(),o=Ls(),a=Vt("notificationsMenuRef"),l=ae([]),u=ae({}),d=ae(!1),h=ae(!1);Ge(d,S=>{S&&O()});const v=(S,[M])=>{var oe,ue;if(!M.isIntersecting){(oe=u.value[S])==null||oe.resetFn(),(ue=u.value[S])==null||ue.stopFn(),delete u.value[S];return}if(u.value[S])return;const B=M.target;if(!B.parentElement)return;const I=sl(B,()=>{u.value[S]&&u.value[S].resetFn()});let w;const Q=i.value?G0:W0,{direction:J,stop:q}=Q(B,{threshold:10,disableTextSelect:!0,onSwipe(){var Se,F;for(const D in u.value)D!==S&&((Se=u.value[D])==null||Se.resetFn());J.value==="left"?u.value[S]={left:"-75px",opacity:1,deleteOpacity:1,isSwiping:!0,resetFn(){this.left="0",this.opacity=1,this.deleteOpacity=0},stopFn:()=>{delete u.value[S],q(),I(),clearTimeout(w)}}:(F=u.value[S])==null||F.resetFn()},onSwipeEnd(){clearTimeout(w),w=setTimeout(()=>{u.value[S]&&(u.value[S].isSwiping=!1)},10)}})},f=S=>{var M;(M=a.value)==null||M.toggle(S)},b=S=>{const M=Date.now()-S,B=Math.floor(M/(1e3*60)),W=Math.floor(M/(1e3*60*60)),I=Math.floor(M/(1e3*60*60*24));return B<60?`${B}${e("components.notification_menu.short_minutes")}`:W<24?`${W}${e("components.notification_menu.short_hours")}`:I<7?`${I}${e("components.notification_menu.short_days")}`:I<30?`${Math.floor(I/7)}${e("components.notification_menu.short_weeks")}`:I<365?`${Math.floor(I/30)}${e("components.notification_menu.short_months")}`:`${Math.floor(I/365)}${e("components.notification_menu.short_years")}`},k=S=>{var B;const M=S.link;(B=a.value)==null||B.hide(),z(S),M&&t.push({path:M})},z=S=>{var M;if(S){const B=u.value[S._id];B==null||B.stopFn();const W=l.value.findIndex(I=>I._id===S._id);W!==-1&&(l.value.splice(W,1),(M=o.value)==null||M.socket.emit("remove-notification",S._id))}},L=()=>{var S,M;for(const B in u.value)(S=u.value[B])==null||S.stopFn();l.value.splice(0,l.value.length),(M=o.value)==null||M.socket.emit("clear-notifications")},se=S=>{switch(S){case"info":return"rgb(33, 150, 243)";case"warn":return"rgb(251, 140, 0)";case"error":return"rgb(176, 0, 32)";default:return"rgb(69, 69, 69)"}},K=S=>{const M=u.value[S._id];M!=null&&M.isSwiping||r.openTextDialog({data:{title:S.title,contentText:S.text,confirmText:S!=null&&S.link?e("components.form.button.go_to_message"):e("components.form.button.mark_as_read")},onConfirm:()=>k(S),onCancel:()=>z(S)})},N=()=>{var S,M;for(const B in u.value)(S=u.value[B])==null||S.resetFn(),(M=u.value[B])==null||M.stopFn()},E=(S,M)=>{if(d.value&&M.channel==="update-check"&&M.status==="available"){const B={_id:"system-update",title:"Update",text:"New camera.ui app update available",type:"info",link:"/settings/system",timestamp:Date.now()};if(l.value.find(W=>W._id===B._id))return;l.value.push(B)}},O=async()=>{if(d.value){window.electron.removeListener("app-status",E),window.electron.on("app-status",E),window.electron.send("check-for-updates");try{if((await window.electron.invoke("get-update-available")).isUpdateAvailable){const M={_id:"system-update",title:"Update",text:"New camera.ui app update available",type:"info",link:"/settings/system",timestamp:Date.now()};if(l.value.find(B=>B._id===M._id))return;l.value.push(M)}}catch{}}};Xc(()=>{o.value=n.connectToNamespace("/notifications"),o.value.request("get-notifications").subscribe(S=>{l.value=S}),o.value.socket.on("notifications",S=>{l.value=S}),o.value.socket.on("remove-notification",S=>{const M=l.value.findIndex(B=>B._id===S||B.title===S);M!==-1&&l.value.splice(M,1)}),o.value.socket.on("clear-notifications",()=>{l.value=[]})});const U=()=>{const S=document.querySelector('meta[name="electron-server"]'),M=S!==null&&S.getAttribute("content")==="true";d.value=window.electron!==void 0,h.value=M,setTimeout(()=>{d.value=window.electron!==void 0,h.value=M},100)};return Sn(()=>{U()}),go(()=>{var S,M,B;(M=(S=o.value)==null?void 0:S.end)==null||M.call(S),(B=window.electron)==null||B.removeListener("app-status",E)}),(S,M)=>{const B=zb,W=Oh,I=ys,w=qb,Q=Ca,J=Hc;return m(),A(yt,null,[y(I,{severity:"secondary",text:"",class:"cui-button p-2 text-color non-draggable-region",onClick:f},{icon:$(()=>[y(B,{class:"w-6 h-6"}),c(l).length?(m(),j(W,{key:0,class:"absolute min-w-[8px] w-[8px] h-[8px] right-[10px] top-[7px]"})):ce("",!0)]),_:1}),y(J,{ref_key:"notificationsMenuRef",ref:a,"append-to":"self",class:"w-[20rem] cui-rounded-corner shadow-lg notification-menu isolate overscroll-contain non-draggable-region",onHide:N},{default:$(()=>[g("div",o5,[g("div",a5,[g("h3",c5,me(S.$t("components.notification_menu.notifications")),1),y(W,{class:"rounded-full text-xs p-1"},{default:$(()=>[Qt(me(c(l).length>99?"99+":c(l).length),1)]),_:1})]),c(l).length?(m(),j(I,{key:0,severity:"danger",text:"",rounded:"",class:"p-2 cui-icon-md",onClick:L},{icon:$(()=>[y(w,{width:"100%",height:"100%"})]),_:1})):ce("",!0)]),g("div",l5,[(m(!0),A(yt,null,qt(c(l),q=>{var oe,ue,Se;return m(),A("div",{key:q._id,class:"relative overflow-hidden"},[Tt((m(),A("div",{class:"relative transition-all duration-200",style:ot({left:((oe=c(u)[q._id])==null?void 0:oe.left)||"0",opacity:((ue=c(u)[q._id])==null?void 0:ue.opacity)||1})},[y(I,{severity:"secondary",text:"",class:"cui-button p-2 block w-full",onClick:F=>K(q)},{default:$(()=>[g("div",u5,[g("div",{class:"w-2 h-2 rounded-full mt-2",style:ot({backgroundColor:se(q.type)})},null,4),g("div",d5,[g("div",h5,[g("h4",m5,me(q.title),1),g("span",p5,me(b(q.timestamp)),1)]),g("p",f5,me(q.text),1)])])]),_:2},1032,["onClick"])],4)),[[c(Z0),F=>v(q._id,F)]]),g("div",{class:"absolute right-0 top-0 h-full flex items-center pr-4",style:ot({opacity:((Se=c(u)[q._id])==null?void 0:Se.deleteOpacity)||0})},[y(I,{severity:"danger",class:"cui-icon-sm",text:"",rounded:"",onClick:F=>z(q)},{icon:$(()=>[y(w,{width:"100%",height:"100%"})]),_:2},1032,["onClick"])],4),c(l).indexOf(q)!==c(l).length-1?(m(),j(Q,{key:0,class:"my-0 py-1"})):ce("",!0)])}),128))]),c(l).length===0?(m(),A("div",g5,me(S.$t("components.notification_menu.no_notifications")),1)):ce("",!0)]),_:1},512)],64)}}}),_5={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function y5(s,e){return m(),A("svg",_5,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 17q-2.075 0-3.537-1.463T7 12t1.463-3.537T12 7t3.538 1.463T17 12t-1.463 3.538T12 17M2 13q-.425 0-.712-.288T1 12t.288-.712T2 11h2q.425 0 .713.288T5 12t-.288.713T4 13zm18 0q-.425 0-.712-.288T19 12t.288-.712T20 11h2q.425 0 .713.288T23 12t-.288.713T22 13zm-8-8q-.425 0-.712-.288T11 4V2q0-.425.288-.712T12 1t.713.288T13 2v2q0 .425-.288.713T12 5m0 18q-.425 0-.712-.288T11 22v-2q0-.425.288-.712T12 19t.713.288T13 20v2q0 .425-.288.713T12 23M5.65 7.05L4.575 6q-.3-.275-.288-.7t.288-.725q.3-.3.725-.3t.7.3L7.05 5.65q.275.3.275.7t-.275.7t-.687.288t-.713-.288M18 19.425l-1.05-1.075q-.275-.3-.275-.712t.275-.688q.275-.3.688-.287t.712.287L19.425 18q.3.275.288.7t-.288.725q-.3.3-.725.3t-.7-.3M16.95 7.05q-.3-.275-.288-.687t.288-.713L18 4.575q.275-.3.7-.288t.725.288q.3.3.3.725t-.3.7L18.35 7.05q-.3.275-.7.275t-.7-.275M4.575 19.425q-.3-.3-.3-.725t.3-.7l1.075-1.05q.3-.275.712-.275t.688.275q.3.275.288.688t-.288.712L6 19.425q-.275.3-.7.288t-.725-.288"},null,-1)]))}const b5=pe({name:"material-symbols-light-mode-rounded",render:y5}),w5={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function x5(s,e){return m(),A("svg",w5,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 21q-3.75 0-6.375-2.625T3 12t2.625-6.375T12 3q.35 0 .688.025t.662.075q-1.025.725-1.638 1.888T11.1 7.5q0 2.25 1.575 3.825T16.5 12.9q1.375 0 2.525-.613T20.9 10.65q.05.325.075.662T21 12q0 3.75-2.625 6.375T12 21"},null,-1)]))}const S5=pe({name:"material-symbols-dark-mode",render:x5}),C5={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"},k5=["id"],E5=["mask"];function A5(s,e){return m(),A("svg",C5,[g("defs",null,[g("mask",{id:s.idMap.ipSDarkMode0},e[0]||(e[0]=[g("g",{fill:"none","stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":"10","stroke-width":"4"},[g("path",{fill:"#fff",stroke:"#fff",d:"m24.003 4l5.27 5.27h9.457v9.456l5.27 5.27l-5.27 5.278v9.456h-9.456L24.004 44l-5.278-5.27H9.27v-9.456L4 23.997l5.27-5.27V9.27h9.456z"}),g("path",{fill:"#000",stroke:"#000",d:"M27 17c0 8-5 9-10 9c0 4 6.5 8 12 4s2-13-2-13"})],-1)]),8,k5)]),g("path",{fill:"currentColor",d:"M0 0h48v48H0z",mask:"url(#"+s.idMap.ipSDarkMode0+")"},null,8,E5)])}const M5=pe({name:"icon-park-solid-dark-mode",render:A5,setup(){return{idMap:{ipSDarkMode0:"uicons-"+Math.random().toString(36).substr(2,10)}}}}),Ol=Mi("theme",()=>{const s=localStorage.getItem("theme"),e=s?JSON.parse(s):{theme:"dark",autoMode:!0},t=bu(e.theme,{onBeforeChange(){if(!r.value)return!1},onChanged(h){e.theme=h,localStorage.setItem("theme",JSON.stringify(e))}}),n=bu(e.autoMode,{onBeforeChange(h){if(h&&!r.value)return!1},onChanged(h){e.autoMode=h,localStorage.setItem("theme",JSON.stringify(e))}}),r=ae(!0),i=Pr(["light","dark"]);Ge(n,h=>{h&&(t.value=o())}),Ge(t,h=>{Zs(()=>{l(h),r.value=!0}),r.value=!1});const o=()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",a=()=>n.value?o():t.value,l=h=>{switch(document.documentElement.setAttribute("data-mode",h),h){case"light":document.documentElement.classList.remove("dark-mode");break;case"dark":document.documentElement.classList.add("dark-mode");break}},u=()=>{n.value?(n.value=!1,t.value="light"):t.value==="light"?t.value="dark":n.value=!0},d=Qh("(prefers-color-scheme: dark)");return Ge(d,h=>{n.value&&(t.value=h?"dark":"light")}),l(a()),{colors:i,theme:t,autoMode:n,setAppTheme:l,getSystemMode:o,toggleTheme:u}}),$5=At({__name:"CuiThemeSwitch",setup(s){const e=Ol(),{theme:t,autoMode:n}=Vs(e),r=()=>{e.toggleTheme()};return(i,o)=>{const a=M5,l=S5,u=b5,d=ys;return m(),j(d,{severity:"secondary",text:"",class:"cui-button p-2 text-color",onClick:r},{default:$(()=>[c(n)?(m(),j(a,{key:0,class:"w-6 h-6"})):c(t)==="dark"?(m(),j(l,{key:1,class:"w-6 h-6"})):c(t)==="light"?(m(),j(u,{key:2,class:"w-6 h-6"})):ce("",!0)]),_:1})}}}),T5={class:"relative flex overflow-hidden items-center justify-center w-5 h-5"},P5={class:"flex flex-col justify-between w-4 h-3 transform transition-all duration-100 origin-center overflow-hidden"},R5=At({__name:"CuiNavbarToggle",setup(s){const e=Tl(),{bus:t}=Pl(),{navbarState:n}=Na(),{xlBreakpoint:r}=Vr(),{uiSettings:i}=Vs(e),o=ae("closed"),a=ne(()=>o.value==="opened");Ge(n,u=>{u&&u!==o.value&&(o.value=u==="minified"||u==="closed"?"closed":"opened")});const l=()=>{t.emit({navbarState:o.value==="opened"?"closed":"opened"})};return(u,d)=>{const h=ys;return!c(r)||c(i).interface.navbarStayCollapsed?(m(),j(h,{key:0,id:"menu-icon",class:"cui-button relative group p-2 transition-colors duration-100",severity:"secondary",text:"",onClick:l},{default:$(()=>[g("div",T5,[g("div",P5,[g("div",{class:at(["h-0.5 w-2 transform transition-all duration-100 origin-center",{"w-4 rotate-45 translate-y-[5px]":c(a)}]),style:{backgroundColor:"var(--text-color)"}},null,2),g("div",{class:at(["h-0.5 w-4 rounded transform transition-all duration-100",{"opacity-0":c(a)}]),style:{backgroundColor:"var(--text-color)"}},null,2),g("div",{class:at(["h-0.5 w-3 transform transition-all duration-100 origin-center",{"w-4 -rotate-45 -translate-y-[5px]":c(a)}]),style:{backgroundColor:"var(--text-color)"}},null,2)])])]),_:1})):ce("",!0)}}}),I5={class:"group relative flex items-center"},O5={key:0,class:"flex items-center mr-3 pointer-events-auto"},N5={class:"flex-1 min-w-0 text-left"},F5={class:"text-sm font-medium truncate"},L5=["is-exact-active"],j5=["is-exact-active"],q5=At({__name:"CuiListItem",props:{active:{type:Boolean},disabled:{type:Boolean},to:{},activeClass:{},buttonProps:{},tooltip:{}},emits:["click"],setup(s,{emit:e}){const t=e,n=s,{disabled:r,active:i,to:o,activeClass:a,buttonProps:l,tooltip:u}=Jt(n),[d,h]=cc(),[v,f]=cc(),b=k=>{r.value||t("click",k)};return(k,z)=>{const L=ys,se=Ei("RouterLink"),K=jr;return m(),A("div",I5,[y(c(v),null,{default:$(({isExactActive:N})=>[g("div",{class:at(["relative z-10 flex items-center w-full px-3 py-2 pointer-events-none",{"opacity-80 text-muted pointer-events-none disabled cursor-not-allowed":c(r)}])},[k.$slots.prepend?(m(),A("div",O5,[ei(k.$slots,"prepend",{isExactActive:N??!1},void 0,!0)])):ce("",!0),g("div",N5,[g("div",F5,[ei(k.$slots,"default",{isExactActive:N??!1},void 0,!0)]),k.$slots.subtitle?(m(),A("div",{key:0,"is-exact-active":N??!1,class:"text-sm text-muted mt-0.5"},[ei(k.$slots,"subtitle",{},void 0,!0)],8,L5)):ce("",!0)]),k.$slots.append?(m(),A("div",{key:1,"is-exact-active":N??!1,class:"flex items-center ml-3 pointer-events-auto"},[ei(k.$slots,"append",{},void 0,!0)],8,j5)):ce("",!0)],2)]),_:3}),y(c(d),null,{default:$(({isExactActive:N})=>[Tt(y(L,et({text:"",fluid:"",disabled:c(r),severity:"contrast",class:["cui-button absolute inset-0",[{active:c(i)||N,"cursor-not-allowed disabled":c(r)},c(i)||N?c(a):void 0]]},c(l),{onClick:b}),null,16,["disabled","class"]),[[K,{value:c(u)}]]),y(c(f),{"is-exact-active":N},null,8,["is-exact-active"])]),_:1}),c(o)?(m(),j(se,{key:0,to:c(o),class:"block transition-all duration-300"},{default:$(({isExactActive:N})=>[y(c(h),{"is-exact-active":N},null,8,["is-exact-active"])]),_:1},8,["to"])):(m(),j(c(h),{key:1}))])}}}),up=qs(q5,[["__scopeId","data-v-115e51ef"]]),D5={key:0,class:"flex flex-col gap-1"},B5={key:2,class:"flex flex-col gap-1"},z5={key:4,class:"flex flex-col gap-1"},dp=At({__name:"CuiMenu",props:{items:{},autoHide:{type:Boolean,default:!0},popover:{},sortList:{type:Boolean}},emits:["show","hide","click:menu-item"],setup(s,{expose:e,emit:t}){const n=t,r=s,{items:i,autoHide:o,popover:a,sortList:l}=Jt(r),u=Vt("menuRef"),d=ae(!1),h=ae(),[v,f]=cc(),b=ne(()=>{const S=i.value.filter(M=>!M.hide);return l.value?S.sort((M,B)=>M.key&&B.key?M.key.localeCompare(B.key):M.label&&B.label?M.label.localeCompare(B.label):0):S}),k=ne(()=>b.value.filter(S=>S.position==="header")),z=ne(()=>b.value.filter(S=>S.position==="footer")),L=ne(()=>b.value.filter(S=>!S.position)),se=S=>{var M;o.value&&O(),(M=S.onClick)==null||M.call(S,yu(h.value)),n("click:menu-item",S)},K=()=>{d.value=!0,n("show")},N=()=>{h.value=void 0,d.value=!1,n("hide")},E=(S,M,B)=>{var W;h.value=B,(W=u.value)==null||W.toggle(S,M)},O=()=>{var S;(S=u.value)==null||S.hide()},U=(S,M)=>{var B;(B=u.value)==null||B.show(S,M)};return e({menu:u,isOpen:d,data:yu(h),toggleMenu:E,hide:O,show:U}),(S,M)=>{const B=Vm,W=po,I=up,w=Ca,Q=Hc;return m(),j(Q,et({ref_key:"menuRef",ref:u,class:"shadow-lg cui-rounded-corner"},c(a),{onShow:K,onHide:N}),{default:$(()=>[y(c(v),null,{default:$(({item:J})=>[(m(),j(I,{key:J.key,to:J.to,class:"min-h-10","active-class":"!bg-primary-500/10",disabled:J.disabled,"button-props":J.buttonProps,tooltip:J.tooltip,onClick:q=>se(J)},zh({default:$(({isExactActive:q})=>[g("span",et(J.labelProps,{class:{"text-primary":q||J.active,"!font-bold":J.avatarProps,"opacity-70":!J.disabled}}),me(J.label),17)]),_:2},[J.avatarProps||J.icon?{name:"prepend",fn:$(({isExactActive:q})=>[J.avatarProps?(m(),j(B,B0(et({key:0},J.avatarProps)),null,16)):ce("",!0),J.icon?(m(),j(Ai(J.icon),et({key:1},J.iconProps,{class:{"text-primary":q||J.active,"opacity-70":!J.disabled}}),null,16,["class"])):ce("",!0)]),key:"0"}:void 0,J.description?{name:"subtitle",fn:$(()=>[g("span",et(J.descriptionProps,{class:{"opacity-70":!J.disabled}}),me(J.description),17)]),key:"1"}:void 0,J.toggle?{name:"append",fn:$(()=>[y(W,{"model-value":J.toggleState,disabled:J.disabled,"onUpdate:modelValue":q=>se(J)},null,8,["model-value","disabled","onUpdate:modelValue"])]),key:"2"}:void 0]),1032,["to","disabled","button-props","tooltip","onClick"]))]),_:1}),c(k).length?(m(),A("div",D5,[(m(!0),A(yt,null,qt(c(k),(J,q)=>(m(),j(c(f),{key:q,item:J},null,8,["item"]))),128))])):ce("",!0),c(k).length&&c(L).length?(m(),j(w,{key:1,class:"m-0 py-3"})):ce("",!0),c(L).length?(m(),A("div",B5,[(m(!0),A(yt,null,qt(c(L),(J,q)=>(m(),j(c(f),{key:q,item:J},null,8,["item"]))),128))])):ce("",!0),c(L).length&&c(z).length?(m(),j(w,{key:3,class:"m-0 py-3"})):ce("",!0),c(z).length?(m(),A("div",z5,[(m(!0),A(yt,null,qt(c(z),(J,q)=>(m(),j(c(f),{key:q,item:J},null,8,["item"]))),128))])):ce("",!0)]),_:1},16)}}}),U5={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function V5(s,e){return m(),A("svg",U5,e[0]||(e[0]=[Bh('<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="1.5"><path d="M11 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v7"></path><path stroke-linejoin="round" d="M2 7h20M5 5.01l.01-.011M8 5.01l.01-.011M11 5.01l.01-.011m10.657 11.668C21.047 15.097 19.635 14 17.99 14c-1.758 0-3.252 1.255-3.793 3"></path><path stroke-linejoin="round" d="M19.995 16.772H21.4a.6.6 0 0 0 .6-.6V14.55m-7.666 4.783C14.953 20.903 16.366 22 18.01 22c1.758 0 3.252-1.255 3.793-3"></path><path stroke-linejoin="round" d="M16.005 19.228H14.6a.6.6 0 0 0-.6.6v1.622"></path></g>',1)]))}const H5=pe({name:"iconoir-reload-window",render:V5}),Q5={class:"relative w-6 h-6"},K5=At({__name:"CuiProfileMenu",setup(s){const{t:e}=js(),t=Fs(),{user:n}=Vs(t),r=Vt("menuRef"),i=ne(()=>lo.filter(l=>{var u;return((u=l.meta)==null?void 0:u.profileMenu)&&l.meta.auth&&Si(l)})),o=ne(()=>{var h,v;const l={label:(h=n.value)==null?void 0:h.username,description:(v=n.value)==null?void 0:v.role,to:"/settings/account",position:"header",avatarProps:{src:"avatar",size:35,style:{width:"35px",height:"35px"}}},u=[...i.value.map(f=>({label:e(`navigation.${f.name.toLowerCase()}`),icon:f.meta.profileMenu.icon.default,to:f.path})),{label:e("components.user_menu.reload"),icon:H5,onClick:a}],d={label:e("components.user_menu.logout"),icon:Gh,position:"footer",iconProps:{class:"!text-primary"},labelProps:{class:"!text-primary"},buttonProps:{class:"hover:!bg-primary-500/10 active:!bg-primary-500/10 focus:!bg-primary-500/10"},onClick:t.logout};return[l,...u,d]}),a=()=>{window.location.reload()};return(l,u)=>{var v;const d=ys,h=dp;return m(),A(yt,null,[y(d,{severity:"secondary",text:"",class:"cui-button p-2 text-color",onClick:(v=c(r))==null?void 0:v.toggleMenu},{default:$(()=>{var f,b,k;return[g("div",Q5,[g("div",{class:at(["absolute top-0.5 left-1/2 -translate-x-1/2 w-1.5 h-1.5 rounded-full transform transition-all duration-100 origin-center",{"w-4 h-[2px] rotate-45 top-1/2 -translate-y-1/2 rounded-none":(f=c(r))==null?void 0:f.isOpen}]),style:{backgroundColor:"var(--text-color)"}},null,2),g("div",{class:at(["absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1.5 h-1.5 rounded-full transition-all duration-100",{"opacity-0 scale-0":(b=c(r))==null?void 0:b.isOpen}]),style:{backgroundColor:"var(--text-color)"}},null,2),g("div",{class:at(["absolute bottom-0.5 left-1/2 -translate-x-1/2 w-1.5 h-1.5 rounded-full transform transition-all duration-100 origin-center",{"w-4 h-[2px] -rotate-45 bottom-1/2 translate-y-1/2 rounded-none":(k=c(r))==null?void 0:k.isOpen}]),style:{backgroundColor:"var(--text-color)"}},null,2)])]}),_:1},8,["onClick"]),y(h,{ref_key:"menuRef",ref:r,items:c(o),popover:{appendTo:"self",pt:{root:{class:"w-[18rem] profile-menu"}}}},null,8,["items"])],64)}}}),Z5={HEIGHT:60},G5={class:"flex flex-row items-center flex-1 p-2"},W5=At({__name:"CuiTopbar",setup(s){const{showBottombar:e}=Na();return(t,n)=>{const r=K5,i=R5,o=$5,a=v5;return m(),A("header",{class:"cui-topbar fixed flex flex-row items-center right-0 pt-safe pr-safe draggable-region",style:ot({height:`calc(${c(Z5).HEIGHT}px + env(safe-area-inset-top, 0px))`})},[g("div",G5,[c(e)?(m(),j(r,{key:0,class:"non-draggable-region"})):(m(),j(i,{key:1,class:"non-draggable-region"})),y(o,{class:"ml-auto non-draggable-region"}),("useCuiPermission"in t?t.useCuiPermission:c(Si))(void 0,"admin")?(m(),j(a,{key:2})):ce("",!0)])],4)}}}),J5=qs(W5,[["__scopeId","data-v-162b131f"]]),Y5={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function X5(s,e){return m(),A("svg",Y5,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4m-8-2l8-8m0 0v5m0-5h-5"},null,-1)]))}const ew=pe({name:"majesticons-open",render:X5}),hp=At({__name:"CuiChipGroup",props:Kn({selectedClass:{},disabled:{type:Boolean},mandatory:{type:Boolean},multiple:{type:Boolean}},{modelValue:{required:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(s){const e=Rr(s,"modelValue"),t=s,{selectedClass:n,disabled:r,mandatory:i,multiple:o}=Jt(t);return Yc("chipGroup",{modelValue:e,selectedClass:n,disabled:r,mandatory:i,updateSelected:l=>{if(!r.value)if(o.value){let u=[...Array.isArray(e.value)?e.value:[]];u.includes(l)?(!i.value||u.length>1)&&(u=u.filter(d=>d!==l)):u.push(l),e.value=u}else e.value===l?i.value||(e.value=void 0):e.value=l}}),(l,u)=>(m(),A("div",{class:at(["flex flex-wrap gap-2",{"opacity-60 pointer-events-none":c(r)}])},[ei(l.$slots,"default")],2))}}),tw={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sw(s,e){return m(),A("svg",tw,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z"},null,-1)]))}const mp=pe({name:"mdi-check",render:sw}),nw={key:0,class:"absolute left-1 top-1/2 transform -translate-y-1/2 flex items-center justify-center cui-icon-sm"},rw=At({__name:"CuiChip",props:{value:{},removable:{type:Boolean},disabled:{type:Boolean},size:{},filter:{type:Boolean}},setup(s){const e=s,{value:t,removable:n,disabled:r,size:i,filter:o}=Jt(e),a=mi("chipGroup"),l=ne(()=>r.value||(a==null?void 0:a.disabled.value)),u=ne(()=>{if(!a)return!1;const v=a.modelValue.value;return Array.isArray(v)?v.includes(t.value):v===t.value}),d=ne(()=>u.value?a==null?void 0:a.selectedClass.value:void 0),h=()=>{l.value||a==null||a.updateSelected(t.value)};return(v,f)=>{const b=mp,k=$0;return m(),j(k,{removable:c(n),disabled:c(l),class:at(["cui-chip inline-flex cursor-pointer transition-all rounded-full py-1 px-2 relative",[{"cui-chip-selected":c(u),"cui-chip-disabled":c(l),"cui-chip-small":c(i)==="small","cui-chip-medium":c(i)==="medium","cui-chip-large":c(i)==="large","pl-7":c(o)&&c(u)},c(d)]]),onClick:h},{default:$(()=>[y(Et,{name:"fade"},{default:$(()=>[c(o)&&c(u)?(m(),A("div",nw,[y(b,{width:"100%",height:"100%"})])):ce("",!0)]),_:1}),ei(v.$slots,"default",{},void 0,!0)]),_:3},8,["removable","disabled","class"])}}}),pp=qs(rw,[["__scopeId","data-v-3b79f904"]]),iw=async({cameraData:s})=>(await Ie.post("/cameras",s)).data,ow=async({cameraData:s})=>(await Ie.post("/cameras/pair",s)).data,aw=async({cameraData:s})=>(await Ie.post("/cameras/preview",s)).data,fp=async({cameraname:s,signal:e})=>(await Ie.get(`/cameras/${s}`,{signal:e})).data,cw=async({cameraname:s})=>(await Ie.delete(`/cameras/${s}/log`)).data,lw=async({cameraname:s,signal:e})=>(await Ie.get(`/cameras/${s}/log/download`,{signal:e})).data,uw=async({cameraname:s,sourcename:e,probeConfig:t,signal:n})=>(await Ie.get(`/cameras/${s}/probe/${e}`,{params:{...t},signal:n})).data,dw=async({cameraname:s,forceNew:e,signal:t})=>(await Ie.get(`/cameras/${s}/snapshot`,{signal:t,params:{forceNew:e}})).data,hw=async({parameter:s,signal:e})=>(await Ie.get("/cameras",{params:s,signal:e})).data,mw=async({type:s,src:e,signal:t})=>(await Ie.get("/cameras/discover",{params:{type:s,src:e},signal:t})).data,pw=async({cameraname:s,cameraData:e})=>(await Ie.patch(`/cameras/${s}`,e)).data,fw=async({cameraname:s,signal:e})=>(await Ie.get(`/cameras/${s}/extensions`,{signal:e})).data,gw=async({cameraname:s,pluginname:e,signal:t})=>(await Ie.get(`/cameras/${s}/${e}/config`,{signal:t})).data,vw=async({cameraname:s,pluginname:e,configData:t})=>(await Ie.patch(`/cameras/${s}/${e}/config`,t)).data,_w=async({cameraname:s,pluginname:e,configData:t})=>(await Ie.put(`/cameras/${s}/${e}/config`,t)).data,yw=async({cameraname:s,pluginname:e,configData:t})=>(await Ie.post(`/cameras/${s}/${e}/config`,t)).data,bw=async({cameraname:s,pluginname:e,type:t})=>(await Ie.put(`/cameras/${s}/${e}/enable`,null,{params:{type:t}})).data,ww=async({cameraname:s,pluginname:e,type:t})=>(await Ie.put(`/cameras/${s}/${e}/disable`,null,{params:{type:t}})).data,xw=async({cameraname:s,pluginname:e,type:t})=>(await Ie.post(`/cameras/${s}/${e}`,null,{params:{type:t}})).data,Sw=async({cameraname:s,pluginname:e,type:t})=>(await Ie.delete(`/cameras/${s}/${e}`,{params:{type:t}})).data,Cw=async({cameraname:s,signal:e})=>(await Ie.get(`/cameras/${s}/zones`,{signal:e})).data,kw=async({cameraname:s,zoneData:e})=>(await Ie.patch(`/cameras/${s}/zones`,e)).data,Ew=async({cameraname:s})=>(await Ie.delete(`/cameras/${s}`)).data,Aw=async()=>(await Ie.delete("/cameras")).data;class Jn{constructor(){p(this,"_queryClient",Ci());p(this,"t",js().t);p(this,"toast",Cn());p(this,"queryActivator",ae([{name:"getCameraQuery",enabled:!0},{name:"getCamerasQuery",enabled:!0},{name:"discoverCamerasQuery",enabled:!0},{name:"getCameraSnapshotQuery",enabled:!0},{name:"getCameraExtensionsQuery",enabled:!0},{name:"getCameraExtensionConfigQuery",enabled:!0},{name:"getZonesQuery",enabled:!0},{name:"probeCameraSourceQuery",enabled:!0},{name:"downloadLogQuery",enabled:!0}]))}get queryClient(){return this._queryClient}createCameraQuery(){return ut({mutationFn:iw,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["camerasList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.camera_added"),life:3e3})}})}pairCameraQuery(){return ut({mutationFn:ow,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["camerasList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.camera_added"),life:3e3})}})}previewCameraQuery(){return ut({mutationFn:aw})}getCameraQuery(e){return Bt({queryKey:["cameras",e],queryFn:({signal:t})=>fp({cameraname:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getCameraQuery"&&t.enabled)})}getCameraExtensionsQuery(e){return Bt({queryKey:["camerasExtensions",e],queryFn:({signal:t})=>fw({cameraname:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getCameraExtensionsQuery"&&t.enabled)})}probeCameraSourceQuery(e,t,n){return Bt({queryKey:["cameras",e,"probe",t],queryFn:({signal:r})=>uw({cameraname:c(e),sourcename:c(t),probeConfig:c(n),signal:r}),enabled:()=>this.queryActivator.value.some(r=>r.name==="probeCameraSourceQuery"&&r.enabled)})}getCameraSnapshotQuery(e,t){return Bt({queryKey:["camerasSnapshot",e],queryFn:({signal:n})=>dw({cameraname:c(e),forceNew:c(t),signal:n}),enabled:()=>this.queryActivator.value.some(n=>n.name==="getCameraSnapshotQuery"&&n.enabled),retry:!1})}getCamerasQuery(e){return Bt({queryKey:["camerasList",e],queryFn:({signal:t})=>hw({parameter:c(e),signal:t}),placeholderData:t=>t,enabled:()=>this.queryActivator.value.some(t=>t.name==="getCamerasQuery"&&t.enabled)})}discoverCamerasQuery(e){return Bt({queryKey:["cameras","discover",e],queryFn:({signal:t})=>mw({...c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="discoverCamerasQuery"&&t.enabled)})}patchCameraQuery(){return ut({mutationFn:pw,onSuccess:async(e,t)=>{if(t.cameraData.name&&t.cameraData.name!==t.cameraname){const r=t.cameraname;await this._queryClient.invalidateQueries({queryKey:[r]}),await this._queryClient.refetchQueries({queryKey:["camerasList"]})}else await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname]}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]}),await this._queryClient.refetchQueries({queryKey:["cameras","extensions",t.cameraname]});this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.camera_updated"),life:3e3})}})}getCameraExtensionConfigQuery(e,t,n){return Bt({queryKey:["cameras","extensions",e,t],queryFn:({signal:r})=>gw({cameraname:c(e),pluginname:c(t),signal:r}),enabled:()=>this.queryActivator.value.some(r=>r.name==="getCameraExtensionConfigQuery"&&r.enabled),refetchInterval(){if(n.value)return 15e3},retry:10,retryDelay:500,staleTime:0})}patchCameraExtensionConfigQuery(){return ut({mutationFn:vw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["cameras","extensions",t.cameraname]}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}setCameraExtensionConfigQuery(){return ut({mutationFn:_w,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["cameras","extensions",t.cameraname]}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}submitCameraExtensionConfigQuery(){return ut({mutationFn:yw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["cameras","extensions",t.cameraname]}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}enableCameraExtensionQuery(){return ut({mutationFn:bw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}disableCameraExtensionQuery(){return ut({mutationFn:ww,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}addCameraExtensionQuery(){return ut({mutationFn:xw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}getZonesQuery(e){return Bt({queryKey:["cameras",e,"zones"],queryFn:({signal:t})=>Cw({cameraname:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getZonesQuery"&&t.enabled)})}patchZonesQuery(){return ut({mutationFn:kw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.zone_updated"),life:3e3})}})}removeCameraExtensionQuery(){return ut({mutationFn:Sw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["cameras",t.cameraname],exact:!0}),await this._queryClient.refetchQueries({queryKey:["camerasExtensions",t.cameraname]})}})}removeCameraQuery(){return ut({mutationFn:Ew,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["camerasList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.camera_removed"),life:3e3})}})}removeCamerasQuery(){return ut({mutationFn:Aw,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["camerasList"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.cameras_removed"),life:3e3})}})}downloadLogQuery(e){return Bt({queryKey:["logs",e],queryFn:({signal:t})=>lw({cameraname:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="downloadLogQuery"&&t.enabled)})}clearLogQuery(){return ut({mutationFn:cw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["logs",t.cameraname],exact:!0}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.log_cleared"),life:3e3})}})}toggleQueryActivator(e,t){const n=this.queryActivator.value.find(r=>r.name===e);n&&(n.enabled=t)}}const Mw=async({pluginData:s})=>(await Ie.post("/plugins",s)).data,$w=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}`,{signal:e})).data,Tw=async({pluginname:s,signal:e})=>(await Ie.get(`/plugins/${s}/versions`,{signal:e})).data,Pw=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/update`,{signal:e})).data,Rw=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/logo`,{signal:e})).data,Iw=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/config`,{signal:e})).data,Ow=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/contract`,{signal:e})).data,Nw=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/readme`,{signal:e})).data,Fw=async({pluginName:s,query:e,signal:t})=>(await Ie.get(`/plugins/${s}/changelog`,{params:e,signal:t})).data,Lw=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/interface`,{signal:e})).data,jw=async({parameter:s,signal:e})=>(await Ie.get("/plugins",{params:s,signal:e})).data,qw=async({parameter:s,signal:e})=>(await Ie.get("/plugins/extensions",{params:s,signal:e})).data,Dw=async({pluginName:s})=>(await Ie.delete(`/plugins/${s}/log`)).data,Bw=async({pluginName:s,signal:e})=>(await Ie.get(`/plugins/${s}/log/download`,{signal:e})).data,zw=async({parameter:s,signal:e})=>(await Ie.get("/plugins/progress",{params:s,signal:e})).data,Uw=async({query:s,parameter:e,signal:t})=>(await Ie.get("/plugins/search",{params:{...s,...e},signal:t})).data,Vw=async({pluginName:s})=>(await Ie.put(`/plugins/${s}/enable`)).data,Hw=async({pluginName:s,configData:e})=>(await Ie.patch(`/plugins/${s}/config`,e)).data,Qw=async({pluginname:s,configData:e})=>(await Ie.put(`/plugins/${s}/config`,e)).data,Kw=async({pluginname:s,configData:e})=>(await Ie.post(`/plugins/${s}/config`,e)).data,Zw=async({pluginName:s})=>(await Ie.put(`/plugins/${s}/disable`)).data,Gw=async({pluginName:s})=>(await Ie.put(`/plugins/${s}/start`)).data,Ww=async({pluginName:s})=>(await Ie.put(`/plugins/${s}/stop`)).data,Jw=async({pluginName:s})=>(await Ie.put(`/plugins/${s}/restart`)).data,Yw=async({pluginName:s,formData:e})=>(await Ie.post(`/plugins/${s}/detect/motion`,e,{responseType:"arraybuffer"})).data,Xw=async({pluginName:s,formData:e})=>(await Ie.post(`/plugins/${s}/detect/objects`,e)).data,e3=async({pluginName:s,formData:e})=>(await Ie.post(`/plugins/${s}/detect/audio`,e)).data,t3=async({pluginName:s,removeStorage:e})=>(await Ie.delete(`/plugins/${s}`,{params:{removeStorage:e}})).data,s3=async()=>(await Ie.delete("/plugins")).data;class gp{constructor(){p(this,"_queryClient",Ci());p(this,"t",js().t);p(this,"toast",Cn());p(this,"queryActivator",ae([{name:"getPluginQuery",enabled:!0},{name:"getPluginsQuery",enabled:!0},{name:"getPluginsExtensionsQuery",enabled:!0},{name:"searchPluginsQuery",enabled:!0},{name:"getPluginVersionsQuery",enabled:!0},{name:"getPluginUpdateQuery",enabled:!0},{name:"getPluginLogoQuery",enabled:!0},{name:"getPluginConfigQuery",enabled:!0},{name:"getPluginContractQuery",enabled:!0},{name:"getPluginReadmeQuery",enabled:!0},{name:"getPluginInterfaceQuery",enabled:!0},{name:"getPluginChangelogQuery",enabled:!0},{name:"getPluginsProgressQuery",enabled:!0},{name:"installPluginQuery",enabled:!0},{name:"enablePluginQuery",enabled:!0},{name:"disablePluginQuery",enabled:!0},{name:"patchPluginConfigQuery",enabled:!0},{name:"setPluginConfigQuery",enabled:!0},{name:"submitPluginConfigQuery",enabled:!0},{name:"startPluginQuery",enabled:!0},{name:"stopPluginQuery",enabled:!0},{name:"restartPluginQuery",enabled:!0},{name:"detectMotionQuery",enabled:!0},{name:"detectObjectsQuery",enabled:!0},{name:"detectAudioQuery",enabled:!0},{name:"uninstallPluginQuery",enabled:!0},{name:"uninstallPluginsQuery",enabled:!0},{name:"downloadLogQuery",enabled:!0}]))}get queryClient(){return this._queryClient}installPluginQuery(){return ut({mutationFn:Mw,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["pluginsList"]}),await this._queryClient.refetchQueries({queryKey:["plugins"]}),await this._queryClient.refetchQueries({queryKey:["pluginsSearch"]}),await this._queryClient.refetchQueries({queryKey:["pluginsProgress"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_installed"),life:3e3})}})}getPluginQuery(e){return Bt({queryKey:["plugins",e],queryFn:({signal:t})=>$w({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginQuery"&&t.enabled)})}getPluginsQuery(e){return Bt({queryKey:["pluginsList",e],queryFn:({signal:t})=>jw({parameter:c(e),signal:t}),placeholderData:t=>t,enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginsQuery"&&t.enabled)})}getPluginsExtensionsQuery(e){return Bt({queryKey:["extensionsList",e],queryFn:({signal:t})=>qw({parameter:c(e),signal:t}),placeholderData:t=>t,enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginsExtensionsQuery"&&t.enabled)})}getPluginsProgressQuery(e){return Bt({queryKey:["pluginsProgress",e],queryFn:({signal:t})=>zw({parameter:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginsProgressQuery"&&t.enabled)})}searchPluginsQuery(e,t){return Bt({queryKey:["pluginsSearch",e,t],queryFn:({signal:n})=>Uw({query:c(e),parameter:c(t),signal:n}),placeholderData:n=>n,enabled:()=>this.queryActivator.value.some(n=>n.name==="searchPluginsQuery"&&n.enabled)})}getPluginVersionsQuery(e){return Bt({queryKey:["plugins",e,"versions"],queryFn:({signal:t})=>Tw({pluginname:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginVersionsQuery"&&t.enabled)})}getPluginUpdateQuery(e){return Bt({queryKey:["plugins",e,"update"],queryFn:({signal:t})=>Pw({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginUpdateQuery"&&t.enabled)})}getPluginLogoQuery(e){return Bt({queryKey:["plugins",e,"logo"],queryFn:({signal:t})=>Rw({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginLogoQuery"&&t.enabled)})}getPluginConfigQuery(e){return Bt({queryKey:["plugins",e,"config"],queryFn:({signal:t})=>Iw({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginConfigQuery"&&t.enabled)})}getPluginContractQuery(e){return Bt({queryKey:["plugins",e,"contract"],queryFn:({signal:t})=>Ow({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginContractQuery"&&t.enabled)})}getPluginReadmeQuery(e){return Bt({queryKey:["plugins",e,"readme"],queryFn:({signal:t})=>Nw({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginReadmeQuery"&&t.enabled)})}getPluginInterfaceQuery(e){return Bt({queryKey:["plugins",e,"interface"],queryFn:({signal:t})=>Lw({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="getPluginInterfaceQuery"&&t.enabled)})}getPluginChangelogQuery(e,t){return Bt({queryKey:["plugins",e,"changelog"],queryFn:({signal:n})=>Fw({pluginName:c(e),query:c(t),signal:n}),enabled:()=>this.queryActivator.value.some(n=>n.name==="getPluginChangelogQuery"&&n.enabled)})}patchPluginConfigQuery(){return ut({mutationFn:Hw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginName]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_config_updated"),life:3e3})}})}startPluginQuery(){return ut({mutationFn:Gw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginName]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_started"),life:3e3})}})}stopPluginQuery(){return ut({mutationFn:Ww,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginName]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_stopped"),life:3e3})}})}restartPluginQuery(){return ut({mutationFn:Jw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginName]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_restarted"),life:3e3})}})}detectMotionQuery(){return ut({mutationFn:Yw})}detectObjectsQuery(){return ut({mutationFn:Xw})}detectAudioQuery(){return ut({mutationFn:e3})}setPluginConfigQuery(){return ut({mutationFn:Qw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginname,t.configData]})}})}submitPluginConfigQuery(){return ut({mutationFn:Kw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginname,t.configData]})}})}enablePluginQuery(){return ut({mutationFn:Vw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["pluginsList"]}),await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginName]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_enabled"),life:3e3})}})}disablePluginQuery(){return ut({mutationFn:Zw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["pluginsList"]}),await this._queryClient.refetchQueries({queryKey:["plugins",t.pluginName]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_disabled"),life:3e3})}})}uninstallPluginQuery(){return ut({mutationFn:t3,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["pluginsList"]}),await this._queryClient.refetchQueries({queryKey:["pluginsSearch"]}),await this._queryClient.refetchQueries({queryKey:["pluginsProgress"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugin_removed"),life:3e3})}})}uninstallPluginsQuery(){return ut({mutationFn:s3,onSuccess:async()=>{await this._queryClient.refetchQueries({queryKey:["pluginsList"]}),await this._queryClient.refetchQueries({queryKey:["pluginsSearch"]}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.plugins_removed"),life:3e3})}})}downloadLogQuery(e){return Bt({queryKey:["logs",e],queryFn:({signal:t})=>Bw({pluginName:c(e),signal:t}),enabled:()=>this.queryActivator.value.some(t=>t.name==="downloadLogQuery"&&t.enabled)})}clearLogQuery(){return ut({mutationFn:Dw,onSuccess:async(e,t)=>{await this._queryClient.refetchQueries({queryKey:["logs",t.pluginName],exact:!0}),this.toast.add({severity:"success",summary:this.t("components.toast.title_success"),detail:this.t("components.toast.log_cleared"),life:3e3})}})}toggleQueryActivator(e,t){const n=this.queryActivator.value.find(r=>r.name===e);n&&(n.enabled=t)}}const n3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function r3(s,e){return m(),A("svg",n3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M17 13h-4v4h-2v-4H7v-2h4V7h2v4h4m-5-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2"},null,-1)]))}const vp=pe({name:"mdi-plus-circle",render:r3}),i3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function o3(s,e){return m(),A("svg",i3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2"},null,-1)]))}const a3=pe({name:"mdi-information",render:o3}),c3={key:0,class:"flex flex-col field-gap"},l3=["for"],u3={key:1,class:"flex flex-col field-gap"},d3=["for"],h3=["for"],m3=["for"],p3={class:"flex items-center gap-4"},f3={class:"flex flex-col field-switch-gap"},g3=["for"],v3=["for"],_3={class:"flex gap-2 items-center w-full"},y3={class:"text-color"},b3={class:"w-full h-full flex flex-col gap-6"},w3={class:"flex flex-row w-full items-center justify-center mt-3"},x3=At({__name:"CuiSchemaField",props:Kn({schemaField:{},configKey:{},arrayItem:{},loading:{type:Boolean,default:!1}},{modelValue:{type:Object,required:!0},modelModifiers:{}}),emits:Kn(["onAction","onSubmit","onTrigger"],["update:modelValue"]),setup(s,{emit:e}){const t=Ol(),n=e,r=Rr(s,"modelValue"),i=s,{theme:o}=Vs(t),{schemaField:a,configKey:l,arrayItem:u,loading:d}=Jt(i),h=ae(0),v=ae(0),f=ae(a.value.opened?[l.value]:[]);Ge(r,()=>{h.value++},{deep:!0});const b=J0(async()=>{if(ar(a.value)&&a.value.format==="qrCode"){let N;return o.value==="dark"?N={dark:"#FFFFFFFF",light:"#FF000000"}:N={dark:"#404040FF",light:"#FFFFFFFF"},await wf.toDataURL(K.value||"",{margin:.5,type:"image/png",color:N,scale:10})}},void 0,{lazy:!0}),k=ne(()=>{if(ar(a.value)&&a.value.format==="image")return K.value}),z=(N,E)=>{const O=ni(N,E);return Array.isArray(O)?O:[]},L=N=>{const E=ni(r.value,N),O=Array.isArray(E)?[...E]:[];fh(a.value)&&a.value.items&&(O.push(Ml(a.value.items)),rc(r.value,N,O),v.value++)},se=(N,E)=>{const O=ni(r.value,N);if(Array.isArray(O)){const U=[...O];U.splice(E,1),rc(r.value,N,U),v.value++,n("onTrigger")}},K=ne({get:()=>(h.value,ni(r.value,l.value)),set:N=>{const E=a.value;let O=N;ba(E)?E.multiple?O=Array.isArray(N)?N:[N]:O=N&&N.toString():ar(E)?O=N!=null?N.toString():"":mh(E)?O=typeof N=="number"?N:parseFloat(N)||0:ph(E)&&(O=N==="true"||N===!0),rc(r.value,l.value,O),h.value++}});return(N,E)=>{const O=Ia,U=ki,S=Ih,M=vo,B=ys,W=ka,I=fo,w=Qc,Q=Nh,J=po,q=Kc,oe=Fh,ue=a3,Se=Wc,F=Ei("CuiSchemaField",!0),D=vp,Y=Jc,Pe=Gc,He=Zc,ht=Lh,Mt=jr;return m(),A("div",null,[c(ar)(c(a))&&c(a).format==="qrCode"?(m(),A("div",c3,[g("label",{for:c(l),class:"cui-label"},me(c(a).title),9,l3),y(O,{src:c(b),class:"mb-3","image-container-class":"w-full h-full"},null,8,["src"])])):ce("",!0),c(ar)(c(a))&&c(a).format==="image"?(m(),A("div",u3,[g("label",{for:c(l),class:"cui-label"},me(c(a).title),9,d3),y(O,{src:c(k),class:"mb-3","image-container-class":"w-full h-full"},null,8,["src"])])):c(Fy)(c(a))?(m(),j(c(Lt),{key:2,modelValue:c(K),"onUpdate:modelValue":E[1]||(E[1]=Qe=>us(K)?K.value=Qe:null),modelModifiers:{trim:!0},name:c(l),as:"div",class:"flex flex-col field-gap"},{default:$(({field:Qe,errors:ze})=>[g("label",{for:c(l),class:"cui-label"},me(c(a).title),9,h3),y(I,null,{default:$(()=>[c(a).format!=="password"?(m(),j(U,et({key:0},Qe,{invalid:ze.length>0,readonly:c(a).readonly,placeholder:c(a).placeholder,loading:c(d),type:"text"}),null,16,["invalid","readonly","placeholder","loading"])):(m(),j(S,et({key:1,"model-value":c(K),invalid:ze.length>0,readonly:c(a).readonly},Qe,{feedback:!1,"toggle-mask":""}),null,16,["model-value","invalid","readonly"])),c(u)?(m(),j(W,{key:2},{default:$(()=>[y(B,{text:"",severity:"secondary",loading:c(d),onClick:E[0]||(E[0]=ge=>se(c(u).key,c(u).index))},{icon:$(()=>[y(M)]),_:1},8,["loading"])]),_:1})):ce("",!0)]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:c(l),class:"cui-input-error"},null,8,["name"])]),_:1}),!ze.length&&c(a).description?(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(c(a).description),1)]),_:1})):ce("",!0)]),_:1},8,["modelValue","name"])):c(mh)(c(a))?(m(),j(c(Lt),{key:3,"model-value":c(K),name:c(l),as:"div",class:"flex flex-col field-gap"},{default:$(({field:Qe,errors:ze})=>[g("label",{for:c(l),class:"cui-label"},me(c(a).title),9,m3),y(I,null,{default:$(()=>[y(Q,et(Qe,{modelValue:c(K),"onUpdate:modelValue":E[2]||(E[2]=ge=>us(K)?K.value=ge:null),invalid:ze.length>0,readonly:c(a).readonly,step:c(a).step||1,min:c(a).minimum,max:c(a).maximum,"use-grouping":!1,loading:c(d),onValueChange:E[3]||(E[3]=ge=>K.value=ge),onInput:E[4]||(E[4]=ge=>K.value=ge.value)}),null,16,["modelValue","invalid","readonly","step","min","max","loading"]),c(u)?(m(),j(W,{key:0},{default:$(()=>[y(B,{text:"",rounded:"",severity:"danger",loading:c(d),onClick:E[5]||(E[5]=ge=>se(c(u).key,c(u).index))},{icon:$(()=>[y(M)]),_:1},8,["loading"])]),_:1})):ce("",!0)]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:c(l),class:"cui-input-error"},null,8,["name"])]),_:1}),!ze.length&&c(a).description?(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(c(a).description),1)]),_:1})):ce("",!0)]),_:1},8,["model-value","name"])):c(ph)(c(a))?(m(),j(c(Lt),{key:4,"model-value":c(K),value:!0,"unchecked-value":!1,type:"checkbox",name:c(l),as:"div",class:"flex flex-col field-gap"},{default:$(({field:Qe,errors:ze})=>[g("div",p3,[g("div",f3,[g("label",{for:c(l),class:"cui-label-switch"},me(c(a).title),9,g3),y(w,{severity:"secondary",variant:"simple",size:"small",class:"cui-input-switch-hint"},{default:$(()=>[Qt(me(c(a).description),1)]),_:1}),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:c(l),class:"cui-input-switch-error"},null,8,["name"])]),_:1})]),y(J,et({"model-value":c(K)},Qe,{invalid:ze.length>0,loading:c(d),class:"ml-auto shrink-0",onValueChange:E[6]||(E[6]=ge=>K.value=ge)}),null,16,["model-value","invalid","loading"])])]),_:1},8,["model-value","name"])):c(ba)(c(a))?(m(),j(c(Lt),{key:5,"model-value":c(K),name:c(l),as:"div",class:"flex flex-col field-gap"},{default:$(({field:Qe,errors:ze})=>[g("label",{for:c(l),class:"cui-label"},me(c(a).title),9,v3),y(I,null,{default:$(()=>[c(a).multiple?(m(),j(oe,et({key:1},Qe,{"model-value":c(K),options:c(a).enum,invalid:ze.length>0,disabled:c(a).readonly,placeholder:c(a).placeholder,"show-clear":!c(a).required&&!c(a).readonly,"show-toggle-all":!1,"max-selected-labels":3,loading:c(d),onValueChange:E[8]||(E[8]=ge=>K.value=ge)}),null,16,["model-value","options","invalid","disabled","placeholder","show-clear","loading"])):(m(),j(q,et({key:0},Qe,{"model-value":c(K),options:c(a).enum,invalid:ze.length>0,disabled:c(a).readonly,placeholder:c(a).placeholder,loading:c(d),onValueChange:E[7]||(E[7]=ge=>K.value=ge)}),null,16,["model-value","options","invalid","disabled","placeholder","loading"])),c(u)?(m(),j(W,{key:2},{default:$(()=>[y(B,{text:"",rounded:"",severity:"danger",loading:c(d),onClick:E[9]||(E[9]=ge=>se(c(u).key,c(u).index))},{icon:$(()=>[y(M)]),_:1},8,["loading"])]),_:1})):ce("",!0)]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:c(l),class:"cui-input-error"},null,8,["name"])]),_:1}),!ze.length&&c(a).description?(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(c(a).description),1)]),_:1})):ce("",!0)]),_:1},8,["model-value","name"])):c(zr)(c(a))?(m(),A(yt,{key:6},[y(B,{fluid:"",class:"mt-3 mb-1 cui-button-medium",severity:c(a).color??"secondary",loading:c(d),label:c(a).title,onClick:E[10]||(E[10]=lr(Qe=>n("onAction",{key:c(l)}),["prevent"]))},null,8,["severity","loading","label"]),c(a).description?(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(c(a).description),1)]),_:1})):ce("",!0)],64)):c(Ur)(c(a))?(m(),A(yt,{key:7},[y(B,{fluid:"",class:"mt-3 mb-1 cui-button-medium",severity:c(a).color??"secondary",loading:c(d),label:c(a).title,onClick:E[11]||(E[11]=lr(Qe=>n("onSubmit",{key:c(a).key}),["prevent"]))},null,8,["severity","loading","label"]),c(a).description?(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(c(a).description),1)]),_:1})):ce("",!0)],64)):c(fh)(c(a))&&c(a).items?(m(),j(ht,{key:8,class:"cui-card border-color-inner",pt:{body:{class:"p-1"}}},{content:$(()=>[(m(),j(He,{key:c(v),value:c(f),"onUpdate:value":E[18]||(E[18]=Qe=>us(f)?f.value=Qe:null),multiple:""},{default:$(()=>[y(Pe,{value:c(l)??"0",class:"border-none"},{default:$(()=>[y(Se,null,{default:$(()=>[g("div",_3,[c(a).description?Tt((m(),j(ue,{key:0,class:"text-muted"},null,512)),[[Mt,{value:c(a).description}]]):ce("",!0),g("span",y3,me(c(a).title||c(l)),1),c(u)?(m(),j(B,{key:1,text:"",rounded:"",severity:"danger",class:"cui-icon-md ml-auto mr-2",loading:c(d),onClick:E[12]||(E[12]=Qe=>se(c(u).key,c(u).index))},{icon:$(()=>[y(M,{width:"100%",height:"100%"})]),_:1},8,["loading"])):ce("",!0)])]),_:1}),y(Y,null,{default:$(()=>[g("div",b3,[(m(!0),A(yt,null,qt(z(r.value,c(l)),(Qe,ze)=>(m(),j(F,{key:`item-${ze}`,modelValue:r.value,"onUpdate:modelValue":E[13]||(E[13]=ge=>r.value=ge),"schema-field":c(a).items,"config-key":`${c(l)}[${ze}]`,"array-item":{key:c(l),index:ze},loading:c(d),onOnAction:E[14]||(E[14]=ge=>n("onAction",ge)),onOnSubmit:E[15]||(E[15]=ge=>n("onSubmit",ge)),onOnTrigger:E[16]||(E[16]=()=>v.value++)},null,8,["modelValue","schema-field","config-key","array-item","loading"]))),128)),g("div",w3,[y(B,{text:"",rounded:"",class:"cui-icon-md",loading:c(d),onClick:E[17]||(E[17]=lr(Qe=>L(c(l)),["prevent"]))},{icon:$(()=>[y(D,{width:"100%",height:"100%"})]),_:1},8,["loading"])])])]),_:1})]),_:1},8,["value"])]),_:1},8,["value"]))]),_:1})):ce("",!0)])}}}),S3={key:0,class:"flex flex-col gap-6"},C3={key:1,class:"flex flex-col gap-6"},_p=At({__name:"CuiSchema",props:{schemaForm:{},loading:{type:Boolean,default:!1},disableButton:{type:Boolean},saveButton:{type:Boolean,default:!0},saveButtonLabel:{},saveButtonColor:{},showButton:{type:Boolean,default:!1}},emits:["onSubmit","onAction","onFormSubmit","changeGroup"],setup(s,{expose:e,emit:t}){const n=t,r=s,{schemaForm:i,loading:o,saveButton:a,saveButtonLabel:l,showButton:u,disableButton:d,saveButtonColor:h}=Jt(r),v=Vt("formRef"),f=ae(""),b=ae(!1),k=ae({});Ge([i,v],([])=>{v.value&&(!Ly(v.value.values,i.value.schema)||b.value)&&(k.value=v.value.values),i.value.config&&Object.keys(i.value.config).length?k.value=xi(i.value.config):k.value=jy(i.value.schema)},{immediate:!0,deep:!0});const z=ne(()=>{const I=zy(i.value.schema);return Wn(I)}),L=ne(()=>{const I=[];return i.value.schema.forEach(w=>{w.group&&!w.hidden&&!I.includes(w.group)&&I.push(w.group)}),I.length&&!f.value&&(f.value=I[0]),I}),se=ne(()=>qy(i.value.schema,f.value)),K=ne(()=>Dy(i.value.schema,f.value));Ge(f,I=>{I&&n("changeGroup",I)});const N=I=>i.value.schema.filter(w=>(w.group===I||!w.group&&I===L.value[0])&&!w.hidden),E=I=>{const w=ar(I)&&I.format==="qrCode",Q=ar(I)&&I.format==="image",J=zr(I)||Ur(I);return!w&&!Q&&!J},O=I=>!I.hidden||I.hidden&&E(I),U=async()=>{var I;return await((I=v.value)==null?void 0:I.validate())},S=I=>{n("onAction",I)},M=async I=>{const w=await U();w!=null&&w.valid&&(w!=null&&w.values)?(b.value=!1,n("onSubmit",{key:I.key,payload:w.values})):(b.value=!0,console.error("result",w))},B=async()=>{const I=await U();I!=null&&I.valid&&(I!=null&&I.values)?(b.value=!1,n("onFormSubmit",I.values)):(b.value=!0,console.error("Form validation failed:",I))};return e({reset:()=>{var I;(I=v.value)==null||I.resetForm()}}),(I,w)=>{const Q=pp,J=hp,q=x3,oe=Dh,ue=qh,Se=jh,F=ys;return m(),A("div",null,[y(c(rl),{ref_key:"formRef",ref:v,"validation-schema":c(z),onSubmit:B},{default:$(()=>[c(L).length?(m(),A("div",S3,[y(J,{modelValue:c(f),"onUpdate:modelValue":w[0]||(w[0]=D=>us(f)?f.value=D:null),mandatory:""},{default:$(()=>[(m(!0),A(yt,null,qt(c(L),D=>(m(),j(Q,{key:D,size:"small",value:D},{default:$(()=>[Qt(me(D),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"]),y(Se,{value:c(f),"onUpdate:value":w[2]||(w[2]=D=>us(f)?f.value=D:null),scrollable:"",class:"w-full h-full"},{default:$(()=>[y(ue,{class:"p-0"},{default:$(()=>[(m(!0),A(yt,null,qt(c(L),(D,Y)=>(m(),j(oe,{key:Y,value:D,"as-child":""},{default:$(Pe=>[Tt(g("div",et({class:Pe.class},{ref_for:!0},Pe.a11yAttrs,{class:"flex flex-col gap-6"}),[(m(!0),A(yt,null,qt(N(D),He=>(m(),A(yt,{key:He.key},[O(He)&&(He.group===D||!He.group&&Y===0)?Tt((m(),j(q,{key:0,modelValue:c(k),"onUpdate:modelValue":w[1]||(w[1]=ht=>us(k)?k.value=ht:null),"schema-field":He,"config-key":He.key,loading:c(o),onOnAction:S,onOnSubmit:M},null,8,["modelValue","schema-field","config-key","loading"])),[[Tr,!He.hidden]]):ce("",!0)],64))),128))],16),[[Tr,Pe.active]])]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["value"])])):(m(),A("div",C3,[(m(!0),A(yt,null,qt(c(i).schema,D=>(m(),A(yt,{key:D.key},[O(D)?Tt((m(),j(q,{key:0,modelValue:c(k),"onUpdate:modelValue":w[3]||(w[3]=Y=>us(k)?k.value=Y:null),"schema-field":D,"config-key":D.key,loading:c(o),onOnAction:S,onOnSubmit:M},null,8,["modelValue","schema-field","config-key","loading"])),[[Tr,!D.hidden]]):ce("",!0)],64))),128))])),!c(se)&&c(K)&&c(a)||c(u)?(m(),j(F,{key:2,fluid:"",class:"mt-7 cui-button-medium",severity:c(h),type:"submit",loading:c(o),disabled:c(d),label:c(l)||I.$t("components.form.button.save")},null,8,["severity","loading","disabled","label"])):ce("",!0)]),_:1},8,["validation-schema"])])}}}),k3=At({__name:"PluginSchema",props:{schemaConfig:{},pluginName:{},cameraName:{},buttonKey:{}},setup(s,{expose:e}){const t=new gp,n=new Jn,r=Cn(),{t:i}=js(),o=mi("dialogRef"),a=mi("dialogRefProps"),l=s,{schemaConfig:u,pluginName:d,cameraName:h,buttonKey:v}=Jt(l),f=ae({schema:[],config:{}}),{mutate:b,isPending:k}=t.submitPluginConfigQuery(),{mutateAsync:z,isPending:L}=t.setPluginConfigQuery(),{mutate:se,isPending:K}=n.submitCameraExtensionConfigQuery(),{mutateAsync:N,isPending:E}=n.setCameraExtensionConfigQuery(),O=ne(()=>{var M;return!!((M=a.loading)!=null&&M.value||k.value||L.value||K.value||E.value)});Ge(u,M=>{f.value=M},{deep:!0,immediate:!0});const U=async M=>{h.value?await N({cameraname:h.value,pluginname:d.value,configData:{key:M.key}}):await z({pluginname:d.value,configData:{key:M.key}})},S=async M=>{console.log("onFormSubmit",M);const B={...u.value.config,...M};console.log("onFormSubmit payload",B);const W=I=>{if(I!=null&&I.toast){const w=Um(I.toast.type);r.add({severity:w,summary:i(`components.toast.title_${w}`),detail:I.toast.message,life:3e3})}I!=null&&I.schema&&Object.keys(I.schema).length&&f.value?f.value.schema=I.schema:o.value.close()};h.value?se({cameraname:h.value,pluginname:d.value,configData:{key:v.value,payload:B}},{onSuccess:W}):b({pluginname:d.value,configData:{key:v.value,payload:B}},{onSuccess:W})};return e({isLoading:O}),(M,B)=>{const W=_p;return m(),j(W,{"schema-form":c(f),loading:c(O),"show-button":"",onOnAction:U,onOnFormSubmit:S},null,8,["schema-form","loading"])}}}),E3={class:"p-4 flex flex-col gap-2"},A3={class:"cui-label"},M3={key:0,class:"flex flex-col gap-2"},$3={class:"cui-label"},T3={key:6,class:"text-sm text-muted text-center min-h-[30px]"},P3={class:"cui-label"},R3={key:7,class:"w-full flex items-center justify-center my-5"},I3={key:1,class:"text-sm text-muted text-center"},O3={key:1,class:"flex flex-col gap-2"},N3={class:"cui-label"},F3={key:0,class:"w-full flex items-center justify-center"},L3={key:1,class:"text-sm text-muted text-center"},j3={key:1,class:"w-full h-full"},q3={class:"cui-list-item"},D3=At({__name:"Plugins",props:{camera:{},cameraDevice:{},loading:{type:Boolean},latestSnapshotSrc:{}},emits:["close"],setup(s,{emit:e}){const t=new Jn,n=new gp,r=Cn(),i=Rl(),{t:o}=js(),a=s,{camera:l,loading:u}=Jt(a),d=Vt("schemaRef"),h=ae("hub"),v=ae(["hub","motionDetection","objectDetection","audioDetection","ptz","more"]),f=ae(""),b=ae(),k=ae(),z=ae(),L=ae(),se=ae(),K=ae(),N=ae(!0);t.toggleQueryActivator("getCameraExtensionConfigQuery",!1);const{data:E}=n.getPluginsQuery({page:1,pageSize:-1}),{data:O,isFetching:U,suspense:S}=t.getCameraExtensionsQuery(l.value.name),{data:M,isFetching:B}=t.getCameraExtensionConfigQuery(l.value.name,f,N),{data:W,isFetching:I}=n.getPluginsExtensionsQuery({page:1,pageSize:-1}),{mutate:w,isPending:Q}=t.submitCameraExtensionConfigQuery(),{mutateAsync:J,isPending:q}=t.patchCameraExtensionConfigQuery(),{mutateAsync:oe,isPending:ue}=t.setCameraExtensionConfigQuery(),{mutateAsync:Se,isPending:F}=t.addCameraExtensionQuery(),{mutateAsync:D,isPending:Y}=t.removeCameraExtensionQuery(),{mutateAsync:Pe,isPending:He}=t.enableCameraExtensionQuery(),{mutateAsync:ht,isPending:Mt}=t.disableCameraExtensionQuery(),Qe=ne(()=>U.value||I.value||F.value||Y.value||He.value||Mt.value),ze=ne(()=>Qe.value||u.value||Q.value||q.value||ue.value),ge=ne(()=>{const he=h.value==="cameraController"&&ft.value,ie=h.value==="hub"&&Yt.value.length,de=h.value==="motionDetection"&&wt.value.length,Le=h.value==="audioDetection"&&zt.value.length,rt=h.value==="objectDetection"&&nt.value.length,Kt=h.value==="ptz"&&Xt.value.length;return!ie&&!de&&!Le&&!rt&&!Kt&&!he}),ft=ne(()=>{var ie;const he=((ie=W.value)==null?void 0:ie.result.filter(de=>{var Le;return de.type.includes("cameraController")&&de.pluginName===((Le=l.value.pluginInfo)==null?void 0:Le.name)}))||[];return he.length&&E.value&&E.value.result.some(de=>de.pluginName===he[0].pluginName&&Ue(de.pluginName))?(b.value=he[0].pluginName,f.value=he[0].pluginName):b.value=void 0,he[0]}),Yt=ne(()=>{var ie;const he=((ie=O.value)==null?void 0:ie.filter(de=>de.type.includes("hub")))||[];return he.length&&E.value&&E.value.result.some(de=>de.pluginName===he[0].pluginName&&Ue(de.pluginName))?(k.value=he[0].pluginName,f.value=he[0].pluginName):k.value=void 0,V(he)}),wt=ne(()=>{var ie,de;const he=((ie=O.value)==null?void 0:ie.filter(Le=>Le.type.includes("motionDetection")))||[];return he.length&&Ue(l.value.extensions.motionDetection)?z.value=(de=l.value.extensions.motionDetection)==null?void 0:de.name:z.value=void 0,V(he)}),zt=ne(()=>{var ie,de;const he=((ie=O.value)==null?void 0:ie.filter(Le=>Le.type.includes("audioDetection")))||[];return he.length&&Ue(l.value.extensions.audioDetection)?L.value=(de=l.value.extensions.audioDetection)==null?void 0:de.name:L.value=void 0,V(he)}),nt=ne(()=>{var ie,de;const he=((ie=O.value)==null?void 0:ie.filter(Le=>Le.type.includes("objectDetection")))||[];return he.length&&Ue(l.value.extensions.objectDetection)?se.value=(de=l.value.extensions.objectDetection)==null?void 0:de.name:se.value=void 0,V(he)}),Xt=ne(()=>{var ie,de;const he=((ie=O.value)==null?void 0:ie.filter(Le=>Le.type.includes("ptz")))||[];return he.length&&Ue(l.value.extensions.ptz)?K.value=(de=l.value.extensions.ptz)==null?void 0:de.name:K.value=void 0,V(he)}),Be=ne(()=>{var de,Le;const he=((de=E.value)==null?void 0:de.result)||[];return(((Le=W.value)==null?void 0:Le.result)||[]).filter(rt=>{const Kt=he.find(Zt=>Zt.pluginName===rt.pluginName);return((Kt==null?void 0:Kt["camera.ui"].extensions)??[]).filter(Zt=>Zt!=="cameraController").length>0})});Ge(b,(he,ie)=>{he&&he!==ie&&X()}),Ge(k,(he,ie)=>{he&&he!==ie&&X(he)}),Ge(z,(he,ie)=>{he!==ie&&(!he&&ie?ye(ie,!1,"motionDetection"):he&&ye(he,!0,"motionDetection"))}),Ge(se,(he,ie)=>{he!==ie&&(!he&&ie?ye(ie,!1,"objectDetection"):he&&ye(he,!0,"objectDetection"))}),Ge(K,(he,ie)=>{he!==ie&&(!he&&ie?ye(ie,!1,"ptz"):he&&ye(he,!0,"ptz"))}),Ge(L,(he,ie)=>{he!==ie&&(!he&&ie?ye(ie,!1,"audioDetection"):he&&ye(he,!0,"audioDetection"))});const Ue=he=>{const ie=typeof he=="string"?he:he==null?void 0:he.name;if(ie&&E.value&&E.value.result.some(de=>de.pluginName===ie&&!de.disabled))return ie},V=he=>he.sort((ie,de)=>!Ue(ie.pluginName)&&Ue(de.pluginName)?1:Ue(ie.pluginName)&&!Ue(de.pluginName)?-1:ie.displayName.localeCompare(de.displayName)),X=he=>{var ie,de;if(t.toggleQueryActivator("getCameraExtensionConfigQuery",!1),he!==void 0)f.value=he;else switch(h.value){case"hub":f.value=Ue((ie=Yt.value[0])==null?void 0:ie.pluginName)||"";break;case"motionDetection":f.value=Ue(l.value.extensions.motionDetection)||"";break;case"audioDetection":f.value=Ue(l.value.extensions.audioDetection)||"";break;case"objectDetection":f.value=Ue(l.value.extensions.objectDetection)||"";break;case"ptz":f.value=Ue(l.value.extensions.ptz)||"";break;case"cameraController":f.value=Ue((de=ft.value)==null?void 0:de.pluginName)||"";break;default:f.value="";break}f.value&&f.value!==""&&t.toggleQueryActivator("getCameraExtensionConfigQuery",!0)},_e=async he=>{var ie;if(O.value)if(O.value.some(de=>de.pluginName===he.pluginName)){for(const de of he.type)await D({cameraname:l.value.name,pluginname:he.pluginName,type:de});(ie=d.value)==null||ie.reset()}else for(const de of he.type)await Se({cameraname:l.value.name,pluginname:he.pluginName,type:de})},ye=async(he,ie,de)=>{var rt;const Le=de in l.value.extensions?l.value.extensions[de]:void 0;l.value&&(ie?(Le==null?void 0:Le.name)!==he&&(await Pe({cameraname:l.value.name,pluginname:he,type:de}),Zs(()=>X(he))):(Le==null?void 0:Le.name)===he&&(await ht({cameraname:l.value.name,pluginname:he,type:de}),(rt=d.value)==null||rt.reset(),Zs(()=>X())))},fe=async(he,ie)=>{await oe({cameraname:l.value.name,pluginname:ie,configData:{key:he.key}})},_t=(he,ie)=>{w({cameraname:l.value.name,pluginname:ie,configData:{key:he.key,payload:he.payload}},{onSuccess:de=>{if(de!=null&&de.toast){const Le=Um(de.toast.type);r.add({severity:Le,summary:o(`components.toast.title_${Le}`),detail:de.toast.message,life:3e3})}de!=null&&de.schema&&Object.keys(de.schema).length&&i.openComponentDialog(k3,{data:{title:o("components.dialog.title.config"),hideConfirmButton:!0,contentProps:{schemaConfig:{schema:de.schema,config:he.payload},pluginName:ie,cameraName:l.value.name,buttonKey:he.key}}})}})},Pt=async(he,ie)=>{await J({cameraname:l.value.name,pluginname:he,configData:ie})};return Xc(async()=>{l.value.pluginInfo&&(v.value.unshift("cameraController"),h.value="cameraController"),await S(),X()}),(he,ie)=>{var Ms,ds;const de=pp,Le=hp,rt=Ca,Kt=Lr,ps=po,Zt=up,os=ew,As=ys,fs=jr;return m(),A("div",E3,[g("span",A3,me(he.$t("components.camera_options.categories")),1),y(Le,{modelValue:c(h),"onUpdate:modelValue":[ie[0]||(ie[0]=R=>us(h)?h.value=R:null),ie[1]||(ie[1]=R=>X())],disabled:c(Qe),mandatory:""},{default:$(()=>[(m(!0),A(yt,null,qt(c(v),R=>(m(),j(de,{key:R,size:"small",disabled:c(ze),value:R},{default:$(()=>[Qt(me(he.$t(`components.camera_options.chip_${R}`)),1)]),_:2},1032,["disabled","value"]))),128))]),_:1},8,["modelValue","disabled"]),y(rt,{class:"m-0 py-3"}),c(h)!=="more"?(m(),A("div",M3,[g("span",$3,me(he.$t("components.camera_options.chip_plugins")),1),c(h)==="cameraController"&&c(ft)?(m(),j(Le,{key:0,modelValue:c(b),"onUpdate:modelValue":ie[2]||(ie[2]=R=>us(b)?b.value=R:null),disabled:c(Qe),mandatory:"",class:"min-h-[30px]"},{default:$(()=>[(m(),j(de,{key:c(ft).pluginName,size:"small",disabled:!Ue(c(ft).pluginName)||c(ze),value:c(ft).pluginName},{default:$(()=>[Qt(me(c(ft).displayName),1)]),_:1},8,["disabled","value"]))]),_:1},8,["modelValue","disabled"])):ce("",!0),c(h)==="hub"&&c(Yt).length?(m(),j(Le,{key:1,modelValue:c(k),"onUpdate:modelValue":ie[3]||(ie[3]=R=>us(k)?k.value=R:null),disabled:c(Qe),mandatory:"",class:"min-h-[30px]"},{default:$(()=>[(m(!0),A(yt,null,qt(c(Yt),R=>(m(),j(de,{key:R.pluginName,size:"small",disabled:!Ue(R.pluginName)||c(ze),value:R.pluginName},{default:$(()=>[Qt(me(R.displayName),1)]),_:2},1032,["disabled","value"]))),128))]),_:1},8,["modelValue","disabled"])):ce("",!0),c(h)==="motionDetection"&&c(wt).length?(m(),j(Le,{key:2,modelValue:c(z),"onUpdate:modelValue":ie[4]||(ie[4]=R=>us(z)?z.value=R:null),disabled:c(Qe),class:"min-h-[30px]"},{default:$(()=>[(m(!0),A(yt,null,qt(c(wt),R=>(m(),j(de,{key:R.pluginName,size:"small",filter:"",disabled:!Ue(R.pluginName)||c(ze),value:R.pluginName},{default:$(()=>[Qt(me(R.displayName),1)]),_:2},1032,["disabled","value"]))),128))]),_:1},8,["modelValue","disabled"])):ce("",!0),c(h)==="objectDetection"&&c(nt).length?(m(),j(Le,{key:3,modelValue:c(se),"onUpdate:modelValue":ie[5]||(ie[5]=R=>us(se)?se.value=R:null),disabled:c(Qe),class:"min-h-[30px]"},{default:$(()=>[(m(!0),A(yt,null,qt(c(nt),R=>(m(),j(de,{key:R.pluginName,size:"small",filter:"",disabled:!Ue(R.pluginName)||c(ze),value:R.pluginName},{default:$(()=>[Qt(me(R.displayName),1)]),_:2},1032,["disabled","value"]))),128))]),_:1},8,["modelValue","disabled"])):ce("",!0),c(h)==="audioDetection"&&c(zt).length?(m(),j(Le,{key:4,modelValue:c(L),"onUpdate:modelValue":ie[6]||(ie[6]=R=>us(L)?L.value=R:null),disabled:c(Qe),class:"min-h-[30px]"},{default:$(()=>[(m(!0),A(yt,null,qt(c(zt),R=>(m(),j(de,{key:R.pluginName,size:"small",filter:"",disabled:!Ue(R.pluginName)||c(ze),value:R.pluginName},{default:$(()=>[Qt(me(R.displayName),1)]),_:2},1032,["disabled","value"]))),128))]),_:1},8,["modelValue","disabled"])):ce("",!0),c(h)==="ptz"&&c(Xt).length?(m(),j(Le,{key:5,modelValue:c(K),"onUpdate:modelValue":ie[7]||(ie[7]=R=>us(K)?K.value=R:null),disabled:c(Qe),class:"min-h-[30px]"},{default:$(()=>[(m(!0),A(yt,null,qt(c(Xt),R=>(m(),j(de,{key:R.pluginName,size:"small",filter:"",disabled:!Ue(R.pluginName)||c(ze),value:R.pluginName},{default:$(()=>[Qt(me(R.displayName),1)]),_:2},1032,["disabled","value"]))),128))]),_:1},8,["modelValue","disabled"])):c(ge)?(m(),A("span",T3,me(he.$t("components.camera_options.no_plugins_enabled")),1)):ce("",!0),y(rt,{class:"m-0 py-3"}),g("span",P3,me(he.$t("components.camera_options.plugin_settings")),1),c(B)||!c(f)||!c(M)||!((Ms=c(M))!=null&&Ms.schema)||((ds=c(M))==null?void 0:ds.schema.length)===0?(m(),A("div",R3,[c(B)?(m(),j(Kt,{key:0,class:"w-[30px] h-[30px]","stroke-width":"5"})):(m(),A("span",I3,me(he.$t("components.camera_options.no_config")),1))])):(m(),j(_p,{ref_key:"schemaRef",ref:d,key:c(f),"schema-form":{schema:c(M).schema,config:c(M).config},loading:c(ze),onOnFormSubmit:ie[8]||(ie[8]=R=>Pt(c(f),R)),onOnSubmit:ie[9]||(ie[9]=R=>_t(R,c(f))),onOnAction:ie[10]||(ie[10]=R=>fe(R,c(f)))},null,8,["schema-form","loading"]))])):c(h)==="more"?(m(),A("div",O3,[g("span",N3,me(he.$t("components.camera_options.manage_plugins")),1),c(I)||!c(Be).length?(m(),A("div",F3,[c(I)?(m(),j(Kt,{key:0,class:"w-[30px] h-[30px]","stroke-width":"5"})):(m(),A("span",L3,me(he.$t("components.camera_options.no_plugins_found")),1))])):(m(),A("div",j3,[(m(!0),A(yt,null,qt(c(Be),R=>Tt((m(),A("div",{key:R.pluginName,class:"cui-list-item"},[y(Zt,{disabled:c(Qe)||!Ue(R.pluginName),class:"h-14",onClick:te=>he.$router.push(`/plugins/${R.pluginName}`)},{append:$(()=>{var te;return[y(ps,{"model-value":(te=c(O))==null?void 0:te.some(ve=>ve.pluginName===R.pluginName),disabled:c(Qe)||!Ue(R.pluginName),"onUpdate:modelValue":ve=>_e(R)},null,8,["model-value","disabled","onUpdate:modelValue"])]}),default:$(()=>[g("span",null,me(R.displayName),1)]),_:2},1032,["disabled","onClick"])])),[[fs,{value:Ue(R.pluginName)===void 0?he.$t("components.form.tooltip.disabled"):""},void 0,{top:!0}]])),128))])),g("div",q3,[y(Zt,{class:"h-14",onClick:ie[11]||(ie[11]=R=>he.$router.push("/plugins"))},{append:$(()=>[y(As,{text:"",rounded:"",severity:"secondary",class:"cui-icon-md"},{icon:$(()=>[y(os,{width:"100%",height:"100%"})]),_:1})]),default:$(()=>[g("span",null,me(he.$t("components.camera_options.more_plugins")),1)]),_:1})])])):ce("",!0)])}}}),B3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function z3(s,e){return m(),A("svg",B3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m0 16H5V5h14zm-2-2H7V7h10z"},null,-1)]))}const U3=pe({name:"mdi-checkbox-intermediate",render:z3}),V3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function H3(s,e){return m(),A("svg",V3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M3.14 1A2.14 2.14 0 0 0 1 3.14V5h2V3h2V1zM7 1v2h3V1zm5 0v2h2v2h2V3.14C16 1.96 15.04 1 13.86 1zM1 7v3h2V7zm8 0c-1.11 0-2 .89-2 2v7h6.86A2.14 2.14 0 0 0 16 13.86V7zm9 0v2h2v2h2V9c0-1.11-.89-2-2-2zM9 9h5v5H9zm-8 3v1.86C1 15.04 1.96 16 3.14 16H5v-2H3v-2zm19 1v3h2v-3zM7 18v2c0 1.11.89 2 2 2h2v-2H9v-2zm13 0v2h-2v2h2c1.11 0 2-.89 2-2v-2zm-7 2v2h3v-2z"},null,-1)]))}const Q3=pe({name:"mdi-vector-intersection",render:H3}),K3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Z3(s,e){return m(),A("svg",K3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M4 6v13h16V6zm14 11H6V8h12z"},null,-1)]))}const G3=pe({name:"mdi-rectangle-outline",render:Z3}),W3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function J3(s,e){return m(),A("svg",W3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M4 6v13h16V6z"},null,-1)]))}const Y3=pe({name:"mdi-rectangle",render:J3}),X3={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function e4(s,e){return m(),A("svg",X3,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m6.03 12.03l2 3.47l-2.53 3.18L2 12.62zM17 18v-2.71c.88-.39 1.5-1.26 1.5-2.29c0-.57-.2-1.1-.53-1.5l1.97-1.15c1.01-.59 1.36-1.88.77-2.89l-1.38-2.4a2.125 2.125 0 0 0-2.89-.78L8.31 9c-.95.53-1.28 1.75-.73 2.71l1.5 2.6c.55.95 1.78 1.28 2.73.73l1.88-1.08c.25.59.72 1.07 1.31 1.33V18c0 1.1.9 2 2 2h5v-2z"},null,-1)]))}const t4=pe({name:"mdi-cctv",render:e4}),s4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function n4(s,e){return m(),A("svg",s4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M20.84 22.73L18.11 20H17c-1.1 0-2-.9-2-2v-1.11l-2.34-2.34l-.85.49c-.95.55-2.18.22-2.73-.73l-1.5-2.6c-.4-.71-.33-1.53.1-2.14L1.11 3l1.28-1.27l19.72 19.73zM18.5 13c0-.57-.2-1.1-.53-1.5l1.97-1.15c1.01-.59 1.36-1.88.77-2.89l-1.38-2.4a2.125 2.125 0 0 0-2.89-.78l-5.67 3.29l7.09 7.09c.4-.44.64-1.02.64-1.66M2 12.62l3.5 6.06l2.53-3.18l-2-3.47z"},null,-1)]))}const r4=pe({name:"mdi-cctv-off",render:n4}),i4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function o4(s,e){return m(),A("svg",i4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 2c5.5 0 10 4.5 10 10s-4.5 10-10 10S2 17.5 2 12S6.5 2 12 2m0 2c-1.9 0-3.6.6-4.9 1.7l11.2 11.2c1-1.4 1.7-3.1 1.7-4.9c0-4.4-3.6-8-8-8m4.9 14.3L5.7 7.1C4.6 8.4 4 10.1 4 12c0 4.4 3.6 8 8 8c1.9 0 3.6-.6 4.9-1.7"},null,-1)]))}const a4=pe({name:"mdi-cancel",render:o4}),c4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function l4(s,e){return m(),A("svg",c4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88c3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"},null,-1)]))}const u4=pe({name:"mdi-undo",render:l4}),d4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function h4(s,e){return m(),A("svg",d4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zm0 5h2v9H9zm4 0h2v9h-2z"},null,-1)]))}const m4=pe({name:"mdi-trash-can",render:h4}),p4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function f4(s,e){return m(),A("svg",p4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83l3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75z"},null,-1)]))}const g4=pe({name:"mdi-pencil",render:f4}),v4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function _4(s,e){return m(),A("svg",v4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"},null,-1)]))}const y4=pe({name:"mdi-plus",render:_4}),b4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function w4(s,e){return m(),A("svg",b4,e[0]||(e[0]=[g("g",{fill:"none"},[g("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M13 4a1 1 0 1 0-2 0v17a1 1 0 1 0 2 0zM7 4h3v5H7a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m-2 6h5v5H5a2 2 0 0 1-2-2v-1a2 2 0 0 1 2-2m9 0v5h2a2 2 0 0 0 2-2v-1a2 2 0 0 0-2-2zm-6 6h2v5H8a2 2 0 0 1-2-2v-1a2 2 0 0 1 2-2m6 0v5h5a2 2 0 0 0 2-2v-1a2 2 0 0 0-2-2zm0-12v5h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"})],-1)]))}const x4=pe({name:"mingcute-timeline-fill",render:w4}),S4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function C4(s,e){return m(),A("svg",S4,e[0]||(e[0]=[g("g",{fill:"none"},[g("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M13 4a1 1 0 1 0-2 0v17a1 1 0 1 0 2 0zM7 4h3v2H7v1h3v2H7a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m11 3h-4v2h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4v2h4zm-8 3H5a2 2 0 0 0-2 2v1a2 2 0 0 0 2 2h5v-2H5v-1h5zm4 0v2h2v1h-2v2h2a2 2 0 0 0 2-2v-1a2 2 0 0 0-2-2zm-4 6H8a2 2 0 0 0-2 2v1a2 2 0 0 0 2 2h2v-2H8v-1h2zm4 0v2h5v1h-5v2h5a2 2 0 0 0 2-2v-1a2 2 0 0 0-2-2z"})],-1)]))}const k4=pe({name:"mingcute-timeline-line",render:C4}),E4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function A4(s,e){return m(),A("svg",E4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M9 11.5A2.5 2.5 0 0 0 11.5 9A2.5 2.5 0 0 0 9 6.5A2.5 2.5 0 0 0 6.5 9A2.5 2.5 0 0 0 9 11.5M9 2c3.86 0 7 3.13 7 7c0 5.25-7 13-7 13S2 14.25 2 9a7 7 0 0 1 7-7m6 15h3v-3h2v3h3v2h-3v3h-2v-3h-3z"},null,-1)]))}const M4=pe({name:"mdi-map-marker-add",render:A4}),$4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function T4(s,e){return m(),A("svg",$4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M15 17h3v-3h2v3h3v2h-3v3h-2v-3h-3zM9 6.5c1.4 0 2.5 1.1 2.5 2.5s-1.1 2.5-2.5 2.5S6.5 10.4 6.5 9S7.6 6.5 9 6.5M9 2c3.9 0 7 3.1 7 7c0 5.2-7 13-7 13S2 14.2 2 9c0-3.9 3.1-7 7-7m0 2C6.2 4 4 6.2 4 9c0 1 0 3 5 9.7C14 12 14 10 14 9c0-2.8-2.2-5-5-5"},null,-1)]))}const P4=pe({name:"mdi-map-marker-add-outline",render:T4}),R4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function I4(s,e){return m(),A("svg",R4,e[0]||(e[0]=[g("g",{fill:"none"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M19.26 16.877c.413.402.74.932.74 1.596c0 .753-.426 1.339-.9 1.745c-.48.408-1.114.731-1.81.983c-1.402.505-3.272.799-5.29.799s-3.888-.294-5.29-.8c-.696-.25-1.33-.574-1.809-.982c-.475-.406-.901-.992-.901-1.745c0-.663.327-1.194.74-1.596A9.97 9.97 0 0 0 12 20c2.859 0 5.438-1.2 7.26-3.123M12 2a8 8 0 1 1 0 16a8 8 0 0 1 0-16m0 4a4 4 0 1 0 0 8a4 4 0 0 0 0-8m0 2a2 2 0 1 1 0 4a2 2 0 0 1 0-4"})],-1)]))}const yp=pe({name:"mingcute-computer-camera-fill",render:I4}),O4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function N4(s,e){return m(),A("svg",O4,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M6.593 16.744a1 1 0 0 1-.246 1.393a1.3 1.3 0 0 0-.319.294l-.024.042l.035.058c.03.04.078.095.16.165c.23.196.62.417 1.19.623C8.523 19.728 10.153 20 12 20c1.848 0 3.478-.272 4.61-.68c.57-.207.961-.428 1.19-.624a1 1 0 0 0 .16-.165l.036-.058l-.024-.04a1.2 1.2 0 0 0-.314-.293a1 1 0 1 1 1.151-1.635c.598.421 1.191 1.074 1.191 1.968c0 .753-.426 1.339-.9 1.744c-.48.41-1.114.732-1.81.984c-1.402.505-3.272.799-5.29.799s-3.888-.294-5.29-.8c-.696-.25-1.33-.574-1.809-.983c-.475-.405-.901-.99-.901-1.744c0-.898.598-1.553 1.2-1.975a1 1 0 0 1 1.393.246M12 2a8 8 0 1 1 0 16a8 8 0 0 1 0-16m0 2a6 6 0 1 0 0 12a6 6 0 0 0 0-12m0 2a4 4 0 1 1 0 8a4 4 0 0 1 0-8m0 2a2 2 0 1 0 0 4a2 2 0 0 0 0-4"})],-1)]))}const F4=pe({name:"mingcute-computer-camera-line",render:N4}),L4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function j4(s,e){return m(),A("svg",L4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M2 6V4q0-.825.588-1.412T4 2h2q.425 0 .713.288T7 3t-.288.713T6 4H4v2q0 .425-.288.713T3 7t-.712-.288T2 6m2 16q-.825 0-1.412-.587T2 20v-2q0-.425.288-.712T3 17t.713.288T4 18v2h2q.425 0 .713.288T7 21t-.288.713T6 22zm16 0h-2q-.425 0-.712-.288T17 21t.288-.712T18 20h2v-2q0-.425.288-.712T21 17t.713.288T22 18v2q0 .825-.587 1.413T20 22m0-16V4h-2q-.425 0-.712-.288T17 3t.288-.712T18 2h2q.825 0 1.413.588T22 4v2q0 .425-.288.713T21 7t-.712-.288T20 6m-6.5 3.5q-.825 0-1.412-.587T11.5 7.5t.588-1.412T13.5 5.5t1.413.588T15.5 7.5t-.587 1.413T13.5 9.5m-.7 8.5h-4l1-5.1l-1.8.7V16q0 .425-.288.712T7 17t-.712-.288T6 16v-3.05q0-.3.163-.537t.437-.363l3.35-1.45q.875-.375 1.288-.487T12 10q.525 0 .975.275T13.7 11l1 1.6q.525.85 1.363 1.475T18 14.9q.425.075.713.375T19 16t-.288.7t-.687.225q-1.35-.2-2.525-.837t-2-1.588z"},null,-1)]))}const q4=pe({name:"material-symbols-detection-and-zone-rounded",render:j4}),D4={viewBox:"0 0 640 512",width:"1.5em",height:"1.2em"};function B4(s,e){return m(),A("svg",D4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M32 119.4C12.9 108.4 0 87.7 0 64C0 28.7 28.7 0 64 0c23.7 0 44.4 12.9 55.4 32h209.1C339.6 12.9 360.3 0 384 0c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4v113.1c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H119.5c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V119.4zM119.4 96c-5.6 9.7-13.7 17.8-23.4 23.4v113.1c9.7 5.6 17.8 13.7 23.4 23.4h209.1c5.6-9.7 13.7-17.8 23.4-23.4V119.4c-9.7-5.6-17.8-13.7-23.4-23.4zm192 384c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V352h64v40.6c9.7 5.6 17.8 13.7 23.4 23.4h209.1c5.6-9.7 13.7-17.8 23.4-23.4V279.5c-9.7-5.6-17.8-13.7-23.4-23.4h-46c-5.4-15.4-14.6-28.9-26.5-39.6v-24.4h72.6c11.1-19.1 31.7-32 55.4-32c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4v113.1c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H311.5z"},null,-1)]))}const z4=pe({name:"fa6-solid-object-ungroup",render:B4}),U4={viewBox:"0 0 640 512",width:"1.5em",height:"1.2em"};function V4(s,e){return m(),A("svg",U4,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M48.2 66.8c-.1-.8-.2-1.7-.2-2.5v-.2c0-8.8 7.2-16 16-16c.9 0 1.9.1 2.8.2C74.3 49.5 80 56.1 80 64c0 8.8-7.2 16-16 16c-7.9 0-14.5-5.7-15.8-13.2M0 64c0 26.9 16.5 49.9 40 59.3v105.3C16.5 238.1 0 261.1 0 288c0 35.3 28.7 64 64 64c26.9 0 49.9-16.5 59.3-40h201.3c9.5 23.5 32.5 40 59.3 40c35.3 0 64-28.7 64-64c0-26.9-16.5-49.9-40-59.3V123.4c23.5-9.5 40-32.5 40-59.3c0-35.3-28.7-64-64-64c-26.9 0-49.9 16.5-59.3 40L123.3 40C113.9 16.5 90.9 0 64 0C28.7 0 0 28.7 0 64m368 0a16 16 0 1 1 32 0a16 16 0 1 1-32 0m-43.3 24c6.5 16 19.3 28.9 35.3 35.3v105.3c-16 6.5-28.9 19.3-35.3 35.3H123.4c-6.5-16-19.3-28.9-35.3-35.3V123.3c16-6.5 28.9-19.3 35.3-35.3zM384 272a16 16 0 1 1 0 32a16 16 0 1 1 0-32M80 288c0 7.9-5.7 14.5-13.2 15.8c-.8.1-1.7.2-2.5.2h-.2c-8.8 0-16-7.2-16-16c0-.9.1-1.9.2-2.8c1.2-7.5 7.8-13.2 15.7-13.2c8.8 0 16 7.2 16 16m391.3-40h45.4c6.5 16 19.3 28.9 35.3 35.3v105.3c-16 6.5-28.9 19.3-35.3 35.3H315.4c-6.5-16-19.3-28.9-35.3-35.3v-36.7h-48v36.7c-23.5 9.5-40 32.5-40 59.3c0 35.3 28.7 64 64 64c26.9 0 49.9-16.5 59.3-40h201.3c9.5 23.5 32.5 40 59.3 40c35.3 0 64-28.7 64-64c0-26.9-16.5-49.9-40-59.3V283.3c23.5-9.5 40-32.5 40-59.3c0-35.3-28.7-64-64-64c-26.9 0-49.9 16.5-59.3 40H448v16.4c9.8 8.8 17.8 19.5 23.3 31.6m88.9-26.7a16 16 0 1 1 31.5 5.5a16 16 0 1 1-31.5-5.5M271.8 450.7a16 16 0 1 1-31.5-5.5a16 16 0 1 1 31.5 5.5m307-18.5a16 16 0 1 1-5.5 31.5a16 16 0 1 1 5.5-31.5"},null,-1)]))}const H4=pe({name:"fa6-regular-object-ungroup",render:V4}),Q4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function K4(s,e){return m(),A("svg",Q4,e[0]||(e[0]=[g("g",{fill:"none",stroke:"currentColor","stroke-width":"1.5"},[g("path",{d:"M2 12c0-4.714 0-7.071 1.464-8.536C4.93 2 7.286 2 12 2s7.071 0 8.535 1.464C22 4.93 22 7.286 22 12s0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465C2 19.072 2 16.714 2 12Z"}),g("circle",{cx:"12",cy:"12",r:"4"})],-1)]))}const Z4=pe({name:"solar-camera-square-linear",render:K4}),G4={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function W4(s,e){return m(),A("svg",G4,e[0]||(e[0]=[g("path",{fill:"currentColor","fill-rule":"evenodd",d:"M15.75 6a3.75 3.75 0 1 0-7.5 0a3.75 3.75 0 0 0 7.5 0M12 3.75a2.25 2.25 0 1 1 0 4.5a2.25 2.25 0 0 1 0-4.5M9.25 18a3.75 3.75 0 1 0-7.5 0a3.75 3.75 0 0 0 7.5 0M5.5 15.75a2.25 2.25 0 1 1 0 4.5a2.25 2.25 0 0 1 0-4.5m13-1.5a3.75 3.75 0 1 1 0 7.5a3.75 3.75 0 0 1 0-7.5M20.75 18a2.25 2.25 0 1 0-4.5 0a2.25 2.25 0 0 0 4.5 0","clip-rule":"evenodd"},null,-1),g("path",{fill:"currentColor",d:"M7.205 7.562a.75.75 0 0 0-.993-1.124A8.73 8.73 0 0 0 3.25 13a.75.75 0 0 0 1.5 0a7.23 7.23 0 0 1 2.455-5.438m10.583-1.124a.75.75 0 0 0-.993 1.124A7.23 7.23 0 0 1 19.25 13a.75.75 0 0 0 1.5 0a8.73 8.73 0 0 0-2.962-6.562m-7.601 13.584a.75.75 0 1 0-.374 1.452a8.8 8.8 0 0 0 4.374 0a.75.75 0 1 0-.374-1.452A7.3 7.3 0 0 1 12 20.25a7.3 7.3 0 0 1-1.813-.228"},null,-1)]))}const J4=pe({name:"solar-share-circle-outline",render:W4}),Nl=At({__name:"CuiSnapshot",props:{cameraName:{},src:{},loading:{type:Boolean},showLoadingScreen:{type:Boolean,default:!0},width:{default:"100%"},height:{default:"100%"},imageWidth:{},imageHeight:{},imageContainerClass:{},imageContainerStyle:{}},setup(s,{expose:e}){const t=new Jn,n=s,{cameraName:r,loading:i,src:o,width:a,height:l,imageHeight:u,imageWidth:d,imageContainerClass:h,imageContainerStyle:v,showLoadingScreen:f}=Jt(n),b=ae(!1);o.value&&t.toggleQueryActivator("getCameraSnapshotQuery",!1);const{data:k,isFetching:z,refetch:L,isRefetching:se}=t.getCameraSnapshotQuery(r,b),K=ne(()=>(i.value||z.value||se.value)&&f.value),N=ne(()=>{if(o.value)return o.value;if(k.value)return`data:image/jpeg;base64,${k.value}`});return e({download:()=>{if(N.value){const U=`${r.value.replace(/ /g,"_").toLowerCase()}_${new Date().toISOString()}.png`,S=document.createElement("a");S.setAttribute("download",U),S.href=N.value,document.body.appendChild(S),S.click(),S.remove()}},refresh:()=>{b.value=!0,L(),b.value=!1},isLoading:K,snapshotSrc:N}),(U,S)=>{const M=Lr,B=Ia;return m(),A("div",{class:"w-full h-full flex items-center justify-center bg-black aspect-video",style:ot({width:`${c(a)}`,height:`${c(l)}`})},[c(K)?(m(),j(M,{key:0,class:"m-0 max-w-[30px] max-h-[30px]","stroke-width":"5",style:ot({width:`calc(${c(a)} / 2)`,height:`calc(${c(l)} / 2)`})},null,8,["style"])):(m(),j(B,{key:1,src:c(N),"aspect-ratio":"16/9",cover:"",width:c(d),height:c(u),"image-container-class":c(h),"image-container-style":c(v)},null,8,["src","width","height","image-container-class","image-container-style"]))],4)}}}),Y4=["d"],X4=At({__name:"CuiPolygon",props:{cameraZones:{}},setup(s){const e=s,{cameraZones:t}=Jt(e),n=Vt("zoneRef"),r=ri(n),i=o=>{if(!o)return"";const a=o.map(u=>{const d=Math.round(u[0]/100*r.width.value),h=Math.round(u[1]/100*r.height.value);return`${d},${h}`});if(a.length===0)return"";let l=`M ${a[0]}`;for(let u=1;u<a.length;u++)l+=` L ${a[u]}`;return l+=" Z",l};return(o,a)=>(m(),A("svg",{ref_key:"zoneRef",ref:n,width:"100%",height:"100%",class:"zones-container polygon-container"},[(m(!0),A(yt,null,qt(c(t),(l,u)=>(m(),A("path",{key:u,d:i(l.points.map(d=>d)),class:at({dash:l.type==="intersect"&&!l.isPrivacyMask}),style:ot({fill:l.isPrivacyMask?"rgba(16, 16, 16, 0.9)":l.filter==="exclude"?"transparent":`${l.color}4D`,stroke:l.isPrivacyMask?"#333333":l.color,"stroke-width":"2"})},null,14,Y4))),128))],512))}}),e6=qs(X4,[["__scopeId","data-v-bcfe05d5"]]),t6={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function s6(s,e){return m(),A("svg",t6,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M3 14s-1 0-1-1s1-4 6-4s6 3 6 4s-1 1-1 1zm5-6a3 3 0 1 0 0-6a3 3 0 0 0 0 6"},null,-1)]))}const n6=pe({name:"bi-person-fill",render:s6}),r6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function i6(s,e){return m(),A("svg",r6,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M6.25 5.25c0-1.422 1.028-2.75 2.5-2.75s2.5 1.328 2.5 2.75S10.222 8 8.75 8s-2.5-1.328-2.5-2.75M1 8.75C1 7.328 2.028 6 3.5 6S6 7.328 6 8.75S4.972 11.5 3.5 11.5S1 10.172 1 8.75M12 10a7 7 0 0 0-7 7c0 1.36.72 2.388 1.7 3.044c.963.645 2.198.956 3.378.956h3.844c1.18 0 2.415-.311 3.377-.956C18.28 19.388 19 18.361 19 17a7 7 0 0 0-7-7m.75-4.75c0-1.422 1.028-2.75 2.5-2.75s2.5 1.328 2.5 2.75S16.722 8 15.25 8s-2.5-1.328-2.5-2.75M18 8.75C18 7.328 19.028 6 20.5 6S23 7.328 23 8.75s-1.028 2.75-2.5 2.75S18 10.172 18 8.75"},null,-1)]))}const o6=pe({name:"fluent-animal-paw-print-24-filled",render:i6}),a6={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function c6(s,e){return m(),A("svg",a6,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m3.044 6l-.01.074A1.5 1.5 0 0 0 2 7.5v3A1.5 1.5 0 0 0 3.5 12h9a1.5 1.5 0 0 0 1.5-1.5v-3a1.5 1.5 0 0 0-1.04-1.428L12.951 6h.549a.5.5 0 0 0 0-1h-.677l-.16-1.253A2 2 0 0 0 10.68 2H5.319a2 2 0 0 0-1.984 1.744L3.173 5H2.5a.5.5 0 0 0 0 1zm2.275-3h5.36a1 1 0 0 1 .992.873L11.943 6h-7.89l.274-2.128A1 1 0 0 1 5.319 3M5.25 9.749a.749.749 0 1 1 0-1.498a.749.749 0 0 1 0 1.498m5.498 0a.749.749 0 1 1 0-1.498a.749.749 0 0 1 0 1.498M12.497 13h-1.5v.25a.75.75 0 0 0 1.5 0zM5 13H3.5v.25a.75.75 0 0 0 1.5 0z"},null,-1)]))}const l6=pe({name:"fluent-vehicle-car-16-filled",render:c6}),u6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d6(s,e){return m(),A("svg",u6,e[0]||(e[0]=[g("g",{fill:"currentColor"},[g("path",{d:"M15.25 6.5a2.25 2.25 0 1 0 0-4.5a2.25 2.25 0 0 0 0 4.5m-2.867-.001c-1.495-.21-4.912.397-6.32 4.15a1 1 0 1 0 1.873.702c.584-1.555 1.636-2.316 2.574-2.655l-1.17 3.006q-.029.075-.045.15a1 1 0 0 0 .164.91l3.562 4.607l.231 3.693a1 1 0 1 0 1.996-.124l-.27-4.307l-2.092-2.707l1.373-2.661l.093.134a2 2 0 0 0 2.42.711l2.115-.886a1 1 0 0 0-.773-1.844l-2.115.886l-1.606-2.335a3.04 3.04 0 0 0-1.661-1.36a1.4 1.4 0 0 0-.35-.07"}),g("path",{d:"m8.45 16.45l.827-2.452l1.469 1.9l-.402 1.191a2 2 0 0 1-2.032 1.356l-2.88-.197a1 1 0 1 1 .136-1.996z"})],-1)]))}const h6=pe({name:"healthicons-running-24px",render:d6}),m6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function p6(s,e){return m(),A("svg",m6,e[0]||(e[0]=[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3zM7 16.5l-4.74-2.85M7 16.5l5-3m-5 3v5.17m5-8.17V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5zm5 3l-5-3m5 3l4.74-2.85M17 16.5v5.17"}),g("path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3l5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0zM12 8L7.26 5.15M12 8l4.74-2.85M12 13.5V8"})],-1)]))}const f6=pe({name:"lucide-boxes",render:p6}),g6={class:"w-full h-full"},v6={key:1,class:"label-text"},_6=At({__name:"CuiBBoxPlayground",props:{showIcon:{type:Boolean,default:!0},showLabel:{type:Boolean,default:!1},showConfidence:{type:Boolean,default:!0},detections:{default(){return[]}},classes:{default(){return["animal","person","vehicle","motion","other"]}}},setup(s,{expose:e}){const t=s,{detections:n,classes:r,showConfidence:i,showIcon:o,showLabel:a}=Jt(t),l=Vt("containerRef"),u=Ls([]),{width:d,height:h}=nl(l),v={motion:{color:"#A855F7",icon:h6},animal:{color:"#22C55E",icon:o6},person:{color:"#3B82F6",icon:n6},vehicle:{color:"#EF4444",icon:l6},other:{color:"#CAC443",icon:f6}},f=ne(()=>Math.min(d.value||800,h.value||600)),b=ne(()=>f.value<200?.8:1),k=ne(()=>S=>{if(!u.value.length||!d.value)return 0;const{inputWidth:M}=u.value[0];return Math.round(S*d.value/M)}),z=ne(()=>S=>{if(!u.value.length||!h.value)return 0;const{inputHeight:M}=u.value[0];return Math.round(S*h.value/M)}),L=ne(()=>(S,M)=>k.value(M)-k.value(S)),se=ne(()=>(S,M)=>z.value(M)-z.value(S)),K=ne(()=>S=>{const M=L.value(S.boundingBox[0],S.boundingBox[2]),B=se.value(S.boundingBox[1],S.boundingBox[3]),W=M<200?.3:M<400?.25:.2;return Math.min(M,B)*W}),N=ne(()=>S=>{const M=z.value(S.boundingBox[1]),B=30*b.value;return M<B}),E=ne(()=>S=>k.value(S.boundingBox[0])>d.value*.7),O=S=>{u.value=S.filter(M=>r.value.includes(M.label))},U=()=>{u.value=[]};return Ge(n,S=>{S.length&&O(S)},{immediate:!0}),e({draw:O,clear:U}),(S,M)=>(m(),A("div",{ref_key:"containerRef",ref:l,class:"bbox-container"},[(m(!0),A(yt,null,qt(c(u),B=>{var W,I;return m(),A("div",{key:B.id,class:"bbox-corners",style:ot({left:`${c(k)(B.boundingBox[0])}px`,top:`${c(z)(B.boundingBox[1])}px`,width:`${c(L)(B.boundingBox[0],B.boundingBox[2])}px`,height:`${c(se)(B.boundingBox[1],B.boundingBox[3])}px`})},[g("div",g6,[(m(),A(yt,null,qt(["tl","tr","bl","br"],w=>{var Q;return g("div",{key:w,class:at(["corner-lines",w]),style:ot({"--corner-color":((Q=v[B.label])==null?void 0:Q.color)||v.other.color,"--corner-size":`${c(K)(B)}px`})},M[0]||(M[0]=[g("div",{class:"line horizontal"},null,-1),g("div",{class:"line vertical"},null,-1)]),6)}),64))]),c(a)||c(i)||c(o)?(m(),A("div",{key:0,class:at(["label z-1",{"label-bottom":c(N)(B),"label-right":c(E)(B)}]),style:ot({backgroundColor:((W=v[B.label])==null?void 0:W.color)||v.other.color,fontSize:`${12*c(b)}px`,padding:`${4*c(b)}px ${8*c(b)}px`,gap:`${4*c(b)}px`})},[c(o)?(m(),j(Ai(((I=v[B.label])==null?void 0:I.icon)||v.other.icon),{key:0})):ce("",!0),c(a)&&c(f)>250?(m(),A("span",v6,me(B.label),1)):ce("",!0),c(i)&&c(f)>250?(m(),A("span",{key:2,class:"confidence",style:ot({fontSize:`${11*c(b)}px`})},me((B.confidence*100).toFixed(1))+"% ",5)):ce("",!0)],6)):ce("",!0)],4)}),128))],512))}}),y6=qs(_6,[["__scopeId","data-v-870e7d93"]]),b6={class:"snapshot-hover-container flex items-center justify-center aspect-video"},w6={class:"shortcut-menu"},x6=At({__name:"CuiCameraShortcuts",props:{cameraName:{},addingShortcuts:{type:Boolean}},setup(s){var Ue;const e=new Jn,t=new M_,n=Fs(),r=qr(),i=s,{cameraName:o,addingShortcuts:a}=Jt(i),{user:l}=Vs(n),u=Vt("placeholderRef"),d=Vt("shortcutContainerRef"),h=Vt("camerasMenuRef"),v=Ls({}),f=Ls({}),b=Ls({}),k=ae({}),z=ae(!1),L=ae(),se=ae(!1),K=ae(!1),N=ae([]),E=ae({}),O=ae(!1),U=nl(d);e.toggleQueryActivator("getCamerasQuery",!1);const{data:S,isFetching:M}=e.getCameraQuery(o),{data:B,isFetching:W}=e.getCamerasQuery({page:1,pageSize:-1}),{data:I,isFetching:w}=t.getShortcutsQuery(((Ue=l.value)==null?void 0:Ue.username)||"",o),{mutate:Q,isPending:J}=t.patchShortcutQuery(),{mutate:q,isPending:oe}=t.createShortcutQuery(),{mutate:ue,isPending:Se}=t.removeShortcutQuery(),F=ne(()=>M.value||w.value||J.value||W.value||oe.value||Se.value),D=ne(()=>{var V;return(V=B.value)!=null&&V.result?B.value.result.filter(X=>X.name!==o.value):[]}),Y=ne(()=>{var V;return((V=l.value)==null?void 0:V.username)??""});Ge([I,S],()=>{I.value&&S.value&&(N.value=xi(I.value))},{immediate:!0,deep:!0}),Ge([U.width,U.height],()=>{K.value=!0,Zs(()=>{ge()})}),Ge(N,()=>{Zs(()=>{ft()})},{deep:!0,immediate:!0}),Ge(K,V=>{V&&(L.value=void 0)});const Pe=V=>{se.value||(L.value=void 0),O.value=V,e.toggleQueryActivator("getCamerasQuery",V)};Ge([u,L],([V,X])=>{V&&X&&setTimeout(()=>{var _e;(_e=h.value)==null||_e.show({currentTarget:V})},50)},{deep:!0}),Ge(E,()=>{Object.entries(E.value).forEach(([V,X])=>{var _e,ye;if(X&&f.value[V]){const fe=v.value[V];fe&&((_e=f.value[V])==null||_e.show({currentTarget:fe}))}else(ye=f.value[V])==null||ye.hide()})},{deep:!0});const He=(V,X)=>{z.value||(e.toggleQueryActivator("getCamerasQuery",X),E.value[V]=z.value?!1:X,Object.entries(E.value).forEach(([_e,ye])=>{_e!==V&&ye&&(E.value[_e]=!1)}))},ht=V=>{z.value||zt(V)},Mt=(V,X)=>{V||(E.value[X._id]?(He(X._id,!1),Be(X.cameraId)):He(X._id,!0))},Qe=()=>{Object.entries(b.value).forEach(([V,X])=>{const _e=d.value;if(!_e)return;const ye=_e.getBoundingClientRect(),fe=X.element.getBoundingClientRect(),_t=(fe.left-ye.left)/ye.width*100,Pt=(fe.top-ye.top)/ye.height*100;k.value[V]={x:Math.max(0,Math.min(_t,100)),y:Math.max(0,Math.min(Pt,100))}})},ze=()=>{Object.entries(b.value).forEach(([V,X])=>{const _e=k.value[V];if(!_e)return;const ye=d.value;if(!ye)return;const fe=ye.getBoundingClientRect(),_t=X.element.getBoundingClientRect(),Pt=fe.width-_t.width,he=fe.height-_t.height,ie=Math.max(0,Math.min(_e.x/100*fe.width,Pt)),de=Math.max(0,Math.min(_e.y/100*fe.height,he));X.setPosition(ie,de)}),K.value=!1},ge=()=>{Object.entries(k.value).forEach(([V,X])=>{k.value[V]={x:Math.max(0,Math.min(X.x,100)),y:Math.max(0,Math.min(X.y,100))}}),ze()},ft=()=>{for(const[V,X]of Object.entries(b.value))N.value.find(_e=>_e._id===V)||(X.destroy(),delete b.value[V],delete k.value[V]);for(const[V]of Object.entries(k.value))N.value.find(X=>X._id===V)||delete k.value[V];for(const[V,X]of Object.entries(v.value)){const _e=N.value.find(ye=>ye._id===V);if(X&&_e&&d.value){b.value[_e._id]&&b.value[_e._id].destroy();const ye=new Zh(X,{containment:d.value});b.value[_e._id]=ye;const[fe,_t]=_e.points,Pt=d.value.getBoundingClientRect(),he=fe/100*Pt.width,ie=_t/100*Pt.height;ye.setPosition(he,ie),k.value[_e._id]={x:fe,y:_t},ye.on("dragMove",()=>{z.value=!0;const de=f.value[V];de==null||de.alignOverlay()}),ye.on("dragEnd",()=>{setTimeout(()=>{z.value=!1},50),Qe();const de=k.value[_e._id];Q({username:Y.value,cameraname:o.value,shortcutid:_e._id,shortcutData:{points:[de.x,de.y]}})})}}ze()},Yt=V=>{if(!a.value||!d.value)return;se.value=!0;const X=d.value.getBoundingClientRect(),_e=35,ye=35;L.value={x:Math.max(0,Math.min(V.clientX-X.left-_e/2,X.width-_e)),y:Math.max(0,Math.min(V.clientY-X.top-ye/2,X.height-ye))}},wt=async V=>{if(!u.value||!d.value)return;const X=d.value,_e=u.value,ye=X.getBoundingClientRect(),fe=_e.getBoundingClientRect(),_t=fe.left-ye.left,Pt=fe.top-ye.top,he=_t/ye.width*100,ie=Pt/ye.height*100;q({username:Y.value,cameraname:o.value,shortcutData:{_id:"",points:[he,ie],cameraId:V._id}},{onSettled:()=>{var de;se.value=!1,L.value=void 0,(de=h.value)==null||de.hide()}})},zt=V=>{const X=b.value[V._id];X==null||X.destroy(),ue({username:Y.value,cameraname:o.value,shortcutid:V._id})},nt=(V,X)=>{v.value[X]=V},Xt=(V,X)=>{f.value[X]=V},Be=async V=>{if(z.value)return;const X=new AbortController,ye=(await fp({cameraname:V,signal:X.signal})).name;ye&&r.push(`/cameras/${ye}`)};return z0(()=>{v.value={}}),Sn(()=>{Zs(()=>{ft()})}),go(()=>{Object.values(b.value).forEach(V=>V.destroy())}),(V,X)=>{const _e=yp,ye=ys,fe=Lr,_t=Sp,Pt=Hc,he=Nl;return m(),A("div",{ref_key:"shortcutContainerRef",ref:d,class:at(["shortcut-container",{"!pointer-events-auto":c(a)}]),style:ot({cursor:c(a)?"pointer":"default"}),onClick:lr(Yt,["self"])},[(m(!0),A(yt,null,qt(c(N),ie=>Tt((m(),A("div",{ref_for:!0,ref:de=>nt(de,ie._id),key:ie._id,class:"draggable absolute pointer-events-auto",style:ot({background:c(E)[ie._id]?"#545454":void 0})},[y(ye,{severity:"secondary",rounded:"",class:"cui-icon-lg shadow-sm pointer-events-auto"},{icon:$(()=>[y(_e,{width:"100%",height:"100%"})]),_:1}),y(Pt,{ref_for:!0,ref:de=>Xt(de,ie._id),class:"shadow-lg cui-rounded-corner overflow-hidden",pt:{content:{class:"p-0"}}},{default:$(()=>{var de;return[g("div",b6,[(de=c(B))!=null&&de.result.find(Le=>Le._id===ie.cameraId)?(m(),j(_t,{key:1,"source-role":"low-resolution","camera-info":c(B).result.find(Le=>Le._id===ie.cameraId),toolbar:!1,control:!1,subcontrol:!1,"live-indicator-overlay":""},null,8,["camera-info"])):(m(),j(fe,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])]}),_:2},1536)],4)),[[c(Vh),[de=>He(ie._id,de),{delayEnter:0,delayLeave:1e3}]],[c(Y0),[()=>ht(ie),{distanceThreshold:24,delay:500,onMouseUp:(de,Le,rt)=>Mt(rt,ie)}]]])),128)),c(L)?(m(),A("div",{key:0,ref_key:"placeholderRef",ref:u,class:"draggable absolute pointer-events-auto",style:ot(`left: ${c(L).x}px; top: ${c(L).y}px;`)},[y(ye,{severity:"secondary",rounded:"",class:"cui-icon-lg shadow-sm pointer-events-auto"},{icon:$(()=>[y(_e,{width:"100%",height:"100%"})]),_:1})],4)):ce("",!0),c(a)&&!c(z)&&!c(K)?(m(),j(Pt,{key:1,ref_key:"camerasMenuRef",ref:h,class:"shadow-lg cui-rounded-corner","auto-z-index":!0,"append-to":"body",onShow:X[0]||(X[0]=ie=>O.value=!0),onHide:X[1]||(X[1]=ie=>Pe(!1))},{default:$(()=>[g("div",w6,[(m(!0),A(yt,null,qt(c(D),ie=>(m(),j(he,{key:ie._id,class:"shortcut-menu-item","camera-name":ie.name,width:"100%",loading:c(F),onClick:lr(de=>wt(ie),["prevent"])},null,8,["camera-name","loading","onClick"]))),128))])]),_:1},512)):ce("",!0)],6)}}}),S6=qs(x6,[["__scopeId","data-v-98006b6f"]]),C6={viewBox:"0 0 512 512",width:"1.2em",height:"1.2em"};function k6(s,e){return m(),A("svg",C6,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"m184 112l144 144l-144 144"},null,-1)]))}const E6=pe({name:"ion-chevron-forward-outline",render:k6}),A6={viewBox:"0 0 512 512",width:"1.2em",height:"1.2em"};function M6(s,e){return m(),A("svg",A6,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"M328 112L184 256l144 144"},null,-1)]))}const $6=pe({name:"ion-chevron-back-outline",render:M6}),T6={viewBox:"0 0 512 512",width:"1.2em",height:"1.2em"};function P6(s,e){return m(),A("svg",T6,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"m112 184l144 144l144-144"},null,-1)]))}const R6=pe({name:"ion-chevron-down-outline",render:P6}),I6={viewBox:"0 0 512 512",width:"1.2em",height:"1.2em"};function O6(s,e){return m(),A("svg",I6,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"m112 328l144-144l144 144"},null,-1)]))}const N6=pe({name:"ion-chevron-up-outline",render:O6}),F6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function L6(s,e){return m(),A("svg",F6,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M18 12.998H6a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2"},null,-1)]))}const j6=pe({name:"ic-round-minus",render:L6}),q6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function D6(s,e){return m(),A("svg",q6,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M18 12.998h-5v5a1 1 0 0 1-2 0v-5H6a1 1 0 0 1 0-2h5v-5a1 1 0 0 1 2 0v5h5a1 1 0 0 1 0 2"},null,-1)]))}const B6=pe({name:"ic-round-plus",render:D6});function Fl(s){const e=ae(),t=ae(!1),n=ae(!1),r=ae(),i=ae(),o=ae(),a=ae(),l=ae(),u=ae(),d=ae(),h=ae([]),v=ne(()=>t.value),f=ne(()=>n.value),b=ne(()=>h.value.includes(Wt.Light)),k=ne(()=>h.value.includes(Wt.Siren)),z=ne(()=>h.value.includes(Wt.Doorbell)),L=ne(()=>h.value.includes(Wt.Battery)),se=ne(()=>h.value.includes(Wt.AudioSensor)),K=ne(()=>h.value.includes(Wt.MotionSensor)||h.value.includes(Wt.MotionDetector)),N=ne(()=>h.value.includes(Wt.ObjectSensor)||h.value.includes(Wt.ObjectDetector)),E=ne(()=>h.value.includes(Wt.PTZ));return Ge(s,O=>{if(!O)return;e.value=O.cameraSubject.value,t.value=O.connected,n.value=O.frameWorkerConnected,h.value=O.getCapabilities(),r.value=O.getValue("light"),i.value=O.getValue("motion"),o.value=O.getValue("audio"),a.value=O.getValue("object"),l.value=O.getValue("doorbell"),u.value=O.getValue("siren"),d.value=O.getValue("battery");const U=fn(O.cameraSubject);Ge(U,ue=>{ue&&(e.value=ue)});const S=fn(O.onConnected);Ge(S,ue=>{t.value=!!ue});const M=fn(O.onFrameWorkerConnected);Ge(M,ue=>{n.value=!!ue});const B=fn(O.capabilities);Ge(B,ue=>{ue&&(h.value=ue.map(Se=>Se.capabilities).flat())});const W=fn(O.onLightSwitched);Ge(W,ue=>{r.value=ue});const I=fn(O.onMotionDetected);Ge(I,ue=>{i.value=ue});const w=fn(O.onAudioDetected);Ge(w,ue=>{o.value=ue});const Q=fn(O.onObjectDetected);Ge(Q,ue=>{a.value=ue});const J=fn(O.onDoorbellPressed);Ge(J,ue=>{l.value=ue});const q=fn(O.onSirenDetected);Ge(q,ue=>{u.value=ue});const oe=fn(O.onBatteryChanged);Ge(oe,ue=>{d.value=ue})},{immediate:!0}),{cameraObject:e,connected:v,frameWorkerConnected:f,hasLight:b,hasSiren:k,hasDoorbell:z,hasBattery:L,hasAudioDetector:se,hasMotionDetector:K,hasObjectDetector:N,hasPtz:E,capabilities:h,lightState:r,motionState:i,audioState:o,objectState:a,doorbellState:l,sirenState:u,batteryState:d}}const z6={class:"relative w-full h-full"},U6={class:"absolute top-1 text-muted"},V6={class:"absolute bottom-1 text-muted"},H6={class:"absolute left-1 text-muted"},Q6={class:"absolute right-1 text-muted"},Mh=100,kr=2e3,as=.05,$h=.05,K6=.03,Z6=At({__name:"CuiCameraPTZ",props:{cameraDevice:{},size:{default:"small"}},emits:["panTiltChange","zoomChange"],setup(s,{expose:e,emit:t}){const n=t,r=s,{cameraDevice:i,size:o}=Jt(r),{capabilities:a}=Fl(i),l=Vt("panTiltRef"),u=Vt("zoomRef"),d=Pr({x:0,y:0}),h=Pr({x:0,y:0}),v=Pr({x:0,y:0}),f=ae(!1),b=ae(!1),k=ae(0),z=ae(0),L=ae(0),se=ae(!1),K=ae(0),N=ae(0),E=ae(0),O=ae(0),U=ae(0),S=ae(0),M=ae(0),B=ae("none"),W=ae(0),I=ae(0),w=ae(0),Q=ae(null),J=ae(Date.now()),q=ne(()=>f.value||b.value),oe=ne(()=>o.value==="small"?45:60),ue=ne(()=>o.value==="small"?10:15),Se=ne(()=>se.value),F=Be=>Math.round(Be*100)/100,D=Be=>F(Math.max(0,Math.min(1,Be))),Y=async Be=>{const Ue=Date.now();if(!(se.value&&Ue-K.value<Mh)){"pan"in Be&&Be.pan!==void 0&&(Be.pan=F(Be.pan)),"tilt"in Be&&Be.tilt!==void 0&&(Be.tilt=F(Be.tilt)),"zoom"in Be&&Be.zoom!==void 0&&(Be.zoom=D(Be.zoom)),se.value=!0,K.value=Ue;try{await i.value.interfaces.ptzCommand(Be)}catch(V){console.error("PTZ command failed:",V)}finally{se.value=!1}}},Pe=()=>{const Be=Date.now(),Ue=(Be-J.value)/1e3;J.value=Be;let V=!1;if(f.value&&(Math.abs(U.value)>=as||Math.abs(S.value)>=as)){const X=U.value*$h*Ue*5,_e=S.value*$h*Ue*5;W.value=Math.max(-1,Math.min(1,W.value+X)),I.value=Math.max(-1,Math.min(1,I.value+_e));const ye=F(W.value),fe=F(I.value);(h.x!==ye||h.y!==fe)&&(h.x=ye,h.y=fe,n("panTiltChange",{x:h.x,y:h.y}),V=!0)}if(b.value&&Math.abs(M.value)>=as){const X=M.value*K6*Ue*10;w.value=Math.max(0,Math.min(1,w.value+X));const _e=F(w.value);z.value!==_e&&(z.value=_e,n("zoomChange",_e),V=!0)}if(V&&q.value&&Date.now()-K.value>=Mh*2){if(f.value&&(Math.abs(U.value)>=as||Math.abs(S.value)>=as)){const _e=F(U.value),ye=F(S.value);B.value==="pan"?Y({type:"continuous",pan:_e,tilt:0,timeout:kr}):B.value==="tilt"?Y({type:"continuous",pan:0,tilt:ye,timeout:kr}):Y({type:"continuous",pan:_e,tilt:ye,timeout:kr})}else if(b.value&&Math.abs(M.value)>=as){const _e=D(Math.abs(M.value)),ye=M.value>0;Y({type:"continuous",zoom:ye?_e:-_e,timeout:kr})}}q.value&&(Q.value=requestAnimationFrame(Pe))},He=()=>{Q.value!==null&&cancelAnimationFrame(Q.value),J.value=Date.now(),Q.value=requestAnimationFrame(Pe)},ht=()=>{Q.value!==null&&(cancelAnimationFrame(Q.value),Q.value=null)},Mt=async()=>{await new Promise(Be=>setTimeout(Be,50)),!q.value&&(Math.abs(N.value)>=as||Math.abs(E.value)>=as||Math.abs(O.value)>=as)&&(U.value=0,S.value=0,M.value=0,B.value="none",N.value=0,E.value=0,O.value=0,await Y({type:"stop"}),ht())},Qe=Be=>{b.value=!0,J.value=Date.now(),w.value=z.value,He(),Be instanceof MouseEvent?ze(Be.clientY):ze(Be.touches[0].clientY)},ze=async Be=>{if(!u.value||!b.value)return;const Ue=u.value.getBoundingClientRect(),V=Ue.top+Ue.height/2,X=oe.value;let _e=Be-V;_e=Math.max(-X,Math.min(X,_e)),k.value=_e;const ye=-_e/X;M.value=ye;const fe=F(ye);if(Math.abs(fe)>=as&&Math.abs(fe-O.value)>=as){O.value=fe;const _t=fe>0,Pt=D(Math.abs(fe));await Y({type:"continuous",zoom:_t?Pt:-Pt,timeout:kr})}else b.value&&Math.abs(fe)<as&&Math.abs(O.value)>=as&&(M.value=0,O.value=0,await Y({type:"stop"}))},ge=Be=>{f.value=!0,J.value=Date.now(),He(),Be instanceof MouseEvent?ft(Be.clientX,Be.clientY):ft(Be.touches[0].clientX,Be.touches[0].clientY)},ft=async(Be,Ue)=>{if(!l.value||!f.value)return;const V=l.value.getBoundingClientRect(),X=V.width/2,_e=V.height/2;let ye=Be-V.left-X,fe=Ue-V.top-_e;const _t=Math.min(X,_e)-ue.value,Pt=Math.sqrt(ye*ye+fe*fe);Pt>_t&&(ye=ye/Pt*_t,fe=fe/Pt*_t),d.x=ye,d.y=fe;const he=ye/_t,ie=-fe/_t,de=Math.abs(he),Le=Math.abs(ie);de>=as||Le>=as?de>Le?(B.value="pan",U.value=he,S.value=0):(B.value="tilt",U.value=0,S.value=ie):(B.value="none",U.value=0,S.value=0),(de>as||Le>as)&&(v.x=U.value,v.y=S.value);const rt=Math.abs(U.value-N.value),Kt=Math.abs(S.value-E.value),ps=rt>=as||Kt>=as,Zt=Math.abs(U.value)>=as||Math.abs(S.value)>=as;if(Zt&&ps){N.value=U.value,E.value=S.value;const os=F(U.value),As=F(S.value);B.value==="pan"?await Y({type:"continuous",pan:os,tilt:0,timeout:kr}):B.value==="tilt"&&await Y({type:"continuous",pan:0,tilt:As,timeout:kr})}else f.value&&!Zt&&(Math.abs(N.value)>=as||Math.abs(E.value)>=as)&&(U.value=0,S.value=0,B.value="none",N.value=0,E.value=0,await Y({type:"stop"}))},Yt=Be=>{f.value&&ft(Be.clientX,Be.clientY),b.value&&ze(Be.clientY)},wt=Be=>{Be.preventDefault(),f.value&&ft(Be.touches[0].clientX,Be.touches[0].clientY),b.value&&ze(Be.touches[0].clientY)},zt=()=>{f.value&&(f.value=!1,d.x=0,d.y=0),b.value&&(L.value=z.value,b.value=!1,k.value=0),Mt()},nt=async(Be,Ue)=>{await Y({type:"preset",preset:Be,speed:Ue})},Xt=async Be=>{await Y({type:"home",speed:Be})};return Sn(()=>{window.addEventListener("mousemove",Yt),window.addEventListener("mouseup",zt),window.addEventListener("touchmove",wt,{passive:!1}),window.addEventListener("touchend",zt)}),go(()=>{window.removeEventListener("mousemove",Yt),window.removeEventListener("mouseup",zt),window.removeEventListener("touchmove",wt),window.removeEventListener("touchend",zt),ht(),Y({type:"stop"})}),e({goToPreset:nt,goToHome:Xt,isLoading:Se}),(Be,Ue)=>{const V=B6,X=j6,_e=N6,ye=R6,fe=$6,_t=E6;return m(),A("div",z6,[c(a).includes(c(Wt).PTZZoom)?(m(),A("div",{key:0,ref_key:"zoomRef",ref:u,class:at(["pointer-events-auto",["absolute left-4 bottom-4 bg-black/70 rounded-full flex flex-col items-center justify-center border border-white/10 shadow-md",c(o)==="small"?"w-12 h-36":"w-16 h-48"]]),onMousedown:Qe,onTouchstart:lr(Qe,["prevent"])},[g("div",{class:at(["absolute top-4 text-muted",c(o)==="small"?"text-base":"text-lg"])},[y(V)],2),g("div",{class:at(["absolute bottom-4 text-muted",c(o)==="small"?"text-base":"text-lg"])},[y(X)],2),g("div",{class:at(["bg-white rounded-full absolute cursor-grab active:cursor-grabbing shadow-lg",c(o)==="small"?"w-8 h-8":"w-10 h-10"]),style:ot({transform:`translateY(${c(k)}px)`})},null,6)],34)):ce("",!0),c(a).includes(c(Wt).PTZ)?(m(),A("div",{key:1,ref_key:"panTiltRef",ref:l,class:at(["pointer-events-auto",["absolute right-4 bottom-4 bg-black/70 rounded-full flex items-center justify-center border border-white/10 shadow-md",c(o)==="small"?"w-24 h-24":"w-32 h-32"]]),onMousedown:ge,onTouchstart:lr(ge,["prevent"])},[g("div",U6,[y(_e)]),g("div",V6,[y(ye)]),g("div",H6,[y(fe)]),g("div",Q6,[y(_t)]),g("div",{class:at(["bg-white rounded-full absolute cursor-grab active:cursor-grabbing shadow-lg transform -translate-x-1/2 -translate-y-1/2",c(o)==="small"?"w-8 h-8":"w-10 h-10"]),style:ot({left:`calc(50% + ${c(d).x}px)`,top:`calc(50% + ${c(d).y}px)`})},null,6)],34)):ce("",!0)])}}}),G6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function W6(s,e){return m(),A("svg",G6,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M17.5 6.5H20a1.5 1.5 0 0 1 0 3h-3A2.5 2.5 0 0 1 14.5 7V4a1.5 1.5 0 0 1 3 0zM4 6.5h2.5V4a1.5 1.5 0 1 1 3 0v3A2.5 2.5 0 0 1 7 9.5H4a1.5 1.5 0 1 1 0-3m0 11h2.5V20a1.5 1.5 0 0 0 3 0v-3A2.5 2.5 0 0 0 7 14.5H4a1.5 1.5 0 0 0 0 3m16 0h-2.5V20a1.5 1.5 0 0 1-3 0v-3a2.5 2.5 0 0 1 2.5-2.5h3a1.5 1.5 0 0 1 0 3"})],-1)]))}const J6=pe({name:"mingcute-fullscreen-exit-fill",render:W6}),Y6={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function X6(s,e){return m(),A("svg",Y6,e[0]||(e[0]=[g("g",{fill:"none","fill-rule":"evenodd"},[g("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),g("path",{fill:"currentColor",d:"M18.5 5.5H16a1.5 1.5 0 0 1 0-3h3A2.5 2.5 0 0 1 21.5 5v3a1.5 1.5 0 0 1-3 0zM8 5.5H5.5V8a1.5 1.5 0 1 1-3 0V5A2.5 2.5 0 0 1 5 2.5h3a1.5 1.5 0 1 1 0 3m0 13H5.5V16a1.5 1.5 0 0 0-3 0v3A2.5 2.5 0 0 0 5 21.5h3a1.5 1.5 0 0 0 0-3m8 0h2.5V16a1.5 1.5 0 0 1 3 0v3a2.5 2.5 0 0 1-2.5 2.5h-3a1.5 1.5 0 0 1 0-3"})],-1)]))}const e8=pe({name:"mingcute-fullscreen-fill",render:X6}),t8={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function s8(s,e){return m(),A("svg",t8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M3.5 2A2.5 2.5 0 0 0 1 4.5v5A2.5 2.5 0 0 0 3.5 12H7v-2a2 2 0 0 1 2-2h5V4.5A2.5 2.5 0 0 0 11.5 2zM8 10a1 1 0 0 1 1-1h5a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1z"},null,-1)]))}const n8=pe({name:"fluent-picture-in-picture16-filled",render:s8}),r8={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function i8(s,e){return m(),A("svg",r8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M1 4.5A2.5 2.5 0 0 1 3.5 2h8A2.5 2.5 0 0 1 14 4.5V8h-1V4.5A1.5 1.5 0 0 0 11.5 3h-8A1.5 1.5 0 0 0 2 4.5v5A1.5 1.5 0 0 0 3.5 11H7v1H3.5A2.5 2.5 0 0 1 1 9.5zM9 9a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1z"},null,-1)]))}const o8=pe({name:"fluent-picture-in-picture16-regular",render:i8}),a8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function c8(s,e){return m(),A("svg",a8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M13.986 14.776a.73.73 0 0 1-.66-.4a.74.74 0 0 1 .3-1a2.45 2.45 0 0 0 1-1.001a.739.739 0 0 1 1.359.127a.75.75 0 0 1-.048.563a3.85 3.85 0 0 1-1.611 1.61a.7.7 0 0 1-.34.1"},null,-1),g("path",{fill:"currentColor",d:"M19.409 10.644a7.55 7.55 0 0 1-.7 3.141a7.48 7.48 0 0 1-4.823 4.003a6.4 6.4 0 0 1-1.151.2v2.511h2.892a.75.75 0 0 1 0 1.501H8.342a.75.75 0 0 1 0-1.5h2.892v-2.512a6 6 0 0 1-.57-.07a.752.752 0 0 1 .27-1.481q.442.078.89.08h.33a5.5 5.5 0 0 0 1.341-.19a5.9 5.9 0 0 0 2.282-1.18a5.9 5.9 0 0 0 2.13-4.543a.75.75 0 0 1 1.502 0zM20.52 4.56l-4.363 4.353l-5.623 5.623l-6.004 6.003a.8.8 0 0 1-.53.22a.75.75 0 0 1-.53-.22a.74.74 0 0 1 0-1.06l3.462-3.462l-.18-.2a7.3 7.3 0 0 1-2.172-5.183a.75.75 0 0 1 .74-.76a.76.76 0 0 1 .751.75a5.92 5.92 0 0 0 1.771 4.172l.14.16l.85-.84a4 4 0 0 1-.65-.77a3.66 3.66 0 0 1-.59-1.892V5.851a4.13 4.13 0 0 1 1.45-2.872a4.92 4.92 0 0 1 5.894 0a4.13 4.13 0 0 1 1.441 2.802v.79l3.092-3.091a.74.74 0 0 1 1.06 0a.75.75 0 0 1-.01 1.08"},null,-1)]))}const l8=pe({name:"mage-microphone-mute-fill",render:c8}),u8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d8(s,e){return m(),A("svg",u8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M16.43 5.838v5.57a4.43 4.43 0 0 1-8.78 0v-5.57a4.43 4.43 0 0 1 8.78 0"},null,-1),g("path",{fill:"currentColor",d:"M12.79 17.998v2.5h2.89a.75.75 0 0 1 0 1.5H8.4a.75.75 0 1 1 0-1.5h2.85v-2.5a7.4 7.4 0 0 1-6.67-7.38a.75.75 0 0 1 1.5 0a5.92 5.92 0 1 0 11.84 0a.75.75 0 0 1 1.5 0a7.4 7.4 0 0 1-6.67 7.38z"},null,-1)]))}const h8=pe({name:"mage-microphone-fill",render:d8}),m8={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function p8(s,e){return m(),A("svg",m8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M7.557 2.066A.75.75 0 0 1 8 2.75v10.5a.75.75 0 0 1-1.248.56L3.59 11H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h1.59l3.162-2.81a.75.75 0 0 1 .805-.124M11.28 5.72a.75.75 0 1 0-1.06 1.06L11.44 8l-1.22 1.22a.75.75 0 1 0 1.06 1.06l1.22-1.22l1.22 1.22a.75.75 0 1 0 1.06-1.06L13.56 8l1.22-1.22a.75.75 0 0 0-1.06-1.06L12.5 6.94z"},null,-1)]))}const f8=pe({name:"heroicons-speaker-x-mark16-solid",render:p8}),g8={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function v8(s,e){return m(),A("svg",g8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M7.557 2.066A.75.75 0 0 1 8 2.75v10.5a.75.75 0 0 1-1.248.56L3.59 11H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h1.59l3.162-2.81a.75.75 0 0 1 .805-.124m5.393.984a.75.75 0 1 0-1.06 1.06a5.5 5.5 0 0 1 0 7.78a.75.75 0 1 0 1.06 1.06a7 7 0 0 0 0-9.9"},null,-1),g("path",{fill:"currentColor",d:"M10.828 5.172a.75.75 0 1 0-1.06 1.06a2.5 2.5 0 0 1 0 3.536a.75.75 0 1 0 1.06 1.06a4 4 0 0 0 0-5.656"},null,-1)]))}const _8=pe({name:"heroicons-speaker-wave16-solid",render:v8}),y8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function b8(s,e){return m(),A("svg",y8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M10 12v10H8v-8H6v-2zm8 2v6c0 1.11-.89 2-2 2h-2a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-4 0v6h2v-6zM11.5 3c2.65 0 5.05 1 6.9 2.6L21 3v7h-7l2.62-2.62C15.23 6.22 13.46 5.5 11.5 5.5c-3.54 0-6.55 2.31-7.6 5.5l-2.37-.78C2.92 6.03 6.85 3 11.5 3"},null,-1)]))}const w8=pe({name:"mdi-fast-forward10",render:b8}),x8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function S8(s,e){return m(),A("svg",x8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M17.276 5.47c.435.16.724.575.724 1.039V17.49c0 .464-.29.879-.724 1.039a3.7 3.7 0 0 1-2.552 0A1.11 1.11 0 0 1 14 17.491V6.51c0-.464.29-.879.724-1.04a3.7 3.7 0 0 1 2.552 0m-8 0c.435.16.724.575.724 1.039V17.49c0 .464-.29.879-.724 1.039a3.7 3.7 0 0 1-2.552 0A1.11 1.11 0 0 1 6 17.491V6.51c0-.464.29-.879.724-1.04a3.7 3.7 0 0 1 2.552 0"},null,-1)]))}const C8=pe({name:"basil-pause-solid",render:S8}),k8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function E8(s,e){return m(),A("svg",k8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M19.266 13.516a1.917 1.917 0 0 0 0-3.032A35.8 35.8 0 0 0 9.35 5.068l-.653-.232c-1.248-.443-2.567.401-2.736 1.69a42.5 42.5 0 0 0 0 10.948c.17 1.289 1.488 2.133 2.736 1.69l.653-.232a35.8 35.8 0 0 0 9.916-5.416"},null,-1)]))}const A8=pe({name:"basil-play-solid",render:E8}),M8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $8(s,e){return m(),A("svg",M8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12.5 3c4.65 0 8.58 3.03 9.97 7.22L20.1 11c-1.05-3.19-4.06-5.5-7.6-5.5c-1.96 0-3.73.72-5.12 1.88L10 10H3V3l2.6 2.6C7.45 4 9.85 3 12.5 3M10 12v10H8v-8H6v-2zm8 2v6c0 1.11-.89 2-2 2h-2a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-4 0v6h2v-6z"},null,-1)]))}const T8=pe({name:"mdi-rewind10",render:$8}),P8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function R8(s,e){return m(),A("svg",P8,e[0]||(e[0]=[g("path",{fill:"none",stroke:"currentColor","stroke-width":"2",d:"M8.5 5.5L12 2l3.5 3.5M22 12H2m3.5-3.5L2 12l3.5 3.5m13 0L22 12l-3.5-3.5M12 22V2M8.5 18.5L12 22l3.5-3.5"},null,-1)]))}const I8=pe({name:"grommet-icons-pan",render:R8}),O8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function N8(s,e){return m(),A("svg",O8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M4 19v-9q0-.475.213-.9t.587-.7l6-4.5q.525-.4 1.2-.4t1.2.4l6 4.5q.375.275.588.7T20 10v9q0 .825-.588 1.413T18 21h-3q-.425 0-.712-.288T14 20v-5q0-.425-.288-.712T13 14h-2q-.425 0-.712.288T10 15v5q0 .425-.288.713T9 21H6q-.825 0-1.412-.587T4 19"},null,-1)]))}const F8=pe({name:"material-symbols-home-rounded",render:N8}),L8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function j8(s,e){return m(),A("svg",L8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 .36A5.4 5.4 0 0 0 6.62 5.3a5.4 5.4 0 0 0-1.22-.14a5.4 5.4 0 0 0-2.143 10.357a5.4 5.4 0 0 0-.737 2.723a5.4 5.4 0 0 0 9.54 3.466a5.4 5.4 0 0 0 8.833-6.137a5.4 5.4 0 0 0-3.505-10.152A5.4 5.4 0 0 0 12 .36M6.283 7.228h10.592c.746 0 1.352.605 1.352 1.349v7.646a1.35 1.35 0 0 1-1.352 1.348h-3.608l-7.24 3.55l1.1-3.55h-.844a1.35 1.35 0 0 1-1.352-1.348V8.577c0-.744.606-1.349 1.352-1.349"},null,-1)]))}const q8=pe({name:"simple-icons-webrtc",render:j8}),D8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function B8(s,e){return m(),A("svg",D8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M17.41 2H6.59A4.58 4.58 0 0 0 2 6.59v10.82A4.58 4.58 0 0 0 6.59 22h10.82A4.58 4.58 0 0 0 22 17.41V6.59A4.58 4.58 0 0 0 17.41 2m-2.653 12.447a1.924 1.924 0 0 1-1.924 1.923h-5.86a1.924 1.924 0 0 1-1.923-1.923v-4.87a1.923 1.923 0 0 1 1.927-1.924h5.856a1.925 1.925 0 0 1 1.924 1.924zm4.2.74a.771.771 0 0 1-1.266.59l-2.211-1.854a.85.85 0 0 1-.3-.653v-2.52a.85.85 0 0 1 .31-.657l2.206-1.82a.769.769 0 0 1 1.26.594z"},null,-1)]))}const z8=pe({name:"cbi-iosfacetime",render:B8}),U8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function V8(s,e){return m(),A("svg",U8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M10.4 13.45h3.2l.6 1.625q.075.2.238.313t.362.112q.35 0 .538-.275t.062-.6l-2.55-6.7q-.075-.2-.237-.312T12.25 7.5h-.5q-.2 0-.363.113t-.237.312L8.625 14.65q-.125.3.05.575t.525.275q.2 0 .363-.112t.237-.313zm.4-1.15L11.95 9h.1l1.15 3.3zM12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12q0-.8.125-1.6T2.5 8.825q.125-.4.513-.537t.737.062q.375.2.538.588t.037.812q-.15.55-.238 1.113T4 12q0 3.35 2.325 5.675T12 20t5.675-2.325T20 12t-2.325-5.675T12 4q-.6 0-1.187.087T9.65 4.35q-.425.125-.8-.025T8.3 3.8t-.013-.762t.563-.513q.75-.275 1.55-.4T12 2q2.075 0 3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22M5.5 7q-.625 0-1.062-.437T4 5.5t.438-1.062T5.5 4t1.063.438T7 5.5t-.437 1.063T5.5 7m6.5 5"},null,-1)]))}const H8=pe({name:"material-symbols-motion-photos-auto-outline-rounded",render:V8}),Q8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function K8(s,e){return m(),A("svg",Q8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"m8.471 7.237l3.056 12.992c.233.993 1.63 1.04 1.929.065l2.945-9.58l.384 1.527a1 1 0 0 0 .97.756H21a1 1 0 1 0 0-2h-2.466l-1.069-4.241c-.247-.981-1.628-1.017-1.925-.05l-2.912 9.472L9.475 2.771c-.24-1.02-1.688-1.03-1.943-.014l-2.065 8.24H3a1 1 0 0 0 0 2h3.247a1 1 0 0 0 .97-.757z"},null,-1)]))}const Z8=pe({name:"fluent-pulse24-filled",render:K8}),G8={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function W8(s,e){return m(),A("svg",G8,e[0]||(e[0]=[g("g",{fill:"none",stroke:"currentColor","stroke-linejoin":"round","stroke-width":"4"},[g("path",{fill:"currentColor",d:"M16.866 7.47A18 18 0 0 0 16 13c0 9.941 8.059 18 18 18a17.9 17.9 0 0 0 7.134-1.47C38.801 36.767 32.012 42 24 42c-9.941 0-18-8.059-18-18c0-7.407 4.473-13.768 10.866-16.53Z"}),g("path",{"stroke-linecap":"round",d:"M31.66 10H41l-10 8h10"})],-1)]))}const J8=pe({name:"icon-park-solid-sleep",render:W8}),Y8={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function X8(s,e){return m(),A("svg",Y8,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 2a7 7 0 0 1 7 7a7 7 0 0 1-7 7a7 7 0 0 1-7-7a7 7 0 0 1 7-7m0 2a5 5 0 0 0-5 5a5 5 0 0 0 5 5a5 5 0 0 0 5-5a5 5 0 0 0-5-5m0 2a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3M6 22a2 2 0 0 1-2-2c0-.38.1-.73.29-1.03l1.82-3.16A9 9 0 0 0 12 18c2.25 0 4.31-.83 5.89-2.19l1.82 3.16c.19.3.29.65.29 1.03a2 2 0 0 1-2 2z"},null,-1)]))}const ex=pe({name:"mdi-webcam",render:X8}),tx={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sx(s,e){return m(),A("svg",tx,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M9.367 2.25h5.266c1.092 0 1.958 0 2.655.057c.714.058 1.317.18 1.869.46a4.75 4.75 0 0 1 2.075 2.077c.281.55.403 1.154.461 1.868c.057.697.057 1.563.057 2.655v5.266c0 1.092 0 1.958-.057 2.655c-.058.714-.18 1.317-.46 1.869a4.75 4.75 0 0 1-2.076 2.075c-.552.281-1.155.403-1.869.461c-.697.057-1.563.057-2.655.057H9.367c-1.092 0-1.958 0-2.655-.057c-.714-.058-1.317-.18-1.868-.46a4.75 4.75 0 0 1-2.076-2.076c-.281-.552-.403-1.155-.461-1.869c-.057-.697-.057-1.563-.057-2.655V9.367c0-1.092 0-1.958.057-2.655c.058-.714.18-1.317.46-1.868a4.75 4.75 0 0 1 2.077-2.076c.55-.281 1.154-.403 1.868-.461c.697-.057 1.563-.057 2.655-.057M10.25 8a.75.75 0 0 0-1.5 0v8a.75.75 0 0 0 1.5 0v-3.25h3.5V16a.75.75 0 0 0 1.5 0V8a.75.75 0 0 0-1.5 0v3.25h-3.5z"},null,-1)]))}const nx=pe({name:"mynaui-letter-h-square-solid",render:sx}),rx={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ix(s,e){return m(),A("svg",rx,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M9.367 2.25h5.266c1.092 0 1.958 0 2.655.057c.714.058 1.317.18 1.869.46a4.75 4.75 0 0 1 2.075 2.077c.281.55.403 1.154.461 1.868c.057.697.057 1.563.057 2.655v5.266c0 1.092 0 1.958-.057 2.655c-.058.714-.18 1.317-.46 1.869a4.75 4.75 0 0 1-2.076 2.075c-.552.281-1.155.403-1.869.461c-.697.057-1.563.057-2.655.057H9.367c-1.092 0-1.958 0-2.655-.057c-.714-.058-1.317-.18-1.868-.46a4.75 4.75 0 0 1-2.076-2.076c-.281-.552-.403-1.155-.461-1.869c-.057-.697-.057-1.563-.057-2.655V9.367c0-1.092 0-1.958.057-2.655c.058-.714.18-1.317.46-1.868a4.75 4.75 0 0 1 2.077-2.076c.55-.281 1.154-.403 1.868-.461c.697-.057 1.563-.057 2.655-.057m.233 5.3A.75.75 0 0 0 8.25 8v8a.75.75 0 0 0 1.5 0v-5.75l1.65 2.2a.75.75 0 0 0 1.2 0l1.65-2.2V16a.75.75 0 0 0 1.5 0V8a.75.75 0 0 0-1.35-.45l-2.4 3.2z"},null,-1)]))}const ox=pe({name:"mynaui-letter-m-square-solid",render:ix}),ax={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function cx(s,e){return m(),A("svg",ax,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M9.367 2.25h5.266c1.092 0 1.958 0 2.655.057c.714.058 1.317.18 1.869.46a4.75 4.75 0 0 1 2.075 2.077c.281.55.403 1.154.461 1.868c.057.697.057 1.563.057 2.655v5.266c0 1.092 0 1.958-.057 2.655c-.058.714-.18 1.317-.46 1.869a4.75 4.75 0 0 1-2.076 2.075c-.552.281-1.155.403-1.869.461c-.697.057-1.563.057-2.655.057H9.367c-1.092 0-1.958 0-2.655-.057c-.714-.058-1.317-.18-1.868-.46a4.75 4.75 0 0 1-2.076-2.076c-.281-.552-.403-1.155-.461-1.869c-.057-.697-.057-1.563-.057-2.655V9.367c0-1.092 0-1.958.057-2.655c.058-.714.18-1.317.46-1.868a4.75 4.75 0 0 1 2.077-2.076c.55-.281 1.154-.403 1.868-.461c.697-.057 1.563-.057 2.655-.057M10.25 8a.75.75 0 0 0-1.5 0v7.5c0 .414.336.75.75.75H15a.75.75 0 0 0 0-1.5h-4.75z"},null,-1)]))}const lx=pe({name:"mynaui-letter-l-square-solid",render:cx}),ux={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dx(s,e){return m(),A("svg",ux,e[0]||(e[0]=[g("g",{fill:"currentColor"},[g("path",{d:"M12.918 12.083h-1.836L12 9.636z"}),g("path",{d:"M9.367 2.25h5.266c1.092 0 1.958 0 2.655.057c.714.058 1.317.18 1.869.46a4.75 4.75 0 0 1 2.075 2.077c.281.55.403 1.154.461 1.868c.057.697.057 1.563.057 2.655v5.266c0 1.092 0 1.958-.057 2.655c-.058.714-.18 1.317-.46 1.869a4.75 4.75 0 0 1-2.076 2.075c-.552.281-1.155.403-1.869.461c-.697.057-1.563.057-2.655.057H9.367c-1.092 0-1.958 0-2.655-.057c-.714-.058-1.317-.18-1.868-.46a4.75 4.75 0 0 1-2.076-2.076c-.281-.552-.403-1.155-.461-1.869c-.057-.697-.057-1.563-.057-2.655V9.367c0-1.092 0-1.958.057-2.655c.058-.714.18-1.317.46-1.868a4.75 4.75 0 0 1 2.077-2.076c.55-.281 1.154-.403 1.868-.461c.697-.057 1.563-.057 2.655-.057m3.335 4.987a.75.75 0 0 0-1.404 0l-3 8a.75.75 0 1 0 1.404.526l.818-2.18h2.96l.818 2.18a.75.75 0 1 0 1.404-.526z"})],-1)]))}const hx=pe({name:"mynaui-letter-a-square-solid",render:dx}),mx={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function px(s,e){return m(),A("svg",mx,e[0]||(e[0]=[g("path",{fill:"currentColor","fill-rule":"evenodd",d:"M18 2.75a.75.75 0 0 1 0-1.5h4a.75.75 0 0 1 .53 1.28l-2.72 2.72H22a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1-.53-1.28l2.72-2.72zm-4.5 6a.75.75 0 0 1 0-1.5h3a.75.75 0 0 1 .53 1.28l-1.72 1.72h1.19a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.53-1.28l1.72-1.72z","clip-rule":"evenodd"},null,-1),g("path",{fill:"currentColor",d:"M12 22c5.523 0 10-4.477 10-10c0-.463-.694-.54-.933-.143a6.5 6.5 0 1 1-8.924-8.924C12.54 2.693 12.463 2 12 2C6.477 2 2 6.477 2 12s4.477 10 10 10"},null,-1)]))}const fx=pe({name:"solar-moon-sleep-bold",render:px}),gx=Symbol("cui-camera-drawer"),qo=Hh(gx),bp={position:"right",showCloseIcon:!1,modal:!0,dismissable:!0,baseZIndex:1e3,blockScroll:!0,pt:{root:{class:"w-full sm:w-[400px]"}}},wp=()=>{const s=ae(!1),e=ne(()=>s.value),t=(r,i)=>{qo.emit({type:"open",options:r,props:{...bp,...i}}),s.value=!0},n=()=>{qo.emit({type:"close"}),s.value=!1};return qo.on(r=>{switch(r.type){case"close":s.value=!1;break;case"open":s.value=!0;break}}),{open:t,close:n,isOpen:e,getEventBus:()=>qo}};async function xp(){const s=Fs(),{api:e,isApiReady:t}=Vs(s);return t.value?e.value:new Promise((n,r)=>{const i=Ge(t,o=>{o&&e.value&&(i(),n(e.value))});setTimeout(()=>{i(),r(new Error("Timeout waiting for API"))},15e3)})}const vx={key:"sleep",class:"absolute left-0 right-0 top-0 bottom-0 bg-black/80 flex items-center justify-center z-7"},_x={class:"flex flex-col items-center justify-center text-center"},yx={key:0,class:"text-white/80 text-sm max-w-xs mt-3"},bx={key:"loading",class:"absolute w-full h-full flex flex-col items-center justify-center z-6 pointer-events-none"},wx={key:0,class:"mt-3 text-white text-sm text-shadow"},xx={key:"overlay",class:"absolute w-full p-4 flex items-center justify-between gap-2 z-6 pointer-events-none"},Sx={key:1,class:"text-sm font-semibold p-2 bg-black/60 rounded-xl text-white"},Cx={id:"timeline-container",key:"timeline",class:"absolute w-full h-full z-5 pointer-events-none"},kx={key:5,class:"absolute top-0 left-0 w-full h-full z-5 pointer-events-none"},Ex=["data-player-id","muted"],Ax={class:"flex items-center gap-2"},Mx={key:1,class:"w-[10px] h-[10px] rounded-full bg-red-500"},$x={class:"text-base font-semibold"},Th=6,Tx=5e3,Ph=5e3,Px=1e4,Rx=1e3,Ix=At({__name:"CuiCameraCard",props:Kn({cameraInfo:{},expandableCard:{type:Boolean,default:!1},flatCard:{type:Boolean,default:!1},cardProps:{},control:{type:Boolean,default:!0},controlFastForwardButton:{type:Boolean,default:!0},controlFsButton:{type:Boolean,default:!0},controlMicrophoneButton:{type:Boolean,default:!0},controlPipButton:{type:Boolean,default:!0},controlPlayPauseButton:{type:Boolean,default:!0},controlRewindButton:{type:Boolean,default:!0},controlSpeakerButton:{type:Boolean,default:!0},subcontrol:{type:Boolean,default:!0},subcontrolActivityModeButton:{type:Boolean,default:!0},subcontrolPtzButton:{type:Boolean,default:!0},subcontrolQualityButton:{type:Boolean,default:!0},subcontrolStreamingModeButton:{type:Boolean,default:!0},cameraNameOverlay:{type:Boolean,default:!0},liveIndicatorOverlay:{type:Boolean,default:!1},modeOverlay:{type:Boolean},toolbar:{type:Boolean,default:!0},toolbarClass:{},toolbarDetectionButton:{type:Boolean,default:!0},toolbarSettingsButton:{type:Boolean,default:!0},toolbarShareButton:{type:Boolean,default:!0},toolbarShortcutsButton:{type:Boolean,default:!0},toolbarSnapshotButton:{type:Boolean,default:!0},toolbarStyle:{},toolbarTimelineButton:{type:Boolean,default:!0},toolbarZoneButton:{type:Boolean,default:!0}},{activityMode:{default:"always-on"},activityModeModifiers:{},sourceRole:{},sourceRoleModifiers:{},streamingMode:{},streamingModeModifiers:{}}),emits:Kn(["streamFinishedLoading","expand"],["update:activityMode","update:sourceRole","update:streamingMode"]),setup(s,{expose:e,emit:t}){const n=new Jn,r=wp(),{mdBreakpoint:i}=Vr(),{isFsSupported:o,isIos:a,isPipSupported:l}=Il(),{t:u}=js(),d=t,h=Rr(s,"activityMode"),v=Rr(s,"sourceRole"),f=Rr(s,"streamingMode"),b=s,{cameraInfo:k,expandableCard:z,flatCard:L,cardProps:se,cameraNameOverlay:K,liveIndicatorOverlay:N,control:E,controlFastForwardButton:O,controlFsButton:U,controlMicrophoneButton:S,controlPipButton:M,controlPlayPauseButton:B,controlRewindButton:W,controlSpeakerButton:I,subcontrol:w,subcontrolActivityModeButton:Q,subcontrolPtzButton:J,subcontrolQualityButton:q,subcontrolStreamingModeButton:oe,toolbar:ue,toolbarClass:Se,toolbarDetectionButton:F,toolbarSettingsButton:D,toolbarShareButton:Y,toolbarShortcutsButton:Pe,toolbarSnapshotButton:He,toolbarStyle:ht,toolbarTimelineButton:Mt,toolbarZoneButton:Qe}=Jt(b),ze=Vt("snapshotRef"),ge=Vt("menuRef"),ft=Vt("motionDetectionCanvasRef"),Yt=Vt("objectDetectionCanvasRef"),wt=Vt("ptzRef"),zt=Vt("playerContainerRef"),nt=Vt("videoPlayerRef"),Xt=Ls(),{cameraObject:Be,motionState:Ue,objectState:V,hasPtz:X,hasMotionDetector:_e,hasObjectDetector:ye}=Fl(Xt),fe=Ls(null),_t=Ls(),Pt=ae(!1),he=ae(!1),ie=ae(!1),de=ae("loading"),Le=ae(!1),rt=ae(!1),Kt=ae(!1),ps=ae(!1),Zt=ae(!1),os=ae({x:0,y:0}),As=ae(1),fs=ae(!1),Ms=ae(!1),ds=ae(!1),R=ae(!1),te=ae(!1),ve=ae(!0),ke=ae(!1),st=ae(!0),Ot=ae(!1),Ht=ae(!1),Ye=ae(!1),Ce=ae(["animal","motion","other","person","vehicle"]),Oe=T_();let Fe,be,it;n.toggleQueryActivator("getCameraQuery",!1);const{data:_,isFetching:x,suspense:C}=n.getCameraQuery(typeof k.value=="string"?k.value:""),T=X0(),P=wu(zt,{delayLeave:1e3}),Z=wu(zt,{delayLeave:0}),Me=ri(zt),{isFullscreen:Te,toggle:le}=ef(a.value?nt:zt),{idle:Ee,reset:gt}=tf(Tx,{initialState:!1});ko(nt,"enterpictureinpicture",()=>Ht.value=!0),ko(nt,"leavepictureinpicture",()=>Ht.value=!1),ko(nt,"pause",()=>{ke.value=!1,Zt.value||So()}),ko(nt,"play",()=>{Zt.value=!1,ke.value=!0});const Xe=ne(()=>(P.value||ve.value)&&E.value&&!fs.value),pt=ne(()=>typeof k.value=="string"&&x.value||!ie.value||Le.value),ls=ne(()=>he.value&&de.value!=="error"),bs=ne(()=>!!navigator.mediaDevices&&Pt.value&&(de.value==="webrtc"||de.value==="webrtc/tcp")),Ii=ne(()=>Ye.value||!ie.value),kn=ne(()=>{var ee;return f.value??((ee=xo.value)==null?void 0:ee.interface.streamingMode)??"webrtc"}),on=ne(()=>{var ee;return v.value??((ee=xo.value)==null?void 0:ee.interface.streamingSource)??"high-resolution"}),Ll=ne(()=>K.value&&Xe.value&&!i.value&&Me.width.value>=350),kp=ne(()=>E.value&&Xe.value&&!rt.value&&Me.width.value>=150),Ep=ne(()=>w.value&&Xe.value&&!rt.value&&Me.width.value>=150),Oi=ne(()=>ds.value&&Me.width.value>=350&&X.value),jl=ne(()=>{var Ae;let ee=(Ae=xo.value)==null?void 0:Ae.interface.aspectRatio;return ee=!ee||ee==="auto"?"16:9":ee,ee.replace(":","/")}),xo=ne(()=>typeof k.value=="string"?_.value:k.value),En=ne(()=>typeof k.value=="string"?k.value:k.value.name),Ap=ne(()=>[{key:"animal",label:"Animal",toggle:!0,toggleState:Ce.value.includes("animal"),disabled:!Ni.value.includes("animal"),onClick:()=>Qr("animal")},{key:"motion",label:"Motion",toggle:!0,toggleState:Ce.value.includes("motion"),disabled:!Ni.value.includes("motion"),onClick:()=>Qr("motion")},{key:"other",label:"Other",toggle:!0,toggleState:Ce.value.includes("other"),disabled:!Ni.value.includes("other"),onClick:()=>Qr("other")},{key:"person",label:"Person",toggle:!0,toggleState:Ce.value.includes("person"),disabled:!Ni.value.includes("person"),onClick:()=>Qr("person")},{key:"vehicle",label:"Vehicle",toggle:!0,toggleState:Ce.value.includes("vehicle"),disabled:!Ni.value.includes("vehicle"),onClick:()=>Qr("vehicle")}]),Mp=ne(()=>{var Ae;const ee={body:{class:"w-full h-full p-0 overflow-hidden justify-center"},root:{class:{}}};return L.value&&(ee.root.class={...ee.root.class,"!rounded-none !border-0":!0}),Cl(ee,(Ae=se.value)==null?void 0:Ae.pt)}),ql=ne(()=>{const ee=Me.width.value;return ee?ee<=150?.4:ee<250?.5:ee<350?.7:ee<450?.85:1:1}),$p=ne(()=>{const ee=Me.height.value,Ae=ql.value;return ee?`${Math.min(Math.max(ee*.05,15),30)*Ae}px`:"20px"}),Tp=ne(()=>{const ee=Me.height.value,Ae=ql.value;return ee?`${Math.min(Math.max(ee*.05,15),30)*Ae}px`:"20px"}),ct=ne(()=>{const ee=Me.width.value;return ee?ee<=150?8:ee<225?10:ee<250?12:ee<350?14:ee<450?16:18:18}),an=ne(()=>{const ee=Me.width.value;return ee?ee<=170?18:ee<225?20:ee<250?22:ee<350?28:ee<450?34:40:40}),Ws=ne(()=>`${an.value}px`),Ni=ne(()=>{var Ae;const ee=new Set(((Ae=xo.value)==null?void 0:Ae.detectionZones.map(St=>St.classes).flat())??[]);return _e.value||ee.delete("motion"),ye.value||(ee.delete("animal"),ee.delete("person"),ee.delete("vehicle"),ee.delete("other")),Array.from(ee)});Ge(T,ee=>{var Ae,St;ee==="hidden"?(clearTimeout(be),be=setTimeout(()=>{Hr()},Px)):(clearTimeout(be),(Ae=fe.value)!=null&&Ae.finishLoading?So():(yr(),(St=fe.value)==null||St.start()))}),Ge(Le,async ee=>{ee&&await Fa(!1,!1)}),Ge(ie,ee=>{ee||Np(),d("streamFinishedLoading",ee)}),Ge(de,ee=>{clearInterval(it),ee==="mse"&&(it=setInterval(Fp,Rx))}),Ge(h,()=>{Gl()}),Ge(Ee,ee=>{h.value==="standby"&&ee&&(rt.value=!0,Hr())}),Ge(Ue,()=>{var ee,Ae,St;((ee=_.value)==null?void 0:ee.detectionZones.length)!==0&&(Wl(((Ae=Ue.value)==null?void 0:Ae.detections)??[]),Yl("motion",((St=Ue.value)==null?void 0:St.detections)??[]))},{deep:!0}),Ge(V,()=>{var ee,Ae,St;((ee=_.value)==null?void 0:ee.detectionZones.length)!==0&&(Wl(((Ae=V.value)==null?void 0:Ae.detections)??[]),Yl("object",((St=V.value)==null?void 0:St.detections)??[]))},{deep:!0});const Pp=async()=>{if(!nt.value)throw new Error("Video player not found!");typeof k.value=="string"&&await C();const ee=await xp();if(Xt.value=await ee.deviceManager.getCamera(En.value),!Xt.value)throw new Error("Camera not found!");fe.value=Xt.value.createWebRTCSession({role:on.value,mode:kn.value,videoElement:nt.value,webrtcConnectTimeout:2e3}),fe.value.addEventListener("error",zl),fe.value.addEventListener("reconnect",yr),fe.value.addEventListener("onModeChange",Ul),fe.value.addEventListener("onSourceChange",Vl),fe.value.addEventListener("onStreamProbe",Hl),fe.value.addEventListener("onFinishLoading",Ql),fe.value.addEventListener("onFirstFrame",Kl),fe.value.addEventListener("onLoadedData",Zl),Gl(!0)},Rp=()=>{var ee;if(kn.value==="auto"){const Ae=(ee=fe.value)!=null&&ee.currentMode?u(`components.player.streaming_mode_${fe.value.currentMode}`):u("components.player.streaming_mode_unknown");return`${u("components.player.streaming_mode_auto")}: ${Ae}`}else return kn.value.startsWith("webrtc")?u("components.player.streaming_mode_webrtc"):kn.value==="mse"?u("components.player.streaming_mode_mse"):u("components.player.streaming_mode_unknown")},Ip=()=>{var ee;if(on.value==="auto"){const Ae=(ee=fe.value)!=null&&ee.currentResolution?u(`components.player.source_role_${fe.value.currentResolution.split("-")[0]}`):u("components.player.source_role_unknown");return`${u("components.player.source_role_auto")}: ${Ae}`}else return on.value==="high-resolution"?u("components.player.source_role_high"):on.value==="mid-resolution"?u("components.player.source_role_mid"):on.value==="low-resolution"?u("components.player.source_role_low"):u("components.player.source_role_unknown")},Dl=ee=>{if(!nt.value||!zt.value||!P.value){os.value={x:0,y:0},As.value=1;return}const Ae=zt.value.getBoundingClientRect(),St=nt.value.getBoundingClientRect(),gs=Math.max(0,(St.width-Ae.width)/2),ss=Math.max(0,(St.height-Ae.height)/2),br=Math.max(-gs,Math.min(gs,ee.pan.x)),wr=Math.max(-ss,Math.min(ss,ee.pan.y));(ee.pan.x!==br||ee.pan.y!==wr)&&(os.value={x:br,y:wr});const Kr=1,es=Th-1;ee.zoom>es?ee.type==="dblClick"?Zs(()=>{As.value=Kr}):Zs(()=>{As.value=es}):ee.zoom===1&&setTimeout(()=>{os.value={x:0,y:0}},10)},Bl=()=>{z.value&&!rt.value&&d("expand")},zl=ee=>{console.error(En.value,ee),de.value="error",ie.value=!1,Le.value=!1},yr=()=>{de.value="reconnecting",ie.value=!1,Le.value=!0},Ul=()=>{de.value=fe.value.currentMode,Le.value=!1,ie.value=!1},Vl=()=>{de.value="adapting",Kt.value=!0},Hl=()=>{de.value=fe.value.currentMode,Pt.value=fe.value.hasBackchannel,he.value=fe.value.hasAudio},Ql=()=>{de.value=fe.value.currentMode,Le.value=!1},Kl=()=>{de.value=fe.value.currentMode,ie.value=!0,Kt.value=!1},Zl=()=>{de.value=fe.value.currentMode,ie.value=!0,Kt.value=!1},Gl=ee=>{var Ae,St,gs,ss;clearTimeout(Fe),h.value==="always-on"?(rt.value=!1,(Ae=fe.value)!=null&&Ae.finishLoading||(ee||yr(),(St=fe.value)==null||St.start())):h.value==="standby"?rt.value||(gt(),(gs=fe.value)!=null&&gs.finishLoading||(yr(),(ss=fe.value)==null||ss.start())):h.value==="activity"&&(ps.value||(rt.value=!0,Hr()))},Wl=ee=>{var Ae,St;h.value==="activity"&&(!!(ee!=null&&ee.length&&ee.some(ss=>Ce.value.includes(ss.label)))?(ps.value=!0,clearTimeout(Fe),(rt.value||!((Ae=fe.value)!=null&&Ae.finishLoading))&&(rt.value=!1,yr(),(St=fe.value)==null||St.start())):(clearTimeout(Fe),Fe=setTimeout(()=>{ps.value||(rt.value=!0,Hr())},Ph),ps.value=!1))},Op=()=>{var ee;rt.value&&(rt.value=!1,yr(),(ee=fe.value)==null||ee.start(),h.value==="standby"?gt():h.value==="activity"&&(clearTimeout(Fe),ps.value||(Fe=setTimeout(()=>{rt.value=!0,Hr()},Ph))))},Hr=()=>{var ee;(ee=fe.value)==null||ee.close(),ie.value=!1},Jl=()=>{var ee;if(nt.value){const Ae=document.createElement("canvas");Ae.width=nt.value.videoWidth,Ae.height=nt.value.videoHeight,(ee=Ae.getContext("2d"))==null||ee.drawImage(nt.value,0,0,Ae.width,Ae.height);const St=Ae.toDataURL("image/png"),gs=`${En.value.replace(/ /g,"_").toLowerCase()}_${new Date().toISOString()}.png`,ss=document.createElement("a");ss.setAttribute("download",gs),ss.href=St,document.body.appendChild(ss),ss.click(),ss.remove()}},Np=()=>{var ee,Ae;(ee=ft.value)==null||ee.clear(),(Ae=Yt.value)==null||Ae.clear()},Yl=(ee,Ae)=>{var St,gs;ie.value&&(ee==="motion"?(St=ft.value)==null||St.draw(Ae):ee==="object"&&((gs=Yt.value)==null||gs.draw(Ae)))},So=async()=>{if(nt.value)try{await nt.value.play()}catch(ee){if(nt.value&&!nt.value.muted)return nt.value.muted=!0,So();console.warn(En.value,ee)}},Fp=()=>{if(nt.value&&de.value==="mse"&&!Le.value&&ie.value&&nt.value.buffered.length>0){const ee=nt.value.buffered.end(nt.value.buffered.length-1);ee-nt.value.currentTime>1&&(nt.value.currentTime=ee)}},Qr=ee=>{const Ae=Ce.value.indexOf(ee);Ae>-1?Ce.value.splice(Ae,1):Ce.value.push(ee)},Xl=ee=>{ee=ee??!te.value,te.value=ee},eu=ee=>{st.value=ee!==void 0?ee:!st.value},Fa=async(ee,Ae=!1)=>{var St,gs;if((St=fe.value)!=null&&St.currentMode.includes("webrtc"))if(Ot.value=ee!==void 0?ee:!Ot.value,Ot.value)try{_t.value=await navigator.mediaDevices.getUserMedia({audio:!0});const ss=_t.value.getAudioTracks()[0];st.value=!Ae,await fe.value.toggleMicrophone(ss)}catch(ss){console.warn(En.value,ss)}else(gs=_t.value)==null||gs.getTracks().forEach(ss=>ss.stop()),_t.value=void 0,await fe.value.toggleMicrophone(null)},tu=ee=>{h.value=ee||(h.value==="always-on"?"standby":h.value==="standby"?"activity":"always-on")},su=async ee=>{var St;let Ae=on.value;Ae=ee||(Ae==="auto"?"low-resolution":Ae==="low-resolution"?"mid-resolution":Ae==="mid-resolution"?"high-resolution":"auto"),await((St=fe.value)==null?void 0:St.toggleRole(Ae)),v.value=Ae},nu=async ee=>{var St;let Ae=kn.value;Ae=ee||(Ae==="auto"?"webrtc":Ae==="webrtc"?"mse":"auto"),await((St=fe.value)==null?void 0:St.toggleMode(Ae)),f.value=Ae},ru=()=>{var ee;document.pictureInPictureElement?document.exitPictureInPicture():document.pictureInPictureEnabled&&((ee=nt.value)==null||ee.requestPictureInPicture())},iu=()=>{nt.value&&(ke.value?(Zt.value=!0,nt.value.pause()):So())},ou=()=>{o.value?le():Te.value=!Te.value},au=()=>{Ms.value=!Ms.value},cu=()=>{ds.value=!ds.value},lu=()=>{fs.value=!fs.value},uu=()=>{R.value=!R.value},du=()=>{},hu=()=>{},Lp=ee=>{Ye.value=ee};return Xc(()=>{typeof k.value=="string"&&n.toggleQueryActivator("getCameraQuery",!0)}),Sn(async()=>{try{await Pp(),setTimeout(()=>{ve.value=!1},1500)}catch(ee){console.error(ee)}}),Ea(()=>{var ee,Ae,St,gs,ss,br,wr,Kr,es;clearTimeout(Fe),(ee=fe.value)==null||ee.removeEventListener("error",zl),(Ae=fe.value)==null||Ae.removeEventListener("reconnect",yr),(St=fe.value)==null||St.removeEventListener("onModeChange",Ul),(gs=fe.value)==null||gs.removeEventListener("onSourceChange",Vl),(ss=fe.value)==null||ss.removeEventListener("onStreamProbe",Hl),(br=fe.value)==null||br.removeEventListener("onFinishLoading",Ql),(wr=fe.value)==null||wr.removeEventListener("onFirstFrame",Kl),(Kr=fe.value)==null||Kr.removeEventListener("onLoadedData",Zl),Hr(),(es=Xt.value)==null||es.close()}),e({togglePlay:iu,toggleSourceRole:su,togglePictureInPicture:ru,toggleActivityMode:tu,toggleAddingShortcuts:lu,toggleStreamingMode:nu,toggleFs:ou,toggleMute:eu,toggleMicrophone:Fa,toggleShortcuts:au,togglePtz:cu,toggleFastForward:hu,toggleRewind:du,toggleZones:Xl,toggleDetectionClass:Qr,toggleTimeline:uu,timelineScroll:Lp,captureScreenshot:Jl}),(ee,Ae)=>{const St=fx,gs=Lr,ss=hx,br=lx,wr=ox,Kr=nx,es=ys,jp=ex,qp=J8,Dp=Z8,Bp=H8,zp=z8,Up=q8,Vp=F8,Hp=I8,Qp=T8,Kp=A8,Zp=C8,Gp=w8,Wp=_8,Jp=f8,Yp=h8,Xp=l8,e0=o8,t0=n8,s0=e8,n0=J6,r0=Z6,i0=S6,mu=y6,o0=e6,a0=Nl,c0=J4,l0=Z4,u0=H4,d0=z4,h0=q4,m0=F4,p0=yp,f0=P4,g0=M4,v0=k4,_0=x4,y0=Uc,b0=wa,w0=Lh,x0=dp,Js=jr;return m(),A("div",null,[y(w0,{class:"cui-card",pt:c(Mp)},{content:$(()=>{var pu;return[g("div",{id:"video-container",ref_key:"playerContainerRef",ref:zt,class:"bg-black flex items-center justify-center relative",onClick:Op},[y(U0,{name:"fade",tag:"div",class:"w-full relative",style:ot({aspectRatio:c(jl)})},{default:$(()=>{var Co,fu;return[c(rt)?(m(),A("div",vx,[g("div",_x,[y(St,{class:"text-white w-[50px] h-[50px]"}),c(Me).width.value>=350?(m(),A("p",yx,me(ee.$t("components.player.stream_paused")),1)):ce("",!0)])])):ce("",!0),c(pt)&&!c(rt)?(m(),A("div",bx,[y(gs,{class:"w-[30px] h-[30px] m-0","stroke-width":"5"}),c(Le)?(m(),A("span",wx,me(ee.$t("components.player.reconnecting"))+"...",1)):ce("",!0)])):ce("",!0),!c(rt)&&(c(Ll)||c(N))?(m(),A("div",xx,[c(N)?(m(),A("div",{key:0,class:at(["w-[10px] h-[10px] rounded-full shadow-md",{"bg-red-500":c(ie),"bg-gray-500":!c(ie)}])},null,2)):ce("",!0),c(Ll)?(m(),A("span",Sx,me(c(En)),1)):ce("",!0)])):ce("",!0),c(Ep)?(m(),A("div",{key:"subcontrol",class:"absolute top-4 right-4 cui-rounded-corner overflow-hidden bg-black/60 flex flex-row items-center justify-center shadow-md z-6 dark-mode",style:ot({top:c(Tp),height:c(Ws)})},[c(q)&&!c(ds)?Tt((m(),j(es,{key:0,disabled:c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:Ae[0]||(Ae[0]=Ln=>su())},{icon:$(()=>[c(on)==="auto"?(m(),j(ss,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):c(on)==="low-resolution"?(m(),j(br,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):c(on)==="mid-resolution"?(m(),j(wr,{key:2,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(Kr,{key:3,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])),[[Js,{value:Ip()},void 0,{top:!0}]]):ce("",!0),c(Q)&&!c(ds)?Tt((m(),j(es,{key:1,disabled:c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:Ae[1]||(Ae[1]=Ln=>tu())},{icon:$(()=>[h.value==="always-on"?(m(),j(jp,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):h.value==="standby"?(m(),j(qp,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(Dp,{key:2,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])),[[Js,{value:h.value==="always-on"?ee.$t("components.player.activity_mode_always_on"):h.value==="standby"?ee.$t("components.player.activity_mode_standby"):ee.$t("components.player.activity_mode_activity")},void 0,{top:!0}]]):ce("",!0),c(oe)&&!c(ds)?Tt((m(),j(es,{key:2,disabled:c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:Ae[2]||(Ae[2]=Ln=>nu())},{icon:$(()=>[c(kn)==="auto"?(m(),j(Bp,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):c(kn)==="mse"?(m(),j(zp,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(Up,{key:2,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])),[[Js,{value:Rp()},void 0,{top:!0}]]):ce("",!0),c(ds)&&c(X)&&c(Me).width.value>=350?Tt((m(),j(es,{key:3,disabled:c(pt)||((Co=c(wt))==null?void 0:Co.isLoading),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:Ae[3]||(Ae[3]=Ln=>{var gu;return(gu=c(wt))==null?void 0:gu.goToHome()})},{icon:$(()=>[y(Vp,{width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])]),_:1},8,["disabled","style"])),[[Js,{value:ee.$t("components.player.ptz_go_to_home")},void 0,{top:!0}]]):ce("",!0),c(J)&&c(Me).width.value>=350&&c(X)?Tt((m(),j(es,{key:4,disabled:c(pt)||c(R),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:cu},{icon:$(()=>[y(Hp,{width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])]),_:1},8,["disabled","style"])),[[Js,{value:ee.$t("components.player.ptz")},void 0,{top:!0}]]):ce("",!0)],4)):ce("",!0),c(kp)&&!c(R)&&!c(Oi)?(m(),A("div",{key:"control",class:"absolute left-[50%] -translate-x-[50%] cui-rounded-corner overflow-hidden bg-black/60 flex flex-row items-center justify-center shadow-md z-6 dark-mode",style:ot({bottom:c($p),height:c(Ws)})},[c(W)?(m(),j(es,{key:0,disabled:"",fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",onClick:du},{icon:$(()=>[y(Qp,{width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])]),_:1})):ce("",!0),c(B)?(m(),j(es,{key:1,disabled:c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:iu},{icon:$(()=>[c(ke)?(m(),j(Zp,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(Kp,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])):ce("",!0),c(O)?(m(),j(es,{key:2,disabled:"",fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:hu},{icon:$(()=>[y(Gp,{width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])]),_:1},8,["style"])):ce("",!0),c(I)?(m(),j(es,{key:3,disabled:!c(ls)||c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:Ae[4]||(Ae[4]=Ln=>eu())},{icon:$(()=>[c(st)?(m(),j(Jp,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(Wp,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])):ce("",!0),c(S)?(m(),j(es,{key:4,disabled:!c(bs)||c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:Ae[5]||(Ae[5]=Ln=>Fa(void 0,!0))},{icon:$(()=>[c(Ot)?(m(),j(Yp,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(Xp,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])):ce("",!0),c(M)?(m(),j(es,{key:5,disabled:!c(l)||c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:ru},{icon:$(()=>[c(Ht)?(m(),j(t0,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(e0,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])):ce("",!0),c(U)?(m(),j(es,{key:6,disabled:!c(o)||c(pt),fluid:"",text:"",severity:"contrast",class:"!rounded-none !h-full",style:ot({width:`${c(an)}px`,height:`${c(Ws)}px`}),onClick:ou},{icon:$(()=>[c(Te)?(m(),j(n0,{key:1,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"])):(m(),j(s0,{key:0,width:`${c(ct)}px`,height:`${c(ct)}px`},null,8,["width","height"]))]),_:1},8,["disabled","style"])):ce("",!0)],4)):ce("",!0),Tt(g("div",Cx,null,512),[[Tr,c(R)&&!c(Oi)&&!c(rt)]]),c(Oi)&&!c(R)&&!c(rt)&&c(Xt)?(m(),A("div",kx,[y(r0,{ref_key:"ptzRef",ref:wt,"camera-device":c(Xt)},null,8,["camera-device"])])):ce("",!0),(c(Ms)||c(fs))&&!c(rt)?(m(),j(i0,{key:6,"camera-name":c(En),"adding-shortcuts":c(fs),class:"z-4 pointer-events-none"},null,8,["camera-name","adding-shortcuts"])):ce("",!0),c(_e)&&!c(rt)?(m(),j(mu,{key:7,ref_key:"motionDetectionCanvasRef",ref:ft,classes:c(Ce),class:"z-3 pointer-events-none"},null,8,["classes"])):ce("",!0),c(ye)&&!c(rt)?(m(),j(mu,{key:8,ref_key:"objectDetectionCanvasRef",ref:Yt,classes:c(Ce),class:"z-3 pointer-events-none"},null,8,["classes"])):ce("",!0),c(te)&&!c(rt)?(m(),j(o0,{key:9,"camera-zones":((fu=c(Be))==null?void 0:fu.detectionZones)??[],class:"z-2 pointer-events-none"},null,8,["camera-zones"])):ce("",!0),Tt(y(a0,{key:"snapshot",ref_key:"snapshotRef",ref:ze,"camera-name":c(En),"show-loading-screen":!1,class:at(["object-contain absolute cursor-[inherit] z-1",{"cursor-pointer":c(z)}]),"image-container-class":"w-full h-full",onClick:Bl},null,8,["camera-name","class"]),[[Tr,(!c(ie)||c(rt)||c(Kt))&&!c(Ht)]]),y(c(xf),{key:"zoomable",pan:c(os),"onUpdate:pan":Ae[6]||(Ae[6]=Ln=>us(os)?os.value=Ln:null),zoom:c(As),"onUpdate:zoom":Ae[7]||(Ae[7]=Ln=>us(As)?As.value=Ln:null),disabled:!c(Z)||c(R)||c(Oi)||c(rt),"enable-control-button":!1,"dbl-click-enabled":!1,"min-zoom":1,"max-zoom":Th,selector:c(Z)?`[data-player-id='${c(Oe)}']`:"disabled","zoom-origin":"pointer",class:"h-full w-full items-center justfiy-center",onPanned:Dl,onZoom:Dl},{default:$(()=>[g("video",{ref_key:"videoPlayerRef",ref:nt,"data-player-id":c(Oe),playsinline:"",autoplay:"",preload:"auto",muted:c(st),class:at(["w-full cursor-[inherit] object-fill",{"cursor-pointer":c(z),"object-contain":c(Te)}]),style:ot({aspectRatio:c(jl)}),onClick:Bl},null,14,Ex)]),_:1},8,["pan","zoom","disabled","selector"])]}),_:1},8,["style"])],512),c(ue)?(m(),A("div",{key:0,class:at(["relative w-full h-[60px] camera-toolbar-background border-t-[1px] border-color flex items-center justify-between py-2 px-4 gap-1 z-1",c(Se)]),style:ot([c(ht)])},[g("div",Ax,[c(Ii)?(m(),j(gs,{key:0,"stroke-width":"5",class:"w-[10px] h-[10px]"})):(m(),A("div",Mx)),g("span",$x,me(c(En)),1)]),Ae[10]||(Ae[10]=g("div",{class:"ml-auto"},null,-1)),c(Y)?Tt((m(),j(es,{key:0,fluid:"",text:"",severity:"contrast",class:"cui-icon-lg not-hover:text-surface-400"},{icon:$(()=>[y(c0,{width:"100%",height:"100%"})]),_:1})),[[Js,{value:ee.$t("components.player.share_camera")},void 0,{top:!0}]]):ce("",!0),c(He)?Tt((m(),j(es,{key:1,fluid:"",text:"",severity:"contrast",class:"cui-icon-lg not-hover:text-surface-400",onClick:Jl},{icon:$(()=>[y(l0,{width:"100%",height:"100%"})]),_:1})),[[Js,{value:ee.$t("components.player.capture_snapshot")},void 0,{top:!0}]]):ce("",!0),c(Qe)?Tt((m(),j(es,{key:2,fluid:"",text:"",severity:"contrast",class:at(["cui-icon-lg not-hover:text-surface-400",{active:c(te)}]),onClick:Ae[8]||(Ae[8]=Co=>Xl())},{icon:$(()=>[c(te)?(m(),j(d0,{key:1,width:"100%",height:"100%"})):(m(),j(u0,{key:0,width:"100%",height:"100%"}))]),_:1},8,["class"])),[[Js,{value:c(te)?ee.$t("components.player.hide_zones"):ee.$t("components.player.show_zones")},void 0,{top:!0}]]):ce("",!0),c(F)&&(c(_e)||c(ye))?Tt((m(),j(es,{key:3,fluid:"",text:"",severity:"contrast",class:at(["cui-icon-lg not-hover:text-surface-400",{active:c(Ce).length}]),onClick:(pu=c(ge))==null?void 0:pu.toggleMenu},{icon:$(()=>[y(h0,{width:"100%",height:"100%"})]),_:1},8,["class","onClick"])),[[Js,{value:ee.$t("components.player.detections")},void 0,{top:!0}]]):ce("",!0),c(Pe)?Tt((m(),j(es,{key:4,fluid:"",text:"",severity:"contrast",class:at(["cui-icon-lg not-hover:text-surface-400",{active:c(Ms)||c(fs)}]),onClick:au},{icon:$(()=>[!c(Ms)&&!c(fs)?(m(),j(m0,{key:0,width:"100%",height:"100%"})):(m(),j(p0,{key:1,width:"100%",height:"100%"}))]),_:1},8,["class"])),[[Js,{value:c(Ms)?ee.$t("components.player.hide_shortcuts"):ee.$t("components.player.show_shortcuts")},void 0,{top:!0}]]):ce("",!0),c(Pe)?Tt((m(),j(es,{key:5,fluid:"",text:"",severity:"contrast",class:at(["cui-icon-lg not-hover:text-surface-400",{active:c(fs)}]),onClick:lu},{icon:$(()=>[c(fs)?(m(),j(g0,{key:1,width:"100%",height:"100%"})):(m(),j(f0,{key:0,width:"100%",height:"100%"}))]),_:1},8,["class"])),[[Js,{value:c(fs)?ee.$t("components.player.save_shortcuts"):ee.$t("components.player.add_shortcuts")},void 0,{top:!0}]]):ce("",!0),c(Mt)?Tt((m(),j(es,{key:6,disabled:c(Oi),fluid:"",text:"",severity:"contrast",class:at(["cui-icon-lg not-hover:text-surface-400",{active:c(R)}]),onClick:uu},{icon:$(()=>[c(R)?(m(),j(_0,{key:1,width:"100%",height:"100%"})):(m(),j(v0,{key:0,width:"100%",height:"100%"}))]),_:1},8,["disabled","class"])),[[Js,{value:c(R)?ee.$t("components.player.hide_timeline"):ee.$t("components.player.show_timeline")},void 0,{top:!0}]]):ce("",!0),c(D)&&("useCuiPermission"in ee?ee.useCuiPermission:c(Si))(void 0,"admin")?Tt((m(),j(es,{key:7,fluid:"",text:"",severity:"contrast",class:at(["cui-icon-lg not-hover:text-surface-400",{active:c(r).isOpen.value}]),onClick:Ae[9]||(Ae[9]=Co=>c(r).open({cameraName:c(En)}))},{icon:$(()=>[c(r).isOpen.value?(m(),j(b0,{key:1,width:"100%",height:"100%"})):(m(),j(y0,{key:0,width:"100%",height:"100%"}))]),_:1},8,["class"])),[[Js,{value:ee.$t("components.player.settings")},void 0,{top:!0}]]):ce("",!0)],6)):ce("",!0)]}),_:1},8,["pt"]),y(x0,{ref_key:"menuRef",ref:ge,items:c(Ap),"sort-list":"","auto-hide":!1},null,8,["items"])])}}}),Sp=qs(Ix,[["__scopeId","data-v-d1d904d2"]]),Ox=ol({protocol:Gm,url:Kh().trim().min(1,"Camera Source is required").array().nonempty("Camera Source is required")}).strict(),Nx=ol({name:Kh().trim().min(1,"Camera Source Name is required"),urls:Ox.array(),role:Al,useForSnapshot:Su().default(!1),hotMode:Su().default(!1)}).strict(),Fx=ol({...Cy.innerType().shape,sources:Nx.array().refine(s=>s.some(e=>e.role==="high-resolution"||e.role==="mid-resolution"||e.role==="low-resolution"),{path:["sources[].role"],message:'One of the roles "high-resolution", "mid-resolution" or "low-resolution" is required'}).refine(s=>s.filter(t=>t.useForSnapshot).length<=1,{message:"Only one source can be used for snapshot",path:["sources"]}).refine(s=>s.filter(t=>t.role==="snapshot").every(t=>!t.useForSnapshot),{message:"Snapshot source can not be used with useForSnapshot",path:["sources"]}).refine(s=>s.filter(t=>t.role==="snapshot").every(t=>!t.hotMode),{message:"Snapshot source can not be used with hotMode"})}).strict(),p9=Wn(Fx),f9=Wn(xy),Lx=Wn(ky),jx=Wn(El),qx={class:"w-full h-full relative"},Dx={class:"flex flex-col justify-center items-center"},Bx={class:"relative w-full"},zx={class:"w-full flex flex-col items-center justify-center gap-6"},Ux={class:"relative w-full flex flex-col items-center justify-center"},Vx={class:"absolute top-0 left-0 right-0 bottom-0"},Hx={class:"playground-container flex w-full h-full"},Qx={class:"sandbox w-full h-full"},Kx={class:"handles"},Zx=["data-id","data-point","data-point-index","data-zone-index","onDblclick"],Gx={class:"clipboard"},Wx={width:"100%",height:"100%",class:"polygon-container"},Jx=["d","onClick","onDblclick","onMousedown","onTouchstart"],Yx={class:"flex flex-col gap-6 zone-buttons justify-center items-center"},Xx=["for"],eS=["for"],tS={class:"flex flex-row h-[50px] rounded-full overflow-hidden justify-self-center max-w-max border-[1px] border-color-inner"},sS={class:"flex flex-row h-[50px] rounded-full overflow-hidden justify-self-center max-w-max border-[1px] border-color-inner"},nS=At({__name:"ZoneEditor",props:{cameraName:{},zones:{}},setup(s,{expose:e}){const t=new Jn,n=Cn(),{t:r}=js(),i=s,o=mi("dialogRefProps"),{cameraName:a,zones:l}=Jt(i),u=Vt("draggablesRef"),d=Vt("outsideRef"),h=Vt("playerRef"),v=Ls([]),f=ae([]),b=ae(!1),k=ae([]),z=ae(void 0),L=ae(-1),se=ae(-1),K=ae(["animal","vehicle","person","other","motion"]);let N=!1;const E={x:0,y:0},O=nl(h);sl(d,V=>{const X=V.target,_e=X.closest(".polygon"),ye=X.closest(".edit-button"),fe=X.closest(".remove-button"),_t=X.closest(".handle"),Pt=X.closest(".zone-buttons"),he=X.closest(".p-multiselect-list"),ie=X.closest(".p-colorpicker-panel");!_e&&!ye&&!fe&&!_t&&!b.value&&!Pt&&!he&&!ie&&(L.value=-1)});const{mutateAsync:U,isPending:S}=t.patchZonesQuery(),M=ne(()=>{var V;return!!((V=o.loading)!=null&&V.value||S.value)}),B=ne(()=>{var X;const V=[];return b.value&&V.push("customizing"),(X=f.value)!=null&&X.length||V.push("start"),V.join(" ")});Ge(se,()=>{se.value=-1}),Ge(L,(V,X)=>{var _e,ye;if(V===-1&&((_e=f.value)!=null&&_e.length)&&f.value[X]){L.value=X;return}V===-1&&((ye=f.value)!=null&&ye.length)&&(se.value=0)}),Ge(l,()=>{f.value=xi(l.value),W()},{deep:!0,immediate:!0});function W(){if(f.value){if(f.value.length===0){k.value=[];return}k.value=f.value.flatMap((V,X)=>V.points.map((_e,ye)=>({_id:`${V.name}-${ye}`,zoneIndex:X,pointIndex:ye,point:[_e[0],_e[1]]})))}}Ge([O.width,O.height],()=>{Yt()});const I=V=>{if("touches"in V){const X=V.touches[0];return{x:X.clientX,y:X.clientY}}return{x:V.clientX,y:V.clientY}},w=(V,X)=>{if(V.stopPropagation(),!h.value)return;Pe(b.value),N=!0,L.value=X;const _e=h.value.getBoundingClientRect(),{x:ye,y:fe}=I(V);E.x=(ye-_e.left)/_e.width*100,E.y=(fe-_e.top)/_e.height*100},Q=V=>{if(!N||!h.value||L.value===-1||!f.value.length)return;const X=h.value.getBoundingClientRect(),{x:_e,y:ye}=I(V),fe=(_e-X.left)/X.width*100,_t=(ye-X.top)/X.height*100,Pt=fe-E.x,he=_t-E.y,ie=f.value[L.value].points;let de=!1;for(let Le=0;Le<ie.length;Le++){const rt=ie[Le][0]+Pt,Kt=ie[Le][1]+he;if(rt<0||rt>100||Kt<0||Kt>100){de=!0;break}}if(!de)for(let Le=0;Le<ie.length;Le++){ie[Le][0]+=Pt,ie[Le][1]+=he,ie[Le][0]=Math.max(0,Math.min(100,ie[Le][0])),ie[Le][1]=Math.max(0,Math.min(100,ie[Le][1]));const rt=ie[Le][0]/100*X.width,Kt=ie[Le][1]/100*X.height,ps=v.value.find(Zt=>Zt.id===`${f.value[L.value].name}-${Le}`);ps==null||ps.setPosition(rt,Kt)}E.x=fe,E.y=_t},J=()=>{setTimeout(()=>{N=!1},100)},q=()=>{!f.value.length||L.value===-1||(f.value[L.value].isPrivacyMask=!f.value[L.value].isPrivacyMask)},oe=()=>{f.value[L.value]&&(f.value[L.value].filter=f.value[L.value].filter==="include"?"exclude":"include")},ue=()=>{f.value[L.value]&&(f.value[L.value].type=f.value[L.value].type==="intersect"?"contain":"intersect")},Se=V=>{if(!b.value||N)return;const X=z.value!==void 0?z.value:f.value.length,_e=Math.min(Math.max(Math.round((V.offsetX-10)/O.width.value*100),0),100),ye=Math.min(Math.max(Math.round((V.offsetY-10)/O.height.value*100),0),100);if(z.value===void 0){const fe=`zone-${Date.now()}`;f.value.push({name:fe,points:[],filter:"include",type:"contain",classes:["animal","motion","person","vehicle"],isPrivacyMask:!1,color:ze()}),z.value=f.value.length-1}f.value[X].points.push([_e,ye]),W(),Zs(()=>{const fe=f.value[X].points.length-1;F({_id:`${f.value[X].name}-${fe}`,zoneIndex:X,pointIndex:fe,point:[_e,ye]})})},F=V=>{var _e;if(V.zoneIndex===void 0||V.pointIndex===void 0)return;const X=(_e=u.value)==null?void 0:_e.filter(ye=>ye.dataset.pointIndex===V.pointIndex.toString()&&ye.dataset.zoneIndex===V.zoneIndex.toString());!X||X.length===0||nt(X[0],V.point)},D=V=>{if(!f.value.length)return;const X=Math.round(V.point[0]/O.width.value*100),_e=Math.round(V.point[1]/O.height.value*100);f.value[V.zoneIndex].points[V.pointIndex]=[X,_e]},Y=()=>{b.value=!0,z.value=void 0},Pe=V=>{var _e;if(z.value===void 0){b.value=!1;return}b.value=V||!1;const X=z.value;!f.value[X]||!f.value[X].points||(f.value[X].points.length<3?(f.value.splice(X,1),W()):((_e=u.value)==null||_e.forEach(ye=>Be(ye)),L.value=X),z.value=void 0)},He=()=>{b.value=!0,z.value=L.value},ht=()=>{L.value===-1||!f.value.length||(f.value.splice(L.value,1),L.value=Math.max(-1,L.value-1),W(),Zs(()=>{Yt()}))},Mt=()=>{var V;if((V=f.value)!=null&&V.length){if(b.value&&z.value!==void 0){const X=f.value[z.value];X.points.length&&(X.points.pop(),X.points.length===0&&(f.value.splice(z.value,1),z.value=void 0),W());return}f.value.length>0&&(f.value.pop(),W(),Zs(()=>{Yt()}))}},Qe=()=>{N=!1,b.value=!1,z.value=void 0,f.value&&(f.value.length=0,k.value=[],Zs(()=>{wt()}))},ze=()=>{const V=Math.floor(Math.random()*256),X=Math.floor(Math.random()*256),_e=Math.floor(Math.random()*256);return"#"+[V,X,_e].map(ye=>ye.toString(16).padStart(2,"0")).join("")},ge=V=>{if(!V||!V.length)return"";const X=V.map(ye=>{const fe=Math.round(ye[0]/100*O.width.value),_t=Math.round(ye[1]/100*O.height.value);return`${fe+10},${_t+10}`});if(X.length===0)return"";let _e=`M ${X[0]}`;for(let ye=1;ye<X.length;ye++)_e+=` L ${X[ye]}`;return _e+=" Z",_e},ft=V=>{b.value||(L.value=V)},Yt=()=>{var V;wt(),(V=u.value)==null||V.forEach(X=>{if(!X.dataset.zoneIndex||!X.dataset.pointIndex)return;const _e=parseInt(X.dataset.zoneIndex),ye=parseInt(X.dataset.pointIndex);if(!f.value[_e]||!f.value[_e].points[ye])return;const fe=f.value[_e].points[ye];fe&&(nt(X,fe),Be(X))})},wt=()=>{v.value.forEach(V=>V.destroy()),v.value=[]},zt=V=>{!f.value.length||!f.value[V.zoneIndex]||f.value[V.zoneIndex].points.length<4||(f.value[V.zoneIndex].points.splice(V.pointIndex,1),W(),Zs(()=>{Yt()}))},nt=(V,X)=>{Object.assign(V.style,Xt(X))},Xt=V=>({left:Math.round(V[0]/100*O.width.value)+"px",top:Math.round(V[1]/100*O.height.value)+"px"}),Be=V=>{V.classList.add("draggable");const X=new Zh(V,{containment:!0,grid:[0,0]}).on("pointerDown",()=>{var _e;(_e=document.querySelectorAll(`[data-point="${V.dataset.zoneIndex}-${V.dataset.pointIndex}"]`)[0])==null||_e.classList.add("changing")}).on("dragMove",()=>{if(!V.dataset.zoneIndex||!V.dataset.pointIndex||!V.dataset.id)return;const _e=X.position.x,ye=X.position.y;D({_id:V.dataset.id,point:[_e,ye],pointIndex:parseInt(V.dataset.pointIndex),zoneIndex:parseInt(V.dataset.zoneIndex)})}).on("pointerUp",()=>{document.querySelectorAll(".point").forEach(_e=>_e.classList.remove("changing"))});X.id=V.dataset.id,v.value.push(X)},Ue=async()=>{if(f.value.length)try{const V=await jx.parse(f.value);if(!V.value)return n.add({severity:"error",summary:r("components.toast.title_error"),detail:r("components.toast.validation_failed"),life:3e3}),console.log("Validation failed",V.errors),null;await U({cameraname:a.value,zoneData:f.value})}catch(V){return console.error("Error saving zones:",V),n.add({severity:"error",summary:r("components.toast.title_error"),detail:r("components.toast.save_failed"),life:3e3}),null}};return Sn(async()=>{var V;setTimeout(()=>{Yt()}),(V=f.value)!=null&&V.length&&(L.value=0)}),e({isLoading:M,onConfirm:Ue}),(V,X)=>{var ve,ke,st,Ot,Ht,Ye,Ce,Oe,Fe;const _e=Sp,ye=Fh,fe=fo,_t=ki,Pt=T0,he=ka,ie=y4,de=ys,Le=mp,rt=g4,Kt=m4,ps=u4,Zt=a4,os=r4,As=t4,fs=Y3,Ms=G3,ds=Q3,R=U3,te=jr;return m(),A("div",qx,[g("div",Dx,[g("div",Bx,[g("div",{ref_key:"outsideRef",ref:d},null,512),g("div",zx,[g("div",Ux,[g("div",Vx,[g("div",Hx,[g("section",{class:at(["playground w-full h-full",c(B)]),onClick:Se},[g("div",Qx,[g("div",Kx,[(m(!0),A(yt,null,qt(c(k),be=>(m(),A("div",{key:be._id,ref_for:!0,ref_key:"draggablesRef",ref:u,class:"handle","data-id":be._id,"data-point":`${be.zoneIndex}-${be.pointIndex}`,"data-point-index":be.pointIndex,"data-zone-index":be.zoneIndex,onDblclick:lr(it=>zt(be),["prevent"])},X[3]||(X[3]=[g("div",{class:"delete-point"},null,-1)]),40,Zx))),128)),g("div",Gx,[(m(),A("svg",Wx,[(m(!0),A(yt,null,qt(c(f),(be,it)=>(m(),A("path",{key:be.name,d:ge(be.points),class:at(["cursor-pointer",{dash:be.type==="intersect"&&!be.isPrivacyMask,selected:c(L)===it}]),style:ot({fill:be.isPrivacyMask?"rgba(16, 16, 16, 0.9)":be.filter==="exclude"?"transparent":`${be.color}4D`,stroke:be.isPrivacyMask?"#333333":be.color,"stroke-width":"2"}),onClick:_=>ft(it),onDblclick:()=>be.isPrivacyMask=!be.isPrivacyMask,onMousedown:_=>w(_,it),onMousemove:Q,onMouseup:J,onTouchstart:_=>w(_,it),onTouchmove:Q,onTouchend:J},null,46,Jx))),128))]))])]),X[4]||(X[4]=g("div",{class:"shadowboard on"},null,-1))])],2)])]),g("div",{ref_key:"playerRef",ref:h,class:"w-full h-full flex flex-col items-center justify-center",style:{width:"calc(100% - 20px)","margin-top":"10px","margin-bottom":"10px"}},[y(_e,{"camera-info":c(a),"source-role":"low-resolution","streaming-mode":"webrtc",toolbar:!1,control:!1,subcontrol:!1,"flat-card":"",class:"w-full h-full border-[1px] border-color-inner"},null,8,["camera-info"])],512)]),g("div",Yx,[y(c(Lt),{"model-value":(ve=c(f)[c(L)])==null?void 0:ve.classes,name:`zone[${c(L)}].classes`,as:"div",class:"flex flex-col field-gap w-full"},{default:$(({field:be,errors:it})=>[g("label",{for:`zone[${c(L)}].classes`,class:"cui-label"},me(V.$t("components.form.label.classes")),9,Xx),y(fe,null,{default:$(()=>{var _,x;return[y(ye,et(be,{"model-value":(_=c(f)[c(L)])==null?void 0:_.classes,options:c(K),disabled:(x=c(f)[c(L)])==null?void 0:x.isPrivacyMask,invalid:it.length>0,loading:c(M),"max-selected-labels":2,"show-toggle-all":!1,"show-clear":"",type:"text",onValueChange:X[0]||(X[0]=C=>c(f)[c(L)].classes=C)}),null,16,["model-value","options","disabled","invalid","loading"])]}),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`zone[${c(L)}].classes`,class:"cui-input-error"},null,8,["name"])]),_:1})]),_:1},8,["model-value","name"]),y(c(Lt),{"model-value":(ke=c(f)[c(L)])==null?void 0:ke.color,name:`zone[${c(L)}].color`,as:"div",class:"flex flex-col field-gap w-full"},{default:$(({field:be,errors:it})=>[g("label",{for:`zone[${c(L)}].color`,class:"cui-label"},me(V.$t("components.form.label.color")),9,eS),y(fe,null,{default:$(()=>{var _;return[y(_t,et(be,{disabled:(_=c(f)[c(L)])==null?void 0:_.isPrivacyMask,invalid:it.length>0,loading:c(M),readonly:"",type:"text"}),null,16,["disabled","invalid","loading"]),y(he,null,{default:$(()=>{var x,C;return[(m(),j(Pt,{key:c(L),"model-value":(x=c(f)[c(L)])==null?void 0:x.color,format:"hex",disabled:(C=c(f)[c(L)])==null?void 0:C.isPrivacyMask,onValueChange:X[1]||(X[1]=T=>T?c(f)[c(L)].color=`#${T}`:null)},null,8,["model-value","disabled"]))]}),_:1})]}),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`zone[${c(L)}].color`,class:"cui-input-error"},null,8,["name"])]),_:1})]),_:1},8,["model-value","name"]),g("div",tS,[c(b)?Tt((m(),j(de,{key:1,disabled:c(z)!==void 0&&((Ot=(st=c(f)[c(z)])==null?void 0:st.points)==null?void 0:Ot.length)<3,loading:c(M),severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:X[2]||(X[2]=be=>Pe(!1))},{icon:$(()=>[y(Le,{width:"20px",height:"20px"})]),_:1},8,["disabled","loading"])),[[te,{value:V.$t("components.form.tooltip.finish")},void 0,{top:!0}]]):Tt((m(),j(de,{key:0,loading:c(M),severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:Y},{icon:$(()=>[y(ie,{width:"20px",height:"20px"})]),_:1},8,["loading"])),[[te,{value:V.$t("components.form.tooltip.new")},void 0,{top:!0}]]),Tt((m(),j(de,{loading:c(M),disabled:!c(f).length||c(L)<0||c(b),severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:He},{icon:$(()=>[y(rt,{width:"20px",height:"20px"})]),_:1},8,["loading","disabled"])),[[te,{value:V.$t("components.form.tooltip.edit")},void 0,{top:!0}]]),Tt((m(),j(de,{loading:c(M),disabled:!c(f).length||c(L)<0,severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:ht},{icon:$(()=>[y(Kt,{width:"20px",height:"20px"})]),_:1},8,["loading","disabled"])),[[te,{value:V.$t("components.form.tooltip.delete")},void 0,{top:!0}]]),Tt((m(),j(de,{loading:c(M),disabled:!c(f).length,severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:Mt},{icon:$(()=>[y(ps,{width:"20px",height:"20px"})]),_:1},8,["loading","disabled"])),[[te,{value:V.$t("components.form.tooltip.undo")},void 0,{top:!0}]]),Tt((m(),j(de,{loading:c(M),disabled:!c(f).length,severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:Qe},{icon:$(()=>[y(Zt,{width:"20px",height:"20px"})]),_:1},8,["loading","disabled"])),[[te,{value:V.$t("components.form.tooltip.clear")},void 0,{top:!0}]])]),g("div",sS,[Tt((m(),j(de,{loading:c(M),disabled:!(c(f).length&&c(L)>=0&&c(f)[c(L)]),severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:q},{icon:$(()=>{var be;return[(be=c(f)[c(L)])!=null&&be.isPrivacyMask?(m(),j(os,{key:0,width:"20px",height:"20px"})):(m(),j(As,{key:1,width:"20px",height:"20px"}))]}),_:1},8,["loading","disabled"])),[[te,{value:(Ht=c(f)[c(L)])!=null&&Ht.isPrivacyMask?V.$t("components.form.tooltip.privacy_mask"):V.$t("components.form.tooltip.public_mask")},void 0,{top:!0}]]),Tt((m(),j(de,{loading:c(M),disabled:(Ye=c(f)[c(L)])==null?void 0:Ye.isPrivacyMask,severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:oe},{icon:$(()=>{var be;return[((be=c(f)[c(L)])==null?void 0:be.filter)==="include"?(m(),j(fs,{key:0,width:"20px",height:"20px"})):(m(),j(Ms,{key:1,width:"20px",height:"20px"}))]}),_:1},8,["loading","disabled"])),[[te,{value:((Ce=c(f)[c(L)])==null?void 0:Ce.filter)==="include"?V.$t("components.form.tooltip.include"):V.$t("components.form.tooltip.exclude")},void 0,{top:!0}]]),Tt((m(),j(de,{loading:c(M),disabled:(Oe=c(f)[c(L)])==null?void 0:Oe.isPrivacyMask,severity:"secondary",class:"!rounded-none !h-full w-[60px]",onClick:ue},{icon:$(()=>{var be;return[((be=c(f)[c(L)])==null?void 0:be.type)==="intersect"?(m(),j(ds,{key:0,width:"20px",height:"20px"})):(m(),j(R,{key:1,width:"20px",height:"20px"}))]}),_:1},8,["loading","disabled"])),[[te,{value:((Fe=c(f)[c(L)])==null?void 0:Fe.type)==="intersect"?V.$t("components.form.tooltip.intersect"):V.$t("components.form.tooltip.contain")},void 0,{top:!0}]])])])])])])])}}}),rS=qs(nS,[["__scopeId","data-v-51a8517c"]]),iS={class:"text-color font-normal"},oS={class:"flex flex-col gap-6"},aS={for:"name",class:"cui-label"},cS={for:"type",class:"cui-label"},lS={class:"flex items-center gap-4"},uS={class:"flex flex-col field-switch-gap"},dS={for:"disabled",class:"cui-label-switch"},hS={class:"text-color font-normal"},mS={class:"flex flex-col gap-6"},pS={for:"info.manufacturer",class:"cui-label"},fS={for:"info.model",class:"cui-label"},gS={for:"info.hardware",class:"cui-label"},vS={for:"info.serialNumber",class:"cui-label"},_S={for:"info.firmwareVersion",class:"cui-label"},yS={for:"info.supportUrl",class:"cui-label"},bS={class:"text-color font-normal"},wS={class:"flex flex-col gap-6"},xS={for:"interface.streamingMode",class:"cui-label"},SS={for:"interface.streamingSource",class:"cui-label"},CS={for:"interface.aspectRatio",class:"cui-label"},kS={class:"text-color font-normal"},ES={class:"flex flex-col gap-6"},AS={for:"detectionSettings.motion.timeout",class:"cui-label"},MS={for:"detectionSettings.object.confidence",class:"cui-label"},$S={class:"text-color font-normal"},TS={class:"flex flex-col gap-6 w-full items-center justify-center"},PS={class:"text-color font-normal"},RS={class:"flex flex-col gap-6"},IS={for:"snapshotTTL",class:"cui-label"},OS={class:"text-color font-normal"},NS={class:"flex flex-col gap-6"},FS={for:"frameWorkerSettings.decoder",class:"cui-label"},LS={for:"frameWorkerSettings.resolution",class:"cui-label"},jS={for:"frameWorkerSettings.fps",class:"cui-label"},qS=At({__name:"Settings",props:Kn({camera:{},cameraDevice:{},loading:{type:Boolean},latestSnapshotSrc:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:Kn(["close"],["update:modelValue"]),setup(s,{emit:e}){const t=new Jn,n=$i(),r=qr(),i=Rl(),{t:o}=js(),a=Rr(s,"modelValue"),l=e,u=s,{camera:d,loading:h}=Jt(u),v=ae(["camera","doorbell"]),f=ae(["auto","mse","webrtc","webrtc/tcp"]),b=ae(["auto","high-resolution","mid-resolution","low-resolution"]),k=ae(["16:9","8:3","4:3","auto"]),z=ae(["pillow","wasm","rust","gpu"]),L=ae(["640x480","640x360","320x240","320x180"]),{mutateAsync:se,isPending:K}=t.removeCameraQuery(),N=ne(()=>h.value||K.value),E=()=>{i.openTextDialog({data:{title:o("components.dialog.title.confirm"),confirmText:o("components.form.button.remove"),contentText:o("components.dialog.message.confirm_remove"),confirmButtonProps:{severity:"danger"}},onConfirm:async()=>{try{await se({cameraname:d.value.name}),n.path.includes(d.value.name)&&r.push({path:"/cameras"}),l("close")}catch{}}})},O=(U=[])=>{i.openComponentDialog(rS,{data:{title:o("components.zone_editor.edit_zones"),loading:N,contentProps:{cameraName:d.value.name,zones:U}}})};return(U,S)=>{const M=Wc,B=ki,W=fo,I=Kc,w=Qc,Q=po,J=ys,q=Jc,oe=Gc,ue=Nh,Se=Zc;return m(),j(Se,{multiple:"",class:"p-4"},{default:$(()=>[y(oe,{value:"general"},{default:$(()=>[y(M,{class:"px-0 pt-0"},{default:$(()=>[g("span",iS,me(U.$t("components.camera_options.general")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",oS,[y(c(Lt),{modelValue:a.value.name,"onUpdate:modelValue":S[0]||(S[0]=F=>a.value.name=F),modelModifiers:{trim:!0},name:"name",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",aS,me(U.$t("components.form.label.name")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"name",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{"model-value":a.value.type,name:"type",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",cS,me(U.$t("components.form.label.type")),1),y(W,null,{default:$(()=>[y(I,et(F,{"model-value":a.value.type,options:c(v),invalid:D.length>0,loading:c(N),type:"text",onValueChange:S[1]||(S[1]=Y=>a.value.type=Y)}),null,16,["model-value","options","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"type",class:"cui-input-error"})]),_:1})]),_:1},8,["model-value"]),y(c(Lt),{"model-value":a.value.disabled,value:!0,"unchecked-value":!1,type:"checkbox",name:"disabled",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("div",lS,[g("div",uS,[g("label",dS,me(U.$t("components.form.label.disabled")),1),y(w,{severity:"secondary",variant:"simple",size:"small",class:"cui-input-switch-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.disable_camera")),1)]),_:1}),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"disabled",class:"cui-input-switch-error"})]),_:1})]),y(Q,et({"model-value":a.value.disabled},F,{invalid:D.length>0,loading:c(N),class:"ml-auto shrink-0",onValueChange:S[2]||(S[2]=Y=>a.value.disabled=Y)}),null,16,["model-value","invalid","loading"])])]),_:1},8,["model-value"]),y(J,{fluid:"",severity:"danger",loading:c(N),class:"cui-button-medium",label:U.$t("components.form.button.remove"),onClick:S[3]||(S[3]=F=>E())},null,8,["loading","label"])])]),_:1})]),_:1}),y(oe,{value:"branding"},{default:$(()=>[y(M,{class:"px-0"},{default:$(()=>[g("span",hS,me(U.$t("components.camera_options.branding")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",mS,[y(c(Lt),{modelValue:a.value.info.manufacturer,"onUpdate:modelValue":S[4]||(S[4]=F=>a.value.info.manufacturer=F),modelModifiers:{trim:!0},name:"info.manufacturer",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",pS,me(U.$t("components.form.label.manufacturer")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"info.manufacturer",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{modelValue:a.value.info.model,"onUpdate:modelValue":S[5]||(S[5]=F=>a.value.info.model=F),modelModifiers:{trim:!0},name:"info.model",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",fS,me(U.$t("components.form.label.model")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"info.model",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{modelValue:a.value.info.hardware,"onUpdate:modelValue":S[6]||(S[6]=F=>a.value.info.hardware=F),modelModifiers:{trim:!0},name:"info.hardware",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",gS,me(U.$t("components.form.label.hardware_version")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"info.hardware",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{modelValue:a.value.info.serialNumber,"onUpdate:modelValue":S[7]||(S[7]=F=>a.value.info.serialNumber=F),modelModifiers:{trim:!0},name:"info.serialNumber",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",vS,me(U.$t("components.form.label.serial_number")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"info.serialNumber",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{modelValue:a.value.info.firmwareVersion,"onUpdate:modelValue":S[8]||(S[8]=F=>a.value.info.firmwareVersion=F),modelModifiers:{trim:!0},name:"info.firmwareVersion",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",_S,me(U.$t("components.form.label.firmware_version")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"info.firmwareVersion",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"]),y(c(Lt),{modelValue:a.value.info.supportUrl,"onUpdate:modelValue":S[9]||(S[9]=F=>a.value.info.supportUrl=F),modelModifiers:{trim:!0},name:"info.supportUrl",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",yS,me(U.$t("components.form.label.support_url")),1),y(W,null,{default:$(()=>[y(B,et(F,{invalid:D.length>0,loading:c(N),type:"text"}),null,16,["invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"info.supportUrl",class:"cui-input-error"})]),_:1})]),_:1},8,["modelValue"])])]),_:1})]),_:1}),y(oe,{value:"interface"},{default:$(()=>[y(M,{class:"px-0"},{default:$(()=>[g("span",bS,me(U.$t("components.camera_options.interface")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",wS,[y(c(Lt),{"model-value":a.value.interface.streamingMode,name:"interface.streamingMode",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",xS,me(U.$t("components.form.label.streaming_mode")),1),y(W,null,{default:$(()=>[y(I,et(F,{"model-value":a.value.interface.streamingMode,options:c(f),invalid:D.length>0,loading:c(N),type:"text",onValueChange:S[10]||(S[10]=Y=>a.value.interface.streamingMode=Y)}),null,16,["model-value","options","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"interface.streamingMode",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.streaming_mode")),1)]),_:1}))]),_:1},8,["model-value"]),y(c(Lt),{"model-value":a.value.interface.streamingSource,name:"interface.streamingSource",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",SS,me(U.$t("components.form.label.streaming_source")),1),y(W,null,{default:$(()=>[y(I,et(F,{"model-value":a.value.interface.streamingSource,options:c(b),invalid:D.length>0,loading:c(N),type:"text",onValueChange:S[11]||(S[11]=Y=>a.value.interface.streamingSource=Y)}),null,16,["model-value","options","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"interface.streamingSource",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.streaming_source")),1)]),_:1}))]),_:1},8,["model-value"]),y(c(Lt),{"model-value":a.value.interface.aspectRatio,name:"interface.aspectRatio",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",CS,me(U.$t("components.form.label.aspect_ratio")),1),y(W,null,{default:$(()=>[y(I,et(F,{"model-value":a.value.interface.aspectRatio,options:c(k),invalid:D.length>0,loading:c(N),type:"text",onValueChange:S[12]||(S[12]=Y=>a.value.interface.aspectRatio=Y)}),null,16,["model-value","options","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"interface.aspectRatio",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.aspect_ratio")),1)]),_:1}))]),_:1},8,["model-value"])])]),_:1})]),_:1}),y(oe,{value:"detection"},{default:$(()=>[y(M,{class:"px-0"},{default:$(()=>[g("span",kS,me(U.$t("components.camera_options.detection")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",ES,[y(c(Lt),{"model-value":a.value.detectionSettings.motion.timeout,name:"detectionSettings.motion.timeout",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",AS,me(U.$t("components.form.label.motion_duration")),1),y(W,null,{default:$(()=>[y(ue,et({"model-value":a.value.detectionSettings.motion.timeout},F,{invalid:D.length>0,loading:c(N),"show-buttons":"","use-grouping":!1,onValueChange:S[13]||(S[13]=Y=>a.value.detectionSettings.motion.timeout=Y),onInput:S[14]||(S[14]=Y=>a.value.detectionSettings.motion.timeout=Y.value)}),null,16,["model-value","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"detectionSettings.motion.timeout",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.motion_duration")),1)]),_:1}))]),_:1},8,["model-value"]),y(c(Lt),{"model-value":a.value.detectionSettings.object.confidence,name:"detectionSettings.object.confidence",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",MS,me(U.$t("components.form.label.confidence")),1),y(W,null,{default:$(()=>[y(ue,et({"model-value":a.value.detectionSettings.object.confidence},F,{invalid:D.length>0,loading:c(N),"show-buttons":"",step:.01,max:1,mode:"decimal","use-grouping":!1,onValueChange:S[15]||(S[15]=Y=>a.value.detectionSettings.object.confidence=Y),onInput:S[16]||(S[16]=Y=>a.value.detectionSettings.object.confidence=Y.value)}),null,16,["model-value","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"detectionSettings.object.confidence",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.confidence")),1)]),_:1}))]),_:1},8,["model-value"])])]),_:1})]),_:1}),y(oe,{value:"zones"},{default:$(()=>[y(M,{class:"px-0"},{default:$(()=>[g("span",$S,me(U.$t("components.camera_options.zones")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",TS,[y(J,{fluid:"",class:"cui-button-medium",loading:c(N),label:U.$t("components.form.button.edit_zones"),onClick:S[17]||(S[17]=F=>O(c(d).detectionZones))},null,8,["loading","label"])])]),_:1})]),_:1}),y(oe,{value:"snapshot"},{default:$(()=>[y(M,{class:"px-0"},{default:$(()=>[g("span",PS,me(U.$t("components.camera_options.snapshot")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",RS,[y(c(Lt),{"model-value":a.value.snapshotTTL,name:"snapshotTTL",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",IS,me(U.$t("components.form.label.cache_time")),1),y(W,null,{default:$(()=>[y(ue,et({"model-value":a.value.snapshotTTL},F,{invalid:D.length>0,loading:c(N),"show-buttons":"","use-grouping":!1,onValueChange:S[18]||(S[18]=Y=>a.value.snapshotTTL=Y),onInput:S[19]||(S[19]=Y=>a.value.snapshotTTL=Y.value)}),null,16,["model-value","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"snapshotTTL",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.cache_time")),1)]),_:1}))]),_:1},8,["model-value"])])]),_:1})]),_:1}),y(oe,{value:"frameworker"},{default:$(()=>[y(M,{class:"px-0"},{default:$(()=>[g("span",OS,me(U.$t("components.camera_options.frame_worker")),1)]),_:1}),y(q,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",NS,[y(c(Lt),{"model-value":a.value.frameWorkerSettings.decoder,name:"frameWorkerSettings.decoder",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",FS,me(U.$t("components.form.label.decoder")),1),y(W,null,{default:$(()=>[y(I,et(F,{"model-value":a.value.frameWorkerSettings.decoder,options:c(z),invalid:D.length>0,loading:c(N),type:"text",onValueChange:S[20]||(S[20]=Y=>a.value.frameWorkerSettings.decoder=Y)}),null,16,["model-value","options","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"frameWorkerSettings.decoder",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.frameworker_decoder")),1)]),_:1}))]),_:1},8,["model-value"]),y(c(Lt),{"model-value":a.value.frameWorkerSettings.resolution,name:"frameWorkerSettings.resolution",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",LS,me(U.$t("components.form.label.resolution")),1),y(W,null,{default:$(()=>[y(I,et(F,{"model-value":a.value.frameWorkerSettings.resolution,options:c(L),invalid:D.length>0,loading:c(N),type:"text",onValueChange:S[21]||(S[21]=Y=>a.value.frameWorkerSettings.resolution=Y)}),null,16,["model-value","options","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"frameWorkerSettings.resolution",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.frameworker_resolution")),1)]),_:1}))]),_:1},8,["model-value"]),y(c(Lt),{"model-value":a.value.frameWorkerSettings.fps,name:"frameWorkerSettings.fps",as:"div",class:"flex flex-col field-gap"},{default:$(({field:F,errors:D})=>[g("label",jS,me(U.$t("components.form.label.fps")),1),y(W,null,{default:$(()=>[y(ue,et({"model-value":a.value.frameWorkerSettings.fps},F,{invalid:D.length>0,loading:c(N),min:0,"show-buttons":"","use-grouping":!1,onValueChange:S[22]||(S[22]=Y=>a.value.frameWorkerSettings.fps=Y),onInput:S[23]||(S[23]=Y=>a.value.frameWorkerSettings.fps=Y.value)}),null,16,["model-value","invalid","loading"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:"frameWorkerSettings.fps",class:"cui-input-error"})]),_:1}),D.length?ce("",!0):(m(),j(w,{key:0,severity:"secondary",variant:"simple",size:"small",class:"cui-input-hint"},{default:$(()=>[Qt(me(U.$t("components.form.hint.frameworker_fps")),1)]),_:1}))]),_:1},8,["model-value"])])]),_:1})]),_:1})]),_:1})}}}),DS={class:"relative"},BS=At({__name:"CuiActionButton",props:{label:{},icon:{},buttonProps:{},tooltipProps:{},actionText:{},actionDuration:{default:1500}},emits:["action"],setup(s,{emit:e}){const t=s,n=e,{label:r,icon:i,buttonProps:o,actionText:a,actionDuration:l,tooltipProps:u}=Jt(t),d=Vt("buttonRef"),h=ae(!1),v=ri(d);let f;const b=ne(()=>({top:`${v.top.value}px`,left:`${v.left.value}px`,transform:"translate(-50%, -100%)",marginTop:"-8px"})),k=z=>{h.value=!1,clearTimeout(f),n("action",z),h.value=!0,f=setTimeout(()=>{h.value=!1},l.value)};return Ea(()=>{f&&clearTimeout(f)}),(z,L)=>{const se=ys;return m(),A("div",{ref_key:"buttonRef",ref:d,class:"relative"},[y(se,et(c(o),{label:c(r),onClick:k}),zh({_:2},[c(i)?{name:"icon",fn:$(()=>[g("div",DS,[(m(),j(Ai(c(i))))])]),key:"0"}:void 0]),1040,["label"]),(m(),j(Uh,{to:"body"},[y(Et,{name:"fade"},{default:$(()=>[c(h)?(m(),j(se,et({key:0,as:"div"},c(u),{class:"fixed text-xs px-2 py-1 rounded whitespace-nowrap z-[99999] cursor-default pointer-events-none",style:c(b),label:c(a)}),null,16,["style","label"])):ce("",!0)]),_:1})]))],512)}}}),zS={viewBox:"0 0 16 16",width:"1.2em",height:"1.2em"};function US(s,e){return m(),A("svg",zS,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M4 4.085V10.5a2.5 2.5 0 0 0 2.336 2.495L6.5 13h4.414A1.5 1.5 0 0 1 9.5 14H6a3 3 0 0 1-3-3V5.5a1.5 1.5 0 0 1 1-1.415M11.5 2A1.5 1.5 0 0 1 13 3.5v7a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 5 10.5v-7A1.5 1.5 0 0 1 6.5 2z"},null,-1)]))}const Rh=pe({name:"fluent-copy-16-filled",render:US}),VS={class:"flex flex-col field-gap"},HS={class:"cui-label"},QS={class:"cui-label"},KS={class:"cui-label"},ZS={key:0,class:"flex flex-col field-gap"},GS={class:"cui-label"},WS={key:1,class:"flex flex-col field-gap"},JS={class:"cui-label"},YS=At({__name:"CameraSource",props:{cameraName:{},source:{},loading:{type:Boolean}},setup(s){const e=new Jn,t=s,{cameraName:n,source:r,loading:i}=Jt(t),{data:o,isFetching:a}=e.probeCameraSourceQuery(n.value,r.value.name,{video:!0,audio:!0,microphone:!0}),{copy:l}=sf({legacy:!0}),u=ne(()=>!!(i.value||a.value)),d=ne(()=>{var f;return((f=o.value)==null?void 0:f.probe.consumers.filter(b=>b.format_name!=="probe").length)||0}),h=ne(()=>{var k,z;const f=(k=o.value)==null?void 0:k.probe.consumers.find(L=>L.format_name==="probe"),b=(z=f==null?void 0:f.senders)==null?void 0:z.filter(L=>L.codec.codec_type==="video");return(b==null?void 0:b.map(L=>L.codec.codec_name))||[]}),v=ne(()=>{var k,z;const f=(k=o.value)==null?void 0:k.probe.consumers.find(L=>L.format_name==="probe"),b=(z=f==null?void 0:f.senders)==null?void 0:z.filter(L=>L.codec.codec_type==="audio");return(b==null?void 0:b.map(L=>L.codec.codec_name))||[]});return(f,b)=>{const k=ki,z=fo,L=BS,se=ka;return m(),A(yt,null,[g("div",VS,[g("label",HS,me(f.$t("components.form.label.connections")),1),y(z,null,{default:$(()=>[y(k,{value:c(d),loading:c(u),readonly:"",type:"text"},null,8,["value","loading"])]),_:1})]),(m(!0),A(yt,null,qt(c(h),(K,N)=>(m(),A("div",{key:N,class:"flex flex-col field-gap"},[g("label",QS,me(f.$t("components.form.label.video_codec")),1),y(z,null,{default:$(()=>[y(k,{"model-value":K,loading:c(u),readonly:"",type:"text"},null,8,["model-value","loading"])]),_:2},1024)]))),128)),(m(!0),A(yt,null,qt(c(v),(K,N)=>(m(),A("div",{key:N,class:"flex flex-col field-gap"},[g("label",KS,me(f.$t("components.form.label.audio_codec")),1),y(z,null,{default:$(()=>[y(k,{"model-value":K,loading:c(u),readonly:"",type:"text"},null,8,["model-value","loading"])]),_:2},1024)]))),128)),c(r).role!=="snapshot"?(m(),A("div",ZS,[g("label",GS,me(f.$t("components.form.label.rtsp_url")),1),y(z,null,{default:$(()=>{var K;return[y(k,{"model-value":(K=c(o))==null?void 0:K.rtspUrl,loading:c(u),readonly:"",type:"text"},null,8,["model-value","loading"]),y(se,null,{default:$(()=>{var N;return[y(L,{"action-text":f.$t("components.form.tooltip.copied"),icon:c(Rh),"button-props":{severity:"secondary",disabled:!((N=c(o))!=null&&N.rtspUrl),loading:c(u),text:!0},onAction:b[0]||(b[0]=E=>c(l)(c(o).rtspUrl))},null,8,["action-text","icon","button-props"])]}),_:1})]}),_:1})])):ce("",!0),c(r).role!=="snapshot"?(m(),A("div",WS,[g("label",JS,me(f.$t("components.form.label.onvif_url")),1),y(z,null,{default:$(()=>{var K;return[y(k,{"model-value":(K=c(o))==null?void 0:K.onvifUrl,loading:c(u),readonly:"",type:"text"},null,8,["model-value","loading"]),y(se,null,{default:$(()=>{var N;return[y(L,{"action-text":f.$t("components.form.tooltip.copied"),icon:c(Rh),"button-props":{severity:"secondary",disabled:!((N=c(o))!=null&&N.onvifUrl),loading:c(u),text:!0},onAction:b[1]||(b[1]=E=>c(l)(c(o).onvifUrl))},null,8,["action-text","icon","button-props"])]}),_:1})]}),_:1})])):ce("",!0)],64)}}}),XS={class:"flex gap-2 items-center w-full"},e7={class:"text-color font-normal"},t7={class:"flex flex-col gap-6"},s7=["for"],n7=["for"],r7={class:"flex items-center gap-4"},i7={class:"flex flex-col field-switch-gap"},o7=["for"],a7={class:"flex items-center gap-4"},c7={class:"flex flex-col field-switch-gap"},l7=["for"],u7={class:"flex flex-col gap-6"},d7=["for"],h7={class:"w-full flex items-center justify-center my-3"},m7=At({__name:"Sources",props:Kn({camera:{},cameraDevice:{},loading:{type:Boolean},latestSnapshotSrc:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:Kn(["close"],["update:modelValue"]),setup(s,{emit:e}){const t=Rr(s,"modelValue"),n=s,{camera:r,loading:i}=Jt(n),o=ae(["high-resolution","mid-resolution","low-resolution","snapshot"]),a=h=>{t.value.sources[h].urls.push("")},l=h=>{t.value.sources.splice(h,1)},u=(h,v)=>{t.value.sources[h].urls.splice(v,1)},d=()=>{t.value&&t.value.sources.push({_id:"",name:"",role:null,urls:[],useForSnapshot:!1,hotMode:!1})};return(h,v)=>{const f=vo,b=ys,k=Wc,z=ki,L=fo,se=YS,K=Kc,N=Qc,E=po,O=ka,U=Jc,S=Gc,M=Zc,B=vp;return m(),A(yt,null,[y(M,{multiple:"",class:"p-4"},{default:$(()=>[(m(!0),A(yt,null,qt(t.value.sources,(W,I)=>(m(),j(S,{key:I,value:I},{default:$(()=>[y(k,{class:at({"px-0 pt-0":I===0,"px-0":I!==0})},{default:$(()=>[g("div",XS,[g("span",e7,me(h.$t("components.camera_options.source")+": "+W.name.replace(/ /g,"_").toLowerCase()),1),y(b,{text:"",rounded:"",loading:c(i),disabled:t.value.sources.length<2,severity:"danger",class:"cui-icon-md ml-auto mr-2",onClick:w=>l(I)},{icon:$(()=>[y(f,{width:"100%",height:"100%"})]),_:2},1032,["loading","disabled","onClick"])])]),_:2},1032,["class"]),y(U,{pt:{content:{class:"px-0"}}},{default:$(()=>[g("div",t7,[y(c(Lt),{modelValue:W.name,"onUpdate:modelValue":w=>W.name=w,modelModifiers:{trim:!0},name:`sources[${I}].name`,as:"div",class:"flex flex-col field-gap"},{default:$(({field:w,errors:Q})=>[g("label",{for:`sources[${I}].name`,class:"cui-label"},me(h.$t("components.form.label.source_name")),9,s7),y(L,null,{default:$(()=>[y(z,et({ref_for:!0},w,{invalid:Q.length>0,loading:c(i),readonly:c(r).sources.some(J=>J.name===W.name),type:"text"}),null,16,["invalid","loading","readonly"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`sources[${I}].name`,class:"cui-input-error"},null,8,["name"])]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue","name"]),W._id?(m(),j(se,{key:0,"camera-name":c(r).name,source:W,loading:c(i)},null,8,["camera-name","source","loading"])):ce("",!0),y(c(Lt),{"model-value":W.role,name:`sources[${I}].role`,as:"div",class:"flex flex-col field-gap"},{default:$(({field:w,errors:Q})=>[g("label",{for:`sources[${I}].role`,class:"cui-label"},me(h.$t("components.form.label.source_role")),9,n7),y(L,null,{default:$(()=>[y(K,et({"model-value":W.role},{ref_for:!0},w,{options:c(o).filter(J=>!t.value.sources.some(q=>q.role===J&&q._id!==W._id)),invalid:Q.length>0,loading:c(i),onValueChange:J=>W.role=J}),null,16,["model-value","options","invalid","loading","onValueChange"])]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`sources[${I}].role`,class:"cui-input-error"},null,8,["name"])]),_:2},1024)]),_:2},1032,["model-value","name"]),W.role!=="snapshot"&&t.value.sources.length>1&&!t.value.sources.some(w=>(w.useForSnapshot||w.role==="snapshot")&&w._id!==W._id)?(m(),j(c(Lt),{key:1,"model-value":W.useForSnapshot,value:!0,"unchecked-value":!1,type:"checkbox",name:`sources[${I}].useForSnapshot`,as:"div",class:"flex flex-col field-gap"},{default:$(({field:w,errors:Q})=>[g("div",r7,[g("div",i7,[g("label",{for:`sources[${I}].useForSnapshot`,class:"cui-label-switch"},me(h.$t("components.form.label.use_for_snapshot")),9,o7),y(N,{severity:"secondary",variant:"simple",size:"small",class:"cui-input-switch-hint"},{default:$(()=>[Qt(me(h.$t("components.form.hint.use_for_snapshot")),1)]),_:1}),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`sources[${I}].useForSnapshot`,class:"cui-input-switch-error"},null,8,["name"])]),_:2},1024)]),y(E,et({"model-value":W.useForSnapshot},{ref_for:!0},w,{invalid:Q.length>0,loading:c(i),class:"ml-auto shrink-0",onValueChange:J=>W.useForSnapshot=J}),null,16,["model-value","invalid","loading","onValueChange"])])]),_:2},1032,["model-value","name"])):ce("",!0),W.role!=="snapshot"?(m(),j(c(Lt),{key:2,"model-value":W.hotMode,value:!0,"unchecked-value":!1,type:"checkbox",name:`sources[${I}].hotMode`,as:"div",class:"flex flex-col field-gap"},{default:$(({field:w,errors:Q})=>[g("div",a7,[g("div",c7,[g("label",{for:`sources[${I}].hotMode`,class:"cui-label-switch"},me(h.$t("components.form.label.hot_mode")),9,l7),y(N,{severity:"secondary",variant:"simple",size:"small",class:"cui-input-switch-hint"},{default:$(()=>[Qt(me(h.$t("components.form.hint.hot_mode")),1)]),_:1}),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`sources[${I}].hotMode`,class:"cui-input-switch-error"},null,8,["name"])]),_:2},1024)]),y(E,et({"model-value":W.hotMode},{ref_for:!0},w,{invalid:Q.length>0,loading:c(i),class:"ml-auto shrink-0",onValueChange:J=>W.hotMode=J}),null,16,["model-value","invalid","loading","onValueChange"])])]),_:2},1032,["model-value","name"])):ce("",!0),g("div",u7,[g("label",{for:`sources[${I}].urls[]`,class:"cui-label"},me(h.$t("components.form.label.sources")),9,d7),(m(!0),A(yt,null,qt(W.urls,(w,Q)=>(m(),j(c(Lt),{key:Q,modelValue:W.urls[Q],"onUpdate:modelValue":J=>W.urls[Q]=J,modelModifiers:{trim:!0},name:`sources[${I}].urls[${Q}]`,as:"div",class:"flex flex-col field-gap"},{default:$(({field:J,errors:q})=>[y(L,null,{default:$(()=>[y(z,et({ref_for:!0},J,{invalid:q.length>0,loading:c(i),type:"text"}),null,16,["invalid","loading"]),W.urls.length>1?(m(),j(O,{key:0},{default:$(()=>[y(b,{text:"",severity:"secondary",loading:c(i),onClick:oe=>u(I,Q)},{icon:$(()=>[y(f)]),_:2},1032,["loading","onClick"])]),_:2},1024)):ce("",!0)]),_:2},1024),y(Et,{name:"fade"},{default:$(()=>[y(c(jt),{name:`sources[${I}].urls[${Q}]`,class:"cui-input-error"},null,8,["name"])]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue","name"]))),128)),y(b,{loading:c(i),label:h.$t("components.form.button.add_source"),class:"ml-auto cui-button-medium",onClick:w=>a(I)},null,8,["loading","label","onClick"])])])]),_:2},1024)]),_:2},1032,["value"]))),128))]),_:1}),g("div",h7,[y(b,{text:"",rounded:"",loading:c(i),class:"cui-icon-xl",onClick:d},{icon:$(()=>[y(B,{width:"100%",height:"100%"})]),_:1},8,["loading"])])],64)}}}),p7={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function f7(s,e){return m(),A("svg",p7,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 2C9.76 2 7.78 3.05 6.5 4.68l9.81 9.82C17.94 13.21 19 11.24 19 9a7 7 0 0 0-7-7M3.28 4L2 5.27L5.04 8.3C5 8.53 5 8.76 5 9c0 2.38 1.19 4.47 3 5.74V17a1 1 0 0 0 1 1h5.73l4 4L20 20.72zM9 20v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-1z"},null,-1)]))}const g7=pe({name:"mdi-lightbulb-off",render:f7}),v7={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function _7(s,e){return m(),A("svg",v7,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M12 6a6 6 0 0 1 6 6c0 2.22-1.21 4.16-3 5.2V19a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1v-1.8c-1.79-1.04-3-2.98-3-5.2a6 6 0 0 1 6-6m2 15v1a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-1zm6-10h3v2h-3zM1 11h3v2H1zM13 1v3h-2V1zM4.92 3.5l2.13 2.14l-1.42 1.41L3.5 4.93zm12.03 2.13l2.12-2.13l1.43 1.43l-2.13 2.12z"},null,-1)]))}const y7=pe({name:"mdi-lightbulb-on",render:_7}),b7={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function w7(s,e){return m(),A("svg",b7,e[0]||(e[0]=[g("g",{fill:"#CFD8DC"},[g("path",{d:"M34 44H14c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h20c1.1 0 2 .9 2 2v34c0 1.1-.9 2-2 2"}),g("path",{d:"M28 13h-8c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h8c.6 0 1 .4 1 1v7c0 .6-.4 1-1 1"})],-1)]))}const x7=pe({name:"flat-color-icons-empty-battery",render:w7}),S7={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function C7(s,e){return m(),A("svg",S7,e[0]||(e[0]=[g("g",{fill:"#CFD8DC"},[g("path",{d:"M34 44H14c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h20c1.1 0 2 .9 2 2v34c0 1.1-.9 2-2 2"}),g("path",{d:"M28 13h-8c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h8c.6 0 1 .4 1 1v7c0 .6-.4 1-1 1"})],-1),g("path",{fill:"#8BC34A",d:"M34 44H14c-1.1 0-2-.9-2-2v-9h24v9c0 1.1-.9 2-2 2"},null,-1)]))}const k7=pe({name:"flat-color-icons-low-battery",render:C7}),E7={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function A7(s,e){return m(),A("svg",E7,e[0]||(e[0]=[g("g",{fill:"#CFD8DC"},[g("path",{d:"M34 44H14c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h20c1.1 0 2 .9 2 2v34c0 1.1-.9 2-2 2"}),g("path",{d:"M28 13h-8c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h8c.6 0 1 .4 1 1v7c0 .6-.4 1-1 1"})],-1),g("path",{fill:"#8BC34A",d:"M34 44H14c-1.1 0-2-.9-2-2V23h24v19c0 1.1-.9 2-2 2"},null,-1)]))}const M7=pe({name:"flat-color-icons-middle-battery",render:A7}),$7={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function T7(s,e){return m(),A("svg",$7,e[0]||(e[0]=[g("g",{fill:"#CFD8DC"},[g("path",{d:"M34 44H14c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h20c1.1 0 2 .9 2 2v34c0 1.1-.9 2-2 2"}),g("path",{d:"M28 13h-8c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h8c.6 0 1 .4 1 1v7c0 .6-.4 1-1 1"})],-1),g("path",{fill:"#8BC34A",d:"M34 44H14c-1.1 0-2-.9-2-2V13h24v29c0 1.1-.9 2-2 2"},null,-1)]))}const P7=pe({name:"flat-color-icons-high-battery",render:T7}),R7={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function I7(s,e){return m(),A("svg",R7,e[0]||(e[0]=[g("g",{fill:"#8BC34A"},[g("path",{d:"M34 44H14c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h20c1.1 0 2 .9 2 2v34c0 1.1-.9 2-2 2"}),g("path",{d:"M28 13h-8c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h8c.6 0 1 .4 1 1v7c0 .6-.4 1-1 1"})],-1)]))}const O7=pe({name:"flat-color-icons-full-battery",render:I7}),N7={viewBox:"0 0 48 48",width:"1.2em",height:"1.2em"};function F7(s,e){return m(),A("svg",N7,e[0]||(e[0]=[g("g",{fill:"#8BC34A"},[g("path",{d:"M34 44H14c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h20c1.1 0 2 .9 2 2v34c0 1.1-.9 2-2 2"}),g("path",{d:"M28 13h-8c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h8c.6 0 1 .4 1 1v7c0 .6-.4 1-1 1"})],-1),g("path",{fill:"#FFEB3B",d:"M30 24h-5.5l2.2-11L18 26h5.5l-2.2 11z"},null,-1)]))}const L7=pe({name:"flat-color-icons-charge-battery",render:F7}),j7={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function q7(s,e){return m(),A("svg",j7,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M6.5 20q-2.28 0-3.89-1.57Q1 16.85 1 14.58q0-1.95 1.17-3.48q1.18-1.53 3.08-1.95q.63-2.3 2.5-3.72Q9.63 4 12 4q2.93 0 4.96 2.04Q19 8.07 19 11q1.73.2 2.86 1.5q1.14 1.28 1.14 3q0 1.88-1.31 3.19T18.5 20Z"},null,-1)]))}const D7=pe({name:"mdi-cloud",render:q7}),B7={key:0,class:"flex items-center justify-center h-full"},z7={key:1},U7={class:"flex flex-col p-4"},V7={class:"camera-info flex justify-between items-center text-sm"},H7={class:"font-bold"},Q7={class:"flex items-center gap-2"},K7={class:"camera-info flex justify-between items-center text-sm"},Z7={class:"font-bold"},G7={class:"flex items-center"},W7={key:0,class:"camera-info flex justify-between items-center text-sm"},J7={class:"font-bold"},Y7={class:"flex items-center gap-2"},X7={key:0},eC={key:1,class:"camera-info flex justify-between items-center text-sm"},tC={class:"font-bold"},sC={class:"flex items-center"},nC={key:2,class:"camera-info flex justify-between items-center text-sm"},rC={class:"font-bold"},iC={class:"flex items-center"},oC={key:1},aC={key:2},cC={key:3,class:"camera-info flex justify-between items-center text-sm"},lC={class:"font-bold"},uC={class:"flex items-center"},dC={key:1},hC={key:2},mC={key:4,class:"camera-info flex justify-between items-center text-sm"},pC={class:"font-bold"},fC={class:"flex items-center"},gC={key:1},vC={key:2},_C={key:5,class:"camera-info flex justify-between items-center text-sm"},yC={class:"font-bold"},bC={class:"flex items-center"},wC={key:1},xC={key:2},SC={key:6,class:"camera-info flex justify-between items-center text-sm"},CC={class:"font-bold"},kC={class:"flex items-center"},EC={key:1},AC={key:2},MC=At({__name:"Overview",props:{camera:{},cameraDevice:{},loading:{type:Boolean},latestSnapshotSrc:{}},emits:["close"],setup(s,{emit:e}){const t=s,{cameraDevice:n,loading:r,latestSnapshotSrc:i}=Jt(t),{cameraObject:o,hasBattery:a,hasLight:l,hasAudioDetector:u,hasDoorbell:d,hasMotionDetector:h,hasObjectDetector:v,hasSiren:f,lightState:b,batteryState:k,motionState:z,objectState:L,audioState:se,doorbellState:K,sirenState:N}=Fl(n),E=ne(()=>r.value);return(O,U)=>{var Se,F,D,Y,Pe,He,ht,Mt,Qe,ze;const S=Lr,M=Nl,B=D7,W=L7,I=O7,w=P7,Q=M7,J=k7,q=x7,oe=y7,ue=g7;return c(o)?(m(),A("div",z7,[y(M,{"camera-name":c(o).name,src:c(i),class:"w-full aspect-video bg-black","image-container-class":"w-full h-full"},null,8,["camera-name","src"]),g("div",U7,[g("div",V7,[g("span",H7,me(O.$t("components.camera_options.name")),1),g("div",Q7,[g("span",null,me(c(o).name),1),c(o).isCloud?(m(),j(B,{key:0,class:"w-5 h-5"})):ce("",!0)])]),g("div",K7,[g("span",Z7,me(O.$t("components.camera_options.plugin")),1),g("div",G7,[c(E)?(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"})):ce("",!0),g("span",null,me(((Se=c(o).pluginInfo)==null?void 0:Se.name)??O.$t("components.camera_options.native")),1)])]),c(a)?(m(),A("div",W7,[g("span",J7,me(O.$t("components.camera_options.battery_state")),1),g("div",Y7,[c(k)!==void 0?(m(),A("span",X7,me(c(k).level)+"%",1)):ce("",!0),c(k)?c(k).charging?(m(),j(W,{key:2,class:"w-5 h-5"})):c(k).level===100?(m(),j(I,{key:3,class:"w-5 h-5"})):c(k).level>=75?(m(),j(w,{key:4,class:"w-5 h-5"})):c(k).level>=50?(m(),j(Q,{key:5,class:"w-5 h-5"})):c(k).level>=25?(m(),j(J,{key:6,class:"w-5 h-5"})):(m(),j(q,{key:7,class:"w-5 h-5"})):(m(),j(S,{key:1,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0),c(l)?(m(),A("div",eC,[g("span",tC,me(O.$t("components.camera_options.light_state")),1),g("div",sC,[c(b)?c(b).state?(m(),j(oe,{key:1,class:"text-yellow-400 w-5 h-5"})):(m(),j(ue,{key:2,class:"text-muted w-5 h-5"})):(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0),c(u)?(m(),A("div",nC,[g("span",rC,me(O.$t("components.camera_options.audio_state")),1),g("div",iC,[c(se)?c(se).state||(F=c(se).lastEvent)!=null&&F.state?(m(),A("span",oC,me(c(Bi)(c(se).state?c(se).timestamp:c(se).lastEvent.timestamp,"DD.MM.YYYY, HH:mm:ss")),1)):(m(),A("span",aC,"-")):(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0),c(d)?(m(),A("div",cC,[g("span",lC,me(O.$t("components.camera_options.doorbell_state")),1),g("div",uC,[c(K)?c(K).state||(D=c(K).lastEvent)!=null&&D.state?(m(),A("span",dC,me(c(Bi)(c(K).state?c(K).timestamp:c(K).lastEvent.timestamp,"DD.MM.YYYY, HH:mm:ss")),1)):(m(),A("span",hC,"-")):(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0),c(h)?(m(),A("div",mC,[g("span",pC,me(O.$t("components.camera_options.motion_state")),1),g("div",fC,[c(z)?c(z).state||(Y=c(z).detections)!=null&&Y.length||(Pe=c(z).lastEvent)!=null&&Pe.state||(ht=(He=c(z).lastEvent)==null?void 0:He.detections)!=null&&ht.length?(m(),A("span",gC,me(c(Bi)(c(z).state||(Mt=c(z).detections)!=null&&Mt.length?c(z).timestamp:c(z).lastEvent.timestamp,"DD.MM.YYYY, HH:mm:ss")),1)):(m(),A("span",vC,"-")):(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0),c(v)?(m(),A("div",_C,[g("span",yC,me(O.$t("components.camera_options.object_state")),1),g("div",bC,[c(L)?c(L).detections.length||(Qe=c(L).lastEvent)!=null&&Qe.detections.length?(m(),A("span",wC,me(c(Bi)(c(L).detections.length?c(L).timestamp:c(L).lastEvent.timestamp,"DD.MM.YYYY, HH:mm:ss")),1)):(m(),A("span",xC,"-")):(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0),c(f)?(m(),A("div",SC,[g("span",CC,me(O.$t("components.camera_options.siren_state")),1),g("div",kC,[c(N)?c(N).state||(ze=c(N).lastEvent)!=null&&ze.state?(m(),A("span",EC,me(c(Bi)(c(N).state?c(N).timestamp:c(N).lastEvent.timestamp,"DD.MM.YYYY, HH:mm:ss")),1)):(m(),A("span",AC,"-")):(m(),j(S,{key:0,"stroke-width":"5",class:"w-[30px] h-[30px]"}))])])):ce("",!0)])])):(m(),A("div",B7,[y(S,{"stroke-width":"5",class:"w-[30px] h-[30px]"})]))}}}),$C=qs(MC,[["__scopeId","data-v-95baba33"]]),TC={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function PC(s,e){return m(),A("svg",TC,e[0]||(e[0]=[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[g("path",{"stroke-width":"3",d:"M5 10h.01M5 16h.01"}),g("path",{"stroke-width":"2",d:"m10 17l4-10m2 10l4-10"})],-1)]))}const RC=pe({name:"humbleicons-url",render:PC}),IC={class:"flex items-center w-full h-[45px] border-b-[1px] border-color px-3"},OC={class:"font-semibold text-lg truncate"},NC=["onClick"],FC={class:"text-xs truncate"},LC={class:"w-full h-full max-h-full overflow-y-scroll"},jC={key:0,class:"flex w-full h-full items-center justify-center mt-5"},qC={key:1,class:"w-full h-full"},DC={key:0,class:"w-full flex items-center justify-center p-4 h-[70px]"},BC=At({__name:"CameraOptions",props:{cameraName:{},latestSnapshotSrc:{}},emits:["close"],setup(s,{emit:e}){const t=new Jn,n=Cn(),{t:r}=js(),i=e,o=s,{cameraName:a,latestSnapshotSrc:l}=Jt(o),u=Vt("formRef"),d=Ls(),h=ae(),v=ae("overview"),f=ae([{name:"overview",icon:Bc},{name:"sources",icon:RC},{name:"settings",icon:wa},{name:"plugins",icon:zc}]),{data:b,isFetching:k,suspense:z}=t.getCameraQuery(a),{mutate:L,isPending:se}=t.patchCameraQuery(),K=ne(()=>k.value||se.value),N=ne(()=>v.value==="sources"||v.value==="settings");Ge(b,O=>{O&&(h.value=xi(O))},{deep:!0,immediate:!0});const E=async()=>{var U;const O=await((U=u.value)==null?void 0:U.validate());O!=null&&O.valid&&O.values?L({cameraname:a.value,cameraData:O.values}):(n.add({severity:"error",summary:r("components.toast.title_error"),detail:r("components.toast.validation_failed"),life:3e3}),console.log("Validation failed",O))};return Sn(async()=>{if(await z(),!b.value)return;const O=await xp();d.value=await O.deviceManager.getCamera(b.value.name)}),Ea(()=>{var O;(O=d.value)==null||O.close()}),(O,U)=>{const S=vo,M=ys,B=R0,W=P0,I=Lr,w=$C,Q=m7,J=qS,q=D3,oe=Dh,ue=qh,Se=jh;return m(),A(yt,null,[g("div",IC,[g("span",OC,me(c(a)),1),y(M,{text:"",rounded:"",severity:"secondary",class:"ml-auto cui-icon-md shrink-0",onClick:U[0]||(U[0]=F=>i("close"))},{icon:$(()=>[y(S,{width:"100%",height:"100%"})]),_:1})]),y(c(rl),{ref_key:"formRef",ref:u,class:"w-full",style:ot({height:`calc(100% - 45px - ${c(N)?"70px":"0px"})`}),"validation-schema":c(Lx)},{default:$(()=>[y(Se,{value:c(v),"onUpdate:value":U[7]||(U[7]=F=>us(v)?v.value=F:null),scrollable:"",class:"w-full h-full"},{default:$(()=>[y(W,{class:"justify-between",pt:{tablist:{class:"h-[65px]"},activeBar:{class:"!w-auto"}}},{default:$(()=>[(m(!0),A(yt,null,qt(c(f),(F,D)=>(m(),j(B,{key:D,value:F.name,"as-child":""},{default:$(Y=>[g("div",et({ref_for:!0},Y.a11yAttrs,{class:["flex flex-col items-center justify-center flex-1 content-background !py-3",[{"hover:!text-color active:!text-color focus:!text-color":!Y.active},Y.class]],onClick:Y.onClick}),[(m(),j(Ai(F.icon),{class:"w-5 h-5"})),g("span",FC,me(O.$t(`components.options_sidebar.segment_tab_${F.name}`)),1)],16,NC)]),_:2},1032,["value"]))),128))]),_:1}),y(ue,{class:"p-0 h-[calc(100%-65px)]"},{default:$(()=>[g("div",LC,[(m(!0),A(yt,null,qt(c(f),(F,D)=>(m(),j(oe,{key:D,value:F.name,"as-child":""},{default:$(Y=>[Y.active?(m(),A("div",et({key:0,class:Y.class},{ref_for:!0},Y.a11yAttrs),[!c(h)||!c(b)||!c(d)?(m(),A("div",jC,[y(I,{"stroke-width":"5",class:"w-[30px] h-[30px]"})])):(m(),A("div",qC,[c(v)==="overview"?(m(),j(w,{key:0,camera:c(b),"camera-device":c(d),loading:c(K),"latest-snapshot-src":c(l),onClose:U[1]||(U[1]=Pe=>i("close"))},null,8,["camera","camera-device","loading","latest-snapshot-src"])):ce("",!0),c(v)==="sources"?(m(),j(Q,{key:1,modelValue:c(h),"onUpdate:modelValue":U[2]||(U[2]=Pe=>us(h)?h.value=Pe:null),camera:c(b),"camera-device":c(d),loading:c(K),onClose:U[3]||(U[3]=Pe=>i("close"))},null,8,["modelValue","camera","camera-device","loading"])):ce("",!0),c(v)==="settings"?(m(),j(J,{key:2,modelValue:c(h),"onUpdate:modelValue":U[4]||(U[4]=Pe=>us(h)?h.value=Pe:null),camera:c(b),"camera-device":c(d),loading:c(K),onClose:U[5]||(U[5]=Pe=>i("close"))},null,8,["modelValue","camera","camera-device","loading"])):ce("",!0),c(v)==="plugins"?(m(),j(q,{key:3,camera:c(b),"camera-device":c(d),loading:c(K),onClose:U[6]||(U[6]=Pe=>i("close"))},null,8,["camera","camera-device","loading"])):ce("",!0)]))],16)):ce("",!0)]),_:2},1032,["value"]))),128))])]),_:1})]),_:1},8,["value"]),c(N)?(m(),A("div",DC,[y(M,{fluid:"",severity:"success",class:"cui-button-medium",label:O.$t("components.form.button.save"),onClick:E},null,8,["label"])])):ce("",!0)]),_:1},8,["style","validation-schema"])],64)}}}),zC={class:"w-full h-full p-safe !pb-0 md:!pl-0"},UC={class:"w-full h-full border-0 md:border-r-[1px] border-color overflow-y-auto pb-safe"},VC=At({__name:"CuiCameraDrawer",setup(s){const e=qr(),t=wp(),n=t.getEventBus(),r=ae(!1),i=ae(),o=ae(),a=ne(()=>bp.pt);Ge(e.currentRoute,(u,d)=>{u.path!==d.path&&t.close()});const l=()=>{r.value=!1,t.close()};return Sn(()=>{n.on(u=>{u.type==="open"?(i.value=u.options,o.value=u.props,r.value=!0):u.type==="close"&&(r.value=!1,i.value=void 0)})}),(u,d)=>{const h=BC,v=I0;return m(),j(v,et({visible:c(r),"onUpdate:visible":d[0]||(d[0]=f=>us(r)?r.value=f:null)},c(o),{class:"border-0 md:border-l-[1px]",pt:c(a),onHide:l}),{container:$(({closeCallback:f})=>[g("div",zC,[g("div",UC,[c(i)?(m(),j(h,et({key:0},c(i),{onClose:f}),null,16,["onClose"])):ce("",!0)])])]),_:1},16,["visible","pt"])}}}),HC={class:"loader flex flex-col justify-center items-center"},QC={key:0,class:"absolute flex flex-col items-center justify-center pb-safe bottom-10"},KC={key:0,class:"offline"},ZC={key:1,class:"text-center text-white text-sm font-bold mt-2"},GC=At({__name:"CuiLoadingScreen",props:{reload:{type:Boolean,default:!1},height:{default:"200px"},width:{default:"200px"},text:{},icon:{}},setup(s){const e=s,{reload:t,width:n,height:r,text:i,icon:o}=Jt(e);let a,l;const u=()=>{clearInterval(a),clearTimeout(l)};return Sn(()=>{u(),t.value&&(a=setInterval(()=>{const d=document.getElementById("lens");d==null||d.classList.remove("cameraLens");const h=document.getElementById("CameraUI_U");h==null||h.classList.remove("cameraLetter"),l=setTimeout(()=>{d==null||d.classList.add("cameraLens"),h==null||h.classList.add("cameraLetter")},100)},2300))}),go(()=>{u()}),(d,h)=>(m(),A("div",HC,[y(c(Aa),{src:c(Fr)("logo_loading_circle.svg"),width:c(n),height:c(r),title:"camera.ui","aria-label":"camera.ui"},null,8,["src","width","height"]),c(o)||c(i)?(m(),A("div",QC,[c(o)?(m(),A("div",KC,[(m(),j(Ai(c(o)),{class:"w-8 h-8 text-primary"}))])):ce("",!0),c(i)?(m(),A("div",ZC,me(c(i)),1)):ce("",!0)])):ce("",!0)]))}}),WC=qs(GC,[["__scopeId","data-v-d2a6a09b"]]),JC={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function YC(s,e){return m(),A("svg",JC,e[0]||(e[0]=[g("path",{fill:"currentColor",d:"M10 3h8l-4 6h4L6 21l4-9H6z"},null,-1)]))}const XC=pe({name:"gridicons-offline",render:YC}),ek={components:{camera_draggable:{no_cameras:"Keine Kameras verfügbar"},camera_events:{no_events:"Keine Ereignisse verfügbar"},camera_options:{advanced:"Erweitert",audio_state:"Audiozustand",battery_state:"Batteriezustand",branding:"Branding",categories:"Kategorien",chip_audioDetection:"Geräuscherkennung",chip_cameraController:"Kamera",chip_hub:"Hub",chip_more:"Mehr",chip_motionDetection:"Bewegungserkennung",chip_objectDetection:"Objekterkennung",chip_plugins:"Plugins",chip_ptz:"PTZ",detection:"Erkennung",doorbell_state:"Türklingelzustand",enabled_extension:"Aktivierte Erweiterung",frame_worker:"Frame Worker",general:"Allgemein",interface:"Interface",light_state:"Lichtzustand",manage_plugins:"Plugins verwalten",model:"Modell",more_plugins:"Mehr Plugins",motion_detection:"Bewegungserkennung",motion_state:"Bewegungszustand",name:"Name",native:"Nativ",no_config:"Keine Konfiguration verfügbar",no_plugins_enabled:"Keine Plugins aktiviert",no_plugins_found:"Keine Plugins gefunden",object_detection:"Objekterkennung",object_state:"Objektzustand",plugin:"Plugin",plugin_settings:"Plugin Einstellungen",recordings:"Aufnahmeeinstellungen",settings:"Einstellungen",siren_state:"Sirenenzustand",source:"Quelle",snapshot:"Snapshot",streaming_mode:"Streaming Modus",unknown:"Unbekannt",zones:"Zonen"},camera_table:{cameras:"Kameras",name:"Name",offline:"Offline",online:"Online",status:"Status"},charts:{no_data:"Keine Daten verfügbar"},detection_interface:{audio_detected:"Audio erkannt",audio_not_detected:"Audio nicht erkannt",audio_required:"Audio Datei erforderlich",detect:"Erkennen",drop_or_select_audio_to_detect:"Audio ablegen oder auswählen, um Geräusche zu erkennen",drop_or_select_image_to_detect_objects:"Bild ablegen oder auswählen, um Objekte zu erkennen",drop_or_select_video_to_detect_motion:"Video ablegen oder auswählen, um Bewegung zu erkennen",file_size_error:"Dateigröße zu groß",image_required:"Image required",interface_config:"Interface-Konfiguration",no_interface_config:"Keine Interface-Konfiguration verfügbar",only_one_audio_allowed:"Es ist nur ein Audio erlaubt",only_one_image_allowed:"Es ist nur ein Bild erlaubt",only_one_video_allowed:"Es ist nur ein Video erlaubt",video_required:"Video required"},dialog:{components:{new_camera:{add_camera:"Kamera hinzufügen",add_camera_description:"Fügen Sie eine Kamera hinzu, die mit Ihrem lokalen Netzwerk verbunden ist",camera:"Kamera",discover_cameras:"Kameras suchen",discover_cameras_description:"Suchen Sie nach Kameras in Ihrem lokalen Netzwerk",no_cameras_found:"Keine Kameras gefunden",protocol_info:"Informationen zum gewählten Protokoll",scan_again:"Erneut scannen",search_camera:"Kamera suchen",source:"Quelle",test_source:"Kameraquelle testen",title:"Neue Kamera",unknown:"Unbekannt"}},message:{confirm_clear_log:"Sind Sie sicher, dass Sie das Protokoll löschen möchten?",confirm_remove:"Sind Sie sicher, dass Sie diese Kamera entfernen möchten?",confirm_remove_layout:"Sind Sie sicher, dass Sie dieses Layout entfernen möchten?",confirm_reset_server:"Sind Sie sicher, dass Sie den Server zurücksetzen möchten?",confirm_restart_go2rtc:"Sind Sie sicher, dass Sie Go2RTC neu starten möchten?",confirm_restart_plugin:"Sind Sie sicher, dass Sie dieses Plugin neu starten möchten?",confirm_restart_server:"Sind Sie sicher, dass Sie den Server neu starten möchten?",confirm_restore:"Sind Sie sicher, dass Sie dieses Backup wiederherstellen möchten?",confirm_uninstall_plugin:"Sind Sie sicher, dass Sie dieses Plugin deinstallieren möchten?",intercom_info:"Sprechen Sie gleichzeitig mit allen Kameras, die eine Sprechanlage haben"},title:{config:"Konfiguration",confirm:"Bestätigen",create_new_user:"Neuer Benuter",edit_dnd:"DND bearbeiten",edit_layout:"Layout bearbeiten",edit_user:"Benutzer bearbeiten",edit_view:"Ansicht bearbeiten",information:"Information",install:"Installieren",install_version:"Version installieren",intercom:"Gegensprechanlage",log:"Log",new_dnd:"Neue DND",new_view:"Neue Ansicht",new_zone:"Neue Zone",plugin_config:"Plugin-Konfiguration",preview:"Vorschau",remove_layout:"Layout entfernen",reset_server:"Server zurücksetzen",restart:"Neustart",result:"Ergebnis",search_plugin:"Plugin suchen",update:"Aktualisieren",unknown:"Unbekannt",zone:"Zone",zone_editor:"Zonen-Editor"}},form:{button:{add:"Hinzufügen",add_source:"Quelle hinzufügen",add_view:"Ansicht hinzufügen",back:"Zurück",cancel:"Abbrechen",change_view:"Ansicht wechseln",clear:"Löschen",close:"Schließen",continue:"Fortfahren",create_new_user:"Neuen Benutzer erstellen",download:"Herunterladen",download_backup_archive:"Backup-Archiv herunterladen",download_cert:"Zertifikat herunterladen",edit:"Bearbeiten",edit_zones:"Zonen bearbeiten",finish:"Fertig",go_to_message:"Zur Nachricht gehen",home:"Startseite",install:"Installieren",login:"Anmelden",logout:"Abmelden",logout_all:"Alle abmelden",manage:"Verwalten",mark_as_read:"Als gelesen markieren",new:"Neu",new_zone:"Neue Zone",next:"Weiter",open_editor:"Editor öffnen",previous:"Zurück",reinstall:"Neu installieren",remove:"Entfernen",reset:"Zurücksetzen",restart:"Neustarten",restore_backup_archive:"Backup-Archiv wiederherstellen",restore_and_restart:"Wiederherstellen und neustarten",save:"Speichern",save_and_restart:"Speichern und neustarten",submit:"Absenden",test_connection:"Verbindung testen",undo:"Rückgängig",uninstall:"Deinstallieren",update:"Aktualisieren",upload:"Hochladen"},error:{no_cameras_selected:"Keine Kameras ausgewählt",no_view_selected:"Keine Ansicht ausgewählt"},hint:{aspect_ratio:"Zwingt das Seitenverhältnis der Kamera auf den gewählten Wert",cache_time:"Zeit in Millisekunden, die der Cache für die Kamerabilder verwendet",confidence:"Die benötigte Konfidenz für die Erkennung eines Objekts",default_settings_page:"Die Standardseite, die beim Öffnen der Einstellungen angezeigt wird",disable_camera:"Deaktiviert die Kamera und stoppt alle Aktivitäten. Die Kamera wird weiterhin angezeigt",frameworker_decoder:"Der Decoder, der für den Frame Worker verwendet wird",frameworker_fps:"Die Anzahl der Frames pro Sekunde, welche für den Frame Worker verwendet werden. '0' verwendet die native Framerate",frameworker_resolution:"Die Auflösung der Kamera, welche für den Frame Worker verwendet wird",hot_mode:"Lässt die Verbindung zur Kamera aktiv, um die Verzögerung zu minimieren",motion_duration:"Zeit in Sekunden, die die Kamera benötigt, um nach einer Bewegungserkennung wieder in den normalen Modus zurückzukehren",navbar_stay_collapsed:"Lässt die Navbar eingeklappt, auch auf größeren Bildschirmen",remember_me:"Erlaubt, dass die Sitzung nicht abläuft",session_timer:"Die Zeit in Millisekunden, bevor die Sitzung abläuft",show_bottombar_on_mobile:"Zeigt die untere Leiste auf Mobilgeräten",show_camera_events:"Zeigt die Kameraereignisse in der Kameraansicht",single_session:"Erlaubt nur eine aktive Sitzung pro Benutzer",streaming_mode:"Stream Transport Protokoll für die Benutzeroberfläche. In 'auto' wird der beste Modus automatisch ausgewählt",streaming_source:"Kameraquelle für den Stream. In 'auto' wird die beste Quelle automatisch ausgewählt",system_preference:"Systemeinstellung für die Benutzeroberfläche",use_for_snapshot:"Verwendet diese Quelle für Snapshots (wenn sonst keine geeignete Quelle existiert)"},label:{actions:"Aktionen",aspect_ratio:"Seitenverhältnis",audio_codec:"Audio-Codec",cache_time:"Cache Zeit",camera:"Kamera",cameras:"Kameras",changelog:"Änderungsprotokoll",classes:"Klassen",color:"Farbe",confidence:"Konfidenz",connections:"Verbindungen",custom_domain:"Benutzerdefinierte Domain",decoder:"Decoder",default_settings_page:"Standard Einstellungsseite",disabled:"Deaktiviert",enabled:"Aktiviert",firmware_version:"Firmware Version",fps:"FPS",frame_worker:"Frame Worker",hardware_version:"Hardware Version",hot_mode:"Hot Modus",language:"Sprache",layout_name:"Layoutname",manufacturer:"Hersteller",model:"Modell",motion_duration:"Bewegungsdauer",name:"Name",navbar_stay_collapsed:"Navbar eingeklappt lassen",new_password:"Neues Passwort",new_password_confirm:"Neues Passwort bestätigen",onvif_url:"ONVIF URL",password:"Passwort",pin:"PIN",plugin_version:"Plugin-Version",recording:"Aufnahme",remember_me:"Erinnere mich",remote_access_mode:"Remote Zugriffsmodus",remove_storage:"Speicher entfernen",resolution:"Auflösung",role:"Rolle",rtsp_url:"RTSP-URL",select_all:"Alle auswählen",select_cameras:"Kameras auswählen",serial_number:"Seriennummer",server_addresses:"Server-Adressen",server_version:"Server-Version",session_timer:"Sitzungstimer",settings:"Einstellungen",show_bottombar_on_mobile:"Bottombar auf Mobilgeräten anzeigen",show_camera_events:"Kameraereignisse anzeigen",single_session:"Einzelne Sitzung",source:"Quelle",source_label:"Quellenbezeichnung",source_name:"Quellenname",source_role:"Quellenrolle",sources:"Quellen",snapshot_url:"Snapshot URL",streaming_mode:"Streaming Modus",streaming_source:"Streaming Quelle",support_url:"Support URL",system_preference:"Systemeinstellung",theme:"Thema",type:"Typ",url:"URL",use_for_snapshot:"Für Snapshot verwenden",username:"Benutzername",version:"Version",video_codec:"Video-Codec",views:"Ansichten",zone_name:"Zonenname"},tooltip:{activity_mode_activity:"Aktivität",activity_mode_always_on:"Immer An",activity_mode_standby:"Standby",clear:"Säubern",contain:"Enthalten",copied:"Kopiert",delete:"Löschen",disable_drag:"Ziehen deaktivieren",disabled:"Deaktiviert",download:"Herunterladen",edit:"Bearbeiten",enable_drag:"Ziehen aktivieren",exclude:"Ausschließen",finish:"Fertig",fullscreen_off:"Vollbildmodus ausschalten",fullscreen_on:"Vollbildmodus einschalten",hide_timeline:"Zeitleiste ausblenden",include:"Einschließen",intercom:"Gegensprechanlage",intersect:"Schneiden",logout:"Abmelden",mode:"Modus",mute:"Stumm",new:"Neu",privacy_mask:"Privatsphärenmaske",public_mask:"Öffentliche Maske",resolution:"Auflösung",restart:"Neustarten",show_timeline:"Zeitleiste anzeigen",source_role_auto:"Auto",source_role_low:"Niedrige Auflösung",source_role_mid:"Mittlere Auflösung",source_role_high:"Hohe Auflösung",source_role_snapshot:"Snapshot",source_role_unknown:"Unbekannt",streaming_mode_auto:"Auto",streaming_mode_mse:"MSE",streaming_mode_unknown:"Unbekannt",streaming_mode_webrtc:"WebRTC ",undo:"Rückgängig",unmute:"Stummschalten aufheben",update_available:"Aktualisierung verfügbar",zoom_in:"Vergrößern",zoom_out:"Verkleinern"}},notification_menu:{clear_notifications:"Benachrichtigungen löschen",debug:"Debug",error:"Fehler",info:"Info",no_notifications:"Keine Benachrichtigungen",notifications:"Benachrichtigungen",short_days:"Tg.",short_hours:"Std.",short_minutes:"Min.",short_months:"M.",short_years:"J.",verbose:"Ausführlich",warn:"Warnung"},options_sidebar:{segment_tab_default:"Standard",segment_tab_overview:"Übersicht",segment_tab_plugins:"Plugins",segment_tab_settings:"Einstellungen",segment_tab_sources:"Quellen"},player:{add_shortcuts:"Shortcuts hinzufügen",activity_mode_activity:"Aktivität",activity_mode_always_on:"Immer An",activity_mode_standby:"Standby",capture_snapshot:"Snapshot aufnehmen",detections:"Erkennungen",hide_shortcuts:"Shortcuts ausblenden",hide_timeline:"Zeitleiste ausblenden",hide_zones:"Zonen ausblenden",live:"Live",log:"Log",ptz:"PTZ",ptz_go_to_home:"Zurück zur Startposition",reconnecting:"Wiederverbinden...",refresh_snapshot:"Snapshot aktualisieren",save_shortcuts:"Shortcuts speichern",settings:"Einstellungen",share_camera:"Kamera teilen",show_shortcuts:"Shortcuts anzeigen",show_timeline:"Zeitleiste anzeigen",show_zones:"Zonen anzeigen",source_role_auto:"Auto",source_role_low:"Niedrige Auflösung",source_role_mid:"Mittlere Auflösung",source_role_high:"Hohe Auflösung",source_role_snapshot:"Snapshot",source_role_unknown:"Unbekannt",stream_paused:"Stream pausiert, um Ressourcen zu schonen. Klicken Sie auf den Stream, um fortzufahren.",streaming_mode_auto:"Auto",streaming_mode_mse:"MSE",streaming_mode_unknown:"Unbekannt",streaming_mode_webrtc:"WebRTC ",zoom_in:"Zoom rein",zoom_out:"Zoom raus"},plugin_card:{author:"Autor",installed:"Installiert",no_description:"Keine Beschreibung verfügbar",restart:"Neustart",select_version:"Version auswählen",settings:"Einstellungen",start:"Start",status_disabled:"Deaktiviert",status_error:"Fehler",status_ready:"Bereit",status_started:"Gestartet",status_starting:"Startet",status_stopped:"Gestoppt",status_unknown:"Unbekannt",stop:"Stop",uninstall:"Deinstallieren",update:"Aktualisieren",update_available:"Aktualisierung verfügbar",updated:"Aktualisiert",version:"Version"},plugin_search:{plugins:"Plugins",refresh:"Aktualisieren"},plugin_types:{hub:"Hub",cameraController:"Kamera-Controller",motionDetection:"Bewegungserkennung",objectDetection:"Objekterkennung",audioDetection:"Geräuscherkennung",ptz:"PTZ"},process_table:{status_error:"Fehler",status_ready:"Bereit",status_started:"Gestartet",status_starting:"Startet",status_stopped:"Gestoppt",status_stopping:"Stoppt",status_unknown:"Unbekannt",system:"System",title_cpu:"CPU",title_cpu_load:"CPU-Auslastung",title_memory:"Speicher",title_memory_load:"Speicherauslastung",title_name:"Name",title_pid:"PID"},timeline:{live:"Live"},topbar:{syncing_data:"Daten synchronisieren..."},toast:{backup_downloaded:"Backup-Datei erfolgreich heruntergeladen",backup_restored:"Backup-Datei erfolgreich wiederhergestellt",camera_added:"Kamera erfolgreich hinzugefügt",camera_removed:"Kamera erfolgreich entfernt",camera_updated:"Kamera erfolgreich aktualisiert",cameras_removed:"Kameras erfolgreich entfernt",config_deleted:"Konfiguration erfolgreich gelöscht",config_go2rtc_deleted:"Go2RTC-Konfiguration erfolgreich gelöscht",config_go2rtc_updated:"Go2RTC-Konfiguration erfolgreich aktualisiert",config_updated:"Konfiguration erfolgreich aktualisiert",error_see_console:"Fehler, siehe Konsole",frame_worker_restarted:"Frame Worker erfolgreich neugestartet",go2rtc_restarted:"Go2RTC erfolgreich neugestartet",log_cleared:"Log erfolgreich gelöscht",no_version_selected:"Keine Version ausgewählt",plugin_config_updated:"Plugin-Konfiguration erfolgreich aktualisiert",plugin_disabled:"Plugin erfolgreich deaktiviert",plugin_enabled:"Plugin erfolgreich aktiviert",plugin_installed:"Plugin erfolgreich installiert",plugin_removed:"Plugin erfolgreich entfernt",plugin_request_sent:"Plugin-Anfrage erfolgreich gesendet",plugin_restarted:"Plugin erfolgreich neugestartet",plugin_settings_updated:"Plugin-Einstellungen erfolgreich aktualisiert",plugin_started:"Plugin erfolgreich gestartet",plugin_stopped:"Plugin erfolgreich gestoppt",plugins_removed:"Plugins erfolgreich entfernt",profile_updated:"Profil erfolgreich aktualisiert",server_resetted:"Server erfolgreich zurückgesetzt",server_restarted:"Server erfolgreich neugestartet",server_updated:"Server erfolgreich aktualisiert",title_error:"Fehler",title_info:"Info",title_success:"Erfolgreich",title_warn:"Warnung",user_added:"Benutzer erfolgreich hinzugefügt",user_logged_out:"Benutzer erfolgreich abgemeldet",user_removed:"Benutzer erfolgreich entfernt",user_updated:"Benutzer erfolgreich aktualisiert",users_removed:"Benutzer erfolgreich entfernt",view_added:"Ansicht erfolgreich hinzugefügt",validation_failed:"Validierung fehlgeschlagen. Überprüfen Sie die Konsole für weitere Informationen",view_removed:"Ansicht erfolgreich entfernt",view_updated:"Ansicht erfolgreich aktualisiert",views_removed:"Ansichten erfolgreich entfernt",zone_updated:"Zone erfolgreich aktualisiert",zone_removed:"Zone erfolgreich entfernt"},upload_files:{drop_or_select_file:"Datei ablegen oder auswählen",only_one_file_allowed:"Es ist nur eine Datei erlaubt"},user_menu:{account:"Konto",admin_panel:"Admin Panel",config:"Konfiguration",console:"Logs",logout:"Abmelden",plugins:"Plugins",reload:"Neu laden"},user_table:{title_address:"Adresse",title_device:"Gerät",title_username:"Benutzername",you:"Du"},view_box:{available_streams:"Verfügbare Streams"},zone_editor:{edit_zones:"Zonen bearbeiten",zone:"Zone"}},general:{loading:"Laden...",role_admin:"Admin",role_user:"Benutzer"},navigation:{account:"Konto",adminpanel:"Admin-Panel",appearance:"Erscheinungsbild",backup:"Backup",cameras:"Kameras",cammesh:"Cammesh",camview:"Kameransicht",config:"Konfiguration",console:"Logs",extras:"Extras",nvr:"NVR",plugins:"Plugins",recordings:"Aufnahmen",remote:"Remote Zugriff",settings:"Einstellungen",system:"System",user:"Benutzer"},navigation_description:{account_description:"Verwalten Sie Kontoeinstellungen und Erfahrungen.",appearance_description:"Verwalten Sie das Erscheinungsbild und die Benutzeroberfläche der App.",backup_description:"Verwalten, planen Sie Backups und stellen Sie Daten wieder her.",nvr_description:"Verwalten Sie das Netzwerk-Videorekorder-System.",recordings_description:"Verwalten Sie Aufnahmen und Speicheroptionen.",remote_access_description:"Verwalten Sie den Remote-Zugriff und die Verbindungseinstellungen.",system_description:"Verwalten Sie das System, überwachen Sie den Status und die Aufgaben.",user_description:"Verwalten Sie Benutzer, Rollen und Berechtigungen."},views:{404:{error_message:"Wir haben überall gesucht, aber diese Seite scheint Verstecken zu spielen... und sie gewinnt! Lass uns dich zurück an einen Ort bringen, der existiert."},adminpanel:{core:"Core",frameworker:"Frameworker",general:"Allgemein",logged_in_users:"Derzeit angemeldete Benutzer",plugins:"Plugins",title:"Admin Panel"},camera:{detections:"Erkennungen",timeline:"Zeitleiste",title:"Kamera"},cameras:{add_camera:"Kamera hinzufügen",events:"Ereignisse",new_camera:"Neue Kamera",no_cameras:"Keine Kameras verfügbar",title:"Kameras"},cammesh:{title:"Cammesh"},camview:{all_cameras:"Alle Kameras",cameras:"Kameras",new_dnd:"Neue DND",new_view:"Neue Ansicht",no_dnds_configured:"Keine DNDs konfiguriert",no_views_configured:"Keine Ansichten konfiguriert",title:"Camview"},config:{title:"Konfiguration"},console:{title:"Logs"},firststeps:{complete:"Fertig",enjoy:"Viel Spaß!",finish_message:"Sie haben die ersten Schritte erfolgreich abgeschlossen. Sie können nun die Anwendung nutzen.",from_backup:"Aus Backup wiederherstellen",new_installation:"Neue Installation",slogan:"Die moderne Lösung für professionelle Videoüberwachung.",start:"Start",start_message:"Bitte wählen Sie, ob Sie eine neue Installation starten oder ein Backup wiederherstellen möchten.",step_account:"Konto",step_appearance:"Erscheinungsbild",step_finish:"Fertig",step_welcome:"Willkommen",title:"Erste Schritte",welcome_to:"Willkommen bei"},login:{title:"Anmelden"},plugin:{changelog:"Änderungsprotokoll",disabled_info:"Plugin ist deaktiviert",no_cameras:"Keine Kamera verfügbar",no_changelog:"Kein Änderungsprotokoll verfügbar",no_readme:"Keine Leseanleitung verfügbar",plugin_is_disabled:"Plugin ist deaktiviert",readme:"Leseanleitung",segment_tab_cameras:"Kameras",segment_tab_interface:"Interface",segment_tab_plugins:"Plugins",segment_tab_settings:"Einstellungen",settings:"Einstellungen",title:"Plugin"},plugins:{no_plugins:"Keine Plugins verfügbar",search_plugins:"Plugins suchen",title:"Plugins"},recordings:{title:"Aufnahmen"},settings:{app:"App",available_updates:"Verfügbare Aktualisierungen",available_updates_info:"Es sind Aktualisierungen für camera.ui verfügbar.",certificate:"Zertifikat",certificate_info:"Laden Sie hier das SSL-Zertifikat der Webseite herunter. Durch das Hinzufügen dieses Zertifikats zu Ihrem Keychain oder Ihrer Zertifikatsverwaltung wird die Seite als sicher erkannt. Dies verbessert die Browsererfahrung und vermeidet Sicherheitswarnungen.",connection:"Verbindung",create_backup:"Backup erstellen",create_backup_info:"Laden Sie ein Sicherungsarchiv Ihrere gesamten camera.ui Umgebung herunter. Dadurch wird der Inhalt Ihres camera.ui Speicherungsverzeichnisses gesichert. Diesen können Sie später auf jeder Plattform wiederherstellen auf der camera.ui läuft.",edit:"Bearbeiten",interface:"Interface",locale:"Sprache",network:"Netzwerk",network_info:"Konfigurieren Sie hier die IP-Adressen, die der Server für die WebRTC-Kommunikation mit den Kameras verwendet. Diese Einstellung ermöglicht eine stabile und effiziente Verbindung zwischen Ihrem System und den angeschlossenen Kameras.",not_available_updates_info:"Ihre camera.ui Version ist auf dem neuesten Stand.",password:"Passwort",profile:"Profil",registered_users:"Registrierte Benutzer",remote_access_info:"Konfigurieren Sie hier die Remote-Zugriffseinstellungen. Diese Einstellungen ermöglichen es Ihnen, von überall auf Ihre camera.ui Umgebung zuzugreifen.",remote_access_settings:"Remote Zugriff Einstellungen",remove:"Entfernen",reset_server:"Server zurücksetzen",reset_server_info:"Durch Klicken auf diesen Button setzen Sie die Konfiguration auf die Standardwerte zurück. Dies entfernt alle Ihre Einstellungen und Daten. Diese Aktion kann nicht rückgängig gemacht werden.",restart_server:"Server neustarten",restart_server_info:"Durch Klicken auf diesen Button starten Sie den Server neu. Ein Ladebildschirm wird angezeigt, bis der Neustart abgeschlossen ist. Anschließend wird die Seite automatisch aktualisiert und steht Ihnen wieder zur Verfügung.",restore_backup:"Backup wiederherstellen",restore_backup_info:"Stellen Sie ein Sicherungsarchiv wieder her, das Sie zuvor mit camera.ui erstellt haben. Ihre camera.ui Konfiguration, Datenbank, Benutzerkonten und Medien werden wiederhergestellt.",search_by_name:"Nach Namen suchen",searching_updates:"Suche nach Aktualisierungen...",server:"Server",sheduled_backup:"Geplantes Backup",sheduled_backup_info:"Planen Sie ein Backup der aktuellen Konfiguration",status:"Status",theme:"Thema",title:"Einstellungen",title_account:"Konto",title_appearance:"Erscheinungsbild",title_backup:"Backup",title_go2rtc:"Go2RTC",title_remote:"Remote Zugriff",title_nvr:"NVR",title_recordings:"Aufnahmen",title_system:"System",title_user:"Benutzer",unknown:"Unbekannt",update_available:"Aktualisierung verfügbar",version:"Version"}}},tk={components:{camera_draggable:{no_cameras:"No cameras available"},camera_events:{no_events:"No events available"},camera_options:{advanced:"Advanced",audio_state:"Audio state",battery_state:"Battery state",branding:"Branding",categories:"Categories",chip_audioDetection:"Audio detection",chip_cameraController:"Camera",chip_hub:"Hub",chip_more:"More",chip_motionDetection:"Motion detection",chip_objectDetection:"Object detection",chip_plugins:"Plugins",chip_ptz:"PTZ",detection:"Detection",doorbell_state:"Doorbell state",enabled_extension:"Enabled extension",frame_worker:"Frame Worker",general:"General",interface:"Interface",light_state:"Light state",manage_plugins:"Manage plugins",model:"Model",more_plugins:"More plugins",motion_detection:"Motion detection",motion_state:"Motion state",name:"Name",native:"Native",no_config:"No configuration available",no_plugins_enabled:"No plugins enabled",no_plugins_found:"No plugins found",object_detection:"Object detection",object_state:"Object state",plugin:"Plugin",plugin_settings:"Plugin settings",recordings:"Recordings",settings:"Settings",siren_state:"Siren state",source:"Source",snapshot:"Snapshot",streaming_mode:"Streaming mode",unknown:"Unknown",zones:"Zones"},camera_table:{cameras:"Cameras",name:"Name",offline:"Offline",online:"Online",status:"Status"},charts:{no_data:"No data available"},detection_interface:{audio_detected:"Audio detected",audio_not_detected:"Audio not detected",audio_required:"Audio required",detect:"Detect",drop_or_select_audio_to_detect:"Drop or select audio to detect",drop_or_select_image_to_detect_objects:"Drop or select image to detect objects",drop_or_select_video_to_detect_motion:"Drop or select video to detect motion",file_size_error:"File size error",image_required:"Image required",interface_config:"Interface configuration",no_interface_config:"No interface configuration available",only_one_audio_allowed:"Es ist nur ein Audio erlaubt",only_one_image_allowed:"Only one image allowed",only_one_video_allowed:"Only one video allowed",video_required:"Video required"},dialog:{components:{new_camera:{add_camera:"Add camera",add_camera_description:"Add a camera connected to your local network",camera:"Camera",discover_cameras:"Discover cameras",discover_cameras_description:"Search for cameras in your local network",no_cameras_found:"No cameras found",protocol_info:"Information about the selected protocol",scan_again:"Scan again",search_camera:"Search camera",source:"Source",test_source:"Test camera source",title:"New camera",unknown:"Unknown"}},message:{confirm_clear_log:"Are you sure you want to clear the log?",confirm_remove:"Are you sure you want to remove this camera?",confirm_remove_layout:"Are you sure you want to remove this layout?",confirm_reset_server:"Are you sure you want to reset the server?",confirm_restart_go2rtc:"Are you sure you want to restart the Go2RTC?",confirm_restart_plugin:"Are you sure you want to restart this plugin?",confirm_restart_server:"Are you sure you want to restart the server?",confirm_restore:"Are you sure you want to restore this backup?",confirm_uninstall_plugin:"Are you sure you want to uninstall this plugin?",intercom_info:"Speak simultaneously to all cameras that have intercom"},title:{config:"Configuration",confirm:"Confirm",create_new_user:"New user",edit_dnd:"Edit DND",edit_layout:"Edit layout",edit_user:"Edit user",edit_view:"Edit view",information:"Information",install:"Install",install_version:"Install version",intercom:"Intercom",log:"Log",new_dnd:"New DND",new_view:"New view",new_zone:"New zone",plugin_config:"Plugin config",preview:"Preview",remove_layout:"Remove layout",reset_server:"Reset server",restart:"Restart",result:"Result",search_plugin:"Search plugin",update:"Update",unknown:"Unknown",zone:"Zone",zone_editor:"Zone editor"}},form:{button:{add:"Add",add_source:"Add source",add_view:"Add view",back:"Back",cancel:"Cancel",change_view:"Change view",clear:"Clear",close:"Close",continue:"Continue",create_new_user:"Create new user",download:"Download",download_backup_archive:"Download backup archive",download_cert:"Download certificate",edit:"Edit",edit_zones:"Edit zones",finish:"Finish",go_to_message:"Go to message",home:"Home",install:"Install",login:"Login",logout:"Logout",logout_all:"Logout all",manage:"Manage",mark_as_read:"Mark as read",new:"New",new_zone:"New zone",next:"Next",open_editor:"Open editor",previous:"Previous",reinstall:"Reinstall",remove:"Remove",reset:"Reset",restart:"Restart",restore_backup_archive:"Restore backup archive",restore_and_restart:"Restore and restart",save:"Save",save_and_restart:"Save and restart",submit:"Submit",test_connection:"Test connection",update:"Update",undo:"Undo",uninstall:"Uninstall",upload:"Upload"},error:{no_cameras_selected:"No cameras selected",no_view_selected:"No view selected"},hint:{aspect_ratio:"Forces the camera aspect ratio to the selected value",cache_time:"Time in milliseconds used for the camera image cache",confidence:"The required confidence level for object detection",default_settings_page:"The default page shown when opening settings",disable_camera:"Deactivates the camera and stops all activities. The camera will still be displayed",frameworker_decoder:"The decoder used for the frame worker",frameworker_fps:"The number of frames per second used for the frame worker. '0' uses the native frame rate",frameworker_resolution:"The camera resolution used for the frame worker",hot_mode:"Keeps the connection to the camera active to minimize delay",motion_duration:"Time in seconds the camera needs to return to normal mode after motion detection",navbar_stay_collapsed:"Keeps the navbar collapsed, even on larger screens",remember_me:"Allows the session not to expire",session_timer:"Time in milliseconds before the session expires",show_bottombar_on_mobile:"Shows the bottom bar on mobile devices",show_camera_events:"Shows camera events in the camera view",single_session:"Allows only one active session per user",streaming_mode:"Stream transport protocol for the user interface. In 'auto' mode, the best mode is automatically selected",streaming_source:"Camera source for the stream. In 'auto' mode, the best source is automatically selected",system_preference:"System setting for the user interface",use_for_snapshot:"Uses this source for snapshots (if no other suitable source exists)"},label:{actions:"Actions",aspect_ratio:"Aspect ratio",audio_codec:"Audio codec",cache_time:"Cache time",camera:"Camera",cameras:"Cameras",changelog:"Changelog",classes:"Classes",color:"Color",confidence:"Confidence",connections:"Connections",custom_domain:"Custom domain",decoder:"Decoder",default_settings_page:"Default Settings page",disabled:"Disabled",enabled:"Enabled",firmware_version:"Firmware version",fps:"FPS",frame_worker:"Frame Worker",hardware_version:"Hardware version",hot_mode:"Hot mode",language:"Language",layout_name:"Layout name",manufacturer:"Manufacturer",model:"Model",motion_duration:"Motion duration",name:"Name",navbar_stay_collapsed:"Stay navbar collapsed",new_password:"New password",new_password_confirm:"Confirm new password",onvif_url:"ONVIF URL",password:"Password",pin:"PIN",plugin_version:"Plugin version",recording:"Recording",remember_me:"Remember me",remote_access_mode:"Remote access mode",remove_storage:"Remove storage",resolution:"Resolution",role:"Role",rtsp_url:"RTSP URL",select_all:"Select all",select_cameras:"Select cameras",serial_number:"Serial number",server_addresses:"Server addresses",server_version:"Server version",session_timer:"Session timer",settings:"Settings",show_bottombar_on_mobile:"Show bottombar on mobile",show_camera_events:"Show camera events",single_session:"Single Session",source:"Source",source_label:"Source label",source_name:"Source name",source_role:"Source role",sources:"Sources",snapshot_url:"Snapshot URL",streaming_mode:"Streaming mode",streaming_source:"Streaming source",support_url:"Support URL",system_preference:"System preference",theme:"Theme",type:"Type",url:"URL",use_for_snapshot:"Use for snapshot",username:"Username",version:"Version",video_codec:"Video codec",views:"Views",zone_name:"Zone name"},tooltip:{activity_mode_activity:"Activity",activity_mode_always_on:"Always On",activity_mode_standby:"Standby",clear:"Clear",contain:"Contain",copied:"Copied",delete:"Delete",disable_drag:"Disable drag",disabled:"Disabled",download:"Download",edit:"Edit",enable_drag:"Enable drag",exclude:"Exclude",finish:"Finish",fullscreen_off:"Fullscreen off",fullscreen_on:"Fullscreen on",hide_timeline:"Hide timeline",include:"Include",intercom:"Intercom",intersect:"Intersect",logout:"Logout",mode:"Mode",mute:"Mute",new:"New",privacy_mask:"Privacy mask",public_mask:"Public mask",resolution:"Resolution",restart:"Restart",show_timeline:"Show timeline",source_role_auto:"Auto",source_role_low:"Low Resolution",source_role_mid:"Mid Resolution",source_role_high:"High Resolution",source_role_snapshot:"Snapshot",source_role_unknown:"Unknown",streaming_mode_auto:"Auto",streaming_mode_mse:"MSE",streaming_mode_unknown:"Unknown",streaming_mode_webrtc:"WebRTC ",undo:"Undo",unmute:"Unmute",update_available:"Update available",zoom_in:"Zoom in",zoom_out:"Zoom out"}},notification_menu:{clear_notifications:"Clear notifications",debug:"Debug",error:"Error",info:"Info",no_notifications:"No notifications",notifications:"Notifications",short_days:"d",short_hours:"hr",short_minutes:"min",short_months:"mo",short_years:"yr",verbose:"Verbose",warn:"Warning"},options_sidebar:{segment_tab_default:"Default",segment_tab_overview:"Overview",segment_tab_plugins:"Plugins",segment_tab_settings:"Settings",segment_tab_sources:"Sources"},player:{add_shortcuts:"Add shortcuts",capture_snapshot:"Capture snapshot",activity_mode_activity:"Activity",activity_mode_always_on:"Always On",activity_mode_standby:"Standby",detections:"Detections",hide_shortcuts:"Hide shortcuts",hide_timeline:"Hide timeline",hide_zones:"Hide zones",live:"Live",log:"Log",ptz:"PTZ",ptz_go_to_home:"Go to home",reconnecting:"Reconnecting...",refresh_snapshot:"Refresh snapshot",save_shortcuts:"Save shortcuts",settings:"Settings",share_camera:"Share Camera",show_shortcuts:"Show shortcuts",show_timeline:"Show timeline",show_zones:"Show zones",source_role_auto:"Auto",source_role_low:"Low Resolution",source_role_mid:"Mid Resolution",source_role_high:"High Resolution",source_role_snapshot:"Snapshot",source_role_unknown:"Unknown",stream_paused:"Stream paused to conserve resources. Click on stream to resume.",streaming_mode_auto:"Auto",streaming_mode_mse:"MSE",streaming_mode_unknown:"Unknown",streaming_mode_webrtc:"WebRTC ",zoom_in:"Zoom in",zoom_out:"Zoom out"},plugin_card:{author:"Author",installed:"Installed",no_description:"No description available",restart:"Restart",select_version:"Select version",settings:"Settings",start:"Start",status_disabled:"Disabled",status_error:"Error",status_ready:"Ready",status_started:"Started",status_starting:"Starting",status_stopped:"Stopped",status_unknown:"Unknown",stop:"Stop",uninstall:"Uninstall",update:"Update",update_available:"Update available",updated:"Updated",version:"Version"},plugin_search:{plugins:"Plugins",refresh:"Refresh"},plugin_types:{hub:"Hub",cameraController:"Camera Controller",motionDetection:"Motion Detection",objectDetection:"Object Detection",audioDetection:"Audio Detection",ptz:"PTZ"},process_table:{status_error:"Error",status_ready:"Ready",status_started:"Started",status_starting:"Starting",status_stopped:"Stopped",status_stopping:"Stopping",status_unknown:"Unknown",system:"System",title_cpu:"CPU",title_cpu_load:"CPU load",title_memory:"Memory",title_memory_load:"Memory load",title_name:"Name",title_pid:"PID"},timeline:{live:"Live"},topbar:{syncing_data:"Syncing data..."},toast:{backup_downloaded:"Backup file download successfully",backup_restored:"Backup file restored successfully",camera_added:"Camera added successfully",camera_removed:"Camera removed successfully",camera_updated:"Camera updated successfully",cameras_removed:"Cameras removed successfully",config_deleted:"Configuration deleted successfully",config_go2rtc_deleted:"Go2RTC configuration deleted successfully",config_go2rtc_updated:"Go2RTC configuration updated successfully",config_updated:"Configuration updated successfully",error_see_console:"Error, see console",frame_worker_restarted:"Frame worker restarted successfully",go2rtc_restarted:"Go2RTC restarted successfully",log_cleared:"Log cleared successfully",no_version_selected:"No version selected",plugin_config_updated:"Plugin configuration updated successfully",plugin_disabled:"Plugin disabled successfully",plugin_enabled:"Plugin enabled successfully",plugin_installed:"Plugin installed successfully",plugin_removed:"Plugin removed successfully",plugin_request_sent:"Plugin request send successfully",plugin_restarted:"Plugin restarted successfully",plugin_settings_updated:"Plugin settings updated successfully",plugin_started:"Plugin started successfully",plugin_stopped:"Plugin stopped successfully",plugins_removed:"Plugins removed successfully",profile_updated:"Profile updated successfully",server_resetted:"Server resetted successfully",server_restarted:"Server restarted successfully",server_updated:"Server updated successfully",title_error:"Error",title_info:"Info",title_success:"Success",title_warn:"Warning",user_added:"User added successfully",user_logged_out:"User logged out successfully",user_removed:"User removed successfully",user_updated:"User updated successfully",users_removed:"Users removed successfully",validation_failed:"Validation failed. Check console for more information",view_added:"View added successfully",view_removed:"View removed successfully",view_updated:"View updated successfully",views_removed:"Views removed successfully",zone_updated:"Zone updated successfully",zone_removed:"Zone removed successfully"},upload_files:{drop_or_select_file:"Drop or select file",only_one_file_allowed:"Only one file allowed"},user_menu:{account:"Account",admin_panel:"Adminpanel",config:"Configuration",console:"Logs",logout:"Logout",plugins:"Plugins",reload:"Reload"},user_table:{title_address:"Address",title_device:"Device",title_username:"Username",you:"You"},view_box:{available_streams:"Available streams"},zone_editor:{edit_zones:"Zonen bearbeiten",zone:"Zone"}},general:{loading:"Loading...",role_admin:"Admin",role_user:"User"},navigation:{account:"Account",adminpanel:"Adminpanel",appearance:"Appearance",backup:"Backup",cameras:"Cameras",cammesh:"Cammesh",camview:"Camview",config:"Configuration",console:"Logs",extras:"Extras",nvr:"NVR",plugins:"Plugins",recordings:"Recordings",remote:"Remote Access",settings:"Settings",system:"System",user:"Users"},navigation_description:{account_description:"Manage account settings & experience.",appearance_description:"Manage app appearance & interface.",backup_description:"Manage, schedule backups & restore data.",nvr_description:"Manage Network Video Recorder system.",recordings_description:"Manage recordings & storage options.",remote_access_description:"Manage remote access and connection settings.",system_description:"Manage system, monitor status & tasks.",user_description:"Manage users, roles & permissions."},views:{404:{error_message:"We've looked everywhere, but this page seems to be playing hide and seek... and it's winning! Let's get you back to somewhere that exists."},adminpanel:{core:"Core",frameworker:"Frameworker",general:"General",logged_in_users:"Logged in users",plugins:"Plugins",title:"Adminpanel"},camera:{detections:"Detections",timeline:"Timeline",title:"Camera"},cameras:{add_camera:"Add camera",events:"Events",new_camera:"New camera",no_cameras:"No cameras available",title:"Cameras"},cammesh:{title:"Cammesh"},camview:{all_cameras:"All cameras",cameras:"Cameras",new_dnd:"New DND",new_view:"New View",no_dnds_configured:"No DNDs configured",no_views_configured:"No views configured",title:"Camview"},config:{title:"Configuration"},console:{title:"Logs"},firststeps:{complete:"Complete",enjoy:"Enjoy!",finish_message:"You have successfully completed the first steps. You can now start using the application.",from_backup:"Restore from Backup",new_installation:"New Installation",slogan:"The modern solution for professional video surveillance.",start:"Start",start_message:"Please choose whether you want to start a new installation or restore from a backup.",step_account:"Account",step_appearance:"Appearance",step_finish:"Finish",step_welcome:"Welcome",title:"First steps",welcome_to:"Welcome to"},login:{title:"Login"},plugin:{changelog:"Changelog",disabled_info:"Plugin is disabled",no_cameras:"No cameras available",no_changelog:"No changelog available",no_readme:"No readme available",plugin_is_disabled:"Plugin is disabled",readme:"Readme",segment_tab_cameras:"Cameras",segment_tab_interface:"Interface",segment_tab_plugins:"Plugins",segment_tab_settings:"Settings",settings:"Settings",title:"Plugin"},plugins:{no_plugins:"No plugins available",search_plugins:"Search plugins",title:"Plugins"},recordings:{title:"Recordings"},settings:{app:"App",available_updates:"Available updates",available_updates_info:"Updates are available for camera.ui.",certificate:"Certificate",certificate_info:"Download the SSL certificate of the website here. By adding this certificate to your keychain or certificate management, the site is recognized as secure. This improves the browser experience and avoids security warnings.",connection:"Connection",create_backup:"Create backup",create_backup_info:"Create a backup of the current configuration. Download a backup archive of your entire camera.ui environment. This will backup the contents of your camera.ui storage directory. You can restore this later on any platform where camera.ui is running.",edit:"Edit",interface:"Interface",locale:"Locale",network:"Network",network_info:"Configure here the IP addresses the server uses for WebRTC communication with the cameras. This setting allows for a stable and efficient connection between your system and the connected cameras.",not_available_updates_info:"You are using the latest version of camera.ui",password:"Password",profile:"Profile",registered_users:"Registered users",remote_access_info:"Configure the remote access settings here. These settings allow you to access your camera.ui environment from anywhere.",remote_access_settings:"Remote access settings",remove:"Remove",reset_server:"Reset server",reset_server_info:"By clicking this button you reset the configuration to the default values. This removes all your settings and data. This action cannot be undone.",restart_server:"Restart server",restart_server_info:"By clicking this button you restart the server. A loading screen will be displayed until the restart is complete. The page will then be automatically refreshed and available to you again.",restore_backup:"Restore backup",restore_backup_info:"Restore a backup archive you previously created with camera.ui. Your camera.ui configuration, database, user accounts, and media will be restored.",search_by_name:"Search by name",searching_updates:"Searching for updates...",server:"Server",sheduled_backup:"Sheduled backup",sheduled_backup_info:"Shedule a backup of the current configuration",status:"Status",theme:"Theme",title:"Settings",title_account:"Account",title_appearance:"Appearance",title_backup:"Backup",title_go2rtc:"Go2RTC",title_nvr:"NVR",title_recordings:"Recordings",title_remote:"Remote Access",title_system:"System",title_user:"User",unknown:"Unknown",update_available:"Update available",version:"Version"}}},sk={de:ek,en:tk},nk=["af","ar","ar-ae","ar-bh","ar-dz","ar-eg","ar-iq","ar-jo","ar-kw","ar-lb","ar-ly","ar-ma","ar-om","ar-qa","ar-sa","ar-sy","ar-tn","ar-ye","as","ast","az","be","bg","bn","br","bs","ca","ce","ch","co","cr","cs","cv","cy","da","de","de-at","de-ch","de-de","de-li","de-lu","el","en","en-au","en-bz","en-ca","en-gb","en-ie","en-jm","en-nz","en-ph","en-tt","en-us","en-za","en-zw","eo","es","es-ar","es-bo","es-cl","es-co","es-cr","es-do","es-ec","es-es","es-gt","es-hn","es-mx","es-ni","es-pa","es-pe","es-pr","es-py","es-sv","es-uy","es-ve","et","eu","fa","fa-ir","fi","fj","fo","fr","fr-be","fr-ca","fr-ch","fr-fr","fr-lu","fr-mc","fur","fy","ga","gd","gd-ie","gl","gu","he","hi","hr","hsb","ht","hu","hy","id","is","it","it-ch","iu","ja","ji","ka","kk","km","kn","ko","ko-kp","ko-kr","ks","ky","la","lb","lt","lv","mi","mk","ml","mo","mr","ms","mt","my","nb","ne","ng","nl","nl-be","nn","no","nv","oc","om","or","pa","pa-in","pa-pk","pl","pt","pt-br","qu","rm","ro","ro-mo","ru","ru-mo","sa","sb","sc","sd","sg","si","sk","sl","so","sq","sr","sv","sv-fi","sv-sv","sw","sx","sz","ta","te","th","tig","tk","tlh","tn","tr","ts","tt","uk","ur","ve","vi","vo","wa","xh","zh","zh-cn","zh-hk","zh-sg","zh-tw","zu"],xa="en",Cp=["de","en"],rk=s=>{var t;const e=n=>ik(nk.find(r=>r===(n==null?void 0:n.toLowerCase())));return(t=window.navigator)!=null&&t.language?e(window.navigator.language):e("en")},ik=s=>{if(!s)return xa;switch(s){case Cp.find(e=>e===s):return s;default:return xa}},ok=af({locale:rk(),fallbackLocale:xa,legacy:!1,globalInjection:!0,messages:sk}),ak={de:Cf,en:Sf},ck=Mi("locale",()=>{const s=el("locale",xa),e=ae(Cp),t=kf(),n=js();Ge(s,o=>{r(o),i(o)});const r=o=>{var a;(a=window.electron)==null||a.send("change-language",o),n.locale.value=o},i=async o=>{const a=ak[o];a&&(t.config.locale=a)};return r(s.value),i(s.value),{languages:e,locale:s,setI18Nlocale:r,setPrimeVueLocale:i}}),lk={key:1},uk=At({__name:"App",setup(s){const{navbarState:e,subbarState:t,showBottombar:n,showNavbar:r,showTopbar:i}=Na(),o=Ci(),a=$i(),l=qr(),u=Cn(),d=Ol(),h=cp(),v=Fs(),f=$l(),{mdBreakpoint:b}=Vr(),{isPWA:k}=Il(),{t:z}=js();ck();const{theme:L}=Vs(d),{routerLoading:se}=Vs(h),{isLoggedIn:K}=Vs(v),{isConnected:N}=Vs(f),E=Vt("navbarRef"),O=Vt("topbarRef"),U=Vt("bottombarRef"),S=ae(!0),M=ae(!0),B=Ls(),W=ae(!1),I=ae(!1),w=ri(E),Q=ri(O),J=ri(U);o.setDefaultOptions({queries:{refetchOnWindowFocus:!1,gcTime:5*60*1e3,staleTime:1e4,networkMode:"always",retry:(F,D)=>{var Y,Pe,He;if(D instanceof of&&((Y=D.response)==null?void 0:Y.status)===401)return Fs().logout(),!1;if(F===0){const ht=((He=(Pe=D.response)==null?void 0:Pe.data)==null?void 0:He.message)??D.message??D;u.add({severity:"error",summary:z("components.toast.title_error"),detail:ht,life:3e3}),console.error(ht)}return F<2}},mutations:{retry:0,networkMode:"always",onError:F=>{var Y,Pe,He,ht;const D=((Pe=(Y=F.response)==null?void 0:Y.data)==null?void 0:Pe.message)??F.message??F;u.add({severity:"error",summary:z("components.toast.title_error"),detail:D,life:3e3}),console.error(((ht=(He=F.response)==null?void 0:He.data)==null?void 0:ht.message)??F.message??F)}}});const q=ne(()=>{var Y,Pe;let F="var(--ground-background)";const D=Xs((Y=a==null?void 0:a.meta.ui)==null?void 0:Y.background);return(Pe=a==null?void 0:a.meta.ui)!=null&&Pe.showTopbar?F="var(--topbar-background)":D&&(F=D),F}),oe=ne(()=>{var Y,Pe;const F=O.value?`${Q.height.value}px`:"env(safe-area-inset-top, 0px)",D=U.value?`${J.height.value}px`:Xs((Pe=(Y=a.meta.ui)==null?void 0:Y.containerSettings)==null?void 0:Pe.ignoreSafeAreaBottom)?"0px":"env(safe-area-inset-bottom, 0px)";return k.value?`calc(100vh - ${F} - ${D})`:`calc(100dvh - ${F} - ${D})`}),ue=ne(()=>{var F;return((F=a.meta.auth)==null?void 0:F.requiresAuth)&&!K.value||S.value});Ge(M,(F,D)=>{D===!1&&F===!0&&o.refetchQueries()}),Ge(K,F=>{F?B.value=f.connect():(B.value=void 0,f.disconnect())},{immediate:!0}),Ge(N,F=>{K.value?M.value=F:M.value=!0}),Ge(se,F=>{const{isLoading:D}=nf(0,{parent:"body"});D.value=F},{immediate:!0}),Ge([q,L],()=>{Zs(()=>{var D,Y;if(/^var\([^)]+\)$/.test(q.value)){const Pe=window.getComputedStyle(document.body),He=q.value.split("var(")[1].split(")")[0],ht=Pe.getPropertyValue(He);(D=document.querySelector('meta[name="theme-color"]'))==null||D.setAttribute("content",ht)}else(Y=document.querySelector('meta[name="theme-color"]'))==null||Y.setAttribute("content",q.value)})},{immediate:!0}),Ge(a,F=>{var D,Y;Xs((Y=(D=F.meta.ui)==null?void 0:D.containerSettings)==null?void 0:Y.disableScroll)?(document.body.classList.add("disable-overflow-scroll"),document.documentElement.classList.add("disable-overflow-scroll")):(document.body.classList.remove("disable-overflow-scroll"),document.documentElement.classList.remove("disable-overflow-scroll"))},{immediate:!0,deep:!0});const Se=()=>{const F=document.querySelector('meta[name="electron-server"]'),D=F!==null&&F.getAttribute("content")==="true";W.value=window.electron!==void 0,I.value=D,setTimeout(()=>{W.value=window.electron!==void 0,I.value=D},100)};return Sn(async()=>{await l.isReady(),S.value=!1,Se()}),(F,D)=>{var wt,zt,nt,Xt,Be,Ue,V,X,_e,ye,fe;const Y=WC,Pe=O0,He=N0,ht=F0,Mt=VC,Qe=J5,ze=Fb,ge=Rb,ft=Ei("RouterView"),Yt=Wf;return c(ue)||!c(M)?(m(),A("div",{key:0,class:"flex w-full h-full justify-center items-center absolute z-50",style:ot({minHeight:c(k)?"100vh !important":"100dvh !important"})},[y(Y,{reload:"",icon:!c(M)&&c(K)?c(XC):void 0},null,8,["icon"])],4)):(m(),A("div",lk,[y(Pe,{position:"bottom-right"}),y(He),y(ht),y(Mt),c(i)?(m(),j(Qe,{key:0,ref_key:"topbarRef",ref:O,style:ot({left:c(b)?"0px":`${c(w).width.value}px`}),class:"z-2 top-0"},null,8,["style"])):ce("",!0),c(n)?(m(),j(ze,{key:1,ref_key:"bottombarRef",ref:U,class:"z-2"},null,512)):ce("",!0),c(r)?(m(),j(ge,{key:2,ref_key:"navbarRef",ref:E,class:"z-3 top-0 left-0"},null,512)):ce("",!0),g("main",{id:"container",class:"relative w-dvw z-1",style:ot({paddingTop:c(O)?`${c(Q).height.value}px`:"env(safe-area-inset-top, 0px)",paddingLeft:c(E)&&!c(b)?`${c(w).width.value}px`:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)",paddingBottom:c(U)?`${c(J).height.value}px`:("toValue"in F?F.toValue:c(Xs))((zt=(wt=F.$route.meta.ui)==null?void 0:wt.containerSettings)==null?void 0:zt.ignoreSafeAreaBottom)?"0px":"env(safe-area-inset-bottom, 0px)"})},[g("div",{class:at(["w-full max-w-full h-full grid",{"p-4":("toValue"in F?F.toValue:c(Xs))((Xt=(nt=F.$route.meta.ui)==null?void 0:nt.containerSettings)==null?void 0:Xt.padding)}]),style:ot({minHeight:c(oe),maxHeight:("toValue"in F?F.toValue:c(Xs))((Ue=(Be=F.$route.meta.ui)==null?void 0:Be.containerSettings)==null?void 0:Ue.disableScroll)?c(oe):void 0,height:("toValue"in F?F.toValue:c(Xs))((X=(V=F.$route.meta.ui)==null?void 0:V.containerSettings)==null?void 0:X.disableScroll)?c(oe):void 0,overflow:("toValue"in F?F.toValue:c(Xs))((ye=(_e=F.$route.meta.ui)==null?void 0:_e.containerSettings)==null?void 0:ye.disableScroll)?"hidden":void 0})},[y(ft,{class:"w-full h-full relative overflow-x-hidden"})],6)],4),c(W)?(m(),j(Yt,{key:3})):ce("",!0),c(e)==="opened"||c(t)==="opened"&&c(b)?(m(),j(Uh,{key:4,to:c(e)==="opened"?"#app":"#container",defer:""},[c(b)?(m(),A("div",{key:0,class:at(["fixed top-0 left-0 right-0 bottom-0 w-full h-full bg-black/50 z-1",{"z-2":c(e)==="opened"}])},null,2)):ce("",!0)],8,["to"])):ce("",!0),g("div",{class:"fixed-bg",style:ot({background:("toValue"in F?F.toValue:c(Xs))((fe=F.$route.meta.ui)==null?void 0:fe.background)})},null,4)]))}}}),dk=qs(uk,[["__scopeId","data-v-6277ff0b"]]),hk=cf(),mk=Af(Mf,{primitive:{borderRadius:{none:"0",xs:"2px",sm:"4px",md:"6px",lg:"8px",xl:"12px"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"}},semantic:{transitionDuration:"0.2s",focusRing:{width:"1px",style:"solid",color:"{primary.color}",offset:"2px",shadow:"none"},disabledOpacity:"0.6",iconSize:"1rem",anchorGutter:"2px",primary:{50:"#fdf4f6",100:"#f7ccd4",200:"#f1a3b2",300:"#eb7b90",400:"#e5526e",500:"#df2a4c",600:"#be2441",700:"#9c1d35",800:"#7b172a",900:"#59111e",950:"#380b13"},formField:{paddingX:"0.75rem",paddingY:"0.5rem",sm:{fontSize:"0.875rem",paddingX:"0.625rem",paddingY:"0.375rem"},lg:{fontSize:"1.125rem",paddingX:"0.875rem",paddingY:"0.625rem"},borderRadius:"{border.radius.md}",focusRing:{width:"0",style:"none",color:"transparent",offset:"0",shadow:"none"},transitionDuration:"{transition.duration}"},list:{padding:"0.25rem 0.25rem",gap:"2px",header:{padding:"0.5rem 1rem 0.25rem 1rem"},option:{padding:"0.5rem 0.75rem",borderRadius:"{border.radius.sm}"},optionGroup:{padding:"0.5rem 0.75rem",fontWeight:"600"}},content:{borderRadius:"{border.radius.md}"},mask:{transitionDuration:"0.15s"},navigation:{list:{padding:"0.25rem 0.25rem",gap:"2px"},item:{padding:"0.5rem 0.75rem",borderRadius:"{border.radius.sm}",gap:"0.5rem"},submenuLabel:{padding:"0.5rem 0.75rem",fontWeight:"600"},submenuIcon:{size:"0.875rem"}},overlay:{select:{borderRadius:"{border.radius.md}",shadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)"},popover:{borderRadius:"{border.radius.md}",padding:"0.75rem",shadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)"},modal:{borderRadius:"{border.radius.xl}",padding:"1.25rem",shadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"},navigation:{shadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)"}},colorScheme:{light:{surface:{0:"#ffffff",50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",850:"#0f172a",900:"#0f172a",925:"#0c1421",950:"#020617",1e3:"#000000"},primary:{color:"{primary.500}",contrastColor:"#ffffff",hoverColor:"{primary.600}",activeColor:"{primary.700}"},highlight:{background:"{primary.50}",focusBackground:"{primary.100}",color:"{primary.700}",focusColor:"{primary.800}"},mask:{background:"rgba(0,0,0,0.4)",color:"{surface.200}"},formField:{background:"{surface.50}",disabledBackground:"{surface.200}",filledBackground:"{surface.50}",filledHoverBackground:"{surface.50}",filledFocusBackground:"{surface.50}",borderColor:"{surface.300}",hoverBorderColor:"{surface.400}",focusBorderColor:"{primary.color}",invalidBorderColor:"{red.400}",color:"{surface.700}",disabledColor:"{surface.500}",placeholderColor:"{surface.500}",invalidPlaceholderColor:"{red.600}",floatLabelColor:"{surface.500}",floatLabelFocusColor:"{primary.600}",floatLabelActiveColor:"{surface.500}",floatLabelInvalidColor:"{form.field.invalid.placeholder.color}",iconColor:"{surface.400}",shadow:"0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgba(18, 18, 23, 0.05)"},text:{color:"{surface.700}",hoverColor:"{surface.800}",mutedColor:"{surface.500}",hoverMutedColor:"{surface.600}"},content:{background:"{surface.0}",hoverBackground:"{surface.100}",borderColor:"{surface.200}",color:"{text.color}",hoverColor:"{text.hover.color}"},overlay:{select:{background:"{surface.0}",borderColor:"{surface.200}",color:"{text.color}"},popover:{background:"{surface.0}",borderColor:"{surface.200}",color:"{text.color}"},modal:{background:"{surface.0}",borderColor:"{surface.200}",color:"{text.color}"}},list:{option:{focusBackground:"{surface.100}",selectedBackground:"{highlight.background}",selectedFocusBackground:"{highlight.focus.background}",color:"{text.color}",focusColor:"{text.hover.color}",selectedColor:"{highlight.color}",selectedFocusColor:"{highlight.focus.color}",icon:{color:"{surface.400}",focusColor:"{surface.500}"}},optionGroup:{background:"transparent",color:"{text.muted.color}"}},navigation:{item:{focusBackground:"{surface.100}",activeBackground:"{surface.100}",color:"{text.color}",focusColor:"{text.hover.color}",activeColor:"{text.hover.color}",icon:{color:"{surface.400}",focusColor:"{surface.500}",activeColor:"{surface.500}"}},submenuLabel:{background:"transparent",color:"{text.muted.color}"},submenuIcon:{color:"{surface.400}",focusColor:"{surface.500}",activeColor:"{surface.500}"}}},dark:{surface:{0:"#ffffff",50:"#f5f5f5",100:"#d1d1d1",200:"#adadad",300:"#898989",400:"#646464",500:"#404040",600:"#363636",700:"#2d2d2d",800:"#232323",850:"#1d1d1d",900:"#1a1a1a",925:"#161616",950:"#101010",1e3:"#0d0d0d"},primary:{color:"{primary.500}",contrastColor:"{surface.900}",hoverColor:"{primary.600}",activeColor:"{primary.700}"},highlight:{background:"color-mix(in srgb, {primary.400}, transparent 84%)",focusBackground:"color-mix(in srgb, {primary.400}, transparent 76%)",color:"rgba(255,255,255,.87)",focusColor:"rgba(255,255,255,.87)"},mask:{background:"rgba(0,0,0,0.6)",color:"{surface.200}"},formField:{background:"{surface.925}",disabledBackground:"{surface.700}",filledBackground:"{surface.800}",filledHoverBackground:"{surface.800}",filledFocusBackground:"{surface.800}",borderColor:"{surface.800}",hoverBorderColor:"{surface.500}",focusBorderColor:"{primary.color}",invalidBorderColor:"{red.300}",color:"{surface.0}",disabledColor:"{surface.400}",placeholderColor:"{surface.400}",invalidPlaceholderColor:"{red.400}",floatLabelColor:"{surface.400}",floatLabelFocusColor:"{primary.color}",floatLabelActiveColor:"{surface.400}",floatLabelInvalidColor:"{form.field.invalid.placeholder.color}",iconColor:"{surface.400}",shadow:"0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgba(18, 18, 23, 0.05)"},text:{color:"{surface.0}",hoverColor:"{surface.0}",mutedColor:"{surface.400}",hoverMutedColor:"{surface.300}"},content:{background:"{surface.900}",hoverBackground:"{surface.800}",borderColor:"{surface.700}",color:"{text.color}",hoverColor:"{text.hover.color}"},overlay:{select:{background:"{surface.900}",borderColor:"{surface.700}",color:"{text.color}"},popover:{background:"{surface.900}",borderColor:"{surface.700}",color:"{text.color}"},modal:{background:"{surface.900}",borderColor:"{surface.700}",color:"{text.color}"}},list:{option:{focusBackground:"{surface.800}",selectedBackground:"{highlight.background}",selectedFocusBackground:"{highlight.focus.background}",color:"{text.color}",focusColor:"{text.hover.color}",selectedColor:"{highlight.color}",selectedFocusColor:"{highlight.focus.color}",icon:{color:"{surface.500}",focusColor:"{surface.400}"}},optionGroup:{background:"transparent",color:"{text.muted.color}"}},navigation:{item:{focusBackground:"{surface.800}",activeBackground:"{surface.800}",color:"{text.color}",focusColor:"{text.hover.color}",activeColor:"{text.hover.color}",icon:{color:"{surface.500}",focusColor:"{surface.400}",activeColor:"{surface.400}"}},submenuLabel:{background:"transparent",color:"{text.muted.color}"},submenuIcon:{color:"{surface.500}",focusColor:"{surface.400}",activeColor:"{surface.400}"}}}}}}),pk=()=>{const s=V0(dk);return s.directive("tooltip",jr),s.use(Oa).use(hk).use(ok).use(L0).use(j0).use(q0).use(Ef,{theme:{preset:mk,options:{cssLayer:{name:"primevue",order:"theme, base, primevue"},darkModeSelector:".dark-mode"}}}).use(k0),s},fk=pk();fk.mount("#app");export{Bi as $,y4 as A,Ib as B,Jn as C,dp as D,d9 as E,up as F,J6 as G,e8 as H,H8 as I,q8 as J,z8 as K,ex as L,h8 as M,J8 as N,hx as O,lx as P,ox as Q,nx as R,wa as S,Z5 as T,M_ as U,q4 as V,k4 as W,x4 as X,g4 as Y,i9 as Z,Ia as _,Rl as a,o9 as a0,Ol as a1,vs as a2,Ie as a3,gp as a4,my as a5,y6 as a6,lh as a7,ah as a8,ih as a9,uh as aa,ch as ab,hh as ac,_p as ad,xp as ae,Um as af,k3 as ag,c9 as ah,ld as ai,zc as aj,Ay as ak,n9 as al,Pl as am,lo as an,u9 as ao,Vm as ap,r9 as aq,ck as ar,h9 as as,l9 as at,a9 as au,Si as b,Cn as c,xi as d,Il as e,$l as f,Fr as g,Vr as h,vo as i,Bc as j,f9 as k,p9 as l,a3 as m,vp as n,m9 as o,wp as p,Tl as q,T_ as r,$_ as s,Na as t,Fs as u,xh as v,Nl as w,Cl as x,Sp as y,qs as z};