@credenza3/scanner-lib 0.0.2 → 0.1.0
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/.turbo/turbo-build.log +9 -26
- package/dist/scanner.es.js +22744 -2964
- package/dist/scanner.umd.js +21 -100
- package/dist/types/index.d.ts +8 -9
- package/package.json +18 -18
- package/dist/qr-scanner-worker.min-DpjUkzFK.js +0 -101
package/dist/scanner.umd.js
CHANGED
|
@@ -1,104 +1,25 @@
|
|
|
1
|
-
(function(ye,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(ye=typeof globalThis<"u"?globalThis:ye||self,$e(ye.CredenzaScanner={}))})(this,(function(ye){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");let Ae=!1,Tr=!1;function Or(){Ae=!0}Or();const Ur=2,Nr=4,Dr=8,qr=1,$r=2,q=Symbol(),zr="http://www.w3.org/1999/xhtml",Mt=!1;var jr=Array.isArray,Wr=Array.prototype.indexOf,Hr=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,Vr=Object.prototype,Xr=Array.prototype,rt=Object.getPrototypeOf;function Gr(o){return o()}function ot(o){for(var t=0;t<o.length;t++)o[t]()}function At(){var o,t,n=new Promise((a,c)=>{o=a,t=c});return{promise:n,resolve:o,reject:t}}const $=2,nt=4,it=8,re=16,oe=32,Ce=64,at=128,z=1024,H=2048,ne=4096,Q=8192,ie=16384,st=32768,Re=65536,Rt=1<<17,Yr=1<<18,je=1<<19,Ft=1<<20,G=256,We=512,He=32768,ct=1<<21,lt=1<<22,pe=1<<23,be=Symbol("$state"),Kr=Symbol("legacy props"),Pe=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function Lt(o){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Qr(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Zr(o){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Jr(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function eo(o){throw new Error("https://svelte.dev/e/effect_orphan")}function to(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function ro(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function oo(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function no(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Tt(o){return o===this.v}function io(o,t){return o!=o?t==t:o!==t||o!==null&&typeof o=="object"||typeof o=="function"}function ao(o){return!io(o,this.v)}let D=null;function Ve(o){D=o}function so(o,t=!1,n){D={p:D,i:!1,c:null,e:null,s:o,x:null,l:Ae&&!t?{s:null,u:null,$:[]}:null}}function co(o){var t=D,n=t.e;if(n!==null){t.e=null;for(var a of n)Yt(a)}return t.i=!0,D=t.p,{}}function Fe(){return!Ae||D!==null&&D.l===null}let _e=[];function lo(){var o=_e;_e=[],ot(o)}function Ot(o){if(_e.length===0){var t=_e;queueMicrotask(()=>{t===_e&&lo()})}_e.push(o)}function uo(o){var t=I;if(t===null)return E.f|=pe,o;if((t.f&st)===0){if((t.f&at)===0)throw o;t.b.error(o)}else Xe(o,t)}function Xe(o,t){for(;t!==null;){if((t.f&at)!==0)try{t.b.error(o);return}catch(n){o=n}t=t.parent}throw o}const Ge=new Set;let U=null,K=null,ce=[],dt=null,ut=!1;class Le{committed=!1;current=new Map;previous=new Map;#t=new Set;#r=new Set;#e=0;#o=0;#i=null;#a=[];#s=[];skipped_effects=new Set;is_fork=!1;process(t){ce=[],this.apply();var n={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const a of t)this.#c(a,n);this.is_fork||this.#l(),this.#o>0||this.is_fork?(this.#n(n.effects),this.#n(n.render_effects),this.#n(n.block_effects)):(U=null,Ut(n.render_effects),Ut(n.effects),this.#i?.resolve()),K=null}#c(t,n){t.f^=z;for(var a=t.first;a!==null;){var c=a.f,u=(c&(oe|Ce))!==0,f=u&&(c&z)!==0,l=f||(c&Q)!==0||this.skipped_effects.has(a);if((a.f&at)!==0&&a.b?.is_pending()&&(n={parent:n,effect:a,effects:[],render_effects:[],block_effects:[]}),!l&&a.fn!==null){u?a.f^=z:(c&nt)!==0?n.effects.push(a):Oe(a)&&((a.f&re)!==0&&n.block_effects.push(a),Ue(a));var B=a.first;if(B!==null){a=B;continue}}var m=a.parent;for(a=a.next;a===null&&m!==null;)m===n.effect&&(this.#n(n.effects),this.#n(n.render_effects),this.#n(n.block_effects),n=n.parent),a=m.next,m=m.parent}}#n(t){for(const n of t)((n.f&H)!==0?this.#a:this.#s).push(n),j(n,z)}capture(t,n){this.previous.has(t)||this.previous.set(t,n),this.current.set(t,t.v),K?.set(t,t.v)}activate(){U=this}deactivate(){U=null,K=null}flush(){if(this.activate(),ce.length>0){if(fo(),U!==null&&U!==this)return}else this.#e===0&&this.process([]);this.deactivate()}discard(){for(const t of this.#r)t(this);this.#r.clear()}#l(){if(this.#o===0){for(const t of this.#t)t();this.#t.clear()}this.#e===0&&this.#d()}#d(){if(Ge.size>1){this.previous.clear();var t=K,n=!0,a={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const c of Ge){if(c===this){n=!1;continue}const u=[];for(const[l,B]of this.current){if(c.current.has(l))if(n&&B!==c.current.get(l))c.current.set(l,B);else continue;u.push(l)}if(u.length===0)continue;const f=[...c.current.keys()].filter(l=>!this.current.has(l));if(f.length>0){const l=new Set,B=new Map;for(const m of u)Nt(m,f,l,B);if(ce.length>0){U=c,c.apply();for(const m of ce)c.#c(m,a);ce=[],c.deactivate()}}}U=null,K=t}this.committed=!0,Ge.delete(this)}increment(t){this.#e+=1,t&&(this.#o+=1)}decrement(t){this.#e-=1,t&&(this.#o-=1),this.revive()}revive(){for(const t of this.#a)j(t,H),we(t);for(const t of this.#s)j(t,ne),we(t);this.#a=[],this.#s=[],this.flush()}oncommit(t){this.#t.add(t)}ondiscard(t){this.#r.add(t)}settled(){return(this.#i??=At()).promise}static ensure(){if(U===null){const t=U=new Le;Ge.add(U),Le.enqueue(()=>{U===t&&t.flush()})}return U}static enqueue(t){Ot(t)}apply(){}}function fo(){var o=Ee;ut=!0;try{var t=0;for(rr(!0);ce.length>0;){var n=Le.ensure();if(t++>1e3){var a,c;ho()}n.process(ce),le.clear()}}finally{ut=!1,rr(o),dt=null}}function ho(){try{to()}catch(o){Xe(o,dt)}}let ae=null;function Ut(o){var t=o.length;if(t!==0){for(var n=0;n<t;){var a=o[n++];if((a.f&(ie|Q))===0&&Oe(a)&&(ae=new Set,Ue(a),a.deps===null&&a.first===null&&a.nodes_start===null&&(a.teardown===null&&a.ac===null?Jt(a):a.fn=null),ae?.size>0)){le.clear();for(const c of ae){if((c.f&(ie|Q))!==0)continue;const u=[c];let f=c.parent;for(;f!==null;)ae.has(f)&&(ae.delete(f),u.push(f)),f=f.parent;for(let l=u.length-1;l>=0;l--){const B=u[l];(B.f&(ie|Q))===0&&Ue(B)}}ae.clear()}}ae=null}}function Nt(o,t,n,a){if(!n.has(o)&&(n.add(o),o.reactions!==null))for(const c of o.reactions){const u=c.f;(u&$)!==0?Nt(c,t,n,a):(u&(lt|re))!==0&&(u&H)===0&&Dt(c,t,a)&&(j(c,H),we(c))}}function Dt(o,t,n){const a=n.get(o);if(a!==void 0)return a;if(o.deps!==null)for(const c of o.deps){if(t.includes(c))return!0;if((c.f&$)!==0&&Dt(c,t,n))return n.set(c,!0),!0}return n.set(o,!1),!1}function we(o){for(var t=dt=o;t.parent!==null;){t=t.parent;var n=t.f;if(ut&&t===I&&(n&re)!==0)return;if((n&(Ce|oe))!==0){if((n&z)===0)return;t.f^=z}}ce.push(t)}function Bo(o,t,n,a){const c=Fe()?ft:qt;if(n.length===0&&o.length===0){a(t.map(c));return}var u=U,f=I,l=mo();function B(){Promise.all(n.map(m=>ko(m))).then(m=>{l();try{a([...t.map(c),...m])}catch(w){(f.f&ie)===0&&Xe(w,f)}u?.deactivate(),Ye()}).catch(m=>{Xe(m,f)})}o.length>0?Promise.all(o).then(()=>{l();try{return B()}finally{u?.deactivate(),Ye()}}):B()}function mo(){var o=I,t=E,n=D,a=U;return function(u=!0){Be(o),J(t),Ve(n),u&&a?.activate()}}function Ye(){Be(null),J(null),Ve(null)}function ft(o){var t=$|H,n=E!==null&&(E.f&$)!==0?E:null;return I===null||n!==null&&(n.f&G)!==0?t|=G:I.f|=je,{ctx:D,deps:null,effects:null,equals:Tt,f:t,fn:o,reactions:null,rv:0,v:q,wv:0,parent:n??I,ac:null}}function ko(o,t){let n=I;n===null&&Qr();var a=n.b,c=void 0,u=Wt(q),f=!E,l=new Map;return Io(()=>{var B=At();c=B.promise;try{Promise.resolve(o()).then(B.resolve,B.reject).then(()=>{m===U&&m.committed&&m.deactivate(),Ye()})}catch(v){B.reject(v),Ye()}var m=U;if(f){var w=!a.is_pending();a.update_pending_count(1),m.increment(w),l.get(m)?.reject(Pe),l.delete(m),l.set(m,B)}const y=(v,p=void 0)=>{if(m.activate(),p)p!==Pe&&(u.f|=pe,mt(u,p));else{(u.f&pe)!==0&&(u.f^=pe),mt(u,v);for(const[g,C]of l){if(l.delete(g),g===m)break;C.reject(Pe)}}f&&(a.update_pending_count(-1),m.decrement(w))};B.promise.then(y,v=>y(null,v||"unknown"))}),Gt(()=>{for(const B of l.values())B.reject(Pe)}),new Promise(B=>{function m(w){function y(){w===c?B(u):m(c)}w.then(y,y)}m(c)})}function qt(o){const t=ft(o);return t.equals=ao,t}function $t(o){var t=o.effects;if(t!==null){o.effects=null;for(var n=0;n<t.length;n+=1)he(t[n])}}function po(o){for(var t=o.parent;t!==null;){if((t.f&$)===0)return t;t=t.parent}return null}function ht(o){var t,n=I;Be(po(o));try{o.f&=~He,$t(o),t=cr(o)}finally{Be(n)}return t}function zt(o){var t=ht(o);if(o.equals(t)||(o.v=t,o.wv=ar()),!ge)if(K!==null)K.set(o,o.v);else{var n=(me||(o.f&G)!==0)&&o.deps!==null?ne:z;j(o,n)}}let Bt=new Set;const le=new Map;let jt=!1;function Wt(o,t){var n={f:0,v:o,reactions:null,equals:Tt,rv:0,wv:0};return n}function de(o,t){const n=Wt(o);return Uo(n),n}function ue(o,t,n=!1){E!==null&&(!Z||(E.f&Rt)!==0)&&Fe()&&(E.f&($|re|lt|Rt))!==0&&!se?.includes(o)&&no();let a=n?xe(t):t;return mt(o,a)}function mt(o,t){if(!o.equals(t)){var n=o.v;ge?le.set(o,t):le.set(o,n),o.v=t;var a=Le.ensure();a.capture(o,n),(o.f&$)!==0&&((o.f&H)!==0&&ht(o),j(o,(o.f&G)===0?z:ne)),o.wv=ar(),Ht(o,H),Fe()&&I!==null&&(I.f&z)!==0&&(I.f&(oe|Ce))===0&&(Y===null?No([o]):Y.push(o)),!a.is_fork&&Bt.size>0&&!jt&&wo()}return t}function wo(){jt=!1;const o=Array.from(Bt);for(const t of o)(t.f&z)!==0&&j(t,ne),Oe(t)&&Ue(t);Bt.clear()}function kt(o){ue(o,o.v+1)}function Ht(o,t){var n=o.reactions;if(n!==null)for(var a=Fe(),c=n.length,u=0;u<c;u++){var f=n[u],l=f.f;if(!(!a&&f===I)){var B=(l&H)===0;B&&j(f,t),(l&$)!==0?(l&He)===0&&(f.f|=He,Ht(f,ne)):B&&((l&re)!==0&&ae!==null&&ae.add(f),we(f))}}}function xe(o){if(typeof o!="object"||o===null||be in o)return o;const t=rt(o);if(t!==Vr&&t!==Xr)return o;var n=new Map,a=jr(o),c=de(0),u=ve,f=l=>{if(ve===u)return l();var B=E,m=ve;J(null),ir(u);var w=l();return J(B),ir(m),w};return a&&n.set("length",de(o.length)),new Proxy(o,{defineProperty(l,B,m){(!("value"in m)||m.configurable===!1||m.enumerable===!1||m.writable===!1)&&ro();var w=n.get(B);return w===void 0?w=f(()=>{var y=de(m.value);return n.set(B,y),y}):ue(w,m.value,!0),!0},deleteProperty(l,B){var m=n.get(B);if(m===void 0){if(B in l){const w=f(()=>de(q));n.set(B,w),kt(c)}}else ue(m,q),kt(c);return!0},get(l,B,m){if(B===be)return o;var w=n.get(B),y=B in l;if(w===void 0&&(!y||ze(l,B)?.writable)&&(w=f(()=>{var p=xe(y?l[B]:q),g=de(p);return g}),n.set(B,w)),w!==void 0){var v=ee(w);return v===q?void 0:v}return Reflect.get(l,B,m)},getOwnPropertyDescriptor(l,B){var m=Reflect.getOwnPropertyDescriptor(l,B);if(m&&"value"in m){var w=n.get(B);w&&(m.value=ee(w))}else if(m===void 0){var y=n.get(B),v=y?.v;if(y!==void 0&&v!==q)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return m},has(l,B){if(B===be)return!0;var m=n.get(B),w=m!==void 0&&m.v!==q||Reflect.has(l,B);if(m!==void 0||I!==null&&(!w||ze(l,B)?.writable)){m===void 0&&(m=f(()=>{var v=w?xe(l[B]):q,p=de(v);return p}),n.set(B,m));var y=ee(m);if(y===q)return!1}return w},set(l,B,m,w){var y=n.get(B),v=B in l;if(a&&B==="length")for(var p=m;p<y.v;p+=1){var g=n.get(p+"");g!==void 0?ue(g,q):p in l&&(g=f(()=>de(q)),n.set(p+"",g))}if(y===void 0)(!v||ze(l,B)?.writable)&&(y=f(()=>de(void 0)),ue(y,xe(m)),n.set(B,y));else{v=y.v!==q;var C=f(()=>xe(m));ue(y,C)}var _=Reflect.getOwnPropertyDescriptor(l,B);if(_?.set&&_.set.call(w,m),!v){if(a&&typeof B=="string"){var M=n.get("length"),b=Number(B);Number.isInteger(b)&&b>=M.v&&ue(M,b+1)}kt(c)}return!0},ownKeys(l){ee(c);var B=Reflect.ownKeys(l).filter(y=>{var v=n.get(y);return v===void 0||v.v!==q});for(var[m,w]of n)w.v!==q&&!(m in l)&&B.push(m);return B},setPrototypeOf(){oo()}})}var go,vo,yo;function Vt(o=""){return document.createTextNode(o)}function pt(o){return vo.call(o)}function wt(o){return yo.call(o)}function Co(o,t){return pt(o)}function bo(o,t=1,n=!1){let a=o;for(;t--;)a=wt(a);return a}function Po(){return!1}function gt(o){var t=E,n=I;J(null),Be(null);try{return o()}finally{J(t),Be(n)}}function Xt(o){I===null&&E===null&&eo(),E!==null&&(E.f&G)!==0&&I===null&&Jr(),ge&&Zr()}function _o(o,t){var n=t.last;n===null?t.last=t.first=o:(n.next=o,o.prev=n,t.last=o)}function fe(o,t,n,a=!0){var c=I;c!==null&&(c.f&Q)!==0&&(o|=Q);var u={ctx:D,deps:null,nodes_start:null,nodes_end:null,f:o|H,first:null,fn:t,last:null,next:null,parent:c,b:c&&c.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(n)try{Ue(u),u.f|=st}catch(B){throw he(u),B}else t!==null&&we(u);if(a){var f=u;if(n&&f.deps===null&&f.teardown===null&&f.nodes_start===null&&f.first===f.last&&(f.f&je)===0&&(f=f.first,(o&re)!==0&&(o&Re)!==0&&f!==null&&(f.f|=Re)),f!==null&&(f.parent=c,c!==null&&_o(f,c),E!==null&&(E.f&$)!==0&&(o&Ce)===0)){var l=E;(l.effects??=[]).push(f)}}return u}function Gt(o){const t=fe(it,null,!1);return j(t,z),t.teardown=o,t}function vt(o){Xt();var t=I.f,n=!E&&(t&oe)!==0&&(t&st)===0;if(n){var a=D;(a.e??=[]).push(o)}else return Yt(o)}function Yt(o){return fe(nt|Ft,o,!1)}function xo(o){return Xt(),fe(it|Ft,o,!0)}function Eo(o){return fe(nt,o,!1)}function Io(o){return fe(lt|je,o,!0)}function Mo(o,t=[],n=[],a=[]){Bo(a,t,n,c=>{fe(it,()=>o(...c.map(ee)),!0)})}function So(o,t=0){var n=fe(re|t,o,!0);return n}function Kt(o,t=!0){return fe(oe|je,o,!0,t)}function Qt(o){var t=o.teardown;if(t!==null){const n=ge,a=E;or(!0),J(null);try{t.call(null)}finally{or(n),J(a)}}}function Zt(o,t=!1){var n=o.first;for(o.first=o.last=null;n!==null;){const c=n.ac;c!==null&>(()=>{c.abort(Pe)});var a=n.next;(n.f&Ce)!==0?n.parent=null:he(n,t),n=a}}function Ao(o){for(var t=o.first;t!==null;){var n=t.next;(t.f&oe)===0&&he(t),t=n}}function he(o,t=!0){var n=!1;(t||(o.f&Yr)!==0)&&o.nodes_start!==null&&o.nodes_end!==null&&(Ro(o.nodes_start,o.nodes_end),n=!0),Zt(o,t&&!n),Ke(o,0),j(o,ie);var a=o.transitions;if(a!==null)for(const u of a)u.stop();Qt(o);var c=o.parent;c!==null&&c.first!==null&&Jt(o),o.next=o.prev=o.teardown=o.ctx=o.deps=o.fn=o.nodes_start=o.nodes_end=o.ac=null}function Ro(o,t){for(;o!==null;){var n=o===t?null:wt(o);o.remove(),o=n}}function Jt(o){var t=o.parent,n=o.prev,a=o.next;n!==null&&(n.next=a),a!==null&&(a.prev=n),t!==null&&(t.first===o&&(t.first=a),t.last===o&&(t.last=n))}function Fo(o,t,n=!0){var a=[];er(o,a,!0),Lo(a,()=>{n&&he(o),t&&t()})}function Lo(o,t){var n=o.length;if(n>0){var a=()=>--n||t();for(var c of o)c.out(a)}else t()}function er(o,t,n){if((o.f&Q)===0){if(o.f^=Q,o.transitions!==null)for(const f of o.transitions)(f.is_global||n)&&t.push(f);for(var a=o.first;a!==null;){var c=a.next,u=(a.f&Re)!==0||(a.f&oe)!==0&&(o.f&re)!==0;er(a,t,u?n:!1),a=c}}}function To(o){tr(o,!0)}function tr(o,t){if((o.f&Q)!==0){o.f^=Q,(o.f&z)===0&&(j(o,H),we(o));for(var n=o.first;n!==null;){var a=n.next,c=(n.f&Re)!==0||(n.f&oe)!==0;tr(n,c?t:!1),n=a}if(o.transitions!==null)for(const u of o.transitions)(u.is_global||t)&&u.in()}}function Oo(o,t){for(var n=o.nodes_start,a=o.nodes_end;n!==null;){var c=n===a?null:wt(n);t.append(n),n=c}}let Ee=!1;function rr(o){Ee=o}let ge=!1;function or(o){ge=o}let E=null,Z=!1;function J(o){E=o}let I=null;function Be(o){I=o}let se=null;function Uo(o){E!==null&&(se===null?se=[o]:se.push(o))}let W=null,X=0,Y=null;function No(o){Y=o}let nr=1,Te=0,ve=Te;function ir(o){ve=o}let me=!1;function ar(){return++nr}function Oe(o){var t=o.f;if((t&H)!==0)return!0;if((t&ne)!==0){var n=o.deps,a=(t&G)!==0;if(t&$&&(o.f&=~He),n!==null){var c,u,f=(t&We)!==0,l=a&&I!==null&&!me,B=n.length;if((f||l)&&(I===null||(I.f&ie)===0)){var m=o,w=m.parent;for(c=0;c<B;c++)u=n[c],(f||!u?.reactions?.includes(m))&&(u.reactions??=[]).push(m);f&&(m.f^=We),l&&w!==null&&(w.f&G)===0&&(m.f^=G)}for(c=0;c<B;c++)if(u=n[c],Oe(u)&&zt(u),u.wv>o.wv)return!0}(!a||I!==null&&!me)&&j(o,z)}return!1}function sr(o,t,n=!0){var a=o.reactions;if(a!==null&&!se?.includes(o))for(var c=0;c<a.length;c++){var u=a[c];(u.f&$)!==0?sr(u,t,!1):t===u&&(n?j(u,H):(u.f&z)!==0&&j(u,ne),we(u))}}function cr(o){var t=W,n=X,a=Y,c=E,u=me,f=se,l=D,B=Z,m=ve,w=o.f;W=null,X=0,Y=null,me=(w&G)!==0&&(Z||!Ee||E===null),E=(w&(oe|Ce))===0?o:null,se=null,Ve(o.ctx),Z=!1,ve=++Te,o.ac!==null&&(gt(()=>{o.ac.abort(Pe)}),o.ac=null);try{o.f|=ct;var y=o.fn,v=y(),p=o.deps;if(W!==null){var g;if(Ke(o,X),p!==null&&X>0)for(p.length=X+W.length,g=0;g<W.length;g++)p[X+g]=W[g];else o.deps=p=W;if(!me||(w&$)!==0&&o.reactions!==null)for(g=X;g<p.length;g++)(p[g].reactions??=[]).push(o)}else p!==null&&X<p.length&&(Ke(o,X),p.length=X);if(Fe()&&Y!==null&&!Z&&p!==null&&(o.f&($|ne|H))===0)for(g=0;g<Y.length;g++)sr(Y[g],o);return c!==null&&c!==o&&(Te++,Y!==null&&(a===null?a=Y:a.push(...Y))),(o.f&pe)!==0&&(o.f^=pe),v}catch(C){return uo(C)}finally{o.f^=ct,W=t,X=n,Y=a,E=c,me=u,se=f,Ve(l),Z=B,ve=m}}function Do(o,t){let n=t.reactions;if(n!==null){var a=Wr.call(n,o);if(a!==-1){var c=n.length-1;c===0?n=t.reactions=null:(n[a]=n[c],n.pop())}}n===null&&(t.f&$)!==0&&(W===null||!W.includes(t))&&(j(t,ne),(t.f&(G|We))===0&&(t.f^=We),$t(t),Ke(t,0))}function Ke(o,t){var n=o.deps;if(n!==null)for(var a=t;a<n.length;a++)Do(o,n[a])}function Ue(o){var t=o.f;if((t&ie)===0){j(o,z);var n=I,a=Ee;I=o,Ee=!0;try{(t&re)!==0?Ao(o):Zt(o),Qt(o);var c=cr(o);o.teardown=typeof c=="function"?c:null,o.wv=nr;var u;Mt&&Tr&&(o.f&H)!==0&&o.deps}finally{Ee=a,I=n}}}function ee(o){var t=o.f,n=(t&$)!==0;if(E!==null&&!Z){var a=I!==null&&(I.f&ie)!==0;if(!a&&!se?.includes(o)){var c=E.deps;if((E.f&ct)!==0)o.rv<Te&&(o.rv=Te,W===null&&c!==null&&c[X]===o?X++:W===null?W=[o]:(!me||!W.includes(o))&&W.push(o));else{(E.deps??=[]).push(o);var u=o.reactions;u===null?o.reactions=[E]:u.includes(E)||u.push(E)}}}else if(n&&o.deps===null&&o.effects===null){var f=o,l=f.parent;l!==null&&(l.f&G)===0&&(f.f^=G)}if(ge){if(le.has(o))return le.get(o);if(n){f=o;var B=f.v;return((f.f&z)===0&&f.reactions!==null||lr(f))&&(B=ht(f)),le.set(f,B),B}}else if(n){if(f=o,K?.has(f))return K.get(f);Oe(f)&&zt(f)}if(K?.has(o))return K.get(o);if((o.f&pe)!==0)throw o.v;return o.v}function lr(o){if(o.v===q)return!0;if(o.deps===null)return!1;for(const t of o.deps)if(le.has(t)||(t.f&$)!==0&&lr(t))return!0;return!1}function Ne(o){var t=Z;try{return Z=!0,o()}finally{Z=t}}const qo=-7169;function j(o,t){o.f=o.f&qo|t}function yt(o){if(!(typeof o!="object"||!o||o instanceof EventTarget)){if(be in o)Ct(o);else if(!Array.isArray(o))for(let t in o){const n=o[t];typeof n=="object"&&n&&be in n&&Ct(n)}}}function Ct(o,t=new Set){if(typeof o=="object"&&o!==null&&!(o instanceof EventTarget)&&!t.has(o)){t.add(o),o instanceof Date&&o.getTime();for(let a in o)try{Ct(o[a],t)}catch{}const n=rt(o);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const a=St(n);for(let c in a){const u=a[c].get;if(u)try{u.call(o)}catch{}}}}}function $o(o,t,n,a={}){function c(u){if(a.capture||jo.call(t,u),!u.cancelBubble)return gt(()=>n?.call(this,u))}return o.startsWith("pointer")||o.startsWith("touch")||o==="wheel"?Ot(()=>{t.addEventListener(o,c,a)}):t.addEventListener(o,c,a),c}function zo(o,t,n,a,c){var u={capture:a,passive:c},f=$o(o,t,n,u);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Gt(()=>{t.removeEventListener(o,f,u)})}let dr=null;function jo(o){var t=this,n=t.ownerDocument,a=o.type,c=o.composedPath?.()||[],u=c[0]||o.target;dr=o;var f=0,l=dr===o&&o.__root;if(l){var B=c.indexOf(l);if(B!==-1&&(t===document||t===window)){o.__root=t;return}var m=c.indexOf(t);if(m===-1)return;B<=m&&(f=B)}if(u=c[f]||o.target,u!==t){Hr(o,"currentTarget",{configurable:!0,get(){return u||n}});var w=E,y=I;J(null),Be(null);try{for(var v,p=[];u!==null;){var g=u.assignedSlot||u.parentNode||u.host||null;try{var C=u["__"+a];C!=null&&(!u.disabled||o.target===u)&&C.call(u,o)}catch(_){v?p.push(_):v=_}if(o.cancelBubble||g===t||g===null)break;u=g}if(v){for(let _ of p)queueMicrotask(()=>{throw _});throw v}}finally{o.__root=t,delete o.currentTarget,J(w),Be(y)}}}function Wo(o){var t=document.createElement("template");return t.innerHTML=o.replaceAll("<!>","<!---->"),t.content}function ur(o,t){var n=I;n.nodes_start===null&&(n.nodes_start=o,n.nodes_end=t)}function fr(o,t){var n=(t&qr)!==0,a=(t&$r)!==0,c,u=!o.startsWith("<!>");return()=>{c===void 0&&(c=Wo(u?o:"<!>"+o),n||(c=pt(c)));var f=a||go?document.importNode(c,!0):c.cloneNode(!0);if(n){var l=pt(f),B=f.lastChild;ur(l,B)}else ur(f,f);return f}}function hr(o,t){o!==null&&o.before(t)}class Ho{anchor;#t=new Map;#r=new Map;#e=new Map;#o=!0;constructor(t,n=!0){this.anchor=t,this.#o=n}#i=()=>{var t=U;if(this.#t.has(t)){var n=this.#t.get(t),a=this.#r.get(n);if(a)To(a);else{var c=this.#e.get(n);c&&(this.#r.set(n,c.effect),this.#e.delete(n),c.fragment.lastChild.remove(),this.anchor.before(c.fragment),a=c.effect)}for(const[u,f]of this.#t){if(this.#t.delete(u),u===t)break;const l=this.#e.get(f);l&&(he(l.effect),this.#e.delete(f))}for(const[u,f]of this.#r){if(u===n)continue;const l=()=>{if(Array.from(this.#t.values()).includes(u)){var m=document.createDocumentFragment();Oo(f,m),m.append(Vt()),this.#e.set(u,{effect:f,fragment:m})}else he(f);this.#r.delete(u)};this.#o||!a?Fo(f,l,!1):l()}}};#a=t=>{this.#t.delete(t);const n=Array.from(this.#t.values());for(const[a,c]of this.#e)n.includes(a)||(he(c.effect),this.#e.delete(a))};ensure(t,n){var a=U,c=Po();if(n&&!this.#r.has(t)&&!this.#e.has(t))if(c){var u=document.createDocumentFragment(),f=Vt();u.append(f),this.#e.set(t,{effect:Kt(()=>n(f)),fragment:u})}else this.#r.set(t,Kt(()=>n(this.anchor)));if(this.#t.set(a,t),c){for(const[l,B]of this.#r)l===t?a.skipped_effects.delete(B):a.skipped_effects.add(B);for(const[l,B]of this.#e)l===t?a.skipped_effects.delete(B.effect):a.skipped_effects.add(B.effect);a.oncommit(this.#i),a.ondiscard(this.#a)}else this.#i()}}function Vo(o){D===null&&Lt(),Ae&&D.l!==null?Go(D).m.push(o):vt(()=>{const t=Ne(o);if(typeof t=="function")return t})}function Xo(o){D===null&&Lt(),Vo(()=>()=>Ne(o))}function Go(o){var t=o.l;return t.u??={a:[],b:[],m:[]}}function Yo(o,t,n=!1){var a=new Ho(o),c=n?Re:0;function u(f,l){a.ensure(f,l)}So(()=>{var f=!1;t((l,B=!0)=>{f=!0,u(B,l)}),f||u(!1,null)},c)}function Br(o,t){Eo(()=>{var n=o.getRootNode(),a=n.host?n:n.head??n.ownerDocument.head;if(!a.querySelector("#"+t.hash)){const c=document.createElement("style");c.id=t.hash,c.textContent=t.code,a.appendChild(c)}})}const Ko=Symbol("is custom element"),Qo=Symbol("is html");function mr(o,t,n,a){var c=Zo(o);c[t]!==(c[t]=n)&&(n==null?o.removeAttribute(t):typeof n!="string"&&Jo(o).includes(t)?o[t]=n:o.setAttribute(t,n))}function Zo(o){return o.__attributes??={[Ko]:o.nodeName.includes("-"),[Qo]:o.namespaceURI===zr}}var kr=new Map;function Jo(o){var t=o.getAttribute("is")||o.nodeName,n=kr.get(t);if(n)return n;kr.set(t,n=[]);for(var a,c=o,u=Element.prototype;u!==c;){a=St(c);for(var f in a)a[f].set&&n.push(f);c=rt(c)}return n}function en(o=!1){const t=D,n=t.l.u;if(!n)return;let a=()=>yt(t.s);if(o){let c=0,u={};const f=ft(()=>{let l=!1;const B=t.s;for(const m in B)B[m]!==u[m]&&(u[m]=B[m],l=!0);return l&&c++,c});a=()=>ee(f)}n.b.length&&xo(()=>{pr(t,a),ot(n.b)}),vt(()=>{const c=Ne(()=>n.m.map(Gr));return()=>{for(const u of c)typeof u=="function"&&u()}}),n.a.length&&vt(()=>{pr(t,a),ot(n.a)})}function pr(o,t){if(o.l.s)for(const n of o.l.s)ee(n);t()}let Qe=!1;function tn(o){var t=Qe;try{return Qe=!1,[o(),Qe]}finally{Qe=t}}function Ze(o,t,n,a){var c=!Ae||(n&Ur)!==0,u=(n&Dr)!==0,f=a,l=!0,B=()=>(l&&(l=!1,f=a),f),m;{var w=be in o||Kr in o;m=ze(o,t)?.set??(w&&t in o?b=>o[t]=b:void 0)}var y,v=!1;[y,v]=tn(()=>o[t]);var p;if(c?p=()=>{var b=o[t];return b===void 0?B():(l=!0,b)}:p=()=>{var b=o[t];return b!==void 0&&(f=void 0),b===void 0?f:b},c&&(n&Nr)===0)return p;if(m){var g=o.$$legacy;return(function(b,A){return arguments.length>0?((!c||!A||g||v)&&m(A?p():b),b):p()})}var C=!1,_=qt(()=>(C=!1,p()));ee(_);var M=I;return(function(b,A){if(arguments.length>0){const O=A?ee(_):c&&u?xe(b):b;return ue(_,O),C=!0,f!==void 0&&(f=O),b}return ge&&C||(M.f&ie)!==0?_.v:ee(_)})}var rn=fr('<div class="cscanapp-close svelte-degygl" role="button" tabindex="0"></div>');const on={hash:"svelte-degygl",code:`.cscanapp-close.svelte-degygl {position:absolute;z-index:10;right:5px;top:5px;width:32px;height:32px;opacity:0.3;cursor:pointer;}.cscanapp-close.svelte-degygl:hover {opacity:1;}.cscanapp-close.svelte-degygl:before,
|
|
2
|
-
.cscanapp-close.svelte-degygl:after {position:absolute;left:15px;content:' ';height:33px;width:2px;background-color:#000;}.cscanapp-close.svelte-degygl:before {transform:rotate(45deg);}.cscanapp-close.svelte-degygl:after {transform:rotate(-45deg);}`};function nn(o,t){Br(o,on);let n=Ze(t,"close",8);var a=rn();zo("click",a,function(...c){n()?.apply(this,c)}),hr(o,a)}var an=fr('<div class="cscanapp svelte-168e0l4"><!> <video class="svelte-168e0l4"></video></div>',2);const sn={hash:"svelte-168e0l4",code:".cscanapp.svelte-168e0l4 {position:relative;width:100%;height:100%;border-radius:inherit;}.cscanapp.svelte-168e0l4 video:where(.svelte-168e0l4) {width:100%;height:100%;object-fit:cover;position:absolute;border-radius:inherit;display:block;}"};function cn(o,t){so(t,!1),Br(o,sn);let n=Ze(t,"close",8),a=Ze(t,"isCloseButton",8),c=Ze(t,"scannerElements",8);Xo(n()),en();var u=an(),f=Co(u);{var l=m=>{nn(m,{get close(){return n()}})};Yo(f,m=>{a()&&m(l)})}var B=bo(f,2);Mo(()=>{mr(u,"id",(yt(c()),Ne(()=>c().ROOT))),mr(B,"id",(yt(c()),Ne(()=>c().VIDEO)))}),hr(o,u),co()}var Ie=(o=>(o.CAPTURE="capture",o.ERROR="error",o.CANCEL="cancel",o))(Ie||{}),Je=(o=>(o.ROOT="cscanapp",o.VIDEO="cscanappVideo",o))(Je||{}),bt={},De={},wr;function ln(){if(wr)return De;wr=1,De.byteLength=l,De.toByteArray=m,De.fromByteArray=v;for(var o=[],t=[],n=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,u=a.length;c<u;++c)o[c]=a[c],t[a.charCodeAt(c)]=c;t[45]=62,t[95]=63;function f(p){var g=p.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var C=p.indexOf("=");C===-1&&(C=g);var _=C===g?0:4-C%4;return[C,_]}function l(p){var g=f(p),C=g[0],_=g[1];return(C+_)*3/4-_}function B(p,g,C){return(g+C)*3/4-C}function m(p){var g,C=f(p),_=C[0],M=C[1],b=new n(B(p,_,M)),A=0,O=M>0?_-4:_,T;for(T=0;T<O;T+=4)g=t[p.charCodeAt(T)]<<18|t[p.charCodeAt(T+1)]<<12|t[p.charCodeAt(T+2)]<<6|t[p.charCodeAt(T+3)],b[A++]=g>>16&255,b[A++]=g>>8&255,b[A++]=g&255;return M===2&&(g=t[p.charCodeAt(T)]<<2|t[p.charCodeAt(T+1)]>>4,b[A++]=g&255),M===1&&(g=t[p.charCodeAt(T)]<<10|t[p.charCodeAt(T+1)]<<4|t[p.charCodeAt(T+2)]>>2,b[A++]=g>>8&255,b[A++]=g&255),b}function w(p){return o[p>>18&63]+o[p>>12&63]+o[p>>6&63]+o[p&63]}function y(p,g,C){for(var _,M=[],b=g;b<C;b+=3)_=(p[b]<<16&16711680)+(p[b+1]<<8&65280)+(p[b+2]&255),M.push(w(_));return M.join("")}function v(p){for(var g,C=p.length,_=C%3,M=[],b=16383,A=0,O=C-_;A<O;A+=b)M.push(y(p,A,A+b>O?O:A+b));return _===1?(g=p[C-1],M.push(o[g>>2]+o[g<<4&63]+"==")):_===2&&(g=(p[C-2]<<8)+p[C-1],M.push(o[g>>10]+o[g>>4&63]+o[g<<2&63]+"=")),M.join("")}return De}var et={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var gr;function dn(){return gr||(gr=1,et.read=function(o,t,n,a,c){var u,f,l=c*8-a-1,B=(1<<l)-1,m=B>>1,w=-7,y=n?c-1:0,v=n?-1:1,p=o[t+y];for(y+=v,u=p&(1<<-w)-1,p>>=-w,w+=l;w>0;u=u*256+o[t+y],y+=v,w-=8);for(f=u&(1<<-w)-1,u>>=-w,w+=a;w>0;f=f*256+o[t+y],y+=v,w-=8);if(u===0)u=1-m;else{if(u===B)return f?NaN:(p?-1:1)*(1/0);f=f+Math.pow(2,a),u=u-m}return(p?-1:1)*f*Math.pow(2,u-a)},et.write=function(o,t,n,a,c,u){var f,l,B,m=u*8-c-1,w=(1<<m)-1,y=w>>1,v=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=a?0:u-1,g=a?1:-1,C=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,f=w):(f=Math.floor(Math.log(t)/Math.LN2),t*(B=Math.pow(2,-f))<1&&(f--,B*=2),f+y>=1?t+=v/B:t+=v*Math.pow(2,1-y),t*B>=2&&(f++,B/=2),f+y>=w?(l=0,f=w):f+y>=1?(l=(t*B-1)*Math.pow(2,c),f=f+y):(l=t*Math.pow(2,y-1)*Math.pow(2,c),f=0));c>=8;o[n+p]=l&255,p+=g,l/=256,c-=8);for(f=f<<c|l,m+=c;m>0;o[n+p]=f&255,p+=g,f/=256,m-=8);o[n+p-g]|=C*128}),et}/*!
|
|
1
|
+
(function(Et,xt){typeof exports=="object"&&typeof module<"u"?xt(exports):typeof define=="function"&&define.amd?define(["exports"],xt):(Et=typeof globalThis<"u"?globalThis:Et||self,xt(Et.CredenzaScanner={}))})(this,function(Et){"use strict";var go=Object.defineProperty;var wo=(Et,xt,Dt)=>xt in Et?go(Et,xt,{enumerable:!0,configurable:!0,writable:!0,value:Dt}):Et[xt]=Dt;var Ur=(Et,xt,Dt)=>wo(Et,typeof xt!="symbol"?xt+"":xt,Dt);function xt(x,f){for(var c=0;c<f.length;c++){const m=f[c];if(typeof m!="string"&&!Array.isArray(m)){for(const I in m)if(I!=="default"&&!(I in x)){const g=Object.getOwnPropertyDescriptor(m,I);g&&Object.defineProperty(x,I,g.get?g:{enumerable:!0,get:()=>m[I]})}}}return Object.freeze(Object.defineProperty(x,Symbol.toStringTag,{value:"Module"}))}function Dt(){}function Vr(x){return x()}function Gr(){return Object.create(null)}function On(x){x.forEach(Vr)}function sr(x){return typeof x=="function"}function Wr(x,f){return x!=x?f==f:x!==f||x&&typeof x=="object"||typeof x=="function"}function Bi(x){return Object.keys(x).length===0}function or(x,f){x.appendChild(f)}function Hr(x,f,c){const m=Di(x);if(!m.getElementById(f)){const I=Hn("style");I.id=f,I.textContent=c,Mi(m,I)}}function Di(x){if(!x)return document;const f=x.getRootNode?x.getRootNode():x.ownerDocument;return f&&f.host?f:x.ownerDocument}function Mi(x,f){return or(x.head||x,f),f.sheet}function Xr(x,f,c){x.insertBefore(f,c||null)}function ar(x){x.parentNode&&x.parentNode.removeChild(x)}function Hn(x){return document.createElement(x)}function vi(x){return document.createTextNode(x)}function Fi(){return vi(" ")}function Li(x,f,c,m){return x.addEventListener(f,c,m),()=>x.removeEventListener(f,c,m)}function Yt(x,f,c){c==null?x.removeAttribute(f):x.getAttribute(f)!==c&&x.setAttribute(f,c)}function Pi(x){return Array.from(x.childNodes)}let Bn;function Dn(x){Bn=x}function ki(){if(!Bn)throw new Error("Function called outside component initialization");return Bn}function Ui(x){ki().$$.on_destroy.push(x)}const fn=[],Yr=[];let dn=[];const zr=[],Vi=Promise.resolve();let lr=!1;function Gi(){lr||(lr=!0,Vi.then(Zr))}function cr(x){dn.push(x)}const ur=new Set;let xn=0;function Zr(){if(xn!==0)return;const x=Bn;do{try{for(;xn<fn.length;){const f=fn[xn];xn++,Dn(f),Wi(f.$$)}}catch(f){throw fn.length=0,xn=0,f}for(Dn(null),fn.length=0,xn=0;Yr.length;)Yr.pop()();for(let f=0;f<dn.length;f+=1){const c=dn[f];ur.has(c)||(ur.add(c),c())}dn.length=0}while(fn.length);for(;zr.length;)zr.pop()();lr=!1,ur.clear(),Dn(x)}function Wi(x){if(x.fragment!==null){x.update(),On(x.before_update);const f=x.dirty;x.dirty=[-1],x.fragment&&x.fragment.p(x.ctx,f),x.after_update.forEach(cr)}}function Hi(x){const f=[],c=[];dn.forEach(m=>x.indexOf(m)===-1?f.push(m):c.push(m)),c.forEach(m=>m()),dn=f}const Xn=new Set;let en;function Xi(){en={r:0,c:[],p:en}}function Yi(){en.r||On(en.c),en=en.p}function Mn(x,f){x&&x.i&&(Xn.delete(x),x.i(f))}function hr(x,f,c,m){if(x&&x.o){if(Xn.has(x))return;Xn.add(x),en.c.push(()=>{Xn.delete(x),m&&(c&&x.d(1),m())}),x.o(f)}else m&&m()}function zi(x){x&&x.c()}function jr(x,f,c){const{fragment:m,after_update:I}=x.$$;m&&m.m(f,c),cr(()=>{const g=x.$$.on_mount.map(Vr).filter(sr);x.$$.on_destroy?x.$$.on_destroy.push(...g):On(g),x.$$.on_mount=[]}),I.forEach(cr)}function Kr(x,f){const c=x.$$;c.fragment!==null&&(Hi(c.after_update),On(c.on_destroy),c.fragment&&c.fragment.d(f),c.on_destroy=c.fragment=null,c.ctx=[])}function Zi(x,f){x.$$.dirty[0]===-1&&(fn.push(x),Gi(),x.$$.dirty.fill(0)),x.$$.dirty[f/31|0]|=1<<f%31}function qr(x,f,c,m,I,g,_=null,S=[-1]){const P=Bn;Dn(x);const p=x.$$={fragment:null,ctx:[],props:g,update:Dt,not_equal:I,bound:Gr(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(f.context||(P?P.$$.context:[])),callbacks:Gr(),dirty:S,skip_bound:!1,root:f.target||P.$$.root};_&&_(p.root);let k=!1;if(p.ctx=c?c(x,f.props||{},(M,ae,...Q)=>{const Pe=Q.length?Q[0]:ae;return p.ctx&&I(p.ctx[M],p.ctx[M]=Pe)&&(!p.skip_bound&&p.bound[M]&&p.bound[M](Pe),k&&Zi(x,M)),ae}):[],p.update(),k=!0,On(p.before_update),p.fragment=m?m(p.ctx):!1,f.target){if(f.hydrate){const M=Pi(f.target);p.fragment&&p.fragment.l(M),M.forEach(ar)}else p.fragment&&p.fragment.c();f.intro&&Mn(x.$$.fragment),jr(x,f.target,f.anchor),Zr()}Dn(P)}class Qr{constructor(){Ur(this,"$$");Ur(this,"$$set")}$destroy(){Kr(this,1),this.$destroy=Dt}$on(f,c){if(!sr(c))return Dt;const m=this.$$.callbacks[f]||(this.$$.callbacks[f]=[]);return m.push(c),()=>{const I=m.indexOf(c);I!==-1&&m.splice(I,1)}}$set(f){this.$$set&&!Bi(f)&&(this.$$.skip_bound=!0,this.$$set(f),this.$$.skip_bound=!1)}}const ji="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ji);function Ki(x){Hr(x,"svelte-1is2ll8",".cscanapp-close.svelte-1is2ll8{position:absolute;z-index:10;right:5px;top:5px;width:32px;height:32px;opacity:0.3;cursor:pointer}.cscanapp-close.svelte-1is2ll8:hover{opacity:1}.cscanapp-close.svelte-1is2ll8:before,.cscanapp-close.svelte-1is2ll8:after{position:absolute;left:15px;content:' ';height:33px;width:2px;background-color:#000}.cscanapp-close.svelte-1is2ll8:before{transform:rotate(45deg)}.cscanapp-close.svelte-1is2ll8:after{transform:rotate(-45deg)}")}function qi(x){let f,c,m;return{c(){f=Hn("div"),Yt(f,"class","cscanapp-close svelte-1is2ll8"),Yt(f,"role","button"),Yt(f,"tabindex","0")},m(I,g){Xr(I,f,g),c||(m=Li(f,"click",function(){sr(x[0])&&x[0].apply(this,arguments)}),c=!0)},p(I,[g]){x=I},i:Dt,o:Dt,d(I){I&&ar(f),c=!1,m()}}}function Qi(x,f,c){let{close:m}=f;return x.$$set=I=>{"close"in I&&c(0,m=I.close)},[m]}class Ji extends Qr{constructor(f){super(),qr(this,f,Qi,qi,Wr,{close:0},Ki)}}function $i(x){Hr(x,"svelte-lbgrjy",".cscanapp.svelte-lbgrjy.svelte-lbgrjy{position:relative;width:100%;height:100%;border-radius:inherit}.cscanapp.svelte-lbgrjy div.svelte-lbgrjy{width:100%;height:100%;object-fit:cover;position:absolute;border-radius:inherit;display:block}")}function Jr(x){let f,c;return f=new Ji({props:{close:x[0]}}),{c(){zi(f.$$.fragment)},m(m,I){jr(f,m,I),c=!0},p(m,I){const g={};I&1&&(g.close=m[0]),f.$set(g)},i(m){c||(Mn(f.$$.fragment,m),c=!0)},o(m){hr(f.$$.fragment,m),c=!1},d(m){Kr(f,m)}}}function es(x){let f,c,m,I,g,_=x[1]&&Jr(x);return{c(){f=Hn("div"),_&&_.c(),c=Fi(),m=Hn("div"),Yt(m,"id","cscanappVideo"),Yt(m,"class","svelte-lbgrjy"),Yt(f,"id",I=x[2].ROOT),Yt(f,"class","cscanapp svelte-lbgrjy")},m(S,P){Xr(S,f,P),_&&_.m(f,null),or(f,c),or(f,m),g=!0},p(S,[P]){S[1]?_?(_.p(S,P),P&2&&Mn(_,1)):(_=Jr(S),_.c(),Mn(_,1),_.m(f,c)):_&&(Xi(),hr(_,1,1,()=>{_=null}),Yi()),(!g||P&4&&I!==(I=S[2].ROOT))&&Yt(f,"id",I)},i(S){g||(Mn(_),g=!0)},o(S){hr(_),g=!1},d(S){S&&ar(f),_&&_.d()}}}function ts(x,f,c){let{close:m}=f,{isCloseButton:I}=f,{scannerElements:g}=f;return Ui(m),x.$$set=_=>{"close"in _&&c(0,m=_.close),"isCloseButton"in _&&c(1,I=_.isCloseButton),"scannerElements"in _&&c(2,g=_.scannerElements)},[m,I,g]}class ns extends Qr{constructor(f){super(),qr(this,f,ts,es,Wr,{close:0,isCloseButton:1,scannerElements:2},$i)}}var gn=(x=>(x.CAPTURE="capture",x.ERROR="error",x.CANCEL="cancel",x))(gn||{}),Yn=(x=>(x.ROOT="cscanapp",x.VIDEO="cscanappVideo",x))(Yn||{}),vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}var fr={},zn={};zn.byteLength=os,zn.toByteArray=ls,zn.fromByteArray=hs;for(var Mt=[],Ct=[],is=typeof Uint8Array<"u"?Uint8Array:Array,dr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wn=0,ss=dr.length;wn<ss;++wn)Mt[wn]=dr[wn],Ct[dr.charCodeAt(wn)]=wn;Ct[45]=62,Ct[95]=63;function $r(x){var f=x.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=x.indexOf("=");c===-1&&(c=f);var m=c===f?0:4-c%4;return[c,m]}function os(x){var f=$r(x),c=f[0],m=f[1];return(c+m)*3/4-m}function as(x,f,c){return(f+c)*3/4-c}function ls(x){var f,c=$r(x),m=c[0],I=c[1],g=new is(as(x,m,I)),_=0,S=I>0?m-4:m,P;for(P=0;P<S;P+=4)f=Ct[x.charCodeAt(P)]<<18|Ct[x.charCodeAt(P+1)]<<12|Ct[x.charCodeAt(P+2)]<<6|Ct[x.charCodeAt(P+3)],g[_++]=f>>16&255,g[_++]=f>>8&255,g[_++]=f&255;return I===2&&(f=Ct[x.charCodeAt(P)]<<2|Ct[x.charCodeAt(P+1)]>>4,g[_++]=f&255),I===1&&(f=Ct[x.charCodeAt(P)]<<10|Ct[x.charCodeAt(P+1)]<<4|Ct[x.charCodeAt(P+2)]>>2,g[_++]=f>>8&255,g[_++]=f&255),g}function cs(x){return Mt[x>>18&63]+Mt[x>>12&63]+Mt[x>>6&63]+Mt[x&63]}function us(x,f,c){for(var m,I=[],g=f;g<c;g+=3)m=(x[g]<<16&16711680)+(x[g+1]<<8&65280)+(x[g+2]&255),I.push(cs(m));return I.join("")}function hs(x){for(var f,c=x.length,m=c%3,I=[],g=16383,_=0,S=c-m;_<S;_+=g)I.push(us(x,_,_+g>S?S:_+g));return m===1?(f=x[c-1],I.push(Mt[f>>2]+Mt[f<<4&63]+"==")):m===2&&(f=(x[c-2]<<8)+x[c-1],I.push(Mt[f>>10]+Mt[f>>4&63]+Mt[f<<2&63]+"=")),I.join("")}var xr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */xr.read=function(x,f,c,m,I){var g,_,S=I*8-m-1,P=(1<<S)-1,p=P>>1,k=-7,M=c?I-1:0,ae=c?-1:1,Q=x[f+M];for(M+=ae,g=Q&(1<<-k)-1,Q>>=-k,k+=S;k>0;g=g*256+x[f+M],M+=ae,k-=8);for(_=g&(1<<-k)-1,g>>=-k,k+=m;k>0;_=_*256+x[f+M],M+=ae,k-=8);if(g===0)g=1-p;else{if(g===P)return _?NaN:(Q?-1:1)*(1/0);_=_+Math.pow(2,m),g=g-p}return(Q?-1:1)*_*Math.pow(2,g-m)},xr.write=function(x,f,c,m,I,g){var _,S,P,p=g*8-I-1,k=(1<<p)-1,M=k>>1,ae=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,Q=m?0:g-1,Pe=m?1:-1,he=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(S=isNaN(f)?1:0,_=k):(_=Math.floor(Math.log(f)/Math.LN2),f*(P=Math.pow(2,-_))<1&&(_--,P*=2),_+M>=1?f+=ae/P:f+=ae*Math.pow(2,1-M),f*P>=2&&(_++,P/=2),_+M>=k?(S=0,_=k):_+M>=1?(S=(f*P-1)*Math.pow(2,I),_=_+M):(S=f*Math.pow(2,M-1)*Math.pow(2,I),_=0));I>=8;x[c+Q]=S&255,Q+=Pe,S/=256,I-=8);for(_=_<<I|S,p+=I;p>0;x[c+Q]=_&255,Q+=Pe,_/=256,p-=8);x[c+Q-Pe]|=he*128};/*!
|
|
3
2
|
* The buffer module from node.js, for the browser.
|
|
4
3
|
*
|
|
5
4
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
6
5
|
* @license MIT
|
|
7
|
-
*/var vr;function un(){return vr||(vr=1,(function(o){const t=ln(),n=dn(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=l,o.SlowBuffer=b,o.INSPECT_MAX_BYTES=50;const c=2147483647;o.kMaxLength=c,l.TYPED_ARRAY_SUPPORT=u(),!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const i=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(i,e),i.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function f(i){if(i>c)throw new RangeError('The value "'+i+'" is invalid for option "size"');const e=new Uint8Array(i);return Object.setPrototypeOf(e,l.prototype),e}function l(i,e,r){if(typeof i=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(i)}return B(i,e,r)}l.poolSize=8192;function B(i,e,r){if(typeof i=="string")return v(i,e);if(ArrayBuffer.isView(i))return g(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(te(i,ArrayBuffer)||i&&te(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(te(i,SharedArrayBuffer)||i&&te(i.buffer,SharedArrayBuffer)))return C(i,e,r);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const s=i.valueOf&&i.valueOf();if(s!=null&&s!==i)return l.from(s,e,r);const d=_(i);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return l.from(i[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}l.from=function(i,e,r){return B(i,e,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array);function m(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function w(i,e,r){return m(i),i<=0?f(i):e!==void 0?typeof r=="string"?f(i).fill(e,r):f(i).fill(e):f(i)}l.alloc=function(i,e,r){return w(i,e,r)};function y(i){return m(i),f(i<0?0:M(i)|0)}l.allocUnsafe=function(i){return y(i)},l.allocUnsafeSlow=function(i){return y(i)};function v(i,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=A(i,e)|0;let s=f(r);const d=s.write(i,e);return d!==r&&(s=s.slice(0,d)),s}function p(i){const e=i.length<0?0:M(i.length)|0,r=f(e);for(let s=0;s<e;s+=1)r[s]=i[s]&255;return r}function g(i){if(te(i,Uint8Array)){const e=new Uint8Array(i);return C(e.buffer,e.byteOffset,e.byteLength)}return p(i)}function C(i,e,r){if(e<0||i.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let s;return e===void 0&&r===void 0?s=new Uint8Array(i):r===void 0?s=new Uint8Array(i,e):s=new Uint8Array(i,e,r),Object.setPrototypeOf(s,l.prototype),s}function _(i){if(l.isBuffer(i)){const e=M(i.length)|0,r=f(e);return r.length===0||i.copy(r,0,0,e),r}if(i.length!==void 0)return typeof i.length!="number"||It(i.length)?f(0):p(i);if(i.type==="Buffer"&&Array.isArray(i.data))return p(i.data)}function M(i){if(i>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return i|0}function b(i){return+i!=i&&(i=0),l.alloc(+i)}l.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==l.prototype},l.compare=function(e,r){if(te(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),te(r,Uint8Array)&&(r=l.from(r,r.offset,r.byteLength)),!l.isBuffer(e)||!l.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let s=e.length,d=r.length;for(let h=0,k=Math.min(s,d);h<k;++h)if(e[h]!==r[h]){s=e[h],d=r[h];break}return s<d?-1:d<s?1:0},l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);let s;if(r===void 0)for(r=0,s=0;s<e.length;++s)r+=e[s].length;const d=l.allocUnsafe(r);let h=0;for(s=0;s<e.length;++s){let k=e[s];if(te(k,Uint8Array))h+k.length>d.length?(l.isBuffer(k)||(k=l.from(k)),k.copy(d,h)):Uint8Array.prototype.set.call(d,k,h);else if(l.isBuffer(k))k.copy(d,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=k.length}return d};function A(i,e){if(l.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||te(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const r=i.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&r===0)return 0;let d=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Et(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Lr(i).length;default:if(d)return s?-1:Et(i).length;e=(""+e).toLowerCase(),d=!0}}l.byteLength=A;function O(i,e,r){let s=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return Pn(this,e,r);case"utf8":case"utf-8":return _r(this,e,r);case"ascii":return Cn(this,e,r);case"latin1":case"binary":return bn(this,e,r);case"base64":return vn(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _n(this,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),s=!0}}l.prototype._isBuffer=!0;function T(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}l.prototype.swap16=function(){const e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)T(this,r,r+1);return this},l.prototype.swap32=function(){const e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)T(this,r,r+3),T(this,r+1,r+2);return this},l.prototype.swap64=function(){const e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)T(this,r,r+7),T(this,r+1,r+6),T(this,r+2,r+5),T(this,r+3,r+4);return this},l.prototype.toString=function(){const e=this.length;return e===0?"":arguments.length===0?_r(this,0,e):O.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0},l.prototype.inspect=function(){let e="";const r=o.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},a&&(l.prototype[a]=l.prototype.inspect),l.prototype.compare=function(e,r,s,d,h){if(te(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),s===void 0&&(s=e?e.length:0),d===void 0&&(d=0),h===void 0&&(h=this.length),r<0||s>e.length||d<0||h>this.length)throw new RangeError("out of range index");if(d>=h&&r>=s)return 0;if(d>=h)return-1;if(r>=s)return 1;if(r>>>=0,s>>>=0,d>>>=0,h>>>=0,this===e)return 0;let k=h-d,x=s-r;const F=Math.min(k,x),R=this.slice(d,h),L=e.slice(r,s);for(let S=0;S<F;++S)if(R[S]!==L[S]){k=R[S],x=L[S];break}return k<x?-1:x<k?1:0};function br(i,e,r,s,d){if(i.length===0)return-1;if(typeof r=="string"?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,It(r)&&(r=d?0:i.length-1),r<0&&(r=i.length+r),r>=i.length){if(d)return-1;r=i.length-1}else if(r<0)if(d)r=0;else return-1;if(typeof e=="string"&&(e=l.from(e,s)),l.isBuffer(e))return e.length===0?-1:Pr(i,e,r,s,d);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(i,e,r):Uint8Array.prototype.lastIndexOf.call(i,e,r):Pr(i,[e],r,s,d);throw new TypeError("val must be string, number or Buffer")}function Pr(i,e,r,s,d){let h=1,k=i.length,x=e.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(i.length<2||e.length<2)return-1;h=2,k/=2,x/=2,r/=2}function F(L,S){return h===1?L[S]:L.readUInt16BE(S*h)}let R;if(d){let L=-1;for(R=r;R<k;R++)if(F(i,R)===F(e,L===-1?0:R-L)){if(L===-1&&(L=R),R-L+1===x)return L*h}else L!==-1&&(R-=R-L),L=-1}else for(r+x>k&&(r=k-x),R=r;R>=0;R--){let L=!0;for(let S=0;S<x;S++)if(F(i,R+S)!==F(e,S)){L=!1;break}if(L)return R}return-1}l.prototype.includes=function(e,r,s){return this.indexOf(e,r,s)!==-1},l.prototype.indexOf=function(e,r,s){return br(this,e,r,s,!0)},l.prototype.lastIndexOf=function(e,r,s){return br(this,e,r,s,!1)};function mn(i,e,r,s){r=Number(r)||0;const d=i.length-r;s?(s=Number(s),s>d&&(s=d)):s=d;const h=e.length;s>h/2&&(s=h/2);let k;for(k=0;k<s;++k){const x=parseInt(e.substr(k*2,2),16);if(It(x))return k;i[r+k]=x}return k}function kn(i,e,r,s){return tt(Et(e,i.length-r),i,r,s)}function pn(i,e,r,s){return tt(Mn(e),i,r,s)}function wn(i,e,r,s){return tt(Lr(e),i,r,s)}function gn(i,e,r,s){return tt(Sn(e,i.length-r),i,r,s)}l.prototype.write=function(e,r,s,d){if(r===void 0)d="utf8",s=this.length,r=0;else if(s===void 0&&typeof r=="string")d=r,s=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(s)?(s=s>>>0,d===void 0&&(d="utf8")):(d=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const h=this.length-r;if((s===void 0||s>h)&&(s=h),e.length>0&&(s<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let k=!1;for(;;)switch(d){case"hex":return mn(this,e,r,s);case"utf8":case"utf-8":return kn(this,e,r,s);case"ascii":case"latin1":case"binary":return pn(this,e,r,s);case"base64":return wn(this,e,r,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gn(this,e,r,s);default:if(k)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),k=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function vn(i,e,r){return e===0&&r===i.length?t.fromByteArray(i):t.fromByteArray(i.slice(e,r))}function _r(i,e,r){r=Math.min(i.length,r);const s=[];let d=e;for(;d<r;){const h=i[d];let k=null,x=h>239?4:h>223?3:h>191?2:1;if(d+x<=r){let F,R,L,S;switch(x){case 1:h<128&&(k=h);break;case 2:F=i[d+1],(F&192)===128&&(S=(h&31)<<6|F&63,S>127&&(k=S));break;case 3:F=i[d+1],R=i[d+2],(F&192)===128&&(R&192)===128&&(S=(h&15)<<12|(F&63)<<6|R&63,S>2047&&(S<55296||S>57343)&&(k=S));break;case 4:F=i[d+1],R=i[d+2],L=i[d+3],(F&192)===128&&(R&192)===128&&(L&192)===128&&(S=(h&15)<<18|(F&63)<<12|(R&63)<<6|L&63,S>65535&&S<1114112&&(k=S))}}k===null?(k=65533,x=1):k>65535&&(k-=65536,s.push(k>>>10&1023|55296),k=56320|k&1023),s.push(k),d+=x}return yn(s)}const xr=4096;function yn(i){const e=i.length;if(e<=xr)return String.fromCharCode.apply(String,i);let r="",s=0;for(;s<e;)r+=String.fromCharCode.apply(String,i.slice(s,s+=xr));return r}function Cn(i,e,r){let s="";r=Math.min(i.length,r);for(let d=e;d<r;++d)s+=String.fromCharCode(i[d]&127);return s}function bn(i,e,r){let s="";r=Math.min(i.length,r);for(let d=e;d<r;++d)s+=String.fromCharCode(i[d]);return s}function Pn(i,e,r){const s=i.length;(!e||e<0)&&(e=0),(!r||r<0||r>s)&&(r=s);let d="";for(let h=e;h<r;++h)d+=An[i[h]];return d}function _n(i,e,r){const s=i.slice(e,r);let d="";for(let h=0;h<s.length-1;h+=2)d+=String.fromCharCode(s[h]+s[h+1]*256);return d}l.prototype.slice=function(e,r){const s=this.length;e=~~e,r=r===void 0?s:~~r,e<0?(e+=s,e<0&&(e=0)):e>s&&(e=s),r<0?(r+=s,r<0&&(r=0)):r>s&&(r=s),r<e&&(r=e);const d=this.subarray(e,r);return Object.setPrototypeOf(d,l.prototype),d};function N(i,e,r){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+e>r)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(e,r,s){e=e>>>0,r=r>>>0,s||N(e,r,this.length);let d=this[e],h=1,k=0;for(;++k<r&&(h*=256);)d+=this[e+k]*h;return d},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,r,s){e=e>>>0,r=r>>>0,s||N(e,r,this.length);let d=this[e+--r],h=1;for(;r>0&&(h*=256);)d+=this[e+--r]*h;return d},l.prototype.readUint8=l.prototype.readUInt8=function(e,r){return e=e>>>0,r||N(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||N(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||N(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readBigUInt64LE=ke(function(e){e=e>>>0,Se(e,"offset");const r=this[e],s=this[e+7];(r===void 0||s===void 0)&&qe(e,this.length-8);const d=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,h=this[++e]+this[++e]*2**8+this[++e]*2**16+s*2**24;return BigInt(d)+(BigInt(h)<<BigInt(32))}),l.prototype.readBigUInt64BE=ke(function(e){e=e>>>0,Se(e,"offset");const r=this[e],s=this[e+7];(r===void 0||s===void 0)&&qe(e,this.length-8);const d=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],h=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+s;return(BigInt(d)<<BigInt(32))+BigInt(h)}),l.prototype.readIntLE=function(e,r,s){e=e>>>0,r=r>>>0,s||N(e,r,this.length);let d=this[e],h=1,k=0;for(;++k<r&&(h*=256);)d+=this[e+k]*h;return h*=128,d>=h&&(d-=Math.pow(2,8*r)),d},l.prototype.readIntBE=function(e,r,s){e=e>>>0,r=r>>>0,s||N(e,r,this.length);let d=r,h=1,k=this[e+--d];for(;d>0&&(h*=256);)k+=this[e+--d]*h;return h*=128,k>=h&&(k-=Math.pow(2,8*r)),k},l.prototype.readInt8=function(e,r){return e=e>>>0,r||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},l.prototype.readInt16LE=function(e,r){e=e>>>0,r||N(e,2,this.length);const s=this[e]|this[e+1]<<8;return s&32768?s|4294901760:s},l.prototype.readInt16BE=function(e,r){e=e>>>0,r||N(e,2,this.length);const s=this[e+1]|this[e]<<8;return s&32768?s|4294901760:s},l.prototype.readInt32LE=function(e,r){return e=e>>>0,r||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,r){return e=e>>>0,r||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readBigInt64LE=ke(function(e){e=e>>>0,Se(e,"offset");const r=this[e],s=this[e+7];(r===void 0||s===void 0)&&qe(e,this.length-8);const d=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(s<<24);return(BigInt(d)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),l.prototype.readBigInt64BE=ke(function(e){e=e>>>0,Se(e,"offset");const r=this[e],s=this[e+7];(r===void 0||s===void 0)&&qe(e,this.length-8);const d=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(d)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+s)}),l.prototype.readFloatLE=function(e,r){return e=e>>>0,r||N(e,4,this.length),n.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,r){return e=e>>>0,r||N(e,4,this.length),n.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||N(e,8,this.length),n.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||N(e,8,this.length),n.read(this,e,!1,52,8)};function V(i,e,r,s,d,h){if(!l.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>d||e<h)throw new RangeError('"value" argument is out of bounds');if(r+s>i.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,r,s,d){if(e=+e,r=r>>>0,s=s>>>0,!d){const x=Math.pow(2,8*s)-1;V(this,e,r,s,x,0)}let h=1,k=0;for(this[r]=e&255;++k<s&&(h*=256);)this[r+k]=e/h&255;return r+s},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,r,s,d){if(e=+e,r=r>>>0,s=s>>>0,!d){const x=Math.pow(2,8*s)-1;V(this,e,r,s,x,0)}let h=s-1,k=1;for(this[r+h]=e&255;--h>=0&&(k*=256);)this[r+h]=e/k&255;return r+s},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,1,255,0),this[r]=e&255,r+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Er(i,e,r,s,d){Fr(e,s,d,i,r,7);let h=Number(e&BigInt(4294967295));i[r++]=h,h=h>>8,i[r++]=h,h=h>>8,i[r++]=h,h=h>>8,i[r++]=h;let k=Number(e>>BigInt(32)&BigInt(4294967295));return i[r++]=k,k=k>>8,i[r++]=k,k=k>>8,i[r++]=k,k=k>>8,i[r++]=k,r}function Ir(i,e,r,s,d){Fr(e,s,d,i,r,7);let h=Number(e&BigInt(4294967295));i[r+7]=h,h=h>>8,i[r+6]=h,h=h>>8,i[r+5]=h,h=h>>8,i[r+4]=h;let k=Number(e>>BigInt(32)&BigInt(4294967295));return i[r+3]=k,k=k>>8,i[r+2]=k,k=k>>8,i[r+1]=k,k=k>>8,i[r]=k,r+8}l.prototype.writeBigUInt64LE=ke(function(e,r=0){return Er(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeBigUInt64BE=ke(function(e,r=0){return Ir(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeIntLE=function(e,r,s,d){if(e=+e,r=r>>>0,!d){const F=Math.pow(2,8*s-1);V(this,e,r,s,F-1,-F)}let h=0,k=1,x=0;for(this[r]=e&255;++h<s&&(k*=256);)e<0&&x===0&&this[r+h-1]!==0&&(x=1),this[r+h]=(e/k>>0)-x&255;return r+s},l.prototype.writeIntBE=function(e,r,s,d){if(e=+e,r=r>>>0,!d){const F=Math.pow(2,8*s-1);V(this,e,r,s,F-1,-F)}let h=s-1,k=1,x=0;for(this[r+h]=e&255;--h>=0&&(k*=256);)e<0&&x===0&&this[r+h+1]!==0&&(x=1),this[r+h]=(e/k>>0)-x&255;return r+s},l.prototype.writeInt8=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1},l.prototype.writeInt16LE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2},l.prototype.writeInt16BE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2},l.prototype.writeInt32LE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4},l.prototype.writeInt32BE=function(e,r,s){return e=+e,r=r>>>0,s||V(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4},l.prototype.writeBigInt64LE=ke(function(e,r=0){return Er(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),l.prototype.writeBigInt64BE=ke(function(e,r=0){return Ir(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Mr(i,e,r,s,d,h){if(r+s>i.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Sr(i,e,r,s,d){return e=+e,r=r>>>0,d||Mr(i,e,r,4),n.write(i,e,r,s,23,4),r+4}l.prototype.writeFloatLE=function(e,r,s){return Sr(this,e,r,!0,s)},l.prototype.writeFloatBE=function(e,r,s){return Sr(this,e,r,!1,s)};function Ar(i,e,r,s,d){return e=+e,r=r>>>0,d||Mr(i,e,r,8),n.write(i,e,r,s,52,8),r+8}l.prototype.writeDoubleLE=function(e,r,s){return Ar(this,e,r,!0,s)},l.prototype.writeDoubleBE=function(e,r,s){return Ar(this,e,r,!1,s)},l.prototype.copy=function(e,r,s,d){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(s||(s=0),!d&&d!==0&&(d=this.length),r>=e.length&&(r=e.length),r||(r=0),d>0&&d<s&&(d=s),d===s||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),e.length-r<d-s&&(d=e.length-r+s);const h=d-s;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,s,d):Uint8Array.prototype.set.call(e,this.subarray(s,d),r),h},l.prototype.fill=function(e,r,s,d){if(typeof e=="string"){if(typeof r=="string"?(d=r,r=0,s=this.length):typeof s=="string"&&(d=s,s=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!l.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(e.length===1){const k=e.charCodeAt(0);(d==="utf8"&&k<128||d==="latin1")&&(e=k)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<s)throw new RangeError("Out of range index");if(s<=r)return this;r=r>>>0,s=s===void 0?this.length:s>>>0,e||(e=0);let h;if(typeof e=="number")for(h=r;h<s;++h)this[h]=e;else{const k=l.isBuffer(e)?e:l.from(e,d),x=k.length;if(x===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(h=0;h<s-r;++h)this[h+r]=k[h%x]}return this};const Me={};function xt(i,e,r){Me[i]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}xt("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),xt("ERR_INVALID_ARG_TYPE",function(i,e){return`The "${i}" argument must be of type number. Received type ${typeof e}`},TypeError),xt("ERR_OUT_OF_RANGE",function(i,e,r){let s=`The value of "${i}" is out of range.`,d=r;return Number.isInteger(r)&&Math.abs(r)>2**32?d=Rr(String(r)):typeof r=="bigint"&&(d=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(d=Rr(d)),d+="n"),s+=` It must be ${e}. Received ${d}`,s},RangeError);function Rr(i){let e="",r=i.length;const s=i[0]==="-"?1:0;for(;r>=s+4;r-=3)e=`_${i.slice(r-3,r)}${e}`;return`${i.slice(0,r)}${e}`}function xn(i,e,r){Se(e,"offset"),(i[e]===void 0||i[e+r]===void 0)&&qe(e,i.length-(r+1))}function Fr(i,e,r,s,d,h){if(i>r||i<e){const k=typeof e=="bigint"?"n":"";let x;throw e===0||e===BigInt(0)?x=`>= 0${k} and < 2${k} ** ${(h+1)*8}${k}`:x=`>= -(2${k} ** ${(h+1)*8-1}${k}) and < 2 ** ${(h+1)*8-1}${k}`,new Me.ERR_OUT_OF_RANGE("value",x,i)}xn(s,d,h)}function Se(i,e){if(typeof i!="number")throw new Me.ERR_INVALID_ARG_TYPE(e,"number",i)}function qe(i,e,r){throw Math.floor(i)!==i?(Se(i,r),new Me.ERR_OUT_OF_RANGE("offset","an integer",i)):e<0?new Me.ERR_BUFFER_OUT_OF_BOUNDS:new Me.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,i)}const En=/[^+/0-9A-Za-z-_]/g;function In(i){if(i=i.split("=")[0],i=i.trim().replace(En,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function Et(i,e){e=e||1/0;let r;const s=i.length;let d=null;const h=[];for(let k=0;k<s;++k){if(r=i.charCodeAt(k),r>55295&&r<57344){if(!d){if(r>56319){(e-=3)>-1&&h.push(239,191,189);continue}else if(k+1===s){(e-=3)>-1&&h.push(239,191,189);continue}d=r;continue}if(r<56320){(e-=3)>-1&&h.push(239,191,189),d=r;continue}r=(d-55296<<10|r-56320)+65536}else d&&(e-=3)>-1&&h.push(239,191,189);if(d=null,r<128){if((e-=1)<0)break;h.push(r)}else if(r<2048){if((e-=2)<0)break;h.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;h.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;h.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return h}function Mn(i){const e=[];for(let r=0;r<i.length;++r)e.push(i.charCodeAt(r)&255);return e}function Sn(i,e){let r,s,d;const h=[];for(let k=0;k<i.length&&!((e-=2)<0);++k)r=i.charCodeAt(k),s=r>>8,d=r%256,h.push(d),h.push(s);return h}function Lr(i){return t.toByteArray(In(i))}function tt(i,e,r,s){let d;for(d=0;d<s&&!(d+r>=e.length||d>=i.length);++d)e[d+r]=i[d];return d}function te(i,e){return i instanceof e||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===e.name}function It(i){return i!==i}const An=(function(){const i="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const s=r*16;for(let d=0;d<16;++d)e[s+d]=i[r]+i[d]}return e})();function ke(i){return typeof BigInt>"u"?Rn:i}function Rn(){throw new Error("BigInt not supported")}})(bt)),bt}var yr=un();const fn=o=>{const t=yr.Buffer.from(o,"base64").toString("utf8"),n=yr.Buffer.from(t,"binary").toString("base64");return o===n?t:o},hn=async o=>{const t=fn(o),n=JSON.parse(t);return{message:t,...n}};class P{constructor(t,n,a,c,u){this._legacyCanvasSize=P.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),a&&typeof a=="object"?this._onDecode=n:(console.warn(a||c||u?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof a=="object"?a:{},this._onDecodeError=n.onDecodeError||(typeof a=="function"?a:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof c=="function"?c:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||u||this._preferredCamera,this._legacyCanvasSize=typeof a=="number"?a:typeof c=="number"?c:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let f=!1;if(t.hidden&&(t.hidden=!1,f=!0),document.body.contains(t)||(document.body.appendChild(t),f=!0),a=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(c=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),u=this.$overlay.style,u.position="absolute",u.display="none",u.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!c&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}a.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let l=window.getComputedStyle(t);l.display==="none"&&(t.style.setProperty("display","block","important"),f=!0),l.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),f=!0),f&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=P.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await P.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(c=>c.kind==="videoinput"),a;try{t&&(await n()).every(c=>!c.label)&&(a=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((c,u)=>({id:c.deviceId,label:c.label||(u===0?"Default Camera":`Camera ${u+1}`)}))}finally{a&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),P._stopVideoStream(a))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),P._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),P._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?P._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(P._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(a=>setTimeout(a,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,a,c,u=!1,f=!1){let l,B=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(l=n.scanRegion,a=n.qrEngine,c=n.canvas,u=n.disallowCanvasResizing||!1,f=n.alsoTryWithoutScanRegion||!1,B=!0):console.warn(n||a||c||u||f?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!a;try{let m,w;[a,m]=await Promise.all([a||P.createQrEngine(),P._loadImage(t)]),[c,w]=P._drawToCanvas(m,l,c,u);let y;if(a instanceof Worker){let v=a;n||P._postWorkerMessageSync(v,"inversionMode","both"),y=await new Promise((p,g)=>{let C,_,M,b=-1;_=O=>{O.data.id===b&&(v.removeEventListener("message",_),v.removeEventListener("error",M),clearTimeout(C),O.data.data!==null?p({data:O.data.data,cornerPoints:P._convertPoints(O.data.cornerPoints,l)}):g(P.NO_QR_CODE_FOUND))},M=O=>{v.removeEventListener("message",_),v.removeEventListener("error",M),clearTimeout(C),g("Scanner error: "+(O?O.message||O:"Unknown Error"))},v.addEventListener("message",_),v.addEventListener("error",M),C=setTimeout(()=>M("timeout"),1e4);let A=w.getImageData(0,0,c.width,c.height);b=P._postWorkerMessageSync(v,"decode",A,[A.data.buffer])})}else y=await Promise.race([new Promise((v,p)=>window.setTimeout(()=>p("Scanner error: timeout"),1e4)),(async()=>{try{var[v]=await a.detect(c);if(!v)throw P.NO_QR_CODE_FOUND;return{data:v.rawValue,cornerPoints:P._convertPoints(v.cornerPoints,l)}}catch(p){if(v=p.message||p,/not implemented|service unavailable/.test(v))return P._disableBarcodeDetector=!0,P.scanImage(t,{scanRegion:l,canvas:c,disallowCanvasResizing:u,alsoTryWithoutScanRegion:f});throw`Scanner error: ${v}`}})()]);return B?y:y.data}catch(m){if(!l||!f)throw m;let w=await P.scanImage(t,{qrEngine:a,canvas:c,disallowCanvasResizing:u});return B?w:w.data}finally{n||P._postWorkerMessage(a,"close")}}setGrayscaleWeights(t,n,a,c=!0){P._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:a,useIntegerApproximation:c})}setInversionMode(t){P._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>Promise.resolve().then(()=>Bn).then(a=>a.createWorker()),!(!P._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:a})=>/Chromium/i.test(a))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:a,platformVersion:c})=>/arm/i.test(a||"arm")&&13<=parseInt(c||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,a=t.videoHeight,c=t.offsetWidth,u=t.offsetHeight,f=t.offsetLeft,l=t.offsetTop,B=window.getComputedStyle(t),m=B.objectFit,w=n/a,y=c/u;switch(m){case"none":var v=n,p=a;break;case"fill":v=c,p=u;break;default:(m==="cover"?w>y:w<y)?(p=u,v=p*w):(v=c,p=v/w),m==="scale-down"&&(v=Math.min(v,n),p=Math.min(p,a))}var[g,C]=B.objectPosition.split(" ").map((M,b)=>{const A=parseFloat(M);return M.endsWith("%")?(b?u-p:c-v)*A/100:A});B=this._scanRegion.width||n,y=this._scanRegion.height||a,m=this._scanRegion.x||0;var _=this._scanRegion.y||0;w=this.$overlay.style,w.width=`${B/n*v}px`,w.height=`${y/a*p}px`,w.top=`${l+C+_/a*p}px`,a=/scaleX\(-1\)/.test(t.style.transform),w.left=`${f+(a?c-g-v:g)+(a?n-m-B:m)/n*v}px`,w.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let a=n.x||0,c=n.y||0,u=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let f of t)f.x=f.x*u+a,f.y=f.y*n+c;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(c=>setTimeout(c,n-t)),this._lastScanTimestamp=Date.now();try{var a=await P.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(c){if(!this._active)return;this._onDecodeError(c)}!P._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=P.createQrEngine()),a?(this._onDecode?this._onDecode(a):this._legacyOnDecode&&this._legacyOnDecode(a.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",a.cornerPoints.map(({x:c,y:u})=>`${c},${u}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==P.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],a=n.map(c=>Object.assign({},c,{[t]:{exact:this._preferredCamera}}));for(let c of[...a,...n])try{let u=await navigator.mediaDevices.getUserMedia({video:c,audio:!1}),f=this._getFacingMode(u)||(c.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:u,facingMode:f}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,a,c=!1){a=a||document.createElement("canvas");let u=n&&n.x?n.x:0,f=n&&n.y?n.y:0,l=n&&n.width?n.width:t.videoWidth||t.width,B=n&&n.height?n.height:t.videoHeight||t.height;return c||(c=n&&n.downScaledWidth?n.downScaledWidth:l,n=n&&n.downScaledHeight?n.downScaledHeight:B,a.width!==c&&(a.width=c),a.height!==n&&(a.height=n)),n=a.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,u,f,l,B,0,0,a.width,a.height),[a,n]}static async _loadImage(t){if(t instanceof Image)return await P._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await P._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,a)=>{let c=u=>{t.removeEventListener("load",c),t.removeEventListener("error",c),u instanceof ErrorEvent?a("Image load error"):n()};t.addEventListener("load",c),t.addEventListener("error",c)})}static async _postWorkerMessage(t,n,a,c){return P._postWorkerMessageSync(await t,n,a,c)}static _postWorkerMessageSync(t,n,a,c){if(!(t instanceof Worker))return-1;let u=P._workerMessageId++;return t.postMessage({id:u,type:n,data:a},c),u}}P.DEFAULT_CANVAS_SIZE=400,P.NO_QR_CODE_FOUND="No QR code found",P._disableBarcodeDetector=!1,P._workerMessageId=0;const _t=class _t{constructor(t,n,a){this.events={};const c=document.querySelector(t.target);if(!c)throw new Error(`Target element '${t.target}' is not found`);this.targetElement=c,this.decode=n,this.scannerElements=a}async _initializeScanner(t,n=25){try{if(!t){const a=await this.listVideoInputDevices();t=this._getMainCameraDeviceId(a)}this.qrScanner=new P(document.getElementById(`${this.scannerElements.VIDEO}`),async a=>{if(this.previousScanText!==a.data)try{this.previousScanText=a.data,this.events?.[Ie.CAPTURE]?.(await this.decode(a.data))}catch(c){this.events?.[Ie.ERROR]?.(c)}},{returnDetailedScanResult:!0,maxScansPerSecond:n,preferredCamera:t,highlightScanRegion:!0,highlightCodeOutline:!0,onDecodeError:()=>{}}),await this.qrScanner.start()}catch(a){this.events?.[Ie.ERROR]?.(a),this.qrScanner?.stop(),this.rootElement?.remove()}}async listVideoInputDevices(){return P.listCameras(!0)}_getMainCameraDeviceId(t){if(!t?.length)throw new Error("No video input devices available");const n=["back","задня"];return t.find(c=>{const u=c.label.toLowerCase();return u.includes(n[0])||u.includes(n[1])})?.id||t[1]?.id||t[0]?.id}close(){this.previousScanText=null,this.events?.[Ie.CANCEL]?.(),this.qrScanner?.stop(),this.rootElement?.remove()}on(t,n){this.events[t]=n}off(t){this.events[t]=void 0}};_t.events=Ie;let Pt=_t;class Cr extends Pt{constructor(t){super(t,hn,Je)}async scan({deviceId:t,maxScansPerSecond:n,isCloseButton:a}={}){a===void 0&&(a=!0),this.qrScanner?.stop(),this.rootElement?.remove(),new cn({target:this.targetElement,props:{close:this.close.bind(this),isCloseButton:a,scannerElements:Je}}),this.rootElement=document.getElementById(Je.ROOT),await this._initializeScanner(t,n)}}typeof window<"u"&&(window.CredenzaScanner=Cr);const Bn=Object.freeze(Object.defineProperty({__proto__:null,createWorker:()=>new Worker(URL.createObjectURL(new Blob([`class x{constructor(a,b){this.width=b;this.height=a.length/b;this.data=a}static createEmpty(a,b){return new x(new Uint8ClampedArray(a*b),a)}get(a,b){return 0>a||a>=this.width||0>b||b>=this.height?!1:!!this.data[b*this.width+a]}set(a,b,c){this.data[b*this.width+a]=c?1:0}setRegion(a,b,c,d,e){for(let f=b;f<b+d;f++)for(let g=a;g<a+c;g++)this.set(g,f,!!e)}}
|
|
8
|
-
|
|
9
|
-
class
|
|
10
|
-
this.bitOffset+=a)}return b}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var B,C=B||(B={});C.Numeric="numeric";C.Alphanumeric="alphanumeric";C.Byte="byte";C.Kanji="kanji";C.ECI="eci";C.StructuredAppend="structuredappend";var D,E=D||(D={});E[E.Terminator=0]="Terminator";E[E.Numeric=1]="Numeric";E[E.Alphanumeric=2]="Alphanumeric";E[E.Byte=4]="Byte";E[E.Kanji=8]="Kanji";E[E.ECI=7]="ECI";E[E.StructuredAppend=3]="StructuredAppend";let F="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");
|
|
11
|
-
|
|
12
|
-
function da(a,b){a=new ba(a);let c=9>=b?0:26>=b?1:2;for(b={text:"",bytes:[],chunks:[],version:b};4<=a.available();){var d=a.readBits(4);if(d===D.Terminator)return b;if(d===D.ECI)0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(7)}):0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(14)}):0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(21)}):b.chunks.push({type:B.ECI,assignmentNumber:-1});else if(d===D.Numeric){var e=a,f=[];d="";for(var g=
|
|
13
|
-
e.readBits([10,12,14][c]);3<=g;){var h=e.readBits(10);if(1E3<=h)throw Error("Invalid numeric value above 999");var k=Math.floor(h/100),m=Math.floor(h/10)%10;h%=10;f.push(48+k,48+m,48+h);d+=k.toString()+m.toString()+h.toString();g-=3}if(2===g){g=e.readBits(7);if(100<=g)throw Error("Invalid numeric value above 99");e=Math.floor(g/10);g%=10;f.push(48+e,48+g);d+=e.toString()+g.toString()}else if(1===g){e=e.readBits(4);if(10<=e)throw Error("Invalid numeric value above 9");f.push(48+e);d+=e.toString()}b.text+=
|
|
14
|
-
d;b.bytes.push(...f);b.chunks.push({type:B.Numeric,text:d})}else if(d===D.Alphanumeric){e=a;f=[];d="";for(g=e.readBits([9,11,13][c]);2<=g;)m=e.readBits(11),k=Math.floor(m/45),m%=45,f.push(F[k].charCodeAt(0),F[m].charCodeAt(0)),d+=F[k]+F[m],g-=2;1===g&&(e=e.readBits(6),f.push(F[e].charCodeAt(0)),d+=F[e]);b.text+=d;b.bytes.push(...f);b.chunks.push({type:B.Alphanumeric,text:d})}else if(d===D.Byte)d=ca(a,c),b.text+=d.text,b.bytes.push(...d.bytes),b.chunks.push({type:B.Byte,bytes:d.bytes,text:d.text});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function ha(a,b){let c=new Uint8ClampedArray(a.length);c.set(a);a=new ea(285,256,0);var d=new G(a,c),e=new Uint8ClampedArray(b),f=!1;for(var g=0;g<b;g++){var h=d.evaluateAt(a.exp(g+a.generatorBase));e[e.length-1-g]=h;0!==h&&(f=!0)}if(!f)return c;d=new G(a,e);d=fa(a,a.buildMonomial(b,1),d,b);if(null===d)return null;b=d[0];g=b.degree();if(1===g)b=[b.getCoefficient(1)];else{e=Array(g);f=0;for(h=1;h<a.size&&f<g;h++)0===b.evaluateAt(h)&&(e[f]=a.inverse(h),f++);b=f!==g?null:e}if(null==b)return null;e=d[1];
|
|
25
|
-
f
|
|
26
|
-
let I=[{infoBits:null,versionNumber:1,alignmentPatternCenters:[],errorCorrectionLevels:[{ecCodewordsPerBlock:7,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:13,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:13}]},{ecCodewordsPerBlock:17,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:2,alignmentPatternCenters:[6,18],errorCorrectionLevels:[{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,
|
|
27
|
-
dataCodewordsPerBlock:34}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:28}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]}]},{infoBits:null,versionNumber:3,alignmentPatternCenters:[6,22],errorCorrectionLevels:[{ecCodewordsPerBlock:15,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:55}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:18,
|
|
28
|
-
ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:13}]}]},{infoBits:null,versionNumber:4,alignmentPatternCenters:[6,26],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:80}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:32}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:9}]}]},
|
|
29
|
-
{infoBits:null,versionNumber:5,alignmentPatternCenters:[6,30],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:43}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:11},{numBlocks:2,dataCodewordsPerBlock:12}]}]},{infoBits:null,versionNumber:6,alignmentPatternCenters:[6,
|
|
30
|
-
34],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:27}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:31892,versionNumber:7,alignmentPatternCenters:[6,22,38],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:78}]},{ecCodewordsPerBlock:18,
|
|
31
|
-
ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:31}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:13},{numBlocks:1,dataCodewordsPerBlock:14}]}]},{infoBits:34236,versionNumber:8,alignmentPatternCenters:[6,24,42],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:97}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:38},
|
|
32
|
-
{numBlocks:2,dataCodewordsPerBlock:39}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:18},{numBlocks:2,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:14},{numBlocks:2,dataCodewordsPerBlock:15}]}]},{infoBits:39577,versionNumber:9,alignmentPatternCenters:[6,26,46],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:36},
|
|
33
|
-
{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:12},{numBlocks:4,dataCodewordsPerBlock:13}]}]},{infoBits:42195,versionNumber:10,alignmentPatternCenters:[6,28,50],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68},{numBlocks:2,dataCodewordsPerBlock:69}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,
|
|
34
|
-
dataCodewordsPerBlock:43},{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]}]},{infoBits:48118,versionNumber:11,alignmentPatternCenters:[6,30,54],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:81}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,
|
|
35
|
-
dataCodewordsPerBlock:50},{numBlocks:4,dataCodewordsPerBlock:51}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:22},{numBlocks:4,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:12},{numBlocks:8,dataCodewordsPerBlock:13}]}]},{infoBits:51042,versionNumber:12,alignmentPatternCenters:[6,32,58],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:92},{numBlocks:2,dataCodewordsPerBlock:93}]},
|
|
36
|
-
{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:20},{numBlocks:6,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:55367,versionNumber:13,alignmentPatternCenters:[6,34,62],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:107}]},
|
|
37
|
-
{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:37},{numBlocks:1,dataCodewordsPerBlock:38}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:20},{numBlocks:4,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:11},{numBlocks:4,dataCodewordsPerBlock:12}]}]},{infoBits:58893,versionNumber:14,alignmentPatternCenters:[6,26,46,66],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:115},
|
|
38
|
-
{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:40},{numBlocks:5,dataCodewordsPerBlock:41}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:16},{numBlocks:5,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:5,dataCodewordsPerBlock:13}]}]},{infoBits:63784,versionNumber:15,alignmentPatternCenters:[6,26,48,70],errorCorrectionLevels:[{ecCodewordsPerBlock:22,
|
|
39
|
-
ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:87},{numBlocks:1,dataCodewordsPerBlock:88}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:41},{numBlocks:5,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:7,dataCodewordsPerBlock:13}]}]},{infoBits:68472,versionNumber:16,alignmentPatternCenters:[6,26,50,
|
|
40
|
-
74],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:98},{numBlocks:1,dataCodewordsPerBlock:99}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:70749,
|
|
41
|
-
versionNumber:17,alignmentPatternCenters:[6,30,54,78],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:1,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22},{numBlocks:15,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:17,
|
|
42
|
-
dataCodewordsPerBlock:15}]}]},{infoBits:76311,versionNumber:18,alignmentPatternCenters:[6,30,56,82],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:120},{numBlocks:1,dataCodewordsPerBlock:121}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:43},{numBlocks:4,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:1,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,
|
|
43
|
-
dataCodewordsPerBlock:14},{numBlocks:19,dataCodewordsPerBlock:15}]}]},{infoBits:79154,versionNumber:19,alignmentPatternCenters:[6,30,58,86],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:113},{numBlocks:4,dataCodewordsPerBlock:114}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:44},{numBlocks:11,dataCodewordsPerBlock:45}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:21},{numBlocks:4,dataCodewordsPerBlock:22}]},
|
|
44
|
-
{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:13},{numBlocks:16,dataCodewordsPerBlock:14}]}]},{infoBits:84390,versionNumber:20,alignmentPatternCenters:[6,34,62,90],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:41},{numBlocks:13,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},
|
|
45
|
-
{numBlocks:5,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:15},{numBlocks:10,dataCodewordsPerBlock:16}]}]},{infoBits:87683,versionNumber:21,alignmentPatternCenters:[6,28,50,72,94],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:116},{numBlocks:4,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},
|
|
46
|
-
{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:16},{numBlocks:6,dataCodewordsPerBlock:17}]}]},{infoBits:92361,versionNumber:22,alignmentPatternCenters:[6,26,50,74,98],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:111},{numBlocks:7,dataCodewordsPerBlock:112}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},
|
|
47
|
-
{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:13}]}]},{infoBits:96236,versionNumber:23,alignmentPatternCenters:[6,30,54,74,102],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:121},{numBlocks:5,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:47},{numBlocks:14,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},
|
|
48
|
-
{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:16,dataCodewordsPerBlock:15},{numBlocks:14,dataCodewordsPerBlock:16}]}]},{infoBits:102084,versionNumber:24,alignmentPatternCenters:[6,28,54,80,106],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:45},{numBlocks:14,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,
|
|
49
|
-
ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:30,dataCodewordsPerBlock:16},{numBlocks:2,dataCodewordsPerBlock:17}]}]},{infoBits:102881,versionNumber:25,alignmentPatternCenters:[6,32,58,84,110],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:106},{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:47},{numBlocks:13,
|
|
50
|
-
dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:110507,versionNumber:26,alignmentPatternCenters:[6,30,58,86,114],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:114},{numBlocks:2,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,
|
|
51
|
-
dataCodewordsPerBlock:46},{numBlocks:4,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:28,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:33,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]}]},{infoBits:110734,versionNumber:27,alignmentPatternCenters:[6,34,62,90,118],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},
|
|
52
|
-
{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:23},{numBlocks:26,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:117786,versionNumber:28,alignmentPatternCenters:[6,26,50,74,98,122],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:117},
|
|
53
|
-
{numBlocks:10,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:45},{numBlocks:23,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:24},{numBlocks:31,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:31,dataCodewordsPerBlock:16}]}]},{infoBits:119615,versionNumber:29,alignmentPatternCenters:[6,30,54,78,102,126],errorCorrectionLevels:[{ecCodewordsPerBlock:30,
|
|
54
|
-
ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:116},{numBlocks:7,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:21,dataCodewordsPerBlock:45},{numBlocks:7,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:23},{numBlocks:37,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:26,dataCodewordsPerBlock:16}]}]},{infoBits:126325,versionNumber:30,alignmentPatternCenters:[6,
|
|
55
|
-
26,52,78,104,130],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:115},{numBlocks:10,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:47},{numBlocks:10,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:25,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:25,dataCodewordsPerBlock:16}]}]},
|
|
56
|
-
{infoBits:127568,versionNumber:31,alignmentPatternCenters:[6,30,56,82,108,134],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:3,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:46},{numBlocks:29,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:24},{numBlocks:1,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},
|
|
57
|
-
{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:133589,versionNumber:32,alignmentPatternCenters:[6,34,60,86,112,138],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:24},{numBlocks:35,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,
|
|
58
|
-
dataCodewordsPerBlock:15},{numBlocks:35,dataCodewordsPerBlock:16}]}]},{infoBits:136944,versionNumber:33,alignmentPatternCenters:[6,30,58,86,114,142],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:21,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:24},{numBlocks:19,dataCodewordsPerBlock:25}]},
|
|
59
|
-
{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:141498,versionNumber:34,alignmentPatternCenters:[6,34,62,90,118,146],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:6,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:44,
|
|
60
|
-
dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:59,dataCodewordsPerBlock:16},{numBlocks:1,dataCodewordsPerBlock:17}]}]},{infoBits:145311,versionNumber:35,alignmentPatternCenters:[6,30,54,78,102,126,150],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:121},{numBlocks:7,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:47},{numBlocks:26,dataCodewordsPerBlock:48}]},
|
|
61
|
-
{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:39,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:41,dataCodewordsPerBlock:16}]}]},{infoBits:150283,versionNumber:36,alignmentPatternCenters:[6,24,50,76,102,128,154],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:121},{numBlocks:14,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,
|
|
62
|
-
dataCodewordsPerBlock:47},{numBlocks:34,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:46,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:64,dataCodewordsPerBlock:16}]}]},{infoBits:152622,versionNumber:37,alignmentPatternCenters:[6,28,54,80,106,132,158],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},
|
|
63
|
-
{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:46},{numBlocks:14,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:49,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:24,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:158308,versionNumber:38,alignmentPatternCenters:[6,32,58,84,110,136,162],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,
|
|
64
|
-
dataCodewordsPerBlock:122},{numBlocks:18,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:46},{numBlocks:32,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:48,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:15},{numBlocks:32,dataCodewordsPerBlock:16}]}]},{infoBits:161089,versionNumber:39,alignmentPatternCenters:[6,26,54,82,110,138,166],
|
|
65
|
-
errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:40,dataCodewordsPerBlock:47},{numBlocks:7,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:43,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:15},{numBlocks:67,dataCodewordsPerBlock:16}]}]},{infoBits:167017,
|
|
66
|
-
versionNumber:40,alignmentPatternCenters:[6,30,58,86,114,142,170],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:118},{numBlocks:6,dataCodewordsPerBlock:119}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:18,dataCodewordsPerBlock:47},{numBlocks:31,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:24},{numBlocks:34,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:15},
|
|
67
|
-
{numBlocks:61,dataCodewordsPerBlock:16}]}]}];function J(a,b){a^=b;for(b=0;a;)b++,a&=a-1;return b}function K(a,b){return b<<1|a}
|
|
68
|
-
let ia=[{bits:21522,formatInfo:{errorCorrectionLevel:1,dataMask:0}},{bits:20773,formatInfo:{errorCorrectionLevel:1,dataMask:1}},{bits:24188,formatInfo:{errorCorrectionLevel:1,dataMask:2}},{bits:23371,formatInfo:{errorCorrectionLevel:1,dataMask:3}},{bits:17913,formatInfo:{errorCorrectionLevel:1,dataMask:4}},{bits:16590,formatInfo:{errorCorrectionLevel:1,dataMask:5}},{bits:20375,formatInfo:{errorCorrectionLevel:1,dataMask:6}},{bits:19104,formatInfo:{errorCorrectionLevel:1,dataMask:7}},{bits:30660,formatInfo:{errorCorrectionLevel:0,
|
|
69
|
-
dataMask:0}},{bits:29427,formatInfo:{errorCorrectionLevel:0,dataMask:1}},{bits:32170,formatInfo:{errorCorrectionLevel:0,dataMask:2}},{bits:30877,formatInfo:{errorCorrectionLevel:0,dataMask:3}},{bits:26159,formatInfo:{errorCorrectionLevel:0,dataMask:4}},{bits:25368,formatInfo:{errorCorrectionLevel:0,dataMask:5}},{bits:27713,formatInfo:{errorCorrectionLevel:0,dataMask:6}},{bits:26998,formatInfo:{errorCorrectionLevel:0,dataMask:7}},{bits:5769,formatInfo:{errorCorrectionLevel:3,dataMask:0}},{bits:5054,
|
|
70
|
-
formatInfo:{errorCorrectionLevel:3,dataMask:1}},{bits:7399,formatInfo:{errorCorrectionLevel:3,dataMask:2}},{bits:6608,formatInfo:{errorCorrectionLevel:3,dataMask:3}},{bits:1890,formatInfo:{errorCorrectionLevel:3,dataMask:4}},{bits:597,formatInfo:{errorCorrectionLevel:3,dataMask:5}},{bits:3340,formatInfo:{errorCorrectionLevel:3,dataMask:6}},{bits:2107,formatInfo:{errorCorrectionLevel:3,dataMask:7}},{bits:13663,formatInfo:{errorCorrectionLevel:2,dataMask:0}},{bits:12392,formatInfo:{errorCorrectionLevel:2,
|
|
71
|
-
dataMask:1}},{bits:16177,formatInfo:{errorCorrectionLevel:2,dataMask:2}},{bits:14854,formatInfo:{errorCorrectionLevel:2,dataMask:3}},{bits:9396,formatInfo:{errorCorrectionLevel:2,dataMask:4}},{bits:8579,formatInfo:{errorCorrectionLevel:2,dataMask:5}},{bits:11994,formatInfo:{errorCorrectionLevel:2,dataMask:6}},{bits:11245,formatInfo:{errorCorrectionLevel:2,dataMask:7}}],ja=[a=>0===(a.y+a.x)%2,a=>0===a.y%2,a=>0===a.x%3,a=>0===(a.y+a.x)%3,a=>0===(Math.floor(a.y/2)+Math.floor(a.x/3))%2,a=>0===a.x*a.y%
|
|
72
|
-
2+a.x*a.y%3,a=>0===(a.y*a.x%2+a.y*a.x%3)%2,a=>0===((a.y+a.x)%2+a.y*a.x%3)%2];
|
|
73
|
-
function ka(a,b,c){c=ja[c.dataMask];let d=a.height;var e=17+4*b.versionNumber;let f=x.createEmpty(e,e);f.setRegion(0,0,9,9,!0);f.setRegion(e-8,0,8,9,!0);f.setRegion(0,e-8,9,8,!0);for(var g of b.alignmentPatternCenters)for(var h of b.alignmentPatternCenters)6===g&&6===h||6===g&&h===e-7||g===e-7&&6===h||f.setRegion(g-2,h-2,5,5,!0);f.setRegion(6,9,1,e-17,!0);f.setRegion(9,6,e-17,1,!0);6<b.versionNumber&&(f.setRegion(e-11,0,3,6,!0),f.setRegion(0,e-11,6,3,!0));b=[];h=g=0;e=!0;for(let k=d-1;0<k;k-=2){6===
|
|
74
|
-
k&&k--;for(let m=0;m<d;m++){let l=e?d-1-m:m;for(let n=0;2>n;n++){let q=k-n;if(!f.get(q,l)){h++;let r=a.get(q,l);c({y:l,x:q})&&(r=!r);g=g<<1|r;8===h&&(b.push(g),g=h=0)}}}e=!e}return b}
|
|
75
|
-
function la(a){var b=a.height,c=Math.floor((b-17)/4);if(6>=c)return I[c-1];c=0;for(var d=5;0<=d;d--)for(var e=b-9;e>=b-11;e--)c=K(a.get(e,d),c);d=0;for(e=5;0<=e;e--)for(let g=b-9;g>=b-11;g--)d=K(a.get(e,g),d);a=Infinity;let f;for(let g of I){if(g.infoBits===c||g.infoBits===d)return g;b=J(c,g.infoBits);b<a&&(f=g,a=b);b=J(d,g.infoBits);b<a&&(f=g,a=b)}if(3>=a)return f}
|
|
76
|
-
function ma(a){let b=0;for(var c=0;8>=c;c++)6!==c&&(b=K(a.get(c,8),b));for(c=7;0<=c;c--)6!==c&&(b=K(a.get(8,c),b));var d=a.height;c=0;for(var e=d-1;e>=d-7;e--)c=K(a.get(8,e),c);for(e=d-8;e<d;e++)c=K(a.get(e,8),c);a=Infinity;d=null;for(let {bits:f,formatInfo:g}of ia){if(f===b||f===c)return g;e=J(b,f);e<a&&(d=g,a=e);b!==c&&(e=J(c,f),e<a&&(d=g,a=e))}return 3>=a?d:null}
|
|
77
|
-
function na(a,b,c){let d=b.errorCorrectionLevels[c],e=[],f=0;d.ecBlocks.forEach(h=>{for(let k=0;k<h.numBlocks;k++)e.push({numDataCodewords:h.dataCodewordsPerBlock,codewords:[]}),f+=h.dataCodewordsPerBlock+d.ecCodewordsPerBlock});if(a.length<f)return null;a=a.slice(0,f);b=d.ecBlocks[0].dataCodewordsPerBlock;for(c=0;c<b;c++)for(var g of e)g.codewords.push(a.shift());if(1<d.ecBlocks.length)for(g=d.ecBlocks[0].numBlocks,b=d.ecBlocks[1].numBlocks,c=0;c<b;c++)e[g+c].codewords.push(a.shift());for(;0<a.length;)for(let h of e)h.codewords.push(a.shift());
|
|
78
|
-
return e}function L(a){let b=la(a);if(!b)return null;var c=ma(a);if(!c)return null;a=ka(a,b,c);var d=na(a,b,c.errorCorrectionLevel);if(!d)return null;c=d.reduce((e,f)=>e+f.numDataCodewords,0);c=new Uint8ClampedArray(c);a=0;for(let e of d){d=ha(e.codewords,e.codewords.length-e.numDataCodewords);if(!d)return null;for(let f=0;f<e.numDataCodewords;f++)c[a++]=d[f]}try{return da(c,b.versionNumber)}catch(e){return null}}
|
|
79
|
-
function M(a,b,c,d){var e=a.x-b.x+c.x-d.x;let f=a.y-b.y+c.y-d.y;if(0===e&&0===f)return{a11:b.x-a.x,a12:b.y-a.y,a13:0,a21:c.x-b.x,a22:c.y-b.y,a23:0,a31:a.x,a32:a.y,a33:1};let g=b.x-c.x;var h=d.x-c.x;let k=b.y-c.y,m=d.y-c.y;c=g*m-h*k;h=(e*m-h*f)/c;e=(g*f-e*k)/c;return{a11:b.x-a.x+h*b.x,a12:b.y-a.y+h*b.y,a13:h,a21:d.x-a.x+e*d.x,a22:d.y-a.y+e*d.y,a23:e,a31:a.x,a32:a.y,a33:1}}
|
|
80
|
-
function oa(a,b,c,d){a=M(a,b,c,d);return{a11:a.a22*a.a33-a.a23*a.a32,a12:a.a13*a.a32-a.a12*a.a33,a13:a.a12*a.a23-a.a13*a.a22,a21:a.a23*a.a31-a.a21*a.a33,a22:a.a11*a.a33-a.a13*a.a31,a23:a.a13*a.a21-a.a11*a.a23,a31:a.a21*a.a32-a.a22*a.a31,a32:a.a12*a.a31-a.a11*a.a32,a33:a.a11*a.a22-a.a12*a.a21}}
|
|
81
|
-
function pa(a,b){var c=oa({x:3.5,y:3.5},{x:b.dimension-3.5,y:3.5},{x:b.dimension-6.5,y:b.dimension-6.5},{x:3.5,y:b.dimension-3.5}),d=M(b.topLeft,b.topRight,b.alignmentPattern,b.bottomLeft),e=d.a11*c.a11+d.a21*c.a12+d.a31*c.a13,f=d.a12*c.a11+d.a22*c.a12+d.a32*c.a13,g=d.a13*c.a11+d.a23*c.a12+d.a33*c.a13,h=d.a11*c.a21+d.a21*c.a22+d.a31*c.a23,k=d.a12*c.a21+d.a22*c.a22+d.a32*c.a23,m=d.a13*c.a21+d.a23*c.a22+d.a33*c.a23,l=d.a11*c.a31+d.a21*c.a32+d.a31*c.a33,n=d.a12*c.a31+d.a22*c.a32+d.a32*c.a33,q=d.a13*
|
|
82
|
-
c.a31+d.a23*c.a32+d.a33*c.a33;c=x.createEmpty(b.dimension,b.dimension);d=(r,u)=>{const p=g*r+m*u+q;return{x:(e*r+h*u+l)/p,y:(f*r+k*u+n)/p}};for(let r=0;r<b.dimension;r++)for(let u=0;u<b.dimension;u++){let p=d(u+.5,r+.5);c.set(u,r,a.get(Math.floor(p.x),Math.floor(p.y)))}return{matrix:c,mappingFunction:d}}let N=(a,b)=>Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2));function O(a){return a.reduce((b,c)=>b+c)}
|
|
83
|
-
function qa(a,b,c){let d=N(a,b),e=N(b,c),f=N(a,c),g,h,k;e>=d&&e>=f?[g,h,k]=[b,a,c]:f>=e&&f>=d?[g,h,k]=[a,b,c]:[g,h,k]=[a,c,b];0>(k.x-h.x)*(g.y-h.y)-(k.y-h.y)*(g.x-h.x)&&([g,k]=[k,g]);return{bottomLeft:g,topLeft:h,topRight:k}}
|
|
84
|
-
function ra(a,b,c,d){d=(O(P(a,c,d,5))/7+O(P(a,b,d,5))/7+O(P(c,a,d,5))/7+O(P(b,a,d,5))/7)/4;if(1>d)throw Error("Invalid module size");b=Math.round(N(a,b)/d);a=Math.round(N(a,c)/d);a=Math.floor((b+a)/2)+7;switch(a%4){case 0:a++;break;case 2:a--}return{dimension:a,moduleSize:d}}
|
|
85
|
-
function Q(a,b,c,d){let e=[{x:Math.floor(a.x),y:Math.floor(a.y)}];var f=Math.abs(b.y-a.y)>Math.abs(b.x-a.x);if(f){var g=Math.floor(a.y);var h=Math.floor(a.x);a=Math.floor(b.y);b=Math.floor(b.x)}else g=Math.floor(a.x),h=Math.floor(a.y),a=Math.floor(b.x),b=Math.floor(b.y);let k=Math.abs(a-g),m=Math.abs(b-h),l=Math.floor(-k/2),n=g<a?1:-1,q=h<b?1:-1,r=!0;for(let u=g,p=h;u!==a+n;u+=n){g=f?p:u;h=f?u:p;if(c.get(g,h)!==r&&(r=!r,e.push({x:g,y:h}),e.length===d+1))break;l+=m;if(0<l){if(p===b)break;p+=q;l-=k}}c=
|
|
86
|
-
[];for(f=0;f<d;f++)e[f]&&e[f+1]?c.push(N(e[f],e[f+1])):c.push(0);return c}function P(a,b,c,d){let e=b.y-a.y,f=b.x-a.x;b=Q(a,b,c,Math.ceil(d/2));a=Q(a,{x:a.x-f,y:a.y-e},c,Math.ceil(d/2));c=b.shift()+a.shift()-1;return a.concat(c).concat(...b)}function R(a,b){let c=O(a)/O(b),d=0;b.forEach((e,f)=>{d+=Math.pow(a[f]-e*c,2)});return{averageSize:c,error:d}}
|
|
87
|
-
function S(a,b,c){try{let d=P(a,{x:-1,y:a.y},c,b.length),e=P(a,{x:a.x,y:-1},c,b.length),f=P(a,{x:Math.max(0,a.x-a.y)-1,y:Math.max(0,a.y-a.x)-1},c,b.length),g=P(a,{x:Math.min(c.width,a.x+a.y)+1,y:Math.min(c.height,a.y+a.x)+1},c,b.length),h=R(d,b),k=R(e,b),m=R(f,b),l=R(g,b),n=(h.averageSize+k.averageSize+m.averageSize+l.averageSize)/4;return Math.sqrt(h.error*h.error+k.error*k.error+m.error*m.error+l.error*l.error)+(Math.pow(h.averageSize-n,2)+Math.pow(k.averageSize-n,2)+Math.pow(m.averageSize-n,2)+
|
|
88
|
-
Math.pow(l.averageSize-n,2))/n}catch(d){return Infinity}}function T(a,b){for(var c=Math.round(b.x);a.get(c,Math.round(b.y));)c--;for(var d=Math.round(b.x);a.get(d,Math.round(b.y));)d++;c=(c+d)/2;for(d=Math.round(b.y);a.get(Math.round(c),d);)d--;for(b=Math.round(b.y);a.get(Math.round(c),b);)b++;return{x:c,y:(d+b)/2}}
|
|
89
|
-
function sa(a){var b=[],c=[];let d=[];var e=[];for(let p=0;p<=a.height;p++){var f=0,g=!1;let t=[0,0,0,0,0];for(let v=-1;v<=a.width;v++){var h=a.get(v,p);if(h===g)f++;else{t=[t[1],t[2],t[3],t[4],f];f=1;g=h;var k=O(t)/7;k=Math.abs(t[0]-k)<k&&Math.abs(t[1]-k)<k&&Math.abs(t[2]-3*k)<3*k&&Math.abs(t[3]-k)<k&&Math.abs(t[4]-k)<k&&!h;var m=O(t.slice(-3))/3;h=Math.abs(t[2]-m)<m&&Math.abs(t[3]-m)<m&&Math.abs(t[4]-m)<m&&h;if(k){let z=v-t[3]-t[4],y=z-t[2];k={startX:y,endX:z,y:p};m=c.filter(w=>y>=w.bottom.startX&&
|
|
90
|
-
y<=w.bottom.endX||z>=w.bottom.startX&&y<=w.bottom.endX||y<=w.bottom.startX&&z>=w.bottom.endX&&1.5>t[2]/(w.bottom.endX-w.bottom.startX)&&.5<t[2]/(w.bottom.endX-w.bottom.startX));0<m.length?m[0].bottom=k:c.push({top:k,bottom:k})}if(h){let z=v-t[4],y=z-t[3];h={startX:y,y:p,endX:z};k=e.filter(w=>y>=w.bottom.startX&&y<=w.bottom.endX||z>=w.bottom.startX&&y<=w.bottom.endX||y<=w.bottom.startX&&z>=w.bottom.endX&&1.5>t[2]/(w.bottom.endX-w.bottom.startX)&&.5<t[2]/(w.bottom.endX-w.bottom.startX));0<k.length?
|
|
91
|
-
k[0].bottom=h:e.push({top:h,bottom:h})}}}b.push(...c.filter(v=>v.bottom.y!==p&&2<=v.bottom.y-v.top.y));c=c.filter(v=>v.bottom.y===p);d.push(...e.filter(v=>v.bottom.y!==p));e=e.filter(v=>v.bottom.y===p)}b.push(...c.filter(p=>2<=p.bottom.y-p.top.y));d.push(...e);c=[];for(var l of b)2>l.bottom.y-l.top.y||(b=(l.top.startX+l.top.endX+l.bottom.startX+l.bottom.endX)/4,e=(l.top.y+l.bottom.y+1)/2,a.get(Math.round(b),Math.round(e))&&(f=[l.top.endX-l.top.startX,l.bottom.endX-l.bottom.startX,l.bottom.y-l.top.y+
|
|
92
|
-
1],f=O(f)/f.length,g=S({x:Math.round(b),y:Math.round(e)},[1,1,3,1,1],a),c.push({score:g,x:b,y:e,size:f})));if(3>c.length)return null;c.sort((p,t)=>p.score-t.score);l=[];for(b=0;b<Math.min(c.length,5);++b){e=c[b];f=[];for(var n of c)n!==e&&f.push(Object.assign(Object.assign({},n),{score:n.score+Math.pow(n.size-e.size,2)/e.size}));f.sort((p,t)=>p.score-t.score);l.push({points:[e,f[0],f[1]],score:e.score+f[0].score+f[1].score})}l.sort((p,t)=>p.score-t.score);let {topRight:q,topLeft:r,bottomLeft:u}=qa(...l[0].points);
|
|
93
|
-
l=U(a,d,q,r,u);n=[];l&&n.push({alignmentPattern:{x:l.alignmentPattern.x,y:l.alignmentPattern.y},bottomLeft:{x:u.x,y:u.y},dimension:l.dimension,topLeft:{x:r.x,y:r.y},topRight:{x:q.x,y:q.y}});l=T(a,q);b=T(a,r);c=T(a,u);(a=U(a,d,l,b,c))&&n.push({alignmentPattern:{x:a.alignmentPattern.x,y:a.alignmentPattern.y},bottomLeft:{x:c.x,y:c.y},topLeft:{x:b.x,y:b.y},topRight:{x:l.x,y:l.y},dimension:a.dimension});return 0===n.length?null:n}
|
|
94
|
-
function U(a,b,c,d,e){let f,g;try{({dimension:f,moduleSize:g}=ra(d,c,e,a))}catch(l){return null}var h=c.x-d.x+e.x,k=c.y-d.y+e.y;c=(N(d,e)+N(d,c))/2/g;e=1-3/c;let m={x:d.x+e*(h-d.x),y:d.y+e*(k-d.y)};b=b.map(l=>{const n=(l.top.startX+l.top.endX+l.bottom.startX+l.bottom.endX)/4;l=(l.top.y+l.bottom.y+1)/2;if(a.get(Math.floor(n),Math.floor(l))){var q=S({x:Math.floor(n),y:Math.floor(l)},[1,1,1],a)+N({x:n,y:l},m);return{x:n,y:l,score:q}}}).filter(l=>!!l).sort((l,n)=>l.score-n.score);return{alignmentPattern:15<=
|
|
95
|
-
c&&b.length?b[0]:m,dimension:f}}
|
|
96
|
-
function V(a){var b=sa(a);if(!b)return null;for(let e of b){b=pa(a,e);var c=b.matrix;if(null==c)c=null;else{var d=L(c);if(d)c=d;else{for(d=0;d<c.width;d++)for(let f=d+1;f<c.height;f++)c.get(d,f)!==c.get(f,d)&&(c.set(d,f,!c.get(d,f)),c.set(f,d,!c.get(f,d)));c=L(c)}}if(c)return{binaryData:c.bytes,data:c.text,chunks:c.chunks,version:c.version,location:{topRightCorner:b.mappingFunction(e.dimension,0),topLeftCorner:b.mappingFunction(0,0),bottomRightCorner:b.mappingFunction(e.dimension,e.dimension),bottomLeftCorner:b.mappingFunction(0,
|
|
97
|
-
e.dimension),topRightFinderPattern:e.topRight,topLeftFinderPattern:e.topLeft,bottomLeftFinderPattern:e.bottomLeft,bottomRightAlignmentPattern:e.alignmentPattern},matrix:b.matrix}}return null}let ta={inversionAttempts:"attemptBoth",greyScaleWeights:{red:.2126,green:.7152,blue:.0722,useIntegerApproximation:!1},canOverwriteImage:!0};function W(a,b){Object.keys(b).forEach(c=>{a[c]=b[c]})}
|
|
98
|
-
function X(a,b,c,d={}){let e=Object.create(null);W(e,ta);W(e,d);d="onlyInvert"===e.inversionAttempts||"invertFirst"===e.inversionAttempts;var f="attemptBoth"===e.inversionAttempts||d;var g=e.greyScaleWeights,h=e.canOverwriteImage,k=b*c;if(a.length!==4*k)throw Error("Malformed data passed to binarizer.");var m=0;if(h){var l=new Uint8ClampedArray(a.buffer,m,k);m+=k}l=new A(b,c,l);if(g.useIntegerApproximation)for(var n=0;n<c;n++)for(var q=0;q<b;q++){var r=4*(n*b+q);l.set(q,n,g.red*a[r]+g.green*a[r+1]+
|
|
99
|
-
g.blue*a[r+2]+128>>8)}else for(n=0;n<c;n++)for(q=0;q<b;q++)r=4*(n*b+q),l.set(q,n,g.red*a[r]+g.green*a[r+1]+g.blue*a[r+2]);g=Math.ceil(b/8);n=Math.ceil(c/8);q=g*n;if(h){var u=new Uint8ClampedArray(a.buffer,m,q);m+=q}u=new A(g,n,u);for(q=0;q<n;q++)for(r=0;r<g;r++){var p=Infinity,t=0;for(var v=0;8>v;v++)for(let w=0;8>w;w++){let aa=l.get(8*r+w,8*q+v);p=Math.min(p,aa);t=Math.max(t,aa)}v=(p+t)/2;v=Math.min(255,1.11*v);24>=t-p&&(v=p/2,0<q&&0<r&&(t=(u.get(r,q-1)+2*u.get(r-1,q)+u.get(r-1,q-1))/4,p<t&&(v=t)));
|
|
100
|
-
u.set(r,q,v)}h?(q=new Uint8ClampedArray(a.buffer,m,k),m+=k,q=new x(q,b)):q=x.createEmpty(b,c);r=null;f&&(h?(a=new Uint8ClampedArray(a.buffer,m,k),r=new x(a,b)):r=x.createEmpty(b,c));for(b=0;b<n;b++)for(a=0;a<g;a++){c=g-3;c=2>a?2:a>c?c:a;h=n-3;h=2>b?2:b>h?h:b;k=0;for(m=-2;2>=m;m++)for(p=-2;2>=p;p++)k+=u.get(c+m,h+p);c=k/25;for(h=0;8>h;h++)for(k=0;8>k;k++)m=8*a+h,p=8*b+k,t=l.get(m,p),q.set(m,p,t<=c),f&&r.set(m,p,!(t<=c))}f=f?{binarized:q,inverted:r}:{binarized:q};let {binarized:z,inverted:y}=f;(f=V(d?
|
|
101
|
-
y:z))||"attemptBoth"!==e.inversionAttempts&&"invertFirst"!==e.inversionAttempts||(f=V(d?z:y));return f}X.default=X;let Y="dontInvert",Z={red:77,green:150,blue:29,useIntegerApproximation:!0};
|
|
102
|
-
self.onmessage=a=>{let b=a.data.id,c=a.data.data;switch(a.data.type){case "decode":(a=X(c.data,c.width,c.height,{inversionAttempts:Y,greyScaleWeights:Z}))?self.postMessage({id:b,type:"qrResult",data:a.data,cornerPoints:[a.location.topLeftCorner,a.location.topRightCorner,a.location.bottomRightCorner,a.location.bottomLeftCorner]}):self.postMessage({id:b,type:"qrResult",data:null});break;case "grayscaleWeights":Z.red=c.red;Z.green=c.green;Z.blue=c.blue;Z.useIntegerApproximation=c.useIntegerApproximation;
|
|
103
|
-
break;case "inversionMode":switch(c){case "original":Y="dontInvert";break;case "invert":Y="onlyInvert";break;case "both":Y="attemptBoth";break;default:throw Error("Invalid inversion mode");}break;case "close":self.close()}}
|
|
104
|
-
`]),{type:"application/javascript"}))},Symbol.toStringTag,{value:"Module"}));ye.Scanner=Cr,Object.defineProperty(ye,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
*/(function(x){const f=zn,c=xr,m=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;x.Buffer=S,x.SlowBuffer=Ne,x.INSPECT_MAX_BYTES=50;const I=2147483647;x.kMaxLength=I,S.TYPED_ARRAY_SUPPORT=g(),!S.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function g(){try{const C=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(C,u),C.foo()===42}catch{return!1}}Object.defineProperty(S.prototype,"parent",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.buffer}}),Object.defineProperty(S.prototype,"offset",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.byteOffset}});function _(C){if(C>I)throw new RangeError('The value "'+C+'" is invalid for option "size"');const u=new Uint8Array(C);return Object.setPrototypeOf(u,S.prototype),u}function S(C,u,h){if(typeof C=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(C)}return P(C,u,h)}S.poolSize=8192;function P(C,u,h){if(typeof C=="string")return ae(C,u);if(ArrayBuffer.isView(C))return Pe(C);if(C==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof C);if(at(C,ArrayBuffer)||C&&at(C.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(at(C,SharedArrayBuffer)||C&&at(C.buffer,SharedArrayBuffer)))return he(C,u,h);if(typeof C=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const T=C.valueOf&&C.valueOf();if(T!=null&&T!==C)return S.from(T,u,h);const O=pt(C);if(O)return O;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof C[Symbol.toPrimitive]=="function")return S.from(C[Symbol.toPrimitive]("string"),u,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof C)}S.from=function(C,u,h){return P(C,u,h)},Object.setPrototypeOf(S.prototype,Uint8Array.prototype),Object.setPrototypeOf(S,Uint8Array);function p(C){if(typeof C!="number")throw new TypeError('"size" argument must be of type number');if(C<0)throw new RangeError('The value "'+C+'" is invalid for option "size"')}function k(C,u,h){return p(C),C<=0?_(C):u!==void 0?typeof h=="string"?_(C).fill(u,h):_(C).fill(u):_(C)}S.alloc=function(C,u,h){return k(C,u,h)};function M(C){return p(C),_(C<0?0:mt(C)|0)}S.allocUnsafe=function(C){return M(C)},S.allocUnsafeSlow=function(C){return M(C)};function ae(C,u){if((typeof u!="string"||u==="")&&(u="utf8"),!S.isEncoding(u))throw new TypeError("Unknown encoding: "+u);const h=ne(C,u)|0;let T=_(h);const O=T.write(C,u);return O!==h&&(T=T.slice(0,O)),T}function Q(C){const u=C.length<0?0:mt(C.length)|0,h=_(u);for(let T=0;T<u;T+=1)h[T]=C[T]&255;return h}function Pe(C){if(at(C,Uint8Array)){const u=new Uint8Array(C);return he(u.buffer,u.byteOffset,u.byteLength)}return Q(C)}function he(C,u,h){if(u<0||C.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if(C.byteLength<u+(h||0))throw new RangeError('"length" is outside of buffer bounds');let T;return u===void 0&&h===void 0?T=new Uint8Array(C):h===void 0?T=new Uint8Array(C,u):T=new Uint8Array(C,u,h),Object.setPrototypeOf(T,S.prototype),T}function pt(C){if(S.isBuffer(C)){const u=mt(C.length)|0,h=_(u);return h.length===0||C.copy(h,0,0,u),h}if(C.length!==void 0)return typeof C.length!="number"||pn(C.length)?_(0):Q(C);if(C.type==="Buffer"&&Array.isArray(C.data))return Q(C.data)}function mt(C){if(C>=I)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I.toString(16)+" bytes");return C|0}function Ne(C){return+C!=C&&(C=0),S.alloc(+C)}S.isBuffer=function(u){return u!=null&&u._isBuffer===!0&&u!==S.prototype},S.compare=function(u,h){if(at(u,Uint8Array)&&(u=S.from(u,u.offset,u.byteLength)),at(h,Uint8Array)&&(h=S.from(h,h.offset,h.byteLength)),!S.isBuffer(u)||!S.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(u===h)return 0;let T=u.length,O=h.length;for(let v=0,U=Math.min(T,O);v<U;++v)if(u[v]!==h[v]){T=u[v],O=h[v];break}return T<O?-1:O<T?1:0},S.isEncoding=function(u){switch(String(u).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},S.concat=function(u,h){if(!Array.isArray(u))throw new TypeError('"list" argument must be an Array of Buffers');if(u.length===0)return S.alloc(0);let T;if(h===void 0)for(h=0,T=0;T<u.length;++T)h+=u[T].length;const O=S.allocUnsafe(h);let v=0;for(T=0;T<u.length;++T){let U=u[T];if(at(U,Uint8Array))v+U.length>O.length?(S.isBuffer(U)||(U=S.from(U)),U.copy(O,v)):Uint8Array.prototype.set.call(O,U,v);else if(S.isBuffer(U))U.copy(O,v);else throw new TypeError('"list" argument must be an Array of Buffers');v+=U.length}return O};function ne(C,u){if(S.isBuffer(C))return C.length;if(ArrayBuffer.isView(C)||at(C,ArrayBuffer))return C.byteLength;if(typeof C!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof C);const h=C.length,T=arguments.length>2&&arguments[2]===!0;if(!T&&h===0)return 0;let O=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Ye(C).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return sn(C).length;default:if(O)return T?-1:Ye(C).length;u=(""+u).toLowerCase(),O=!0}}S.byteLength=ne;function Ee(C,u,h){let T=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,u>>>=0,h<=u))return"";for(C||(C="utf8");;)switch(C){case"hex":return vt(this,u,h);case"utf8":case"utf-8":return He(this,u,h);case"ascii":return le(this,u,h);case"latin1":case"binary":return tn(this,u,h);case"base64":return Te(this,u,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ft(this,u,h);default:if(T)throw new TypeError("Unknown encoding: "+C);C=(C+"").toLowerCase(),T=!0}}S.prototype._isBuffer=!0;function nt(C,u,h){const T=C[u];C[u]=C[h],C[h]=T}S.prototype.swap16=function(){const u=this.length;if(u%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<u;h+=2)nt(this,h,h+1);return this},S.prototype.swap32=function(){const u=this.length;if(u%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<u;h+=4)nt(this,h,h+3),nt(this,h+1,h+2);return this},S.prototype.swap64=function(){const u=this.length;if(u%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<u;h+=8)nt(this,h,h+7),nt(this,h+1,h+6),nt(this,h+2,h+5),nt(this,h+3,h+4);return this},S.prototype.toString=function(){const u=this.length;return u===0?"":arguments.length===0?He(this,0,u):Ee.apply(this,arguments)},S.prototype.toLocaleString=S.prototype.toString,S.prototype.equals=function(u){if(!S.isBuffer(u))throw new TypeError("Argument must be a Buffer");return this===u?!0:S.compare(this,u)===0},S.prototype.inspect=function(){let u="";const h=x.INSPECT_MAX_BYTES;return u=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(u+=" ... "),"<Buffer "+u+">"},m&&(S.prototype[m]=S.prototype.inspect),S.prototype.compare=function(u,h,T,O,v){if(at(u,Uint8Array)&&(u=S.from(u,u.offset,u.byteLength)),!S.isBuffer(u))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof u);if(h===void 0&&(h=0),T===void 0&&(T=u?u.length:0),O===void 0&&(O=0),v===void 0&&(v=this.length),h<0||T>u.length||O<0||v>this.length)throw new RangeError("out of range index");if(O>=v&&h>=T)return 0;if(O>=v)return-1;if(h>=T)return 1;if(h>>>=0,T>>>=0,O>>>=0,v>>>=0,this===u)return 0;let U=v-O,G=T-h;const ce=Math.min(U,G),te=this.slice(O,v),oe=u.slice(h,T);for(let Ce=0;Ce<ce;++Ce)if(te[Ce]!==oe[Ce]){U=te[Ce],G=oe[Ce];break}return U<G?-1:G<U?1:0};function me(C,u,h,T,O){if(C.length===0)return-1;if(typeof h=="string"?(T=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,pn(h)&&(h=O?0:C.length-1),h<0&&(h=C.length+h),h>=C.length){if(O)return-1;h=C.length-1}else if(h<0)if(O)h=0;else return-1;if(typeof u=="string"&&(u=S.from(u,T)),S.isBuffer(u))return u.length===0?-1:Z(C,u,h,T,O);if(typeof u=="number")return u=u&255,typeof Uint8Array.prototype.indexOf=="function"?O?Uint8Array.prototype.indexOf.call(C,u,h):Uint8Array.prototype.lastIndexOf.call(C,u,h):Z(C,[u],h,T,O);throw new TypeError("val must be string, number or Buffer")}function Z(C,u,h,T,O){let v=1,U=C.length,G=u.length;if(T!==void 0&&(T=String(T).toLowerCase(),T==="ucs2"||T==="ucs-2"||T==="utf16le"||T==="utf-16le")){if(C.length<2||u.length<2)return-1;v=2,U/=2,G/=2,h/=2}function ce(oe,Ce){return v===1?oe[Ce]:oe.readUInt16BE(Ce*v)}let te;if(O){let oe=-1;for(te=h;te<U;te++)if(ce(C,te)===ce(u,oe===-1?0:te-oe)){if(oe===-1&&(oe=te),te-oe+1===G)return oe*v}else oe!==-1&&(te-=te-oe),oe=-1}else for(h+G>U&&(h=U-G),te=h;te>=0;te--){let oe=!0;for(let Ce=0;Ce<G;Ce++)if(ce(C,te+Ce)!==ce(u,Ce)){oe=!1;break}if(oe)return te}return-1}S.prototype.includes=function(u,h,T){return this.indexOf(u,h,T)!==-1},S.prototype.indexOf=function(u,h,T){return me(this,u,h,T,!0)},S.prototype.lastIndexOf=function(u,h,T){return me(this,u,h,T,!1)};function Ie(C,u,h,T){h=Number(h)||0;const O=C.length-h;T?(T=Number(T),T>O&&(T=O)):T=O;const v=u.length;T>v/2&&(T=v/2);let U;for(U=0;U<T;++U){const G=parseInt(u.substr(U*2,2),16);if(pn(G))return U;C[h+U]=G}return U}function z(C,u,h,T){return q(Ye(u,C.length-h),C,h,T)}function zt(C,u,h,T){return q(Re(u),C,h,T)}function rt(C,u,h,T){return q(sn(u),C,h,T)}function se(C,u,h,T){return q(we(u,C.length-h),C,h,T)}S.prototype.write=function(u,h,T,O){if(h===void 0)O="utf8",T=this.length,h=0;else if(T===void 0&&typeof h=="string")O=h,T=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(T)?(T=T>>>0,O===void 0&&(O="utf8")):(O=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const v=this.length-h;if((T===void 0||T>v)&&(T=v),u.length>0&&(T<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");O||(O="utf8");let U=!1;for(;;)switch(O){case"hex":return Ie(this,u,h,T);case"utf8":case"utf-8":return z(this,u,h,T);case"ascii":case"latin1":case"binary":return zt(this,u,h,T);case"base64":return rt(this,u,h,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return se(this,u,h,T);default:if(U)throw new TypeError("Unknown encoding: "+O);O=(""+O).toLowerCase(),U=!0}},S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Te(C,u,h){return u===0&&h===C.length?f.fromByteArray(C):f.fromByteArray(C.slice(u,h))}function He(C,u,h){h=Math.min(C.length,h);const T=[];let O=u;for(;O<h;){const v=C[O];let U=null,G=v>239?4:v>223?3:v>191?2:1;if(O+G<=h){let ce,te,oe,Ce;switch(G){case 1:v<128&&(U=v);break;case 2:ce=C[O+1],(ce&192)===128&&(Ce=(v&31)<<6|ce&63,Ce>127&&(U=Ce));break;case 3:ce=C[O+1],te=C[O+2],(ce&192)===128&&(te&192)===128&&(Ce=(v&15)<<12|(ce&63)<<6|te&63,Ce>2047&&(Ce<55296||Ce>57343)&&(U=Ce));break;case 4:ce=C[O+1],te=C[O+2],oe=C[O+3],(ce&192)===128&&(te&192)===128&&(oe&192)===128&&(Ce=(v&15)<<18|(ce&63)<<12|(te&63)<<6|oe&63,Ce>65535&&Ce<1114112&&(U=Ce))}}U===null?(U=65533,G=1):U>65535&&(U-=65536,T.push(U>>>10&1023|55296),U=56320|U&1023),T.push(U),O+=G}return Ze(T)}const V=4096;function Ze(C){const u=C.length;if(u<=V)return String.fromCharCode.apply(String,C);let h="",T=0;for(;T<u;)h+=String.fromCharCode.apply(String,C.slice(T,T+=V));return h}function le(C,u,h){let T="";h=Math.min(C.length,h);for(let O=u;O<h;++O)T+=String.fromCharCode(C[O]&127);return T}function tn(C,u,h){let T="";h=Math.min(C.length,h);for(let O=u;O<h;++O)T+=String.fromCharCode(C[O]);return T}function vt(C,u,h){const T=C.length;(!u||u<0)&&(u=0),(!h||h<0||h>T)&&(h=T);let O="";for(let v=u;v<h;++v)O+=Rt[C[v]];return O}function Ft(C,u,h){const T=C.slice(u,h);let O="";for(let v=0;v<T.length-1;v+=2)O+=String.fromCharCode(T[v]+T[v+1]*256);return O}S.prototype.slice=function(u,h){const T=this.length;u=~~u,h=h===void 0?T:~~h,u<0?(u+=T,u<0&&(u=0)):u>T&&(u=T),h<0?(h+=T,h<0&&(h=0)):h>T&&(h=T),h<u&&(h=u);const O=this.subarray(u,h);return Object.setPrototypeOf(O,S.prototype),O};function Xe(C,u,h){if(C%1!==0||C<0)throw new RangeError("offset is not uint");if(C+u>h)throw new RangeError("Trying to access beyond buffer length")}S.prototype.readUintLE=S.prototype.readUIntLE=function(u,h,T){u=u>>>0,h=h>>>0,T||Xe(u,h,this.length);let O=this[u],v=1,U=0;for(;++U<h&&(v*=256);)O+=this[u+U]*v;return O},S.prototype.readUintBE=S.prototype.readUIntBE=function(u,h,T){u=u>>>0,h=h>>>0,T||Xe(u,h,this.length);let O=this[u+--h],v=1;for(;h>0&&(v*=256);)O+=this[u+--h]*v;return O},S.prototype.readUint8=S.prototype.readUInt8=function(u,h){return u=u>>>0,h||Xe(u,1,this.length),this[u]},S.prototype.readUint16LE=S.prototype.readUInt16LE=function(u,h){return u=u>>>0,h||Xe(u,2,this.length),this[u]|this[u+1]<<8},S.prototype.readUint16BE=S.prototype.readUInt16BE=function(u,h){return u=u>>>0,h||Xe(u,2,this.length),this[u]<<8|this[u+1]},S.prototype.readUint32LE=S.prototype.readUInt32LE=function(u,h){return u=u>>>0,h||Xe(u,4,this.length),(this[u]|this[u+1]<<8|this[u+2]<<16)+this[u+3]*16777216},S.prototype.readUint32BE=S.prototype.readUInt32BE=function(u,h){return u=u>>>0,h||Xe(u,4,this.length),this[u]*16777216+(this[u+1]<<16|this[u+2]<<8|this[u+3])},S.prototype.readBigUInt64LE=bt(function(u){u=u>>>0,xe(u,"offset");const h=this[u],T=this[u+7];(h===void 0||T===void 0)&&It(u,this.length-8);const O=h+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24,v=this[++u]+this[++u]*2**8+this[++u]*2**16+T*2**24;return BigInt(O)+(BigInt(v)<<BigInt(32))}),S.prototype.readBigUInt64BE=bt(function(u){u=u>>>0,xe(u,"offset");const h=this[u],T=this[u+7];(h===void 0||T===void 0)&&It(u,this.length-8);const O=h*2**24+this[++u]*2**16+this[++u]*2**8+this[++u],v=this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+T;return(BigInt(O)<<BigInt(32))+BigInt(v)}),S.prototype.readIntLE=function(u,h,T){u=u>>>0,h=h>>>0,T||Xe(u,h,this.length);let O=this[u],v=1,U=0;for(;++U<h&&(v*=256);)O+=this[u+U]*v;return v*=128,O>=v&&(O-=Math.pow(2,8*h)),O},S.prototype.readIntBE=function(u,h,T){u=u>>>0,h=h>>>0,T||Xe(u,h,this.length);let O=h,v=1,U=this[u+--O];for(;O>0&&(v*=256);)U+=this[u+--O]*v;return v*=128,U>=v&&(U-=Math.pow(2,8*h)),U},S.prototype.readInt8=function(u,h){return u=u>>>0,h||Xe(u,1,this.length),this[u]&128?(255-this[u]+1)*-1:this[u]},S.prototype.readInt16LE=function(u,h){u=u>>>0,h||Xe(u,2,this.length);const T=this[u]|this[u+1]<<8;return T&32768?T|4294901760:T},S.prototype.readInt16BE=function(u,h){u=u>>>0,h||Xe(u,2,this.length);const T=this[u+1]|this[u]<<8;return T&32768?T|4294901760:T},S.prototype.readInt32LE=function(u,h){return u=u>>>0,h||Xe(u,4,this.length),this[u]|this[u+1]<<8|this[u+2]<<16|this[u+3]<<24},S.prototype.readInt32BE=function(u,h){return u=u>>>0,h||Xe(u,4,this.length),this[u]<<24|this[u+1]<<16|this[u+2]<<8|this[u+3]},S.prototype.readBigInt64LE=bt(function(u){u=u>>>0,xe(u,"offset");const h=this[u],T=this[u+7];(h===void 0||T===void 0)&&It(u,this.length-8);const O=this[u+4]+this[u+5]*2**8+this[u+6]*2**16+(T<<24);return(BigInt(O)<<BigInt(32))+BigInt(h+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24)}),S.prototype.readBigInt64BE=bt(function(u){u=u>>>0,xe(u,"offset");const h=this[u],T=this[u+7];(h===void 0||T===void 0)&&It(u,this.length-8);const O=(h<<24)+this[++u]*2**16+this[++u]*2**8+this[++u];return(BigInt(O)<<BigInt(32))+BigInt(this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+T)}),S.prototype.readFloatLE=function(u,h){return u=u>>>0,h||Xe(u,4,this.length),c.read(this,u,!0,23,4)},S.prototype.readFloatBE=function(u,h){return u=u>>>0,h||Xe(u,4,this.length),c.read(this,u,!1,23,4)},S.prototype.readDoubleLE=function(u,h){return u=u>>>0,h||Xe(u,8,this.length),c.read(this,u,!0,52,8)},S.prototype.readDoubleBE=function(u,h){return u=u>>>0,h||Xe(u,8,this.length),c.read(this,u,!1,52,8)};function Se(C,u,h,T,O,v){if(!S.isBuffer(C))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>O||u<v)throw new RangeError('"value" argument is out of bounds');if(h+T>C.length)throw new RangeError("Index out of range")}S.prototype.writeUintLE=S.prototype.writeUIntLE=function(u,h,T,O){if(u=+u,h=h>>>0,T=T>>>0,!O){const G=Math.pow(2,8*T)-1;Se(this,u,h,T,G,0)}let v=1,U=0;for(this[h]=u&255;++U<T&&(v*=256);)this[h+U]=u/v&255;return h+T},S.prototype.writeUintBE=S.prototype.writeUIntBE=function(u,h,T,O){if(u=+u,h=h>>>0,T=T>>>0,!O){const G=Math.pow(2,8*T)-1;Se(this,u,h,T,G,0)}let v=T-1,U=1;for(this[h+v]=u&255;--v>=0&&(U*=256);)this[h+v]=u/U&255;return h+T},S.prototype.writeUint8=S.prototype.writeUInt8=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,1,255,0),this[h]=u&255,h+1},S.prototype.writeUint16LE=S.prototype.writeUInt16LE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,2,65535,0),this[h]=u&255,this[h+1]=u>>>8,h+2},S.prototype.writeUint16BE=S.prototype.writeUInt16BE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,2,65535,0),this[h]=u>>>8,this[h+1]=u&255,h+2},S.prototype.writeUint32LE=S.prototype.writeUInt32LE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,4,4294967295,0),this[h+3]=u>>>24,this[h+2]=u>>>16,this[h+1]=u>>>8,this[h]=u&255,h+4},S.prototype.writeUint32BE=S.prototype.writeUInt32BE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,4,4294967295,0),this[h]=u>>>24,this[h+1]=u>>>16,this[h+2]=u>>>8,this[h+3]=u&255,h+4};function Lt(C,u,h,T,O){nn(u,T,O,C,h,7);let v=Number(u&BigInt(4294967295));C[h++]=v,v=v>>8,C[h++]=v,v=v>>8,C[h++]=v,v=v>>8,C[h++]=v;let U=Number(u>>BigInt(32)&BigInt(4294967295));return C[h++]=U,U=U>>8,C[h++]=U,U=U>>8,C[h++]=U,U=U>>8,C[h++]=U,h}function qe(C,u,h,T,O){nn(u,T,O,C,h,7);let v=Number(u&BigInt(4294967295));C[h+7]=v,v=v>>8,C[h+6]=v,v=v>>8,C[h+5]=v,v=v>>8,C[h+4]=v;let U=Number(u>>BigInt(32)&BigInt(4294967295));return C[h+3]=U,U=U>>8,C[h+2]=U,U=U>>8,C[h+1]=U,U=U>>8,C[h]=U,h+8}S.prototype.writeBigUInt64LE=bt(function(u,h=0){return Lt(this,u,h,BigInt(0),BigInt("0xffffffffffffffff"))}),S.prototype.writeBigUInt64BE=bt(function(u,h=0){return qe(this,u,h,BigInt(0),BigInt("0xffffffffffffffff"))}),S.prototype.writeIntLE=function(u,h,T,O){if(u=+u,h=h>>>0,!O){const ce=Math.pow(2,8*T-1);Se(this,u,h,T,ce-1,-ce)}let v=0,U=1,G=0;for(this[h]=u&255;++v<T&&(U*=256);)u<0&&G===0&&this[h+v-1]!==0&&(G=1),this[h+v]=(u/U>>0)-G&255;return h+T},S.prototype.writeIntBE=function(u,h,T,O){if(u=+u,h=h>>>0,!O){const ce=Math.pow(2,8*T-1);Se(this,u,h,T,ce-1,-ce)}let v=T-1,U=1,G=0;for(this[h+v]=u&255;--v>=0&&(U*=256);)u<0&&G===0&&this[h+v+1]!==0&&(G=1),this[h+v]=(u/U>>0)-G&255;return h+T},S.prototype.writeInt8=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,1,127,-128),u<0&&(u=255+u+1),this[h]=u&255,h+1},S.prototype.writeInt16LE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,2,32767,-32768),this[h]=u&255,this[h+1]=u>>>8,h+2},S.prototype.writeInt16BE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,2,32767,-32768),this[h]=u>>>8,this[h+1]=u&255,h+2},S.prototype.writeInt32LE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,4,2147483647,-2147483648),this[h]=u&255,this[h+1]=u>>>8,this[h+2]=u>>>16,this[h+3]=u>>>24,h+4},S.prototype.writeInt32BE=function(u,h,T){return u=+u,h=h>>>0,T||Se(this,u,h,4,2147483647,-2147483648),u<0&&(u=4294967295+u+1),this[h]=u>>>24,this[h+1]=u>>>16,this[h+2]=u>>>8,this[h+3]=u&255,h+4},S.prototype.writeBigInt64LE=bt(function(u,h=0){return Lt(this,u,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),S.prototype.writeBigInt64BE=bt(function(u,h=0){return qe(this,u,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function En(C,u,h,T,O,v){if(h+T>C.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function $(C,u,h,T,O){return u=+u,h=h>>>0,O||En(C,u,h,4),c.write(C,u,h,T,23,4),h+4}S.prototype.writeFloatLE=function(u,h,T){return $(this,u,h,!0,T)},S.prototype.writeFloatBE=function(u,h,T){return $(this,u,h,!1,T)};function Cn(C,u,h,T,O){return u=+u,h=h>>>0,O||En(C,u,h,8),c.write(C,u,h,T,52,8),h+8}S.prototype.writeDoubleLE=function(u,h,T){return Cn(this,u,h,!0,T)},S.prototype.writeDoubleBE=function(u,h,T){return Cn(this,u,h,!1,T)},S.prototype.copy=function(u,h,T,O){if(!S.isBuffer(u))throw new TypeError("argument should be a Buffer");if(T||(T=0),!O&&O!==0&&(O=this.length),h>=u.length&&(h=u.length),h||(h=0),O>0&&O<T&&(O=T),O===T||u.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("sourceEnd out of bounds");O>this.length&&(O=this.length),u.length-h<O-T&&(O=u.length-h+T);const v=O-T;return this===u&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,T,O):Uint8Array.prototype.set.call(u,this.subarray(T,O),h),v},S.prototype.fill=function(u,h,T,O){if(typeof u=="string"){if(typeof h=="string"?(O=h,h=0,T=this.length):typeof T=="string"&&(O=T,T=this.length),O!==void 0&&typeof O!="string")throw new TypeError("encoding must be a string");if(typeof O=="string"&&!S.isEncoding(O))throw new TypeError("Unknown encoding: "+O);if(u.length===1){const U=u.charCodeAt(0);(O==="utf8"&&U<128||O==="latin1")&&(u=U)}}else typeof u=="number"?u=u&255:typeof u=="boolean"&&(u=Number(u));if(h<0||this.length<h||this.length<T)throw new RangeError("Out of range index");if(T<=h)return this;h=h>>>0,T=T===void 0?this.length:T>>>0,u||(u=0);let v;if(typeof u=="number")for(v=h;v<T;++v)this[v]=u;else{const U=S.isBuffer(u)?u:S.from(u,O),G=U.length;if(G===0)throw new TypeError('The value "'+u+'" is invalid for argument "value"');for(v=0;v<T-h;++v)this[v+h]=U[v%G]}return this};const Fe={};function Xt(C,u,h){Fe[C]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${C}]`,this.stack,delete this.name}get code(){return C}set code(O){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:O,writable:!0})}toString(){return`${this.name} [${C}]: ${this.message}`}}}Xt("ERR_BUFFER_OUT_OF_BOUNDS",function(C){return C?`${C} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Xt("ERR_INVALID_ARG_TYPE",function(C,u){return`The "${C}" argument must be of type number. Received type ${typeof u}`},TypeError),Xt("ERR_OUT_OF_RANGE",function(C,u,h){let T=`The value of "${C}" is out of range.`,O=h;return Number.isInteger(h)&&Math.abs(h)>2**32?O=Zt(String(h)):typeof h=="bigint"&&(O=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(O=Zt(O)),O+="n"),T+=` It must be ${u}. Received ${O}`,T},RangeError);function Zt(C){let u="",h=C.length;const T=C[0]==="-"?1:0;for(;h>=T+4;h-=3)u=`_${C.slice(h-3,h)}${u}`;return`${C.slice(0,h)}${u}`}function it(C,u,h){xe(u,"offset"),(C[u]===void 0||C[u+h]===void 0)&&It(u,C.length-(h+1))}function nn(C,u,h,T,O,v){if(C>h||C<u){const U=typeof u=="bigint"?"n":"";let G;throw u===0||u===BigInt(0)?G=`>= 0${U} and < 2${U} ** ${(v+1)*8}${U}`:G=`>= -(2${U} ** ${(v+1)*8-1}${U}) and < 2 ** ${(v+1)*8-1}${U}`,new Fe.ERR_OUT_OF_RANGE("value",G,C)}it(T,O,v)}function xe(C,u){if(typeof C!="number")throw new Fe.ERR_INVALID_ARG_TYPE(u,"number",C)}function It(C,u,h){throw Math.floor(C)!==C?(xe(C,h),new Fe.ERR_OUT_OF_RANGE("offset","an integer",C)):u<0?new Fe.ERR_BUFFER_OUT_OF_BOUNDS:new Fe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${u}`,C)}const yt=/[^+/0-9A-Za-z-_]/g;function rn(C){if(C=C.split("=")[0],C=C.trim().replace(yt,""),C.length<2)return"";for(;C.length%4!==0;)C=C+"=";return C}function Ye(C,u){u=u||1/0;let h;const T=C.length;let O=null;const v=[];for(let U=0;U<T;++U){if(h=C.charCodeAt(U),h>55295&&h<57344){if(!O){if(h>56319){(u-=3)>-1&&v.push(239,191,189);continue}else if(U+1===T){(u-=3)>-1&&v.push(239,191,189);continue}O=h;continue}if(h<56320){(u-=3)>-1&&v.push(239,191,189),O=h;continue}h=(O-55296<<10|h-56320)+65536}else O&&(u-=3)>-1&&v.push(239,191,189);if(O=null,h<128){if((u-=1)<0)break;v.push(h)}else if(h<2048){if((u-=2)<0)break;v.push(h>>6|192,h&63|128)}else if(h<65536){if((u-=3)<0)break;v.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((u-=4)<0)break;v.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return v}function Re(C){const u=[];for(let h=0;h<C.length;++h)u.push(C.charCodeAt(h)&255);return u}function we(C,u){let h,T,O;const v=[];for(let U=0;U<C.length&&!((u-=2)<0);++U)h=C.charCodeAt(U),T=h>>8,O=h%256,v.push(O),v.push(T);return v}function sn(C){return f.toByteArray(rn(C))}function q(C,u,h,T){let O;for(O=0;O<T&&!(O+h>=u.length||O>=C.length);++O)u[O+h]=C[O];return O}function at(C,u){return C instanceof u||C!=null&&C.constructor!=null&&C.constructor.name!=null&&C.constructor.name===u.name}function pn(C){return C!==C}const Rt=function(){const C="0123456789abcdef",u=new Array(256);for(let h=0;h<16;++h){const T=h*16;for(let O=0;O<16;++O)u[T+O]=C[h]+C[O]}return u}();function bt(C){return typeof BigInt>"u"?wt:C}function wt(){throw new Error("BigInt not supported")}})(fr);const fs=x=>{const f=fr.Buffer.from(x,"base64").toString("utf8"),c=fr.Buffer.from(f,"binary").toString("base64");return x===c?f:x},ds=async x=>{const f=fs(x);try{const c=JSON.parse(f);return{message:f,...c,format:"JSON"}}catch{return{message:f,raw:x,format:"RAW_TEXT"}}};var j;(function(x){x[x.QR_CODE=0]="QR_CODE",x[x.AZTEC=1]="AZTEC",x[x.CODABAR=2]="CODABAR",x[x.CODE_39=3]="CODE_39",x[x.CODE_93=4]="CODE_93",x[x.CODE_128=5]="CODE_128",x[x.DATA_MATRIX=6]="DATA_MATRIX",x[x.MAXICODE=7]="MAXICODE",x[x.ITF=8]="ITF",x[x.EAN_13=9]="EAN_13",x[x.EAN_8=10]="EAN_8",x[x.PDF_417=11]="PDF_417",x[x.RSS_14=12]="RSS_14",x[x.RSS_EXPANDED=13]="RSS_EXPANDED",x[x.UPC_A=14]="UPC_A",x[x.UPC_E=15]="UPC_E",x[x.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(j||(j={}));var ei=new Map([[j.QR_CODE,"QR_CODE"],[j.AZTEC,"AZTEC"],[j.CODABAR,"CODABAR"],[j.CODE_39,"CODE_39"],[j.CODE_93,"CODE_93"],[j.CODE_128,"CODE_128"],[j.DATA_MATRIX,"DATA_MATRIX"],[j.MAXICODE,"MAXICODE"],[j.ITF,"ITF"],[j.EAN_13,"EAN_13"],[j.EAN_8,"EAN_8"],[j.PDF_417,"PDF_417"],[j.RSS_14,"RSS_14"],[j.RSS_EXPANDED,"RSS_EXPANDED"],[j.UPC_A,"UPC_A"],[j.UPC_E,"UPC_E"],[j.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),ti;(function(x){x[x.UNKNOWN=0]="UNKNOWN",x[x.URL=1]="URL"})(ti||(ti={}));function xs(x){return Object.values(j).includes(x)}var Zn;(function(x){x[x.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",x[x.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Zn||(Zn={}));var gs=function(){function x(){}return x.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",x.SCAN_DEFAULT_FPS=2,x.DEFAULT_DISABLE_FLIP=!1,x.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,x.DEFAULT_SUPPORTED_SCAN_TYPE=[Zn.SCAN_TYPE_CAMERA,Zn.SCAN_TYPE_FILE],x}(),ni=function(){function x(f,c){this.format=f,this.formatName=c}return x.prototype.toString=function(){return this.formatName},x.create=function(f){if(!ei.has(f))throw"".concat(f," not in html5QrcodeSupportedFormatsTextMap");return new x(f,ei.get(f))},x}(),ri=function(){function x(){}return x.createFromText=function(f){var c={text:f};return{decodedText:f,result:c}},x.createFromQrcodeResult=function(f){return{decodedText:f.text,result:f}},x}(),gr;(function(x){x[x.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",x[x.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",x[x.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(gr||(gr={}));var ws=function(){function x(){}return x.createFrom=function(f){return{errorMessage:f,type:gr.UNKWOWN_ERROR}},x}(),As=function(){function x(f){this.verbose=f}return x.prototype.log=function(f){this.verbose&&console.log(f)},x.prototype.warn=function(f){this.verbose&&console.warn(f)},x.prototype.logError=function(f,c){(this.verbose||c===!0)&&console.error(f)},x.prototype.logErrors=function(f){if(f.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(f)},x}();function Ht(x){return typeof x>"u"||x===null}var An=function(){function x(){}return x.codeParseError=function(f){return"QR code parse error, error = ".concat(f)},x.errorGettingUserMedia=function(f){return"Error getting userMedia, error = ".concat(f)},x.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},x.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},x.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},x.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},x.scannerPaused=function(){return"Scanner paused"},x}(),ii=function(){function x(){}return x.isMediaStreamConstraintsValid=function(f,c){if(typeof f!="object"){var m=typeof f;return c.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(m,"."),!0),!1}for(var I=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],g=new Set(I),_=Object.keys(f),S=0,P=_;S<P.length;S++){var p=P[S];if(g.has(p))return c.logError("".concat(p," is not supported videoConstaints."),!0),!1}return!0},x}(),wr={exports:{}};(function(x,f){(function(c,m){m(f)})(vn,function(c){function m(w){return w==null}var I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,e){w.__proto__=e}||function(w,e){for(var t in e)e.hasOwnProperty(t)&&(w[t]=e[t])};function g(w,e){I(w,e);function t(){this.constructor=w}w.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function _(w,e){var t=Object.setPrototypeOf;t?t(w,e):w.__proto__=e}function S(w,e){e===void 0&&(e=w.constructor);var t=Error.captureStackTrace;t&&t(w,e)}var P=function(w){g(e,w);function e(t){var n=this.constructor,r=w.call(this,t)||this;return Object.defineProperty(r,"name",{value:n.name,enumerable:!1}),_(r,n.prototype),S(r),r}return e}(Error);class p extends P{constructor(e=void 0){super(e),this.message=e}getKind(){return this.constructor.kind}}p.kind="Exception";class k extends p{}k.kind="ArgumentException";class M extends p{}M.kind="IllegalArgumentException";class ae{constructor(e){if(this.binarizer=e,e===null)throw new M("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,t){return this.binarizer.getBlackRow(e,t)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,t,n,r){const i=this.binarizer.getLuminanceSource().crop(e,t,n,r);return new ae(this.binarizer.createBinarizer(i))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new ae(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new ae(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class Q extends p{static getChecksumInstance(){return new Q}}Q.kind="ChecksumException";class Pe{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class he{static arraycopy(e,t,n,r,i){for(;i--;)n[r++]=e[t++]}static currentTimeMillis(){return Date.now()}}class pt extends p{}pt.kind="IndexOutOfBoundsException";class mt extends pt{constructor(e=void 0,t=void 0){super(t),this.index=e,this.message=t}}mt.kind="ArrayIndexOutOfBoundsException";class Ne{static fill(e,t){for(let n=0,r=e.length;n<r;n++)e[n]=t}static fillWithin(e,t,n,r){Ne.rangeCheck(e.length,t,n);for(let i=t;i<n;i++)e[i]=r}static rangeCheck(e,t,n){if(t>n)throw new M("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new mt(t);if(n>e)throw new mt(n)}static asList(...e){return e}static create(e,t,n){return Array.from({length:e}).map(i=>Array.from({length:t}).fill(n))}static createInt32Array(e,t,n){return Array.from({length:e}).map(i=>Int32Array.from({length:t}).fill(n))}static equals(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}static hashCode(e){if(e===null)return 0;let t=1;for(const n of e)t=31*t+n;return t}static fillUint8Array(e,t){for(let n=0;n!==e.length;n++)e[n]=t}static copyOf(e,t){return e.slice(0,t)}static copyOfUint8Array(e,t){if(e.length<=t){const n=new Uint8Array(t);return n.set(e),n}return e.slice(0,t)}static copyOfRange(e,t,n){const r=n-t,i=new Int32Array(r);return he.arraycopy(e,t,i,0,r),i}static binarySearch(e,t,n){n===void 0&&(n=Ne.numberComparator);let r=0,i=e.length-1;for(;r<=i;){const s=i+r>>1,o=n(t,e[s]);if(o>0)r=s+1;else if(o<0)i=s-1;else return s}return-r-1}static numberComparator(e,t){return e-t}}class ne{static numberOfTrailingZeros(e){let t;if(e===0)return 32;let n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)}static numberOfLeadingZeros(e){if(e===0)return 32;let t=1;return e>>>16||(t+=16,e<<=16),e>>>24||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t}static toHexString(e){return e.toString(16)}static toBinaryString(e){return String(parseInt(String(e),2))}static bitCount(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63}static truncDivision(e,t){return Math.trunc(e/t)}static parseInt(e,t=void 0){return parseInt(e,t)}}ne.MIN_VALUE_32_BITS=-2147483648,ne.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Ee{constructor(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=Ee.makeArray(e):this.bits=t)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(e){if(e>this.bits.length*32){const t=Ee.makeArray(e);he.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}}get(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0}set(e){this.bits[Math.floor(e/32)]|=1<<(e&31)}flip(e){this.bits[Math.floor(e/32)]^=1<<(e&31)}getNextSet(e){const t=this.size;if(e>=t)return t;const n=this.bits;let r=Math.floor(e/32),i=n[r];i&=~((1<<(e&31))-1);const s=n.length;for(;i===0;){if(++r===s)return t;i=n[r]}const o=r*32+ne.numberOfTrailingZeros(i);return o>t?t:o}getNextUnset(e){const t=this.size;if(e>=t)return t;const n=this.bits;let r=Math.floor(e/32),i=~n[r];i&=~((1<<(e&31))-1);const s=n.length;for(;i===0;){if(++r===s)return t;i=~n[r]}const o=r*32+ne.numberOfTrailingZeros(i);return o>t?t:o}setBulk(e,t){this.bits[Math.floor(e/32)]=t}setRange(e,t){if(t<e||e<0||t>this.size)throw new M;if(t===e)return;t--;const n=Math.floor(e/32),r=Math.floor(t/32),i=this.bits;for(let s=n;s<=r;s++){const o=s>n?0:e&31,l=(2<<(s<r?31:t&31))-(1<<o);i[s]|=l}}clear(){const e=this.bits.length,t=this.bits;for(let n=0;n<e;n++)t[n]=0}isRange(e,t,n){if(t<e||e<0||t>this.size)throw new M;if(t===e)return!0;t--;const r=Math.floor(e/32),i=Math.floor(t/32),s=this.bits;for(let o=r;o<=i;o++){const a=o>r?0:e&31,d=(2<<(o<i?31:t&31))-(1<<a)&4294967295;if((s[o]&d)!==(n?d:0))return!1}return!0}appendBit(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(e,t){if(t<0||t>32)throw new M("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(let n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)}appendBitArray(e){const t=e.size;this.ensureCapacity(this.size+t);for(let n=0;n<t;n++)this.appendBit(e.get(n))}xor(e){if(this.size!==e.size)throw new M("Sizes don't match");const t=this.bits;for(let n=0,r=t.length;n<r;n++)t[n]^=e.bits[n]}toBytes(e,t,n,r){for(let i=0;i<r;i++){let s=0;for(let o=0;o<8;o++)this.get(e)&&(s|=1<<7-o),e++;t[n+i]=s}}getBitArray(){return this.bits}reverse(){const e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),n=t+1,r=this.bits;for(let i=0;i<n;i++){let s=r[i];s=s>>1&1431655765|(s&1431655765)<<1,s=s>>2&858993459|(s&858993459)<<2,s=s>>4&252645135|(s&252645135)<<4,s=s>>8&16711935|(s&16711935)<<8,s=s>>16&65535|(s&65535)<<16,e[t-i]=s}if(this.size!==n*32){const i=n*32-this.size;let s=e[0]>>>i;for(let o=1;o<n;o++){const a=e[o];s|=a<<32-i,e[o-1]=s,s=a>>>i}e[n-1]=s}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof Ee))return!1;const t=e;return this.size===t.size&&Ne.equals(this.bits,t.bits)}hashCode(){return 31*this.size+Ne.hashCode(this.bits)}toString(){let e="";for(let t=0,n=this.size;t<n;t++)t&7||(e+=" "),e+=this.get(t)?"X":".";return e}clone(){return new Ee(this.size,this.bits.slice())}}var nt;(function(w){w[w.OTHER=0]="OTHER",w[w.PURE_BARCODE=1]="PURE_BARCODE",w[w.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",w[w.TRY_HARDER=3]="TRY_HARDER",w[w.CHARACTER_SET=4]="CHARACTER_SET",w[w.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",w[w.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",w[w.ASSUME_GS1=7]="ASSUME_GS1",w[w.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",w[w.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",w[w.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(nt||(nt={}));var me=nt;class Z extends p{static getFormatInstance(){return new Z}}Z.kind="FormatException";var Ie;(function(w){w[w.Cp437=0]="Cp437",w[w.ISO8859_1=1]="ISO8859_1",w[w.ISO8859_2=2]="ISO8859_2",w[w.ISO8859_3=3]="ISO8859_3",w[w.ISO8859_4=4]="ISO8859_4",w[w.ISO8859_5=5]="ISO8859_5",w[w.ISO8859_6=6]="ISO8859_6",w[w.ISO8859_7=7]="ISO8859_7",w[w.ISO8859_8=8]="ISO8859_8",w[w.ISO8859_9=9]="ISO8859_9",w[w.ISO8859_10=10]="ISO8859_10",w[w.ISO8859_11=11]="ISO8859_11",w[w.ISO8859_13=12]="ISO8859_13",w[w.ISO8859_14=13]="ISO8859_14",w[w.ISO8859_15=14]="ISO8859_15",w[w.ISO8859_16=15]="ISO8859_16",w[w.SJIS=16]="SJIS",w[w.Cp1250=17]="Cp1250",w[w.Cp1251=18]="Cp1251",w[w.Cp1252=19]="Cp1252",w[w.Cp1256=20]="Cp1256",w[w.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",w[w.UTF8=22]="UTF8",w[w.ASCII=23]="ASCII",w[w.Big5=24]="Big5",w[w.GB18030=25]="GB18030",w[w.EUC_KR=26]="EUC_KR"})(Ie||(Ie={}));class z{constructor(e,t,n,...r){this.valueIdentifier=e,this.name=n,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=r,z.VALUE_IDENTIFIER_TO_ECI.set(e,this),z.NAME_TO_ECI.set(n,this);const i=this.values;for(let s=0,o=i.length;s!==o;s++){const a=i[s];z.VALUES_TO_ECI.set(a,this)}for(const s of r)z.NAME_TO_ECI.set(s,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(e){if(e<0||e>=900)throw new Z("incorect value");const t=z.VALUES_TO_ECI.get(e);if(t===void 0)throw new Z("incorect value");return t}static getCharacterSetECIByName(e){const t=z.NAME_TO_ECI.get(e);if(t===void 0)throw new Z("incorect value");return t}equals(e){if(!(e instanceof z))return!1;const t=e;return this.getName()===t.getName()}}z.VALUE_IDENTIFIER_TO_ECI=new Map,z.VALUES_TO_ECI=new Map,z.NAME_TO_ECI=new Map,z.Cp437=new z(Ie.Cp437,Int32Array.from([0,2]),"Cp437"),z.ISO8859_1=new z(Ie.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),z.ISO8859_2=new z(Ie.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),z.ISO8859_3=new z(Ie.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),z.ISO8859_4=new z(Ie.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),z.ISO8859_5=new z(Ie.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),z.ISO8859_6=new z(Ie.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),z.ISO8859_7=new z(Ie.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),z.ISO8859_8=new z(Ie.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),z.ISO8859_9=new z(Ie.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),z.ISO8859_10=new z(Ie.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),z.ISO8859_11=new z(Ie.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),z.ISO8859_13=new z(Ie.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),z.ISO8859_14=new z(Ie.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),z.ISO8859_15=new z(Ie.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),z.ISO8859_16=new z(Ie.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),z.SJIS=new z(Ie.SJIS,20,"SJIS","Shift_JIS"),z.Cp1250=new z(Ie.Cp1250,21,"Cp1250","windows-1250"),z.Cp1251=new z(Ie.Cp1251,22,"Cp1251","windows-1251"),z.Cp1252=new z(Ie.Cp1252,23,"Cp1252","windows-1252"),z.Cp1256=new z(Ie.Cp1256,24,"Cp1256","windows-1256"),z.UnicodeBigUnmarked=new z(Ie.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),z.UTF8=new z(Ie.UTF8,26,"UTF8","UTF-8"),z.ASCII=new z(Ie.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),z.Big5=new z(Ie.Big5,28,"Big5"),z.GB18030=new z(Ie.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),z.EUC_KR=new z(Ie.EUC_KR,30,"EUC_KR","EUC-KR");class zt extends p{}zt.kind="UnsupportedOperationException";class rt{static decode(e,t){const n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)}static shouldDecodeOnFallback(e){return!rt.isBrowser()&&e==="ISO-8859-1"}static encode(e,t){const n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(e){return typeof e=="string"?e:e.getName()}static encodingCharacterSet(e){return e instanceof z?e:z.getCharacterSetECIByName(e)}static decodeFallback(e,t){const n=this.encodingCharacterSet(t);if(rt.isDecodeFallbackSupported(n)){let r="";for(let i=0,s=e.length;i<s;i++){let o=e[i].toString(16);o.length<2&&(o="0"+o),r+="%"+o}return decodeURIComponent(r)}if(n.equals(z.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new zt(`Encoding ${this.encodingName(t)} not supported by fallback.`)}static isDecodeFallbackSupported(e){return e.equals(z.UTF8)||e.equals(z.ISO8859_1)||e.equals(z.ASCII)}static encodeFallback(e){const n=btoa(unescape(encodeURIComponent(e))).split(""),r=[];for(let i=0;i<n.length;i++)r.push(n[i].charCodeAt(0));return new Uint8Array(r)}}class se{static castAsNonUtf8Char(e,t=null){const n=t?t.getName():this.ISO88591;return rt.decode(new Uint8Array([e]),n)}static guessEncoding(e,t){if(t!=null&&t.get(me.CHARACTER_SET)!==void 0)return t.get(me.CHARACTER_SET).toString();const n=e.length;let r=!0,i=!0,s=!0,o=0,a=0,l=0,d=0,A=0,E=0,b=0,N=0,R=0,B=0,L=0;const X=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191;for(let Y=0;Y<n&&(r||i||s);Y++){const H=e[Y]&255;s&&(o>0?H&128?o--:s=!1:H&128&&(H&64?(o++,H&32?(o++,H&16?(o++,H&8?s=!1:d++):l++):a++):s=!1)),r&&(H>127&&H<160?r=!1:H>159&&(H<192||H===215||H===247)&&L++),i&&(A>0?H<64||H===127||H>252?i=!1:A--:H===128||H===160||H>239?i=!1:H>160&&H<224?(E++,N=0,b++,b>R&&(R=b)):H>127?(A++,b=0,N++,N>B&&(B=N)):(b=0,N=0))}return s&&o>0&&(s=!1),i&&A>0&&(i=!1),s&&(X||a+l+d>0)?se.UTF8:i&&(se.ASSUME_SHIFT_JIS||R>=3||B>=3)?se.SHIFT_JIS:r&&i?R===2&&E===2||L*10>=n?se.SHIFT_JIS:se.ISO88591:r?se.ISO88591:i?se.SHIFT_JIS:s?se.UTF8:se.PLATFORM_DEFAULT_ENCODING}static format(e,...t){let n=-1;function r(s,o,a,l,d,A){if(s==="%%")return"%";if(t[++n]===void 0)return;s=l?parseInt(l.substr(1)):void 0;let E=d?parseInt(d.substr(1)):void 0,b;switch(A){case"s":b=t[n];break;case"c":b=t[n][0];break;case"f":b=parseFloat(t[n]).toFixed(s);break;case"p":b=parseFloat(t[n]).toPrecision(s);break;case"e":b=parseFloat(t[n]).toExponential(s);break;case"x":b=parseInt(t[n]).toString(E||16);break;case"d":b=parseFloat(parseInt(t[n],E||10).toPrecision(s)).toFixed(0);break}b=typeof b=="object"?JSON.stringify(b):(+b).toString(E);let N=parseInt(a),R=a&&a[0]+""=="0"?"0":" ";for(;b.length<N;)b=o!==void 0?b+R:R+b;return b}let i=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(i,r)}static getBytes(e,t){return rt.encode(e,t)}static getCharCode(e,t=0){return e.charCodeAt(t)}static getCharAt(e){return String.fromCharCode(e)}}se.SHIFT_JIS=z.SJIS.getName(),se.GB2312="GB2312",se.ISO88591=z.ISO8859_1.getName(),se.EUC_JP="EUC_JP",se.UTF8=z.UTF8.getName(),se.PLATFORM_DEFAULT_ENCODING=se.UTF8,se.ASSUME_SHIFT_JIS=!1;class Te{constructor(e=""){this.value=e}enableDecoding(e){return this.encoding=e,this}append(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=se.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this}appendChars(e,t,n){for(let r=t;t<t+n;r++)this.append(e[r]);return this}length(){return this.value.length}charAt(e){return this.value.charAt(e)}deleteCharAt(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)}setCharAt(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)}substring(e,t){return this.value.substring(e,t)}setLengthToZero(){this.value=""}toString(){return this.value}insert(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+t.length)}}class He{constructor(e,t,n,r){if(this.width=e,this.height=t,this.rowSize=n,this.bits=r,t==null&&(t=e),this.height=t,e<1||t<1)throw new M("Both dimensions must be greater than 0");n==null&&(n=Math.floor((e+31)/32)),this.rowSize=n,r==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(e){const t=e.length,n=e[0].length,r=new He(n,t);for(let i=0;i<t;i++){const s=e[i];for(let o=0;o<n;o++)s[o]&&r.set(o,i)}return r}static parseFromString(e,t,n){if(e===null)throw new M("stringRepresentation cannot be null");const r=new Array(e.length);let i=0,s=0,o=-1,a=0,l=0;for(;l<e.length;)if(e.charAt(l)===`
|
|
7
|
+
`||e.charAt(l)==="\r"){if(i>s){if(o===-1)o=i-s;else if(i-s!==o)throw new M("row lengths do not match");s=i,a++}l++}else if(e.substring(l,l+t.length)===t)l+=t.length,r[i]=!0,i++;else if(e.substring(l,l+n.length)===n)l+=n.length,r[i]=!1,i++;else throw new M("illegal character encountered: "+e.substring(l));if(i>s){if(o===-1)o=i-s;else if(i-s!==o)throw new M("row lengths do not match");a++}const d=new He(o,a);for(let A=0;A<i;A++)r[A]&&d.set(Math.floor(A%o),Math.floor(A/o));return d}get(e,t){const n=t*this.rowSize+Math.floor(e/32);return(this.bits[n]>>>(e&31)&1)!==0}set(e,t){const n=t*this.rowSize+Math.floor(e/32);this.bits[n]|=1<<(e&31)&4294967295}unset(e,t){const n=t*this.rowSize+Math.floor(e/32);this.bits[n]&=~(1<<(e&31)&4294967295)}flip(e,t){const n=t*this.rowSize+Math.floor(e/32);this.bits[n]^=1<<(e&31)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new M("input matrix dimensions do not match");const t=new Ee(Math.floor(this.width/32)+1),n=this.rowSize,r=this.bits;for(let i=0,s=this.height;i<s;i++){const o=i*n,a=e.getRow(i,t).getBitArray();for(let l=0;l<n;l++)r[o+l]^=a[l]}}clear(){const e=this.bits,t=e.length;for(let n=0;n<t;n++)e[n]=0}setRegion(e,t,n,r){if(t<0||e<0)throw new M("Left and top must be nonnegative");if(r<1||n<1)throw new M("Height and width must be at least 1");const i=e+n,s=t+r;if(s>this.height||i>this.width)throw new M("The region must fit inside the matrix");const o=this.rowSize,a=this.bits;for(let l=t;l<s;l++){const d=l*o;for(let A=e;A<i;A++)a[d+Math.floor(A/32)]|=1<<(A&31)&4294967295}}getRow(e,t){t==null||t.getSize()<this.width?t=new Ee(this.width):t.clear();const n=this.rowSize,r=this.bits,i=e*n;for(let s=0;s<n;s++)t.setBulk(s*32,r[i+s]);return t}setRow(e,t){he.arraycopy(t.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)}rotate180(){const e=this.getWidth(),t=this.getHeight();let n=new Ee(e),r=new Ee(e);for(let i=0,s=Math.floor((t+1)/2);i<s;i++)n=this.getRow(i,n),r=this.getRow(t-1-i,r),n.reverse(),r.reverse(),this.setRow(i,r),this.setRow(t-1-i,n)}getEnclosingRectangle(){const e=this.width,t=this.height,n=this.rowSize,r=this.bits;let i=e,s=t,o=-1,a=-1;for(let l=0;l<t;l++)for(let d=0;d<n;d++){const A=r[l*n+d];if(A!==0){if(l<s&&(s=l),l>a&&(a=l),d*32<i){let E=0;for(;!(A<<31-E&4294967295);)E++;d*32+E<i&&(i=d*32+E)}if(d*32+31>o){let E=31;for(;!(A>>>E);)E--;d*32+E>o&&(o=d*32+E)}}}return o<i||a<s?null:Int32Array.from([i,s,o-i+1,a-s+1])}getTopLeftOnBit(){const e=this.rowSize,t=this.bits;let n=0;for(;n<t.length&&t[n]===0;)n++;if(n===t.length)return null;const r=n/e;let i=n%e*32;const s=t[n];let o=0;for(;!(s<<31-o&4294967295);)o++;return i+=o,Int32Array.from([i,r])}getBottomRightOnBit(){const e=this.rowSize,t=this.bits;let n=t.length-1;for(;n>=0&&t[n]===0;)n--;if(n<0)return null;const r=Math.floor(n/e);let i=Math.floor(n%e)*32;const s=t[n];let o=31;for(;!(s>>>o);)o--;return i+=o,Int32Array.from([i,r])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){if(!(e instanceof He))return!1;const t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&Ne.equals(this.bits,t.bits)}hashCode(){let e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+Ne.hashCode(this.bits),e}toString(e="X ",t=" ",n=`
|
|
8
|
+
`){return this.buildToString(e,t,n)}buildToString(e,t,n){let r=new Te;for(let i=0,s=this.height;i<s;i++){for(let o=0,a=this.width;o<a;o++)r.append(this.get(o,i)?e:t);r.append(n)}return r.toString()}clone(){return new He(this.width,this.height,this.rowSize,this.bits.slice())}}class V extends p{static getNotFoundInstance(){return new V}}V.kind="NotFoundException";class Ze extends Pe{constructor(e){super(e),this.luminances=Ze.EMPTY,this.buckets=new Int32Array(Ze.LUMINANCE_BUCKETS)}getBlackRow(e,t){const n=this.getLuminanceSource(),r=n.getWidth();t==null||t.getSize()<r?t=new Ee(r):t.clear(),this.initArrays(r);const i=n.getRow(e,this.luminances),s=this.buckets;for(let a=0;a<r;a++)s[(i[a]&255)>>Ze.LUMINANCE_SHIFT]++;const o=Ze.estimateBlackPoint(s);if(r<3)for(let a=0;a<r;a++)(i[a]&255)<o&&t.set(a);else{let a=i[0]&255,l=i[1]&255;for(let d=1;d<r-1;d++){const A=i[d+1]&255;(l*4-a-A)/2<o&&t.set(d),a=l,l=A}}return t}getBlackMatrix(){const e=this.getLuminanceSource(),t=e.getWidth(),n=e.getHeight(),r=new He(t,n);this.initArrays(t);const i=this.buckets;for(let a=1;a<5;a++){const l=Math.floor(n*a/5),d=e.getRow(l,this.luminances),A=Math.floor(t*4/5);for(let E=Math.floor(t/5);E<A;E++){const b=d[E]&255;i[b>>Ze.LUMINANCE_SHIFT]++}}const s=Ze.estimateBlackPoint(i),o=e.getMatrix();for(let a=0;a<n;a++){const l=a*t;for(let d=0;d<t;d++)(o[l+d]&255)<s&&r.set(d,a)}return r}createBinarizer(e){return new Ze(e)}initArrays(e){this.luminances.length<e&&(this.luminances=new Uint8ClampedArray(e));const t=this.buckets;for(let n=0;n<Ze.LUMINANCE_BUCKETS;n++)t[n]=0}static estimateBlackPoint(e){const t=e.length;let n=0,r=0,i=0;for(let d=0;d<t;d++)e[d]>i&&(r=d,i=e[d]),e[d]>n&&(n=e[d]);let s=0,o=0;for(let d=0;d<t;d++){const A=d-r,E=e[d]*A*A;E>o&&(s=d,o=E)}if(r>s){const d=r;r=s,s=d}if(s-r<=t/16)throw new V;let a=s-1,l=-1;for(let d=s-1;d>r;d--){const A=d-r,E=A*A*(s-d)*(n-e[d]);E>l&&(a=d,l=E)}return a<<Ze.LUMINANCE_SHIFT}}Ze.LUMINANCE_BITS=5,Ze.LUMINANCE_SHIFT=8-Ze.LUMINANCE_BITS,Ze.LUMINANCE_BUCKETS=1<<Ze.LUMINANCE_BITS,Ze.EMPTY=Uint8ClampedArray.from([0]);class le extends Ze{constructor(e){super(e),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const e=this.getLuminanceSource(),t=e.getWidth(),n=e.getHeight();if(t>=le.MINIMUM_DIMENSION&&n>=le.MINIMUM_DIMENSION){const r=e.getMatrix();let i=t>>le.BLOCK_SIZE_POWER;t&le.BLOCK_SIZE_MASK&&i++;let s=n>>le.BLOCK_SIZE_POWER;n&le.BLOCK_SIZE_MASK&&s++;const o=le.calculateBlackPoints(r,i,s,t,n),a=new He(t,n);le.calculateThresholdForBlock(r,i,s,t,n,o,a),this.matrix=a}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new le(e)}static calculateThresholdForBlock(e,t,n,r,i,s,o){const a=i-le.BLOCK_SIZE,l=r-le.BLOCK_SIZE;for(let d=0;d<n;d++){let A=d<<le.BLOCK_SIZE_POWER;A>a&&(A=a);const E=le.cap(d,2,n-3);for(let b=0;b<t;b++){let N=b<<le.BLOCK_SIZE_POWER;N>l&&(N=l);const R=le.cap(b,2,t-3);let B=0;for(let X=-2;X<=2;X++){const Y=s[E+X];B+=Y[R-2]+Y[R-1]+Y[R]+Y[R+1]+Y[R+2]}const L=B/25;le.thresholdBlock(e,N,A,L,r,o)}}}static cap(e,t,n){return e<t?t:e>n?n:e}static thresholdBlock(e,t,n,r,i,s){for(let o=0,a=n*i+t;o<le.BLOCK_SIZE;o++,a+=i)for(let l=0;l<le.BLOCK_SIZE;l++)(e[a+l]&255)<=r&&s.set(t+l,n+o)}static calculateBlackPoints(e,t,n,r,i){const s=i-le.BLOCK_SIZE,o=r-le.BLOCK_SIZE,a=new Array(n);for(let l=0;l<n;l++){a[l]=new Int32Array(t);let d=l<<le.BLOCK_SIZE_POWER;d>s&&(d=s);for(let A=0;A<t;A++){let E=A<<le.BLOCK_SIZE_POWER;E>o&&(E=o);let b=0,N=255,R=0;for(let L=0,X=d*r+E;L<le.BLOCK_SIZE;L++,X+=r){for(let Y=0;Y<le.BLOCK_SIZE;Y++){const H=e[X+Y]&255;b+=H,H<N&&(N=H),H>R&&(R=H)}if(R-N>le.MIN_DYNAMIC_RANGE)for(L++,X+=r;L<le.BLOCK_SIZE;L++,X+=r)for(let Y=0;Y<le.BLOCK_SIZE;Y++)b+=e[X+Y]&255}let B=b>>le.BLOCK_SIZE_POWER*2;if(R-N<=le.MIN_DYNAMIC_RANGE&&(B=N/2,l>0&&A>0)){const L=(a[l-1][A]+2*a[l][A-1]+a[l-1][A-1])/4;N<L&&(B=L)}a[l][A]=B}}return a}}le.BLOCK_SIZE_POWER=3,le.BLOCK_SIZE=1<<le.BLOCK_SIZE_POWER,le.BLOCK_SIZE_MASK=le.BLOCK_SIZE-1,le.MINIMUM_DIMENSION=le.BLOCK_SIZE*5,le.MIN_DYNAMIC_RANGE=24;class tn{constructor(e,t){this.width=e,this.height=t}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(e,t,n,r){throw new zt("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new zt("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new zt("This luminance source does not support rotation by 45 degrees.")}toString(){const e=new Uint8ClampedArray(this.width);let t=new Te;for(let n=0;n<this.height;n++){const r=this.getRow(n,e);for(let i=0;i<this.width;i++){const s=r[i]&255;let o;s<64?o="#":s<128?o="+":s<192?o=".":o=" ",t.append(o)}t.append(`
|
|
9
|
+
`)}return t.toString()}}class vt extends tn{constructor(e){super(e.getWidth(),e.getHeight()),this.delegate=e}getRow(e,t){const n=this.delegate.getRow(e,t),r=this.getWidth();for(let i=0;i<r;i++)n[i]=255-(n[i]&255);return n}getMatrix(){const e=this.delegate.getMatrix(),t=this.getWidth()*this.getHeight(),n=new Uint8ClampedArray(t);for(let r=0;r<t;r++)n[r]=255-(e[r]&255);return n}isCropSupported(){return this.delegate.isCropSupported()}crop(e,t,n,r){return new vt(this.delegate.crop(e,t,n,r))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new vt(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new vt(this.delegate.rotateCounterClockwise45())}}class Ft extends tn{constructor(e){super(e.width,e.height),this.canvas=e,this.tempCanvasElement=null,this.buffer=Ft.makeBufferFromCanvasImageData(e)}static makeBufferFromCanvasImageData(e){const t=e.getContext("2d").getImageData(0,0,e.width,e.height);return Ft.toGrayscaleBuffer(t.data,e.width,e.height)}static toGrayscaleBuffer(e,t,n){const r=new Uint8ClampedArray(t*n);for(let i=0,s=0,o=e.length;i<o;i+=4,s++){let a;if(e[i+3]===0)a=255;else{const d=e[i],A=e[i+1],E=e[i+2];a=306*d+601*A+117*E+512>>10}r[s]=a}return r}getRow(e,t){if(e<0||e>=this.getHeight())throw new M("Requested row is outside the image: "+e);const n=this.getWidth(),r=e*n;return t===null?t=this.buffer.slice(r,r+n):(t.length<n&&(t=new Uint8ClampedArray(n)),t.set(this.buffer.slice(r,r+n))),t}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(e,t,n,r){return super.crop(e,t,n,r),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const e=this.canvas.ownerDocument.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height,this.tempCanvasElement=e}return this.tempCanvasElement}rotate(e){const t=this.getTempCanvasElement(),n=t.getContext("2d"),r=e*Ft.DEGREE_TO_RADIANS,i=this.canvas.width,s=this.canvas.height,o=Math.ceil(Math.abs(Math.cos(r))*i+Math.abs(Math.sin(r))*s),a=Math.ceil(Math.abs(Math.sin(r))*i+Math.abs(Math.cos(r))*s);return t.width=o,t.height=a,n.translate(o/2,a/2),n.rotate(r),n.drawImage(this.canvas,i/-2,s/-2),this.buffer=Ft.makeBufferFromCanvasImageData(t),this}invert(){return new vt(this)}}Ft.DEGREE_TO_RADIANS=Math.PI/180;class Xe{constructor(e,t,n){this.deviceId=e,this.label=t,this.kind="videoinput",this.groupId=n||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var Se=(globalThis||vn||self||window||void 0)&&(globalThis||vn||self||window||void 0).__awaiter||function(w,e,t,n){function r(i){return i instanceof t?i:new t(function(s){s(i)})}return new(t||(t=Promise))(function(i,s){function o(d){try{l(n.next(d))}catch(A){s(A)}}function a(d){try{l(n.throw(d))}catch(A){s(A)}}function l(d){d.done?i(d.value):r(d.value).then(o,a)}l((n=n.apply(w,e||[])).next())})};class Lt{constructor(e,t=500,n){this.reader=e,this.timeBetweenScansMillis=t,this._hints=n,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(e){this._timeBetweenDecodingAttempts=e<0?0:e}set hints(e){this._hints=e||null}get hints(){return this._hints}listVideoInputDevices(){return Se(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const e=yield navigator.mediaDevices.enumerateDevices(),t=[];for(const n of e){const r=n.kind==="video"?"videoinput":n.kind;if(r!=="videoinput")continue;const i=n.deviceId||n.id,s=n.label||`Video device ${t.length+1}`,o=n.groupId,a={deviceId:i,label:s,kind:r,groupId:o};t.push(a)}return t})}getVideoInputDevices(){return Se(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(t=>new Xe(t.deviceId,t.label))})}findDeviceById(e){return Se(this,void 0,void 0,function*(){const t=yield this.listVideoInputDevices();return t?t.find(n=>n.deviceId===e):null})}decodeFromInputVideoDevice(e,t){return Se(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,t)})}decodeOnceFromVideoDevice(e,t){return Se(this,void 0,void 0,function*(){this.reset();let n;e?n={deviceId:{exact:e}}:n={facingMode:"environment"};const r={video:n};return yield this.decodeOnceFromConstraints(r,t)})}decodeOnceFromConstraints(e,t){return Se(this,void 0,void 0,function*(){const n=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(n,t)})}decodeOnceFromStream(e,t){return Se(this,void 0,void 0,function*(){this.reset();const n=yield this.attachStreamToVideo(e,t);return yield this.decodeOnce(n)})}decodeFromInputVideoDeviceContinuously(e,t,n){return Se(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,t,n)})}decodeFromVideoDevice(e,t,n){return Se(this,void 0,void 0,function*(){let r;e?r={deviceId:{exact:e}}:r={facingMode:"environment"};const i={video:r};return yield this.decodeFromConstraints(i,t,n)})}decodeFromConstraints(e,t,n){return Se(this,void 0,void 0,function*(){const r=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(r,t,n)})}decodeFromStream(e,t,n){return Se(this,void 0,void 0,function*(){this.reset();const r=yield this.attachStreamToVideo(e,t);return yield this.decodeContinuously(r,n)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,t){return Se(this,void 0,void 0,function*(){const n=this.prepareVideoElement(t);return this.addVideoSource(n,e),this.videoElement=n,this.stream=e,yield this.playVideoOnLoadAsync(n),n})}playVideoOnLoadAsync(e){return new Promise((t,n)=>this.playVideoOnLoad(e,()=>t()))}playVideoOnLoad(e,t){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return Se(this,void 0,void 0,function*(){if(this.isVideoPlaying(e)){console.warn("Trying to play video that is already playing.");return}try{yield e.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(e,t){const n=document.getElementById(e);if(!n)throw new k(`element with id '${e}' not found`);if(n.nodeName.toLowerCase()!==t.toLowerCase())throw new k(`element with id '${e}' must be an ${t} element`);return n}decodeFromImage(e,t){if(!e&&!t)throw new k("either imageElement with a src set or an url must be provided");return t&&!e?this.decodeFromImageUrl(t):this.decodeFromImageElement(e)}decodeFromVideo(e,t){if(!e&&!t)throw new k("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,t,n){if(e===void 0&&t===void 0)throw new k("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,n):this.decodeFromVideoElementContinuously(e,n)}decodeFromImageElement(e){if(!e)throw new k("An image element must be provided.");this.reset();const t=this.prepareImageElement(e);this.imageElement=t;let n;return this.isImageLoaded(t)?n=this.decodeOnce(t,!1,!0):n=this._decodeOnLoadImage(t),n}decodeFromVideoElement(e){const t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)}decodeFromVideoElementContinuously(e,t){const n=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(n,t)}_decodeFromVideoElementSetup(e){if(!e)throw new k("A video element must be provided.");this.reset();const t=this.prepareVideoElement(e);return this.videoElement=t,t}decodeFromImageUrl(e){if(!e)throw new k("An URL must be provided.");this.reset();const t=this.prepareImageElement();this.imageElement=t;const n=this._decodeOnLoadImage(t);return t.src=e,n}decodeFromVideoUrl(e){if(!e)throw new k("An URL must be provided.");this.reset();const t=this.prepareVideoElement(),n=this.decodeFromVideoElement(t);return t.src=e,n}decodeFromVideoUrlContinuously(e,t){if(!e)throw new k("An URL must be provided.");this.reset();const n=this.prepareVideoElement(),r=this.decodeFromVideoElementContinuously(n,t);return n.src=e,r}_decodeOnLoadImage(e){return new Promise((t,n)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(t,n),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return Se(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,t){return Se(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,t)})}isImageLoaded(e){return!(!e.complete||e.naturalWidth===0)}prepareImageElement(e){let t;return typeof e>"u"&&(t=document.createElement("img"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t}prepareVideoElement(e){let t;return!e&&typeof document<"u"&&(t=document.createElement("video"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t}decodeOnce(e,t=!0,n=!0){this._stopAsyncDecode=!1;const r=(i,s)=>{if(this._stopAsyncDecode){s(new V("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const o=this.decode(e);i(o)}catch(o){const a=t&&o instanceof V,d=(o instanceof Q||o instanceof Z)&&n;if(a||d)return setTimeout(r,this._timeBetweenDecodingAttempts,i,s);s(o)}};return new Promise((i,s)=>r(i,s))}decodeContinuously(e,t){this._stopContinuousDecode=!1;const n=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const r=this.decode(e);t(r,null),setTimeout(n,this.timeBetweenScansMillis)}catch(r){t(null,r);const i=r instanceof Q||r instanceof Z,s=r instanceof V;(i||s)&&setTimeout(n,this._timeBetweenDecodingAttempts)}};n()}decode(e){const t=this.createBinaryBitmap(e);return this.decodeBitmap(t)}_isHTMLVideoElement(e){return e.videoWidth!==0}drawFrameOnCanvas(e,t,n){t||(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),n||(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}drawImageOnCanvas(e,t,n=this.captureCanvasContext){t||(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),n||(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}createBinaryBitmap(e){this.getCaptureCanvasContext(e),this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);const t=this.getCaptureCanvas(e),n=new Ft(t),r=new le(n);return new ae(r)}getCaptureCanvasContext(e){if(!this.captureCanvasContext){const n=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=n}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){const t=this.createCaptureCanvas(e);this.captureCanvas=t}return this.captureCanvas}decodeBitmap(e){return this.reader.decode(e,this._hints)}createCaptureCanvas(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const t=document.createElement("canvas");let n,r;return typeof e<"u"&&(e instanceof HTMLVideoElement?(n=e.videoWidth,r=e.videoHeight):e instanceof HTMLImageElement&&(n=e.naturalWidth||e.width,r=e.naturalHeight||e.height)),t.style.width=n+"px",t.style.height=r+"px",t.width=n,t.height=r,t}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(e,t){try{e.srcObject=t}catch{e.src=URL.createObjectURL(t)}}cleanVideoSource(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")}}class qe{constructor(e,t,n=t==null?0:8*t.length,r,i,s=he.currentTimeMillis()){this.text=e,this.rawBytes=t,this.numBits=n,this.resultPoints=r,this.format=i,this.timestamp=s,this.text=e,this.rawBytes=t,n==null?this.numBits=t==null?0:8*t.length:this.numBits=n,this.resultPoints=r,this.format=i,this.resultMetadata=null,s==null?this.timestamp=he.currentTimeMillis():this.timestamp=s}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(e,t){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,t)}putAllMetadata(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))}addResultPoints(e){const t=this.resultPoints;if(t===null)this.resultPoints=e;else if(e!==null&&e.length>0){const n=new Array(t.length+e.length);he.arraycopy(t,0,n,0,t.length),he.arraycopy(e,0,n,t.length,e.length),this.resultPoints=n}}getTimestamp(){return this.timestamp}toString(){return this.text}}var En;(function(w){w[w.AZTEC=0]="AZTEC",w[w.CODABAR=1]="CODABAR",w[w.CODE_39=2]="CODE_39",w[w.CODE_93=3]="CODE_93",w[w.CODE_128=4]="CODE_128",w[w.DATA_MATRIX=5]="DATA_MATRIX",w[w.EAN_8=6]="EAN_8",w[w.EAN_13=7]="EAN_13",w[w.ITF=8]="ITF",w[w.MAXICODE=9]="MAXICODE",w[w.PDF_417=10]="PDF_417",w[w.QR_CODE=11]="QR_CODE",w[w.RSS_14=12]="RSS_14",w[w.RSS_EXPANDED=13]="RSS_EXPANDED",w[w.UPC_A=14]="UPC_A",w[w.UPC_E=15]="UPC_E",w[w.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(En||(En={}));var $=En,Cn;(function(w){w[w.OTHER=0]="OTHER",w[w.ORIENTATION=1]="ORIENTATION",w[w.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",w[w.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",w[w.ISSUE_NUMBER=4]="ISSUE_NUMBER",w[w.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",w[w.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",w[w.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",w[w.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",w[w.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",w[w.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Cn||(Cn={}));var Fe=Cn;class Xt{constructor(e,t,n,r,i=-1,s=-1){this.rawBytes=e,this.text=t,this.byteSegments=n,this.ecLevel=r,this.structuredAppendSequenceNumber=i,this.structuredAppendParity=s,this.numBits=e==null?0:8*e.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(e){this.numBits=e}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(e){this.errorsCorrected=e}getErasures(){return this.erasures}setErasures(e){this.erasures=e}getOther(){return this.other}setOther(e){this.other=e}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class Zt{exp(e){return this.expTable[e]}log(e){if(e===0)throw new M;return this.logTable[e]}static addOrSubtract(e,t){return e^t}}class it{constructor(e,t){if(t.length===0)throw new M;this.field=e;const n=t.length;if(n>1&&t[0]===0){let r=1;for(;r<n&&t[r]===0;)r++;r===n?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(n-r),he.arraycopy(t,r,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);const t=this.coefficients;let n;if(e===1){n=0;for(let s=0,o=t.length;s!==o;s++){const a=t[s];n=Zt.addOrSubtract(n,a)}return n}n=t[0];const r=t.length,i=this.field;for(let s=1;s<r;s++)n=Zt.addOrSubtract(i.multiply(e,n),t[s]);return n}addOrSubtract(e){if(!this.field.equals(e.field))throw new M("GenericGFPolys do not have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;let t=this.coefficients,n=e.coefficients;if(t.length>n.length){const s=t;t=n,n=s}let r=new Int32Array(n.length);const i=n.length-t.length;he.arraycopy(n,0,r,0,i);for(let s=i;s<n.length;s++)r[s]=Zt.addOrSubtract(t[s-i],n[s]);return new it(this.field,r)}multiply(e){if(!this.field.equals(e.field))throw new M("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();const t=this.coefficients,n=t.length,r=e.coefficients,i=r.length,s=new Int32Array(n+i-1),o=this.field;for(let a=0;a<n;a++){const l=t[a];for(let d=0;d<i;d++)s[a+d]=Zt.addOrSubtract(s[a+d],o.multiply(l,r[d]))}return new it(o,s)}multiplyScalar(e){if(e===0)return this.field.getZero();if(e===1)return this;const t=this.coefficients.length,n=this.field,r=new Int32Array(t),i=this.coefficients;for(let s=0;s<t;s++)r[s]=n.multiply(i[s],e);return new it(n,r)}multiplyByMonomial(e,t){if(e<0)throw new M;if(t===0)return this.field.getZero();const n=this.coefficients,r=n.length,i=new Int32Array(r+e),s=this.field;for(let o=0;o<r;o++)i[o]=s.multiply(n[o],t);return new it(s,i)}divide(e){if(!this.field.equals(e.field))throw new M("GenericGFPolys do not have same GenericGF field");if(e.isZero())throw new M("Divide by 0");const t=this.field;let n=t.getZero(),r=this;const i=e.getCoefficient(e.getDegree()),s=t.inverse(i);for(;r.getDegree()>=e.getDegree()&&!r.isZero();){const o=r.getDegree()-e.getDegree(),a=t.multiply(r.getCoefficient(r.getDegree()),s),l=e.multiplyByMonomial(o,a),d=t.buildMonomial(o,a);n=n.addOrSubtract(d),r=r.addOrSubtract(l)}return[n,r]}toString(){let e="";for(let t=this.getDegree();t>=0;t--){let n=this.getCoefficient(t);if(n!==0){if(n<0?(e+=" - ",n=-n):e.length>0&&(e+=" + "),t===0||n!==1){const r=this.field.log(n);r===0?e+="1":r===1?e+="a":(e+="a^",e+=r)}t!==0&&(t===1?e+="x":(e+="x^",e+=t))}}return e}}class nn extends p{}nn.kind="ArithmeticException";class xe extends Zt{constructor(e,t,n){super(),this.primitive=e,this.size=t,this.generatorBase=n;const r=new Int32Array(t);let i=1;for(let o=0;o<t;o++)r[o]=i,i*=2,i>=t&&(i^=e,i&=t-1);this.expTable=r;const s=new Int32Array(t);for(let o=0;o<t-1;o++)s[r[o]]=o;this.logTable=s,this.zero=new it(this,Int32Array.from([0])),this.one=new it(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,t){if(e<0)throw new M;if(t===0)return this.zero;const n=new Int32Array(e+1);return n[0]=t,new it(this,n)}inverse(e){if(e===0)throw new nn;return this.expTable[this.size-this.logTable[e]-1]}multiply(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+ne.toHexString(this.primitive)+","+this.size+")"}equals(e){return e===this}}xe.AZTEC_DATA_12=new xe(4201,4096,1),xe.AZTEC_DATA_10=new xe(1033,1024,1),xe.AZTEC_DATA_6=new xe(67,64,1),xe.AZTEC_PARAM=new xe(19,16,1),xe.QR_CODE_FIELD_256=new xe(285,256,0),xe.DATA_MATRIX_FIELD_256=new xe(301,256,1),xe.AZTEC_DATA_8=xe.DATA_MATRIX_FIELD_256,xe.MAXICODE_FIELD_64=xe.AZTEC_DATA_6;class It extends p{}It.kind="ReedSolomonException";class yt extends p{}yt.kind="IllegalStateException";class rn{constructor(e){this.field=e}decode(e,t){const n=this.field,r=new it(n,e),i=new Int32Array(t);let s=!0;for(let b=0;b<t;b++){const N=r.evaluateAt(n.exp(b+n.getGeneratorBase()));i[i.length-1-b]=N,N!==0&&(s=!1)}if(s)return;const o=new it(n,i),a=this.runEuclideanAlgorithm(n.buildMonomial(t,1),o,t),l=a[0],d=a[1],A=this.findErrorLocations(l),E=this.findErrorMagnitudes(d,A);for(let b=0;b<A.length;b++){const N=e.length-1-n.log(A[b]);if(N<0)throw new It("Bad error location");e[N]=xe.addOrSubtract(e[N],E[b])}}runEuclideanAlgorithm(e,t,n){if(e.getDegree()<t.getDegree()){const b=e;e=t,t=b}const r=this.field;let i=e,s=t,o=r.getZero(),a=r.getOne();for(;s.getDegree()>=(n/2|0);){let b=i,N=o;if(i=s,o=a,i.isZero())throw new It("r_{i-1} was zero");s=b;let R=r.getZero();const B=i.getCoefficient(i.getDegree()),L=r.inverse(B);for(;s.getDegree()>=i.getDegree()&&!s.isZero();){const X=s.getDegree()-i.getDegree(),Y=r.multiply(s.getCoefficient(s.getDegree()),L);R=R.addOrSubtract(r.buildMonomial(X,Y)),s=s.addOrSubtract(i.multiplyByMonomial(X,Y))}if(a=R.multiply(o).addOrSubtract(N),s.getDegree()>=i.getDegree())throw new yt("Division algorithm failed to reduce polynomial?")}const l=a.getCoefficient(0);if(l===0)throw new It("sigmaTilde(0) was zero");const d=r.inverse(l),A=a.multiplyScalar(d),E=s.multiplyScalar(d);return[A,E]}findErrorLocations(e){const t=e.getDegree();if(t===1)return Int32Array.from([e.getCoefficient(1)]);const n=new Int32Array(t);let r=0;const i=this.field;for(let s=1;s<i.getSize()&&r<t;s++)e.evaluateAt(s)===0&&(n[r]=i.inverse(s),r++);if(r!==t)throw new It("Error locator degree does not match number of roots");return n}findErrorMagnitudes(e,t){const n=t.length,r=new Int32Array(n),i=this.field;for(let s=0;s<n;s++){const o=i.inverse(t[s]);let a=1;for(let l=0;l<n;l++)if(s!==l){const d=i.multiply(t[l],o),A=d&1?d&-2:d|1;a=i.multiply(a,A)}r[s]=i.multiply(e.evaluateAt(o),i.inverse(a)),i.getGeneratorBase()!==0&&(r[s]=i.multiply(r[s],o))}return r}}var Ye;(function(w){w[w.UPPER=0]="UPPER",w[w.LOWER=1]="LOWER",w[w.MIXED=2]="MIXED",w[w.DIGIT=3]="DIGIT",w[w.PUNCT=4]="PUNCT",w[w.BINARY=5]="BINARY"})(Ye||(Ye={}));class Re{decode(e){this.ddata=e;let t=e.getBits(),n=this.extractBits(t),r=this.correctBits(n),i=Re.convertBoolArrayToByteArray(r),s=Re.getEncodedData(r),o=new Xt(i,s,null,null);return o.setNumBits(r.length),o}static highLevelDecode(e){return this.getEncodedData(e)}static getEncodedData(e){let t=e.length,n=Ye.UPPER,r=Ye.UPPER,i="",s=0;for(;s<t;)if(r===Ye.BINARY){if(t-s<5)break;let o=Re.readCode(e,s,5);if(s+=5,o===0){if(t-s<11)break;o=Re.readCode(e,s,11)+31,s+=11}for(let a=0;a<o;a++){if(t-s<8){s=t;break}const l=Re.readCode(e,s,8);i+=se.castAsNonUtf8Char(l),s+=8}r=n}else{let o=r===Ye.DIGIT?4:5;if(t-s<o)break;let a=Re.readCode(e,s,o);s+=o;let l=Re.getCharacter(r,a);l.startsWith("CTRL_")?(n=r,r=Re.getTable(l.charAt(5)),l.charAt(6)==="L"&&(n=r)):(i+=l,r=n)}return i}static getTable(e){switch(e){case"L":return Ye.LOWER;case"P":return Ye.PUNCT;case"M":return Ye.MIXED;case"D":return Ye.DIGIT;case"B":return Ye.BINARY;case"U":default:return Ye.UPPER}}static getCharacter(e,t){switch(e){case Ye.UPPER:return Re.UPPER_TABLE[t];case Ye.LOWER:return Re.LOWER_TABLE[t];case Ye.MIXED:return Re.MIXED_TABLE[t];case Ye.PUNCT:return Re.PUNCT_TABLE[t];case Ye.DIGIT:return Re.DIGIT_TABLE[t];default:throw new yt("Bad table")}}correctBits(e){let t,n;this.ddata.getNbLayers()<=2?(n=6,t=xe.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(n=8,t=xe.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(n=10,t=xe.AZTEC_DATA_10):(n=12,t=xe.AZTEC_DATA_12);let r=this.ddata.getNbDatablocks(),i=e.length/n;if(i<r)throw new Z;let s=e.length%n,o=new Int32Array(i);for(let E=0;E<i;E++,s+=n)o[E]=Re.readCode(e,s,n);try{new rn(t).decode(o,i-r)}catch(E){throw new Z(E)}let a=(1<<n)-1,l=0;for(let E=0;E<r;E++){let b=o[E];if(b===0||b===a)throw new Z;(b===1||b===a-1)&&l++}let d=new Array(r*n-l),A=0;for(let E=0;E<r;E++){let b=o[E];if(b===1||b===a-1)d.fill(b>1,A,A+n-1),A+=n-1;else for(let N=n-1;N>=0;--N)d[A++]=(b&1<<N)!==0}return d}extractBits(e){let t=this.ddata.isCompact(),n=this.ddata.getNbLayers(),r=(t?11:14)+n*4,i=new Int32Array(r),s=new Array(this.totalBitsInLayer(n,t));if(t)for(let o=0;o<i.length;o++)i[o]=o;else{let o=r+1+2*ne.truncDivision(ne.truncDivision(r,2)-1,15),a=r/2,l=ne.truncDivision(o,2);for(let d=0;d<a;d++){let A=d+ne.truncDivision(d,15);i[a-d-1]=l-A-1,i[a+d]=l+A+1}}for(let o=0,a=0;o<n;o++){let l=(n-o)*4+(t?9:12),d=o*2,A=r-1-d;for(let E=0;E<l;E++){let b=E*2;for(let N=0;N<2;N++)s[a+b+N]=e.get(i[d+N],i[d+E]),s[a+2*l+b+N]=e.get(i[d+E],i[A-N]),s[a+4*l+b+N]=e.get(i[A-N],i[A-E]),s[a+6*l+b+N]=e.get(i[A-E],i[d+N])}a+=l*8}return s}static readCode(e,t,n){let r=0;for(let i=t;i<t+n;i++)r<<=1,e[i]&&(r|=1);return r}static readByte(e,t){let n=e.length-t;return n>=8?Re.readCode(e,t,8):Re.readCode(e,t,n)<<8-n}static convertBoolArrayToByteArray(e){let t=new Uint8Array((e.length+7)/8);for(let n=0;n<t.length;n++)t[n]=Re.readByte(e,8*n);return t}totalBitsInLayer(e,t){return((t?88:112)+16*e)*e}}Re.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Re.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Re.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
|
|
10
|
+
`,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],Re.PUNCT_TABLE=["","\r",`\r
|
|
11
|
+
`,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Re.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class we{constructor(){}static round(e){return e===NaN?0:e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,t,n,r){const i=e-n,s=t-r;return Math.sqrt(i*i+s*s)}static sum(e){let t=0;for(let n=0,r=e.length;n!==r;n++){const i=e[n];t+=i}return t}}class sn{static floatToIntBits(e){return e}}sn.MAX_VALUE=Number.MAX_SAFE_INTEGER;class q{constructor(e,t){this.x=e,this.y=t}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof q){const t=e;return this.x===t.x&&this.y===t.y}return!1}hashCode(){return 31*sn.floatToIntBits(this.x)+sn.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){const t=this.distance(e[0],e[1]),n=this.distance(e[1],e[2]),r=this.distance(e[0],e[2]);let i,s,o;if(n>=t&&n>=r?(s=e[0],i=e[1],o=e[2]):r>=n&&r>=t?(s=e[1],i=e[0],o=e[2]):(s=e[2],i=e[0],o=e[1]),this.crossProductZ(i,s,o)<0){const a=i;i=o,o=a}e[0]=i,e[1]=s,e[2]=o}static distance(e,t){return we.distance(e.x,e.y,t.x,t.y)}static crossProductZ(e,t,n){const r=t.x,i=t.y;return(n.x-r)*(e.y-i)-(n.y-i)*(e.x-r)}}class at{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class pn extends at{constructor(e,t,n,r,i){super(e,t),this.compact=n,this.nbDatablocks=r,this.nbLayers=i}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class Rt{constructor(e,t,n,r){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),t==null&&(t=Rt.INIT_SIZE),n==null&&(n=e.getWidth()/2|0),r==null&&(r=e.getHeight()/2|0);const i=t/2|0;if(this.leftInit=n-i,this.rightInit=n+i,this.upInit=r-i,this.downInit=r+i,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new V}detect(){let e=this.leftInit,t=this.rightInit,n=this.upInit,r=this.downInit,i=!1,s=!0,o=!1,a=!1,l=!1,d=!1,A=!1;const E=this.width,b=this.height;for(;s;){s=!1;let N=!0;for(;(N||!a)&&t<E;)N=this.containsBlackPoint(n,r,t,!1),N?(t++,s=!0,a=!0):a||t++;if(t>=E){i=!0;break}let R=!0;for(;(R||!l)&&r<b;)R=this.containsBlackPoint(e,t,r,!0),R?(r++,s=!0,l=!0):l||r++;if(r>=b){i=!0;break}let B=!0;for(;(B||!d)&&e>=0;)B=this.containsBlackPoint(n,r,e,!1),B?(e--,s=!0,d=!0):d||e--;if(e<0){i=!0;break}let L=!0;for(;(L||!A)&&n>=0;)L=this.containsBlackPoint(e,t,n,!0),L?(n--,s=!0,A=!0):A||n--;if(n<0){i=!0;break}s&&(o=!0)}if(!i&&o){const N=t-e;let R=null;for(let Y=1;R===null&&Y<N;Y++)R=this.getBlackPointOnSegment(e,r-Y,e+Y,r);if(R==null)throw new V;let B=null;for(let Y=1;B===null&&Y<N;Y++)B=this.getBlackPointOnSegment(e,n+Y,e+Y,n);if(B==null)throw new V;let L=null;for(let Y=1;L===null&&Y<N;Y++)L=this.getBlackPointOnSegment(t,n+Y,t-Y,n);if(L==null)throw new V;let X=null;for(let Y=1;X===null&&Y<N;Y++)X=this.getBlackPointOnSegment(t,r-Y,t-Y,r);if(X==null)throw new V;return this.centerEdges(X,R,L,B)}else throw new V}getBlackPointOnSegment(e,t,n,r){const i=we.round(we.distance(e,t,n,r)),s=(n-e)/i,o=(r-t)/i,a=this.image;for(let l=0;l<i;l++){const d=we.round(e+l*s),A=we.round(t+l*o);if(a.get(d,A))return new q(d,A)}return null}centerEdges(e,t,n,r){const i=e.getX(),s=e.getY(),o=t.getX(),a=t.getY(),l=n.getX(),d=n.getY(),A=r.getX(),E=r.getY(),b=Rt.CORR;return i<this.width/2?[new q(A-b,E+b),new q(o+b,a+b),new q(l-b,d-b),new q(i+b,s-b)]:[new q(A+b,E+b),new q(o+b,a-b),new q(l-b,d+b),new q(i-b,s-b)]}containsBlackPoint(e,t,n,r){const i=this.image;if(r){for(let s=e;s<=t;s++)if(i.get(s,n))return!0}else for(let s=e;s<=t;s++)if(i.get(n,s))return!0;return!1}}Rt.INIT_SIZE=10,Rt.CORR=1;class bt{static checkAndNudgePoints(e,t){const n=e.getWidth(),r=e.getHeight();let i=!0;for(let s=0;s<t.length&&i;s+=2){const o=Math.floor(t[s]),a=Math.floor(t[s+1]);if(o<-1||o>n||a<-1||a>r)throw new V;i=!1,o===-1?(t[s]=0,i=!0):o===n&&(t[s]=n-1,i=!0),a===-1?(t[s+1]=0,i=!0):a===r&&(t[s+1]=r-1,i=!0)}i=!0;for(let s=t.length-2;s>=0&&i;s-=2){const o=Math.floor(t[s]),a=Math.floor(t[s+1]);if(o<-1||o>n||a<-1||a>r)throw new V;i=!1,o===-1?(t[s]=0,i=!0):o===n&&(t[s]=n-1,i=!0),a===-1?(t[s+1]=0,i=!0):a===r&&(t[s+1]=r-1,i=!0)}}}class wt{constructor(e,t,n,r,i,s,o,a,l){this.a11=e,this.a21=t,this.a31=n,this.a12=r,this.a22=i,this.a32=s,this.a13=o,this.a23=a,this.a33=l}static quadrilateralToQuadrilateral(e,t,n,r,i,s,o,a,l,d,A,E,b,N,R,B){const L=wt.quadrilateralToSquare(e,t,n,r,i,s,o,a);return wt.squareToQuadrilateral(l,d,A,E,b,N,R,B).times(L)}transformPoints(e){const t=e.length,n=this.a11,r=this.a12,i=this.a13,s=this.a21,o=this.a22,a=this.a23,l=this.a31,d=this.a32,A=this.a33;for(let E=0;E<t;E+=2){const b=e[E],N=e[E+1],R=i*b+a*N+A;e[E]=(n*b+s*N+l)/R,e[E+1]=(r*b+o*N+d)/R}}transformPointsWithValues(e,t){const n=this.a11,r=this.a12,i=this.a13,s=this.a21,o=this.a22,a=this.a23,l=this.a31,d=this.a32,A=this.a33,E=e.length;for(let b=0;b<E;b++){const N=e[b],R=t[b],B=i*N+a*R+A;e[b]=(n*N+s*R+l)/B,t[b]=(r*N+o*R+d)/B}}static squareToQuadrilateral(e,t,n,r,i,s,o,a){const l=e-n+i-o,d=t-r+s-a;if(l===0&&d===0)return new wt(n-e,i-n,e,r-t,s-r,t,0,0,1);{const A=n-i,E=o-i,b=r-s,N=a-s,R=A*N-E*b,B=(l*N-E*d)/R,L=(A*d-l*b)/R;return new wt(n-e+B*n,o-e+L*o,e,r-t+B*r,a-t+L*a,t,B,L,1)}}static quadrilateralToSquare(e,t,n,r,i,s,o,a){return wt.squareToQuadrilateral(e,t,n,r,i,s,o,a).buildAdjoint()}buildAdjoint(){return new wt(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(e){return new wt(this.a11*e.a11+this.a21*e.a12+this.a31*e.a13,this.a11*e.a21+this.a21*e.a22+this.a31*e.a23,this.a11*e.a31+this.a21*e.a32+this.a31*e.a33,this.a12*e.a11+this.a22*e.a12+this.a32*e.a13,this.a12*e.a21+this.a22*e.a22+this.a32*e.a23,this.a12*e.a31+this.a22*e.a32+this.a32*e.a33,this.a13*e.a11+this.a23*e.a12+this.a33*e.a13,this.a13*e.a21+this.a23*e.a22+this.a33*e.a23,this.a13*e.a31+this.a23*e.a32+this.a33*e.a33)}}class C extends bt{sampleGrid(e,t,n,r,i,s,o,a,l,d,A,E,b,N,R,B,L,X,Y){const H=wt.quadrilateralToQuadrilateral(r,i,s,o,a,l,d,A,E,b,N,R,B,L,X,Y);return this.sampleGridWithTransform(e,t,n,H)}sampleGridWithTransform(e,t,n,r){if(t<=0||n<=0)throw new V;const i=new He(t,n),s=new Float32Array(2*t);for(let o=0;o<n;o++){const a=s.length,l=o+.5;for(let d=0;d<a;d+=2)s[d]=d/2+.5,s[d+1]=l;r.transformPoints(s),bt.checkAndNudgePoints(e,s);try{for(let d=0;d<a;d+=2)e.get(Math.floor(s[d]),Math.floor(s[d+1]))&&i.set(d/2,o)}catch{throw new V}}return i}}class u{static setGridSampler(e){u.gridSampler=e}static getInstance(){return u.gridSampler}}u.gridSampler=new C;class h{constructor(e,t){this.x=e,this.y=t}toResultPoint(){return new q(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class T{constructor(e){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=e}detect(){return this.detectMirror(!1)}detectMirror(e){let t=this.getMatrixCenter(),n=this.getBullsEyeCorners(t);if(e){let s=n[0];n[0]=n[2],n[2]=s}this.extractParameters(n);let r=this.sampleGrid(this.image,n[this.shift%4],n[(this.shift+1)%4],n[(this.shift+2)%4],n[(this.shift+3)%4]),i=this.getMatrixCornerPoints(n);return new pn(r,i,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(e){if(!this.isValidPoint(e[0])||!this.isValidPoint(e[1])||!this.isValidPoint(e[2])||!this.isValidPoint(e[3]))throw new V;let t=2*this.nbCenterLayers,n=new Int32Array([this.sampleLine(e[0],e[1],t),this.sampleLine(e[1],e[2],t),this.sampleLine(e[2],e[3],t),this.sampleLine(e[3],e[0],t)]);this.shift=this.getRotation(n,t);let r=0;for(let s=0;s<4;s++){let o=n[(this.shift+s)%4];this.compact?(r<<=7,r+=o>>1&127):(r<<=10,r+=(o>>2&992)+(o>>1&31))}let i=this.getCorrectedParameterData(r,this.compact);this.compact?(this.nbLayers=(i>>6)+1,this.nbDataBlocks=(i&63)+1):(this.nbLayers=(i>>11)+1,this.nbDataBlocks=(i&2047)+1)}getRotation(e,t){let n=0;e.forEach((r,i,s)=>{let o=(r>>t-2<<1)+(r&1);n=(n<<3)+o}),n=((n&1)<<11)+(n>>1);for(let r=0;r<4;r++)if(ne.bitCount(n^this.EXPECTED_CORNER_BITS[r])<=2)return r;throw new V}getCorrectedParameterData(e,t){let n,r;t?(n=7,r=2):(n=10,r=4);let i=n-r,s=new Int32Array(n);for(let a=n-1;a>=0;--a)s[a]=e&15,e>>=4;try{new rn(xe.AZTEC_PARAM).decode(s,i)}catch{throw new V}let o=0;for(let a=0;a<r;a++)o=(o<<4)+s[a];return o}getBullsEyeCorners(e){let t=e,n=e,r=e,i=e,s=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let A=this.getFirstDifferent(t,s,1,-1),E=this.getFirstDifferent(n,s,1,1),b=this.getFirstDifferent(r,s,-1,1),N=this.getFirstDifferent(i,s,-1,-1);if(this.nbCenterLayers>2){let R=this.distancePoint(N,A)*this.nbCenterLayers/(this.distancePoint(i,t)*(this.nbCenterLayers+2));if(R<.75||R>1.25||!this.isWhiteOrBlackRectangle(A,E,b,N))break}t=A,n=E,r=b,i=N,s=!s}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new V;this.compact=this.nbCenterLayers===5;let o=new q(t.getX()+.5,t.getY()-.5),a=new q(n.getX()+.5,n.getY()+.5),l=new q(r.getX()-.5,r.getY()+.5),d=new q(i.getX()-.5,i.getY()-.5);return this.expandSquare([o,a,l,d],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,t,n,r;try{let o=new Rt(this.image).detect();e=o[0],t=o[1],n=o[2],r=o[3]}catch{let a=this.image.getWidth()/2,l=this.image.getHeight()/2;e=this.getFirstDifferent(new h(a+7,l-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new h(a+7,l+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new h(a-7,l+7),!1,-1,1).toResultPoint(),r=this.getFirstDifferent(new h(a-7,l-7),!1,-1,-1).toResultPoint()}let i=we.round((e.getX()+r.getX()+t.getX()+n.getX())/4),s=we.round((e.getY()+r.getY()+t.getY()+n.getY())/4);try{let o=new Rt(this.image,15,i,s).detect();e=o[0],t=o[1],n=o[2],r=o[3]}catch{e=this.getFirstDifferent(new h(i+7,s-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new h(i+7,s+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new h(i-7,s+7),!1,-1,1).toResultPoint(),r=this.getFirstDifferent(new h(i-7,s-7),!1,-1,-1).toResultPoint()}return i=we.round((e.getX()+r.getX()+t.getX()+n.getX())/4),s=we.round((e.getY()+r.getY()+t.getY()+n.getY())/4),new h(i,s)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,t,n,r,i){let s=u.getInstance(),o=this.getDimension(),a=o/2-this.nbCenterLayers,l=o/2+this.nbCenterLayers;return s.sampleGrid(e,o,o,a,a,l,a,l,l,a,l,t.getX(),t.getY(),n.getX(),n.getY(),r.getX(),r.getY(),i.getX(),i.getY())}sampleLine(e,t,n){let r=0,i=this.distanceResultPoint(e,t),s=i/n,o=e.getX(),a=e.getY(),l=s*(t.getX()-e.getX())/i,d=s*(t.getY()-e.getY())/i;for(let A=0;A<n;A++)this.image.get(we.round(o+A*l),we.round(a+A*d))&&(r|=1<<n-A-1);return r}isWhiteOrBlackRectangle(e,t,n,r){let i=3;e=new h(e.getX()-i,e.getY()+i),t=new h(t.getX()-i,t.getY()-i),n=new h(n.getX()+i,n.getY()-i),r=new h(r.getX()+i,r.getY()+i);let s=this.getColor(r,e);if(s===0)return!1;let o=this.getColor(e,t);return o!==s||(o=this.getColor(t,n),o!==s)?!1:(o=this.getColor(n,r),o===s)}getColor(e,t){let n=this.distancePoint(e,t),r=(t.getX()-e.getX())/n,i=(t.getY()-e.getY())/n,s=0,o=e.getX(),a=e.getY(),l=this.image.get(e.getX(),e.getY()),d=Math.ceil(n);for(let E=0;E<d;E++)o+=r,a+=i,this.image.get(we.round(o),we.round(a))!==l&&s++;let A=s/n;return A>.1&&A<.9?0:A<=.1===l?1:-1}getFirstDifferent(e,t,n,r){let i=e.getX()+n,s=e.getY()+r;for(;this.isValid(i,s)&&this.image.get(i,s)===t;)i+=n,s+=r;for(i-=n,s-=r;this.isValid(i,s)&&this.image.get(i,s)===t;)i+=n;for(i-=n;this.isValid(i,s)&&this.image.get(i,s)===t;)s+=r;return s-=r,new h(i,s)}expandSquare(e,t,n){let r=n/(2*t),i=e[0].getX()-e[2].getX(),s=e[0].getY()-e[2].getY(),o=(e[0].getX()+e[2].getX())/2,a=(e[0].getY()+e[2].getY())/2,l=new q(o+r*i,a+r*s),d=new q(o-r*i,a-r*s);i=e[1].getX()-e[3].getX(),s=e[1].getY()-e[3].getY(),o=(e[1].getX()+e[3].getX())/2,a=(e[1].getY()+e[3].getY())/2;let A=new q(o+r*i,a+r*s),E=new q(o-r*i,a-r*s);return[l,A,d,E]}isValid(e,t){return e>=0&&e<this.image.getWidth()&&t>0&&t<this.image.getHeight()}isValidPoint(e){let t=we.round(e.getX()),n=we.round(e.getY());return this.isValid(t,n)}distancePoint(e,t){return we.distance(e.getX(),e.getY(),t.getX(),t.getY())}distanceResultPoint(e,t){return we.distance(e.getX(),e.getY(),t.getX(),t.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(ne.truncDivision(this.nbLayers-4,8)+1)+15}}class O{decode(e,t=null){let n=null,r=new T(e.getBlackMatrix()),i=null,s=null;try{let d=r.detectMirror(!1);i=d.getPoints(),this.reportFoundResultPoints(t,i),s=new Re().decode(d)}catch(d){n=d}if(s==null)try{let d=r.detectMirror(!0);i=d.getPoints(),this.reportFoundResultPoints(t,i),s=new Re().decode(d)}catch(d){throw n??d}let o=new qe(s.getText(),s.getRawBytes(),s.getNumBits(),i,$.AZTEC,he.currentTimeMillis()),a=s.getByteSegments();a!=null&&o.putMetadata(Fe.BYTE_SEGMENTS,a);let l=s.getECLevel();return l!=null&&o.putMetadata(Fe.ERROR_CORRECTION_LEVEL,l),o}reportFoundResultPoints(e,t){if(e!=null){let n=e.get(me.NEED_RESULT_POINT_CALLBACK);n!=null&&t.forEach((r,i,s)=>{n.foundPossibleResultPoint(r)})}}reset(){}}class v extends Lt{constructor(e=500){super(new O,e)}}class U{decode(e,t){try{return this.doDecode(e,t)}catch{if(t&&t.get(me.TRY_HARDER)===!0&&e.isRotateSupported()){const i=e.rotateCounterClockwise(),s=this.doDecode(i,t),o=s.getResultMetadata();let a=270;o!==null&&o.get(Fe.ORIENTATION)===!0&&(a=a+o.get(Fe.ORIENTATION)%360),s.putMetadata(Fe.ORIENTATION,a);const l=s.getResultPoints();if(l!==null){const d=i.getHeight();for(let A=0;A<l.length;A++)l[A]=new q(d-l[A].getY()-1,l[A].getX())}return s}else throw new V}}reset(){}doDecode(e,t){const n=e.getWidth(),r=e.getHeight();let i=new Ee(n);const s=t&&t.get(me.TRY_HARDER)===!0,o=Math.max(1,r>>(s?8:5));let a;s?a=r:a=15;const l=Math.trunc(r/2);for(let d=0;d<a;d++){const A=Math.trunc((d+1)/2),E=(d&1)===0,b=l+o*(E?A:-A);if(b<0||b>=r)break;try{i=e.getBlackRow(b,i)}catch{continue}for(let N=0;N<2;N++){if(N===1&&(i.reverse(),t&&t.get(me.NEED_RESULT_POINT_CALLBACK)===!0)){const R=new Map;t.forEach((B,L)=>R.set(L,B)),R.delete(me.NEED_RESULT_POINT_CALLBACK),t=R}try{const R=this.decodeRow(b,i,t);if(N===1){R.putMetadata(Fe.ORIENTATION,180);const B=R.getResultPoints();B!==null&&(B[0]=new q(n-B[0].getX()-1,B[0].getY()),B[1]=new q(n-B[1].getX()-1,B[1].getY()))}return R}catch{}}}throw new V}static recordPattern(e,t,n){const r=n.length;for(let l=0;l<r;l++)n[l]=0;const i=e.getSize();if(t>=i)throw new V;let s=!e.get(t),o=0,a=t;for(;a<i;){if(e.get(a)!==s)n[o]++;else{if(++o===r)break;n[o]=1,s=!s}a++}if(!(o===r||o===r-1&&a===i))throw new V}static recordPatternInReverse(e,t,n){let r=n.length,i=e.get(t);for(;t>0&&r>=0;)e.get(--t)!==i&&(r--,i=!i);if(r>=0)throw new V;U.recordPattern(e,t+1,n)}static patternMatchVariance(e,t,n){const r=e.length;let i=0,s=0;for(let l=0;l<r;l++)i+=e[l],s+=t[l];if(i<s)return Number.POSITIVE_INFINITY;const o=i/s;n*=o;let a=0;for(let l=0;l<r;l++){const d=e[l],A=t[l]*o,E=d>A?d-A:A-d;if(E>n)return Number.POSITIVE_INFINITY;a+=E}return a/i}}class G extends U{static findStartPattern(e){const t=e.getSize(),n=e.getNextSet(0);let r=0,i=Int32Array.from([0,0,0,0,0,0]),s=n,o=!1;const a=6;for(let l=n;l<t;l++)if(e.get(l)!==o)i[r]++;else{if(r===a-1){let d=G.MAX_AVG_VARIANCE,A=-1;for(let E=G.CODE_START_A;E<=G.CODE_START_C;E++){const b=U.patternMatchVariance(i,G.CODE_PATTERNS[E],G.MAX_INDIVIDUAL_VARIANCE);b<d&&(d=b,A=E)}if(A>=0&&e.isRange(Math.max(0,s-(l-s)/2),s,!1))return Int32Array.from([s,l,A]);s+=i[0]+i[1],i=i.slice(2,i.length-1),i[r-1]=0,i[r]=0,r--}else r++;i[r]=1,o=!o}throw new V}static decodeCode(e,t,n){U.recordPattern(e,n,t);let r=G.MAX_AVG_VARIANCE,i=-1;for(let s=0;s<G.CODE_PATTERNS.length;s++){const o=G.CODE_PATTERNS[s],a=this.patternMatchVariance(t,o,G.MAX_INDIVIDUAL_VARIANCE);a<r&&(r=a,i=s)}if(i>=0)return i;throw new V}decodeRow(e,t,n){const r=n&&n.get(me.ASSUME_GS1)===!0,i=G.findStartPattern(t),s=i[2];let o=0;const a=new Uint8Array(20);a[o++]=s;let l;switch(s){case G.CODE_START_A:l=G.CODE_CODE_A;break;case G.CODE_START_B:l=G.CODE_CODE_B;break;case G.CODE_START_C:l=G.CODE_CODE_C;break;default:throw new Z}let d=!1,A=!1,E="",b=i[0],N=i[1];const R=Int32Array.from([0,0,0,0,0,0]);let B=0,L=0,X=s,Y=0,H=!0,ge=!1,ue=!1;for(;!d;){const Rn=A;switch(A=!1,B=L,L=G.decodeCode(t,R,N),a[o++]=L,L!==G.CODE_STOP&&(H=!0),L!==G.CODE_STOP&&(Y++,X+=Y*L),b=N,N+=R.reduce((fo,xo)=>fo+xo,0),L){case G.CODE_START_A:case G.CODE_START_B:case G.CODE_START_C:throw new Z}switch(l){case G.CODE_CODE_A:if(L<64)ue===ge?E+=String.fromCharCode(32+L):E+=String.fromCharCode(32+L+128),ue=!1;else if(L<96)ue===ge?E+=String.fromCharCode(L-64):E+=String.fromCharCode(L+64),ue=!1;else switch(L!==G.CODE_STOP&&(H=!1),L){case G.CODE_FNC_1:r&&(E.length===0?E+="]C1":E+="");break;case G.CODE_FNC_2:case G.CODE_FNC_3:break;case G.CODE_FNC_4_A:!ge&&ue?(ge=!0,ue=!1):ge&&ue?(ge=!1,ue=!1):ue=!0;break;case G.CODE_SHIFT:A=!0,l=G.CODE_CODE_B;break;case G.CODE_CODE_B:l=G.CODE_CODE_B;break;case G.CODE_CODE_C:l=G.CODE_CODE_C;break;case G.CODE_STOP:d=!0;break}break;case G.CODE_CODE_B:if(L<96)ue===ge?E+=String.fromCharCode(32+L):E+=String.fromCharCode(32+L+128),ue=!1;else switch(L!==G.CODE_STOP&&(H=!1),L){case G.CODE_FNC_1:r&&(E.length===0?E+="]C1":E+="");break;case G.CODE_FNC_2:case G.CODE_FNC_3:break;case G.CODE_FNC_4_B:!ge&&ue?(ge=!0,ue=!1):ge&&ue?(ge=!1,ue=!1):ue=!0;break;case G.CODE_SHIFT:A=!0,l=G.CODE_CODE_A;break;case G.CODE_CODE_A:l=G.CODE_CODE_A;break;case G.CODE_CODE_C:l=G.CODE_CODE_C;break;case G.CODE_STOP:d=!0;break}break;case G.CODE_CODE_C:if(L<100)L<10&&(E+="0"),E+=L;else switch(L!==G.CODE_STOP&&(H=!1),L){case G.CODE_FNC_1:r&&(E.length===0?E+="]C1":E+="");break;case G.CODE_CODE_A:l=G.CODE_CODE_A;break;case G.CODE_CODE_B:l=G.CODE_CODE_B;break;case G.CODE_STOP:d=!0;break}break}Rn&&(l=l===G.CODE_CODE_A?G.CODE_CODE_B:G.CODE_CODE_A)}const ft=N-b;if(N=t.getNextUnset(N),!t.isRange(N,Math.min(t.getSize(),N+(N-b)/2),!1))throw new V;if(X-=Y*B,X%103!==B)throw new Q;const Bt=E.length;if(Bt===0)throw new V;Bt>0&&H&&(l===G.CODE_CODE_C?E=E.substring(0,Bt-2):E=E.substring(0,Bt-1));const dt=(i[1]+i[0])/2,De=b+ft/2,tt=a.length,At=new Uint8Array(tt);for(let Rn=0;Rn<tt;Rn++)At[Rn]=a[Rn];const Nn=[new q(dt,e),new q(De,e)];return new qe(E,At,0,Nn,$.CODE_128,new Date().getTime())}}G.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],G.MAX_AVG_VARIANCE=.25,G.MAX_INDIVIDUAL_VARIANCE=.7,G.CODE_SHIFT=98,G.CODE_CODE_C=99,G.CODE_CODE_B=100,G.CODE_CODE_A=101,G.CODE_FNC_1=102,G.CODE_FNC_2=97,G.CODE_FNC_3=96,G.CODE_FNC_4_A=101,G.CODE_FNC_4_B=100,G.CODE_START_A=103,G.CODE_START_B=104,G.CODE_START_C=105,G.CODE_STOP=106;class ce extends U{constructor(e=!1,t=!1){super(),this.usingCheckDigit=e,this.extendedMode=t,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(e,t,n){let r=this.counters;r.fill(0),this.decodeRowResult="";let i=ce.findAsteriskPattern(t,r),s=t.getNextSet(i[1]),o=t.getSize(),a,l;do{ce.recordPattern(t,s,r);let R=ce.toNarrowWidePattern(r);if(R<0)throw new V;a=ce.patternToChar(R),this.decodeRowResult+=a,l=s;for(let B of r)s+=B;s=t.getNextSet(s)}while(a!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let d=0;for(let R of r)d+=R;let A=s-l-d;if(s!==o&&A*2<d)throw new V;if(this.usingCheckDigit){let R=this.decodeRowResult.length-1,B=0;for(let L=0;L<R;L++)B+=ce.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(L));if(this.decodeRowResult.charAt(R)!==ce.ALPHABET_STRING.charAt(B%43))throw new Q;this.decodeRowResult=this.decodeRowResult.substring(0,R)}if(this.decodeRowResult.length===0)throw new V;let E;this.extendedMode?E=ce.decodeExtended(this.decodeRowResult):E=this.decodeRowResult;let b=(i[1]+i[0])/2,N=l+d/2;return new qe(E,null,0,[new q(b,e),new q(N,e)],$.CODE_39,new Date().getTime())}static findAsteriskPattern(e,t){let n=e.getSize(),r=e.getNextSet(0),i=0,s=r,o=!1,a=t.length;for(let l=r;l<n;l++)if(e.get(l)!==o)t[i]++;else{if(i===a-1){if(this.toNarrowWidePattern(t)===ce.ASTERISK_ENCODING&&e.isRange(Math.max(0,s-Math.floor((l-s)/2)),s,!1))return[s,l];s+=t[0]+t[1],t.copyWithin(0,2,2+i-1),t[i-1]=0,t[i]=0,i--}else i++;t[i]=1,o=!o}throw new V}static toNarrowWidePattern(e){let t=e.length,n=0,r;do{let i=2147483647;for(let a of e)a<i&&a>n&&(i=a);n=i,r=0;let s=0,o=0;for(let a=0;a<t;a++){let l=e[a];l>n&&(o|=1<<t-1-a,r++,s+=l)}if(r===3){for(let a=0;a<t&&r>0;a++){let l=e[a];if(l>n&&(r--,l*2>=s))return-1}return o}}while(r>3);return-1}static patternToChar(e){for(let t=0;t<ce.CHARACTER_ENCODINGS.length;t++)if(ce.CHARACTER_ENCODINGS[t]===e)return ce.ALPHABET_STRING.charAt(t);if(e===ce.ASTERISK_ENCODING)return"*";throw new V}static decodeExtended(e){let t=e.length,n="";for(let r=0;r<t;r++){let i=e.charAt(r);if(i==="+"||i==="$"||i==="%"||i==="/"){let s=e.charAt(r+1),o="\0";switch(i){case"+":if(s>="A"&&s<="Z")o=String.fromCharCode(s.charCodeAt(0)+32);else throw new Z;break;case"$":if(s>="A"&&s<="Z")o=String.fromCharCode(s.charCodeAt(0)-64);else throw new Z;break;case"%":if(s>="A"&&s<="E")o=String.fromCharCode(s.charCodeAt(0)-38);else if(s>="F"&&s<="J")o=String.fromCharCode(s.charCodeAt(0)-11);else if(s>="K"&&s<="O")o=String.fromCharCode(s.charCodeAt(0)+16);else if(s>="P"&&s<="T")o=String.fromCharCode(s.charCodeAt(0)+43);else if(s==="U")o="\0";else if(s==="V")o="@";else if(s==="W")o="`";else if(s==="X"||s==="Y"||s==="Z")o="";else throw new Z;break;case"/":if(s>="A"&&s<="O")o=String.fromCharCode(s.charCodeAt(0)-32);else if(s==="Z")o=":";else throw new Z;break}n+=o,r++}else n+=i}return n}}ce.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",ce.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],ce.ASTERISK_ENCODING=148;class te extends U{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,t,n){let r=this.decodeStart(t),i=this.decodeEnd(t),s=new Te;te.decodeMiddle(t,r[1],i[0],s);let o=s.toString(),a=null;n!=null&&(a=n.get(me.ALLOWED_LENGTHS)),a==null&&(a=te.DEFAULT_ALLOWED_LENGTHS);let l=o.length,d=!1,A=0;for(let N of a){if(l===N){d=!0;break}N>A&&(A=N)}if(!d&&l>A&&(d=!0),!d)throw new Z;const E=[new q(r[1],e),new q(i[0],e)];return new qe(o,null,0,E,$.ITF,new Date().getTime())}static decodeMiddle(e,t,n,r){let i=new Int32Array(10),s=new Int32Array(5),o=new Int32Array(5);for(i.fill(0),s.fill(0),o.fill(0);t<n;){U.recordPattern(e,t,i);for(let l=0;l<5;l++){let d=2*l;s[l]=i[d],o[l]=i[d+1]}let a=te.decodeDigit(s);r.append(a.toString()),a=this.decodeDigit(o),r.append(a.toString()),i.forEach(function(l){t+=l})}}decodeStart(e){let t=te.skipWhiteSpace(e),n=te.findGuardPattern(e,t,te.START_PATTERN);return this.narrowLineWidth=(n[1]-n[0])/4,this.validateQuietZone(e,n[0]),n}validateQuietZone(e,t){let n=this.narrowLineWidth*10;n=n<t?n:t;for(let r=t-1;n>0&&r>=0&&!e.get(r);r--)n--;if(n!==0)throw new V}static skipWhiteSpace(e){const t=e.getSize(),n=e.getNextSet(0);if(n===t)throw new V;return n}decodeEnd(e){e.reverse();try{let t=te.skipWhiteSpace(e),n;try{n=te.findGuardPattern(e,t,te.END_PATTERN_REVERSED[0])}catch(i){i instanceof V&&(n=te.findGuardPattern(e,t,te.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,n[0]);let r=n[0];return n[0]=e.getSize()-n[1],n[1]=e.getSize()-r,n}finally{e.reverse()}}static findGuardPattern(e,t,n){let r=n.length,i=new Int32Array(r),s=e.getSize(),o=!1,a=0,l=t;i.fill(0);for(let d=t;d<s;d++)if(e.get(d)!==o)i[a]++;else{if(a===r-1){if(U.patternMatchVariance(i,n,te.MAX_INDIVIDUAL_VARIANCE)<te.MAX_AVG_VARIANCE)return[l,d];l+=i[0]+i[1],he.arraycopy(i,2,i,0,a-1),i[a-1]=0,i[a]=0,a--}else a++;i[a]=1,o=!o}throw new V}static decodeDigit(e){let t=te.MAX_AVG_VARIANCE,n=-1,r=te.PATTERNS.length;for(let i=0;i<r;i++){let s=te.PATTERNS[i],o=U.patternMatchVariance(e,s,te.MAX_INDIVIDUAL_VARIANCE);o<t?(t=o,n=i):o===t&&(n=-1)}if(n>=0)return n%10;throw new V}}te.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],te.MAX_AVG_VARIANCE=.38,te.MAX_INDIVIDUAL_VARIANCE=.5,te.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],te.START_PATTERN=Int32Array.from([1,1,1,1]),te.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class oe extends U{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let t=!1,n,r=0,i=Int32Array.from([0,0,0]);for(;!t;){i=Int32Array.from([0,0,0]),n=oe.findGuardPattern(e,r,!1,this.START_END_PATTERN,i);let s=n[0];r=n[1];let o=s-(r-s);o>=0&&(t=e.isRange(o,s,!1))}return n}static checkChecksum(e){return oe.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return oe.getStandardUPCEANChecksum(e.substring(0,t-1))===n}static getStandardUPCEANChecksum(e){let t=e.length,n=0;for(let r=t-1;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new Z;n+=i}n*=3;for(let r=t-2;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new Z;n+=i}return(1e3-n)%10}static decodeEnd(e,t){return oe.findGuardPattern(e,t,!1,oe.START_END_PATTERN,new Int32Array(oe.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,t,n,r){return this.findGuardPattern(e,t,n,r,new Int32Array(r.length))}static findGuardPattern(e,t,n,r,i){let s=e.getSize();t=n?e.getNextUnset(t):e.getNextSet(t);let o=0,a=t,l=r.length,d=n;for(let A=t;A<s;A++)if(e.get(A)!==d)i[o]++;else{if(o===l-1){if(U.patternMatchVariance(i,r,oe.MAX_INDIVIDUAL_VARIANCE)<oe.MAX_AVG_VARIANCE)return Int32Array.from([a,A]);a+=i[0]+i[1];let E=i.slice(2,i.length-1);for(let b=0;b<o-1;b++)i[b]=E[b];i[o-1]=0,i[o]=0,o--}else o++;i[o]=1,d=!d}throw new V}static decodeDigit(e,t,n,r){this.recordPattern(e,n,t);let i=this.MAX_AVG_VARIANCE,s=-1,o=r.length;for(let a=0;a<o;a++){let l=r[a],d=U.patternMatchVariance(t,l,oe.MAX_INDIVIDUAL_VARIANCE);d<i&&(i=d,s=a)}if(s>=0)return s;throw new V}}oe.MAX_AVG_VARIANCE=.48,oe.MAX_INDIVIDUAL_VARIANCE=.7,oe.START_END_PATTERN=Int32Array.from([1,1,1]),oe.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),oe.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),oe.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class Ce{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,n){let r=this.decodeRowStringBuffer,i=this.decodeMiddle(t,n,r),s=r.toString(),o=Ce.parseExtensionString(s),a=[new q((n[0]+n[1])/2,e),new q(i,e)],l=new qe(s,null,0,a,$.UPC_EAN_EXTENSION,new Date().getTime());return o!=null&&l.putAllMetadata(o),l}decodeMiddle(e,t,n){let r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1],o=0;for(let l=0;l<5&&s<i;l++){let d=oe.decodeDigit(e,r,s,oe.L_AND_G_PATTERNS);n+=String.fromCharCode(48+d%10);for(let A of r)s+=A;d>=10&&(o|=1<<4-l),l!==4&&(s=e.getNextSet(s),s=e.getNextUnset(s))}if(n.length!==5)throw new V;let a=this.determineCheckDigit(o);if(Ce.extensionChecksum(n.toString())!==a)throw new V;return s}static extensionChecksum(e){let t=e.length,n=0;for(let r=t-2;r>=0;r-=2)n+=e.charAt(r).charCodeAt(0)-48;n*=3;for(let r=t-1;r>=0;r-=2)n+=e.charAt(r).charCodeAt(0)-48;return n*=3,n%10}determineCheckDigit(e){for(let t=0;t<10;t++)if(e===this.CHECK_DIGIT_ENCODINGS[t])return t;throw new V}static parseExtensionString(e){if(e.length!==5)return null;let t=Ce.parseExtension5String(e);return t==null?null:new Map([[Fe.SUGGESTED_PRICE,t]])}static parseExtension5String(e){let t;switch(e.charAt(0)){case"0":t="£";break;case"5":t="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}t="";break;default:t="";break}let n=parseInt(e.substring(1)),r=(n/100).toString(),i=n%100,s=i<10?"0"+i:i.toString();return t+r+"."+s}}class pr{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,n){let r=this.decodeRowStringBuffer,i=this.decodeMiddle(t,n,r),s=r.toString(),o=pr.parseExtensionString(s),a=[new q((n[0]+n[1])/2,e),new q(i,e)],l=new qe(s,null,0,a,$.UPC_EAN_EXTENSION,new Date().getTime());return o!=null&&l.putAllMetadata(o),l}decodeMiddle(e,t,n){let r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1],o=0;for(let a=0;a<2&&s<i;a++){let l=oe.decodeDigit(e,r,s,oe.L_AND_G_PATTERNS);n+=String.fromCharCode(48+l%10);for(let d of r)s+=d;l>=10&&(o|=1<<1-a),a!==1&&(s=e.getNextSet(s),s=e.getNextUnset(s))}if(n.length!==2)throw new V;if(parseInt(n.toString())%4!==o)throw new V;return s}static parseExtensionString(e){return e.length!==2?null:new Map([[Fe.ISSUE_NUMBER,parseInt(e)]])}}class xi{static decodeRow(e,t,n){let r=oe.findGuardPattern(t,n,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new Ce().decodeRow(e,t,r)}catch{return new pr().decodeRow(e,t,r)}}}xi.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class ye extends oe{constructor(){super(),this.decodeRowStringBuffer="",ye.L_AND_G_PATTERNS=ye.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let t=ye.L_PATTERNS[e-10],n=new Int32Array(t.length);for(let r=0;r<t.length;r++)n[r]=t[t.length-r-1];ye.L_AND_G_PATTERNS[e]=n}}decodeRow(e,t,n){let r=ye.findStartGuardPattern(t),i=n==null?null:n.get(me.NEED_RESULT_POINT_CALLBACK);if(i!=null){const H=new q((r[0]+r[1])/2,e);i.foundPossibleResultPoint(H)}let s=this.decodeMiddle(t,r,this.decodeRowStringBuffer),o=s.rowOffset,a=s.resultString;if(i!=null){const H=new q(o,e);i.foundPossibleResultPoint(H)}let l=this.decodeEnd(t,o);if(i!=null){const H=new q((l[0]+l[1])/2,e);i.foundPossibleResultPoint(H)}let d=l[1],A=d+(d-l[0]);if(A>=t.getSize()||!t.isRange(d,A,!1))throw new V;let E=a.toString();if(E.length<8)throw new Z;if(!ye.checkChecksum(E))throw new Q;let b=(r[1]+r[0])/2,N=(l[1]+l[0])/2,R=this.getBarcodeFormat(),B=[new q(b,e),new q(N,e)],L=new qe(E,null,0,B,R,new Date().getTime()),X=0;try{let H=xi.decodeRow(e,t,l[1]);L.putMetadata(Fe.UPC_EAN_EXTENSION,H.getText()),L.putAllMetadata(H.getResultMetadata()),L.addResultPoints(H.getResultPoints()),X=H.getText().length}catch{}let Y=n==null?null:n.get(me.ALLOWED_EAN_EXTENSIONS);if(Y!=null){let H=!1;for(let ge in Y)if(X.toString()===ge){H=!0;break}if(!H)throw new V}return L}decodeEnd(e,t){return ye.findGuardPattern(e,t,!1,ye.START_END_PATTERN,new Int32Array(ye.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return ye.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return ye.getStandardUPCEANChecksum(e.substring(0,t-1))===n}static getStandardUPCEANChecksum(e){let t=e.length,n=0;for(let r=t-1;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new Z;n+=i}n*=3;for(let r=t-2;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new Z;n+=i}return(1e3-n)%10}}class on extends ye{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,n){let r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1],o=0;for(let l=0;l<6&&s<i;l++){let d=ye.decodeDigit(e,r,s,ye.L_AND_G_PATTERNS);n+=String.fromCharCode(48+d%10);for(let A of r)s+=A;d>=10&&(o|=1<<5-l)}n=on.determineFirstDigit(n,o),s=ye.findGuardPattern(e,s,!0,ye.MIDDLE_PATTERN,new Int32Array(ye.MIDDLE_PATTERN.length).fill(0))[1];for(let l=0;l<6&&s<i;l++){let d=ye.decodeDigit(e,r,s,ye.L_PATTERNS);n+=String.fromCharCode(48+d);for(let A of r)s+=A}return{rowOffset:s,resultString:n}}getBarcodeFormat(){return $.EAN_13}static determineFirstDigit(e,t){for(let n=0;n<10;n++)if(t===this.FIRST_DIGIT_ENCODINGS[n])return e=String.fromCharCode(48+n)+e,e;throw new V}}on.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class gi extends ye{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,n){const r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1];for(let a=0;a<4&&s<i;a++){let l=ye.decodeDigit(e,r,s,ye.L_PATTERNS);n+=String.fromCharCode(48+l);for(let d of r)s+=d}s=ye.findGuardPattern(e,s,!0,ye.MIDDLE_PATTERN,new Int32Array(ye.MIDDLE_PATTERN.length).fill(0))[1];for(let a=0;a<4&&s<i;a++){let l=ye.decodeDigit(e,r,s,ye.L_PATTERNS);n+=String.fromCharCode(48+l);for(let d of r)s+=d}return{rowOffset:s,resultString:n}}getBarcodeFormat(){return $.EAN_8}}class wi extends ye{constructor(){super(...arguments),this.ean13Reader=new on}getBarcodeFormat(){return $.UPC_A}decode(e,t){return this.maybeReturnResult(this.ean13Reader.decode(e))}decodeRow(e,t,n){return this.maybeReturnResult(this.ean13Reader.decodeRow(e,t,n))}decodeMiddle(e,t,n){return this.ean13Reader.decodeMiddle(e,t,n)}maybeReturnResult(e){let t=e.getText();if(t.charAt(0)==="0"){let n=new qe(t.substring(1),null,null,e.getResultPoints(),$.UPC_A);return e.getResultMetadata()!=null&&n.putAllMetadata(e.getResultMetadata()),n}else throw new V}reset(){this.ean13Reader.reset()}}class Ot extends ye{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(e,t,n){const r=this.decodeMiddleCounters.map(l=>l);r[0]=0,r[1]=0,r[2]=0,r[3]=0;const i=e.getSize();let s=t[1],o=0;for(let l=0;l<6&&s<i;l++){const d=Ot.decodeDigit(e,r,s,Ot.L_AND_G_PATTERNS);n+=String.fromCharCode(48+d%10);for(let A of r)s+=A;d>=10&&(o|=1<<5-l)}let a=Ot.determineNumSysAndCheckDigit(n,o);return{rowOffset:s,resultString:a}}decodeEnd(e,t){return Ot.findGuardPatternWithoutCounters(e,t,!0,Ot.MIDDLE_END_PATTERN)}checkChecksum(e){return ye.checkChecksum(Ot.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,t){for(let n=0;n<=1;n++)for(let r=0;r<10;r++)if(t===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[n][r]){let i=String.fromCharCode(48+n),s=String.fromCharCode(48+r);return i+e+s}throw V.getNotFoundInstance()}getBarcodeFormat(){return $.UPC_E}static convertUPCEtoUPCA(e){const t=e.slice(1,7).split("").map(i=>i.charCodeAt(0)),n=new Te;n.append(e.charAt(0));let r=t[5];switch(r){case 0:case 1:case 2:n.appendChars(t,0,2),n.append(r),n.append("0000"),n.appendChars(t,2,3);break;case 3:n.appendChars(t,0,3),n.append("00000"),n.appendChars(t,3,2);break;case 4:n.appendChars(t,0,4),n.append("00000"),n.append(t[4]);break;default:n.appendChars(t,0,5),n.append("0000"),n.append(r);break}return e.length>=8&&n.append(e.charAt(7)),n.toString()}}Ot.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Ot.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class mr extends U{constructor(e){super();let t=e==null?null:e.get(me.POSSIBLE_FORMATS),n=[];m(t)?(n.push(new on),n.push(new wi),n.push(new gi),n.push(new Ot)):(t.indexOf($.EAN_13)>-1&&n.push(new on),t.indexOf($.UPC_A)>-1&&n.push(new wi),t.indexOf($.EAN_8)>-1&&n.push(new gi),t.indexOf($.UPC_E)>-1&&n.push(new Ot)),this.readers=n}decodeRow(e,t,n){for(let r of this.readers)try{const i=r.decodeRow(e,t,n),s=i.getBarcodeFormat()===$.EAN_13&&i.getText().charAt(0)==="0",o=n==null?null:n.get(me.POSSIBLE_FORMATS),a=o==null||o.includes($.UPC_A);if(s&&a){const l=i.getRawBytes(),d=new qe(i.getText().substring(1),l,l?l.length:null,i.getResultPoints(),$.UPC_A);return d.putAllMetadata(i.getResultMetadata()),d}return i}catch{}throw new V}reset(){for(let e of this.readers)e.reset()}}class st extends U{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,t){for(let n=0;n<t.length;n++)if(U.patternMatchVariance(e,t[n],st.MAX_INDIVIDUAL_VARIANCE)<st.MAX_AVG_VARIANCE)return n;throw new V}static count(e){return we.sum(new Int32Array(e))}static increment(e,t){let n=0,r=t[0];for(let i=1;i<e.length;i++)t[i]>r&&(r=t[i],n=i);e[n]++}static decrement(e,t){let n=0,r=t[0];for(let i=1;i<e.length;i++)t[i]<r&&(r=t[i],n=i);e[n]--}static isFinderPattern(e){let t=e[0]+e[1],n=t+e[2]+e[3],r=t/n;if(r>=st.MIN_FINDER_PATTERN_RATIO&&r<=st.MAX_FINDER_PATTERN_RATIO){let i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let o of e)o>s&&(s=o),o<i&&(i=o);return s<10*i}return!1}}st.MAX_AVG_VARIANCE=.2,st.MAX_INDIVIDUAL_VARIANCE=.45,st.MIN_FINDER_PATTERN_RATIO=9.5/12,st.MAX_FINDER_PATTERN_RATIO=12.5/14;class mn{constructor(e,t){this.value=e,this.checksumPortion=t}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(e){if(!(e instanceof mn))return!1;const t=e;return this.value===t.value&&this.checksumPortion===t.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class qn{constructor(e,t,n,r,i){this.value=e,this.startEnd=t,this.value=e,this.startEnd=t,this.resultPoints=new Array,this.resultPoints.push(new q(n,i)),this.resultPoints.push(new q(r,i))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(e){if(!(e instanceof qn))return!1;const t=e;return this.value===t.value}hashCode(){return this.value}}class Pt{constructor(){}static getRSSvalue(e,t,n){let r=0;for(let a of e)r+=a;let i=0,s=0,o=e.length;for(let a=0;a<o-1;a++){let l;for(l=1,s|=1<<a;l<e[a];l++,s&=~(1<<a)){let d=Pt.combins(r-l-1,o-a-2);if(n&&s===0&&r-l-(o-a-1)>=o-a-1&&(d-=Pt.combins(r-l-(o-a),o-a-2)),o-a-1>1){let A=0;for(let E=r-l-(o-a-2);E>t;E--)A+=Pt.combins(r-l-E-1,o-a-3);d-=A*(o-1-a)}else r-l>t&&d--;i+=d}r-=l}return i}static combins(e,t){let n,r;e-t>t?(r=t,n=e-t):(r=e-t,n=t);let i=1,s=1;for(let o=e;o>n;o--)i*=o,s<=r&&(i/=s,s++);for(;s<=r;)i/=s,s++;return i}}class ks{static buildBitArray(e){let t=e.length*2-1;e[e.length-1].getRightChar()==null&&(t-=1);let n=12*t,r=new Ee(n),i=0,o=e[0].getRightChar().getValue();for(let a=11;a>=0;--a)o&1<<a&&r.set(i),i++;for(let a=1;a<e.length;++a){let l=e[a],d=l.getLeftChar().getValue();for(let A=11;A>=0;--A)d&1<<A&&r.set(i),i++;if(l.getRightChar()!=null){let A=l.getRightChar().getValue();for(let E=11;E>=0;--E)A&1<<E&&r.set(i),i++}}return r}}class an{constructor(e,t){t?this.decodedInformation=null:(this.finished=e,this.decodedInformation=t)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class Ir{constructor(e){this.newPosition=e}getNewPosition(){return this.newPosition}}class ct extends Ir{constructor(e,t){super(e),this.value=t}getValue(){return this.value}isFNC1(){return this.value===ct.FNC1}}ct.FNC1="$";class ln extends Ir{constructor(e,t,n){super(e),n?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=t}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class Tt extends Ir{constructor(e,t,n){if(super(e),t<0||t>10||n<0||n>10)throw new Z;this.firstDigit=t,this.secondDigit=n}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===Tt.FNC1}isSecondDigitFNC1(){return this.secondDigit===Tt.FNC1}isAnyFNC1(){return this.firstDigit===Tt.FNC1||this.secondDigit===Tt.FNC1}}Tt.FNC1=10;class K{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new V;let t=e.substring(0,2);for(let i of K.TWO_DIGIT_DATA_LENGTH)if(i[0]===t)return i[1]===K.VARIABLE_LENGTH?K.processVariableAI(2,i[2],e):K.processFixedAI(2,i[1],e);if(e.length<3)throw new V;let n=e.substring(0,3);for(let i of K.THREE_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===K.VARIABLE_LENGTH?K.processVariableAI(3,i[2],e):K.processFixedAI(3,i[1],e);for(let i of K.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===K.VARIABLE_LENGTH?K.processVariableAI(4,i[2],e):K.processFixedAI(4,i[1],e);if(e.length<4)throw new V;let r=e.substring(0,4);for(let i of K.FOUR_DIGIT_DATA_LENGTH)if(i[0]===r)return i[1]===K.VARIABLE_LENGTH?K.processVariableAI(4,i[2],e):K.processFixedAI(4,i[1],e);throw new V}static processFixedAI(e,t,n){if(n.length<e)throw new V;let r=n.substring(0,e);if(n.length<e+t)throw new V;let i=n.substring(e,e+t),s=n.substring(e+t),o="("+r+")"+i,a=K.parseFieldsInGeneralPurpose(s);return a==null?o:o+a}static processVariableAI(e,t,n){let r=n.substring(0,e),i;n.length<e+t?i=n.length:i=e+t;let s=n.substring(e,i),o=n.substring(i),a="("+r+")"+s,l=K.parseFieldsInGeneralPurpose(o);return l==null?a:a+l}}K.VARIABLE_LENGTH=[],K.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",K.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",K.VARIABLE_LENGTH,20],["22",K.VARIABLE_LENGTH,29],["30",K.VARIABLE_LENGTH,8],["37",K.VARIABLE_LENGTH,8],["90",K.VARIABLE_LENGTH,30],["91",K.VARIABLE_LENGTH,30],["92",K.VARIABLE_LENGTH,30],["93",K.VARIABLE_LENGTH,30],["94",K.VARIABLE_LENGTH,30],["95",K.VARIABLE_LENGTH,30],["96",K.VARIABLE_LENGTH,30],["97",K.VARIABLE_LENGTH,3],["98",K.VARIABLE_LENGTH,30],["99",K.VARIABLE_LENGTH,30]],K.THREE_DIGIT_DATA_LENGTH=[["240",K.VARIABLE_LENGTH,30],["241",K.VARIABLE_LENGTH,30],["242",K.VARIABLE_LENGTH,6],["250",K.VARIABLE_LENGTH,30],["251",K.VARIABLE_LENGTH,30],["253",K.VARIABLE_LENGTH,17],["254",K.VARIABLE_LENGTH,20],["400",K.VARIABLE_LENGTH,30],["401",K.VARIABLE_LENGTH,30],["402",17],["403",K.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",K.VARIABLE_LENGTH,20],["421",K.VARIABLE_LENGTH,15],["422",3],["423",K.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],K.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",K.VARIABLE_LENGTH,15],["391",K.VARIABLE_LENGTH,18],["392",K.VARIABLE_LENGTH,15],["393",K.VARIABLE_LENGTH,18],["703",K.VARIABLE_LENGTH,30]],K.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",K.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",K.VARIABLE_LENGTH,20],["8003",K.VARIABLE_LENGTH,30],["8004",K.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",K.VARIABLE_LENGTH,30],["8008",K.VARIABLE_LENGTH,12],["8018",18],["8020",K.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",K.VARIABLE_LENGTH,70],["8200",K.VARIABLE_LENGTH,70]];class In{constructor(e){this.buffer=new Te,this.information=e}decodeAllCodes(e,t){let n=t,r=null;do{let i=this.decodeGeneralPurposeField(n,r),s=K.parseFieldsInGeneralPurpose(i.getNewString());if(s!=null&&e.append(s),i.isRemaining()?r=""+i.getRemainingValue():r=null,n===i.getNewPosition())break;n=i.getNewPosition()}while(!0);return e.toString()}isStillNumeric(e){if(e+7>this.information.getSize())return e+4<=this.information.getSize();for(let t=e;t<e+3;++t)if(this.information.get(t))return!0;return this.information.get(e+3)}decodeNumeric(e){if(e+7>this.information.getSize()){let i=this.extractNumericValueFromBitArray(e,4);return i===0?new Tt(this.information.getSize(),Tt.FNC1,Tt.FNC1):new Tt(this.information.getSize(),i-1,Tt.FNC1)}let t=this.extractNumericValueFromBitArray(e,7),n=(t-8)/11,r=(t-8)%11;return new Tt(e+7,n,r)}extractNumericValueFromBitArray(e,t){return In.extractNumericValueFromBitArray(this.information,e,t)}static extractNumericValueFromBitArray(e,t,n){let r=0;for(let i=0;i<n;++i)e.get(t+i)&&(r|=1<<n-i-1);return r}decodeGeneralPurposeField(e,t){this.buffer.setLengthToZero(),t!=null&&this.buffer.append(t),this.current.setPosition(e);let n=this.parseBlocks();return n!=null&&n.isRemaining()?new ln(this.current.getPosition(),this.buffer.toString(),n.getRemainingValue()):new ln(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let e,t;do{let n=this.current.getPosition();if(this.current.isAlpha()?(t=this.parseAlphaBlock(),e=t.isFinished()):this.current.isIsoIec646()?(t=this.parseIsoIec646Block(),e=t.isFinished()):(t=this.parseNumericBlock(),e=t.isFinished()),!(n!==this.current.getPosition())&&!e)break}while(!e);return t.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let e=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFirstDigitFNC1()){let t;return e.isSecondDigitFNC1()?t=new ln(this.current.getPosition(),this.buffer.toString()):t=new ln(this.current.getPosition(),this.buffer.toString(),e.getSecondDigit()),new an(!0,t)}if(this.buffer.append(e.getFirstDigit()),e.isSecondDigitFNC1()){let t=new ln(this.current.getPosition(),this.buffer.toString());return new an(!0,t)}this.buffer.append(e.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new an(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let e=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let t=new ln(this.current.getPosition(),this.buffer.toString());return new an(!0,t)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new an(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let e=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let t=new ln(this.current.getPosition(),this.buffer.toString());return new an(!0,t)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new an(!1)}isStillIsoIec646(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+7>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<116)return!0;if(e+8>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,8);return r>=232&&r<253}decodeIsoIec646(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new ct(e+5,ct.FNC1);if(t>=5&&t<15)return new ct(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<90)return new ct(e+7,""+(n+1));if(n>=90&&n<116)return new ct(e+7,""+(n+7));let r=this.extractNumericValueFromBitArray(e,8),i;switch(r){case 232:i="!";break;case 233:i='"';break;case 234:i="%";break;case 235:i="&";break;case 236:i="'";break;case 237:i="(";break;case 238:i=")";break;case 239:i="*";break;case 240:i="+";break;case 241:i=",";break;case 242:i="-";break;case 243:i=".";break;case 244:i="/";break;case 245:i=":";break;case 246:i=";";break;case 247:i="<";break;case 248:i="=";break;case 249:i=">";break;case 250:i="?";break;case 251:i="_";break;case 252:i=" ";break;default:throw new Z}return new ct(e+8,i)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+6>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,6);return n>=16&&n<63}decodeAlphanumeric(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new ct(e+5,ct.FNC1);if(t>=5&&t<15)return new ct(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,6);if(n>=32&&n<58)return new ct(e+6,""+(n+33));let r;switch(n){case 58:r="*";break;case 59:r=",";break;case 60:r="-";break;case 61:r=".";break;case 62:r="/";break;default:throw new yt("Decoding invalid alphanumeric value: "+n)}return new ct(e+6,r)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<5&&t+e<this.information.getSize();++t)if(t===2){if(!this.information.get(e+2))return!1}else if(this.information.get(e+t))return!1;return!0}isAlphaOr646ToNumericLatch(e){if(e+3>this.information.getSize())return!1;for(let t=e;t<e+3;++t)if(this.information.get(t))return!1;return!0}isNumericToAlphaNumericLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<4&&t+e<this.information.getSize();++t)if(this.information.get(e+t))return!1;return!0}}class yr{constructor(e){this.information=e,this.generalDecoder=new In(e)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class ut extends yr{constructor(e){super(e)}encodeCompressedGtin(e,t){e.append("(01)");let n=e.length();e.append("9"),this.encodeCompressedGtinWithoutAI(e,t,n)}encodeCompressedGtinWithoutAI(e,t,n){for(let r=0;r<4;++r){let i=this.getGeneralDecoder().extractNumericValueFromBitArray(t+10*r,10);i/100===0&&e.append("0"),i/10===0&&e.append("0"),e.append(i)}ut.appendCheckDigit(e,n)}static appendCheckDigit(e,t){let n=0;for(let r=0;r<13;r++){let i=e.charAt(r+t).charCodeAt(0)-48;n+=r&1?i:3*i}n=10-n%10,n===10&&(n=0),e.append(n)}}ut.GTIN_SIZE=40;class yn extends ut{constructor(e){super(e)}parseInformation(){let e=new Te;e.append("(01)");let t=e.length(),n=this.getGeneralDecoder().extractNumericValueFromBitArray(yn.HEADER_SIZE,4);return e.append(n),this.encodeCompressedGtinWithoutAI(e,yn.HEADER_SIZE+4,t),this.getGeneralDecoder().decodeAllCodes(e,yn.HEADER_SIZE+44)}}yn.HEADER_SIZE=4;class Qn extends yr{constructor(e){super(e)}parseInformation(){let e=new Te;return this.getGeneralDecoder().decodeAllCodes(e,Qn.HEADER_SIZE)}}Qn.HEADER_SIZE=5;class Jn extends ut{constructor(e){super(e)}encodeCompressedWeight(e,t,n){let r=this.getGeneralDecoder().extractNumericValueFromBitArray(t,n);this.addWeightCode(e,r);let i=this.checkWeight(r),s=1e5;for(let o=0;o<5;++o)i/s===0&&e.append("0"),s/=10;e.append(i)}}class kt extends Jn{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()!=kt.HEADER_SIZE+Jn.GTIN_SIZE+kt.WEIGHT_SIZE)throw new V;let e=new Te;return this.encodeCompressedGtin(e,kt.HEADER_SIZE),this.encodeCompressedWeight(e,kt.HEADER_SIZE+Jn.GTIN_SIZE,kt.WEIGHT_SIZE),e.toString()}}kt.HEADER_SIZE=5,kt.WEIGHT_SIZE=15;class Us extends kt{constructor(e){super(e)}addWeightCode(e,t){e.append("(3103)")}checkWeight(e){return e}}class Vs extends kt{constructor(e){super(e)}addWeightCode(e,t){t<1e4?e.append("(3202)"):e.append("(3203)")}checkWeight(e){return e<1e4?e:e-1e4}}class Ut extends ut{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<Ut.HEADER_SIZE+ut.GTIN_SIZE)throw new V;let e=new Te;this.encodeCompressedGtin(e,Ut.HEADER_SIZE);let t=this.getGeneralDecoder().extractNumericValueFromBitArray(Ut.HEADER_SIZE+ut.GTIN_SIZE,Ut.LAST_DIGIT_SIZE);e.append("(392"),e.append(t),e.append(")");let n=this.getGeneralDecoder().decodeGeneralPurposeField(Ut.HEADER_SIZE+ut.GTIN_SIZE+Ut.LAST_DIGIT_SIZE,null);return e.append(n.getNewString()),e.toString()}}Ut.HEADER_SIZE=8,Ut.LAST_DIGIT_SIZE=2;class lt extends ut{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<lt.HEADER_SIZE+ut.GTIN_SIZE)throw new V;let e=new Te;this.encodeCompressedGtin(e,lt.HEADER_SIZE);let t=this.getGeneralDecoder().extractNumericValueFromBitArray(lt.HEADER_SIZE+ut.GTIN_SIZE,lt.LAST_DIGIT_SIZE);e.append("(393"),e.append(t),e.append(")");let n=this.getGeneralDecoder().extractNumericValueFromBitArray(lt.HEADER_SIZE+ut.GTIN_SIZE+lt.LAST_DIGIT_SIZE,lt.FIRST_THREE_DIGITS_SIZE);n/100==0&&e.append("0"),n/10==0&&e.append("0"),e.append(n);let r=this.getGeneralDecoder().decodeGeneralPurposeField(lt.HEADER_SIZE+ut.GTIN_SIZE+lt.LAST_DIGIT_SIZE+lt.FIRST_THREE_DIGITS_SIZE,null);return e.append(r.getNewString()),e.toString()}}lt.HEADER_SIZE=8,lt.LAST_DIGIT_SIZE=2,lt.FIRST_THREE_DIGITS_SIZE=10;class ke extends Jn{constructor(e,t,n){super(e),this.dateCode=n,this.firstAIdigits=t}parseInformation(){if(this.getInformation().getSize()!=ke.HEADER_SIZE+ke.GTIN_SIZE+ke.WEIGHT_SIZE+ke.DATE_SIZE)throw new V;let e=new Te;return this.encodeCompressedGtin(e,ke.HEADER_SIZE),this.encodeCompressedWeight(e,ke.HEADER_SIZE+ke.GTIN_SIZE,ke.WEIGHT_SIZE),this.encodeCompressedDate(e,ke.HEADER_SIZE+ke.GTIN_SIZE+ke.WEIGHT_SIZE),e.toString()}encodeCompressedDate(e,t){let n=this.getGeneralDecoder().extractNumericValueFromBitArray(t,ke.DATE_SIZE);if(n==38400)return;e.append("("),e.append(this.dateCode),e.append(")");let r=n%32;n/=32;let i=n%12+1;n/=12;let s=n;s/10==0&&e.append("0"),e.append(s),i/10==0&&e.append("0"),e.append(i),r/10==0&&e.append("0"),e.append(r)}addWeightCode(e,t){e.append("("),e.append(this.firstAIdigits),e.append(t/1e5),e.append(")")}checkWeight(e){return e%1e5}}ke.HEADER_SIZE=8,ke.WEIGHT_SIZE=20,ke.DATE_SIZE=16;function Ai(w){try{if(w.get(1))return new yn(w);if(!w.get(2))return new Qn(w);switch(In.extractNumericValueFromBitArray(w,1,4)){case 4:return new Us(w);case 5:return new Vs(w)}switch(In.extractNumericValueFromBitArray(w,1,5)){case 12:return new Ut(w);case 13:return new lt(w)}switch(In.extractNumericValueFromBitArray(w,1,7)){case 56:return new ke(w,"310","11");case 57:return new ke(w,"320","11");case 58:return new ke(w,"310","13");case 59:return new ke(w,"320","13");case 60:return new ke(w,"310","15");case 61:return new ke(w,"320","15");case 62:return new ke(w,"310","17");case 63:return new ke(w,"320","17")}}catch(e){throw console.log(e),new yt("unknown decoder: "+w)}}class jt{constructor(e,t,n,r){this.leftchar=e,this.rightchar=t,this.finderpattern=n,this.maybeLast=r}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(e,t){return e instanceof jt?jt.equalsOrNull(e.leftchar,t.leftchar)&&jt.equalsOrNull(e.rightchar,t.rightchar)&&jt.equalsOrNull(e.finderpattern,t.finderpattern):!1}static equalsOrNull(e,t){return e===null?t===null:jt.equals(e,t)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class br{constructor(e,t,n){this.pairs=e,this.rowNumber=t,this.wasReversed=n}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(e){return this.checkEqualitity(this,e)}toString(){return"{ "+this.pairs+" }"}equals(e,t){return e instanceof br?this.checkEqualitity(e,t)&&e.wasReversed===t.wasReversed:!1}checkEqualitity(e,t){if(!e||!t)return;let n;return e.forEach((r,i)=>{t.forEach(s=>{r.getLeftChar().getValue()===s.getLeftChar().getValue()&&r.getRightChar().getValue()===s.getRightChar().getValue()&&r.getFinderPatter().getValue()===s.getFinderPatter().getValue()&&(n=!0)})}),n}}class W extends st{constructor(e){super(...arguments),this.pairs=new Array(W.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=e===!0}decodeRow(e,t,n){this.pairs.length=0,this.startFromEven=!1;try{return W.constructResult(this.decodeRow2pairs(e,t))}catch(r){this.verbose&&console.log(r)}return this.pairs.length=0,this.startFromEven=!0,W.constructResult(this.decodeRow2pairs(e,t))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,t){let n=!1;for(;!n;)try{this.pairs.push(this.retrieveNextPair(t,this.pairs,e))}catch(i){if(i instanceof V){if(!this.pairs.length)throw new V;n=!0}}if(this.checkChecksum())return this.pairs;let r;if(this.rows.length?r=!0:r=!1,this.storeRow(e,!1),r){let i=this.checkRowsBoolean(!1);if(i!=null||(i=this.checkRowsBoolean(!0),i!=null))return i}throw new V}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let t=null;try{t=this.checkRows(new Array,0)}catch(n){this.verbose&&console.log(n)}return e&&(this.rows=this.rows.reverse()),t}checkRows(e,t){for(let n=t;n<this.rows.length;n++){let r=this.rows[n];this.pairs.length=0;for(let s of e)this.pairs.push(s.getPairs());if(this.pairs.push(r.getPairs()),!W.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let i=new Array(e);i.push(r);try{return this.checkRows(i,n+1)}catch(s){this.verbose&&console.log(s)}}throw new V}static isValidSequence(e){for(let t of W.FINDER_PATTERN_SEQUENCES){if(e.length>t.length)continue;let n=!0;for(let r=0;r<e.length;r++)if(e[r].getFinderPattern().getValue()!=t[r]){n=!1;break}if(n)return!0}return!1}storeRow(e,t){let n=0,r=!1,i=!1;for(;n<this.rows.length;){let s=this.rows[n];if(s.getRowNumber()>e){i=s.isEquivalent(this.pairs);break}r=s.isEquivalent(this.pairs),n++}i||r||W.isPartialRow(this.pairs,this.rows)||(this.rows.push(n,new br(this.pairs,e,t)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,t){for(let n of t)if(n.getPairs().length!==e.length){for(let r of n.getPairs())for(let i of e)if(jt.equals(r,i))break}}static isPartialRow(e,t){for(let n of t){let r=!0;for(let i of e){let s=!1;for(let o of n.getPairs())if(i.equals(o)){s=!0;break}if(!s){r=!1;break}}if(r)return!0}return!1}getRows(){return this.rows}static constructResult(e){let t=ks.buildBitArray(e),r=Ai(t).parseInformation(),i=e[0].getFinderPattern().getResultPoints(),s=e[e.length-1].getFinderPattern().getResultPoints(),o=[i[0],i[1],s[0],s[1]];return new qe(r,null,null,o,$.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),t=e.getLeftChar(),n=e.getRightChar();if(n==null)return!1;let r=n.getChecksumPortion(),i=2;for(let o=1;o<this.pairs.size();++o){let a=this.pairs.get(o);r+=a.getLeftChar().getChecksumPortion(),i++;let l=a.getRightChar();l!=null&&(r+=l.getChecksumPortion(),i++)}return r%=211,211*(i-4)+r==t.getValue()}static getNextSecondBar(e,t){let n;return e.get(t)?(n=e.getNextUnset(t),n=e.getNextSet(n)):(n=e.getNextSet(t),n=e.getNextUnset(n)),n}retrieveNextPair(e,t,n){let r=t.length%2==0;this.startFromEven&&(r=!r);let i,s=!0,o=-1;do this.findNextPair(e,t,o),i=this.parseFoundFinderPattern(e,n,r),i==null?o=W.getNextSecondBar(e,this.startEnd[0]):s=!1;while(s);let a=this.decodeDataCharacter(e,i,r,!0);if(!this.isEmptyPair(t)&&t[t.length-1].mustBeLast())throw new V;let l;try{l=this.decodeDataCharacter(e,i,r,!1)}catch(d){l=null,this.verbose&&console.log(d)}return new jt(a,l,i,!0)}isEmptyPair(e){return e.length===0}findNextPair(e,t,n){let r=this.getDecodeFinderCounters();r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s;n>=0?s=n:this.isEmptyPair(t)?s=0:s=t[t.length-1].getFinderPattern().getStartEnd()[1];let o=t.length%2!=0;this.startFromEven&&(o=!o);let a=!1;for(;s<i&&(a=!e.get(s),!!a);)s++;let l=0,d=s;for(let A=s;A<i;A++)if(e.get(A)!=a)r[l]++;else{if(l==3){if(o&&W.reverseCounters(r),W.isFinderPattern(r)){this.startEnd[0]=d,this.startEnd[1]=A;return}o&&W.reverseCounters(r),d+=r[0]+r[1],r[0]=r[2],r[1]=r[3],r[2]=0,r[3]=0,l--}else l++;r[l]=1,a=!a}throw new V}static reverseCounters(e){let t=e.length;for(let n=0;n<t/2;++n){let r=e[n];e[n]=e[t-n-1],e[t-n-1]=r}}parseFoundFinderPattern(e,t,n){let r,i,s;if(n){let l=this.startEnd[0]-1;for(;l>=0&&!e.get(l);)l--;l++,r=this.startEnd[0]-l,i=l,s=this.startEnd[1]}else i=this.startEnd[0],s=e.getNextUnset(this.startEnd[1]+1),r=s-this.startEnd[1];let o=this.getDecodeFinderCounters();he.arraycopy(o,0,o,1,o.length-1),o[0]=r;let a;try{a=this.parseFinderValue(o,W.FINDER_PATTERNS)}catch{return null}return new qn(a,[i,s],i,s,t)}decodeDataCharacter(e,t,n,r){let i=this.getDataCharacterCounters();for(let De=0;De<i.length;De++)i[De]=0;if(r)W.recordPatternInReverse(e,t.getStartEnd()[0],i);else{W.recordPattern(e,t.getStartEnd()[1],i);for(let De=0,tt=i.length-1;De<tt;De++,tt--){let At=i[De];i[De]=i[tt],i[tt]=At}}let s=17,o=we.sum(new Int32Array(i))/s,a=(t.getStartEnd()[1]-t.getStartEnd()[0])/15;if(Math.abs(o-a)/a>.3)throw new V;let l=this.getOddCounts(),d=this.getEvenCounts(),A=this.getOddRoundingErrors(),E=this.getEvenRoundingErrors();for(let De=0;De<i.length;De++){let tt=1*i[De]/o,At=tt+.5;if(At<1){if(tt<.3)throw new V;At=1}else if(At>8){if(tt>8.7)throw new V;At=8}let Nn=De/2;De&1?(d[Nn]=At,E[Nn]=tt-At):(l[Nn]=At,A[Nn]=tt-At)}this.adjustOddEvenCounts(s);let b=4*t.getValue()+(n?0:2)+(r?0:1)-1,N=0,R=0;for(let De=l.length-1;De>=0;De--){if(W.isNotA1left(t,n,r)){let tt=W.WEIGHTS[b][2*De];R+=l[De]*tt}N+=l[De]}let B=0;for(let De=d.length-1;De>=0;De--)if(W.isNotA1left(t,n,r)){let tt=W.WEIGHTS[b][2*De+1];B+=d[De]*tt}let L=R+B;if(N&1||N>13||N<4)throw new V;let X=(13-N)/2,Y=W.SYMBOL_WIDEST[X],H=9-Y,ge=Pt.getRSSvalue(l,Y,!0),ue=Pt.getRSSvalue(d,H,!1),ft=W.EVEN_TOTAL_SUBSET[X],Bt=W.GSUM[X],dt=ge*ft+ue+Bt;return new mn(dt,L)}static isNotA1left(e,t,n){return!(e.getValue()==0&&t&&n)}adjustOddEvenCounts(e){let t=we.sum(new Int32Array(this.getOddCounts())),n=we.sum(new Int32Array(this.getEvenCounts())),r=!1,i=!1;t>13?i=!0:t<4&&(r=!0);let s=!1,o=!1;n>13?o=!0:n<4&&(s=!0);let a=t+n-e,l=(t&1)==1,d=(n&1)==0;if(a==1)if(l){if(d)throw new V;i=!0}else{if(!d)throw new V;o=!0}else if(a==-1)if(l){if(d)throw new V;r=!0}else{if(!d)throw new V;s=!0}else if(a==0){if(l){if(!d)throw new V;t<n?(r=!0,o=!0):(i=!0,s=!0)}else if(d)throw new V}else throw new V;if(r){if(i)throw new V;W.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(i&&W.decrement(this.getOddCounts(),this.getOddRoundingErrors()),s){if(o)throw new V;W.increment(this.getEvenCounts(),this.getOddRoundingErrors())}o&&W.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}W.SYMBOL_WIDEST=[7,5,4,3,1],W.EVEN_TOTAL_SUBSET=[4,20,52,104,204],W.GSUM=[0,348,1388,2948,3988],W.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],W.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],W.FINDER_PAT_A=0,W.FINDER_PAT_B=1,W.FINDER_PAT_C=2,W.FINDER_PAT_D=3,W.FINDER_PAT_E=4,W.FINDER_PAT_F=5,W.FINDER_PATTERN_SEQUENCES=[[W.FINDER_PAT_A,W.FINDER_PAT_A],[W.FINDER_PAT_A,W.FINDER_PAT_B,W.FINDER_PAT_B],[W.FINDER_PAT_A,W.FINDER_PAT_C,W.FINDER_PAT_B,W.FINDER_PAT_D],[W.FINDER_PAT_A,W.FINDER_PAT_E,W.FINDER_PAT_B,W.FINDER_PAT_D,W.FINDER_PAT_C],[W.FINDER_PAT_A,W.FINDER_PAT_E,W.FINDER_PAT_B,W.FINDER_PAT_D,W.FINDER_PAT_D,W.FINDER_PAT_F],[W.FINDER_PAT_A,W.FINDER_PAT_E,W.FINDER_PAT_B,W.FINDER_PAT_D,W.FINDER_PAT_E,W.FINDER_PAT_F,W.FINDER_PAT_F],[W.FINDER_PAT_A,W.FINDER_PAT_A,W.FINDER_PAT_B,W.FINDER_PAT_B,W.FINDER_PAT_C,W.FINDER_PAT_C,W.FINDER_PAT_D,W.FINDER_PAT_D],[W.FINDER_PAT_A,W.FINDER_PAT_A,W.FINDER_PAT_B,W.FINDER_PAT_B,W.FINDER_PAT_C,W.FINDER_PAT_C,W.FINDER_PAT_D,W.FINDER_PAT_E,W.FINDER_PAT_E],[W.FINDER_PAT_A,W.FINDER_PAT_A,W.FINDER_PAT_B,W.FINDER_PAT_B,W.FINDER_PAT_C,W.FINDER_PAT_C,W.FINDER_PAT_D,W.FINDER_PAT_E,W.FINDER_PAT_F,W.FINDER_PAT_F],[W.FINDER_PAT_A,W.FINDER_PAT_A,W.FINDER_PAT_B,W.FINDER_PAT_B,W.FINDER_PAT_C,W.FINDER_PAT_D,W.FINDER_PAT_D,W.FINDER_PAT_E,W.FINDER_PAT_E,W.FINDER_PAT_F,W.FINDER_PAT_F]],W.MAX_PAIRS=11;class Gs extends mn{constructor(e,t,n){super(e,t),this.count=0,this.finderPattern=n}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class Ge extends st{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(e,t,n){const r=this.decodePair(t,!1,e,n);Ge.addOrTally(this.possibleLeftPairs,r),t.reverse();let i=this.decodePair(t,!0,e,n);Ge.addOrTally(this.possibleRightPairs,i),t.reverse();for(let s of this.possibleLeftPairs)if(s.getCount()>1){for(let o of this.possibleRightPairs)if(o.getCount()>1&&Ge.checkChecksum(s,o))return Ge.constructResult(s,o)}throw new V}static addOrTally(e,t){if(t==null)return;let n=!1;for(let r of e)if(r.getValue()===t.getValue()){r.incrementCount(),n=!0;break}n||e.push(t)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,t){let n=4537077*e.getValue()+t.getValue(),r=new String(n).toString(),i=new Te;for(let l=13-r.length;l>0;l--)i.append("0");i.append(r);let s=0;for(let l=0;l<13;l++){let d=i.charAt(l).charCodeAt(0)-48;s+=l&1?d:3*d}s=10-s%10,s===10&&(s=0),i.append(s.toString());let o=e.getFinderPattern().getResultPoints(),a=t.getFinderPattern().getResultPoints();return new qe(i.toString(),null,0,[o[0],o[1],a[0],a[1]],$.RSS_14,new Date().getTime())}static checkChecksum(e,t){let n=(e.getChecksumPortion()+16*t.getChecksumPortion())%79,r=9*e.getFinderPattern().getValue()+t.getFinderPattern().getValue();return r>72&&r--,r>8&&r--,n===r}decodePair(e,t,n,r){try{let i=this.findFinderPattern(e,t),s=this.parseFoundFinderPattern(e,n,t,i),o=r==null?null:r.get(me.NEED_RESULT_POINT_CALLBACK);if(o!=null){let d=(i[0]+i[1])/2;t&&(d=e.getSize()-1-d),o.foundPossibleResultPoint(new q(d,n))}let a=this.decodeDataCharacter(e,s,!0),l=this.decodeDataCharacter(e,s,!1);return new Gs(1597*a.getValue()+l.getValue(),a.getChecksumPortion()+4*l.getChecksumPortion(),s)}catch{return null}}decodeDataCharacter(e,t,n){let r=this.getDataCharacterCounters();for(let B=0;B<r.length;B++)r[B]=0;if(n)U.recordPatternInReverse(e,t.getStartEnd()[0],r);else{U.recordPattern(e,t.getStartEnd()[1]+1,r);for(let B=0,L=r.length-1;B<L;B++,L--){let X=r[B];r[B]=r[L],r[L]=X}}let i=n?16:15,s=we.sum(new Int32Array(r))/i,o=this.getOddCounts(),a=this.getEvenCounts(),l=this.getOddRoundingErrors(),d=this.getEvenRoundingErrors();for(let B=0;B<r.length;B++){let L=r[B]/s,X=Math.floor(L+.5);X<1?X=1:X>8&&(X=8);let Y=Math.floor(B/2);B&1?(a[Y]=X,d[Y]=L-X):(o[Y]=X,l[Y]=L-X)}this.adjustOddEvenCounts(n,i);let A=0,E=0;for(let B=o.length-1;B>=0;B--)E*=9,E+=o[B],A+=o[B];let b=0,N=0;for(let B=a.length-1;B>=0;B--)b*=9,b+=a[B],N+=a[B];let R=E+3*b;if(n){if(A&1||A>12||A<4)throw new V;let B=(12-A)/2,L=Ge.OUTSIDE_ODD_WIDEST[B],X=9-L,Y=Pt.getRSSvalue(o,L,!1),H=Pt.getRSSvalue(a,X,!0),ge=Ge.OUTSIDE_EVEN_TOTAL_SUBSET[B],ue=Ge.OUTSIDE_GSUM[B];return new mn(Y*ge+H+ue,R)}else{if(N&1||N>10||N<4)throw new V;let B=(10-N)/2,L=Ge.INSIDE_ODD_WIDEST[B],X=9-L,Y=Pt.getRSSvalue(o,L,!0),H=Pt.getRSSvalue(a,X,!1),ge=Ge.INSIDE_ODD_TOTAL_SUBSET[B],ue=Ge.INSIDE_GSUM[B];return new mn(H*ge+Y+ue,R)}}findFinderPattern(e,t){let n=this.getDecodeFinderCounters();n[0]=0,n[1]=0,n[2]=0,n[3]=0;let r=e.getSize(),i=!1,s=0;for(;s<r&&(i=!e.get(s),t!==i);)s++;let o=0,a=s;for(let l=s;l<r;l++)if(e.get(l)!==i)n[o]++;else{if(o===3){if(st.isFinderPattern(n))return[a,l];a+=n[0]+n[1],n[0]=n[2],n[1]=n[3],n[2]=0,n[3]=0,o--}else o++;n[o]=1,i=!i}throw new V}parseFoundFinderPattern(e,t,n,r){let i=e.get(r[0]),s=r[0]-1;for(;s>=0&&i!==e.get(s);)s--;s++;const o=r[0]-s,a=this.getDecodeFinderCounters(),l=new Int32Array(a.length);he.arraycopy(a,0,l,1,a.length-1),l[0]=o;const d=this.parseFinderValue(l,Ge.FINDER_PATTERNS);let A=s,E=r[1];return n&&(A=e.getSize()-1-A,E=e.getSize()-1-E),new qn(d,[s,r[1]],A,E,t)}adjustOddEvenCounts(e,t){let n=we.sum(new Int32Array(this.getOddCounts())),r=we.sum(new Int32Array(this.getEvenCounts())),i=!1,s=!1,o=!1,a=!1;e?(n>12?s=!0:n<4&&(i=!0),r>12?a=!0:r<4&&(o=!0)):(n>11?s=!0:n<5&&(i=!0),r>10?a=!0:r<4&&(o=!0));let l=n+r-t,d=(n&1)===(e?1:0),A=(r&1)===1;if(l===1)if(d){if(A)throw new V;s=!0}else{if(!A)throw new V;a=!0}else if(l===-1)if(d){if(A)throw new V;i=!0}else{if(!A)throw new V;o=!0}else if(l===0){if(d){if(!A)throw new V;n<r?(i=!0,a=!0):(s=!0,o=!0)}else if(A)throw new V}else throw new V;if(i){if(s)throw new V;st.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(s&&st.decrement(this.getOddCounts(),this.getOddRoundingErrors()),o){if(a)throw new V;st.increment(this.getEvenCounts(),this.getOddRoundingErrors())}a&&st.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}Ge.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],Ge.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],Ge.OUTSIDE_GSUM=[0,161,961,2015,2715],Ge.INSIDE_GSUM=[0,336,1036,1516],Ge.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],Ge.INSIDE_ODD_WIDEST=[2,4,6,8],Ge.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class bn extends U{constructor(e,t){super(),this.readers=[],this.verbose=t===!0;const n=e?e.get(me.POSSIBLE_FORMATS):null,r=e&&e.get(me.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;n?((n.includes($.EAN_13)||n.includes($.UPC_A)||n.includes($.EAN_8)||n.includes($.UPC_E))&&this.readers.push(new mr(e)),n.includes($.CODE_39)&&this.readers.push(new ce(r)),n.includes($.CODE_128)&&this.readers.push(new G),n.includes($.ITF)&&this.readers.push(new te),n.includes($.RSS_14)&&this.readers.push(new Ge),n.includes($.RSS_EXPANDED)&&this.readers.push(new W(this.verbose))):(this.readers.push(new mr(e)),this.readers.push(new ce),this.readers.push(new mr(e)),this.readers.push(new G),this.readers.push(new te),this.readers.push(new Ge),this.readers.push(new W(this.verbose)))}decodeRow(e,t,n){for(let r=0;r<this.readers.length;r++)try{return this.readers[r].decodeRow(e,t,n)}catch{}throw new V}reset(){this.readers.forEach(e=>e.reset())}}class Ws extends Lt{constructor(e=500,t){super(new bn(t),e,t)}}class _e{constructor(e,t,n){this.ecCodewords=e,this.ecBlocks=[t],n&&this.ecBlocks.push(n)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class be{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Ae{constructor(e,t,n,r,i,s){this.versionNumber=e,this.symbolSizeRows=t,this.symbolSizeColumns=n,this.dataRegionSizeRows=r,this.dataRegionSizeColumns=i,this.ecBlocks=s;let o=0;const a=s.getECCodewords(),l=s.getECBlocks();for(let d of l)o+=d.getCount()*(d.getDataCodewords()+a);this.totalCodewords=o}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(e,t){if(e&1||t&1)throw new Z;for(let n of Ae.VERSIONS)if(n.symbolSizeRows===e&&n.symbolSizeColumns===t)return n;throw new Z}toString(){return""+this.versionNumber}static buildVersions(){return[new Ae(1,10,10,8,8,new _e(5,new be(1,3))),new Ae(2,12,12,10,10,new _e(7,new be(1,5))),new Ae(3,14,14,12,12,new _e(10,new be(1,8))),new Ae(4,16,16,14,14,new _e(12,new be(1,12))),new Ae(5,18,18,16,16,new _e(14,new be(1,18))),new Ae(6,20,20,18,18,new _e(18,new be(1,22))),new Ae(7,22,22,20,20,new _e(20,new be(1,30))),new Ae(8,24,24,22,22,new _e(24,new be(1,36))),new Ae(9,26,26,24,24,new _e(28,new be(1,44))),new Ae(10,32,32,14,14,new _e(36,new be(1,62))),new Ae(11,36,36,16,16,new _e(42,new be(1,86))),new Ae(12,40,40,18,18,new _e(48,new be(1,114))),new Ae(13,44,44,20,20,new _e(56,new be(1,144))),new Ae(14,48,48,22,22,new _e(68,new be(1,174))),new Ae(15,52,52,24,24,new _e(42,new be(2,102))),new Ae(16,64,64,14,14,new _e(56,new be(2,140))),new Ae(17,72,72,16,16,new _e(36,new be(4,92))),new Ae(18,80,80,18,18,new _e(48,new be(4,114))),new Ae(19,88,88,20,20,new _e(56,new be(4,144))),new Ae(20,96,96,22,22,new _e(68,new be(4,174))),new Ae(21,104,104,24,24,new _e(56,new be(6,136))),new Ae(22,120,120,18,18,new _e(68,new be(6,175))),new Ae(23,132,132,20,20,new _e(62,new be(8,163))),new Ae(24,144,144,22,22,new _e(62,new be(8,156),new be(2,155))),new Ae(25,8,18,6,16,new _e(7,new be(1,5))),new Ae(26,8,32,6,14,new _e(11,new be(1,10))),new Ae(27,12,26,10,24,new _e(14,new be(1,16))),new Ae(28,12,36,10,16,new _e(18,new be(1,22))),new Ae(29,16,36,14,16,new _e(24,new be(1,32))),new Ae(30,16,48,14,22,new _e(28,new be(1,49)))]}}Ae.VERSIONS=Ae.buildVersions();class Tr{constructor(e){const t=e.getHeight();if(t<8||t>144||t&1)throw new Z;this.version=Tr.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new He(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){const t=e.getHeight(),n=e.getWidth();return Ae.getVersionForDimensions(t,n)}readCodewords(){const e=new Int8Array(this.version.getTotalCodewords());let t=0,n=4,r=0;const i=this.mappingBitMatrix.getHeight(),s=this.mappingBitMatrix.getWidth();let o=!1,a=!1,l=!1,d=!1;do if(n===i&&r===0&&!o)e[t++]=this.readCorner1(i,s)&255,n-=2,r+=2,o=!0;else if(n===i-2&&r===0&&s&3&&!a)e[t++]=this.readCorner2(i,s)&255,n-=2,r+=2,a=!0;else if(n===i+4&&r===2&&!(s&7)&&!l)e[t++]=this.readCorner3(i,s)&255,n-=2,r+=2,l=!0;else if(n===i-2&&r===0&&(s&7)===4&&!d)e[t++]=this.readCorner4(i,s)&255,n-=2,r+=2,d=!0;else{do n<i&&r>=0&&!this.readMappingMatrix.get(r,n)&&(e[t++]=this.readUtah(n,r,i,s)&255),n-=2,r+=2;while(n>=0&&r<s);n+=1,r+=3;do n>=0&&r<s&&!this.readMappingMatrix.get(r,n)&&(e[t++]=this.readUtah(n,r,i,s)&255),n+=2,r-=2;while(n<i&&r>=0);n+=3,r+=1}while(n<i||r<s);if(t!==this.version.getTotalCodewords())throw new Z;return e}readModule(e,t,n,r){return e<0&&(e+=n,t+=4-(n+4&7)),t<0&&(t+=r,e+=4-(r+4&7)),this.readMappingMatrix.set(t,e),this.mappingBitMatrix.get(t,e)}readUtah(e,t,n,r){let i=0;return this.readModule(e-2,t-2,n,r)&&(i|=1),i<<=1,this.readModule(e-2,t-1,n,r)&&(i|=1),i<<=1,this.readModule(e-1,t-2,n,r)&&(i|=1),i<<=1,this.readModule(e-1,t-1,n,r)&&(i|=1),i<<=1,this.readModule(e-1,t,n,r)&&(i|=1),i<<=1,this.readModule(e,t-2,n,r)&&(i|=1),i<<=1,this.readModule(e,t-1,n,r)&&(i|=1),i<<=1,this.readModule(e,t,n,r)&&(i|=1),i}readCorner1(e,t){let n=0;return this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,1,e,t)&&(n|=1),n<<=1,this.readModule(e-1,2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n<<=1,this.readModule(2,t-1,e,t)&&(n|=1),n<<=1,this.readModule(3,t-1,e,t)&&(n|=1),n}readCorner2(e,t){let n=0;return this.readModule(e-3,0,e,t)&&(n|=1),n<<=1,this.readModule(e-2,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(0,t-4,e,t)&&(n|=1),n<<=1,this.readModule(0,t-3,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n}readCorner3(e,t){let n=0;return this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,t-1,e,t)&&(n|=1),n<<=1,this.readModule(0,t-3,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-3,e,t)&&(n|=1),n<<=1,this.readModule(1,t-2,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n}readCorner4(e,t){let n=0;return this.readModule(e-3,0,e,t)&&(n|=1),n<<=1,this.readModule(e-2,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n<<=1,this.readModule(2,t-1,e,t)&&(n|=1),n<<=1,this.readModule(3,t-1,e,t)&&(n|=1),n}extractDataRegion(e){const t=this.version.getSymbolSizeRows(),n=this.version.getSymbolSizeColumns();if(e.getHeight()!==t)throw new M("Dimension of bitMatrix must match the version size");const r=this.version.getDataRegionSizeRows(),i=this.version.getDataRegionSizeColumns(),s=t/r|0,o=n/i|0,a=s*r,l=o*i,d=new He(l,a);for(let A=0;A<s;++A){const E=A*r;for(let b=0;b<o;++b){const N=b*i;for(let R=0;R<r;++R){const B=A*(r+2)+1+R,L=E+R;for(let X=0;X<i;++X){const Y=b*(i+2)+1+X;if(e.get(Y,B)){const H=N+X;d.set(H,L)}}}}}return d}}class Sr{constructor(e,t){this.numDataCodewords=e,this.codewords=t}static getDataBlocks(e,t){const n=t.getECBlocks();let r=0;const i=n.getECBlocks();for(let R of i)r+=R.getCount();const s=new Array(r);let o=0;for(let R of i)for(let B=0;B<R.getCount();B++){const L=R.getDataCodewords(),X=n.getECCodewords()+L;s[o++]=new Sr(L,new Uint8Array(X))}const l=s[0].codewords.length-n.getECCodewords(),d=l-1;let A=0;for(let R=0;R<d;R++)for(let B=0;B<o;B++)s[B].codewords[R]=e[A++];const E=t.getVersionNumber()===24,b=E?8:o;for(let R=0;R<b;R++)s[R].codewords[l-1]=e[A++];const N=s[0].codewords.length;for(let R=l;R<N;R++)for(let B=0;B<o;B++){const L=E?(B+8)%o:B,X=E&&L>7?R-1:R;s[L].codewords[X]=e[A++]}if(A!==e.length)throw new M;return s}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class _r{constructor(e){this.bytes=e,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(e){if(e<1||e>32||e>this.available())throw new M(""+e);let t=0,n=this.bitOffset,r=this.byteOffset;const i=this.bytes;if(n>0){const s=8-n,o=e<s?e:s,a=s-o,l=255>>8-o<<a;t=(i[r]&l)>>a,e-=o,n+=o,n===8&&(n=0,r++)}if(e>0){for(;e>=8;)t=t<<8|i[r]&255,r++,e-=8;if(e>0){const s=8-e,o=255>>s<<s;t=t<<e|(i[r]&o)>>s,n+=e}}return this.bitOffset=n,this.byteOffset=r,t}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var je;(function(w){w[w.PAD_ENCODE=0]="PAD_ENCODE",w[w.ASCII_ENCODE=1]="ASCII_ENCODE",w[w.C40_ENCODE=2]="C40_ENCODE",w[w.TEXT_ENCODE=3]="TEXT_ENCODE",w[w.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",w[w.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",w[w.BASE256_ENCODE=6]="BASE256_ENCODE"})(je||(je={}));class Kt{static decode(e){const t=new _r(e),n=new Te,r=new Te,i=new Array;let s=je.ASCII_ENCODE;do if(s===je.ASCII_ENCODE)s=this.decodeAsciiSegment(t,n,r);else{switch(s){case je.C40_ENCODE:this.decodeC40Segment(t,n);break;case je.TEXT_ENCODE:this.decodeTextSegment(t,n);break;case je.ANSIX12_ENCODE:this.decodeAnsiX12Segment(t,n);break;case je.EDIFACT_ENCODE:this.decodeEdifactSegment(t,n);break;case je.BASE256_ENCODE:this.decodeBase256Segment(t,n,i);break;default:throw new Z}s=je.ASCII_ENCODE}while(s!==je.PAD_ENCODE&&t.available()>0);return r.length()>0&&n.append(r.toString()),new Xt(e,n.toString(),i.length===0?null:i,null)}static decodeAsciiSegment(e,t,n){let r=!1;do{let i=e.readBits(8);if(i===0)throw new Z;if(i<=128)return r&&(i+=128),t.append(String.fromCharCode(i-1)),je.ASCII_ENCODE;if(i===129)return je.PAD_ENCODE;if(i<=229){const s=i-130;s<10&&t.append("0"),t.append(""+s)}else switch(i){case 230:return je.C40_ENCODE;case 231:return je.BASE256_ENCODE;case 232:t.append("");break;case 233:case 234:break;case 235:r=!0;break;case 236:t.append("[)>05"),n.insert(0,"");break;case 237:t.append("[)>06"),n.insert(0,"");break;case 238:return je.ANSIX12_ENCODE;case 239:return je.TEXT_ENCODE;case 240:return je.EDIFACT_ENCODE;case 241:break;default:if(i!==254||e.available()!==0)throw new Z;break}}while(e.available()>0);return je.ASCII_ENCODE}static decodeC40Segment(e,t){let n=!1;const r=[];let i=0;do{if(e.available()===8)return;const s=e.readBits(8);if(s===254)return;this.parseTwoBytes(s,e.readBits(8),r);for(let o=0;o<3;o++){const a=r[o];switch(i){case 0:if(a<3)i=a+1;else if(a<this.C40_BASIC_SET_CHARS.length){const l=this.C40_BASIC_SET_CHARS[a];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else throw new Z;break;case 1:n?(t.append(String.fromCharCode(a+128)),n=!1):t.append(String.fromCharCode(a)),i=0;break;case 2:if(a<this.C40_SHIFT2_SET_CHARS.length){const l=this.C40_SHIFT2_SET_CHARS[a];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else switch(a){case 27:t.append("");break;case 30:n=!0;break;default:throw new Z}i=0;break;case 3:n?(t.append(String.fromCharCode(a+224)),n=!1):t.append(String.fromCharCode(a+96)),i=0;break;default:throw new Z}}}while(e.available()>0)}static decodeTextSegment(e,t){let n=!1,r=[],i=0;do{if(e.available()===8)return;const s=e.readBits(8);if(s===254)return;this.parseTwoBytes(s,e.readBits(8),r);for(let o=0;o<3;o++){const a=r[o];switch(i){case 0:if(a<3)i=a+1;else if(a<this.TEXT_BASIC_SET_CHARS.length){const l=this.TEXT_BASIC_SET_CHARS[a];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else throw new Z;break;case 1:n?(t.append(String.fromCharCode(a+128)),n=!1):t.append(String.fromCharCode(a)),i=0;break;case 2:if(a<this.TEXT_SHIFT2_SET_CHARS.length){const l=this.TEXT_SHIFT2_SET_CHARS[a];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else switch(a){case 27:t.append("");break;case 30:n=!0;break;default:throw new Z}i=0;break;case 3:if(a<this.TEXT_SHIFT3_SET_CHARS.length){const l=this.TEXT_SHIFT3_SET_CHARS[a];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l),i=0}else throw new Z;break;default:throw new Z}}}while(e.available()>0)}static decodeAnsiX12Segment(e,t){const n=[];do{if(e.available()===8)return;const r=e.readBits(8);if(r===254)return;this.parseTwoBytes(r,e.readBits(8),n);for(let i=0;i<3;i++){const s=n[i];switch(s){case 0:t.append("\r");break;case 1:t.append("*");break;case 2:t.append(">");break;case 3:t.append(" ");break;default:if(s<14)t.append(String.fromCharCode(s+44));else if(s<40)t.append(String.fromCharCode(s+51));else throw new Z;break}}}while(e.available()>0)}static parseTwoBytes(e,t,n){let r=(e<<8)+t-1,i=Math.floor(r/1600);n[0]=i,r-=i*1600,i=Math.floor(r/40),n[1]=i,n[2]=r-i*40}static decodeEdifactSegment(e,t){do{if(e.available()<=16)return;for(let n=0;n<4;n++){let r=e.readBits(6);if(r===31){const i=8-e.getBitOffset();i!==8&&e.readBits(i);return}r&32||(r|=64),t.append(String.fromCharCode(r))}}while(e.available()>0)}static decodeBase256Segment(e,t,n){let r=1+e.getByteOffset();const i=this.unrandomize255State(e.readBits(8),r++);let s;if(i===0?s=e.available()/8|0:i<250?s=i:s=250*(i-249)+this.unrandomize255State(e.readBits(8),r++),s<0)throw new Z;const o=new Uint8Array(s);for(let a=0;a<s;a++){if(e.available()<8)throw new Z;o[a]=this.unrandomize255State(e.readBits(8),r++)}n.push(o);try{t.append(rt.decode(o,se.ISO88591))}catch(a){throw new yt("Platform does not support required encoding: "+a.message)}}static unrandomize255State(e,t){const n=149*t%255+1,r=e-n;return r>=0?r:r+256}}Kt.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Kt.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Kt.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Kt.TEXT_SHIFT2_SET_CHARS=Kt.C40_SHIFT2_SET_CHARS,Kt.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Hs{constructor(){this.rsDecoder=new rn(xe.DATA_MATRIX_FIELD_256)}decode(e){const t=new Tr(e),n=t.getVersion(),r=t.readCodewords(),i=Sr.getDataBlocks(r,n);let s=0;for(let l of i)s+=l.getNumDataCodewords();const o=new Uint8Array(s),a=i.length;for(let l=0;l<a;l++){const d=i[l],A=d.getCodewords(),E=d.getNumDataCodewords();this.correctErrors(A,E);for(let b=0;b<E;b++)o[b*a+l]=A[b]}return Kt.decode(o)}correctErrors(e,t){const n=new Int32Array(e);try{this.rsDecoder.decode(n,e.length-t)}catch{throw new Q}for(let r=0;r<t;r++)e[r]=n[r]}}class ze{constructor(e){this.image=e,this.rectangleDetector=new Rt(this.image)}detect(){const e=this.rectangleDetector.detect();let t=this.detectSolid1(e);if(t=this.detectSolid2(t),t[3]=this.correctTopRight(t),!t[3])throw new V;t=this.shiftToModuleCenter(t);const n=t[0],r=t[1],i=t[2],s=t[3];let o=this.transitionsBetween(n,s)+1,a=this.transitionsBetween(i,s)+1;(o&1)===1&&(o+=1),(a&1)===1&&(a+=1),4*o<7*a&&4*a<7*o&&(o=a=Math.max(o,a));let l=ze.sampleGrid(this.image,n,r,i,s,o,a);return new at(l,[n,r,i,s])}static shiftPoint(e,t,n){let r=(t.getX()-e.getX())/(n+1),i=(t.getY()-e.getY())/(n+1);return new q(e.getX()+r,e.getY()+i)}static moveAway(e,t,n){let r=e.getX(),i=e.getY();return r<t?r-=1:r+=1,i<n?i-=1:i+=1,new q(r,i)}detectSolid1(e){let t=e[0],n=e[1],r=e[3],i=e[2],s=this.transitionsBetween(t,n),o=this.transitionsBetween(n,r),a=this.transitionsBetween(r,i),l=this.transitionsBetween(i,t),d=s,A=[i,t,n,r];return d>o&&(d=o,A[0]=t,A[1]=n,A[2]=r,A[3]=i),d>a&&(d=a,A[0]=n,A[1]=r,A[2]=i,A[3]=t),d>l&&(A[0]=r,A[1]=i,A[2]=t,A[3]=n),A}detectSolid2(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i),o=ze.shiftPoint(n,r,(s+1)*4),a=ze.shiftPoint(r,n,(s+1)*4),l=this.transitionsBetween(o,t),d=this.transitionsBetween(a,i);return l<d?(e[0]=t,e[1]=n,e[2]=r,e[3]=i):(e[0]=n,e[1]=r,e[2]=i,e[3]=t),e}correctTopRight(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i),o=this.transitionsBetween(n,i),a=ze.shiftPoint(t,n,(o+1)*4),l=ze.shiftPoint(r,n,(s+1)*4);s=this.transitionsBetween(a,i),o=this.transitionsBetween(l,i);let d=new q(i.getX()+(r.getX()-n.getX())/(s+1),i.getY()+(r.getY()-n.getY())/(s+1)),A=new q(i.getX()+(t.getX()-n.getX())/(o+1),i.getY()+(t.getY()-n.getY())/(o+1));if(!this.isValid(d))return this.isValid(A)?A:null;if(!this.isValid(A))return d;let E=this.transitionsBetween(a,d)+this.transitionsBetween(l,d),b=this.transitionsBetween(a,A)+this.transitionsBetween(l,A);return E>b?d:A}shiftToModuleCenter(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i)+1,o=this.transitionsBetween(r,i)+1,a=ze.shiftPoint(t,n,o*4),l=ze.shiftPoint(r,n,s*4);s=this.transitionsBetween(a,i)+1,o=this.transitionsBetween(l,i)+1,(s&1)===1&&(s+=1),(o&1)===1&&(o+=1);let d=(t.getX()+n.getX()+r.getX()+i.getX())/4,A=(t.getY()+n.getY()+r.getY()+i.getY())/4;t=ze.moveAway(t,d,A),n=ze.moveAway(n,d,A),r=ze.moveAway(r,d,A),i=ze.moveAway(i,d,A);let E,b;return a=ze.shiftPoint(t,n,o*4),a=ze.shiftPoint(a,i,s*4),E=ze.shiftPoint(n,t,o*4),E=ze.shiftPoint(E,r,s*4),l=ze.shiftPoint(r,i,o*4),l=ze.shiftPoint(l,n,s*4),b=ze.shiftPoint(i,r,o*4),b=ze.shiftPoint(b,t,s*4),[a,E,l,b]}isValid(e){return e.getX()>=0&&e.getX()<this.image.getWidth()&&e.getY()>0&&e.getY()<this.image.getHeight()}static sampleGrid(e,t,n,r,i,s,o){return u.getInstance().sampleGrid(e,s,o,.5,.5,s-.5,.5,s-.5,o-.5,.5,o-.5,t.getX(),t.getY(),i.getX(),i.getY(),r.getX(),r.getY(),n.getX(),n.getY())}transitionsBetween(e,t){let n=Math.trunc(e.getX()),r=Math.trunc(e.getY()),i=Math.trunc(t.getX()),s=Math.trunc(t.getY()),o=Math.abs(s-r)>Math.abs(i-n);if(o){let R=n;n=r,r=R,R=i,i=s,s=R}let a=Math.abs(i-n),l=Math.abs(s-r),d=-a/2,A=r<s?1:-1,E=n<i?1:-1,b=0,N=this.image.get(o?r:n,o?n:r);for(let R=n,B=r;R!==i;R+=E){let L=this.image.get(o?B:R,o?R:B);if(L!==N&&(b++,N=L),d+=l,d>0){if(B===s)break;B+=A,d-=a}}return b}}class qt{constructor(){this.decoder=new Hs}decode(e,t=null){let n,r;if(t!=null&&t.has(me.PURE_BARCODE)){const l=qt.extractPureBits(e.getBlackMatrix());n=this.decoder.decode(l),r=qt.NO_POINTS}else{const l=new ze(e.getBlackMatrix()).detect();n=this.decoder.decode(l.getBits()),r=l.getPoints()}const i=n.getRawBytes(),s=new qe(n.getText(),i,8*i.length,r,$.DATA_MATRIX,he.currentTimeMillis()),o=n.getByteSegments();o!=null&&s.putMetadata(Fe.BYTE_SEGMENTS,o);const a=n.getECLevel();return a!=null&&s.putMetadata(Fe.ERROR_CORRECTION_LEVEL,a),s}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),n=e.getBottomRightOnBit();if(t==null||n==null)throw new V;const r=this.moduleSize(t,e);let i=t[1];const s=n[1];let o=t[0];const l=(n[0]-o+1)/r,d=(s-i+1)/r;if(l<=0||d<=0)throw new V;const A=r/2;i+=A,o+=A;const E=new He(l,d);for(let b=0;b<d;b++){const N=i+b*r;for(let R=0;R<l;R++)e.get(o+R*r,N)&&E.set(R,b)}return E}static moduleSize(e,t){const n=t.getWidth();let r=e[0];const i=e[1];for(;r<n&&t.get(r,i);)r++;if(r===n)throw new V;const s=r-e[0];if(s===0)throw new V;return s}}qt.NO_POINTS=[];class Xs extends Lt{constructor(e=500){super(new qt,e)}}var Tn;(function(w){w[w.L=0]="L",w[w.M=1]="M",w[w.Q=2]="Q",w[w.H=3]="H"})(Tn||(Tn={}));class Me{constructor(e,t,n){this.value=e,this.stringValue=t,this.bits=n,Me.FOR_BITS.set(n,this),Me.FOR_VALUE.set(e,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(e){switch(e){case"L":return Me.L;case"M":return Me.M;case"Q":return Me.Q;case"H":return Me.H;default:throw new k(e+"not available")}}toString(){return this.stringValue}equals(e){if(!(e instanceof Me))return!1;const t=e;return this.value===t.value}static forBits(e){if(e<0||e>=Me.FOR_BITS.size)throw new M;return Me.FOR_BITS.get(e)}}Me.FOR_BITS=new Map,Me.FOR_VALUE=new Map,Me.L=new Me(Tn.L,"L",1),Me.M=new Me(Tn.M,"M",0),Me.Q=new Me(Tn.Q,"Q",3),Me.H=new Me(Tn.H,"H",2);class ot{constructor(e){this.errorCorrectionLevel=Me.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,t){return ne.bitCount(e^t)}static decodeFormatInformation(e,t){const n=ot.doDecodeFormatInformation(e,t);return n!==null?n:ot.doDecodeFormatInformation(e^ot.FORMAT_INFO_MASK_QR,t^ot.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,t){let n=Number.MAX_SAFE_INTEGER,r=0;for(const i of ot.FORMAT_INFO_DECODE_LOOKUP){const s=i[0];if(s===e||s===t)return new ot(i[1]);let o=ot.numBitsDiffering(e,s);o<n&&(r=i[1],n=o),e!==t&&(o=ot.numBitsDiffering(t,s),o<n&&(r=i[1],n=o))}return n<=3?new ot(r):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(e){if(!(e instanceof ot))return!1;const t=e;return this.errorCorrectionLevel===t.errorCorrectionLevel&&this.dataMask===t.dataMask}}ot.FORMAT_INFO_MASK_QR=21522,ot.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class D{constructor(e,...t){this.ecCodewordsPerBlock=e,this.ecBlocks=t}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let e=0;const t=this.ecBlocks;for(const n of t)e+=n.getCount();return e}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class y{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class J{constructor(e,t,...n){this.versionNumber=e,this.alignmentPatternCenters=t,this.ecBlocks=n;let r=0;const i=n[0].getECCodewordsPerBlock(),s=n[0].getECBlocks();for(const o of s)r+=o.getCount()*(o.getDataCodewords()+i);this.totalCodewords=r}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(e){return this.ecBlocks[e.getValue()]}static getProvisionalVersionForDimension(e){if(e%4!==1)throw new Z;try{return this.getVersionForNumber((e-17)/4)}catch{throw new Z}}static getVersionForNumber(e){if(e<1||e>40)throw new M;return J.VERSIONS[e-1]}static decodeVersionInformation(e){let t=Number.MAX_SAFE_INTEGER,n=0;for(let r=0;r<J.VERSION_DECODE_INFO.length;r++){const i=J.VERSION_DECODE_INFO[r];if(i===e)return J.getVersionForNumber(r+7);const s=ot.numBitsDiffering(e,i);s<t&&(n=r+7,t=s)}return t<=3?J.getVersionForNumber(n):null}buildFunctionPattern(){const e=this.getDimensionForVersion(),t=new He(e);t.setRegion(0,0,9,9),t.setRegion(e-8,0,8,9),t.setRegion(0,e-8,9,8);const n=this.alignmentPatternCenters.length;for(let r=0;r<n;r++){const i=this.alignmentPatternCenters[r]-2;for(let s=0;s<n;s++)r===0&&(s===0||s===n-1)||r===n-1&&s===0||t.setRegion(this.alignmentPatternCenters[s]-2,i,5,5)}return t.setRegion(6,9,1,e-17),t.setRegion(9,6,e-17,1),this.versionNumber>6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t}toString(){return""+this.versionNumber}}J.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),J.VERSIONS=[new J(1,new Int32Array(0),new D(7,new y(1,19)),new D(10,new y(1,16)),new D(13,new y(1,13)),new D(17,new y(1,9))),new J(2,Int32Array.from([6,18]),new D(10,new y(1,34)),new D(16,new y(1,28)),new D(22,new y(1,22)),new D(28,new y(1,16))),new J(3,Int32Array.from([6,22]),new D(15,new y(1,55)),new D(26,new y(1,44)),new D(18,new y(2,17)),new D(22,new y(2,13))),new J(4,Int32Array.from([6,26]),new D(20,new y(1,80)),new D(18,new y(2,32)),new D(26,new y(2,24)),new D(16,new y(4,9))),new J(5,Int32Array.from([6,30]),new D(26,new y(1,108)),new D(24,new y(2,43)),new D(18,new y(2,15),new y(2,16)),new D(22,new y(2,11),new y(2,12))),new J(6,Int32Array.from([6,34]),new D(18,new y(2,68)),new D(16,new y(4,27)),new D(24,new y(4,19)),new D(28,new y(4,15))),new J(7,Int32Array.from([6,22,38]),new D(20,new y(2,78)),new D(18,new y(4,31)),new D(18,new y(2,14),new y(4,15)),new D(26,new y(4,13),new y(1,14))),new J(8,Int32Array.from([6,24,42]),new D(24,new y(2,97)),new D(22,new y(2,38),new y(2,39)),new D(22,new y(4,18),new y(2,19)),new D(26,new y(4,14),new y(2,15))),new J(9,Int32Array.from([6,26,46]),new D(30,new y(2,116)),new D(22,new y(3,36),new y(2,37)),new D(20,new y(4,16),new y(4,17)),new D(24,new y(4,12),new y(4,13))),new J(10,Int32Array.from([6,28,50]),new D(18,new y(2,68),new y(2,69)),new D(26,new y(4,43),new y(1,44)),new D(24,new y(6,19),new y(2,20)),new D(28,new y(6,15),new y(2,16))),new J(11,Int32Array.from([6,30,54]),new D(20,new y(4,81)),new D(30,new y(1,50),new y(4,51)),new D(28,new y(4,22),new y(4,23)),new D(24,new y(3,12),new y(8,13))),new J(12,Int32Array.from([6,32,58]),new D(24,new y(2,92),new y(2,93)),new D(22,new y(6,36),new y(2,37)),new D(26,new y(4,20),new y(6,21)),new D(28,new y(7,14),new y(4,15))),new J(13,Int32Array.from([6,34,62]),new D(26,new y(4,107)),new D(22,new y(8,37),new y(1,38)),new D(24,new y(8,20),new y(4,21)),new D(22,new y(12,11),new y(4,12))),new J(14,Int32Array.from([6,26,46,66]),new D(30,new y(3,115),new y(1,116)),new D(24,new y(4,40),new y(5,41)),new D(20,new y(11,16),new y(5,17)),new D(24,new y(11,12),new y(5,13))),new J(15,Int32Array.from([6,26,48,70]),new D(22,new y(5,87),new y(1,88)),new D(24,new y(5,41),new y(5,42)),new D(30,new y(5,24),new y(7,25)),new D(24,new y(11,12),new y(7,13))),new J(16,Int32Array.from([6,26,50,74]),new D(24,new y(5,98),new y(1,99)),new D(28,new y(7,45),new y(3,46)),new D(24,new y(15,19),new y(2,20)),new D(30,new y(3,15),new y(13,16))),new J(17,Int32Array.from([6,30,54,78]),new D(28,new y(1,107),new y(5,108)),new D(28,new y(10,46),new y(1,47)),new D(28,new y(1,22),new y(15,23)),new D(28,new y(2,14),new y(17,15))),new J(18,Int32Array.from([6,30,56,82]),new D(30,new y(5,120),new y(1,121)),new D(26,new y(9,43),new y(4,44)),new D(28,new y(17,22),new y(1,23)),new D(28,new y(2,14),new y(19,15))),new J(19,Int32Array.from([6,30,58,86]),new D(28,new y(3,113),new y(4,114)),new D(26,new y(3,44),new y(11,45)),new D(26,new y(17,21),new y(4,22)),new D(26,new y(9,13),new y(16,14))),new J(20,Int32Array.from([6,34,62,90]),new D(28,new y(3,107),new y(5,108)),new D(26,new y(3,41),new y(13,42)),new D(30,new y(15,24),new y(5,25)),new D(28,new y(15,15),new y(10,16))),new J(21,Int32Array.from([6,28,50,72,94]),new D(28,new y(4,116),new y(4,117)),new D(26,new y(17,42)),new D(28,new y(17,22),new y(6,23)),new D(30,new y(19,16),new y(6,17))),new J(22,Int32Array.from([6,26,50,74,98]),new D(28,new y(2,111),new y(7,112)),new D(28,new y(17,46)),new D(30,new y(7,24),new y(16,25)),new D(24,new y(34,13))),new J(23,Int32Array.from([6,30,54,78,102]),new D(30,new y(4,121),new y(5,122)),new D(28,new y(4,47),new y(14,48)),new D(30,new y(11,24),new y(14,25)),new D(30,new y(16,15),new y(14,16))),new J(24,Int32Array.from([6,28,54,80,106]),new D(30,new y(6,117),new y(4,118)),new D(28,new y(6,45),new y(14,46)),new D(30,new y(11,24),new y(16,25)),new D(30,new y(30,16),new y(2,17))),new J(25,Int32Array.from([6,32,58,84,110]),new D(26,new y(8,106),new y(4,107)),new D(28,new y(8,47),new y(13,48)),new D(30,new y(7,24),new y(22,25)),new D(30,new y(22,15),new y(13,16))),new J(26,Int32Array.from([6,30,58,86,114]),new D(28,new y(10,114),new y(2,115)),new D(28,new y(19,46),new y(4,47)),new D(28,new y(28,22),new y(6,23)),new D(30,new y(33,16),new y(4,17))),new J(27,Int32Array.from([6,34,62,90,118]),new D(30,new y(8,122),new y(4,123)),new D(28,new y(22,45),new y(3,46)),new D(30,new y(8,23),new y(26,24)),new D(30,new y(12,15),new y(28,16))),new J(28,Int32Array.from([6,26,50,74,98,122]),new D(30,new y(3,117),new y(10,118)),new D(28,new y(3,45),new y(23,46)),new D(30,new y(4,24),new y(31,25)),new D(30,new y(11,15),new y(31,16))),new J(29,Int32Array.from([6,30,54,78,102,126]),new D(30,new y(7,116),new y(7,117)),new D(28,new y(21,45),new y(7,46)),new D(30,new y(1,23),new y(37,24)),new D(30,new y(19,15),new y(26,16))),new J(30,Int32Array.from([6,26,52,78,104,130]),new D(30,new y(5,115),new y(10,116)),new D(28,new y(19,47),new y(10,48)),new D(30,new y(15,24),new y(25,25)),new D(30,new y(23,15),new y(25,16))),new J(31,Int32Array.from([6,30,56,82,108,134]),new D(30,new y(13,115),new y(3,116)),new D(28,new y(2,46),new y(29,47)),new D(30,new y(42,24),new y(1,25)),new D(30,new y(23,15),new y(28,16))),new J(32,Int32Array.from([6,34,60,86,112,138]),new D(30,new y(17,115)),new D(28,new y(10,46),new y(23,47)),new D(30,new y(10,24),new y(35,25)),new D(30,new y(19,15),new y(35,16))),new J(33,Int32Array.from([6,30,58,86,114,142]),new D(30,new y(17,115),new y(1,116)),new D(28,new y(14,46),new y(21,47)),new D(30,new y(29,24),new y(19,25)),new D(30,new y(11,15),new y(46,16))),new J(34,Int32Array.from([6,34,62,90,118,146]),new D(30,new y(13,115),new y(6,116)),new D(28,new y(14,46),new y(23,47)),new D(30,new y(44,24),new y(7,25)),new D(30,new y(59,16),new y(1,17))),new J(35,Int32Array.from([6,30,54,78,102,126,150]),new D(30,new y(12,121),new y(7,122)),new D(28,new y(12,47),new y(26,48)),new D(30,new y(39,24),new y(14,25)),new D(30,new y(22,15),new y(41,16))),new J(36,Int32Array.from([6,24,50,76,102,128,154]),new D(30,new y(6,121),new y(14,122)),new D(28,new y(6,47),new y(34,48)),new D(30,new y(46,24),new y(10,25)),new D(30,new y(2,15),new y(64,16))),new J(37,Int32Array.from([6,28,54,80,106,132,158]),new D(30,new y(17,122),new y(4,123)),new D(28,new y(29,46),new y(14,47)),new D(30,new y(49,24),new y(10,25)),new D(30,new y(24,15),new y(46,16))),new J(38,Int32Array.from([6,32,58,84,110,136,162]),new D(30,new y(4,122),new y(18,123)),new D(28,new y(13,46),new y(32,47)),new D(30,new y(48,24),new y(14,25)),new D(30,new y(42,15),new y(32,16))),new J(39,Int32Array.from([6,26,54,82,110,138,166]),new D(30,new y(20,117),new y(4,118)),new D(28,new y(40,47),new y(7,48)),new D(30,new y(43,24),new y(22,25)),new D(30,new y(10,15),new y(67,16))),new J(40,Int32Array.from([6,30,58,86,114,142,170]),new D(30,new y(19,118),new y(6,119)),new D(28,new y(18,47),new y(31,48)),new D(30,new y(34,24),new y(34,25)),new D(30,new y(20,15),new y(61,16)))];var Qe;(function(w){w[w.DATA_MASK_000=0]="DATA_MASK_000",w[w.DATA_MASK_001=1]="DATA_MASK_001",w[w.DATA_MASK_010=2]="DATA_MASK_010",w[w.DATA_MASK_011=3]="DATA_MASK_011",w[w.DATA_MASK_100=4]="DATA_MASK_100",w[w.DATA_MASK_101=5]="DATA_MASK_101",w[w.DATA_MASK_110=6]="DATA_MASK_110",w[w.DATA_MASK_111=7]="DATA_MASK_111"})(Qe||(Qe={}));class St{constructor(e,t){this.value=e,this.isMasked=t}unmaskBitMatrix(e,t){for(let n=0;n<t;n++)for(let r=0;r<t;r++)this.isMasked(n,r)&&e.flip(r,n)}}St.values=new Map([[Qe.DATA_MASK_000,new St(Qe.DATA_MASK_000,(w,e)=>(w+e&1)===0)],[Qe.DATA_MASK_001,new St(Qe.DATA_MASK_001,(w,e)=>(w&1)===0)],[Qe.DATA_MASK_010,new St(Qe.DATA_MASK_010,(w,e)=>e%3===0)],[Qe.DATA_MASK_011,new St(Qe.DATA_MASK_011,(w,e)=>(w+e)%3===0)],[Qe.DATA_MASK_100,new St(Qe.DATA_MASK_100,(w,e)=>(Math.floor(w/2)+Math.floor(e/3)&1)===0)],[Qe.DATA_MASK_101,new St(Qe.DATA_MASK_101,(w,e)=>w*e%6===0)],[Qe.DATA_MASK_110,new St(Qe.DATA_MASK_110,(w,e)=>w*e%6<3)],[Qe.DATA_MASK_111,new St(Qe.DATA_MASK_111,(w,e)=>(w+e+w*e%3&1)===0)]]);class Ys{constructor(e){const t=e.getHeight();if(t<21||(t&3)!==1)throw new Z;this.bitMatrix=e}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let e=0;for(let i=0;i<6;i++)e=this.copyBit(i,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let i=5;i>=0;i--)e=this.copyBit(8,i,e);const t=this.bitMatrix.getHeight();let n=0;const r=t-7;for(let i=t-1;i>=r;i--)n=this.copyBit(8,i,n);for(let i=t-8;i<t;i++)n=this.copyBit(i,8,n);if(this.parsedFormatInfo=ot.decodeFormatInformation(e,n),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new Z}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const e=this.bitMatrix.getHeight(),t=Math.floor((e-17)/4);if(t<=6)return J.getVersionForNumber(t);let n=0;const r=e-11;for(let s=5;s>=0;s--)for(let o=e-9;o>=r;o--)n=this.copyBit(o,s,n);let i=J.decodeVersionInformation(n);if(i!==null&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;n=0;for(let s=5;s>=0;s--)for(let o=e-9;o>=r;o--)n=this.copyBit(s,o,n);if(i=J.decodeVersionInformation(n),i!==null&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;throw new Z}copyBit(e,t,n){return(this.isMirror?this.bitMatrix.get(t,e):this.bitMatrix.get(e,t))?n<<1|1:n<<1}readCodewords(){const e=this.readFormatInformation(),t=this.readVersion(),n=St.values.get(e.getDataMask()),r=this.bitMatrix.getHeight();n.unmaskBitMatrix(this.bitMatrix,r);const i=t.buildFunctionPattern();let s=!0;const o=new Uint8Array(t.getTotalCodewords());let a=0,l=0,d=0;for(let A=r-1;A>0;A-=2){A===6&&A--;for(let E=0;E<r;E++){const b=s?r-1-E:E;for(let N=0;N<2;N++)i.get(A-N,b)||(d++,l<<=1,this.bitMatrix.get(A-N,b)&&(l|=1),d===8&&(o[a++]=l,d=0,l=0))}s=!s}if(a!==t.getTotalCodewords())throw new Z;return o}remask(){if(this.parsedFormatInfo===null)return;const e=St.values[this.parsedFormatInfo.getDataMask()],t=this.bitMatrix.getHeight();e.unmaskBitMatrix(this.bitMatrix,t)}setMirror(e){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=e}mirror(){const e=this.bitMatrix;for(let t=0,n=e.getWidth();t<n;t++)for(let r=t+1,i=e.getHeight();r<i;r++)e.get(t,r)!==e.get(r,t)&&(e.flip(r,t),e.flip(t,r))}}class Nr{constructor(e,t){this.numDataCodewords=e,this.codewords=t}static getDataBlocks(e,t,n){if(e.length!==t.getTotalCodewords())throw new M;const r=t.getECBlocksForLevel(n);let i=0;const s=r.getECBlocks();for(const N of s)i+=N.getCount();const o=new Array(i);let a=0;for(const N of s)for(let R=0;R<N.getCount();R++){const B=N.getDataCodewords(),L=r.getECCodewordsPerBlock()+B;o[a++]=new Nr(B,new Uint8Array(L))}const l=o[0].codewords.length;let d=o.length-1;for(;d>=0&&o[d].codewords.length!==l;)d--;d++;const A=l-r.getECCodewordsPerBlock();let E=0;for(let N=0;N<A;N++)for(let R=0;R<a;R++)o[R].codewords[N]=e[E++];for(let N=d;N<a;N++)o[N].codewords[A]=e[E++];const b=o[0].codewords.length;for(let N=A;N<b;N++)for(let R=0;R<a;R++){const B=R<d?N:N+1;o[R].codewords[B]=e[E++]}return o}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var _t;(function(w){w[w.TERMINATOR=0]="TERMINATOR",w[w.NUMERIC=1]="NUMERIC",w[w.ALPHANUMERIC=2]="ALPHANUMERIC",w[w.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",w[w.BYTE=4]="BYTE",w[w.ECI=5]="ECI",w[w.KANJI=6]="KANJI",w[w.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",w[w.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",w[w.HANZI=9]="HANZI"})(_t||(_t={}));class ee{constructor(e,t,n,r){this.value=e,this.stringValue=t,this.characterCountBitsForVersions=n,this.bits=r,ee.FOR_BITS.set(r,this),ee.FOR_VALUE.set(e,this)}static forBits(e){const t=ee.FOR_BITS.get(e);if(t===void 0)throw new M;return t}getCharacterCountBits(e){const t=e.getVersionNumber();let n;return t<=9?n=0:t<=26?n=1:n=2,this.characterCountBitsForVersions[n]}getValue(){return this.value}getBits(){return this.bits}equals(e){if(!(e instanceof ee))return!1;const t=e;return this.value===t.value}toString(){return this.stringValue}}ee.FOR_BITS=new Map,ee.FOR_VALUE=new Map,ee.TERMINATOR=new ee(_t.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),ee.NUMERIC=new ee(_t.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),ee.ALPHANUMERIC=new ee(_t.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),ee.STRUCTURED_APPEND=new ee(_t.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),ee.BYTE=new ee(_t.BYTE,"BYTE",Int32Array.from([8,16,16]),4),ee.ECI=new ee(_t.ECI,"ECI",Int32Array.from([0,0,0]),7),ee.KANJI=new ee(_t.KANJI,"KANJI",Int32Array.from([8,10,12]),8),ee.FNC1_FIRST_POSITION=new ee(_t.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),ee.FNC1_SECOND_POSITION=new ee(_t.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),ee.HANZI=new ee(_t.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class Ue{static decode(e,t,n,r){const i=new _r(e);let s=new Te;const o=new Array;let a=-1,l=-1;try{let d=null,A=!1,E;do{if(i.available()<4)E=ee.TERMINATOR;else{const b=i.readBits(4);E=ee.forBits(b)}switch(E){case ee.TERMINATOR:break;case ee.FNC1_FIRST_POSITION:case ee.FNC1_SECOND_POSITION:A=!0;break;case ee.STRUCTURED_APPEND:if(i.available()<16)throw new Z;a=i.readBits(8),l=i.readBits(8);break;case ee.ECI:const b=Ue.parseECIValue(i);if(d=z.getCharacterSetECIByValue(b),d===null)throw new Z;break;case ee.HANZI:const N=i.readBits(4),R=i.readBits(E.getCharacterCountBits(t));N===Ue.GB2312_SUBSET&&Ue.decodeHanziSegment(i,s,R);break;default:const B=i.readBits(E.getCharacterCountBits(t));switch(E){case ee.NUMERIC:Ue.decodeNumericSegment(i,s,B);break;case ee.ALPHANUMERIC:Ue.decodeAlphanumericSegment(i,s,B,A);break;case ee.BYTE:Ue.decodeByteSegment(i,s,B,d,o,r);break;case ee.KANJI:Ue.decodeKanjiSegment(i,s,B);break;default:throw new Z}break}}while(E!==ee.TERMINATOR)}catch{throw new Z}return new Xt(e,s.toString(),o.length===0?null:o,n===null?null:n.toString(),a,l)}static decodeHanziSegment(e,t,n){if(n*13>e.available())throw new Z;const r=new Uint8Array(2*n);let i=0;for(;n>0;){const s=e.readBits(13);let o=s/96<<8&4294967295|s%96;o<959?o+=41377:o+=42657,r[i]=o>>8&255,r[i+1]=o&255,i+=2,n--}try{t.append(rt.decode(r,se.GB2312))}catch(s){throw new Z(s)}}static decodeKanjiSegment(e,t,n){if(n*13>e.available())throw new Z;const r=new Uint8Array(2*n);let i=0;for(;n>0;){const s=e.readBits(13);let o=s/192<<8&4294967295|s%192;o<7936?o+=33088:o+=49472,r[i]=o>>8,r[i+1]=o,i+=2,n--}try{t.append(rt.decode(r,se.SHIFT_JIS))}catch(s){throw new Z(s)}}static decodeByteSegment(e,t,n,r,i,s){if(8*n>e.available())throw new Z;const o=new Uint8Array(n);for(let l=0;l<n;l++)o[l]=e.readBits(8);let a;r===null?a=se.guessEncoding(o,s):a=r.getName();try{t.append(rt.decode(o,a))}catch(l){throw new Z(l)}i.push(o)}static toAlphaNumericChar(e){if(e>=Ue.ALPHANUMERIC_CHARS.length)throw new Z;return Ue.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,t,n,r){const i=t.length();for(;n>1;){if(e.available()<11)throw new Z;const s=e.readBits(11);t.append(Ue.toAlphaNumericChar(Math.floor(s/45))),t.append(Ue.toAlphaNumericChar(s%45)),n-=2}if(n===1){if(e.available()<6)throw new Z;t.append(Ue.toAlphaNumericChar(e.readBits(6)))}if(r)for(let s=i;s<t.length();s++)t.charAt(s)==="%"&&(s<t.length()-1&&t.charAt(s+1)==="%"?t.deleteCharAt(s+1):t.setCharAt(s,""))}static decodeNumericSegment(e,t,n){for(;n>=3;){if(e.available()<10)throw new Z;const r=e.readBits(10);if(r>=1e3)throw new Z;t.append(Ue.toAlphaNumericChar(Math.floor(r/100))),t.append(Ue.toAlphaNumericChar(Math.floor(r/10)%10)),t.append(Ue.toAlphaNumericChar(r%10)),n-=3}if(n===2){if(e.available()<7)throw new Z;const r=e.readBits(7);if(r>=100)throw new Z;t.append(Ue.toAlphaNumericChar(Math.floor(r/10))),t.append(Ue.toAlphaNumericChar(r%10))}else if(n===1){if(e.available()<4)throw new Z;const r=e.readBits(4);if(r>=10)throw new Z;t.append(Ue.toAlphaNumericChar(r))}}static parseECIValue(e){const t=e.readBits(8);if(!(t&128))return t&127;if((t&192)===128){const n=e.readBits(8);return(t&63)<<8&4294967295|n}if((t&224)===192){const n=e.readBits(16);return(t&31)<<16&4294967295|n}throw new Z}}Ue.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ue.GB2312_SUBSET=1;class Ei{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||e===null||e.length<3)return;const t=e[0];e[0]=e[2],e[2]=t}}class zs{constructor(){this.rsDecoder=new rn(xe.QR_CODE_FIELD_256)}decodeBooleanArray(e,t){return this.decodeBitMatrix(He.parseFromBooleanArray(e),t)}decodeBitMatrix(e,t){const n=new Ys(e);let r=null;try{return this.decodeBitMatrixParser(n,t)}catch(i){r=i}try{n.remask(),n.setMirror(!0),n.readVersion(),n.readFormatInformation(),n.mirror();const i=this.decodeBitMatrixParser(n,t);return i.setOther(new Ei(!0)),i}catch(i){throw r!==null?r:i}}decodeBitMatrixParser(e,t){const n=e.readVersion(),r=e.readFormatInformation().getErrorCorrectionLevel(),i=e.readCodewords(),s=Nr.getDataBlocks(i,n,r);let o=0;for(const d of s)o+=d.getNumDataCodewords();const a=new Uint8Array(o);let l=0;for(const d of s){const A=d.getCodewords(),E=d.getNumDataCodewords();this.correctErrors(A,E);for(let b=0;b<E;b++)a[l++]=A[b]}return Ue.decode(a,n,r,t)}correctErrors(e,t){const n=new Int32Array(e);try{this.rsDecoder.decode(n,e.length-t)}catch{throw new Q}for(let r=0;r<t;r++)e[r]=n[r]}}class Rr extends q{constructor(e,t,n){super(e,t),this.estimatedModuleSize=n}aboutEquals(e,t,n){if(Math.abs(t-this.getY())<=e&&Math.abs(n-this.getX())<=e){const r=Math.abs(e-this.estimatedModuleSize);return r<=1||r<=this.estimatedModuleSize}return!1}combineEstimate(e,t,n){const r=(this.getX()+t)/2,i=(this.getY()+e)/2,s=(this.estimatedModuleSize+n)/2;return new Rr(r,i,s)}}class $n{constructor(e,t,n,r,i,s,o){this.image=e,this.startX=t,this.startY=n,this.width=r,this.height=i,this.moduleSize=s,this.resultPointCallback=o,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const e=this.startX,t=this.height,n=this.width,r=e+n,i=this.startY+t/2,s=new Int32Array(3),o=this.image;for(let a=0;a<t;a++){const l=i+(a&1?-Math.floor((a+1)/2):Math.floor((a+1)/2));s[0]=0,s[1]=0,s[2]=0;let d=e;for(;d<r&&!o.get(d,l);)d++;let A=0;for(;d<r;){if(o.get(d,l))if(A===1)s[1]++;else if(A===2){if(this.foundPatternCross(s)){const E=this.handlePossibleCenter(s,l,d);if(E!==null)return E}s[0]=s[2],s[1]=1,s[2]=0,A=1}else s[++A]++;else A===1&&A++,s[A]++;d++}if(this.foundPatternCross(s)){const E=this.handlePossibleCenter(s,l,r);if(E!==null)return E}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new V}static centerFromEnd(e,t){return t-e[2]-e[1]/2}foundPatternCross(e){const t=this.moduleSize,n=t/2;for(let r=0;r<3;r++)if(Math.abs(t-e[r])>=n)return!1;return!0}crossCheckVertical(e,t,n,r){const i=this.image,s=i.getHeight(),o=this.crossCheckStateCount;o[0]=0,o[1]=0,o[2]=0;let a=e;for(;a>=0&&i.get(t,a)&&o[1]<=n;)o[1]++,a--;if(a<0||o[1]>n)return NaN;for(;a>=0&&!i.get(t,a)&&o[0]<=n;)o[0]++,a--;if(o[0]>n)return NaN;for(a=e+1;a<s&&i.get(t,a)&&o[1]<=n;)o[1]++,a++;if(a===s||o[1]>n)return NaN;for(;a<s&&!i.get(t,a)&&o[2]<=n;)o[2]++,a++;if(o[2]>n)return NaN;const l=o[0]+o[1]+o[2];return 5*Math.abs(l-r)>=2*r?NaN:this.foundPatternCross(o)?$n.centerFromEnd(o,a):NaN}handlePossibleCenter(e,t,n){const r=e[0]+e[1]+e[2],i=$n.centerFromEnd(e,n),s=this.crossCheckVertical(t,i,2*e[1],r);if(!isNaN(s)){const o=(e[0]+e[1]+e[2])/3;for(const l of this.possibleCenters)if(l.aboutEquals(o,s,i))return l.combineEstimate(s,i,o);const a=new Rr(i,s,o);this.possibleCenters.push(a),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(a)}return null}}class Or extends q{constructor(e,t,n,r){super(e,t),this.estimatedModuleSize=n,this.count=r,r===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,t,n){if(Math.abs(t-this.getY())<=e&&Math.abs(n-this.getX())<=e){const r=Math.abs(e-this.estimatedModuleSize);return r<=1||r<=this.estimatedModuleSize}return!1}combineEstimate(e,t,n){const r=this.count+1,i=(this.count*this.getX()+t)/r,s=(this.count*this.getY()+e)/r,o=(this.count*this.estimatedModuleSize+n)/r;return new Or(i,s,o,r)}}class Zs{constructor(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class Je{constructor(e,t){this.image=e,this.resultPointCallback=t,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=t}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(e){const t=e!=null&&e.get(me.TRY_HARDER)!==void 0,n=e!=null&&e.get(me.PURE_BARCODE)!==void 0,r=this.image,i=r.getHeight(),s=r.getWidth();let o=Math.floor(3*i/(4*Je.MAX_MODULES));(o<Je.MIN_SKIP||t)&&(o=Je.MIN_SKIP);let a=!1;const l=new Int32Array(5);for(let A=o-1;A<i&&!a;A+=o){l[0]=0,l[1]=0,l[2]=0,l[3]=0,l[4]=0;let E=0;for(let b=0;b<s;b++)if(r.get(b,A))(E&1)===1&&E++,l[E]++;else if(E&1)l[E]++;else if(E===4)if(Je.foundPatternCross(l)){if(this.handlePossibleCenter(l,A,b,n)===!0)if(o=2,this.hasSkipped===!0)a=this.haveMultiplyConfirmedCenters();else{const R=this.findRowSkip();R>l[2]&&(A+=R-l[2]-o,b=s-1)}else{l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,E=3;continue}E=0,l[0]=0,l[1]=0,l[2]=0,l[3]=0,l[4]=0}else l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,E=3;else l[++E]++;Je.foundPatternCross(l)&&this.handlePossibleCenter(l,A,s,n)===!0&&(o=l[0],this.hasSkipped&&(a=this.haveMultiplyConfirmedCenters()))}const d=this.selectBestPatterns();return q.orderBestPatterns(d),new Zs(d)}static centerFromEnd(e,t){return t-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let t=0;for(let i=0;i<5;i++){const s=e[i];if(s===0)return!1;t+=s}if(t<7)return!1;const n=t/7,r=n/2;return Math.abs(n-e[0])<r&&Math.abs(n-e[1])<r&&Math.abs(3*n-e[2])<3*r&&Math.abs(n-e[3])<r&&Math.abs(n-e[4])<r}getCrossCheckStateCount(){const e=this.crossCheckStateCount;return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e}crossCheckDiagonal(e,t,n,r){const i=this.getCrossCheckStateCount();let s=0;const o=this.image;for(;e>=s&&t>=s&&o.get(t-s,e-s);)i[2]++,s++;if(e<s||t<s)return!1;for(;e>=s&&t>=s&&!o.get(t-s,e-s)&&i[1]<=n;)i[1]++,s++;if(e<s||t<s||i[1]>n)return!1;for(;e>=s&&t>=s&&o.get(t-s,e-s)&&i[0]<=n;)i[0]++,s++;if(i[0]>n)return!1;const a=o.getHeight(),l=o.getWidth();for(s=1;e+s<a&&t+s<l&&o.get(t+s,e+s);)i[2]++,s++;if(e+s>=a||t+s>=l)return!1;for(;e+s<a&&t+s<l&&!o.get(t+s,e+s)&&i[3]<n;)i[3]++,s++;if(e+s>=a||t+s>=l||i[3]>=n)return!1;for(;e+s<a&&t+s<l&&o.get(t+s,e+s)&&i[4]<n;)i[4]++,s++;if(i[4]>=n)return!1;const d=i[0]+i[1]+i[2]+i[3]+i[4];return Math.abs(d-r)<2*r&&Je.foundPatternCross(i)}crossCheckVertical(e,t,n,r){const i=this.image,s=i.getHeight(),o=this.getCrossCheckStateCount();let a=e;for(;a>=0&&i.get(t,a);)o[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(t,a)&&o[1]<=n;)o[1]++,a--;if(a<0||o[1]>n)return NaN;for(;a>=0&&i.get(t,a)&&o[0]<=n;)o[0]++,a--;if(o[0]>n)return NaN;for(a=e+1;a<s&&i.get(t,a);)o[2]++,a++;if(a===s)return NaN;for(;a<s&&!i.get(t,a)&&o[3]<n;)o[3]++,a++;if(a===s||o[3]>=n)return NaN;for(;a<s&&i.get(t,a)&&o[4]<n;)o[4]++,a++;if(o[4]>=n)return NaN;const l=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(l-r)>=2*r?NaN:Je.foundPatternCross(o)?Je.centerFromEnd(o,a):NaN}crossCheckHorizontal(e,t,n,r){const i=this.image,s=i.getWidth(),o=this.getCrossCheckStateCount();let a=e;for(;a>=0&&i.get(a,t);)o[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(a,t)&&o[1]<=n;)o[1]++,a--;if(a<0||o[1]>n)return NaN;for(;a>=0&&i.get(a,t)&&o[0]<=n;)o[0]++,a--;if(o[0]>n)return NaN;for(a=e+1;a<s&&i.get(a,t);)o[2]++,a++;if(a===s)return NaN;for(;a<s&&!i.get(a,t)&&o[3]<n;)o[3]++,a++;if(a===s||o[3]>=n)return NaN;for(;a<s&&i.get(a,t)&&o[4]<n;)o[4]++,a++;if(o[4]>=n)return NaN;const l=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(l-r)>=r?NaN:Je.foundPatternCross(o)?Je.centerFromEnd(o,a):NaN}handlePossibleCenter(e,t,n,r){const i=e[0]+e[1]+e[2]+e[3]+e[4];let s=Je.centerFromEnd(e,n),o=this.crossCheckVertical(t,Math.floor(s),e[2],i);if(!isNaN(o)&&(s=this.crossCheckHorizontal(Math.floor(s),Math.floor(o),e[2],i),!isNaN(s)&&(!r||this.crossCheckDiagonal(Math.floor(o),Math.floor(s),e[2],i)))){const a=i/7;let l=!1;const d=this.possibleCenters;for(let A=0,E=d.length;A<E;A++){const b=d[A];if(b.aboutEquals(a,o,s)){d[A]=b.combineEstimate(o,s,a),l=!0;break}}if(!l){const A=new Or(s,o,a);d.push(A),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(A)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let t=null;for(const n of this.possibleCenters)if(n.getCount()>=Je.CENTER_QUORUM)if(t==null)t=n;else return this.hasSkipped=!0,Math.floor((Math.abs(t.getX()-n.getX())-Math.abs(t.getY()-n.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let e=0,t=0;const n=this.possibleCenters.length;for(const s of this.possibleCenters)s.getCount()>=Je.CENTER_QUORUM&&(e++,t+=s.getEstimatedModuleSize());if(e<3)return!1;const r=t/n;let i=0;for(const s of this.possibleCenters)i+=Math.abs(s.getEstimatedModuleSize()-r);return i<=.05*t}selectBestPatterns(){const e=this.possibleCenters.length;if(e<3)throw new V;const t=this.possibleCenters;let n;if(e>3){let r=0,i=0;for(const a of this.possibleCenters){const l=a.getEstimatedModuleSize();r+=l,i+=l*l}n=r/e;let s=Math.sqrt(i/e-n*n);t.sort((a,l)=>{const d=Math.abs(l.getEstimatedModuleSize()-n),A=Math.abs(a.getEstimatedModuleSize()-n);return d<A?-1:d>A?1:0});const o=Math.max(.2*n,s);for(let a=0;a<t.length&&t.length>3;a++){const l=t[a];Math.abs(l.getEstimatedModuleSize()-n)>o&&(t.splice(a,1),a--)}}if(t.length>3){let r=0;for(const i of t)r+=i.getEstimatedModuleSize();n=r/t.length,t.sort((i,s)=>{if(s.getCount()===i.getCount()){const o=Math.abs(s.getEstimatedModuleSize()-n),a=Math.abs(i.getEstimatedModuleSize()-n);return o<a?1:o>a?-1:0}else return s.getCount()-i.getCount()}),t.splice(3)}return[t[0],t[1],t[2]]}}Je.CENTER_QUORUM=2,Je.MIN_SKIP=3,Je.MAX_MODULES=57;class Fn{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(me.NEED_RESULT_POINT_CALLBACK);const n=new Je(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(n)}processFinderPatternInfo(e){const t=e.getTopLeft(),n=e.getTopRight(),r=e.getBottomLeft(),i=this.calculateModuleSize(t,n,r);if(i<1)throw new V("No pattern found in proccess finder.");const s=Fn.computeDimension(t,n,r,i),o=J.getProvisionalVersionForDimension(s),a=o.getDimensionForVersion()-7;let l=null;if(o.getAlignmentPatternCenters().length>0){const b=n.getX()-t.getX()+r.getX(),N=n.getY()-t.getY()+r.getY(),R=1-3/a,B=Math.floor(t.getX()+R*(b-t.getX())),L=Math.floor(t.getY()+R*(N-t.getY()));for(let X=4;X<=16;X<<=1)try{l=this.findAlignmentInRegion(i,B,L,X);break}catch(Y){if(!(Y instanceof V))throw Y}}const d=Fn.createTransform(t,n,r,l,s),A=Fn.sampleGrid(this.image,d,s);let E;return l===null?E=[r,t,n]:E=[r,t,n,l],new at(A,E)}static createTransform(e,t,n,r,i){const s=i-3.5;let o,a,l,d;return r!==null?(o=r.getX(),a=r.getY(),l=s-3,d=l):(o=t.getX()-e.getX()+n.getX(),a=t.getY()-e.getY()+n.getY(),l=s,d=s),wt.quadrilateralToQuadrilateral(3.5,3.5,s,3.5,l,d,3.5,s,e.getX(),e.getY(),t.getX(),t.getY(),o,a,n.getX(),n.getY())}static sampleGrid(e,t,n){return u.getInstance().sampleGridWithTransform(e,n,n,t)}static computeDimension(e,t,n,r){const i=we.round(q.distance(e,t)/r),s=we.round(q.distance(e,n)/r);let o=Math.floor((i+s)/2)+7;switch(o&3){case 0:o++;break;case 2:o--;break;case 3:throw new V("Dimensions could be not found.")}return o}calculateModuleSize(e,t,n){return(this.calculateModuleSizeOneWay(e,t)+this.calculateModuleSizeOneWay(e,n))/2}calculateModuleSizeOneWay(e,t){const n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY())),r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(n)?r/7:isNaN(r)?n/7:(n+r)/14}sizeOfBlackWhiteBlackRunBothWays(e,t,n,r){let i=this.sizeOfBlackWhiteBlackRun(e,t,n,r),s=1,o=e-(n-e);o<0?(s=e/(e-o),o=0):o>=this.image.getWidth()&&(s=(this.image.getWidth()-1-e)/(o-e),o=this.image.getWidth()-1);let a=Math.floor(t-(r-t)*s);return s=1,a<0?(s=t/(t-a),a=0):a>=this.image.getHeight()&&(s=(this.image.getHeight()-1-t)/(a-t),a=this.image.getHeight()-1),o=Math.floor(e+(o-e)*s),i+=this.sizeOfBlackWhiteBlackRun(e,t,o,a),i-1}sizeOfBlackWhiteBlackRun(e,t,n,r){const i=Math.abs(r-t)>Math.abs(n-e);if(i){let b=e;e=t,t=b,b=n,n=r,r=b}const s=Math.abs(n-e),o=Math.abs(r-t);let a=-s/2;const l=e<n?1:-1,d=t<r?1:-1;let A=0;const E=n+l;for(let b=e,N=t;b!==E;b+=l){const R=i?N:b,B=i?b:N;if(A===1===this.image.get(R,B)){if(A===2)return we.distance(b,N,e,t);A++}if(a+=o,a>0){if(N===r)break;N+=d,a-=s}}return A===2?we.distance(n+l,r,e,t):NaN}findAlignmentInRegion(e,t,n,r){const i=Math.floor(r*e),s=Math.max(0,t-i),o=Math.min(this.image.getWidth()-1,t+i);if(o-s<e*3)throw new V("Alignment top exceeds estimated module size.");const a=Math.max(0,n-i),l=Math.min(this.image.getHeight()-1,n+i);if(l-a<e*3)throw new V("Alignment bottom exceeds estimated module size.");return new $n(this.image,s,a,o-s,l-a,e,this.resultPointCallback).find()}}class Qt{constructor(){this.decoder=new zs}getDecoder(){return this.decoder}decode(e,t){let n,r;if(t!=null&&t.get(me.PURE_BARCODE)!==void 0){const a=Qt.extractPureBits(e.getBlackMatrix());n=this.decoder.decodeBitMatrix(a,t),r=Qt.NO_POINTS}else{const a=new Fn(e.getBlackMatrix()).detect(t);n=this.decoder.decodeBitMatrix(a.getBits(),t),r=a.getPoints()}n.getOther()instanceof Ei&&n.getOther().applyMirroredCorrection(r);const i=new qe(n.getText(),n.getRawBytes(),void 0,r,$.QR_CODE,void 0),s=n.getByteSegments();s!==null&&i.putMetadata(Fe.BYTE_SEGMENTS,s);const o=n.getECLevel();return o!==null&&i.putMetadata(Fe.ERROR_CORRECTION_LEVEL,o),n.hasStructuredAppend()&&(i.putMetadata(Fe.STRUCTURED_APPEND_SEQUENCE,n.getStructuredAppendSequenceNumber()),i.putMetadata(Fe.STRUCTURED_APPEND_PARITY,n.getStructuredAppendParity())),i}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),n=e.getBottomRightOnBit();if(t===null||n===null)throw new V;const r=this.moduleSize(t,e);let i=t[1],s=n[1],o=t[0],a=n[0];if(o>=a||i>=s)throw new V;if(s-i!==a-o&&(a=o+(s-i),a>=e.getWidth()))throw new V;const l=Math.round((a-o+1)/r),d=Math.round((s-i+1)/r);if(l<=0||d<=0)throw new V;if(d!==l)throw new V;const A=Math.floor(r/2);i+=A,o+=A;const E=o+Math.floor((l-1)*r)-a;if(E>0){if(E>A)throw new V;o-=E}const b=i+Math.floor((d-1)*r)-s;if(b>0){if(b>A)throw new V;i-=b}const N=new He(l,d);for(let R=0;R<d;R++){const B=i+Math.floor(R*r);for(let L=0;L<l;L++)e.get(o+Math.floor(L*r),B)&&N.set(L,R)}return N}static moduleSize(e,t){const n=t.getHeight(),r=t.getWidth();let i=e[0],s=e[1],o=!0,a=0;for(;i<r&&s<n;){if(o!==t.get(i,s)){if(++a===5)break;o=!o}i++,s++}if(i===r||s===n)throw new V;return(i-e[0])/7}}Qt.NO_POINTS=new Array;class ie{PDF417Common(){}static getBitCountSum(e){return we.sum(e)}static toIntArray(e){if(e==null||!e.length)return ie.EMPTY_INT_ARRAY;const t=new Int32Array(e.length);let n=0;for(const r of e)t[n++]=r;return t}static getCodeword(e){const t=Ne.binarySearch(ie.SYMBOL_TABLE,e&262143);return t<0?-1:(ie.CODEWORD_TABLE[t]-1)%ie.NUMBER_OF_CODEWORDS}}ie.NUMBER_OF_CODEWORDS=929,ie.MAX_CODEWORDS_IN_BARCODE=ie.NUMBER_OF_CODEWORDS-1,ie.MIN_ROWS_IN_BARCODE=3,ie.MAX_ROWS_IN_BARCODE=90,ie.MODULES_IN_CODEWORD=17,ie.MODULES_IN_STOP_PATTERN=18,ie.BARS_IN_MODULE=8,ie.EMPTY_INT_ARRAY=new Int32Array([]),ie.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),ie.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class js{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class fe{static detectMultiple(e,t,n){let r=e.getBlackMatrix(),i=fe.detect(n,r);return i.length||(r=r.clone(),r.rotate180(),i=fe.detect(n,r)),new js(r,i)}static detect(e,t){const n=new Array;let r=0,i=0,s=!1;for(;r<t.getHeight();){const o=fe.findVertices(t,r,i);if(o[0]==null&&o[3]==null){if(!s)break;s=!1,i=0;for(const a of n)a[1]!=null&&(r=Math.trunc(Math.max(r,a[1].getY()))),a[3]!=null&&(r=Math.max(r,Math.trunc(a[3].getY())));r+=fe.ROW_STEP;continue}if(s=!0,n.push(o),!e)break;o[2]!=null?(i=Math.trunc(o[2].getX()),r=Math.trunc(o[2].getY())):(i=Math.trunc(o[4].getX()),r=Math.trunc(o[4].getY()))}return n}static findVertices(e,t,n){const r=e.getHeight(),i=e.getWidth(),s=new Array(8);return fe.copyToResult(s,fe.findRowsWithPattern(e,r,i,t,n,fe.START_PATTERN),fe.INDEXES_START_PATTERN),s[4]!=null&&(n=Math.trunc(s[4].getX()),t=Math.trunc(s[4].getY())),fe.copyToResult(s,fe.findRowsWithPattern(e,r,i,t,n,fe.STOP_PATTERN),fe.INDEXES_STOP_PATTERN),s}static copyToResult(e,t,n){for(let r=0;r<n.length;r++)e[n[r]]=t[r]}static findRowsWithPattern(e,t,n,r,i,s){const o=new Array(4);let a=!1;const l=new Int32Array(s.length);for(;r<t;r+=fe.ROW_STEP){let A=fe.findGuardPattern(e,i,r,n,!1,s,l);if(A!=null){for(;r>0;){const E=fe.findGuardPattern(e,i,--r,n,!1,s,l);if(E!=null)A=E;else{r++;break}}o[0]=new q(A[0],r),o[1]=new q(A[1],r),a=!0;break}}let d=r+1;if(a){let A=0,E=Int32Array.from([Math.trunc(o[0].getX()),Math.trunc(o[1].getX())]);for(;d<t;d++){const b=fe.findGuardPattern(e,E[0],d,n,!1,s,l);if(b!=null&&Math.abs(E[0]-b[0])<fe.MAX_PATTERN_DRIFT&&Math.abs(E[1]-b[1])<fe.MAX_PATTERN_DRIFT)E=b,A=0;else{if(A>fe.SKIPPED_ROW_COUNT_MAX)break;A++}}d-=A+1,o[2]=new q(E[0],d),o[3]=new q(E[1],d)}return d-r<fe.BARCODE_MIN_HEIGHT&&Ne.fill(o,null),o}static findGuardPattern(e,t,n,r,i,s,o){Ne.fillWithin(o,0,o.length,0);let a=t,l=0;for(;e.get(a,n)&&a>0&&l++<fe.MAX_PIXEL_DRIFT;)a--;let d=a,A=0,E=s.length;for(let b=i;d<r;d++)if(e.get(d,n)!==b)o[A]++;else{if(A===E-1){if(fe.patternMatchVariance(o,s,fe.MAX_INDIVIDUAL_VARIANCE)<fe.MAX_AVG_VARIANCE)return new Int32Array([a,d]);a+=o[0]+o[1],he.arraycopy(o,2,o,0,A-1),o[A-1]=0,o[A]=0,A--}else A++;o[A]=1,b=!b}return A===E-1&&fe.patternMatchVariance(o,s,fe.MAX_INDIVIDUAL_VARIANCE)<fe.MAX_AVG_VARIANCE?new Int32Array([a,d-1]):null}static patternMatchVariance(e,t,n){let r=e.length,i=0,s=0;for(let l=0;l<r;l++)i+=e[l],s+=t[l];if(i<s)return 1/0;let o=i/s;n*=o;let a=0;for(let l=0;l<r;l++){let d=e[l],A=t[l]*o,E=d>A?d-A:A-d;if(E>n)return 1/0;a+=E}return a/i}}fe.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),fe.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),fe.MAX_AVG_VARIANCE=.42,fe.MAX_INDIVIDUAL_VARIANCE=.8,fe.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),fe.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),fe.MAX_PIXEL_DRIFT=3,fe.MAX_PATTERN_DRIFT=5,fe.SKIPPED_ROW_COUNT_MAX=25,fe.ROW_STEP=5,fe.BARCODE_MIN_HEIGHT=10;class $e{constructor(e,t){if(t.length===0)throw new M;this.field=e;let n=t.length;if(n>1&&t[0]===0){let r=1;for(;r<n&&t[r]===0;)r++;r===n?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(n-r),he.arraycopy(t,r,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);if(e===1){let r=0;for(let i of this.coefficients)r=this.field.add(r,i);return r}let t=this.coefficients[0],n=this.coefficients.length;for(let r=1;r<n;r++)t=this.field.add(this.field.multiply(e,t),this.coefficients[r]);return t}add(e){if(!this.field.equals(e.field))throw new M("ModulusPolys do not have same ModulusGF field");if(this.isZero())return e;if(e.isZero())return this;let t=this.coefficients,n=e.coefficients;if(t.length>n.length){let s=t;t=n,n=s}let r=new Int32Array(n.length),i=n.length-t.length;he.arraycopy(n,0,r,0,i);for(let s=i;s<n.length;s++)r[s]=this.field.add(t[s-i],n[s]);return new $e(this.field,r)}subtract(e){if(!this.field.equals(e.field))throw new M("ModulusPolys do not have same ModulusGF field");return e.isZero()?this:this.add(e.negative())}multiply(e){return e instanceof $e?this.multiplyOther(e):this.multiplyScalar(e)}multiplyOther(e){if(!this.field.equals(e.field))throw new M("ModulusPolys do not have same ModulusGF field");if(this.isZero()||e.isZero())return new $e(this.field,new Int32Array([0]));let t=this.coefficients,n=t.length,r=e.coefficients,i=r.length,s=new Int32Array(n+i-1);for(let o=0;o<n;o++){let a=t[o];for(let l=0;l<i;l++)s[o+l]=this.field.add(s[o+l],this.field.multiply(a,r[l]))}return new $e(this.field,s)}negative(){let e=this.coefficients.length,t=new Int32Array(e);for(let n=0;n<e;n++)t[n]=this.field.subtract(0,this.coefficients[n]);return new $e(this.field,t)}multiplyScalar(e){if(e===0)return new $e(this.field,new Int32Array([0]));if(e===1)return this;let t=this.coefficients.length,n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=this.field.multiply(this.coefficients[r],e);return new $e(this.field,n)}multiplyByMonomial(e,t){if(e<0)throw new M;if(t===0)return new $e(this.field,new Int32Array([0]));let n=this.coefficients.length,r=new Int32Array(n+e);for(let i=0;i<n;i++)r[i]=this.field.multiply(this.coefficients[i],t);return new $e(this.field,r)}toString(){let e=new Te;for(let t=this.getDegree();t>=0;t--){let n=this.getCoefficient(t);n!==0&&(n<0?(e.append(" - "),n=-n):e.length()>0&&e.append(" + "),(t===0||n!==1)&&e.append(n),t!==0&&(t===1?e.append("x"):(e.append("x^"),e.append(t))))}return e.toString()}}class Ks{add(e,t){return(e+t)%this.modulus}subtract(e,t){return(this.modulus+e-t)%this.modulus}exp(e){return this.expTable[e]}log(e){if(e===0)throw new M;return this.logTable[e]}inverse(e){if(e===0)throw new nn;return this.expTable[this.modulus-this.logTable[e]-1]}multiply(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.modulus-1)]}getSize(){return this.modulus}equals(e){return e===this}}class Br extends Ks{constructor(e,t){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let n=1;for(let r=0;r<e;r++)this.expTable[r]=n,n=n*t%e;for(let r=0;r<e-1;r++)this.logTable[this.expTable[r]]=r;this.zero=new $e(this,new Int32Array([0])),this.one=new $e(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,t){if(e<0)throw new M;if(t===0)return this.zero;let n=new Int32Array(e+1);return n[0]=t,new $e(this,n)}}Br.PDF417_GF=new Br(ie.NUMBER_OF_CODEWORDS,3);class Ci{constructor(){this.field=Br.PDF417_GF}decode(e,t,n){let r=new $e(this.field,e),i=new Int32Array(t),s=!1;for(let N=t;N>0;N--){let R=r.evaluateAt(this.field.exp(N));i[t-N]=R,R!==0&&(s=!0)}if(!s)return 0;let o=this.field.getOne();if(n!=null)for(const N of n){let R=this.field.exp(e.length-1-N),B=new $e(this.field,new Int32Array([this.field.subtract(0,R),1]));o=o.multiply(B)}let a=new $e(this.field,i),l=this.runEuclideanAlgorithm(this.field.buildMonomial(t,1),a,t),d=l[0],A=l[1],E=this.findErrorLocations(d),b=this.findErrorMagnitudes(A,d,E);for(let N=0;N<E.length;N++){let R=e.length-1-this.field.log(E[N]);if(R<0)throw Q.getChecksumInstance();e[R]=this.field.subtract(e[R],b[N])}return E.length}runEuclideanAlgorithm(e,t,n){if(e.getDegree()<t.getDegree()){let E=e;e=t,t=E}let r=e,i=t,s=this.field.getZero(),o=this.field.getOne();for(;i.getDegree()>=Math.round(n/2);){let E=r,b=s;if(r=i,s=o,r.isZero())throw Q.getChecksumInstance();i=E;let N=this.field.getZero(),R=r.getCoefficient(r.getDegree()),B=this.field.inverse(R);for(;i.getDegree()>=r.getDegree()&&!i.isZero();){let L=i.getDegree()-r.getDegree(),X=this.field.multiply(i.getCoefficient(i.getDegree()),B);N=N.add(this.field.buildMonomial(L,X)),i=i.subtract(r.multiplyByMonomial(L,X))}o=N.multiply(s).subtract(b).negative()}let a=o.getCoefficient(0);if(a===0)throw Q.getChecksumInstance();let l=this.field.inverse(a),d=o.multiply(l),A=i.multiply(l);return[d,A]}findErrorLocations(e){let t=e.getDegree(),n=new Int32Array(t),r=0;for(let i=1;i<this.field.getSize()&&r<t;i++)e.evaluateAt(i)===0&&(n[r]=this.field.inverse(i),r++);if(r!==t)throw Q.getChecksumInstance();return n}findErrorMagnitudes(e,t,n){let r=t.getDegree(),i=new Int32Array(r);for(let l=1;l<=r;l++)i[r-l]=this.field.multiply(l,t.getCoefficient(l));let s=new $e(this.field,i),o=n.length,a=new Int32Array(o);for(let l=0;l<o;l++){let d=this.field.inverse(n[l]),A=this.field.subtract(0,e.evaluateAt(d)),E=this.field.inverse(s.evaluateAt(d));a[l]=this.field.multiply(A,E)}return a}}class cn{constructor(e,t,n,r,i){e instanceof cn?this.constructor_2(e):this.constructor_1(e,t,n,r,i)}constructor_1(e,t,n,r,i){const s=t==null||n==null,o=r==null||i==null;if(s&&o)throw new V;s?(t=new q(0,r.getY()),n=new q(0,i.getY())):o&&(r=new q(e.getWidth()-1,t.getY()),i=new q(e.getWidth()-1,n.getY())),this.image=e,this.topLeft=t,this.bottomLeft=n,this.topRight=r,this.bottomRight=i,this.minX=Math.trunc(Math.min(t.getX(),n.getX())),this.maxX=Math.trunc(Math.max(r.getX(),i.getX())),this.minY=Math.trunc(Math.min(t.getY(),r.getY())),this.maxY=Math.trunc(Math.max(n.getY(),i.getY()))}constructor_2(e){this.image=e.image,this.topLeft=e.getTopLeft(),this.bottomLeft=e.getBottomLeft(),this.topRight=e.getTopRight(),this.bottomRight=e.getBottomRight(),this.minX=e.getMinX(),this.maxX=e.getMaxX(),this.minY=e.getMinY(),this.maxY=e.getMaxY()}static merge(e,t){return e==null?t:t==null?e:new cn(e.image,e.topLeft,e.bottomLeft,t.topRight,t.bottomRight)}addMissingRows(e,t,n){let r=this.topLeft,i=this.bottomLeft,s=this.topRight,o=this.bottomRight;if(e>0){let a=n?this.topLeft:this.topRight,l=Math.trunc(a.getY()-e);l<0&&(l=0);let d=new q(a.getX(),l);n?r=d:s=d}if(t>0){let a=n?this.bottomLeft:this.bottomRight,l=Math.trunc(a.getY()+t);l>=this.image.getHeight()&&(l=this.image.getHeight()-1);let d=new q(a.getX(),l);n?i=d:o=d}return new cn(this.image,r,i,s,o)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class qs{constructor(e,t,n,r){this.columnCount=e,this.errorCorrectionLevel=r,this.rowCountUpperPart=t,this.rowCountLowerPart=n,this.rowCount=t+n}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Ln{constructor(){this.buffer=""}static form(e,t){let n=-1;function r(s,o,a,l,d,A){if(s==="%%")return"%";if(t[++n]===void 0)return;s=l?parseInt(l.substr(1)):void 0;let E=d?parseInt(d.substr(1)):void 0,b;switch(A){case"s":b=t[n];break;case"c":b=t[n][0];break;case"f":b=parseFloat(t[n]).toFixed(s);break;case"p":b=parseFloat(t[n]).toPrecision(s);break;case"e":b=parseFloat(t[n]).toExponential(s);break;case"x":b=parseInt(t[n]).toString(E||16);break;case"d":b=parseFloat(parseInt(t[n],E||10).toPrecision(s)).toFixed(0);break}b=typeof b=="object"?JSON.stringify(b):(+b).toString(E);let N=parseInt(a),R=a&&a[0]+""=="0"?"0":" ";for(;b.length<N;)b=o!==void 0?b+R:R+b;return b}let i=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(i,r)}format(e,...t){this.buffer+=Ln.form(e,t)}toString(){return this.buffer}}class Pn{constructor(e){this.boundingBox=new cn(e),this.codewords=new Array(e.getMaxY()-e.getMinY()+1)}getCodewordNearby(e){let t=this.getCodeword(e);if(t!=null)return t;for(let n=1;n<Pn.MAX_NEARBY_DISTANCE;n++){let r=this.imageRowToCodewordIndex(e)-n;if(r>=0&&(t=this.codewords[r],t!=null)||(r=this.imageRowToCodewordIndex(e)+n,r<this.codewords.length&&(t=this.codewords[r],t!=null)))return t}return null}imageRowToCodewordIndex(e){return e-this.boundingBox.getMinY()}setCodeword(e,t){this.codewords[this.imageRowToCodewordIndex(e)]=t}getCodeword(e){return this.codewords[this.imageRowToCodewordIndex(e)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const e=new Ln;let t=0;for(const n of this.codewords){if(n==null){e.format("%3d: | %n",t++);continue}e.format("%3d: %3d|%3d%n",t++,n.getRowNumber(),n.getValue())}return e.toString()}}Pn.MAX_NEARBY_DISTANCE=5;class kn{constructor(){this.values=new Map}setValue(e){e=Math.trunc(e);let t=this.values.get(e);t==null&&(t=0),t++,this.values.set(e,t)}getValue(){let e=-1,t=new Array;for(const[n,r]of this.values.entries()){const i={getKey:()=>n,getValue:()=>r};i.getValue()>e?(e=i.getValue(),t=[],t.push(i.getKey())):i.getValue()===e&&t.push(i.getKey())}return ie.toIntArray(t)}getConfidence(e){return this.values.get(e)}}class pi extends Pn{constructor(e,t){super(e),this._isLeft=t}setRowNumbers(){for(let e of this.getCodewords())e!=null&&e.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let t=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(t,e);let n=this.getBoundingBox(),r=this._isLeft?n.getTopLeft():n.getTopRight(),i=this._isLeft?n.getBottomLeft():n.getBottomRight(),s=this.imageRowToCodewordIndex(Math.trunc(r.getY())),o=this.imageRowToCodewordIndex(Math.trunc(i.getY())),a=-1,l=1,d=0;for(let A=s;A<o;A++){if(t[A]==null)continue;let E=t[A],b=E.getRowNumber()-a;if(b===0)d++;else if(b===1)l=Math.max(l,d),d=1,a=E.getRowNumber();else if(b<0||E.getRowNumber()>=e.getRowCount()||b>A)t[A]=null;else{let N;l>2?N=(l-2)*b:N=b;let R=N>=A;for(let B=1;B<=N&&!R;B++)R=t[A-B]!=null;R?t[A]=null:(a=E.getRowNumber(),d=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(e==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let t=new Int32Array(e.getRowCount());for(let n of this.getCodewords())if(n!=null){let r=n.getRowNumber();if(r>=t.length)continue;t[r]++}return t}adjustIncompleteIndicatorColumnRowNumbers(e){let t=this.getBoundingBox(),n=this._isLeft?t.getTopLeft():t.getTopRight(),r=this._isLeft?t.getBottomLeft():t.getBottomRight(),i=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.imageRowToCodewordIndex(Math.trunc(r.getY())),o=this.getCodewords(),a=-1;for(let l=i;l<s;l++){if(o[l]==null)continue;let d=o[l];d.setRowNumberAsRowIndicatorColumn();let A=d.getRowNumber()-a;A===0||(A===1?a=d.getRowNumber():d.getRowNumber()>=e.getRowCount()?o[l]=null:a=d.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),t=new kn,n=new kn,r=new kn,i=new kn;for(let o of e){if(o==null)continue;o.setRowNumberAsRowIndicatorColumn();let a=o.getValue()%30,l=o.getRowNumber();switch(this._isLeft||(l+=2),l%3){case 0:n.setValue(a*3+1);break;case 1:i.setValue(a/3),r.setValue(a%3);break;case 2:t.setValue(a+1);break}}if(t.getValue().length===0||n.getValue().length===0||r.getValue().length===0||i.getValue().length===0||t.getValue()[0]<1||n.getValue()[0]+r.getValue()[0]<ie.MIN_ROWS_IN_BARCODE||n.getValue()[0]+r.getValue()[0]>ie.MAX_ROWS_IN_BARCODE)return null;let s=new qs(t.getValue()[0],n.getValue()[0],r.getValue()[0],i.getValue()[0]);return this.removeIncorrectCodewords(e,s),s}removeIncorrectCodewords(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(e[n]==null)continue;let i=r.getValue()%30,s=r.getRowNumber();if(s>t.getRowCount()){e[n]=null;continue}switch(this._isLeft||(s+=2),s%3){case 0:i*3+1!==t.getRowCountUpperPart()&&(e[n]=null);break;case 1:(Math.trunc(i/3)!==t.getErrorCorrectionLevel()||i%3!==t.getRowCountLowerPart())&&(e[n]=null);break;case 2:i+1!==t.getColumnCount()&&(e[n]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
|
|
12
|
+
`+super.toString()}}class Un{constructor(e,t){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=e,this.barcodeColumnCount=e.getColumnCount(),this.boundingBox=t,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let e=ie.MAX_CODEWORDS_IN_BARCODE,t;do t=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e<t);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(e){e!=null&&e.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let e=this.adjustRowNumbersByRow();if(e===0)return 0;for(let t=1;t<this.barcodeColumnCount+1;t++){let n=this.detectionResultColumns[t].getCodewords();for(let r=0;r<n.length;r++)n[r]!=null&&(n[r].hasValidRowNumber()||this.adjustRowNumbers(t,r,n))}return e}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let e=this.detectionResultColumns[0].getCodewords(),t=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let n=0;n<e.length;n++)if(e[n]!=null&&t[n]!=null&&e[n].getRowNumber()===t[n].getRowNumber())for(let r=1;r<=this.barcodeColumnCount;r++){let i=this.detectionResultColumns[r].getCodewords()[n];i!=null&&(i.setRowNumber(e[n].getRowNumber()),i.hasValidRowNumber()||(this.detectionResultColumns[r].getCodewords()[n]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let e=0,t=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let n=0;n<t.length;n++){if(t[n]==null)continue;let r=t[n].getRowNumber(),i=0;for(let s=this.barcodeColumnCount+1;s>0&&i<this.ADJUST_ROW_NUMBER_SKIP;s--){let o=this.detectionResultColumns[s].getCodewords()[n];o!=null&&(i=Un.adjustRowNumberIfValid(r,i,o),o.hasValidRowNumber()||e++)}}return e}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let e=0,t=this.detectionResultColumns[0].getCodewords();for(let n=0;n<t.length;n++){if(t[n]==null)continue;let r=t[n].getRowNumber(),i=0;for(let s=1;s<this.barcodeColumnCount+1&&i<this.ADJUST_ROW_NUMBER_SKIP;s++){let o=this.detectionResultColumns[s].getCodewords()[n];o!=null&&(i=Un.adjustRowNumberIfValid(r,i,o),o.hasValidRowNumber()||e++)}}return e}static adjustRowNumberIfValid(e,t,n){return n==null||n.hasValidRowNumber()||(n.isValidRowNumber(e)?(n.setRowNumber(e),t=0):++t),t}adjustRowNumbers(e,t,n){if(!this.detectionResultColumns[e-1])return;let r=n[t],i=this.detectionResultColumns[e-1].getCodewords(),s=i;this.detectionResultColumns[e+1]!=null&&(s=this.detectionResultColumns[e+1].getCodewords());let o=new Array(14);o[2]=i[t],o[3]=s[t],t>0&&(o[0]=n[t-1],o[4]=i[t-1],o[5]=s[t-1]),t>1&&(o[8]=n[t-2],o[10]=i[t-2],o[11]=s[t-2]),t<n.length-1&&(o[1]=n[t+1],o[6]=i[t+1],o[7]=s[t+1]),t<n.length-2&&(o[9]=n[t+2],o[12]=i[t+2],o[13]=s[t+2]);for(let a of o)if(Un.adjustRowNumber(r,a))return}static adjustRowNumber(e,t){return t==null?!1:t.hasValidRowNumber()&&t.getBucket()===e.getBucket()?(e.setRowNumber(t.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(e){this.boundingBox=e}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(e,t){this.detectionResultColumns[e]=t}getDetectionResultColumn(e){return this.detectionResultColumns[e]}toString(){let e=this.detectionResultColumns[0];e==null&&(e=this.detectionResultColumns[this.barcodeColumnCount+1]);let t=new Ln;for(let n=0;n<e.getCodewords().length;n++){t.format("CW %3d:",n);for(let r=0;r<this.barcodeColumnCount+2;r++){if(this.detectionResultColumns[r]==null){t.format(" | ");continue}let i=this.detectionResultColumns[r].getCodewords()[n];if(i==null){t.format(" | ");continue}t.format(" %3d|%3d",i.getRowNumber(),i.getValue())}t.format("%n")}return t.toString()}}class Vn{constructor(e,t,n,r){this.rowNumber=Vn.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(e),this.endX=Math.trunc(t),this.bucket=Math.trunc(n),this.value=Math.trunc(r)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(e){return e!==Vn.BARCODE_ROW_UNKNOWN&&this.bucket===e%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(e){this.rowNumber=e}toString(){return this.rowNumber+"|"+this.value}}Vn.BARCODE_ROW_UNKNOWN=-1;class ht{static initialize(){for(let e=0;e<ie.SYMBOL_TABLE.length;e++){let t=ie.SYMBOL_TABLE[e],n=t&1;for(let r=0;r<ie.BARS_IN_MODULE;r++){let i=0;for(;(t&1)===n;)i+=1,t>>=1;n=t&1,ht.RATIOS_TABLE[e]||(ht.RATIOS_TABLE[e]=new Array(ie.BARS_IN_MODULE)),ht.RATIOS_TABLE[e][ie.BARS_IN_MODULE-r-1]=Math.fround(i/ie.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let t=ht.getDecodedCodewordValue(ht.sampleBitCounts(e));return t!==-1?t:ht.getClosestDecodedValue(e)}static sampleBitCounts(e){let t=we.sum(e),n=new Int32Array(ie.BARS_IN_MODULE),r=0,i=0;for(let s=0;s<ie.MODULES_IN_CODEWORD;s++){let o=t/(2*ie.MODULES_IN_CODEWORD)+s*t/ie.MODULES_IN_CODEWORD;i+e[r]<=o&&(i+=e[r],r++),n[r]++}return n}static getDecodedCodewordValue(e){let t=ht.getBitValue(e);return ie.getCodeword(t)===-1?-1:t}static getBitValue(e){let t=0;for(let n=0;n<e.length;n++)for(let r=0;r<e[n];r++)t=t<<1|(n%2===0?1:0);return Math.trunc(t)}static getClosestDecodedValue(e){let t=we.sum(e),n=new Array(ie.BARS_IN_MODULE);if(t>1)for(let s=0;s<n.length;s++)n[s]=Math.fround(e[s]/t);let r=sn.MAX_VALUE,i=-1;this.bSymbolTableReady||ht.initialize();for(let s=0;s<ht.RATIOS_TABLE.length;s++){let o=0,a=ht.RATIOS_TABLE[s];for(let l=0;l<ie.BARS_IN_MODULE;l++){let d=Math.fround(a[l]-n[l]);if(o+=Math.fround(d*d),o>=r)break}o<r&&(r=o,i=ie.SYMBOL_TABLE[s])}return i}}ht.bSymbolTableReady=!1,ht.RATIOS_TABLE=new Array(ie.SYMBOL_TABLE.length).map(w=>new Array(ie.BARS_IN_MODULE));class mi{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(e){this.segmentIndex=e}getFileId(){return this.fileId}setFileId(e){this.fileId=e}getOptionalData(){return this.optionalData}setOptionalData(e){this.optionalData=e}isLastSegment(){return this.lastSegment}setLastSegment(e){this.lastSegment=e}getSegmentCount(){return this.segmentCount}setSegmentCount(e){this.segmentCount=e}getSender(){return this.sender||null}setSender(e){this.sender=e}getAddressee(){return this.addressee||null}setAddressee(e){this.addressee=e}getFileName(){return this.fileName}setFileName(e){this.fileName=e}getFileSize(){return this.fileSize}setFileSize(e){this.fileSize=e}getChecksum(){return this.checksum}setChecksum(e){this.checksum=e}getTimestamp(){return this.timestamp}setTimestamp(e){this.timestamp=e}}class Ii{static parseLong(e,t=void 0){return parseInt(e,t)}}class yi extends p{}yi.kind="NullPointerException";class Qs{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,t,n){if(e==null)throw new yi;if(t<0||t>e.length||n<0||t+n>e.length||t+n<0)throw new pt;if(n===0)return;for(let r=0;r<n;r++)this.write(e[t+r])}flush(){}close(){}}class Js extends p{}class $s extends Qs{constructor(e=32){if(super(),this.count=0,e<0)throw new M("Negative initial size: "+e);this.buf=new Uint8Array(e)}ensureCapacity(e){e-this.buf.length>0&&this.grow(e)}grow(e){let n=this.buf.length<<1;if(n-e<0&&(n=e),n<0){if(e<0)throw new Js;n=ne.MAX_VALUE}this.buf=Ne.copyOfUint8Array(this.buf,n)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,t,n){if(t<0||t>e.length||n<0||t+n-e.length>0)throw new pt;this.ensureCapacity(this.count+n),he.arraycopy(e,t,this.buf,this.count,n),this.count+=n}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return Ne.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(e){return e?typeof e=="string"?this.toString_string(e):this.toString_number(e):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(e){return new String(this.buf).toString()}toString_number(e){return new String(this.buf).toString()}close(){}}var Oe;(function(w){w[w.ALPHA=0]="ALPHA",w[w.LOWER=1]="LOWER",w[w.MIXED=2]="MIXED",w[w.PUNCT=3]="PUNCT",w[w.ALPHA_SHIFT=4]="ALPHA_SHIFT",w[w.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Oe||(Oe={}));function bi(){if(typeof window<"u")return window.BigInt||null;if(typeof vn<"u")return vn.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let er;function Jt(w){if(typeof er>"u"&&(er=bi()),er===null)throw new Error("BigInt is not supported!");return er(w)}function eo(){let w=[];w[0]=Jt(1);let e=Jt(900);w[1]=e;for(let t=2;t<16;t++)w[t]=w[t-1]*e;return w}class F{static decode(e,t){let n=new Te(""),r=z.ISO8859_1;n.enableDecoding(r);let i=1,s=e[i++],o=new mi;for(;i<e[0];){switch(s){case F.TEXT_COMPACTION_MODE_LATCH:i=F.textCompaction(e,i,n);break;case F.BYTE_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH_6:i=F.byteCompaction(s,e,r,i,n);break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[i++]);break;case F.NUMERIC_COMPACTION_MODE_LATCH:i=F.numericCompaction(e,i,n);break;case F.ECI_CHARSET:z.getCharacterSetECIByValue(e[i++]);break;case F.ECI_GENERAL_PURPOSE:i+=2;break;case F.ECI_USER_DEFINED:i++;break;case F.BEGIN_MACRO_PDF417_CONTROL_BLOCK:i=F.decodeMacroBlock(e,i,o);break;case F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case F.MACRO_PDF417_TERMINATOR:throw new Z;default:i--,i=F.textCompaction(e,i,n);break}if(i<e.length)s=e[i++];else throw Z.getFormatInstance()}if(n.length()===0)throw Z.getFormatInstance();let a=new Xt(null,n.toString(),null,t);return a.setOther(o),a}static decodeMacroBlock(e,t,n){if(t+F.NUMBER_OF_SEQUENCE_CODEWORDS>e[0])throw Z.getFormatInstance();let r=new Int32Array(F.NUMBER_OF_SEQUENCE_CODEWORDS);for(let o=0;o<F.NUMBER_OF_SEQUENCE_CODEWORDS;o++,t++)r[o]=e[t];n.setSegmentIndex(ne.parseInt(F.decodeBase900toBase10(r,F.NUMBER_OF_SEQUENCE_CODEWORDS)));let i=new Te;t=F.textCompaction(e,t,i),n.setFileId(i.toString());let s=-1;for(e[t]===F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(s=t+1);t<e[0];)switch(e[t]){case F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(t++,e[t]){case F.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let o=new Te;t=F.textCompaction(e,t+1,o),n.setFileName(o.toString());break;case F.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let a=new Te;t=F.textCompaction(e,t+1,a),n.setSender(a.toString());break;case F.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let l=new Te;t=F.textCompaction(e,t+1,l),n.setAddressee(l.toString());break;case F.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let d=new Te;t=F.numericCompaction(e,t+1,d),n.setSegmentCount(ne.parseInt(d.toString()));break;case F.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let A=new Te;t=F.numericCompaction(e,t+1,A),n.setTimestamp(Ii.parseLong(A.toString()));break;case F.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let E=new Te;t=F.numericCompaction(e,t+1,E),n.setChecksum(ne.parseInt(E.toString()));break;case F.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let b=new Te;t=F.numericCompaction(e,t+1,b),n.setFileSize(Ii.parseLong(b.toString()));break;default:throw Z.getFormatInstance()}break;case F.MACRO_PDF417_TERMINATOR:t++,n.setLastSegment(!0);break;default:throw Z.getFormatInstance()}if(s!==-1){let o=t-s;n.isLastSegment()&&o--,n.setOptionalData(Ne.copyOfRange(e,s,s+o))}return t}static textCompaction(e,t,n){let r=new Int32Array((e[0]-t)*2),i=new Int32Array((e[0]-t)*2),s=0,o=!1;for(;t<e[0]&&!o;){let a=e[t++];if(a<F.TEXT_COMPACTION_MODE_LATCH)r[s]=a/30,r[s+1]=a%30,s+=2;else switch(a){case F.TEXT_COMPACTION_MODE_LATCH:r[s++]=F.TEXT_COMPACTION_MODE_LATCH;break;case F.BYTE_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH_6:case F.NUMERIC_COMPACTION_MODE_LATCH:case F.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case F.MACRO_PDF417_TERMINATOR:t--,o=!0;break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r[s]=F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,a=e[t++],i[s]=a,s++;break}}return F.decodeTextCompaction(r,i,s,n),t}static decodeTextCompaction(e,t,n,r){let i=Oe.ALPHA,s=Oe.ALPHA,o=0;for(;o<n;){let a=e[o],l="";switch(i){case Oe.ALPHA:if(a<26)l=String.fromCharCode(65+a);else switch(a){case 26:l=" ";break;case F.LL:i=Oe.LOWER;break;case F.ML:i=Oe.MIXED;break;case F.PS:s=i,i=Oe.PUNCT_SHIFT;break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[o]);break;case F.TEXT_COMPACTION_MODE_LATCH:i=Oe.ALPHA;break}break;case Oe.LOWER:if(a<26)l=String.fromCharCode(97+a);else switch(a){case 26:l=" ";break;case F.AS:s=i,i=Oe.ALPHA_SHIFT;break;case F.ML:i=Oe.MIXED;break;case F.PS:s=i,i=Oe.PUNCT_SHIFT;break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[o]);break;case F.TEXT_COMPACTION_MODE_LATCH:i=Oe.ALPHA;break}break;case Oe.MIXED:if(a<F.PL)l=F.MIXED_CHARS[a];else switch(a){case F.PL:i=Oe.PUNCT;break;case 26:l=" ";break;case F.LL:i=Oe.LOWER;break;case F.AL:i=Oe.ALPHA;break;case F.PS:s=i,i=Oe.PUNCT_SHIFT;break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[o]);break;case F.TEXT_COMPACTION_MODE_LATCH:i=Oe.ALPHA;break}break;case Oe.PUNCT:if(a<F.PAL)l=F.PUNCT_CHARS[a];else switch(a){case F.PAL:i=Oe.ALPHA;break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[o]);break;case F.TEXT_COMPACTION_MODE_LATCH:i=Oe.ALPHA;break}break;case Oe.ALPHA_SHIFT:if(i=s,a<26)l=String.fromCharCode(65+a);else switch(a){case 26:l=" ";break;case F.TEXT_COMPACTION_MODE_LATCH:i=Oe.ALPHA;break}break;case Oe.PUNCT_SHIFT:if(i=s,a<F.PAL)l=F.PUNCT_CHARS[a];else switch(a){case F.PAL:i=Oe.ALPHA;break;case F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[o]);break;case F.TEXT_COMPACTION_MODE_LATCH:i=Oe.ALPHA;break}break}l!==""&&r.append(l),o++}}static byteCompaction(e,t,n,r,i){let s=new $s,o=0,a=0,l=!1;switch(e){case F.BYTE_COMPACTION_MODE_LATCH:let d=new Int32Array(6),A=t[r++];for(;r<t[0]&&!l;)switch(d[o++]=A,a=900*a+A,A=t[r++],A){case F.TEXT_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH:case F.NUMERIC_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH_6:case F.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case F.MACRO_PDF417_TERMINATOR:r--,l=!0;break;default:if(o%5===0&&o>0){for(let E=0;E<6;++E)s.write(Number(Jt(a)>>Jt(8*(5-E))));a=0,o=0}break}r===t[0]&&A<F.TEXT_COMPACTION_MODE_LATCH&&(d[o++]=A);for(let E=0;E<o;E++)s.write(d[E]);break;case F.BYTE_COMPACTION_MODE_LATCH_6:for(;r<t[0]&&!l;){let E=t[r++];if(E<F.TEXT_COMPACTION_MODE_LATCH)o++,a=900*a+E;else switch(E){case F.TEXT_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH:case F.NUMERIC_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH_6:case F.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case F.MACRO_PDF417_TERMINATOR:r--,l=!0;break}if(o%5===0&&o>0){for(let b=0;b<6;++b)s.write(Number(Jt(a)>>Jt(8*(5-b))));a=0,o=0}}break}return i.append(rt.decode(s.toByteArray(),n)),r}static numericCompaction(e,t,n){let r=0,i=!1,s=new Int32Array(F.MAX_NUMERIC_CODEWORDS);for(;t<e[0]&&!i;){let o=e[t++];if(t===e[0]&&(i=!0),o<F.TEXT_COMPACTION_MODE_LATCH)s[r]=o,r++;else switch(o){case F.TEXT_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH:case F.BYTE_COMPACTION_MODE_LATCH_6:case F.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case F.MACRO_PDF417_TERMINATOR:t--,i=!0;break}(r%F.MAX_NUMERIC_CODEWORDS===0||o===F.NUMERIC_COMPACTION_MODE_LATCH||i)&&r>0&&(n.append(F.decodeBase900toBase10(s,r)),r=0)}return t}static decodeBase900toBase10(e,t){let n=Jt(0);for(let i=0;i<t;i++)n+=F.EXP900[t-i-1]*Jt(e[i]);let r=n.toString();if(r.charAt(0)!=="1")throw new Z;return r.substring(1)}}F.TEXT_COMPACTION_MODE_LATCH=900,F.BYTE_COMPACTION_MODE_LATCH=901,F.NUMERIC_COMPACTION_MODE_LATCH=902,F.BYTE_COMPACTION_MODE_LATCH_6=924,F.ECI_USER_DEFINED=925,F.ECI_GENERAL_PURPOSE=926,F.ECI_CHARSET=927,F.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,F.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,F.MACRO_PDF417_TERMINATOR=922,F.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,F.MAX_NUMERIC_CODEWORDS=15,F.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,F.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,F.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,F.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,F.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,F.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,F.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,F.PL=25,F.LL=27,F.AS=27,F.ML=28,F.AL=28,F.PS=29,F.PAL=29,F.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,:
|
|
13
|
+
-.$/"|*()?{}'`,F.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",F.EXP900=bi()?eo():[],F.NUMBER_OF_SEQUENCE_CODEWORDS=2;class de{constructor(){}static decode(e,t,n,r,i,s,o){let a=new cn(e,t,n,r,i),l=null,d=null,A;for(let N=!0;;N=!1){if(t!=null&&(l=de.getRowIndicatorColumn(e,a,t,!0,s,o)),r!=null&&(d=de.getRowIndicatorColumn(e,a,r,!1,s,o)),A=de.merge(l,d),A==null)throw V.getNotFoundInstance();let R=A.getBoundingBox();if(N&&R!=null&&(R.getMinY()<a.getMinY()||R.getMaxY()>a.getMaxY()))a=R;else break}A.setBoundingBox(a);let E=A.getBarcodeColumnCount()+1;A.setDetectionResultColumn(0,l),A.setDetectionResultColumn(E,d);let b=l!=null;for(let N=1;N<=E;N++){let R=b?N:E-N;if(A.getDetectionResultColumn(R)!==void 0)continue;let B;R===0||R===E?B=new pi(a,R===0):B=new Pn(a),A.setDetectionResultColumn(R,B);let L=-1,X=L;for(let Y=a.getMinY();Y<=a.getMaxY();Y++){if(L=de.getStartColumn(A,R,Y,b),L<0||L>a.getMaxX()){if(X===-1)continue;L=X}let H=de.detectCodeword(e,a.getMinX(),a.getMaxX(),b,L,Y,s,o);H!=null&&(B.setCodeword(Y,H),X=L,s=Math.min(s,H.getWidth()),o=Math.max(o,H.getWidth()))}}return de.createDecoderResult(A)}static merge(e,t){if(e==null&&t==null)return null;let n=de.getBarcodeMetadata(e,t);if(n==null)return null;let r=cn.merge(de.adjustBoundingBox(e),de.adjustBoundingBox(t));return new Un(n,r)}static adjustBoundingBox(e){if(e==null)return null;let t=e.getRowHeights();if(t==null)return null;let n=de.getMax(t),r=0;for(let o of t)if(r+=n-o,o>0)break;let i=e.getCodewords();for(let o=0;r>0&&i[o]==null;o++)r--;let s=0;for(let o=t.length-1;o>=0&&(s+=n-t[o],!(t[o]>0));o--);for(let o=i.length-1;s>0&&i[o]==null;o--)s--;return e.getBoundingBox().addMissingRows(r,s,e.isLeft())}static getMax(e){let t=-1;for(let n of e)t=Math.max(t,n);return t}static getBarcodeMetadata(e,t){let n;if(e==null||(n=e.getBarcodeMetadata())==null)return t==null?null:t.getBarcodeMetadata();let r;return t==null||(r=t.getBarcodeMetadata())==null?n:n.getColumnCount()!==r.getColumnCount()&&n.getErrorCorrectionLevel()!==r.getErrorCorrectionLevel()&&n.getRowCount()!==r.getRowCount()?null:n}static getRowIndicatorColumn(e,t,n,r,i,s){let o=new pi(t,r);for(let a=0;a<2;a++){let l=a===0?1:-1,d=Math.trunc(Math.trunc(n.getX()));for(let A=Math.trunc(Math.trunc(n.getY()));A<=t.getMaxY()&&A>=t.getMinY();A+=l){let E=de.detectCodeword(e,0,e.getWidth(),r,d,A,i,s);E!=null&&(o.setCodeword(A,E),r?d=E.getStartX():d=E.getEndX())}}return o}static adjustCodewordCount(e,t){let n=t[0][1],r=n.getValue(),i=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-de.getNumberOfECCodeWords(e.getBarcodeECLevel());if(r.length===0){if(i<1||i>ie.MAX_CODEWORDS_IN_BARCODE)throw V.getNotFoundInstance();n.setValue(i)}else r[0]!==i&&n.setValue(i)}static createDecoderResult(e){let t=de.createBarcodeMatrix(e);de.adjustCodewordCount(e,t);let n=new Array,r=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),i=[],s=new Array;for(let a=0;a<e.getBarcodeRowCount();a++)for(let l=0;l<e.getBarcodeColumnCount();l++){let d=t[a][l+1].getValue(),A=a*e.getBarcodeColumnCount()+l;d.length===0?n.push(A):d.length===1?r[A]=d[0]:(s.push(A),i.push(d))}let o=new Array(i.length);for(let a=0;a<o.length;a++)o[a]=i[a];return de.createDecoderResultFromAmbiguousValues(e.getBarcodeECLevel(),r,ie.toIntArray(n),ie.toIntArray(s),o)}static createDecoderResultFromAmbiguousValues(e,t,n,r,i){let s=new Int32Array(r.length),o=100;for(;o-- >0;){for(let a=0;a<s.length;a++)t[r[a]]=i[a][s[a]];try{return de.decodeCodewords(t,e,n)}catch(a){if(!(a instanceof Q))throw a}if(s.length===0)throw Q.getChecksumInstance();for(let a=0;a<s.length;a++)if(s[a]<i[a].length-1){s[a]++;break}else if(s[a]=0,a===s.length-1)throw Q.getChecksumInstance()}throw Q.getChecksumInstance()}static createBarcodeMatrix(e){let t=Array.from({length:e.getBarcodeRowCount()},()=>new Array(e.getBarcodeColumnCount()+2));for(let r=0;r<t.length;r++)for(let i=0;i<t[r].length;i++)t[r][i]=new kn;let n=0;for(let r of e.getDetectionResultColumns()){if(r!=null){for(let i of r.getCodewords())if(i!=null){let s=i.getRowNumber();if(s>=0){if(s>=t.length)continue;t[s][n].setValue(i.getValue())}}}n++}return t}static isValidBarcodeColumn(e,t){return t>=0&&t<=e.getBarcodeColumnCount()+1}static getStartColumn(e,t,n,r){let i=r?1:-1,s=null;if(de.isValidBarcodeColumn(e,t-i)&&(s=e.getDetectionResultColumn(t-i).getCodeword(n)),s!=null)return r?s.getEndX():s.getStartX();if(s=e.getDetectionResultColumn(t).getCodewordNearby(n),s!=null)return r?s.getStartX():s.getEndX();if(de.isValidBarcodeColumn(e,t-i)&&(s=e.getDetectionResultColumn(t-i).getCodewordNearby(n)),s!=null)return r?s.getEndX():s.getStartX();let o=0;for(;de.isValidBarcodeColumn(e,t-i);){t-=i;for(let a of e.getDetectionResultColumn(t).getCodewords())if(a!=null)return(r?a.getEndX():a.getStartX())+i*o*(a.getEndX()-a.getStartX());o++}return r?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,t,n,r,i,s,o,a){i=de.adjustCodewordStartColumn(e,t,n,r,i,s);let l=de.getModuleBitCount(e,t,n,r,i,s);if(l==null)return null;let d,A=we.sum(l);if(r)d=i+A;else{for(let N=0;N<l.length/2;N++){let R=l[N];l[N]=l[l.length-1-N],l[l.length-1-N]=R}d=i,i=d-A}if(!de.checkCodewordSkew(A,o,a))return null;let E=ht.getDecodedValue(l),b=ie.getCodeword(E);return b===-1?null:new Vn(i,d,de.getCodewordBucketNumber(E),b)}static getModuleBitCount(e,t,n,r,i,s){let o=i,a=new Int32Array(8),l=0,d=r?1:-1,A=r;for(;(r?o<n:o>=t)&&l<a.length;)e.get(o,s)===A?(a[l]++,o+=d):(l++,A=!A);return l===a.length||o===(r?n:t)&&l===a.length-1?a:null}static getNumberOfECCodeWords(e){return 2<<e}static adjustCodewordStartColumn(e,t,n,r,i,s){let o=i,a=r?-1:1;for(let l=0;l<2;l++){for(;(r?o>=t:o<n)&&r===e.get(o,s);){if(Math.abs(i-o)>de.CODEWORD_SKEW_SIZE)return i;o+=a}a=-a,r=!r}return o}static checkCodewordSkew(e,t,n){return t-de.CODEWORD_SKEW_SIZE<=e&&e<=n+de.CODEWORD_SKEW_SIZE}static decodeCodewords(e,t,n){if(e.length===0)throw Z.getFormatInstance();let r=1<<t+1,i=de.correctErrors(e,n,r);de.verifyCodewordCount(e,r);let s=F.decode(e,""+t);return s.setErrorsCorrected(i),s.setErasures(n.length),s}static correctErrors(e,t,n){if(t!=null&&t.length>n/2+de.MAX_ERRORS||n<0||n>de.MAX_EC_CODEWORDS)throw Q.getChecksumInstance();return de.errorCorrection.decode(e,n,t)}static verifyCodewordCount(e,t){if(e.length<4)throw Z.getFormatInstance();let n=e[0];if(n>e.length)throw Z.getFormatInstance();if(n===0)if(t<e.length)e[0]=e.length-t;else throw Z.getFormatInstance()}static getBitCountForCodeword(e){let t=new Int32Array(8),n=0,r=t.length-1;for(;!((e&1)!==n&&(n=e&1,r--,r<0));)t[r]++,e>>=1;return t}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return de.getCodewordBucketNumber(de.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let t=new Ln;for(let n=0;n<e.length;n++){t.format("Row %2d: ",n);for(let r=0;r<e[n].length;r++){let i=e[n][r];i.getValue().length===0?t.format(" ",null):t.format("%4d(%2d)",i.getValue()[0],i.getConfidence(i.getValue()[0]))}t.format("%n")}return t.toString()}}de.CODEWORD_SKEW_SIZE=2,de.MAX_ERRORS=3,de.MAX_EC_CODEWORDS=512,de.errorCorrection=new Ci;class et{decode(e,t=null){let n=et.decode(e,t,!1);if(n==null||n.length===0||n[0]==null)throw V.getNotFoundInstance();return n[0]}decodeMultiple(e,t=null){try{return et.decode(e,t,!0)}catch(n){throw n instanceof Z||n instanceof Q?V.getNotFoundInstance():n}}static decode(e,t,n){const r=new Array,i=fe.detectMultiple(e,t,n);for(const s of i.getPoints()){const o=de.decode(i.getBits(),s[4],s[5],s[6],s[7],et.getMinCodewordWidth(s),et.getMaxCodewordWidth(s)),a=new qe(o.getText(),o.getRawBytes(),void 0,s,$.PDF_417);a.putMetadata(Fe.ERROR_CORRECTION_LEVEL,o.getECLevel());const l=o.getOther();l!=null&&a.putMetadata(Fe.PDF417_EXTRA_METADATA,l),r.push(a)}return r.map(s=>s)}static getMaxWidth(e,t){return e==null||t==null?0:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMinWidth(e,t){return e==null||t==null?ne.MAX_VALUE:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(et.getMaxWidth(e[0],e[4]),et.getMaxWidth(e[6],e[2])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN),Math.max(et.getMaxWidth(e[1],e[5]),et.getMaxWidth(e[7],e[3])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(et.getMinWidth(e[0],e[4]),et.getMinWidth(e[6],e[2])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN),Math.min(et.getMinWidth(e[1],e[5]),et.getMinWidth(e[7],e[3])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN)))}reset(){}}class tr extends p{}tr.kind="ReaderException";class Ti{constructor(e,t){this.verbose=e===!0,t&&this.setHints(t)}decode(e,t){return t&&this.setHints(t),this.decodeInternal(e)}decodeWithState(e){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(e)}setHints(e){this.hints=e;const t=!m(e)&&e.get(me.TRY_HARDER)===!0,n=m(e)?null:e.get(me.POSSIBLE_FORMATS),r=new Array;if(!m(n)){const i=n.some(s=>s===$.UPC_A||s===$.UPC_E||s===$.EAN_13||s===$.EAN_8||s===$.CODABAR||s===$.CODE_39||s===$.CODE_93||s===$.CODE_128||s===$.ITF||s===$.RSS_14||s===$.RSS_EXPANDED);i&&!t&&r.push(new bn(e,this.verbose)),n.includes($.QR_CODE)&&r.push(new Qt),n.includes($.DATA_MATRIX)&&r.push(new qt),n.includes($.AZTEC)&&r.push(new O),n.includes($.PDF_417)&&r.push(new et),i&&t&&r.push(new bn(e,this.verbose))}r.length===0&&(t||r.push(new bn(e,this.verbose)),r.push(new Qt),r.push(new qt),r.push(new O),r.push(new et),t&&r.push(new bn(e,this.verbose))),this.readers=r}reset(){if(this.readers!==null)for(const e of this.readers)e.reset()}decodeInternal(e){if(this.readers===null)throw new tr("No readers where selected, nothing can be read.");for(const t of this.readers)try{return t.decode(e,this.hints)}catch(n){if(n instanceof tr)continue}throw new V("No MultiFormat Readers were able to detect the code.")}}class to extends Lt{constructor(e=null,t=500){const n=new Ti;n.setHints(e),super(n,t)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class no extends Lt{constructor(e=500){super(new et,e)}}class ro extends Lt{constructor(e=500){super(new Qt,e)}}var Dr;(function(w){w[w.ERROR_CORRECTION=0]="ERROR_CORRECTION",w[w.CHARACTER_SET=1]="CHARACTER_SET",w[w.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",w[w.MIN_SIZE=3]="MIN_SIZE",w[w.MAX_SIZE=4]="MAX_SIZE",w[w.MARGIN=5]="MARGIN",w[w.PDF417_COMPACT=6]="PDF417_COMPACT",w[w.PDF417_COMPACTION=7]="PDF417_COMPACTION",w[w.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",w[w.AZTEC_LAYERS=9]="AZTEC_LAYERS",w[w.QR_VERSION=10]="QR_VERSION"})(Dr||(Dr={}));var Ke=Dr;class Mr{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new it(e,Int32Array.from([1])))}buildGenerator(e){const t=this.cachedGenerators;if(e>=t.length){let n=t[t.length-1];const r=this.field;for(let i=t.length;i<=e;i++){const s=n.multiply(new it(r,Int32Array.from([1,r.exp(i-1+r.getGeneratorBase())])));t.push(s),n=s}}return t[e]}encode(e,t){if(t===0)throw new M("No error correction bytes");const n=e.length-t;if(n<=0)throw new M("No data bytes provided");const r=this.buildGenerator(t),i=new Int32Array(n);he.arraycopy(e,0,i,0,n);let s=new it(this.field,i);s=s.multiplyByMonomial(t,1);const a=s.divide(r)[1].getCoefficients(),l=t-a.length;for(let d=0;d<l;d++)e[n+d]=0;he.arraycopy(a,0,e,n+l,a.length)}}class We{constructor(){}static applyMaskPenaltyRule1(e){return We.applyMaskPenaltyRule1Internal(e,!0)+We.applyMaskPenaltyRule1Internal(e,!1)}static applyMaskPenaltyRule2(e){let t=0;const n=e.getArray(),r=e.getWidth(),i=e.getHeight();for(let s=0;s<i-1;s++){const o=n[s];for(let a=0;a<r-1;a++){const l=o[a];l===o[a+1]&&l===n[s+1][a]&&l===n[s+1][a+1]&&t++}}return We.N2*t}static applyMaskPenaltyRule3(e){let t=0;const n=e.getArray(),r=e.getWidth(),i=e.getHeight();for(let s=0;s<i;s++)for(let o=0;o<r;o++){const a=n[s];o+6<r&&a[o]===1&&a[o+1]===0&&a[o+2]===1&&a[o+3]===1&&a[o+4]===1&&a[o+5]===0&&a[o+6]===1&&(We.isWhiteHorizontal(a,o-4,o)||We.isWhiteHorizontal(a,o+7,o+11))&&t++,s+6<i&&n[s][o]===1&&n[s+1][o]===0&&n[s+2][o]===1&&n[s+3][o]===1&&n[s+4][o]===1&&n[s+5][o]===0&&n[s+6][o]===1&&(We.isWhiteVertical(n,o,s-4,s)||We.isWhiteVertical(n,o,s+7,s+11))&&t++}return t*We.N3}static isWhiteHorizontal(e,t,n){t=Math.max(t,0),n=Math.min(n,e.length);for(let r=t;r<n;r++)if(e[r]===1)return!1;return!0}static isWhiteVertical(e,t,n,r){n=Math.max(n,0),r=Math.min(r,e.length);for(let i=n;i<r;i++)if(e[i][t]===1)return!1;return!0}static applyMaskPenaltyRule4(e){let t=0;const n=e.getArray(),r=e.getWidth(),i=e.getHeight();for(let a=0;a<i;a++){const l=n[a];for(let d=0;d<r;d++)l[d]===1&&t++}const s=e.getHeight()*e.getWidth();return Math.floor(Math.abs(t*2-s)*10/s)*We.N4}static getDataMaskBit(e,t,n){let r,i;switch(e){case 0:r=n+t&1;break;case 1:r=n&1;break;case 2:r=t%3;break;case 3:r=(n+t)%3;break;case 4:r=Math.floor(n/2)+Math.floor(t/3)&1;break;case 5:i=n*t,r=(i&1)+i%3;break;case 6:i=n*t,r=(i&1)+i%3&1;break;case 7:i=n*t,r=i%3+(n+t&1)&1;break;default:throw new M("Invalid mask pattern: "+e)}return r===0}static applyMaskPenaltyRule1Internal(e,t){let n=0;const r=t?e.getHeight():e.getWidth(),i=t?e.getWidth():e.getHeight(),s=e.getArray();for(let o=0;o<r;o++){let a=0,l=-1;for(let d=0;d<i;d++){const A=t?s[o][d]:s[d][o];A===l?a++:(a>=5&&(n+=We.N1+(a-5)),a=1,l=A)}a>=5&&(n+=We.N1+(a-5))}return n}}We.N1=3,We.N2=3,We.N3=40,We.N4=10;class nr{constructor(e,t){this.width=e,this.height=t;const n=new Array(t);for(let r=0;r!==t;r++)n[r]=new Uint8Array(e);this.bytes=n}getHeight(){return this.height}getWidth(){return this.width}get(e,t){return this.bytes[t][e]}getArray(){return this.bytes}setNumber(e,t,n){this.bytes[t][e]=n}setBoolean(e,t,n){this.bytes[t][e]=n?1:0}clear(e){for(const t of this.bytes)Ne.fill(t,e)}equals(e){if(!(e instanceof nr))return!1;const t=e;if(this.width!==t.width||this.height!==t.height)return!1;for(let n=0,r=this.height;n<r;++n){const i=this.bytes[n],s=t.bytes[n];for(let o=0,a=this.width;o<a;++o)if(i[o]!==s[o])return!1}return!0}toString(){const e=new Te;for(let t=0,n=this.height;t<n;++t){const r=this.bytes[t];for(let i=0,s=this.width;i<s;++i)switch(r[i]){case 0:e.append(" 0");break;case 1:e.append(" 1");break;default:e.append(" ");break}e.append(`
|
|
14
|
+
`)}return e.toString()}}class un{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const e=new Te;return e.append(`<<
|
|
15
|
+
`),e.append(" mode: "),e.append(this.mode?this.mode.toString():"null"),e.append(`
|
|
16
|
+
ecLevel: `),e.append(this.ecLevel?this.ecLevel.toString():"null"),e.append(`
|
|
17
|
+
version: `),e.append(this.version?this.version.toString():"null"),e.append(`
|
|
18
|
+
maskPattern: `),e.append(this.maskPattern.toString()),this.matrix?(e.append(`
|
|
19
|
+
matrix:
|
|
20
|
+
`),e.append(this.matrix.toString())):e.append(`
|
|
21
|
+
matrix: null
|
|
22
|
+
`),e.append(`>>
|
|
23
|
+
`),e.toString()}setMode(e){this.mode=e}setECLevel(e){this.ecLevel=e}setVersion(e){this.version=e}setMaskPattern(e){this.maskPattern=e}setMatrix(e){this.matrix=e}static isValidMaskPattern(e){return e>=0&&e<un.NUM_MASK_PATTERNS}}un.NUM_MASK_PATTERNS=8;class Be extends p{}Be.kind="WriterException";class re{constructor(){}static clearMatrix(e){e.clear(255)}static buildMatrix(e,t,n,r,i){re.clearMatrix(i),re.embedBasicPatterns(n,i),re.embedTypeInfo(t,r,i),re.maybeEmbedVersionInfo(n,i),re.embedDataBits(e,r,i)}static embedBasicPatterns(e,t){re.embedPositionDetectionPatternsAndSeparators(t),re.embedDarkDotAtLeftBottomCorner(t),re.maybeEmbedPositionAdjustmentPatterns(e,t),re.embedTimingPatterns(t)}static embedTypeInfo(e,t,n){const r=new Ee;re.makeTypeInfoBits(e,t,r);for(let i=0,s=r.getSize();i<s;++i){const o=r.get(r.getSize()-1-i),a=re.TYPE_INFO_COORDINATES[i],l=a[0],d=a[1];if(n.setBoolean(l,d,o),i<8){const A=n.getWidth()-i-1;n.setBoolean(A,8,o)}else{const E=n.getHeight()-7+(i-8);n.setBoolean(8,E,o)}}}static maybeEmbedVersionInfo(e,t){if(e.getVersionNumber()<7)return;const n=new Ee;re.makeVersionInfoBits(e,n);let r=6*3-1;for(let i=0;i<6;++i)for(let s=0;s<3;++s){const o=n.get(r);r--,t.setBoolean(i,t.getHeight()-11+s,o),t.setBoolean(t.getHeight()-11+s,i,o)}}static embedDataBits(e,t,n){let r=0,i=-1,s=n.getWidth()-1,o=n.getHeight()-1;for(;s>0;){for(s===6&&(s-=1);o>=0&&o<n.getHeight();){for(let a=0;a<2;++a){const l=s-a;if(!re.isEmpty(n.get(l,o)))continue;let d;r<e.getSize()?(d=e.get(r),++r):d=!1,t!==255&&We.getDataMaskBit(t,l,o)&&(d=!d),n.setBoolean(l,o,d)}o+=i}i=-i,o+=i,s-=2}if(r!==e.getSize())throw new Be("Not all bits consumed: "+r+"/"+e.getSize())}static findMSBSet(e){return 32-ne.numberOfLeadingZeros(e)}static calculateBCHCode(e,t){if(t===0)throw new M("0 polynomial");const n=re.findMSBSet(t);for(e<<=n-1;re.findMSBSet(e)>=n;)e^=t<<re.findMSBSet(e)-n;return e}static makeTypeInfoBits(e,t,n){if(!un.isValidMaskPattern(t))throw new Be("Invalid mask pattern");const r=e.getBits()<<3|t;n.appendBits(r,5);const i=re.calculateBCHCode(r,re.TYPE_INFO_POLY);n.appendBits(i,10);const s=new Ee;if(s.appendBits(re.TYPE_INFO_MASK_PATTERN,15),n.xor(s),n.getSize()!==15)throw new Be("should not happen but we got: "+n.getSize())}static makeVersionInfoBits(e,t){t.appendBits(e.getVersionNumber(),6);const n=re.calculateBCHCode(e.getVersionNumber(),re.VERSION_INFO_POLY);if(t.appendBits(n,12),t.getSize()!==18)throw new Be("should not happen but we got: "+t.getSize())}static isEmpty(e){return e===255}static embedTimingPatterns(e){for(let t=8;t<e.getWidth()-8;++t){const n=(t+1)%2;re.isEmpty(e.get(t,6))&&e.setNumber(t,6,n),re.isEmpty(e.get(6,t))&&e.setNumber(6,t,n)}}static embedDarkDotAtLeftBottomCorner(e){if(e.get(8,e.getHeight()-8)===0)throw new Be;e.setNumber(8,e.getHeight()-8,1)}static embedHorizontalSeparationPattern(e,t,n){for(let r=0;r<8;++r){if(!re.isEmpty(n.get(e+r,t)))throw new Be;n.setNumber(e+r,t,0)}}static embedVerticalSeparationPattern(e,t,n){for(let r=0;r<7;++r){if(!re.isEmpty(n.get(e,t+r)))throw new Be;n.setNumber(e,t+r,0)}}static embedPositionAdjustmentPattern(e,t,n){for(let r=0;r<5;++r){const i=re.POSITION_ADJUSTMENT_PATTERN[r];for(let s=0;s<5;++s)n.setNumber(e+s,t+r,i[s])}}static embedPositionDetectionPattern(e,t,n){for(let r=0;r<7;++r){const i=re.POSITION_DETECTION_PATTERN[r];for(let s=0;s<7;++s)n.setNumber(e+s,t+r,i[s])}}static embedPositionDetectionPatternsAndSeparators(e){const t=re.POSITION_DETECTION_PATTERN[0].length;re.embedPositionDetectionPattern(0,0,e),re.embedPositionDetectionPattern(e.getWidth()-t,0,e),re.embedPositionDetectionPattern(0,e.getWidth()-t,e);const n=8;re.embedHorizontalSeparationPattern(0,n-1,e),re.embedHorizontalSeparationPattern(e.getWidth()-n,n-1,e),re.embedHorizontalSeparationPattern(0,e.getWidth()-n,e);const r=7;re.embedVerticalSeparationPattern(r,0,e),re.embedVerticalSeparationPattern(e.getHeight()-r-1,0,e),re.embedVerticalSeparationPattern(r,e.getHeight()-r,e)}static maybeEmbedPositionAdjustmentPatterns(e,t){if(e.getVersionNumber()<2)return;const n=e.getVersionNumber()-1,r=re.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[n];for(let i=0,s=r.length;i!==s;i++){const o=r[i];if(o>=0)for(let a=0;a!==s;a++){const l=r[a];l>=0&&re.isEmpty(t.get(l,o))&&re.embedPositionAdjustmentPattern(l-2,o-2,t)}}}}re.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),re.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),re.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),re.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),re.VERSION_INFO_POLY=7973,re.TYPE_INFO_POLY=1335,re.TYPE_INFO_MASK_PATTERN=21522;class io{constructor(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Le{constructor(){}static calculateMaskPenalty(e){return We.applyMaskPenaltyRule1(e)+We.applyMaskPenaltyRule2(e)+We.applyMaskPenaltyRule3(e)+We.applyMaskPenaltyRule4(e)}static encode(e,t,n=null){let r=Le.DEFAULT_BYTE_MODE_ENCODING;const i=n!==null&&n.get(Ke.CHARACTER_SET)!==void 0;i&&(r=n.get(Ke.CHARACTER_SET).toString());const s=this.chooseMode(e,r),o=new Ee;if(s===ee.BYTE&&(i||Le.DEFAULT_BYTE_MODE_ENCODING!==r)){const Y=z.getCharacterSetECIByName(r);Y!==void 0&&this.appendECI(Y,o)}this.appendModeInfo(s,o);const a=new Ee;this.appendBytes(e,s,a,r);let l;if(n!==null&&n.get(Ke.QR_VERSION)!==void 0){const Y=Number.parseInt(n.get(Ke.QR_VERSION).toString(),10);l=J.getVersionForNumber(Y);const H=this.calculateBitsNeeded(s,o,a,l);if(!this.willFit(H,l,t))throw new Be("Data too big for requested version")}else l=this.recommendVersion(t,s,o,a);const d=new Ee;d.appendBitArray(o);const A=s===ee.BYTE?a.getSizeInBytes():e.length;this.appendLengthInfo(A,l,s,d),d.appendBitArray(a);const E=l.getECBlocksForLevel(t),b=l.getTotalCodewords()-E.getTotalECCodewords();this.terminateBits(b,d);const N=this.interleaveWithECBytes(d,l.getTotalCodewords(),b,E.getNumBlocks()),R=new un;R.setECLevel(t),R.setMode(s),R.setVersion(l);const B=l.getDimensionForVersion(),L=new nr(B,B),X=this.chooseMaskPattern(N,t,l,L);return R.setMaskPattern(X),re.buildMatrix(N,t,l,X,L),R.setMatrix(L),R}static recommendVersion(e,t,n,r){const i=this.calculateBitsNeeded(t,n,r,J.getVersionForNumber(1)),s=this.chooseVersion(i,e),o=this.calculateBitsNeeded(t,n,r,s);return this.chooseVersion(o,e)}static calculateBitsNeeded(e,t,n,r){return t.getSize()+e.getCharacterCountBits(r)+n.getSize()}static getAlphanumericCode(e){return e<Le.ALPHANUMERIC_TABLE.length?Le.ALPHANUMERIC_TABLE[e]:-1}static chooseMode(e,t=null){if(z.SJIS.getName()===t&&this.isOnlyDoubleByteKanji(e))return ee.KANJI;let n=!1,r=!1;for(let i=0,s=e.length;i<s;++i){const o=e.charAt(i);if(Le.isDigit(o))n=!0;else if(this.getAlphanumericCode(o.charCodeAt(0))!==-1)r=!0;else return ee.BYTE}return r?ee.ALPHANUMERIC:n?ee.NUMERIC:ee.BYTE}static isOnlyDoubleByteKanji(e){let t;try{t=rt.encode(e,z.SJIS)}catch{return!1}const n=t.length;if(n%2!==0)return!1;for(let r=0;r<n;r+=2){const i=t[r]&255;if((i<129||i>159)&&(i<224||i>235))return!1}return!0}static chooseMaskPattern(e,t,n,r){let i=Number.MAX_SAFE_INTEGER,s=-1;for(let o=0;o<un.NUM_MASK_PATTERNS;o++){re.buildMatrix(e,t,n,o,r);let a=this.calculateMaskPenalty(r);a<i&&(i=a,s=o)}return s}static chooseVersion(e,t){for(let n=1;n<=40;n++){const r=J.getVersionForNumber(n);if(Le.willFit(e,r,t))return r}throw new Be("Data too big")}static willFit(e,t,n){const r=t.getTotalCodewords(),s=t.getECBlocksForLevel(n).getTotalECCodewords(),o=r-s,a=(e+7)/8;return o>=a}static terminateBits(e,t){const n=e*8;if(t.getSize()>n)throw new Be("data bits cannot fit in the QR Code"+t.getSize()+" > "+n);for(let s=0;s<4&&t.getSize()<n;++s)t.appendBit(!1);const r=t.getSize()&7;if(r>0)for(let s=r;s<8;s++)t.appendBit(!1);const i=e-t.getSizeInBytes();for(let s=0;s<i;++s)t.appendBits(s&1?17:236,8);if(t.getSize()!==n)throw new Be("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(e,t,n,r,i,s){if(r>=n)throw new Be("Block ID too large");const o=e%n,a=n-o,l=Math.floor(e/n),d=l+1,A=Math.floor(t/n),E=A+1,b=l-A,N=d-E;if(b!==N)throw new Be("EC bytes mismatch");if(n!==a+o)throw new Be("RS blocks mismatch");if(e!==(A+b)*a+(E+N)*o)throw new Be("Total bytes mismatch");r<a?(i[0]=A,s[0]=b):(i[0]=E,s[0]=N)}static interleaveWithECBytes(e,t,n,r){if(e.getSizeInBytes()!==n)throw new Be("Number of bits and data bytes does not match");let i=0,s=0,o=0;const a=new Array;for(let d=0;d<r;++d){const A=new Int32Array(1),E=new Int32Array(1);Le.getNumDataBytesAndNumECBytesForBlockID(t,n,r,d,A,E);const b=A[0],N=new Uint8Array(b);e.toBytes(8*i,N,0,b);const R=Le.generateECBytes(N,E[0]);a.push(new io(N,R)),s=Math.max(s,b),o=Math.max(o,R.length),i+=A[0]}if(n!==i)throw new Be("Data bytes does not match offset");const l=new Ee;for(let d=0;d<s;++d)for(const A of a){const E=A.getDataBytes();d<E.length&&l.appendBits(E[d],8)}for(let d=0;d<o;++d)for(const A of a){const E=A.getErrorCorrectionBytes();d<E.length&&l.appendBits(E[d],8)}if(t!==l.getSizeInBytes())throw new Be("Interleaving error: "+t+" and "+l.getSizeInBytes()+" differ.");return l}static generateECBytes(e,t){const n=e.length,r=new Int32Array(n+t);for(let s=0;s<n;s++)r[s]=e[s]&255;new Mr(xe.QR_CODE_FIELD_256).encode(r,t);const i=new Uint8Array(t);for(let s=0;s<t;s++)i[s]=r[n+s];return i}static appendModeInfo(e,t){t.appendBits(e.getBits(),4)}static appendLengthInfo(e,t,n,r){const i=n.getCharacterCountBits(t);if(e>=1<<i)throw new Be(e+" is bigger than "+((1<<i)-1));r.appendBits(e,i)}static appendBytes(e,t,n,r){switch(t){case ee.NUMERIC:Le.appendNumericBytes(e,n);break;case ee.ALPHANUMERIC:Le.appendAlphanumericBytes(e,n);break;case ee.BYTE:Le.append8BitBytes(e,n,r);break;case ee.KANJI:Le.appendKanjiBytes(e,n);break;default:throw new Be("Invalid mode: "+t)}}static getDigit(e){return e.charCodeAt(0)-48}static isDigit(e){const t=Le.getDigit(e);return t>=0&&t<=9}static appendNumericBytes(e,t){const n=e.length;let r=0;for(;r<n;){const i=Le.getDigit(e.charAt(r));if(r+2<n){const s=Le.getDigit(e.charAt(r+1)),o=Le.getDigit(e.charAt(r+2));t.appendBits(i*100+s*10+o,10),r+=3}else if(r+1<n){const s=Le.getDigit(e.charAt(r+1));t.appendBits(i*10+s,7),r+=2}else t.appendBits(i,4),r++}}static appendAlphanumericBytes(e,t){const n=e.length;let r=0;for(;r<n;){const i=Le.getAlphanumericCode(e.charCodeAt(r));if(i===-1)throw new Be;if(r+1<n){const s=Le.getAlphanumericCode(e.charCodeAt(r+1));if(s===-1)throw new Be;t.appendBits(i*45+s,11),r+=2}else t.appendBits(i,6),r++}}static append8BitBytes(e,t,n){let r;try{r=rt.encode(e,n)}catch(i){throw new Be(i)}for(let i=0,s=r.length;i!==s;i++){const o=r[i];t.appendBits(o,8)}}static appendKanjiBytes(e,t){let n;try{n=rt.encode(e,z.SJIS)}catch(i){throw new Be(i)}const r=n.length;for(let i=0;i<r;i+=2){const s=n[i]&255,o=n[i+1]&255,a=s<<8&4294967295|o;let l=-1;if(a>=33088&&a<=40956?l=a-33088:a>=57408&&a<=60351&&(l=a-49472),l===-1)throw new Be("Invalid byte sequence");const d=(l>>8)*192+(l&255);t.appendBits(d,13)}}static appendECI(e,t){t.appendBits(ee.ECI.getBits(),4),t.appendBits(e.getValue(),8)}}Le.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Le.DEFAULT_BYTE_MODE_ENCODING=z.UTF8.getName();class hn{write(e,t,n,r=null){if(e.length===0)throw new M("Found empty contents");if(t<0||n<0)throw new M("Requested dimensions are too small: "+t+"x"+n);let i=Me.L,s=hn.QUIET_ZONE_SIZE;r!==null&&(r.get(Ke.ERROR_CORRECTION)!==void 0&&(i=Me.fromString(r.get(Ke.ERROR_CORRECTION).toString())),r.get(Ke.MARGIN)!==void 0&&(s=Number.parseInt(r.get(Ke.MARGIN).toString(),10)));const o=Le.encode(e,i,r);return this.renderResult(o,t,n,s)}writeToDom(e,t,n,r,i=null){typeof e=="string"&&(e=document.querySelector(e));const s=this.write(t,n,r,i);e&&e.appendChild(s)}renderResult(e,t,n,r){const i=e.getMatrix();if(i===null)throw new yt;const s=i.getWidth(),o=i.getHeight(),a=s+r*2,l=o+r*2,d=Math.max(t,a),A=Math.max(n,l),E=Math.min(Math.floor(d/a),Math.floor(A/l)),b=Math.floor((d-s*E)/2),N=Math.floor((A-o*E)/2),R=this.createSVGElement(d,A);for(let B=0,L=N;B<o;B++,L+=E)for(let X=0,Y=b;X<s;X++,Y+=E)if(i.get(X,B)===1){const H=this.createSvgRectElement(Y,L,E,E);R.appendChild(H)}return R}createSVGElement(e,t){const n=document.createElementNS(hn.SVG_NS,"svg");return n.setAttributeNS(null,"height",e.toString()),n.setAttributeNS(null,"width",t.toString()),n}createSvgRectElement(e,t,n,r){const i=document.createElementNS(hn.SVG_NS,"rect");return i.setAttributeNS(null,"x",e.toString()),i.setAttributeNS(null,"y",t.toString()),i.setAttributeNS(null,"height",n.toString()),i.setAttributeNS(null,"width",r.toString()),i.setAttributeNS(null,"fill","#000000"),i}}hn.QUIET_ZONE_SIZE=4,hn.SVG_NS="http://www.w3.org/2000/svg";class Sn{encode(e,t,n,r,i){if(e.length===0)throw new M("Found empty contents");if(t!==$.QR_CODE)throw new M("Can only encode QR_CODE, but got "+t);if(n<0||r<0)throw new M(`Requested dimensions are too small: ${n}x${r}`);let s=Me.L,o=Sn.QUIET_ZONE_SIZE;i!==null&&(i.get(Ke.ERROR_CORRECTION)!==void 0&&(s=Me.fromString(i.get(Ke.ERROR_CORRECTION).toString())),i.get(Ke.MARGIN)!==void 0&&(o=Number.parseInt(i.get(Ke.MARGIN).toString(),10)));const a=Le.encode(e,s,i);return Sn.renderResult(a,n,r,o)}static renderResult(e,t,n,r){const i=e.getMatrix();if(i===null)throw new yt;const s=i.getWidth(),o=i.getHeight(),a=s+r*2,l=o+r*2,d=Math.max(t,a),A=Math.max(n,l),E=Math.min(Math.floor(d/a),Math.floor(A/l)),b=Math.floor((d-s*E)/2),N=Math.floor((A-o*E)/2),R=new He(d,A);for(let B=0,L=N;B<o;B++,L+=E)for(let X=0,Y=b;X<s;X++,Y+=E)i.get(X,B)===1&&R.setRegion(Y,L,E,E);return R}}Sn.QUIET_ZONE_SIZE=4;class so{encode(e,t,n,r,i){let s;switch(t){case $.QR_CODE:s=new Sn;break;default:throw new M("No encoder available for format "+t)}return s.encode(e,t,n,r,i)}}class Vt extends tn{constructor(e,t,n,r,i,s,o,a){if(super(s,o),this.yuvData=e,this.dataWidth=t,this.dataHeight=n,this.left=r,this.top=i,r+s>t||i+o>n)throw new M("Crop rectangle does not fit within image data.");a&&this.reverseHorizontal(s,o)}getRow(e,t){if(e<0||e>=this.getHeight())throw new M("Requested row is outside the image: "+e);const n=this.getWidth();(t==null||t.length<n)&&(t=new Uint8ClampedArray(n));const r=(e+this.top)*this.dataWidth+this.left;return he.arraycopy(this.yuvData,r,t,0,n),t}getMatrix(){const e=this.getWidth(),t=this.getHeight();if(e===this.dataWidth&&t===this.dataHeight)return this.yuvData;const n=e*t,r=new Uint8ClampedArray(n);let i=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return he.arraycopy(this.yuvData,i,r,0,n),r;for(let s=0;s<t;s++){const o=s*e;he.arraycopy(this.yuvData,i,r,o,e),i+=this.dataWidth}return r}isCropSupported(){return!0}crop(e,t,n,r){return new Vt(this.yuvData,this.dataWidth,this.dataHeight,this.left+e,this.top+t,n,r,!1)}renderThumbnail(){const e=this.getWidth()/Vt.THUMBNAIL_SCALE_FACTOR,t=this.getHeight()/Vt.THUMBNAIL_SCALE_FACTOR,n=new Int32Array(e*t),r=this.yuvData;let i=this.top*this.dataWidth+this.left;for(let s=0;s<t;s++){const o=s*e;for(let a=0;a<e;a++){const l=r[i+a*Vt.THUMBNAIL_SCALE_FACTOR]&255;n[o+a]=4278190080|l*65793}i+=this.dataWidth*Vt.THUMBNAIL_SCALE_FACTOR}return n}getThumbnailWidth(){return this.getWidth()/Vt.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Vt.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(e,t){const n=this.yuvData;for(let r=0,i=this.top*this.dataWidth+this.left;r<t;r++,i+=this.dataWidth){const s=i+e/2;for(let o=i,a=i+e-1;o<s;o++,a--){const l=n[o];n[o]=n[a],n[a]=l}}}invert(){return new vt(this)}}Vt.THUMBNAIL_SCALE_FACTOR=2;class vr extends tn{constructor(e,t,n,r,i,s,o){if(super(t,n),this.dataWidth=r,this.dataHeight=i,this.left=s,this.top=o,e.BYTES_PER_ELEMENT===4){const a=t*n,l=new Uint8ClampedArray(a);for(let d=0;d<a;d++){const A=e[d],E=A>>16&255,b=A>>7&510,N=A&255;l[d]=(E+b+N)/4&255}this.luminances=l}else this.luminances=e;if(r===void 0&&(this.dataWidth=t),i===void 0&&(this.dataHeight=n),s===void 0&&(this.left=0),o===void 0&&(this.top=0),this.left+t>this.dataWidth||this.top+n>this.dataHeight)throw new M("Crop rectangle does not fit within image data.")}getRow(e,t){if(e<0||e>=this.getHeight())throw new M("Requested row is outside the image: "+e);const n=this.getWidth();(t==null||t.length<n)&&(t=new Uint8ClampedArray(n));const r=(e+this.top)*this.dataWidth+this.left;return he.arraycopy(this.luminances,r,t,0,n),t}getMatrix(){const e=this.getWidth(),t=this.getHeight();if(e===this.dataWidth&&t===this.dataHeight)return this.luminances;const n=e*t,r=new Uint8ClampedArray(n);let i=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return he.arraycopy(this.luminances,i,r,0,n),r;for(let s=0;s<t;s++){const o=s*e;he.arraycopy(this.luminances,i,r,o,e),i+=this.dataWidth}return r}isCropSupported(){return!0}crop(e,t,n,r){return new vr(this.luminances,n,r,this.dataWidth,this.dataHeight,this.left+e,this.top+t)}invert(){return new vt(this)}}class Si extends z{static forName(e){return this.getCharacterSetECIByName(e)}}class Fr{}Fr.ISO_8859_1=z.ISO8859_1;class _i{isCompact(){return this.compact}setCompact(e){this.compact=e}getSize(){return this.size}setSize(e){this.size=e}getLayers(){return this.layers}setLayers(e){this.layers=e}getCodeWords(){return this.codeWords}setCodeWords(e){this.codeWords=e}getMatrix(){return this.matrix}setMatrix(e){this.matrix=e}}class Ni{static singletonList(e){return[e]}static min(e,t){return e.sort(t)[0]}}class oo{constructor(e){this.previous=e}getPrevious(){return this.previous}}class _n extends oo{constructor(e,t,n){super(e),this.value=t,this.bitCount=n}appendTo(e,t){e.appendBits(this.value,this.bitCount)}add(e,t){return new _n(this,e,t)}addBinaryShift(e,t){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new _n(this,e,t)}toString(){let e=this.value&(1<<this.bitCount)-1;return e|=1<<this.bitCount,"<"+ne.toBinaryString(e|1<<this.bitCount).substring(1)+">"}}class Lr extends _n{constructor(e,t,n){super(e,0,0),this.binaryShiftStart=t,this.binaryShiftByteCount=n}appendTo(e,t){for(let n=0;n<this.binaryShiftByteCount;n++)(n===0||n===31&&this.binaryShiftByteCount<=62)&&(e.appendBits(31,5),this.binaryShiftByteCount>62?e.appendBits(this.binaryShiftByteCount-31,16):n===0?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(t[this.binaryShiftStart+n],8)}addBinaryShift(e,t){return new Lr(this,e,t)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function ao(w,e,t){return new Lr(w,e,t)}function Gn(w,e,t){return new _n(w,e,t)}const lo=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],$t=0,rr=1,Nt=2,Ri=3,Gt=4,co=new _n(null,0,0),Pr=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function uo(w){for(let e of w)Ne.fill(e,-1);return w[$t][Gt]=0,w[rr][Gt]=0,w[rr][$t]=28,w[Ri][Gt]=0,w[Nt][Gt]=0,w[Nt][$t]=15,w}const Oi=uo(Ne.createInt32Array(6,6));class Wt{constructor(e,t,n,r){this.token=e,this.mode=t,this.binaryShiftByteCount=n,this.bitCount=r}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,t){let n=this.bitCount,r=this.token;if(e!==this.mode){let s=Pr[this.mode][e];r=Gn(r,s&65535,s>>16),n+=s>>16}let i=e===Nt?4:5;return r=Gn(r,t,i),new Wt(r,e,0,n+i)}shiftAndAppend(e,t){let n=this.token,r=this.mode===Nt?4:5;return n=Gn(n,Oi[this.mode][e],r),n=Gn(n,t,5),new Wt(n,this.mode,0,this.bitCount+r+5)}addBinaryShiftChar(e){let t=this.token,n=this.mode,r=this.bitCount;if(this.mode===Gt||this.mode===Nt){let o=Pr[n][$t];t=Gn(t,o&65535,o>>16),r+=o>>16,n=$t}let i=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,s=new Wt(t,n,this.binaryShiftByteCount+1,r+i);return s.binaryShiftByteCount===2078&&(s=s.endBinaryShift(e+1)),s}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let t=this.token;return t=ao(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new Wt(t,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let t=this.bitCount+(Pr[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?t+=Wt.calculateBinaryShiftCost(e)-Wt.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount}toBitArray(e){let t=[];for(let r=this.endBinaryShift(e.length).token;r!==null;r=r.getPrevious())t.unshift(r);let n=new Ee;for(const r of t)r.appendTo(n,e);return n}toString(){return se.format("%s bits=%d bytes=%d",lo[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}Wt.INITIAL_STATE=new Wt(co,$t,0,0);function ho(w){const e=se.getCharCode(" "),t=se.getCharCode("."),n=se.getCharCode(",");w[$t][e]=1;const r=se.getCharCode("Z"),i=se.getCharCode("A");for(let E=i;E<=r;E++)w[$t][E]=E-i+2;w[rr][e]=1;const s=se.getCharCode("z"),o=se.getCharCode("a");for(let E=o;E<=s;E++)w[rr][E]=E-o+2;w[Nt][e]=1;const a=se.getCharCode("9"),l=se.getCharCode("0");for(let E=l;E<=a;E++)w[Nt][E]=E-l+2;w[Nt][n]=12,w[Nt][t]=13;const d=["\0"," ","","","","","","","\x07","\b"," ",`
|
|
24
|
+
`,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let E=0;E<d.length;E++)w[Ri][se.getCharCode(d[E])]=E;const A=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let E=0;E<A.length;E++)se.getCharCode(A[E])>0&&(w[Gt][se.getCharCode(A[E])]=E);return w}const kr=ho(Ne.createInt32Array(5,256));class Wn{constructor(e){this.text=e}encode(){const e=se.getCharCode(" "),t=se.getCharCode(`
|
|
25
|
+
`);let n=Ni.singletonList(Wt.INITIAL_STATE);for(let i=0;i<this.text.length;i++){let s,o=i+1<this.text.length?this.text[i+1]:0;switch(this.text[i]){case se.getCharCode("\r"):s=o===t?2:0;break;case se.getCharCode("."):s=o===e?3:0;break;case se.getCharCode(","):s=o===e?4:0;break;case se.getCharCode(":"):s=o===e?5:0;break;default:s=0}s>0?(n=Wn.updateStateListForPair(n,i,s),i++):n=this.updateStateListForChar(n,i)}return Ni.min(n,(i,s)=>i.getBitCount()-s.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,t){const n=[];for(let r of e)this.updateStateForChar(r,t,n);return Wn.simplifyStates(n)}updateStateForChar(e,t,n){let r=this.text[t]&255,i=kr[e.getMode()][r]>0,s=null;for(let o=0;o<=Gt;o++){let a=kr[o][r];if(a>0){if(s==null&&(s=e.endBinaryShift(t)),!i||o===e.getMode()||o===Nt){const l=s.latchAndAppend(o,a);n.push(l)}if(!i&&Oi[e.getMode()][o]>=0){const l=s.shiftAndAppend(o,a);n.push(l)}}}if(e.getBinaryShiftByteCount()>0||kr[e.getMode()][r]===0){let o=e.addBinaryShiftChar(t);n.push(o)}}static updateStateListForPair(e,t,n){const r=[];for(let i of e)this.updateStateForPair(i,t,n,r);return this.simplifyStates(r)}static updateStateForPair(e,t,n,r){let i=e.endBinaryShift(t);if(r.push(i.latchAndAppend(Gt,n)),e.getMode()!==Gt&&r.push(i.shiftAndAppend(Gt,n)),n===3||n===4){let s=i.latchAndAppend(Nt,16-n).latchAndAppend(Nt,1);r.push(s)}if(e.getBinaryShiftByteCount()>0){let s=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);r.push(s)}}static simplifyStates(e){let t=[];for(const n of e){let r=!0;for(const i of t){if(i.isBetterThanOrEqualTo(n)){r=!1;break}n.isBetterThanOrEqualTo(i)&&(t=t.filter(s=>s!==i))}r&&t.push(n)}return t}}class pe{constructor(){}static encodeBytes(e){return pe.encode(e,pe.DEFAULT_EC_PERCENT,pe.DEFAULT_AZTEC_LAYERS)}static encode(e,t,n){let r=new Wn(e).encode(),i=ne.truncDivision(r.getSize()*t,100)+11,s=r.getSize()+i,o,a,l,d,A;if(n!==pe.DEFAULT_AZTEC_LAYERS){if(o=n<0,a=Math.abs(n),a>(o?pe.MAX_NB_BITS_COMPACT:pe.MAX_NB_BITS))throw new M(se.format("Illegal value %s for layers",n));l=pe.totalBitsInLayer(a,o),d=pe.WORD_SIZE[a];let H=l-l%d;if(A=pe.stuffBits(r,d),A.getSize()+i>H)throw new M("Data to large for user specified layer");if(o&&A.getSize()>d*64)throw new M("Data to large for user specified layer")}else{d=0,A=null;for(let H=0;;H++){if(H>pe.MAX_NB_BITS)throw new M("Data too large for an Aztec code");if(o=H<=3,a=o?H+1:H,l=pe.totalBitsInLayer(a,o),s>l)continue;(A==null||d!==pe.WORD_SIZE[a])&&(d=pe.WORD_SIZE[a],A=pe.stuffBits(r,d));let ge=l-l%d;if(!(o&&A.getSize()>d*64)&&A.getSize()+i<=ge)break}}let E=pe.generateCheckWords(A,l,d),b=A.getSize()/d,N=pe.generateModeMessage(o,a,b),R=(o?11:14)+a*4,B=new Int32Array(R),L;if(o){L=R;for(let H=0;H<B.length;H++)B[H]=H}else{L=R+1+2*ne.truncDivision(ne.truncDivision(R,2)-1,15);let H=ne.truncDivision(R,2),ge=ne.truncDivision(L,2);for(let ue=0;ue<H;ue++){let ft=ue+ne.truncDivision(ue,15);B[H-ue-1]=ge-ft-1,B[H+ue]=ge+ft+1}}let X=new He(L);for(let H=0,ge=0;H<a;H++){let ue=(a-H)*4+(o?9:12);for(let ft=0;ft<ue;ft++){let Bt=ft*2;for(let dt=0;dt<2;dt++)E.get(ge+Bt+dt)&&X.set(B[H*2+dt],B[H*2+ft]),E.get(ge+ue*2+Bt+dt)&&X.set(B[H*2+ft],B[R-1-H*2-dt]),E.get(ge+ue*4+Bt+dt)&&X.set(B[R-1-H*2-dt],B[R-1-H*2-ft]),E.get(ge+ue*6+Bt+dt)&&X.set(B[R-1-H*2-ft],B[H*2+dt])}ge+=ue*8}if(pe.drawModeMessage(X,o,L,N),o)pe.drawBullsEye(X,ne.truncDivision(L,2),5);else{pe.drawBullsEye(X,ne.truncDivision(L,2),7);for(let H=0,ge=0;H<ne.truncDivision(R,2)-1;H+=15,ge+=16)for(let ue=ne.truncDivision(L,2)&1;ue<L;ue+=2)X.set(ne.truncDivision(L,2)-ge,ue),X.set(ne.truncDivision(L,2)+ge,ue),X.set(ue,ne.truncDivision(L,2)-ge),X.set(ue,ne.truncDivision(L,2)+ge)}let Y=new _i;return Y.setCompact(o),Y.setSize(L),Y.setLayers(a),Y.setCodeWords(b),Y.setMatrix(X),Y}static drawBullsEye(e,t,n){for(let r=0;r<n;r+=2)for(let i=t-r;i<=t+r;i++)e.set(i,t-r),e.set(i,t+r),e.set(t-r,i),e.set(t+r,i);e.set(t-n,t-n),e.set(t-n+1,t-n),e.set(t-n,t-n+1),e.set(t+n,t-n),e.set(t+n,t-n+1),e.set(t+n,t+n-1)}static generateModeMessage(e,t,n){let r=new Ee;return e?(r.appendBits(t-1,2),r.appendBits(n-1,6),r=pe.generateCheckWords(r,28,4)):(r.appendBits(t-1,5),r.appendBits(n-1,11),r=pe.generateCheckWords(r,40,4)),r}static drawModeMessage(e,t,n,r){let i=ne.truncDivision(n,2);if(t)for(let s=0;s<7;s++){let o=i-3+s;r.get(s)&&e.set(o,i-5),r.get(s+7)&&e.set(i+5,o),r.get(20-s)&&e.set(o,i+5),r.get(27-s)&&e.set(i-5,o)}else for(let s=0;s<10;s++){let o=i-5+s+ne.truncDivision(s,5);r.get(s)&&e.set(o,i-7),r.get(s+10)&&e.set(i+7,o),r.get(29-s)&&e.set(o,i+7),r.get(39-s)&&e.set(i-7,o)}}static generateCheckWords(e,t,n){let r=e.getSize()/n,i=new Mr(pe.getGF(n)),s=ne.truncDivision(t,n),o=pe.bitsToWords(e,n,s);i.encode(o,s-r);let a=t%n,l=new Ee;l.appendBits(0,a);for(const d of Array.from(o))l.appendBits(d,n);return l}static bitsToWords(e,t,n){let r=new Int32Array(n),i,s;for(i=0,s=e.getSize()/t;i<s;i++){let o=0;for(let a=0;a<t;a++)o|=e.get(i*t+a)?1<<t-a-1:0;r[i]=o}return r}static getGF(e){switch(e){case 4:return xe.AZTEC_PARAM;case 6:return xe.AZTEC_DATA_6;case 8:return xe.AZTEC_DATA_8;case 10:return xe.AZTEC_DATA_10;case 12:return xe.AZTEC_DATA_12;default:throw new M("Unsupported word size "+e)}}static stuffBits(e,t){let n=new Ee,r=e.getSize(),i=(1<<t)-2;for(let s=0;s<r;s+=t){let o=0;for(let a=0;a<t;a++)(s+a>=r||e.get(s+a))&&(o|=1<<t-1-a);(o&i)===i?(n.appendBits(o&i,t),s--):o&i?n.appendBits(o,t):(n.appendBits(o|1,t),s--)}return n}static totalBitsInLayer(e,t){return((t?88:112)+16*e)*e}}pe.DEFAULT_EC_PERCENT=33,pe.DEFAULT_AZTEC_LAYERS=0,pe.MAX_NB_BITS=32,pe.MAX_NB_BITS_COMPACT=4,pe.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class ir{encode(e,t,n,r){return this.encodeWithHints(e,t,n,r,null)}encodeWithHints(e,t,n,r,i){let s=Fr.ISO_8859_1,o=pe.DEFAULT_EC_PERCENT,a=pe.DEFAULT_AZTEC_LAYERS;return i!=null&&(i.has(Ke.CHARACTER_SET)&&(s=Si.forName(i.get(Ke.CHARACTER_SET).toString())),i.has(Ke.ERROR_CORRECTION)&&(o=ne.parseInt(i.get(Ke.ERROR_CORRECTION).toString())),i.has(Ke.AZTEC_LAYERS)&&(a=ne.parseInt(i.get(Ke.AZTEC_LAYERS).toString()))),ir.encodeLayers(e,t,n,r,s,o,a)}static encodeLayers(e,t,n,r,i,s,o){if(t!==$.AZTEC)throw new M("Can only encode AZTEC, but got "+t);let a=pe.encode(se.getBytes(e,i),s,o);return ir.renderResult(a,n,r)}static renderResult(e,t,n){let r=e.getMatrix();if(r==null)throw new yt;let i=r.getWidth(),s=r.getHeight(),o=Math.max(t,i),a=Math.max(n,s),l=Math.min(o/i,a/s),d=(o-i*l)/2,A=(a-s*l)/2,E=new He(o,a);for(let b=0,N=A;b<s;b++,N+=l)for(let R=0,B=d;R<i;R++,B+=l)r.get(R,b)&&E.setRegion(B,N,l,l);return E}}c.AbstractExpandedDecoder=yr,c.ArgumentException=k,c.ArithmeticException=nn,c.AztecCode=_i,c.AztecCodeReader=O,c.AztecCodeWriter=ir,c.AztecDecoder=Re,c.AztecDetector=T,c.AztecDetectorResult=pn,c.AztecEncoder=pe,c.AztecHighLevelEncoder=Wn,c.AztecPoint=h,c.BarcodeFormat=$,c.Binarizer=Pe,c.BinaryBitmap=ae,c.BitArray=Ee,c.BitMatrix=He,c.BitSource=_r,c.BrowserAztecCodeReader=v,c.BrowserBarcodeReader=Ws,c.BrowserCodeReader=Lt,c.BrowserDatamatrixCodeReader=Xs,c.BrowserMultiFormatReader=to,c.BrowserPDF417Reader=no,c.BrowserQRCodeReader=ro,c.BrowserQRCodeSvgWriter=hn,c.CharacterSetECI=z,c.ChecksumException=Q,c.Code128Reader=G,c.Code39Reader=ce,c.DataMatrixDecodedBitStreamParser=Kt,c.DataMatrixReader=qt,c.DecodeHintType=me,c.DecoderResult=Xt,c.DefaultGridSampler=C,c.DetectorResult=at,c.EAN13Reader=on,c.EncodeHintType=Ke,c.Exception=p,c.FormatException=Z,c.GenericGF=xe,c.GenericGFPoly=it,c.GlobalHistogramBinarizer=Ze,c.GridSampler=bt,c.GridSamplerInstance=u,c.HTMLCanvasElementLuminanceSource=Ft,c.HybridBinarizer=le,c.ITFReader=te,c.IllegalArgumentException=M,c.IllegalStateException=yt,c.InvertedLuminanceSource=vt,c.LuminanceSource=tn,c.MathUtils=we,c.MultiFormatOneDReader=bn,c.MultiFormatReader=Ti,c.MultiFormatWriter=so,c.NotFoundException=V,c.OneDReader=U,c.PDF417DecodedBitStreamParser=F,c.PDF417DecoderErrorCorrection=Ci,c.PDF417Reader=et,c.PDF417ResultMetadata=mi,c.PerspectiveTransform=wt,c.PlanarYUVLuminanceSource=Vt,c.QRCodeByteMatrix=nr,c.QRCodeDataMask=St,c.QRCodeDecodedBitStreamParser=Ue,c.QRCodeDecoderErrorCorrectionLevel=Me,c.QRCodeDecoderFormatInformation=ot,c.QRCodeEncoder=Le,c.QRCodeEncoderQRCode=un,c.QRCodeMaskUtil=We,c.QRCodeMatrixUtil=re,c.QRCodeMode=ee,c.QRCodeReader=Qt,c.QRCodeVersion=J,c.QRCodeWriter=Sn,c.RGBLuminanceSource=vr,c.RSS14Reader=Ge,c.RSSExpandedReader=W,c.ReaderException=tr,c.ReedSolomonDecoder=rn,c.ReedSolomonEncoder=Mr,c.ReedSolomonException=It,c.Result=qe,c.ResultMetadataType=Fe,c.ResultPoint=q,c.StringUtils=se,c.UnsupportedOperationException=zt,c.VideoInputDevice=Xe,c.WhiteRectangleDetector=Rt,c.WriterException=Be,c.ZXingArrays=Ne,c.ZXingCharset=Si,c.ZXingInteger=ne,c.ZXingStandardCharsets=Fr,c.ZXingStringBuilder=Te,c.ZXingStringEncoding=rt,c.ZXingSystem=he,c.createAbstractExpandedDecoder=Ai,Object.defineProperty(c,"__esModule",{value:!0})})})(wr,wr.exports);var ve=wr.exports;const Es=xt({__proto__:null,default:rs(ve)},[ve]);var si=function(){function x(f,c,m){if(this.formatMap=new Map([[j.QR_CODE,ve.BarcodeFormat.QR_CODE],[j.AZTEC,ve.BarcodeFormat.AZTEC],[j.CODABAR,ve.BarcodeFormat.CODABAR],[j.CODE_39,ve.BarcodeFormat.CODE_39],[j.CODE_93,ve.BarcodeFormat.CODE_93],[j.CODE_128,ve.BarcodeFormat.CODE_128],[j.DATA_MATRIX,ve.BarcodeFormat.DATA_MATRIX],[j.MAXICODE,ve.BarcodeFormat.MAXICODE],[j.ITF,ve.BarcodeFormat.ITF],[j.EAN_13,ve.BarcodeFormat.EAN_13],[j.EAN_8,ve.BarcodeFormat.EAN_8],[j.PDF_417,ve.BarcodeFormat.PDF_417],[j.RSS_14,ve.BarcodeFormat.RSS_14],[j.RSS_EXPANDED,ve.BarcodeFormat.RSS_EXPANDED],[j.UPC_A,ve.BarcodeFormat.UPC_A],[j.UPC_E,ve.BarcodeFormat.UPC_E],[j.UPC_EAN_EXTENSION,ve.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!Es)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=c,this.logger=m;var I=this.createZXingFormats(f),g=new Map;g.set(ve.DecodeHintType.POSSIBLE_FORMATS,I),g.set(ve.DecodeHintType.TRY_HARDER,!1),this.hints=g}return x.prototype.decodeAsync=function(f){var c=this;return new Promise(function(m,I){try{m(c.decode(f))}catch(g){I(g)}})},x.prototype.decode=function(f){var c=new ve.MultiFormatReader(this.verbose,this.hints),m=new ve.HTMLCanvasElementLuminanceSource(f),I=new ve.BinaryBitmap(new ve.HybridBinarizer(m)),g=c.decode(I);return{text:g.text,format:ni.create(this.toHtml5QrcodeSupportedFormats(g.format)),debugData:this.createDebugData()}},x.prototype.createReverseFormatMap=function(){var f=new Map;return this.formatMap.forEach(function(c,m,I){f.set(c,m)}),f},x.prototype.toHtml5QrcodeSupportedFormats=function(f){if(!this.reverseFormatMap.has(f))throw"reverseFormatMap doesn't have ".concat(f);return this.reverseFormatMap.get(f)},x.prototype.createZXingFormats=function(f){for(var c=[],m=0,I=f;m<I.length;m++){var g=I[m];this.formatMap.has(g)?c.push(this.formatMap.get(g)):this.logger.logError("".concat(g," is not supported by")+"ZXingHtml5QrcodeShim")}return c},x.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},x}(),Cs=function(x,f,c,m){function I(g){return g instanceof c?g:new c(function(_){_(g)})}return new(c||(c=Promise))(function(g,_){function S(k){try{p(m.next(k))}catch(M){_(M)}}function P(k){try{p(m.throw(k))}catch(M){_(M)}}function p(k){k.done?g(k.value):I(k.value).then(S,P)}p((m=m.apply(x,f||[])).next())})},ps=function(x,f){var c={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},m,I,g,_;return _={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function S(p){return function(k){return P([p,k])}}function P(p){if(m)throw new TypeError("Generator is already executing.");for(;_&&(_=0,p[0]&&(c=0)),c;)try{if(m=1,I&&(g=p[0]&2?I.return:p[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,p[1])).done)return g;switch(I=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return c.label++,{value:p[1],done:!1};case 5:c.label++,I=p[1],p=[0];continue;case 7:p=c.ops.pop(),c.trys.pop();continue;default:if(g=c.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){c=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){c.label=p[1];break}if(p[0]===6&&c.label<g[1]){c.label=g[1],g=p;break}if(g&&c.label<g[2]){c.label=g[2],c.ops.push(p);break}g[2]&&c.ops.pop(),c.trys.pop();continue}p=f.call(x,c)}catch(k){p=[6,k],I=0}finally{m=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},oi=function(){function x(f,c,m){if(this.formatMap=new Map([[j.QR_CODE,"qr_code"],[j.AZTEC,"aztec"],[j.CODABAR,"codabar"],[j.CODE_39,"code_39"],[j.CODE_93,"code_93"],[j.CODE_128,"code_128"],[j.DATA_MATRIX,"data_matrix"],[j.ITF,"itf"],[j.EAN_13,"ean_13"],[j.EAN_8,"ean_8"],[j.PDF_417,"pdf417"],[j.UPC_A,"upc_a"],[j.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!x.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=c,this.logger=m;var I=this.createBarcodeDetectorFormats(f);if(this.detector=new BarcodeDetector(I),!this.detector)throw"BarcodeDetector detector not supported"}return x.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var f=new BarcodeDetector({formats:["qr_code"]});return typeof f<"u"},x.prototype.decodeAsync=function(f){return Cs(this,void 0,void 0,function(){var c,m;return ps(this,function(I){switch(I.label){case 0:return[4,this.detector.detect(f)];case 1:if(c=I.sent(),!c||c.length===0)throw"No barcode or QR code detected.";return m=this.selectLargestBarcode(c),[2,{text:m.rawValue,format:ni.create(this.toHtml5QrcodeSupportedFormats(m.format)),debugData:this.createDebugData()}]}})})},x.prototype.selectLargestBarcode=function(f){for(var c=null,m=0,I=0,g=f;I<g.length;I++){var _=g[I],S=_.boundingBox.width*_.boundingBox.height;S>m&&(m=S,c=_)}if(!c)throw"No largest barcode found";return c},x.prototype.createBarcodeDetectorFormats=function(f){for(var c=[],m=0,I=f;m<I.length;m++){var g=I[m];this.formatMap.has(g)?c.push(this.formatMap.get(g)):this.logger.warn("".concat(g," is not supported by")+"BarcodeDetectorDelegate")}return{formats:c}},x.prototype.toHtml5QrcodeSupportedFormats=function(f){if(!this.reverseFormatMap.has(f))throw"reverseFormatMap doesn't have ".concat(f);return this.reverseFormatMap.get(f)},x.prototype.createReverseFormatMap=function(){var f=new Map;return this.formatMap.forEach(function(c,m,I){f.set(c,m)}),f},x.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},x}(),ai=function(x,f,c,m){function I(g){return g instanceof c?g:new c(function(_){_(g)})}return new(c||(c=Promise))(function(g,_){function S(k){try{p(m.next(k))}catch(M){_(M)}}function P(k){try{p(m.throw(k))}catch(M){_(M)}}function p(k){k.done?g(k.value):I(k.value).then(S,P)}p((m=m.apply(x,f||[])).next())})},li=function(x,f){var c={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},m,I,g,_;return _={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function S(p){return function(k){return P([p,k])}}function P(p){if(m)throw new TypeError("Generator is already executing.");for(;_&&(_=0,p[0]&&(c=0)),c;)try{if(m=1,I&&(g=p[0]&2?I.return:p[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,p[1])).done)return g;switch(I=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return c.label++,{value:p[1],done:!1};case 5:c.label++,I=p[1],p=[0];continue;case 7:p=c.ops.pop(),c.trys.pop();continue;default:if(g=c.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){c=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){c.label=p[1];break}if(p[0]===6&&c.label<g[1]){c.label=g[1],g=p;break}if(g&&c.label<g[2]){c.label=g[2],c.ops.push(p);break}g[2]&&c.ops.pop(),c.trys.pop();continue}p=f.call(x,c)}catch(k){p=[6,k],I=0}finally{m=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},ms=function(){function x(f,c,m,I){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=m,c&&oi.isSupported()?(this.primaryDecoder=new oi(f,m,I),this.secondaryDecoder=new si(f,m,I)):this.primaryDecoder=new si(f,m,I)}return x.prototype.decodeAsync=function(f){return ai(this,void 0,void 0,function(){var c;return li(this,function(m){switch(m.label){case 0:c=performance.now(),m.label=1;case 1:return m.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(f)];case 2:return[2,m.sent()];case 3:return this.possiblyLogPerformance(c),[7];case 4:return[2]}})})},x.prototype.decodeRobustlyAsync=function(f){return ai(this,void 0,void 0,function(){var c,m;return li(this,function(I){switch(I.label){case 0:c=performance.now(),I.label=1;case 1:return I.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(f)];case 2:return[2,I.sent()];case 3:if(m=I.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(f)];throw m;case 4:return this.possiblyLogPerformance(c),[7];case 5:return[2]}})})},x.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},x.prototype.possiblyLogPerformance=function(f){if(this.verbose){var c=performance.now()-f;this.executionResults.push(c),this.executions++,this.possiblyFlushPerformanceReport()}},x.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var f=0,c=0,m=this.executionResults;c<m.length;c++){var I=m[c];f+=I}var g=f/this.executionResults.length;console.log("".concat(g," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},x}(),Ar=function(){var x=function(f,c){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,I){m.__proto__=I}||function(m,I){for(var g in I)Object.prototype.hasOwnProperty.call(I,g)&&(m[g]=I[g])},x(f,c)};return function(f,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");x(f,c);function m(){this.constructor=f}f.prototype=c===null?Object.create(c):(m.prototype=c.prototype,new m)}}(),jn=function(x,f,c,m){function I(g){return g instanceof c?g:new c(function(_){_(g)})}return new(c||(c=Promise))(function(g,_){function S(k){try{p(m.next(k))}catch(M){_(M)}}function P(k){try{p(m.throw(k))}catch(M){_(M)}}function p(k){k.done?g(k.value):I(k.value).then(S,P)}p((m=m.apply(x,f||[])).next())})},Kn=function(x,f){var c={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},m,I,g,_;return _={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function S(p){return function(k){return P([p,k])}}function P(p){if(m)throw new TypeError("Generator is already executing.");for(;_&&(_=0,p[0]&&(c=0)),c;)try{if(m=1,I&&(g=p[0]&2?I.return:p[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,p[1])).done)return g;switch(I=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return c.label++,{value:p[1],done:!1};case 5:c.label++,I=p[1],p=[0];continue;case 7:p=c.ops.pop(),c.trys.pop();continue;default:if(g=c.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){c=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){c.label=p[1];break}if(p[0]===6&&c.label<g[1]){c.label=g[1],g=p;break}if(g&&c.label<g[2]){c.label=g[2],c.ops.push(p);break}g[2]&&c.ops.pop(),c.trys.pop();continue}p=f.call(x,c)}catch(k){p=[6,k],I=0}finally{m=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},ci=function(){function x(f,c){this.name=f,this.track=c}return x.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},x.prototype.apply=function(f){var c={};c[this.name]=f;var m={advanced:[c]};return this.track.applyConstraints(m)},x.prototype.value=function(){var f=this.track.getSettings();if(this.name in f){var c=f[this.name];return c}return null},x}(),Is=function(x){Ar(f,x);function f(c,m){return x.call(this,c,m)||this}return f.prototype.min=function(){return this.getCapabilities().min},f.prototype.max=function(){return this.getCapabilities().max},f.prototype.step=function(){return this.getCapabilities().step},f.prototype.apply=function(c){var m={};m[this.name]=c;var I={advanced:[m]};return this.track.applyConstraints(I)},f.prototype.getCapabilities=function(){this.failIfNotSupported();var c=this.track.getCapabilities(),m=c[this.name];return{min:m.min,max:m.max,step:m.step}},f.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},f}(ci),ys=function(x){Ar(f,x);function f(c){return x.call(this,"zoom",c)||this}return f}(Is),bs=function(x){Ar(f,x);function f(c){return x.call(this,"torch",c)||this}return f}(ci),Ts=function(){function x(f){this.track=f}return x.prototype.zoomFeature=function(){return new ys(this.track)},x.prototype.torchFeature=function(){return new bs(this.track)},x}(),Ss=function(){function x(f,c,m){this.isClosed=!1,this.parentElement=f,this.mediaStream=c,this.callbacks=m,this.surface=this.createVideoElement(this.parentElement.clientWidth),f.append(this.surface)}return x.prototype.createVideoElement=function(f){var c=document.createElement("video");return c.style.width="".concat(f,"px"),c.style.display="block",c.muted=!0,c.setAttribute("muted","true"),c.playsInline=!0,c},x.prototype.setupSurface=function(){var f=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var c=function(){var m=f.surface.clientWidth,I=f.surface.clientHeight;f.callbacks.onRenderSurfaceReady(m,I),f.surface.removeEventListener("playing",c)};this.surface.addEventListener("playing",c),this.surface.srcObject=this.mediaStream,this.surface.play()},x.create=function(f,c,m,I){return jn(this,void 0,void 0,function(){var g,_;return Kn(this,function(S){switch(S.label){case 0:return g=new x(f,c,I),m.aspectRatio?(_={aspectRatio:m.aspectRatio},[4,g.getFirstTrackOrFail().applyConstraints(_)]):[3,2];case 1:S.sent(),S.label=2;case 2:return g.setupSurface(),[2,g]}})})},x.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},x.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},x.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},x.prototype.resume=function(f){this.failIfClosed();var c=this,m=function(){setTimeout(f,200),c.surface.removeEventListener("playing",m)};this.surface.addEventListener("playing",m),this.surface.play()},x.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},x.prototype.getSurface=function(){return this.failIfClosed(),this.surface},x.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},x.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},x.prototype.applyVideoConstraints=function(f){return jn(this,void 0,void 0,function(){return Kn(this,function(c){if("aspectRatio"in f)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(f)]})})},x.prototype.close=function(){if(this.isClosed)return Promise.resolve();var f=this;return new Promise(function(c,m){var I=f.mediaStream.getVideoTracks(),g=I.length,_=0;f.mediaStream.getVideoTracks().forEach(function(S){f.mediaStream.removeTrack(S),S.stop(),++_,_>=g&&(f.isClosed=!0,f.parentElement.removeChild(f.surface),c())})})},x.prototype.getCapabilities=function(){return new Ts(this.getFirstTrackOrFail())},x}(),_s=function(){function x(f){this.mediaStream=f}return x.prototype.render=function(f,c,m){return jn(this,void 0,void 0,function(){return Kn(this,function(I){return[2,Ss.create(f,this.mediaStream,c,m)]})})},x.create=function(f){return jn(this,void 0,void 0,function(){var c,m;return Kn(this,function(I){switch(I.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return c={audio:!1,video:f},[4,navigator.mediaDevices.getUserMedia(c)];case 1:return m=I.sent(),[2,new x(m)]}})})},x}(),ui=function(x,f,c,m){function I(g){return g instanceof c?g:new c(function(_){_(g)})}return new(c||(c=Promise))(function(g,_){function S(k){try{p(m.next(k))}catch(M){_(M)}}function P(k){try{p(m.throw(k))}catch(M){_(M)}}function p(k){k.done?g(k.value):I(k.value).then(S,P)}p((m=m.apply(x,f||[])).next())})},hi=function(x,f){var c={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},m,I,g,_;return _={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function S(p){return function(k){return P([p,k])}}function P(p){if(m)throw new TypeError("Generator is already executing.");for(;_&&(_=0,p[0]&&(c=0)),c;)try{if(m=1,I&&(g=p[0]&2?I.return:p[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,p[1])).done)return g;switch(I=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return c.label++,{value:p[1],done:!1};case 5:c.label++,I=p[1],p=[0];continue;case 7:p=c.ops.pop(),c.trys.pop();continue;default:if(g=c.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){c=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){c.label=p[1];break}if(p[0]===6&&c.label<g[1]){c.label=g[1],g=p;break}if(g&&c.label<g[2]){c.label=g[2],c.ops.push(p);break}g[2]&&c.ops.pop(),c.trys.pop();continue}p=f.call(x,c)}catch(k){p=[6,k],I=0}finally{m=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Ns=function(){function x(){}return x.failIfNotSupported=function(){return ui(this,void 0,void 0,function(){return hi(this,function(f){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new x]})})},x.prototype.create=function(f){return ui(this,void 0,void 0,function(){return hi(this,function(c){return[2,_s.create(f)]})})},x}(),Rs=function(x,f,c,m){function I(g){return g instanceof c?g:new c(function(_){_(g)})}return new(c||(c=Promise))(function(g,_){function S(k){try{p(m.next(k))}catch(M){_(M)}}function P(k){try{p(m.throw(k))}catch(M){_(M)}}function p(k){k.done?g(k.value):I(k.value).then(S,P)}p((m=m.apply(x,f||[])).next())})},Os=function(x,f){var c={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},m,I,g,_;return _={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function S(p){return function(k){return P([p,k])}}function P(p){if(m)throw new TypeError("Generator is already executing.");for(;_&&(_=0,p[0]&&(c=0)),c;)try{if(m=1,I&&(g=p[0]&2?I.return:p[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,p[1])).done)return g;switch(I=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return c.label++,{value:p[1],done:!1};case 5:c.label++,I=p[1],p=[0];continue;case 7:p=c.ops.pop(),c.trys.pop();continue;default:if(g=c.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){c=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){c.label=p[1];break}if(p[0]===6&&c.label<g[1]){c.label=g[1],g=p;break}if(g&&c.label<g[2]){c.label=g[2],c.ops.push(p);break}g[2]&&c.ops.pop(),c.trys.pop();continue}p=f.call(x,c)}catch(k){p=[6,k],I=0}finally{m=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Bs=function(){function x(){}return x.retrieve=function(){if(navigator.mediaDevices)return x.getCamerasFromMediaDevices();var f=MediaStreamTrack;return MediaStreamTrack&&f.getSources?x.getCamerasFromMediaStreamTrack():x.rejectWithError()},x.rejectWithError=function(){var f=An.unableToQuerySupportedDevices();return x.isHttpsOrLocalhost()||(f=An.insecureContextCameraQueryError()),Promise.reject(f)},x.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var f=location.host.split(":")[0];return f==="127.0.0.1"||f==="localhost"},x.getCamerasFromMediaDevices=function(){return Rs(this,void 0,void 0,function(){var f,c,m,I,g,_,S;return Os(this,function(P){switch(P.label){case 0:return f=function(p){for(var k=p.getVideoTracks(),M=0,ae=k;M<ae.length;M++){var Q=ae[M];Q.enabled=!1,Q.stop(),p.removeTrack(Q)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return c=P.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(m=P.sent(),I=[],g=0,_=m;g<_.length;g++)S=_[g],S.kind==="videoinput"&&I.push({id:S.deviceId,label:S.label});return f(c),[2,I]}})})},x.getCamerasFromMediaStreamTrack=function(){return new Promise(function(f,c){var m=function(g){for(var _=[],S=0,P=g;S<P.length;S++){var p=P[S];p.kind==="video"&&_.push({id:p.id,label:p.label})}f(_)},I=MediaStreamTrack;I.getSources(m)})},x}(),Ve;(function(x){x[x.UNKNOWN=0]="UNKNOWN",x[x.NOT_STARTED=1]="NOT_STARTED",x[x.SCANNING=2]="SCANNING",x[x.PAUSED=3]="PAUSED"})(Ve||(Ve={}));var Ds=function(){function x(){this.state=Ve.NOT_STARTED,this.onGoingTransactionNewState=Ve.UNKNOWN}return x.prototype.directTransition=function(f){this.failIfTransitionOngoing(),this.validateTransition(f),this.state=f},x.prototype.startTransition=function(f){return this.failIfTransitionOngoing(),this.validateTransition(f),this.onGoingTransactionNewState=f,this},x.prototype.execute=function(){if(this.onGoingTransactionNewState===Ve.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var f=this.onGoingTransactionNewState;this.onGoingTransactionNewState=Ve.UNKNOWN,this.directTransition(f)},x.prototype.cancel=function(){if(this.onGoingTransactionNewState===Ve.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=Ve.UNKNOWN},x.prototype.getState=function(){return this.state},x.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==Ve.UNKNOWN)throw"Cannot transition to a new state, already under transition"},x.prototype.validateTransition=function(f){switch(this.state){case Ve.UNKNOWN:throw"Transition from unknown is not allowed";case Ve.NOT_STARTED:this.failIfNewStateIs(f,[Ve.PAUSED]);break;case Ve.SCANNING:break;case Ve.PAUSED:break}},x.prototype.failIfNewStateIs=function(f,c){for(var m=0,I=c;m<I.length;m++){var g=I[m];if(f===g)throw"Cannot transition from ".concat(this.state," to ").concat(f)}},x}(),Ms=function(){function x(f){this.stateManager=f}return x.prototype.startTransition=function(f){return this.stateManager.startTransition(f)},x.prototype.directTransition=function(f){this.stateManager.directTransition(f)},x.prototype.getState=function(){return this.stateManager.getState()},x.prototype.canScanFile=function(){return this.stateManager.getState()===Ve.NOT_STARTED},x.prototype.isScanning=function(){return this.stateManager.getState()!==Ve.NOT_STARTED},x.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===Ve.SCANNING},x.prototype.isPaused=function(){return this.stateManager.getState()===Ve.PAUSED},x}(),vs=function(){function x(){}return x.create=function(){return new Ms(new Ds)},x}(),Fs=function(){var x=function(f,c){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,I){m.__proto__=I}||function(m,I){for(var g in I)Object.prototype.hasOwnProperty.call(I,g)&&(m[g]=I[g])},x(f,c)};return function(f,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");x(f,c);function m(){this.constructor=f}f.prototype=c===null?Object.create(c):(m.prototype=c.prototype,new m)}}(),gt=function(x){Fs(f,x);function f(){return x!==null&&x.apply(this,arguments)||this}return f.DEFAULT_WIDTH=300,f.DEFAULT_WIDTH_OFFSET=2,f.FILE_SCAN_MIN_HEIGHT=300,f.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,f.MIN_QR_BOX_SIZE=50,f.SHADED_LEFT=1,f.SHADED_RIGHT=2,f.SHADED_TOP=3,f.SHADED_BOTTOM=4,f.SHADED_REGION_ELEMENT_ID="qr-shaded-region",f.VERBOSE=!1,f.BORDER_SHADER_DEFAULT_COLOR="#ffffff",f.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",f}(gs),Ls=function(){function x(f,c){this.logger=c,this.fps=gt.SCAN_DEFAULT_FPS,f?(f.fps&&(this.fps=f.fps),this.disableFlip=f.disableFlip===!0,this.qrbox=f.qrbox,this.aspectRatio=f.aspectRatio,this.videoConstraints=f.videoConstraints):this.disableFlip=gt.DEFAULT_DISABLE_FLIP}return x.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?ii.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},x.prototype.isShadedBoxEnabled=function(){return!Ht(this.qrbox)},x.create=function(f,c){return new x(f,c)},x}(),Ps=function(){function x(f,c){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(f))throw"HTML Element with id=".concat(f," not found");this.elementId=f,this.verbose=!1;var m;typeof c=="boolean"?this.verbose=c===!0:c&&(m=c,this.verbose=m.verbose===!0,m.experimentalFeatures),this.logger=new As(this.verbose),this.qrcode=new ms(this.getSupportedFormats(c),this.getUseBarCodeDetectorIfSupported(m),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=vs.create()}return x.prototype.start=function(f,c,m,I){var g=this;if(!f)throw"cameraIdOrConfig is required";if(!m||typeof m!="function")throw"qrCodeSuccessCallback is required and should be a function.";var _;I?_=I:_=this.verbose?this.logger.log:function(){};var S=Ls.create(c,this.logger);this.clearElement();var P=!1;S.videoConstraints&&(S.isMediaStreamConstraintsValid()?P=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var p=P,k=document.getElementById(this.elementId);k.clientWidth?k.clientWidth:gt.DEFAULT_WIDTH,k.style.position="relative",this.shouldScan=!0,this.element=k;var M=this,ae=this.stateManagerProxy.startTransition(Ve.SCANNING);return new Promise(function(Q,Pe){var he=p?S.videoConstraints:M.createVideoConstraints(f);if(!he){ae.cancel(),Pe("videoConstraints should be defined");return}var pt={};(!p||S.aspectRatio)&&(pt.aspectRatio=S.aspectRatio);var mt={onRenderSurfaceReady:function(Ne,ne){M.setupUi(Ne,ne,S),M.isScanning=!0,M.foreverScan(S,m,_)}};Ns.failIfNotSupported().then(function(Ne){Ne.create(he).then(function(ne){return ne.render(g.element,pt,mt).then(function(Ee){M.renderedCamera=Ee,ae.execute(),Q(null)}).catch(function(Ee){ae.cancel(),Pe(Ee)})}).catch(function(ne){ae.cancel(),Pe(An.errorGettingUserMedia(ne))})}).catch(function(Ne){ae.cancel(),Pe(An.cameraStreamingNotSupported())})})},x.prototype.pause=function(f){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(Ve.PAUSED),this.showPausedState(),(Ht(f)||f!==!0)&&(f=!1),f&&this.renderedCamera&&this.renderedCamera.pause()},x.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var f=this,c=function(){f.stateManagerProxy.directTransition(Ve.SCANNING),f.hidePausedState()};if(!this.renderedCamera.isPaused()){c();return}this.renderedCamera.resume(function(){c()})},x.prototype.getState=function(){return this.stateManagerProxy.getState()},x.prototype.stop=function(){var f=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var c=this.stateManagerProxy.startTransition(Ve.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var m=function(){if(f.element){var g=document.getElementById(gt.SHADED_REGION_ELEMENT_ID);g&&f.element.removeChild(g)}},I=this;return this.renderedCamera.close().then(function(){return I.renderedCamera=null,I.element&&(I.element.removeChild(I.canvasElement),I.canvasElement=null),m(),I.qrRegion&&(I.qrRegion=null),I.context&&(I.context=null),c.execute(),I.hidePausedState(),I.isScanning=!1,Promise.resolve()})},x.prototype.scanFile=function(f,c){return this.scanFileV2(f,c).then(function(m){return m.decodedText})},x.prototype.scanFileV2=function(f,c){var m=this;if(!f||!(f instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Ht(c)&&(c=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(I,g){m.possiblyCloseLastScanImageFile(),m.clearElement(),m.lastScanImageFile=URL.createObjectURL(f);var _=new Image;_.onload=function(){var S=_.width,P=_.height,p=document.getElementById(m.elementId),k=p.clientWidth?p.clientWidth:gt.DEFAULT_WIDTH,M=Math.max(p.clientHeight?p.clientHeight:P,gt.FILE_SCAN_MIN_HEIGHT),ae=m.computeCanvasDrawConfig(S,P,k,M);if(c){var Q=m.createCanvasElement(k,M,"qr-canvas-visible");Q.style.display="inline-block",p.appendChild(Q);var Pe=Q.getContext("2d");if(!Pe)throw"Unable to get 2d context from canvas";Pe.canvas.width=k,Pe.canvas.height=M,Pe.drawImage(_,0,0,S,P,ae.x,ae.y,ae.width,ae.height)}var he=gt.FILE_SCAN_HIDDEN_CANVAS_PADDING,pt=Math.max(_.width,ae.width),mt=Math.max(_.height,ae.height),Ne=pt+2*he,ne=mt+2*he,Ee=m.createCanvasElement(Ne,ne);p.appendChild(Ee);var nt=Ee.getContext("2d");if(!nt)throw"Unable to get 2d context from canvas";nt.canvas.width=Ne,nt.canvas.height=ne,nt.drawImage(_,0,0,S,P,he,he,pt,mt);try{m.qrcode.decodeRobustlyAsync(Ee).then(function(me){I(ri.createFromQrcodeResult(me))}).catch(g)}catch(me){g("QR code parse error, error = ".concat(me))}},_.onerror=g,_.onabort=g,_.onstalled=g,_.onsuspend=g,_.src=URL.createObjectURL(f)})},x.prototype.clear=function(){this.clearElement()},x.getCameras=function(){return Bs.retrieve()},x.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},x.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},x.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},x.prototype.applyVideoConstraints=function(f){if(f){if(!ii.isMediaStreamConstraintsValid(f,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(f)},x.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},x.prototype.getSupportedFormats=function(f){var c=[j.QR_CODE,j.AZTEC,j.CODABAR,j.CODE_39,j.CODE_93,j.CODE_128,j.DATA_MATRIX,j.MAXICODE,j.ITF,j.EAN_13,j.EAN_8,j.PDF_417,j.RSS_14,j.RSS_EXPANDED,j.UPC_A,j.UPC_E,j.UPC_EAN_EXTENSION];if(!f||typeof f=="boolean"||!f.formatsToSupport)return c;if(!Array.isArray(f.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(f.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var m=[],I=0,g=f.formatsToSupport;I<g.length;I++){var _=g[I];xs(_)?m.push(_):this.logger.warn("Invalid format: ".concat(_," passed in config, ignoring."))}if(m.length===0)throw"None of formatsToSupport match supported values.";return m},x.prototype.getUseBarCodeDetectorIfSupported=function(f){if(Ht(f))return!0;if(!Ht(f.useBarCodeDetectorIfSupported))return f.useBarCodeDetectorIfSupported!==!1;if(Ht(f.experimentalFeatures))return!0;var c=f.experimentalFeatures;return Ht(c.useBarCodeDetectorIfSupported)?!0:c.useBarCodeDetectorIfSupported!==!1},x.prototype.validateQrboxSize=function(f,c,m){var I=this,g=m.qrbox;this.validateQrboxConfig(g);var _=this.toQrdimensions(f,c,g),S=function(p){if(p<gt.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(gt.MIN_QR_BOX_SIZE,"px.")},P=function(p){return p>f&&(I.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),p=f),p};S(_.width),S(_.height),_.width=P(_.width)},x.prototype.validateQrboxConfig=function(f){if(typeof f!="number"&&typeof f!="function"&&(f.width===void 0||f.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},x.prototype.toQrdimensions=function(f,c,m){if(typeof m=="number")return{width:m,height:m};if(typeof m=="function")try{return m(f,c)}catch(I){throw new Error("qrbox config was passed as a function but it failed with unknown error"+I)}return m},x.prototype.setupUi=function(f,c,m){m.isShadedBoxEnabled()&&this.validateQrboxSize(f,c,m);var I=Ht(m.qrbox)?{width:f,height:c}:m.qrbox;this.validateQrboxConfig(I);var g=this.toQrdimensions(f,c,I);g.height>c&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var _=m.isShadedBoxEnabled()&&g.height<=c,S={x:0,y:0,width:f,height:c},P=_?this.getShadedRegionBounds(f,c,g):S,p=this.createCanvasElement(P.width,P.height),k={willReadFrequently:!0},M=p.getContext("2d",k);M.canvas.width=P.width,M.canvas.height=P.height,this.element.append(p),_&&this.possiblyInsertShadingElement(this.element,f,c,g),this.createScannerPausedUiElement(this.element),this.qrRegion=P,this.context=M,this.canvasElement=p},x.prototype.createScannerPausedUiElement=function(f){var c=document.createElement("div");c.innerText=An.scannerPaused(),c.style.display="none",c.style.position="absolute",c.style.top="0px",c.style.zIndex="1",c.style.background="rgba(9, 9, 9, 0.46)",c.style.color="#FFECEC",c.style.textAlign="center",c.style.width="100%",f.appendChild(c),this.scannerPausedUiElement=c},x.prototype.scanContext=function(f,c){var m=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(I){return f(I.text,ri.createFromQrcodeResult(I)),m.possiblyUpdateShaders(!0),!0}).catch(function(I){m.possiblyUpdateShaders(!1);var g=An.codeParseError(I);return c(g,ws.createFrom(g)),!1})},x.prototype.foreverScan=function(f,c,m){var I=this;if(this.shouldScan&&this.renderedCamera){var g=this.renderedCamera.getSurface(),_=g.videoWidth/g.clientWidth,S=g.videoHeight/g.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var P=this.qrRegion.width*_,p=this.qrRegion.height*S,k=this.qrRegion.x*_,M=this.qrRegion.y*S;this.context.drawImage(g,k,M,P,p,0,0,this.qrRegion.width,this.qrRegion.height);var ae=function(){I.foreverScanTimeout=setTimeout(function(){I.foreverScan(f,c,m)},I.getTimeoutFps(f.fps))};this.scanContext(c,m).then(function(Q){!Q&&f.disableFlip!==!0?(I.context.translate(I.context.canvas.width,0),I.context.scale(-1,1),I.scanContext(c,m).finally(function(){ae()})):ae()}).catch(function(Q){I.logger.logError("Error happend while scanning context",Q),ae()})}},x.prototype.createVideoConstraints=function(f){if(typeof f=="string")return{deviceId:{exact:f}};if(typeof f=="object"){var c="facingMode",m="deviceId",I={user:!0,environment:!0},g="exact",_=function(Pe){if(Pe in I)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(Pe,"'")},S=Object.keys(f);if(S.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(S.length," keys");var P=Object.keys(f)[0];if(P!==c&&P!==m)throw"Only '".concat(c,"' and '").concat(m,"' ")+" are supported for 'cameraIdOrConfig'";if(P===c){var p=f.facingMode;if(typeof p=="string"){if(_(p))return{facingMode:p}}else if(typeof p=="object")if(g in p){if(_(p["".concat(g)]))return{facingMode:{exact:p["".concat(g)]}}}else throw"'facingMode' should be string or object with"+" ".concat(g," as key.");else{var k=typeof p;throw"Invalid type of 'facingMode' = ".concat(k)}}else{var M=f.deviceId;if(typeof M=="string")return{deviceId:M};if(typeof M=="object"){if(g in M)return{deviceId:{exact:M["".concat(g)]}};throw"'deviceId' should be string or object with"+" ".concat(g," as key.")}else{var ae=typeof M;throw"Invalid type of 'deviceId' = ".concat(ae)}}}var Q=typeof f;throw"Invalid type of 'cameraIdOrConfig' = ".concat(Q)},x.prototype.computeCanvasDrawConfig=function(f,c,m,I){if(f<=m&&c<=I){var g=(m-f)/2,_=(I-c)/2;return{x:g,y:_,width:f,height:c}}else{var S=f,P=c;return f>m&&(c=m/f*c,f=m),c>I&&(f=I/c*f,c=I),this.logger.log("Image downsampled from "+"".concat(S,"X").concat(P)+" to ".concat(f,"X").concat(c,".")),this.computeCanvasDrawConfig(f,c,m,I)}},x.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var f=document.getElementById(this.elementId);f&&(f.innerHTML="")},x.prototype.possiblyUpdateShaders=function(f){this.qrMatch!==f&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(c){c.style.backgroundColor=f?gt.BORDER_SHADER_MATCH_COLOR:gt.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=f)},x.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},x.prototype.createCanvasElement=function(f,c,m){var I=f,g=c,_=document.createElement("canvas");return _.style.width="".concat(I,"px"),_.style.height="".concat(g,"px"),_.style.display="none",_.id=Ht(m)?"qr-canvas":m,_},x.prototype.getShadedRegionBounds=function(f,c,m){if(m.width>f||m.height>c)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(f-m.width)/2,y:(c-m.height)/2,width:m.width,height:m.height}},x.prototype.possiblyInsertShadingElement=function(f,c,m,I){if(!(c-I.width<1||m-I.height<1)){var g=document.createElement("div");g.style.position="absolute";var _=(c-I.width)/2,S=(m-I.height)/2;if(g.style.borderLeft="".concat(_,"px solid rgba(0, 0, 0, 0.48)"),g.style.borderRight="".concat(_,"px solid rgba(0, 0, 0, 0.48)"),g.style.borderTop="".concat(S,"px solid rgba(0, 0, 0, 0.48)"),g.style.borderBottom="".concat(S,"px solid rgba(0, 0, 0, 0.48)"),g.style.boxSizing="border-box",g.style.top="0px",g.style.bottom="0px",g.style.left="0px",g.style.right="0px",g.id="".concat(gt.SHADED_REGION_ELEMENT_ID),c-I.width<11||m-I.height<11)this.hasBorderShaders=!1;else{var P=5,p=40;this.insertShaderBorders(g,p,P,-P,null,0,!0),this.insertShaderBorders(g,p,P,-P,null,0,!1),this.insertShaderBorders(g,p,P,null,-P,0,!0),this.insertShaderBorders(g,p,P,null,-P,0,!1),this.insertShaderBorders(g,P,p+P,-P,null,-P,!0),this.insertShaderBorders(g,P,p+P,null,-P,-P,!0),this.insertShaderBorders(g,P,p+P,-P,null,-P,!1),this.insertShaderBorders(g,P,p+P,null,-P,-P,!1),this.hasBorderShaders=!0}f.append(g)}},x.prototype.insertShaderBorders=function(f,c,m,I,g,_,S){var P=document.createElement("div");P.style.position="absolute",P.style.backgroundColor=gt.BORDER_SHADER_DEFAULT_COLOR,P.style.width="".concat(c,"px"),P.style.height="".concat(m,"px"),I!==null&&(P.style.top="".concat(I,"px")),g!==null&&(P.style.bottom="".concat(g,"px")),S?P.style.left="".concat(_,"px"):P.style.right="".concat(_,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(P),f.appendChild(P)},x.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},x.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},x.prototype.getTimeoutFps=function(f){return 1e3/f},x}(),fi;(function(x){x[x.STATUS_DEFAULT=0]="STATUS_DEFAULT",x[x.STATUS_SUCCESS=1]="STATUS_SUCCESS",x[x.STATUS_WARNING=2]="STATUS_WARNING",x[x.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(fi||(fi={}));const Cr=class Cr{constructor(f,c,m){this.previousScanText=null,this.rootElement=null,this.html5QrScanner=null,this.events={};const I=document.querySelector(f.target);if(!I)throw new Error(`Target element '${f.target}' is not found`);this.targetElement=I,this.decode=c,this.scannerElements=m}async _initializeScanner(f,c=10){var m,I;try{const g=this.scannerElements.VIDEO;this.html5QrScanner=new Ps(g);const _={fps:c,qrbox:{width:250,height:250},formatsToSupport:[j.QR_CODE,j.UPC_A,j.UPC_E,j.EAN_13]},S=f||{facingMode:"environment"};await this.html5QrScanner.start(S,_,async P=>{var p,k,M,ae;if(this.previousScanText!==P)try{this.previousScanText=P;const Q=await this.decode(P);(k=(p=this.events)==null?void 0:p[gn.CAPTURE])==null||k.call(p,Q)}catch(Q){(ae=(M=this.events)==null?void 0:M[gn.ERROR])==null||ae.call(M,Q)}},()=>{})}catch(g){(I=(m=this.events)==null?void 0:m[gn.ERROR])==null||I.call(m,g),await this.stopAndCleanup()}}async stopAndCleanup(){var f,c;(f=this.html5QrScanner)!=null&&f.isScanning&&await this.html5QrScanner.stop(),(c=this.rootElement)==null||c.remove(),this.previousScanText=null}async close(){var f,c;(c=(f=this.events)==null?void 0:f[gn.CANCEL])==null||c.call(f),await this.stopAndCleanup()}on(f,c){this.events[f]=c}off(f){this.events[f]=void 0}};Cr.events=gn;let Er=Cr;class di extends Er{constructor(f){super(f,ds,Yn)}async scan({deviceId:f,maxScansPerSecond:c=10,isCloseButton:m=!0}={}){await this.stopAndCleanup(),new ns({target:this.targetElement,props:{close:this.close.bind(this),isCloseButton:m,scannerElements:Yn}}),this.rootElement=document.getElementById(Yn.ROOT),await this._initializeScanner(f,c)}}typeof window<"u"&&(window.CredenzaScanner=di),Et.Scanner=di,Object.defineProperty(Et,Symbol.toStringTag,{value:"Module"})});
|