camera.ui3 0.0.31-alpha.9 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/interface/@intlify.8z0ZxsCR.0.0.31-alpha.9.js +15 -0
  2. package/dist/interface/{@mdi.DVdKciOk.0.0.31-alpha.9.js → @mdi.CBFP0hLg.0.0.31-alpha.9.js} +1 -1
  3. package/dist/interface/{@tanstack.DiO-YfND.0.0.31-alpha.9.js → @tanstack.Btgptvlr.0.0.31-alpha.9.js} +1 -1
  4. package/dist/interface/{@vee-validate.BcQFNWZE.0.0.31-alpha.9.js → @vee-validate.D1idmuLl.0.0.31-alpha.9.js} +1 -1
  5. package/dist/interface/@vue.DSpVzvLE.0.0.31-alpha.9.js +17 -0
  6. package/dist/interface/{@vueform.CY_hGye7.0.0.31-alpha.9.js → @vueform.DRS8F1ON.0.0.31-alpha.9.js} +1 -1
  7. package/dist/interface/{@vueuse.9BxRKi-L.0.0.31-alpha.9.js → @vueuse.lQHIM9Ji.0.0.31-alpha.9.js} +1 -1
  8. package/dist/interface/Account.CWYwYkAb.0.0.31-alpha.9.js +1 -0
  9. package/dist/interface/Adminpanel.Dn_K3XUd.0.0.31-alpha.9.js +2 -0
  10. package/dist/interface/Appearance.DLb__Sif.0.0.31-alpha.9.js +1 -0
  11. package/dist/interface/Backup.Dt3JgVrT.0.0.31-alpha.9.js +1 -0
  12. package/dist/interface/Camera.4AeJvhsq.0.0.31-alpha.9.js +1 -0
  13. package/dist/interface/Cameras.CGeE3KOM.0.0.31-alpha.9.js +1 -0
  14. package/dist/interface/Camview.sGBSah9x.0.0.31-alpha.9.js +1 -0
  15. package/dist/interface/Config.Bv2WgErD.0.0.31-alpha.9.js +1 -0
  16. package/dist/interface/Console.DGg2Jq9h.0.0.31-alpha.9.js +4 -0
  17. package/dist/interface/FirstSteps.DvByehg0.0.0.31-alpha.9.js +1 -0
  18. package/dist/interface/{NewCamera.9oVueNXm.0.0.31-alpha.9.js → NewCamera.BIyRmkan.0.0.31-alpha.9.js} +2 -2
  19. package/dist/interface/Plugin.DcUILrgC.0.0.31-alpha.9.js +1 -0
  20. package/dist/interface/Plugins.vo7Mx2j4.0.0.31-alpha.9.js +1 -0
  21. package/dist/interface/Recordings.CJUoi8qm.0.0.31-alpha.9.js +1 -0
  22. package/dist/interface/Recordings.N4AMYLOy.0.0.31-alpha.9.js +1 -0
  23. package/dist/interface/Settings.D8b47k9p.0.0.31-alpha.9.js +1 -0
  24. package/dist/interface/System.otwybl-J.0.0.31-alpha.9.js +4 -0
  25. package/dist/interface/User.BtRFc2QZ.0.0.31-alpha.9.js +1 -0
  26. package/dist/interface/{VConfigEditor.vue_vue_type_script_setup_true_lang.BAYmotSN.0.0.31-alpha.9.js → VConfigEditor.vue_vue_type_script_setup_true_lang.BMJS_7ZD.0.0.31-alpha.9.js} +1 -1
  27. package/dist/interface/{VConsole.BpaR5IBq.0.0.31-alpha.9.js → VConsole.CuO-3hA4.0.0.31-alpha.9.js} +1 -1
  28. package/dist/interface/VPlayer.Dqk3IaYl.0.0.31-alpha.9.js +1 -0
  29. package/dist/interface/{VPluginCard.C3zVPPxc.0.0.31-alpha.9.js → VPluginCard.DI974_rR.0.0.31-alpha.9.js} +1 -1
  30. package/dist/interface/assets/{Camera.0.0.31-alpha.9.BDtUJ-lA.css → Camera.0.0.31-alpha.9.Dz_0ZY4W.css} +1 -1
  31. package/dist/interface/assets/{VPlayer.0.0.31-alpha.9.DL-vUJg6.css → VPlayer.0.0.31-alpha.9.hKi0NXFe.css} +1 -1
  32. package/dist/interface/assets/{main.0.0.31-alpha.9.DVYbSD6m.css → main.0.0.31-alpha.9.ZRChory7.css} +1 -1
  33. package/dist/interface/engine.io-client.BzMoog8q.0.0.31-alpha.9.js +1 -0
  34. package/dist/interface/index.html +18 -19
  35. package/dist/interface/main.-w4XIAj8.0.0.31-alpha.9.js +4 -0
  36. package/dist/interface/{pinia.CtdBjRVP.0.0.31-alpha.9.js → pinia.CMvEC38j.0.0.31-alpha.9.js} +1 -1
  37. package/dist/interface/{plugins.Bkal5GEl.0.0.31-alpha.9.js → plugins.bQCZbo8M.0.0.31-alpha.9.js} +1 -1
  38. package/dist/interface/socket.io-client.HSZfpHWX.0.0.31-alpha.9.js +1 -0
  39. package/dist/interface/sw.js +1 -1
  40. package/dist/interface/{system.DW1v9qpo.0.0.31-alpha.9.js → system.Bg0Mnh8C.0.0.31-alpha.9.js} +1 -1
  41. package/dist/interface/{v-calendar.CpGjgKe5.0.0.31-alpha.9.js → v-calendar.C6y6UX0U.0.0.31-alpha.9.js} +1 -1
  42. package/dist/interface/{vee-validate.BMToAU75.0.0.31-alpha.9.js → vee-validate.EBXl7pXZ.0.0.31-alpha.9.js} +1 -1
  43. package/dist/interface/vue-i18n.BxvFdZfG.0.0.31-alpha.9.js +5 -0
  44. package/dist/interface/{vue-inline-svg.pmg4fXNu.0.0.31-alpha.9.js → vue-inline-svg.DryJfuXO.0.0.31-alpha.9.js} +1 -1
  45. package/dist/interface/{vue-router.D52Gr9tg.0.0.31-alpha.9.js → vue-router.tZAYeGmk.0.0.31-alpha.9.js} +1 -1
  46. package/dist/interface/{vue3-apexcharts.BmV4BSAH.0.0.31-alpha.9.js → vue3-apexcharts.z9tPv-7C.0.0.31-alpha.9.js} +1 -1
  47. package/dist/interface/{vue3-dnd.CZCIjzeJ.0.0.31-alpha.9.js → vue3-dnd.CjEEXgGE.0.0.31-alpha.9.js} +1 -1
  48. package/dist/interface/{vue3-toastify.61dIcR4V.0.0.31-alpha.9.js → vue3-toastify.DRSIlF3j.0.0.31-alpha.9.js} +1 -1
  49. package/dist/interface/{vuetify.Bil1YTHi.0.0.31-alpha.9.js → vuetify.C_HFG9xV.0.0.31-alpha.9.js} +1 -1
  50. package/dist/server/bin/cameraui.d.ts +1 -0
  51. package/dist/server/bin/cameraui.js +3 -1
  52. package/dist/server/bin/cameraui.js.map +1 -1
  53. package/dist/server/bin/logger.d.ts +2 -1
  54. package/dist/server/bin/logger.js +17 -15
  55. package/dist/server/bin/logger.js.map +1 -1
  56. package/dist/server/package.json +10 -10
  57. package/dist/server/src/api/controllers/cameras.controller.d.ts +2 -2
  58. package/dist/server/src/api/controllers/cameras.controller.js +1 -1
  59. package/dist/server/src/api/controllers/cameras.controller.js.map +1 -1
  60. package/dist/server/src/api/controllers/plugins.controller.js +2 -2
  61. package/dist/server/src/api/controllers/plugins.controller.js.map +1 -1
  62. package/dist/server/src/api/database/index.d.ts +1 -1
  63. package/dist/server/src/api/database/index.js +1 -1
  64. package/dist/server/src/api/database/migration.js +11 -0
  65. package/dist/server/src/api/database/migration.js.map +1 -1
  66. package/dist/server/src/api/database/types.d.ts +2 -1
  67. package/dist/server/src/api/go2rtc/api/streams.d.ts +1 -1
  68. package/dist/server/src/api/go2rtc/types.d.ts +2 -18
  69. package/dist/server/src/api/schemas/cameras.schema.d.ts +14 -0
  70. package/dist/server/src/api/schemas/cameras.schema.js +3 -0
  71. package/dist/server/src/api/schemas/cameras.schema.js.map +1 -1
  72. package/dist/server/src/api/types/index.d.ts +7 -0
  73. package/dist/server/src/api/websocket/nsp/server.d.ts +8 -3
  74. package/dist/server/src/api/websocket/nsp/server.js +51 -22
  75. package/dist/server/src/api/websocket/nsp/server.js.map +1 -1
  76. package/dist/server/src/nats/websocket.js +5 -5
  77. package/package.json +10 -10
  78. package/dist/interface/@camera.ui.5tgIM73-.0.0.31-alpha.9.js +0 -3
  79. package/dist/interface/@intlify.Jdj6PDCT.0.0.31-alpha.9.js +0 -19
  80. package/dist/interface/@vue.FH56CEei.0.0.31-alpha.9.js +0 -17
  81. package/dist/interface/Account.ClNqrEzq.0.0.31-alpha.9.js +0 -1
  82. package/dist/interface/Adminpanel.EgJtOipv.0.0.31-alpha.9.js +0 -2
  83. package/dist/interface/Appearance.Bd_De-AN.0.0.31-alpha.9.js +0 -1
  84. package/dist/interface/Backup.DJHIFHH5.0.0.31-alpha.9.js +0 -1
  85. package/dist/interface/Camera.DtJ7F2vx.0.0.31-alpha.9.js +0 -1
  86. package/dist/interface/Cameras.C6Jw9DBM.0.0.31-alpha.9.js +0 -1
  87. package/dist/interface/Camview.D-kKkkwH.0.0.31-alpha.9.js +0 -1
  88. package/dist/interface/Config.tNTb0Q1P.0.0.31-alpha.9.js +0 -1
  89. package/dist/interface/Console.5zJr03Pu.0.0.31-alpha.9.js +0 -4
  90. package/dist/interface/FirstSteps.Dv-f7Q30.0.0.31-alpha.9.js +0 -1
  91. package/dist/interface/Plugin.MmkX88gY.0.0.31-alpha.9.js +0 -1
  92. package/dist/interface/Plugins.C4zCniN8.0.0.31-alpha.9.js +0 -1
  93. package/dist/interface/Recordings.CNdtF6ac.0.0.31-alpha.9.js +0 -1
  94. package/dist/interface/Recordings.D8wI1lYM.0.0.31-alpha.9.js +0 -1
  95. package/dist/interface/Settings.DQNCNI65.0.0.31-alpha.9.js +0 -1
  96. package/dist/interface/System.BH3d2wgd.0.0.31-alpha.9.js +0 -4
  97. package/dist/interface/User.KszaeyZA.0.0.31-alpha.9.js +0 -1
  98. package/dist/interface/VPlayer.BARBY2Yl.0.0.31-alpha.9.js +0 -1
  99. package/dist/interface/engine.io-client.AS8grqwl.0.0.31-alpha.9.js +0 -1
  100. package/dist/interface/main.qn-1EUvn.0.0.31-alpha.9.js +0 -2
  101. package/dist/interface/socket.io-client.BgnB__Bp.0.0.31-alpha.9.js +0 -1
  102. package/dist/interface/vue-i18n.bhUkliEa.0.0.31-alpha.9.js +0 -9
