import{H as xn,I as gi,d as wi,r as $n,o as Ai,J as Ei,b as Ci,e as mi,_ as Ii}from"./index-5eeeef58.js";function pi(A,g){for(var h=0;hm[I]})}}}return Object.freeze(Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}))}var H;(function(A){A[A.QR_CODE=0]="QR_CODE",A[A.AZTEC=1]="AZTEC",A[A.CODABAR=2]="CODABAR",A[A.CODE_39=3]="CODE_39",A[A.CODE_93=4]="CODE_93",A[A.CODE_128=5]="CODE_128",A[A.DATA_MATRIX=6]="DATA_MATRIX",A[A.MAXICODE=7]="MAXICODE",A[A.ITF=8]="ITF",A[A.EAN_13=9]="EAN_13",A[A.EAN_8=10]="EAN_8",A[A.PDF_417=11]="PDF_417",A[A.RSS_14=12]="RSS_14",A[A.RSS_EXPANDED=13]="RSS_EXPANDED",A[A.UPC_A=14]="UPC_A",A[A.UPC_E=15]="UPC_E",A[A.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(H||(H={}));var Tr=new Map([[H.QR_CODE,"QR_CODE"],[H.AZTEC,"AZTEC"],[H.CODABAR,"CODABAR"],[H.CODE_39,"CODE_39"],[H.CODE_93,"CODE_93"],[H.CODE_128,"CODE_128"],[H.DATA_MATRIX,"DATA_MATRIX"],[H.MAXICODE,"MAXICODE"],[H.ITF,"ITF"],[H.EAN_13,"EAN_13"],[H.EAN_8,"EAN_8"],[H.PDF_417,"PDF_417"],[H.RSS_14,"RSS_14"],[H.RSS_EXPANDED,"RSS_EXPANDED"],[H.UPC_A,"UPC_A"],[H.UPC_E,"UPC_E"],[H.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),yr;(function(A){A[A.UNKNOWN=0]="UNKNOWN",A[A.URL=1]="URL"})(yr||(yr={}));function bi(A){return Object.values(H).includes(A)}var _n;(function(A){A[A.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",A[A.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(_n||(_n={}));var Ti=function(){function A(){}return A.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",A.SCAN_DEFAULT_FPS=2,A.DEFAULT_DISABLE_FLIP=!1,A.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,A.DEFAULT_SUPPORTED_SCAN_TYPE=[_n.SCAN_TYPE_CAMERA,_n.SCAN_TYPE_FILE],A}(),Pr=function(){function A(g,h){this.format=g,this.formatName=h}return A.prototype.toString=function(){return this.formatName},A.create=function(g){if(!Tr.has(g))throw"".concat(g," not in html5QrcodeSupportedFormatsTextMap");return new A(g,Tr.get(g))},A}(),Sr=function(){function A(){}return A.createFromText=function(g){var h={text:g};return{decodedText:g,result:h}},A.createFromQrcodeResult=function(g){return{decodedText:g.text,result:g}},A}(),er;(function(A){A[A.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",A[A.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",A[A.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(er||(er={}));var yi=function(){function A(){}return A.createFrom=function(g){return{errorMessage:g,type:er.UNKWOWN_ERROR}},A}(),Si=function(){function A(g){this.verbose=g}return A.prototype.log=function(g){this.verbose&&console.log(g)},A.prototype.warn=function(g){this.verbose&&console.warn(g)},A.prototype.logError=function(g,h){(this.verbose||h===!0)&&console.error(g)},A.prototype.logErrors=function(g){if(g.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(g)},A}();function bt(A){return typeof A>"u"||A===null}var $t=function(){function A(){}return A.codeParseError=function(g){return"QR code parse error, error = ".concat(g)},A.errorGettingUserMedia=function(g){return"Error getting userMedia, error = ".concat(g)},A.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},A.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},A.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},A.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},A.scannerPaused=function(){return"Scanner paused"},A}(),Lr=function(){function A(){}return A.isMediaStreamConstraintsValid=function(g,h){if(typeof g!="object"){var m=typeof g;return h.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"],d=new Set(I),S=Object.keys(g),P=0,B=S;Pn)throw new D("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new Tt(t);if(n>e)throw new Tt(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>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 j{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)}}j.MIN_VALUE_32_BITS=-2147483648,j.MAX_VALUE=Number.MAX_SAFE_INTEGER;class ae{constructor(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=ae.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=ae.makeArray(e);re.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+j.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+j.numberOfTrailingZeros(i);return o>t?t:o}setBulk(e,t){this.bits[Math.floor(e/32)]=t}setRange(e,t){if(tthis.size)throw new D;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<<(sthis.size)throw new D;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,c=(2<<(o32)throw new D("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>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>>i}e[n-1]=s}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof ae))return!1;const t=e;return this.size===t.size&&me.equals(this.bits,t.bits)}hashCode(){return 31*this.size+me.hashCode(this.bits)}toString(){let e="";for(let t=0,n=this.size;t=900)throw new U("incorect value");const t=k.VALUES_TO_ECI.get(e);if(t===void 0)throw new U("incorect value");return t}static getCharacterSetECIByName(e){const t=k.NAME_TO_ECI.get(e);if(t===void 0)throw new U("incorect value");return t}equals(e){if(!(e instanceof k))return!1;const t=e;return this.getName()===t.getName()}}k.VALUE_IDENTIFIER_TO_ECI=new Map,k.VALUES_TO_ECI=new Map,k.NAME_TO_ECI=new Map,k.Cp437=new k(ue.Cp437,Int32Array.from([0,2]),"Cp437"),k.ISO8859_1=new k(ue.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),k.ISO8859_2=new k(ue.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),k.ISO8859_3=new k(ue.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),k.ISO8859_4=new k(ue.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),k.ISO8859_5=new k(ue.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),k.ISO8859_6=new k(ue.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),k.ISO8859_7=new k(ue.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),k.ISO8859_8=new k(ue.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),k.ISO8859_9=new k(ue.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),k.ISO8859_10=new k(ue.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),k.ISO8859_11=new k(ue.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),k.ISO8859_13=new k(ue.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),k.ISO8859_14=new k(ue.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),k.ISO8859_15=new k(ue.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),k.ISO8859_16=new k(ue.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),k.SJIS=new k(ue.SJIS,20,"SJIS","Shift_JIS"),k.Cp1250=new k(ue.Cp1250,21,"Cp1250","windows-1250"),k.Cp1251=new k(ue.Cp1251,22,"Cp1251","windows-1251"),k.Cp1252=new k(ue.Cp1252,23,"Cp1252","windows-1252"),k.Cp1256=new k(ue.Cp1256,24,"Cp1256","windows-1256"),k.UnicodeBigUnmarked=new k(ue.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),k.UTF8=new k(ue.UTF8,26,"UTF8","UTF-8"),k.ASCII=new k(ue.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),k.Big5=new k(ue.Big5,28,"Big5"),k.GB18030=new k(ue.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),k.EUC_KR=new k(ue.EUC_KR,30,"EUC_KR","EUC-KR");class Ht extends w{}Ht.kind="UnsupportedOperationException";class Je{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!Je.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 k?e:k.getCharacterSetECIByName(e)}static decodeFallback(e,t){const n=this.encodingCharacterSet(t);if(Je.isDecodeFallbackSupported(n)){let r="";for(let i=0,s=e.length;i3&&e[0]===239&&e[1]===187&&e[2]===191;for(let F=0;F0?v&128?o--:s=!1:v&128&&(v&64?(o++,v&32?(o++,v&16?(o++,v&8?s=!1:c++):l++):a++):s=!1)),r&&(v>127&&v<160?r=!1:v>159&&(v<192||v===215||v===247)&&_++),i&&(u>0?v<64||v===127||v>252?i=!1:u--:v===128||v===160||v>239?i=!1:v>160&&v<224?(x++,p=0,C++,C>b&&(b=C)):v>127?(u++,C=0,p++,p>T&&(T=p)):(C=0,p=0))}return s&&o>0&&(s=!1),i&&u>0&&(i=!1),s&&(L||a+l+c>0)?q.UTF8:i&&(q.ASSUME_SHIFT_JIS||b>=3||T>=3)?q.SHIFT_JIS:r&&i?b===2&&x===2||_*10>=n?q.SHIFT_JIS:q.ISO88591:r?q.ISO88591:i?q.SHIFT_JIS:s?q.UTF8:q.PLATFORM_DEFAULT_ENCODING}static format(e,...t){let n=-1;function r(s,o,a,l,c,u){if(s==="%%")return"%";if(t[++n]===void 0)return;s=l?parseInt(l.substr(1)):void 0;let x=c?parseInt(c.substr(1)):void 0,C;switch(u){case"s":C=t[n];break;case"c":C=t[n][0];break;case"f":C=parseFloat(t[n]).toFixed(s);break;case"p":C=parseFloat(t[n]).toPrecision(s);break;case"e":C=parseFloat(t[n]).toExponential(s);break;case"x":C=parseInt(t[n]).toString(x||16);break;case"d":C=parseFloat(parseInt(t[n],x||10).toPrecision(s)).toFixed(0);break}C=typeof C=="object"?JSON.stringify(C):(+C).toString(x);let p=parseInt(a),b=a&&a[0]+""=="0"?"0":" ";for(;C.lengths){if(o===-1)o=i-s;else if(i-s!==o)throw new D("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 D("illegal character encountered: "+e.substring(l));if(i>s){if(o===-1)o=i-s;else if(i-s!==o)throw new D("row lengths do not match");a++}const c=new Le(o,a);for(let u=0;u>>(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 D("input matrix dimensions do not match");const t=new ae(Math.floor(this.width/32)+1),n=this.rowSize,r=this.bits;for(let i=0,s=this.height;ithis.height||i>this.width)throw new D("The region must fit inside the matrix");const o=this.rowSize,a=this.bits;for(let l=t;la&&(a=l),c*32o){let x=31;for(;!(u>>>x);)x--;c*32+x>o&&(o=c*32+x)}}}return o=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 Le))return!1;const t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&me.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+me.hashCode(this.bits),e}toString(e="X ",t=" ",n=` `){return this.buildToString(e,t,n)}buildToString(e,t,n){let r=new ge;for(let i=0,s=this.height;i>Fe.LUMINANCE_SHIFT]++;const o=Fe.estimateBlackPoint(s);if(r<3)for(let a=0;a>Fe.LUMINANCE_SHIFT]++}}const s=Fe.estimateBlackPoint(i),o=e.getMatrix();for(let a=0;ai&&(r=c,i=e[c]),e[c]>n&&(n=e[c]);let s=0,o=0;for(let c=0;co&&(s=c,o=x)}if(r>s){const c=r;r=s,s=c}if(s-r<=t/16)throw new R;let a=s-1,l=-1;for(let c=s-1;c>r;c--){const u=c-r,x=u*u*(s-c)*(n-e[c]);x>l&&(a=c,l=x)}return a<=J.MINIMUM_DIMENSION&&n>=J.MINIMUM_DIMENSION){const r=e.getMatrix();let i=t>>J.BLOCK_SIZE_POWER;t&J.BLOCK_SIZE_MASK&&i++;let s=n>>J.BLOCK_SIZE_POWER;n&J.BLOCK_SIZE_MASK&&s++;const o=J.calculateBlackPoints(r,i,s,t,n),a=new Le(t,n);J.calculateThresholdForBlock(r,i,s,t,n,o,a),this.matrix=a}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new J(e)}static calculateThresholdForBlock(e,t,n,r,i,s,o){const a=i-J.BLOCK_SIZE,l=r-J.BLOCK_SIZE;for(let c=0;ca&&(u=a);const x=J.cap(c,2,n-3);for(let C=0;Cl&&(p=l);const b=J.cap(C,2,t-3);let T=0;for(let L=-2;L<=2;L++){const F=s[x+L];T+=F[b-2]+F[b-1]+F[b]+F[b+1]+F[b+2]}const _=T/25;J.thresholdBlock(e,p,u,_,r,o)}}}static cap(e,t,n){return en?n:e}static thresholdBlock(e,t,n,r,i,s){for(let o=0,a=n*i+t;os&&(c=s);for(let u=0;uo&&(x=o);let C=0,p=255,b=0;for(let _=0,L=c*r+x;_b&&(b=v)}if(b-p>J.MIN_DYNAMIC_RANGE)for(_++,L+=r;_>J.BLOCK_SIZE_POWER*2;if(b-p<=J.MIN_DYNAMIC_RANGE&&(T=p/2,l>0&&u>0)){const _=(a[l-1][u]+2*a[l][u-1]+a[l-1][u-1])/4;p<_&&(T=_)}a[l][u]=T}}return a}}J.BLOCK_SIZE_POWER=3,J.BLOCK_SIZE=1<>10}r[s]=a}return r}getRow(e,t){if(e<0||e>=this.getHeight())throw new D("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.lengthnew rr(t.deviceId,t.label))})}findDeviceById(e){return Ke(this,void 0,void 0,function*(){const t=yield this.listVideoInputDevices();return t?t.find(n=>n.deviceId===e):null})}decodeFromInputVideoDevice(e,t){return Ke(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,t)})}decodeOnceFromVideoDevice(e,t){return Ke(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 Ke(this,void 0,void 0,function*(){const n=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(n,t)})}decodeOnceFromStream(e,t){return Ke(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 Ke(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,t,n)})}decodeFromVideoDevice(e,t,n){return Ke(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 Ke(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 Ke(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 Ke(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 Ke(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 O(`element with id '${e}' not found`);if(n.nodeName.toLowerCase()!==t.toLowerCase())throw new O(`element with id '${e}' must be an ${t} element`);return n}decodeFromImage(e,t){if(!e&&!t)throw new O("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 O("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 O("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 O("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 O("A video element must be provided.");this.reset();const t=this.prepareVideoElement(e);return this.videoElement=t,t}decodeFromImageUrl(e){if(!e)throw new O("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 O("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 O("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 Ke(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,t){return Ke(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 R("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 R,c=(o instanceof te||o instanceof U)&&n;if(a||c)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 te||r instanceof U,s=r instanceof R;(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 Nt(t),r=new J(n);return new de(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 je{constructor(e,t,n=t==null?0:8*t.length,r,i,s=re.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=re.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);re.arraycopy(t,0,n,0,t.length),re.arraycopy(e,0,n,t.length,e.length),this.resultPoints=n}}getTimestamp(){return this.timestamp}toString(){return this.text}}var Dn;(function(f){f[f.AZTEC=0]="AZTEC",f[f.CODABAR=1]="CODABAR",f[f.CODE_39=2]="CODE_39",f[f.CODE_93=3]="CODE_93",f[f.CODE_128=4]="CODE_128",f[f.DATA_MATRIX=5]="DATA_MATRIX",f[f.EAN_8=6]="EAN_8",f[f.EAN_13=7]="EAN_13",f[f.ITF=8]="ITF",f[f.MAXICODE=9]="MAXICODE",f[f.PDF_417=10]="PDF_417",f[f.QR_CODE=11]="QR_CODE",f[f.RSS_14=12]="RSS_14",f[f.RSS_EXPANDED=13]="RSS_EXPANDED",f[f.UPC_A=14]="UPC_A",f[f.UPC_E=15]="UPC_E",f[f.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Dn||(Dn={}));var z=Dn,Mn;(function(f){f[f.OTHER=0]="OTHER",f[f.ORIENTATION=1]="ORIENTATION",f[f.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",f[f.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",f[f.ISSUE_NUMBER=4]="ISSUE_NUMBER",f[f.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",f[f.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",f[f.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",f[f.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",f[f.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",f[f.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Mn||(Mn={}));var ke=Mn;class tn{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 nn{exp(e){return this.expTable[e]}log(e){if(e===0)throw new D;return this.logTable[e]}static addOrSubtract(e,t){return e^t}}class $e{constructor(e,t){if(t.length===0)throw new D;this.field=e;const n=t.length;if(n>1&&t[0]===0){let r=1;for(;rn.length){const s=t;t=n,n=s}let r=new Int32Array(n.length);const i=n.length-t.length;re.arraycopy(n,0,r,0,i);for(let s=i;s=e.getDegree()&&!r.isZero();){const o=r.getDegree()-e.getDegree(),a=t.multiply(r.getCoefficient(r.getDegree()),s),l=e.multiplyByMonomial(o,a),c=t.buildMonomial(o,a);n=n.addOrSubtract(c),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 gn extends w{}gn.kind="ArithmeticException";class le extends nn{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&&(i^=e,i&=t-1);this.expTable=r;const s=new Int32Array(t);for(let o=0;o=(n/2|0);){let C=i,p=o;if(i=s,o=a,i.isZero())throw new Wt("r_{i-1} was zero");s=C;let b=r.getZero();const T=i.getCoefficient(i.getDegree()),_=r.inverse(T);for(;s.getDegree()>=i.getDegree()&&!s.isZero();){const L=s.getDegree()-i.getDegree(),F=r.multiply(s.getCoefficient(s.getDegree()),_);b=b.addOrSubtract(r.buildMonomial(L,F)),s=s.addOrSubtract(i.multiplyByMonomial(L,F))}if(a=b.multiply(o).addOrSubtract(p),s.getDegree()>=i.getDegree())throw new gt("Division algorithm failed to reduce polynomial?")}const l=a.getCoefficient(0);if(l===0)throw new Wt("sigmaTilde(0) was zero");const c=r.inverse(l),u=a.multiplyScalar(c),x=s.multiplyScalar(c);return[u,x]}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;s1,u,u+n-1),u+=n-1;else for(let p=n-1;p>=0;--p)c[u++]=(C&1<=8?Ie.readCode(e,t,8):Ie.readCode(e,t,n)<<8-n}static convertBoolArrayToByteArray(e){let t=new Uint8Array((e.length+7)/8);for(let n=0;n","?","[","]","{","}","CTRL_UL"],Ie.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class se{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 wn{static floatToIntBits(e){return e}}wn.MAX_VALUE=Number.MAX_SAFE_INTEGER;class W{constructor(e,t){this.x=e,this.y=t}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof W){const t=e;return this.x===t.x&&this.y===t.y}return!1}hashCode(){return 31*wn.floatToIntBits(this.x)+wn.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 se.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 An{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class ir extends An{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 pt{constructor(e,t,n,r){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),t==null&&(t=pt.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 R}detect(){let e=this.leftInit,t=this.rightInit,n=this.upInit,r=this.downInit,i=!1,s=!0,o=!1,a=!1,l=!1,c=!1,u=!1;const x=this.width,C=this.height;for(;s;){s=!1;let p=!0;for(;(p||!a)&&t=x){i=!0;break}let b=!0;for(;(b||!l)&&r=C){i=!0;break}let T=!0;for(;(T||!c)&&e>=0;)T=this.containsBlackPoint(n,r,e,!1),T?(e--,s=!0,c=!0):c||e--;if(e<0){i=!0;break}let _=!0;for(;(_||!u)&&n>=0;)_=this.containsBlackPoint(e,t,n,!0),_?(n--,s=!0,u=!0):u||n--;if(n<0){i=!0;break}s&&(o=!0)}if(!i&&o){const p=t-e;let b=null;for(let F=1;b===null&&Fn||a<-1||a>r)throw new R;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 R;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 ft{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,c,u,x,C,p,b,T){const _=ft.quadrilateralToSquare(e,t,n,r,i,s,o,a);return ft.squareToQuadrilateral(l,c,u,x,C,p,b,T).times(_)}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,c=this.a32,u=this.a33;for(let x=0;x>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(j.bitCount(n^this.EXPECTED_CORNER_BITS[r])<=2)return r;throw new R}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(le.AZTEC_PARAM).decode(s,i)}catch{throw new R}let o=0;for(let a=0;a2){let b=this.distancePoint(p,u)*this.nbCenterLayers/(this.distancePoint(i,t)*(this.nbCenterLayers+2));if(b<.75||b>1.25||!this.isWhiteOrBlackRectangle(u,x,C,p))break}t=u,n=x,r=C,i=p,s=!s}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new R;this.compact=this.nbCenterLayers===5;let o=new W(t.getX()+.5,t.getY()-.5),a=new W(n.getX()+.5,n.getY()+.5),l=new W(r.getX()-.5,r.getY()+.5),c=new W(i.getX()-.5,i.getY()-.5);return this.expandSquare([o,a,l,c],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,t,n,r;try{let o=new pt(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 qe(a+7,l-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new qe(a+7,l+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new qe(a-7,l+7),!1,-1,1).toResultPoint(),r=this.getFirstDifferent(new qe(a-7,l-7),!1,-1,-1).toResultPoint()}let i=se.round((e.getX()+r.getX()+t.getX()+n.getX())/4),s=se.round((e.getY()+r.getY()+t.getY()+n.getY())/4);try{let o=new pt(this.image,15,i,s).detect();e=o[0],t=o[1],n=o[2],r=o[3]}catch{e=this.getFirstDifferent(new qe(i+7,s-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new qe(i+7,s+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new qe(i-7,s+7),!1,-1,1).toResultPoint(),r=this.getFirstDifferent(new qe(i-7,s-7),!1,-1,-1).toResultPoint()}return i=se.round((e.getX()+r.getX()+t.getX()+n.getX())/4),s=se.round((e.getY()+r.getY()+t.getY()+n.getY())/4),new qe(i,s)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,t,n,r,i){let s=_t.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,c=s*(t.getY()-e.getY())/i;for(let u=0;u.1&&u<.9?0:u<=.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 qe(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 W(o+r*i,a+r*s),c=new W(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 u=new W(o+r*i,a+r*s),x=new W(o-r*i,a-r*s);return[l,u,c,x]}isValid(e,t){return e>=0&&e0&&t{n.foundPossibleResultPoint(r)})}}reset(){}}class kr extends Pt{constructor(e=500){super(new En,e)}}class Me{decode(e,t){try{return this.doDecode(e,t)}catch{if(t&&t.get(xe.TRY_HARDER)===!0&&e.isRotateSupported()){const i=e.rotateCounterClockwise(),s=this.doDecode(i,t),o=s.getResultMetadata();let a=270;o!==null&&o.get(ke.ORIENTATION)===!0&&(a=a+o.get(ke.ORIENTATION)%360),s.putMetadata(ke.ORIENTATION,a);const l=s.getResultPoints();if(l!==null){const c=i.getHeight();for(let u=0;u>(s?8:5));let a;s?a=r:a=15;const l=Math.trunc(r/2);for(let c=0;c=r)break;try{i=e.getBlackRow(C,i)}catch{continue}for(let p=0;p<2;p++){if(p===1&&(i.reverse(),t&&t.get(xe.NEED_RESULT_POINT_CALLBACK)===!0)){const b=new Map;t.forEach((T,_)=>b.set(_,T)),b.delete(xe.NEED_RESULT_POINT_CALLBACK),t=b}try{const b=this.decodeRow(C,i,t);if(p===1){b.putMetadata(ke.ORIENTATION,180);const T=b.getResultPoints();T!==null&&(T[0]=new W(n-T[0].getX()-1,T[0].getY()),T[1]=new W(n-T[1].getX()-1,T[1].getY()))}return b}catch{}}}throw new R}static recordPattern(e,t,n){const r=n.length;for(let l=0;l=i)throw new R;let s=!e.get(t),o=0,a=t;for(;a0&&r>=0;)e.get(--t)!==i&&(r--,i=!i);if(r>=0)throw new R;Me.recordPattern(e,t+1,n)}static patternMatchVariance(e,t,n){const r=e.length;let i=0,s=0;for(let l=0;lu?c-u:u-c;if(x>n)return Number.POSITIVE_INFINITY;a+=x}return a/i}}class V extends Me{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=0&&e.isRange(Math.max(0,s-(l-s)/2),s,!1))return Int32Array.from([s,l,u]);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 R}static decodeCode(e,t,n){Me.recordPattern(e,n,t);let r=V.MAX_AVG_VARIANCE,i=-1;for(let s=0;s=0)return i;throw new R}decodeRow(e,t,n){const r=n&&n.get(xe.ASSUME_GS1)===!0,i=V.findStartPattern(t),s=i[2];let o=0;const a=new Uint8Array(20);a[o++]=s;let l;switch(s){case V.CODE_START_A:l=V.CODE_CODE_A;break;case V.CODE_START_B:l=V.CODE_CODE_B;break;case V.CODE_START_C:l=V.CODE_CODE_C;break;default:throw new U}let c=!1,u=!1,x="",C=i[0],p=i[1];const b=Int32Array.from([0,0,0,0,0,0]);let T=0,_=0,L=s,F=0,v=!0,ne=!1,Q=!1;for(;!c;){const Jt=u;switch(u=!1,T=_,_=V.decodeCode(t,b,p),a[o++]=_,_!==V.CODE_STOP&&(v=!0),_!==V.CODE_STOP&&(F++,L+=F*_),C=p,p+=b.reduce((di,xi)=>di+xi,0),_){case V.CODE_START_A:case V.CODE_START_B:case V.CODE_START_C:throw new U}switch(l){case V.CODE_CODE_A:if(_<64)Q===ne?x+=String.fromCharCode(" ".charCodeAt(0)+_):x+=String.fromCharCode(" ".charCodeAt(0)+_+128),Q=!1;else if(_<96)Q===ne?x+=String.fromCharCode(_-64):x+=String.fromCharCode(_+64),Q=!1;else switch(_!==V.CODE_STOP&&(v=!1),_){case V.CODE_FNC_1:r&&(x.length===0?x+="]C1":x+=String.fromCharCode(29));break;case V.CODE_FNC_2:case V.CODE_FNC_3:break;case V.CODE_FNC_4_A:!ne&&Q?(ne=!0,Q=!1):ne&&Q?(ne=!1,Q=!1):Q=!0;break;case V.CODE_SHIFT:u=!0,l=V.CODE_CODE_B;break;case V.CODE_CODE_B:l=V.CODE_CODE_B;break;case V.CODE_CODE_C:l=V.CODE_CODE_C;break;case V.CODE_STOP:c=!0;break}break;case V.CODE_CODE_B:if(_<96)Q===ne?x+=String.fromCharCode(" ".charCodeAt(0)+_):x+=String.fromCharCode(" ".charCodeAt(0)+_+128),Q=!1;else switch(_!==V.CODE_STOP&&(v=!1),_){case V.CODE_FNC_1:r&&(x.length===0?x+="]C1":x+=String.fromCharCode(29));break;case V.CODE_FNC_2:case V.CODE_FNC_3:break;case V.CODE_FNC_4_B:!ne&&Q?(ne=!0,Q=!1):ne&&Q?(ne=!1,Q=!1):Q=!0;break;case V.CODE_SHIFT:u=!0,l=V.CODE_CODE_A;break;case V.CODE_CODE_A:l=V.CODE_CODE_A;break;case V.CODE_CODE_C:l=V.CODE_CODE_C;break;case V.CODE_STOP:c=!0;break}break;case V.CODE_CODE_C:if(_<100)_<10&&(x+="0"),x+=_;else switch(_!==V.CODE_STOP&&(v=!1),_){case V.CODE_FNC_1:r&&(x.length===0?x+="]C1":x+=String.fromCharCode(29));break;case V.CODE_CODE_A:l=V.CODE_CODE_A;break;case V.CODE_CODE_B:l=V.CODE_CODE_B;break;case V.CODE_STOP:c=!0;break}break}Jt&&(l=l===V.CODE_CODE_A?V.CODE_CODE_B:V.CODE_CODE_A)}const rt=p-C;if(p=t.getNextUnset(p),!t.isRange(p,Math.min(t.getSize(),p+(p-C)/2),!1))throw new R;if(L-=F*T,L%103!==T)throw new te;const dt=x.length;if(dt===0)throw new R;dt>0&&v&&(l===V.CODE_CODE_C?x=x.substring(0,dt-2):x=x.substring(0,dt-1));const it=(i[1]+i[0])/2,Ce=C+rt/2,Xe=a.length,st=new Uint8Array(Xe);for(let Jt=0;Jtn&&(i=a);n=i,r=0;let s=0,o=0;for(let a=0;an&&(o|=1<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="A"&&s<="Z")o=String.fromCharCode(s.charCodeAt(0)+32);else throw new U;break;case"$":if(s>="A"&&s<="Z")o=String.fromCharCode(s.charCodeAt(0)-64);else throw new U;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 U;break;case"/":if(s>="A"&&s<="O")o=String.fromCharCode(s.charCodeAt(0)-32);else if(s==="Z")o=":";else throw new U;break}n+=o,r++}else n+=i}return n}}Be.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",Be.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],Be.ASTERISK_ENCODING=148;class Ae extends Me{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,t,n){let r=this.decodeStart(t),i=this.decodeEnd(t),s=new ge;Ae.decodeMiddle(t,r[1],i[0],s);let o=s.toString(),a=null;n!=null&&(a=n.get(xe.ALLOWED_LENGTHS)),a==null&&(a=Ae.DEFAULT_ALLOWED_LENGTHS);let l=o.length,c=!1,u=0;for(let p of a){if(l===p){c=!0;break}p>u&&(u=p)}if(!c&&l>u&&(c=!0),!c)throw new U;const x=[new W(r[1],e),new W(i[0],e)];return new je(o,null,0,x,z.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);t0&&r>=0&&!e.get(r);r--)n--;if(n!==0)throw new R}static skipWhiteSpace(e){const t=e.getSize(),n=e.getNextSet(0);if(n===t)throw new R;return n}decodeEnd(e){e.reverse();try{let t=Ae.skipWhiteSpace(e),n;try{n=Ae.findGuardPattern(e,t,Ae.END_PATTERN_REVERSED[0])}catch(i){i instanceof R&&(n=Ae.findGuardPattern(e,t,Ae.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 c=t;c=0)return n%10;throw new R}}Ae.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])],Ae.MAX_AVG_VARIANCE=.38,Ae.MAX_INDIVIDUAL_VARIANCE=.5,Ae.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],Ae.START_PATTERN=Int32Array.from([1,1,1,1]),Ae.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Ne extends Me{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=Ne.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 Ne.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return Ne.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)-"0".charCodeAt(0);if(i<0||i>9)throw new U;n+=i}n*=3;for(let r=t-2;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-"0".charCodeAt(0);if(i<0||i>9)throw new U;n+=i}return(1e3-n)%10}static decodeEnd(e,t){return Ne.findGuardPattern(e,t,!1,Ne.START_END_PATTERN,new Int32Array(Ne.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,c=n;for(let u=t;u=0)return s;throw new R}}Ne.MAX_AVG_VARIANCE=.48,Ne.MAX_INDIVIDUAL_VARIANCE=.7,Ne.START_END_PATTERN=Int32Array.from([1,1,1]),Ne.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Ne.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Ne.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 sn{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=sn.parseExtensionString(s),a=[new W((n[0]+n[1])/2,e),new W(i,e)],l=new je(s,null,0,a,z.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=10&&(o|=1<<4-l),l!==4&&(s=e.getNextSet(s),s=e.getNextUnset(s))}if(n.length!==5)throw new R;let a=this.determineCheckDigit(o);if(sn.extensionChecksum(n.toString())!==a)throw new R;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)-"0".charCodeAt(0);n*=3;for(let r=t-1;r>=0;r-=2)n+=e.charAt(r).charCodeAt(0)-"0".charCodeAt(0);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 R}static parseExtensionString(e){if(e.length!==5)return null;let t=sn.parseExtension5String(e);return t==null?null:new Map([[ke.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 vn{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=vn.parseExtensionString(s),a=[new W((n[0]+n[1])/2,e),new W(i,e)],l=new je(s,null,0,a,z.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=10&&(o|=1<<1-a),a!==1&&(s=e.getNextSet(s),s=e.getNextUnset(s))}if(n.length!==2)throw new R;if(parseInt(n.toString())%4!==o)throw new R;return s}static parseExtensionString(e){return e.length!==2?null:new Map([[ke.ISSUE_NUMBER,parseInt(e)]])}}class ar{static decodeRow(e,t,n){let r=Ne.findGuardPattern(t,n,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new sn().decodeRow(e,t,r)}catch{return new vn().decodeRow(e,t,r)}}}ar.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class ce extends Ne{constructor(){super(),this.decodeRowStringBuffer="",ce.L_AND_G_PATTERNS=ce.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let t=ce.L_PATTERNS[e-10],n=new Int32Array(t.length);for(let r=0;r=t.getSize()||!t.isRange(c,u,!1))throw new R;let x=a.toString();if(x.length<8)throw new U;if(!ce.checkChecksum(x))throw new te;let C=(r[1]+r[0])/2,p=(l[1]+l[0])/2,b=this.getBarcodeFormat(),T=[new W(C,e),new W(p,e)],_=new je(x,null,0,T,b,new Date().getTime()),L=0;try{let v=ar.decodeRow(e,t,l[1]);_.putMetadata(ke.UPC_EAN_EXTENSION,v.getText()),_.putAllMetadata(v.getResultMetadata()),_.addResultPoints(v.getResultPoints()),L=v.getText().length}catch{}let F=n==null?null:n.get(xe.ALLOWED_EAN_EXTENSIONS);if(F!=null){let v=!1;for(let ne in F)if(L.toString()===ne){v=!0;break}if(!v)throw new R}return _}decodeEnd(e,t){return ce.findGuardPattern(e,t,!1,ce.START_END_PATTERN,new Int32Array(ce.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return ce.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return ce.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)-"0".charCodeAt(0);if(i<0||i>9)throw new U;n+=i}n*=3;for(let r=t-2;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-"0".charCodeAt(0);if(i<0||i>9)throw new U;n+=i}return(1e3-n)%10}}class Lt extends ce{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=10&&(o|=1<<5-l)}n=Lt.determineFirstDigit(n,o),s=ce.findGuardPattern(e,s,!0,ce.MIDDLE_PATTERN,new Int32Array(ce.MIDDLE_PATTERN.length).fill(0))[1];for(let l=0;l<6&&sl);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=10&&(o|=1<<5-l)}let a=ut.determineNumSysAndCheckDigit(n,o);return{rowOffset:s,resultString:a}}decodeEnd(e,t){return ut.findGuardPatternWithoutCounters(e,t,!0,ut.MIDDLE_END_PATTERN)}checkChecksum(e){return ce.checkChecksum(ut.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("0".charCodeAt(0)+n),s=String.fromCharCode("0".charCodeAt(0)+r);return i+e+s}throw R.getNotFoundInstance()}getBarcodeFormat(){return z.UPC_E}static convertUPCEtoUPCA(e){const t=e.slice(1,7).split("").map(i=>i.charCodeAt(0)),n=new ge;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()}}ut.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),ut.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 Pn extends Me{constructor(e){super();let t=e==null?null:e.get(xe.POSSIBLE_FORMATS),n=[];m(t)?(n.push(new Lt),n.push(new cr),n.push(new lr),n.push(new ut)):(t.indexOf(z.EAN_13)>-1&&n.push(new Lt),t.indexOf(z.UPC_A)>-1&&n.push(new cr),t.indexOf(z.EAN_8)>-1&&n.push(new lr),t.indexOf(z.UPC_E)>-1&&n.push(new ut)),this.readers=n}decodeRow(e,t,n){for(let r of this.readers)try{const i=r.decodeRow(e,t,n),s=i.getBarcodeFormat()===z.EAN_13&&i.getText().charAt(0)==="0",o=n==null?null:n.get(xe.POSSIBLE_FORMATS),a=o==null||o.includes(z.UPC_A);if(s&&a){const l=i.getRawBytes(),c=new je(i.getText().substring(1),l,l?l.length:null,i.getResultPoints(),z.UPC_A);return c.putAllMetadata(i.getResultMetadata()),c}return i}catch{}throw new R}reset(){for(let e of this.readers)e.reset()}}class Ye extends Me{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;nr&&(r=t[i],n=i);e[n]++}static decrement(e,t){let n=0,r=t[0];for(let i=1;i=Ye.MIN_FINDER_PATTERN_RATIO&&r<=Ye.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=o-a-1&&(c-=wt.combins(r-l-(o-a),o-a-2)),o-a-1>1){let u=0;for(let x=r-l-(o-a-2);x>t;x--)u+=wt.combins(r-l-x-1,o-a-3);c-=u*(o-1-a)}else r-l>t&&c--;i+=c}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 Ur{static buildBitArray(e){let t=e.length*2-1;e[e.length-1].getRightChar()==null&&(t-=1);let n=12*t,r=new ae(n),i=0,o=e[0].getRightChar().getValue();for(let a=11;a>=0;--a)o&1<=0;--u)c&1<=0;--x)u&1<10||n<0||n>10)throw new U;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===at.FNC1}isSecondDigitFNC1(){return this.secondDigit===at.FNC1}isAnyFNC1(){return this.firstDigit===at.FNC1||this.secondDigit===at.FNC1}}at.FNC1=10;class G{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new R;let t=e.substring(0,2);for(let i of G.TWO_DIGIT_DATA_LENGTH)if(i[0]===t)return i[1]===G.VARIABLE_LENGTH?G.processVariableAI(2,i[2],e):G.processFixedAI(2,i[1],e);if(e.length<3)throw new R;let n=e.substring(0,3);for(let i of G.THREE_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===G.VARIABLE_LENGTH?G.processVariableAI(3,i[2],e):G.processFixedAI(3,i[1],e);for(let i of G.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===G.VARIABLE_LENGTH?G.processVariableAI(4,i[2],e):G.processFixedAI(4,i[1],e);if(e.length<4)throw new R;let r=e.substring(0,4);for(let i of G.FOUR_DIGIT_DATA_LENGTH)if(i[0]===r)return i[1]===G.VARIABLE_LENGTH?G.processVariableAI(4,i[2],e):G.processFixedAI(4,i[1],e);throw new R}static processFixedAI(e,t,n){if(n.lengththis.information.getSize())return e+4<=this.information.getSize();for(let t=e;tthis.information.getSize()){let i=this.extractNumericValueFromBitArray(e,4);return i===0?new at(this.information.getSize(),at.FNC1,at.FNC1):new at(this.information.getSize(),i-1,at.FNC1)}let t=this.extractNumericValueFromBitArray(e,7),n=(t-8)/11,r=(t-8)%11;return new at(e+7,n,r)}extractNumericValueFromBitArray(e,t){return Yt.extractNumericValueFromBitArray(this.information,e,t)}static extractNumericValueFromBitArray(e,t,n){let r=0;for(let i=0;ithis.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 et(e+5,et.FNC1);if(t>=5&&t<15)return new et(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<90)return new et(e+7,""+(n+1));if(n>=90&&n<116)return new et(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 U}return new et(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 et(e+5,et.FNC1);if(t>=5&&t<15)return new et(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,6);if(n>=32&&n<58)return new et(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 gt("Decoding invalid alphanumeric value: "+n)}return new et(e+6,r)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<5&&t+ethis.information.getSize())return!1;for(let t=e;tthis.information.getSize())return!1;for(let t=0;t<4&&t+e{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 M extends Ye{constructor(e){super(...arguments),this.pairs=new Array(M.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 M.constructResult(this.decodeRow2pairs(e,t))}catch(r){this.verbose&&console.log(r)}return this.pairs.length=0,this.startFromEven=!0,M.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 R){if(!this.pairs.length)throw new R;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 R}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;nt.length)continue;let n=!0;for(let r=0;re){i=s.isEquivalent(this.pairs);break}r=s.isEquivalent(this.pairs),n++}i||r||M.isPartialRow(this.pairs,this.rows)||(this.rows.push(n,new kn(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(Ot.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=Ur.buildBitArray(e),r=hr(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 je(r,null,null,o,z.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=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=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();re.arraycopy(o,0,o,1,o.length-1),o[0]=r;let a;try{a=this.parseFinderValue(o,M.FINDER_PATTERNS)}catch{return null}return new Cn(a,[i,s],i,s,t)}decodeDataCharacter(e,t,n,r){let i=this.getDataCharacterCounters();for(let Ce=0;Ce.3)throw new R;let l=this.getOddCounts(),c=this.getEvenCounts(),u=this.getOddRoundingErrors(),x=this.getEvenRoundingErrors();for(let Ce=0;Ce8){if(Xe>8.7)throw new R;st=8}let Qt=Ce/2;Ce&1?(c[Qt]=st,x[Qt]=Xe-st):(l[Qt]=st,u[Qt]=Xe-st)}this.adjustOddEvenCounts(s);let C=4*t.getValue()+(n?0:2)+(r?0:1)-1,p=0,b=0;for(let Ce=l.length-1;Ce>=0;Ce--){if(M.isNotA1left(t,n,r)){let Xe=M.WEIGHTS[C][2*Ce];b+=l[Ce]*Xe}p+=l[Ce]}let T=0;for(let Ce=c.length-1;Ce>=0;Ce--)if(M.isNotA1left(t,n,r)){let Xe=M.WEIGHTS[C][2*Ce+1];T+=c[Ce]*Xe}let _=b+T;if(p&1||p>13||p<4)throw new R;let L=(13-p)/2,F=M.SYMBOL_WIDEST[L],v=9-F,ne=wt.getRSSvalue(l,F,!0),Q=wt.getRSSvalue(c,v,!1),rt=M.EVEN_TOTAL_SUBSET[L],dt=M.GSUM[L],it=ne*rt+Q+dt;return new Xt(it,_)}static isNotA1left(e,t,n){return!(e.getValue()==0&&t&&n)}adjustOddEvenCounts(e){let t=se.sum(new Int32Array(this.getOddCounts())),n=se.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,c=(n&1)==0;if(a==1)if(l){if(c)throw new R;i=!0}else{if(!c)throw new R;o=!0}else if(a==-1)if(l){if(c)throw new R;r=!0}else{if(!c)throw new R;s=!0}else if(a==0){if(l){if(!c)throw new R;t1){for(let o of this.possibleRightPairs)if(o.getCount()>1&&_e.checkChecksum(s,o))return _e.constructResult(s,o)}throw new R}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 ge;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 c=i.charAt(l).charCodeAt(0)-"0".charCodeAt(0);s+=l&1?c:3*c}s=10-s%10,s===10&&(s=0),i.append(s.toString());let o=e.getFinderPattern().getResultPoints(),a=t.getFinderPattern().getResultPoints();return new je(i.toString(),null,0,[o[0],o[1],a[0],a[1]],z.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(xe.NEED_RESULT_POINT_CALLBACK);if(o!=null){let c=(i[0]+i[1])/2;t&&(c=e.getSize()-1-c),o.foundPossibleResultPoint(new W(c,n))}let a=this.decodeDataCharacter(e,s,!0),l=this.decodeDataCharacter(e,s,!1);return new Hr(1597*a.getValue()+l.getValue(),a.getChecksumPortion()+4*l.getChecksumPortion(),s)}catch{return null}}decodeDataCharacter(e,t,n){let r=this.getDataCharacterCounters();for(let T=0;T8&&(L=8);let F=Math.floor(T/2);T&1?(a[F]=L,c[F]=_-L):(o[F]=L,l[F]=_-L)}this.adjustOddEvenCounts(n,i);let u=0,x=0;for(let T=o.length-1;T>=0;T--)x*=9,x+=o[T],u+=o[T];let C=0,p=0;for(let T=a.length-1;T>=0;T--)C*=9,C+=a[T],p+=a[T];let b=x+3*C;if(n){if(u&1||u>12||u<4)throw new R;let T=(12-u)/2,_=_e.OUTSIDE_ODD_WIDEST[T],L=9-_,F=wt.getRSSvalue(o,_,!1),v=wt.getRSSvalue(a,L,!0),ne=_e.OUTSIDE_EVEN_TOTAL_SUBSET[T],Q=_e.OUTSIDE_GSUM[T];return new Xt(F*ne+v+Q,b)}else{if(p&1||p>10||p<4)throw new R;let T=(10-p)/2,_=_e.INSIDE_ODD_WIDEST[T],L=9-_,F=wt.getRSSvalue(o,_,!0),v=wt.getRSSvalue(a,L,!1),ne=_e.INSIDE_ODD_TOTAL_SUBSET[T],Q=_e.INSIDE_GSUM[T];return new Xt(v*ne+F+Q,b)}}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=0&&i!==e.get(s);)s--;s++;const o=r[0]-s,a=this.getDecodeFinderCounters(),l=new Int32Array(a.length);re.arraycopy(a,0,l,1,a.length-1),l[0]=o;const c=this.parseFinderValue(l,_e.FINDER_PATTERNS);let u=s,x=r[1];return n&&(u=e.getSize()-1-u,x=e.getSize()-1-x),new Cn(c,[s,r[1]],u,x,t)}adjustOddEvenCounts(e,t){let n=se.sum(new Int32Array(this.getOddCounts())),r=se.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,c=(n&1)===(e?1:0),u=(r&1)===1;if(l===1)if(c){if(u)throw new R;s=!0}else{if(!u)throw new R;a=!0}else if(l===-1)if(c){if(u)throw new R;i=!0}else{if(!u)throw new R;o=!0}else if(l===0){if(c){if(!u)throw new R;ne.reset())}}class Wr extends Pt{constructor(e=500,t){super(new Zt(t),e,t)}}class fe{constructor(e,t,n){this.ecCodewords=e,this.ecBlocks=[t],n&&this.ecBlocks.push(n)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class he{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class ie{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 c of l)o+=c.getCount()*(c.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 U;for(let n of ie.VERSIONS)if(n.symbolSizeRows===e&&n.symbolSizeColumns===t)return n;throw new U}toString(){return""+this.versionNumber}static buildVersions(){return[new ie(1,10,10,8,8,new fe(5,new he(1,3))),new ie(2,12,12,10,10,new fe(7,new he(1,5))),new ie(3,14,14,12,12,new fe(10,new he(1,8))),new ie(4,16,16,14,14,new fe(12,new he(1,12))),new ie(5,18,18,16,16,new fe(14,new he(1,18))),new ie(6,20,20,18,18,new fe(18,new he(1,22))),new ie(7,22,22,20,20,new fe(20,new he(1,30))),new ie(8,24,24,22,22,new fe(24,new he(1,36))),new ie(9,26,26,24,24,new fe(28,new he(1,44))),new ie(10,32,32,14,14,new fe(36,new he(1,62))),new ie(11,36,36,16,16,new fe(42,new he(1,86))),new ie(12,40,40,18,18,new fe(48,new he(1,114))),new ie(13,44,44,20,20,new fe(56,new he(1,144))),new ie(14,48,48,22,22,new fe(68,new he(1,174))),new ie(15,52,52,24,24,new fe(42,new he(2,102))),new ie(16,64,64,14,14,new fe(56,new he(2,140))),new ie(17,72,72,16,16,new fe(36,new he(4,92))),new ie(18,80,80,18,18,new fe(48,new he(4,114))),new ie(19,88,88,20,20,new fe(56,new he(4,144))),new ie(20,96,96,22,22,new fe(68,new he(4,174))),new ie(21,104,104,24,24,new fe(56,new he(6,136))),new ie(22,120,120,18,18,new fe(68,new he(6,175))),new ie(23,132,132,20,20,new fe(62,new he(8,163))),new ie(24,144,144,22,22,new fe(62,new he(8,156),new he(2,155))),new ie(25,8,18,6,16,new fe(7,new he(1,5))),new ie(26,8,32,6,14,new fe(11,new he(1,10))),new ie(27,12,26,10,24,new fe(14,new he(1,16))),new ie(28,12,36,10,16,new fe(18,new he(1,22))),new ie(29,16,36,14,16,new fe(24,new he(1,32))),new ie(30,16,48,14,22,new fe(28,new he(1,49)))]}}ie.VERSIONS=ie.buildVersions();class Un{constructor(e){const t=e.getHeight();if(t<8||t>144||t&1)throw new U;this.version=Un.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new Le(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){const t=e.getHeight(),n=e.getWidth();return ie.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,c=!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&&!c)e[t++]=this.readCorner4(i,s)&255,n-=2,r+=2,c=!0;else{do n=0&&!this.readMappingMatrix.get(r,n)&&(e[t++]=this.readUtah(n,r,i,s)&255),n-=2,r+=2;while(n>=0&&r=0&&r=0);n+=3,r+=1}while(n7?b-1:b;s[_].codewords[L]=e[u++]}if(u!==e.length)throw new D;return s}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class Gn{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 D(""+e);let t=0,n=this.bitOffset,r=this.byteOffset;const i=this.bytes;if(n>0){const s=8-n,o=e>8-o<>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,n+=e}}return this.bitOffset=n,this.byteOffset=r,t}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var ve;(function(f){f[f.PAD_ENCODE=0]="PAD_ENCODE",f[f.ASCII_ENCODE=1]="ASCII_ENCODE",f[f.C40_ENCODE=2]="C40_ENCODE",f[f.TEXT_ENCODE=3]="TEXT_ENCODE",f[f.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",f[f.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",f[f.BASE256_ENCODE=6]="BASE256_ENCODE"})(ve||(ve={}));class Rt{static decode(e){const t=new Gn(e),n=new ge,r=new ge,i=new Array;let s=ve.ASCII_ENCODE;do if(s===ve.ASCII_ENCODE)s=this.decodeAsciiSegment(t,n,r);else{switch(s){case ve.C40_ENCODE:this.decodeC40Segment(t,n);break;case ve.TEXT_ENCODE:this.decodeTextSegment(t,n);break;case ve.ANSIX12_ENCODE:this.decodeAnsiX12Segment(t,n);break;case ve.EDIFACT_ENCODE:this.decodeEdifactSegment(t,n);break;case ve.BASE256_ENCODE:this.decodeBase256Segment(t,n,i);break;default:throw new U}s=ve.ASCII_ENCODE}while(s!==ve.PAD_ENCODE&&t.available()>0);return r.length()>0&&n.append(r.toString()),new tn(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 U;if(i<=128)return r&&(i+=128),t.append(String.fromCharCode(i-1)),ve.ASCII_ENCODE;if(i===129)return ve.PAD_ENCODE;if(i<=229){const s=i-130;s<10&&t.append("0"),t.append(""+s)}else switch(i){case 230:return ve.C40_ENCODE;case 231:return ve.BASE256_ENCODE;case 232:t.append(String.fromCharCode(29));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 ve.ANSIX12_ENCODE;case 239:return ve.TEXT_ENCODE;case 240:return ve.EDIFACT_ENCODE;case 241:break;default:if(i!==254||e.available()!==0)throw new U;break}}while(e.available()>0);return ve.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(a0)}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(a0)}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 U;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 U;const o=new Uint8Array(s);for(let a=0;a=0?r:r+256}}Rt.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"],Rt.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Rt.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"],Rt.TEXT_SHIFT2_SET_CHARS=Rt.C40_SHIFT2_SET_CHARS,Rt.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","{","|","}","~",String.fromCharCode(127)];class Xr{constructor(){this.rsDecoder=new rn(le.DATA_MATRIX_FIELD_256)}decode(e){const t=new Un(e),n=t.getVersion(),r=t.readCodewords(),i=Vn.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;lo&&(c=o,u[0]=t,u[1]=n,u[2]=r,u[3]=i),c>a&&(c=a,u[0]=n,u[1]=r,u[2]=i,u[3]=t),c>l&&(u[0]=r,u[1]=i,u[2]=t,u[3]=n),u}detectSolid2(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i),o=De.shiftPoint(n,r,(s+1)*4),a=De.shiftPoint(r,n,(s+1)*4),l=this.transitionsBetween(o,t),c=this.transitionsBetween(a,i);return lC?c:u}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=De.shiftPoint(t,n,o*4),l=De.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 c=(t.getX()+n.getX()+r.getX()+i.getX())/4,u=(t.getY()+n.getY()+r.getY()+i.getY())/4;t=De.moveAway(t,c,u),n=De.moveAway(n,c,u),r=De.moveAway(r,c,u),i=De.moveAway(i,c,u);let x,C;return a=De.shiftPoint(t,n,o*4),a=De.shiftPoint(a,i,s*4),x=De.shiftPoint(n,t,o*4),x=De.shiftPoint(x,r,s*4),l=De.shiftPoint(r,i,o*4),l=De.shiftPoint(l,n,s*4),C=De.shiftPoint(i,r,o*4),C=De.shiftPoint(C,t,s*4),[a,x,l,C]}isValid(e){return e.getX()>=0&&e.getX()0&&e.getY()Math.abs(i-n);if(o){let b=n;n=r,r=b,b=i,i=s,s=b}let a=Math.abs(i-n),l=Math.abs(s-r),c=-a/2,u=r0){if(T===s)break;T+=u,c-=a}}return C}}class Dt{constructor(){this.decoder=new Xr}decode(e,t=null){let n,r;if(t!=null&&t.has(xe.PURE_BARCODE)){const l=Dt.extractPureBits(e.getBlackMatrix());n=this.decoder.decode(l),r=Dt.NO_POINTS}else{const l=new De(e.getBlackMatrix()).detect();n=this.decoder.decode(l.getBits()),r=l.getPoints()}const i=n.getRawBytes(),s=new je(n.getText(),i,8*i.length,r,z.DATA_MATRIX,re.currentTimeMillis()),o=n.getByteSegments();o!=null&&s.putMetadata(ke.BYTE_SEGMENTS,o);const a=n.getECLevel();return a!=null&&s.putMetadata(ke.ERROR_CORRECTION_LEVEL,a),s}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),n=e.getBottomRightOnBit();if(t==null||n==null)throw new R;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,c=(s-i+1)/r;if(l<=0||c<=0)throw new R;const u=r/2;i+=u,o+=u;const x=new Le(l,c);for(let C=0;C=pe.FOR_BITS.size)throw new D;return pe.FOR_BITS.get(e)}}pe.FOR_BITS=new Map,pe.FOR_VALUE=new Map,pe.L=new pe(Kt.L,"L",1),pe.M=new pe(Kt.M,"M",0),pe.Q=new pe(Kt.Q,"Q",3),pe.H=new pe(Kt.H,"H",2);class ze{constructor(e){this.errorCorrectionLevel=pe.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,t){return j.bitCount(e^t)}static decodeFormatInformation(e,t){const n=ze.doDecodeFormatInformation(e,t);return n!==null?n:ze.doDecodeFormatInformation(e^ze.FORMAT_INFO_MASK_QR,t^ze.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,t){let n=Number.MAX_SAFE_INTEGER,r=0;for(const i of ze.FORMAT_INFO_DECODE_LOOKUP){const s=i[0];if(s===e||s===t)return new ze(i[1]);let o=ze.numBitsDiffering(e,s);o40)throw new D;return X.VERSIONS[e-1]}static decodeVersionInformation(e){let t=Number.MAX_SAFE_INTEGER,n=0;for(let r=0;r6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t}toString(){return""+this.versionNumber}}X.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]),X.VERSIONS=[new X(1,new Int32Array(0),new y(7,new E(1,19)),new y(10,new E(1,16)),new y(13,new E(1,13)),new y(17,new E(1,9))),new X(2,Int32Array.from([6,18]),new y(10,new E(1,34)),new y(16,new E(1,28)),new y(22,new E(1,22)),new y(28,new E(1,16))),new X(3,Int32Array.from([6,22]),new y(15,new E(1,55)),new y(26,new E(1,44)),new y(18,new E(2,17)),new y(22,new E(2,13))),new X(4,Int32Array.from([6,26]),new y(20,new E(1,80)),new y(18,new E(2,32)),new y(26,new E(2,24)),new y(16,new E(4,9))),new X(5,Int32Array.from([6,30]),new y(26,new E(1,108)),new y(24,new E(2,43)),new y(18,new E(2,15),new E(2,16)),new y(22,new E(2,11),new E(2,12))),new X(6,Int32Array.from([6,34]),new y(18,new E(2,68)),new y(16,new E(4,27)),new y(24,new E(4,19)),new y(28,new E(4,15))),new X(7,Int32Array.from([6,22,38]),new y(20,new E(2,78)),new y(18,new E(4,31)),new y(18,new E(2,14),new E(4,15)),new y(26,new E(4,13),new E(1,14))),new X(8,Int32Array.from([6,24,42]),new y(24,new E(2,97)),new y(22,new E(2,38),new E(2,39)),new y(22,new E(4,18),new E(2,19)),new y(26,new E(4,14),new E(2,15))),new X(9,Int32Array.from([6,26,46]),new y(30,new E(2,116)),new y(22,new E(3,36),new E(2,37)),new y(20,new E(4,16),new E(4,17)),new y(24,new E(4,12),new E(4,13))),new X(10,Int32Array.from([6,28,50]),new y(18,new E(2,68),new E(2,69)),new y(26,new E(4,43),new E(1,44)),new y(24,new E(6,19),new E(2,20)),new y(28,new E(6,15),new E(2,16))),new X(11,Int32Array.from([6,30,54]),new y(20,new E(4,81)),new y(30,new E(1,50),new E(4,51)),new y(28,new E(4,22),new E(4,23)),new y(24,new E(3,12),new E(8,13))),new X(12,Int32Array.from([6,32,58]),new y(24,new E(2,92),new E(2,93)),new y(22,new E(6,36),new E(2,37)),new y(26,new E(4,20),new E(6,21)),new y(28,new E(7,14),new E(4,15))),new X(13,Int32Array.from([6,34,62]),new y(26,new E(4,107)),new y(22,new E(8,37),new E(1,38)),new y(24,new E(8,20),new E(4,21)),new y(22,new E(12,11),new E(4,12))),new X(14,Int32Array.from([6,26,46,66]),new y(30,new E(3,115),new E(1,116)),new y(24,new E(4,40),new E(5,41)),new y(20,new E(11,16),new E(5,17)),new y(24,new E(11,12),new E(5,13))),new X(15,Int32Array.from([6,26,48,70]),new y(22,new E(5,87),new E(1,88)),new y(24,new E(5,41),new E(5,42)),new y(30,new E(5,24),new E(7,25)),new y(24,new E(11,12),new E(7,13))),new X(16,Int32Array.from([6,26,50,74]),new y(24,new E(5,98),new E(1,99)),new y(28,new E(7,45),new E(3,46)),new y(24,new E(15,19),new E(2,20)),new y(30,new E(3,15),new E(13,16))),new X(17,Int32Array.from([6,30,54,78]),new y(28,new E(1,107),new E(5,108)),new y(28,new E(10,46),new E(1,47)),new y(28,new E(1,22),new E(15,23)),new y(28,new E(2,14),new E(17,15))),new X(18,Int32Array.from([6,30,56,82]),new y(30,new E(5,120),new E(1,121)),new y(26,new E(9,43),new E(4,44)),new y(28,new E(17,22),new E(1,23)),new y(28,new E(2,14),new E(19,15))),new X(19,Int32Array.from([6,30,58,86]),new y(28,new E(3,113),new E(4,114)),new y(26,new E(3,44),new E(11,45)),new y(26,new E(17,21),new E(4,22)),new y(26,new E(9,13),new E(16,14))),new X(20,Int32Array.from([6,34,62,90]),new y(28,new E(3,107),new E(5,108)),new y(26,new E(3,41),new E(13,42)),new y(30,new E(15,24),new E(5,25)),new y(28,new E(15,15),new E(10,16))),new X(21,Int32Array.from([6,28,50,72,94]),new y(28,new E(4,116),new E(4,117)),new y(26,new E(17,42)),new y(28,new E(17,22),new E(6,23)),new y(30,new E(19,16),new E(6,17))),new X(22,Int32Array.from([6,26,50,74,98]),new y(28,new E(2,111),new E(7,112)),new y(28,new E(17,46)),new y(30,new E(7,24),new E(16,25)),new y(24,new E(34,13))),new X(23,Int32Array.from([6,30,54,78,102]),new y(30,new E(4,121),new E(5,122)),new y(28,new E(4,47),new E(14,48)),new y(30,new E(11,24),new E(14,25)),new y(30,new E(16,15),new E(14,16))),new X(24,Int32Array.from([6,28,54,80,106]),new y(30,new E(6,117),new E(4,118)),new y(28,new E(6,45),new E(14,46)),new y(30,new E(11,24),new E(16,25)),new y(30,new E(30,16),new E(2,17))),new X(25,Int32Array.from([6,32,58,84,110]),new y(26,new E(8,106),new E(4,107)),new y(28,new E(8,47),new E(13,48)),new y(30,new E(7,24),new E(22,25)),new y(30,new E(22,15),new E(13,16))),new X(26,Int32Array.from([6,30,58,86,114]),new y(28,new E(10,114),new E(2,115)),new y(28,new E(19,46),new E(4,47)),new y(28,new E(28,22),new E(6,23)),new y(30,new E(33,16),new E(4,17))),new X(27,Int32Array.from([6,34,62,90,118]),new y(30,new E(8,122),new E(4,123)),new y(28,new E(22,45),new E(3,46)),new y(30,new E(8,23),new E(26,24)),new y(30,new E(12,15),new E(28,16))),new X(28,Int32Array.from([6,26,50,74,98,122]),new y(30,new E(3,117),new E(10,118)),new y(28,new E(3,45),new E(23,46)),new y(30,new E(4,24),new E(31,25)),new y(30,new E(11,15),new E(31,16))),new X(29,Int32Array.from([6,30,54,78,102,126]),new y(30,new E(7,116),new E(7,117)),new y(28,new E(21,45),new E(7,46)),new y(30,new E(1,23),new E(37,24)),new y(30,new E(19,15),new E(26,16))),new X(30,Int32Array.from([6,26,52,78,104,130]),new y(30,new E(5,115),new E(10,116)),new y(28,new E(19,47),new E(10,48)),new y(30,new E(15,24),new E(25,25)),new y(30,new E(23,15),new E(25,16))),new X(31,Int32Array.from([6,30,56,82,108,134]),new y(30,new E(13,115),new E(3,116)),new y(28,new E(2,46),new E(29,47)),new y(30,new E(42,24),new E(1,25)),new y(30,new E(23,15),new E(28,16))),new X(32,Int32Array.from([6,34,60,86,112,138]),new y(30,new E(17,115)),new y(28,new E(10,46),new E(23,47)),new y(30,new E(10,24),new E(35,25)),new y(30,new E(19,15),new E(35,16))),new X(33,Int32Array.from([6,30,58,86,114,142]),new y(30,new E(17,115),new E(1,116)),new y(28,new E(14,46),new E(21,47)),new y(30,new E(29,24),new E(19,25)),new y(30,new E(11,15),new E(46,16))),new X(34,Int32Array.from([6,34,62,90,118,146]),new y(30,new E(13,115),new E(6,116)),new y(28,new E(14,46),new E(23,47)),new y(30,new E(44,24),new E(7,25)),new y(30,new E(59,16),new E(1,17))),new X(35,Int32Array.from([6,30,54,78,102,126,150]),new y(30,new E(12,121),new E(7,122)),new y(28,new E(12,47),new E(26,48)),new y(30,new E(39,24),new E(14,25)),new y(30,new E(22,15),new E(41,16))),new X(36,Int32Array.from([6,24,50,76,102,128,154]),new y(30,new E(6,121),new E(14,122)),new y(28,new E(6,47),new E(34,48)),new y(30,new E(46,24),new E(10,25)),new y(30,new E(2,15),new E(64,16))),new X(37,Int32Array.from([6,28,54,80,106,132,158]),new y(30,new E(17,122),new E(4,123)),new y(28,new E(29,46),new E(14,47)),new y(30,new E(49,24),new E(10,25)),new y(30,new E(24,15),new E(46,16))),new X(38,Int32Array.from([6,32,58,84,110,136,162]),new y(30,new E(4,122),new E(18,123)),new y(28,new E(13,46),new E(32,47)),new y(30,new E(48,24),new E(14,25)),new y(30,new E(42,15),new E(32,16))),new X(39,Int32Array.from([6,26,54,82,110,138,166]),new y(30,new E(20,117),new E(4,118)),new y(28,new E(40,47),new E(7,48)),new y(30,new E(43,24),new E(22,25)),new y(30,new E(10,15),new E(67,16))),new X(40,Int32Array.from([6,30,58,86,114,142,170]),new y(30,new E(19,118),new E(6,119)),new y(28,new E(18,47),new E(31,48)),new y(30,new E(34,24),new E(34,25)),new y(30,new E(20,15),new E(61,16)))];var Ue;(function(f){f[f.DATA_MASK_000=0]="DATA_MASK_000",f[f.DATA_MASK_001=1]="DATA_MASK_001",f[f.DATA_MASK_010=2]="DATA_MASK_010",f[f.DATA_MASK_011=3]="DATA_MASK_011",f[f.DATA_MASK_100=4]="DATA_MASK_100",f[f.DATA_MASK_101=5]="DATA_MASK_101",f[f.DATA_MASK_110=6]="DATA_MASK_110",f[f.DATA_MASK_111=7]="DATA_MASK_111"})(Ue||(Ue={}));class lt{constructor(e,t){this.value=e,this.isMasked=t}unmaskBitMatrix(e,t){for(let n=0;n(f+e&1)===0)],[Ue.DATA_MASK_001,new lt(Ue.DATA_MASK_001,(f,e)=>(f&1)===0)],[Ue.DATA_MASK_010,new lt(Ue.DATA_MASK_010,(f,e)=>e%3===0)],[Ue.DATA_MASK_011,new lt(Ue.DATA_MASK_011,(f,e)=>(f+e)%3===0)],[Ue.DATA_MASK_100,new lt(Ue.DATA_MASK_100,(f,e)=>(Math.floor(f/2)+Math.floor(e/3)&1)===0)],[Ue.DATA_MASK_101,new lt(Ue.DATA_MASK_101,(f,e)=>f*e%6===0)],[Ue.DATA_MASK_110,new lt(Ue.DATA_MASK_110,(f,e)=>f*e%6<3)],[Ue.DATA_MASK_111,new lt(Ue.DATA_MASK_111,(f,e)=>(f+e+f*e%3&1)===0)]]);class zr{constructor(e){const t=e.getHeight();if(t<21||(t&3)!==1)throw new U;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=0;s--)for(let o=e-9;o>=r;o--)n=this.copyBit(o,s,n);let i=X.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=X.decodeVersionInformation(n),i!==null&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;throw new U}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=lt.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,c=0;for(let u=r-1;u>0;u-=2){u===6&&u--;for(let x=0;x=0&&o[c].codewords.length!==l;)c--;c++;const u=l-r.getECCodewordsPerBlock();let x=0;for(let p=0;pe.available())throw new U;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(Je.decode(r,q.GB2312))}catch(s){throw new U(s)}}static decodeKanjiSegment(e,t,n){if(n*13>e.available())throw new U;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(Je.decode(r,q.SHIFT_JIS))}catch(s){throw new U(s)}}static decodeByteSegment(e,t,n,r,i,s){if(8*n>e.available())throw new U;const o=new Uint8Array(n);for(let l=0;l=Se.ALPHANUMERIC_CHARS.length)throw new U;return Se.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,t,n,r){const i=t.length();for(;n>1;){if(e.available()<11)throw new U;const s=e.readBits(11);t.append(Se.toAlphaNumericChar(Math.floor(s/45))),t.append(Se.toAlphaNumericChar(s%45)),n-=2}if(n===1){if(e.available()<6)throw new U;t.append(Se.toAlphaNumericChar(e.readBits(6)))}if(r)for(let s=i;s=3;){if(e.available()<10)throw new U;const r=e.readBits(10);if(r>=1e3)throw new U;t.append(Se.toAlphaNumericChar(Math.floor(r/100))),t.append(Se.toAlphaNumericChar(Math.floor(r/10)%10)),t.append(Se.toAlphaNumericChar(r%10)),n-=3}if(n===2){if(e.available()<7)throw new U;const r=e.readBits(7);if(r>=100)throw new U;t.append(Se.toAlphaNumericChar(Math.floor(r/10))),t.append(Se.toAlphaNumericChar(r%10))}else if(n===1){if(e.available()<4)throw new U;const r=e.readBits(4);if(r>=10)throw new U;t.append(Se.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 U}}Se.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Se.GB2312_SUBSET=1;class fr{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 Zr{constructor(){this.rsDecoder=new rn(le.QR_CODE_FIELD_256)}decodeBooleanArray(e,t){return this.decodeBitMatrix(Le.parseFromBooleanArray(e),t)}decodeBitMatrix(e,t){const n=new zr(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 fr(!0)),i}catch(i){throw r!==null?r:i}}decodeBitMatrixParser(e,t){const n=e.readVersion(),r=e.readFormatInformation().getErrorCorrectionLevel(),i=e.readCodewords(),s=Hn.getDataBlocks(i,n,r);let o=0;for(const c of s)o+=c.getNumDataCodewords();const a=new Uint8Array(o);let l=0;for(const c of s){const u=c.getCodewords(),x=c.getNumDataCodewords();this.correctErrors(u,x);for(let C=0;C=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;an)return NaN;for(;an)return NaN;const l=o[0]+o[1]+o[2];return 5*Math.abs(l-r)>=2*r?NaN:this.foundPatternCross(o)?pn.centerFromEnd(o,a):NaN}handlePossibleCenter(e,t,n){const r=e[0]+e[1]+e[2],i=pn.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 Wn(i,s,o);this.possibleCenters.push(a),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(a)}return null}}class Xn extends W{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 Xn(i,s,o,r)}}class Kr{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 Ve{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(xe.TRY_HARDER)!==void 0,n=e!=null&&e.get(xe.PURE_BARCODE)!==void 0,r=this.image,i=r.getHeight(),s=r.getWidth();let o=Math.floor(3*i/(4*Ve.MAX_MODULES));(ol[2]&&(u+=b-l[2]-o,C=s-1)}else{l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,x=3;continue}x=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,x=3;else l[++x]++;Ve.foundPatternCross(l)&&this.handlePossibleCenter(l,u,s,n)===!0&&(o=l[0],this.hasSkipped&&(a=this.haveMultiplyConfirmedCenters()))}const c=this.selectBestPatterns();return W.orderBestPatterns(c),new Kr(c)}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])=s&&t>=s&&o.get(t-s,e-s);)i[2]++,s++;if(e=s&&t>=s&&!o.get(t-s,e-s)&&i[1]<=n;)i[1]++,s++;if(en)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)return!1;for(;e+s=a||t+s>=l||i[3]>=n)return!1;for(;e+s=n)return!1;const c=i[0]+i[1]+i[2]+i[3]+i[4];return Math.abs(c-r)<2*r&&Ve.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=n)return NaN;for(;a=n)return NaN;const l=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(l-r)>=2*r?NaN:Ve.foundPatternCross(o)?Ve.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=n)return NaN;for(;a=n)return NaN;const l=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(l-r)>=r?NaN:Ve.foundPatternCross(o)?Ve.centerFromEnd(o,a):NaN}handlePossibleCenter(e,t,n,r){const i=e[0]+e[1]+e[2]+e[3]+e[4];let s=Ve.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 c=this.possibleCenters;for(let u=0,x=c.length;u=Ve.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()>=Ve.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 R;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 c=Math.abs(l.getEstimatedModuleSize()-n),u=Math.abs(a.getEstimatedModuleSize()-n);return cu?1:0});const o=Math.max(.2*n,s);for(let a=0;a3;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 oa?-1:0}else return s.getCount()-i.getCount()}),t.splice(3)}return[t[0],t[1],t[2]]}}Ve.CENTER_QUORUM=2,Ve.MIN_SKIP=3,Ve.MAX_MODULES=57;class on{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(xe.NEED_RESULT_POINT_CALLBACK);const n=new Ve(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 R("No pattern found in proccess finder.");const s=on.computeDimension(t,n,r,i),o=X.getProvisionalVersionForDimension(s),a=o.getDimensionForVersion()-7;let l=null;if(o.getAlignmentPatternCenters().length>0){const C=n.getX()-t.getX()+r.getX(),p=n.getY()-t.getY()+r.getY(),b=1-3/a,T=Math.floor(t.getX()+b*(C-t.getX())),_=Math.floor(t.getY()+b*(p-t.getY()));for(let L=4;L<=16;L<<=1)try{l=this.findAlignmentInRegion(i,T,_,L);break}catch(F){if(!(F instanceof R))throw F}}const c=on.createTransform(t,n,r,l,s),u=on.sampleGrid(this.image,c,s);let x;return l===null?x=[r,t,n]:x=[r,t,n,l],new An(u,x)}static createTransform(e,t,n,r,i){const s=i-3.5;let o,a,l,c;return r!==null?(o=r.getX(),a=r.getY(),l=s-3,c=l):(o=t.getX()-e.getX()+n.getX(),a=t.getY()-e.getY()+n.getY(),l=s,c=s),ft.quadrilateralToQuadrilateral(3.5,3.5,s,3.5,l,c,3.5,s,e.getX(),e.getY(),t.getX(),t.getY(),o,a,n.getX(),n.getY())}static sampleGrid(e,t,n){return _t.getInstance().sampleGridWithTransform(e,n,n,t)}static computeDimension(e,t,n,r){const i=se.round(W.distance(e,t)/r),s=se.round(W.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 R("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 C=e;e=t,t=C,C=n,n=r,r=C}const s=Math.abs(n-e),o=Math.abs(r-t);let a=-s/2;const l=e0){if(p===r)break;p+=c,a-=s}}return u===2?se.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=a||i>=s)throw new R;if(s-i!==a-o&&(a=o+(s-i),a>=e.getWidth()))throw new R;const l=Math.round((a-o+1)/r),c=Math.round((s-i+1)/r);if(l<=0||c<=0)throw new R;if(c!==l)throw new R;const u=Math.floor(r/2);i+=u,o+=u;const x=o+Math.floor((l-1)*r)-a;if(x>0){if(x>u)throw new R;o-=x}const C=i+Math.floor((c-1)*r)-s;if(C>0){if(C>u)throw new R;i-=C}const p=new Le(l,c);for(let b=0;b0;){const x=$.findGuardPattern(e,i,--r,n,!1,s,l);if(x!=null)u=x;else{r++;break}}o[0]=new W(u[0],r),o[1]=new W(u[1],r),a=!0;break}}let c=r+1;if(a){let u=0,x=Int32Array.from([Math.trunc(o[0].getX()),Math.trunc(o[1].getX())]);for(;c$.SKIPPED_ROW_COUNT_MAX)break;u++}}c-=u+1,o[2]=new W(x[0],c),o[3]=new W(x[1],c)}return c-r<$.BARCODE_MIN_HEIGHT&&me.fill(o,null),o}static findGuardPattern(e,t,n,r,i,s,o){me.fillWithin(o,0,o.length,0);let a=t,l=0;for(;e.get(a,n)&&a>0&&l++<$.MAX_PIXEL_DRIFT;)a--;let c=a,u=0,x=s.length;for(let C=i;cu?c-u:u-c;if(x>n)return 1/0;a+=x}return a/i}}$.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),$.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),$.MAX_AVG_VARIANCE=.42,$.MAX_INDIVIDUAL_VARIANCE=.8,$.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),$.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),$.MAX_PIXEL_DRIFT=3,$.MAX_PATTERN_DRIFT=5,$.SKIPPED_ROW_COUNT_MAX=25,$.ROW_STEP=5,$.BARCODE_MIN_HEIGHT=10;class He{constructor(e,t){if(t.length===0)throw new D;this.field=e;let n=t.length;if(n>1&&t[0]===0){let r=1;for(;rn.length){let s=t;t=n,n=s}let r=new Int32Array(n.length),i=n.length-t.length;re.arraycopy(n,0,r,0,i);for(let s=i;s=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 qr{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 D;return this.logTable[e]}inverse(e){if(e===0)throw new gn;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 Yn extends qr{constructor(e,t){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let n=1;for(let r=0;r0;p--){let b=r.evaluateAt(this.field.exp(p));i[t-p]=b,b!==0&&(s=!0)}if(!s)return 0;let o=this.field.getOne();if(n!=null)for(const p of n){let b=this.field.exp(e.length-1-p),T=new He(this.field,new Int32Array([this.field.subtract(0,b),1]));o=o.multiply(T)}let a=new He(this.field,i),l=this.runEuclideanAlgorithm(this.field.buildMonomial(t,1),a,t),c=l[0],u=l[1],x=this.findErrorLocations(c),C=this.findErrorMagnitudes(u,c,x);for(let p=0;p=Math.round(n/2);){let x=r,C=s;if(r=i,s=o,r.isZero())throw te.getChecksumInstance();i=x;let p=this.field.getZero(),b=r.getCoefficient(r.getDegree()),T=this.field.inverse(b);for(;i.getDegree()>=r.getDegree()&&!i.isZero();){let _=i.getDegree()-r.getDegree(),L=this.field.multiply(i.getCoefficient(i.getDegree()),T);p=p.add(this.field.buildMonomial(_,L)),i=i.subtract(r.multiplyByMonomial(_,L))}o=p.multiply(s).subtract(C).negative()}let a=o.getCoefficient(0);if(a===0)throw te.getChecksumInstance();let l=this.field.inverse(a),c=o.multiply(l),u=i.multiply(l);return[c,u]}findErrorLocations(e){let t=e.getDegree(),n=new Int32Array(t),r=0;for(let i=1;i0){let a=n?this.topLeft:this.topRight,l=Math.trunc(a.getY()-e);l<0&&(l=0);let c=new W(a.getX(),l);n?r=c:s=c}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 c=new W(a.getX(),l);n?i=c:o=c}return new Ut(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 Qr{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 an{constructor(){this.buffer=""}static form(e,t){let n=-1;function r(s,o,a,l,c,u){if(s==="%%")return"%";if(t[++n]===void 0)return;s=l?parseInt(l.substr(1)):void 0;let x=c?parseInt(c.substr(1)):void 0,C;switch(u){case"s":C=t[n];break;case"c":C=t[n][0];break;case"f":C=parseFloat(t[n]).toFixed(s);break;case"p":C=parseFloat(t[n]).toPrecision(s);break;case"e":C=parseFloat(t[n]).toExponential(s);break;case"x":C=parseInt(t[n]).toString(x||16);break;case"d":C=parseFloat(parseInt(t[n],x||10).toPrecision(s)).toFixed(0);break}C=typeof C=="object"?JSON.stringify(C):(+C).toString(x);let p=parseInt(a),b=a&&a[0]+""=="0"?"0":" ";for(;C.length=0&&(t=this.codewords[r],t!=null)||(r=this.imageRowToCodewordIndex(e)+n,rn,getValue:()=>r};i.getValue()>e?(e=i.getValue(),t=[],t.push(i.getKey())):i.getValue()===e&&t.push(i.getKey())}return K.toIntArray(t)}getConfidence(e){return this.values.get(e)}}class dr extends ln{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,c=0;for(let u=s;u=e.getRowCount()||C>u)t[u]=null;else{let p;l>2?p=(l-2)*C:p=C;let b=p>=u;for(let T=1;T<=p&&!b;T++)b=t[u-T]!=null;b?t[u]=null:(a=x.getRowNumber(),c=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=e.getRowCount()?o[l]=null:a=c.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),t=new cn,n=new cn,r=new cn,i=new cn;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]K.MAX_ROWS_IN_BARCODE)return null;let s=new Qr(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;nt.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+` `+super.toString()}}class hn{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=K.MAX_CODEWORDS_IN_BARCODE,t;do t=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e0&&i0&&(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>=1;n=t&1,nt.RATIOS_TABLE[e]||(nt.RATIOS_TABLE[e]=new Array(K.BARS_IN_MODULE)),nt.RATIOS_TABLE[e][K.BARS_IN_MODULE-r-1]=Math.fround(i/K.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let t=nt.getDecodedCodewordValue(nt.sampleBitCounts(e));return t!==-1?t:nt.getClosestDecodedValue(e)}static sampleBitCounts(e){let t=se.sum(e),n=new Int32Array(K.BARS_IN_MODULE),r=0,i=0;for(let s=0;s1)for(let s=0;s=r)break}onew Array(K.BARS_IN_MODULE));class xr{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 gr{static parseLong(e,t=void 0){return parseInt(e,t)}}class wr extends w{}wr.kind="NullPointerException";class Jr{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,t,n){if(e==null)throw new wr;if(t<0||t>e.length||n<0||t+n>e.length||t+n<0)throw new xt;if(n===0)return;for(let r=0;r0&&this.grow(e)}grow(e){let n=this.buf.length<<1;if(n-e<0&&(n=e),n<0){if(e<0)throw new $r;n=j.MAX_VALUE}this.buf=me.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 xt;this.ensureCapacity(this.count+n),re.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 me.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 we;(function(f){f[f.ALPHA=0]="ALPHA",f[f.LOWER=1]="LOWER",f[f.MIXED=2]="MIXED",f[f.PUNCT=3]="PUNCT",f[f.ALPHA_SHIFT=4]="ALPHA_SHIFT",f[f.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(we||(we={}));function Ar(){if(typeof window<"u")return window.BigInt||null;if(typeof xn<"u")return xn.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let bn;function Bt(f){if(typeof bn>"u"&&(bn=Ar()),bn===null)throw new Error("BigInt is not supported!");return bn(f)}function ti(){let f=[];f[0]=Bt(1);let e=Bt(900);f[1]=e;for(let t=2;t<16;t++)f[t]=f[t-1]*e;return f}class N{static decode(e,t){let n=new ge(""),r=k.ISO8859_1;n.enableDecoding(r);let i=1,s=e[i++],o=new xr;for(;ie[0])throw U.getFormatInstance();let r=new Int32Array(N.NUMBER_OF_SEQUENCE_CODEWORDS);for(let o=0;o0){for(let x=0;x<6;++x)s.write(Number(Bt(a)>>Bt(8*(5-x))));a=0,o=0}break}r===t[0]&&u0){for(let C=0;C<6;++C)s.write(Number(Bt(a)>>Bt(8*(5-C))));a=0,o=0}}break}return i.append(Je.decode(s.toByteArray(),n)),r}static numericCompaction(e,t,n){let r=0,i=!1,s=new Int32Array(N.MAX_NUMERIC_CODEWORDS);for(;t0&&(n.append(N.decodeBase900toBase10(s,r)),r=0)}return t}static decodeBase900toBase10(e,t){let n=Bt(0);for(let i=0;i@[\\]_\`~!\r ,: -.$/"|*()?{}'`,N.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",N.EXP900=Ar()?ti():[],N.NUMBER_OF_SEQUENCE_CODEWORDS=2;class ee{constructor(){}static decode(e,t,n,r,i,s,o){let a=new Ut(e,t,n,r,i),l=null,c=null,u;for(let p=!0;;p=!1){if(t!=null&&(l=ee.getRowIndicatorColumn(e,a,t,!0,s,o)),r!=null&&(c=ee.getRowIndicatorColumn(e,a,r,!1,s,o)),u=ee.merge(l,c),u==null)throw R.getNotFoundInstance();let b=u.getBoundingBox();if(p&&b!=null&&(b.getMinY()a.getMaxY()))a=b;else break}u.setBoundingBox(a);let x=u.getBarcodeColumnCount()+1;u.setDetectionResultColumn(0,l),u.setDetectionResultColumn(x,c);let C=l!=null;for(let p=1;p<=x;p++){let b=C?p:x-p;if(u.getDetectionResultColumn(b)!==void 0)continue;let T;b===0||b===x?T=new dr(a,b===0):T=new ln(a),u.setDetectionResultColumn(b,T);let _=-1,L=_;for(let F=a.getMinY();F<=a.getMaxY();F++){if(_=ee.getStartColumn(u,b,F,C),_<0||_>a.getMaxX()){if(L===-1)continue;_=L}let v=ee.detectCodeword(e,a.getMinX(),a.getMaxX(),C,_,F,s,o);v!=null&&(T.setCodeword(F,v),L=_,s=Math.min(s,v.getWidth()),o=Math.max(o,v.getWidth()))}}return ee.createDecoderResult(u)}static merge(e,t){if(e==null&&t==null)return null;let n=ee.getBarcodeMetadata(e,t);if(n==null)return null;let r=Ut.merge(ee.adjustBoundingBox(e),ee.adjustBoundingBox(t));return new hn(n,r)}static adjustBoundingBox(e){if(e==null)return null;let t=e.getRowHeights();if(t==null)return null;let n=ee.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 dr(t,r);for(let a=0;a<2;a++){let l=a===0?1:-1,c=Math.trunc(Math.trunc(n.getX()));for(let u=Math.trunc(Math.trunc(n.getY()));u<=t.getMaxY()&&u>=t.getMinY();u+=l){let x=ee.detectCodeword(e,0,e.getWidth(),r,c,u,i,s);x!=null&&(o.setCodeword(u,x),r?c=x.getStartX():c=x.getEndX())}}return o}static adjustCodewordCount(e,t){let n=t[0][1],r=n.getValue(),i=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-ee.getNumberOfECCodeWords(e.getBarcodeECLevel());if(r.length===0){if(i<1||i>K.MAX_CODEWORDS_IN_BARCODE)throw R.getNotFoundInstance();n.setValue(i)}else r[0]!==i&&n.setValue(i)}static createDecoderResult(e){let t=ee.createBarcodeMatrix(e);ee.adjustCodewordCount(e,t);let n=new Array,r=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),i=[],s=new Array;for(let a=0;a0;){for(let a=0;anew Array(e.getBarcodeColumnCount()+2));for(let r=0;r=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(ee.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(ee.isValidBarcodeColumn(e,t-i)&&(s=e.getDetectionResultColumn(t-i).getCodewordNearby(n)),s!=null)return r?s.getEndX():s.getStartX();let o=0;for(;ee.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=ee.adjustCodewordStartColumn(e,t,n,r,i,s);let l=ee.getModuleBitCount(e,t,n,r,i,s);if(l==null)return null;let c,u=se.sum(l);if(r)c=i+u;else{for(let p=0;p=t)&&l=t:oee.CODEWORD_SKEW_SIZE)return i;o+=a}a=-a,r=!r}return o}static checkCodewordSkew(e,t,n){return t-ee.CODEWORD_SKEW_SIZE<=e&&e<=n+ee.CODEWORD_SKEW_SIZE}static decodeCodewords(e,t,n){if(e.length===0)throw U.getFormatInstance();let r=1<n/2+ee.MAX_ERRORS||n<0||n>ee.MAX_EC_CODEWORDS)throw te.getChecksumInstance();return ee.errorCorrection.decode(e,n,t)}static verifyCodewordCount(e,t){if(e.length<4)throw U.getFormatInstance();let n=e[0];if(n>e.length)throw U.getFormatInstance();if(n===0)if(t>=1;return t}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return ee.getCodewordBucketNumber(ee.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let t=new an;for(let n=0;ns)}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?j.MAX_VALUE:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(We.getMaxWidth(e[0],e[4]),We.getMaxWidth(e[6],e[2])*K.MODULES_IN_CODEWORD/K.MODULES_IN_STOP_PATTERN),Math.max(We.getMaxWidth(e[1],e[5]),We.getMaxWidth(e[7],e[3])*K.MODULES_IN_CODEWORD/K.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(We.getMinWidth(e[0],e[4]),We.getMinWidth(e[6],e[2])*K.MODULES_IN_CODEWORD/K.MODULES_IN_STOP_PATTERN),Math.min(We.getMinWidth(e[1],e[5]),We.getMinWidth(e[7],e[3])*K.MODULES_IN_CODEWORD/K.MODULES_IN_STOP_PATTERN)))}reset(){}}class Tn extends w{}Tn.kind="ReaderException";class Er{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(xe.TRY_HARDER)===!0,n=m(e)?null:e.get(xe.POSSIBLE_FORMATS),r=new Array;if(!m(n)){const i=n.some(s=>s===z.UPC_A||s===z.UPC_E||s===z.EAN_13||s===z.EAN_8||s===z.CODABAR||s===z.CODE_39||s===z.CODE_93||s===z.CODE_128||s===z.ITF||s===z.RSS_14||s===z.RSS_EXPANDED);i&&!t&&r.push(new Zt(e,this.verbose)),n.includes(z.QR_CODE)&&r.push(new Mt),n.includes(z.DATA_MATRIX)&&r.push(new Dt),n.includes(z.AZTEC)&&r.push(new En),n.includes(z.PDF_417)&&r.push(new We),i&&t&&r.push(new Zt(e,this.verbose))}r.length===0&&(t||r.push(new Zt(e,this.verbose)),r.push(new Mt),r.push(new Dt),r.push(new En),r.push(new We),t&&r.push(new Zt(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 Tn("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 Tn)continue}throw new R("No MultiFormat Readers were able to detect the code.")}}class ni extends Pt{constructor(e=null,t=500){const n=new Er;n.setHints(e),super(n,t)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class ri extends Pt{constructor(e=500){super(new We,e)}}class ii extends Pt{constructor(e=500){super(new Mt,e)}}var zn;(function(f){f[f.ERROR_CORRECTION=0]="ERROR_CORRECTION",f[f.CHARACTER_SET=1]="CHARACTER_SET",f[f.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",f[f.MIN_SIZE=3]="MIN_SIZE",f[f.MAX_SIZE=4]="MAX_SIZE",f[f.MARGIN=5]="MARGIN",f[f.PDF417_COMPACT=6]="PDF417_COMPACT",f[f.PDF417_COMPACTION=7]="PDF417_COMPACTION",f[f.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",f[f.AZTEC_LAYERS=9]="AZTEC_LAYERS",f[f.QR_VERSION=10]="QR_VERSION"})(zn||(zn={}));var Pe=zn;class Zn{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new $e(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 $e(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 D("No error correction bytes");const n=e.length-t;if(n<=0)throw new D("No data bytes provided");const r=this.buildGenerator(t),i=new Int32Array(n);re.arraycopy(e,0,i,0,n);let s=new $e(this.field,i);s=s.multiplyByMonomial(t,1);const a=s.divide(r)[1].getCoefficients(),l=t-a.length;for(let c=0;c=5&&(n+=Oe.N1+(a-5)),a=1,l=u)}a>=5&&(n+=Oe.N1+(a-5))}return n}}Oe.N1=3,Oe.N2=3,Oe.N3=40,Oe.N4=10;class yn{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)me.fill(t,e)}equals(e){if(!(e instanceof yn))return!1;const t=e;if(this.width!==t.width||this.height!==t.height)return!1;for(let n=0,r=this.height;n> `),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&&e0;){for(s===6&&(s-=1);o>=0&&o=n;)e^=t<=0)for(let a=0;a!==s;a++){const l=r[a];l>=0&&Z.isEmpty(t.get(l,o))&&Z.embedPositionAdjustmentPattern(l-2,o-2,t)}}}}Z.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])]),Z.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])]),Z.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])]),Z.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])]),Z.VERSION_INFO_POLY=7973,Z.TYPE_INFO_POLY=1335,Z.TYPE_INFO_MASK_PATTERN=21522;class si{constructor(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class be{constructor(){}static calculateMaskPenalty(e){return Oe.applyMaskPenaltyRule1(e)+Oe.applyMaskPenaltyRule2(e)+Oe.applyMaskPenaltyRule3(e)+Oe.applyMaskPenaltyRule4(e)}static encode(e,t,n=null){let r=be.DEFAULT_BYTE_MODE_ENCODING;const i=n!==null&&n.get(Pe.CHARACTER_SET)!==void 0;i&&(r=n.get(Pe.CHARACTER_SET).toString());const s=this.chooseMode(e,r),o=new ae;if(s===Y.BYTE&&(i||be.DEFAULT_BYTE_MODE_ENCODING!==r)){const F=k.getCharacterSetECIByName(r);F!==void 0&&this.appendECI(F,o)}this.appendModeInfo(s,o);const a=new ae;this.appendBytes(e,s,a,r);let l;if(n!==null&&n.get(Pe.QR_VERSION)!==void 0){const F=Number.parseInt(n.get(Pe.QR_VERSION).toString(),10);l=X.getVersionForNumber(F);const v=this.calculateBitsNeeded(s,o,a,l);if(!this.willFit(v,l,t))throw new Ee("Data too big for requested version")}else l=this.recommendVersion(t,s,o,a);const c=new ae;c.appendBitArray(o);const u=s===Y.BYTE?a.getSizeInBytes():e.length;this.appendLengthInfo(u,l,s,c),c.appendBitArray(a);const x=l.getECBlocksForLevel(t),C=l.getTotalCodewords()-x.getTotalECCodewords();this.terminateBits(C,c);const p=this.interleaveWithECBytes(c,l.getTotalCodewords(),C,x.getNumBlocks()),b=new Vt;b.setECLevel(t),b.setMode(s),b.setVersion(l);const T=l.getDimensionForVersion(),_=new yn(T,T),L=this.chooseMaskPattern(p,t,l,_);return b.setMaskPattern(L),Z.buildMatrix(p,t,l,L,_),b.setMatrix(_),b}static recommendVersion(e,t,n,r){const i=this.calculateBitsNeeded(t,n,r,X.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 e159)&&(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=a}static terminateBits(e,t){const n=e*8;if(t.getSize()>n)throw new Ee("data bits cannot fit in the QR Code"+t.getSize()+" > "+n);for(let s=0;s<4&&t.getSize()0)for(let s=r;s<8;s++)t.appendBit(!1);const i=e-t.getSizeInBytes();for(let s=0;s=n)throw new Ee("Block ID too large");const o=e%n,a=n-o,l=Math.floor(e/n),c=l+1,u=Math.floor(t/n),x=u+1,C=l-u,p=c-x;if(C!==p)throw new Ee("EC bytes mismatch");if(n!==a+o)throw new Ee("RS blocks mismatch");if(e!==(u+C)*a+(x+p)*o)throw new Ee("Total bytes mismatch");r=1<=0&&t<=9}static appendNumericBytes(e,t){const n=e.length;let r=0;for(;r=33088&&a<=40956?l=a-33088:a>=57408&&a<=60351&&(l=a-49472),l===-1)throw new Ee("Invalid byte sequence");const c=(l>>8)*192+(l&255);t.appendBits(c,13)}}static appendECI(e,t){t.appendBits(Y.ECI.getBits(),4),t.appendBits(e.getValue(),8)}}be.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]),be.DEFAULT_BYTE_MODE_ENCODING=k.UTF8.getName();class Gt{write(e,t,n,r=null){if(e.length===0)throw new D("Found empty contents");if(t<0||n<0)throw new D("Requested dimensions are too small: "+t+"x"+n);let i=pe.L,s=Gt.QUIET_ZONE_SIZE;r!==null&&(r.get(Pe.ERROR_CORRECTION)!==void 0&&(i=pe.fromString(r.get(Pe.ERROR_CORRECTION).toString())),r.get(Pe.MARGIN)!==void 0&&(s=Number.parseInt(r.get(Pe.MARGIN).toString(),10)));const o=be.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 gt;const s=i.getWidth(),o=i.getHeight(),a=s+r*2,l=o+r*2,c=Math.max(t,a),u=Math.max(n,l),x=Math.min(Math.floor(c/a),Math.floor(u/l)),C=Math.floor((c-s*x)/2),p=Math.floor((u-o*x)/2),b=this.createSVGElement(c,u);for(let T=0,_=p;Tt||i+o>n)throw new D("Crop rectangle does not fit within image data.");a&&this.reverseHorizontal(s,o)}getRow(e,t){if(e<0||e>=this.getHeight())throw new D("Requested row is outside the image: "+e);const n=this.getWidth();(t==null||t.length>16&255,C=u>>7&510,p=u&255;l[c]=(x+C+p)/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 D("Crop rectangle does not fit within image data.")}getRow(e,t){if(e<0||e>=this.getHeight())throw new D("Requested row is outside the image: "+e);const n=this.getWidth();(t==null||t.length"}}class qn extends qt{constructor(e,t,n){super(e,0,0),this.binaryShiftStart=t,this.binaryShiftByteCount=n}appendTo(e,t){for(let n=0;n62?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 qn(this,e,t)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function li(f,e,t){return new qn(f,e,t)}function un(f,e,t){return new qt(f,e,t)}const ci=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],vt=0,Sn=1,ht=2,pr=3,mt=4,hi=new qt(null,0,0),Qn=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,655360+928+30]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,655360+928+30]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,917504+14336+928+30]),Int32Array.from([(5<<16)+29,(5<<16)+28,655360+928+30,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,655360+992+28,655360+992+30,655360+992+29,0])];function fi(f){for(let e of f)me.fill(e,-1);return f[vt][mt]=0,f[Sn][mt]=0,f[Sn][vt]=28,f[pr][mt]=0,f[ht][mt]=0,f[ht][vt]=15,f}const br=fi(me.createInt32Array(6,6));class It{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=Qn[this.mode][e];r=un(r,s&65535,s>>16),n+=s>>16}let i=e===ht?4:5;return r=un(r,t,i),new It(r,e,0,n+i)}shiftAndAppend(e,t){let n=this.token,r=this.mode===ht?4:5;return n=un(n,br[this.mode][e],r),n=un(n,t,5),new It(n,this.mode,0,this.bitCount+r+5)}addBinaryShiftChar(e){let t=this.token,n=this.mode,r=this.bitCount;if(this.mode===mt||this.mode===ht){let o=Qn[n][vt];t=un(t,o&65535,o>>16),r+=o>>16,n=vt}let i=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,s=new It(t,n,this.binaryShiftByteCount+1,r+i);return s.binaryShiftByteCount===2047+31&&(s=s.endBinaryShift(e+1)),s}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let t=this.token;return t=li(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new It(t,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let t=this.bitCount+(Qn[this.mode][e.mode]>>16);return this.binaryShiftByteCounte.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 ae;for(const r of t)r.appendTo(n,e);return n}toString(){return q.format("%s bits=%d bytes=%d",ci[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}It.INITIAL_STATE=new It(hi,vt,0,0);function ui(f){const e=q.getCharCode(" "),t=q.getCharCode("."),n=q.getCharCode(",");f[vt][e]=1;const r=q.getCharCode("Z"),i=q.getCharCode("A");for(let x=i;x<=r;x++)f[vt][x]=x-i+2;f[Sn][e]=1;const s=q.getCharCode("z"),o=q.getCharCode("a");for(let x=o;x<=s;x++)f[Sn][x]=x-o+2;f[ht][e]=1;const a=q.getCharCode("9"),l=q.getCharCode("0");for(let x=l;x<=a;x++)f[ht][x]=x-l+2;f[ht][n]=12,f[ht][t]=13;const c=["\0"," ","","","","","","","\x07","\b"," ",` `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let x=0;x","?","[","]","{","}"];for(let x=0;x0&&(f[mt][q.getCharCode(u[x])]=x);return f}const Jn=ui(me.createInt32Array(5,256));class dn{constructor(e){this.text=e}encode(){const e=q.getCharCode(" "),t=q.getCharCode(` `);let n=Ir.singletonList(It.INITIAL_STATE);for(let i=0;i0?(n=dn.updateStateListForPair(n,i,s),i++):n=this.updateStateListForChar(n,i)}return Ir.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 dn.simplifyStates(n)}updateStateForChar(e,t,n){let r=this.text[t]&255,i=Jn[e.getMode()][r]>0,s=null;for(let o=0;o<=mt;o++){let a=Jn[o][r];if(a>0){if(s==null&&(s=e.endBinaryShift(t)),!i||o===e.getMode()||o===ht){const l=s.latchAndAppend(o,a);n.push(l)}if(!i&&br[e.getMode()][o]>=0){const l=s.shiftAndAppend(o,a);n.push(l)}}}if(e.getBinaryShiftByteCount()>0||Jn[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(mt,n)),e.getMode()!==mt&&r.push(i.shiftAndAppend(mt,n)),n===3||n===4){let s=i.latchAndAppend(ht,16-n).latchAndAppend(ht,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 oe{constructor(){}static encodeBytes(e){return oe.encode(e,oe.DEFAULT_EC_PERCENT,oe.DEFAULT_AZTEC_LAYERS)}static encode(e,t,n){let r=new dn(e).encode(),i=j.truncDivision(r.getSize()*t,100)+11,s=r.getSize()+i,o,a,l,c,u;if(n!==oe.DEFAULT_AZTEC_LAYERS){if(o=n<0,a=Math.abs(n),a>(o?oe.MAX_NB_BITS_COMPACT:oe.MAX_NB_BITS))throw new D(q.format("Illegal value %s for layers",n));l=oe.totalBitsInLayer(a,o),c=oe.WORD_SIZE[a];let v=l-l%c;if(u=oe.stuffBits(r,c),u.getSize()+i>v)throw new D("Data to large for user specified layer");if(o&&u.getSize()>c*64)throw new D("Data to large for user specified layer")}else{c=0,u=null;for(let v=0;;v++){if(v>oe.MAX_NB_BITS)throw new D("Data too large for an Aztec code");if(o=v<=3,a=o?v+1:v,l=oe.totalBitsInLayer(a,o),s>l)continue;(u==null||c!==oe.WORD_SIZE[a])&&(c=oe.WORD_SIZE[a],u=oe.stuffBits(r,c));let ne=l-l%c;if(!(o&&u.getSize()>c*64)&&u.getSize()+i<=ne)break}}let x=oe.generateCheckWords(u,l,c),C=u.getSize()/c,p=oe.generateModeMessage(o,a,C),b=(o?11:14)+a*4,T=new Int32Array(b),_;if(o){_=b;for(let v=0;v=r||e.get(s+a))&&(o|=1<0&&d[d.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!d||w[1]>d[0]&&w[1]m&&(m=P,h=S)}if(!h)throw"No largest barcode found";return h},A.prototype.createBarcodeDetectorFormats=function(g){for(var h=[],m=0,I=g;m0&&d[d.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!d||w[1]>d[0]&&w[1]0&&d[d.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!d||w[1]>d[0]&&w[1]=d&&(g.isClosed=!0,g.parentElement.removeChild(g.surface),h())})})},A.prototype.getCapabilities=function(){return new Pi(this.getFirstTrackOrFail())},A}(),Fi=function(){function A(g){this.mediaStream=g}return A.prototype.render=function(g,h,m){return On(this,void 0,void 0,function(){return Rn(this,function(I){return[2,Li.create(g,this.mediaStream,h,m)]})})},A.create=function(g){return On(this,void 0,void 0,function(){var h,m;return Rn(this,function(I){switch(I.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return h={audio:!1,video:g},[4,navigator.mediaDevices.getUserMedia(h)];case 1:return m=I.sent(),[2,new A(m)]}})})},A}(),Dr=globalThis&&globalThis.__awaiter||function(A,g,h,m){function I(d){return d instanceof h?d:new h(function(S){S(d)})}return new(h||(h=Promise))(function(d,S){function P(O){try{w(m.next(O))}catch(D){S(D)}}function B(O){try{w(m.throw(O))}catch(D){S(D)}}function w(O){O.done?d(O.value):I(O.value).then(P,B)}w((m=m.apply(A,g||[])).next())})},Mr=globalThis&&globalThis.__generator||function(A,g){var h={label:0,sent:function(){if(d[0]&1)throw d[1];return d[1]},trys:[],ops:[]},m,I,d,S;return S={next:P(0),throw:P(1),return:P(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function P(w){return function(O){return B([w,O])}}function B(w){if(m)throw new TypeError("Generator is already executing.");for(;S&&(S=0,w[0]&&(h=0)),h;)try{if(m=1,I&&(d=w[0]&2?I.return:w[0]?I.throw||((d=I.return)&&d.call(I),0):I.next)&&!(d=d.call(I,w[1])).done)return d;switch(I=0,d&&(w=[w[0]&2,d.value]),w[0]){case 0:case 1:d=w;break;case 4:return h.label++,{value:w[1],done:!1};case 5:h.label++,I=w[1],w=[0];continue;case 7:w=h.ops.pop(),h.trys.pop();continue;default:if(d=h.trys,!(d=d.length>0&&d[d.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!d||w[1]>d[0]&&w[1]0&&d[d.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!d||w[1]>d[0]&&w[1]g&&(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."),w=g),w};P(S.width),P(S.height),S.width=B(S.width)},A.prototype.validateQrboxConfig=function(g){if(typeof g!="number"&&typeof g!="function"&&(g.width===void 0||g.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},A.prototype.toQrdimensions=function(g,h,m){if(typeof m=="number")return{width:m,height:m};if(typeof m=="function")try{return m(g,h)}catch(I){throw new Error("qrbox config was passed as a function but it failed with unknown error"+I)}return m},A.prototype.setupUi=function(g,h,m){m.isShadedBoxEnabled()&&this.validateQrboxSize(g,h,m);var I=bt(m.qrbox)?{width:g,height:h}:m.qrbox;this.validateQrboxConfig(I);var d=this.toQrdimensions(g,h,I);d.height>h&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var S=m.isShadedBoxEnabled()&&d.height<=h,P={x:0,y:0,width:g,height:h},B=S?this.getShadedRegionBounds(g,h,d):P,w=this.createCanvasElement(B.width,B.height),O={willReadFrequently:!0},D=w.getContext("2d",O);D.canvas.width=B.width,D.canvas.height=B.height,this.element.append(w),S&&this.possiblyInsertShadingElement(this.element,g,h,d),this.createScannerPausedUiElement(this.element),this.qrRegion=B,this.context=D,this.canvasElement=w},A.prototype.createScannerPausedUiElement=function(g){var h=document.createElement("div");h.innerText=$t.scannerPaused(),h.style.display="none",h.style.position="absolute",h.style.top="0px",h.style.zIndex="1",h.style.background="rgba(9, 9, 9, 0.46)",h.style.color="#FFECEC",h.style.textAlign="center",h.style.width="100%",g.appendChild(h),this.scannerPausedUiElement=h},A.prototype.scanContext=function(g,h){var m=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(I){return g(I.text,Sr.createFromQrcodeResult(I)),m.possiblyUpdateShaders(!0),!0}).catch(function(I){m.possiblyUpdateShaders(!1);var d=$t.codeParseError(I);return h(d,yi.createFrom(d)),!1})},A.prototype.foreverScan=function(g,h,m){var I=this;if(this.shouldScan&&this.renderedCamera){var d=this.renderedCamera.getSurface(),S=d.videoWidth/d.clientWidth,P=d.videoHeight/d.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var B=this.qrRegion.width*S,w=this.qrRegion.height*P,O=this.qrRegion.x*S,D=this.qrRegion.y*P;this.context.drawImage(d,O,D,B,w,0,0,this.qrRegion.width,this.qrRegion.height);var de=function(){I.foreverScanTimeout=setTimeout(function(){I.foreverScan(g,h,m)},I.getTimeoutFps(g.fps))};this.scanContext(h,m).then(function(te){!te&&g.disableFlip!==!0?(I.context.translate(I.context.canvas.width,0),I.context.scale(-1,1),I.scanContext(h,m).finally(function(){de()})):de()}).catch(function(te){I.logger.logError("Error happend while scanning context",te),de()})}},A.prototype.createVideoConstraints=function(g){if(typeof g=="string")return{deviceId:{exact:g}};if(typeof g=="object"){var h="facingMode",m="deviceId",I={user:!0,environment:!0},d="exact",S=function(Ze){if(Ze in I)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(Ze,"'")},P=Object.keys(g);if(P.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(P.length," keys");var B=Object.keys(g)[0];if(B!==h&&B!==m)throw"Only '".concat(h,"' and '").concat(m,"' ")+" are supported for 'cameraIdOrConfig'";if(B===h){var w=g.facingMode;if(typeof w=="string"){if(S(w))return{facingMode:w}}else if(typeof w=="object")if(d in w){if(S(w["".concat(d)]))return{facingMode:{exact:w["".concat(d)]}}}else throw"'facingMode' should be string or object with"+" ".concat(d," as key.");else{var O=typeof w;throw"Invalid type of 'facingMode' = ".concat(O)}}else{var D=g.deviceId;if(typeof D=="string")return{deviceId:D};if(typeof D=="object"){if(d in D)return{deviceId:{exact:D["".concat(d)]}};throw"'deviceId' should be string or object with"+" ".concat(d," as key.")}else{var de=typeof D;throw"Invalid type of 'deviceId' = ".concat(de)}}}var te=typeof g;throw"Invalid type of 'cameraIdOrConfig' = ".concat(te)},A.prototype.computeCanvasDrawConfig=function(g,h,m,I){if(g<=m&&h<=I){var d=(m-g)/2,S=(I-h)/2;return{x:d,y:S,width:g,height:h}}else{var P=g,B=h;return g>m&&(h=m/g*h,g=m),h>I&&(g=I/h*g,h=I),this.logger.log("Image downsampled from "+"".concat(P,"X").concat(B)+" to ".concat(g,"X").concat(h,".")),this.computeCanvasDrawConfig(g,h,m,I)}},A.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var g=document.getElementById(this.elementId);g&&(g.innerHTML="")},A.prototype.possiblyUpdateShaders=function(g){this.qrMatch!==g&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(h){h.style.backgroundColor=g?ot.BORDER_SHADER_MATCH_COLOR:ot.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=g)},A.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},A.prototype.createCanvasElement=function(g,h,m){var I=g,d=h,S=document.createElement("canvas");return S.style.width="".concat(I,"px"),S.style.height="".concat(d,"px"),S.style.display="none",S.id=bt(m)?"qr-canvas":m,S},A.prototype.getShadedRegionBounds=function(g,h,m){if(m.width>g||m.height>h)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(g-m.width)/2,y:(h-m.height)/2,width:m.width,height:m.height}},A.prototype.possiblyInsertShadingElement=function(g,h,m,I){if(!(h-I.width<1||m-I.height<1)){var d=document.createElement("div");d.style.position="absolute";var S=(h-I.width)/2,P=(m-I.height)/2;if(d.style.borderLeft="".concat(S,"px solid rgba(0, 0, 0, 0.48)"),d.style.borderRight="".concat(S,"px solid rgba(0, 0, 0, 0.48)"),d.style.borderTop="".concat(P,"px solid rgba(0, 0, 0, 0.48)"),d.style.borderBottom="".concat(P,"px solid rgba(0, 0, 0, 0.48)"),d.style.boxSizing="border-box",d.style.top="0px",d.style.bottom="0px",d.style.left="0px",d.style.right="0px",d.id="".concat(ot.SHADED_REGION_ELEMENT_ID),h-I.width<11||m-I.height<11)this.hasBorderShaders=!1;else{var B=5,w=40;this.insertShaderBorders(d,w,B,-B,null,0,!0),this.insertShaderBorders(d,w,B,-B,null,0,!1),this.insertShaderBorders(d,w,B,null,-B,0,!0),this.insertShaderBorders(d,w,B,null,-B,0,!1),this.insertShaderBorders(d,B,w+B,-B,null,-B,!0),this.insertShaderBorders(d,B,w+B,null,-B,-B,!0),this.insertShaderBorders(d,B,w+B,-B,null,-B,!1),this.insertShaderBorders(d,B,w+B,null,-B,-B,!1),this.hasBorderShaders=!0}g.append(d)}},A.prototype.insertShaderBorders=function(g,h,m,I,d,S,P){var B=document.createElement("div");B.style.position="absolute",B.style.backgroundColor=ot.BORDER_SHADER_DEFAULT_COLOR,B.style.width="".concat(h,"px"),B.style.height="".concat(m,"px"),I!==null&&(B.style.top="".concat(I,"px")),d!==null&&(B.style.bottom="".concat(d,"px")),P?B.style.left="".concat(S,"px"):B.style.right="".concat(S,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(B),g.appendChild(B)},A.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},A.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},A.prototype.getTimeoutFps=function(g){return 1e3/g},A}();globalThis&&globalThis.__awaiter;globalThis&&globalThis.__generator;globalThis&&globalThis.__awaiter;globalThis&&globalThis.__generator;var vr;(function(A){A[A.STATUS_DEFAULT=0]="STATUS_DEFAULT",A[A.STATUS_SUCCESS=1]="STATUS_SUCCESS",A[A.STATUS_WARNING=2]="STATUS_WARNING",A[A.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(vr||(vr={}));const Zi={id:"reader"},Ki=wi({__name:"Index",emits:["success","failure"],setup(A,{expose:g,emit:h}){const m=h,I=$n(""),d=$n(""),S=$n(null);Ai(()=>{}),Ei(()=>{console.log("qr-onUnmounted"),w()});const P=()=>{Br.getCameras().then(O=>{console.log("摄像头信息",O),O&&O.length&&(O.length>1?I.value=O[1].id:I.value=O[0].id,d.value=O,B())}).catch(O=>{alert(O),console.log("获取设备信息失败",O)})},B=()=>{S.value=new Br("reader"),console.log("html5QrCode",S),S.value.start(I.value,{fps:10,qrbox:{width:250,height:250},focusMode:"continuous"},(O,D)=>{console.log("扫描的结果",O,D),m("success",D),w()},(O,D)=>{console.log("暂无额扫描结果",O,D)}).catch(O=>{console.log(`Unable to start scanning, error: ${O}`)})},w=()=>{S.value.stop().then(O=>{console.log("QR Code scanning stopped.",O)}).catch(O=>{console.log("Unable to stop scanning.",O)})};return g({open:P,stop:w}),(O,D)=>(Ci(),mi("div",Zi))}});const qi=Ii(Ki,[["__scopeId","data-v-a17624fc"]]);export{qi as Q};