@microblink/capture 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture.js +28 -25
- package/dist/capture.umd.cjs +3 -3
- package/dist/resources/advanced/capture-wasm.js +157 -4029
- package/dist/resources/advanced/capture-wasm.wasm +0 -0
- package/dist/resources/advanced-threads/capture-wasm.js +174 -4473
- package/dist/resources/advanced-threads/capture-wasm.wasm +0 -0
- package/dist/resources/advanced-threads/capture-wasm.worker.js +1 -109
- package/dist/resources/basic/capture-wasm.js +157 -4026
- package/dist/resources/basic/capture-wasm.wasm +0 -0
- package/dist/resources/capture-worker.js +2 -2
- package/microblink-capture-1.1.1.tgz +0 -0
- package/package.json +1 -1
package/dist/capture.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
typeof HTMLVideoElement < "u" && !("requestVideoFrameCallback" in HTMLVideoElement.prototype) && "getVideoPlaybackQuality" in HTMLVideoElement.prototype && (HTMLVideoElement.prototype._rvfcpolyfillmap = {}, HTMLVideoElement.prototype.requestVideoFrameCallback = function(e) {
|
|
2
|
+
const t = performance.now(), n = this.getVideoPlaybackQuality(), i = this.mozPresentedFrames || this.mozPaintedFrames || n.totalVideoFrames - n.droppedVideoFrames, r = (o, s) => {
|
|
3
|
+
const a = this.getVideoPlaybackQuality(), c = this.mozPresentedFrames || this.mozPaintedFrames || a.totalVideoFrames - a.droppedVideoFrames;
|
|
4
|
+
if (c > i) {
|
|
5
|
+
const u = this.mozFrameDelay || a.totalFrameDelay - n.totalFrameDelay || 0, l = s - o;
|
|
6
|
+
e(s, {
|
|
7
|
+
presentationTime: s + u * 1e3,
|
|
8
|
+
expectedDisplayTime: s + l,
|
|
9
|
+
width: this.videoWidth,
|
|
10
|
+
height: this.videoHeight,
|
|
11
|
+
mediaTime: Math.max(0, this.currentTime || 0) + l / 1e3,
|
|
12
|
+
presentedFrames: c,
|
|
13
|
+
processingDuration: u
|
|
14
|
+
}), delete this._rvfcpolyfillmap[t];
|
|
15
|
+
} else
|
|
16
|
+
this._rvfcpolyfillmap[t] = requestAnimationFrame((u) => r(s, u));
|
|
17
|
+
};
|
|
18
|
+
return this._rvfcpolyfillmap[t] = requestAnimationFrame((o) => r(t, o)), t;
|
|
19
|
+
}, HTMLVideoElement.prototype.cancelVideoFrameCallback = function(e) {
|
|
20
|
+
cancelAnimationFrame(this._rvfcpolyfillmap[e]), delete this._rvfcpolyfillmap[e];
|
|
21
|
+
});
|
|
1
22
|
/**
|
|
2
23
|
* @license
|
|
3
24
|
* Copyright 2019 Google LLC
|
|
@@ -236,27 +257,6 @@ function xu() {
|
|
|
236
257
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
237
258
|
}
|
|
238
259
|
var fa = /* @__PURE__ */ ((e) => (e[e.Invalid = 0] = "Invalid", e[e.RequiresServerPermission = 1] = "RequiresServerPermission", e[e.Valid = 2] = "Valid", e))(fa || {}), da = /* @__PURE__ */ ((e) => (e[e.Ok = 0] = "Ok", e[e.NetworkError = 1] = "NetworkError", e[e.RemoteLock = 2] = "RemoteLock", e[e.PermissionExpired = 3] = "PermissionExpired", e[e.PayloadCorrupted = 4] = "PayloadCorrupted", e[e.PayloadSignatureVerificationFailed = 5] = "PayloadSignatureVerificationFailed", e[e.IncorrectTokenState = 6] = "IncorrectTokenState", e))(da || {});
|
|
239
|
-
typeof HTMLVideoElement < "u" && !("requestVideoFrameCallback" in HTMLVideoElement.prototype) && "getVideoPlaybackQuality" in HTMLVideoElement.prototype && (HTMLVideoElement.prototype._rvfcpolyfillmap = {}, HTMLVideoElement.prototype.requestVideoFrameCallback = function(e) {
|
|
240
|
-
const t = performance.now(), n = this.getVideoPlaybackQuality(), i = this.mozPresentedFrames || this.mozPaintedFrames || n.totalVideoFrames - n.droppedVideoFrames, r = (o, s) => {
|
|
241
|
-
const a = this.getVideoPlaybackQuality(), c = this.mozPresentedFrames || this.mozPaintedFrames || a.totalVideoFrames - a.droppedVideoFrames;
|
|
242
|
-
if (c > i) {
|
|
243
|
-
const u = this.mozFrameDelay || a.totalFrameDelay - n.totalFrameDelay || 0, l = s - o;
|
|
244
|
-
e(s, {
|
|
245
|
-
presentationTime: s + u * 1e3,
|
|
246
|
-
expectedDisplayTime: s + l,
|
|
247
|
-
width: this.videoWidth,
|
|
248
|
-
height: this.videoHeight,
|
|
249
|
-
mediaTime: Math.max(0, this.currentTime || 0) + l / 1e3,
|
|
250
|
-
presentedFrames: c,
|
|
251
|
-
processingDuration: u
|
|
252
|
-
}), delete this._rvfcpolyfillmap[t];
|
|
253
|
-
} else
|
|
254
|
-
this._rvfcpolyfillmap[t] = requestAnimationFrame((u) => r(s, u));
|
|
255
|
-
};
|
|
256
|
-
return this._rvfcpolyfillmap[t] = requestAnimationFrame((o) => r(t, o)), t;
|
|
257
|
-
}, HTMLVideoElement.prototype.cancelVideoFrameCallback = function(e) {
|
|
258
|
-
cancelAnimationFrame(this._rvfcpolyfillmap[e]), delete this._rvfcpolyfillmap[e];
|
|
259
|
-
});
|
|
260
260
|
const ko = Element.prototype.attachShadow;
|
|
261
261
|
function Zr() {
|
|
262
262
|
return typeof window.ShadyDOM < "u" && typeof ShadowRoot < "u";
|
|
@@ -1933,10 +1933,13 @@ const Ro = "application/javascript", rl = (e, t = {}) => {
|
|
|
1933
1933
|
const _fixImports = (url) => new URL(url, '${s.join("/") + "/"}').href;
|
|
1934
1934
|
importScripts = (...urls) => _importScripts(...urls.map(_fixImports));
|
|
1935
1935
|
`;
|
|
1936
|
-
let c =
|
|
1937
|
-
n.useBlob
|
|
1938
|
-
new Blob([
|
|
1939
|
-
|
|
1936
|
+
let c = "";
|
|
1937
|
+
if (n.useBlob) {
|
|
1938
|
+
const u = new Blob([a + o], { type: Ro });
|
|
1939
|
+
c = URL.createObjectURL(u);
|
|
1940
|
+
} else
|
|
1941
|
+
c = `data:${Ro},` + encodeURIComponent(a + o);
|
|
1942
|
+
i(c);
|
|
1940
1943
|
}).catch(r)
|
|
1941
1944
|
);
|
|
1942
1945
|
}, ol = async (e = window.location.href) => {
|
package/dist/capture.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(Ne,Gt){typeof exports=="object"&&typeof module<"u"?Gt(exports):typeof define=="function"&&define.amd?define(["exports"],Gt):(Ne=typeof globalThis<"u"?globalThis:Ne||self,Gt(Ne.capture={}))})(this,function(Ne){"use strict";/**
|
|
1
|
+
(function(Ne,Gt){typeof exports=="object"&&typeof module<"u"?Gt(exports):typeof define=="function"&&define.amd?define(["exports"],Gt):(Ne=typeof globalThis<"u"?globalThis:Ne||self,Gt(Ne.capture={}))})(this,function(Ne){"use strict";typeof HTMLVideoElement<"u"&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){const t=performance.now(),n=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||n.totalVideoFrames-n.droppedVideoFrames,r=(o,s)=>{const a=this.getVideoPlaybackQuality(),c=this.mozPresentedFrames||this.mozPaintedFrames||a.totalVideoFrames-a.droppedVideoFrames;if(c>i){const u=this.mozFrameDelay||a.totalFrameDelay-n.totalFrameDelay||0,l=s-o;e(s,{presentationTime:s+u*1e3,expectedDisplayTime:s+l,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+l/1e3,presentedFrames:c,processingDuration:u}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(u=>r(s,u))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(o=>r(t,o)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/const Gt=Symbol("Comlink.proxy"),Tu=Symbol("Comlink.endpoint"),Lu=Symbol("Comlink.releaseProxy"),Qi=Symbol("Comlink.finalizer"),$n=Symbol("Comlink.thrown"),Yo=e=>typeof e=="object"&&e!==null||typeof e=="function",ju={canHandle:e=>Yo(e)&&e[Gt],serialize(e){const{port1:t,port2:n}=new MessageChannel;return Ro(e,t),[n,[n]]},deserialize(e){return e.start(),Bo(e)}},Au={canHandle:e=>Yo(e)&&$n in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},Po=new Map([["proxy",ju],["throw",Au]]);function Eu(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function Ro(e,t=globalThis,n=["*"]){t.addEventListener("message",function i(r){if(!r||!r.data)return;if(!Eu(n,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}const{id:o,type:s,path:a}=Object.assign({path:[]},r.data),c=(r.data.argumentList||[]).map(Ot);let u;try{const l=a.slice(0,-1).reduce((f,h)=>f[h],e),g=a.reduce((f,h)=>f[h],e);switch(s){case"GET":u=g;break;case"SET":l[a.slice(-1)[0]]=Ot(r.data.value),u=!0;break;case"APPLY":u=g.apply(l,c);break;case"CONSTRUCT":{const f=new g(...c);u=xu(f)}break;case"ENDPOINT":{const{port1:f,port2:h}=new MessageChannel;Ro(e,h),u=Vo(f,[f])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[$n]:0}}Promise.resolve(u).catch(l=>({value:l,[$n]:0})).then(l=>{const[g,f]=Xn(l);t.postMessage(Object.assign(Object.assign({},g),{id:o}),f),s==="RELEASE"&&(t.removeEventListener("message",i),Fo(t),Qi in e&&typeof e[Qi]=="function"&&e[Qi]())}).catch(l=>{const[g,f]=Xn({value:new TypeError("Unserializable return value"),[$n]:0});t.postMessage(Object.assign(Object.assign({},g),{id:o}),f)})}),t.start&&t.start()}function Su(e){return e.constructor.name==="MessagePort"}function Fo(e){Su(e)&&e.close()}function Bo(e,t){return Gi(e,[],t)}function Wn(e){if(e)throw new Error("Proxy has been released and is not useable")}function Ho(e){return Vt(e,{type:"RELEASE"}).then(()=>{Fo(e)})}const Zn=new WeakMap,qn="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(Zn.get(e)||0)-1;Zn.set(e,t),t===0&&Ho(e)});function pu(e,t){const n=(Zn.get(t)||0)+1;Zn.set(t,n),qn&&qn.register(e,t,e)}function Iu(e){qn&&qn.unregister(e)}function Gi(e,t=[],n=function(){}){let i=!1;const r=new Proxy(n,{get(o,s){if(Wn(i),s===Lu)return()=>{Iu(r),Ho(e),i=!0};if(s==="then"){if(t.length===0)return{then:()=>r};const a=Vt(e,{type:"GET",path:t.map(c=>c.toString())}).then(Ot);return a.then.bind(a)}return Gi(e,[...t,s])},set(o,s,a){Wn(i);const[c,u]=Xn(a);return Vt(e,{type:"SET",path:[...t,s].map(l=>l.toString()),value:c},u).then(Ot)},apply(o,s,a){Wn(i);const c=t[t.length-1];if(c===Tu)return Vt(e,{type:"ENDPOINT"}).then(Ot);if(c==="bind")return Gi(e,t.slice(0,-1));const[u,l]=Qo(a);return Vt(e,{type:"APPLY",path:t.map(g=>g.toString()),argumentList:u},l).then(Ot)},construct(o,s){Wn(i);const[a,c]=Qo(s);return Vt(e,{type:"CONSTRUCT",path:t.map(u=>u.toString()),argumentList:a},c).then(Ot)}});return pu(r,e),r}function wu(e){return Array.prototype.concat.apply([],e)}function Qo(e){const t=e.map(Xn);return[t.map(n=>n[0]),wu(t.map(n=>n[1]))]}const Go=new WeakMap;function Vo(e,t){return Go.set(e,t),e}function xu(e){return Object.assign(e,{[Gt]:!0})}function Xn(e){for(const[t,n]of Po)if(n.canHandle(e)){const[i,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},r]}return[{type:"RAW",value:e},Go.get(e)||[]]}function Ot(e){switch(e.type){case"HANDLER":return Po.get(e.name).deserialize(e.value);case"RAW":return e.value}}function Vt(e,t,n){return new Promise(i=>{const r=Du();e.addEventListener("message",function o(s){!s.data||!s.data.id||s.data.id!==r||(e.removeEventListener("message",o),i(s.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:r},t),n)})}function Du(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Vi=(e=>(e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid",e))(Vi||{}),Ki=(e=>(e[e.Ok=0]="Ok",e[e.NetworkError=1]="NetworkError",e[e.RemoteLock=2]="RemoteLock",e[e.PermissionExpired=3]="PermissionExpired",e[e.PayloadCorrupted=4]="PayloadCorrupted",e[e.PayloadSignatureVerificationFailed=5]="PayloadSignatureVerificationFailed",e[e.IncorrectTokenState=6]="IncorrectTokenState",e))(Ki||{});typeof HTMLVideoElement<"u"&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){const t=performance.now(),n=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||n.totalVideoFrames-n.droppedVideoFrames,r=(o,s)=>{const a=this.getVideoPlaybackQuality(),c=this.mozPresentedFrames||this.mozPaintedFrames||a.totalVideoFrames-a.droppedVideoFrames;if(c>i){const u=this.mozFrameDelay||a.totalFrameDelay-n.totalFrameDelay||0,l=s-o;e(s,{presentationTime:s+u*1e3,expectedDisplayTime:s+l,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+l/1e3,presentedFrames:c,processingDuration:u}),delete this._rvfcpolyfillmap[t]}else this._rvfcpolyfillmap[t]=requestAnimationFrame(u=>r(s,u))};return this._rvfcpolyfillmap[t]=requestAnimationFrame(o=>r(t,o)),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});const Ko=Element.prototype.attachShadow;function $i(){return typeof window.ShadyDOM<"u"&&typeof ShadowRoot<"u"}function bu(){return typeof ShadowRoot<"u"}function vu(e){Ko==null||$i()||(Element.prototype.attachShadow=function(t){const n=Ko.call(this,t);return e(n),n})}function Ou(e,...t){const n=new Set(t);let i=!1;const r=()=>{for(const o of n)e(o);n.clear()};return{isRunning(){return i},schedule(o){n.add(o),i&&r()},stop(){i=!1},run(){i||(i=!0,r())}}}const Cu={childList:!0,subtree:!0},zu=e=>{typeof queueMicrotask<"u"?queueMicrotask(e):typeof Promise<"u"?Promise.resolve().then(()=>e()):setTimeout(()=>e(),0)};function $o(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null)return[...e];{const t=[];for(let n=0;n<e.length;n++)t[n]=e[n];return t}}function _u(e,t){return $i()?new Set($o(window.ShadyDOM.nativeMethods.querySelectorAll.call(document.documentElement,t))):new Set("querySelectorAll"in e?$o(e.querySelectorAll(t)):[])}function ku(e,t){return new Set([...e??[],...t??[]])}function Uu(e){return"activeElement"in e}function Wo(e=document.documentElement){if(Uu(e)&&Zo(e),$i()&&e instanceof ShadowRoot||!bu())return;const t=e.childNodes,n="shadowRoot"in e&&e.shadowRoot!=null?[e.shadowRoot]:[];for(const i of[...t,...n])Wo(i)}function Yu(e){return"isConnected"in Node.prototype?e.isConnected:e.ownerDocument==null||!(e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED)}const An=new Map;function Pu(e,t){const n=new Set,i=new Set,r=new Map,o=new WeakMap;let s=!1,a=!1,c=!1;const u=()=>{a=!0;const T=[...n];T.length>0&&t(T,e),n.clear(),s=!1,a=!1},l=()=>{s||(s=!0,zu(u))},g=T=>{n.add(T),a||l()},f=()=>{const T=[...n];return n.clear(),T},h=()=>{i.clear()},d=(T,N)=>{let j=r.get(T);const A=_u(T,N),E=j?.get(N),S=ku(A,E);M(S),j==null&&(j=new Map,r.set(T,j)),j.set(N,A)},M=T=>{for(const N of T){const j=o.get(N),A=Yu(N);j!==A&&(o.set(N,A),g({connected:A,target:N}))}},m={observedTargets:i,queryRootAndHandleMutationChanges:d,handleMutationChange:M,addObservedTarget:T=>{if(Zi.run(),c||(c=!0,Wo()),i.add(T),typeof T!="string")M([T]);else for(const N of Wi)d(N,T)},clearObservedTargets:h,clearQueue:f};An.set(e,m)}const Ru=e=>{for(const t of e)if(t.type==="childList")for(const n of An.values())for(const i of n.observedTargets)typeof i=="string"?n.queryRootAndHandleMutationChanges(t.target,i):n.handleMutationChange([i])},Wi=new Set,Zo=(()=>{let e;return function(t){Wi.has(t)||(Wi.add(t),e==null&&(e=new MutationObserver(Ru)),e.observe(t,Cu))}})(),Zi=Ou(Zo,document.documentElement);class Ct{constructor(t){if(new.target===void 0)throw new TypeError(`Constructor ${Ct.name} requires 'new'`);if(t===void 0)throw new ReferenceError(`Failed to construct '${Ct.name}': 1 argument required, but only 0 present.`);if(typeof t!="function")throw new TypeError(`Failed to construct '${Ct.name}': The callback provided as parameter 1 is not a function.`);Pu(this,t)}get[Symbol.toStringTag](){return"ConnectionObserver"}observe(t){if(t===void 0)throw new ReferenceError(`Failed to execute '${this.observe.name}' on '${Ct.name}': 1 argument required, but only 0 present.`);if(typeof t!="string"&&!(t instanceof Node))throw new TypeError(`Failed to execute '${this.observe.name}' on '${Ct.name}': parameter 1 is not of type 'Node' or a DOMString.`);const n=An.get(this);n?.addObservedTarget(t)}takeRecords(){const t=An.get(this);return t==null?[]:t.clearQueue()}disconnect(){const t=An.get(this);t?.clearObservedTargets()}}vu(Zi.schedule.bind(Zi));var Fu=function(){function e(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),Bu=Hu(["",""],["",""]);function Hu(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Qu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var we=function(){function e(){for(var t=this,n=arguments.length,i=Array(n),r=0;r<n;r++)i[r]=arguments[r];return Qu(this,e),this.tag=function(o){for(var s=arguments.length,a=Array(s>1?s-1:0),c=1;c<s;c++)a[c-1]=arguments[c];return typeof o=="function"?t.interimTag.bind(t,o):typeof o=="string"?t.transformEndResult(o):(o=o.map(t.transformString.bind(t)),t.transformEndResult(o.reduce(t.processSubstitutions.bind(t,a))))},i.length>0&&Array.isArray(i[0])&&(i=i[0]),this.transformers=i.map(function(o){return typeof o=="function"?o():o}),this.tag}return Fu(e,[{key:"interimTag",value:function(n,i){for(var r=arguments.length,o=Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return this.tag(Bu,n.apply(void 0,[i].concat(o)))}},{key:"processSubstitutions",value:function(n,i,r){var o=this.transformSubstitution(n.shift(),i);return"".concat(i,o,r)}},{key:"transformString",value:function(n){var i=function(o,s){return s.onString?s.onString(o):o};return this.transformers.reduce(i,n)}},{key:"transformSubstitution",value:function(n,i){var r=function(s,a){return a.onSubstitution?a.onSubstitution(s,i):s};return this.transformers.reduce(r,n)}},{key:"transformEndResult",value:function(n){var i=function(o,s){return s.onEndResult?s.onEndResult(o):o};return this.transformers.reduce(i,n)}}]),e}(),xe=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return{onEndResult:function(i){if(t==="")return i.trim();if(t=t.toLowerCase(),t==="start"||t==="left")return i.replace(/^\s*/,"");if(t==="end"||t==="right")return i.replace(/\s*$/,"");throw new Error("Side not supported: "+t)}}};function Gu(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}var mt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"initial";return{onEndResult:function(i){if(t==="initial"){var r=i.match(/^[^\S\n]*(?=\S)/gm),o=r&&Math.min.apply(Math,Gu(r.map(function(a){return a.length})));if(o){var s=new RegExp("^.{"+o+"}","gm");return i.replace(s,"")}return i}if(t==="all")return i.replace(/^[^\S\n]+/gm,"");throw new Error("Unknown type: "+t)}}},Kt=function(t,n){return{onEndResult:function(r){if(t==null||n==null)throw new Error("replaceResultTransformer requires at least 2 arguments.");return r.replace(t,n)}}},$t=function(t,n){return{onSubstitution:function(r,o){if(t==null||n==null)throw new Error("replaceSubstitutionTransformer requires at least 2 arguments.");return r==null?r:r.toString().replace(t,n)}}},Vu={separator:"",conjunction:"",serial:!1},tt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Vu;return{onSubstitution:function(i,r){if(Array.isArray(i)){var o=i.length,s=t.separator,a=t.conjunction,c=t.serial,u=r.match(/(\n?[^\S\n]+)$/);if(u?i=i.join(s+u[1]):i=i.join(s+" "),a&&o>1){var l=i.lastIndexOf(s);i=i.slice(0,l)+(c?s:"")+" "+a+i.slice(l+1)}}return i}}},qo=function(t){return{onSubstitution:function(i,r){if(t!=null&&typeof t=="string")typeof i=="string"&&i.includes(t)&&(i=i.split(t));else throw new Error("You need to specify a string character to split by.");return i}}},Xo=function(t){return t!=null&&!Number.isNaN(t)&&typeof t!="boolean"},Ku=function(){return{onSubstitution:function(n){return Array.isArray(n)?n.filter(Xo):Xo(n)?n:""}}};new we(tt({separator:","}),mt,xe),new we(tt({separator:",",conjunction:"and"}),mt,xe),new we(tt({separator:",",conjunction:"or"}),mt,xe),new we(qo(`
|
|
5
|
+
*/const Gt=Symbol("Comlink.proxy"),Tu=Symbol("Comlink.endpoint"),Lu=Symbol("Comlink.releaseProxy"),Qi=Symbol("Comlink.finalizer"),$n=Symbol("Comlink.thrown"),Yo=e=>typeof e=="object"&&e!==null||typeof e=="function",ju={canHandle:e=>Yo(e)&&e[Gt],serialize(e){const{port1:t,port2:n}=new MessageChannel;return Ro(e,t),[n,[n]]},deserialize(e){return e.start(),Bo(e)}},Au={canHandle:e=>Yo(e)&&$n in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},Po=new Map([["proxy",ju],["throw",Au]]);function Eu(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function Ro(e,t=globalThis,n=["*"]){t.addEventListener("message",function i(r){if(!r||!r.data)return;if(!Eu(n,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}const{id:o,type:s,path:a}=Object.assign({path:[]},r.data),c=(r.data.argumentList||[]).map(Ot);let u;try{const l=a.slice(0,-1).reduce((f,h)=>f[h],e),g=a.reduce((f,h)=>f[h],e);switch(s){case"GET":u=g;break;case"SET":l[a.slice(-1)[0]]=Ot(r.data.value),u=!0;break;case"APPLY":u=g.apply(l,c);break;case"CONSTRUCT":{const f=new g(...c);u=xu(f)}break;case"ENDPOINT":{const{port1:f,port2:h}=new MessageChannel;Ro(e,h),u=Vo(f,[f])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[$n]:0}}Promise.resolve(u).catch(l=>({value:l,[$n]:0})).then(l=>{const[g,f]=Xn(l);t.postMessage(Object.assign(Object.assign({},g),{id:o}),f),s==="RELEASE"&&(t.removeEventListener("message",i),Fo(t),Qi in e&&typeof e[Qi]=="function"&&e[Qi]())}).catch(l=>{const[g,f]=Xn({value:new TypeError("Unserializable return value"),[$n]:0});t.postMessage(Object.assign(Object.assign({},g),{id:o}),f)})}),t.start&&t.start()}function Su(e){return e.constructor.name==="MessagePort"}function Fo(e){Su(e)&&e.close()}function Bo(e,t){return Gi(e,[],t)}function Wn(e){if(e)throw new Error("Proxy has been released and is not useable")}function Ho(e){return Vt(e,{type:"RELEASE"}).then(()=>{Fo(e)})}const Zn=new WeakMap,qn="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(Zn.get(e)||0)-1;Zn.set(e,t),t===0&&Ho(e)});function pu(e,t){const n=(Zn.get(t)||0)+1;Zn.set(t,n),qn&&qn.register(e,t,e)}function Iu(e){qn&&qn.unregister(e)}function Gi(e,t=[],n=function(){}){let i=!1;const r=new Proxy(n,{get(o,s){if(Wn(i),s===Lu)return()=>{Iu(r),Ho(e),i=!0};if(s==="then"){if(t.length===0)return{then:()=>r};const a=Vt(e,{type:"GET",path:t.map(c=>c.toString())}).then(Ot);return a.then.bind(a)}return Gi(e,[...t,s])},set(o,s,a){Wn(i);const[c,u]=Xn(a);return Vt(e,{type:"SET",path:[...t,s].map(l=>l.toString()),value:c},u).then(Ot)},apply(o,s,a){Wn(i);const c=t[t.length-1];if(c===Tu)return Vt(e,{type:"ENDPOINT"}).then(Ot);if(c==="bind")return Gi(e,t.slice(0,-1));const[u,l]=Qo(a);return Vt(e,{type:"APPLY",path:t.map(g=>g.toString()),argumentList:u},l).then(Ot)},construct(o,s){Wn(i);const[a,c]=Qo(s);return Vt(e,{type:"CONSTRUCT",path:t.map(u=>u.toString()),argumentList:a},c).then(Ot)}});return pu(r,e),r}function wu(e){return Array.prototype.concat.apply([],e)}function Qo(e){const t=e.map(Xn);return[t.map(n=>n[0]),wu(t.map(n=>n[1]))]}const Go=new WeakMap;function Vo(e,t){return Go.set(e,t),e}function xu(e){return Object.assign(e,{[Gt]:!0})}function Xn(e){for(const[t,n]of Po)if(n.canHandle(e)){const[i,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},r]}return[{type:"RAW",value:e},Go.get(e)||[]]}function Ot(e){switch(e.type){case"HANDLER":return Po.get(e.name).deserialize(e.value);case"RAW":return e.value}}function Vt(e,t,n){return new Promise(i=>{const r=Du();e.addEventListener("message",function o(s){!s.data||!s.data.id||s.data.id!==r||(e.removeEventListener("message",o),i(s.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:r},t),n)})}function Du(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Vi=(e=>(e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid",e))(Vi||{}),Ki=(e=>(e[e.Ok=0]="Ok",e[e.NetworkError=1]="NetworkError",e[e.RemoteLock=2]="RemoteLock",e[e.PermissionExpired=3]="PermissionExpired",e[e.PayloadCorrupted=4]="PayloadCorrupted",e[e.PayloadSignatureVerificationFailed=5]="PayloadSignatureVerificationFailed",e[e.IncorrectTokenState=6]="IncorrectTokenState",e))(Ki||{});const Ko=Element.prototype.attachShadow;function $i(){return typeof window.ShadyDOM<"u"&&typeof ShadowRoot<"u"}function bu(){return typeof ShadowRoot<"u"}function vu(e){Ko==null||$i()||(Element.prototype.attachShadow=function(t){const n=Ko.call(this,t);return e(n),n})}function Ou(e,...t){const n=new Set(t);let i=!1;const r=()=>{for(const o of n)e(o);n.clear()};return{isRunning(){return i},schedule(o){n.add(o),i&&r()},stop(){i=!1},run(){i||(i=!0,r())}}}const Cu={childList:!0,subtree:!0},zu=e=>{typeof queueMicrotask<"u"?queueMicrotask(e):typeof Promise<"u"?Promise.resolve().then(()=>e()):setTimeout(()=>e(),0)};function $o(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null)return[...e];{const t=[];for(let n=0;n<e.length;n++)t[n]=e[n];return t}}function _u(e,t){return $i()?new Set($o(window.ShadyDOM.nativeMethods.querySelectorAll.call(document.documentElement,t))):new Set("querySelectorAll"in e?$o(e.querySelectorAll(t)):[])}function ku(e,t){return new Set([...e??[],...t??[]])}function Uu(e){return"activeElement"in e}function Wo(e=document.documentElement){if(Uu(e)&&Zo(e),$i()&&e instanceof ShadowRoot||!bu())return;const t=e.childNodes,n="shadowRoot"in e&&e.shadowRoot!=null?[e.shadowRoot]:[];for(const i of[...t,...n])Wo(i)}function Yu(e){return"isConnected"in Node.prototype?e.isConnected:e.ownerDocument==null||!(e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED)}const An=new Map;function Pu(e,t){const n=new Set,i=new Set,r=new Map,o=new WeakMap;let s=!1,a=!1,c=!1;const u=()=>{a=!0;const T=[...n];T.length>0&&t(T,e),n.clear(),s=!1,a=!1},l=()=>{s||(s=!0,zu(u))},g=T=>{n.add(T),a||l()},f=()=>{const T=[...n];return n.clear(),T},h=()=>{i.clear()},d=(T,N)=>{let j=r.get(T);const A=_u(T,N),E=j?.get(N),S=ku(A,E);M(S),j==null&&(j=new Map,r.set(T,j)),j.set(N,A)},M=T=>{for(const N of T){const j=o.get(N),A=Yu(N);j!==A&&(o.set(N,A),g({connected:A,target:N}))}},m={observedTargets:i,queryRootAndHandleMutationChanges:d,handleMutationChange:M,addObservedTarget:T=>{if(Zi.run(),c||(c=!0,Wo()),i.add(T),typeof T!="string")M([T]);else for(const N of Wi)d(N,T)},clearObservedTargets:h,clearQueue:f};An.set(e,m)}const Ru=e=>{for(const t of e)if(t.type==="childList")for(const n of An.values())for(const i of n.observedTargets)typeof i=="string"?n.queryRootAndHandleMutationChanges(t.target,i):n.handleMutationChange([i])},Wi=new Set,Zo=(()=>{let e;return function(t){Wi.has(t)||(Wi.add(t),e==null&&(e=new MutationObserver(Ru)),e.observe(t,Cu))}})(),Zi=Ou(Zo,document.documentElement);class Ct{constructor(t){if(new.target===void 0)throw new TypeError(`Constructor ${Ct.name} requires 'new'`);if(t===void 0)throw new ReferenceError(`Failed to construct '${Ct.name}': 1 argument required, but only 0 present.`);if(typeof t!="function")throw new TypeError(`Failed to construct '${Ct.name}': The callback provided as parameter 1 is not a function.`);Pu(this,t)}get[Symbol.toStringTag](){return"ConnectionObserver"}observe(t){if(t===void 0)throw new ReferenceError(`Failed to execute '${this.observe.name}' on '${Ct.name}': 1 argument required, but only 0 present.`);if(typeof t!="string"&&!(t instanceof Node))throw new TypeError(`Failed to execute '${this.observe.name}' on '${Ct.name}': parameter 1 is not of type 'Node' or a DOMString.`);const n=An.get(this);n?.addObservedTarget(t)}takeRecords(){const t=An.get(this);return t==null?[]:t.clearQueue()}disconnect(){const t=An.get(this);t?.clearObservedTargets()}}vu(Zi.schedule.bind(Zi));var Fu=function(){function e(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),Bu=Hu(["",""],["",""]);function Hu(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Qu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var we=function(){function e(){for(var t=this,n=arguments.length,i=Array(n),r=0;r<n;r++)i[r]=arguments[r];return Qu(this,e),this.tag=function(o){for(var s=arguments.length,a=Array(s>1?s-1:0),c=1;c<s;c++)a[c-1]=arguments[c];return typeof o=="function"?t.interimTag.bind(t,o):typeof o=="string"?t.transformEndResult(o):(o=o.map(t.transformString.bind(t)),t.transformEndResult(o.reduce(t.processSubstitutions.bind(t,a))))},i.length>0&&Array.isArray(i[0])&&(i=i[0]),this.transformers=i.map(function(o){return typeof o=="function"?o():o}),this.tag}return Fu(e,[{key:"interimTag",value:function(n,i){for(var r=arguments.length,o=Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return this.tag(Bu,n.apply(void 0,[i].concat(o)))}},{key:"processSubstitutions",value:function(n,i,r){var o=this.transformSubstitution(n.shift(),i);return"".concat(i,o,r)}},{key:"transformString",value:function(n){var i=function(o,s){return s.onString?s.onString(o):o};return this.transformers.reduce(i,n)}},{key:"transformSubstitution",value:function(n,i){var r=function(s,a){return a.onSubstitution?a.onSubstitution(s,i):s};return this.transformers.reduce(r,n)}},{key:"transformEndResult",value:function(n){var i=function(o,s){return s.onEndResult?s.onEndResult(o):o};return this.transformers.reduce(i,n)}}]),e}(),xe=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return{onEndResult:function(i){if(t==="")return i.trim();if(t=t.toLowerCase(),t==="start"||t==="left")return i.replace(/^\s*/,"");if(t==="end"||t==="right")return i.replace(/\s*$/,"");throw new Error("Side not supported: "+t)}}};function Gu(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}var mt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"initial";return{onEndResult:function(i){if(t==="initial"){var r=i.match(/^[^\S\n]*(?=\S)/gm),o=r&&Math.min.apply(Math,Gu(r.map(function(a){return a.length})));if(o){var s=new RegExp("^.{"+o+"}","gm");return i.replace(s,"")}return i}if(t==="all")return i.replace(/^[^\S\n]+/gm,"");throw new Error("Unknown type: "+t)}}},Kt=function(t,n){return{onEndResult:function(r){if(t==null||n==null)throw new Error("replaceResultTransformer requires at least 2 arguments.");return r.replace(t,n)}}},$t=function(t,n){return{onSubstitution:function(r,o){if(t==null||n==null)throw new Error("replaceSubstitutionTransformer requires at least 2 arguments.");return r==null?r:r.toString().replace(t,n)}}},Vu={separator:"",conjunction:"",serial:!1},tt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Vu;return{onSubstitution:function(i,r){if(Array.isArray(i)){var o=i.length,s=t.separator,a=t.conjunction,c=t.serial,u=r.match(/(\n?[^\S\n]+)$/);if(u?i=i.join(s+u[1]):i=i.join(s+" "),a&&o>1){var l=i.lastIndexOf(s);i=i.slice(0,l)+(c?s:"")+" "+a+i.slice(l+1)}}return i}}},qo=function(t){return{onSubstitution:function(i,r){if(t!=null&&typeof t=="string")typeof i=="string"&&i.includes(t)&&(i=i.split(t));else throw new Error("You need to specify a string character to split by.");return i}}},Xo=function(t){return t!=null&&!Number.isNaN(t)&&typeof t!="boolean"},Ku=function(){return{onSubstitution:function(n){return Array.isArray(n)?n.filter(Xo):Xo(n)?n:""}}};new we(tt({separator:","}),mt,xe),new we(tt({separator:",",conjunction:"and"}),mt,xe),new we(tt({separator:",",conjunction:"or"}),mt,xe),new we(qo(`
|
|
6
6
|
`),Ku,tt,mt,xe),new we(qo(`
|
|
7
7
|
`),tt,mt,xe,$t(/&/g,"&"),$t(/</g,"<"),$t(/>/g,">"),$t(/"/g,"""),$t(/'/g,"'"),$t(/`/g,"`")),new we(Kt(/(?:\n(?:\s*))+/g," "),xe),new we(Kt(/(?:\n\s*)/g,""),xe),new we(tt({separator:","}),Kt(/(?:\s+)/g," "),xe),new we(tt({separator:",",conjunction:"or"}),Kt(/(?:\s+)/g," "),xe),new we(tt({separator:",",conjunction:"and"}),Kt(/(?:\s+)/g," "),xe),new we(tt,mt,xe),new we(tt,Kt(/(?:\s+)/g," "),xe),new we(mt,xe);var qi=new we(mt("all"),xe),$u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xi={exports:{}};(function(e,t){(function(n,i){var r="1.0.36",o="",s="?",a="function",c="undefined",u="object",l="string",g="major",f="model",h="name",d="type",M="vendor",y="version",m="architecture",T="console",N="mobile",j="tablet",A="smarttv",E="wearable",S="embedded",I=350,z="Amazon",C="Apple",R="ASUS",F="BlackBerry",x="Browser",D="Chrome",b="Edge",w="Firefox",v="Google",O="Huawei",_="LG",$="Microsoft",X="Motorola",se="Opera",Se="Samsung",at="Sharp",Je="Sony",U="Xiaomi",de="Zebra",fe="Facebook",Bt="Chromium OS",Gn="Mac OS",Ht=function(W,re){var Q={};for(var ce in W)re[ce]&&re[ce].length%2===0?Q[ce]=re[ce].concat(W[ce]):Q[ce]=W[ce];return Q},Qt=function(W){for(var re={},Q=0;Q<W.length;Q++)re[W[Q].toUpperCase()]=W[Q];return re},Bi=function(W,re){return typeof W===l?Vn(re).indexOf(Vn(W))!==-1:!1},Vn=function(W){return W.toLowerCase()},Cy=function(W){return typeof W===l?W.replace(/[^\d\.]/g,o).split(".")[0]:i},_o=function(W,re){if(typeof W===l)return W=W.replace(/^\s\s*/,o),typeof re===c?W:W.substring(0,I)},Kn=function(W,re){for(var Q=0,ce,vt,ct,ie,B,ut;Q<re.length&&!B;){var Uo=re[Q],Nu=re[Q+1];for(ce=vt=0;ce<Uo.length&&!B&&Uo[ce];)if(B=Uo[ce++].exec(W),B)for(ct=0;ct<Nu.length;ct++)ut=B[++vt],ie=Nu[ct],typeof ie===u&&ie.length>0?ie.length===2?typeof ie[1]==a?this[ie[0]]=ie[1].call(this,ut):this[ie[0]]=ie[1]:ie.length===3?typeof ie[1]===a&&!(ie[1].exec&&ie[1].test)?this[ie[0]]=ut?ie[1].call(this,ut,ie[2]):i:this[ie[0]]=ut?ut.replace(ie[1],ie[2]):i:ie.length===4&&(this[ie[0]]=ut?ie[3].call(this,ut.replace(ie[1],ie[2])):i):this[ie]=ut||i;Q+=2}},ko=function(W,re){for(var Q in re)if(typeof re[Q]===u&&re[Q].length>0){for(var ce=0;ce<re[Q].length;ce++)if(Bi(re[Q][ce],W))return Q===s?i:Q}else if(Bi(re[Q],W))return Q===s?i:Q;return W},zy={"1.0":"/8","1.2":"/1","1.3":"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},yu={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2","8.1":"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},mu={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[y,[h,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[y,[h,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[h,y],[/opios[\/ ]+([\w\.]+)/i],[y,[h,se+" Mini"]],[/\bopr\/([\w\.]+)/i],[y,[h,se]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[h,y],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[y,[h,"UC"+x]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[y,[h,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[y,[h,"WeChat"]],[/konqueror\/([\w\.]+)/i],[y,[h,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[y,[h,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[y,[h,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[h,/(.+)/,"$1 Secure "+x],y],[/\bfocus\/([\w\.]+)/i],[y,[h,w+" Focus"]],[/\bopt\/([\w\.]+)/i],[y,[h,se+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[y,[h,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[y,[h,"Dolphin"]],[/coast\/([\w\.]+)/i],[y,[h,se+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[y,[h,"MIUI "+x]],[/fxios\/([-\w\.]+)/i],[y,[h,w]],[/\bqihu|(qi?ho?o?|360)browser/i],[[h,"360 "+x]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[h,/(.+)/,"$1 "+x],y],[/(comodo_dragon)\/([\w\.]+)/i],[[h,/_/g," "],y],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[h,y],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[h],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[h,fe],y],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[h,y],[/\bgsa\/([\w\.]+) .*safari\//i],[y,[h,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[y,[h,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[y,[h,D+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[h,D+" WebView"],y],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[y,[h,"Android "+x]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[h,y],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[y,[h,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[y,h],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[h,[y,ko,zy]],[/(webkit|khtml)\/([\w\.]+)/i],[h,y],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[h,"Netscape"],y],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[y,[h,w+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[h,y],[/(cobalt)\/([\w\.]+)/i],[h,[y,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[m,"amd64"]],[/(ia32(?=;))/i],[[m,Vn]],[/((?:i[346]|x)86)[;\)]/i],[[m,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[m,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[m,"armhf"]],[/windows (ce|mobile); ppc;/i],[[m,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[m,/ower/,o,Vn]],[/(sun4\w)[;\)]/i],[[m,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[m,Vn]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[f,[M,Se],[d,j]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[f,[M,Se],[d,N]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[f,[M,C],[d,N]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[f,[M,C],[d,j]],[/(macintosh);/i],[f,[M,C]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[f,[M,at],[d,N]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[f,[M,O],[d,j]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[f,[M,O],[d,N]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[f,/_/g," "],[M,U],[d,N]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[f,/_/g," "],[M,U],[d,j]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[f,[M,"OPPO"],[d,N]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[f,[M,"Vivo"],[d,N]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[f,[M,"Realme"],[d,N]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[f,[M,X],[d,N]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[f,[M,X],[d,j]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[f,[M,_],[d,j]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[f,[M,_],[d,N]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[f,[M,"Lenovo"],[d,j]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[f,/_/g," "],[M,"Nokia"],[d,N]],[/(pixel c)\b/i],[f,[M,v],[d,j]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[f,[M,v],[d,N]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[f,[M,Je],[d,N]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[f,"Xperia Tablet"],[M,Je],[d,j]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[f,[M,"OnePlus"],[d,N]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[f,[M,z],[d,j]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[f,/(.+)/g,"Fire Phone $1"],[M,z],[d,N]],[/(playbook);[-\w\),; ]+(rim)/i],[f,M,[d,j]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[f,[M,F],[d,N]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[f,[M,R],[d,j]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[f,[M,R],[d,N]],[/(nexus 9)/i],[f,[M,"HTC"],[d,j]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[M,[f,/_/g," "],[d,N]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[f,[M,"Acer"],[d,j]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[f,[M,"Meizu"],[d,N]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[M,f,[d,N]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[M,f,[d,j]],[/(surface duo)/i],[f,[M,$],[d,j]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[f,[M,"Fairphone"],[d,N]],[/(u304aa)/i],[f,[M,"AT&T"],[d,N]],[/\bsie-(\w*)/i],[f,[M,"Siemens"],[d,N]],[/\b(rct\w+) b/i],[f,[M,"RCA"],[d,j]],[/\b(venue[\d ]{2,7}) b/i],[f,[M,"Dell"],[d,j]],[/\b(q(?:mv|ta)\w+) b/i],[f,[M,"Verizon"],[d,j]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[f,[M,"Barnes & Noble"],[d,j]],[/\b(tm\d{3}\w+) b/i],[f,[M,"NuVision"],[d,j]],[/\b(k88) b/i],[f,[M,"ZTE"],[d,j]],[/\b(nx\d{3}j) b/i],[f,[M,"ZTE"],[d,N]],[/\b(gen\d{3}) b.+49h/i],[f,[M,"Swiss"],[d,N]],[/\b(zur\d{3}) b/i],[f,[M,"Swiss"],[d,j]],[/\b((zeki)?tb.*\b) b/i],[f,[M,"Zeki"],[d,j]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[M,"Dragon Touch"],f,[d,j]],[/\b(ns-?\w{0,9}) b/i],[f,[M,"Insignia"],[d,j]],[/\b((nxa|next)-?\w{0,9}) b/i],[f,[M,"NextBook"],[d,j]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[M,"Voice"],f,[d,N]],[/\b(lvtel\-)?(v1[12]) b/i],[[M,"LvTel"],f,[d,N]],[/\b(ph-1) /i],[f,[M,"Essential"],[d,N]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[f,[M,"Envizen"],[d,j]],[/\b(trio[-\w\. ]+) b/i],[f,[M,"MachSpeed"],[d,j]],[/\btu_(1491) b/i],[f,[M,"Rotor"],[d,j]],[/(shield[\w ]+) b/i],[f,[M,"Nvidia"],[d,j]],[/(sprint) (\w+)/i],[M,f,[d,N]],[/(kin\.[onetw]{3})/i],[[f,/\./g," "],[M,$],[d,N]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[f,[M,de],[d,j]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[f,[M,de],[d,N]],[/smart-tv.+(samsung)/i],[M,[d,A]],[/hbbtv.+maple;(\d+)/i],[[f,/^/,"SmartTV"],[M,Se],[d,A]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[M,_],[d,A]],[/(apple) ?tv/i],[M,[f,C+" TV"],[d,A]],[/crkey/i],[[f,D+"cast"],[M,v],[d,A]],[/droid.+aft(\w+)( bui|\))/i],[f,[M,z],[d,A]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[f,[M,at],[d,A]],[/(bravia[\w ]+)( bui|\))/i],[f,[M,Je],[d,A]],[/(mitv-\w{5}) bui/i],[f,[M,U],[d,A]],[/Hbbtv.*(technisat) (.*);/i],[M,f,[d,A]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[M,_o],[f,_o],[d,A]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,A]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[M,f,[d,T]],[/droid.+; (shield) bui/i],[f,[M,"Nvidia"],[d,T]],[/(playstation [345portablevi]+)/i],[f,[M,Je],[d,T]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[f,[M,$],[d,T]],[/((pebble))app/i],[M,f,[d,E]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[f,[M,C],[d,E]],[/droid.+; (glass) \d/i],[f,[M,v],[d,E]],[/droid.+; (wt63?0{2,3})\)/i],[f,[M,de],[d,E]],[/(quest( 2| pro)?)/i],[f,[M,fe],[d,E]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[M,[d,S]],[/(aeobc)\b/i],[f,[M,z],[d,S]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[f,[d,N]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[f,[d,j]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,j]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,N]],[/(android[-\w\. ]{0,9});.+buil/i],[f,[M,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[y,[h,b+"HTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[y,[h,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[h,y],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[y,h]],os:[[/microsoft (windows) (vista|xp)/i],[h,y],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[h,[y,ko,yu]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[h,"Windows"],[y,ko,yu]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[y,/_/g,"."],[h,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[h,Gn],[y,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[y,h],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[h,y],[/\(bb(10);/i],[y,[h,F]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[y,[h,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[y,[h,w+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[y,[h,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[y,[h,"watchOS"]],[/crkey\/([\d\.]+)/i],[y,[h,D+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[h,Bt],y],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[h,y],[/(sunos) ?([\w\.\d]*)/i],[[h,"Solaris"],y],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[h,y]]},et=function(W,re){if(typeof W===u&&(re=W,W=i),!(this instanceof et))return new et(W,re).getResult();var Q=typeof n!==c&&n.navigator?n.navigator:i,ce=W||(Q&&Q.userAgent?Q.userAgent:o),vt=Q&&Q.userAgentData?Q.userAgentData:i,ct=re?Ht(mu,re):mu,ie=Q&&Q.userAgent==ce;return this.getBrowser=function(){var B={};return B[h]=i,B[y]=i,Kn.call(B,ce,ct.browser),B[g]=Cy(B[y]),ie&&Q&&Q.brave&&typeof Q.brave.isBrave==a&&(B[h]="Brave"),B},this.getCPU=function(){var B={};return B[m]=i,Kn.call(B,ce,ct.cpu),B},this.getDevice=function(){var B={};return B[M]=i,B[f]=i,B[d]=i,Kn.call(B,ce,ct.device),ie&&!B[d]&&vt&&vt.mobile&&(B[d]=N),ie&&B[f]=="Macintosh"&&Q&&typeof Q.standalone!==c&&Q.maxTouchPoints&&Q.maxTouchPoints>2&&(B[f]="iPad",B[d]=j),B},this.getEngine=function(){var B={};return B[h]=i,B[y]=i,Kn.call(B,ce,ct.engine),B},this.getOS=function(){var B={};return B[h]=i,B[y]=i,Kn.call(B,ce,ct.os),ie&&!B[h]&&vt&&vt.platform!="Unknown"&&(B[h]=vt.platform.replace(/chrome os/i,Bt).replace(/macos/i,Gn)),B},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return ce},this.setUA=function(B){return ce=typeof B===l&&B.length>I?_o(B,I):B,this},this.setUA(ce),this};et.VERSION=r,et.BROWSER=Qt([h,y,g]),et.CPU=Qt([m]),et.DEVICE=Qt([f,M,d,T,N,A,j,E,S]),et.ENGINE=et.OS=Qt([h,y]),e.exports&&(t=e.exports=et),t.UAParser=et;var jn=typeof n!==c&&(n.jQuery||n.Zepto);if(jn&&!jn.ua){var Hi=new et;jn.ua=Hi.getResult(),jn.ua.get=function(){return Hi.getUA()},jn.ua.set=function(W){Hi.setUA(W);var re=Hi.getResult();for(var Q in re)jn.ua[Q]=re[Q]}}})(typeof window=="object"?window:$u)})(Xi,Xi.exports);var Wu=Xi.exports;const Zu=Jo(Wu);function es(e){const t=Object.keys(e);if(t.length===0)throw new Error("No members in object!");let n=t[0],i=-1/0;for(const[r,o]of Object.entries(e))o>i&&(i=o,n=r);return n}const Ji=e=>{if(e instanceof Error)return e;try{return new Error(JSON.stringify(e))}catch{return new Error(String(e))}};class ts{deviceInfo;settings;activeStream;name;#e;constructor(t,n){this.deviceInfo=t,this.name=t.label,this.activeStream=null,this.#e=is(t),this.settings=n}async startStream(){if(this.activeStream)return this.activeStream;const t=await navigator.mediaDevices.getUserMedia(this.#e);this.activeStream=t,t.onaddtrack=i=>console.log("added track",i),t.onremovetrack=i=>console.log("removed track",i);const n=t.getVideoTracks()[0];return n.onended=i=>{console.log("track ended",i),this.stopStream()},t}stopStream(){this.activeStream&&(console.log(`Stopping active stream on ${this.name}`),nr(this.activeStream),this.activeStream=null)}getVideoTrack(){if(this.activeStream)return this.activeStream.getVideoTracks()[0]}}const er=new Zu,tr=er.getOS().name==="Android",ns=er.getOS().name==="iOS",qu=async()=>{try{const e=await navigator.mediaDevices.getUserMedia({video:!0});nr(e)}catch{throw new Error("Camera permission not given")}},Xu=async()=>{if(!navigator.mediaDevices)throw new Error(qi`
|
|
8
8
|
Cameras can only be used in a secure context:
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const _importScripts = importScripts;
|
|
12
12
|
const _fixImports = (url) => new URL(url, '${s.join("/")+"/"}').href;
|
|
13
13
|
importScripts = (...urls) => _importScripts(...urls.map(_fixImports));
|
|
14
|
-
`;let c=`data:${rs},`+encodeURIComponent(a+o);n.useBlob&&(c=URL.createObjectURL(new Blob([`importScripts("${c}")`],{type:rs}))),i(c)}).catch(r))},sl=async(e=window.location.href)=>{const t=await ol(e+"/resources/capture-worker.js"),n=new Worker(t);n.onerror=r=>{console.error("Worker error:",r)};const i=Bo(n);return await i.setResourceUrl(e+"/resources"),i};let al=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");const os="capture-userid";function cl(){const e=localStorage.getItem(os);if(e)return e;const t=al();return localStorage.setItem(os,t),t}function ul(e){return{licenseId:e.licenseId,licensee:e.licensee,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}async function ll(e){try{return await(await fetch("https://baltazar.microblink.com/api/v1/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(ul(e))})).json()}catch(t){throw console.error(t),t}}class fl{#e;#t;constructor(t,n){this.#e=t,this.#t=n}analyze=async t=>{const n=rl(t);return await this.#e.analyze(Vo(n,[n.data.buffer]))};finishSideCapture=async()=>await this.#t.finishSideCapture();getResult=async()=>await this.#t.getResult();getSettings=async()=>await this.#t.getSettings();updateSettings=async t=>{const i={...await this.getSettings(),...t};await this.#t.updateSettings(i)};resetCapture=async()=>{await this.#t.reset()};async terminateWorker(){await this.#e.terminate()}}async function ss(e){const t=await sl(e.resourceUrl),n=cl(),i=await t.loadWasm(),r=await i.initializeWithLicenseKey(e.licenseKey,n,!1);if(r.unlockResult===Vi.RequiresServerPermission){const u=await ll(r),l=await i.submitServerPermission(JSON.stringify(u));if(console.log(l),l.status!==Ki.Ok)throw new Error("Server unlock not ok.")}const o=await t.createAnalyzer();if(!o)throw new Error("Failed to create analyzer");let a={...await o.getSettings(),minimumDocumentDpi:220};return e.analyzerSettings&&Object.assign(a,e.analyzerSettings),await o.updateSettings(a),new fl(t,o)}const De=Symbol.for("@ts-pattern/matcher"),as=Symbol.for("@ts-pattern/isVariadic"),Jn="@ts-pattern/anonymous-select-key",ir=e=>!!(e&&typeof e=="object"),ei=e=>e&&!!e[De],Te=(e,t,n)=>{if(ei(e)){const i=e[De](),{matched:r,selections:o}=i.match(t);return r&&o&&Object.keys(o).forEach(s=>n(s,o[s])),r}if(ir(e)){if(!ir(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let i=[],r=[],o=[];for(const s of e.keys()){const a=e[s];ei(a)&&a[as]?o.push(a):o.length?r.push(a):i.push(a)}if(o.length){if(o.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<i.length+r.length)return!1;const s=t.slice(0,i.length),a=r.length===0?[]:t.slice(-r.length),c=t.slice(i.length,r.length===0?1/0:-r.length);return i.every((u,l)=>Te(u,s[l],n))&&r.every((u,l)=>Te(u,a[l],n))&&(o.length===0||Te(o[0],c,n))}return e.length===t.length&&e.every((s,a)=>Te(s,t[a],n))}return Object.keys(e).every(i=>{const r=e[i];return(i in t||ei(o=r)&&o[De]().matcherType==="optional")&&Te(r,t[i],n);var o})}return Object.is(t,e)},Oe=e=>{var t,n,i;return ir(e)?ei(e)?(t=(n=(i=e[De]()).getSelectionKeys)==null?void 0:n.call(i))!=null?t:[]:Array.isArray(e)?En(e,Oe):En(Object.values(e),Oe):[]},En=(e,t)=>e.reduce((n,i)=>n.concat(t(i)),[]);function dl(...e){if(e.length===1){const[t]=e;return n=>Te(t,n,()=>{})}if(e.length===2){const[t,n]=e;return Te(t,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${e.length}.`)}function je(e){return Object.assign(e,{optional:()=>or(e),and:t=>ue(e,t),or:t=>cs(e,t),select:t=>t===void 0?Sn(e):Sn(t,e)})}function rr(e){return Object.assign((t=>Object.assign(t,{*[Symbol.iterator](){yield Object.assign(t,{[as]:!0})}}))(e),{optional:()=>rr(or(e)),select:t=>rr(t===void 0?Sn(e):Sn(t,e))})}function or(e){return je({[De]:()=>({match:t=>{let n={};const i=(r,o)=>{n[r]=o};return t===void 0?(Oe(e).forEach(r=>i(r,void 0)),{matched:!0,selections:n}):{matched:Te(e,t,i),selections:n}},getSelectionKeys:()=>Oe(e),matcherType:"optional"})})}const gl=(e,t)=>{for(const n of e)if(!t(n))return!1;return!0},Ml=(e,t)=>{for(const[n,i]of e.entries())if(!t(i,n))return!1;return!0};function ue(...e){return je({[De]:()=>({match:t=>{let n={};const i=(r,o)=>{n[r]=o};return{matched:e.every(r=>Te(r,t,i)),selections:n}},getSelectionKeys:()=>En(e,Oe),matcherType:"and"})})}function cs(...e){return je({[De]:()=>({match:t=>{let n={};const i=(r,o)=>{n[r]=o};return En(e,Oe).forEach(r=>i(r,void 0)),{matched:e.some(r=>Te(r,t,i)),selections:n}},getSelectionKeys:()=>En(e,Oe),matcherType:"or"})})}function J(e){return{[De]:()=>({match:t=>({matched:!!e(t)})})}}function Sn(...e){const t=typeof e[0]=="string"?e[0]:void 0,n=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return je({[De]:()=>({match:i=>{let r={[t??Jn]:i};return{matched:n===void 0||Te(n,i,(o,s)=>{r[o]=s}),selections:r}},getSelectionKeys:()=>[t??Jn].concat(n===void 0?[]:Oe(n))})})}function nt(e){return typeof e=="number"}function zt(e){return typeof e=="string"}function Nt(e){return typeof e=="bigint"}const us=je(J(function(e){return!0})),hl=us,_t=e=>Object.assign(je(e),{startsWith:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&i.startsWith(n)))));var n},endsWith:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&i.endsWith(n)))));var n},minLength:t=>_t(ue(e,(n=>J(i=>zt(i)&&i.length>=n))(t))),maxLength:t=>_t(ue(e,(n=>J(i=>zt(i)&&i.length<=n))(t))),includes:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&i.includes(n)))));var n},regex:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&!!i.match(n)))));var n}}),yl=_t(J(zt)),it=e=>Object.assign(je(e),{between:(t,n)=>it(ue(e,((i,r)=>J(o=>nt(o)&&i<=o&&r>=o))(t,n))),lt:t=>it(ue(e,(n=>J(i=>nt(i)&&i<n))(t))),gt:t=>it(ue(e,(n=>J(i=>nt(i)&&i>n))(t))),lte:t=>it(ue(e,(n=>J(i=>nt(i)&&i<=n))(t))),gte:t=>it(ue(e,(n=>J(i=>nt(i)&&i>=n))(t))),int:()=>it(ue(e,J(t=>nt(t)&&Number.isInteger(t)))),finite:()=>it(ue(e,J(t=>nt(t)&&Number.isFinite(t)))),positive:()=>it(ue(e,J(t=>nt(t)&&t>0))),negative:()=>it(ue(e,J(t=>nt(t)&&t<0)))}),ml=it(J(nt)),Tt=e=>Object.assign(je(e),{between:(t,n)=>Tt(ue(e,((i,r)=>J(o=>Nt(o)&&i<=o&&r>=o))(t,n))),lt:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i<n))(t))),gt:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i>n))(t))),lte:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i<=n))(t))),gte:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i>=n))(t))),positive:()=>Tt(ue(e,J(t=>Nt(t)&&t>0))),negative:()=>Tt(ue(e,J(t=>Nt(t)&&t<0)))}),Nl=Tt(J(Nt)),Tl=je(J(function(e){return typeof e=="boolean"})),Ll=je(J(function(e){return typeof e=="symbol"})),jl=je(J(function(e){return e==null}));var Al={__proto__:null,matcher:De,optional:or,array:function(...e){return rr({[De]:()=>({match:t=>{if(!Array.isArray(t))return{matched:!1};if(e.length===0)return{matched:!0};const n=e[0];let i={};if(t.length===0)return Oe(n).forEach(o=>{i[o]=[]}),{matched:!0,selections:i};const r=(o,s)=>{i[o]=(i[o]||[]).concat([s])};return{matched:t.every(o=>Te(n,o,r)),selections:i}},getSelectionKeys:()=>e.length===0?[]:Oe(e[0])})})},set:function(...e){return je({[De]:()=>({match:t=>{if(!(t instanceof Set))return{matched:!1};let n={};if(t.size===0)return{matched:!0,selections:n};if(e.length===0)return{matched:!0};const i=(o,s)=>{n[o]=(n[o]||[]).concat([s])},r=e[0];return{matched:gl(t,o=>Te(r,o,i)),selections:n}},getSelectionKeys:()=>e.length===0?[]:Oe(e[0])})})},map:function(...e){return je({[De]:()=>({match:t=>{if(!(t instanceof Map))return{matched:!1};let n={};if(t.size===0)return{matched:!0,selections:n};const i=(a,c)=>{n[a]=(n[a]||[]).concat([c])};if(e.length===0)return{matched:!0};var r;if(e.length===1)throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${(r=e[0])==null?void 0:r.toString()}`);const[o,s]=e;return{matched:Ml(t,(a,c)=>{const u=Te(o,c,i),l=Te(s,a,i);return u&&l}),selections:n}},getSelectionKeys:()=>e.length===0?[]:[...Oe(e[0]),...Oe(e[1])]})})},intersection:ue,union:cs,not:function(e){return je({[De]:()=>({match:t=>({matched:!Te(e,t,()=>{})}),getSelectionKeys:()=>[],matcherType:"not"})})},when:J,select:Sn,any:us,_:hl,string:yl,number:ml,bigint:Nl,boolean:Tl,symbol:Ll,nullish:jl,instanceOf:function(e){return je(J(function(t){return n=>n instanceof t}(e)))},shape:function(e){return je(J(dl(e)))}};const sr={matched:!1,value:void 0};function El(e){return new ti(e,sr)}class ti{constructor(t,n){this.input=void 0,this.state=void 0,this.input=t,this.state=n}with(...t){if(this.state.matched)return this;const n=t[t.length-1],i=[t[0]];let r;t.length===3&&typeof t[1]=="function"?(i.push(t[0]),r=t[1]):t.length>2&&i.push(...t.slice(1,t.length-1));let o=!1,s={};const a=(u,l)=>{o=!0,s[u]=l},c=!i.some(u=>Te(u,this.input,a))||r&&!r(this.input)?sr:{matched:!0,value:n(o?Jn in s?s[Jn]:s:this.input,this.input)};return new ti(this.input,c)}when(t,n){if(this.state.matched)return this;const i=!!t(this.input);return new ti(this.input,i?{matched:!0,value:n(this.input,this.input)}:sr)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){return this.run()}run(){if(this.state.matched)return this.state.value;let t;try{t=JSON.stringify(this.input)}catch{t=this.input}throw new Error(`Pattern matching error: no pattern matches value ${t}`)}returnType(){return this}}const Le={PROCESSING:{key:"PROCESSING",reticleType:"processing",minDuration:1e3},SIDE_CAPTURED:{key:"SIDE_CAPTURED",reticleType:"flip",minDuration:3e3},DOCUMENT_CAPTURED:{key:"DOCUMENT_CAPTURED",reticleType:"done",minDuration:1e3},SENSING_FRONT:{key:"SENSING_FRONT",reticleType:"searching",minDuration:1e3},SENSING_BACK:{key:"SENSING_BACK",reticleType:"searching",minDuration:1e3},DOCUMENT_FRAMING_CAMERA_TOO_FAR:{key:"DOCUMENT_FRAMING_CAMERA_TOO_FAR",reticleType:"error",minDuration:1500},DOCUMENT_FRAMING_CAMERA_TOO_CLOSE:{key:"DOCUMENT_FRAMING_CAMERA_TOO_CLOSE",reticleType:"error",minDuration:1500},DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION:{key:"DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION",reticleType:"rotate",minDuration:3e3},DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE:{key:"DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE",reticleType:"error",minDuration:1500},DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP:{key:"DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP",reticleType:"error",minDuration:1500},DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE:{key:"DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE",reticleType:"error",minDuration:1500},LIGHTING_TOO_DARK:{key:"LIGHTING_TOO_DARK",reticleType:"error",minDuration:1500},LIGHTING_TOO_BRIGHT:{key:"LIGHTING_TOO_BRIGHT",reticleType:"error",minDuration:1500},BLUR_DETECTED:{key:"BLUR_DETECTED",reticleType:"error",minDuration:1500},GLARE_DETECTED:{key:"GLARE_DETECTED",reticleType:"error",minDuration:1500},OCCLUDED:{key:"OCCLUDED",reticleType:"error",minDuration:1500},WRONG_SIDE:{key:"WRONG_SIDE",reticleType:"error",minDuration:1500}};class Sl{timeWindow=3e3;decayRate=.95;eventStack=[];currentUiState=Le.SENSING_FRONT;currentStateStartTime=performance.now();reset(){this.eventStack=[]}getUiState(t){const n=performance.now(),i={stateKey:this.getUiStateKeyFromResult(t),timeStamp:n,currentWeight:1};if(i.stateKey==="SIDE_CAPTURED"||i.stateKey==="DOCUMENT_CAPTURED")return this.eventStack=[],Le[i.stateKey];this.eventStack.push(i);const r={};if(this.eventStack.forEach(s=>{if(n-s.timeStamp>this.timeWindow){this.eventStack.shift();return}const a=s.timeStamp/n;s.currentWeight*=this.decayRate*a,r[s.stateKey]||(r[s.stateKey]=[]),r[s.stateKey].push(s.currentWeight)}),n-this.currentStateStartTime<this.currentUiState.minDuration)return this.currentUiState;const o={};for(const s in r){const a=s,c=s.length/this.eventStack.length,u=r[a].reduce((l,g)=>l+g,0);o[a]=u*c}try{const s=es(o),a=Le[s];return a!==this.currentUiState&&(this.currentUiState=a,this.currentStateStartTime=n),a}catch{return this.currentUiState}}getUiStateKeyFromResult(t){return El(t).with({frameCaptured:!0,captureState:Al.when(n=>n==="first-side-capture-in-progress"||n==="second-side-capture-in-progress")},()=>"PROCESSING").with({captureState:"first-side-capture-in-progress",frameAnalysisStatus:{framingStatus:"no-document"}},()=>"SENSING_FRONT").with({captureState:"second-side-capture-in-progress",frameAnalysisStatus:{framingStatus:"no-document"}},()=>"SENSING_BACK").with({captureState:"document-captured"},()=>"DOCUMENT_CAPTURED").with({captureState:"side-captured"},()=>"SIDE_CAPTURED").with({frameAnalysisStatus:{sideAnalysisStatus:"side-already-captured"}},()=>"WRONG_SIDE").with({frameAnalysisStatus:{framingStatus:"camera-angle-too-steep"}},()=>"DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP").with({frameAnalysisStatus:{framingStatus:"camera-too-close"}},()=>"DOCUMENT_FRAMING_CAMERA_TOO_CLOSE").with({frameAnalysisStatus:{framingStatus:"camera-orientation-unsuitable"}},()=>"DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE").with({frameAnalysisStatus:{framingStatus:"camera-too-far"}},()=>"DOCUMENT_FRAMING_CAMERA_TOO_FAR").with({frameAnalysisStatus:{framingStatus:"document-too-close-to-frame-edge"}},()=>"DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE").with({frameAnalysisStatus:{lightingStatus:"too-bright"}},()=>"LIGHTING_TOO_BRIGHT").with({frameAnalysisStatus:{lightingStatus:"too-dark"}},()=>"LIGHTING_TOO_DARK").with({frameAnalysisStatus:{blurStatus:"blur-detected"}},()=>"BLUR_DETECTED").with({frameAnalysisStatus:{glareStatus:"glare-detected"}},()=>"GLARE_DETECTED").with({frameAnalysisStatus:{occlusionStatus:"occluded"}},()=>"OCCLUDED").otherwise(()=>"SENSING_FRONT")}}const ar=new Sl,cr=document.createElement("canvas"),ni=cr.getContext("2d",{willReadFrequently:!0,alpha:!1});function pl(e,t=!1){if(!ni)throw new Error("CanvasRenderingContext2D is missing!");const n=e.videoWidth,i=e.videoHeight;return cr.width=n,cr.height=i,ni.drawImage(e,0,0,n,i),t&&ni.scale(-1,1),ni.getImageData(0,0,n,i)}const Il=e=>(t,n,i)=>{const r=i.subscribe;return i.subscribe=(s,a,c)=>{let u=s;if(a){const l=c?.equalityFn||Object.is;let g=s(i.getState());u=f=>{const h=s(f);if(!l(g,h)){const d=g;a(g=h,d)}},c?.fireImmediately&&a(g,g)}return r(u)},e(t,n,i)},ls=e=>{let t;const n=new Set,i=(c,u)=>{const l=typeof c=="function"?c(t):c;if(!Object.is(l,t)){const g=t;t=u??typeof l!="object"?l:Object.assign({},t,l),n.forEach(f=>f(t,g))}},r=()=>t,a={setState:i,getState:r,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{n.clear()}};return t=e(i,r,a),a},wl=e=>e?ls(e):ls,fs={cameras:[],videoElement:null,selectedCamera:null,isPlaying:!1,isCapturing:!1,isSwappingCamera:!1,isQueryingCameras:!1,callbacks:{},mirrorX:!1,uiState:structuredClone(Le.SENSING_FRONT),captureRequiresLandscape:!1,initialized:!1,errorState:null,analyzerSettings:{}},k=wl()(Il(()=>structuredClone(fs)));k.subscribe(e=>e.videoElement,(e,t)=>{!e&&t&&ur()});const ur=()=>{console.log("resetting zustand store"),k.getState().cameras.forEach(e=>{e.stopStream()}),k.setState(structuredClone(fs))};let lr,ii;class xl{#e;#t;constructor(t){this.#e=t}setupVideoElement(t){new Ct(i=>{i[0].connected||this.destroy()}).observe(t),t.playsInline=!0,t.setAttribute("muted","")}async updateAnalyzerSettings(t){if(k.getState().isCapturing){console.warn("Cancel the capture process using `cancelCapture()` before updating settings");return}try{await this.#e.updateSettings(t)}catch(n){console.error("Error updating analyzer settings",n)}}async selectCamera(t){const n=k.getState();if(n.selectedCamera===t){console.warn("Already selected");return}if(n.isSwappingCamera)return;const i=n.selectedCamera;k.setState({isSwappingCamera:!0}),i&&i.stopStream(),n.videoElement&&(n.videoElement.srcObject=null);try{const r=await t.startStream();n.videoElement&&(n.videoElement.srcObject=r,n.isPlaying&&await n.videoElement.play()),k.setState({selectedCamera:t,isSwappingCamera:!1})}catch(r){console.error(r)}}async updateCameraDevices(){if(k.getState().isQueryingCameras||k.getState().isSwappingCamera)return;k.setState({isQueryingCameras:!0});const t=await il();if(t.length<1)throw new Error("No capable devices found! Your camera needs to have a minimum resolution of 1920x1080");el(t);const n=tl(t),i=t.find(r=>r.deviceInfo.deviceId===n);k.setState({cameras:t,selectedCamera:i,isQueryingCameras:!1})}async startPlayback(){const t=k.getState();if(!t.isPlaying){if(!t.videoElement){console.warn("No video element present.");return}if(!t.videoElement.srcObject){console.warn("No source present. Start a camera stream first.");return}if(!t.selectedCamera){console.warn("No selected camera");return}await t.selectedCamera.startStream(),await t.videoElement.play(),k.setState({isPlaying:!0}),t.isCapturing===!0&&t.videoElement.requestVideoFrameCallback(()=>void this.#n())}}async startCameraStream(t,n=!0){if(k.getState().isPlaying){console.warn("Already streaming");return}if(k.getState().selectedCamera)console.log("Reusing previous device");else try{await this.updateCameraDevices()}catch(c){k.setState({errorState:Ji(c)});return}const i=k.getState();if(!i.selectedCamera){console.warn("No selected camera!");return}const r=await i.selectedCamera.startStream(),o=r.getVideoTracks()[0],s=o.getSettings();if(!s.width||!s.height)throw new Error("Video doesn't have dimensions!");if(!t.isConnected)throw new Error("Video element needs to be in the document!");k.getState().videoElement||this.setupVideoElement(t),t.srcObject=r,t.width=s.width,t.height=s.height,o.getSettings().facingMode==="environment"?k.setState({mirrorX:!1}):k.setState({mirrorX:!0}),k.setState({videoElement:t}),n&&await this.startPlayback()}async startCapture(){const t=k.getState();if(!t.isCapturing){if(!t.videoElement){console.warn("Missing video element");return}if(!t.selectedCamera){console.warn("No active camera!");return}await this.startPlayback(),k.getState().isPlaying&&(k.setState({isCapturing:!0}),this.#t=t.videoElement.requestVideoFrameCallback(()=>void this.#n()))}}pauseCapture(){const t=k.getState().videoElement;t&&this.#t&&t.cancelVideoFrameCallback(this.#t),k.setState({isCapturing:!1})}async cancelCapture(){await this.resetCapture(),ar.reset(),this.pauseCapture(),k.setState({uiState:Le.SENSING_FRONT})}async resetCapture(){await this.#e.resetCapture(),this.#i()}async stopStream(){console.log("stopStream called");const t=k.getState();if(t.selectedCamera?.stopStream(),!t.videoElement){console.log("no video element");return}t.videoElement.srcObject=null,await this.cancelCapture(),this.pausePlayback()}async finishSideCapture(){return await this.#e.finishSideCapture()}pausePlayback(){console.log("pausePlayback called");const t=k.getState();if(!t.videoElement){k.setState({isPlaying:!1});return}this.pauseCapture(),t.videoElement.pause(),k.setState({isPlaying:!1})}#i(){k.setState({captureRequiresLandscape:!1})}async#n(){const t=k.getState();if(!t.isCapturing||!t.isPlaying)return;if(!t.videoElement){console.error("Missing video element");return}const n=t.callbacks?.onFrameAnalysis,i=typeof n=="function",r=pl(t.videoElement);lr=new ImageData(Uint8ClampedArray.from(r.data),r.width,r.height);const o=await this.#e.analyze(r);if("error"in o){k.setState({errorState:Ji(o.error)});return}const s=ar.getUiState(o);if(i)try{n(o,lr),window.setTimeout(()=>lr=null,0)}catch(a){throw console.warn("onFrameAnalysis callback exception"),a}if(s.key==="DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE"){if(!k.getState().captureRequiresLandscape){this.pauseCapture();const a=Le.DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION;k.setState({uiState:a,captureRequiresLandscape:!0}),await new Promise(c=>setTimeout(c,a.minDuration)),await this.startCapture();return}k.setState({uiState:Le.DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE})}if(s.key==="SIDE_CAPTURED"){this.pauseCapture(),k.setState({uiState:Le.SIDE_CAPTURED}),await new Promise(a=>setTimeout(a,Le.SIDE_CAPTURED.minDuration)),await this.startCapture();return}if(s.key==="DOCUMENT_CAPTURED"){this.pausePlayback(),k.setState({uiState:Le.DOCUMENT_CAPTURED}),await new Promise(c=>setTimeout(c,Le.DOCUMENT_CAPTURED.minDuration));const a=await this.#e.getResult();try{t.callbacks?.onCaptureResult?.(a)}catch(c){console.warn("onCaptureResult callback exception",c)}this.#i();return}k.setState({uiState:s}),this.#t=t.videoElement.requestVideoFrameCallback(()=>void this.#n())}setCallbacks(t){k.setState({callbacks:t})}setMirrorX(t){k.setState({mirrorX:t})}subscribe=k.subscribe;getState=k.getState;async destroy(){ur(),await this.#e.terminateWorker()}}async function ds(e){try{if(!window.isSecureContext)throw new Error(qi`
|
|
14
|
+
`;let c="";if(n.useBlob){const u=new Blob([a+o],{type:rs});c=URL.createObjectURL(u)}else c=`data:${rs},`+encodeURIComponent(a+o);i(c)}).catch(r))},sl=async(e=window.location.href)=>{const t=await ol(e+"/resources/capture-worker.js"),n=new Worker(t);n.onerror=r=>{console.error("Worker error:",r)};const i=Bo(n);return await i.setResourceUrl(e+"/resources"),i};let al=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");const os="capture-userid";function cl(){const e=localStorage.getItem(os);if(e)return e;const t=al();return localStorage.setItem(os,t),t}function ul(e){return{licenseId:e.licenseId,licensee:e.licensee,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}async function ll(e){try{return await(await fetch("https://baltazar.microblink.com/api/v1/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(ul(e))})).json()}catch(t){throw console.error(t),t}}class fl{#e;#t;constructor(t,n){this.#e=t,this.#t=n}analyze=async t=>{const n=rl(t);return await this.#e.analyze(Vo(n,[n.data.buffer]))};finishSideCapture=async()=>await this.#t.finishSideCapture();getResult=async()=>await this.#t.getResult();getSettings=async()=>await this.#t.getSettings();updateSettings=async t=>{const i={...await this.getSettings(),...t};await this.#t.updateSettings(i)};resetCapture=async()=>{await this.#t.reset()};async terminateWorker(){await this.#e.terminate()}}async function ss(e){const t=await sl(e.resourceUrl),n=cl(),i=await t.loadWasm(),r=await i.initializeWithLicenseKey(e.licenseKey,n,!1);if(r.unlockResult===Vi.RequiresServerPermission){const u=await ll(r),l=await i.submitServerPermission(JSON.stringify(u));if(console.log(l),l.status!==Ki.Ok)throw new Error("Server unlock not ok.")}const o=await t.createAnalyzer();if(!o)throw new Error("Failed to create analyzer");let a={...await o.getSettings(),minimumDocumentDpi:220};return e.analyzerSettings&&Object.assign(a,e.analyzerSettings),await o.updateSettings(a),new fl(t,o)}const De=Symbol.for("@ts-pattern/matcher"),as=Symbol.for("@ts-pattern/isVariadic"),Jn="@ts-pattern/anonymous-select-key",ir=e=>!!(e&&typeof e=="object"),ei=e=>e&&!!e[De],Te=(e,t,n)=>{if(ei(e)){const i=e[De](),{matched:r,selections:o}=i.match(t);return r&&o&&Object.keys(o).forEach(s=>n(s,o[s])),r}if(ir(e)){if(!ir(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let i=[],r=[],o=[];for(const s of e.keys()){const a=e[s];ei(a)&&a[as]?o.push(a):o.length?r.push(a):i.push(a)}if(o.length){if(o.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<i.length+r.length)return!1;const s=t.slice(0,i.length),a=r.length===0?[]:t.slice(-r.length),c=t.slice(i.length,r.length===0?1/0:-r.length);return i.every((u,l)=>Te(u,s[l],n))&&r.every((u,l)=>Te(u,a[l],n))&&(o.length===0||Te(o[0],c,n))}return e.length===t.length&&e.every((s,a)=>Te(s,t[a],n))}return Object.keys(e).every(i=>{const r=e[i];return(i in t||ei(o=r)&&o[De]().matcherType==="optional")&&Te(r,t[i],n);var o})}return Object.is(t,e)},Oe=e=>{var t,n,i;return ir(e)?ei(e)?(t=(n=(i=e[De]()).getSelectionKeys)==null?void 0:n.call(i))!=null?t:[]:Array.isArray(e)?En(e,Oe):En(Object.values(e),Oe):[]},En=(e,t)=>e.reduce((n,i)=>n.concat(t(i)),[]);function dl(...e){if(e.length===1){const[t]=e;return n=>Te(t,n,()=>{})}if(e.length===2){const[t,n]=e;return Te(t,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${e.length}.`)}function je(e){return Object.assign(e,{optional:()=>or(e),and:t=>ue(e,t),or:t=>cs(e,t),select:t=>t===void 0?Sn(e):Sn(t,e)})}function rr(e){return Object.assign((t=>Object.assign(t,{*[Symbol.iterator](){yield Object.assign(t,{[as]:!0})}}))(e),{optional:()=>rr(or(e)),select:t=>rr(t===void 0?Sn(e):Sn(t,e))})}function or(e){return je({[De]:()=>({match:t=>{let n={};const i=(r,o)=>{n[r]=o};return t===void 0?(Oe(e).forEach(r=>i(r,void 0)),{matched:!0,selections:n}):{matched:Te(e,t,i),selections:n}},getSelectionKeys:()=>Oe(e),matcherType:"optional"})})}const gl=(e,t)=>{for(const n of e)if(!t(n))return!1;return!0},Ml=(e,t)=>{for(const[n,i]of e.entries())if(!t(i,n))return!1;return!0};function ue(...e){return je({[De]:()=>({match:t=>{let n={};const i=(r,o)=>{n[r]=o};return{matched:e.every(r=>Te(r,t,i)),selections:n}},getSelectionKeys:()=>En(e,Oe),matcherType:"and"})})}function cs(...e){return je({[De]:()=>({match:t=>{let n={};const i=(r,o)=>{n[r]=o};return En(e,Oe).forEach(r=>i(r,void 0)),{matched:e.some(r=>Te(r,t,i)),selections:n}},getSelectionKeys:()=>En(e,Oe),matcherType:"or"})})}function J(e){return{[De]:()=>({match:t=>({matched:!!e(t)})})}}function Sn(...e){const t=typeof e[0]=="string"?e[0]:void 0,n=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return je({[De]:()=>({match:i=>{let r={[t??Jn]:i};return{matched:n===void 0||Te(n,i,(o,s)=>{r[o]=s}),selections:r}},getSelectionKeys:()=>[t??Jn].concat(n===void 0?[]:Oe(n))})})}function nt(e){return typeof e=="number"}function zt(e){return typeof e=="string"}function Nt(e){return typeof e=="bigint"}const us=je(J(function(e){return!0})),hl=us,_t=e=>Object.assign(je(e),{startsWith:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&i.startsWith(n)))));var n},endsWith:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&i.endsWith(n)))));var n},minLength:t=>_t(ue(e,(n=>J(i=>zt(i)&&i.length>=n))(t))),maxLength:t=>_t(ue(e,(n=>J(i=>zt(i)&&i.length<=n))(t))),includes:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&i.includes(n)))));var n},regex:t=>{return _t(ue(e,(n=t,J(i=>zt(i)&&!!i.match(n)))));var n}}),yl=_t(J(zt)),it=e=>Object.assign(je(e),{between:(t,n)=>it(ue(e,((i,r)=>J(o=>nt(o)&&i<=o&&r>=o))(t,n))),lt:t=>it(ue(e,(n=>J(i=>nt(i)&&i<n))(t))),gt:t=>it(ue(e,(n=>J(i=>nt(i)&&i>n))(t))),lte:t=>it(ue(e,(n=>J(i=>nt(i)&&i<=n))(t))),gte:t=>it(ue(e,(n=>J(i=>nt(i)&&i>=n))(t))),int:()=>it(ue(e,J(t=>nt(t)&&Number.isInteger(t)))),finite:()=>it(ue(e,J(t=>nt(t)&&Number.isFinite(t)))),positive:()=>it(ue(e,J(t=>nt(t)&&t>0))),negative:()=>it(ue(e,J(t=>nt(t)&&t<0)))}),ml=it(J(nt)),Tt=e=>Object.assign(je(e),{between:(t,n)=>Tt(ue(e,((i,r)=>J(o=>Nt(o)&&i<=o&&r>=o))(t,n))),lt:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i<n))(t))),gt:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i>n))(t))),lte:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i<=n))(t))),gte:t=>Tt(ue(e,(n=>J(i=>Nt(i)&&i>=n))(t))),positive:()=>Tt(ue(e,J(t=>Nt(t)&&t>0))),negative:()=>Tt(ue(e,J(t=>Nt(t)&&t<0)))}),Nl=Tt(J(Nt)),Tl=je(J(function(e){return typeof e=="boolean"})),Ll=je(J(function(e){return typeof e=="symbol"})),jl=je(J(function(e){return e==null}));var Al={__proto__:null,matcher:De,optional:or,array:function(...e){return rr({[De]:()=>({match:t=>{if(!Array.isArray(t))return{matched:!1};if(e.length===0)return{matched:!0};const n=e[0];let i={};if(t.length===0)return Oe(n).forEach(o=>{i[o]=[]}),{matched:!0,selections:i};const r=(o,s)=>{i[o]=(i[o]||[]).concat([s])};return{matched:t.every(o=>Te(n,o,r)),selections:i}},getSelectionKeys:()=>e.length===0?[]:Oe(e[0])})})},set:function(...e){return je({[De]:()=>({match:t=>{if(!(t instanceof Set))return{matched:!1};let n={};if(t.size===0)return{matched:!0,selections:n};if(e.length===0)return{matched:!0};const i=(o,s)=>{n[o]=(n[o]||[]).concat([s])},r=e[0];return{matched:gl(t,o=>Te(r,o,i)),selections:n}},getSelectionKeys:()=>e.length===0?[]:Oe(e[0])})})},map:function(...e){return je({[De]:()=>({match:t=>{if(!(t instanceof Map))return{matched:!1};let n={};if(t.size===0)return{matched:!0,selections:n};const i=(a,c)=>{n[a]=(n[a]||[]).concat([c])};if(e.length===0)return{matched:!0};var r;if(e.length===1)throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${(r=e[0])==null?void 0:r.toString()}`);const[o,s]=e;return{matched:Ml(t,(a,c)=>{const u=Te(o,c,i),l=Te(s,a,i);return u&&l}),selections:n}},getSelectionKeys:()=>e.length===0?[]:[...Oe(e[0]),...Oe(e[1])]})})},intersection:ue,union:cs,not:function(e){return je({[De]:()=>({match:t=>({matched:!Te(e,t,()=>{})}),getSelectionKeys:()=>[],matcherType:"not"})})},when:J,select:Sn,any:us,_:hl,string:yl,number:ml,bigint:Nl,boolean:Tl,symbol:Ll,nullish:jl,instanceOf:function(e){return je(J(function(t){return n=>n instanceof t}(e)))},shape:function(e){return je(J(dl(e)))}};const sr={matched:!1,value:void 0};function El(e){return new ti(e,sr)}class ti{constructor(t,n){this.input=void 0,this.state=void 0,this.input=t,this.state=n}with(...t){if(this.state.matched)return this;const n=t[t.length-1],i=[t[0]];let r;t.length===3&&typeof t[1]=="function"?(i.push(t[0]),r=t[1]):t.length>2&&i.push(...t.slice(1,t.length-1));let o=!1,s={};const a=(u,l)=>{o=!0,s[u]=l},c=!i.some(u=>Te(u,this.input,a))||r&&!r(this.input)?sr:{matched:!0,value:n(o?Jn in s?s[Jn]:s:this.input,this.input)};return new ti(this.input,c)}when(t,n){if(this.state.matched)return this;const i=!!t(this.input);return new ti(this.input,i?{matched:!0,value:n(this.input,this.input)}:sr)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){return this.run()}run(){if(this.state.matched)return this.state.value;let t;try{t=JSON.stringify(this.input)}catch{t=this.input}throw new Error(`Pattern matching error: no pattern matches value ${t}`)}returnType(){return this}}const Le={PROCESSING:{key:"PROCESSING",reticleType:"processing",minDuration:1e3},SIDE_CAPTURED:{key:"SIDE_CAPTURED",reticleType:"flip",minDuration:3e3},DOCUMENT_CAPTURED:{key:"DOCUMENT_CAPTURED",reticleType:"done",minDuration:1e3},SENSING_FRONT:{key:"SENSING_FRONT",reticleType:"searching",minDuration:1e3},SENSING_BACK:{key:"SENSING_BACK",reticleType:"searching",minDuration:1e3},DOCUMENT_FRAMING_CAMERA_TOO_FAR:{key:"DOCUMENT_FRAMING_CAMERA_TOO_FAR",reticleType:"error",minDuration:1500},DOCUMENT_FRAMING_CAMERA_TOO_CLOSE:{key:"DOCUMENT_FRAMING_CAMERA_TOO_CLOSE",reticleType:"error",minDuration:1500},DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION:{key:"DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION",reticleType:"rotate",minDuration:3e3},DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE:{key:"DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE",reticleType:"error",minDuration:1500},DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP:{key:"DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP",reticleType:"error",minDuration:1500},DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE:{key:"DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE",reticleType:"error",minDuration:1500},LIGHTING_TOO_DARK:{key:"LIGHTING_TOO_DARK",reticleType:"error",minDuration:1500},LIGHTING_TOO_BRIGHT:{key:"LIGHTING_TOO_BRIGHT",reticleType:"error",minDuration:1500},BLUR_DETECTED:{key:"BLUR_DETECTED",reticleType:"error",minDuration:1500},GLARE_DETECTED:{key:"GLARE_DETECTED",reticleType:"error",minDuration:1500},OCCLUDED:{key:"OCCLUDED",reticleType:"error",minDuration:1500},WRONG_SIDE:{key:"WRONG_SIDE",reticleType:"error",minDuration:1500}};class Sl{timeWindow=3e3;decayRate=.95;eventStack=[];currentUiState=Le.SENSING_FRONT;currentStateStartTime=performance.now();reset(){this.eventStack=[]}getUiState(t){const n=performance.now(),i={stateKey:this.getUiStateKeyFromResult(t),timeStamp:n,currentWeight:1};if(i.stateKey==="SIDE_CAPTURED"||i.stateKey==="DOCUMENT_CAPTURED")return this.eventStack=[],Le[i.stateKey];this.eventStack.push(i);const r={};if(this.eventStack.forEach(s=>{if(n-s.timeStamp>this.timeWindow){this.eventStack.shift();return}const a=s.timeStamp/n;s.currentWeight*=this.decayRate*a,r[s.stateKey]||(r[s.stateKey]=[]),r[s.stateKey].push(s.currentWeight)}),n-this.currentStateStartTime<this.currentUiState.minDuration)return this.currentUiState;const o={};for(const s in r){const a=s,c=s.length/this.eventStack.length,u=r[a].reduce((l,g)=>l+g,0);o[a]=u*c}try{const s=es(o),a=Le[s];return a!==this.currentUiState&&(this.currentUiState=a,this.currentStateStartTime=n),a}catch{return this.currentUiState}}getUiStateKeyFromResult(t){return El(t).with({frameCaptured:!0,captureState:Al.when(n=>n==="first-side-capture-in-progress"||n==="second-side-capture-in-progress")},()=>"PROCESSING").with({captureState:"first-side-capture-in-progress",frameAnalysisStatus:{framingStatus:"no-document"}},()=>"SENSING_FRONT").with({captureState:"second-side-capture-in-progress",frameAnalysisStatus:{framingStatus:"no-document"}},()=>"SENSING_BACK").with({captureState:"document-captured"},()=>"DOCUMENT_CAPTURED").with({captureState:"side-captured"},()=>"SIDE_CAPTURED").with({frameAnalysisStatus:{sideAnalysisStatus:"side-already-captured"}},()=>"WRONG_SIDE").with({frameAnalysisStatus:{framingStatus:"camera-angle-too-steep"}},()=>"DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP").with({frameAnalysisStatus:{framingStatus:"camera-too-close"}},()=>"DOCUMENT_FRAMING_CAMERA_TOO_CLOSE").with({frameAnalysisStatus:{framingStatus:"camera-orientation-unsuitable"}},()=>"DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE").with({frameAnalysisStatus:{framingStatus:"camera-too-far"}},()=>"DOCUMENT_FRAMING_CAMERA_TOO_FAR").with({frameAnalysisStatus:{framingStatus:"document-too-close-to-frame-edge"}},()=>"DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE").with({frameAnalysisStatus:{lightingStatus:"too-bright"}},()=>"LIGHTING_TOO_BRIGHT").with({frameAnalysisStatus:{lightingStatus:"too-dark"}},()=>"LIGHTING_TOO_DARK").with({frameAnalysisStatus:{blurStatus:"blur-detected"}},()=>"BLUR_DETECTED").with({frameAnalysisStatus:{glareStatus:"glare-detected"}},()=>"GLARE_DETECTED").with({frameAnalysisStatus:{occlusionStatus:"occluded"}},()=>"OCCLUDED").otherwise(()=>"SENSING_FRONT")}}const ar=new Sl,cr=document.createElement("canvas"),ni=cr.getContext("2d",{willReadFrequently:!0,alpha:!1});function pl(e,t=!1){if(!ni)throw new Error("CanvasRenderingContext2D is missing!");const n=e.videoWidth,i=e.videoHeight;return cr.width=n,cr.height=i,ni.drawImage(e,0,0,n,i),t&&ni.scale(-1,1),ni.getImageData(0,0,n,i)}const Il=e=>(t,n,i)=>{const r=i.subscribe;return i.subscribe=(s,a,c)=>{let u=s;if(a){const l=c?.equalityFn||Object.is;let g=s(i.getState());u=f=>{const h=s(f);if(!l(g,h)){const d=g;a(g=h,d)}},c?.fireImmediately&&a(g,g)}return r(u)},e(t,n,i)},ls=e=>{let t;const n=new Set,i=(c,u)=>{const l=typeof c=="function"?c(t):c;if(!Object.is(l,t)){const g=t;t=u??typeof l!="object"?l:Object.assign({},t,l),n.forEach(f=>f(t,g))}},r=()=>t,a={setState:i,getState:r,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{n.clear()}};return t=e(i,r,a),a},wl=e=>e?ls(e):ls,fs={cameras:[],videoElement:null,selectedCamera:null,isPlaying:!1,isCapturing:!1,isSwappingCamera:!1,isQueryingCameras:!1,callbacks:{},mirrorX:!1,uiState:structuredClone(Le.SENSING_FRONT),captureRequiresLandscape:!1,initialized:!1,errorState:null,analyzerSettings:{}},k=wl()(Il(()=>structuredClone(fs)));k.subscribe(e=>e.videoElement,(e,t)=>{!e&&t&&ur()});const ur=()=>{console.log("resetting zustand store"),k.getState().cameras.forEach(e=>{e.stopStream()}),k.setState(structuredClone(fs))};let lr,ii;class xl{#e;#t;constructor(t){this.#e=t}setupVideoElement(t){new Ct(i=>{i[0].connected||this.destroy()}).observe(t),t.playsInline=!0,t.setAttribute("muted","")}async updateAnalyzerSettings(t){if(k.getState().isCapturing){console.warn("Cancel the capture process using `cancelCapture()` before updating settings");return}try{await this.#e.updateSettings(t)}catch(n){console.error("Error updating analyzer settings",n)}}async selectCamera(t){const n=k.getState();if(n.selectedCamera===t){console.warn("Already selected");return}if(n.isSwappingCamera)return;const i=n.selectedCamera;k.setState({isSwappingCamera:!0}),i&&i.stopStream(),n.videoElement&&(n.videoElement.srcObject=null);try{const r=await t.startStream();n.videoElement&&(n.videoElement.srcObject=r,n.isPlaying&&await n.videoElement.play()),k.setState({selectedCamera:t,isSwappingCamera:!1})}catch(r){console.error(r)}}async updateCameraDevices(){if(k.getState().isQueryingCameras||k.getState().isSwappingCamera)return;k.setState({isQueryingCameras:!0});const t=await il();if(t.length<1)throw new Error("No capable devices found! Your camera needs to have a minimum resolution of 1920x1080");el(t);const n=tl(t),i=t.find(r=>r.deviceInfo.deviceId===n);k.setState({cameras:t,selectedCamera:i,isQueryingCameras:!1})}async startPlayback(){const t=k.getState();if(!t.isPlaying){if(!t.videoElement){console.warn("No video element present.");return}if(!t.videoElement.srcObject){console.warn("No source present. Start a camera stream first.");return}if(!t.selectedCamera){console.warn("No selected camera");return}await t.selectedCamera.startStream(),await t.videoElement.play(),k.setState({isPlaying:!0}),t.isCapturing===!0&&t.videoElement.requestVideoFrameCallback(()=>void this.#n())}}async startCameraStream(t,n=!0){if(k.getState().isPlaying){console.warn("Already streaming");return}if(k.getState().selectedCamera)console.log("Reusing previous device");else try{await this.updateCameraDevices()}catch(c){k.setState({errorState:Ji(c)});return}const i=k.getState();if(!i.selectedCamera){console.warn("No selected camera!");return}const r=await i.selectedCamera.startStream(),o=r.getVideoTracks()[0],s=o.getSettings();if(!s.width||!s.height)throw new Error("Video doesn't have dimensions!");if(!t.isConnected)throw new Error("Video element needs to be in the document!");k.getState().videoElement||this.setupVideoElement(t),t.srcObject=r,t.width=s.width,t.height=s.height,o.getSettings().facingMode==="environment"?k.setState({mirrorX:!1}):k.setState({mirrorX:!0}),k.setState({videoElement:t}),n&&await this.startPlayback()}async startCapture(){const t=k.getState();if(!t.isCapturing){if(!t.videoElement){console.warn("Missing video element");return}if(!t.selectedCamera){console.warn("No active camera!");return}await this.startPlayback(),k.getState().isPlaying&&(k.setState({isCapturing:!0}),this.#t=t.videoElement.requestVideoFrameCallback(()=>void this.#n()))}}pauseCapture(){const t=k.getState().videoElement;t&&this.#t&&t.cancelVideoFrameCallback(this.#t),k.setState({isCapturing:!1})}async cancelCapture(){await this.resetCapture(),ar.reset(),this.pauseCapture(),k.setState({uiState:Le.SENSING_FRONT})}async resetCapture(){await this.#e.resetCapture(),this.#i()}async stopStream(){console.log("stopStream called");const t=k.getState();if(t.selectedCamera?.stopStream(),!t.videoElement){console.log("no video element");return}t.videoElement.srcObject=null,await this.cancelCapture(),this.pausePlayback()}async finishSideCapture(){return await this.#e.finishSideCapture()}pausePlayback(){console.log("pausePlayback called");const t=k.getState();if(!t.videoElement){k.setState({isPlaying:!1});return}this.pauseCapture(),t.videoElement.pause(),k.setState({isPlaying:!1})}#i(){k.setState({captureRequiresLandscape:!1})}async#n(){const t=k.getState();if(!t.isCapturing||!t.isPlaying)return;if(!t.videoElement){console.error("Missing video element");return}const n=t.callbacks?.onFrameAnalysis,i=typeof n=="function",r=pl(t.videoElement);lr=new ImageData(Uint8ClampedArray.from(r.data),r.width,r.height);const o=await this.#e.analyze(r);if("error"in o){k.setState({errorState:Ji(o.error)});return}const s=ar.getUiState(o);if(i)try{n(o,lr),window.setTimeout(()=>lr=null,0)}catch(a){throw console.warn("onFrameAnalysis callback exception"),a}if(s.key==="DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE"){if(!k.getState().captureRequiresLandscape){this.pauseCapture();const a=Le.DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION;k.setState({uiState:a,captureRequiresLandscape:!0}),await new Promise(c=>setTimeout(c,a.minDuration)),await this.startCapture();return}k.setState({uiState:Le.DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE})}if(s.key==="SIDE_CAPTURED"){this.pauseCapture(),k.setState({uiState:Le.SIDE_CAPTURED}),await new Promise(a=>setTimeout(a,Le.SIDE_CAPTURED.minDuration)),await this.startCapture();return}if(s.key==="DOCUMENT_CAPTURED"){this.pausePlayback(),k.setState({uiState:Le.DOCUMENT_CAPTURED}),await new Promise(c=>setTimeout(c,Le.DOCUMENT_CAPTURED.minDuration));const a=await this.#e.getResult();try{t.callbacks?.onCaptureResult?.(a)}catch(c){console.warn("onCaptureResult callback exception",c)}this.#i();return}k.setState({uiState:s}),this.#t=t.videoElement.requestVideoFrameCallback(()=>void this.#n())}setCallbacks(t){k.setState({callbacks:t})}setMirrorX(t){k.setState({mirrorX:t})}subscribe=k.subscribe;getState=k.getState;async destroy(){ur(),await this.#e.terminateWorker()}}async function ds(e){try{if(!window.isSecureContext)throw new Error(qi`
|
|
15
15
|
Can't load the SDK outside a secure context:
|
|
16
16
|
https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
|
|
17
17
|
`);if(k.getState().initialized&&ii)return console.warn("Already initialized, reusing previous SDK instance."),ii;const{callbacks:t,...n}=e,i=await ss(n),r=await i.getSettings();return k.setState({analyzerSettings:r}),t&&k.setState({callbacks:t}),k.setState({initialized:!0}),ii=new xl(i),ii}catch(t){throw k.setState({errorState:Ji(t)}),t}}const gs={context:void 0,registry:void 0},Dl=(e,t)=>e===t,Fe=Symbol("solid-proxy"),ri=Symbol("solid-track"),oi={equals:Dl};let Ms=Ts;const lt=1,si=2,hs={owned:null,cleanups:null,context:null,owner:null};var ee=null;let fr=null,oe=null,Ae=null,ft=null,ai=0;const[bl,ky]=P(!1);function kt(e,t){const n=oe,i=ee,r=e.length===0,o=t===void 0?i:t,s=r?hs:{owned:null,cleanups:null,context:o?o.context:null,owner:o},a=r?e:()=>e(()=>ye(()=>di(s)));ee=s,oe=null;try{return jt(a,!0)}finally{oe=n,ee=i}}function P(e,t){t=t?Object.assign({},oi,t):oi;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},i=r=>(typeof r=="function"&&(r=r(n.value)),Ns(n,r));return[ms.bind(n),i]}function ys(e,t,n){const i=ui(e,t,!0,lt);Wt(i)}function Be(e,t,n){const i=ui(e,t,!1,lt);Wt(i)}function H(e,t,n){Ms=Ul;const i=ui(e,t,!1,lt);(!n||!n.render)&&(i.user=!0),ft?ft.push(i):Wt(i)}function Y(e,t,n){n=n?Object.assign({},oi,n):oi;const i=ui(e,t,!0,0);return i.observers=null,i.observerSlots=null,i.comparator=n.equals||void 0,Wt(i),ms.bind(i)}function dr(e){return jt(e,!1)}function ye(e){if(oe===null)return e();const t=oe;oe=null;try{return e()}finally{oe=t}}function Ze(e,t,n){const i=Array.isArray(e);let r,o=n&&n.defer;return s=>{let a;if(i){a=Array(e.length);for(let u=0;u<e.length;u++)a[u]=e[u]()}else a=e();if(o){o=!1;return}const c=ye(()=>t(a,r,s));return r=a,c}}function Lt(e){H(()=>ye(e))}function V(e){return ee===null||(ee.cleanups===null?ee.cleanups=[e]:ee.cleanups.push(e)),e}function gr(){return oe}function vl(){return ee}function Ol(e,t){const n=ee,i=oe;ee=e,oe=null;try{return jt(t,!0)}catch(r){Mr(r)}finally{ee=n,oe=i}}function Cl(e){const t=oe,n=ee;return Promise.resolve().then(()=>{oe=t,ee=n;let i;return jt(e,!1),oe=ee=null,i?i.done:void 0})}function zl(){return[bl,Cl]}function Ce(e,t){const n=Symbol("context");return{id:n,Provider:Pl(n),defaultValue:e}}function ze(e){return ee&&ee.context&&ee.context[e.id]!==void 0?ee.context[e.id]:e.defaultValue}function ci(e){const t=Y(e),n=Y(()=>hr(t()));return n.toArray=()=>{const i=n();return Array.isArray(i)?i:i!=null?[i]:[]},n}function ms(){if(this.sources&&this.state)if(this.state===lt)Wt(this);else{const e=Ae;Ae=null,jt(()=>fi(this),!1),Ae=e}if(oe){const e=this.observers?this.observers.length:0;oe.sources?(oe.sources.push(this),oe.sourceSlots.push(e)):(oe.sources=[this],oe.sourceSlots=[e]),this.observers?(this.observers.push(oe),this.observerSlots.push(oe.sources.length-1)):(this.observers=[oe],this.observerSlots=[oe.sources.length-1])}return this.value}function Ns(e,t,n){let i=e.value;return(!e.comparator||!e.comparator(i,t))&&(e.value=t,e.observers&&e.observers.length&&jt(()=>{for(let r=0;r<e.observers.length;r+=1){const o=e.observers[r],s=fr&&fr.running;s&&fr.disposed.has(o),(s?!o.tState:!o.state)&&(o.pure?Ae.push(o):ft.push(o),o.observers&&Ls(o)),s||(o.state=lt)}if(Ae.length>1e6)throw Ae=[],new Error},!1)),t}function Wt(e){if(!e.fn)return;di(e);const t=ee,n=oe,i=ai;oe=ee=e,_l(e,e.value,i),oe=n,ee=t}function _l(e,t,n){let i;try{i=e.fn(t)}catch(r){return e.pure&&(e.state=lt,e.owned&&e.owned.forEach(di),e.owned=null),e.updatedAt=n+1,Mr(r)}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Ns(e,i):e.value=i,e.updatedAt=n)}function ui(e,t,n,i=lt,r){const o={fn:e,state:i,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:ee,context:ee?ee.context:null,pure:n};return ee===null||ee!==hs&&(ee.owned?ee.owned.push(o):ee.owned=[o]),o}function li(e){if(e.state===0)return;if(e.state===si)return fi(e);if(e.suspense&&ye(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<ai);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===lt)Wt(e);else if(e.state===si){const i=Ae;Ae=null,jt(()=>fi(e,t[0]),!1),Ae=i}}function jt(e,t){if(Ae)return e();let n=!1;t||(Ae=[]),ft?n=!0:ft=[],ai++;try{const i=e();return kl(n),i}catch(i){n||(ft=null),Ae=null,Mr(i)}}function kl(e){if(Ae&&(Ts(Ae),Ae=null),e)return;const t=ft;ft=null,t.length&&jt(()=>Ms(t),!1)}function Ts(e){for(let t=0;t<e.length;t++)li(e[t])}function Ul(e){let t,n=0;for(t=0;t<e.length;t++){const i=e[t];i.user?e[n++]=i:li(i)}for(t=0;t<n;t++)li(e[t])}function fi(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const i=e.sources[n];if(i.sources){const r=i.state;r===lt?i!==t&&(!i.updatedAt||i.updatedAt<ai)&&li(i):r===si&&fi(i,t)}}}function Ls(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=si,n.pure?Ae.push(n):ft.push(n),n.observers&&Ls(n))}}function di(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),i=e.sourceSlots.pop(),r=n.observers;if(r&&r.length){const o=r.pop(),s=n.observerSlots.pop();i<r.length&&(o.sourceSlots[s]=i,r[i]=o,n.observerSlots[i]=s)}}if(e.owned){for(t=e.owned.length-1;t>=0;t--)di(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Yl(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Mr(e,t=ee){throw Yl(e)}function hr(e){if(typeof e=="function"&&!e.length)return hr(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const i=hr(e[n]);Array.isArray(i)?t.push.apply(t,i):t.push(i)}return t}return e}function Pl(e,t){return function(i){let r;return Be(()=>r=ye(()=>(ee.context={...ee.context,[e]:i.value},ci(()=>i.children))),void 0),r}}const Rl=Symbol("fallback");function js(e){for(let t=0;t<e.length;t++)e[t]()}function Fl(e,t,n={}){let i=[],r=[],o=[],s=0,a=t.length>1?[]:null;return V(()=>js(o)),()=>{let c=e()||[],u,l;return c[ri],ye(()=>{let f=c.length,h,d,M,y,m,T,N,j,A;if(f===0)s!==0&&(js(o),o=[],i=[],r=[],s=0,a&&(a=[])),n.fallback&&(i=[Rl],r[0]=kt(E=>(o[0]=E,n.fallback())),s=1);else if(s===0){for(r=new Array(f),l=0;l<f;l++)i[l]=c[l],r[l]=kt(g);s=f}else{for(M=new Array(f),y=new Array(f),a&&(m=new Array(f)),T=0,N=Math.min(s,f);T<N&&i[T]===c[T];T++);for(N=s-1,j=f-1;N>=T&&j>=T&&i[N]===c[j];N--,j--)M[j]=r[N],y[j]=o[N],a&&(m[j]=a[N]);for(h=new Map,d=new Array(j+1),l=j;l>=T;l--)A=c[l],u=h.get(A),d[l]=u===void 0?-1:u,h.set(A,l);for(u=T;u<=N;u++)A=i[u],l=h.get(A),l!==void 0&&l!==-1?(M[l]=r[u],y[l]=o[u],a&&(m[l]=a[u]),l=d[l],h.set(A,l)):o[u]();for(l=T;l<f;l++)l in M?(r[l]=M[l],o[l]=y[l],a&&(a[l]=m[l],a[l](l))):r[l]=kt(g);r=r.slice(0,s=f),i=c.slice(0)}return r});function g(f){if(o[l]=f,a){const[h,d]=P(l);return a[l]=d,t(c[l],h)}return t(c[l])}}}function L(e,t){return ye(()=>e(t||{}))}function gi(){return!0}const yr={get(e,t,n){return t===Fe?n:e.get(t)},has(e,t){return t===Fe?!0:e.has(t)},set:gi,deleteProperty:gi,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:gi,deleteProperty:gi}},ownKeys(e){return e.keys()}};function mr(e){return(e=typeof e=="function"?e():e)?e:{}}function Bl(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function q(...e){let t=!1;for(let o=0;o<e.length;o++){const s=e[o];t=t||!!s&&Fe in s,e[o]=typeof s=="function"?(t=!0,Y(s)):s}if(t)return new Proxy({get(o){for(let s=e.length-1;s>=0;s--){const a=mr(e[s])[o];if(a!==void 0)return a}},has(o){for(let s=e.length-1;s>=0;s--)if(o in mr(e[s]))return!0;return!1},keys(){const o=[];for(let s=0;s<e.length;s++)o.push(...Object.keys(mr(e[s])));return[...new Set(o)]}},yr);const n={},i={},r=new Set;for(let o=e.length-1;o>=0;o--){const s=e[o];if(!s)continue;const a=Object.getOwnPropertyNames(s);for(let c=0,u=a.length;c<u;c++){const l=a[c];if(l==="__proto__"||l==="constructor")continue;const g=Object.getOwnPropertyDescriptor(s,l);if(!r.has(l))g.get?(r.add(l),Object.defineProperty(n,l,{enumerable:!0,configurable:!0,get:Bl.bind(i[l]=[g.get.bind(s)])})):(g.value!==void 0&&r.add(l),n[l]=g.value);else{const f=i[l];f?g.get?f.push(g.get.bind(s)):g.value!==void 0&&f.push(()=>g.value):n[l]===void 0&&(n[l]=g.value)}}}return n}function ae(e,...t){if(Fe in e){const r=new Set(t.length>1?t.flat():t[0]),o=t.map(s=>new Proxy({get(a){return s.includes(a)?e[a]:void 0},has(a){return s.includes(a)&&a in e},keys(){return s.filter(a=>a in e)}},yr));return o.push(new Proxy({get(s){return r.has(s)?void 0:e[s]},has(s){return r.has(s)?!1:s in e},keys(){return Object.keys(e).filter(s=>!r.has(s))}},yr)),o}const n={},i=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const o=Object.getOwnPropertyDescriptor(e,r),s=!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable;let a=!1,c=0;for(const u of t)u.includes(r)&&(a=!0,s?i[c][r]=o.value:Object.defineProperty(i[c],r,o)),++c;a||(s?n[r]=o.value:Object.defineProperty(n,r,o))}return[...i,n]}let Hl=0;function Zt(){const e=gs.context;return e?`${e.id}${e.count++}`:`cl-${Hl++}`}const As=e=>`Stale read from <${e}>.`;function Es(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Y(Fl(()=>e.each,e.children,t||void 0))}function he(e){const t=e.keyed,n=Y(()=>e.when,void 0,{equals:(i,r)=>t?i===r:!i==!r});return Y(()=>{const i=n();if(i){const r=e.children;return typeof r=="function"&&r.length>0?ye(()=>r(t?i:()=>{if(!ye(n))throw As("Show");return e.when})):r}return e.fallback},void 0,void 0)}function Nr(e){let t=!1;const n=(o,s)=>o[0]===s[0]&&(t?o[1]===s[1]:!o[1]==!s[1])&&o[2]===s[2],i=ci(()=>e.children),r=Y(()=>{let o=i();Array.isArray(o)||(o=[o]);for(let s=0;s<o.length;s++){const a=o[s].when;if(a)return t=!!o[s].keyed,[s,a,o[s]]}return[-1]},void 0,{equals:n});return Y(()=>{const[o,s,a]=r();if(o<0)return e.fallback;const c=a.children;return typeof c=="function"&&c.length>0?ye(()=>c(t?s:()=>{if(ye(r)[0]!==o)throw As("Match");return a.when})):c},void 0,void 0)}function rt(e){return e}const Ql=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],Gl=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...Ql]),Vl=new Set(["innerHTML","textContent","innerText","children"]),Kl=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),$l=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function Wl(e,t){const n=$l[e];return typeof n=="object"?n[t]?n.$:void 0:n}const Zl=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ql=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),Xl={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function Jl(e,t,n){let i=n.length,r=t.length,o=i,s=0,a=0,c=t[r-1].nextSibling,u=null;for(;s<r||a<o;){if(t[s]===n[a]){s++,a++;continue}for(;t[r-1]===n[o-1];)r--,o--;if(r===s){const l=o<i?a?n[a-1].nextSibling:n[o-a]:c;for(;a<o;)e.insertBefore(n[a++],l)}else if(o===a)for(;s<r;)(!u||!u.has(t[s]))&&t[s].remove(),s++;else if(t[s]===n[o-1]&&n[a]===t[r-1]){const l=t[--r].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--o],l),t[r]=n[o]}else{if(!u){u=new Map;let g=a;for(;g<o;)u.set(n[g],g++)}const l=u.get(t[s]);if(l!=null)if(a<l&&l<o){let g=s,f=1,h;for(;++g<r&&g<o&&!((h=u.get(t[g]))==null||h!==l+f);)f++;if(f>l-a){const d=t[s];for(;a<l;)e.insertBefore(n[a++],d)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}}const Ss="_$DX_DELEGATE";function ef(e,t,n,i={}){let r;return kt(o=>{r=o,t===document?e():G(t,e(),t.firstChild?null:void 0,n)},i.owner),()=>{r(),t.textContent=""}}function ne(e,t,n){let i;const r=()=>{const s=document.createElement("template");return s.innerHTML=e,n?s.content.firstChild.firstChild:s.content.firstChild},o=t?()=>ye(()=>document.importNode(i||(i=r()),!0)):()=>(i||(i=r())).cloneNode(!0);return o.cloneNode=o,o}function tf(e,t=window.document){const n=t[Ss]||(t[Ss]=new Set);for(let i=0,r=e.length;i<r;i++){const o=e[i];n.has(o)||(n.add(o),t.addEventListener(o,uf))}}function At(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function nf(e,t,n,i){i==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,i)}function ge(e,t){t==null?e.removeAttribute("class"):e.className=t}function rf(e,t,n,i){if(i)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const r=n[0];e.addEventListener(t,n[0]=o=>r.call(e,n[1],o))}else e.addEventListener(t,n)}function of(e,t,n={}){const i=Object.keys(t||{}),r=Object.keys(n);let o,s;for(o=0,s=r.length;o<s;o++){const a=r[o];!a||a==="undefined"||t[a]||(Is(e,a,!1),delete n[a])}for(o=0,s=i.length;o<s;o++){const a=i[o],c=!!t[a];!a||a==="undefined"||n[a]===c||!c||(Is(e,a,!0),n[a]=c)}return n}function sf(e,t,n){if(!t)return n?At(e,"style"):t;const i=e.style;if(typeof t=="string")return i.cssText=t;typeof n=="string"&&(i.cssText=n=void 0),n||(n={}),t||(t={});let r,o;for(o in n)t[o]==null&&i.removeProperty(o),delete n[o];for(o in t)r=t[o],r!==n[o]&&(i.setProperty(o,r),n[o]=r);return n}function be(e,t={},n,i){const r={};return i||Be(()=>r.children=qt(e,t.children,r.children)),Be(()=>t.ref&&t.ref(e)),Be(()=>af(e,t,n,!0,r,!0)),r}function ps(e,t,n){return ye(()=>e(t,n))}function G(e,t,n,i){if(n!==void 0&&!i&&(i=[]),typeof t!="function")return qt(e,t,i,n);Be(r=>qt(e,t(),r,n),i)}function af(e,t,n,i,r={},o=!1){t||(t={});for(const s in r)if(!(s in t)){if(s==="children")continue;r[s]=ws(e,s,null,r[s],n,o)}for(const s in t){if(s==="children"){i||qt(e,t.children);continue}const a=t[s];r[s]=ws(e,s,a,r[s],n,o)}}function cf(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Is(e,t,n){const i=t.trim().split(/\s+/);for(let r=0,o=i.length;r<o;r++)e.classList.toggle(i[r],n)}function ws(e,t,n,i,r,o){let s,a,c,u,l;if(t==="style")return sf(e,n,i);if(t==="classList")return of(e,n,i);if(n===i)return i;if(t==="ref")o||n(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);i&&e.removeEventListener(g,i),n&&e.addEventListener(g,n)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);i&&e.removeEventListener(g,i,!0),n&&e.addEventListener(g,n,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),f=Zl.has(g);if(!f&&i){const h=Array.isArray(i)?i[0]:i;e.removeEventListener(g,h)}(f||n)&&(rf(e,g,n,f),f&&tf([g]))}else if(t.slice(0,5)==="attr:")At(e,t.slice(5),n);else if((l=t.slice(0,5)==="prop:")||(c=Vl.has(t))||!r&&((u=Wl(t,e.tagName))||(a=Gl.has(t)))||(s=e.nodeName.includes("-")))l&&(t=t.slice(5),a=!0),t==="class"||t==="className"?ge(e,n):s&&!a&&!c?e[cf(t)]=n:e[u||t]=n;else{const g=r&&t.indexOf(":")>-1&&Xl[t.split(":")[0]];g?nf(e,g,t,n):At(e,Kl[t]||t,n)}return n}function uf(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}});n;){const i=n[t];if(i&&!n.disabled){const r=n[`${t}Data`];if(r!==void 0?i.call(n,r,e):i.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function qt(e,t,n,i,r){for(;typeof n=="function";)n=n();if(t===n)return n;const o=typeof t,s=i!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o==="string"||o==="number")if(o==="number"&&(t=t.toString()),s){let a=n[0];a&&a.nodeType===3?a.data=t:a=document.createTextNode(t),n=Xt(e,n,i,a)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t;else if(t==null||o==="boolean")n=Xt(e,n,i);else{if(o==="function")return Be(()=>{let a=t();for(;typeof a=="function";)a=a();n=qt(e,a,n,i)}),()=>n;if(Array.isArray(t)){const a=[],c=n&&Array.isArray(n);if(Tr(a,t,n,r))return Be(()=>n=qt(e,a,n,i,!0)),()=>n;if(a.length===0){if(n=Xt(e,n,i),s)return n}else c?n.length===0?xs(e,a,i):Jl(e,n,a):(n&&Xt(e),xs(e,a));n=a}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=Xt(e,n,i,t);Xt(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function Tr(e,t,n,i){let r=!1;for(let o=0,s=t.length;o<s;o++){let a=t[o],c=n&&n[o],u;if(!(a==null||a===!0||a===!1))if((u=typeof a)=="object"&&a.nodeType)e.push(a);else if(Array.isArray(a))r=Tr(e,a,c)||r;else if(u==="function")if(i){for(;typeof a=="function";)a=a();r=Tr(e,Array.isArray(a)?a:[a],Array.isArray(c)?c:[c])||r}else e.push(a),r=!0;else{const l=String(a);c&&c.nodeType===3&&c.data===l?e.push(c):e.push(document.createTextNode(l))}}return r}function xs(e,t,n=null){for(let i=0,r=t.length;i<r;i++)e.insertBefore(t[i],n)}function Xt(e,t,n,i){if(n===void 0)return e.textContent="";const r=i||document.createTextNode("");if(t.length){let o=!1;for(let s=t.length-1;s>=0;s--){const a=t[s];if(r!==a){const c=a.parentNode===e;!o&&!s?c?e.replaceChild(r,a):e.insertBefore(r,n):c&&a.remove()}else o=!0}}else e.insertBefore(r,n);return[r]}const lf="http://www.w3.org/2000/svg";function Ds(e,t=!1){return t?document.createElementNS(lf,e):document.createElement(e)}function Lr(e){const{useShadow:t}=e,n=document.createTextNode(""),i=()=>e.mount||document.body,r=vl();let o,s=!!gs.context;return H(()=>{o||(o=Ol(r,()=>Y(()=>e.children)));const a=i();if(a instanceof HTMLHeadElement){const[c,u]=P(!1),l=()=>u(!0);kt(g=>G(a,()=>c()?g():o(),null)),V(l)}else{const c=Ds(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),G(u,o),a.appendChild(c),e.ref&&e.ref(c),V(()=>a.removeChild(c))}},void 0,{render:!s}),n}function pn(e){const[t,n]=ae(e,["component"]),i=Y(()=>t.component);return Y(()=>{const r=i();switch(typeof r){case"function":return ye(()=>r(n));case"string":const o=ql.has(r),s=Ds(r,o);return be(s,n,o),s}})}var ff=function(t){return df(t)&&!gf(t)};function df(e){return!!e&&typeof e=="object"}function gf(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||yf(e)}var Mf=typeof Symbol=="function"&&Symbol.for,hf=Mf?Symbol.for("react.element"):60103;function yf(e){return e.$$typeof===hf}function mf(e){return Array.isArray(e)?[]:{}}function In(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Jt(mf(e),e,t):e}function Nf(e,t,n){return e.concat(t).map(function(i){return In(i,n)})}function Tf(e,t){if(!t.customMerge)return Jt;var n=t.customMerge(e);return typeof n=="function"?n:Jt}function Lf(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function bs(e){return Object.keys(e).concat(Lf(e))}function vs(e,t){try{return t in e}catch{return!1}}function jf(e,t){return vs(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Af(e,t,n){var i={};return n.isMergeableObject(e)&&bs(e).forEach(function(r){i[r]=In(e[r],n)}),bs(t).forEach(function(r){jf(e,r)||(vs(e,r)&&n.isMergeableObject(t[r])?i[r]=Tf(r,n)(e[r],t[r],n):i[r]=In(t[r],n))}),i}function Jt(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Nf,n.isMergeableObject=n.isMergeableObject||ff,n.cloneUnlessOtherwiseSpecified=In;var i=Array.isArray(t),r=Array.isArray(e),o=i===r;return o?i?n.arrayMerge(e,t,n):Af(e,t,n):In(t,n)}Jt.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(i,r){return Jt(i,r,n)},{})};var Ef=Jt,Sf=Ef;const pf=Jo(Sf),jr=Symbol("store-raw"),en=Symbol("store-node"),dt=Symbol("store-has"),Os=Symbol("store-self");function Cs(e){let t=e[Fe];if(!t&&(Object.defineProperty(e,Fe,{value:t=new Proxy(e,xf)}),!Array.isArray(e))){const n=Object.keys(e),i=Object.getOwnPropertyDescriptors(e);for(let r=0,o=n.length;r<o;r++){const s=n[r];i[s].get&&Object.defineProperty(e,s,{enumerable:i[s].enumerable,get:i[s].get.bind(t)})}}return t}function Et(e){let t;return e!=null&&typeof e=="object"&&(e[Fe]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function tn(e,t=new Set){let n,i,r,o;if(n=e!=null&&e[jr])return n;if(!Et(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let s=0,a=e.length;s<a;s++)r=e[s],(i=tn(r,t))!==r&&(e[s]=i)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const s=Object.keys(e),a=Object.getOwnPropertyDescriptors(e);for(let c=0,u=s.length;c<u;c++)o=s[c],!a[o].get&&(r=e[o],(i=tn(r,t))!==r&&(e[o]=i))}return e}function Mi(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function wn(e,t,n){if(e[t])return e[t];const[i,r]=P(n,{equals:!1,internal:!0});return i.$=r,e[t]=i}function If(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Fe||t===en||(delete n.value,delete n.writable,n.get=()=>e[Fe][t]),n}function zs(e){gr()&&wn(Mi(e,en),Os)()}function wf(e){return zs(e),Reflect.ownKeys(e)}const xf={get(e,t,n){if(t===jr)return e;if(t===Fe)return n;if(t===ri)return zs(e),n;const i=Mi(e,en),r=i[t];let o=r?r():e[t];if(t===en||t===dt||t==="__proto__")return o;if(!r){const s=Object.getOwnPropertyDescriptor(e,t);gr()&&(typeof o!="function"||e.hasOwnProperty(t))&&!(s&&s.get)&&(o=wn(i,t,o)())}return Et(o)?Cs(o):o},has(e,t){return t===jr||t===Fe||t===ri||t===en||t===dt||t==="__proto__"?!0:(gr()&&wn(Mi(e,dt),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:wf,getOwnPropertyDescriptor:If};function He(e,t,n,i=!1){if(!i&&e[t]===n)return;const r=e[t],o=e.length;n===void 0?(delete e[t],e[dt]&&e[dt][t]&&r!==void 0&&e[dt][t].$()):(e[t]=n,e[dt]&&e[dt][t]&&r===void 0&&e[dt][t].$());let s=Mi(e,en),a;if((a=wn(s,t,r))&&a.$(()=>n),Array.isArray(e)&&e.length!==o){for(let c=e.length;c<o;c++)(a=s[c])&&a.$();(a=wn(s,"length",o))&&a.$(e.length)}(a=s[Os])&&a.$()}function _s(e,t){const n=Object.keys(t);for(let i=0;i<n.length;i+=1){const r=n[i];He(e,r,t[r])}}function Df(e,t){if(typeof t=="function"&&(t=t(e)),t=tn(t),Array.isArray(t)){if(e===t)return;let n=0,i=t.length;for(;n<i;n++){const r=t[n];e[n]!==r&&He(e,n,r)}He(e,"length",i)}else _s(e,t)}function xn(e,t,n=[]){let i,r=e;if(t.length>1){i=t.shift();const s=typeof i,a=Array.isArray(e);if(Array.isArray(i)){for(let c=0;c<i.length;c++)xn(e,[i[c]].concat(t),n);return}else if(a&&s==="function"){for(let c=0;c<e.length;c++)i(e[c],c)&&xn(e,[c].concat(t),n);return}else if(a&&s==="object"){const{from:c=0,to:u=e.length-1,by:l=1}=i;for(let g=c;g<=u;g+=l)xn(e,[g].concat(t),n);return}else if(t.length>1){xn(e[i],t,[i].concat(n));return}r=e[i],n=[i].concat(n)}let o=t[0];typeof o=="function"&&(o=o(r,n),o===r)||i===void 0&&o==null||(o=tn(o),i===void 0||Et(r)&&Et(o)&&!Array.isArray(o)?_s(r,o):He(e,i,o))}function Ar(...[e,t]){const n=tn(e||{}),i=Array.isArray(n),r=Cs(n);function o(...s){dr(()=>{i&&s.length===1?Df(n,s[0]):xn(n,s)})}return[r,o]}const Er=Symbol("store-root");function nn(e,t,n,i,r){const o=t[n];if(e===o)return;if(n!==Er&&(!Et(e)||!Et(o)||r&&e[r]!==o[r])){He(t,n,e);return}if(Array.isArray(e)){if(e.length&&o.length&&(!i||r&&e[0]&&e[0][r]!=null)){let c,u,l,g,f,h,d,M;for(l=0,g=Math.min(o.length,e.length);l<g&&(o[l]===e[l]||r&&o[l]&&e[l]&&o[l][r]===e[l][r]);l++)nn(e[l],o,l,i,r);const y=new Array(e.length),m=new Map;for(g=o.length-1,f=e.length-1;g>=l&&f>=l&&(o[g]===e[f]||r&&o[l]&&e[l]&&o[g][r]===e[f][r]);g--,f--)y[f]=o[g];if(l>f||l>g){for(u=l;u<=f;u++)He(o,u,e[u]);for(;u<e.length;u++)He(o,u,y[u]),nn(e[u],o,u,i,r);o.length>e.length&&He(o,"length",e.length);return}for(d=new Array(f+1),u=f;u>=l;u--)h=e[u],M=r&&h?h[r]:h,c=m.get(M),d[u]=c===void 0?-1:c,m.set(M,u);for(c=l;c<=g;c++)h=o[c],M=r&&h?h[r]:h,u=m.get(M),u!==void 0&&u!==-1&&(y[u]=o[c],u=d[u],m.set(M,u));for(u=l;u<e.length;u++)u in y?(He(o,u,y[u]),nn(e[u],o,u,i,r)):He(o,u,e[u])}else for(let c=0,u=e.length;c<u;c++)nn(e[c],o,c,i,r);o.length>e.length&&He(o,"length",e.length);return}const s=Object.keys(e);for(let c=0,u=s.length;c<u;c++)nn(e[s[c]],o,s[c],i,r);const a=Object.keys(o);for(let c=0,u=a.length;c<u;c++)e[a[c]]===void 0&&He(o,a[c],void 0)}function ks(e,t={}){const{merge:n,key:i="id"}=t,r=tn(e);return o=>{if(!Et(o)||!Et(r))return r;const s=nn(r,{[Er]:o},Er,n,i);return s===void 0?o:s}}const bf={scan_the_front_side:"Scan the front side of the document",flip_document:"Flip the document",scan_the_back_side:"Scan the back side of the document",scanning_wrong_side:"Scanning wrong side",move_closer:"Move closer",move_farther:"Move farther",camera_angle_too_steep:"Keep document parallel to phone",document_too_close_to_edge:"Move farther",rotate_phone_animation:"Rotate card or turn phone to landscape",rotate_phone:"Rotate phone or card",lightning_too_bright:"Move to spot with less lighting",lightning_too_dark:"Move to brighter spot",blur_detected:"Keep document and phone still",glare_detected:"Tilt or move document to remove reflection",occluded:"Keep the document fully visible",need_help_tooltip:"Need help?",onboarding_field_visible_title:"Keep all the details visible",onboarding_field_visible_details:"Make sure you keep the document well lit. All document fields should be visible on the camera screen.",tutorial_fields_visible_title:"Keep all the fields visible",tutorial_fields_visible_start:"Start scanning",tutorial_fields_visible_details:"Make sure you aren’t covering parts of the document with a finger, including the bottom lines. Also, watch out for hologram reflections that go over the document fields.",tutorial_harsh_light_title:"Watch out for harsh light",tutorial_harsh_light_details:"Avoid direct harsh light because it reflects from the document and can make parts of the document unreadable. If you can’t read data on the document, it won’t be visible to the camera either.",tutorial_keep_still_title:"Keep still while scanning",tutorial_keep_still_details:"Try to keep the phone and document still while scanning. Moving either can blur the image and make data on the document unreadable.",camera_unavailable:"Camera Unavailable",camera_permission_error:"App doesn't have permission to use the camera, please change privacy settings",settings:"Settings",camera_media_capture_error:"Unable to capture media",camera_unable_to_resume_session:"Unable to resume",camera_query_in_progress:"Selecting best camera, please wait",done:"Done",cancel:"Cancel",back:"Back",next:"Next",ok:"OK",dismiss:"Dismiss"},Us=Ce(),vf=e=>{const[t,n]=Ar(structuredClone({...bf,...e.userStrings})),i={t,updateLocalization:n};return L(Us.Provider,{value:i,get children(){return e.children}})};function Ut(){const e=ze(Us);if(!e)throw new Error("LocalizationProvider not in scope.");return e}function Sr(e){return(...t)=>{for(const n of e)n&&n(...t)}}function Of(e){return(...t)=>{for(let n=e.length-1;n>=0;n--){const i=e[n];i&&i(...t)}}}var p=e=>typeof e=="function"&&!e.length?e():e,Ys=e=>Array.isArray(e)?e:e?[e]:[];function Cf(e,...t){return typeof e=="function"?e(...t):e}var zf=V;function _f(e,t,n,i){return e.addEventListener(t,n,i),zf(e.removeEventListener.bind(e,t,n,i))}function kf(e,t,n,i){const r=()=>{Ys(p(e)).forEach(o=>{o&&Ys(p(t)).forEach(s=>_f(o,s,n,i))})};typeof e=="function"?H(r):Be(r)}var pr=Symbol("fallback");function Ps(e){for(const t of e)t.dispose()}function Uf(e,t,n,i={}){const r=new Map;return V(()=>Ps(r.values())),()=>{const s=e()||[];return s[ri],ye(()=>{if(!s.length)return Ps(r.values()),r.clear(),i.fallback?[kt(g=>(r.set(pr,{dispose:g}),i.fallback()))]:[];const a=new Array(s.length),c=r.get(pr);if(!r.size||c){c?.dispose(),r.delete(pr);for(let l=0;l<s.length;l++){const g=s[l],f=t(g,l);o(a,g,l,f)}return a}const u=new Set(r.keys());for(let l=0;l<s.length;l++){const g=s[l],f=t(g,l);u.delete(f);const h=r.get(f);h?(a[l]=h.mapped,h.setIndex?.(l),h.setItem(()=>g)):o(a,g,l,f)}for(const l of u)r.get(l)?.dispose(),r.delete(l);return a})};function o(s,a,c,u){kt(l=>{const[g,f]=P(a),h={setItem:f,dispose:l};if(n.length>1){const[d,M]=P(c);h.setIndex=M,h.mapped=n(g,d)}else h.mapped=n(g);r.set(u,h),s[c]=h.mapped})}}function Yf(e){const{by:t}=e;return Y(Uf(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function Pf(e){const t=typeof e.on=="function"||Array.isArray(e.on)?e.on:()=>e.on;return Y(Ze(t,(n,i)=>{const r=e.children;return typeof r=="function"&&r.length>0?r(n,i):r}))}function hi(){return!0}var Rf={get(e,t,n){return t===Fe?n:e.get(t)},has(e,t){return e.has(t)},set:hi,deleteProperty:hi,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:hi,deleteProperty:hi}},ownKeys(e){return e.keys()}},Ff=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Rs(e){const t={};let n;for(;n=Ff.exec(e);)t[n[1]]=n[2];return t}function Fs(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Rs(e)}else typeof t=="string"&&(t=Rs(t));return{...e,...t}}var Ir=(e,t,n)=>{let i;for(const r of e){const o=p(r)[t];i?o&&(i=n(i,o)):i=o}return i};function Bf(...e){const t=Array.isArray(e[0]),n=t?e[0]:e;if(n.length===1)return n[0];const i=t&&e[1]?.reverseEventHandlers?Of:Sr,r={};for(const s of n){const a=p(s);for(const c in a)if(c[0]==="o"&&c[1]==="n"&&c[2]){const u=a[c],l=c.toLowerCase(),g=typeof u=="function"?u:Array.isArray(u)?u.length===1?u[0]:u[0].bind(void 0,u[1]):void 0;g?r[l]?r[l].push(g):r[l]=[g]:delete r[l]}}const o=q(...n);return new Proxy({get(s){if(typeof s!="string")return Reflect.get(o,s);if(s==="style")return Ir(n,"style",Fs);if(s==="ref"){const a=[];for(const c of n){const u=p(c)[s];typeof u=="function"&&a.push(u)}return i(a)}if(s[0]==="o"&&s[1]==="n"&&s[2]){const a=r[s.toLowerCase()];return a?i(a):Reflect.get(o,s)}return s==="class"||s==="className"?Ir(n,s,(a,c)=>`${a} ${c}`):s==="classList"?Ir(n,s,(a,c)=>({...a,...c})):Reflect.get(o,s)},has(s){return Reflect.has(o,s)},keys(){return Object.keys(o)}},Rf)}function _e(...e){return Sr(e)}var Bs=e=>e instanceof Element;function wr(e,t){if(t(e))return e;if(typeof e=="function"&&!e.length)return wr(e(),t);if(Array.isArray(e))for(const n of e){const i=wr(n,t);if(i)return i}return null}function Hf(e,t=Bs,n=Bs){const i=Y(e);return Y(()=>wr(i(),t))}function Hs(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}function Qf(e){return typeof e=="number"}function Gf(e){return Array.isArray(e)}function rn(e){return Object.prototype.toString.call(e)==="[object String]"}function xr(e){return typeof e=="function"}function on(e){return t=>`${e()}-${t}`}function Qe(e,t){return e?e===t||e.contains(t):!1}function Dn(e,t=!1){const{activeElement:n}=ke(e);if(!n?.nodeName)return null;if(Qs(n)&&n.contentDocument)return Dn(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const r=ke(n).getElementById(i);if(r)return r}}return n}function Dr(e){return ke(e).defaultView||window}function ke(e){return e?e.ownerDocument||e:document}function Qs(e){return e.tagName==="IFRAME"}var Gs=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(Gs||{});function Vs(e){return typeof window>"u"||window.navigator==null?!1:window.navigator.userAgentData?.brands.some(t=>e.test(t.brand))||e.test(window.navigator.userAgent)}function br(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function bn(){return br(/^Mac/i)}function Vf(){return br(/^iPhone/i)}function Kf(){return br(/^iPad/i)||bn()&&navigator.maxTouchPoints>1}function Ks(){return Vf()||Kf()}function $f(){return bn()||Ks()}function Wf(){return Vs(/AppleWebKit/i)&&!Zf()}function Zf(){return Vs(/Chrome/i)}function me(e,t){return t&&(xr(t)?t(e):t[0](t[1],e)),e?.defaultPrevented}function Ge(e){return t=>{for(const n of e)me(t,n)}}function qf(e){return bn()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Ee(e){if(e)if(Xf())e.focus({preventScroll:!0});else{const t=Jf(e);e.focus(),ed(t)}}var yi=null;function Xf(){if(yi==null){yi=!1;try{document.createElement("div").focus({get preventScroll(){return yi=!0,!0}})}catch{}}return yi}function Jf(e){let t=e.parentNode;const n=[],i=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==i;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return i instanceof HTMLElement&&n.push({element:i,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft}),n}function ed(e){for(const{element:t,scrollTop:n,scrollLeft:i}of e)t.scrollTop=n,t.scrollLeft=i}var $s=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],td=[...$s,'[tabindex]:not([tabindex="-1"]):not([disabled])'],vr=$s.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",nd=td.join(':not([hidden]):not([tabindex="-1"]),');function Ws(e,t){const i=Array.from(e.querySelectorAll(vr)).filter(Zs);return t&&Zs(e)&&i.unshift(e),i.forEach((r,o)=>{if(Qs(r)&&r.contentDocument){const s=r.contentDocument.body,a=Ws(s,!1);i.splice(o,1,...a)}}),i}function Zs(e){return qs(e)&&!id(e)}function qs(e){return e.matches(vr)&&Or(e)}function id(e){return parseInt(e.getAttribute("tabindex")||"0",10)<0}function Or(e,t){return e.nodeName!=="#comment"&&rd(e)&&od(e,t)&&(!e.parentElement||Or(e.parentElement,e))}function rd(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let i=t!=="none"&&n!=="hidden"&&n!=="collapse";if(i){if(!e.ownerDocument.defaultView)return i;const{getComputedStyle:r}=e.ownerDocument.defaultView,{display:o,visibility:s}=r(e);i=o!=="none"&&s!=="hidden"&&s!=="collapse"}return i}function od(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function sd(e,t){return t.some(n=>n.contains(e))}function ad(e,t,n){const i=t?.tabbable?nd:vr,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(o){return t?.from?.contains(o)?NodeFilter.FILTER_REJECT:o.matches(i)&&Or(o)&&(!n||sd(o,n))&&(!t?.accept||t.accept(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t?.from&&(r.currentNode=t.from),r}function cd(){}function ud(e){return[e.clientX,e.clientY]}function ld(e,t){const[n,i]=e;let r=!1;const o=t.length;for(let s=o,a=0,c=s-1;a<s;c=a++){const[u,l]=t[a],[g,f]=t[c],[,h]=t[c===0?s-1:c-1]||[0,0],d=(l-f)*(n-u)-(u-g)*(i-l);if(f<l){if(i>=f&&i<l){if(d===0)return!0;d>0&&(i===f?i>h&&(r=!r):r=!r)}}else if(l<f){if(i>l&&i<=f){if(d===0)return!0;d<0&&(i===f?i<h&&(r=!r):r=!r)}}else if(i==l&&(n>=g&&n<=u||n>=u&&n<=g))return!0}return r}function Me(e,t){return q(e,t)}var vn=new Map,Xs=new Set;function Js(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let i=vn.get(n.target);i||(i=new Set,vn.set(n.target,i),n.target.addEventListener("transitioncancel",t)),i.add(n.propertyName)},t=n=>{if(!n.target)return;const i=vn.get(n.target);if(i&&(i.delete(n.propertyName),i.size===0&&(n.target.removeEventListener("transitioncancel",t),vn.delete(n.target)),vn.size===0)){for(const r of Xs)r();Xs.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Js():document.addEventListener("DOMContentLoaded",Js));function ea(e,t){const n=ta(e,t,"left"),i=ta(e,t,"top"),r=t.offsetWidth,o=t.offsetHeight;let s=e.scrollLeft,a=e.scrollTop;const c=s+e.offsetWidth,u=a+e.offsetHeight;n<=s?s=n:n+r>c&&(s+=n+r-c),i<=a?a=i:i+o>u&&(a+=i+o-u),e.scrollLeft=s,e.scrollTop=a}function ta(e,t,n){const i=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[i],t.offsetParent!==e);){if(t.offsetParent.contains(e)){r-=e[i];break}t=t.offsetParent}return r}var fd={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};function Cr(e){let t=e.startIndex??0;const n=e.startLevel??0,i=[],r=c=>{if(c==null)return"";const u=e.getKey??"key",l=rn(u)?c[u]:u(c);return l!=null?String(l):""},o=c=>{if(c==null)return"";const u=e.getTextValue??"textValue",l=rn(u)?c[u]:u(c);return l!=null?String(l):""},s=c=>{if(c==null)return!1;const u=e.getDisabled??"disabled";return(rn(u)?c[u]:u(c))??!1},a=c=>{if(c!=null)return rn(e.getSectionChildren)?c[e.getSectionChildren]:e.getSectionChildren?.(c)};for(const c of e.dataSource){if(rn(c)||Qf(c)){i.push({type:"item",rawValue:c,key:String(c),textValue:String(c),disabled:s(c),level:n,index:t}),t++;continue}if(a(c)!=null){i.push({type:"section",rawValue:c,key:"",textValue:"",disabled:!1,level:n,index:t}),t++;const u=a(c)??[];if(u.length>0){const l=Cr({dataSource:u,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:t,startLevel:n+1});i.push(...l),t+=l.length}}else i.push({type:"item",rawValue:c,key:r(c),textValue:o(c),disabled:s(c),level:n,index:t}),t++}return i}/*!
|