@camera.ui/browser 0.0.99 → 0.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- var t={855:t=>{const e="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=()=>e.now(),i=t=>t===1/0||(t=>t&&t===Math.floor(t)&&t>0&&isFinite(t))(t);class n{constructor({max:t=1/0,ttl:e,updateAgeOnGet:s=!1,checkAgeOnGet:n=!1,noUpdateTTL:r=!1,dispose:o,noDisposeOnSet:a=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,void 0!==e&&!i(e))throw new TypeError("ttl must be positive integer or Infinity if set");if(!i(t))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=e,this.max=t,this.updateAgeOnGet=!!s,this.checkAgeOnGet=!!n,this.noUpdateTTL=!!r,this.noDisposeOnSet=!!a,void 0!==o){if("function"!=typeof o)throw new TypeError("dispose must be function if set");this.dispose=o}this.timer=void 0,this.timerExpiration=void 0}setTimer(t,e){if(this.timerExpiration<t)return;this.timer&&clearTimeout(this.timer);const i=setTimeout((()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(const t in this.expirations){this.setTimer(t,t-s());break}}),e);i.unref&&i.unref(),this.timerExpiration=t,this.timer=i}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 t=this.dispose!==n.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(const[e,s]of t)this.dispose(s,e,"delete")}setTTL(t,e=this.ttl){const i=this.expirationMap.get(t);if(void 0!==i){const e=this.expirations[i];!e||e.length<=1?delete this.expirations[i]:this.expirations[i]=e.filter((e=>e!==t))}if(e!==1/0){const i=Math.floor(s()+e);this.expirationMap.set(t,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,e)),this.expirations[i].push(t)}else this.expirationMap.set(t,1/0)}set(t,e,{ttl:s=this.ttl,noUpdateTTL:n=this.noUpdateTTL,noDisposeOnSet:r=this.noDisposeOnSet}={}){if(!i(s))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(t)){n||this.setTTL(t,s);const i=this.data.get(t);i!==e&&(this.data.set(t,e),r||this.dispose(i,t,"set"))}else this.setTTL(t,s),this.data.set(t,e);for(;this.size>this.max;)this.purgeToCapacity();return this}has(t){return this.data.has(t)}getRemainingTTL(t){const e=this.expirationMap.get(t);return e===1/0?e:void 0!==e?Math.max(0,Math.ceil(e-s())):0}get(t,{updateAgeOnGet:e=this.updateAgeOnGet,ttl:s=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){const n=this.data.get(t);if(!i||0!==this.getRemainingTTL(t))return e&&this.setTTL(t,s),n;this.delete(t)}dispose(t,e){}delete(t){const e=this.expirationMap.get(t);if(void 0!==e){const s=this.data.get(t);this.data.delete(t),this.expirationMap.delete(t);const i=this.expirations[e];return i&&(i.length<=1?delete this.expirations[e]:this.expirations[e]=i.filter((e=>e!==t))),this.dispose(s,t,"delete"),0===this.size&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(const t in this.expirations){const e=this.expirations[t];if(!(this.size-e.length>=this.max)){const t=this.size-this.max,s=[];for(const i of e.splice(0,t))s.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(const[t,e]of s)this.dispose(e,t,"evict");return}{delete this.expirations[t];const s=[];for(const t of e)s.push([t,this.data.get(t)]),this.data.delete(t),this.expirationMap.delete(t);for(const[t,e]of s)this.dispose(e,t,"evict")}}}get size(){return this.data.size}purgeStale(){const t=Math.ceil(s());for(const e in this.expirations){if("Infinity"===e||e>t)return;const s=[...this.expirations[e]||[]],i=[];delete this.expirations[e];for(const t of s)i.push([t,this.data.get(t)]),this.data.delete(t),this.expirationMap.delete(t);for(const[t,e]of i)this.dispose(e,t,"stale")}0===this.size&&this.cancelTimer()}*entries(){for(const t in this.expirations)for(const e of this.expirations[t])yield[e,this.data.get(e)]}*keys(){for(const t in this.expirations)for(const e of this.expirations[t])yield e}*values(){for(const t in this.expirations)for(const e of this.expirations[t])yield this.data.get(e)}[Symbol.iterator](){return this.entries()}}t.exports=n}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i](r,r.exports,s),r.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};s.d(i,{j:()=>Qe});var n={};s.r(n),s.d(n,{Decoder:()=>Ue,Encoder:()=>Ne,PacketType:()=>Ie,protocol:()=>qe});class r{baseURL;abortControllers=new Set;constructor(t){this.baseURL=`${t}/api`}async request(t,e,s,i={}){const n=new AbortController;this.abortControllers.add(n);const r=setTimeout((()=>{n.abort(),this.abortControllers.delete(n)}),15e3);try{const r=await fetch(`${this.baseURL}${e}`,{method:t,headers:{"Content-Type":"application/json",...i.headers},body:s?JSON.stringify(s):void 0,signal:n.signal,...i});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r}finally{clearTimeout(r),this.abortControllers.delete(n)}}get(t,e){return this.request("GET",t,void 0,e)}post(t,e,s){return this.request("POST",t,e,s)}}process.env.CAMERA_UI_RUNMODE,process.env.CAMERA_UI_RUNMODE,process.env.CAMERA_UI_RUNMODE,process.env.CAMERA_UI_AS_SERVICE;class o{subscriptions=[];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 a(t,e,s=!1){if(t===e)return!0;if((void 0===t||void 0===e||null===t||null===e)&&(t||e))return!1;const i=t?.constructor.name,n=e?.constructor.name;if(i!==n)return!1;if("Array"===i&&"Array"===n){if(t.length!==e.length)return!1;if(s){const i=[...e];return t.every((t=>{const e=i.findIndex((e=>a(t,e,s)));return-1!==e&&(i.splice(e,1),!0)}))}{let i=!0;for(let n=0;n<t.length;n++)if(!a(t[n],e[n],s)){i=!1;break}return i}}if("Object"===i&&"Object"===n){let i=!0;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r++)if(t[n[r]]&&e[n[r]]){if(t[n[r]]===e[n[r]])continue;if(!t[n[r]]||"Array"!==t[n[r]].constructor.name&&"Object"!==t[n[r]].constructor.name){if(t[n[r]]!==e[n[r]]){i=!1;break}}else if(i=a(t[n[r]],e[n[r]],s),!i)break}else if(t[n[r]]&&!e[n[r]]||!t[n[r]]&&e[n[r]]){i=!1;break}return i}return t===e}function c(t){return JSON.parse(JSON.stringify(t))}var h=s(855),u=s.n(h),l=function(t,e){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])},l(t,e)};function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}function p(t,e){var s,i,n,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(r=0)),r;)try{if(s=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!((n=(n=r.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){r.label=a[1];break}if(6===a[0]&&r.label<n[1]){r.label=n[1],n=a;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(a);break}n[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(t){a=[6,t],i=0}finally{s=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,s=e&&t[e],i=0;if(s)return s.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(t,e){var s="function"==typeof Symbol&&t[Symbol.iterator];if(!s)return t;var i,n,r=s.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}return o}function g(t,e,s){if(s||2===arguments.length)for(var i,n=0,r=e.length;n<r;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function y(t){return this instanceof y?(this.v=t,this):new y(t)}function b(t){return"function"==typeof t}function v(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var w=v((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function S(t,e){if(t){var s=t.indexOf(e);0<=s&&t.splice(s,1)}}var _=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var t,e,s,i,n;if(!this.closed){this.closed=!0;var r=this._parentage;if(r)if(this._parentage=null,Array.isArray(r))try{for(var o=f(r),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else r.remove(this);var c=this.initialTeardown;if(b(c))try{c()}catch(t){n=t instanceof w?t.errors:[t]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var u=f(h),l=u.next();!l.done;l=u.next()){var d=l.value;try{E(d)}catch(t){n=null!=n?n:[],t instanceof w?n=g(g([],m(n)),m(t.errors)):n.push(t)}}}catch(t){s={error:t}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}if(n)throw new w(n)}},t.prototype.add=function(e){var s;if(e&&e!==this)if(this.closed)E(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(s=this._finalizers)&&void 0!==s?s:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&S(e,t)},t.prototype.remove=function(e){var s=this._finalizers;s&&S(s,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),k=_.EMPTY;function x(t){return t instanceof _||t&&"closed"in t&&b(t.remove)&&b(t.add)&&b(t.unsubscribe)}function E(t){b(t)?t():t.unsubscribe()}var T={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},O={setTimeout:function(t,e){for(var s=[],i=2;i<arguments.length;i++)s[i-2]=arguments[i];var n=O.delegate;return(null==n?void 0:n.setTimeout)?n.setTimeout.apply(n,g([t,e],m(s))):setTimeout.apply(void 0,g([t,e],m(s)))},clearTimeout:function(t){var e=O.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function C(t){O.setTimeout((function(){var e=T.onUnhandledError;if(!e)throw t;e(t)}))}function R(){}var A=B("C",void 0,void 0);function B(t,e,s){return{kind:t,value:e,error:s}}var j=null;function L(t){if(T.useDeprecatedSynchronousErrorHandling){var e=!j;if(e&&(j={errorThrown:!1,error:null}),t(),e){var s=j,i=s.errorThrown,n=s.error;if(j=null,i)throw n}}else t()}var P=function(t){function e(e){var s=t.call(this)||this;return s.isStopped=!1,e?(s.destination=e,x(e)&&e.add(s)):s.destination=U,s}return d(e,t),e.create=function(t,e,s){return new I(t,e,s)},e.prototype.next=function(t){this.isStopped?F(function(t){return B("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?F(B("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?F(A,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(_),M=Function.prototype.bind;function D(t,e){return M.call(t,e)}var q=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){N(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){N(t)}else N(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){N(t)}},t}(),I=function(t){function e(e,s,i){var n,r,o=t.call(this)||this;return b(e)||!e?n={next:null!=e?e:void 0,error:null!=s?s:void 0,complete:null!=i?i:void 0}:o&&T.useDeprecatedNextContext?((r=Object.create(e)).unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&D(e.next,r),error:e.error&&D(e.error,r),complete:e.complete&&D(e.complete,r)}):n=e,o.destination=new q(n),o}return d(e,t),e}(P);function N(t){var e;T.useDeprecatedSynchronousErrorHandling?(e=t,T.useDeprecatedSynchronousErrorHandling&&j&&(j.errorThrown=!0,j.error=e)):C(t)}function F(t,e){var s=T.onStoppedNotification;s&&O.setTimeout((function(){return s(t,e)}))}var U={closed:!0,next:R,error:function(t){throw t},complete:R},V="function"==typeof Symbol&&Symbol.observable||"@@observable";function W(t){return t}var z=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var s=new t;return s.source=this,s.operator=e,s},t.prototype.subscribe=function(t,e,s){var i=this,n=function(t){return t&&t instanceof P||function(t){return t&&b(t.next)&&b(t.error)&&b(t.complete)}(t)&&x(t)}(t)?t:new I(t,e,s);return L((function(){var t=i,e=t.operator,s=t.source;n.add(e?e.call(n,s):s?i._subscribe(n):i._trySubscribe(n))})),n},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var s=this;return new(e=H(e))((function(e,i){var n=new I({next:function(e){try{t(e)}catch(t){i(t),n.unsubscribe()}},error:i,complete:e});s.subscribe(n)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[V]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0===(s=t).length?W:1===s.length?s[0]:function(t){return s.reduce((function(t,e){return e(t)}),t)})(this);var s},t.prototype.toPromise=function(t){var e=this;return new(t=H(t))((function(t,s){var i;e.subscribe((function(t){return i=t}),(function(t){return s(t)}),(function(){return t(i)}))}))},t.create=function(e){return new t(e)},t}();function H(t){var e;return null!==(e=null!=t?t:T.Promise)&&void 0!==e?e:Promise}var $=v((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Y=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return d(e,t),e.prototype.lift=function(t){var e=new J(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new $},e.prototype.next=function(t){var e=this;L((function(){var s,i;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var n=f(e.currentObservers),r=n.next();!r.done;r=n.next())r.value.next(t)}catch(t){s={error:t}}finally{try{r&&!r.done&&(i=n.return)&&i.call(n)}finally{if(s)throw s.error}}}}))},e.prototype.error=function(t){var e=this;L((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var s=e.observers;s.length;)s.shift().error(t)}}))},e.prototype.complete=function(){var t=this;L((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,s=this,i=s.hasError,n=s.isStopped,r=s.observers;return i||n?k:(this.currentObservers=null,r.push(t),new _((function(){e.currentObservers=null,S(r,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,s=e.hasError,i=e.thrownError,n=e.isStopped;s?t.error(i):n&&t.complete()},e.prototype.asObservable=function(){var t=new z;return t.source=this,t},e.create=function(t,e){return new J(t,e)},e}(z),J=function(t){function e(e,s){var i=t.call(this)||this;return i.destination=e,i.source=s,i}return d(e,t),e.prototype.next=function(t){var e,s;null===(s=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===s||s.call(e,t)},e.prototype.error=function(t){var e,s;null===(s=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===s||s.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,s;return null!==(s=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==s?s:k},e}(Y),K=function(t){function e(e){var s=t.call(this)||this;return s._value=e,s}return d(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var s=t.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},e.prototype.getValue=function(){var t=this,e=t.hasError,s=t.thrownError,i=t._value;if(e)throw s;return this._throwIfClosed(),i},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(Y),G={now:function(){return(G.delegate||Date).now()},delegate:void 0},Q=function(t){function e(e,s,i){void 0===e&&(e=1/0),void 0===s&&(s=1/0),void 0===i&&(i=G);var n=t.call(this)||this;return n._bufferSize=e,n._windowTime=s,n._timestampProvider=i,n._buffer=[],n._infiniteTimeWindow=!0,n._infiniteTimeWindow=s===1/0,n._bufferSize=Math.max(1,e),n._windowTime=Math.max(1,s),n}return d(e,t),e.prototype.next=function(e){var s=this,i=s.isStopped,n=s._buffer,r=s._infiniteTimeWindow,o=s._timestampProvider,a=s._windowTime;i||(n.push(e),!r&&n.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),s=this._infiniteTimeWindow,i=this._buffer.slice(),n=0;n<i.length&&!t.closed;n+=s?1:2)t.next(i[n]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,s=t._timestampProvider,i=t._buffer,n=t._infiniteTimeWindow,r=(n?1:2)*e;if(e<1/0&&r<i.length&&i.splice(0,i.length-r),!n){for(var o=s.now(),a=0,c=1;c<i.length&&i[c]<=o;c+=2)a=c;a&&i.splice(0,a+1)}},e}(Y);function X(t){return function(e){if(function(t){return b(null==t?void 0:t.lift)}(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}function Z(t,e,s,i,n){return new tt(t,e,s,i,n)}var tt=function(t){function e(e,s,i,n,r,o){var a=t.call(this,e)||this;return a.onFinalize=r,a.shouldUnsubscribe=o,a._next=s?function(t){try{s(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=n?function(t){try{n(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=i?function(){try{i()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return d(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;t.prototype.unsubscribe.call(this),!s&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(P);function et(){return X((function(t,e){var s,i=!1;t.subscribe(Z(e,(function(t){var n=s;s=t,i&&e.next([n,t]),i=!0})))}))}function st(t,e){return X((function(s,i){var n=0;s.subscribe(Z(i,(function(s){return t.call(e,s,n++)&&i.next(s)})))}))}function it(t,e){return X((function(s,i){var n=0;s.subscribe(Z(i,(function(s){i.next(t.call(e,s,n++))})))}))}var nt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t},rt="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ot(t){if(t instanceof z)return t;if(null!=t){if(function(t){return b(t[V])}(t))return n=t,new z((function(t){var e=n[V]();if(b(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(nt(t))return i=t,new z((function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()}));if(function(t){return b(null==t?void 0:t.then)}(t))return s=t,new z((function(t){s.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,C)}));if(function(t){return Symbol.asyncIterator&&b(null==t?void 0:t[Symbol.asyncIterator])}(t))return at(t);if(function(t){return b(null==t?void 0:t[rt])}(t))return e=t,new z((function(t){var s,i;try{for(var n=f(e),r=n.next();!r.done;r=n.next()){var o=r.value;if(t.next(o),t.closed)return}}catch(t){s={error:t}}finally{try{r&&!r.done&&(i=n.return)&&i.call(n)}finally{if(s)throw s.error}}t.complete()}));if(function(t){return b(null==t?void 0:t.getReader)}(t))return at(function(t){return function(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,n=s.apply(t,e||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(t){return function(e){return Promise.resolve(e).then(t,h)}})),i[Symbol.asyncIterator]=function(){return this},i;function o(t,e){n[t]&&(i[t]=function(e){return new Promise((function(s,i){r.push([t,e,s,i])>1||a(t,e)}))},e&&(i[t]=e(i[t])))}function a(t,e){try{(s=n[t](e)).value instanceof y?Promise.resolve(s.value.v).then(c,h):u(r[0][2],s)}catch(t){u(r[0][3],t)}var s}function c(t){a("next",t)}function h(t){a("throw",t)}function u(t,e){t(e),r.shift(),r.length&&a(r[0][0],r[0][1])}}(this,arguments,(function(){var e,s,i;return p(this,(function(n){switch(n.label){case 0:e=t.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,y(e.read())];case 3:return s=n.sent(),i=s.value,s.done?[4,y(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,y(i)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}}))}))}(t))}var e,s,i,n;throw function(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(t)}function at(t){return new z((function(e){(function(t,e){var s,i,n,r,o,a,c,h;return o=this,a=void 0,h=function(){var o,a;return p(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),s=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,s=t[Symbol.asyncIterator];return s?s.call(t):(t=f(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(s){e[s]=t[s]&&function(e){return new Promise((function(i,n){!function(t,e,s,i){Promise.resolve(i).then((function(e){t({value:e,done:s})}),e)}(i,n,(e=t[s](e)).done,e.value)}))}}}(t),c.label=1;case 1:return[4,s.next()];case 2:if((i=c.sent()).done)return[3,4];if(o=i.value,e.next(o),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),n={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),i&&!i.done&&(r=s.return)?[4,r.call(s)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}}))},new((c=void 0)||(c=Promise))((function(t,e){function s(t){try{n(h.next(t))}catch(t){e(t)}}function i(t){try{n(h.throw(t))}catch(t){e(t)}}function n(e){e.done?t(e.value):function(t){return t instanceof c?t:new c((function(e){e(t)}))}(e.value).then(s,i)}n((h=h.apply(o,a||[])).next())}))})(t,e).catch((function(t){return e.error(t)}))}))}function ct(t){void 0===t&&(t={});var e=t.connector,s=void 0===e?function(){return new Y}:e,i=t.resetOnError,n=void 0===i||i,r=t.resetOnComplete,o=void 0===r||r,a=t.resetOnRefCountZero,c=void 0===a||a;return function(t){var e,i,r,a=0,h=!1,u=!1,l=function(){null==i||i.unsubscribe(),i=void 0},d=function(){l(),e=r=void 0,h=u=!1},p=function(){var t=e;d(),null==t||t.unsubscribe()};return X((function(t,f){a++,u||h||l();var m=r=null!=r?r:s();f.add((function(){0!=--a||u||h||(i=ht(p,c))})),m.subscribe(f),!e&&a>0&&(e=new I({next:function(t){return m.next(t)},error:function(t){u=!0,l(),i=ht(d,n,t),m.error(t)},complete:function(){h=!0,l(),i=ht(d,o),m.complete()}}),ot(t).subscribe(e))}))(t)}}function ht(t,e){for(var s=[],i=2;i<arguments.length;i++)s[i-2]=arguments[i];if(!0!==e){if(!1!==e){var n=new I({next:function(){n.unsubscribe(),t()}});return ot(e.apply(void 0,g([],m(s)))).subscribe(n)}}else t()}function ut(t,e,s){return void 0===s&&(s=1/0),b(e)?ut((function(s,i){return it((function(t,n){return e(s,t,i,n)}))(ot(t(s,i)))}),s):("number"==typeof e&&(s=e),X((function(e,i){return function(t,e,s,i,n,r,o,a){var c=[],h=0,u=0,l=!1,d=function(){!l||c.length||h||e.complete()},p=function(t){return h<i?f(t):c.push(t)},f=function(t){h++;var n=!1;ot(s(t,u++)).subscribe(Z(e,(function(t){e.next(t)}),(function(){n=!0}),void 0,(function(){if(n)try{h--;for(var t=function(){var t=c.shift();f(t)};c.length&&h<i;)t();d()}catch(t){e.error(t)}})))};return t.subscribe(Z(e,p,(function(){l=!0,d()}))),function(){}}(e,i,t,s)})))}const lt=(t,e)=>{const[s,i,n,r]=t,[o,a,c,h]=e,u=Math.max(s,o),l=Math.max(i,a),d=Math.min(n,c),p=Math.min(r,h),f=Math.max(0,d-u)*Math.max(0,p-l);return f/((n-s)*(r-i)+(c-o)*(h-a)-f)},dt=(t,e)=>{const{origWidth:s,origHeight:i}=e,n=t.points.map((([t,e])=>[t*s/100,e*i/100]));return{...t,points:n}},pt=t=>{const{origWidth:e,origHeight:s,inputWidth:i,inputHeight:n}=t,[r,o,a,c]=t.boundingBox,h=r*e/i,u=o*s/n,l=a*e/i,d=c*s/n;return{...t,boundingBox:[h,u,l,d]}},ft=(t,e,s)=>{if(t.confidence<s.object.confidence)return!1;if(0===e.length)return!0;const[i,n,r,o]=t.boundingBox,a={xmin:i,ymin:n,xmax:r,ymax:o};let c=!1;for(const s of e){const e=dt(s,t);if(e.isPrivacyMask){if(gt(a,e.points)){c=!1;break}}else"include"===e.filter?"contain"===e.type?gt(a,e.points)&&(c=!0):"intersect"===e.type&&(mt(a,e.points)||gt(a,e.points))&&(c=!0):"exclude"===e.filter&&("contain"===e.type?gt(a,e.points)||(c=!0):"intersect"===e.type&&(mt(a,e.points)||gt(a,e.points)||(c=!0)))}return c},mt=(t,e)=>{const s=yt(t);for(const t of s)for(let s=0;s<e.length;s++){const i=[e[s],e[(s+1)%e.length]];if(bt(t,i))return!0}return!1},gt=(t,e)=>[[t.xmin,t.ymin],[t.xmax,t.ymin],[t.xmax,t.ymax],[t.xmin,t.ymax]].every((t=>vt(t,e))),yt=t=>{const{xmin:e,ymin:s,xmax:i,ymax:n}=t;return[[[e,s],[i,s]],[[i,s],[i,n]],[[i,n],[e,n]],[[e,n],[e,s]]]},bt=(t,e)=>{const s=(t,e,s)=>(s[1]-t[1])*(e[0]-t[0])>(e[1]-t[1])*(s[0]-t[0]);return i=t[0],n=t[1],s(i,r=e[0],o=e[1])!==s(n,r,o)&&s(i,n,r)!==s(i,n,o);var i,n,r,o},vt=(t,e)=>{const[s,i]=t;let n=!1,[r,o]=e[e.length-1];for(const[t,a]of e)a>i!=o>i&&s<(r-t)*(i-a)/(o-a)+t&&(n=!n),[r,o]=[t,a];return n};class wt extends o{logger;snapshotCache;cameraSubject;cameraState=new K(!1);lightState=new K(this.getLightState({state:!1},!0));motionState=new K(this.getMotionState({detections:[],state:!1},!0));audioState=new K(this.getAudioState({state:!1,db:0},!0));objectState=new K(this.getObjectState({detections:[]},!0));doorbellState=new K(this.getDoorbellState({state:!1},!0));sirenState=new K(this.getSirenState({state:!1,level:0},!0));batteryState=new K(this.getBatteryState({level:100,charging:!1,lowBattery:!1},!0));onConnected=this.createStateObservable(this.cameraState);onLightSwitched=this.createStateObservable(this.lightState);onMotionDetected=this.createStateObservable(this.motionState);onAudioDetected=this.createStateObservable(this.audioState);onObjectDetected=this.createStateObservable(this.objectState);onDoorbellPressed=this.createStateObservable(this.doorbellState);onSirenDetected=this.createStateObservable(this.sirenState);onBatteryChanged=this.createStateObservable(this.batteryState);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((t=>t.roles.includes("snapshot")&&!t.internal))}get highResolutionSource(){return this.sources.find((t=>t.roles.includes("high-resolution")&&!t.internal))}get midResolutionSource(){return this.sources.find((t=>t.roles.includes("mid-resolution")&&!t.internal))}get lowResolutionSource(){return this.sources.find((t=>t.roles.includes("low-resolution")&&!t.internal))}get ptz(){return this.ptzDelegate}constructor(t,e){super(),this.logger=e,this.cameraSubject=new K(t),this.updateCamera(t),this.snapshotCache=new(u())({max:100,ttl:1e3*this.snapshotTTL}),"native"===t.pluginId&&this.cameraState.next(!0)}getValue(t){switch(t){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: ${t}`)}}async snapshot(t){this.snapshotCache.purgeStale();const e=this.snapshotSource||this.streamSource,s=e.urls.www.jpegSnapshot,i=this.snapshotCache.get(e._id);if(!t&&i)return this.logger.trace(this.name,"Snapshot requested (cached)"),i;this.logger.trace(this.name,"Snapshot requested (fetching)");try{if("native"!==this.cameraObject.pluginId){const t=await this.cameraDelegate.snapshot();if(t&&t.byteLength>0)return this.snapshotCache.set(e._id,t),t}const t=new AbortController,i=setTimeout((()=>t.abort()),5e3),n=await fetch(s,{signal:t.signal});if(clearTimeout(i),!n.ok)throw new Error("Status Code: "+n.status);const r=await n.arrayBuffer();return r.byteLength>0&&this.snapshotCache.set(e._id,r),r}catch{return}}onStateChange(t){return this[`${t}State`].pipe(et(),st((([e,s])=>"boolean"==typeof e||"boolean"==typeof s?e!==s:this.stateChanged(e,s,t))),it((([t,e])=>({oldState:t,newState:e}))),ct({connector:()=>new Q(1)}))}onPropertyChange(t){return this.cameraSubject.pipe(et(),ut((([e,s])=>(Array.isArray(t)?t:[t]).map((t=>({property:t,oldData:e[t],newData:s[t]}))))),st((({oldData:t,newData:e})=>!a(t,e,!0))),ct({connector:()=>new Q(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(t){t.snapshotTTL!==this.snapshotTTL&&this.snapshotCache.clear(),this.cameraSubject.next(t)}updateCameraState(t){this.cameraState.next(t)}updateStateInternal(t,e,s){let i,n=!1;if(s)n=!0,i=e;else{const s=this.checkStateInternal(t,e);n=s.changed,i=s.event}if(n)switch(t){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: ${t}`)}}checkStateInternal(t,e){let s,i=!1;switch(t){case"audio":const n=e;s=this.getAudioState(n),i=this.stateChanged(this.getValue("audio"),s,"audio");break;case"light":const r=e;s=this.getLightState(r),i=this.stateChanged(this.getValue("light"),s,"light");break;case"motion":const o=e;void 0!==o.state&&(o.detections=[]),o.detections=((t,e=.2)=>{if(0===t.length)return[];const s=[...t].sort(((t,e)=>{const s=(t.boundingBox[2]-t.boundingBox[0])*(t.boundingBox[3]-t.boundingBox[1]);return(e.boundingBox[2]-e.boundingBox[0])*(e.boundingBox[3]-e.boundingBox[1])-s})),i=[];for(;s.length>0;){let t={...s[0]};s.shift();const n=[];for(let i=0;i<s.length;i++)lt(t.boundingBox,s[i].boundingBox)>e&&n.push(i);if(n.length>0){const e=[t,...n.map((t=>s[t]))],i=[Math.min(...e.map((t=>t.boundingBox[0]))),Math.min(...e.map((t=>t.boundingBox[1]))),Math.max(...e.map((t=>t.boundingBox[2]))),Math.max(...e.map((t=>t.boundingBox[3])))],r=e.reduce(((t,e)=>t.confidence>e.confidence?t:e));t={...r,boundingBox:i,id:r.id||t.id};for(let t=n.length-1;t>=0;t--)s.splice(n[t],1)}i.push(t)}return i})(o.detections),o.detections=((t,e,s)=>{const i=[];for(const n of t)ft(pt(n),e,s)&&e.some((t=>!t.classes.length||t.classes.includes(n.label)))&&i.push(n);return i})(o.detections,this.activityZones,this.activitySettings),s=this.getMotionState(o),i=this.stateChanged(this.getValue("motion"),s,"motion");break;case"object":const a=e;a.detections=((t,e,s)=>{const i=[];for(const n of t)ft(pt(n),e,s)&&e.some((t=>!t.classes.length||t.classes.includes(n.label)))&&i.push(n);return i})(a.detections,this.activityZones,this.activitySettings),s=this.getObjectState(a),i=this.stateChanged(this.getValue("object"),s,"object");break;case"doorbell":const c=e;s=this.getDoorbellState(c),i=this.stateChanged(this.getValue("doorbell"),s,"doorbell");break;case"siren":const h=e;s=this.getSirenState(h),i=this.stateChanged(this.getValue("siren"),s,"siren");break;case"battery":const u=e;s=this.getBatteryState(u),i=this.stateChanged(this.getValue("battery"),s,"battery");break;default:throw new Error(`Unknown state: ${t}`)}return{changed:i,event:s}}stateChanged(t,e,s){if(!t||!e||!s)return!1;if("audio"==s){if(!this.hasAudioDetector)return!1;const s=t,i=e;return s.state!==i.state||s.db!==i.db}if("motion"==s){if(!this.hasMotionDetector)return!1;const s=t,i=e;return void 0!==i.state?s.state!==i.state:!a(s.detections,i.detections,!0)}if("object"==s){if(!this.hasObjectDetector)return!1;const s=e;return!a(t.detections,s.detections,!0)}if("siren"==s){if(!this.hasSiren)return!1;const s=t,i=e;return s.state!==i.state||s.level!==i.level}if("battery"==s){if(!this.hasBattery)return!1;const s=t,i=e;return s.level!==i.level||s.lowBattery!==i.lowBattery||s.charging!==i.charging}if("doorbell"==s){if(!this.hasBinarySensor)return!1;const s=e;return t.state!==s.state}if("light"==s){if(!this.hasLight)return!1;const s=e;return t.state!==s.state}return!1}getAudioState(t,e=!1){let s,i;if(!e){const t=this.getValue("audio");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,db:e.db||s?.db||0,lastEvent:s||(e.state?e:void 0)}}return i}getMotionState(t,e=!1){let s,i;if(!e){const t=this.getValue("motion");t.detections.length?s=t:t.lastEvent?.detections.length&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,lastEvent:s||(e.detections.length?e:void 0)}}return i}getObjectState(t,e=!1){let s,i;if(!e){const t=this.getValue("object");t.detections.length?s=t:t.lastEvent?.detections.length&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,lastEvent:s||(e.detections.length?e:void 0)}}return i}getDoorbellState(t,e=!1){let s,i;if(!e){const t=this.getValue("doorbell");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,lastEvent:s||(e.state?e:void 0)}}return i}getLightState(t,e=!1){let s,i;if(!e){const t=this.getValue("light");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,lastEvent:s||(e.state?e:void 0)}}return i}getSirenState(t,e=!1){let s,i;if(!e){const t=this.getValue("siren");t.state?s=t:t.lastEvent?.state&&(s=t.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,level:e.level||s?.level||0,lastEvent:s||(e.state?e:void 0)}}return i}getBatteryState(t,e=!1){let s,i;if(!e){const e=this.getValue("battery");this.stateChanged(e,t,"battery")?s=e:e.lastEvent&&this.stateChanged(e.lastEvent,t,"battery")&&(s=e.lastEvent),s&&delete s.lastEvent}if(this.isStateEvent(t))i=t;else{const e={...t,timestamp:Date.now()};i={...e,charging:t.charging||s?.charging||!1,lowBattery:t.lowBattery||s?.lowBattery||!1,lastEvent:s||e}}return i}isStateEvent(t){return"timestamp"in t}createStateObservable(t){return t.pipe(ct({connector:()=>new Q(1)}))}}class St{delegate;onRequest;constructor(t){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 _t{delegate;onRequest;constructor(t){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,i){return this.onRequest(t,e,s,i)}}class kt{delegate;onRequest;constructor(t){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 xt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}));class Et extends EventTarget{cameraDevice;socketService;logger;options;videoPlayer;socket;streamId;hasBackchannel=!1;hasAudio=!0;closed=!1;micTransceiver=null;pc=null;buf=new Uint8Array(2097152);mediaSource=null;sourceBuffer=null;bufLen=0;mseCodecs="";videoPlayerMp4;media=["video","audio","microphone"];codecList=[];reconnectTimeout;_finishLoading=!1;_firstFrameReceived=!1;animationFrameId;get mode(){return this.options.mode}webrtcReconnectTimeout;constructor(t,e,s,i){super(),this.options=i,this.videoPlayer=i.videoElement,this.cameraDevice=t,this.socketService=e,this.logger=s;const{socket:n}=this.socketService.getSocket(`${t.id}-go2rtcSession`,!0);this.socket=n,this.socket.connect(),this.streamId=xt(),this.createCodecsList()}connect(t){t&&(this.options.mode=t),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(t){console.log(this.cameraDevice.name,"Reconnecting..."),this.dispatchEvent(new Event("reconnect")),this.close(),await new Promise((t=>setTimeout(t,100))),this.connect(t)}reset(){this._finishLoading=!1,this._firstFrameReceived=!1,this.pc?.getTransceivers().forEach((t=>t.sender?.track?.stop())),this.pc?.close(),this.pc=null,this.videoPlayerMp4?.remove(),this.videoPlayerMp4=void 0,this.videoPlayer.srcObject=null,this.videoPlayer.src="",this.videoPlayer.poster="",void 0!==this.animationFrameId&&("cancelVideoFrameCallback"in this.videoPlayer?this.videoPlayer.cancelVideoFrameCallback(this.animationFrameId):cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}close(){console.log(this.cameraDevice.name,"Closing..."),this.closed=!0,this.reset(),this.disconnect(),this.socket.emit("end"),this.socket.removeAllListeners()}onWsOpen({id:t}){if(t===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:t}){t===this.streamId&&(this.closed||void 0===this.options.reconnectInterval||(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout((()=>{this.reconnect()}),this.options.reconnectInterval)))}onWsMessage({id:t,data:e}){if(t===this.streamId&&e.type){switch(e.type){case"mse":this.onMseData(e);break;case"hls":this.onHlsData(e);break;case"webrtc/candidate":case"webrtc/answer":this.onWebrtcData(e);break;case"mse-binary":this.onMseBuffer(e);break;case"mjpeg-binary":this.onMjpegBuffer(e);break;case"mp4-binary":this.onMp4Buffer(e);break;case"stream-info":this.onStreamInfo(e);break;case"error":this.dispatchEvent(new ErrorEvent("error",{error:e,message:e.value}))}!this._firstFrameReceived&&["mse-binary","mjpeg-binary","mp4-binary"].includes(e.type)&&this.onFirstFrame()}}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",(t=>{if("webrtc/tcp"===this.options.mode&&"udp"===t.candidate?.protocol)return;const e=t.candidate?.toJSON().candidate||"";this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/candidate",value:e}})})),this.pc.addEventListener("connectionstatechange",(()=>{if(console.log(this.cameraDevice.name,"Connection state:",this.pc?.connectionState),"connected"===this.pc?.connectionState){const t=this.pc?.getTransceivers().filter((t=>"recvonly"===t.currentDirection)).map((t=>t.receiver.track));this.videoPlayer.srcObject=new MediaStream(t),this.onFinishLoading(),this.play(),this.disconnect()}else"failed"!==this.pc?.connectionState&&"disconnected"!==this.pc?.connectionState||(clearTimeout(this.webrtcReconnectTimeout),this.webrtcReconnectTimeout=setTimeout((()=>{"failed"!==this.pc?.connectionState&&"disconnected"!==this.pc?.connectionState||this.reconnect()}),1e3))})),this.pc.addTransceiver("video",{direction:"recvonly"}),this.pc.addTransceiver("audio",{direction:"recvonly"}),this.micTransceiver=this.pc.addTransceiver("audio",{direction:"sendonly"});const t=await this.pc.createOffer();await this.pc.setLocalDescription(t),console.log(this.cameraDevice.name,"Offer:",t.sdp),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/offer",value:t.sdp}})}async onWebrtcData(t){try{switch(t.type){case"webrtc/candidate":if("webrtc/tcp"===this.options.mode&&t.value.indexOf(" udp ")>0)return;await(this.pc?.addIceCandidate({candidate:t.value,sdpMid:"0"}));break;case"webrtc/answer":if(console.log(this.cameraDevice.name,"Answer:",t.value),await(this.pc?.setRemoteDescription({type:"answer",sdp:t.value})),!this._firstFrameReceived&&this.pc){const t=this.pc.getReceivers().find((t=>"video"===t.track.kind))?.track;if(t)if("requestVideoFrameCallback"in t)this.animationFrameId=t.requestVideoFrameCallback((()=>{this.onFirstFrame()}));else{const t=()=>{this.videoPlayer.readyState>=2&&this.videoPlayer.videoWidth>0?this.onFirstFrame():this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}}break;case"error":if(console.log(this.cameraDevice.name,"WebRTC Error:",t.value),t.value.indexOf("webrtc/offer")<0)return;this.pc?.close()}}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:t,message:t.message}))}}requestMse(){if(this.reset(),"ManagedMediaSource"in window){console.log(this.cameraDevice.name,"Using ManagedMediaSource");const t=window.ManagedMediaSource;this.mediaSource=new t,this.mediaSource.addEventListener("sourceopen",(()=>{this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mse",value:this.parseCodecs(t.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(t){this.mediaSource&&(this.mseCodecs=t.value,this.bufLen=0,this.buf=new Uint8Array(2097152),this.sourceBuffer=this.mediaSource.addSourceBuffer(t.value),this.sourceBuffer.mode="segments",this.sourceBuffer.addEventListener("updateend",(()=>{if(!this.sourceBuffer?.updating)try{if(this.bufLen>0){const t=this.buf.slice(0,this.bufLen);this.bufLen=0,this.sourceBuffer?.appendBuffer(t)}else if(this.sourceBuffer?.buffered?.length){const t=this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1)-15,e=this.sourceBuffer.buffered.start(0);t>e&&(this.sourceBuffer.remove(e,t),this.mediaSource?.setLiveSeekableRange(t,t+15))}}catch{}})))}async onMseBuffer(t){if("closed"!==this.mediaSource?.readyState)if(this.onFinishLoading(),this.sourceBuffer?.updating||this.bufLen>0){const e=new Uint8Array(t.value);this.buf.set(e,this.bufLen),this.bufLen+=e.byteLength}else try{this.sourceBuffer?.appendBuffer(t.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(t){this.videoPlayer.controls=!1,this.videoPlayer.poster="data:image/jpeg;base64,"+this.btoaBinary(t.value),this.onFinishLoading()}requestMp4(){this.reset();const t=document.createElement("canvas");let e=null;this.videoPlayerMp4=document.createElement("video"),this.videoPlayerMp4.autoplay=!0,this.videoPlayerMp4.playsInline=!0,this.videoPlayerMp4.muted=!0,this.videoPlayerMp4.addEventListener("loadeddata",(()=>{this.videoPlayerMp4&&(e||(t.width=this.videoPlayerMp4.videoWidth,t.height=this.videoPlayerMp4.videoHeight,e=t.getContext("2d")),e?.drawImage(this.videoPlayerMp4,0,0,t.width,t.height),this.videoPlayer.controls=!1,this.videoPlayer.poster=t.toDataURL("image/jpeg"))}));const s=this.codecList.filter((t=>this.media.includes(t.indexOf("vc1")>0?"video":"audio"))).filter((t=>this.videoPlayer.canPlayType(`video/mp4; codecs="${t}"`))).join();console.log(this.cameraDevice.name,"Playable codecs (MP4):",s),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mp4",value:s}})}onMp4Buffer(t){this.onFinishLoading(),this.videoPlayerMp4&&(this.videoPlayerMp4.src="data:video/mp4;base64,"+this.btoaBinary(t.value))}requestHls(){this.reset();const t=this.parseCodecs((t=>this.videoPlayer.canPlayType(t)));console.log(this.cameraDevice.name,"Playable codecs (HLS):",t),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"hls",value:t}})}onHlsData(t){const e="http"+t.wsURL.substring(2,t.wsURL.indexOf("/ws"))+"/hls/",s=t.value.replace("hls/",e),i="data:application/vnd.apple.mpegurl;base64,"+btoa(s.toString());this.videoPlayer.src=i,this.onFinishLoading(),this.play()}onStreamInfo(t){const e=t.value,s=e?.producers[0];s&&(this.hasBackchannel=s.senders?.some((t=>"audio"===t.codec.codec_type))||!1,this.hasAudio=s.receivers?.some((t=>"audio"===t.codec.codec_type))||!1)}async play(){try{await this.videoPlayer.play()}catch(t){if(!this.videoPlayer.muted)return this.videoPlayer.muted=!0,this.play();this.logger.warn(this.cameraDevice.name,t)}}onFirstFrame(){this._firstFrameReceived||(this._firstFrameReceived=!0,this.dispatchEvent(new Event("onFirstFrame")),console.log(this.cameraDevice.name,"First frame received"))}onFinishLoading(){this._finishLoading||(this._finishLoading=!0,this.dispatchEvent(new Event("onFinishLoading")))}createCodecsList(){const t=["avc1.640029","avc1.64002A","avc1.640033","hvc1.1.6.L153.B0","mp4a.40.2","mp4a.40.5","flac","opus"],e="undefined"==typeof window?null:navigator.userAgent.match(/Version\/(\d+).+Safari/);if(e?.[1]){const s=e[1]<"13"?"mp4a.40.2":e[1]<"14"?"flac":"opus";t.splice(t.indexOf(s))}this.codecList=t}parseCodecs(t){return this.codecList.filter((t=>this.media.includes(t.indexOf("vc1")>0?"video":"audio"))).filter((e=>t(`video/mp4; codecs="${e}"`))).join()}btoaBinary(t){const e=new Uint8Array(t),s=e.byteLength;let i="";for(let t=0;t<s;t++)i+=String.fromCharCode(e[t]);return window.btoa(i)}}class Tt extends wt{socketService;socket;pluginName="@camera.ui/client";subject;_started=!1;get started(){return this._started}cameraDelegate=new St(this.onRequest.bind(this));ptzDelegate=new kt(this.onRequest.bind(this));prebufferDelegate=new _t(this.onRequest.bind(this));get sources(){return this._sources.filter((t=>!t.internal))}get internalSources(){return this._sources.map((t=>({...t,type:t.name.endsWith(" AAC")?"aac":t.name.endsWith(" OPUS")?"opus":"pcma"}))).filter((t=>t.internal))}get _sources(){return JSON.parse(JSON.stringify(this.cameraSubject.getValue().sources)).map((t=>({...t,getPrebufferingState:e=>this.prebufferDelegate.getPrebufferingState(t.name,e),probeStream:()=>this.onRequest("cameraFn","probeStream",[t._id])})))}constructor(t,e,s){super(t,s),this.socketService=e;const{socket:i}=this.socketService.getSocket(this.id,!0);this.socket=i,this.socket.connect(),this.subject=`${this.pluginName}.camera.${this.id}`,this.listenToMessages()}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(t){return new Et(this,this.socketService,this.logger,t)}async refreshStates(){const t=await this.onRequest("cameraFn","refreshStates");super.updateCamera(t.camera),super.updateCameraState(t.cameraState);for(const[e,s]of Object.entries(t.states))super.updateStateInternal(e,s,!0)}async cleanup(){this.stop(),this.removeAllListeners(),this.unsubscribe(),this.socket.removeAllListeners()}listenToMessages(){this.socket.emit("joinRoomDevice",this.id),this.socket.on("updateState",(t=>{t.cameraId===this.id&&super.updateStateInternal(t.stateName,t.data.newEvent,!0)})),this.socket.on("updateDevice",(t=>{if(t.cameraId===this.id)switch(t.type){case"removed":this.cleanup();break;case"updated":super.updateCamera(t.data);break;case"cameraState":super.updateCameraState(t.data)}}))}onRequest(t,e,s=[]){const i={requestId:xt(),targetId:this.subject,targetName:this.name,pluginId:this.pluginName,cameraId:this.id,type:"request",proxy:"camera",client:t,fn:e,args:s,timestamp:Date.now(),timeout:5e3};return new Promise(((t,e)=>{this.socket.emit("request",i,(s=>{s.error?e(s.error):t(s.response)}))}))}}class Ot{socketService;socket;logger;pluginName="@camera.ui/client";subject;constructor(t,e){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:xt(),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(((t,e)=>{this.socket.emit("request",s,(s=>{s.error?e(s.error):t(s.response)}))}))}}class Ct{socketService;socket;logger;pluginName="@camera.ui/client";subject;constructor(t,e){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 t=new Tt(e,this.socketService,this.logger);return await t.refreshStates(),t}}async getCameraByName(t){const e=await this.onRequest("getCameraByName",[t]);if(e){const t=new Tt(e,this.socketService,this.logger);return await t.refreshStates(),t}}onRequest(t,e){const s={requestId:xt(),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(((t,e)=>{this.socket.emit("request",s,(s=>{s.error?e(s.error):t(s.response)}))}))}}const Rt=Object.create(null);Rt.open="0",Rt.close="1",Rt.ping="2",Rt.pong="3",Rt.message="4",Rt.upgrade="5",Rt.noop="6";const At=Object.create(null);Object.keys(Rt).forEach((t=>{At[Rt[t]]=t}));const Bt={type:"error",data:"parser error"},jt="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Lt="function"==typeof ArrayBuffer,Pt=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Mt=({type:t,data:e},s,i)=>jt&&e instanceof Blob?s?i(e):Dt(e,i):Lt&&(e instanceof ArrayBuffer||Pt(e))?s?i(e):Dt(new Blob([e]),i):i(Rt[t]+(e||"")),Dt=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function qt(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let It;const Nt="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)Nt["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const Ft="function"==typeof ArrayBuffer,Ut=(t,e)=>{if("string"!=typeof t)return{type:"message",data:Wt(t,e)};const s=t.charAt(0);return"b"===s?{type:"message",data:Vt(t.substring(1),e)}:At[s]?t.length>1?{type:At[s],data:t.substring(1)}:{type:At[s]}:Bt},Vt=(t,e)=>{if(Ft){const s=(t=>{let e,s,i,n,r,o=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const h=new ArrayBuffer(o),u=new Uint8Array(h);for(e=0;e<a;e+=4)s=Nt[t.charCodeAt(e)],i=Nt[t.charCodeAt(e+1)],n=Nt[t.charCodeAt(e+2)],r=Nt[t.charCodeAt(e+3)],u[c++]=s<<2|i>>4,u[c++]=(15&i)<<4|n>>2,u[c++]=(3&n)<<6|63&r;return h})(t);return Wt(s,e)}return{base64:!0,data:t}},Wt=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,zt=String.fromCharCode(30);let Ht;function $t(t){return t.reduce(((t,e)=>t+e.length),0)}function Yt(t,e){if(t[0].length===e)return t.shift();const s=new Uint8Array(e);let i=0;for(let n=0;n<e;n++)s[n]=t[0][i++],i===t[0].length&&(t.shift(),i=0);return t.length&&i<t[0].length&&(t[0]=t[0].slice(i)),s}function Jt(t){if(t)return function(t){for(var e in Jt.prototype)t[e]=Jt.prototype[e];return t}(t)}Jt.prototype.on=Jt.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},Jt.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},Jt.prototype.off=Jt.prototype.removeListener=Jt.prototype.removeAllListeners=Jt.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,i=this._callbacks["$"+t];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n=0;n<i.length;n++)if((s=i[n])===e||s.fn===e){i.splice(n,1);break}return 0===i.length&&delete this._callbacks["$"+t],this},Jt.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+t],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(s){i=0;for(var n=(s=s.slice(0)).length;i<n;++i)s[i].apply(this,e)}return this},Jt.prototype.emitReserved=Jt.prototype.emit,Jt.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},Jt.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Kt="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Gt="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Qt(t,...e){return e.reduce(((e,s)=>(t.hasOwnProperty(s)&&(e[s]=t[s]),e)),{})}const Xt=Gt.setTimeout,Zt=Gt.clearTimeout;function te(t,e){e.useNativeTimers?(t.setTimeoutFn=Xt.bind(Gt),t.clearTimeoutFn=Zt.bind(Gt)):(t.setTimeoutFn=Gt.setTimeout.bind(Gt),t.clearTimeoutFn=Gt.clearTimeout.bind(Gt))}function ee(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class se extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class ie extends Jt{constructor(t){super(),this.writable=!1,te(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,s){return super.emitReserved("error",new se(t,e,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Ut(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-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(t[s]));return e}(t);return e.length?"?"+e:""}}class ne extends ie{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let t=0;this._polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const s=t.split(zt),i=[];for(let t=0;t<s.length;t++){const n=Ut(s[t],e);if(i.push(n),"error"===n.type)break}return i})(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const s=t.length,i=new Array(s);let n=0;t.forEach(((t,r)=>{Mt(t,!1,(t=>{i[r]=t,++n===s&&e(i.join(zt))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=ee()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}}let re=!1;try{re="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const oe=re;function ae(){}class ce extends ne{constructor(t){if(super(t),"undefined"!=typeof location){const e="https:"===location.protocol;let s=location.port;s||(s=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||s!==t.port}}doWrite(t,e){const s=this.request({method:"POST",data:t});s.on("success",e),s.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}class he extends Jt{constructor(t,e,s){super(),this.createRequest=t,te(this,s),this._opts=s,this._method=s.method||"GET",this._uri=e,this._data=void 0!==s.data?s.data:null,this._create()}_create(){var t;const e=Qt(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(e);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this._opts.extraHeaders[t])}}catch(t){}if("POST"===this._method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{s.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this._opts.cookieJar)||void 0===t||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var t;3===s.readyState&&(null===(t=this._opts.cookieJar)||void 0===t||t.parseCookies(s.getResponseHeader("set-cookie"))),4===s.readyState&&(200===s.status||1223===s.status?this._onLoad():this.setTimeoutFn((()=>{this._onError("number"==typeof s.status?s.status:0)}),0))},s.send(this._data)}catch(t){return void this.setTimeoutFn((()=>{this._onError(t)}),0)}"undefined"!=typeof document&&(this._index=he.requestsCount++,he.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=ae,t)try{this._xhr.abort()}catch(t){}"undefined"!=typeof document&&delete he.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}function ue(){for(let t in he.requests)he.requests.hasOwnProperty(t)&&he.requests[t].abort()}he.requestsCount=0,he.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",ue):"function"==typeof addEventListener&&addEventListener("onpagehide"in Gt?"pagehide":"unload",ue,!1));const le=function(){const t=de({xdomain:!1});return t&&null!==t.responseType}();function de(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||oe))return new XMLHttpRequest}catch(t){}if(!e)try{return new(Gt[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}const pe="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class fe extends ie{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,s=pe?{}:Qt(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,s)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const s=t[e],i=e===t.length-1;Mt(s,this.supportsBinary,(t=>{try{this.doWrite(s,t)}catch(t){}i&&Kt((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=ee()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const me=Gt.WebSocket||Gt.MozWebSocket,ge={websocket:class extends fe{createSocket(t,e,s){return pe?new me(t,e,s):e?new me(t,e):new me(t)}doWrite(t,e){this.ws.send(e)}},webtransport:class extends ie{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this._transport.ready.then((()=>{this._transport.createBidirectionalStream().then((t=>{const e=function(t,e){Ht||(Ht=new TextDecoder);const s=[];let i=0,n=-1,r=!1;return new TransformStream({transform(o,a){for(s.push(o);;){if(0===i){if($t(s)<1)break;const t=Yt(s,1);r=!(128&~t[0]),n=127&t[0],i=n<126?3:126===n?1:2}else if(1===i){if($t(s)<2)break;const t=Yt(s,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),i=3}else if(2===i){if($t(s)<8)break;const t=Yt(s,8),e=new DataView(t.buffer,t.byteOffset,t.length),r=e.getUint32(0);if(r>Math.pow(2,21)-1){a.enqueue(Bt);break}n=r*Math.pow(2,32)+e.getUint32(4),i=3}else{if($t(s)<n)break;const t=Yt(s,n);a.enqueue(Ut(r?t:Ht.decode(t),e)),i=0}if(0===n||n>t){a.enqueue(Bt);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),i=new TransformStream({transform(t,e){!function(t,e){jt&&t.data instanceof Blob?t.data.arrayBuffer().then(qt).then(e):Lt&&(t.data instanceof ArrayBuffer||Pt(t.data))?e(qt(t.data)):Mt(t,!1,(t=>{It||(It=new TextEncoder),e(It.encode(t))}))}(t,(s=>{const i=s.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,i)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(i))}t.data&&"string"!=typeof t.data&&(n[0]|=128),e.enqueue(n),e.enqueue(s)}))}});i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const n=()=>{s.read().then((({done:t,value:e})=>{t||(this.onPacket(e),n())})).catch((t=>{}))};n();const r={type:"open"};this.query.sid&&(r.data=`{"sid":"${this.query.sid}"}`),this._writer.write(r).then((()=>this.onOpen()))}))}))}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const s=t[e],i=e===t.length-1;this._writer.write(s).then((()=>{i&&Kt((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this._transport)||void 0===t||t.close()}},polling:class extends ce{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=le&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new he(de,this.uri(),t)}}},ye=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,be=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ve(t){if(t.length>8e3)throw"URI too long";const e=t,s=t.indexOf("["),i=t.indexOf("]");-1!=s&&-1!=i&&(t=t.substring(0,s)+t.substring(s,i).replace(/:/g,";")+t.substring(i,t.length));let n=ye.exec(t||""),r={},o=14;for(;o--;)r[be[o]]=n[o]||"";return-1!=s&&-1!=i&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=function(t,e){const s=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||s.splice(0,1),"/"==e.slice(-1)&&s.splice(s.length-1,1),s}(0,r.path),r.queryKey=function(t,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,i){e&&(s[e]=i)})),s}(0,r.query),r}const we="function"==typeof addEventListener&&"function"==typeof removeEventListener,Se=[];we&&addEventListener("offline",(()=>{Se.forEach((t=>t()))}),!1);class _e extends Jt{constructor(t,e){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&"object"==typeof t&&(e=t,t=null),t){const s=ve(t);e.hostname=s.host,e.secure="https"===s.protocol||"wss"===s.protocol,e.port=s.port,s.query&&(e.query=s.query)}else e.host&&(e.hostname=ve(e.host).host);te(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach((t=>{const e=t.prototype.name;this.transports.push(e),this._transportsByName[e]=t})),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?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},s=t.split("&");for(let t=0,i=s.length;t<i;t++){let i=s[t].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}(this.opts.query)),we&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Se.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),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 this._transportsByName[t](s)}_open(){if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);const t=this.opts.rememberUpgrade&&_e.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}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",(t=>this._onClose("transport close",t)))}onOpen(){this.readyState="open",_e.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();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._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn((()=>{this._onClose("ping timeout")}),t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&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&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const i=this.writeBuffer[s].data;if(i&&(t+="string"==typeof(e=i)?function(t){let e=0,s=0;for(let i=0,n=t.length;i<n;i++)e=t.charCodeAt(i),e<128?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(i++,s+=4);return s}(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}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Kt((()=>{this._onClose("ping timeout")}),this.setTimeoutFn)),t}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,i){if("function"==typeof e&&(i=e,e=void 0),"function"==typeof s&&(i=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const n={type:t,data:e,options:s};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),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"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?s():t()})):this.upgrading?s():t()),this}_onError(t){if(_e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),we&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const t=Se.indexOf(this._offlineEventListener);-1!==t&&Se.splice(t,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}_e.protocol=4;class ke extends _e{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),s=!1;_e.priorWebsocketSuccess=!1;const i=()=>{s||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!s)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;_e.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(h(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function n(){s||(s=!0,h(),e.close(),e=null)}const r=t=>{const s=new Error("probe error: "+t);s.transport=e.name,n(),this.emitReserved("upgradeError",s)};function o(){r("transport closed")}function a(){r("socket closed")}function c(t){e&&t.name!==e.name&&n()}const h=()=>{e.removeListener("open",i),e.removeListener("error",r),e.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};e.once("open",i),e.once("error",r),e.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{s||e.open()}),200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let s=0;s<t.length;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}class xe extends ke{constructor(t,e={}){const s="object"==typeof t?t:e;(!s.transports||s.transports&&"string"==typeof s.transports[0])&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map((t=>ge[t])).filter((t=>!!t))),super(t,s)}}const Ee="function"==typeof ArrayBuffer,Te=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Oe=Object.prototype.toString,Ce="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Oe.call(Blob),Re="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Oe.call(File);function Ae(t){return Ee&&(t instanceof ArrayBuffer||Te(t))||Ce&&t instanceof Blob||Re&&t instanceof File}function Be(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,s=t.length;e<s;e++)if(Be(t[e]))return!0;return!1}if(Ae(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return Be(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&Be(t[e]))return!0;return!1}function je(t){const e=[],s=t.data,i=t;return i.data=Le(s,e),i.attachments=e.length,{packet:i,buffers:e}}function Le(t,e){if(!t)return t;if(Ae(t)){const s={_placeholder:!0,num:e.length};return e.push(t),s}if(Array.isArray(t)){const s=new Array(t.length);for(let i=0;i<t.length;i++)s[i]=Le(t[i],e);return s}if("object"==typeof t&&!(t instanceof Date)){const s={};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=Le(t[i],e));return s}return t}function Pe(t,e){return t.data=Me(t.data,e),delete t.attachments,t}function Me(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let s=0;s<t.length;s++)t[s]=Me(t[s],e);else if("object"==typeof t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(t[s]=Me(t[s],e));return t}const De=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],qe=5;var Ie;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(Ie||(Ie={}));class Ne{constructor(t){this.replacer=t}encode(t){return t.type!==Ie.EVENT&&t.type!==Ie.ACK||!Be(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===Ie.EVENT?Ie.BINARY_EVENT:Ie.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==Ie.BINARY_EVENT&&t.type!==Ie.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=je(t),s=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(s),i}}function Fe(t){return"[object Object]"===Object.prototype.toString.call(t)}class Ue extends Jt{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const s=e.type===Ie.BINARY_EVENT;s||e.type===Ie.BINARY_ACK?(e.type=s?Ie.EVENT:Ie.ACK,this.reconstructor=new Ve(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!Ae(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(void 0===Ie[s.type])throw new Error("unknown packet type "+s.type);if(s.type===Ie.BINARY_EVENT||s.type===Ie.BINARY_ACK){const i=e+1;for(;"-"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(i,e);if(n!=Number(n)||"-"!==t.charAt(e))throw new Error("Illegal attachments");s.attachments=Number(n)}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 i=t.charAt(e+1);if(""!==i&&Number(i)==i){const i=e+1;for(;++e;){const s=t.charAt(e);if(null==s||Number(s)!=s){--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(!Ue.isPayloadValid(s.type,i))throw new Error("invalid payload");s.data=i}return s}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(t){return!1}}static isPayloadValid(t,e){switch(t){case Ie.CONNECT:return Fe(e);case Ie.DISCONNECT:return void 0===e;case Ie.CONNECT_ERROR:return"string"==typeof e||Fe(e);case Ie.EVENT:case Ie.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===De.indexOf(e[0]));case Ie.ACK:case Ie.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ve{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=Pe(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function We(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const ze=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class He extends Jt{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=[We(t,"open",this.onopen.bind(this)),We(t,"packet",this.onpacket.bind(this)),We(t,"error",this.onerror.bind(this)),We(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var s,i,n;if(ze.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 r={type:Ie.EVENT,data:e,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,s=e.pop();this._registerAckCallback(t,s),r.id=t}const o=null===(i=null===(s=this.io.engine)||void 0===s?void 0:s.transport)||void 0===i?void 0:i.writable,a=this.connected&&!(null===(n=this.io.engine)||void 0===n?void 0:n._hasPingExpired());return this.flags.volatile&&!o||(a?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(t,e){var s;const i=null!==(s=this.flags.timeout)&&void 0!==s?s:this._opts.ackTimeout;if(void 0===i)return void(this.acks[t]=e);const n=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),i),r=(...t)=>{this.io.clearTimeoutFn(n),e.apply(this,t)};r.withError=!0,this.acks[t]=r}emitWithAck(t,...e){return new Promise(((s,i)=>{const n=(t,e)=>t?i(t):s(e);n.withError=!0,e.push(n),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...i)=>{if(s===this._queue[0])return null!==t?s.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...i)),s.pending=!1,this._drainQueue()})),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)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(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Ie.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 Ie.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 Ie.EVENT:case Ie.BINARY_EVENT:this.onevent(t);break;case Ie.ACK:case Ie.BINARY_ACK:this.onack(t);break;case Ie.DISCONNECT:this.ondisconnect();break;case Ie.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||[];null!=t.id&&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&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let s=!1;return function(...i){s||(s=!0,e.packet({type:Ie.ACK,id:t,data:i}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(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:Ie.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 $e(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}$e.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*t);t=1&Math.floor(10*e)?t+s:t-s}return 0|Math.min(t,this.max)},$e.prototype.reset=function(){this.attempts=0},$e.prototype.setMin=function(t){this.ms=t},$e.prototype.setMax=function(t){this.max=t},$e.prototype.setJitter=function(t){this.jitter=t};class Ye extends Jt{constructor(t,e){var s;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,te(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=e.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new $e({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new xe(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=We(e,"open",(function(){s.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},r=We(e,"error",n);if(!1!==this._timeout){const t=this._timeout,s=this.setTimeoutFn((()=>{i(),n(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&s.unref(),this.subs.push((()=>{this.clearTimeoutFn(s)}))}return this.subs.push(i),this.subs.push(r),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(We(t,"ping",this.onping.bind(this)),We(t,"data",this.ondata.bind(this)),We(t,"error",this.onerror.bind(this)),We(t,"close",this.onclose.bind(this)),We(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){Kt((()=>{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 He(this,t,e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].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")}disconnect(){return this._close()}onclose(t,e){var s;this.cleanup(),null===(s=this.engine)||void 0===s||s.close(),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((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):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 Je={};function Ke(t,e){"object"==typeof t&&(e=t,t=void 0);const s=function(t,e="",s){let i=t;s=s||"undefined"!=typeof location&&location,null==t&&(t=s.protocol+"//"+s.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?s.protocol+t:s.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==s?s.protocol+"//"+t:"https://"+t),i=ve(t)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const n=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+e,i.href=i.protocol+"://"+n+(s&&s.port===i.port?"":":"+i.port),i}(t,(e=e||{}).path||"/socket.io"),i=s.source,n=s.id,r=s.path,o=Je[n]&&r in Je[n].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?a=new Ye(i,e):(Je[n]||(Je[n]=new Ye(i,e)),a=Je[n]),s.query&&!e.query&&(e.query=s.queryKey),a.socket(s.path,e)}Object.assign(Ke,{Manager:Ye,Socket:He,io:Ke,connect:Ke});class Ge{socket;token;endpoint;socketList=new Map;constructor(t,e){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 Ye(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 Qe{api;socketService;config;logger;token;deviceManager;coreManager;constructor(t){this.config=t,this.logger=t.logger||{...console,attention:console.warn},this.api=new r(t.endpoint)}async connect(){return this.deviceManager&&this.coreManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new Ge(this.config.endpoint,this.token),this.coreManager=new Ot(this.socketService,this.logger),this.deviceManager=new Ct(this.socketService,this.logger),this.checkSession()),{coreManager:this.coreManager,deviceManager:this.deviceManager}}async disconnect(){this.socketService?.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(){if(this.config.username&&this.config.password)try{const t=await this.api.post("/auth/login",{username:this.config.username,password:this.config.password}),e=await t.json();this.token=e.access_token}catch(t){throw 401===t.response?.status?new Error("Invalid credentials"):new Error(`Failed to get token: ${t.message}`)}else if(this.config.token&&!this.config.skipCheck)try{await this.api.get("/auth/check",{headers:{Authorization:`Bearer ${this.config.token}`}})}catch(t){throw new Error(`Invalid token: ${t.message}`)}this.token=this.token||this.config.token}getDeviceManager(){return this.deviceManager}checkSession(){this.socketService?.socket.removeListener("invalidToken"),this.socketService?.socket.on("invalidToken",(async t=>{t===this.token&&await this.disconnect()}))}cleanUpClient(){this.deviceManager=void 0}}var Xe=i.j;export{Xe as CameraUiClient};
1
+ var e={855:e=>{const t="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,r=()=>t.now(),n=e=>e===1/0||(e=>e&&e===Math.floor(e)&&e>0&&isFinite(e))(e);class i{constructor({max:e=1/0,ttl:t,updateAgeOnGet:r=!1,checkAgeOnGet:i=!1,noUpdateTTL:s=!1,dispose:o,noDisposeOnSet:a=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,void 0!==t&&!n(t))throw new TypeError("ttl must be positive integer or Infinity if set");if(!n(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=t,this.max=e,this.updateAgeOnGet=!!r,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!s,this.noDisposeOnSet=!!a,void 0!==o){if("function"!=typeof o)throw new TypeError("dispose must be function if set");this.dispose=o}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,t){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);const n=setTimeout((()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(const e in this.expirations){this.setTimer(e,e-r());break}}),t);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}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 e=this.dispose!==i.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(const[t,r]of e)this.dispose(r,t,"delete")}setTTL(e,t=this.ttl){const n=this.expirationMap.get(e);if(void 0!==n){const t=this.expirations[n];!t||t.length<=1?delete this.expirations[n]:this.expirations[n]=t.filter((t=>t!==e))}if(t!==1/0){const n=Math.floor(r()+t);this.expirationMap.set(e,n),this.expirations[n]||(this.expirations[n]=[],this.setTimer(n,t)),this.expirations[n].push(e)}else this.expirationMap.set(e,1/0)}set(e,t,{ttl:r=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:s=this.noDisposeOnSet}={}){if(!n(r))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,r);const n=this.data.get(e);n!==t&&(this.data.set(e,t),s||this.dispose(n,e,"set"))}else this.setTTL(e,r),this.data.set(e,t);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){const t=this.expirationMap.get(e);return t===1/0?t:void 0!==t?Math.max(0,Math.ceil(t-r())):0}get(e,{updateAgeOnGet:t=this.updateAgeOnGet,ttl:r=this.ttl,checkAgeOnGet:n=this.checkAgeOnGet}={}){const i=this.data.get(e);if(!n||0!==this.getRemainingTTL(e))return t&&this.setTTL(e,r),i;this.delete(e)}dispose(e,t){}delete(e){const t=this.expirationMap.get(e);if(void 0!==t){const r=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);const n=this.expirations[t];return n&&(n.length<=1?delete this.expirations[t]:this.expirations[t]=n.filter((t=>t!==e))),this.dispose(r,e,"delete"),0===this.size&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(const e in this.expirations){const t=this.expirations[e];if(!(this.size-t.length>=this.max)){const e=this.size-this.max,r=[];for(const n of t.splice(0,e))r.push([n,this.data.get(n)]),this.data.delete(n),this.expirationMap.delete(n);for(const[e,t]of r)this.dispose(t,e,"evict");return}{delete this.expirations[e];const r=[];for(const e of t)r.push([e,this.data.get(e)]),this.data.delete(e),this.expirationMap.delete(e);for(const[e,t]of r)this.dispose(t,e,"evict")}}}get size(){return this.data.size}purgeStale(){const e=Math.ceil(r());for(const t in this.expirations){if("Infinity"===t||t>e)return;const r=[...this.expirations[t]||[]],n=[];delete this.expirations[t];for(const e of r)n.push([e,this.data.get(e)]),this.data.delete(e),this.expirationMap.delete(e);for(const[e,t]of n)this.dispose(t,e,"stale")}0===this.size&&this.cancelTimer()}*entries(){for(const e in this.expirations)for(const t of this.expirations[e])yield[t,this.data.get(t)]}*keys(){for(const e in this.expirations)for(const t of this.expirations[e])yield t}*values(){for(const e in this.expirations)for(const t of this.expirations[e])yield this.data.get(t)}[Symbol.iterator](){return this.entries()}}e.exports=i}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.d(n,{j:()=>Cr});var i={};r.r(i),r.d(i,{Decoder:()=>vr,Encoder:()=>yr,PacketType:()=>mr,protocol:()=>gr});class s{baseURL;abortControllers=new Set;constructor(e){this.baseURL=`${e}/api`}async request(e,t,r,n={}){const i=new AbortController;this.abortControllers.add(i);const s=setTimeout((()=>{i.abort(),this.abortControllers.delete(i)}),15e3);try{const s=await fetch(`${this.baseURL}${t}`,{method:e,headers:{"Content-Type":"application/json",...n.headers},body:r?JSON.stringify(r):void 0,signal:i.signal,...n});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s}finally{clearTimeout(s),this.abortControllers.delete(i)}}get(e,t){return this.request("GET",e,void 0,t)}post(e,t,r){return this.request("POST",e,t,r)}}process.env.CAMERA_UI_RUNMODE,process.env.CAMERA_UI_RUNMODE,process.env.CAMERA_UI_RUNMODE,process.env.CAMERA_UI_AS_SERVICE;class o{subscriptions=[];additionalSubscriptions=[];addSubscriptions(...e){this.subscriptions.push(...e)}addAdditionalSubscriptions(...e){this.additionalSubscriptions.push(...e)}unsubscribe(){this.subscriptions.forEach((e=>e.unsubscribe()))}unsubscribeAdditional(){this.additionalSubscriptions.forEach((e=>e.unsubscribe()))}}function a(e,t,r=!1){if(e===t)return!0;if((void 0===e||void 0===t||null===e||null===t)&&(e||t))return!1;const n=e?.constructor.name,i=t?.constructor.name;if(n!==i)return!1;if("Array"===n&&"Array"===i){if(e.length!==t.length)return!1;if(r){const n=[...t];return e.every((e=>{const t=n.findIndex((t=>a(e,t,r)));return-1!==t&&(n.splice(t,1),!0)}))}{let n=!0;for(let i=0;i<e.length;i++)if(!a(e[i],t[i],r)){n=!1;break}return n}}if("Object"===n&&"Object"===i){let n=!0;const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let s=0;s<i.length;s++)if(e[i[s]]&&t[i[s]]){if(e[i[s]]===t[i[s]])continue;if(!e[i[s]]||"Array"!==e[i[s]].constructor.name&&"Object"!==e[i[s]].constructor.name){if(e[i[s]]!==t[i[s]]){n=!1;break}}else if(n=a(e[i[s]],t[i[s]],r),!n)break}else if(e[i[s]]&&!t[i[s]]||!e[i[s]]&&t[i[s]]){n=!1;break}return n}return e===t}function c(e){return JSON.parse(JSON.stringify(e))}var h=r(855),u=r.n(h),l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},l(e,t)};function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function d(e,t){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function m(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function b(e){return"function"==typeof e}function v(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var w=v((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function S(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var _=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var o=f(s),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(b(c))try{c()}catch(e){i=e instanceof w?e.errors:[e]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var u=f(h),l=u.next();!l.done;l=u.next()){var p=l.value;try{x(p)}catch(e){i=null!=i?i:[],e instanceof w?i=m(m([],g(i)),g(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}}if(i)throw new w(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)x(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&S(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&S(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),k=_.EMPTY;function E(e){return e instanceof _||e&&"closed"in e&&b(e.remove)&&b(e.add)&&b(e.unsubscribe)}function x(e){b(e)?e():e.unsubscribe()}var T={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},O={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=O.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,m([e,t],g(r))):setTimeout.apply(void 0,m([e,t],g(r)))},clearTimeout:function(e){var t=O.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function P(e){O.setTimeout((function(){var t=T.onUnhandledError;if(!t)throw e;t(e)}))}function C(){}var A=R("C",void 0,void 0);function R(e,t,r){return{kind:e,value:t,error:r}}var M=null;function L(e){if(T.useDeprecatedSynchronousErrorHandling){var t=!M;if(t&&(M={errorThrown:!1,error:null}),e(),t){var r=M,n=r.errorThrown,i=r.error;if(M=null,n)throw i}}else e()}var j=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,E(t)&&t.add(r)):r.destination=U,r}return p(t,e),t.create=function(e,t,r){return new q(e,t,r)},t.prototype.next=function(e){this.isStopped?F(function(e){return R("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?F(R("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?F(A,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.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}(_),B=Function.prototype.bind;function I(e,t){return B.call(e,t)}var D=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){N(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){N(e)}else N(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){N(e)}},e}(),q=function(e){function t(t,r,n){var i,s,o=e.call(this)||this;return b(t)||!t?i={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:o&&T.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return o.unsubscribe()},i={next:t.next&&I(t.next,s),error:t.error&&I(t.error,s),complete:t.complete&&I(t.complete,s)}):i=t,o.destination=new D(i),o}return p(t,e),t}(j);function N(e){var t;T.useDeprecatedSynchronousErrorHandling?(t=e,T.useDeprecatedSynchronousErrorHandling&&M&&(M.errorThrown=!0,M.error=t)):P(e)}function F(e,t){var r=T.onStoppedNotification;r&&O.setTimeout((function(){return r(e,t)}))}var U={closed:!0,next:C,error:function(e){throw e},complete:C},V="function"==typeof Symbol&&Symbol.observable||"@@observable";function W(e){return e}var z=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n=this,i=function(e){return e&&e instanceof j||function(e){return e&&b(e.next)&&b(e.error)&&b(e.complete)}(e)&&E(e)}(e)?e:new q(e,t,r);return L((function(){var e=n,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?n._subscribe(i):n._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=H(t))((function(t,n){var i=new q({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});r.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[V]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(0===(r=e).length?W:1===r.length?r[0]:function(e){return r.reduce((function(e,t){return t(e)}),e)})(this);var r},e.prototype.toPromise=function(e){var t=this;return new(e=H(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function H(e){var t;return null!==(t=null!=e?e:T.Promise)&&void 0!==t?t:Promise}var $=v((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),G=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return p(t,e),t.prototype.lift=function(e){var t=new J(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new $},t.prototype.next=function(e){var t=this;L((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=f(t.currentObservers),s=i.next();!s.done;s=i.next())s.value.next(e)}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;L((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;L((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.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(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,s=r.observers;return n||i?k:(this.currentObservers=null,s.push(e),new _((function(){t.currentObservers=null,S(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new z;return e.source=this,e},t.create=function(e,t){return new J(e,t)},t}(z),J=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return p(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:k},t}(G),Y=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return p(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(G),K={now:function(){return(K.delegate||Date).now()},delegate:void 0},Q=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=K);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return p(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,o=r._timestampProvider,a=r._windowTime;n||(i.push(t),!s&&i.push(o.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,s=(i?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!i){for(var o=r.now(),a=0,c=1;c<n.length&&n[c]<=o;c+=2)a=c;a&&n.splice(0,a+1)}},t}(G);function X(e){return function(t){if(function(e){return b(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function Z(e,t,r,n,i){return new ee(e,t,r,n,i)}var ee=function(e){function t(t,r,n,i,s,o){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=o,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return p(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(j);function te(){return X((function(e,t){var r,n=!1;e.subscribe(Z(t,(function(e){var i=r;r=e,n&&t.next([i,e]),n=!0})))}))}function re(e,t){return X((function(r,n){var i=0;r.subscribe(Z(n,(function(r){return e.call(t,r,i++)&&n.next(r)})))}))}function ne(e,t){return X((function(r,n){var i=0;r.subscribe(Z(n,(function(r){n.next(e.call(t,r,i++))})))}))}var ie=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e},se="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function oe(e){if(e instanceof z)return e;if(null!=e){if(function(e){return b(e[V])}(e))return i=e,new z((function(e){var t=i[V]();if(b(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(ie(e))return n=e,new z((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(function(e){return b(null==e?void 0:e.then)}(e))return r=e,new z((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,P)}));if(function(e){return Symbol.asyncIterator&&b(null==e?void 0:e[Symbol.asyncIterator])}(e))return ae(e);if(function(e){return b(null==e?void 0:e[se])}(e))return t=e,new z((function(e){var r,n;try{for(var i=f(t),s=i.next();!s.done;s=i.next()){var o=s.value;if(e.next(o),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()}));if(function(e){return b(null==e?void 0:e.getReader)}(e))return ae(function(e){return function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(e){return function(t){return Promise.resolve(t).then(e,h)}})),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){i[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=i[e](t)).value instanceof y?Promise.resolve(r.value.v).then(c,h):u(s[0][2],r)}catch(e){u(s[0][3],e)}var r}function c(e){a("next",e)}function h(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}(this,arguments,(function(){var t,r,n;return d(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,y(t.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,y(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,y(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e))}var t,r,n,i;throw function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(e)}function ae(e){return new z((function(t){(function(e,t){var r,n,i,s,o,a,c,h;return o=this,a=void 0,h=function(){var o,a;return d(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=f(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}}(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(o=n.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))},new((c=void 0)||(c=Promise))((function(e,t){function r(e){try{i(h.next(e))}catch(e){t(e)}}function n(e){try{i(h.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):function(e){return e instanceof c?e:new c((function(t){t(e)}))}(t.value).then(r,n)}i((h=h.apply(o,a||[])).next())}))})(e,t).catch((function(e){return t.error(e)}))}))}function ce(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new G}:t,n=e.resetOnError,i=void 0===n||n,s=e.resetOnComplete,o=void 0===s||s,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,s,a=0,h=!1,u=!1,l=function(){null==n||n.unsubscribe(),n=void 0},p=function(){l(),t=s=void 0,h=u=!1},d=function(){var e=t;p(),null==e||e.unsubscribe()};return X((function(e,f){a++,u||h||l();var g=s=null!=s?s:r();f.add((function(){0!=--a||u||h||(n=he(d,c))})),g.subscribe(f),!t&&a>0&&(t=new q({next:function(e){return g.next(e)},error:function(e){u=!0,l(),n=he(p,i,e),g.error(e)},complete:function(){h=!0,l(),n=he(p,o),g.complete()}}),oe(e).subscribe(t))}))(e)}}function he(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var i=new q({next:function(){i.unsubscribe(),e()}});return oe(t.apply(void 0,m([],g(r)))).subscribe(i)}}else e()}function ue(e,t,r){return void 0===r&&(r=1/0),b(t)?ue((function(r,n){return ne((function(e,i){return t(r,e,n,i)}))(oe(e(r,n)))}),r):("number"==typeof t&&(r=t),X((function(t,n){return function(e,t,r,n,i,s,o,a){var c=[],h=0,u=0,l=!1,p=function(){!l||c.length||h||t.complete()},d=function(e){return h<n?f(e):c.push(e)},f=function(e){h++;var i=!1;oe(r(e,u++)).subscribe(Z(t,(function(e){t.next(e)}),(function(){i=!0}),void 0,(function(){if(i)try{h--;for(var e=function(){var e=c.shift();f(e)};c.length&&h<n;)e();p()}catch(e){t.error(e)}})))};return e.subscribe(Z(t,d,(function(){l=!0,p()}))),function(){}}(t,n,e,r)})))}function le(e,t){const[r,n,i,s]=e,[o,a,c,h]=t,u=Math.max(r,o),l=Math.max(n,a),p=Math.min(i,c),d=Math.min(s,h),f=Math.max(0,p-u)*Math.max(0,d-l);return f/((i-r)*(s-n)+(c-o)*(h-a)-f)}function pe(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function de(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return pe({type:"Polygon",coordinates:e},t,r)}function fe(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function ge(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function me(e,t,r){if(null!==e)for(var n,i,s,o,a,c,h,u,l=0,p=0,d=e.type,f="FeatureCollection"===d,g="Feature"===d,m=f?e.features.length:1,y=0;y<m;y++){a=(u=!!(h=f?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var b=0;b<a;b++){var v=0,w=0;if(null!==(o=u?h.geometries[b]:h)){c=o.coordinates;var S=o.type;switch(l=!r||"Polygon"!==S&&"MultiPolygon"!==S?0:1,S){case null:break;case"Point":if(!1===t(c,p,y,v,w))return!1;p++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],p,y,v,w))return!1;p++,"MultiPoint"===S&&v++}"LineString"===S&&v++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-l;i++){if(!1===t(c[n][i],p,y,v,w))return!1;p++}"MultiLineString"===S&&v++,"Polygon"===S&&w++}"Polygon"===S&&v++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(s=0;s<c[n][i].length-l;s++){if(!1===t(c[n][i][s],p,y,v,w))return!1;p++}w++}v++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(!1===me(o.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ye(e,t){!function(e,t){var r,n,i,s,o,a,c,h,u,l,p=0,d="FeatureCollection"===e.type,f="Feature"===e.type,g=d?e.features.length:1;for(r=0;r<g;r++){for(a=d?e.features[r].geometry:f?e.geometry:e,h=d?e.features[r].properties:f?e.properties:{},u=d?e.features[r].bbox:f?e.bbox:void 0,l=d?e.features[r].id:f?e.id:void 0,o=(c=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,i=0;i<o;i++)if(null!==(s=c?a.geometries[i]:a))switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(s,p,h,u,l))return!1;break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===t(s.geometries[n],p,h,u,l))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,h,u,l))return!1;p++}}(e,(function(e,r,n,i,s){var o,a=null===e?null:e.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==t(pe(e,n,{bbox:i,id:s}),r,0)&&void 0}switch(a){case"MultiPoint":o="Point";break;case"MultiLineString":o="LineString";break;case"MultiPolygon":o="Polygon"}for(var c=0;c<e.coordinates.length;c++){var h=e.coordinates[c];if(!1===t(pe({type:o,coordinates:h},n),r,c))return!1}}))}function be(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const r=[1/0,1/0,-1/0,-1/0];return me(e,(e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])})),r}Math.PI;const ve=function(e,t){for(var r=0,n=0,i=0,s=0,o=0,a=0,c=0,h=0,u=null,l=null,p=e[0],d=e[1],f=t.length;r<f;r++){n=0;var g=t[r].length-1,m=t[r];if((u=m[0])[0]!==m[g][0]&&u[1]!==m[g][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-d;n<g;n++)if(h=(l=m[n+1])[1]-d,a<0&&h<0||a>0&&h>0)a=h,o=(u=l)[0]-p;else{if(c=l[0]-e[0],h>0&&a<=0){if((s=o*h-c*a)>0)i+=1;else if(0===s)return 0}else if(a>0&&h<=0){if((s=o*h-c*a)<0)i+=1;else if(0===s)return 0}else if(0===h&&a<0){if(0==(s=o*h-c*a))return 0}else if(0===a&&h<0){if(0==(s=o*h-c*a))return 0}else if(0===a&&0===h){if(c<=0&&o>=0)return 0;if(o<=0&&c>=0)return 0}u=l,a=h,o=c}}return i%2!=0};function we(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Se(e){return"Feature"===e.type?e.geometry:e}function _e(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=we(e),i=Se(t),s=i.type,o=t.bbox;let a=i.coordinates;if(o&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,o))return!1;"Polygon"===s&&(a=[a]);let c=!1;for(var h=0;h<a.length;++h){const e=ve(n,a[h]);if(0===e)return!r.ignoreBoundary;e&&(c=!0)}return c}function ke(e,t,r={}){const n=we(e),i=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(t);for(let e=0;e<i.length-1;e++){let t=!1;if(r.ignoreEndVertices&&(0===e&&(t="start"),e===i.length-2&&(t="end"),0===e&&e+1===i.length-1&&(t="both")),Ee(i[e],i[e+1],n,t,void 0===r.epsilon?null:r.epsilon))return!0}return!1}function Ee(e,t,r,n,i){const s=r[0],o=r[1],a=e[0],c=e[1],h=t[0],u=t[1],l=h-a,p=u-c,d=(r[0]-a)*p-(r[1]-c)*l;if(null!==i){if(Math.abs(d)>i)return!1}else if(0!==d)return!1;return n?"start"===n?Math.abs(l)>=Math.abs(p)?l>0?a<s&&s<=h:h<=s&&s<a:p>0?c<o&&o<=u:u<=o&&o<c:"end"===n?Math.abs(l)>=Math.abs(p)?l>0?a<=s&&s<h:h<s&&s<=a:p>0?c<=o&&o<u:u<o&&o<=c:"both"===n&&(Math.abs(l)>=Math.abs(p)?l>0?a<s&&s<h:h<s&&s<a:p>0?c<o&&o<u:u<o&&o<c):Math.abs(l)>=Math.abs(p)?l>0?a<=s&&s<=h:h<=s&&s<=a:p>0?c<=o&&o<=u:u<=o&&o<=c}function xe(e,t){const r=Se(e),n=Se(t),i=r.type,s=n.type,o=r.coordinates,a=n.coordinates;switch(i){case"Point":if("Point"===s)return Pe(o,a);throw new Error("feature2 "+s+" geometry not supported");case"MultiPoint":switch(s){case"Point":return function(e,t){let r,n=!1;for(r=0;r<e.coordinates.length;r++)if(Pe(e.coordinates[r],t.coordinates)){n=!0;break}return n}(r,n);case"MultiPoint":return function(e,t){for(const r of t.coordinates){let t=!1;for(const n of e.coordinates)if(Pe(r,n)){t=!0;break}if(!t)return!1}return!0}(r,n);default:throw new Error("feature2 "+s+" geometry not supported")}case"LineString":switch(s){case"Point":return ke(n,r,{ignoreEndVertices:!0});case"LineString":return function(e,t){let r=!1;for(const n of t.coordinates)if(ke({type:"Point",coordinates:n},e,{ignoreEndVertices:!0})&&(r=!0),!ke({type:"Point",coordinates:n},e,{ignoreEndVertices:!1}))return!1;return r}(r,n);case"MultiPoint":return function(e,t){let r=!1;for(const n of t.coordinates)if(ke(n,e,{ignoreEndVertices:!0})&&(r=!0),!ke(n,e))return!1;return!!r}(r,n);default:throw new Error("feature2 "+s+" geometry not supported")}case"Polygon":switch(s){case"Point":return _e(n,r,{ignoreBoundary:!0});case"LineString":return function(e,t){let r=!1,n=0;if(!Oe(be(e),be(t)))return!1;for(;n<t.coordinates.length-1;n++)if(_e({type:"Point",coordinates:(i=t.coordinates[n],s=t.coordinates[n+1],[(i[0]+s[0])/2,(i[1]+s[1])/2])},e,{ignoreBoundary:!0})){r=!0;break}var i,s;return r}(r,n);case"Polygon":return Te(r,n);case"MultiPoint":return function(e,t){for(const r of t.coordinates)if(!_e(r,e,{ignoreBoundary:!0}))return!1;return!0}(r,n);default:throw new Error("feature2 "+s+" geometry not supported")}case"MultiPolygon":if("Polygon"===s)return function(e,t){return e.coordinates.some((e=>Te({type:"Polygon",coordinates:e},t)))}(r,n);throw new Error("feature2 "+s+" geometry not supported");default:throw new Error("feature1 "+i+" geometry not supported")}}function Te(e,t){if("Feature"===e.type&&null===e.geometry)return!1;if("Feature"===t.type&&null===t.geometry)return!1;if(!Oe(be(e),be(t)))return!1;const r=Se(t).coordinates;for(const t of r)for(const r of t)if(!_e(r,e))return!1;return!0}function Oe(e,t){return!(e[0]>t[0]||e[2]<t[2]||e[1]>t[1]||e[3]<t[3])}function Pe(e,t){return e[0]===t[0]&&e[1]===t[1]}class Ce{constructor(e=[],t=Ae){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e<n;){let n=1+(e<<1),s=t[n];const o=n+1;if(o<this.length&&r(t[o],s)<0&&(n=o,s=t[o]),r(s,i)>=0)break;t[e]=s,e=n}t[e]=i}}function Ae(e,t){return e<t?-1:e>t?1:0}function Re(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Me(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Le{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let je=0,Be=0,Ie=0;function De(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let e=0;e<n.length;e++)for(let r=0;r<n[e].length;r++){let i=n[e][r][0],s=null;Be+=1;for(let o=0;o<n[e][r].length-1;o++){s=n[e][r][o+1];const a=new Le(i,je,Be,Ie),c=new Le(s,je,Be,Ie+1);a.otherEvent=c,c.otherEvent=a,Re(a,c)>0?(c.isLeftEndpoint=!0,a.isLeftEndpoint=!1):(a.isLeftEndpoint=!0,c.isLeftEndpoint=!1),t.push(a),t.push(c),i=s,Ie+=1}}je+=1}class qe{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function Ne(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,i=e.rightSweepEvent.p.x,s=e.rightSweepEvent.p.y,o=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,h=t.rightSweepEvent.p.y,u=(h-a)*(i-r)-(c-o)*(s-n);if(0===u)return!1;const l=((c-o)*(n-a)-(h-a)*(r-o))/u,p=((i-r)*(n-a)-(s-n)*(r-o))/u;return l>=0&&l<=1&&p>=0&&p<=1&&[r+l*(i-r),n+l*(s-n)]}var Fe=function(e,t){const r=new Ce([],Re);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)De(r[e],t)}else De(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new Ce([],Me);for(;e.length;){const i=e.pop();if(i.isLeftEndpoint){const e=new qe(i);for(let s=0;s<n.data.length;s++){const o=n.data[s];if(t&&o.leftSweepEvent.featureId===i.featureId)continue;const a=Ne(e,o);!1!==a&&r.push(a)}n.push(e)}else!1===i.isLeftEndpoint&&n.pop()}return r}(r,t)};function Ue(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:i=!1}=r;let s=[];"FeatureCollection"===e.type?s=s.concat(e.features):"Feature"===e.type?s.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||s.push(pe(e)),"FeatureCollection"===t.type?s=s.concat(t.features):"Feature"===t.type?s.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||s.push(pe(t));const o=Fe(fe(s),i);let a=[];if(n){const e={};o.forEach((t=>{const r=t.join(",");e[r]||(e[r]=!0,a.push(t))}))}else a=o;return fe(a.map((e=>function(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ge(e[0])||!ge(e[1]))throw new Error("coordinates must contain numbers");return pe({type:"Point",coordinates:e},t,r)}(e))))}function Ve(e,t={}){const r=Se(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return We(Se(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=Se(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},i=[];return r.forEach((e=>{i.push(We(e,n))})),fe(i)}(r,t);default:throw new Error("invalid poly")}}function We(e,t){return e.length>1?function(e,t,r={}){return pe({type:"MultiLineString",coordinates:e},t,r)}(e,t):function(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return pe({type:"LineString",coordinates:e},t,r)}(e[0],t)}function ze(e,t){for(let r=0;r<e.coordinates.length-1;r++)if($e(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function He(e,t,r){for(const r of t.coordinates)if(_e(r,e))return!0;return Ue(t,Ve(e),{ignoreSelfIntersections:r}).features.length>0}function $e(e,t,r){const n=r[0]-e[0],i=r[1]-e[1],s=t[0]-e[0],o=t[1]-e[1];return 0==n*o-i*s&&(Math.abs(s)>=Math.abs(o)?s>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:o>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}function Ge(e,t,r={}){var n;const i=null!=(n=r.ignoreSelfIntersections)&&n;let s=!1;return ye(e,(e=>{ye(t,(t=>{if(!0===s)return!0;s=!function(e,t,r={}){var n;const i=null!=(n=r.ignoreSelfIntersections)&&n;let s=!0;return ye(e,(e=>{ye(t,(t=>{if(!1===s)return!1;s=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,i=t.coordinates,!(n[0]===i[0]&&n[1]===i[1]);case"LineString":return!ze(t,e);case"Polygon":return!_e(e,t)}break;case"LineString":switch(t.type){case"Point":return!ze(e,t);case"LineString":return!function(e,t,r){return Ue(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!He(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!_e(t,e);case"LineString":return!He(e,t,r);case"Polygon":return!function(e,t,r){for(const r of e.coordinates[0])if(_e(r,t))return!0;for(const r of t.coordinates[0])if(_e(r,e))return!0;return Ue(Ve(e),Ve(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,i;return!1}(e.geometry,t.geometry,i)}))})),s}(e.geometry,t.geometry,{ignoreSelfIntersections:i})}))})),s}const Je=(e,t)=>{const{origWidth:r,origHeight:n}=t,i=e.points.map((([e,t])=>[e*r/100,t*n/100]));return i.length>0&&!Ye(i[0],i[i.length-1])&&i.push(i[0]),{...e,points:i}},Ye=(e,t)=>e[0]===t[0]&&e[1]===t[1],Ke=e=>{const{origWidth:t,origHeight:r,inputWidth:n,inputHeight:i}=e;let[s,o,a,c]=e.boundingBox;return s=s*t/n,o=o*r/i,a=a*t/n,c=c*r/i,s=Math.max(0,Math.min(s,t)),o=Math.max(0,Math.min(o,r)),a=Math.max(0,Math.min(a,t)),c=Math.max(0,Math.min(c,r)),{...e,boundingBox:[s,o,a,c]}},Qe=(e,t,r)=>{if(e.confidence<r.object.confidence)return!1;if(0===t.length)return!0;const[n,i,s,o]=e.boundingBox,a=function(e,t={}){const r=Number(e[0]),n=Number(e[1]),i=Number(e[2]),s=Number(e[3]);if(6===e.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");const o=[r,n];return de([[o,[i,n],[i,s],[r,s],o]],t.properties,{bbox:e,id:t.id})}([n,i,s,o]);for(const r of t){const t=Je(r,e),n=de([t.points]);if(t.classes.length>0&&!t.classes.includes(e.label))continue;const i=Ge(a,n),s=xe(n,a);if(t.isPrivacyMask){if(i||s)return!1}else if("include"===t.filter){if("contain"===t.type){if(s)return!0}else if("intersect"===t.type&&(i||s))return!0}else if("exclude"===t.filter)if("contain"===t.type){if(!s)return!0}else if("intersect"===t.type&&!i&&!s)return!0}return!1};class Xe extends o{logger;snapshotCache;cameraSubject;cameraState=new Y(!1);lightState=new Y(this.getLightState({state:!1},!0));motionState=new Y(this.getMotionState({detections:[],state:!1},!0));audioState=new Y(this.getAudioState({state:!1,db:0},!0));objectState=new Y(this.getObjectState({detections:[]},!0));doorbellState=new Y(this.getDoorbellState({state:!1},!0));sirenState=new Y(this.getSirenState({state:!1,level:0},!0));batteryState=new Y(this.getBatteryState({level:100,charging:!1,lowBattery:!1},!0));onConnected=this.createStateObservable(this.cameraState);onLightSwitched=this.createStateObservable(this.lightState);onMotionDetected=this.createStateObservable(this.motionState);onAudioDetected=this.createStateObservable(this.audioState);onObjectDetected=this.createStateObservable(this.objectState);onDoorbellPressed=this.createStateObservable(this.doorbellState);onSirenDetected=this.createStateObservable(this.sirenState);onBatteryChanged=this.createStateObservable(this.batteryState);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}constructor(e,t){super(),this.logger=t,this.cameraSubject=new Y(e),this.updateCamera(e),this.snapshotCache=new(u())({max:100,ttl:1e3*this.snapshotTTL}),"native"===e.pluginId&&this.cameraState.next(!0)}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 t=this.snapshotSource||this.streamSource,r=t.urls.www.jpegSnapshot,n=this.snapshotCache.get(t._id);if(!e&&n)return this.logger.trace(this.name,"Snapshot requested (cached)"),n;this.logger.trace(this.name,"Snapshot requested (fetching)");try{if("native"!==this.cameraObject.pluginId){const e=await this.cameraDelegate.snapshot();if(e&&e.byteLength>0)return this.snapshotCache.set(t._id,e),e}const e=new AbortController,n=setTimeout((()=>e.abort()),5e3),i=await fetch(r,{signal:e.signal});if(clearTimeout(n),!i.ok)throw new Error("Status Code: "+i.status);const s=await i.arrayBuffer();return s.byteLength>0&&this.snapshotCache.set(t._id,s),s}catch{return}}onStateChange(e){return this[`${e}State`].pipe(te(),re((([t,r])=>"boolean"==typeof t||"boolean"==typeof r?t!==r:this.stateChanged(t,r,e))),ne((([e,t])=>({oldState:e,newState:t}))),ce({connector:()=>new Q(1)}))}onPropertyChange(e){return this.cameraSubject.pipe(te(),ue((([t,r])=>(Array.isArray(e)?e:[e]).map((e=>({property:e,oldData:t[e],newData:r[e]}))))),re((({oldData:e,newData:t})=>!a(e,t,!0))),ce({connector:()=>new Q(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,t,r,n){let i,s=!1;if(r)s=!0,i=t;else{const r=this.checkStateInternal(e,t,n);s=r.changed,i=r.event}if(s)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,t,r){let n,i=!1;switch(e){case"audio":const s=t;n=this.getAudioState(s),i=this.stateChanged(this.getValue("audio"),n,"audio");break;case"light":const o=t;n=this.getLightState(o),i=this.stateChanged(this.getValue("light"),n,"light");break;case"motion":const a=t;void 0!==a.state&&(a.detections=[]),r||(a.detections=function(e,t=.2){if(0===e.length)return[];const r=e.map((e=>e.boundingBox)),n=e.map((e=>e.confidence)),i=n.map(((e,t)=>({conf:e,idx:t}))).sort(((e,t)=>t.conf-e.conf)).map((e=>e.idx)),s=[],o=new Array(e.length).fill(!1);for(const a of i){if(o[a])continue;const i=r[a],c={...e[a]},h=r.map((e=>le(i,e))).map((e=>e>t)).map(((e,t)=>({overlap:e,idx:t}))).filter((e=>e.overlap&&!o[e.idx])).map((e=>e.idx));if(h.length>1){const t=h.map((e=>r[e])),i=[Math.min(...t.map((e=>e[0]))),Math.min(...t.map((e=>e[1]))),Math.max(...t.map((e=>e[2]))),Math.max(...t.map((e=>e[3])))],s=e[h.reduce(((e,t)=>n[t]>n[e]?t:e))];c.id=s.id||c.id||"motion",c.boundingBox=i,c.confidence=Math.max(...h.map((e=>n[e]))),h.forEach((e=>{o[e]=!0})),o[a]=!1}s.push(c)}return s}(a.detections),a.detections=((e,t,r)=>{const n=[];for(const i of e)Qe(Ke(i),t,r)&&t.some((e=>!e.classes.length||e.classes.includes(i.label)))&&n.push(i);return n})(a.detections,this.activityZones,this.activitySettings)),n=this.getMotionState(a),i=this.stateChanged(this.getValue("motion"),n,"motion");break;case"object":const c=t;r||(c.detections=((e,t,r)=>{const n=[];for(const i of e){const e=Ke(i);Qe(e,t,r)&&t.some((e=>!e.classes.length||e.classes.includes(i.label)))&&n.push(e)}return n})(c.detections,this.activityZones,this.activitySettings)),n=this.getObjectState(c),i=this.stateChanged(this.getValue("object"),n,"object");break;case"doorbell":const h=t;n=this.getDoorbellState(h),i=this.stateChanged(this.getValue("doorbell"),n,"doorbell");break;case"siren":const u=t;n=this.getSirenState(u),i=this.stateChanged(this.getValue("siren"),n,"siren");break;case"battery":const l=t;n=this.getBatteryState(l),i=this.stateChanged(this.getValue("battery"),n,"battery");break;default:throw new Error(`Unknown state: ${e}`)}return{changed:i,event:n}}stateChanged(e,t,r){if(!e||!t||!r)return!1;if("audio"==r){if(!this.hasAudioDetector)return!1;const r=e,n=t;return r.state!==n.state||r.db!==n.db}if("motion"==r){if(!this.hasMotionDetector)return!1;const r=e,n=t;return void 0!==n.state?r.state!==n.state:!a(r.detections,n.detections,!0)}if("object"==r){if(!this.hasObjectDetector)return!1;const r=t;return!a(e.detections,r.detections,!0)}if("siren"==r){if(!this.hasSiren)return!1;const r=e,n=t;return r.state!==n.state||r.level!==n.level}if("battery"==r){if(!this.hasBattery)return!1;const r=e,n=t;return r.level!==n.level||r.lowBattery!==n.lowBattery||r.charging!==n.charging}if("doorbell"==r){if(!this.hasBinarySensor)return!1;const r=t;return e.state!==r.state}if("light"==r){if(!this.hasLight)return!1;const r=t;return e.state!==r.state}return!1}getAudioState(e,t=!1){let r,n;if(!t){const e=this.getValue("audio");e.state?r=e:e.lastEvent?.state&&(r=e.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,db:t.db||r?.db||0,lastEvent:r||(t.state?t:void 0)}}return n}getMotionState(e,t=!1){let r,n;if(!t){const e=this.getValue("motion");e.detections.length?r=e:e.lastEvent?.detections.length&&(r=e.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,lastEvent:r||(t.detections.length?t:void 0)}}return n}getObjectState(e,t=!1){let r,n;if(!t){const e=this.getValue("object");e.detections.length?r=e:e.lastEvent?.detections.length&&(r=e.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,lastEvent:r||(t.detections.length?t:void 0)}}return n}getDoorbellState(e,t=!1){let r,n;if(!t){const e=this.getValue("doorbell");e.state?r=e:e.lastEvent?.state&&(r=e.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,lastEvent:r||(t.state?t:void 0)}}return n}getLightState(e,t=!1){let r,n;if(!t){const e=this.getValue("light");e.state?r=e:e.lastEvent?.state&&(r=e.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,lastEvent:r||(t.state?t:void 0)}}return n}getSirenState(e,t=!1){let r,n;if(!t){const e=this.getValue("siren");e.state?r=e:e.lastEvent?.state&&(r=e.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,level:t.level||r?.level||0,lastEvent:r||(t.state?t:void 0)}}return n}getBatteryState(e,t=!1){let r,n;if(!t){const t=this.getValue("battery");this.stateChanged(t,e,"battery")?r=t:t.lastEvent&&this.stateChanged(t.lastEvent,e,"battery")&&(r=t.lastEvent),r&&delete r.lastEvent}if(this.isStateEvent(e))n=e;else{const t={...e,timestamp:Date.now()};n={...t,charging:e.charging||r?.charging||!1,lowBattery:e.lowBattery||r?.lowBattery||!1,lastEvent:r||t}}return n}isStateEvent(e){return"timestamp"in e}createStateObservable(e){return e.pipe(ce({connector:()=>new Q(1)}))}}class Ze{delegate;onRequest;constructor(e){this.onRequest=e}async snapshot(){return this.delegate?this.delegate.snapshot():this._onRequest("snapshot",[],5e3)}_onRequest(e,t,r){return this.onRequest("cameraDelegate",e,t,r)}}class et{delegate;onRequest;constructor(e){this.onRequest=e}async getPrebufferingState(e,t){return this.delegate?this.delegate.getPrebufferingState(e,t):this._onRequest("prebufferDelegate","getPrebufferingState",[e,t])}_onRequest(e,t,r,n){return this.onRequest(e,t,r,n)}}class tt{delegate;onRequest;constructor(e){this.onRequest=e}async moveAbsolute(e,t,r){return this.delegate?this.delegate.moveAbsolute(e,t,r):this._onRequest("moveAbsolute",[e,t,r])}async moveRelative(e,t,r){return this.delegate?this.delegate.moveRelative(e,t,r):this._onRequest("moveRelative",[e,t,r])}async moveContinuous(e,t,r){return this.delegate?this.delegate.moveContinuous(e,t,r):this._onRequest("moveContinuous",[e,t,r])}async stop(){return this.delegate?this.delegate.stop():this._onRequest("stop",[])}_onRequest(e,t,r){return this.onRequest("ptzDelegate",e,t,r)}}const rt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));class nt extends EventTarget{cameraDevice;socketService;logger;options;videoPlayer;socket;streamId;hasBackchannel=!1;hasAudio=!0;closed=!1;micTransceiver=null;pc=null;buf=new Uint8Array(2097152);mediaSource=null;sourceBuffer=null;bufLen=0;mseCodecs="";videoPlayerMp4;media=["video","audio","microphone"];codecList=[];reconnectTimeout;_finishLoading=!1;_firstFrameReceived=!1;animationFrameId;get mode(){return this.options.mode}webrtcReconnectTimeout;constructor(e,t,r,n){super(),this.options=n,this.videoPlayer=n.videoElement,this.cameraDevice=e,this.socketService=t,this.logger=r;const{socket:i}=this.socketService.getSocket(`${e.id}-go2rtcSession`,!0);this.socket=i,this.socket.connect(),this.streamId=rt(),this.createCodecsList()}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((e=>setTimeout(e,100))),this.connect(e)}reset(){this._finishLoading=!1,this._firstFrameReceived=!1,this.pc?.getTransceivers().forEach((e=>e.sender?.track?.stop())),this.pc?.close(),this.pc=null,this.videoPlayerMp4?.remove(),this.videoPlayerMp4=void 0,this.videoPlayer.srcObject=null,this.videoPlayer.src="",this.videoPlayer.poster="",void 0!==this.animationFrameId&&("cancelVideoFrameCallback"in this.videoPlayer?this.videoPlayer.cancelVideoFrameCallback(this.animationFrameId):cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}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||void 0===this.options.reconnectInterval||(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout((()=>{this.reconnect()}),this.options.reconnectInterval)))}onWsMessage({id:e,data:t}){if(e===this.streamId&&t.type){switch(t.type){case"mse":this.onMseData(t);break;case"hls":this.onHlsData(t);break;case"webrtc/candidate":case"webrtc/answer":this.onWebrtcData(t);break;case"mse-binary":this.onMseBuffer(t);break;case"mjpeg-binary":this.onMjpegBuffer(t);break;case"mp4-binary":this.onMp4Buffer(t);break;case"stream-info":this.onStreamInfo(t);break;case"error":this.dispatchEvent(new ErrorEvent("error",{error:t,message:t.value}))}!this._firstFrameReceived&&["mse-binary","mjpeg-binary","mp4-binary"].includes(t.type)&&this.onFirstFrame()}}async requestWebrtc(){this.reset(),this.pc=new RTCPeerConnection({bundlePolicy:"max-bundle",iceServers:[{urls:"stun:stun.l.google.com:19302"}],sdpSemantics:"unified-plan"}),this.pc.onicecandidate=e=>{if(console.log(this.cameraDevice.name,"onicecandidate",e.candidate),"webrtc/tcp"===this.options.mode&&"udp"===e.candidate?.protocol)return;const t=e.candidate?.toJSON().candidate||"";this.socket.emit("stream-payload",{id:this.streamId,data:{type:"webrtc/candidate",value:t}})},this.pc.onconnectionstatechange=()=>{if(console.log(this.cameraDevice.name,"onconnectionstatechange:",this.pc?.connectionState),"connected"===this.pc?.connectionState){const e=this.pc?.getTransceivers().filter((e=>"recvonly"===e.currentDirection)).map((e=>e.receiver.track));this.videoPlayer.srcObject=new MediaStream(e),this.onFinishLoading(),this.play(),this.disconnect()}else"failed"!==this.pc?.connectionState&&"disconnected"!==this.pc?.connectionState||(clearTimeout(this.webrtcReconnectTimeout),this.webrtcReconnectTimeout=setTimeout((()=>{"failed"!==this.pc?.connectionState&&"disconnected"!==this.pc?.connectionState||this.reconnect()}),1e3))},this.pc.oniceconnectionstatechange=()=>{console.log(this.cameraDevice.name,"iceconnectionstatechange",this.pc?.iceConnectionState)},this.pc.onicecandidateerror=e=>{console.log(this.cameraDevice.name,"onicecandidateerror",e)},this.pc.onsignalingstatechange=()=>{console.log(this.cameraDevice.name,"onsignalingstatechange",this.pc?.signalingState)},this.pc.onicegatheringstatechange=()=>{console.log(this.cameraDevice.name,"onicegatheringstatechange",this.pc?.iceGatheringState)},this.pc.onnegotiationneeded=e=>{console.log(this.cameraDevice.name,"onnegotiationneeded",e)},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){try{switch(e.type){case"webrtc/candidate":if(console.log(this.cameraDevice.name,"remote candidate:",e.value),"webrtc/tcp"===this.options.mode&&e.value.indexOf(" udp ")>0)return;await(this.pc?.addIceCandidate({candidate:e.value,sdpMid:"0"}));break;case"webrtc/answer":if(console.log(this.cameraDevice.name,"Answer:",e.value),await(this.pc?.setRemoteDescription({type:"answer",sdp:e.value})),!this._firstFrameReceived&&this.pc){const e=this.pc.getReceivers().find((e=>"video"===e.track.kind))?.track;if(e)if("requestVideoFrameCallback"in e)this.animationFrameId=e.requestVideoFrameCallback((()=>{this.onFirstFrame()}));else{const e=()=>{this.videoPlayer.readyState>=2&&this.videoPlayer.videoWidth>0?this.onFirstFrame():this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}}break;case"error":if(console.log(this.cameraDevice.name,"WebRTC Error:",e.value),e.value.indexOf("webrtc/offer")<0)return;this.pc?.close()}}catch(e){this.dispatchEvent(new ErrorEvent("error",{error:e,message:e.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",(()=>{if(!this.sourceBuffer?.updating)try{if(this.bufLen>0){const e=this.buf.slice(0,this.bufLen);this.bufLen=0,this.sourceBuffer?.appendBuffer(e)}else if(this.sourceBuffer?.buffered?.length){const e=this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1)-15,t=this.sourceBuffer.buffered.start(0);e>t&&(this.sourceBuffer.remove(t,e),this.mediaSource?.setLiveSeekableRange(e,e+15))}}catch{}})))}async onMseBuffer(e){if("closed"!==this.mediaSource?.readyState)if(this.onFinishLoading(),this.sourceBuffer?.updating||this.bufLen>0){const t=new Uint8Array(e.value);this.buf.set(t,this.bufLen),this.bufLen+=t.byteLength}else try{this.sourceBuffer?.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.onFinishLoading()}requestMp4(){this.reset();const e=document.createElement("canvas");let t=null;this.videoPlayerMp4=document.createElement("video"),this.videoPlayerMp4.autoplay=!0,this.videoPlayerMp4.playsInline=!0,this.videoPlayerMp4.muted=!0,this.videoPlayerMp4.addEventListener("loadeddata",(()=>{this.videoPlayerMp4&&(t||(e.width=this.videoPlayerMp4.videoWidth,e.height=this.videoPlayerMp4.videoHeight,t=e.getContext("2d")),t?.drawImage(this.videoPlayerMp4,0,0,e.width,e.height),this.videoPlayer.controls=!1,this.videoPlayer.poster=e.toDataURL("image/jpeg"))}));const r=this.codecList.filter((e=>this.media.includes(e.indexOf("vc1")>0?"video":"audio"))).filter((e=>this.videoPlayer.canPlayType(`video/mp4; codecs="${e}"`))).join();console.log(this.cameraDevice.name,"Playable codecs (MP4):",r),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mp4",value:r}})}onMp4Buffer(e){this.onFinishLoading(),this.videoPlayerMp4&&(this.videoPlayerMp4.src="data:video/mp4;base64,"+this.btoaBinary(e.value))}requestHls(){this.reset();const e=this.parseCodecs((e=>this.videoPlayer.canPlayType(e)));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 t="http"+e.wsURL.substring(2,e.wsURL.indexOf("/ws"))+"/hls/",r=e.value.replace("hls/",t),n="data:application/vnd.apple.mpegurl;base64,"+btoa(r.toString());this.videoPlayer.src=n,this.onFinishLoading(),this.play()}onStreamInfo(e){const t=e.value,r=t?.producers[0];r&&(this.hasBackchannel=r.senders?.some((e=>"audio"===e.codec.codec_type))||!1,this.hasAudio=r.receivers?.some((e=>"audio"===e.codec.codec_type))||!1)}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)}}onFirstFrame(){this._firstFrameReceived||(this._firstFrameReceived=!0,this.dispatchEvent(new Event("onFirstFrame")),console.log(this.cameraDevice.name,"First frame received"))}onFinishLoading(){this._finishLoading||(this._finishLoading=!0,this.dispatchEvent(new Event("onFinishLoading")))}createCodecsList(){const e=["avc1.640029","avc1.64002A","avc1.640033","hvc1.1.6.L153.B0","mp4a.40.2","mp4a.40.5","flac","opus"],t="undefined"==typeof window?null:navigator.userAgent.match(/Version\/(\d+).+Safari/);if(t?.[1]){const r=t[1]<"13"?"mp4a.40.2":t[1]<"14"?"flac":"opus";e.splice(e.indexOf(r))}this.codecList=e}parseCodecs(e){return this.codecList.filter((e=>this.media.includes(e.indexOf("vc1")>0?"video":"audio"))).filter((t=>e(`video/mp4; codecs="${t}"`))).join()}btoaBinary(e){const t=new Uint8Array(e),r=t.byteLength;let n="";for(let e=0;e<r;e++)n+=String.fromCharCode(t[e]);return window.btoa(n)}}class it extends Xe{socketService;socket;pluginName="@camera.ui/client";subject;_started=!1;get started(){return this._started}cameraDelegate=new Ze(this.onRequest.bind(this));ptzDelegate=new tt(this.onRequest.bind(this));prebufferDelegate=new et(this.onRequest.bind(this));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:t=>this.prebufferDelegate.getPrebufferingState(e.name,t),probeStream:(t=!1)=>this.onRequest("cameraFn","probeStream",[e._id,t])})))}constructor(e,t,r){super(e,r),this.socketService=t;const{socket:n}=this.socketService.getSocket(this.id,!0);this.socket=n,this.socket.connect(),this.subject=`${this.pluginName}.camera.${this.id}`,this.listenToMessages()}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 nt(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[t,r]of Object.entries(e.states))super.updateStateInternal(t,r,!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,t,r=[]){const n={requestId:rt(),targetId:this.subject,targetName:this.name,pluginId:this.pluginName,cameraId:this.id,type:"request",proxy:"camera",client:e,fn:t,args:r,timestamp:Date.now(),timeout:5e3};return new Promise(((e,t)=>{this.socket.emit("request",n,(r=>{r.error?t(r.error):e(r.response)}))}))}}class st{socketService;socket;logger;pluginName="@camera.ui/client";subject;constructor(e,t){this.socketService=e,this.socket=e.socket,this.logger=t,this.subject=`${this.pluginName}.coreManager`}async getFFmpegPath(){return this.onRequest("getFFmpegPath")}async getHwaccelInfo(e){return this.onRequest("getHwaccelInfo",[e])}async getServerAddresses(){return this.onRequest("getServerAddresses")}async getIceServers(){return this.onRequest("getIceServers")}onRequest(e,t){const r={requestId:rt(),targetId:this.subject,targetName:this.pluginName,pluginId:this.pluginName,type:"request",proxy:"core",client:"coreFn",fn:e,args:t||[],timestamp:Date.now(),timeout:5e3};return new Promise(((e,t)=>{this.socket.emit("request",r,(r=>{r.error?t(r.error):e(r.response)}))}))}}class ot{socketService;socket;logger;pluginName="@camera.ui/client";subject;constructor(e,t){this.socketService=e,this.socket=e.socket,this.logger=t,this.subject=`${this.pluginName}.deviceManager`}async getCameraById(e){const t=await this.onRequest("getCameraById",[e]);if(t){const e=new it(t,this.socketService,this.logger);return await e.refreshStates(),e}}async getCameraByName(e){const t=await this.onRequest("getCameraByName",[e]);if(t){const e=new it(t,this.socketService,this.logger);return await e.refreshStates(),e}}onRequest(e,t){const r={requestId:rt(),targetId:this.subject,targetName:this.pluginName,pluginId:this.pluginName,type:"request",proxy:"device",client:"deviceFn",fn:e,args:t||[],timestamp:Date.now(),timeout:5e3};return new Promise(((e,t)=>{this.socket.emit("request",r,(r=>{r.error?t(r.error):e(r.response)}))}))}}const at=Object.create(null);at.open="0",at.close="1",at.ping="2",at.pong="3",at.message="4",at.upgrade="5",at.noop="6";const ct=Object.create(null);Object.keys(at).forEach((e=>{ct[at[e]]=e}));const ht={type:"error",data:"parser error"},ut="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),lt="function"==typeof ArrayBuffer,pt=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,dt=({type:e,data:t},r,n)=>ut&&t instanceof Blob?r?n(t):ft(t,n):lt&&(t instanceof ArrayBuffer||pt(t))?r?n(t):ft(new Blob([t]),n):n(at[e]+(t||"")),ft=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function gt(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let mt;const yt="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)yt["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(e)]=e;const bt="function"==typeof ArrayBuffer,vt=(e,t)=>{if("string"!=typeof e)return{type:"message",data:St(e,t)};const r=e.charAt(0);return"b"===r?{type:"message",data:wt(e.substring(1),t)}:ct[r]?e.length>1?{type:ct[r],data:e.substring(1)}:{type:ct[r]}:ht},wt=(e,t)=>{if(bt){const r=(e=>{let t,r,n,i,s,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const h=new ArrayBuffer(o),u=new Uint8Array(h);for(t=0;t<a;t+=4)r=yt[e.charCodeAt(t)],n=yt[e.charCodeAt(t+1)],i=yt[e.charCodeAt(t+2)],s=yt[e.charCodeAt(t+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return h})(e);return St(r,t)}return{base64:!0,data:e}},St=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,_t=String.fromCharCode(30);let kt;function Et(e){return e.reduce(((e,t)=>e+t.length),0)}function xt(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let i=0;i<t;i++)r[i]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function Tt(e){if(e)return function(e){for(var t in Tt.prototype)e[t]=Tt.prototype[t];return e}(e)}Tt.prototype.on=Tt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Tt.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},Tt.prototype.off=Tt.prototype.removeListener=Tt.prototype.removeAllListeners=Tt.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<n.length;i++)if((r=n[i])===t||r.fn===t){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},Tt.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,t)}return this},Tt.prototype.emitReserved=Tt.prototype.emit,Tt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Tt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Ot="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Pt="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Ct(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const At=Pt.setTimeout,Rt=Pt.clearTimeout;function Mt(e,t){t.useNativeTimers?(e.setTimeoutFn=At.bind(Pt),e.clearTimeoutFn=Rt.bind(Pt)):(e.setTimeoutFn=Pt.setTimeout.bind(Pt),e.clearTimeoutFn=Pt.clearTimeout.bind(Pt))}function Lt(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class jt extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Bt extends Tt{constructor(e){super(),this.writable=!1,Mt(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,r){return super.emitReserved("error",new jt(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=vt(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}(e);return t.length?"?"+t:""}}class It extends Bt{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};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(e){((e,t)=>{const r=e.split(_t),n=[];for(let e=0;e<r.length;e++){const i=vt(r[e],t);if(n.push(i),"error"===i.type)break}return n})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const r=e.length,n=new Array(r);let i=0;e.forEach(((e,s)=>{dt(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(_t))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Lt()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let Dt=!1;try{Dt="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const qt=Dt;function Nt(){}class Ft extends It{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}class Ut extends Tt{constructor(e,t,r){super(),this.createRequest=e,Mt(this,r),this._opts=r,this._method=r.method||"GET",this._uri=t,this._data=void 0!==r.data?r.data:null,this._create()}_create(){var e;const t=Ct(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(t);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{r.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(r.getResponseHeader("set-cookie"))),4===r.readyState&&(200===r.status||1223===r.status?this._onLoad():this.setTimeoutFn((()=>{this._onError("number"==typeof r.status?r.status:0)}),0))},r.send(this._data)}catch(e){return void this.setTimeoutFn((()=>{this._onError(e)}),0)}"undefined"!=typeof document&&(this._index=Ut.requestsCount++,Ut.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=Nt,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Ut.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}function Vt(){for(let e in Ut.requests)Ut.requests.hasOwnProperty(e)&&Ut.requests[e].abort()}Ut.requestsCount=0,Ut.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Vt):"function"==typeof addEventListener&&addEventListener("onpagehide"in Pt?"pagehide":"unload",Vt,!1));const Wt=function(){const e=zt({xdomain:!1});return e&&null!==e.responseType}();function zt(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||qt))return new XMLHttpRequest}catch(e){}if(!t)try{return new(Pt[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}const Ht="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class $t extends Bt{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,r=Ht?{}:Ct(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,r)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;dt(r,this.supportsBinary,(e=>{try{this.doWrite(r,e)}catch(e){}n&&Ot((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Lt()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const Gt=Pt.WebSocket||Pt.MozWebSocket,Jt={websocket:class extends $t{createSocket(e,t,r){return Ht?new Gt(e,t,r):t?new Gt(e,t):new Gt(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends Bt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this._transport.ready.then((()=>{this._transport.createBidirectionalStream().then((e=>{const t=function(e,t){kt||(kt=new TextDecoder);const r=[];let n=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(r.push(o);;){if(0===n){if(Et(r)<1)break;const e=xt(r,1);s=!(128&~e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(Et(r)<2)break;const e=xt(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(Et(r)<8)break;const e=xt(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(ht);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(Et(r)<i)break;const e=xt(r,i);a.enqueue(vt(s?e:kt.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(ht);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=new TransformStream({transform(e,t){!function(e,t){ut&&e.data instanceof Blob?e.data.arrayBuffer().then(gt).then(t):lt&&(e.data instanceof ArrayBuffer||pt(e.data))?t(gt(e.data)):dt(e,!1,(e=>{mt||(mt=new TextEncoder),t(mt.encode(e))}))}(e,(r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,n)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(n))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(r)}))}});n.readable.pipeTo(e.writable),this._writer=n.writable.getWriter();const i=()=>{r.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then((()=>this.onOpen()))}))}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;this._writer.write(r).then((()=>{n&&Ot((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends Ft{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Wt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ut(zt,this.uri(),e)}}},Yt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Kt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Qt(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let i=Yt.exec(e||""),s={},o=14;for(;o--;)s[Kt[o]]=i[o]||"";return-1!=r&&-1!=n&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){const r=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1),"/"==t.slice(-1)&&r.splice(r.length-1,1),r}(0,s.path),s.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(r[t]=n)})),r}(0,s.query),s}const Xt="function"==typeof addEventListener&&"function"==typeof removeEventListener,Zt=[];Xt&&addEventListener("offline",(()=>{Zt.forEach((e=>e()))}),!1);class er extends Tt{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const r=Qt(e);t.hostname=r.host,t.secure="https"===r.protocol||"wss"===r.protocol,t.port=r.port,r.query&&(t.query=r.query)}else t.host&&(t.hostname=Qt(t.host).host);Mt(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach((e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e})),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},r=e.split("&");for(let e=0,n=r.length;e<n;e++){let n=r[e].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}(this.opts.query)),Xt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Zt.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);const e=this.opts.rememberUpgrade&&er.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.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)))}onOpen(){this.readyState="open",er.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn((()=>{this._onClose("ping timeout")}),e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const n=this.writeBuffer[r].data;if(n&&(e+="string"==typeof(t=n)?function(e){let t=0,r=0;for(let n=0,i=e.length;n<i;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}(t):Math.ceil(1.33*(t.byteLength||t.size))),r>0&&e>this._maxPayload)return this.writeBuffer.slice(0,r);e+=2}var t;return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Ot((()=>{this._onClose("ping timeout")}),this.setTimeoutFn)),e}write(e,t,r){return this._sendPacket("message",e,t,r),this}send(e,t,r){return this._sendPacket("message",e,t,r),this}_sendPacket(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}_onError(e){if(er.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Xt&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=Zt.indexOf(this._offlineEventListener);-1!==e&&Zt.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}er.protocol=4;class tr extends er{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),r=!1;er.priorWebsocketSuccess=!1;const n=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!r)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;er.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){r||(r=!0,h(),t.close(),t=null)}const s=e=>{const r=new Error("probe error: "+e);r.transport=t.name,i(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&i()}const h=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",n),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{r||t.open()}),200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}class rr extends tr{constructor(e,t={}){const r="object"==typeof e?e:t;(!r.transports||r.transports&&"string"==typeof r.transports[0])&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map((e=>Jt[e])).filter((e=>!!e))),super(e,r)}}const nr="function"==typeof ArrayBuffer,ir=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,sr=Object.prototype.toString,or="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===sr.call(Blob),ar="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===sr.call(File);function cr(e){return nr&&(e instanceof ArrayBuffer||ir(e))||or&&e instanceof Blob||ar&&e instanceof File}function hr(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(hr(e[t]))return!0;return!1}if(cr(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return hr(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&hr(e[t]))return!0;return!1}function ur(e){const t=[],r=e.data,n=e;return n.data=lr(r,t),n.attachments=t.length,{packet:n,buffers:t}}function lr(e,t){if(!e)return e;if(cr(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=lr(e[n],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=lr(e[n],t));return r}return e}function pr(e,t){return e.data=dr(e.data,t),delete e.attachments,e}function dr(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=dr(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=dr(e[r],t));return e}const fr=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],gr=5;var mr;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(mr||(mr={}));class yr{constructor(e){this.replacer=e}encode(e){return e.type!==mr.EVENT&&e.type!==mr.ACK||!hr(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===mr.EVENT?mr.BINARY_EVENT:mr.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==mr.BINARY_EVENT&&e.type!==mr.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=ur(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}}function br(e){return"[object Object]"===Object.prototype.toString.call(e)}class vr extends Tt{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===mr.BINARY_EVENT;r||t.type===mr.BINARY_ACK?(t.type=r?mr.EVENT:mr.ACK,this.reconstructor=new wr(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!cr(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===mr[r.type])throw new Error("unknown packet type "+r.type);if(r.type===mr.BINARY_EVENT||r.type===mr.BINARY_ACK){const n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(n,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(t+1)){const n=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);r.nsp=e.substring(n,t)}else r.nsp="/";const n=e.charAt(t+1);if(""!==n&&Number(n)==n){const n=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){const n=this.tryParse(e.substr(t));if(!vr.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case mr.CONNECT:return br(t);case mr.DISCONNECT:return void 0===t;case mr.CONNECT_ERROR:return"string"==typeof t||br(t);case mr.EVENT:case mr.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===fr.indexOf(t[0]));case mr.ACK:case mr.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class wr{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=pr(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Sr(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const _r=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class kr extends Tt{constructor(e,t,r){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=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Sr(e,"open",this.onopen.bind(this)),Sr(e,"packet",this.onpacket.bind(this)),Sr(e,"error",this.onerror.bind(this)),Sr(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var r,n,i;if(_r.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:mr.EVENT,data:t,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),s.id=e}const o=null===(n=null===(r=this.io.engine)||void 0===r?void 0:r.transport)||void 0===n?void 0:n.writable,a=this.connected&&!(null===(i=this.io.engine)||void 0===i?void 0:i._hasPingExpired());return this.flags.volatile&&!o||(a?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var r;const n=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===n)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),n),s=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,e)};s.withError=!0,this.acks[e]=s}emitWithAck(e,...t){return new Promise(((r,n)=>{const i=(e,t)=>e?n(e):r(t);i.withError=!0,t.push(i),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...n)=>{if(r===this._queue[0])return null!==e?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:mr.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((e=>{if(!this.sendBuffer.some((t=>String(t.id)===e))){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}}))}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case mr.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.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 mr.EVENT:case mr.BINARY_EVENT:this.onevent(e);break;case mr.ACK:case mr.BINARY_ACK:this.onack(e);break;case mr.DISCONNECT:this.ondisconnect();break;case mr.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...n){r||(r=!0,t.packet({type:mr.ACK,id:e,data:n}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:mr.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function Er(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Er.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+r:e-r}return 0|Math.min(e,this.max)},Er.prototype.reset=function(){this.attempts=0},Er.prototype.setMin=function(e){this.ms=e},Er.prototype.setMax=function(e){this.max=e},Er.prototype.setJitter=function(e){this.jitter=e};class xr extends Tt{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,Mt(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new Er({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||i;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new rr(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=Sr(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=Sr(t,"error",i);if(!1!==this._timeout){const e=this._timeout,r=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(n),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Sr(e,"ping",this.onping.bind(this)),Sr(e,"data",this.ondata.bind(this)),Sr(e,"error",this.onerror.bind(this)),Sr(e,"close",this.onclose.bind(this)),Sr(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){Ot((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new kr(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var r;this.cleanup(),null===(r=this.engine)||void 0===r||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Tr={};function Or(e,t){"object"==typeof e&&(t=e,e=void 0);const r=function(e,t="",r){let n=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),n=Qt(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),n=r.source,i=r.id,s=r.path,o=Tr[i]&&s in Tr[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new xr(n,t):(Tr[i]||(Tr[i]=new xr(n,t)),a=Tr[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}Object.assign(Or,{Manager:xr,Socket:kr,io:Or,connect:Or});class Pr{socket;token;endpoint;socketList=new Map;constructor(e,t){this.endpoint=e.replace("https://","wss://").replace("http://","ws://"),this.token=t,this.socket=this.getSocket("default").socket,this.socket.connect()}close(){this.socket.emit("end"),this.socket.removeAllListeners(),this.socket.disconnect()}getSocket(e,t){return this.createManager(t)}createManager(e){const t=new xr(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:e}),r=t.socket("/proxy",{auth:{token:`Bearer ${this.token}`}});return{manager:t,socket:r}}}class Cr{api;socketService;config;logger;token;deviceManager;coreManager;constructor(e){this.config=e,this.logger=e.logger||{...console,attention:console.warn},this.api=new s(e.endpoint)}async connect(){return this.deviceManager&&this.coreManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new Pr(this.config.endpoint,this.token),this.coreManager=new st(this.socketService,this.logger),this.deviceManager=new ot(this.socketService,this.logger),this.checkSession()),{coreManager:this.coreManager,deviceManager:this.deviceManager}}async disconnect(){this.socketService?.close(),this.cleanUpClient(),this.config.username&&this.config.password&&await this.api.post("/auth/logout",void 0,{headers:{Authorization:`Bearer ${this.token}`}})}async updateCredentials(e){this.config={...this.config,...e},this.socketService&&await this.disconnect(),await this.connect()}async login(){if(this.config.username&&this.config.password)try{const e=await this.api.post("/auth/login",{username:this.config.username,password:this.config.password}),t=await e.json();this.token=t.access_token}catch(e){throw 401===e.response?.status?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(){this.socketService?.socket.removeListener("invalidToken"),this.socketService?.socket.on("invalidToken",(async e=>{e===this.token&&await this.disconnect()}))}cleanUpClient(){this.deviceManager=void 0}}var Ar=n.j;export{Ar as CameraUiClient};
@@ -9,7 +9,7 @@ export declare class CoreManager implements CoreManagerInterface {
9
9
  private subject;
10
10
  constructor(socketService: SocketService, logger: BaseLogger);
11
11
  getFFmpegPath(): Promise<string>;
12
- getHwaccelInfo(): Promise<FfmpegArgs>;
12
+ getHwaccelInfo(targetCodec: 'h264' | 'h265'): Promise<FfmpegArgs>;
13
13
  getServerAddresses(): Promise<string[]>;
14
14
  getIceServers(): Promise<IceServer[]>;
15
15
  private onRequest;
@@ -73,8 +73,8 @@ export declare abstract class BaseCameraDevice extends Subscribed {
73
73
  protected removeAllListeners(): void;
74
74
  protected updateCamera(updatedCamera: Camera): void;
75
75
  protected updateCameraState(state: boolean): void;
76
- protected updateStateInternal<T extends keyof SetValues>(stateName: T, eventData: SetValues[T], skipCheck?: boolean): void;
77
- protected checkStateInternal<T extends keyof SetValues>(stateName: T, event: SetValues[T]): {
76
+ protected updateStateInternal<T extends keyof SetValues>(stateName: T, eventData: SetValues[T], skipCheck?: boolean, skipDetectionsCheck?: boolean): void;
77
+ protected checkStateInternal<T extends keyof SetValues>(stateName: T, event: SetValues[T], skipDetectionsCheck?: boolean): {
78
78
  changed: boolean;
79
79
  event: StateValues[T];
80
80
  };
@@ -1,2 +1,2 @@
1
1
  import type { Detection } from '@camera.ui/types';
2
- export declare const mergeDetections: (detections: Detection[], iouThreshold?: number) => Detection[];
2
+ export declare function mergeDetections(detections: Detection[], iouThreshold?: number): Detection[];
@@ -1,5 +1,5 @@
1
1
  import type { CameraActivitySettings, Detection, DetectionZone } from '@camera.ui/types';
2
2
  export declare const convertZonePointsToPixels: (zone: DetectionZone, detection: Detection) => DetectionZone;
3
3
  export declare const convertBoundingBoxToPixels: (detection: Detection) => Detection;
4
- export declare const areObjectDetectionsValid: (detections: Detection[], zones: DetectionZone[], activitySettings: CameraActivitySettings) => Detection[];
5
4
  export declare const areMotionDetectionsValid: (detections: Detection[], zones: DetectionZone[], activitySettings: CameraActivitySettings) => Detection[];
5
+ export declare const areObjectDetectionsValid: (detections: Detection[], zones: DetectionZone[], activitySettings: CameraActivitySettings) => Detection[];
@@ -121,7 +121,7 @@ export interface CameraDeviceProxyMethods {
121
121
  addCameraSource(source: CameraConfigInputSettings): Promise<void>;
122
122
  updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
123
123
  removeCameraSource(sourceId: string): Promise<void>;
124
- probeStream(sourceId: string): Promise<ProbeStream | undefined>;
124
+ probeStream(sourceId: string, refresh: boolean): Promise<ProbeStream | undefined>;
125
125
  }
126
126
  export interface CameraDeviceListenerStatePayload<K extends keyof StateValues> {
127
127
  stateName: K;
@@ -19,7 +19,7 @@ export type ImageInputFormat = 'yuv' | 'rgb' | 'rgba' | 'gray';
19
19
  export type ImageOutputFormat = 'rgb' | 'rgba' | 'gray';
20
20
  export type CameraExtension = 'hub' | 'prebuffer' | 'motionDetection' | 'objectDetection' | 'audioDetection' | 'ptz';
21
21
  export type CameraFrameWorkerDecoder = 'pillow' | 'wasm';
22
- export type CameraFrameWorkerResolution = 640 | 480 | 320;
22
+ export type CameraFrameWorkerResolution = '640' | '480' | '320' | 'native';
23
23
  export type AudioCodec = 'PCMU' | 'PCMA' | 'MPEG4-GENERIC' | 'opus' | 'G722' | 'MPA' | 'PCM' | 'FLAC';
24
24
  export type AudioFFmpegCodec = 'pcm_mulaw' | 'pcm_alaw' | 'aac' | 'libopus' | 'g722' | 'mp3' | 'pcm_s16be' | 'pcm_s16le' | 'flac';
25
25
  export type VideoCodec = 'H264' | 'H265' | 'VP8' | 'VP9' | 'AV1' | 'JPEG' | 'RAW';
@@ -306,7 +306,7 @@ export interface CameraDelegates {
306
306
  }
307
307
  export interface CameraSource extends CameraInput {
308
308
  getPrebufferingState(container: Container): Promise<PrebufferState | undefined>;
309
- probeStream(): Promise<ProbeStream | undefined>;
309
+ probeStream(refresh?: boolean): Promise<ProbeStream | undefined>;
310
310
  }
311
311
  export interface CameraInternalSource extends CameraSource {
312
312
  type: 'aac' | 'opus' | 'pcma';
@@ -470,14 +470,16 @@ export interface DeviceManager {
470
470
  }
471
471
  export interface CoreManager {
472
472
  getFFmpegPath(): Promise<string>;
473
- getHwaccelInfo(): Promise<FfmpegArgs>;
473
+ getHwaccelInfo(targetCodec: 'h264' | 'h265'): Promise<FfmpegArgs>;
474
474
  getServerAddresses(): Promise<string[]>;
475
475
  getIceServers(): Promise<IceServer[]>;
476
476
  }
477
477
  export interface FfmpegArgs {
478
+ codec: string;
478
479
  hwaccel: string;
479
480
  hwaccelArgs: string[];
480
- hwaccelFilter: string;
481
+ hwaccelFilters: string[];
482
+ hwDeviceArgs: string[];
481
483
  threads: string;
482
484
  }
483
485
  export interface IceServer {
@@ -220,15 +220,15 @@ export declare const streamingModeSchema: zod.ZodUnion<[zod.ZodLiteral<"mse">, z
220
220
  export declare const frameWorkerSettingsSchema: zod.ZodObject<{
221
221
  decoder: zod.ZodUnion<[zod.ZodLiteral<"pillow">, zod.ZodLiteral<"wasm">]>;
222
222
  fps: zod.ZodNumber;
223
- resolution: zod.ZodUnion<[zod.ZodLiteral<640>, zod.ZodLiteral<480>, zod.ZodLiteral<320>]>;
223
+ resolution: zod.ZodUnion<[zod.ZodLiteral<"640">, zod.ZodLiteral<"480">, zod.ZodLiteral<"320">, zod.ZodLiteral<"native">]>;
224
224
  }, "strip", zod.ZodTypeAny, {
225
225
  decoder: "pillow" | "wasm";
226
226
  fps: number;
227
- resolution: 640 | 480 | 320;
227
+ resolution: "native" | "640" | "480" | "320";
228
228
  }, {
229
229
  decoder: "pillow" | "wasm";
230
230
  fps: number;
231
- resolution: 640 | 480 | 320;
231
+ resolution: "native" | "640" | "480" | "320";
232
232
  }>;
233
233
  export declare const cameraTypeSchema: zod.ZodUnion<[zod.ZodLiteral<"camera">, zod.ZodLiteral<"doorbell">]>;
234
234
  export declare const interfaceSettingsSchema: zod.ZodObject<{
@@ -470,15 +470,15 @@ export declare const createCameraSchema: zod.ZodObject<{
470
470
  frameWorkerSettings: zod.ZodDefault<zod.ZodObject<{
471
471
  decoder: zod.ZodUnion<[zod.ZodLiteral<"pillow">, zod.ZodLiteral<"wasm">]>;
472
472
  fps: zod.ZodNumber;
473
- resolution: zod.ZodUnion<[zod.ZodLiteral<640>, zod.ZodLiteral<480>, zod.ZodLiteral<320>]>;
473
+ resolution: zod.ZodUnion<[zod.ZodLiteral<"640">, zod.ZodLiteral<"480">, zod.ZodLiteral<"320">, zod.ZodLiteral<"native">]>;
474
474
  }, "strip", zod.ZodTypeAny, {
475
475
  decoder: "pillow" | "wasm";
476
476
  fps: number;
477
- resolution: 640 | 480 | 320;
477
+ resolution: "native" | "640" | "480" | "320";
478
478
  }, {
479
479
  decoder: "pillow" | "wasm";
480
480
  fps: number;
481
- resolution: 640 | 480 | 320;
481
+ resolution: "native" | "640" | "480" | "320";
482
482
  }>>;
483
483
  }, "strict", zod.ZodTypeAny, {
484
484
  pluginId: string;
@@ -525,7 +525,7 @@ export declare const createCameraSchema: zod.ZodObject<{
525
525
  frameWorkerSettings: {
526
526
  decoder: "pillow" | "wasm";
527
527
  fps: number;
528
- resolution: 640 | 480 | 320;
528
+ resolution: "native" | "640" | "480" | "320";
529
529
  };
530
530
  sources: {
531
531
  _id: string;
@@ -604,7 +604,7 @@ export declare const createCameraSchema: zod.ZodObject<{
604
604
  frameWorkerSettings?: {
605
605
  decoder: "pillow" | "wasm";
606
606
  fps: number;
607
- resolution: 640 | 480 | 320;
607
+ resolution: "native" | "640" | "480" | "320";
608
608
  } | undefined;
609
609
  extensions?: {
610
610
  plugins: string[];
@@ -627,7 +627,7 @@ export declare const patchCameraSchema: zod.ZodObject<{
627
627
  disabled: zod.ZodOptional<zod.ZodBoolean>;
628
628
  type: zod.ZodOptional<zod.ZodUnion<[zod.ZodLiteral<"camera">, zod.ZodLiteral<"doorbell">]>>;
629
629
  name: zod.ZodOptional<zod.ZodString>;
630
- snapshotTTL: zod.ZodDefault<zod.ZodNumber>;
630
+ snapshotTTL: zod.ZodOptional<zod.ZodNumber>;
631
631
  info: zod.ZodOptional<zod.ZodObject<{
632
632
  model: zod.ZodOptional<zod.ZodOptional<zod.ZodString>>;
633
633
  manufacturer: zod.ZodOptional<zod.ZodOptional<zod.ZodString>>;
@@ -822,18 +822,17 @@ export declare const patchCameraSchema: zod.ZodObject<{
822
822
  frameWorkerSettings: zod.ZodOptional<zod.ZodObject<{
823
823
  decoder: zod.ZodOptional<zod.ZodUnion<[zod.ZodLiteral<"pillow">, zod.ZodLiteral<"wasm">]>>;
824
824
  fps: zod.ZodOptional<zod.ZodNumber>;
825
- resolution: zod.ZodOptional<zod.ZodUnion<[zod.ZodLiteral<640>, zod.ZodLiteral<480>, zod.ZodLiteral<320>]>>;
825
+ resolution: zod.ZodOptional<zod.ZodUnion<[zod.ZodLiteral<"640">, zod.ZodLiteral<"480">, zod.ZodLiteral<"320">, zod.ZodLiteral<"native">]>>;
826
826
  }, "strip", zod.ZodTypeAny, {
827
827
  decoder?: "pillow" | "wasm" | undefined;
828
828
  fps?: number | undefined;
829
- resolution?: 640 | 480 | 320 | undefined;
829
+ resolution?: "native" | "640" | "480" | "320" | undefined;
830
830
  }, {
831
831
  decoder?: "pillow" | "wasm" | undefined;
832
832
  fps?: number | undefined;
833
- resolution?: 640 | 480 | 320 | undefined;
833
+ resolution?: "native" | "640" | "480" | "320" | undefined;
834
834
  }>>;
835
835
  }, "strict", zod.ZodTypeAny, {
836
- snapshotTTL: number;
837
836
  type?: "camera" | "doorbell" | undefined;
838
837
  disabled?: boolean | undefined;
839
838
  name?: string | undefined;
@@ -859,6 +858,7 @@ export declare const patchCameraSchema: zod.ZodObject<{
859
858
  firmwareVersion?: string | undefined;
860
859
  supportUrl?: string | undefined;
861
860
  } | undefined;
861
+ snapshotTTL?: number | undefined;
862
862
  activitySettings?: {
863
863
  object?: {
864
864
  confidence: number;
@@ -870,7 +870,7 @@ export declare const patchCameraSchema: zod.ZodObject<{
870
870
  frameWorkerSettings?: {
871
871
  decoder?: "pillow" | "wasm" | undefined;
872
872
  fps?: number | undefined;
873
- resolution?: 640 | 480 | 320 | undefined;
873
+ resolution?: "native" | "640" | "480" | "320" | undefined;
874
874
  } | undefined;
875
875
  sources?: {
876
876
  _id: string;
@@ -933,7 +933,7 @@ export declare const patchCameraSchema: zod.ZodObject<{
933
933
  frameWorkerSettings?: {
934
934
  decoder?: "pillow" | "wasm" | undefined;
935
935
  fps?: number | undefined;
936
- resolution?: 640 | 480 | 320 | undefined;
936
+ resolution?: "native" | "640" | "480" | "320" | undefined;
937
937
  } | undefined;
938
938
  sources?: {
939
939
  name: string;
@@ -33,7 +33,7 @@ export declare const userPreferencesCamviewViewsLayout: zod.ZodObject<{
33
33
  type: "dnd" | "view";
34
34
  _id: string;
35
35
  name: string;
36
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
36
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
37
37
  cameras: {
38
38
  cameraId: string;
39
39
  index: number;
@@ -41,7 +41,7 @@ export declare const userPreferencesCamviewViewsLayout: zod.ZodObject<{
41
41
  }, {
42
42
  type: "dnd" | "view";
43
43
  name: string;
44
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
44
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
45
45
  cameras: {
46
46
  cameraId: string;
47
47
  index: number;
@@ -63,14 +63,14 @@ export declare const patchPreferencesCamviewViewsLayout: zod.ZodOptional<zod.Zod
63
63
  }>, "many">>;
64
64
  }, "strip", zod.ZodTypeAny, {
65
65
  name?: string | undefined;
66
- viewSize?: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26 | undefined;
66
+ viewSize?: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26 | undefined;
67
67
  cameras?: {
68
68
  cameraId: string;
69
69
  index: number;
70
70
  }[] | undefined;
71
71
  }, {
72
72
  name?: string | undefined;
73
- viewSize?: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26 | undefined;
73
+ viewSize?: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26 | undefined;
74
74
  cameras?: {
75
75
  cameraId: string;
76
76
  index: number;
@@ -96,7 +96,7 @@ export declare const userPreferencesCamview: zod.ZodObject<{
96
96
  type: "dnd" | "view";
97
97
  _id: string;
98
98
  name: string;
99
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
99
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
100
100
  cameras: {
101
101
  cameraId: string;
102
102
  index: number;
@@ -104,7 +104,7 @@ export declare const userPreferencesCamview: zod.ZodObject<{
104
104
  }, {
105
105
  type: "dnd" | "view";
106
106
  name: string;
107
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
107
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
108
108
  cameras: {
109
109
  cameraId: string;
110
110
  index: number;
@@ -116,7 +116,7 @@ export declare const userPreferencesCamview: zod.ZodObject<{
116
116
  type: "dnd" | "view";
117
117
  _id: string;
118
118
  name: string;
119
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
119
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
120
120
  cameras: {
121
121
  cameraId: string;
122
122
  index: number;
@@ -126,7 +126,7 @@ export declare const userPreferencesCamview: zod.ZodObject<{
126
126
  views: {
127
127
  type: "dnd" | "view";
128
128
  name: string;
129
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
129
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
130
130
  cameras: {
131
131
  cameraId: string;
132
132
  index: number;
@@ -256,7 +256,7 @@ export declare const userPreferences: zod.ZodObject<{
256
256
  type: "dnd" | "view";
257
257
  _id: string;
258
258
  name: string;
259
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
259
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
260
260
  cameras: {
261
261
  cameraId: string;
262
262
  index: number;
@@ -264,7 +264,7 @@ export declare const userPreferences: zod.ZodObject<{
264
264
  }, {
265
265
  type: "dnd" | "view";
266
266
  name: string;
267
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
267
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
268
268
  cameras: {
269
269
  cameraId: string;
270
270
  index: number;
@@ -276,7 +276,7 @@ export declare const userPreferences: zod.ZodObject<{
276
276
  type: "dnd" | "view";
277
277
  _id: string;
278
278
  name: string;
279
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
279
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
280
280
  cameras: {
281
281
  cameraId: string;
282
282
  index: number;
@@ -286,7 +286,7 @@ export declare const userPreferences: zod.ZodObject<{
286
286
  views: {
287
287
  type: "dnd" | "view";
288
288
  name: string;
289
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
289
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
290
290
  cameras: {
291
291
  cameraId: string;
292
292
  index: number;
@@ -358,7 +358,7 @@ export declare const userPreferences: zod.ZodObject<{
358
358
  type: "dnd" | "view";
359
359
  _id: string;
360
360
  name: string;
361
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
361
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
362
362
  cameras: {
363
363
  cameraId: string;
364
364
  index: number;
@@ -380,7 +380,7 @@ export declare const userPreferences: zod.ZodObject<{
380
380
  views: {
381
381
  type: "dnd" | "view";
382
382
  name: string;
383
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
383
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
384
384
  cameras: {
385
385
  cameraId: string;
386
386
  index: number;
@@ -420,7 +420,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
420
420
  type: "dnd" | "view";
421
421
  _id: string;
422
422
  name: string;
423
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
423
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
424
424
  cameras: {
425
425
  cameraId: string;
426
426
  index: number;
@@ -428,7 +428,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
428
428
  }, {
429
429
  type: "dnd" | "view";
430
430
  name: string;
431
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
431
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
432
432
  cameras: {
433
433
  cameraId: string;
434
434
  index: number;
@@ -440,7 +440,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
440
440
  type: "dnd" | "view";
441
441
  _id: string;
442
442
  name: string;
443
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
443
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
444
444
  cameras: {
445
445
  cameraId: string;
446
446
  index: number;
@@ -450,7 +450,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
450
450
  views: {
451
451
  type: "dnd" | "view";
452
452
  name: string;
453
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
453
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
454
454
  cameras: {
455
455
  cameraId: string;
456
456
  index: number;
@@ -522,7 +522,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
522
522
  type: "dnd" | "view";
523
523
  _id: string;
524
524
  name: string;
525
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
525
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
526
526
  cameras: {
527
527
  cameraId: string;
528
528
  index: number;
@@ -544,7 +544,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
544
544
  views: {
545
545
  type: "dnd" | "view";
546
546
  name: string;
547
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
547
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
548
548
  cameras: {
549
549
  cameraId: string;
550
550
  index: number;
@@ -579,7 +579,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
579
579
  type: "dnd" | "view";
580
580
  _id: string;
581
581
  name: string;
582
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
582
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
583
583
  cameras: {
584
584
  cameraId: string;
585
585
  index: number;
@@ -612,7 +612,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
612
612
  views: {
613
613
  type: "dnd" | "view";
614
614
  name: string;
615
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
615
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
616
616
  cameras: {
617
617
  cameraId: string;
618
618
  index: number;
@@ -647,7 +647,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
647
647
  type: "dnd" | "view";
648
648
  _id: string;
649
649
  name: string;
650
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
650
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
651
651
  cameras: {
652
652
  cameraId: string;
653
653
  index: number;
@@ -680,7 +680,7 @@ export declare const createUserSchema: zod.ZodEffects<zod.ZodObject<{
680
680
  views: {
681
681
  type: "dnd" | "view";
682
682
  name: string;
683
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
683
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
684
684
  cameras: {
685
685
  cameraId: string;
686
686
  index: number;
@@ -734,7 +734,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
734
734
  type: "dnd" | "view";
735
735
  _id: string;
736
736
  name: string;
737
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
737
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
738
738
  cameras: {
739
739
  cameraId: string;
740
740
  index: number;
@@ -742,7 +742,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
742
742
  }, {
743
743
  type: "dnd" | "view";
744
744
  name: string;
745
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
745
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
746
746
  cameras: {
747
747
  cameraId: string;
748
748
  index: number;
@@ -754,7 +754,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
754
754
  type: "dnd" | "view";
755
755
  _id: string;
756
756
  name: string;
757
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
757
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
758
758
  cameras: {
759
759
  cameraId: string;
760
760
  index: number;
@@ -764,7 +764,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
764
764
  views: {
765
765
  type: "dnd" | "view";
766
766
  name: string;
767
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
767
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
768
768
  cameras: {
769
769
  cameraId: string;
770
770
  index: number;
@@ -836,7 +836,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
836
836
  type: "dnd" | "view";
837
837
  _id: string;
838
838
  name: string;
839
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
839
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
840
840
  cameras: {
841
841
  cameraId: string;
842
842
  index: number;
@@ -858,7 +858,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
858
858
  views: {
859
859
  type: "dnd" | "view";
860
860
  name: string;
861
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
861
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
862
862
  cameras: {
863
863
  cameraId: string;
864
864
  index: number;
@@ -893,7 +893,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
893
893
  type: "dnd" | "view";
894
894
  _id: string;
895
895
  name: string;
896
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
896
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
897
897
  cameras: {
898
898
  cameraId: string;
899
899
  index: number;
@@ -926,7 +926,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
926
926
  views: {
927
927
  type: "dnd" | "view";
928
928
  name: string;
929
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
929
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
930
930
  cameras: {
931
931
  cameraId: string;
932
932
  index: number;
@@ -961,7 +961,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
961
961
  type: "dnd" | "view";
962
962
  _id: string;
963
963
  name: string;
964
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
964
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
965
965
  cameras: {
966
966
  cameraId: string;
967
967
  index: number;
@@ -994,7 +994,7 @@ export declare const patchUserSchema: zod.ZodEffects<zod.ZodObject<{
994
994
  views: {
995
995
  type: "dnd" | "view";
996
996
  name: string;
997
- viewSize: 1 | 4 | 16 | 6 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
997
+ viewSize: 1 | 4 | 6 | 16 | 20 | 12 | 10 | 7 | 9 | 13 | 15 | 26;
998
998
  cameras: {
999
999
  cameraId: string;
1000
1000
  index: number;
@@ -26,7 +26,7 @@ export declare class CameraController extends CameraDevice {
26
26
  connect(): Promise<void>;
27
27
  disconnect(): Promise<void>;
28
28
  updateState<T extends keyof SetValues>(stateName: T, eventData: SetValues[T]): Promise<void>;
29
- probeStream(sourceId: string): Promise<ProbeStream | undefined>;
29
+ probeStream(sourceId: string, refresh?: boolean): Promise<ProbeStream | undefined>;
30
30
  addCameraSource(source: CameraConfigInputSettings): Promise<void>;
31
31
  updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
32
32
  removeCameraSource(sourceId: string): Promise<void>;
@@ -11,7 +11,7 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
11
11
  connect(cameraId: string, pluginId: string): void;
12
12
  disconnect(cameraId: string, pluginId: string): void;
13
13
  updateState<T extends keyof SetValues>(stateName: T, eventData: SetValues[T], cameraId: string, pluginId: string): Promise<void>;
14
- probeStream(sourceId: string, cameraId: string): Promise<ProbeStream | undefined>;
14
+ probeStream(sourceId: string, refresh: boolean, cameraId: string): Promise<ProbeStream | undefined>;
15
15
  addCameraSource(source: CameraConfigInputSettings, cameraId: string, pluginId: string): Promise<void>;
16
16
  updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>, cameraId: string, pluginId: string): Promise<void>;
17
17
  removeCameraSource(sourceId: string, cameraId: string, pluginId: string): Promise<void>;
@@ -7,7 +7,7 @@ export declare class CoreManagerProxy implements CoreManager {
7
7
  private messageQueue;
8
8
  constructor(messageQueue: MessageQueue);
9
9
  getFFmpegPath(): Promise<string>;
10
- getHwaccelInfo(): Promise<FfmpegArgs>;
10
+ getHwaccelInfo(targetCodec: 'h264' | 'h265'): Promise<FfmpegArgs>;
11
11
  getServerAddresses(): Promise<string[]>;
12
12
  getIceServers(): Promise<IceServer[]>;
13
13
  requestHandler(message: ProxyMessageStructure): Promise<void | ProxyMessageStructure>;
@@ -7,6 +7,7 @@ export declare class PluginManager {
7
7
  private api;
8
8
  private configService;
9
9
  private pythonVersionsToInstall;
10
+ installedPythonVersions: Set<string>;
10
11
  plugins: Map<string, Plugin>;
11
12
  pluginWorkers: Map<string, PluginWorker>;
12
13
  searchPaths: Set<string>;
@@ -8,6 +8,7 @@ export declare class PluginWorker {
8
8
  private logger;
9
9
  private configService;
10
10
  private socketService;
11
+ private pluginManager;
11
12
  private publisher?;
12
13
  private subscriber?;
13
14
  private subject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camera.ui/browser",
3
- "version": "0.0.99",
3
+ "version": "0.0.100",
4
4
  "description": "camera.ui browser client",
5
5
  "author": "seydx (https://github.com/seydx/camera.ui)",
6
6
  "module": "./dist/bundle.js",
@@ -32,9 +32,9 @@
32
32
  "devDependencies": {
33
33
  "@rushstack/eslint-patch": "^1.10.4",
34
34
  "@swc/register": "^0.1.10",
35
- "@types/webrtc": "^0.0.43",
36
- "@typescript-eslint/eslint-plugin": "^8.7.0",
37
- "@typescript-eslint/parser": "^8.7.0",
35
+ "@types/webrtc": "^0.0.44",
36
+ "@typescript-eslint/eslint-plugin": "^8.8.0",
37
+ "@typescript-eslint/parser": "^8.8.0",
38
38
  "bufferutil": "^4.0.8",
39
39
  "eslint": "^8.57.0",
40
40
  "eslint-config-prettier": "^9.1.0",
@@ -45,7 +45,7 @@
45
45
  "typescript": "^5.6.2",
46
46
  "updates": "^16.4.0",
47
47
  "utf-8-validate": "^6.0.4",
48
- "webpack": "^5.94.0",
48
+ "webpack": "^5.95.0",
49
49
  "webpack-cli": "^5.1.4"
50
50
  },
51
51
  "bugs": {