@@ -1,3 +0,0 @@
1
- var Tt=Object.defineProperty;var Ot=(r,t,e)=>t in r?Tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>Ot(r,typeof t!="symbol"?t+"":t,e);var Ct={855:r=>{const t=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,e=()=>t.now(),s=i=>i===1/0||(o=>o&&o===Math.floor(o)&&o>0&&isFinite(o))(i);class n{constructor({max:o=1/0,ttl:a,updateAgeOnGet:c=!1,checkAgeOnGet:u=!1,noUpdateTTL:h=!1,dispose:l,noDisposeOnSet:g=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,a!==void 0&&!s(a))throw new TypeError("ttl must be positive integer or Infinity if set");if(!s(o))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=a,this.max=o,this.updateAgeOnGet=!!c,this.checkAgeOnGet=!!u,this.noUpdateTTL=!!h,this.noDisposeOnSet=!!g,l!==void 0){if(typeof l!="function")throw new TypeError("dispose must be function if set");this.dispose=l}this.timer=void 0,this.timerExpiration=void 0}setTimer(o,a){if(this.timerExpiration<o)return;this.timer&&clearTimeout(this.timer);const c=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(const u in this.expirations){this.setTimer(u,u-e());break}},a);c.unref&&c.unref(),this.timerExpiration=o,this.timer=c}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!==n.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(const[a,c]of o)this.dispose(c,a,"delete")}setTTL(o,a=this.ttl){const c=this.expirationMap.get(o);if(c!==void 0){const u=this.expirations[c];!u||u.length<=1?delete this.expirations[c]:this.expirations[c]=u.filter(h=>h!==o)}if(a!==1/0){const u=Math.floor(e()+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:c=this.ttl,noUpdateTTL:u=this.noUpdateTTL,noDisposeOnSet:h=this.noDisposeOnSet}={}){if(!s(c))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(o)){u||this.setTTL(o,c);const l=this.data.get(o);l!==a&&(this.data.set(o,a),h||this.dispose(l,o,"set"))}else this.setTTL(o,c),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-e())):0}get(o,{updateAgeOnGet:a=this.updateAgeOnGet,ttl:c=this.ttl,checkAgeOnGet:u=this.checkAgeOnGet}={}){const h=this.data.get(o);if(!u||this.getRemainingTTL(o)!==0)return a&&this.setTTL(o,c),h;this.delete(o)}dispose(o,a){}delete(o){const a=this.expirationMap.get(o);if(a!==void 0){const c=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(h=>h!==o)),this.dispose(c,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 c=this.size-this.max,u=[];for(const h of a.splice(0,c))u.push([h,this.data.get(h)]),this.data.delete(h),this.expirationMap.delete(h);for(const[h,l]of u)this.dispose(l,h,"evict");return}{delete this.expirations[o];const c=[];for(const u of a)c.push([u,this.data.get(u)]),this.data.delete(u),this.expirationMap.delete(u);for(const[u,h]of c)this.dispose(h,u,"evict")}}}get size(){return this.data.size}purgeStale(){const o=Math.ceil(e());for(const a in this.expirations){if(a==="Infinity"||a>o)return;const c=[...this.expirations[a]||[]],u=[];delete this.expirations[a];for(const h of c)u.push([h,this.data.get(h)]),this.data.delete(h),this.expirationMap.delete(h);for(const[h,l]of u)this.dispose(l,h,"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()}}r.exports=n}},Pe={};function O(r){var t=Pe[r];if(t!==void 0)return t.exports;var e=Pe[r]={exports:{}};return Ct[r](e,e.exports,O),e.exports}O.n=r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return O.d(t,{a:t}),t},O.d=(r,t)=>{for(var e in t)O.o(t,e)&&!O.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})},O.o=(r,t)=>Object.prototype.hasOwnProperty.call(r,t),O.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var st={};O.d(st,{j:()=>_s});var we={};O.r(we),O.d(we,{Decoder:()=>je,Encoder:()=>ws,PacketType:()=>b,protocol:()=>vs});class At{constructor(t){p(this,"baseURL");p(this,"abortControllers",new Set);this.baseURL=`${t}/api`}async request(t,e,s,n={}){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}${e}`,{method:t,headers:{"Content-Type":"application/json",...n.headers},body:s?JSON.stringify(s):void 0,signal:i.signal,...n});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a}finally{clearTimeout(o),this.abortControllers.delete(i)}}get(t,e){return this.request("GET",t,void 0,e)}post(t,e,s){return this.request("POST",t,e,s)}}class Rt{constructor(){p(this,"subscriptions",[]);p(this,"additionalSubscriptions",[])}addSubscriptions(...t){this.subscriptions.push(...t)}addAdditionalSubscriptions(...t){this.additionalSubscriptions.push(...t)}unsubscribe(){this.subscriptions.forEach(t=>t.unsubscribe())}unsubscribeAdditional(){this.additionalSubscriptions.forEach(t=>t.unsubscribe())}}function U(r,t,e=!1){if(r===t)return!0;if((r===void 0||t===void 0||r===null||t===null)&&(r||t))return!1;const s=r==null?void 0:r.constructor.name,n=t==null?void 0:t.constructor.name;if(s!==n)return!1;if(s==="Array"&&n==="Array"){if(r.length!==t.length)return!1;if(e){const i=[...t];return r.every(o=>{const a=i.findIndex(c=>U(o,c,e));return a!==-1&&(i.splice(a,1),!0)})}{let i=!0;for(let o=0;o<r.length;o++)if(!U(r[o],t[o],e)){i=!1;break}return i}}if(s==="Object"&&n==="Object"){let i=!0;const o=Object.keys(r),a=Object.keys(t);if(o.length!==a.length)return!1;for(let c=0;c<o.length;c++)if(r[o[c]]&&t[o[c]]){if(r[o[c]]===t[o[c]])continue;if(!r[o[c]]||r[o[c]].constructor.name!=="Array"&&r[o[c]].constructor.name!=="Object"){if(r[o[c]]!==t[o[c]]){i=!1;break}}else if(i=U(r[o[c]],t[o[c]],e),!i)break}else if(r[o[c]]&&!t[o[c]]||!r[o[c]]&&t[o[c]]){i=!1;break}return i}return r===t}function C(r){return JSON.parse(JSON.stringify(r))}var Bt=O(855),Lt=O.n(Bt),Se=function(r,t){return Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,s){e.__proto__=s}||function(e,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])},Se(r,t)};function q(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=r}Se(r,t),r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function rt(r,t){var e,s,n,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[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(c){return function(u){return function(h){if(e)throw new TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(i=0)),i;)try{if(e=1,s&&(n=2&h[0]?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[2&h[0],n.value]),h[0]){case 0:case 1:n=h;break;case 4:return i.label++,{value:h[1],done:!1};case 5:i.label++,s=h[1],h=[0];continue;case 7:h=i.ops.pop(),i.trys.pop();continue;default:if(!((n=(n=i.trys).length>0&&n[n.length-1])||h[0]!==6&&h[0]!==2)){i=0;continue}if(h[0]===3&&(!n||h[1]>n[0]&&h[1]<n[3])){i.label=h[1];break}if(h[0]===6&&i.label<n[1]){i.label=n[1],n=h;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(h);break}n[2]&&i.ops.pop(),i.trys.pop();continue}h=t.call(r,i)}catch(l){h=[6,l],s=0}finally{e=n=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([c,u])}}}function z(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],s=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&s>=r.length&&(r=void 0),{value:r&&r[s++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function se(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var s,n,i=e.call(r),o=[];try{for(;(t===void 0||t-- >0)&&!(s=i.next()).done;)o.push(s.value)}catch(a){n={error:a}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(n)throw n.error}}return o}function re(r,t,e){if(arguments.length===2)for(var s,n=0,i=t.length;n<i;n++)!s&&n in t||(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return r.concat(s||Array.prototype.slice.call(t))}function N(r){return this instanceof N?(this.v=r,this):new N(r)}function E(r){return typeof r=="function"}function nt(r){var t=r(function(e){Error.call(e),e.stack=new Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ue=nt(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
2
- `+t.map(function(e,s){return s+1+") "+e.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function ke(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var oe=function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,s,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=z(o),c=a.next();!c.done;c=a.next())c.value.remove(this)}catch(d){t={error:d}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var u=this.initialTeardown;if(E(u))try{u()}catch(d){i=d instanceof ue?d.errors:[d]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var l=z(h),g=l.next();!g.done;g=l.next()){var y=g.value;try{Me(y)}catch(d){i=i??[],d instanceof ue?i=re(re([],se(i)),se(d.errors)):i.push(d)}}}catch(d){s={error:d}}finally{try{g&&!g.done&&(n=l.return)&&n.call(l)}finally{if(s)throw s.error}}}if(i)throw new ue(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Me(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&ke(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&ke(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=function(){var t=new r;return t.closed=!0,t}(),r}(),it=oe.EMPTY;function ot(r){return r instanceof oe||r&&"closed"in r&&E(r.remove)&&E(r.add)&&E(r.unsubscribe)}function Me(r){E(r)?r():r.unsubscribe()}var at={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},jt={setTimeout:function(r,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];return setTimeout.apply(void 0,re([r,t],se(e)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function ct(r){jt.setTimeout(function(){throw r})}function De(){}function Z(r){r()}var Be=function(r){function t(e){var s=r.call(this)||this;return s.isStopped=!1,e?(s.destination=e,ot(e)&&e.add(s)):s.destination=Dt,s}return q(t,r),t.create=function(e,s,n){return new H(e,s,n)},t.prototype.next=function(e){this.isStopped?void 0:this._next(e)},t.prototype.error=function(e){this.isStopped?void 0:(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?void 0:(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(oe),Pt=Function.prototype.bind;function le(r,t){return Pt.call(r,t)}var Mt=function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(s){Y(s)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){Y(s)}else Y(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Y(e)}},r}(),H=function(r){function t(e,s,n){var i,o,a=r.call(this)||this;return E(e)||!e?i={next:e??void 0,error:s??void 0,complete:n??void 0}:a&&at.useDeprecatedNextContext?((o=Object.create(e)).unsubscribe=function(){return a.unsubscribe()},i={next:e.next&&le(e.next,o),error:e.error&&le(e.error,o),complete:e.complete&&le(e.complete,o)}):i=e,a.destination=new Mt(i),a}return q(t,r),t}(Be);function Y(r){ct(r)}var Dt={closed:!0,next:De,error:function(r){throw r},complete:De},xe=typeof Symbol=="function"&&Symbol.observable||"@@observable";function qt(r){return r}var M=function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,s){var n=this,i=function(o){return o&&o instanceof Be||function(a){return a&&E(a.next)&&E(a.error)&&E(a.complete)}(o)&&ot(o)}(t)?t:new H(t,e,s);return Z(function(){var o=n,a=o.operator,c=o.source;i.add(a?a.call(i,c):c?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var s=this;return new(e=qe(e))(function(n,i){var o=new H({next:function(a){try{t(a)}catch(c){i(c),o.unsubscribe()}},error:i,complete:n});s.subscribe(o)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[xe]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return((s=t).length===0?qt:s.length===1?s[0]:function(n){return s.reduce(function(i,o){return o(i)},n)})(this);var s},r.prototype.toPromise=function(t){var e=this;return new(t=qe(t))(function(s,n){var i;e.subscribe(function(o){return i=o},function(o){return n(o)},function(){return s(i)})})},r.create=function(t){return new r(t)},r}();function qe(r){var t;return(t=r??at.Promise)!==null&&t!==void 0?t:Promise}var It=nt(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ae=function(r){function t(){var e=r.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return q(t,r),t.prototype.lift=function(e){var s=new Ie(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new It},t.prototype.next=function(e){var s=this;Z(function(){var n,i;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=z(s.currentObservers),a=o.next();!a.done;a=o.next())a.value.next(e)}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var s=this;Z(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=e;for(var n=s.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;Z(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var s=e.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var s=this,n=this,i=n.hasError,o=n.isStopped,a=n.observers;return i||o?it:(this.currentObservers=null,a.push(e),new oe(function(){s.currentObservers=null,ke(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var s=this,n=s.hasError,i=s.thrownError,o=s.isStopped;n?e.error(i):o&&e.complete()},t.prototype.asObservable=function(){var e=new M;return e.source=this,e},t.create=function(e,s){return new Ie(e,s)},t}(M),Ie=function(r){function t(e,s){var n=r.call(this)||this;return n.destination=e,n.source=s,n}return q(t,r),t.prototype.next=function(e){var s,n;(n=(s=this.destination)===null||s===void 0?void 0:s.next)===null||n===void 0||n.call(s,e)},t.prototype.error=function(e){var s,n;(n=(s=this.destination)===null||s===void 0?void 0:s.error)===null||n===void 0||n.call(s,e)},t.prototype.complete=function(){var e,s;(s=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||s===void 0||s.call(e)},t.prototype._subscribe=function(e){var s,n;return(n=(s=this.source)===null||s===void 0?void 0:s.subscribe(e))!==null&&n!==void 0?n:it},t}(ae),j=function(r){function t(e){var s=r.call(this)||this;return s._value=e,s}return q(t,r),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=r.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,n=e.thrownError,i=e._value;if(s)throw n;return this._throwIfClosed(),i},t.prototype.next=function(e){r.prototype.next.call(this,this._value=e)},t}(ae),ht={now:function(){return(ht.delegate||Date).now()},delegate:void 0},pe=function(r){function t(e,s,n){e===void 0&&(e=1/0),s===void 0&&(s=1/0),n===void 0&&(n=ht);var i=r.call(this)||this;return i._bufferSize=e,i._windowTime=s,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=s===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,s),i}return q(t,r),t.prototype.next=function(e){var s=this,n=s.isStopped,i=s._buffer,o=s._infiniteTimeWindow,a=s._timestampProvider,c=s._windowTime;n||(i.push(e),!o&&i.push(a.now()+c)),this._trimBuffer(),r.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var s=this._innerSubscribe(e),n=this._infiniteTimeWindow,i=this._buffer.slice(),o=0;o<i.length&&!e.closed;o+=n?1:2)e.next(i[o]);return this._checkFinalizedStatuses(e),s},t.prototype._trimBuffer=function(){var e=this,s=e._bufferSize,n=e._timestampProvider,i=e._buffer,o=e._infiniteTimeWindow,a=(o?1:2)*s;if(s<1/0&&a<i.length&&i.splice(0,i.length-a),!o){for(var c=n.now(),u=0,h=1;h<i.length&&i[h]<=c;h+=2)u=h;u&&i.splice(0,u+1)}},t}(ae);function J(r){return function(t){if(function(e){return E(e==null?void 0:e.lift)}(t))return t.lift(function(e){try{return r(e,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}function $(r,t,e,s,n){return new Nt(r,t,e,s,n)}var Nt=function(r){function t(e,s,n,i,o,a){var c=r.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=s?function(u){try{s(u)}catch(h){e.error(h)}}:r.prototype._next,c._error=i?function(u){try{i(u)}catch(h){e.error(h)}finally{this.unsubscribe()}}:r.prototype._error,c._complete=n?function(){try{n()}catch(u){e.error(u)}finally{this.unsubscribe()}}:r.prototype._complete,c}return q(t,r),t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;r.prototype.unsubscribe.call(this),!s&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Be);function Ne(){return J(function(r,t){var e,s=!1;r.subscribe($(t,function(n){var i=e;e=n,s&&t.next([i,n]),s=!0}))})}function Ue(r,t){return J(function(e,s){var n=0;e.subscribe($(s,function(i){return r.call(t,i,n++)&&s.next(i)}))})}function ut(r,t){return J(function(e,s){var n=0;e.subscribe($(s,function(i){s.next(r.call(t,i,n++))}))})}var Ut=function(r){return r&&typeof r.length=="number"&&typeof r!="function"},Vt=typeof Symbol=="function"&&Symbol.iterator?Symbol.iterator:"@@iterator";function ne(r){if(r instanceof M)return r;if(r!=null){if(function(i){return E(i[xe])}(r))return n=r,new M(function(i){var o=n[xe]();if(E(o.subscribe))return o.subscribe(i);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(Ut(r))return s=r,new M(function(i){for(var o=0;o<s.length&&!i.closed;o++)i.next(s[o]);i.complete()});if(function(i){return E(i==null?void 0:i.then)}(r))return e=r,new M(function(i){e.then(function(o){i.closed||(i.next(o),i.complete())},function(o){return i.error(o)}).then(null,ct)});if(function(i){return Symbol.asyncIterator&&E(i==null?void 0:i[Symbol.asyncIterator])}(r))return Ve(r);if(function(i){return E(i==null?void 0:i[Vt])}(r))return t=r,new M(function(i){var o,a;try{for(var c=z(t),u=c.next();!u.done;u=c.next()){var h=u.value;if(i.next(h),i.closed)return}}catch(l){o={error:l}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}i.complete()});if(function(i){return E(i==null?void 0:i.getReader)}(r))return Ve(function(i){return function(o,a,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u,h=c.apply(o,a||[]),l=[];return u=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",function(f){return function(m){return Promise.resolve(m).then(f,v)}}),u[Symbol.asyncIterator]=function(){return this},u;function g(f,m){h[f]&&(u[f]=function(w){return new Promise(function(_,T){l.push([f,w,_,T])>1||y(f,w)})},m&&(u[f]=m(u[f])))}function y(f,m){try{(w=h[f](m)).value instanceof N?Promise.resolve(w.value.v).then(d,v):S(l[0][2],w)}catch(_){S(l[0][3],_)}var w}function d(f){y("next",f)}function v(f){y("throw",f)}function S(f,m){f(m),l.shift(),l.length&&y(l[0][0],l[0][1])}}(this,arguments,function(){var o,a,c;return rt(this,function(u){switch(u.label){case 0:o=i.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,N(o.read())];case 3:return a=u.sent(),c=a.value,a.done?[4,N(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,N(c)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return o.releaseLock(),[7];case 10:return[2]}})})}(r))}var t,e,s,n;throw function(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(r)}function Ve(r){return new M(function(t){(function(e,s){var n,i,o,a,c,u,h,l;return c=this,u=void 0,l=function(){var g,y;return rt(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),n=function(v){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var S,f=v[Symbol.asyncIterator];return f?f.call(v):(v=z(v),S={},m("next"),m("throw"),m("return"),S[Symbol.asyncIterator]=function(){return this},S);function m(w){S[w]=v[w]&&function(_){return new Promise(function(T,k){(function(P,kt,xt,_t){Promise.resolve(_t).then(function(Et){P({value:Et,done:xt})},kt)})(T,k,(_=v[w](_)).done,_.value)})}}}(e),d.label=1;case 1:return[4,n.next()];case 2:if((i=d.sent()).done)return[3,4];if(g=i.value,s.next(g),s.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return y=d.sent(),o={error:y},[3,11];case 6:return d.trys.push([6,,9,10]),i&&!i.done&&(a=n.return)?[4,a.call(n)]:[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 s.complete(),[2]}})},new((h=void 0)||(h=Promise))(function(g,y){function d(f){try{S(l.next(f))}catch(m){y(m)}}function v(f){try{S(l.throw(f))}catch(m){y(m)}}function S(f){f.done?g(f.value):function(m){return m instanceof h?m:new h(function(w){w(m)})}(f.value).then(d,v)}S((l=l.apply(c,u||[])).next())})})(r,t).catch(function(e){return t.error(e)})})}function de(r){r===void 0&&(r={});var t=r.connector,e=t===void 0?function(){return new ae}:t,s=r.resetOnError,n=s===void 0||s,i=r.resetOnComplete,o=i===void 0||i,a=r.resetOnRefCountZero,c=a===void 0||a;return function(u){var h,l,g,y=0,d=!1,v=!1,S=function(){l==null||l.unsubscribe(),l=void 0},f=function(){S(),h=g=void 0,d=v=!1},m=function(){var w=h;f(),w==null||w.unsubscribe()};return J(function(w,_){y++,v||d||S();var T=g=g??e();_.add(function(){--y!=0||v||d||(l=fe(m,c))}),T.subscribe(_),!h&&y>0&&(h=new H({next:function(k){return T.next(k)},error:function(k){v=!0,S(),l=fe(f,n,k),T.error(k)},complete:function(){d=!0,S(),l=fe(f,o),T.complete()}}),ne(w).subscribe(h))})(u)}}function fe(r,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];if(t!==!0){if(t!==!1){var n=new H({next:function(){n.unsubscribe(),r()}});return ne(t.apply(void 0,re([],se(e)))).subscribe(n)}}else r()}function lt(r,t,e){return e===void 0&&(e=1/0),E(t)?lt(function(s,n){return ut(function(i,o){return t(s,i,n,o)})(ne(r(s,n)))},e):(typeof t=="number"&&(e=t),J(function(s,n){return function(i,o,a,c,u,h,l,g){var y=[],d=0,v=0,S=!1,f=function(){!S||y.length||d||o.complete()},m=function(_){return d<c?w(_):y.push(_)},w=function(_){d++;var T=!1;ne(a(_,v++)).subscribe($(o,function(k){o.next(k)},function(){T=!0},void 0,function(){if(T)try{d--;for(var k=function(){var P=y.shift();w(P)};y.length&&d<c;)k();f()}catch(P){o.error(P)}}))};return i.subscribe($(o,m,function(){S=!0,f()})),function(){}}(s,n,r,e)}))}const Ft=(r,t)=>{const[e,s,n,i]=r,[o,a,c,u]=t,h=Math.max(e,o),l=Math.max(s,a),g=Math.min(n,c),y=Math.min(i,u),d=Math.max(0,g-h)*Math.max(0,y-l);return d/((n-e)*(i-s)+(c-o)*(u-a)-d)},Wt=(r,t)=>{const{origWidth:e,origHeight:s}=t,n=r.points.map(([i,o])=>[i*e/100,o*s/100]);return{...r,points:n}},Fe=r=>{const{origWidth:t,origHeight:e,inputWidth:s,inputHeight:n}=r,[i,o,a,c]=r.boundingBox,u=i*t/s,h=o*e/n,l=a*t/s,g=c*e/n;return{...r,boundingBox:[u,h,l,g]}},We=(r,t,e)=>{if(r.confidence<e.object.confidence)return!1;if(t.length===0)return!0;const[s,n,i,o]=r.boundingBox,a={xmin:s,ymin:n,xmax:i,ymax:o};let c=!1;for(const u of t){const h=Wt(u,r);if(h.isPrivacyMask){if(V(a,h.points)){c=!1;break}}else h.filter==="include"?h.type==="contain"?V(a,h.points)&&(c=!0):h.type==="intersect"&&(ze(a,h.points)||V(a,h.points))&&(c=!0):h.filter==="exclude"&&(h.type==="contain"?V(a,h.points)||(c=!0):h.type==="intersect"&&(ze(a,h.points)||V(a,h.points)||(c=!0)))}return c},ze=(r,t)=>{const e=zt(r);for(const s of e)for(let n=0;n<t.length;n++){const i=[t[n],t[(n+1)%t.length]];if(Ht(s,i))return!0}return!1},V=(r,t)=>[[r.xmin,r.ymin],[r.xmax,r.ymin],[r.xmax,r.ymax],[r.xmin,r.ymax]].every(e=>$t(e,t)),zt=r=>{const{xmin:t,ymin:e,xmax:s,ymax:n}=r;return[[[t,e],[s,e]],[[s,e],[s,n]],[[s,n],[t,n]],[[t,n],[t,e]]]},Ht=(r,t)=>{const e=(a,c,u)=>(u[1]-a[1])*(c[0]-a[0])>(c[1]-a[1])*(u[0]-a[0]);return s=r[0],n=r[1],e(s,i=t[0],o=t[1])!==e(n,i,o)&&e(s,n,i)!==e(s,n,o);var s,n,i,o},$t=(r,t)=>{const[e,s]=r;let n=!1,[i,o]=t[t.length-1];for(const[a,c]of t)c>s!=o>s&&e<(i-a)*(s-c)/(o-c)+a&&(n=!n),[i,o]=[a,c];return n};class Jt extends Rt{constructor(e,s){super();p(this,"logger");p(this,"snapshotCache");p(this,"cameraSubject");p(this,"cameraState",new j(!1));p(this,"lightState",new j(this.getLightState({state:!1},!0)));p(this,"motionState",new j(this.getMotionState({detections:[],state:!1},!0)));p(this,"audioState",new j(this.getAudioState({state:!1,db:0},!0)));p(this,"objectState",new j(this.getObjectState({detections:[]},!0)));p(this,"doorbellState",new j(this.getDoorbellState({state:!1},!0)));p(this,"sirenState",new j(this.getSirenState({state:!1,level:0},!0)));p(this,"batteryState",new j(this.getBatteryState({level:100,charging:!1,lowBattery:!1},!0)));p(this,"onConnected",this.createStateObservable(this.cameraState));p(this,"onLightSwitched",this.createStateObservable(this.lightState));p(this,"onMotionDetected",this.createStateObservable(this.motionState));p(this,"onAudioDetected",this.createStateObservable(this.audioState));p(this,"onObjectDetected",this.createStateObservable(this.objectState));p(this,"onDoorbellPressed",this.createStateObservable(this.doorbellState));p(this,"onSirenDetected",this.createStateObservable(this.sirenState));p(this,"onBatteryChanged",this.createStateObservable(this.batteryState));this.logger=s,this.cameraSubject=new j(e),this.updateCamera(e),this.snapshotCache=new(Lt())({max:100,ttl:1e3*this.snapshotTTL}),e.pluginId==="native"&&this.cameraState.next(!0)}get cameraObject(){return C(this.cameraSubject.getValue())}get id(){return this.cameraSubject.getValue()._id}get nativeId(){return this.cameraSubject.getValue().nativeId}get pluginId(){return this.cameraSubject.getValue().pluginId}get connected(){return this.cameraState.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 C(this.cameraSubject.getValue().info)}get isCloud(){return this.cameraSubject.getValue().isCloud}get hasLight(){return this.cameraSubject.getValue().hasLight}get hasSiren(){return this.cameraSubject.getValue().hasSiren}get hasBinarySensor(){return this.cameraSubject.getValue().hasBinarySensor}get hasBattery(){return this.cameraSubject.getValue().hasBattery}get hasMotionDetector(){return this.cameraSubject.getValue().hasMotionDetector}get hasAudioDetector(){return this.cameraSubject.getValue().hasAudioDetector}get hasObjectDetector(){return this.cameraSubject.getValue().hasObjectDetector}get hasPtz(){return this.cameraSubject.getValue().hasPtz}get hasPrebuffer(){return this.cameraSubject.getValue().hasPrebuffer}get snapshotTTL(){return this.cameraSubject.getValue().snapshotTTL}get activityZones(){return C(this.cameraSubject.getValue().activityZones)}get activitySettings(){return C(this.cameraSubject.getValue().activitySettings)}get frameWorkerSettings(){return C(this.cameraSubject.getValue().frameWorkerSettings)}get streamSource(){return this.highResolutionSource||this.midResolutionSource||this.lowResolutionSource}get snapshotSource(){return this.sources.find(e=>e.roles.includes("snapshot")&&!e.internal)}get highResolutionSource(){return this.sources.find(e=>e.roles.includes("high-resolution")&&!e.internal)}get midResolutionSource(){return this.sources.find(e=>e.roles.includes("mid-resolution")&&!e.internal)}get lowResolutionSource(){return this.sources.find(e=>e.roles.includes("low-resolution")&&!e.internal)}get ptz(){return this.ptzDelegate}getValue(e){switch(e){case"light":return C(this.lightState.getValue());case"motion":return C(this.motionState.getValue());case"audio":return C(this.audioState.getValue());case"object":return C(this.objectState.getValue());case"doorbell":return C(this.doorbellState.getValue());case"siren":return C(this.sirenState.getValue());case"battery":return C(this.batteryState.getValue());default:throw new Error(`Unknown state: ${e}`)}}async snapshot(e){this.snapshotCache.purgeStale();const s=this.snapshotSource||this.streamSource,n=s.urls.www.jpegSnapshot,i=this.snapshotCache.get(s._id);if(!e&&i)return this.logger.trace(this.name,"Snapshot requested (cached)"),i;this.logger.trace(this.name,"Snapshot requested (fetching)");try{if(this.cameraObject.pluginId!=="native"){const h=await this.cameraDelegate.snapshot();if(h&&h.byteLength>0)return this.snapshotCache.set(s._id,h),h}const o=new AbortController,a=setTimeout(()=>o.abort(),5e3),c=await fetch(n,{signal:o.signal});if(clearTimeout(a),!c.ok)throw new Error("Status Code: "+c.status);const u=await c.arrayBuffer();return u.byteLength>0&&this.snapshotCache.set(s._id,u),u}catch{return}}onStateChange(e){return this[`${e}State`].pipe(Ne(),Ue(([s,n])=>typeof s=="boolean"||typeof n=="boolean"?s!==n:this.stateChanged(s,n,e)),ut(([s,n])=>({oldState:s,newState:n})),de({connector:()=>new pe(1)}))}onPropertyChange(e){return this.cameraSubject.pipe(Ne(),lt(([s,n])=>(Array.isArray(e)?e:[e]).map(i=>({property:i,oldData:s[i],newData:n[i]}))),Ue(({oldData:s,newData:n})=>!U(s,n,!0)),de({connector:()=>new pe(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()}updateCamera(e){e.snapshotTTL!==this.snapshotTTL&&this.snapshotCache.clear(),this.cameraSubject.next(e)}updateCameraState(e){this.cameraState.next(e)}updateStateInternal(e,s,n){let i,o=!1;if(n)o=!0,i=s;else{const a=this.checkStateInternal(e,s);o=a.changed,i=a.event}if(o)switch(e){case"light":this.lightState.next(this.getLightState(i));break;case"motion":this.motionState.next(this.getMotionState(i));break;case"audio":this.audioState.next(this.getAudioState(i));break;case"object":this.objectState.next(this.getObjectState(i));break;case"doorbell":this.doorbellState.next(this.getDoorbellState(i));break;case"siren":this.sirenState.next(this.getSirenState(i));break;case"battery":this.batteryState.next(this.getBatteryState(i));break;default:throw new Error(`Unknown state: ${e}`)}}checkStateInternal(e,s){let n,i=!1;switch(e){case"audio":const o=s;n=this.getAudioState(o),i=this.stateChanged(this.getValue("audio"),n,"audio");break;case"light":const a=s;n=this.getLightState(a),i=this.stateChanged(this.getValue("light"),n,"light");break;case"motion":const c=s;c.state!==void 0&&(c.detections=[]),c.detections=((y,d=.2)=>{if(y.length===0)return[];const v=[...y].sort((f,m)=>{const w=(f.boundingBox[2]-f.boundingBox[0])*(f.boundingBox[3]-f.boundingBox[1]);return(m.boundingBox[2]-m.boundingBox[0])*(m.boundingBox[3]-m.boundingBox[1])-w}),S=[];for(;v.length>0;){let f={...v[0]};v.shift();const m=[];for(let w=0;w<v.length;w++)Ft(f.boundingBox,v[w].boundingBox)>d&&m.push(w);if(m.length>0){const w=[f,...m.map(k=>v[k])],_=[Math.min(...w.map(k=>k.boundingBox[0])),Math.min(...w.map(k=>k.boundingBox[1])),Math.max(...w.map(k=>k.boundingBox[2])),Math.max(...w.map(k=>k.boundingBox[3]))],T=w.reduce((k,P)=>k.confidence>P.confidence?k:P);f={...T,boundingBox:_,id:T.id||f.id};for(let k=m.length-1;k>=0;k--)v.splice(m[k],1)}S.push(f)}return S})(c.detections),c.detections=((y,d,v)=>{const S=[];for(const f of y)We(Fe(f),d,v)&&d.some(m=>!m.classes.length||m.classes.includes(f.label))&&S.push(f);return S})(c.detections,this.activityZones,this.activitySettings),n=this.getMotionState(c),i=this.stateChanged(this.getValue("motion"),n,"motion");break;case"object":const u=s;u.detections=((y,d,v)=>{const S=[];for(const f of y)We(Fe(f),d,v)&&d.some(m=>!m.classes.length||m.classes.includes(f.label))&&S.push(f);return S})(u.detections,this.activityZones,this.activitySettings),n=this.getObjectState(u),i=this.stateChanged(this.getValue("object"),n,"object");break;case"doorbell":const h=s;n=this.getDoorbellState(h),i=this.stateChanged(this.getValue("doorbell"),n,"doorbell");break;case"siren":const l=s;n=this.getSirenState(l),i=this.stateChanged(this.getValue("siren"),n,"siren");break;case"battery":const g=s;n=this.getBatteryState(g),i=this.stateChanged(this.getValue("battery"),n,"battery");break;default:throw new Error(`Unknown state: ${e}`)}return{changed:i,event:n}}stateChanged(e,s,n){if(!e||!s||!n)return!1;if(n=="audio"){if(!this.hasAudioDetector)return!1;const i=e,o=s;return i.state!==o.state||i.db!==o.db}if(n=="motion"){if(!this.hasMotionDetector)return!1;const i=e,o=s;return o.state!==void 0?i.state!==o.state:!U(i.detections,o.detections,!0)}if(n=="object"){if(!this.hasObjectDetector)return!1;const i=s;return!U(e.detections,i.detections,!0)}if(n=="siren"){if(!this.hasSiren)return!1;const i=e,o=s;return i.state!==o.state||i.level!==o.level}if(n=="battery"){if(!this.hasBattery)return!1;const i=e,o=s;return i.level!==o.level||i.lowBattery!==o.lowBattery||i.charging!==o.charging}if(n=="doorbell"){if(!this.hasBinarySensor)return!1;const i=s;return e.state!==i.state}if(n=="light"){if(!this.hasLight)return!1;const i=s;return e.state!==i.state}return!1}getAudioState(e,s=!1){var o;let n,i;if(!s){const a=this.getValue("audio");a.state?n=a:(o=a.lastEvent)!=null&&o.state&&(n=a.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const a={...e,timestamp:Date.now()};i={...a,db:a.db||(n==null?void 0:n.db)||0,lastEvent:n||(a.state?a:void 0)}}return i}getMotionState(e,s=!1){var o;let n,i;if(!s){const a=this.getValue("motion");a.detections.length?n=a:(o=a.lastEvent)!=null&&o.detections.length&&(n=a.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const a={...e,timestamp:Date.now()};i={...a,lastEvent:n||(a.detections.length?a:void 0)}}return i}getObjectState(e,s=!1){var o;let n,i;if(!s){const a=this.getValue("object");a.detections.length?n=a:(o=a.lastEvent)!=null&&o.detections.length&&(n=a.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const a={...e,timestamp:Date.now()};i={...a,lastEvent:n||(a.detections.length?a:void 0)}}return i}getDoorbellState(e,s=!1){var o;let n,i;if(!s){const a=this.getValue("doorbell");a.state?n=a:(o=a.lastEvent)!=null&&o.state&&(n=a.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const a={...e,timestamp:Date.now()};i={...a,lastEvent:n||(a.state?a:void 0)}}return i}getLightState(e,s=!1){var o;let n,i;if(!s){const a=this.getValue("light");a.state?n=a:(o=a.lastEvent)!=null&&o.state&&(n=a.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const a={...e,timestamp:Date.now()};i={...a,lastEvent:n||(a.state?a:void 0)}}return i}getSirenState(e,s=!1){var o;let n,i;if(!s){const a=this.getValue("siren");a.state?n=a:(o=a.lastEvent)!=null&&o.state&&(n=a.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const a={...e,timestamp:Date.now()};i={...a,level:a.level||(n==null?void 0:n.level)||0,lastEvent:n||(a.state?a:void 0)}}return i}getBatteryState(e,s=!1){let n,i;if(!s){const o=this.getValue("battery");this.stateChanged(o,e,"battery")?n=o:o.lastEvent&&this.stateChanged(o.lastEvent,e,"battery")&&(n=o.lastEvent),n&&delete n.lastEvent}if(this.isStateEvent(e))i=e;else{const o={...e,timestamp:Date.now()};i={...o,charging:e.charging||(n==null?void 0:n.charging)||!1,lowBattery:e.lowBattery||(n==null?void 0:n.lowBattery)||!1,lastEvent:n||o}}return i}isStateEvent(e){return"timestamp"in e}createStateObservable(e){return e.pipe(de({connector:()=>new pe(1)}))}}class Yt{constructor(t){p(this,"delegate");p(this,"onRequest");this.onRequest=t}async snapshot(){return this.delegate?this.delegate.snapshot():this._onRequest("snapshot",[],5e3)}_onRequest(t,e,s){return this.onRequest("cameraDelegate",t,e,s)}}class Kt{constructor(t){p(this,"delegate");p(this,"onRequest");this.onRequest=t}async getPrebufferingState(t,e){return this.delegate?this.delegate.getPrebufferingState(t,e):this._onRequest("prebufferDelegate","getPrebufferingState",[t,e])}_onRequest(t,e,s,n){return this.onRequest(t,e,s,n)}}class Gt{constructor(t){p(this,"delegate");p(this,"onRequest");this.onRequest=t}async moveAbsolute(t,e,s){return this.delegate?this.delegate.moveAbsolute(t,e,s):this._onRequest("moveAbsolute",[t,e,s])}async moveRelative(t,e,s){return this.delegate?this.delegate.moveRelative(t,e,s):this._onRequest("moveRelative",[t,e,s])}async moveContinuous(t,e,s){return this.delegate?this.delegate.moveContinuous(t,e,s):this._onRequest("moveContinuous",[t,e,s])}async stop(){return this.delegate?this.delegate.stop():this._onRequest("stop",[])}_onRequest(t,e,s){return this.onRequest("ptzDelegate",t,e,s)}}const ce=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const t=16*Math.random()|0;return(r==="x"?t:3&t|8).toString(16)});class Xt extends EventTarget{constructor(e,s,n,i){super();p(this,"cameraDevice");p(this,"socketService");p(this,"logger");p(this,"options");p(this,"videoPlayer");p(this,"socket");p(this,"streamId");p(this,"hasBackchannel",!1);p(this,"closed",!1);p(this,"micTransceiver",null);p(this,"pc",null);p(this,"buf",new Uint8Array(2097152));p(this,"mediaSource",null);p(this,"sourceBuffer",null);p(this,"bufLen",0);p(this,"mseCodecs","");p(this,"videoPlayerMp4");p(this,"media",["video","audio","microphone"]);p(this,"codecList",[]);p(this,"reconnectTimeout");p(this,"_finishLoading",!1);p(this,"webrtcReconnectTimeout");this.options=i,this.videoPlayer=i.videoElement,this.cameraDevice=e,this.socketService=s,this.logger=n;const{socket:o}=this.socketService.getSocket(`${e.id}-go2rtcSession`,!0);this.socket=o,this.socket.connect(),this.streamId=ce(),this.createCodecsList()}get mode(){return this.options.mode}connect(e){e&&(this.options.mode=e),console.log(this.cameraDevice.name,`Connecting... (${this.options.mode})`),this.socket.on("ws-open",this.onWsOpen.bind(this)),this.socket.on("ws-close",this.onWsClose.bind(this)),this.socket.on("ws-message",this.onWsMessage.bind(this)),this.socket.emit("ws-open",{id:this.streamId,cameraSource:this.options.sourceName,mode:this.options.mode})}disconnect(){console.log(this.cameraDevice.name,"Disconnecting..."),this.socket.removeListener("ws-open",this.onWsOpen.bind(this)),this.socket.removeListener("ws-close",this.onWsClose.bind(this)),this.socket.removeListener("ws-message",this.onWsMessage.bind(this)),this.socket.emit("ws-close",{id:this.streamId})}async reconnect(e){console.log(this.cameraDevice.name,"Reconnecting..."),this.dispatchEvent(new Event("reconnect")),this.close(),await new Promise(s=>setTimeout(s,100)),this.connect(e)}reset(){var e,s,n;this._finishLoading=!1,(e=this.pc)==null||e.getTransceivers().forEach(i=>{var o,a;return(a=(o=i.sender)==null?void 0:o.track)==null?void 0:a.stop()}),(s=this.pc)==null||s.close(),this.pc=null,(n=this.videoPlayerMp4)==null||n.remove(),this.videoPlayerMp4=void 0,this.videoPlayer.srcObject=null,this.videoPlayer.src="",this.videoPlayer.poster=""}close(){console.log(this.cameraDevice.name,"Closing..."),this.closed=!0,this.reset(),this.disconnect(),this.socket.emit("end"),this.socket.removeAllListeners()}onWsOpen({id:e}){if(e===this.streamId)switch(console.log(this.cameraDevice.name,"Connected"),this.options.mode){case"webrtc":case"webrtc/tcp":console.log(this.cameraDevice.name,"Requesting WebRTC session..."),this.requestWebrtc();break;case"mse":console.log(this.cameraDevice.name,"Requesting MSE session..."),this.requestMse();break;case"hls":console.log(this.cameraDevice.name,"Requesting HLS session..."),this.requestHls();break;case"mp4":console.log(this.cameraDevice.name,"Requesting MP4 session..."),this.requestMp4();break;case"mjpeg":console.log(this.cameraDevice.name,"Requesting MJPEG session..."),this.requestMjpeg();break;default:console.log(this.cameraDevice.name,"Unknown mode:",this.options.mode),this.dispatchEvent(new ErrorEvent("error",{message:"Unknown mode: "+this.options.mode}))}}onWsClose({id:e}){e===this.streamId&&(this.closed||this.options.reconnectInterval===void 0||(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout(()=>{this.reconnect()},this.options.reconnectInterval)))}onWsMessage({id:e,data:s}){if(e===this.streamId&&s.type)switch(s.type){case"mse":this.onMseData(s);break;case"hls":this.onHlsData(s);break;case"webrtc/candidate":case"webrtc/answer":this.onWebrtcData(s);break;case"mse-binary":this.onMseBuffer(s);break;case"mjpeg-binary":this.onMjpegBuffer(s);break;case"mp4-binary":this.onMp4Buffer(s);break;case"stream-info":this.onStreamInfo(s);break;case"error":this.dispatchEvent(new ErrorEvent("error",{error:s,message:s.value}))}}async requestWebrtc(){this.reset(),this.pc=new RTCPeerConnection({bundlePolicy:"max-bundle",iceServers:[{urls:"stun:stun.l.google.com:19302"}],sdpSemantics:"unified-plan"}),this.pc.addEventListener("icecandidate",s=>{var i,o;if(this.options.mode==="webrtc/tcp"&&((i=s.candidate)==null?void 0:i.protocol)==="udp")return;const n=((o=s.candidate)==null?void 0:o.toJSON().candidate)||"";this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/candidate",value:n}})}),this.pc.addEventListener("connectionstatechange",()=>{var s,n,i,o,a;if(console.log(this.cameraDevice.name,"Connection state:",(s=this.pc)==null?void 0:s.connectionState),((n=this.pc)==null?void 0:n.connectionState)==="connected"){const c=(i=this.pc)==null?void 0:i.getTransceivers().filter(u=>u.currentDirection==="recvonly").map(u=>u.receiver.track);this.videoPlayer.srcObject=new MediaStream(c),this.finishLoading(),this.play(),this.disconnect()}else((o=this.pc)==null?void 0:o.connectionState)!=="failed"&&((a=this.pc)==null?void 0:a.connectionState)!=="disconnected"||(clearTimeout(this.webrtcReconnectTimeout),this.webrtcReconnectTimeout=setTimeout(()=>{var c,u;((c=this.pc)==null?void 0:c.connectionState)!=="failed"&&((u=this.pc)==null?void 0:u.connectionState)!=="disconnected"||this.reconnect()},1e3))}),this.pc.addTransceiver("video",{direction:"recvonly"}),this.pc.addTransceiver("audio",{direction:"recvonly"}),this.micTransceiver=this.pc.addTransceiver("audio",{direction:"sendonly"});const e=await this.pc.createOffer();await this.pc.setLocalDescription(e),console.log(this.cameraDevice.name,"Offer:",e.sdp),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/offer",value:e.sdp}})}async onWebrtcData(e){var s,n,i;try{switch(e.type){case"webrtc/candidate":if(this.options.mode==="webrtc/tcp"&&e.value.indexOf(" udp ")>0)return;await((s=this.pc)==null?void 0:s.addIceCandidate({candidate:e.value,sdpMid:"0"}));break;case"webrtc/answer":console.log(this.cameraDevice.name,"Answer:",e.value),await((n=this.pc)==null?void 0:n.setRemoteDescription({type:"answer",sdp:e.value}));break;case"error":if(console.log(this.cameraDevice.name,"WebRTC Error:",e.value),e.value.indexOf("webrtc/offer")<0)return;(i=this.pc)==null||i.close()}}catch(o){this.dispatchEvent(new ErrorEvent("error",{error:o,message:o.message}))}}requestMse(){if(this.reset(),"ManagedMediaSource"in window){console.log(this.cameraDevice.name,"Using ManagedMediaSource");const e=window.ManagedMediaSource;this.mediaSource=new e,this.mediaSource.addEventListener("sourceopen",()=>{this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mse",value:this.parseCodecs(e.isTypeSupported)}})},{once:!0}),this.videoPlayer.disableRemotePlayback=!0,this.videoPlayer.srcObject=this.mediaSource}else console.log(this.cameraDevice.name,"Using MediaSource"),this.mediaSource=new MediaSource,this.mediaSource.addEventListener("sourceopen",()=>{URL.revokeObjectURL(this.videoPlayer.src),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mse",value:this.parseCodecs(MediaSource.isTypeSupported)}})},{once:!0}),this.videoPlayer.src=URL.createObjectURL(this.mediaSource),this.videoPlayer.srcObject=null;this.play(),this.mseCodecs=""}onMseData(e){this.mediaSource&&(this.mseCodecs=e.value,this.bufLen=0,this.buf=new Uint8Array(2097152),this.sourceBuffer=this.mediaSource.addSourceBuffer(e.value),this.sourceBuffer.mode="segments",this.sourceBuffer.addEventListener("updateend",()=>{var s,n,i,o,a;if(!((s=this.sourceBuffer)!=null&&s.updating))try{if(this.bufLen>0){const c=this.buf.slice(0,this.bufLen);this.bufLen=0,(n=this.sourceBuffer)==null||n.appendBuffer(c)}else if((o=(i=this.sourceBuffer)==null?void 0:i.buffered)!=null&&o.length){const c=this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1)-15,u=this.sourceBuffer.buffered.start(0);c>u&&(this.sourceBuffer.remove(u,c),(a=this.mediaSource)==null||a.setLiveSeekableRange(c,c+15))}}catch{}}))}async onMseBuffer(e){var s,n,i;if(((s=this.mediaSource)==null?void 0:s.readyState)!=="closed")if(this.finishLoading(),((n=this.sourceBuffer)==null?void 0:n.updating)||this.bufLen>0){const o=new Uint8Array(e.value);this.buf.set(o,this.bufLen),this.bufLen+=o.byteLength}else try{(i=this.sourceBuffer)==null||i.appendBuffer(e.value)}catch{}else this.closed||(this.closed=!0,this.dispatchEvent(new ErrorEvent("error",{message:"MediaSource closed"})),this.options.mode="webrtc",this.requestWebrtc())}requestMjpeg(){this.reset(),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mjpeg"}})}onMjpegBuffer(e){this.videoPlayer.controls=!1,this.videoPlayer.poster="data:image/jpeg;base64,"+this.btoaBinary(e.value),this.finishLoading()}requestMp4(){this.reset();const e=document.createElement("canvas");let s=null;this.videoPlayerMp4=document.createElement("video"),this.videoPlayerMp4.autoplay=!0,this.videoPlayerMp4.playsInline=!0,this.videoPlayerMp4.muted=!0,this.videoPlayerMp4.addEventListener("loadeddata",()=>{this.videoPlayerMp4&&(s||(e.width=this.videoPlayerMp4.videoWidth,e.height=this.videoPlayerMp4.videoHeight,s=e.getContext("2d")),s==null||s.drawImage(this.videoPlayerMp4,0,0,e.width,e.height),this.videoPlayer.controls=!1,this.videoPlayer.poster=e.toDataURL("image/jpeg"))});const n=this.codecList.filter(i=>this.media.includes(i.indexOf("vc1")>0?"video":"audio")).filter(i=>this.videoPlayer.canPlayType(`video/mp4; codecs="${i}"`)).join();console.log(this.cameraDevice.name,"Playable codecs (MP4):",n),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mp4",value:n}})}onMp4Buffer(e){this.finishLoading(),this.videoPlayerMp4&&(this.videoPlayerMp4.src="data:video/mp4;base64,"+this.btoaBinary(e.value))}requestHls(){this.reset();const e=this.parseCodecs(s=>this.videoPlayer.canPlayType(s));console.log(this.cameraDevice.name,"Playable codecs (HLS):",e),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"hls",value:e}})}onHlsData(e){const s="http"+e.wsURL.substring(2,e.wsURL.indexOf("/ws"))+"/hls/",n=e.value.replace("hls/",s),i="data:application/vnd.apple.mpegurl;base64,"+btoa(n.toString());this.videoPlayer.src=i,this.finishLoading(),this.play()}onStreamInfo(e){var n;const s=e.value;(n=s==null?void 0:s.producers)!=null&&n.length&&(this.hasBackchannel=s.producers.some(i=>{var o;return(o=i.senders)==null?void 0:o.length}))}async play(){try{await this.videoPlayer.play()}catch(e){if(!this.videoPlayer.muted)return this.videoPlayer.muted=!0,this.play();this.logger.warn(this.cameraDevice.name,e)}}finishLoading(){this._finishLoading||(this._finishLoading=!0,this.dispatchEvent(new Event("finishLoading")))}createCodecsList(){const e=["avc1.640029","avc1.64002A","avc1.640033","hvc1.1.6.L153.B0","mp4a.40.2","mp4a.40.5","flac","opus"],s=typeof window>"u"?null:navigator.userAgent.match(/Version\/(\d+).+Safari/);if(s!=null&&s[1]){const n=s[1]<"13"?"mp4a.40.2":s[1]<"14"?"flac":"opus";e.splice(e.indexOf(n))}this.codecList=e}parseCodecs(e){return this.codecList.filter(s=>this.media.includes(s.indexOf("vc1")>0?"video":"audio")).filter(s=>e(`video/mp4; codecs="${s}"`)).join()}btoaBinary(e){const s=new Uint8Array(e),n=s.byteLength;let i="";for(let o=0;o<n;o++)i+=String.fromCharCode(s[o]);return window.btoa(i)}}class He extends Jt{constructor(e,s,n){super(e,n);p(this,"socketService");p(this,"socket");p(this,"pluginName","@camera.ui/client");p(this,"subject");p(this,"_started",!1);p(this,"cameraDelegate",new Yt(this.onRequest.bind(this)));p(this,"ptzDelegate",new Gt(this.onRequest.bind(this)));p(this,"prebufferDelegate",new Kt(this.onRequest.bind(this)));this.socketService=s;const{socket:i}=this.socketService.getSocket(this.id,!0);this.socket=i,this.socket.connect(),this.subject=`${this.pluginName}.camera.${this.id}`,this.listenToMessages()}get started(){return this._started}get sources(){return this._sources.filter(e=>!e.internal)}get internalSources(){return this._sources.map(e=>({...e,type:e.name.endsWith(" AAC")?"aac":e.name.endsWith(" OPUS")?"opus":"pcma"})).filter(e=>e.internal)}get _sources(){return JSON.parse(JSON.stringify(this.cameraSubject.getValue().sources)).map(e=>({...e,getPrebufferingState:s=>this.prebufferDelegate.getPrebufferingState(e.name,s),probeStream:()=>this.onRequest("cameraFn","probeStream",[e._id])}))}async start(){this._started||(this._started=!0,await this.refreshStates(),this.socket.emit("joinRoomStates",this.id))}stop(){this._started=!1,this.socket.emit("leaveRoomStates",this.id)}close(){this.cleanup()}connect(){return this.onRequest("cameraFn","connect")}disconnect(){return this.onRequest("cameraFn","disconnect")}createSession(e){return new Xt(this,this.socketService,this.logger,e)}async refreshStates(){const e=await this.onRequest("cameraFn","refreshStates");super.updateCamera(e.camera),super.updateCameraState(e.cameraState);for(const[s,n]of Object.entries(e.states))super.updateStateInternal(s,n,!0)}async cleanup(){this.stop(),this.removeAllListeners(),this.unsubscribe(),this.socket.removeAllListeners()}listenToMessages(){this.socket.emit("joinRoomDevice",this.id),this.socket.on("updateState",e=>{e.cameraId===this.id&&super.updateStateInternal(e.stateName,e.data.newEvent,!0)}),this.socket.on("updateDevice",e=>{if(e.cameraId===this.id)switch(e.type){case"removed":this.cleanup();break;case"updated":super.updateCamera(e.data);break;case"cameraState":super.updateCameraState(e.data)}})}onRequest(e,s,n=[]){const i={requestId:ce(),targetId:this.subject,targetName:this.name,pluginId:this.pluginName,cameraId:this.id,type:"request",proxy:"camera",client:e,fn:s,args:n,timestamp:Date.now(),timeout:5e3};return new Promise((o,a)=>{this.socket.emit("request",i,c=>{c.error?a(c.error):o(c.response)})})}}class Qt{constructor(t,e){p(this,"socketService");p(this,"socket");p(this,"logger");p(this,"pluginName","@camera.ui/client");p(this,"subject");this.socketService=t,this.socket=t.socket,this.logger=e,this.subject=`${this.pluginName}.coreManager`}async getFFmpegPath(){return this.onRequest("getFFmpegPath")}async getHwaccelInfo(){return this.onRequest("getHwaccelInfo")}async getServerAddresses(){return this.onRequest("getServerAddresses")}async getIceServers(){return this.onRequest("getIceServers")}onRequest(t,e){const s={requestId:ce(),targetId:this.subject,targetName:this.pluginName,pluginId:this.pluginName,type:"request",proxy:"core",client:"coreFn",fn:t,args:e||[],timestamp:Date.now(),timeout:5e3};return new Promise((n,i)=>{this.socket.emit("request",s,o=>{o.error?i(o.error):n(o.response)})})}}class Zt{constructor(t,e){p(this,"socketService");p(this,"socket");p(this,"logger");p(this,"pluginName","@camera.ui/client");p(this,"subject");this.socketService=t,this.socket=t.socket,this.logger=e,this.subject=`${this.pluginName}.deviceManager`}async getCameraById(t){const e=await this.onRequest("getCameraById",[t]);if(e){const s=new He(e,this.socketService,this.logger);return await s.refreshStates(),s}}async getCameraByName(t){const e=await this.onRequest("getCameraByName",[t]);if(e){const s=new He(e,this.socketService,this.logger);return await s.refreshStates(),s}}onRequest(t,e){const s={requestId:ce(),targetId:this.subject,targetName:this.pluginName,pluginId:this.pluginName,type:"request",proxy:"device",client:"deviceFn",fn:t,args:e||[],timestamp:Date.now(),timeout:5e3};return new Promise((n,i)=>{this.socket.emit("request",s,o=>{o.error?i(o.error):n(o.response)})})}}const B=Object.create(null);B.open="0",B.close="1",B.ping="2",B.pong="3",B.message="4",B.upgrade="5",B.noop="6";const ee=Object.create(null);Object.keys(B).forEach(r=>{ee[B[r]]=r});const _e={type:"error",data:"parser error"},pt=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",dt=typeof ArrayBuffer=="function",ft=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,ge=({type:r,data:t},e,s)=>pt&&t instanceof Blob?e?s(t):$e(t,s):dt&&(t instanceof ArrayBuffer||ft(t))?e?s(t):$e(new Blob([t]),s):s(B[r]+(t||"")),$e=(r,t)=>{const e=new FileReader;return e.onload=function(){const s=e.result.split(",")[1];t("b"+(s||""))},e.readAsDataURL(r)};function Je(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}let me;const W=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<64;r++)W["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(r)]=r;const es=typeof ArrayBuffer=="function",Ee=(r,t)=>{if(typeof r!="string")return{type:"message",data:gt(r,t)};const e=r.charAt(0);return e==="b"?{type:"message",data:ts(r.substring(1),t)}:ee[e]?r.length>1?{type:ee[e],data:r.substring(1)}:{type:ee[e]}:_e},ts=(r,t)=>{if(es){const e=(s=>{let n,i,o,a,c,u=.75*s.length,h=s.length,l=0;s[s.length-1]==="="&&(u--,s[s.length-2]==="="&&u--);const g=new ArrayBuffer(u),y=new Uint8Array(g);for(n=0;n<h;n+=4)i=W[s.charCodeAt(n)],o=W[s.charCodeAt(n+1)],a=W[s.charCodeAt(n+2)],c=W[s.charCodeAt(n+3)],y[l++]=i<<2|o>>4,y[l++]=(15&o)<<4|a>>2,y[l++]=(3&a)<<6|63&c;return g})(r);return gt(e,t)}return{base64:!0,data:r}},gt=(r,t)=>t==="blob"?r instanceof Blob?r:new Blob([r]):r instanceof ArrayBuffer?r:r.buffer,Ye="";let ye;function K(r){return r.reduce((t,e)=>t+e.length,0)}function G(r,t){if(r[0].length===t)return r.shift();const e=new Uint8Array(t);let s=0;for(let n=0;n<t;n++)e[n]=r[0][s++],s===r[0].length&&(r.shift(),s=0);return r.length&&s<r[0].length&&(r[0]=r[0].slice(s)),e}function x(r){if(r)return function(t){for(var e in x.prototype)t[e]=x.prototype[e];return t}(r)}x.prototype.on=x.prototype.addEventListener=function(r,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(t),this},x.prototype.once=function(r,t){function e(){this.off(r,e),t.apply(this,arguments)}return e.fn=t,this.on(r,e),this},x.prototype.off=x.prototype.removeListener=x.prototype.removeAllListeners=x.prototype.removeEventListener=function(r,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e,s=this._callbacks["$"+r];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n=0;n<s.length;n++)if((e=s[n])===t||e.fn===t){s.splice(n,1);break}return s.length===0&&delete this._callbacks["$"+r],this},x.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),e=this._callbacks["$"+r],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(e){s=0;for(var n=(e=e.slice(0)).length;s<n;++s)e[s].apply(this,t)}return this},x.prototype.emitReserved=x.prototype.emit,x.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]},x.prototype.hasListeners=function(r){return!!this.listeners(r).length};const A=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function mt(r,...t){return t.reduce((e,s)=>(r.hasOwnProperty(s)&&(e[s]=r[s]),e),{})}const ss=A.setTimeout,rs=A.clearTimeout;function he(r,t){t.useNativeTimers?(r.setTimeoutFn=ss.bind(A),r.clearTimeoutFn=rs.bind(A)):(r.setTimeoutFn=A.setTimeout.bind(A),r.clearTimeoutFn=A.clearTimeout.bind(A))}class ns extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class be extends x{constructor(t){super(),this.writable=!1,he(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,s){return super.emitReserved("error",new ns(t,e,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return this.readyState!=="opening"&&this.readyState!=="open"||(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Ee(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const e=function(s){let n="";for(let i in s)s.hasOwnProperty(i)&&(n.length&&(n+="&"),n+=encodeURIComponent(i)+"="+encodeURIComponent(s[i]));return n}(t);return e.length?"?"+e:""}}const yt="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Te=64,is={};let Ke,Ge=0,X=0;function Xe(r){let t="";do t=yt[r%Te]+t,r=Math.floor(r/Te);while(r>0);return t}function Qe(){const r=Xe(+new Date);return r!==Ke?(Ge=0,Ke=r):r+"."+Xe(Ge++)}for(;X<Te;X++)is[yt[X]]=X;let bt=!1;try{bt=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const os=bt;function vt(r){const t=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||os))return new XMLHttpRequest}catch{}if(!t)try{return new A[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function as(){}const cs=new vt({xdomain:!1}).responseType!=null;class L extends x{constructor(t,e){super(),he(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=e.data!==void 0?e.data:null,this.create()}create(){var t;const e=mt(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const s=this.xhr=new vt(e);try{s.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&s.setRequestHeader(n,this.opts.extraHeaders[n])}}catch{}if(this.method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(t=this.opts.cookieJar)===null||t===void 0||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),s.onreadystatechange=()=>{var n;s.readyState===3&&((n=this.opts.cookieJar)===null||n===void 0||n.parseCookies(s)),s.readyState===4&&(s.status===200||s.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof s.status=="number"?s.status:0)},0))},s.send(this.data)}catch(n){return void this.setTimeoutFn(()=>{this.onError(n)},0)}typeof document<"u"&&(this.index=L.requestsCount++,L.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(this.xhr!==void 0&&this.xhr!==null){if(this.xhr.onreadystatechange=as,t)try{this.xhr.abort()}catch{}typeof document<"u"&&delete L.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function Ze(){for(let r in L.requests)L.requests.hasOwnProperty(r)&&L.requests[r].abort()}L.requestsCount=0,L.requests={},typeof document<"u"&&(typeof attachEvent=="function"?attachEvent("onunload",Ze):typeof addEventListener=="function"&&addEventListener("onpagehide"in A?"pagehide":"unload",Ze,!1));const Oe=typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,t)=>t(r,0),Q=A.WebSocket||A.MozWebSocket,et=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",hs={websocket:class extends be{constructor(r){super(r),this.supportsBinary=!r.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const r=this.uri(),t=this.opts.protocols,e=et?{}:mt(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(e.headers=this.opts.extraHeaders);try{this.ws=et?new Q(r,t,e):t?new Q(r,t):new Q(r)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=r=>this.onClose({description:"websocket connection closed",context:r}),this.ws.onmessage=r=>this.onData(r.data),this.ws.onerror=r=>this.onError("websocket error",r)}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const e=r[t],s=t===r.length-1;ge(e,this.supportsBinary,n=>{try{this.ws.send(n)}catch{}s&&Oe(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.close(),this.ws=null)}uri(){const r=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Qe()),this.supportsBinary||(t.b64=1),this.createUri(r,t)}check(){return!!Q}},webtransport:class extends be{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(r=>{this.onError("webtransport error",r)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(r=>{const t=function(o,a){ye||(ye=new TextDecoder);const c=[];let u=0,h=-1,l=!1;return new TransformStream({transform(g,y){for(c.push(g);;){if(u===0){if(K(c)<1)break;const d=G(c,1);l=!(128&~d[0]),h=127&d[0],u=h<126?3:h===126?1:2}else if(u===1){if(K(c)<2)break;const d=G(c,2);h=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),u=3}else if(u===2){if(K(c)<8)break;const d=G(c,8),v=new DataView(d.buffer,d.byteOffset,d.length),S=v.getUint32(0);if(S>Math.pow(2,21)-1){y.enqueue(_e);break}h=S*Math.pow(2,32)+v.getUint32(4),u=3}else{if(K(c)<h)break;const d=G(c,h);y.enqueue(Ee(l?d:ye.decode(d),a)),u=0}if(h===0||h>o){y.enqueue(_e);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),e=r.readable.pipeThrough(t).getReader(),s=new TransformStream({transform(o,a){(function(c,u){pt&&c.data instanceof Blob?c.data.arrayBuffer().then(Je).then(u):dt&&(c.data instanceof ArrayBuffer||ft(c.data))?u(Je(c.data)):ge(c,!1,h=>{me||(me=new TextEncoder),u(me.encode(h))})})(o,c=>{const u=c.length;let h;if(u<126)h=new Uint8Array(1),new DataView(h.buffer).setUint8(0,u);else if(u<65536){h=new Uint8Array(3);const l=new DataView(h.buffer);l.setUint8(0,126),l.setUint16(1,u)}else{h=new Uint8Array(9);const l=new DataView(h.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(u))}o.data&&typeof o.data!="string"&&(h[0]|=128),a.enqueue(h),a.enqueue(c)})}});s.readable.pipeTo(r.writable),this.writer=s.writable.getWriter();const n=()=>{e.read().then(({done:o,value:a})=>{o||(this.onPacket(a),n())}).catch(o=>{})};n();const i={type:"open"};this.query.sid&&(i.data=`{"sid":"${this.query.sid}"}`),this.writer.write(i).then(()=>this.onOpen())})}))}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const e=r[t],s=t===r.length-1;this.writer.write(e).then(()=>{s&&Oe(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var r;(r=this.transport)===null||r===void 0||r.close()}},polling:class extends be{constructor(r){if(super(r),this.polling=!1,typeof location<"u"){const e=location.protocol==="https:";let s=location.port;s||(s=e?"443":"80"),this.xd=typeof location<"u"&&r.hostname!==location.hostname||s!==r.port}const t=r&&r.forceBase64;this.supportsBinary=cs&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(r){this.readyState="pausing";const t=()=>{this.readyState="paused",r()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",function(){--e||t()})),this.writable||(e++,this.once("drain",function(){--e||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(r){((t,e)=>{const s=t.split(Ye),n=[];for(let i=0;i<s.length;i++){const o=Ee(s[i],e);if(n.push(o),o.type==="error")break}return n})(r,this.socket.binaryType).forEach(t=>{if(this.readyState==="opening"&&t.type==="open"&&this.onOpen(),t.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)}),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const r=()=>{this.write([{type:"close"}])};this.readyState==="open"?r():this.once("open",r)}write(r){this.writable=!1,((t,e)=>{const s=t.length,n=new Array(s);let i=0;t.forEach((o,a)=>{ge(o,!1,c=>{n[a]=c,++i===s&&e(n.join(Ye))})})})(r,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const r=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Qe()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(r,t)}request(r={}){return Object.assign(r,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new L(this.uri(),r)}doWrite(r,t){const e=this.request({method:"POST",data:r});e.on("success",t),e.on("error",(s,n)=>{this.onError("xhr post error",s,n)})}doPoll(){const r=this.request();r.on("data",this.onData.bind(this)),r.on("error",(t,e)=>{this.onError("xhr poll error",t,e)}),this.pollXhr=r}}},us=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ls=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ce(r){if(r.length>2e3)throw"URI too long";const t=r,e=r.indexOf("["),s=r.indexOf("]");e!=-1&&s!=-1&&(r=r.substring(0,e)+r.substring(e,s).replace(/:/g,";")+r.substring(s,r.length));let n=us.exec(r||""),i={},o=14;for(;o--;)i[ls[o]]=n[o]||"";return e!=-1&&s!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=function(a,c){const u=c.replace(/\/{2,9}/g,"/").split("/");return c.slice(0,1)!="/"&&c.length!==0||u.splice(0,1),c.slice(-1)=="/"&&u.splice(u.length-1,1),u}(0,i.path),i.queryKey=function(a,c){const u={};return c.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(h,l,g){l&&(u[l]=g)}),u}(0,i.query),i}class D extends x{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&typeof t=="object"&&(e=t,t=null),t?(t=Ce(t),e.hostname=t.host,e.secure=t.protocol==="https"||t.protocol==="wss",e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=Ce(e.host).host),he(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=function(s){let n={},i=s.split("&");for(let o=0,a=i.length;o<a;o++){let c=i[o].split("=");n[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return n}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new hs[t](s)}open(){let t;if(this.opts.rememberUpgrade&&D.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else{if(this.transports.length===0)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch{return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",e=>this.onClose("transport close",e))}probe(t){let e=this.createTransport(t),s=!1;D.priorWebsocketSuccess=!1;const n=()=>{s||(e.send([{type:"ping",data:"probe"}]),e.once("packet",l=>{if(!s)if(l.type==="pong"&&l.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;D.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(h(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const g=new Error("probe error");g.transport=e.name,this.emitReserved("upgradeError",g)}}))};function i(){s||(s=!0,h(),e.close(),e=null)}const o=l=>{const g=new Error("probe error: "+l);g.transport=e.name,i(),this.emitReserved("upgradeError",g)};function a(){o("transport closed")}function c(){o("socket closed")}function u(l){e&&l.name!==e.name&&i()}const h=()=>{e.removeListener("open",n),e.removeListener("error",o),e.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};e.once("open",n),e.once("error",o),e.once("close",a),this.once("close",c),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{s||e.open()},200):e.open()}onOpen(){if(this.readyState="open",D.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const n=this.writeBuffer[s].data;if(n&&(t+=typeof(e=n)=="string"?function(i){let o=0,a=0;for(let c=0,u=i.length;c<u;c++)o=i.charCodeAt(c),o<128?a+=1:o<2048?a+=2:o<55296||o>=57344?a+=3:(c++,a+=4);return a}(e):Math.ceil(1.33*(e.byteLength||e.size))),s>0&&t>this.maxPayload)return this.writeBuffer.slice(0,s);t+=2}var e;return this.writeBuffer}write(t,e,s){return this.sendPacket("message",t,e,s),this}send(t,e,s){return this.sendPacket("message",t,e,s),this}sendPacket(t,e,s,n){if(typeof e=="function"&&(n=e,e=void 0),typeof s=="function"&&(n=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;(s=s||{}).compress=s.compress!==!1;const i={type:t,data:e,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},s=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return this.readyState!=="opening"&&this.readyState!=="open"||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():t()}):this.upgrading?s():t()),this}onError(t){D.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){this.readyState!=="opening"&&this.readyState!=="open"&&this.readyState!=="closing"||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const n=t.length;for(;s<n;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}D.protocol=4;const ps=typeof ArrayBuffer=="function",ds=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,wt=Object.prototype.toString,fs=typeof Blob=="function"||typeof Blob<"u"&&wt.call(Blob)==="[object BlobConstructor]",gs=typeof File=="function"||typeof File<"u"&&wt.call(File)==="[object FileConstructor]";function Le(r){return ps&&(r instanceof ArrayBuffer||ds(r))||fs&&r instanceof Blob||gs&&r instanceof File}function te(r,t){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let e=0,s=r.length;e<s;e++)if(te(r[e]))return!0;return!1}if(Le(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return te(r.toJSON(),!0);for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)&&te(r[e]))return!0;return!1}function ms(r){const t=[],e=r.data,s=r;return s.data=Ae(e,t),s.attachments=t.length,{packet:s,buffers:t}}function Ae(r,t){if(!r)return r;if(Le(r)){const e={_placeholder:!0,num:t.length};return t.push(r),e}if(Array.isArray(r)){const e=new Array(r.length);for(let s=0;s<r.length;s++)e[s]=Ae(r[s],t);return e}if(typeof r=="object"&&!(r instanceof Date)){const e={};for(const s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=Ae(r[s],t));return e}return r}function ys(r,t){return r.data=Re(r.data,t),delete r.attachments,r}function Re(r,t){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<t.length)return t[r.num];throw new Error("illegal attachments")}if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e]=Re(r[e],t);else if(typeof r=="object")for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=Re(r[e],t));return r}const bs=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],vs=5;var b;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(b||(b={}));class ws{constructor(t){this.replacer=t}encode(t){return t.type!==b.EVENT&&t.type!==b.ACK||!te(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===b.EVENT?b.BINARY_EVENT:b.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==b.BINARY_EVENT&&t.type!==b.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(e+=t.nsp+","),t.id!=null&&(e+=t.id),t.data!=null&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=ms(t),s=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(s),n}}function tt(r){return Object.prototype.toString.call(r)==="[object Object]"}class je extends x{constructor(t){super(),this.reviver=t}add(t){let e;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const s=e.type===b.BINARY_EVENT;s||e.type===b.BINARY_ACK?(e.type=s?b.EVENT:b.ACK,this.reconstructor=new Ss(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!Le(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(t){let e=0;const s={type:Number(t.charAt(0))};if(b[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===b.BINARY_EVENT||s.type===b.BINARY_ACK){const i=e+1;for(;t.charAt(++e)!=="-"&&e!=t.length;);const o=t.substring(i,e);if(o!=Number(o)||t.charAt(e)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(t.charAt(e+1)==="/"){const i=e+1;for(;++e&&t.charAt(e)!==","&&e!==t.length;);s.nsp=t.substring(i,e)}else s.nsp="/";const n=t.charAt(e+1);if(n!==""&&Number(n)==n){const i=e+1;for(;++e;){const o=t.charAt(e);if(o==null||Number(o)!=o){--e;break}if(e===t.length)break}s.id=Number(t.substring(i,e+1))}if(t.charAt(++e)){const i=this.tryParse(t.substr(e));if(!je.isPayloadValid(s.type,i))throw new Error("invalid payload");s.data=i}return s}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case b.CONNECT:return tt(e);case b.DISCONNECT:return e===void 0;case b.CONNECT_ERROR:return typeof e=="string"||tt(e);case b.EVENT:case b.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&bs.indexOf(e[0])===-1);case b.ACK:case b.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ss{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=ys(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function R(r,t,e){return r.on(t,e),function(){r.off(t,e)}}const ks=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class St extends x{constructor(t,e,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[R(t,"open",this.onopen.bind(this)),R(t,"packet",this.onpacket.bind(this)),R(t,"error",this.onerror.bind(this)),R(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(ks.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const s={type:b.EVENT,data:e,options:{}};if(s.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const i=this.ids++,o=e.pop();this._registerAckCallback(i,o),s.id=i}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,e){var s;const n=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(n===void 0)return void(this.acks[t]=e);const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);e.call(this,new Error("operation has timed out"))},n),o=(...a)=>{this.io.clearTimeoutFn(i),e.apply(this,a)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...e){return new Promise((s,n)=>{const i=(o,a)=>o?n(o):s(a);i.withError=!0,e.push(i),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((n,...i)=>{if(s===this._queue[0])return n!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(n)):(this._queue.shift(),e&&e(null,...i)),s.pending=!1,this._drainQueue()}),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:b.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(e=>String(e.id)===t)){const e=this.acks[t];delete this.acks[t],e.withError&&e.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case b.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case b.EVENT:case b.BINARY_EVENT:this.onevent(t);break;case b.ACK:case b.BINARY_ACK:this.onack(t);break;case b.DISCONNECT:this.ondisconnect();break;case b.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let s=!1;return function(...n){s||(s=!0,e.packet({type:b.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:b.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const s of e)s.apply(this,t.data)}}}function I(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}I.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*r);r=1&Math.floor(10*t)?r+e:r-e}return 0|Math.min(r,this.max)},I.prototype.reset=function(){this.attempts=0},I.prototype.setMin=function(r){this.ms=r},I.prototype.setMax=function(r){this.max=r},I.prototype.setJitter=function(r){this.jitter=r};class ie extends x{constructor(t,e){var s;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,he(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((s=e.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new I({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||we;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new D(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const n=R(e,"open",function(){s.onopen(),t&&t()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},o=R(e,"error",i);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{n(),i(new Error("timeout")),e.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(n),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(R(t,"ping",this.onping.bind(this)),R(t,"data",this.ondata.bind(this)),R(t,"error",this.onerror.bind(this)),R(t,"close",this.onclose.bind(this)),R(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){Oe(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new St(this,t,e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(const s of e)if(this.nsps[s].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let s=0;s<e.length;s++)this.engine.write(e[s],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open(n=>{n?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",n)):t.onreconnect()}))},e);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const F={};function ve(r,t){typeof r=="object"&&(t=r,r=void 0);const e=function(c,u="",h){let l=c;h=h||typeof location<"u"&&location,c==null&&(c=h.protocol+"//"+h.host),typeof c=="string"&&(c.charAt(0)==="/"&&(c=c.charAt(1)==="/"?h.protocol+c:h.host+c),/^(https?|wss?):\/\//.test(c)||(c=h!==void 0?h.protocol+"//"+c:"https://"+c),l=Ce(c)),l.port||(/^(http|ws)$/.test(l.protocol)?l.port="80":/^(http|ws)s$/.test(l.protocol)&&(l.port="443")),l.path=l.path||"/";const g=l.host.indexOf(":")!==-1?"["+l.host+"]":l.host;return l.id=l.protocol+"://"+g+":"+l.port+u,l.href=l.protocol+"://"+g+(h&&h.port===l.port?"":":"+l.port),l}(r,(t=t||{}).path||"/socket.io"),s=e.source,n=e.id,i=e.path,o=F[n]&&i in F[n].nsps;let a;return t.forceNew||t["force new connection"]||t.multiplex===!1||o?a=new ie(s,t):(F[n]||(F[n]=new ie(s,t)),a=F[n]),e.query&&!t.query&&(t.query=e.queryKey),a.socket(e.path,t)}Object.assign(ve,{Manager:ie,Socket:St,io:ve,connect:ve});class xs{constructor(t,e){p(this,"socket");p(this,"token");p(this,"endpoint");p(this,"socketList",new Map);this.endpoint=t.replace("https://","wss://").replace("http://","ws://"),this.token=e,this.socket=this.getSocket("default").socket,this.socket.connect()}close(){this.socket.emit("end"),this.socket.removeAllListeners(),this.socket.disconnect()}getSocket(t,e){return this.createManager(e)}createManager(t){const e=new ie(this.endpoint,{reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,randomizationFactor:.5,timeout:2e4,autoConnect:!0,transports:["websocket","polling"],rejectUnauthorized:!1,secure:!0,forceNew:t}),s=e.socket("/proxy",{auth:{token:`Bearer ${this.token}`}});return{manager:e,socket:s}}}class _s{constructor(t){p(this,"api");p(this,"socketService");p(this,"config");p(this,"logger");p(this,"token");p(this,"deviceManager");p(this,"coreManager");this.config=t,this.logger=t.logger||{...console,attention:console.warn},this.api=new At(t.endpoint)}async connect(){return this.deviceManager&&this.coreManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new xs(this.config.endpoint,this.token),this.coreManager=new Qt(this.socketService,this.logger),this.deviceManager=new Zt(this.socketService,this.logger),this.checkSession()),{coreManager:this.coreManager,deviceManager:this.deviceManager}}async disconnect(){var t;(t=this.socketService)==null||t.close(),this.cleanUpClient(),this.config.username&&this.config.password&&await this.api.post("/auth/logout",void 0,{headers:{Authorization:`Bearer ${this.token}`}})}async updateCredentials(t){this.config={...this.config,...t},this.socketService&&await this.disconnect(),await this.connect()}async login(){var t;if(this.config.username&&this.config.password)try{const e=await this.api.post("/auth/login",{username:this.config.username,password:this.config.password}),s=await e.json();this.token=s.access_token}catch(e){throw((t=e.response)==null?void 0:t.status)===401?new Error("Invalid credentials"):new Error(`Failed to get token: ${e.message}`)}else if(this.config.token&&!this.config.skipCheck)try{await this.api.get("/auth/check",{headers:{Authorization:`Bearer ${this.config.token}`}})}catch(e){throw new Error(`Invalid token: ${e.message}`)}this.token=this.token||this.config.token}getDeviceManager(){return this.deviceManager}checkSession(){var t,e;(t=this.socketService)==null||t.socket.removeListener("invalidToken"),(e=this.socketService)==null||e.socket.on("invalidToken",async s=>{s===this.token&&await this.disconnect()})}cleanUpClient(){this.deviceManager=void 0}}var Ts=st.j;export{Ts as X};
@@ -1,19 +0,0 @@
1
- /*!
2
- * shared v10.0.1
3
- * (c) 2024 kazuya kawaguchi
4
- * Released under the MIT License.
5
- */const dt=(e,t,n)=>mt({l:e,k:t,s:n}),mt=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),K=e=>typeof e=="number"&&isFinite(e),_t=e=>We(e)==="[object Date]",Ce=e=>We(e)==="[object RegExp]",_e=e=>P(e)&&Object.keys(e).length===0,ee=Object.assign;let Ie;const Et=()=>Ie||(Ie=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Se(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const H=Array.isArray,F=e=>typeof e=="function",b=e=>typeof e=="string",$=e=>typeof e=="boolean",w=e=>e!==null&&typeof e=="object",Lt=e=>w(e)&&F(e.then)&&F(e.catch),Ue=Object.prototype.toString,We=e=>Ue.call(e),P=e=>{if(!w(e))return!1;const t=Object.getPrototypeOf(e);return t===null||t.constructor===Object},pt=e=>e==null?"":H(e)||P(e)&&e.toString===Ue?JSON.stringify(e,null,2):String(e);function ht(e,t=""){return e.reduce((n,s,i)=>i===0?n+s:n+t+s,"")}function Nt(e,t){typeof console<"u"&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}/*!
6
- * shared v10.0.1
7
- * (c) 2024 kazuya kawaguchi
8
- * Released under the MIT License.
9
- */const $e=Object.assign,be=e=>typeof e=="string";function Ke(e,t=""){return e.reduce((n,s,i)=>i===0?n+s:n+t+s,"")}/*!
10
- * message-compiler v10.0.1
11
- * (c) 2024 kazuya kawaguchi
12
- * Released under the MIT License.
13
- */function gt(e,t,n){return{line:e,column:t,offset:n}}function fe(e,t,n){return{start:e,end:t}}const k={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16},Tt=17;function Ee(e,t,n={}){const{domain:s,messages:i,args:c}=n,m=e,_=new SyntaxError(String(m));return _.code=e,t&&(_.location=t),_.domain=s,_}function Ct(e){throw e}const x=" ",It="\r",W=`
14
- `,St="\u2028",bt="\u2029";function At(e){const t=e;let n=0,s=1,i=1,c=0;const m=S=>t[S]===It&&t[S+1]===W,_=S=>t[S]===W,f=S=>t[S]===bt,L=S=>t[S]===St,I=S=>m(S)||_(S)||f(S)||L(S),C=()=>n,N=()=>s,A=()=>i,y=()=>c,O=S=>m(S)||f(S)||L(S)?W:t[S],g=()=>O(n),l=()=>O(n+c);function d(){return c=0,I(n)&&(s++,i=0),m(n)&&n++,n++,i++,t[n]}function E(){return m(n+c)&&c++,c++,t[n+c]}function o(){n=0,s=1,i=1,c=0}function p(S=0){c=S}function h(){const S=n+c;for(;S!==n;)d();c=0}return{index:C,line:N,column:A,peekOffset:y,charAt:O,currentChar:g,currentPeek:l,next:d,peek:E,reset:o,resetPeek:p,skipToPeek:h}}const Q=void 0,Ot=".",Ae="'",yt="tokenizer";function kt(e,t={}){const n=t.location!==!1,s=At(e),i=()=>s.index(),c=()=>gt(s.line(),s.column(),s.index()),m=c(),_=i(),f={currentType:13,offset:_,startLoc:m,endLoc:m,lastType:13,lastOffset:_,lastStartLoc:m,lastEndLoc:m,braceNest:0,inLinked:!1,text:""},L=()=>f,{onError:I}=t;function C(r,a,u,...T){const M=L();if(a.column+=u,a.offset+=u,I){const v=n?fe(M.startLoc,a):null,Y=Ee(r,v,{domain:yt,args:T});I(Y)}}function N(r,a,u){r.endLoc=c(),r.currentType=a;const T={type:a};return n&&(T.loc=fe(r.startLoc,r.endLoc)),u!=null&&(T.value=u),T}const A=r=>N(r,13);function y(r,a){return r.currentChar()===a?(r.next(),a):(C(k.EXPECTED_TOKEN,c(),0,a),"")}function O(r){let a="";for(;r.currentPeek()===x||r.currentPeek()===W;)a+=r.currentPeek(),r.peek();return a}function g(r){const a=O(r);return r.skipToPeek(),a}function l(r){if(r===Q)return!1;const a=r.charCodeAt(0);return a>=97&&a<=122||a>=65&&a<=90||a===95}function d(r){if(r===Q)return!1;const a=r.charCodeAt(0);return a>=48&&a<=57}function E(r,a){const{currentType:u}=a;if(u!==2)return!1;O(r);const T=l(r.currentPeek());return r.resetPeek(),T}function o(r,a){const{currentType:u}=a;if(u!==2)return!1;O(r);const T=r.currentPeek()==="-"?r.peek():r.currentPeek(),M=d(T);return r.resetPeek(),M}function p(r,a){const{currentType:u}=a;if(u!==2)return!1;O(r);const T=r.currentPeek()===Ae;return r.resetPeek(),T}function h(r,a){const{currentType:u}=a;if(u!==7)return!1;O(r);const T=r.currentPeek()===".";return r.resetPeek(),T}function S(r,a){const{currentType:u}=a;if(u!==8)return!1;O(r);const T=l(r.currentPeek());return r.resetPeek(),T}function D(r,a){const{currentType:u}=a;if(!(u===7||u===11))return!1;O(r);const T=r.currentPeek()===":";return r.resetPeek(),T}function R(r,a){const{currentType:u}=a;if(u!==9)return!1;const T=()=>{const v=r.currentPeek();return v==="{"?l(r.peek()):v==="@"||v==="|"||v===":"||v==="."||v===x||!v?!1:v===W?(r.peek(),T()):j(r,!1)},M=T();return r.resetPeek(),M}function V(r){O(r);const a=r.currentPeek()==="|";return r.resetPeek(),a}function j(r,a=!0){const u=(M=!1,v="")=>{const Y=r.currentPeek();return Y==="{"||Y==="@"||!Y?M:Y==="|"?!(v===x||v===W):Y===x?(r.peek(),u(!0,x)):Y===W?(r.peek(),u(!0,W)):!0},T=u();return a&&r.resetPeek(),T}function U(r,a){const u=r.currentChar();return u===Q?Q:a(u)?(r.next(),u):null}function re(r){const a=r.charCodeAt(0);return a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57||a===95||a===36}function Be(r){return U(r,re)}function Je(r){const a=r.charCodeAt(0);return a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57||a===95||a===36||a===45}function Qe(r){return U(r,Je)}function qe(r){const a=r.charCodeAt(0);return a>=48&&a<=57}function Ze(r){return U(r,qe)}function ze(r){const a=r.charCodeAt(0);return a>=48&&a<=57||a>=65&&a<=70||a>=97&&a<=102}function et(r){return U(r,ze)}function ge(r){let a="",u="";for(;a=Ze(r);)u+=a;return u}function tt(r){let a="";for(;;){const u=r.currentChar();if(u==="{"||u==="}"||u==="@"||u==="|"||!u)break;if(u===x||u===W)if(j(r))a+=u,r.next();else{if(V(r))break;a+=u,r.next()}else a+=u,r.next()}return a}function nt(r){g(r);let a="",u="";for(;a=Qe(r);)u+=a;return r.currentChar()===Q&&C(k.UNTERMINATED_CLOSING_BRACE,c(),0),u}function rt(r){g(r);let a="";return r.currentChar()==="-"?(r.next(),a+=`-${ge(r)}`):a+=ge(r),r.currentChar()===Q&&C(k.UNTERMINATED_CLOSING_BRACE,c(),0),a}function st(r){return r!==Ae&&r!==W}function at(r){g(r),y(r,"'");let a="",u="";for(;a=U(r,st);)a==="\\"?u+=lt(r):u+=a;const T=r.currentChar();return T===W||T===Q?(C(k.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,c(),0),T===W&&(r.next(),y(r,"'")),u):(y(r,"'"),u)}function lt(r){const a=r.currentChar();switch(a){case"\\":case"'":return r.next(),`\\${a}`;case"u":return Te(r,a,4);case"U":return Te(r,a,6);default:return C(k.UNKNOWN_ESCAPE_SEQUENCE,c(),0,a),""}}function Te(r,a,u){y(r,a);let T="";for(let M=0;M<u;M++){const v=et(r);if(!v){C(k.INVALID_UNICODE_ESCAPE_SEQUENCE,c(),0,`\\${a}${T}${r.currentChar()}`);break}T+=v}return`\\${a}${T}`}function ct(r){return r!=="{"&&r!=="}"&&r!==x&&r!==W}function it(r){g(r);let a="",u="";for(;a=U(r,ct);)u+=a;return u}function ot(r){let a="",u="";for(;a=Be(r);)u+=a;return u}function ut(r){const a=u=>{const T=r.currentChar();return T==="{"||T==="@"||T==="|"||T==="("||T===")"||!T||T===x?u:(u+=T,r.next(),a(u))};return a("")}function le(r){g(r);const a=y(r,"|");return g(r),a}function ce(r,a){let u=null;switch(r.currentChar()){case"{":return a.braceNest>=1&&C(k.NOT_ALLOW_NEST_PLACEHOLDER,c(),0),r.next(),u=N(a,2,"{"),g(r),a.braceNest++,u;case"}":return a.braceNest>0&&a.currentType===2&&C(k.EMPTY_PLACEHOLDER,c(),0),r.next(),u=N(a,3,"}"),a.braceNest--,a.braceNest>0&&g(r),a.inLinked&&a.braceNest===0&&(a.inLinked=!1),u;case"@":return a.braceNest>0&&C(k.UNTERMINATED_CLOSING_BRACE,c(),0),u=se(r,a)||A(a),a.braceNest=0,u;default:{let M=!0,v=!0,Y=!0;if(V(r))return a.braceNest>0&&C(k.UNTERMINATED_CLOSING_BRACE,c(),0),u=N(a,1,le(r)),a.braceNest=0,a.inLinked=!1,u;if(a.braceNest>0&&(a.currentType===4||a.currentType===5||a.currentType===6))return C(k.UNTERMINATED_CLOSING_BRACE,c(),0),a.braceNest=0,ie(r,a);if(M=E(r,a))return u=N(a,4,nt(r)),g(r),u;if(v=o(r,a))return u=N(a,5,rt(r)),g(r),u;if(Y=p(r,a))return u=N(a,6,at(r)),g(r),u;if(!M&&!v&&!Y)return u=N(a,12,it(r)),C(k.INVALID_TOKEN_IN_PLACEHOLDER,c(),0,u.value),g(r),u;break}}return u}function se(r,a){const{currentType:u}=a;let T=null;const M=r.currentChar();switch((u===7||u===8||u===11||u===9)&&(M===W||M===x)&&C(k.INVALID_LINKED_FORMAT,c(),0),M){case"@":return r.next(),T=N(a,7,"@"),a.inLinked=!0,T;case".":return g(r),r.next(),N(a,8,".");case":":return g(r),r.next(),N(a,9,":");default:return V(r)?(T=N(a,1,le(r)),a.braceNest=0,a.inLinked=!1,T):h(r,a)||D(r,a)?(g(r),se(r,a)):S(r,a)?(g(r),N(a,11,ot(r))):R(r,a)?(g(r),M==="{"?ce(r,a)||T:N(a,10,ut(r))):(u===7&&C(k.INVALID_LINKED_FORMAT,c(),0),a.braceNest=0,a.inLinked=!1,ie(r,a))}}function ie(r,a){let u={type:13};if(a.braceNest>0)return ce(r,a)||A(a);if(a.inLinked)return se(r,a)||A(a);switch(r.currentChar()){case"{":return ce(r,a)||A(a);case"}":return C(k.UNBALANCED_CLOSING_BRACE,c(),0),r.next(),N(a,3,"}");case"@":return se(r,a)||A(a);default:{if(V(r))return u=N(a,1,le(r)),a.braceNest=0,a.inLinked=!1,u;if(j(r))return N(a,0,tt(r));break}}return u}function ft(){const{currentType:r,offset:a,startLoc:u,endLoc:T}=f;return f.lastType=r,f.lastOffset=a,f.lastStartLoc=u,f.lastEndLoc=T,f.offset=i(),f.startLoc=c(),s.currentChar()===Q?N(f,13):ie(s,f)}return{nextToken:ft,currentOffset:i,currentPosition:c,context:L}}const Pt="parser",Dt=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function Rt(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const s=parseInt(t||n,16);return s<=55295||s>=57344?String.fromCodePoint(s):"�"}}}function Mt(e={}){const t=e.location!==!1,{onError:n}=e;function s(l,d,E,o,...p){const h=l.currentPosition();if(h.offset+=o,h.column+=o,n){const S=t?fe(E,h):null,D=Ee(d,S,{domain:Pt,args:p});n(D)}}function i(l,d,E){const o={type:l};return t&&(o.start=d,o.end=d,o.loc={start:E,end:E}),o}function c(l,d,E,o){t&&(l.end=d,l.loc&&(l.loc.end=E))}function m(l,d){const E=l.context(),o=i(3,E.offset,E.startLoc);return o.value=d,c(o,l.currentOffset(),l.currentPosition()),o}function _(l,d){const E=l.context(),{lastOffset:o,lastStartLoc:p}=E,h=i(5,o,p);return h.index=parseInt(d,10),l.nextToken(),c(h,l.currentOffset(),l.currentPosition()),h}function f(l,d){const E=l.context(),{lastOffset:o,lastStartLoc:p}=E,h=i(4,o,p);return h.key=d,l.nextToken(),c(h,l.currentOffset(),l.currentPosition()),h}function L(l,d){const E=l.context(),{lastOffset:o,lastStartLoc:p}=E,h=i(9,o,p);return h.value=d.replace(Dt,Rt),l.nextToken(),c(h,l.currentOffset(),l.currentPosition()),h}function I(l){const d=l.nextToken(),E=l.context(),{lastOffset:o,lastStartLoc:p}=E,h=i(8,o,p);return d.type!==11?(s(l,k.UNEXPECTED_EMPTY_LINKED_MODIFIER,E.lastStartLoc,0),h.value="",c(h,o,p),{nextConsumeToken:d,node:h}):(d.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,G(d)),h.value=d.value||"",c(h,l.currentOffset(),l.currentPosition()),{node:h})}function C(l,d){const E=l.context(),o=i(7,E.offset,E.startLoc);return o.value=d,c(o,l.currentOffset(),l.currentPosition()),o}function N(l){const d=l.context(),E=i(6,d.offset,d.startLoc);let o=l.nextToken();if(o.type===8){const p=I(l);E.modifier=p.node,o=p.nextConsumeToken||l.nextToken()}switch(o.type!==9&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(o)),o=l.nextToken(),o.type===2&&(o=l.nextToken()),o.type){case 10:o.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(o)),E.key=C(l,o.value||"");break;case 4:o.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(o)),E.key=f(l,o.value||"");break;case 5:o.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(o)),E.key=_(l,o.value||"");break;case 6:o.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(o)),E.key=L(l,o.value||"");break;default:{s(l,k.UNEXPECTED_EMPTY_LINKED_KEY,d.lastStartLoc,0);const p=l.context(),h=i(7,p.offset,p.startLoc);return h.value="",c(h,p.offset,p.startLoc),E.key=h,c(E,p.offset,p.startLoc),{nextConsumeToken:o,node:E}}}return c(E,l.currentOffset(),l.currentPosition()),{node:E}}function A(l){const d=l.context(),E=d.currentType===1?l.currentOffset():d.offset,o=d.currentType===1?d.endLoc:d.startLoc,p=i(2,E,o);p.items=[];let h=null;do{const R=h||l.nextToken();switch(h=null,R.type){case 0:R.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(R)),p.items.push(m(l,R.value||""));break;case 5:R.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(R)),p.items.push(_(l,R.value||""));break;case 4:R.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(R)),p.items.push(f(l,R.value||""));break;case 6:R.value==null&&s(l,k.UNEXPECTED_LEXICAL_ANALYSIS,d.lastStartLoc,0,G(R)),p.items.push(L(l,R.value||""));break;case 7:{const V=N(l);p.items.push(V.node),h=V.nextConsumeToken||null;break}}}while(d.currentType!==13&&d.currentType!==1);const S=d.currentType===1?d.lastOffset:l.currentOffset(),D=d.currentType===1?d.lastEndLoc:l.currentPosition();return c(p,S,D),p}function y(l,d,E,o){const p=l.context();let h=o.items.length===0;const S=i(1,d,E);S.cases=[],S.cases.push(o);do{const D=A(l);h||(h=D.items.length===0),S.cases.push(D)}while(p.currentType!==13);return h&&s(l,k.MUST_HAVE_MESSAGES_IN_PLURAL,E,0),c(S,l.currentOffset(),l.currentPosition()),S}function O(l){const d=l.context(),{offset:E,startLoc:o}=d,p=A(l);return d.currentType===13?p:y(l,E,o,p)}function g(l){const d=kt(l,$e({},e)),E=d.context(),o=i(0,E.offset,E.startLoc);return t&&o.loc&&(o.loc.source=l),o.body=O(d),e.onCacheKey&&(o.cacheKey=e.onCacheKey(l)),E.currentType!==13&&s(d,k.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,l[E.offset]||""),c(o,d.currentOffset(),d.currentPosition()),o}return{parse:g}}function G(e){if(e.type===13)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function vt(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:c=>(n.helpers.add(c),c)}}function Oe(e,t){for(let n=0;n<e.length;n++)Le(e[n],t)}function Le(e,t){switch(e.type){case 1:Oe(e.cases,t),t.helper("plural");break;case 2:Oe(e.items,t);break;case 6:{Le(e.key,t),t.helper("linked"),t.helper("type");break}case 5:t.helper("interpolate"),t.helper("list");break;case 4:t.helper("interpolate"),t.helper("named");break}}function Ft(e,t={}){const n=vt(e);n.helper("normalize"),e.body&&Le(e.body,n);const s=n.context();e.helpers=Array.from(s.helpers)}function wt(e){const t=e.body;return t.type===2?ye(t):t.cases.forEach(n=>ye(n)),e}function ye(e){if(e.items.length===1){const t=e.items[0];(t.type===3||t.type===9)&&(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;n<e.items.length;n++){const s=e.items[n];if(!(s.type===3||s.type===9)||s.value==null)break;t.push(s.value)}if(t.length===e.items.length){e.static=Ke(t);for(let n=0;n<e.items.length;n++){const s=e.items[n];(s.type===3||s.type===9)&&delete s.value}}}}function Z(e){switch(e.t=e.type,e.type){case 0:{const t=e;Z(t.body),t.b=t.body,delete t.body;break}case 1:{const t=e,n=t.cases;for(let s=0;s<n.length;s++)Z(n[s]);t.c=n,delete t.cases;break}case 2:{const t=e,n=t.items;for(let s=0;s<n.length;s++)Z(n[s]);t.i=n,delete t.items,t.static&&(t.s=t.static,delete t.static);break}case 3:case 9:case 8:case 7:{const t=e;t.value&&(t.v=t.value,delete t.value);break}case 6:{const t=e;Z(t.key),t.k=t.key,delete t.key,t.modifier&&(Z(t.modifier),t.m=t.modifier,delete t.modifier);break}case 5:{const t=e;t.i=t.index,delete t.index;break}case 4:{const t=e;t.k=t.key,delete t.key;break}}delete e.type}function Ut(e,t){const{sourceMap:n,filename:s,breakLineCode:i,needIndent:c}=t,m=t.location!==!1,_={filename:s,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:i,needIndent:c,indentLevel:0};m&&e.loc&&(_.source=e.loc.source);const f=()=>_;function L(g,l){_.code+=g}function I(g,l=!0){const d=l?i:"";L(c?d+" ".repeat(g):d)}function C(g=!0){const l=++_.indentLevel;g&&I(l)}function N(g=!0){const l=--_.indentLevel;g&&I(l)}function A(){I(_.indentLevel)}return{context:f,push:L,indent:C,deindent:N,newline:A,helper:g=>`_${g}`,needIndent:()=>_.needIndent}}function Wt(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),z(e,t.key),t.modifier?(e.push(", "),z(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function $t(e,t){const{helper:n,needIndent:s}=e;e.push(`${n("normalize")}([`),e.indent(s());const i=t.items.length;for(let c=0;c<i&&(z(e,t.items[c]),c!==i-1);c++)e.push(", ");e.deindent(s()),e.push("])")}function Kt(e,t){const{helper:n,needIndent:s}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(s());const i=t.cases.length;for(let c=0;c<i&&(z(e,t.cases[c]),c!==i-1);c++)e.push(", ");e.deindent(s()),e.push("])")}}function Vt(e,t){t.body?z(e,t.body):e.push("null")}function z(e,t){const{helper:n}=e;switch(t.type){case 0:Vt(e,t);break;case 1:Kt(e,t);break;case 2:$t(e,t);break;case 6:Wt(e,t);break;case 8:e.push(JSON.stringify(t.value),t);break;case 7:e.push(JSON.stringify(t.value),t);break;case 5:e.push(`${n("interpolate")}(${n("list")}(${t.index}))`,t);break;case 4:e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`,t);break;case 9:e.push(JSON.stringify(t.value),t);break;case 3:e.push(JSON.stringify(t.value),t);break}}const Yt=(e,t={})=>{const n=be(t.mode)?t.mode:"normal",s=be(t.filename)?t.filename:"message.intl",i=!!t.sourceMap,c=t.breakLineCode!=null?t.breakLineCode:n==="arrow"?";":`
15
- `,m=t.needIndent?t.needIndent:n!=="arrow",_=e.helpers||[],f=Ut(e,{mode:n,filename:s,sourceMap:i,breakLineCode:c,needIndent:m});f.push(n==="normal"?"function __msg__ (ctx) {":"(ctx) => {"),f.indent(m),_.length>0&&(f.push(`const { ${Ke(_.map(C=>`${C}: _${C}`),", ")} } = ctx`),f.newline()),f.push("return "),z(f,e),f.deindent(m),f.push("}"),delete e.helpers;const{code:L,map:I}=f.context();return{ast:e,code:L,map:I?I.toJSON():void 0}};function Xt(e,t={}){const n=$e({},t),s=!!n.jit,i=!!n.minify,c=n.optimize==null?!0:n.optimize,_=Mt(n).parse(e);return s?(c&&wt(_),i&&Z(_),{ast:_,code:""}):(Ft(_,n),Yt(_,n))}/*!
16
- * core-base v10.0.1
17
- * (c) 2024 kazuya kawaguchi
18
- * Released under the MIT License.
19
- */function Gt(){typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(Et().__INTLIFY_PROD_DEVTOOLS__=!1)}function oe(e){return n=>Ht(n,e)}function Ht(e,t){const n=t.b||t.body;if((n.t||n.type)===1){const s=n,i=s.c||s.cases;return e.plural(i.reduce((c,m)=>[...c,ke(e,m)],[]))}else return ke(e,n)}function ke(e,t){const n=t.s||t.static;if(n)return e.type==="text"?n:e.normalize([n]);{const s=(t.i||t.items).reduce((i,c)=>[...i,de(e,c)],[]);return e.normalize(s)}}function de(e,t){const n=t.t||t.type;switch(n){case 3:{const s=t;return s.v||s.value}case 9:{const s=t;return s.v||s.value}case 4:{const s=t;return e.interpolate(e.named(s.k||s.key))}case 5:{const s=t;return e.interpolate(e.list(s.i!=null?s.i:s.index))}case 6:{const s=t,i=s.m||s.modifier;return e.linked(de(e,s.k||s.key),i?de(e,i):void 0,e.type)}case 7:{const s=t;return s.v||s.value}case 8:{const s=t;return s.v||s.value}default:throw new Error(`unhandled node type on format message part: ${n}`)}}const jt=e=>e;let ae=Object.create(null);const te=e=>w(e)&&(e.t===0||e.type===0)&&("b"in e||"body"in e);function xt(e,t={}){let n=!1;const s=t.onError||Ct;return t.onError=i=>{n=!0,s(i)},{...Xt(e,t),detectError:n}}function Pn(e,t){if(b(e)){$(t.warnHtmlMessage)&&t.warnHtmlMessage;const s=(t.onCacheKey||jt)(e),i=ae[s];if(i)return i;const{ast:c,detectError:m}=xt(e,{...t,location:!1,jit:!0}),_=oe(c);return m?_:ae[s]=_}else{const n=e.cacheKey;if(n){const s=ae[n];return s||(ae[n]=oe(e))}else return oe(e)}}let ne=null;function Dn(e){ne=e}function Bt(e,t,n){ne&&ne.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:n})}const Jt=Qt("function:translate");function Qt(e){return t=>ne&&ne.emit(e,t)}const B={INVALID_ARGUMENT:Tt,INVALID_DATE_ARGUMENT:18,INVALID_ISO_DATE_ARGUMENT:19,NOT_SUPPORT_NON_STRING_MESSAGE:20,NOT_SUPPORT_LOCALE_PROMISE_VALUE:21,NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:22,NOT_SUPPORT_LOCALE_TYPE:23},Rn=24;function J(e){return Ee(e,null,void 0)}function pe(e,t){return t.locale!=null?Pe(t.locale):Pe(e.locale)}let ue;function Pe(e){if(b(e))return e;if(F(e)){if(e.resolvedOnce&&ue!=null)return ue;if(e.constructor.name==="Function"){const t=e();if(Lt(t))throw J(B.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return ue=t}else throw J(B.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}else throw J(B.NOT_SUPPORT_LOCALE_TYPE)}function qt(e,t,n){return[...new Set([n,...H(t)?t:w(t)?Object.keys(t):b(t)?[t]:[n]])]}function Mn(e,t,n){const s=b(n)?n:me,i=e;i.__localeChainCache||(i.__localeChainCache=new Map);let c=i.__localeChainCache.get(s);if(!c){c=[];let m=[n];for(;H(m);)m=De(c,m,t);const _=H(t)||!P(t)?t:t.default?t.default:null;m=b(_)?[_]:_,H(m)&&De(c,m,!1),i.__localeChainCache.set(s,c)}return c}function De(e,t,n){let s=!0;for(let i=0;i<t.length&&$(s);i++){const c=t[i];b(c)&&(s=Zt(e,t[i],n))}return s}function Zt(e,t,n){let s;const i=t.split("-");do{const c=i.join("-");s=zt(e,c,n),i.splice(-1,1)}while(i.length&&s===!0);return s}function zt(e,t,n){let s=!1;if(!e.includes(t)&&(s=!0,t)){s=t[t.length-1]!=="!";const i=t.replace(/!/g,"");e.push(i),(H(n)||P(n))&&n[i]&&(s=n[i])}return s}const q=[];q[0]={w:[0],i:[3,0],"[":[4],o:[7]};q[1]={w:[1],".":[2],"[":[4],o:[7]};q[2]={w:[2],i:[3,0],0:[3,0]};q[3]={i:[3,0],0:[3,0],w:[1,1],".":[2,1],"[":[4,1],o:[7,1]};q[4]={"'":[5,0],'"':[6,0],"[":[4,2],"]":[1,3],o:8,l:[4,0]};q[5]={"'":[4,0],o:8,l:[5,0]};q[6]={'"':[4,0],o:8,l:[6,0]};const en=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function tn(e){return en.test(e)}function nn(e){const t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===n&&(t===34||t===39)?e.slice(1,-1):e}function rn(e){if(e==null)return"o";switch(e.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return e;case 95:case 36:case 45:return"i";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"w"}return"i"}function sn(e){const t=e.trim();return e.charAt(0)==="0"&&isNaN(parseInt(e))?!1:tn(t)?nn(t):"*"+t}function an(e){const t=[];let n=-1,s=0,i=0,c,m,_,f,L,I,C;const N=[];N[0]=()=>{m===void 0?m=_:m+=_},N[1]=()=>{m!==void 0&&(t.push(m),m=void 0)},N[2]=()=>{N[0](),i++},N[3]=()=>{if(i>0)i--,s=4,N[0]();else{if(i=0,m===void 0||(m=sn(m),m===!1))return!1;N[1]()}};function A(){const y=e[n+1];if(s===5&&y==="'"||s===6&&y==='"')return n++,_="\\"+y,N[0](),!0}for(;s!==null;)if(n++,c=e[n],!(c==="\\"&&A())){if(f=rn(c),C=q[s],L=C[f]||C.l||8,L===8||(s=L[0],L[1]!==void 0&&(I=N[L[1]],I&&(_=c,I()===!1))))return;if(s===7)return t}}const Re=new Map;function ln(e,t){return w(e)?e[t]:null}function vn(e,t){if(!w(e))return null;let n=Re.get(t);if(n||(n=an(t),n&&Re.set(t,n)),!n)return null;const s=n.length;let i=e,c=0;for(;c<s;){const m=i[n[c]];if(m===void 0||F(i))return null;i=m,c++}return i}const cn="10.0.1",he=-1,me="en-US",Fn="",Me=e=>`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function on(){return{upper:(e,t)=>t==="text"&&b(e)?e.toUpperCase():t==="vnode"&&w(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>t==="text"&&b(e)?e.toLowerCase():t==="vnode"&&w(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>t==="text"&&b(e)?Me(e):t==="vnode"&&w(e)&&"__v_isVNode"in e?Me(e.children):e}}let Ve;function wn(e){Ve=e}let Ye;function Un(e){Ye=e}let Xe;function Wn(e){Xe=e}let Ge=null;const $n=e=>{Ge=e},un=()=>Ge;let He=null;const Kn=e=>{He=e},Vn=()=>He;let ve=0;function Yn(e={}){const t=F(e.onWarn)?e.onWarn:Nt,n=b(e.version)?e.version:cn,s=b(e.locale)||F(e.locale)?e.locale:me,i=F(s)?me:s,c=H(e.fallbackLocale)||P(e.fallbackLocale)||b(e.fallbackLocale)||e.fallbackLocale===!1?e.fallbackLocale:i,m=P(e.messages)?e.messages:{[i]:{}},_=P(e.datetimeFormats)?e.datetimeFormats:{[i]:{}},f=P(e.numberFormats)?e.numberFormats:{[i]:{}},L=ee({},e.modifiers||{},on()),I=e.pluralRules||{},C=F(e.missing)?e.missing:null,N=$(e.missingWarn)||Ce(e.missingWarn)?e.missingWarn:!0,A=$(e.fallbackWarn)||Ce(e.fallbackWarn)?e.fallbackWarn:!0,y=!!e.fallbackFormat,O=!!e.unresolving,g=F(e.postTranslation)?e.postTranslation:null,l=P(e.processor)?e.processor:null,d=$(e.warnHtmlMessage)?e.warnHtmlMessage:!0,E=!!e.escapeParameter,o=F(e.messageCompiler)?e.messageCompiler:Ve,p=F(e.messageResolver)?e.messageResolver:Ye||ln,h=F(e.localeFallbacker)?e.localeFallbacker:Xe||qt,S=w(e.fallbackContext)?e.fallbackContext:void 0,D=e,R=w(D.__datetimeFormatters)?D.__datetimeFormatters:new Map,V=w(D.__numberFormatters)?D.__numberFormatters:new Map,j=w(D.__meta)?D.__meta:{};ve++;const U={version:n,cid:ve,locale:s,fallbackLocale:c,messages:m,modifiers:L,pluralRules:I,missing:C,missingWarn:N,fallbackWarn:A,fallbackFormat:y,unresolving:O,postTranslation:g,processor:l,warnHtmlMessage:d,escapeParameter:E,messageCompiler:o,messageResolver:p,localeFallbacker:h,fallbackContext:S,onWarn:t,__meta:j};return U.datetimeFormats=_,U.numberFormats=f,U.__datetimeFormatters=R,U.__numberFormatters=V,__INTLIFY_PROD_DEVTOOLS__&&Bt(U,n,j),U}function Ne(e,t,n,s,i){const{missing:c,onWarn:m}=e;if(c!==null){const _=c(e,n,t,i);return b(_)?_:t}else return t}function Xn(e,t,n){const s=e;s.__localeChainCache=new Map,e.localeFallbacker(e,n,t)}function fn(e,t){return e===t?!1:e.split("-")[0]===t.split("-")[0]}function dn(e,t){const n=t.indexOf(e);if(n===-1)return!1;for(let s=n+1;s<t.length;s++)if(fn(e,t[s]))return!0;return!1}function Gn(e,...t){const{datetimeFormats:n,unresolving:s,fallbackLocale:i,onWarn:c,localeFallbacker:m}=e,{__datetimeFormatters:_}=e,[f,L,I,C]=_n(...t),N=$(I.missingWarn)?I.missingWarn:e.missingWarn;$(I.fallbackWarn)?I.fallbackWarn:e.fallbackWarn;const A=!!I.part,y=pe(e,I),O=m(e,i,y);if(!b(f)||f==="")return new Intl.DateTimeFormat(y,C).format(L);let g={},l,d=null;const E="datetime format";for(let h=0;h<O.length&&(l=O[h],g=n[l]||{},d=g[f],!P(d));h++)Ne(e,f,l,N,E);if(!P(d)||!b(l))return s?he:f;let o=`${l}__${f}`;_e(C)||(o=`${o}__${JSON.stringify(C)}`);let p=_.get(o);return p||(p=new Intl.DateTimeFormat(l,ee({},d,C)),_.set(o,p)),A?p.formatToParts(L):p.format(L)}const mn=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function _n(...e){const[t,n,s,i]=e,c={};let m={},_;if(b(t)){const f=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!f)throw J(B.INVALID_ISO_DATE_ARGUMENT);const L=f[3]?f[3].trim().startsWith("T")?`${f[1].trim()}${f[3].trim()}`:`${f[1].trim()}T${f[3].trim()}`:f[1].trim();_=new Date(L);try{_.toISOString()}catch{throw J(B.INVALID_ISO_DATE_ARGUMENT)}}else if(_t(t)){if(isNaN(t.getTime()))throw J(B.INVALID_DATE_ARGUMENT);_=t}else if(K(t))_=t;else throw J(B.INVALID_ARGUMENT);return b(n)?c.key=n:P(n)&&Object.keys(n).forEach(f=>{mn.includes(f)?m[f]=n[f]:c[f]=n[f]}),b(s)?c.locale=s:P(s)&&(m=s),P(i)&&(m=i),[c.key||"",_,c,m]}function Hn(e,t,n){const s=e;for(const i in n){const c=`${t}__${i}`;s.__datetimeFormatters.has(c)&&s.__datetimeFormatters.delete(c)}}function jn(e,...t){const{numberFormats:n,unresolving:s,fallbackLocale:i,onWarn:c,localeFallbacker:m}=e,{__numberFormatters:_}=e,[f,L,I,C]=Ln(...t),N=$(I.missingWarn)?I.missingWarn:e.missingWarn;$(I.fallbackWarn)?I.fallbackWarn:e.fallbackWarn;const A=!!I.part,y=pe(e,I),O=m(e,i,y);if(!b(f)||f==="")return new Intl.NumberFormat(y,C).format(L);let g={},l,d=null;const E="number format";for(let h=0;h<O.length&&(l=O[h],g=n[l]||{},d=g[f],!P(d));h++)Ne(e,f,l,N,E);if(!P(d)||!b(l))return s?he:f;let o=`${l}__${f}`;_e(C)||(o=`${o}__${JSON.stringify(C)}`);let p=_.get(o);return p||(p=new Intl.NumberFormat(l,ee({},d,C)),_.set(o,p)),A?p.formatToParts(L):p.format(L)}const En=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function Ln(...e){const[t,n,s,i]=e,c={};let m={};if(!K(t))throw J(B.INVALID_ARGUMENT);const _=t;return b(n)?c.key=n:P(n)&&Object.keys(n).forEach(f=>{En.includes(f)?m[f]=n[f]:c[f]=n[f]}),b(s)?c.locale=s:P(s)&&(m=s),P(i)&&(m=i),[c.key||"",_,c,m]}function xn(e,t,n){const s=e;for(const i in n){const c=`${t}__${i}`;s.__numberFormatters.has(c)&&s.__numberFormatters.delete(c)}}const pn=e=>e,hn=e=>"",Nn="text",gn=e=>e.length===0?"":ht(e),Tn=pt;function Fe(e,t){return e=Math.abs(e),t===2?e?e>1?1:0:1:e?Math.min(e,2):0}function Cn(e){const t=K(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(K(e.named.count)||K(e.named.n))?K(e.named.count)?e.named.count:K(e.named.n)?e.named.n:t:t}function In(e,t){t.count||(t.count=e),t.n||(t.n=e)}function Sn(e={}){const t=e.locale,n=Cn(e),s=w(e.pluralRules)&&b(t)&&F(e.pluralRules[t])?e.pluralRules[t]:Fe,i=w(e.pluralRules)&&b(t)&&F(e.pluralRules[t])?Fe:void 0,c=l=>l[s(n,l.length,i)],m=e.list||[],_=l=>m[l],f=e.named||{};K(e.pluralIndex)&&In(n,f);const L=l=>f[l];function I(l,d){const E=F(e.messages)?e.messages(l,!!d):w(e.messages)?e.messages[l]:!1;return E||(e.parent?e.parent.message(l):hn)}const C=l=>e.modifiers?e.modifiers[l]:pn,N=P(e.processor)&&F(e.processor.normalize)?e.processor.normalize:gn,A=P(e.processor)&&F(e.processor.interpolate)?e.processor.interpolate:Tn,y=P(e.processor)&&b(e.processor.type)?e.processor.type:Nn,g={list:_,named:L,plural:c,linked:(l,...d)=>{const[E,o]=d;let p="text",h="";d.length===1?w(E)?(h=E.modifier||h,p=E.type||p):b(E)&&(h=E||h):d.length===2&&(b(E)&&(h=E||h),b(o)&&(p=o||p));const S=I(l,!0)(g),D=p==="vnode"&&H(S)&&h?S[0]:S;return h?C(h)(D,p):D},message:I,type:y,interpolate:A,normalize:N,values:ee({},m,f)};return g}const we=()=>"",X=e=>F(e);function Bn(e,...t){const{fallbackFormat:n,postTranslation:s,unresolving:i,messageCompiler:c,fallbackLocale:m,messages:_}=e,[f,L]=On(...t),I=$(L.missingWarn)?L.missingWarn:e.missingWarn,C=$(L.fallbackWarn)?L.fallbackWarn:e.fallbackWarn,N=$(L.escapeParameter)?L.escapeParameter:e.escapeParameter,A=!!L.resolvedMessage,y=b(L.default)||$(L.default)?$(L.default)?c?f:()=>f:L.default:n?c?f:()=>f:null,O=n||y!=null&&(b(y)||F(y)),g=pe(e,L);N&&bn(L);let[l,d,E]=A?[f,g,_[g]||{}]:je(e,f,g,m,C,I),o=l,p=f;if(!A&&!(b(o)||te(o)||X(o))&&O&&(o=y,p=o),!A&&(!(b(o)||te(o)||X(o))||!b(d)))return i?he:f;let h=!1;const S=()=>{h=!0},D=X(o)?o:xe(e,f,d,o,p,S);if(h)return o;const R=kn(e,d,E,L),V=Sn(R),j=An(e,D,V),U=s?s(j,f):j;if(__INTLIFY_PROD_DEVTOOLS__){const re={timestamp:Date.now(),key:b(f)?f:X(o)?o.key:"",locale:d||(X(o)?o.locale:""),format:b(o)?o:X(o)?o.source:"",message:U};re.meta=ee({},e.__meta,un()||{}),Jt(re)}return U}function bn(e){H(e.list)?e.list=e.list.map(t=>b(t)?Se(t):t):w(e.named)&&Object.keys(e.named).forEach(t=>{b(e.named[t])&&(e.named[t]=Se(e.named[t]))})}function je(e,t,n,s,i,c){const{messages:m,onWarn:_,messageResolver:f,localeFallbacker:L}=e,I=L(e,s,n);let C={},N,A=null;const y="translate";for(let O=0;O<I.length&&(N=I[O],C=m[N]||{},(A=f(C,t))===null&&(A=C[t]),!(b(A)||te(A)||X(A)));O++)if(!dn(N,I)){const g=Ne(e,t,N,c,y);g!==t&&(A=g)}return[A,N,C]}function xe(e,t,n,s,i,c){const{messageCompiler:m,warnHtmlMessage:_}=e;if(X(s)){const L=s;return L.locale=L.locale||n,L.key=L.key||t,L}if(m==null){const L=()=>s;return L.locale=n,L.key=t,L}const f=m(s,yn(e,n,i,s,_,c));return f.locale=n,f.key=t,f.source=s,f}function An(e,t,n){return t(n)}function On(...e){const[t,n,s]=e,i={};if(!b(t)&&!K(t)&&!X(t)&&!te(t))throw J(B.INVALID_ARGUMENT);const c=K(t)?String(t):(X(t),t);return K(n)?i.plural=n:b(n)?i.default=n:P(n)&&!_e(n)?i.named=n:H(n)&&(i.list=n),K(s)?i.plural=s:b(s)?i.default=s:P(s)&&ee(i,s),[c,i]}function yn(e,t,n,s,i,c){return{locale:t,key:n,warnHtmlMessage:i,onError:m=>{throw c&&c(m),m},onCacheKey:m=>dt(t,n,m)}}function kn(e,t,n,s){const{modifiers:i,pluralRules:c,messageResolver:m,fallbackLocale:_,fallbackWarn:f,missingWarn:L,fallbackContext:I}=e,N={locale:t,modifiers:i,pluralRules:c,messages:(A,y)=>{let O=m(n,A);if(O==null&&(I||y)){const[,,g]=je(I||e,A,t,_,f,L);O=m(g,A)}if(b(O)||te(O)){let g=!1;const d=xe(e,A,t,O,A,()=>{g=!0});return g?we:d}else return X(O)?O:we}};return e.processor&&(N.processor=e.processor),s.list&&(N.list=s.list),s.named&&(N.named=s.named),K(s.plural)&&(N.pluralIndex=s.plural),N}Gt();export{Rn as C,me as D,Fn as M,En as N,mn as a,Yn as b,Ee as c,Hn as d,xn as e,$n as f,Vn as g,he as h,_n as i,Gn as j,Ln as k,te as l,X as m,jn as n,Mn as o,On as p,Un as q,wn as r,Dn as s,Bn as t,Xn as u,Wn as v,Kn as w,Pn as x,vn as y};