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