barcode-detector
Version:
A Barcode Detection API polyfill that uses ZXing webassembly under the hood
2 lines (1 loc) • 40.5 kB
JavaScript
var BarcodeDetectionAPI=(function(_){"use strict";var rr=_=>{throw TypeError(_)};var nr=(_,M,F)=>M.has(_)||rr("Cannot "+F);var ar=(_,M,F)=>(nr(_,M,"read from private field"),F?F.call(_):M.get(_)),or=(_,M,F)=>M.has(_)?rr("Cannot add the same private member more than once"):M instanceof WeakSet?M.add(_):M.set(_,F),ir=(_,M,F,yt)=>(nr(_,M,"write to private field"),yt?yt.call(_,F):M.set(_,F),F);var it,he;const M=[["Aztec","M"],["Codabar","L"],["Code39","L"],["Code93","L"],["Code128","L"],["DataBar","L"],["DataBarExpanded","L"],["DataMatrix","M"],["EAN-8","L"],["EAN-13","L"],["ITF","L"],["MaxiCode","M"],["PDF417","M"],["QRCode","M"],["UPC-A","L"],["UPC-E","L"],["MicroQRCode","M"],["rMQRCode","M"],["DXFilmEdge","L"],["DataBarLimited","L"]],F=M.map(([i])=>i),yt=F.filter((i,f)=>M[f][1]==="L"),sr=F.filter((i,f)=>M[f][1]==="M");function Rt(i){switch(i){case"Linear-Codes":return yt.reduce((f,h)=>f|Rt(h),0);case"Matrix-Codes":return sr.reduce((f,h)=>f|Rt(h),0);case"Any":return(1<<M.length)-1;case"None":return 0;default:return 1<<F.indexOf(i)}}function ur(i){if(i===0)return"None";const f=31-Math.clz32(i);return F[f]}function cr(i){return i.reduce((f,h)=>f|Rt(h),0)}const lr=["LocalAverage","GlobalHistogram","FixedThreshold","BoolCast"];function fr(i){return lr.indexOf(i)}const te=["Unknown","ASCII","ISO8859_1","ISO8859_2","ISO8859_3","ISO8859_4","ISO8859_5","ISO8859_6","ISO8859_7","ISO8859_8","ISO8859_9","ISO8859_10","ISO8859_11","ISO8859_13","ISO8859_14","ISO8859_15","ISO8859_16","Cp437","Cp1250","Cp1251","Cp1252","Cp1256","Shift_JIS","Big5","GB2312","GB18030","EUC_JP","EUC_KR","UTF16BE","UTF16BE","UTF8","UTF16LE","UTF32BE","UTF32LE","BINARY"];function dr(i){return i==="UnicodeBig"?te.indexOf("UTF16BE"):te.indexOf(i)}const hr=["Text","Binary","Mixed","GS1","ISO15434","UnknownECI"];function pr(i){return hr[i]}const yr=["Ignore","Read","Require"];function vr(i){return yr.indexOf(i)}const mr=["Plain","ECI","HRI","Hex","Escaped"];function gr(i){return mr.indexOf(i)}const vt={formats:[],tryHarder:!0,tryRotate:!0,tryInvert:!0,tryDownscale:!0,tryDenoise:!1,binarizer:"LocalAverage",isPure:!1,downscaleFactor:3,downscaleThreshold:500,minLineCount:2,maxNumberOfSymbols:255,tryCode39ExtendedMode:!0,returnErrors:!1,eanAddOnSymbol:"Ignore",textMode:"HRI",characterSet:"Unknown"};function ee(i){return{...i,formats:cr(i.formats),binarizer:fr(i.binarizer),eanAddOnSymbol:vr(i.eanAddOnSymbol),textMode:gr(i.textMode),characterSet:dr(i.characterSet)}}function wr(i){return{...i,format:ur(i.format),contentType:pr(i.contentType),eccLevel:i.ecLevel}}const br="2.2.4",$r="fba4e9503fee4518ca2e89510baeea9bcc36dc8d",Cr={locateFile:(i,f)=>{const h=i.match(/_(.+?)\.wasm$/);return h?`https://fastly.jsdelivr.net/npm/zxing-wasm@2.2.4/dist/${h[1]}/${i}`:f+i}},mt=new WeakMap;function Tr(i,f){return Object.is(i,f)||Object.keys(i).length===Object.keys(f).length&&Object.keys(i).every(h=>Object.hasOwn(f,h)&&i[h]===f[h])}function re(i,{overrides:f,equalityFn:h=Tr,fireImmediately:C=!1}={}){var l;const[D,A]=(l=mt.get(i))!=null?l:[Cr],R=f!=null?f:D;let S;if(C){if(A&&(S=h(D,R)))return A;const B=i({...R});return mt.set(i,[R,B]),B}(S!=null?S:h(D,R))||mt.set(i,[R])}function Pr(i){mt.delete(i)}async function Er(i,f,h=vt){const C={...vt,...h},l=await re(i,{fireImmediately:!0});let D,A;if("width"in f&&"height"in f&&"data"in f){const{data:S,data:{byteLength:B},width:H,height:Y}=f;A=l._malloc(B),l.HEAPU8.set(S,A),D=l.readBarcodesFromPixmap(A,H,Y,ee(C))}else{let S,B;if("buffer"in f)[S,B]=[f.byteLength,f];else if("byteLength"in f)[S,B]=[f.byteLength,new Uint8Array(f)];else if("size"in f)[S,B]=[f.size,new Uint8Array(await f.arrayBuffer())];else throw new TypeError("Invalid input type");A=l._malloc(S),l.HEAPU8.set(B,A),D=l.readBarcodesFromImage(A,S,ee(C))}l._free(A);const R=[];for(let S=0;S<D.size();++S)R.push(wr(D.get(S)));return R}({...vt,formats:[...vt.formats]});async function Bt(i={}){var f,h,C,l=i,D=!!globalThis.window,A=typeof Bun<"u",R=!!globalThis.WorkerGlobalScope;!((h=globalThis.process)===null||h===void 0||(h=h.versions)===null||h===void 0)&&h.node&&((C=globalThis.process)===null||C===void 0?void 0:C.type)!="renderer";var S="./this.program",B,H="";function Y(t){return l.locateFile?l.locateFile(t,H):H+t}var nt,Z;if(D||R||A){try{H=new URL(".",B).href}catch{}R&&(Z=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),nt=async t=>{var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)}}var st=console.log.bind(console),k=console.error.bind(console),Q,gt=!1,pe,ye,J,N,wt,ut,ct,T,ve,me,ge=!1;function we(){var t=Dt.buffer;J=new Int8Array(t),wt=new Int16Array(t),l.HEAPU8=N=new Uint8Array(t),ut=new Uint16Array(t),ct=new Int32Array(t),T=new Uint32Array(t),ve=new Float32Array(t),me=new Float64Array(t)}function Xr(){if(l.preRun)for(typeof l.preRun=="function"&&(l.preRun=[l.preRun]);l.preRun.length;)an(l.preRun.shift());be(Ce)}function qr(){ge=!0,pt.xa()}function Yr(){if(l.postRun)for(typeof l.postRun=="function"&&(l.postRun=[l.postRun]);l.postRun.length;)nn(l.postRun.shift());be($e)}function Ut(t){var e,r;(e=l.onAbort)===null||e===void 0||e.call(l,t),t="Aborted("+t+")",k(t),gt=!0,t+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(t);throw(r=ye)===null||r===void 0||r(n),n}var bt;function Zr(){return Y("zxing_reader.wasm")}function Qr(t){if(t==bt&&Q)return new Uint8Array(Q);if(Z)return Z(t);throw"both async and sync fetching of the wasm failed"}async function Jr(t){if(!Q)try{var e=await nt(t);return new Uint8Array(e)}catch{}return Qr(t)}async function Kr(t,e){try{var r=await Jr(t),n=await WebAssembly.instantiate(r,e);return n}catch(a){k(`failed to asynchronously prepare wasm: ${a}`),Ut(a)}}async function tn(t,e,r){if(!t&&WebAssembly.instantiateStreaming)try{var n=fetch(e,{credentials:"same-origin"}),a=await WebAssembly.instantiateStreaming(n,r);return a}catch(o){k(`wasm streaming compile failed: ${o}`),k("falling back to ArrayBuffer instantiation")}return Kr(e,r)}function en(){var t={a:ja};return t}async function rn(){function t(o,s){return pt=o.exports,Ba(pt),we(),pt}function e(o){return t(o.instance)}var r=en();if(l.instantiateWasm)return new Promise((o,s)=>{l.instantiateWasm(r,(u,c)=>{o(t(u))})});bt!=null||(bt=Zr());var n=await tn(Q,bt,r),a=e(n);return a}var be=t=>{for(;t.length>0;)t.shift()(l)},$e=[],nn=t=>$e.push(t),Ce=[],an=t=>Ce.push(t),m=t=>Ne(t),g=()=>ze(),$t=[],Ct=0,on=t=>{var e=new Vt(t);return e.get_caught()||(e.set_caught(!0),Ct--),e.set_rethrown(!1),$t.push(e),Xe(t),He(t)},z=0,sn=()=>{v(0,0);var t=$t.pop();Ge(t.excPtr),z=0};class Vt{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){T[this.ptr+4>>2]=e}get_type(){return T[this.ptr+4>>2]}set_destructor(e){T[this.ptr+8>>2]=e}get_destructor(){return T[this.ptr+8>>2]}set_caught(e){e=e?1:0,J[this.ptr+12]=e}get_caught(){return J[this.ptr+12]!=0}set_rethrown(e){e=e?1:0,J[this.ptr+13]=e}get_rethrown(){return J[this.ptr+13]!=0}init(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r)}set_adjusted_ptr(e){T[this.ptr+16>>2]=e}get_adjusted_ptr(){return T[this.ptr+16>>2]}}var Tt=t=>ke(t),Wt=t=>{var e=z;if(!e)return Tt(0),0;var r=new Vt(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return Tt(0),e;for(var a of t){if(a===0||a===n)break;var o=r.ptr+16;if(qe(a,n,o))return Tt(a),e}return Tt(n),e},un=()=>Wt([]),cn=t=>Wt([t]),ln=(t,e)=>Wt([t,e]),fn=()=>{var t=$t.pop();t||Ut("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||($t.push(t),t.set_rethrown(!0),t.set_caught(!1),Ct++),z=e,z},dn=(t,e,r)=>{var n=new Vt(t);throw n.init(e,r),z=t,Ct++,z},hn=()=>Ct,pn=t=>{throw z||(z=t),z},yn=()=>Ut(""),Pt={},Ht=t=>{for(;t.length;){var e=t.pop(),r=t.pop();r(e)}};function lt(t){return this.fromWireType(T[t>>2])}var at={},K={},Et={},vn=class extends Error{constructor(t){super(t),this.name="InternalError"}},Ot=t=>{throw new vn(t)},tt=(t,e,r)=>{t.forEach(u=>Et[u]=e);function n(u){var c=r(u);c.length!==t.length&&Ot("Mismatched type converter count");for(var d=0;d<t.length;++d)V(t[d],c[d])}var a=new Array(e.length),o=[],s=0;{const u=e;for(let c=0;c<u.length;++c){const d=u[c];K.hasOwnProperty(d)?a[c]=K[d]:(o.push(d),at.hasOwnProperty(d)||(at[d]=[]),at[d].push(()=>{a[c]=K[d],++s,s===o.length&&n(a)}))}}o.length===0&&n(a)},mn=t=>{var e=Pt[t];delete Pt[t];var r=e.rawConstructor,n=e.rawDestructor,a=e.fields,o=a.map(s=>s.getterReturnType).concat(a.map(s=>s.setterArgumentType));tt([t],o,s=>{var u={};{const c=a;for(let d=0;d<c.length;++d){const p=c[d],y=s[d],$=p.getter,E=p.getterContext,I=s[d+a.length],x=p.setter,O=p.setterContext;u[p.fieldName]={read:P=>y.fromWireType($(E,P)),write:(P,rt)=>{var L=[];x(O,P,I.toWireType(L,rt)),Ht(L)},optional:y.optional}}}return[{name:e.name,fromWireType:c=>{var d={};for(var p in u)d[p]=u[p].read(c);return n(c),d},toWireType:(c,d)=>{for(var p in u)if(!(p in d)&&!u[p].optional)throw new TypeError(`Missing field: "${p}"`);var y=r();for(p in u)u[p].write(y,d[p]);return c!==null&&c.push(n,y),y},readValueFromPointer:lt,destructorFunction:n}]})},gn=(t,e,r,n,a)=>{},j=t=>{for(var e="";;){var r=N[t++];if(!r)return e;e+=String.fromCharCode(r)}},ft=class extends Error{constructor(t){super(t),this.name="BindingError"}},b=t=>{throw new ft(t)};function wn(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=e.name;if(t||b(`type "${n}" must have a positive integer typeid pointer`),K.hasOwnProperty(t)){if(r.ignoreDuplicateRegistrations)return;b(`Cannot register type '${n}' twice`)}if(K[t]=e,delete Et[t],at.hasOwnProperty(t)){var a=at[t];delete at[t],a.forEach(o=>o())}}function V(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return wn(t,e,r)}var bn=(t,e,r,n)=>{e=j(e),V(t,{name:e,fromWireType:function(a){return!!a},toWireType:function(a,o){return o?r:n},readValueFromPointer:function(a){return this.fromWireType(N[a])},destructorFunction:null})},$n=t=>({count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}),kt=t=>{function e(r){return r.$$.ptrType.registeredClass.name}b(e(t)+" instance already deleted")},Nt=!1,Te=t=>{},Cn=t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)},Pe=t=>{t.count.value-=1;var e=t.count.value===0;e&&Cn(t)},dt=t=>globalThis.FinalizationRegistry?(Nt=new FinalizationRegistry(e=>{Pe(e.$$)}),dt=e=>{var r=e.$$,n=!!r.smartPtr;if(n){var a={$$:r};Nt.register(e,a,e)}return e},Te=e=>Nt.unregister(e),dt(t)):(dt=e=>e,t),Tn=()=>{let t=_t.prototype;Object.assign(t,{isAliasOf(r){if(!(this instanceof _t)||!(r instanceof _t))return!1;var n=this.$$.ptrType.registeredClass,a=this.$$.ptr;r.$$=r.$$;for(var o=r.$$.ptrType.registeredClass,s=r.$$.ptr;n.baseClass;)a=n.upcast(a),n=n.baseClass;for(;o.baseClass;)s=o.upcast(s),o=o.baseClass;return n===o&&a===s},clone(){if(this.$$.ptr||kt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var r=dt(Object.create(Object.getPrototypeOf(this),{$$:{value:$n(this.$$)}}));return r.$$.count.value+=1,r.$$.deleteScheduled=!1,r},delete(){this.$$.ptr||kt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&b("Object already scheduled for deletion"),Te(this),Pe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||kt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&b("Object already scheduled for deletion"),this.$$.deleteScheduled=!0,this}});const e=Symbol.dispose;e&&(t[e]=t.delete)};function _t(){}var zt=(t,e)=>Object.defineProperty(e,"name",{value:t}),Ee={},Oe=(t,e,r)=>{if(t[e].overloadTable===void 0){var n=t[e];t[e]=function(){for(var a=arguments.length,o=new Array(a),s=0;s<a;s++)o[s]=arguments[s];return t[e].overloadTable.hasOwnProperty(o.length)||b(`Function '${r}' called with an invalid number of arguments (${o.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[o.length].apply(this,o)},t[e].overloadTable=[],t[e].overloadTable[n.argCount]=n}},_e=(t,e,r)=>{l.hasOwnProperty(t)?((r===void 0||l[t].overloadTable!==void 0&&l[t].overloadTable[r]!==void 0)&&b(`Cannot register public name '${t}' twice`),Oe(l,t,t),l[t].overloadTable.hasOwnProperty(r)&&b(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),l[t].overloadTable[r]=e):(l[t]=e,l[t].argCount=r)},Pn=48,En=57,On=t=>{t=t.replace(/[^a-zA-Z0-9_]/g,"$");var e=t.charCodeAt(0);return e>=Pn&&e<=En?`_${t}`:t};function _n(t,e,r,n,a,o,s,u){this.name=t,this.constructor=e,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=s,this.downcast=u,this.pureVirtualFunctions=[]}var Gt=(t,e,r)=>{for(;e!==r;)e.upcast||b(`Expected null or instance of ${r.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t},Xt=t=>{if(t===null)return"null";var e=typeof t;return e==="object"||e==="array"||e==="function"?t.toString():""+t};function Sn(t,e){if(e===null)return this.isReference&&b(`null is not a valid ${this.name}`),0;e.$$||b(`Cannot pass "${Xt(e)}" as a ${this.name}`),e.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=e.$$.ptrType.registeredClass,n=Gt(e.$$.ptr,r,this.registeredClass);return n}function xn(t,e){var r;if(e===null)return this.isReference&&b(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),t!==null&&t.push(this.rawDestructor,r),r):0;(!e||!e.$$)&&b(`Cannot pass "${Xt(e)}" as a ${this.name}`),e.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&b(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var n=e.$$.ptrType.registeredClass;if(r=Gt(e.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&b("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?r=e.$$.smartPtr:b(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)r=e.$$.smartPtr;else{var a=e.clone();r=this.rawShare(r,W.toHandle(()=>a.delete())),t!==null&&t.push(this.rawDestructor,r)}break;default:b("Unsupporting sharing policy")}return r}function In(t,e){if(e===null)return this.isReference&&b(`null is not a valid ${this.name}`),0;e.$$||b(`Cannot pass "${Xt(e)}" as a ${this.name}`),e.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&b(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var r=e.$$.ptrType.registeredClass,n=Gt(e.$$.ptr,r,this.registeredClass);return n}var Se=(t,e,r)=>{if(e===r)return t;if(r.baseClass===void 0)return null;var n=Se(t,e,r.baseClass);return n===null?null:r.downcast(n)},Dn={},Mn=(t,e)=>{for(e===void 0&&b("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e},An=(t,e)=>(e=Mn(t,e),Dn[e]),St=(t,e)=>{(!e.ptrType||!e.ptr)&&Ot("makeClassHandle requires ptr and ptrType");var r=!!e.smartPtrType,n=!!e.smartPtr;return r!==n&&Ot("Both smartPtrType and smartPtr must be specified"),e.count={value:1},dt(Object.create(t,{$$:{value:e,writable:!0}}))};function Fn(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var r=An(this.registeredClass,e);if(r!==void 0){if(r.$$.count.value===0)return r.$$.ptr=e,r.$$.smartPtr=t,r.clone();var n=r.clone();return this.destructor(t),n}function a(){return this.isSmartPointer?St(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):St(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var o=this.registeredClass.getActualType(e),s=Ee[o];if(!s)return a.call(this);var u;this.isConst?u=s.constPointerType:u=s.pointerType;var c=Se(e,this.registeredClass,u.registeredClass);return c===null?a.call(this):this.isSmartPointer?St(u.registeredClass.instancePrototype,{ptrType:u,ptr:c,smartPtrType:this,smartPtr:t}):St(u.registeredClass.instancePrototype,{ptrType:u,ptr:c})}var Rn=()=>{Object.assign(xt.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){var e;(e=this.rawDestructor)===null||e===void 0||e.call(this,t)},readValueFromPointer:lt,fromWireType:Fn})};function xt(t,e,r,n,a,o,s,u,c,d,p){this.name=t,this.registeredClass=e,this.isReference=r,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=s,this.rawGetPointee=u,this.rawConstructor=c,this.rawShare=d,this.rawDestructor=p,!a&&e.baseClass===void 0?n?(this.toWireType=Sn,this.destructorFunction=null):(this.toWireType=In,this.destructorFunction=null):this.toWireType=xn}var xe=(t,e,r)=>{l.hasOwnProperty(t)||Ot("Replacing nonexistent public symbol"),l[t].overloadTable!==void 0&&r!==void 0?l[t].overloadTable[r]=e:(l[t]=e,l[t].argCount=r)},X={},Bn=(t,e,r)=>{t=t.replace(/p/g,"i");var n=X[t];return n(e,...r)},Ie=[],w=t=>{var e=Ie[t];return e||(Ie[t]=e=Qe.get(t)),e},jn=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(t.includes("j"))return Bn(t,e,r);var n=w(e),a=n(...r);return a},Ln=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return jn(t,e,a,r)}},U=function(t,e){t=j(t);function r(){if(t.includes("j"))return Ln(t,e);var a=w(e);return a}var n=r();return typeof n!="function"&&b(`unknown function pointer with signature ${t}: ${e}`),n};class Un extends Error{}var De=t=>{var e=We(t),r=j(e);return q(e),r},It=(t,e)=>{var r=[],n={};function a(o){if(!n[o]&&!K[o]){if(Et[o]){Et[o].forEach(a);return}r.push(o),n[o]=!0}}throw e.forEach(a),new Un(`${t}: `+r.map(De).join([", "]))},Vn=(t,e,r,n,a,o,s,u,c,d,p,y,$)=>{p=j(p),o=U(a,o),u&&(u=U(s,u)),d&&(d=U(c,d)),$=U(y,$);var E=On(p);_e(E,function(){It(`Cannot construct ${p} due to unbound types`,[n])}),tt([t,e,r],n?[n]:[],I=>{I=I[0];var x,O;n?(x=I.registeredClass,O=x.instancePrototype):O=_t.prototype;var P=zt(p,function(){if(Object.getPrototypeOf(this)!==rt)throw new ft(`Use 'new' to construct ${p}`);if(L.constructor_body===void 0)throw new ft(`${p} has no accessible constructor`);for(var tr=arguments.length,At=new Array(tr),Ft=0;Ft<tr;Ft++)At[Ft]=arguments[Ft];var er=L.constructor_body[At.length];if(er===void 0)throw new ft(`Tried to invoke ctor of ${p} with invalid number of parameters (${At.length}) - expected (${Object.keys(L.constructor_body).toString()}) parameters instead!`);return er.apply(this,At)}),rt=Object.create(O,{constructor:{value:P}});P.prototype=rt;var L=new _n(p,P,rt,$,x,o,u,d);if(L.baseClass){var G,Mt;(Mt=(G=L.baseClass).__derivedClasses)!==null&&Mt!==void 0||(G.__derivedClasses=[]),L.baseClass.__derivedClasses.push(L)}var $o=new xt(p,L,!0,!1,!1),Je=new xt(p+"*",L,!1,!1,!1),Ke=new xt(p+" const*",L,!1,!0,!1);return Ee[t]={pointerType:Je,constPointerType:Ke},xe(E,P),[$o,Je,Ke]})},qt=(t,e)=>{for(var r=[],n=0;n<t;n++)r.push(T[e+n*4>>2]);return r};function Wn(t){for(var e=1;e<t.length;++e)if(t[e]!==null&&t[e].destructorFunction===void 0)return!0;return!1}function Yt(t,e,r,n,a,o){var s=e.length;s<2&&b("argTypes array size mismatch! Must at least get return value and 'this' types!");var u=e[1]!==null&&r!==null,c=Wn(e),d=!e[0].isVoid,p=s-2,y=new Array(p),$=[],E=[],I=function(){E.length=0;var x;$.length=u?2:1,$[0]=a,u&&(x=e[1].toWireType(E,this),$[1]=x);for(var O=0;O<p;++O)y[O]=e[O+2].toWireType(E,O<0||arguments.length<=O?void 0:arguments[O]),$.push(y[O]);var P=n(...$);function rt(L){if(c)Ht(E);else for(var G=u?1:2;G<e.length;G++){var Mt=G===1?x:y[G-2];e[G].destructorFunction!==null&&e[G].destructorFunction(Mt)}if(d)return e[0].fromWireType(L)}return rt(P)};return zt(t,I)}var Hn=(t,e,r,n,a,o)=>{var s=qt(e,r);a=U(n,a),tt([],[t],u=>{u=u[0];var c=`constructor ${u.name}`;if(u.registeredClass.constructor_body===void 0&&(u.registeredClass.constructor_body=[]),u.registeredClass.constructor_body[e-1]!==void 0)throw new ft(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${u.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return u.registeredClass.constructor_body[e-1]=()=>{It(`Cannot construct ${u.name} due to unbound types`,s)},tt([],s,d=>(d.splice(1,0,null),u.registeredClass.constructor_body[e-1]=Yt(c,d,null,a,o),[])),[]})},Me=t=>{t=t.trim();const e=t.indexOf("(");return e===-1?t:t.slice(0,e)},kn=(t,e,r,n,a,o,s,u,c,d)=>{var p=qt(r,n);e=j(e),e=Me(e),o=U(a,o),tt([],[t],y=>{y=y[0];var $=`${y.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),u&&y.registeredClass.pureVirtualFunctions.push(e);function E(){It(`Cannot call ${$} due to unbound types`,p)}var I=y.registeredClass.instancePrototype,x=I[e];return x===void 0||x.overloadTable===void 0&&x.className!==y.name&&x.argCount===r-2?(E.argCount=r-2,E.className=y.name,I[e]=E):(Oe(I,e,$),I[e].overloadTable[r-2]=E),tt([],p,O=>{var P=Yt($,O,y,o,s);return I[e].overloadTable===void 0?(P.argCount=r-2,I[e]=P):I[e].overloadTable[r-2]=P,[]}),[]})},Ae=[],et=[0,1,,1,null,1,!0,1,!1,1],Zt=t=>{t>9&&--et[t+1]===0&&(et[t]=void 0,Ae.push(t))},W={toValue:t=>(t||b(`Cannot use deleted val. handle = ${t}`),et[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=Ae.pop()||et.length;return et[e]=t,et[e+1]=1,e}}}},Fe={name:"emscripten::val",fromWireType:t=>{var e=W.toValue(t);return Zt(t),e},toWireType:(t,e)=>W.toHandle(e),readValueFromPointer:lt,destructorFunction:null},Nn=t=>V(t,Fe),zn=(t,e)=>{switch(e){case 4:return function(r){return this.fromWireType(ve[r>>2])};case 8:return function(r){return this.fromWireType(me[r>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},Gn=(t,e,r)=>{e=j(e),V(t,{name:e,fromWireType:n=>n,toWireType:(n,a)=>a,readValueFromPointer:zn(e,r),destructorFunction:null})},Xn=(t,e,r,n,a,o,s,u)=>{var c=qt(e,r);t=j(t),t=Me(t),a=U(n,a),_e(t,function(){It(`Cannot call ${t} due to unbound types`,c)},e-1),tt([],c,d=>{var p=[d[0],null].concat(d.slice(1));return xe(t,Yt(t,p,null,a,o),e-1),[]})},qn=(t,e,r)=>{switch(e){case 1:return r?n=>J[n]:n=>N[n];case 2:return r?n=>wt[n>>1]:n=>ut[n>>1];case 4:return r?n=>ct[n>>2]:n=>T[n>>2];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},Yn=(t,e,r,n,a)=>{e=j(e);const o=n===0;let s=c=>c;if(o){var u=32-8*r;s=c=>c<<u>>>u,a=s(a)}V(t,{name:e,fromWireType:s,toWireType:(c,d)=>d,readValueFromPointer:qn(e,r,n!==0),destructorFunction:null})},Zn=(t,e,r)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],a=n[e];function o(s){var u=T[s>>2],c=T[s+4>>2];return new a(J.buffer,c,u)}r=j(r),V(t,{name:r,fromWireType:o,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},Qn=Object.assign({optional:!0},Fe),Jn=(t,e)=>{V(t,Qn)},Kn=(t,e,r,n)=>{if(!(n>0))return 0;for(var a=r,o=r+n-1,s=0;s<t.length;++s){var u=t.codePointAt(s);if(u<=127){if(r>=o)break;e[r++]=u}else if(u<=2047){if(r+1>=o)break;e[r++]=192|u>>6,e[r++]=128|u&63}else if(u<=65535){if(r+2>=o)break;e[r++]=224|u>>12,e[r++]=128|u>>6&63,e[r++]=128|u&63}else{if(r+3>=o)break;e[r++]=240|u>>18,e[r++]=128|u>>12&63,e[r++]=128|u>>6&63,e[r++]=128|u&63,s++}}return e[r]=0,r-a},ot=(t,e,r)=>Kn(t,N,e,r),Re=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++r):e+=3}return e},Be=globalThis.TextDecoder&&new TextDecoder,je=(t,e,r,n)=>{var a=e+r;if(n)return a;for(;t[e]&&!(e>=a);)++e;return e},Le=function(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;var a=je(t,e,r,n);if(a-e>16&&t.buffer&&Be)return Be.decode(t.subarray(e,a));for(var o="";e<a;){var s=t[e++];if(!(s&128)){o+=String.fromCharCode(s);continue}var u=t[e++]&63;if((s&224)==192){o+=String.fromCharCode((s&31)<<6|u);continue}var c=t[e++]&63;if((s&240)==224?s=(s&15)<<12|u<<6|c:s=(s&7)<<18|u<<12|c<<6|t[e++]&63,s<65536)o+=String.fromCharCode(s);else{var d=s-65536;o+=String.fromCharCode(55296|d>>10,56320|d&1023)}}return o},ta=(t,e,r)=>t?Le(N,t,e,r):"",ea=(t,e)=>{e=j(e),V(t,{name:e,fromWireType(r){var n=T[r>>2],a=r+4,o;return o=ta(a,n,!0),q(r),o},toWireType(r,n){n instanceof ArrayBuffer&&(n=new Uint8Array(n));var a,o=typeof n=="string";o||ArrayBuffer.isView(n)&&n.BYTES_PER_ELEMENT==1||b("Cannot pass non-string to std::string"),o?a=Re(n):a=n.length;var s=Kt(4+a+1),u=s+4;return T[s>>2]=a,o?ot(n,u,a+1):N.set(n,u),r!==null&&r.push(q,s),s},readValueFromPointer:lt,destructorFunction(r){q(r)}})},Ue=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,ra=(t,e,r)=>{var n=t>>1,a=je(ut,n,e/2,r);if(a-n>16&&Ue)return Ue.decode(ut.subarray(n,a));for(var o="",s=n;s<a;++s){var u=ut[s];o+=String.fromCharCode(u)}return o},na=(t,e,r)=>{if(r!=null||(r=2147483647),r<2)return 0;r-=2;for(var n=e,a=r<t.length*2?r/2:t.length,o=0;o<a;++o){var s=t.charCodeAt(o);wt[e>>1]=s,e+=2}return wt[e>>1]=0,e-n},aa=t=>t.length*2,oa=(t,e,r)=>{for(var n="",a=t>>2,o=0;!(o>=e/4);o++){var s=T[a+o];if(!s&&!r)break;n+=String.fromCodePoint(s)}return n},ia=(t,e,r)=>{if(r!=null||(r=2147483647),r<4)return 0;for(var n=e,a=n+r-4,o=0;o<t.length;++o){var s=t.codePointAt(o);if(s>65535&&o++,ct[e>>2]=s,e+=4,e+4>a)break}return ct[e>>2]=0,e-n},sa=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.codePointAt(r);n>65535&&r++,e+=4}return e},ua=(t,e,r)=>{r=j(r);var n,a,o;e===2?(n=ra,a=na,o=aa):(n=oa,a=ia,o=sa),V(t,{name:r,fromWireType:s=>{var u=T[s>>2],c=n(s+4,u*e,!0);return q(s),c},toWireType:(s,u)=>{typeof u!="string"&&b(`Cannot pass non-string to C++ string type ${r}`);var c=o(u),d=Kt(4+c+e);return T[d>>2]=c/e,a(u,d+4,c+e),s!==null&&s.push(q,d),d},readValueFromPointer:lt,destructorFunction(s){q(s)}})},ca=(t,e,r,n,a,o)=>{Pt[t]={name:j(e),rawConstructor:U(r,n),rawDestructor:U(a,o),fields:[]}},la=(t,e,r,n,a,o,s,u,c,d)=>{Pt[t].fields.push({fieldName:j(e),getterReturnType:r,getter:U(n,a),getterContext:o,setterArgumentType:s,setter:U(u,c),setterContext:d})},fa=(t,e)=>{e=j(e),V(t,{isVoid:!0,name:e,fromWireType:()=>{},toWireType:(r,n)=>{}})},Qt=[],da=t=>{var e=Qt.length;return Qt.push(t),e},ha=(t,e)=>{var r=K[t];return r===void 0&&b(`${e} has unknown type ${De(t)}`),r},pa=(t,e)=>{for(var r=new Array(t),n=0;n<t;++n)r[n]=ha(T[e+n*4>>2],`parameter ${n}`);return r},ya=(t,e,r)=>{var n=[],a=t(n,r);return n.length&&(T[e>>2]=W.toHandle(n)),a},va={},Ve=t=>{var e=va[t];return e===void 0?j(t):e},ma=(t,e,r)=>{var n=8,[a,...o]=pa(t,e),s=a.toWireType.bind(a),u=o.map(y=>y.readValueFromPointer.bind(y));t--;var c=new Array(t),d=(y,$,E,I)=>{for(var x=0,O=0;O<t;++O)c[O]=u[O](I+x),x+=n;var P;switch(r){case 0:P=W.toValue(y).apply(null,c);break;case 2:P=Reflect.construct(W.toValue(y),c);break;case 3:P=c[0];break;case 1:P=W.toValue(y)[Ve($)](...c);break}return ya(s,E,P)},p=`methodCaller<(${o.map(y=>y.name)}) => ${a.name}>`;return da(zt(p,d))},ga=t=>t?(t=Ve(t),W.toHandle(globalThis[t])):W.toHandle(globalThis),wa=t=>{t>9&&(et[t+1]+=1)},ba=(t,e,r,n,a)=>Qt[t](e,r,n,a),$a=t=>{var e=W.toValue(t);Ht(e),Zt(t)},Ca=(t,e,r,n)=>{var a=new Date().getFullYear(),o=new Date(a,0,1),s=new Date(a,6,1),u=o.getTimezoneOffset(),c=s.getTimezoneOffset(),d=Math.max(u,c);T[t>>2]=d*60,ct[e>>2]=+(u!=c);var p=E=>{var I=E>=0?"-":"+",x=Math.abs(E),O=String(Math.floor(x/60)).padStart(2,"0"),P=String(x%60).padStart(2,"0");return`UTC${I}${O}${P}`},y=p(u),$=p(c);c<u?(ot(y,r,17),ot($,n,17)):(ot(y,n,17),ot($,r,17))},Ta=()=>2147483648,Pa=(t,e)=>Math.ceil(t/e)*e,Ea=t=>{var e=Dt.buffer.byteLength,r=(t-e+65535)/65536|0;try{return Dt.grow(r),we(),1}catch{}},Oa=t=>{var e=N.length;t>>>=0;var r=Ta();if(t>r)return!1;for(var n=1;n<=4;n*=2){var a=e*(1+.2/n);a=Math.min(a,t+100663296);var o=Math.min(r,Pa(Math.max(t,a),65536)),s=Ea(o);if(s)return!0}return!1},Jt={},_a=()=>S||"./this.program",ht=()=>{if(!ht.strings){var t=(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:_a()};for(var r in Jt)Jt[r]===void 0?delete e[r]:e[r]=Jt[r];var n=[];for(var r in e)n.push(`${r}=${e[r]}`);ht.strings=n}return ht.strings},Sa=(t,e)=>{var r=0,n=0;for(var a of ht()){var o=e+r;T[t+n>>2]=o,r+=ot(a,o,1/0)+1,n+=4}return 0},xa=(t,e)=>{var r=ht();T[t>>2]=r.length;var n=0;for(var a of r)n+=Re(a)+1;return T[e>>2]=n,0},Ia=t=>52;function Da(t,e,r,n,a){return 70}var Ma=[null,[],[]],Aa=(t,e)=>{var r=Ma[t];e===0||e===10?((t===1?st:k)(Le(r)),r.length=0):r.push(e)},Fa=(t,e,r,n)=>{for(var a=0,o=0;o<r;o++){var s=T[e>>2],u=T[e+4>>2];e+=8;for(var c=0;c<u;c++)Aa(t,N[s+c]);a+=u}return T[n>>2]=a,0},Ra=t=>t;if(Tn(),Rn(),l.noExitRuntime&&l.noExitRuntime,l.print&&(st=l.print),l.printErr&&(k=l.printErr),l.wasmBinary&&(Q=l.wasmBinary),l.arguments&&l.arguments,l.thisProgram&&(S=l.thisProgram),l.preInit)for(typeof l.preInit=="function"&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.shift()();var We,q,Kt,He,v,ke,Ne,ze,Ge,Xe,qe,Ye,Ze,Dt,Qe;function Ba(t){We=t.ya,q=l._free=t.za,Kt=l._malloc=t.Ba,He=t.Ca,v=t.Da,ke=t.Ea,Ne=t.Fa,ze=t.Ga,Ge=t.Ha,Xe=t.Ia,qe=t.Ja,X.viijii=t.Ka,Ye=X.iiijj=t.La,X.jiji=t.Ma,Ze=X.jiiii=t.Na,X.iiiiij=t.Oa,X.iiiiijj=t.Pa,X.iiiiiijj=t.Qa,Dt=t.wa,Qe=t.Aa}var ja={s:on,w:sn,a:un,j:cn,m:ln,Q:fn,p:dn,U:hn,d:pn,ca:yn,ta:mn,ba:gn,oa:bn,ra:Vn,qa:Hn,H:kn,ma:Nn,X:Gn,Y:Xn,x:Yn,t:Zn,sa:Jn,na:ea,R:ua,I:ca,ua:la,pa:fa,N:ma,va:Zt,D:ga,S:wa,M:ba,ia:$a,da:Ca,ga:Oa,ea:Sa,fa:xa,ha:Ia,$:Da,V:Fa,K:io,C:co,Z:Na,T:vo,r:ro,b:Ha,E:oo,ka:fo,c:za,ja:ho,h:ka,i:qa,q:Ja,P:ao,v:to,F:eo,L:no,z:lo,J:mo,aa:go,_:wo,f:Ga,l:La,e:Wa,g:Va,O:yo,k:Ua,la:so,o:Ka,B:Ya,u:uo,W:Qa,A:po,n:Xa,G:Za,y:Ra};function La(t,e){var r=g();try{w(t)(e)}catch(n){if(m(r),n!==n+0)throw n;v(1,0)}}function Ua(t,e,r,n,a){var o=g();try{w(t)(e,r,n,a)}catch(s){if(m(o),s!==s+0)throw s;v(1,0)}}function Va(t,e,r,n){var a=g();try{w(t)(e,r,n)}catch(o){if(m(a),o!==o+0)throw o;v(1,0)}}function Wa(t,e,r){var n=g();try{w(t)(e,r)}catch(a){if(m(n),a!==a+0)throw a;v(1,0)}}function Ha(t,e){var r=g();try{return w(t)(e)}catch(n){if(m(r),n!==n+0)throw n;v(1,0)}}function ka(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(o){if(m(a),o!==o+0)throw o;v(1,0)}}function Na(t,e,r,n,a,o){var s=g();try{return w(t)(e,r,n,a,o)}catch(u){if(m(s),u!==u+0)throw u;v(1,0)}}function za(t,e,r){var n=g();try{return w(t)(e,r)}catch(a){if(m(n),a!==a+0)throw a;v(1,0)}}function Ga(t){var e=g();try{w(t)()}catch(r){if(m(e),r!==r+0)throw r;v(1,0)}}function Xa(t,e,r,n,a,o,s,u,c,d,p){var y=g();try{w(t)(e,r,n,a,o,s,u,c,d,p)}catch($){if(m(y),$!==$+0)throw $;v(1,0)}}function qa(t,e,r,n,a){var o=g();try{return w(t)(e,r,n,a)}catch(s){if(m(o),s!==s+0)throw s;v(1,0)}}function Ya(t,e,r,n,a,o,s){var u=g();try{w(t)(e,r,n,a,o,s)}catch(c){if(m(u),c!==c+0)throw c;v(1,0)}}function Za(t,e,r,n,a,o,s,u,c,d,p,y,$,E,I,x){var O=g();try{w(t)(e,r,n,a,o,s,u,c,d,p,y,$,E,I,x)}catch(P){if(m(O),P!==P+0)throw P;v(1,0)}}function Qa(t,e,r,n,a,o,s,u,c){var d=g();try{w(t)(e,r,n,a,o,s,u,c)}catch(p){if(m(d),p!==p+0)throw p;v(1,0)}}function Ja(t,e,r,n,a,o){var s=g();try{return w(t)(e,r,n,a,o)}catch(u){if(m(s),u!==u+0)throw u;v(1,0)}}function Ka(t,e,r,n,a,o){var s=g();try{w(t)(e,r,n,a,o)}catch(u){if(m(s),u!==u+0)throw u;v(1,0)}}function to(t,e,r,n,a,o,s){var u=g();try{return w(t)(e,r,n,a,o,s)}catch(c){if(m(u),c!==c+0)throw c;v(1,0)}}function eo(t,e,r,n,a,o,s,u){var c=g();try{return w(t)(e,r,n,a,o,s,u)}catch(d){if(m(c),d!==d+0)throw d;v(1,0)}}function ro(t){var e=g();try{return w(t)()}catch(r){if(m(e),r!==r+0)throw r;v(1,0)}}function no(t,e,r,n,a,o,s,u,c){var d=g();try{return w(t)(e,r,n,a,o,s,u,c)}catch(p){if(m(d),p!==p+0)throw p;v(1,0)}}function ao(t,e,r,n,a,o,s){var u=g();try{return w(t)(e,r,n,a,o,s)}catch(c){if(m(u),c!==c+0)throw c;v(1,0)}}function oo(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(o){if(m(a),o!==o+0)throw o;v(1,0)}}function io(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(o){if(m(a),o!==o+0)throw o;v(1,0)}}function so(t,e,r,n,a,o,s,u){var c=g();try{w(t)(e,r,n,a,o,s,u)}catch(d){if(m(c),d!==d+0)throw d;v(1,0)}}function uo(t,e,r,n,a,o,s,u){var c=g();try{w(t)(e,r,n,a,o,s,u)}catch(d){if(m(c),d!==d+0)throw d;v(1,0)}}function co(t,e,r,n,a,o){var s=g();try{return w(t)(e,r,n,a,o)}catch(u){if(m(s),u!==u+0)throw u;v(1,0)}}function lo(t,e,r,n,a,o,s,u,c,d){var p=g();try{return w(t)(e,r,n,a,o,s,u,c,d)}catch(y){if(m(p),y!==y+0)throw y;v(1,0)}}function fo(t,e,r){var n=g();try{return w(t)(e,r)}catch(a){if(m(n),a!==a+0)throw a;v(1,0)}}function ho(t,e,r,n,a){var o=g();try{return w(t)(e,r,n,a)}catch(s){if(m(o),s!==s+0)throw s;v(1,0)}}function po(t,e,r,n,a,o,s,u,c,d){var p=g();try{w(t)(e,r,n,a,o,s,u,c,d)}catch(y){if(m(p),y!==y+0)throw y;v(1,0)}}function yo(t,e,r,n,a,o,s){var u=g();try{w(t)(e,r,n,a,o,s)}catch(c){if(m(u),c!==c+0)throw c;v(1,0)}}function vo(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(o){if(m(a),o!==o+0)throw o;v(1,0)}}function mo(t,e,r,n,a,o,s,u,c,d,p,y){var $=g();try{return w(t)(e,r,n,a,o,s,u,c,d,p,y)}catch(E){if(m($),E!==E+0)throw E;v(1,0)}}function go(t,e,r,n,a,o,s){var u=g();try{return Ye(t,e,r,n,a,o,s)}catch(c){if(m(u),c!==c+0)throw c;v(1,0)}}function wo(t,e,r,n,a){var o=g();try{return Ze(t,e,r,n,a)}catch(s){if(m(o),s!==s+0)throw s;v(1,0)}}function bo(){Xr();function t(){var e,r;l.calledRun=!0,!gt&&(qr(),(e=pe)===null||e===void 0||e(l),(r=l.onRuntimeInitialized)===null||r===void 0||r.call(l),Yr())}l.setStatus?(l.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>l.setStatus(""),1),t()},1)):t()}var pt;return pt=await rn(),bo(),ge?f=l:f=new Promise((t,e)=>{pe=t,ye=e}),f}function jt(i){return re(Bt,i)}function Or(){return Pr(Bt)}function _r(i){jt({overrides:i,equalityFn:Object.is,fireImmediately:!1})}async function Sr(i,f){return Er(Bt,i,f)}const xr="85d46f55d7c86a4d09bb04273367408b19c324f582d040d018aecb25a9a82942",ne=[["aztec","Aztec"],["code_128","Code128"],["code_39","Code39"],["code_93","Code93"],["codabar","Codabar"],["databar","DataBar"],["databar_expanded","DataBarExpanded"],["databar_limited","DataBarLimited"],["data_matrix","DataMatrix"],["dx_film_edge","DXFilmEdge"],["ean_13","EAN-13"],["ean_8","EAN-8"],["itf","ITF"],["maxi_code","MaxiCode"],["micro_qr_code","MicroQRCode"],["pdf417","PDF417"],["qr_code","QRCode"],["rm_qr_code","rMQRCode"],["upc_a","UPC-A"],["upc_e","UPC-E"],["linear_codes","Linear-Codes"],["matrix_codes","Matrix-Codes"],["any","Any"]],Ir=[...ne,["unknown"]].map(i=>i[0]),Lt=new Map(ne);function Dr(i){for(const[f,h]of Lt)if(i===h)return f;return"unknown"}function Mr(i){if(ae(i))return{width:i.naturalWidth,height:i.naturalHeight};if(oe(i))return{width:i.width.baseVal.value,height:i.height.baseVal.value};if(ie(i))return{width:i.videoWidth,height:i.videoHeight};if(ue(i))return{width:i.width,height:i.height};if(le(i))return{width:i.displayWidth,height:i.displayHeight};if(se(i))return{width:i.width,height:i.height};if(ce(i))return{width:i.width,height:i.height};throw new TypeError("The provided value is not of type '(Blob or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or ImageData or OffscreenCanvas or SVGImageElement or VideoFrame)'.")}function ae(i){var f,h;try{return i instanceof((h=(f=i==null?void 0:i.ownerDocument)==null?void 0:f.defaultView)==null?void 0:h.HTMLImageElement)}catch{return!1}}function oe(i){var f,h;try{return i instanceof((h=(f=i==null?void 0:i.ownerDocument)==null?void 0:f.defaultView)==null?void 0:h.SVGImageElement)}catch{return!1}}function ie(i){var f,h;try{return i instanceof((h=(f=i==null?void 0:i.ownerDocument)==null?void 0:f.defaultView)==null?void 0:h.HTMLVideoElement)}catch{return!1}}function se(i){var f,h;try{return i instanceof((h=(f=i==null?void 0:i.ownerDocument)==null?void 0:f.defaultView)==null?void 0:h.HTMLCanvasElement)}catch{return!1}}function ue(i){try{return i instanceof ImageBitmap||Object.prototype.toString.call(i)==="[object ImageBitmap]"}catch{return!1}}function ce(i){try{return i instanceof OffscreenCanvas||Object.prototype.toString.call(i)==="[object OffscreenCanvas]"}catch{return!1}}function le(i){try{return i instanceof VideoFrame||Object.prototype.toString.call(i)==="[object VideoFrame]"}catch{return!1}}function Ar(i){try{return i instanceof Blob||Object.prototype.toString.call(i)==="[object Blob]"}catch{return!1}}function Fr(i){try{return i instanceof ImageData||Object.prototype.toString.call(i)==="[object ImageData]"}catch{return!1}}function Rr(i,f){try{const h=new OffscreenCanvas(i,f);if(h.getContext("2d")instanceof OffscreenCanvasRenderingContext2D)return h;throw void 0}catch{const h=document.createElement("canvas");return h.width=i,h.height=f,h}}async function fe(i){if(ae(i)&&!await Ur(i))throw new DOMException("Failed to load or decode HTMLImageElement.","InvalidStateError");if(oe(i)&&!await Vr(i))throw new DOMException("Failed to load or decode SVGImageElement.","InvalidStateError");if(le(i)&&Wr(i))throw new DOMException("VideoFrame is closed.","InvalidStateError");if(ie(i)&&(i.readyState===0||i.readyState===1))throw new DOMException("Invalid element or state.","InvalidStateError");if(ue(i)&&kr(i))throw new DOMException("The image source is detached.","InvalidStateError");const{width:f,height:h}=Mr(i);if(f===0||h===0)return null;const l=Rr(f,h).getContext("2d");l.drawImage(i,0,0);try{return l.getImageData(0,0,f,h)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function Br(i){let f;try{f=await createImageBitmap(i)}catch{try{if(globalThis.Image){f=new Image;let l="";try{l=URL.createObjectURL(i),f.src=l,await f.decode()}finally{URL.revokeObjectURL(l)}}else return i}catch{throw new DOMException("Failed to load or decode Blob.","InvalidStateError")}}return await fe(f)}function jr(i){const{width:f,height:h}=i;if(f===0||h===0)return null;const C=i.getContext("2d");try{return C.getImageData(0,0,f,h)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function Lr(i){if(Ar(i))return await Br(i);if(Fr(i)){if(Hr(i))throw new DOMException("The image data has been detached.","InvalidStateError");return i}return se(i)||ce(i)?jr(i):await fe(i)}async function Ur(i){try{return await i.decode(),!0}catch{return!1}}async function Vr(i){var f;try{return await((f=i.decode)==null?void 0:f.call(i)),!0}catch{return!1}}function Wr(i){return i.format===null}function Hr(i){return i.data.buffer.byteLength===0}function kr(i){return i.width===0&&i.height===0}function de(i,f){return Nr(i)?new DOMException(`${f}: ${i.message}`,i.name):zr(i)?new i.constructor(`${f}: ${i.message}`):new Error(`${f}: ${i}`)}function Nr(i){return i instanceof DOMException||Object.prototype.toString.call(i)==="[object DOMException]"}function zr(i){return i instanceof Error||Object.prototype.toString.call(i)==="[object Error]"}class Gr{constructor(f={}){or(this,it);var h;try{const C=(h=f==null?void 0:f.formats)==null?void 0:h.filter(l=>l!=="unknown");if((C==null?void 0:C.length)===0)throw new TypeError("Hint option provided, but is empty.");for(const l of C!=null?C:[])if(!Lt.has(l))throw new TypeError(`Failed to read the 'formats' property from 'BarcodeDetectorOptions': The provided value '${l}' is not a valid enum value of type BarcodeFormat.`);ir(this,it,C!=null?C:[]),jt({fireImmediately:!0}).catch(()=>{})}catch(C){throw de(C,"Failed to construct 'BarcodeDetector'")}}static async getSupportedFormats(){return Ir.filter(f=>f!=="unknown")}async detect(f){try{const h=await Lr(f);if(h===null)return[];let C;const l={tryCode39ExtendedMode:!1,textMode:"Plain",formats:ar(this,it).map(D=>Lt.get(D))};try{C=await Sr(h,l)}catch(D){throw console.error(D),new DOMException("Barcode detection service unavailable.","NotSupportedError")}return C.map(D=>{const{topLeft:{x:A,y:R},topRight:{x:S,y:B},bottomLeft:{x:H,y:Y},bottomRight:{x:nt,y:Z}}=D.position,st=Math.min(A,S,H,nt),k=Math.min(R,B,Y,Z),Q=Math.max(A,S,H,nt),gt=Math.max(R,B,Y,Z);return{boundingBox:new DOMRectReadOnly(st,k,Q-st,gt-k),rawValue:D.text,format:Dr(D.format),cornerPoints:[{x:A,y:R},{x:S,y:B},{x:nt,y:Z},{x:H,y:Y}]}})}catch(h){throw de(h,"Failed to execute 'detect' on 'BarcodeDetector'")}}}return it=new WeakMap,(he=globalThis.BarcodeDetector)!=null||(globalThis.BarcodeDetector=Gr),_.ZXING_CPP_COMMIT=$r,_.ZXING_WASM_SHA256=xr,_.ZXING_WASM_VERSION=br,_.prepareZXingModule=jt,_.purgeZXingModule=Or,_.setZXingModuleOverrides=_r,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),_})({});