@camera.ui/browser 0.0.85 → 0.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/types/packages/client/browser/src/client.d.ts +3 -1
  3. package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +1 -2
  4. package/dist/types/packages/client/browser/src/proxy/coreManager.d.ts +14 -0
  5. package/dist/types/packages/client/browser/src/proxy/index.d.ts +1 -0
  6. package/dist/types/packages/client/browser/src/streaming/go2rts-session.d.ts +0 -1
  7. package/dist/types/packages/client/browser/src/utils.d.ts +1 -1
  8. package/dist/types/server/src/api/database/index.d.ts +9 -3
  9. package/dist/types/server/src/api/database/types.d.ts +12 -0
  10. package/dist/types/server/src/api/schemas/cameras.schema.d.ts +5 -4
  11. package/dist/types/server/src/api/schemas/system.schema.d.ts +9 -0
  12. package/dist/types/server/src/api/schemas/users.schema.d.ts +36 -36
  13. package/dist/types/server/src/api/services/system.service.d.ts +7 -0
  14. package/dist/types/server/src/api/types/index.d.ts +4 -0
  15. package/dist/types/server/src/api/utils/fetch.d.ts +2 -0
  16. package/dist/types/server/src/api/websocket/nsp/main.d.ts +7 -0
  17. package/dist/types/server/src/api/websocket/nsp/notifications.d.ts +5 -4
  18. package/dist/types/server/src/api/websocket/nsp/server.d.ts +14 -2
  19. package/dist/types/server/src/api/websocket/types.d.ts +1 -1
  20. package/dist/types/server/src/camera/controller.d.ts +0 -3
  21. package/dist/types/server/src/camera/device.d.ts +0 -1
  22. package/dist/types/server/src/camera/index.d.ts +0 -2
  23. package/dist/types/server/src/camera/streaming/peer-connection.d.ts +2 -1
  24. package/dist/types/server/src/camera/streaming/webrtc-connection.d.ts +1 -2
  25. package/dist/types/server/src/camera/streaming/werift-session.d.ts +1 -0
  26. package/dist/types/server/src/camera/types.d.ts +1 -0
  27. package/dist/types/server/src/nats/index.d.ts +4 -1
  28. package/dist/types/server/src/nats/proxy/cameraDevice.d.ts +0 -3
  29. package/dist/types/server/src/nats/proxy/coreManager.d.ts +14 -0
  30. package/dist/types/server/src/nats/types.d.ts +25 -6
  31. package/dist/types/server/src/polyglot/node/plugins/pluginApi.d.ts +3 -0
  32. package/dist/types/server/src/polyglot/node/plugins/proxy/cameraDevice.d.ts +0 -3
  33. package/dist/types/server/src/polyglot/node/plugins/proxy/coreManager.d.ts +40 -0
  34. package/dist/types/server/src/services/config/index.d.ts +1 -0
  35. package/dist/types/server/src/services/logger/index.d.ts +2 -3
  36. package/dist/types/server/src/utils/network.d.ts +12 -0
  37. package/dist/types/server/src/utils/npm.d.ts +1 -0
  38. package/dist/types/shared/types/index.d.ts +1 -0
  39. package/package.json +3 -3
  40. package/dist/types/server/src/api/websocket/nsp/frameWorker.d.ts +0 -13
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{j:()=>En});var s={};t.r(s),t.d(s,{hasBrowserEnv:()=>dt,hasStandardBrowserEnv:()=>ft,hasStandardBrowserWebWorkerEnv:()=>gt,origin:()=>mt});var i={};function n(t,e){return function(){return t.apply(e,arguments)}}t.r(i),t.d(i,{Decoder:()=>fn,Encoder:()=>ln,PacketType:()=>un,protocol:()=>hn});const{toString:r}=Object.prototype,{getPrototypeOf:o}=Object,a=(t=>e=>{const s=r.call(e);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),c=t=>(t=t.toLowerCase(),e=>a(e)===t),h=t=>e=>typeof e===t,{isArray:u}=Array,l=h("undefined"),d=c("ArrayBuffer"),f=h("string"),p=h("function"),g=h("number"),m=t=>null!==t&&"object"==typeof t,y=t=>{if("object"!==a(t))return!1;const e=o(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},b=c("Date"),v=c("File"),w=c("Blob"),S=c("FileList"),k=c("URLSearchParams"),[E,_,O,T]=["ReadableStream","Request","Response","Headers"].map(c);function x(t,e,{allOwnKeys:s=!1}={}){if(null==t)return;let i,n;if("object"!=typeof t&&(t=[t]),u(t))for(i=0,n=t.length;i<n;i++)e.call(null,t[i],i,t);else{const n=s?Object.getOwnPropertyNames(t):Object.keys(t),r=n.length;let o;for(i=0;i<r;i++)o=n[i],e.call(null,t[o],o,t)}}function A(t,e){e=e.toLowerCase();const s=Object.keys(t);let i,n=s.length;for(;n-- >0;)if(i=s[n],e===i.toLowerCase())return i;return null}const R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,L=t=>!l(t)&&t!==R,C=(j="undefined"!=typeof Uint8Array&&o(Uint8Array),t=>j&&t instanceof j);var j;const B=c("HTMLFormElement"),P=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype),D=c("RegExp"),F=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t),i={};x(s,((s,n)=>{let r;!1!==(r=e(s,n,t))&&(i[n]=r||s)})),Object.defineProperties(t,i)},N="abcdefghijklmnopqrstuvwxyz",M="0123456789",z={DIGIT:M,ALPHA:N,ALPHA_DIGIT:N+N.toUpperCase()+M},I=c("AsyncFunction"),U=(q="function"==typeof setImmediate,V=p(R.postMessage),q?setImmediate:V?(W=`axios@${Math.random()}`,H=[],R.addEventListener("message",(({source:t,data:e})=>{t===R&&e===W&&H.length&&H.shift()()}),!1),t=>{H.push(t),R.postMessage(W,"*")}):t=>setTimeout(t));var q,V,W,H;const $="undefined"!=typeof queueMicrotask?queueMicrotask.bind(R):"undefined"!=typeof process&&process.nextTick||U,J={isArray:u,isArrayBuffer:d,isBuffer:function(t){return null!==t&&!l(t)&&null!==t.constructor&&!l(t.constructor)&&p(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||p(t.append)&&("formdata"===(e=a(t))||"object"===e&&p(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&d(t.buffer),e},isString:f,isNumber:g,isBoolean:t=>!0===t||!1===t,isObject:m,isPlainObject:y,isReadableStream:E,isRequest:_,isResponse:O,isHeaders:T,isUndefined:l,isDate:b,isFile:v,isBlob:w,isRegExp:D,isFunction:p,isStream:t=>m(t)&&p(t.pipe),isURLSearchParams:k,isTypedArray:C,isFileList:S,forEach:x,merge:function t(){const{caseless:e}=L(this)&&this||{},s={},i=(i,n)=>{const r=e&&A(s,n)||n;y(s[r])&&y(i)?s[r]=t(s[r],i):y(i)?s[r]=t({},i):u(i)?s[r]=i.slice():s[r]=i};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&x(arguments[t],i);return s},extend:(t,e,s,{allOwnKeys:i}={})=>(x(e,((e,i)=>{s&&p(e)?t[i]=n(e,s):t[i]=e}),{allOwnKeys:i}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,s,i)=>{t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),s&&Object.assign(t.prototype,s)},toFlatObject:(t,e,s,i)=>{let n,r,a;const c={};if(e=e||{},null==t)return e;do{for(n=Object.getOwnPropertyNames(t),r=n.length;r-- >0;)a=n[r],i&&!i(a,t,e)||c[a]||(e[a]=t[a],c[a]=!0);t=!1!==s&&o(t)}while(t&&(!s||s(t,e))&&t!==Object.prototype);return e},kindOf:a,kindOfTest:c,endsWith:(t,e,s)=>{t=String(t),(void 0===s||s>t.length)&&(s=t.length),s-=e.length;const i=t.indexOf(e,s);return-1!==i&&i===s},toArray:t=>{if(!t)return null;if(u(t))return t;let e=t.length;if(!g(e))return null;const s=new Array(e);for(;e-- >0;)s[e]=t[e];return s},forEachEntry:(t,e)=>{const s=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=s.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},matchAll:(t,e)=>{let s;const i=[];for(;null!==(s=t.exec(e));)i.push(s);return i},isHTMLForm:B,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:F,freezeMethods:t=>{F(t,((e,s)=>{if(p(t)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const i=t[s];p(i)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}))}))},toObjectSet:(t,e)=>{const s={},i=t=>{t.forEach((t=>{s[t]=!0}))};return u(t)?i(t):i(String(t).split(e)),s},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,s){return e.toUpperCase()+s})),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:A,global:R,isContextDefined:L,ALPHABET:z,generateString:(t=16,e=z.ALPHA_DIGIT)=>{let s="";const{length:i}=e;for(;t--;)s+=e[Math.random()*i|0];return s},isSpecCompliantForm:function(t){return!!(t&&p(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),s=(t,i)=>{if(m(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[i]=t;const n=u(t)?[]:{};return x(t,((t,e)=>{const r=s(t,i+1);!l(r)&&(n[e]=r)})),e[i]=void 0,n}}return t};return s(t,0)},isAsyncFn:I,isThenable:t=>t&&(m(t)||p(t))&&p(t.then)&&p(t.catch),setImmediate:U,asap:$};function G(t,e,s,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),s&&(this.config=s),i&&(this.request=i),n&&(this.response=n)}J.inherits(G,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:J.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const K=G.prototype,Y={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{Y[t]={value:t}})),Object.defineProperties(G,Y),Object.defineProperty(K,"isAxiosError",{value:!0}),G.from=(t,e,s,i,n,r)=>{const o=Object.create(K);return J.toFlatObject(t,o,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),G.call(o,t.message,e,s,i,n),o.cause=t,o.name=t.name,r&&Object.assign(o,r),o};const X=G;function Q(t){return J.isPlainObject(t)||J.isArray(t)}function Z(t){return J.endsWith(t,"[]")?t.slice(0,-2):t}function tt(t,e,s){return t?t.concat(e).map((function(t,e){return t=Z(t),!s&&e?"["+t+"]":t})).join(s?".":""):e}const et=J.toFlatObject(J,{},null,(function(t){return/^is[A-Z]/.test(t)})),st=function(t,e,s){if(!J.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const i=(s=J.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!J.isUndefined(e[t])}))).metaTokens,n=s.visitor||h,r=s.dots,o=s.indexes,a=(s.Blob||"undefined"!=typeof Blob&&Blob)&&J.isSpecCompliantForm(e);if(!J.isFunction(n))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(J.isDate(t))return t.toISOString();if(!a&&J.isBlob(t))throw new X("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(t)||J.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function h(t,s,n){let a=t;if(t&&!n&&"object"==typeof t)if(J.endsWith(s,"{}"))s=i?s:s.slice(0,-2),t=JSON.stringify(t);else if(J.isArray(t)&&function(t){return J.isArray(t)&&!t.some(Q)}(t)||(J.isFileList(t)||J.endsWith(s,"[]"))&&(a=J.toArray(t)))return s=Z(s),a.forEach((function(t,i){!J.isUndefined(t)&&null!==t&&e.append(!0===o?tt([s],i,r):null===o?s:s+"[]",c(t))})),!1;return!!Q(t)||(e.append(tt(n,s,r),c(t)),!1)}const u=[],l=Object.assign(et,{defaultVisitor:h,convertValue:c,isVisitable:Q});if(!J.isObject(t))throw new TypeError("data must be an object");return function t(s,i){if(!J.isUndefined(s)){if(-1!==u.indexOf(s))throw Error("Circular reference detected in "+i.join("."));u.push(s),J.forEach(s,(function(s,r){!0===(!(J.isUndefined(s)||null===s)&&n.call(e,s,J.isString(r)?r.trim():r,i,l))&&t(s,i?i.concat(r):[r])})),u.pop()}}(t),e};function it(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function nt(t,e){this._pairs=[],t&&st(t,this,e)}const rt=nt.prototype;rt.append=function(t,e){this._pairs.push([t,e])},rt.toString=function(t){const e=t?function(e){return t.call(this,e,it)}:it;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const ot=nt;function at(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ct(t,e,s){if(!e)return t;const i=s&&s.encode||at,n=s&&s.serialize;let r;if(r=n?n(e,s):J.isURLSearchParams(e)?e.toString():new ot(e,s).toString(i),r){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t}const ht=class{constructor(){this.handlers=[]}use(t,e,s){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!s&&s.synchronous,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){J.forEach(this.handlers,(function(e){null!==e&&t(e)}))}},ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},lt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ot,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},dt="undefined"!=typeof window&&"undefined"!=typeof document,ft=(pt="undefined"!=typeof navigator&&navigator.product,dt&&["ReactNative","NativeScript","NS"].indexOf(pt)<0);var pt;const gt="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,mt=dt&&window.location.href||"http://localhost",yt={...s,...lt},bt=function(t){function e(t,s,i,n){let r=t[n++];if("__proto__"===r)return!0;const o=Number.isFinite(+r),a=n>=t.length;return r=!r&&J.isArray(i)?i.length:r,a?(J.hasOwnProp(i,r)?i[r]=[i[r],s]:i[r]=s,!o):(i[r]&&J.isObject(i[r])||(i[r]=[]),e(t,s,i[r],n)&&J.isArray(i[r])&&(i[r]=function(t){const e={},s=Object.keys(t);let i;const n=s.length;let r;for(i=0;i<n;i++)r=s[i],e[r]=t[r];return e}(i[r])),!o)}if(J.isFormData(t)&&J.isFunction(t.entries)){const s={};return J.forEachEntry(t,((t,i)=>{e(function(t){return J.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),i,s,0)})),s}return null},vt={transitional:ut,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const s=e.getContentType()||"",i=s.indexOf("application/json")>-1,n=J.isObject(t);if(n&&J.isHTMLForm(t)&&(t=new FormData(t)),J.isFormData(t))return i?JSON.stringify(bt(t)):t;if(J.isArrayBuffer(t)||J.isBuffer(t)||J.isStream(t)||J.isFile(t)||J.isBlob(t)||J.isReadableStream(t))return t;if(J.isArrayBufferView(t))return t.buffer;if(J.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let r;if(n){if(s.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return st(t,new yt.classes.URLSearchParams,Object.assign({visitor:function(t,e,s,i){return yt.isNode&&J.isBuffer(t)?(this.append(e,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((r=J.isFileList(t))||s.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return st(r?{"files[]":t}:t,e&&new e,this.formSerializer)}}return n||i?(e.setContentType("application/json",!1),function(t,e,s){if(J.isString(t))try{return(0,JSON.parse)(t),J.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||vt.transitional,s=e&&e.forcedJSONParsing,i="json"===this.responseType;if(J.isResponse(t)||J.isReadableStream(t))return t;if(t&&J.isString(t)&&(s&&!this.responseType||i)){const s=!(e&&e.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(t){if(s){if("SyntaxError"===t.name)throw X.from(t,X.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:yt.classes.FormData,Blob:yt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],(t=>{vt.headers[t]={}}));const wt=vt,St=J.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),kt=Symbol("internals");function Et(t){return t&&String(t).trim().toLowerCase()}function _t(t){return!1===t||null==t?t:J.isArray(t)?t.map(_t):String(t)}function Ot(t,e,s,i,n){return J.isFunction(i)?i.call(this,e,s):(n&&(e=s),J.isString(e)?J.isString(i)?-1!==e.indexOf(i):J.isRegExp(i)?i.test(e):void 0:void 0)}class Tt{constructor(t){t&&this.set(t)}set(t,e,s){const i=this;function n(t,e,s){const n=Et(e);if(!n)throw new Error("header name must be a non-empty string");const r=J.findKey(i,n);(!r||void 0===i[r]||!0===s||void 0===s&&!1!==i[r])&&(i[r||e]=_t(t))}const r=(t,e)=>J.forEach(t,((t,s)=>n(t,s,e)));if(J.isPlainObject(t)||t instanceof this.constructor)r(t,e);else if(J.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))r((t=>{const e={};let s,i,n;return t&&t.split("\n").forEach((function(t){n=t.indexOf(":"),s=t.substring(0,n).trim().toLowerCase(),i=t.substring(n+1).trim(),!s||e[s]&&St[s]||("set-cookie"===s?e[s]?e[s].push(i):e[s]=[i]:e[s]=e[s]?e[s]+", "+i:i)})),e})(t),e);else if(J.isHeaders(t))for(const[e,i]of t.entries())n(i,e,s);else null!=t&&n(e,t,s);return this}get(t,e){if(t=Et(t)){const s=J.findKey(this,t);if(s){const t=this[s];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=s.exec(t);)e[i[1]]=i[2];return e}(t);if(J.isFunction(e))return e.call(this,t,s);if(J.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Et(t)){const s=J.findKey(this,t);return!(!s||void 0===this[s]||e&&!Ot(0,this[s],s,e))}return!1}delete(t,e){const s=this;let i=!1;function n(t){if(t=Et(t)){const n=J.findKey(s,t);!n||e&&!Ot(0,s[n],n,e)||(delete s[n],i=!0)}}return J.isArray(t)?t.forEach(n):n(t),i}clear(t){const e=Object.keys(this);let s=e.length,i=!1;for(;s--;){const n=e[s];t&&!Ot(0,this[n],n,t,!0)||(delete this[n],i=!0)}return i}normalize(t){const e=this,s={};return J.forEach(this,((i,n)=>{const r=J.findKey(s,n);if(r)return e[r]=_t(i),void delete e[n];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,s)=>e.toUpperCase()+s))}(n):String(n).trim();o!==n&&delete e[n],e[o]=_t(i),s[o]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return J.forEach(this,((s,i)=>{null!=s&&!1!==s&&(e[i]=t&&J.isArray(s)?s.join(", "):s)})),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const s=new this(t);return e.forEach((t=>s.set(t))),s}static accessor(t){const e=(this[kt]=this[kt]={accessors:{}}).accessors,s=this.prototype;function i(t){const i=Et(t);e[i]||(function(t,e){const s=J.toCamelCase(" "+e);["get","set","has"].forEach((i=>{Object.defineProperty(t,i+s,{value:function(t,s,n){return this[i].call(this,e,t,s,n)},configurable:!0})}))}(s,t),e[i]=!0)}return J.isArray(t)?t.forEach(i):i(t),this}}Tt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),J.reduceDescriptors(Tt.prototype,(({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[s]=t}}})),J.freezeMethods(Tt);const xt=Tt;function At(t,e){const s=this||wt,i=e||s,n=xt.from(i.headers);let r=i.data;return J.forEach(t,(function(t){r=t.call(s,r,n.normalize(),e?e.status:void 0)})),n.normalize(),r}function Rt(t){return!(!t||!t.__CANCEL__)}function Lt(t,e,s){X.call(this,null==t?"canceled":t,X.ERR_CANCELED,e,s),this.name="CanceledError"}J.inherits(Lt,X,{__CANCEL__:!0});const Ct=Lt;function jt(t,e,s){const i=s.config.validateStatus;s.status&&i&&!i(s.status)?e(new X("Request failed with status code "+s.status,[X.ERR_BAD_REQUEST,X.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):t(s)}const Bt=(t,e,s=3)=>{let i=0;const n=function(t,e){t=t||10;const s=new Array(t),i=new Array(t);let n,r=0,o=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),h=i[o];n||(n=c),s[r]=a,i[r]=c;let u=o,l=0;for(;u!==r;)l+=s[u++],u%=t;if(r=(r+1)%t,r===o&&(o=(o+1)%t),c-n<e)return;const d=h&&c-h;return d?Math.round(1e3*l/d):void 0}}(50,250);return function(t,e){let s,i,n=0,r=1e3/e;const o=(e,r=Date.now())=>{n=r,s=null,i&&(clearTimeout(i),i=null),t.apply(null,e)};return[(...t)=>{const e=Date.now(),a=e-n;a>=r?o(t,e):(s=t,i||(i=setTimeout((()=>{i=null,o(s)}),r-a)))},()=>s&&o(s)]}((s=>{const r=s.loaded,o=s.lengthComputable?s.total:void 0,a=r-i,c=n(a);i=r,t({loaded:r,total:o,progress:o?r/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&r<=o?(o-r)/c:void 0,event:s,lengthComputable:null!=o,[e?"download":"upload"]:!0})}),s)},Pt=(t,e)=>{const s=null!=t;return[i=>e[0]({lengthComputable:s,total:t,loaded:i}),e[1]]},Dt=t=>(...e)=>J.asap((()=>t(...e))),Ft=yt.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let s;function i(s){let i=s;return t&&(e.setAttribute("href",i),i=e.href),e.setAttribute("href",i),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname}}return s=i(window.location.href),function(t){const e=J.isString(t)?i(t):t;return e.protocol===s.protocol&&e.host===s.host}}():function(){return!0},Nt=yt.hasStandardBrowserEnv?{write(t,e,s,i,n,r){const o=[t+"="+encodeURIComponent(e)];J.isNumber(s)&&o.push("expires="+new Date(s).toGMTString()),J.isString(i)&&o.push("path="+i),J.isString(n)&&o.push("domain="+n),!0===r&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Mt(t,e){return t&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const zt=t=>t instanceof xt?{...t}:t;function It(t,e){e=e||{};const s={};function i(t,e,s){return J.isPlainObject(t)&&J.isPlainObject(e)?J.merge.call({caseless:s},t,e):J.isPlainObject(e)?J.merge({},e):J.isArray(e)?e.slice():e}function n(t,e,s){return J.isUndefined(e)?J.isUndefined(t)?void 0:i(void 0,t,s):i(t,e,s)}function r(t,e){if(!J.isUndefined(e))return i(void 0,e)}function o(t,e){return J.isUndefined(e)?J.isUndefined(t)?void 0:i(void 0,t):i(void 0,e)}function a(s,n,r){return r in e?i(s,n):r in t?i(void 0,s):void 0}const c={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(t,e)=>n(zt(t),zt(e),!0)};return J.forEach(Object.keys(Object.assign({},t,e)),(function(i){const r=c[i]||n,o=r(t[i],e[i],i);J.isUndefined(o)&&r!==a||(s[i]=o)})),s}const Ut=t=>{const e=It({},t);let s,{data:i,withXSRFToken:n,xsrfHeaderName:r,xsrfCookieName:o,headers:a,auth:c}=e;if(e.headers=a=xt.from(a),e.url=ct(Mt(e.baseURL,e.url),t.params,t.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),J.isFormData(i))if(yt.hasStandardBrowserEnv||yt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(s=a.getContentType())){const[t,...e]=s?s.split(";").map((t=>t.trim())).filter(Boolean):[];a.setContentType([t||"multipart/form-data",...e].join("; "))}if(yt.hasStandardBrowserEnv&&(n&&J.isFunction(n)&&(n=n(e)),n||!1!==n&&Ft(e.url))){const t=r&&o&&Nt.read(o);t&&a.set(r,t)}return e},qt="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,s){const i=Ut(t);let n=i.data;const r=xt.from(i.headers).normalize();let o,a,c,h,u,{responseType:l,onUploadProgress:d,onDownloadProgress:f}=i;function p(){h&&h(),u&&u(),i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}let g=new XMLHttpRequest;function m(){if(!g)return;const i=xt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());jt((function(t){e(t),p()}),(function(t){s(t),p()}),{data:l&&"text"!==l&&"json"!==l?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:i,config:t,request:g}),g=null}g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(s(new X("Request aborted",X.ECONNABORTED,t,g)),g=null)},g.onerror=function(){s(new X("Network Error",X.ERR_NETWORK,t,g)),g=null},g.ontimeout=function(){let e=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const n=i.transitional||ut;i.timeoutErrorMessage&&(e=i.timeoutErrorMessage),s(new X(e,n.clarifyTimeoutError?X.ETIMEDOUT:X.ECONNABORTED,t,g)),g=null},void 0===n&&r.setContentType(null),"setRequestHeader"in g&&J.forEach(r.toJSON(),(function(t,e){g.setRequestHeader(e,t)})),J.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),l&&"json"!==l&&(g.responseType=i.responseType),f&&([c,u]=Bt(f,!0),g.addEventListener("progress",c)),d&&g.upload&&([a,h]=Bt(d),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",h)),(i.cancelToken||i.signal)&&(o=e=>{g&&(s(!e||e.type?new Ct(null,t,g):e),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));const y=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(i.url);y&&-1===yt.protocols.indexOf(y)?s(new X("Unsupported protocol "+y+":",X.ERR_BAD_REQUEST,t)):g.send(n||null)}))},Vt=(t,e)=>{let s,i=new AbortController;const n=function(t){if(!s){s=!0,o();const e=t instanceof Error?t:this.reason;i.abort(e instanceof X?e:new Ct(e instanceof Error?e.message:e))}};let r=e&&setTimeout((()=>{n(new X(`timeout ${e} of ms exceeded`,X.ETIMEDOUT))}),e);const o=()=>{t&&(r&&clearTimeout(r),r=null,t.forEach((t=>{t&&(t.removeEventListener?t.removeEventListener("abort",n):t.unsubscribe(n))})),t=null)};t.forEach((t=>t&&t.addEventListener&&t.addEventListener("abort",n)));const{signal:a}=i;return a.unsubscribe=o,[a,()=>{r&&clearTimeout(r),r=null}]},Wt=function*(t,e){let s=t.byteLength;if(!e||s<e)return void(yield t);let i,n=0;for(;n<s;)i=n+e,yield t.slice(n,i),n=i},Ht=(t,e,s,i,n)=>{const r=async function*(t,e,s){for await(const i of t)yield*Wt(ArrayBuffer.isView(i)?i:await s(String(i)),e)}(t,e,n);let o,a=0,c=t=>{o||(o=!0,i&&i(t))};return new ReadableStream({async pull(t){try{const{done:e,value:i}=await r.next();if(e)return c(),void t.close();let n=i.byteLength;if(s){let t=a+=n;s(t)}t.enqueue(new Uint8Array(i))}catch(t){throw c(t),t}},cancel:t=>(c(t),r.return())},{highWaterMark:2})},$t="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Jt=$t&&"function"==typeof ReadableStream,Gt=$t&&("function"==typeof TextEncoder?(Kt=new TextEncoder,t=>Kt.encode(t)):async t=>new Uint8Array(await new Response(t).arrayBuffer()));var Kt;const Yt=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},Xt=Jt&&Yt((()=>{let t=!1;const e=new Request(yt.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})),Qt=Jt&&Yt((()=>J.isReadableStream(new Response("").body))),Zt={stream:Qt&&(t=>t.body)};var te;$t&&(te=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!Zt[t]&&(Zt[t]=J.isFunction(te[t])?e=>e[t]():(e,s)=>{throw new X(`Response type '${t}' is not supported`,X.ERR_NOT_SUPPORT,s)})})));const ee=$t&&(async t=>{let{url:e,method:s,data:i,signal:n,cancelToken:r,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:h,headers:u,withCredentials:l="same-origin",fetchOptions:d}=Ut(t);h=h?(h+"").toLowerCase():"text";let f,p,[g,m]=n||r||o?Vt([n,r],o):[];const y=()=>{!f&&setTimeout((()=>{g&&g.unsubscribe()})),f=!0};let b;try{if(c&&Xt&&"get"!==s&&"head"!==s&&0!==(b=await(async(t,e)=>{const s=J.toFiniteNumber(t.getContentLength());return null==s?(async t=>null==t?0:J.isBlob(t)?t.size:J.isSpecCompliantForm(t)?(await new Request(t).arrayBuffer()).byteLength:J.isArrayBufferView(t)||J.isArrayBuffer(t)?t.byteLength:(J.isURLSearchParams(t)&&(t+=""),J.isString(t)?(await Gt(t)).byteLength:void 0))(e):s})(u,i))){let t,s=new Request(e,{method:"POST",body:i,duplex:"half"});if(J.isFormData(i)&&(t=s.headers.get("content-type"))&&u.setContentType(t),s.body){const[t,e]=Pt(b,Bt(Dt(c)));i=Ht(s.body,65536,t,e,Gt)}}J.isString(l)||(l=l?"include":"omit"),p=new Request(e,{...d,signal:g,method:s.toUpperCase(),headers:u.normalize().toJSON(),body:i,duplex:"half",credentials:l});let n=await fetch(p);const r=Qt&&("stream"===h||"response"===h);if(Qt&&(a||r)){const t={};["status","statusText","headers"].forEach((e=>{t[e]=n[e]}));const e=J.toFiniteNumber(n.headers.get("content-length")),[s,i]=a&&Pt(e,Bt(Dt(a),!0))||[];n=new Response(Ht(n.body,65536,s,(()=>{i&&i(),r&&y()}),Gt),t)}h=h||"text";let o=await Zt[J.findKey(Zt,h)||"text"](n,t);return!r&&y(),m&&m(),await new Promise(((e,s)=>{jt(e,s,{data:o,headers:xt.from(n.headers),status:n.status,statusText:n.statusText,config:t,request:p})}))}catch(e){if(y(),e&&"TypeError"===e.name&&/fetch/i.test(e.message))throw Object.assign(new X("Network Error",X.ERR_NETWORK,t,p),{cause:e.cause||e});throw X.from(e,e&&e.code,t,p)}}),se={http:null,xhr:qt,fetch:ee};J.forEach(se,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const ie=t=>`- ${t}`,ne=t=>J.isFunction(t)||null===t||!1===t,re=t=>{t=J.isArray(t)?t:[t];const{length:e}=t;let s,i;const n={};for(let r=0;r<e;r++){let e;if(s=t[r],i=s,!ne(s)&&(i=se[(e=String(s)).toLowerCase()],void 0===i))throw new X(`Unknown adapter '${e}'`);if(i)break;n[e||"#"+r]=i}if(!i){const t=Object.entries(n).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let s=e?t.length>1?"since :\n"+t.map(ie).join("\n"):" "+ie(t[0]):"as no adapter specified";throw new X("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return i};function oe(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ct(null,t)}function ae(t){return oe(t),t.headers=xt.from(t.headers),t.data=At.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),re(t.adapter||wt.adapter)(t).then((function(e){return oe(t),e.data=At.call(t,t.transformResponse,e),e.headers=xt.from(e.headers),e}),(function(e){return Rt(e)||(oe(t),e&&e.response&&(e.response.data=At.call(t,t.transformResponse,e.response),e.response.headers=xt.from(e.response.headers))),Promise.reject(e)}))}const ce={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{ce[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}}));const he={};ce.transitional=function(t,e,s){function i(t,e){return"[Axios v1.7.4] Transitional option '"+t+"'"+e+(s?". "+s:"")}return(s,n,r)=>{if(!1===t)throw new X(i(n," has been removed"+(e?" in "+e:"")),X.ERR_DEPRECATED);return e&&!he[n]&&(he[n]=!0,console.warn(i(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(s,n,r)}};const ue={assertOptions:function(t,e,s){if("object"!=typeof t)throw new X("options must be an object",X.ERR_BAD_OPTION_VALUE);const i=Object.keys(t);let n=i.length;for(;n-- >0;){const r=i[n],o=e[r];if(o){const e=t[r],s=void 0===e||o(e,r,t);if(!0!==s)throw new X("option "+r+" must be "+s,X.ERR_BAD_OPTION_VALUE)}else if(!0!==s)throw new X("Unknown option "+r,X.ERR_BAD_OPTION)}},validators:ce},le=ue.validators;class de{constructor(t){this.defaults=t,this.interceptors={request:new ht,response:new ht}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e;Error.captureStackTrace?Error.captureStackTrace(e={}):e=new Error;const s=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?s&&!String(t.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+s):t.stack=s}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=It(this.defaults,e);const{transitional:s,paramsSerializer:i,headers:n}=e;void 0!==s&&ue.assertOptions(s,{silentJSONParsing:le.transitional(le.boolean),forcedJSONParsing:le.transitional(le.boolean),clarifyTimeoutError:le.transitional(le.boolean)},!1),null!=i&&(J.isFunction(i)?e.paramsSerializer={serialize:i}:ue.assertOptions(i,{encode:le.function,serialize:le.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&J.merge(n.common,n[e.method]);n&&J.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete n[t]})),e.headers=xt.concat(r,n);const o=[];let a=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,o.unshift(t.fulfilled,t.rejected))}));const c=[];let h;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let u,l=0;if(!a){const t=[ae.bind(this),void 0];for(t.unshift.apply(t,o),t.push.apply(t,c),u=t.length,h=Promise.resolve(e);l<u;)h=h.then(t[l++],t[l++]);return h}u=o.length;let d=e;for(l=0;l<u;){const t=o[l++],e=o[l++];try{d=t(d)}catch(t){e.call(this,t);break}}try{h=ae.call(this,d)}catch(t){return Promise.reject(t)}for(l=0,u=c.length;l<u;)h=h.then(c[l++],c[l++]);return h}getUri(t){return ct(Mt((t=It(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}J.forEach(["delete","get","head","options"],(function(t){de.prototype[t]=function(e,s){return this.request(It(s||{},{method:t,url:e,data:(s||{}).data}))}})),J.forEach(["post","put","patch"],(function(t){function e(e){return function(s,i,n){return this.request(It(n||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}de.prototype[t]=e(),de.prototype[t+"Form"]=e(!0)}));const fe=de;class pe{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise((function(t){e=t}));const s=this;this.promise.then((t=>{if(!s._listeners)return;let e=s._listeners.length;for(;e-- >0;)s._listeners[e](t);s._listeners=null})),this.promise.then=t=>{let e;const i=new Promise((t=>{s.subscribe(t),e=t})).then(t);return i.cancel=function(){s.unsubscribe(e)},i},t((function(t,i,n){s.reason||(s.reason=new Ct(t,i,n),e(s.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}static source(){let t;return{token:new pe((function(e){t=e})),cancel:t}}}const ge=pe,me={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(me).forEach((([t,e])=>{me[e]=t}));const ye=me,be=function t(e){const s=new fe(e),i=n(fe.prototype.request,s);return J.extend(i,fe.prototype,s,{allOwnKeys:!0}),J.extend(i,s,null,{allOwnKeys:!0}),i.create=function(s){return t(It(e,s))},i}(wt);be.Axios=fe,be.CanceledError=Ct,be.CancelToken=ge,be.isCancel=Rt,be.VERSION="1.7.4",be.toFormData=st,be.AxiosError=X,be.Cancel=be.CanceledError,be.all=function(t){return Promise.all(t)},be.spread=function(t){return function(e){return t.apply(null,e)}},be.isAxiosError=function(t){return J.isObject(t)&&!0===t.isAxiosError},be.mergeConfig=It,be.AxiosHeaders=xt,be.formToJSON=t=>bt(J.isHTMLForm(t)?new FormData(t):t),be.getAdapter=re,be.HttpStatusCode=ye,be.default=be;const ve=be;class we{interceptor;constructor(t){this.interceptor=ve.create({baseURL:`${t}/api`}),this.interceptor.interceptors.request.use((t=>{const e=ve.CancelToken.source();return t.cancelToken=e.token,setTimeout((()=>{e.cancel("Timeout: request took more than 15 seconds")}),15e3),t}),(t=>Promise.reject(t)))}}const Se="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,ke=new Set,Ee="object"==typeof process&&process?process:{},_e=(t,e,s,i)=>{"function"==typeof Ee.emitWarning?Ee.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let Oe=globalThis.AbortController,Te=globalThis.AbortSignal;if(void 0===Oe){Te=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},Oe=class{constructor(){e()}signal=new Te;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==Ee.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,_e("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const xe=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Ae=t=>xe(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Re:null:null;class Re extends Array{constructor(t){super(t),this.fill(0)}}class Le{heap;length;static#t=!1;static create(t){const e=Ae(t);if(!e)return[];Le.#t=!0;const s=new Le(t,e);return Le.#t=!1,s}constructor(t,e){if(!Le.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class Ce{#e;#s;#i;#n;#r;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#h;#u;#l;#d;#f;#p;#g;#m;#y;#b;#v;#w;#S;#k;#E;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#h,keyList:t.#u,valList:t.#l,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#g},free:t.#m,isBackgroundFetch:e=>t.#_(e),backgroundFetch:(e,s,i,n)=>t.#O(e,s,i,n),moveToTail:e=>t.#T(e),indexes:e=>t.#x(e),rindexes:e=>t.#A(e),isStale:e=>t.#R(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#o}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:h,noDisposeOnSet:u,noUpdateTTL:l,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:w,ignoreFetchAbort:S}=t;if(0!==e&&!xe(e))throw new TypeError("max option must be a nonnegative integer");const k=e?Ae(e):Array;if(!k)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=d,this.maxEntrySize=f||this.#s,this.sizeCalculation=p,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#o=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=g,this.#k=!!g,this.#h=new Map,this.#u=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#d=new k(e),this.#f=new k(e),this.#p=0,this.#g=0,this.#m=Le.create(e),this.#a=0,this.#c=0,"function"==typeof c&&(this.#i=c),"function"==typeof h?(this.#n=h,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#S=!!this.#i,this.#E=!!this.#n,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!l,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#s&&!xe(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!xe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=xe(i)||0===i?i:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!xe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#C()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";(t=>!ke.has(t))(t)&&(ke.add(t),_e("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,Ce))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#C(){const t=new Re(this.#e),e=new Re(this.#e);this.#w=t,this.#v=e,this.#j=(s,i,n=Se.now())=>{if(e[s]=0!==i?n:0,t[s]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#R(s)&&this.#B(this.#u[s],"expire")}),i+1);t.unref&&t.unref()}},this.#P=s=>{e[s]=0!==t[s]?Se.now():0},this.#D=(n,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;n.ttl=o,n.start=a,n.now=s||i();const c=n.now-a;n.remainingTTL=o-c}};let s=0;const i=()=>{const t=Se.now();if(this.ttlResolution>0){s=t;const e=setTimeout((()=>s=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#h.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];return o&&a?o-((s||i())-a):1/0},this.#R=n=>{const r=e[n],o=t[n];return!!o&&!!r&&(s||i())-r>o}}#P=()=>{};#D=()=>{};#j=()=>{};#R=()=>!1;#L(){const t=new Re(this.#e);this.#c=0,this.#b=t,this.#F=e=>{this.#c-=t[e],t[e]=0},this.#N=(t,e,s,i)=>{if(this.#_(e))return 0;if(!xe(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!xe(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#M=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#c>s;)this.#z(!0)}this.#c+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#c)}}#F=t=>{};#M=(t,e,s)=>{};#N=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#x({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#g;this.#I(e)&&(!t&&this.#R(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#I(e)&&(!t&&this.#R(e)||(yield e),e!==this.#g);)e=this.#d[e]}#I(t){return void 0!==t&&this.#h.get(this.#u[t])===t}*entries(){for(const t of this.#x())void 0===this.#l[t]||void 0===this.#u[t]||this.#_(this.#l[t])||(yield[this.#u[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#u[t]||this.#_(this.#l[t])||(yield[this.#u[t],this.#l[t]])}*keys(){for(const t of this.#x()){const e=this.#u[t];void 0===e||this.#_(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#u[t];void 0===e||this.#_(this.#l[t])||(yield e)}}*values(){for(const t of this.#x())void 0===this.#l[t]||this.#_(this.#l[t])||(yield this.#l[t])}*rvalues(){for(const t of this.#A())void 0===this.#l[t]||this.#_(this.#l[t])||(yield this.#l[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#x()){const i=this.#l[s],n=this.#_(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#u[s],this))return this.get(this.#u[s],e)}}forEach(t,e=this){for(const s of this.#x()){const i=this.#l[s],n=this.#_(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#u[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const i=this.#l[s],n=this.#_(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#u[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#R(e)&&(this.#B(this.#u[e],"expire"),t=!0);return t}info(t){const e=this.#h.get(t);if(void 0===e)return;const s=this.#l[e],i=this.#_(s)?s.__staleWhileFetching:s;if(void 0===i)return;const n={value:i};if(this.#w&&this.#v){const t=this.#w[e],s=this.#v[e];if(t&&s){const e=t-(Se.now()-s);n.ttl=e,n.start=Date.now()}}return this.#b&&(n.size=this.#b[e]),n}dump(){const t=[];for(const e of this.#x({allowStale:!0})){const s=this.#u[e],i=this.#l[e],n=this.#_(i)?i.__staleWhileFetching:i;if(void 0===n||void 0===s)continue;const r={value:n};if(this.#w&&this.#v){r.ttl=this.#w[e];const t=Se.now()-this.#v[e];r.start=Math.floor(Date.now()-t)}this.#b&&(r.size=this.#b[e]),t.unshift([s,r])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=Se.now()-t}this.set(e,s.value,s)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#N(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#B(t,"set"),this;let u=0===this.#a?void 0:this.#h.get(t);if(void 0===u)u=0===this.#a?this.#g:0!==this.#m.length?this.#m.pop():this.#a===this.#e?this.#z(!1):this.#a,this.#u[u]=t,this.#l[u]=e,this.#h.set(t,u),this.#d[this.#g]=u,this.#f[u]=this.#g,this.#g=u,this.#a++,this.#M(u,h,a),a&&(a.set="add"),c=!1;else{this.#T(u);const s=this.#l[u];if(e!==s){if(this.#k&&this.#_(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#S&&this.#i?.(e,t,"set"),this.#E&&this.#y?.push([e,t,"set"]))}else r||(this.#S&&this.#i?.(s,t,"set"),this.#E&&this.#y?.push([s,t,"set"]));if(this.#F(u),this.#M(u,h,a),this.#l[u]=e,a){a.set="replace";const t=s&&this.#_(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#C(),this.#w&&(c||this.#j(u,i,n),a&&this.#D(a,u)),!r&&this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#l[this.#p];if(this.#z(!0),this.#_(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#z(t){const e=this.#p,s=this.#u[e],i=this.#l[e];return this.#k&&this.#_(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#E)&&(this.#S&&this.#i?.(i,s,"evict"),this.#E&&this.#y?.push([i,s,"evict"])),this.#F(e),t&&(this.#u[e]=void 0,this.#l[e]=void 0,this.#m.push(e)),1===this.#a?(this.#p=this.#g=0,this.#m.length=0):this.#p=this.#d[e],this.#h.delete(s),this.#a--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#h.get(t);if(void 0!==n){const t=this.#l[n];if(this.#_(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#R(n))return s&&this.#P(n),i&&(i.has="hit",this.#D(i,n)),!0;i&&(i.has="stale",this.#D(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#h.get(t);if(void 0===i||!s&&this.#R(i))return;const n=this.#l[i];return this.#_(n)?n.__staleWhileFetching:n}#O(t,e,s,i){const n=void 0===e?void 0:this.#l[e];if(this.#_(n))return n;const r=new Oe,{signal:o}=s;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:s,context:i},c=(i,n=!1)=>{const{aborted:o}=r.signal,c=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,c&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!c&&!n)return h(r.signal.reason);const l=u;return this.#l[e]===u&&(void 0===i?l.__staleWhileFetching?this.#l[e]=l.__staleWhileFetching:this.#B(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,a.options))),i},h=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u&&(c&&void 0!==h.__staleWhileFetching?o||(this.#l[e]=h.__staleWhileFetching):this.#B(t,"fetch")),a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#r?.(t,n,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),h(t)))),l=Object.assign(u,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,l,{...a.options,status:void 0}),e=this.#h.get(t)):this.#l[e]=l,l}#_(t){if(!this.#k)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Oe}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:g=!1,status:m,signal:y}=e;if(!this.#k)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:m});const b={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:m,signal:y};let v=this.#h.get(t);if(void 0===v){m&&(m.fetch="miss");const e=this.#O(t,v,b,p);return e.__returned=e}{const e=this.#l[v];if(this.#_(e)){const t=s&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#R(v);if(!g&&!n)return m&&(m.fetch="hit"),this.#T(v),i&&this.#P(v),m&&this.#D(m,v),e;const r=this.#O(t,v,b,p),o=void 0!==r.__staleWhileFetching&&s;return m&&(m.fetch=n?"stale":"refresh",o&&n&&(m.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}async forceFetch(t,e={}){const s=await this.fetch(t,e);if(void 0===s)throw new Error("fetch() returned undefined");return s}memo(t,e={}){const s=this.#o;if(!s)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:n,...r}=e,o=this.get(t,r);if(!n&&void 0!==o)return o;const a=s(t,o,{options:r,context:i});return this.set(t,a,r),a}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#l[o],a=this.#_(e);return r&&this.#D(r,o),this.#R(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.#B(t,"expire"),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#T(o),i&&this.#P(o),e))}r&&(r.get="miss")}#U(t,e){this.#f[e]=t,this.#d[t]=e}#T(t){t!==this.#g&&(t===this.#p?this.#p=this.#d[t]:this.#U(this.#f[t],this.#d[t]),this.#U(this.#g,t),this.#g=t)}delete(t){return this.#B(t,"delete")}#B(t,e){let s=!1;if(0!==this.#a){const i=this.#h.get(t);if(void 0!==i)if(s=!0,1===this.#a)this.#q(e);else{this.#F(i);const s=this.#l[i];if(this.#_(s)?s.__abortController.abort(new Error("deleted")):(this.#S||this.#E)&&(this.#S&&this.#i?.(s,t,e),this.#E&&this.#y?.push([s,t,e])),this.#h.delete(t),this.#u[i]=void 0,this.#l[i]=void 0,i===this.#g)this.#g=this.#f[i];else if(i===this.#p)this.#p=this.#d[i];else{const t=this.#f[i];this.#d[t]=this.#d[i];const e=this.#d[i];this.#f[e]=this.#f[i]}this.#a--,this.#m.push(i)}}if(this.#E&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return s}clear(){return this.#q("delete")}#q(t){for(const e of this.#A({allowStale:!0})){const s=this.#l[e];if(this.#_(s))s.__abortController.abort(new Error("deleted"));else{const i=this.#u[e];this.#S&&this.#i?.(s,i,t),this.#E&&this.#y?.push([s,i,t])}}if(this.#h.clear(),this.#l.fill(void 0),this.#u.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#g=0,this.#m.length=0,this.#c=0,this.#a=0,this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}var je=function(t,e){return je=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])},je(t,e)};function Be(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}je(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}function Pe(t,e){var s,i,n,r,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(c){return function(a){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(o=0)),o;)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 o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}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 De(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 Fe(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 Ne(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 Me(t){return this instanceof Me?(this.v=t,this):new Me(t)}function ze(t){return"function"==typeof t}function Ie(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 Ue=Ie((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 qe(t,e){if(t){var s=t.indexOf(e);0<=s&&t.splice(s,1)}}var Ve=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=De(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(ze(c))try{c()}catch(t){n=t instanceof Ue?t.errors:[t]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var u=De(h),l=u.next();!l.done;l=u.next()){var d=l.value;try{$e(d)}catch(t){n=null!=n?n:[],t instanceof Ue?n=Ne(Ne([],Fe(n)),Fe(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 Ue(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)&&qe(e,t)},t.prototype.remove=function(e){var s=this._finalizers;s&&qe(s,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),We=Ve.EMPTY;function He(t){return t instanceof Ve||t&&"closed"in t&&ze(t.remove)&&ze(t.add)&&ze(t.unsubscribe)}function $e(t){ze(t)?t():t.unsubscribe()}var Je={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ge={setTimeout:function(t,e){for(var s=[],i=2;i<arguments.length;i++)s[i-2]=arguments[i];var n=Ge.delegate;return(null==n?void 0:n.setTimeout)?n.setTimeout.apply(n,Ne([t,e],Fe(s))):setTimeout.apply(void 0,Ne([t,e],Fe(s)))},clearTimeout:function(t){var e=Ge.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Ke(t){Ge.setTimeout((function(){var e=Je.onUnhandledError;if(!e)throw t;e(t)}))}function Ye(){}var Xe=Qe("C",void 0,void 0);function Qe(t,e,s){return{kind:t,value:e,error:s}}var Ze=null;function ts(t){if(Je.useDeprecatedSynchronousErrorHandling){var e=!Ze;if(e&&(Ze={errorThrown:!1,error:null}),t(),e){var s=Ze,i=s.errorThrown,n=s.error;if(Ze=null,i)throw n}}else t()}var es=function(t){function e(e){var s=t.call(this)||this;return s.isStopped=!1,e?(s.destination=e,He(e)&&e.add(s)):s.destination=cs,s}return Be(e,t),e.create=function(t,e,s){return new rs(t,e,s)},e.prototype.next=function(t){this.isStopped?as(function(t){return Qe("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?as(Qe("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?as(Xe,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}(Ve),ss=Function.prototype.bind;function is(t,e){return ss.call(t,e)}var ns=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){os(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){os(t)}else os(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){os(t)}},t}(),rs=function(t){function e(e,s,i){var n,r,o=t.call(this)||this;return ze(e)||!e?n={next:null!=e?e:void 0,error:null!=s?s:void 0,complete:null!=i?i:void 0}:o&&Je.useDeprecatedNextContext?((r=Object.create(e)).unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&is(e.next,r),error:e.error&&is(e.error,r),complete:e.complete&&is(e.complete,r)}):n=e,o.destination=new ns(n),o}return Be(e,t),e}(es);function os(t){var e;Je.useDeprecatedSynchronousErrorHandling?(e=t,Je.useDeprecatedSynchronousErrorHandling&&Ze&&(Ze.errorThrown=!0,Ze.error=e)):Ke(t)}function as(t,e){var s=Je.onStoppedNotification;s&&Ge.setTimeout((function(){return s(t,e)}))}var cs={closed:!0,next:Ye,error:function(t){throw t},complete:Ye},hs="function"==typeof Symbol&&Symbol.observable||"@@observable";function us(t){return t}var ls=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 es||function(t){return t&&ze(t.next)&&ze(t.error)&&ze(t.complete)}(t)&&He(t)}(t)?t:new rs(t,e,s);return ts((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=ds(e))((function(e,i){var n=new rs({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[hs]=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?us: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=ds(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 ds(t){var e;return null!==(e=null!=t?t:Je.Promise)&&void 0!==e?e:Promise}var fs=Ie((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),ps=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 Be(e,t),e.prototype.lift=function(t){var e=new gs(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new fs},e.prototype.next=function(t){var e=this;ts((function(){var s,i;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var n=De(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;ts((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;ts((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?We:(this.currentObservers=null,r.push(t),new Ve((function(){e.currentObservers=null,qe(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 ls;return t.source=this,t},e.create=function(t,e){return new gs(t,e)},e}(ls),gs=function(t){function e(e,s){var i=t.call(this)||this;return i.destination=e,i.source=s,i}return Be(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:We},e}(ps),ms=function(t){function e(e){var s=t.call(this)||this;return s._value=e,s}return Be(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}(ps),ys={now:function(){return(ys.delegate||Date).now()},delegate:void 0},bs=function(t){function e(e,s,i){void 0===e&&(e=1/0),void 0===s&&(s=1/0),void 0===i&&(i=ys);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 Be(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}(ps);function vs(t){return function(e){if(function(t){return ze(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 ws(t,e,s,i,n){return new Ss(t,e,s,i,n)}var Ss=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 Be(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}(es);function ks(){return vs((function(t,e){var s,i=!1;t.subscribe(ws(e,(function(t){var n=s;s=t,i&&e.next([n,t]),i=!0})))}))}function Es(t,e){return vs((function(s,i){var n=0;s.subscribe(ws(i,(function(s){return t.call(e,s,n++)&&i.next(s)})))}))}function _s(t,e){return vs((function(s,i){var n=0;s.subscribe(ws(i,(function(s){i.next(t.call(e,s,n++))})))}))}var Os=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t},Ts="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function xs(t){if(t instanceof ls)return t;if(null!=t){if(function(t){return ze(t[hs])}(t))return n=t,new ls((function(t){var e=n[hs]();if(ze(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Os(t))return i=t,new ls((function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()}));if(function(t){return ze(null==t?void 0:t.then)}(t))return s=t,new ls((function(t){s.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,Ke)}));if(function(t){return Symbol.asyncIterator&&ze(null==t?void 0:t[Symbol.asyncIterator])}(t))return As(t);if(function(t){return ze(null==t?void 0:t[Ts])}(t))return e=t,new ls((function(t){var s,i;try{for(var n=De(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 ze(null==t?void 0:t.getReader)}(t))return As(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={},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 Me?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 Pe(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,Me(e.read())];case 3:return s=n.sent(),i=s.value,s.done?[4,Me(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,Me(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 As(t){return new ls((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 Pe(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=De(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 Rs(t){void 0===t&&(t={});var e=t.connector,s=void 0===e?function(){return new ps}: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},f=function(){var t=e;d(),null==t||t.unsubscribe()};return vs((function(t,p){a++,u||h||l();var g=r=null!=r?r:s();p.add((function(){0!=--a||u||h||(i=Ls(f,c))})),g.subscribe(p),!e&&a>0&&(e=new rs({next:function(t){return g.next(t)},error:function(t){u=!0,l(),i=Ls(d,n,t),g.error(t)},complete:function(){h=!0,l(),i=Ls(d,o),g.complete()}}),xs(t).subscribe(e))}))(t)}}function Ls(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 rs({next:function(){n.unsubscribe(),t()}});return xs(e.apply(void 0,Ne([],Fe(s)))).subscribe(n)}}else t()}function Cs(t,e,s){return void 0===s&&(s=1/0),ze(e)?Cs((function(s,i){return _s((function(t,n){return e(s,t,i,n)}))(xs(t(s,i)))}),s):("number"==typeof e&&(s=e),vs((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()},f=function(t){return h<i?p(t):c.push(t)},p=function(t){h++;var n=!1;xs(s(t,u++)).subscribe(ws(e,(function(t){e.next(t)}),(function(){n=!0}),void 0,(function(){if(n)try{h--;for(var t=function(){var t=c.shift();p(t)};c.length&&h<i;)t();d()}catch(t){e.error(t)}})))};return t.subscribe(ws(e,f,(function(){l=!0,d()}))),function(){}}(e,i,t,s)})))}function js(t,e){return t===e}class Bs{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()))}}const Ps=(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=>Ps(t,e,s)));return-1!==e&&(i.splice(e,1),!0)}))}{let i=!0;for(let n=0;n<t.length;n++)if(!Ps(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=Ps(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},Ds=t=>JSON.parse(JSON.stringify(t)),Fs=(t,e)=>{const{origWidth:s,origHeight:i}=e,n=t.points.map((([t,e])=>[t*s/100,e*i/100]));return{...t,points:n}},Ns=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]}},Ms=(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=Fs(s,t);if(e.isPrivacyMask){if(Is(a,e.points)){c=!1;break}}else"include"===e.filter?"contain"===e.type?Is(a,e.points)&&(c=!0):"intersect"===e.type&&(zs(a,e.points)||Is(a,e.points))&&(c=!0):"exclude"===e.filter&&("contain"===e.type?Is(a,e.points)||(c=!0):"intersect"===e.type&&(zs(a,e.points)||Is(a,e.points)||(c=!0)))}return c},zs=(t,e)=>{const s=Us(t);for(const t of s)for(let s=0;s<e.length;s++){const i=[e[s],e[(s+1)%e.length]];if(qs(t,i))return!0}return!1},Is=(t,e)=>[[t.xmin,t.ymin],[t.xmax,t.ymin],[t.xmax,t.ymax],[t.xmin,t.ymax]].every((t=>Vs(t,e))),Us=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]]]},qs=(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},Vs=(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 Ws extends Bs{logger;snapshotCache=new Ce({max:100,ttl:3e5});cameraSubject;cameraState=new ms(!1);lightState=new ms(this.getLightState({state:!1},!0));motionState=new ms(this.getMotionState({detections:[],state:!1},!0));audioState=new ms(this.getAudioState({state:!1,db:0},!0));objectState=new ms(this.getObjectState({detections:[]},!0));doorbellState=new ms(this.getDoorbellState({state:!1},!0));sirenState=new ms(this.getSirenState({state:!1,level:0},!0));batteryState=new ms(this.getBatteryState({level:100,charging:!1,lowBattery:!1},!0));prebufferStateSubjects={};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 Ds(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 Ds(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 activityZones(){return Ds(this.cameraSubject.getValue().activityZones)}get activitySettings(){return Ds(this.cameraSubject.getValue().activitySettings)}get frameWorkerSettings(){return Ds(this.cameraSubject.getValue().frameWorkerSettings)}get streamSource(){return this.highResolutionSource||this.midResolutionSource||this.lowResolutionSource}get snapshotSource(){return this.sources.find((t=>t.roles.includes("snapshot")))}get highResolutionSource(){return this.sources.find((t=>t.roles.includes("high-resolution")))}get midResolutionSource(){return this.sources.find((t=>t.roles.includes("mid-resolution")))}get lowResolutionSource(){return this.sources.find((t=>t.roles.includes("low-resolution")))}get ptz(){return this.ptzDelegate}constructor(t,e){super(),this.logger=e,this.cameraSubject=new ms(t),this.updateCamera(t),"native"===t.pluginId&&this.cameraState.next(!0)}getValue(t){switch(t){case"light":return Ds(this.lightState.getValue());case"motion":return Ds(this.motionState.getValue());case"audio":return Ds(this.audioState.getValue());case"object":return Ds(this.objectState.getValue());case"doorbell":return Ds(this.doorbellState.getValue());case"siren":return Ds(this.sirenState.getValue());case"battery":return Ds(this.batteryState.getValue());default:throw new Error(`Unknown state: ${t}`)}}async snapshot(t){const e=this.snapshotSource||this.streamSource,s=e.urls.www.jpegSnapshot,i=this.snapshotCache.get(e._id);if(!t&&i)return i;if(!e.roles.includes("snapshot")&&"native"!==this.cameraObject.pluginId){const t=await this.cameraDelegate.snapshot();return t&&t.byteLength>0&&this.snapshotCache.set(e._id,t),t}const n=await fetch(s);if(!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}onStateChange(t){return this[`${t}State`].pipe(ks(),Es((([e,s])=>"boolean"==typeof e||"boolean"==typeof s?e!==s:this.stateChanged(e,s,t))),_s((([t,e])=>({oldState:t,newState:e}))),Rs({connector:()=>new bs(1)}))}onPropertyChange(t){return this.cameraSubject.pipe(ks(),Cs((([e,s])=>(Array.isArray(t)?t:[t]).map((t=>({property:t,oldData:e[t],newData:s[t]}))))),Es((({oldData:t,newData:e})=>!Ps(t,e,!0))),Rs({connector:()=>new bs(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){this.cameraSubject.next(t);const e=this.cameraSubject.getValue().sources;for(const t in this.prebufferStateSubjects)if(!e.some((e=>e._id===t))){for(const e in this.prebufferStateSubjects[t])this.prebufferStateSubjects[t][e].complete();delete this.prebufferStateSubjects[t]}for(const t of e)this.prebufferStateSubjects[t._id]||(this.prebufferStateSubjects[t._id]={mp4:new ms({state:!1,duration:0}),mpegts:new ms({state:!1,duration:0})})}updateCameraState(t){this.cameraState.next(t)}updatePrebuffer(t,e,s){this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&this.prebufferStateSubjects[t][e].next({state:s.state,url:s.url||void 0,duration:s.duration})}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,s)=>{const i=[];for(const n of t)Ms(Ns(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)Ms(Ns(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}}cameraSourcePrebufferState(t,e){let s={state:!1,duration:0};return this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&(s=this.prebufferStateSubjects[t][e].getValue()),s}createPrebufferStateObservable(t,e){return this.prebufferStateSubjects[t][e].pipe((void 0===i&&(i=us),s=null!=(s=(t,e)=>t.state===e.state&&t.url===e.url)?s:js,vs((function(t,e){var n,r=!0;t.subscribe(ws(e,(function(t){var o=i(t);!r&&s(n,o)||(r=!1,n=o,e.next(t))})))}))),Rs({connector:()=>new bs(1)}));var s,i}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:!Ps(s.detections,i.detections,!0)}if("object"==s){if(!this.hasObjectDetector)return!1;const s=e;return!Ps(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(Rs({connector:()=>new bs(1)}))}}class Hs{}class $s{}class Js{}class Gs extends Hs{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async snapshot(){return this.delegate?this.delegate.snapshot():this._onRequest("snapshot")}_onRequest(t,e,s){return this.onRequest("cameraDelegate",t,e,s)}}class Ks extends $s{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async getStreamInfo(t){return this.delegate?this.delegate.getStreamInfo(t):this._onRequest("prebufferDelegate","getStreamInfo",[t])}async updatePrebufferState(t,e,s){return this._onRequest("cameraFn","updatePrebufferState",[t,e,s],0)}_onRequest(t,e,s,i){return this.onRequest(t,e,s,i)}}class Ys extends Js{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}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)}}class Xs extends EventTarget{cameraDevice;socketService;logger;options;videoPlayer;socket;streamId;hasBackchannel=!1;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;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=this.uuidv4(),this.createCodecsList()}connect(t){t&&(this.options.mode=t),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(){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){this.dispatchEvent(new Event("reconnect")),this.close(),await new Promise((t=>setTimeout(t,100))),this.connect(t)}reset(){this._finishLoading=!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=""}close(){this.closed=!0,this.reset(),this.disconnect(),this.socket.emit("end"),this.socket.removeAllListeners()}onWsOpen({id:t}){if(t===this.streamId)switch(this.options.mode){case"webrtc":case"webrtc/tcp":this.requestWebrtc();break;case"mse":this.requestMse();break;case"hls":this.requestHls();break;case"mp4":this.requestMp4();break;case"mjpeg":this.requestMjpeg();break;default: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}))}}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("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.finishLoading(),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))}));const t=await this.createOffer();t&&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":await(this.pc?.setRemoteDescription({type:"answer",sdp:t.value}));break;case"error":if(t.value.indexOf("webrtc/offer")<0)return;this.pc?.close()}}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:t,message:t.message}))}}async createOffer(){if(this.pc){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();return await this.pc.setLocalDescription(t),t}}requestMse(){if(this.reset(),"ManagedMediaSource"in window){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 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.finishLoading(),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.finishLoading()}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();this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mp4",value:s}})}onMp4Buffer(t){this.finishLoading(),this.videoPlayerMp4&&(this.videoPlayerMp4.src="data:video/mp4;base64,"+this.btoaBinary(t.value))}requestHls(){this.reset(),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"hls",value:this.parseCodecs((t=>this.videoPlayer.canPlayType(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.finishLoading(),this.play()}onStreamInfo(t){const e=t.value;e?.producers?.length&&(this.hasBackchannel=e.producers.some((t=>t.senders?.length)))}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)}}finishLoading(){this._finishLoading||(this._finishLoading=!0,this.dispatchEvent(new Event("finishLoading")))}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)}uuidv4(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}}class Qs extends Ws{socketService;socket;pluginName="@camera.ui/client";subject;_started=!1;get started(){return this._started}cameraDelegate=new Gs(this.onRequest.bind(this),this.logger);ptzDelegate=new Ys(this.onRequest.bind(this),this.logger);prebufferDelegate=new Ks(this.onRequest.bind(this),this.logger);get sources(){return JSON.parse(JSON.stringify(this.cameraSubject.getValue().sources)).map((t=>({...t,updatePrebufferingState:async()=>{throw new Error("Not available in client")},getPrebufferingState:e=>super.cameraSourcePrebufferState(t._id,e),onPrebuffering:e=>super.createPrebufferStateObservable(t._id,e),getStreamInfo:async()=>this.prebufferDelegate.getStreamInfo(t.name)})))}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")}getIceServers(){return this.onRequest("cameraFn","getIceServers")}createSession(t){return new Xs(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);for(const[e,s]of Object.entries(t.prebufferStates))super.updatePrebuffer(e,"mp4",s.mp4),super.updatePrebuffer(e,"mpegts",s.mpegts)}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);break;case"prebufferState":super.updatePrebuffer(t.data.sourceId,t.data.container,t.data.state)}}))}onRequest(t,e,s=[]){const i={requestId:crypto.randomUUID(),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 Zs{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 Qs(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 Qs(e,this.socketService,this.logger);return await t.refreshStates(),t}}onRequest(t,e){const s={requestId:crypto.randomUUID(),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 ti=Object.create(null);ti.open="0",ti.close="1",ti.ping="2",ti.pong="3",ti.message="4",ti.upgrade="5",ti.noop="6";const ei=Object.create(null);Object.keys(ti).forEach((t=>{ei[ti[t]]=t}));const si={type:"error",data:"parser error"},ii="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),ni="function"==typeof ArrayBuffer,ri=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,oi=({type:t,data:e},s,i)=>ii&&e instanceof Blob?s?i(e):ai(e,i):ni&&(e instanceof ArrayBuffer||ri(e))?s?i(e):ai(new Blob([e]),i):i(ti[t]+(e||"")),ai=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function ci(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let hi;const ui="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)ui["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const li="function"==typeof ArrayBuffer,di=(t,e)=>{if("string"!=typeof t)return{type:"message",data:pi(t,e)};const s=t.charAt(0);return"b"===s?{type:"message",data:fi(t.substring(1),e)}:ei[s]?t.length>1?{type:ei[s],data:t.substring(1)}:{type:ei[s]}:si},fi=(t,e)=>{if(li){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=ui[t.charCodeAt(e)],i=ui[t.charCodeAt(e+1)],n=ui[t.charCodeAt(e+2)],r=ui[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 pi(s,e)}return{base64:!0,data:t}},pi=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,gi=String.fromCharCode(30);let mi;function yi(t){return t.reduce(((t,e)=>t+e.length),0)}function bi(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 vi(t){if(t)return function(t){for(var e in vi.prototype)t[e]=vi.prototype[e];return t}(t)}vi.prototype.on=vi.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},vi.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},vi.prototype.off=vi.prototype.removeListener=vi.prototype.removeAllListeners=vi.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},vi.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},vi.prototype.emitReserved=vi.prototype.emit,vi.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},vi.prototype.hasListeners=function(t){return!!this.listeners(t).length};const wi="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Si(t,...e){return e.reduce(((e,s)=>(t.hasOwnProperty(s)&&(e[s]=t[s]),e)),{})}const ki=wi.setTimeout,Ei=wi.clearTimeout;function _i(t,e){e.useNativeTimers?(t.setTimeoutFn=ki.bind(wi),t.clearTimeoutFn=Ei.bind(wi)):(t.setTimeoutFn=wi.setTimeout.bind(wi),t.clearTimeoutFn=wi.clearTimeout.bind(wi))}class Oi extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class Ti extends vi{constructor(t){super(),this.writable=!1,_i(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,s){return super.emitReserved("error",new Oi(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=di(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:""}}const xi="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Ai=64,Ri={};let Li,Ci=0,ji=0;function Bi(t){let e="";do{e=xi[t%Ai]+e,t=Math.floor(t/Ai)}while(t>0);return e}function Pi(){const t=Bi(+new Date);return t!==Li?(Ci=0,Li=t):t+"."+Bi(Ci++)}for(;ji<Ai;ji++)Ri[xi[ji]]=ji;let Di=!1;try{Di="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const Fi=Di;function Ni(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||Fi))return new XMLHttpRequest}catch(t){}if(!e)try{return new(wi[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function Mi(){}const zi=null!=new Ni({xdomain:!1}).responseType;class Ii extends vi{constructor(t,e){super(),_i(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var t;const e=Si(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const s=this.xhr=new Ni(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)),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=Ii.requestsCount++,Ii.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=Mi,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete Ii.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 Ui(){for(let t in Ii.requests)Ii.requests.hasOwnProperty(t)&&Ii.requests[t].abort()}Ii.requestsCount=0,Ii.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Ui):"function"==typeof addEventListener&&addEventListener("onpagehide"in wi?"pagehide":"unload",Ui,!1));const qi="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Vi=wi.WebSocket||wi.MozWebSocket,Wi="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),Hi={websocket:class extends Ti{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,s=Wi?{}:Si(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=Wi?new Vi(t,e,s):e?new Vi(t,e):new Vi(t)}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;oi(s,this.supportsBinary,(t=>{try{this.ws.send(t)}catch(t){}i&&qi((()=>{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]=Pi()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!Vi}},webtransport:class extends Ti{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),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){mi||(mi=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(yi(s)<1)break;const t=bi(s,1);r=!(128&~t[0]),n=127&t[0],i=n<126?3:126===n?1:2}else if(1===i){if(yi(s)<2)break;const t=bi(s,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),i=3}else if(2===i){if(yi(s)<8)break;const t=bi(s,8),e=new DataView(t.buffer,t.byteOffset,t.length),r=e.getUint32(0);if(r>Math.pow(2,21)-1){a.enqueue(si);break}n=r*Math.pow(2,32)+e.getUint32(4),i=3}else{if(yi(s)<n)break;const t=bi(s,n);a.enqueue(di(r?t:mi.decode(t),e)),i=0}if(0===n||n>t){a.enqueue(si);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),i=new TransformStream({transform(t,e){!function(t,e){ii&&t.data instanceof Blob?t.data.arrayBuffer().then(ci).then(e):ni&&(t.data instanceof ArrayBuffer||ri(t.data))?e(ci(t.data)):oi(t,!1,(t=>{hi||(hi=new TextEncoder),e(hi.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&&qi((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends Ti{constructor(t){if(super(t),this.polling=!1,"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}const e=t&&t.forceBase64;this.supportsBinary=zi&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}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(gi),i=[];for(let t=0;t<s.length;t++){const n=di(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)=>{oi(t,!1,(t=>{i[r]=t,++n===s&&e(i.join(gi))}))}))})(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]=Pi()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ii(this.uri(),t)}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}}},$i=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ji=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Gi(t){if(t.length>2e3)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=$i.exec(t||""),r={},o=14;for(;o--;)r[Ji[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}class Ki extends vi{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=Gi(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=Gi(e.host).host),_i(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=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"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)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(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"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new Hi[t](s)}open(){let t;if(this.opts.rememberUpgrade&&Ki.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),s=!1;Ki.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;Ki.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()}onOpen(){if(this.readyState="open",Ki.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,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}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){Ki.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const i=t.length;for(;s<i;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}Ki.protocol=4,Ki.protocol;const Yi="function"==typeof ArrayBuffer,Xi=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Qi=Object.prototype.toString,Zi="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Qi.call(Blob),tn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Qi.call(File);function en(t){return Yi&&(t instanceof ArrayBuffer||Xi(t))||Zi&&t instanceof Blob||tn&&t instanceof File}function sn(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,s=t.length;e<s;e++)if(sn(t[e]))return!0;return!1}if(en(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return sn(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&sn(t[e]))return!0;return!1}function nn(t){const e=[],s=t.data,i=t;return i.data=rn(s,e),i.attachments=e.length,{packet:i,buffers:e}}function rn(t,e){if(!t)return t;if(en(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]=rn(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]=rn(t[i],e));return s}return t}function on(t,e){return t.data=an(t.data,e),delete t.attachments,t}function an(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]=an(t[s],e);else if("object"==typeof t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(t[s]=an(t[s],e));return t}const cn=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],hn=5;var un;!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"}(un||(un={}));class ln{constructor(t){this.replacer=t}encode(t){return t.type!==un.EVENT&&t.type!==un.ACK||!sn(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===un.EVENT?un.BINARY_EVENT:un.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==un.BINARY_EVENT&&t.type!==un.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=nn(t),s=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(s),i}}function dn(t){return"[object Object]"===Object.prototype.toString.call(t)}class fn extends vi{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===un.BINARY_EVENT;s||e.type===un.BINARY_ACK?(e.type=s?un.EVENT:un.ACK,this.reconstructor=new pn(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!en(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===un[s.type])throw new Error("unknown packet type "+s.type);if(s.type===un.BINARY_EVENT||s.type===un.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(!fn.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 un.CONNECT:return dn(e);case un.DISCONNECT:return void 0===e;case un.CONNECT_ERROR:return"string"==typeof e||dn(e);case un.EVENT:case un.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===cn.indexOf(e[0]));case un.ACK:case un.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class pn{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=on(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function gn(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const mn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class yn extends vi{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=[gn(t,"open",this.onopen.bind(this)),gn(t,"packet",this.onpacket.bind(this)),gn(t,"error",this.onerror.bind(this)),gn(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){if(mn.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const s={type:un.EVENT,data:e,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,i=e.pop();this._registerAckCallback(t,i),s.id=t}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),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:un.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 un.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 un.EVENT:case un.BINARY_EVENT:this.onevent(t);break;case un.ACK:case un.BINARY_ACK:this.onack(t);break;case un.DISCONNECT:this.ondisconnect();break;case un.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:un.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:un.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 bn(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}bn.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)},bn.prototype.reset=function(){this.attempts=0},bn.prototype.setMin=function(t){this.ms=t},bn.prototype.setMax=function(t){this.max=t},bn.prototype.setJitter=function(t){this.jitter=t};class vn extends vi{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,_i(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 bn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||i;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,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 Ki(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=gn(e,"open",(function(){s.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},r=gn(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(gn(t,"ping",this.onping.bind(this)),gn(t,"data",this.ondata.bind(this)),gn(t,"error",this.onerror.bind(this)),gn(t,"close",this.onclose.bind(this)),gn(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){qi((()=>{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 yn(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"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((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 wn={};function Sn(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=Gi(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=wn[n]&&r in wn[n].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?a=new vn(i,e):(wn[n]||(wn[n]=new vn(i,e)),a=wn[n]),s.query&&!e.query&&(e.query=s.queryKey),a.socket(s.path,e)}Object.assign(Sn,{Manager:vn,Socket:yn,io:Sn,connect:Sn});class kn{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.socketList.has(t)||this.socketList.set(t,this.createManager(e)),this.socketList.get(t)}createManager(t){const e=new vn(this.endpoint,{reconnection:!0,reconnectionDelay:500,rejectUnauthorized:!1,transports:["websocket"],forceNew:t}),s=e.socket("/proxy",{auth:{token:`Bearer ${this.token}`}});return{manager:e,socket:s}}}class En{api;socketService;config;logger;token;deviceManager;constructor(t){this.config=t,this.logger=t.logger||{...console,attention:console.warn},this.api=new we(t.endpoint)}async connect(){return this.deviceManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new kn(this.config.endpoint,this.token),this.deviceManager=new Zs(this.socketService,this.logger),this.checkSession()),{deviceManager:this.deviceManager}}async disconnect(){this.socketService?.close(),this.cleanUpClient(),this.config.username&&this.config.password&&await this.api.interceptor.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.interceptor.post("/auth/login",{username:this.config.username,password:this.config.password});this.token=t.data.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.interceptor.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 _n=e.j;export{_n as CameraUiClient};
1
+ var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{j:()=>On});var s={};t.r(s),t.d(s,{hasBrowserEnv:()=>dt,hasStandardBrowserEnv:()=>ft,hasStandardBrowserWebWorkerEnv:()=>gt,origin:()=>mt});var i={};function n(t,e){return function(){return t.apply(e,arguments)}}t.r(i),t.d(i,{Decoder:()=>gn,Encoder:()=>fn,PacketType:()=>dn,protocol:()=>ln});const{toString:r}=Object.prototype,{getPrototypeOf:o}=Object,a=(t=>e=>{const s=r.call(e);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),c=t=>(t=t.toLowerCase(),e=>a(e)===t),h=t=>e=>typeof e===t,{isArray:u}=Array,l=h("undefined"),d=c("ArrayBuffer"),f=h("string"),p=h("function"),g=h("number"),m=t=>null!==t&&"object"==typeof t,y=t=>{if("object"!==a(t))return!1;const e=o(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},b=c("Date"),v=c("File"),w=c("Blob"),S=c("FileList"),k=c("URLSearchParams"),[E,_,O,x]=["ReadableStream","Request","Response","Headers"].map(c);function T(t,e,{allOwnKeys:s=!1}={}){if(null==t)return;let i,n;if("object"!=typeof t&&(t=[t]),u(t))for(i=0,n=t.length;i<n;i++)e.call(null,t[i],i,t);else{const n=s?Object.getOwnPropertyNames(t):Object.keys(t),r=n.length;let o;for(i=0;i<r;i++)o=n[i],e.call(null,t[o],o,t)}}function A(t,e){e=e.toLowerCase();const s=Object.keys(t);let i,n=s.length;for(;n-- >0;)if(i=s[n],e===i.toLowerCase())return i;return null}const R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,L=t=>!l(t)&&t!==R,C=(j="undefined"!=typeof Uint8Array&&o(Uint8Array),t=>j&&t instanceof j);var j;const B=c("HTMLFormElement"),P=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype),D=c("RegExp"),F=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t),i={};T(s,((s,n)=>{let r;!1!==(r=e(s,n,t))&&(i[n]=r||s)})),Object.defineProperties(t,i)},N="abcdefghijklmnopqrstuvwxyz",M="0123456789",z={DIGIT:M,ALPHA:N,ALPHA_DIGIT:N+N.toUpperCase()+M},I=c("AsyncFunction"),q=(U="function"==typeof setImmediate,V=p(R.postMessage),U?setImmediate:V?(W=`axios@${Math.random()}`,H=[],R.addEventListener("message",(({source:t,data:e})=>{t===R&&e===W&&H.length&&H.shift()()}),!1),t=>{H.push(t),R.postMessage(W,"*")}):t=>setTimeout(t));var U,V,W,H;const $="undefined"!=typeof queueMicrotask?queueMicrotask.bind(R):"undefined"!=typeof process&&process.nextTick||q,J={isArray:u,isArrayBuffer:d,isBuffer:function(t){return null!==t&&!l(t)&&null!==t.constructor&&!l(t.constructor)&&p(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||p(t.append)&&("formdata"===(e=a(t))||"object"===e&&p(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&d(t.buffer),e},isString:f,isNumber:g,isBoolean:t=>!0===t||!1===t,isObject:m,isPlainObject:y,isReadableStream:E,isRequest:_,isResponse:O,isHeaders:x,isUndefined:l,isDate:b,isFile:v,isBlob:w,isRegExp:D,isFunction:p,isStream:t=>m(t)&&p(t.pipe),isURLSearchParams:k,isTypedArray:C,isFileList:S,forEach:T,merge:function t(){const{caseless:e}=L(this)&&this||{},s={},i=(i,n)=>{const r=e&&A(s,n)||n;y(s[r])&&y(i)?s[r]=t(s[r],i):y(i)?s[r]=t({},i):u(i)?s[r]=i.slice():s[r]=i};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&T(arguments[t],i);return s},extend:(t,e,s,{allOwnKeys:i}={})=>(T(e,((e,i)=>{s&&p(e)?t[i]=n(e,s):t[i]=e}),{allOwnKeys:i}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,s,i)=>{t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),s&&Object.assign(t.prototype,s)},toFlatObject:(t,e,s,i)=>{let n,r,a;const c={};if(e=e||{},null==t)return e;do{for(n=Object.getOwnPropertyNames(t),r=n.length;r-- >0;)a=n[r],i&&!i(a,t,e)||c[a]||(e[a]=t[a],c[a]=!0);t=!1!==s&&o(t)}while(t&&(!s||s(t,e))&&t!==Object.prototype);return e},kindOf:a,kindOfTest:c,endsWith:(t,e,s)=>{t=String(t),(void 0===s||s>t.length)&&(s=t.length),s-=e.length;const i=t.indexOf(e,s);return-1!==i&&i===s},toArray:t=>{if(!t)return null;if(u(t))return t;let e=t.length;if(!g(e))return null;const s=new Array(e);for(;e-- >0;)s[e]=t[e];return s},forEachEntry:(t,e)=>{const s=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=s.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},matchAll:(t,e)=>{let s;const i=[];for(;null!==(s=t.exec(e));)i.push(s);return i},isHTMLForm:B,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:F,freezeMethods:t=>{F(t,((e,s)=>{if(p(t)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const i=t[s];p(i)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}))}))},toObjectSet:(t,e)=>{const s={},i=t=>{t.forEach((t=>{s[t]=!0}))};return u(t)?i(t):i(String(t).split(e)),s},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,s){return e.toUpperCase()+s})),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:A,global:R,isContextDefined:L,ALPHABET:z,generateString:(t=16,e=z.ALPHA_DIGIT)=>{let s="";const{length:i}=e;for(;t--;)s+=e[Math.random()*i|0];return s},isSpecCompliantForm:function(t){return!!(t&&p(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),s=(t,i)=>{if(m(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[i]=t;const n=u(t)?[]:{};return T(t,((t,e)=>{const r=s(t,i+1);!l(r)&&(n[e]=r)})),e[i]=void 0,n}}return t};return s(t,0)},isAsyncFn:I,isThenable:t=>t&&(m(t)||p(t))&&p(t.then)&&p(t.catch),setImmediate:q,asap:$};function G(t,e,s,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),s&&(this.config=s),i&&(this.request=i),n&&(this.response=n)}J.inherits(G,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:J.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const K=G.prototype,Y={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{Y[t]={value:t}})),Object.defineProperties(G,Y),Object.defineProperty(K,"isAxiosError",{value:!0}),G.from=(t,e,s,i,n,r)=>{const o=Object.create(K);return J.toFlatObject(t,o,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),G.call(o,t.message,e,s,i,n),o.cause=t,o.name=t.name,r&&Object.assign(o,r),o};const X=G;function Q(t){return J.isPlainObject(t)||J.isArray(t)}function Z(t){return J.endsWith(t,"[]")?t.slice(0,-2):t}function tt(t,e,s){return t?t.concat(e).map((function(t,e){return t=Z(t),!s&&e?"["+t+"]":t})).join(s?".":""):e}const et=J.toFlatObject(J,{},null,(function(t){return/^is[A-Z]/.test(t)})),st=function(t,e,s){if(!J.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const i=(s=J.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!J.isUndefined(e[t])}))).metaTokens,n=s.visitor||h,r=s.dots,o=s.indexes,a=(s.Blob||"undefined"!=typeof Blob&&Blob)&&J.isSpecCompliantForm(e);if(!J.isFunction(n))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(J.isDate(t))return t.toISOString();if(!a&&J.isBlob(t))throw new X("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(t)||J.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function h(t,s,n){let a=t;if(t&&!n&&"object"==typeof t)if(J.endsWith(s,"{}"))s=i?s:s.slice(0,-2),t=JSON.stringify(t);else if(J.isArray(t)&&function(t){return J.isArray(t)&&!t.some(Q)}(t)||(J.isFileList(t)||J.endsWith(s,"[]"))&&(a=J.toArray(t)))return s=Z(s),a.forEach((function(t,i){!J.isUndefined(t)&&null!==t&&e.append(!0===o?tt([s],i,r):null===o?s:s+"[]",c(t))})),!1;return!!Q(t)||(e.append(tt(n,s,r),c(t)),!1)}const u=[],l=Object.assign(et,{defaultVisitor:h,convertValue:c,isVisitable:Q});if(!J.isObject(t))throw new TypeError("data must be an object");return function t(s,i){if(!J.isUndefined(s)){if(-1!==u.indexOf(s))throw Error("Circular reference detected in "+i.join("."));u.push(s),J.forEach(s,(function(s,r){!0===(!(J.isUndefined(s)||null===s)&&n.call(e,s,J.isString(r)?r.trim():r,i,l))&&t(s,i?i.concat(r):[r])})),u.pop()}}(t),e};function it(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function nt(t,e){this._pairs=[],t&&st(t,this,e)}const rt=nt.prototype;rt.append=function(t,e){this._pairs.push([t,e])},rt.toString=function(t){const e=t?function(e){return t.call(this,e,it)}:it;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const ot=nt;function at(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ct(t,e,s){if(!e)return t;const i=s&&s.encode||at,n=s&&s.serialize;let r;if(r=n?n(e,s):J.isURLSearchParams(e)?e.toString():new ot(e,s).toString(i),r){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t}const ht=class{constructor(){this.handlers=[]}use(t,e,s){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!s&&s.synchronous,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){J.forEach(this.handlers,(function(e){null!==e&&t(e)}))}},ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},lt={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ot,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},dt="undefined"!=typeof window&&"undefined"!=typeof document,ft=(pt="undefined"!=typeof navigator&&navigator.product,dt&&["ReactNative","NativeScript","NS"].indexOf(pt)<0);var pt;const gt="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,mt=dt&&window.location.href||"http://localhost",yt={...s,...lt},bt=function(t){function e(t,s,i,n){let r=t[n++];if("__proto__"===r)return!0;const o=Number.isFinite(+r),a=n>=t.length;return r=!r&&J.isArray(i)?i.length:r,a?(J.hasOwnProp(i,r)?i[r]=[i[r],s]:i[r]=s,!o):(i[r]&&J.isObject(i[r])||(i[r]=[]),e(t,s,i[r],n)&&J.isArray(i[r])&&(i[r]=function(t){const e={},s=Object.keys(t);let i;const n=s.length;let r;for(i=0;i<n;i++)r=s[i],e[r]=t[r];return e}(i[r])),!o)}if(J.isFormData(t)&&J.isFunction(t.entries)){const s={};return J.forEachEntry(t,((t,i)=>{e(function(t){return J.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),i,s,0)})),s}return null},vt={transitional:ut,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const s=e.getContentType()||"",i=s.indexOf("application/json")>-1,n=J.isObject(t);if(n&&J.isHTMLForm(t)&&(t=new FormData(t)),J.isFormData(t))return i?JSON.stringify(bt(t)):t;if(J.isArrayBuffer(t)||J.isBuffer(t)||J.isStream(t)||J.isFile(t)||J.isBlob(t)||J.isReadableStream(t))return t;if(J.isArrayBufferView(t))return t.buffer;if(J.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let r;if(n){if(s.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return st(t,new yt.classes.URLSearchParams,Object.assign({visitor:function(t,e,s,i){return yt.isNode&&J.isBuffer(t)?(this.append(e,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((r=J.isFileList(t))||s.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return st(r?{"files[]":t}:t,e&&new e,this.formSerializer)}}return n||i?(e.setContentType("application/json",!1),function(t,e,s){if(J.isString(t))try{return(0,JSON.parse)(t),J.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||vt.transitional,s=e&&e.forcedJSONParsing,i="json"===this.responseType;if(J.isResponse(t)||J.isReadableStream(t))return t;if(t&&J.isString(t)&&(s&&!this.responseType||i)){const s=!(e&&e.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(t){if(s){if("SyntaxError"===t.name)throw X.from(t,X.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:yt.classes.FormData,Blob:yt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],(t=>{vt.headers[t]={}}));const wt=vt,St=J.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),kt=Symbol("internals");function Et(t){return t&&String(t).trim().toLowerCase()}function _t(t){return!1===t||null==t?t:J.isArray(t)?t.map(_t):String(t)}function Ot(t,e,s,i,n){return J.isFunction(i)?i.call(this,e,s):(n&&(e=s),J.isString(e)?J.isString(i)?-1!==e.indexOf(i):J.isRegExp(i)?i.test(e):void 0:void 0)}class xt{constructor(t){t&&this.set(t)}set(t,e,s){const i=this;function n(t,e,s){const n=Et(e);if(!n)throw new Error("header name must be a non-empty string");const r=J.findKey(i,n);(!r||void 0===i[r]||!0===s||void 0===s&&!1!==i[r])&&(i[r||e]=_t(t))}const r=(t,e)=>J.forEach(t,((t,s)=>n(t,s,e)));if(J.isPlainObject(t)||t instanceof this.constructor)r(t,e);else if(J.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))r((t=>{const e={};let s,i,n;return t&&t.split("\n").forEach((function(t){n=t.indexOf(":"),s=t.substring(0,n).trim().toLowerCase(),i=t.substring(n+1).trim(),!s||e[s]&&St[s]||("set-cookie"===s?e[s]?e[s].push(i):e[s]=[i]:e[s]=e[s]?e[s]+", "+i:i)})),e})(t),e);else if(J.isHeaders(t))for(const[e,i]of t.entries())n(i,e,s);else null!=t&&n(e,t,s);return this}get(t,e){if(t=Et(t)){const s=J.findKey(this,t);if(s){const t=this[s];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=s.exec(t);)e[i[1]]=i[2];return e}(t);if(J.isFunction(e))return e.call(this,t,s);if(J.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Et(t)){const s=J.findKey(this,t);return!(!s||void 0===this[s]||e&&!Ot(0,this[s],s,e))}return!1}delete(t,e){const s=this;let i=!1;function n(t){if(t=Et(t)){const n=J.findKey(s,t);!n||e&&!Ot(0,s[n],n,e)||(delete s[n],i=!0)}}return J.isArray(t)?t.forEach(n):n(t),i}clear(t){const e=Object.keys(this);let s=e.length,i=!1;for(;s--;){const n=e[s];t&&!Ot(0,this[n],n,t,!0)||(delete this[n],i=!0)}return i}normalize(t){const e=this,s={};return J.forEach(this,((i,n)=>{const r=J.findKey(s,n);if(r)return e[r]=_t(i),void delete e[n];const o=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,s)=>e.toUpperCase()+s))}(n):String(n).trim();o!==n&&delete e[n],e[o]=_t(i),s[o]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return J.forEach(this,((s,i)=>{null!=s&&!1!==s&&(e[i]=t&&J.isArray(s)?s.join(", "):s)})),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const s=new this(t);return e.forEach((t=>s.set(t))),s}static accessor(t){const e=(this[kt]=this[kt]={accessors:{}}).accessors,s=this.prototype;function i(t){const i=Et(t);e[i]||(function(t,e){const s=J.toCamelCase(" "+e);["get","set","has"].forEach((i=>{Object.defineProperty(t,i+s,{value:function(t,s,n){return this[i].call(this,e,t,s,n)},configurable:!0})}))}(s,t),e[i]=!0)}return J.isArray(t)?t.forEach(i):i(t),this}}xt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),J.reduceDescriptors(xt.prototype,(({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[s]=t}}})),J.freezeMethods(xt);const Tt=xt;function At(t,e){const s=this||wt,i=e||s,n=Tt.from(i.headers);let r=i.data;return J.forEach(t,(function(t){r=t.call(s,r,n.normalize(),e?e.status:void 0)})),n.normalize(),r}function Rt(t){return!(!t||!t.__CANCEL__)}function Lt(t,e,s){X.call(this,null==t?"canceled":t,X.ERR_CANCELED,e,s),this.name="CanceledError"}J.inherits(Lt,X,{__CANCEL__:!0});const Ct=Lt;function jt(t,e,s){const i=s.config.validateStatus;s.status&&i&&!i(s.status)?e(new X("Request failed with status code "+s.status,[X.ERR_BAD_REQUEST,X.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):t(s)}const Bt=(t,e,s=3)=>{let i=0;const n=function(t,e){t=t||10;const s=new Array(t),i=new Array(t);let n,r=0,o=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),h=i[o];n||(n=c),s[r]=a,i[r]=c;let u=o,l=0;for(;u!==r;)l+=s[u++],u%=t;if(r=(r+1)%t,r===o&&(o=(o+1)%t),c-n<e)return;const d=h&&c-h;return d?Math.round(1e3*l/d):void 0}}(50,250);return function(t,e){let s,i,n=0,r=1e3/e;const o=(e,r=Date.now())=>{n=r,s=null,i&&(clearTimeout(i),i=null),t.apply(null,e)};return[(...t)=>{const e=Date.now(),a=e-n;a>=r?o(t,e):(s=t,i||(i=setTimeout((()=>{i=null,o(s)}),r-a)))},()=>s&&o(s)]}((s=>{const r=s.loaded,o=s.lengthComputable?s.total:void 0,a=r-i,c=n(a);i=r,t({loaded:r,total:o,progress:o?r/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&r<=o?(o-r)/c:void 0,event:s,lengthComputable:null!=o,[e?"download":"upload"]:!0})}),s)},Pt=(t,e)=>{const s=null!=t;return[i=>e[0]({lengthComputable:s,total:t,loaded:i}),e[1]]},Dt=t=>(...e)=>J.asap((()=>t(...e))),Ft=yt.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let s;function i(s){let i=s;return t&&(e.setAttribute("href",i),i=e.href),e.setAttribute("href",i),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname}}return s=i(window.location.href),function(t){const e=J.isString(t)?i(t):t;return e.protocol===s.protocol&&e.host===s.host}}():function(){return!0},Nt=yt.hasStandardBrowserEnv?{write(t,e,s,i,n,r){const o=[t+"="+encodeURIComponent(e)];J.isNumber(s)&&o.push("expires="+new Date(s).toGMTString()),J.isString(i)&&o.push("path="+i),J.isString(n)&&o.push("domain="+n),!0===r&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Mt(t,e){return t&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const zt=t=>t instanceof Tt?{...t}:t;function It(t,e){e=e||{};const s={};function i(t,e,s){return J.isPlainObject(t)&&J.isPlainObject(e)?J.merge.call({caseless:s},t,e):J.isPlainObject(e)?J.merge({},e):J.isArray(e)?e.slice():e}function n(t,e,s){return J.isUndefined(e)?J.isUndefined(t)?void 0:i(void 0,t,s):i(t,e,s)}function r(t,e){if(!J.isUndefined(e))return i(void 0,e)}function o(t,e){return J.isUndefined(e)?J.isUndefined(t)?void 0:i(void 0,t):i(void 0,e)}function a(s,n,r){return r in e?i(s,n):r in t?i(void 0,s):void 0}const c={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(t,e)=>n(zt(t),zt(e),!0)};return J.forEach(Object.keys(Object.assign({},t,e)),(function(i){const r=c[i]||n,o=r(t[i],e[i],i);J.isUndefined(o)&&r!==a||(s[i]=o)})),s}const qt=t=>{const e=It({},t);let s,{data:i,withXSRFToken:n,xsrfHeaderName:r,xsrfCookieName:o,headers:a,auth:c}=e;if(e.headers=a=Tt.from(a),e.url=ct(Mt(e.baseURL,e.url),t.params,t.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),J.isFormData(i))if(yt.hasStandardBrowserEnv||yt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(s=a.getContentType())){const[t,...e]=s?s.split(";").map((t=>t.trim())).filter(Boolean):[];a.setContentType([t||"multipart/form-data",...e].join("; "))}if(yt.hasStandardBrowserEnv&&(n&&J.isFunction(n)&&(n=n(e)),n||!1!==n&&Ft(e.url))){const t=r&&o&&Nt.read(o);t&&a.set(r,t)}return e},Ut="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,s){const i=qt(t);let n=i.data;const r=Tt.from(i.headers).normalize();let o,a,c,h,u,{responseType:l,onUploadProgress:d,onDownloadProgress:f}=i;function p(){h&&h(),u&&u(),i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}let g=new XMLHttpRequest;function m(){if(!g)return;const i=Tt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());jt((function(t){e(t),p()}),(function(t){s(t),p()}),{data:l&&"text"!==l&&"json"!==l?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:i,config:t,request:g}),g=null}g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(s(new X("Request aborted",X.ECONNABORTED,t,g)),g=null)},g.onerror=function(){s(new X("Network Error",X.ERR_NETWORK,t,g)),g=null},g.ontimeout=function(){let e=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const n=i.transitional||ut;i.timeoutErrorMessage&&(e=i.timeoutErrorMessage),s(new X(e,n.clarifyTimeoutError?X.ETIMEDOUT:X.ECONNABORTED,t,g)),g=null},void 0===n&&r.setContentType(null),"setRequestHeader"in g&&J.forEach(r.toJSON(),(function(t,e){g.setRequestHeader(e,t)})),J.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),l&&"json"!==l&&(g.responseType=i.responseType),f&&([c,u]=Bt(f,!0),g.addEventListener("progress",c)),d&&g.upload&&([a,h]=Bt(d),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",h)),(i.cancelToken||i.signal)&&(o=e=>{g&&(s(!e||e.type?new Ct(null,t,g):e),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));const y=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(i.url);y&&-1===yt.protocols.indexOf(y)?s(new X("Unsupported protocol "+y+":",X.ERR_BAD_REQUEST,t)):g.send(n||null)}))},Vt=(t,e)=>{let s,i=new AbortController;const n=function(t){if(!s){s=!0,o();const e=t instanceof Error?t:this.reason;i.abort(e instanceof X?e:new Ct(e instanceof Error?e.message:e))}};let r=e&&setTimeout((()=>{n(new X(`timeout ${e} of ms exceeded`,X.ETIMEDOUT))}),e);const o=()=>{t&&(r&&clearTimeout(r),r=null,t.forEach((t=>{t&&(t.removeEventListener?t.removeEventListener("abort",n):t.unsubscribe(n))})),t=null)};t.forEach((t=>t&&t.addEventListener&&t.addEventListener("abort",n)));const{signal:a}=i;return a.unsubscribe=o,[a,()=>{r&&clearTimeout(r),r=null}]},Wt=function*(t,e){let s=t.byteLength;if(!e||s<e)return void(yield t);let i,n=0;for(;n<s;)i=n+e,yield t.slice(n,i),n=i},Ht=(t,e,s,i,n)=>{const r=async function*(t,e,s){for await(const i of t)yield*Wt(ArrayBuffer.isView(i)?i:await s(String(i)),e)}(t,e,n);let o,a=0,c=t=>{o||(o=!0,i&&i(t))};return new ReadableStream({async pull(t){try{const{done:e,value:i}=await r.next();if(e)return c(),void t.close();let n=i.byteLength;if(s){let t=a+=n;s(t)}t.enqueue(new Uint8Array(i))}catch(t){throw c(t),t}},cancel:t=>(c(t),r.return())},{highWaterMark:2})},$t="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Jt=$t&&"function"==typeof ReadableStream,Gt=$t&&("function"==typeof TextEncoder?(Kt=new TextEncoder,t=>Kt.encode(t)):async t=>new Uint8Array(await new Response(t).arrayBuffer()));var Kt;const Yt=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},Xt=Jt&&Yt((()=>{let t=!1;const e=new Request(yt.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})),Qt=Jt&&Yt((()=>J.isReadableStream(new Response("").body))),Zt={stream:Qt&&(t=>t.body)};var te;$t&&(te=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!Zt[t]&&(Zt[t]=J.isFunction(te[t])?e=>e[t]():(e,s)=>{throw new X(`Response type '${t}' is not supported`,X.ERR_NOT_SUPPORT,s)})})));const ee=$t&&(async t=>{let{url:e,method:s,data:i,signal:n,cancelToken:r,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:h,headers:u,withCredentials:l="same-origin",fetchOptions:d}=qt(t);h=h?(h+"").toLowerCase():"text";let f,p,[g,m]=n||r||o?Vt([n,r],o):[];const y=()=>{!f&&setTimeout((()=>{g&&g.unsubscribe()})),f=!0};let b;try{if(c&&Xt&&"get"!==s&&"head"!==s&&0!==(b=await(async(t,e)=>{const s=J.toFiniteNumber(t.getContentLength());return null==s?(async t=>null==t?0:J.isBlob(t)?t.size:J.isSpecCompliantForm(t)?(await new Request(t).arrayBuffer()).byteLength:J.isArrayBufferView(t)||J.isArrayBuffer(t)?t.byteLength:(J.isURLSearchParams(t)&&(t+=""),J.isString(t)?(await Gt(t)).byteLength:void 0))(e):s})(u,i))){let t,s=new Request(e,{method:"POST",body:i,duplex:"half"});if(J.isFormData(i)&&(t=s.headers.get("content-type"))&&u.setContentType(t),s.body){const[t,e]=Pt(b,Bt(Dt(c)));i=Ht(s.body,65536,t,e,Gt)}}J.isString(l)||(l=l?"include":"omit"),p=new Request(e,{...d,signal:g,method:s.toUpperCase(),headers:u.normalize().toJSON(),body:i,duplex:"half",credentials:l});let n=await fetch(p);const r=Qt&&("stream"===h||"response"===h);if(Qt&&(a||r)){const t={};["status","statusText","headers"].forEach((e=>{t[e]=n[e]}));const e=J.toFiniteNumber(n.headers.get("content-length")),[s,i]=a&&Pt(e,Bt(Dt(a),!0))||[];n=new Response(Ht(n.body,65536,s,(()=>{i&&i(),r&&y()}),Gt),t)}h=h||"text";let o=await Zt[J.findKey(Zt,h)||"text"](n,t);return!r&&y(),m&&m(),await new Promise(((e,s)=>{jt(e,s,{data:o,headers:Tt.from(n.headers),status:n.status,statusText:n.statusText,config:t,request:p})}))}catch(e){if(y(),e&&"TypeError"===e.name&&/fetch/i.test(e.message))throw Object.assign(new X("Network Error",X.ERR_NETWORK,t,p),{cause:e.cause||e});throw X.from(e,e&&e.code,t,p)}}),se={http:null,xhr:Ut,fetch:ee};J.forEach(se,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const ie=t=>`- ${t}`,ne=t=>J.isFunction(t)||null===t||!1===t,re=t=>{t=J.isArray(t)?t:[t];const{length:e}=t;let s,i;const n={};for(let r=0;r<e;r++){let e;if(s=t[r],i=s,!ne(s)&&(i=se[(e=String(s)).toLowerCase()],void 0===i))throw new X(`Unknown adapter '${e}'`);if(i)break;n[e||"#"+r]=i}if(!i){const t=Object.entries(n).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let s=e?t.length>1?"since :\n"+t.map(ie).join("\n"):" "+ie(t[0]):"as no adapter specified";throw new X("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return i};function oe(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ct(null,t)}function ae(t){return oe(t),t.headers=Tt.from(t.headers),t.data=At.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),re(t.adapter||wt.adapter)(t).then((function(e){return oe(t),e.data=At.call(t,t.transformResponse,e),e.headers=Tt.from(e.headers),e}),(function(e){return Rt(e)||(oe(t),e&&e.response&&(e.response.data=At.call(t,t.transformResponse,e.response),e.response.headers=Tt.from(e.response.headers))),Promise.reject(e)}))}const ce={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{ce[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}}));const he={};ce.transitional=function(t,e,s){function i(t,e){return"[Axios v1.7.4] Transitional option '"+t+"'"+e+(s?". "+s:"")}return(s,n,r)=>{if(!1===t)throw new X(i(n," has been removed"+(e?" in "+e:"")),X.ERR_DEPRECATED);return e&&!he[n]&&(he[n]=!0,console.warn(i(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(s,n,r)}};const ue={assertOptions:function(t,e,s){if("object"!=typeof t)throw new X("options must be an object",X.ERR_BAD_OPTION_VALUE);const i=Object.keys(t);let n=i.length;for(;n-- >0;){const r=i[n],o=e[r];if(o){const e=t[r],s=void 0===e||o(e,r,t);if(!0!==s)throw new X("option "+r+" must be "+s,X.ERR_BAD_OPTION_VALUE)}else if(!0!==s)throw new X("Unknown option "+r,X.ERR_BAD_OPTION)}},validators:ce},le=ue.validators;class de{constructor(t){this.defaults=t,this.interceptors={request:new ht,response:new ht}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e;Error.captureStackTrace?Error.captureStackTrace(e={}):e=new Error;const s=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?s&&!String(t.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+s):t.stack=s}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=It(this.defaults,e);const{transitional:s,paramsSerializer:i,headers:n}=e;void 0!==s&&ue.assertOptions(s,{silentJSONParsing:le.transitional(le.boolean),forcedJSONParsing:le.transitional(le.boolean),clarifyTimeoutError:le.transitional(le.boolean)},!1),null!=i&&(J.isFunction(i)?e.paramsSerializer={serialize:i}:ue.assertOptions(i,{encode:le.function,serialize:le.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&J.merge(n.common,n[e.method]);n&&J.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete n[t]})),e.headers=Tt.concat(r,n);const o=[];let a=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,o.unshift(t.fulfilled,t.rejected))}));const c=[];let h;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let u,l=0;if(!a){const t=[ae.bind(this),void 0];for(t.unshift.apply(t,o),t.push.apply(t,c),u=t.length,h=Promise.resolve(e);l<u;)h=h.then(t[l++],t[l++]);return h}u=o.length;let d=e;for(l=0;l<u;){const t=o[l++],e=o[l++];try{d=t(d)}catch(t){e.call(this,t);break}}try{h=ae.call(this,d)}catch(t){return Promise.reject(t)}for(l=0,u=c.length;l<u;)h=h.then(c[l++],c[l++]);return h}getUri(t){return ct(Mt((t=It(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}J.forEach(["delete","get","head","options"],(function(t){de.prototype[t]=function(e,s){return this.request(It(s||{},{method:t,url:e,data:(s||{}).data}))}})),J.forEach(["post","put","patch"],(function(t){function e(e){return function(s,i,n){return this.request(It(n||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}de.prototype[t]=e(),de.prototype[t+"Form"]=e(!0)}));const fe=de;class pe{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise((function(t){e=t}));const s=this;this.promise.then((t=>{if(!s._listeners)return;let e=s._listeners.length;for(;e-- >0;)s._listeners[e](t);s._listeners=null})),this.promise.then=t=>{let e;const i=new Promise((t=>{s.subscribe(t),e=t})).then(t);return i.cancel=function(){s.unsubscribe(e)},i},t((function(t,i,n){s.reason||(s.reason=new Ct(t,i,n),e(s.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}static source(){let t;return{token:new pe((function(e){t=e})),cancel:t}}}const ge=pe,me={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(me).forEach((([t,e])=>{me[e]=t}));const ye=me,be=function t(e){const s=new fe(e),i=n(fe.prototype.request,s);return J.extend(i,fe.prototype,s,{allOwnKeys:!0}),J.extend(i,s,null,{allOwnKeys:!0}),i.create=function(s){return t(It(e,s))},i}(wt);be.Axios=fe,be.CanceledError=Ct,be.CancelToken=ge,be.isCancel=Rt,be.VERSION="1.7.4",be.toFormData=st,be.AxiosError=X,be.Cancel=be.CanceledError,be.all=function(t){return Promise.all(t)},be.spread=function(t){return function(e){return t.apply(null,e)}},be.isAxiosError=function(t){return J.isObject(t)&&!0===t.isAxiosError},be.mergeConfig=It,be.AxiosHeaders=Tt,be.formToJSON=t=>bt(J.isHTMLForm(t)?new FormData(t):t),be.getAdapter=re,be.HttpStatusCode=ye,be.default=be;const ve=be;class we{interceptor;constructor(t){this.interceptor=ve.create({baseURL:`${t}/api`}),this.interceptor.interceptors.request.use((t=>{const e=ve.CancelToken.source();return t.cancelToken=e.token,setTimeout((()=>{e.cancel("Timeout: request took more than 15 seconds")}),15e3),t}),(t=>Promise.reject(t)))}}const Se="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,ke=new Set,Ee="object"==typeof process&&process?process:{},_e=(t,e,s,i)=>{"function"==typeof Ee.emitWarning?Ee.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let Oe=globalThis.AbortController,xe=globalThis.AbortSignal;if(void 0===Oe){xe=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},Oe=class{constructor(){e()}signal=new xe;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==Ee.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,_e("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const Te=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Ae=t=>Te(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Re:null:null;class Re extends Array{constructor(t){super(t),this.fill(0)}}class Le{heap;length;static#t=!1;static create(t){const e=Ae(t);if(!e)return[];Le.#t=!0;const s=new Le(t,e);return Le.#t=!1,s}constructor(t,e){if(!Le.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class Ce{#e;#s;#i;#n;#r;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#h;#u;#l;#d;#f;#p;#g;#m;#y;#b;#v;#w;#S;#k;#E;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,sizes:t.#b,keyMap:t.#h,keyList:t.#u,valList:t.#l,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#g},free:t.#m,isBackgroundFetch:e=>t.#_(e),backgroundFetch:(e,s,i,n)=>t.#O(e,s,i,n),moveToTail:e=>t.#x(e),indexes:e=>t.#T(e),rindexes:e=>t.#A(e),isStale:e=>t.#R(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#o}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:h,noDisposeOnSet:u,noUpdateTTL:l,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:w,ignoreFetchAbort:S}=t;if(0!==e&&!Te(e))throw new TypeError("max option must be a nonnegative integer");const k=e?Ae(e):Array;if(!k)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=d,this.maxEntrySize=f||this.#s,this.sizeCalculation=p,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#o=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=g,this.#k=!!g,this.#h=new Map,this.#u=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#d=new k(e),this.#f=new k(e),this.#p=0,this.#g=0,this.#m=Le.create(e),this.#a=0,this.#c=0,"function"==typeof c&&(this.#i=c),"function"==typeof h?(this.#n=h,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#S=!!this.#i,this.#E=!!this.#n,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!l,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#s&&!Te(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!Te(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#L()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=Te(i)||0===i?i:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!Te(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#C()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";(t=>!ke.has(t))(t)&&(ke.add(t),_e("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,Ce))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#C(){const t=new Re(this.#e),e=new Re(this.#e);this.#w=t,this.#v=e,this.#j=(s,i,n=Se.now())=>{if(e[s]=0!==i?n:0,t[s]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#R(s)&&this.#B(this.#u[s],"expire")}),i+1);t.unref&&t.unref()}},this.#P=s=>{e[s]=0!==t[s]?Se.now():0},this.#D=(n,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;n.ttl=o,n.start=a,n.now=s||i();const c=n.now-a;n.remainingTTL=o-c}};let s=0;const i=()=>{const t=Se.now();if(this.ttlResolution>0){s=t;const e=setTimeout((()=>s=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#h.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];return o&&a?o-((s||i())-a):1/0},this.#R=n=>{const r=e[n],o=t[n];return!!o&&!!r&&(s||i())-r>o}}#P=()=>{};#D=()=>{};#j=()=>{};#R=()=>!1;#L(){const t=new Re(this.#e);this.#c=0,this.#b=t,this.#F=e=>{this.#c-=t[e],t[e]=0},this.#N=(t,e,s,i)=>{if(this.#_(e))return 0;if(!Te(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!Te(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#M=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#c>s;)this.#z(!0)}this.#c+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#c)}}#F=t=>{};#M=(t,e,s)=>{};#N=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#g;this.#I(e)&&(!t&&this.#R(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#I(e)&&(!t&&this.#R(e)||(yield e),e!==this.#g);)e=this.#d[e]}#I(t){return void 0!==t&&this.#h.get(this.#u[t])===t}*entries(){for(const t of this.#T())void 0===this.#l[t]||void 0===this.#u[t]||this.#_(this.#l[t])||(yield[this.#u[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#u[t]||this.#_(this.#l[t])||(yield[this.#u[t],this.#l[t]])}*keys(){for(const t of this.#T()){const e=this.#u[t];void 0===e||this.#_(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#u[t];void 0===e||this.#_(this.#l[t])||(yield e)}}*values(){for(const t of this.#T())void 0===this.#l[t]||this.#_(this.#l[t])||(yield this.#l[t])}*rvalues(){for(const t of this.#A())void 0===this.#l[t]||this.#_(this.#l[t])||(yield this.#l[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#T()){const i=this.#l[s],n=this.#_(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#u[s],this))return this.get(this.#u[s],e)}}forEach(t,e=this){for(const s of this.#T()){const i=this.#l[s],n=this.#_(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#u[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const i=this.#l[s],n=this.#_(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#u[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#R(e)&&(this.#B(this.#u[e],"expire"),t=!0);return t}info(t){const e=this.#h.get(t);if(void 0===e)return;const s=this.#l[e],i=this.#_(s)?s.__staleWhileFetching:s;if(void 0===i)return;const n={value:i};if(this.#w&&this.#v){const t=this.#w[e],s=this.#v[e];if(t&&s){const e=t-(Se.now()-s);n.ttl=e,n.start=Date.now()}}return this.#b&&(n.size=this.#b[e]),n}dump(){const t=[];for(const e of this.#T({allowStale:!0})){const s=this.#u[e],i=this.#l[e],n=this.#_(i)?i.__staleWhileFetching:i;if(void 0===n||void 0===s)continue;const r={value:n};if(this.#w&&this.#v){r.ttl=this.#w[e];const t=Se.now()-this.#v[e];r.start=Math.floor(Date.now()-t)}this.#b&&(r.size=this.#b[e]),t.unshift([s,r])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=Se.now()-t}this.set(e,s.value,s)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#N(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#B(t,"set"),this;let u=0===this.#a?void 0:this.#h.get(t);if(void 0===u)u=0===this.#a?this.#g:0!==this.#m.length?this.#m.pop():this.#a===this.#e?this.#z(!1):this.#a,this.#u[u]=t,this.#l[u]=e,this.#h.set(t,u),this.#d[this.#g]=u,this.#f[u]=this.#g,this.#g=u,this.#a++,this.#M(u,h,a),a&&(a.set="add"),c=!1;else{this.#x(u);const s=this.#l[u];if(e!==s){if(this.#k&&this.#_(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#S&&this.#i?.(e,t,"set"),this.#E&&this.#y?.push([e,t,"set"]))}else r||(this.#S&&this.#i?.(s,t,"set"),this.#E&&this.#y?.push([s,t,"set"]));if(this.#F(u),this.#M(u,h,a),this.#l[u]=e,a){a.set="replace";const t=s&&this.#_(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#C(),this.#w&&(c||this.#j(u,i,n),a&&this.#D(a,u)),!r&&this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#l[this.#p];if(this.#z(!0),this.#_(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#z(t){const e=this.#p,s=this.#u[e],i=this.#l[e];return this.#k&&this.#_(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#E)&&(this.#S&&this.#i?.(i,s,"evict"),this.#E&&this.#y?.push([i,s,"evict"])),this.#F(e),t&&(this.#u[e]=void 0,this.#l[e]=void 0,this.#m.push(e)),1===this.#a?(this.#p=this.#g=0,this.#m.length=0):this.#p=this.#d[e],this.#h.delete(s),this.#a--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#h.get(t);if(void 0!==n){const t=this.#l[n];if(this.#_(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#R(n))return s&&this.#P(n),i&&(i.has="hit",this.#D(i,n)),!0;i&&(i.has="stale",this.#D(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#h.get(t);if(void 0===i||!s&&this.#R(i))return;const n=this.#l[i];return this.#_(n)?n.__staleWhileFetching:n}#O(t,e,s,i){const n=void 0===e?void 0:this.#l[e];if(this.#_(n))return n;const r=new Oe,{signal:o}=s;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:s,context:i},c=(i,n=!1)=>{const{aborted:o}=r.signal,c=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,c&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!c&&!n)return h(r.signal.reason);const l=u;return this.#l[e]===u&&(void 0===i?l.__staleWhileFetching?this.#l[e]=l.__staleWhileFetching:this.#B(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,a.options))),i},h=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u&&(c&&void 0!==h.__staleWhileFetching?o||(this.#l[e]=h.__staleWhileFetching):this.#B(t,"fetch")),a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#r?.(t,n,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),h(t)))),l=Object.assign(u,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,l,{...a.options,status:void 0}),e=this.#h.get(t)):this.#l[e]=l,l}#_(t){if(!this.#k)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Oe}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:g=!1,status:m,signal:y}=e;if(!this.#k)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:m});const b={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:m,signal:y};let v=this.#h.get(t);if(void 0===v){m&&(m.fetch="miss");const e=this.#O(t,v,b,p);return e.__returned=e}{const e=this.#l[v];if(this.#_(e)){const t=s&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#R(v);if(!g&&!n)return m&&(m.fetch="hit"),this.#x(v),i&&this.#P(v),m&&this.#D(m,v),e;const r=this.#O(t,v,b,p),o=void 0!==r.__staleWhileFetching&&s;return m&&(m.fetch=n?"stale":"refresh",o&&n&&(m.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}async forceFetch(t,e={}){const s=await this.fetch(t,e);if(void 0===s)throw new Error("fetch() returned undefined");return s}memo(t,e={}){const s=this.#o;if(!s)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:n,...r}=e,o=this.get(t,r);if(!n&&void 0!==o)return o;const a=s(t,o,{options:r,context:i});return this.set(t,a,r),a}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#l[o],a=this.#_(e);return r&&this.#D(r,o),this.#R(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.#B(t,"expire"),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#x(o),i&&this.#P(o),e))}r&&(r.get="miss")}#q(t,e){this.#f[e]=t,this.#d[t]=e}#x(t){t!==this.#g&&(t===this.#p?this.#p=this.#d[t]:this.#q(this.#f[t],this.#d[t]),this.#q(this.#g,t),this.#g=t)}delete(t){return this.#B(t,"delete")}#B(t,e){let s=!1;if(0!==this.#a){const i=this.#h.get(t);if(void 0!==i)if(s=!0,1===this.#a)this.#U(e);else{this.#F(i);const s=this.#l[i];if(this.#_(s)?s.__abortController.abort(new Error("deleted")):(this.#S||this.#E)&&(this.#S&&this.#i?.(s,t,e),this.#E&&this.#y?.push([s,t,e])),this.#h.delete(t),this.#u[i]=void 0,this.#l[i]=void 0,i===this.#g)this.#g=this.#f[i];else if(i===this.#p)this.#p=this.#d[i];else{const t=this.#f[i];this.#d[t]=this.#d[i];const e=this.#d[i];this.#f[e]=this.#f[i]}this.#a--,this.#m.push(i)}}if(this.#E&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return s}clear(){return this.#U("delete")}#U(t){for(const e of this.#A({allowStale:!0})){const s=this.#l[e];if(this.#_(s))s.__abortController.abort(new Error("deleted"));else{const i=this.#u[e];this.#S&&this.#i?.(s,i,t),this.#E&&this.#y?.push([s,i,t])}}if(this.#h.clear(),this.#l.fill(void 0),this.#u.fill(void 0),this.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#g=0,this.#m.length=0,this.#c=0,this.#a=0,this.#E&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}var je=function(t,e){return je=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])},je(t,e)};function Be(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}je(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}function Pe(t,e){var s,i,n,r,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(c){return function(a){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(o=0)),o;)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 o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}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 De(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 Fe(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 Ne(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 Me(t){return this instanceof Me?(this.v=t,this):new Me(t)}function ze(t){return"function"==typeof t}function Ie(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 qe=Ie((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 Ue(t,e){if(t){var s=t.indexOf(e);0<=s&&t.splice(s,1)}}var Ve=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=De(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(ze(c))try{c()}catch(t){n=t instanceof qe?t.errors:[t]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var u=De(h),l=u.next();!l.done;l=u.next()){var d=l.value;try{$e(d)}catch(t){n=null!=n?n:[],t instanceof qe?n=Ne(Ne([],Fe(n)),Fe(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 qe(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)&&Ue(e,t)},t.prototype.remove=function(e){var s=this._finalizers;s&&Ue(s,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),We=Ve.EMPTY;function He(t){return t instanceof Ve||t&&"closed"in t&&ze(t.remove)&&ze(t.add)&&ze(t.unsubscribe)}function $e(t){ze(t)?t():t.unsubscribe()}var Je={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ge={setTimeout:function(t,e){for(var s=[],i=2;i<arguments.length;i++)s[i-2]=arguments[i];var n=Ge.delegate;return(null==n?void 0:n.setTimeout)?n.setTimeout.apply(n,Ne([t,e],Fe(s))):setTimeout.apply(void 0,Ne([t,e],Fe(s)))},clearTimeout:function(t){var e=Ge.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Ke(t){Ge.setTimeout((function(){var e=Je.onUnhandledError;if(!e)throw t;e(t)}))}function Ye(){}var Xe=Qe("C",void 0,void 0);function Qe(t,e,s){return{kind:t,value:e,error:s}}var Ze=null;function ts(t){if(Je.useDeprecatedSynchronousErrorHandling){var e=!Ze;if(e&&(Ze={errorThrown:!1,error:null}),t(),e){var s=Ze,i=s.errorThrown,n=s.error;if(Ze=null,i)throw n}}else t()}var es=function(t){function e(e){var s=t.call(this)||this;return s.isStopped=!1,e?(s.destination=e,He(e)&&e.add(s)):s.destination=cs,s}return Be(e,t),e.create=function(t,e,s){return new rs(t,e,s)},e.prototype.next=function(t){this.isStopped?as(function(t){return Qe("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?as(Qe("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?as(Xe,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}(Ve),ss=Function.prototype.bind;function is(t,e){return ss.call(t,e)}var ns=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){os(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){os(t)}else os(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){os(t)}},t}(),rs=function(t){function e(e,s,i){var n,r,o=t.call(this)||this;return ze(e)||!e?n={next:null!=e?e:void 0,error:null!=s?s:void 0,complete:null!=i?i:void 0}:o&&Je.useDeprecatedNextContext?((r=Object.create(e)).unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&is(e.next,r),error:e.error&&is(e.error,r),complete:e.complete&&is(e.complete,r)}):n=e,o.destination=new ns(n),o}return Be(e,t),e}(es);function os(t){var e;Je.useDeprecatedSynchronousErrorHandling?(e=t,Je.useDeprecatedSynchronousErrorHandling&&Ze&&(Ze.errorThrown=!0,Ze.error=e)):Ke(t)}function as(t,e){var s=Je.onStoppedNotification;s&&Ge.setTimeout((function(){return s(t,e)}))}var cs={closed:!0,next:Ye,error:function(t){throw t},complete:Ye},hs="function"==typeof Symbol&&Symbol.observable||"@@observable";function us(t){return t}var ls=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 es||function(t){return t&&ze(t.next)&&ze(t.error)&&ze(t.complete)}(t)&&He(t)}(t)?t:new rs(t,e,s);return ts((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=ds(e))((function(e,i){var n=new rs({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[hs]=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?us: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=ds(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 ds(t){var e;return null!==(e=null!=t?t:Je.Promise)&&void 0!==e?e:Promise}var fs=Ie((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),ps=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 Be(e,t),e.prototype.lift=function(t){var e=new gs(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new fs},e.prototype.next=function(t){var e=this;ts((function(){var s,i;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var n=De(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;ts((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;ts((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?We:(this.currentObservers=null,r.push(t),new Ve((function(){e.currentObservers=null,Ue(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 ls;return t.source=this,t},e.create=function(t,e){return new gs(t,e)},e}(ls),gs=function(t){function e(e,s){var i=t.call(this)||this;return i.destination=e,i.source=s,i}return Be(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:We},e}(ps),ms=function(t){function e(e){var s=t.call(this)||this;return s._value=e,s}return Be(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}(ps),ys={now:function(){return(ys.delegate||Date).now()},delegate:void 0},bs=function(t){function e(e,s,i){void 0===e&&(e=1/0),void 0===s&&(s=1/0),void 0===i&&(i=ys);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 Be(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}(ps);function vs(t){return function(e){if(function(t){return ze(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 ws(t,e,s,i,n){return new Ss(t,e,s,i,n)}var Ss=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 Be(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}(es);function ks(){return vs((function(t,e){var s,i=!1;t.subscribe(ws(e,(function(t){var n=s;s=t,i&&e.next([n,t]),i=!0})))}))}function Es(t,e){return vs((function(s,i){var n=0;s.subscribe(ws(i,(function(s){return t.call(e,s,n++)&&i.next(s)})))}))}function _s(t,e){return vs((function(s,i){var n=0;s.subscribe(ws(i,(function(s){i.next(t.call(e,s,n++))})))}))}var Os=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t},xs="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ts(t){if(t instanceof ls)return t;if(null!=t){if(function(t){return ze(t[hs])}(t))return n=t,new ls((function(t){var e=n[hs]();if(ze(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Os(t))return i=t,new ls((function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()}));if(function(t){return ze(null==t?void 0:t.then)}(t))return s=t,new ls((function(t){s.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,Ke)}));if(function(t){return Symbol.asyncIterator&&ze(null==t?void 0:t[Symbol.asyncIterator])}(t))return As(t);if(function(t){return ze(null==t?void 0:t[xs])}(t))return e=t,new ls((function(t){var s,i;try{for(var n=De(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 ze(null==t?void 0:t.getReader)}(t))return As(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={},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 Me?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 Pe(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,Me(e.read())];case 3:return s=n.sent(),i=s.value,s.done?[4,Me(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,Me(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 As(t){return new ls((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 Pe(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=De(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 Rs(t){void 0===t&&(t={});var e=t.connector,s=void 0===e?function(){return new ps}: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},f=function(){var t=e;d(),null==t||t.unsubscribe()};return vs((function(t,p){a++,u||h||l();var g=r=null!=r?r:s();p.add((function(){0!=--a||u||h||(i=Ls(f,c))})),g.subscribe(p),!e&&a>0&&(e=new rs({next:function(t){return g.next(t)},error:function(t){u=!0,l(),i=Ls(d,n,t),g.error(t)},complete:function(){h=!0,l(),i=Ls(d,o),g.complete()}}),Ts(t).subscribe(e))}))(t)}}function Ls(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 rs({next:function(){n.unsubscribe(),t()}});return Ts(e.apply(void 0,Ne([],Fe(s)))).subscribe(n)}}else t()}function Cs(t,e,s){return void 0===s&&(s=1/0),ze(e)?Cs((function(s,i){return _s((function(t,n){return e(s,t,i,n)}))(Ts(t(s,i)))}),s):("number"==typeof e&&(s=e),vs((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()},f=function(t){return h<i?p(t):c.push(t)},p=function(t){h++;var n=!1;Ts(s(t,u++)).subscribe(ws(e,(function(t){e.next(t)}),(function(){n=!0}),void 0,(function(){if(n)try{h--;for(var t=function(){var t=c.shift();p(t)};c.length&&h<i;)t();d()}catch(t){e.error(t)}})))};return t.subscribe(ws(e,f,(function(){l=!0,d()}))),function(){}}(e,i,t,s)})))}function js(t,e){return t===e}class Bs{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()))}}const Ps=(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=>Ps(t,e,s)));return-1!==e&&(i.splice(e,1),!0)}))}{let i=!0;for(let n=0;n<t.length;n++)if(!Ps(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=Ps(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},Ds=t=>JSON.parse(JSON.stringify(t)),Fs=(t,e)=>{const{origWidth:s,origHeight:i}=e,n=t.points.map((([t,e])=>[t*s/100,e*i/100]));return{...t,points:n}},Ns=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]}},Ms=(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=Fs(s,t);if(e.isPrivacyMask){if(Is(a,e.points)){c=!1;break}}else"include"===e.filter?"contain"===e.type?Is(a,e.points)&&(c=!0):"intersect"===e.type&&(zs(a,e.points)||Is(a,e.points))&&(c=!0):"exclude"===e.filter&&("contain"===e.type?Is(a,e.points)||(c=!0):"intersect"===e.type&&(zs(a,e.points)||Is(a,e.points)||(c=!0)))}return c},zs=(t,e)=>{const s=qs(t);for(const t of s)for(let s=0;s<e.length;s++){const i=[e[s],e[(s+1)%e.length]];if(Us(t,i))return!0}return!1},Is=(t,e)=>[[t.xmin,t.ymin],[t.xmax,t.ymin],[t.xmax,t.ymax],[t.xmin,t.ymax]].every((t=>Vs(t,e))),qs=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]]]},Us=(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},Vs=(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 Ws extends Bs{logger;snapshotCache=new Ce({max:100,ttl:3e5});cameraSubject;cameraState=new ms(!1);lightState=new ms(this.getLightState({state:!1},!0));motionState=new ms(this.getMotionState({detections:[],state:!1},!0));audioState=new ms(this.getAudioState({state:!1,db:0},!0));objectState=new ms(this.getObjectState({detections:[]},!0));doorbellState=new ms(this.getDoorbellState({state:!1},!0));sirenState=new ms(this.getSirenState({state:!1,level:0},!0));batteryState=new ms(this.getBatteryState({level:100,charging:!1,lowBattery:!1},!0));prebufferStateSubjects={};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 Ds(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 Ds(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 activityZones(){return Ds(this.cameraSubject.getValue().activityZones)}get activitySettings(){return Ds(this.cameraSubject.getValue().activitySettings)}get frameWorkerSettings(){return Ds(this.cameraSubject.getValue().frameWorkerSettings)}get streamSource(){return this.highResolutionSource||this.midResolutionSource||this.lowResolutionSource}get snapshotSource(){return this.sources.find((t=>t.roles.includes("snapshot")))}get highResolutionSource(){return this.sources.find((t=>t.roles.includes("high-resolution")))}get midResolutionSource(){return this.sources.find((t=>t.roles.includes("mid-resolution")))}get lowResolutionSource(){return this.sources.find((t=>t.roles.includes("low-resolution")))}get ptz(){return this.ptzDelegate}constructor(t,e){super(),this.logger=e,this.cameraSubject=new ms(t),this.updateCamera(t),"native"===t.pluginId&&this.cameraState.next(!0)}getValue(t){switch(t){case"light":return Ds(this.lightState.getValue());case"motion":return Ds(this.motionState.getValue());case"audio":return Ds(this.audioState.getValue());case"object":return Ds(this.objectState.getValue());case"doorbell":return Ds(this.doorbellState.getValue());case"siren":return Ds(this.sirenState.getValue());case"battery":return Ds(this.batteryState.getValue());default:throw new Error(`Unknown state: ${t}`)}}async snapshot(t){const e=this.snapshotSource||this.streamSource,s=e.urls.www.jpegSnapshot,i=this.snapshotCache.get(e._id);if(!t&&i)return i;if(!e.roles.includes("snapshot")&&"native"!==this.cameraObject.pluginId){const t=await this.cameraDelegate.snapshot();return t&&t.byteLength>0&&this.snapshotCache.set(e._id,t),t}const n=await fetch(s);if(!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}onStateChange(t){return this[`${t}State`].pipe(ks(),Es((([e,s])=>"boolean"==typeof e||"boolean"==typeof s?e!==s:this.stateChanged(e,s,t))),_s((([t,e])=>({oldState:t,newState:e}))),Rs({connector:()=>new bs(1)}))}onPropertyChange(t){return this.cameraSubject.pipe(ks(),Cs((([e,s])=>(Array.isArray(t)?t:[t]).map((t=>({property:t,oldData:e[t],newData:s[t]}))))),Es((({oldData:t,newData:e})=>!Ps(t,e,!0))),Rs({connector:()=>new bs(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){this.cameraSubject.next(t);const e=this.cameraSubject.getValue().sources;for(const t in this.prebufferStateSubjects)if(!e.some((e=>e._id===t))){for(const e in this.prebufferStateSubjects[t])this.prebufferStateSubjects[t][e].complete();delete this.prebufferStateSubjects[t]}for(const t of e)this.prebufferStateSubjects[t._id]||(this.prebufferStateSubjects[t._id]={mp4:new ms({state:!1,duration:0}),mpegts:new ms({state:!1,duration:0})})}updateCameraState(t){this.cameraState.next(t)}updatePrebuffer(t,e,s){this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&this.prebufferStateSubjects[t][e].next({state:s.state,url:s.url||void 0,duration:s.duration})}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,s)=>{const i=[];for(const n of t)Ms(Ns(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)Ms(Ns(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}}cameraSourcePrebufferState(t,e){let s={state:!1,duration:0};return this.prebufferStateSubjects[t]&&this.prebufferStateSubjects[t][e]&&(s=this.prebufferStateSubjects[t][e].getValue()),s}createPrebufferStateObservable(t,e){return this.prebufferStateSubjects[t][e].pipe((void 0===i&&(i=us),s=null!=(s=(t,e)=>t.state===e.state&&t.url===e.url)?s:js,vs((function(t,e){var n,r=!0;t.subscribe(ws(e,(function(t){var o=i(t);!r&&s(n,o)||(r=!1,n=o,e.next(t))})))}))),Rs({connector:()=>new bs(1)}));var s,i}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:!Ps(s.detections,i.detections,!0)}if("object"==s){if(!this.hasObjectDetector)return!1;const s=e;return!Ps(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(Rs({connector:()=>new bs(1)}))}}class Hs{}class $s{}class Js{}class Gs extends Hs{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async snapshot(){return this.delegate?this.delegate.snapshot():this._onRequest("snapshot")}_onRequest(t,e,s){return this.onRequest("cameraDelegate",t,e,s)}}class Ks extends $s{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}async getStreamInfo(t){return this.delegate?this.delegate.getStreamInfo(t):this._onRequest("prebufferDelegate","getStreamInfo",[t])}async updatePrebufferState(t,e,s){return this._onRequest("cameraFn","updatePrebufferState",[t,e,s],0)}_onRequest(t,e,s,i){return this.onRequest(t,e,s,i)}}class Ys extends Js{delegate;onRequest;logger;constructor(t,e){super(),this.onRequest=t,this.logger=e}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 Xs=()=>"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 Qs extends EventTarget{cameraDevice;socketService;logger;options;videoPlayer;socket;streamId;hasBackchannel=!1;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;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=Xs(),this.createCodecsList()}connect(t){t&&(this.options.mode=t),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(){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){this.dispatchEvent(new Event("reconnect")),this.close(),await new Promise((t=>setTimeout(t,100))),this.connect(t)}reset(){this._finishLoading=!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=""}close(){this.closed=!0,this.reset(),this.disconnect(),this.socket.emit("end"),this.socket.removeAllListeners()}onWsOpen({id:t}){if(t===this.streamId)switch(this.options.mode){case"webrtc":case"webrtc/tcp":this.requestWebrtc();break;case"mse":this.requestMse();break;case"hls":this.requestHls();break;case"mp4":this.requestMp4();break;case"mjpeg":this.requestMjpeg();break;default: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}))}}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("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.finishLoading(),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))}));const t=await this.createOffer();t&&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":await(this.pc?.setRemoteDescription({type:"answer",sdp:t.value}));break;case"error":if(t.value.indexOf("webrtc/offer")<0)return;this.pc?.close()}}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:t,message:t.message}))}}async createOffer(){if(this.pc){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();return await this.pc.setLocalDescription(t),t}}requestMse(){if(this.reset(),"ManagedMediaSource"in window){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 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.finishLoading(),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.finishLoading()}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();this.socket.emit("stream-payload",{id:this.streamId,data:{type:"mp4",value:s}})}onMp4Buffer(t){this.finishLoading(),this.videoPlayerMp4&&(this.videoPlayerMp4.src="data:video/mp4;base64,"+this.btoaBinary(t.value))}requestHls(){this.reset(),this.socket.emit("stream-payload",{id:this.streamId,data:{type:"hls",value:this.parseCodecs((t=>this.videoPlayer.canPlayType(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.finishLoading(),this.play()}onStreamInfo(t){const e=t.value;e?.producers?.length&&(this.hasBackchannel=e.producers.some((t=>t.senders?.length)))}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)}}finishLoading(){this._finishLoading||(this._finishLoading=!0,this.dispatchEvent(new Event("finishLoading")))}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 Zs extends Ws{socketService;socket;pluginName="@camera.ui/client";subject;_started=!1;get started(){return this._started}cameraDelegate=new Gs(this.onRequest.bind(this),this.logger);ptzDelegate=new Ys(this.onRequest.bind(this),this.logger);prebufferDelegate=new Ks(this.onRequest.bind(this),this.logger);get sources(){return JSON.parse(JSON.stringify(this.cameraSubject.getValue().sources)).map((t=>({...t,updatePrebufferingState:async()=>{throw new Error("Not available in client")},getPrebufferingState:e=>super.cameraSourcePrebufferState(t._id,e),onPrebuffering:e=>super.createPrebufferStateObservable(t._id,e),getStreamInfo:async()=>this.prebufferDelegate.getStreamInfo(t.name)})))}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 Qs(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);for(const[e,s]of Object.entries(t.prebufferStates))super.updatePrebuffer(e,"mp4",s.mp4),super.updatePrebuffer(e,"mpegts",s.mpegts)}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);break;case"prebufferState":super.updatePrebuffer(t.data.sourceId,t.data.container,t.data.state)}}))}onRequest(t,e,s=[]){const i={requestId:Xs(),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 ti{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 getServerAddresses(){return this.onRequest("getServerAddresses")}async getIceServers(){return this.onRequest("getIceServers")}onRequest(t,e){const s={requestId:Xs(),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 ei{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 Zs(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 Zs(e,this.socketService,this.logger);return await t.refreshStates(),t}}onRequest(t,e){const s={requestId:Xs(),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 si=Object.create(null);si.open="0",si.close="1",si.ping="2",si.pong="3",si.message="4",si.upgrade="5",si.noop="6";const ii=Object.create(null);Object.keys(si).forEach((t=>{ii[si[t]]=t}));const ni={type:"error",data:"parser error"},ri="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),oi="function"==typeof ArrayBuffer,ai=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,ci=({type:t,data:e},s,i)=>ri&&e instanceof Blob?s?i(e):hi(e,i):oi&&(e instanceof ArrayBuffer||ai(e))?s?i(e):hi(new Blob([e]),i):i(si[t]+(e||"")),hi=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function ui(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let li;const di="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)di["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const fi="function"==typeof ArrayBuffer,pi=(t,e)=>{if("string"!=typeof t)return{type:"message",data:mi(t,e)};const s=t.charAt(0);return"b"===s?{type:"message",data:gi(t.substring(1),e)}:ii[s]?t.length>1?{type:ii[s],data:t.substring(1)}:{type:ii[s]}:ni},gi=(t,e)=>{if(fi){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=di[t.charCodeAt(e)],i=di[t.charCodeAt(e+1)],n=di[t.charCodeAt(e+2)],r=di[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 mi(s,e)}return{base64:!0,data:t}},mi=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,yi=String.fromCharCode(30);let bi;function vi(t){return t.reduce(((t,e)=>t+e.length),0)}function wi(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 Si(t){if(t)return function(t){for(var e in Si.prototype)t[e]=Si.prototype[e];return t}(t)}Si.prototype.on=Si.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},Si.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},Si.prototype.off=Si.prototype.removeListener=Si.prototype.removeAllListeners=Si.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},Si.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},Si.prototype.emitReserved=Si.prototype.emit,Si.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},Si.prototype.hasListeners=function(t){return!!this.listeners(t).length};const ki="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Ei(t,...e){return e.reduce(((e,s)=>(t.hasOwnProperty(s)&&(e[s]=t[s]),e)),{})}const _i=ki.setTimeout,Oi=ki.clearTimeout;function xi(t,e){e.useNativeTimers?(t.setTimeoutFn=_i.bind(ki),t.clearTimeoutFn=Oi.bind(ki)):(t.setTimeoutFn=ki.setTimeout.bind(ki),t.clearTimeoutFn=ki.clearTimeout.bind(ki))}class Ti extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class Ai extends Si{constructor(t){super(),this.writable=!1,xi(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,s){return super.emitReserved("error",new Ti(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=pi(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:""}}const Ri="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Li=64,Ci={};let ji,Bi=0,Pi=0;function Di(t){let e="";do{e=Ri[t%Li]+e,t=Math.floor(t/Li)}while(t>0);return e}function Fi(){const t=Di(+new Date);return t!==ji?(Bi=0,ji=t):t+"."+Di(Bi++)}for(;Pi<Li;Pi++)Ci[Ri[Pi]]=Pi;let Ni=!1;try{Ni="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const Mi=Ni;function zi(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||Mi))return new XMLHttpRequest}catch(t){}if(!e)try{return new(ki[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function Ii(){}const qi=null!=new zi({xdomain:!1}).responseType;class Ui extends Si{constructor(t,e){super(),xi(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var t;const e=Ei(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const s=this.xhr=new zi(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)),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=Ui.requestsCount++,Ui.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=Ii,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete Ui.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 Vi(){for(let t in Ui.requests)Ui.requests.hasOwnProperty(t)&&Ui.requests[t].abort()}Ui.requestsCount=0,Ui.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Vi):"function"==typeof addEventListener&&addEventListener("onpagehide"in ki?"pagehide":"unload",Vi,!1));const Wi="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Hi=ki.WebSocket||ki.MozWebSocket,$i="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),Ji={websocket:class extends Ai{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,s=$i?{}:Ei(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=$i?new Hi(t,e,s):e?new Hi(t,e):new Hi(t)}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;ci(s,this.supportsBinary,(t=>{try{this.ws.send(t)}catch(t){}i&&Wi((()=>{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]=Fi()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!Hi}},webtransport:class extends Ai{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),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){bi||(bi=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(vi(s)<1)break;const t=wi(s,1);r=!(128&~t[0]),n=127&t[0],i=n<126?3:126===n?1:2}else if(1===i){if(vi(s)<2)break;const t=wi(s,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),i=3}else if(2===i){if(vi(s)<8)break;const t=wi(s,8),e=new DataView(t.buffer,t.byteOffset,t.length),r=e.getUint32(0);if(r>Math.pow(2,21)-1){a.enqueue(ni);break}n=r*Math.pow(2,32)+e.getUint32(4),i=3}else{if(vi(s)<n)break;const t=wi(s,n);a.enqueue(pi(r?t:bi.decode(t),e)),i=0}if(0===n||n>t){a.enqueue(ni);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),i=new TransformStream({transform(t,e){!function(t,e){ri&&t.data instanceof Blob?t.data.arrayBuffer().then(ui).then(e):oi&&(t.data instanceof ArrayBuffer||ai(t.data))?e(ui(t.data)):ci(t,!1,(t=>{li||(li=new TextEncoder),e(li.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&&Wi((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends Ai{constructor(t){if(super(t),this.polling=!1,"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}const e=t&&t.forceBase64;this.supportsBinary=qi&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}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(yi),i=[];for(let t=0;t<s.length;t++){const n=pi(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)=>{ci(t,!1,(t=>{i[r]=t,++n===s&&e(i.join(yi))}))}))})(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]=Fi()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ui(this.uri(),t)}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}}},Gi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ki=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Yi(t){if(t.length>2e3)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=Gi.exec(t||""),r={},o=14;for(;o--;)r[Ki[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}class Xi extends Si{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=Yi(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=Yi(e.host).host),xi(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=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"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)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(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"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new Ji[t](s)}open(){let t;if(this.opts.rememberUpgrade&&Xi.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),s=!1;Xi.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;Xi.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()}onOpen(){if(this.readyState="open",Xi.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,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}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){Xi.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const i=t.length;for(;s<i;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}Xi.protocol=4,Xi.protocol;const Qi="function"==typeof ArrayBuffer,Zi=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,tn=Object.prototype.toString,en="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===tn.call(Blob),sn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===tn.call(File);function nn(t){return Qi&&(t instanceof ArrayBuffer||Zi(t))||en&&t instanceof Blob||sn&&t instanceof File}function rn(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,s=t.length;e<s;e++)if(rn(t[e]))return!0;return!1}if(nn(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return rn(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&rn(t[e]))return!0;return!1}function on(t){const e=[],s=t.data,i=t;return i.data=an(s,e),i.attachments=e.length,{packet:i,buffers:e}}function an(t,e){if(!t)return t;if(nn(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]=an(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]=an(t[i],e));return s}return t}function cn(t,e){return t.data=hn(t.data,e),delete t.attachments,t}function hn(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]=hn(t[s],e);else if("object"==typeof t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(t[s]=hn(t[s],e));return t}const un=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],ln=5;var dn;!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"}(dn||(dn={}));class fn{constructor(t){this.replacer=t}encode(t){return t.type!==dn.EVENT&&t.type!==dn.ACK||!rn(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===dn.EVENT?dn.BINARY_EVENT:dn.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==dn.BINARY_EVENT&&t.type!==dn.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=on(t),s=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(s),i}}function pn(t){return"[object Object]"===Object.prototype.toString.call(t)}class gn extends Si{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===dn.BINARY_EVENT;s||e.type===dn.BINARY_ACK?(e.type=s?dn.EVENT:dn.ACK,this.reconstructor=new mn(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!nn(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===dn[s.type])throw new Error("unknown packet type "+s.type);if(s.type===dn.BINARY_EVENT||s.type===dn.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(!gn.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 dn.CONNECT:return pn(e);case dn.DISCONNECT:return void 0===e;case dn.CONNECT_ERROR:return"string"==typeof e||pn(e);case dn.EVENT:case dn.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===un.indexOf(e[0]));case dn.ACK:case dn.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mn{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=cn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function yn(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const bn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class vn extends Si{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=[yn(t,"open",this.onopen.bind(this)),yn(t,"packet",this.onpacket.bind(this)),yn(t,"error",this.onerror.bind(this)),yn(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){if(bn.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const s={type:dn.EVENT,data:e,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,i=e.pop();this._registerAckCallback(t,i),s.id=t}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),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:dn.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 dn.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 dn.EVENT:case dn.BINARY_EVENT:this.onevent(t);break;case dn.ACK:case dn.BINARY_ACK:this.onack(t);break;case dn.DISCONNECT:this.ondisconnect();break;case dn.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:dn.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:dn.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 wn(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}wn.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)},wn.prototype.reset=function(){this.attempts=0},wn.prototype.setMin=function(t){this.ms=t},wn.prototype.setMax=function(t){this.max=t},wn.prototype.setJitter=function(t){this.jitter=t};class Sn extends Si{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,xi(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 wn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||i;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,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 Xi(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=yn(e,"open",(function(){s.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},r=yn(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(yn(t,"ping",this.onping.bind(this)),yn(t,"data",this.ondata.bind(this)),yn(t,"error",this.onerror.bind(this)),yn(t,"close",this.onclose.bind(this)),yn(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){Wi((()=>{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 vn(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"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((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 kn={};function En(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=Yi(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=kn[n]&&r in kn[n].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?a=new Sn(i,e):(kn[n]||(kn[n]=new Sn(i,e)),a=kn[n]),s.query&&!e.query&&(e.query=s.queryKey),a.socket(s.path,e)}Object.assign(En,{Manager:Sn,Socket:vn,io:En,connect:En});class _n{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.socketList.has(t)||this.socketList.set(t,this.createManager(e)),this.socketList.get(t)}createManager(t){const e=new Sn(this.endpoint,{reconnection:!0,reconnectionDelay:500,rejectUnauthorized:!1,transports:["websocket"],forceNew:t}),s=e.socket("/proxy",{auth:{token:`Bearer ${this.token}`}});return{manager:e,socket:s}}}class On{api;socketService;config;logger;token;deviceManager;coreManager;constructor(t){this.config=t,this.logger=t.logger||{...console,attention:console.warn},this.api=new we(t.endpoint)}async connect(){return this.deviceManager&&this.coreManager||(this.cleanUpClient(),await this.login(),this.token=this.token||this.config.token,this.socketService=new _n(this.config.endpoint,this.token),this.coreManager=new ti(this.socketService,this.logger),this.deviceManager=new ei(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.interceptor.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.interceptor.post("/auth/login",{username:this.config.username,password:this.config.password});this.token=t.data.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.interceptor.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 xn=e.j;export{xn as CameraUiClient};