l||e.sy+e.sHeight>h)throw new Error("Invalid position.");null===(n=Gr._onLog)||void 0===n||n.call(Gr,"getImageData(), START: "+(c=Date.now()));const u=Math.round(e.sx),f=Math.round(e.sy),g=Math.round(e.sWidth),m=Math.round(e.sHeight),p=Math.round(e.dWidth),_=Math.round(e.dHeight);let v,y=(null==i?void 0:i.pixelFormat)||wi.RGBA,w=null==i?void 0:i.bufferContainer;if(w&&(wi.GREY===y&&w.length{if(!i)return t;let r=e+Math.round((t-e)/i)*i;return n&&(r=Math.min(r,n)),r};class Yr{static get version(){return"4.3.3-dev-20251029130621"}static isStorageAvailable(t){let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}static findBestRearCameraInIOS(t,e){if(!t||!t.length)return null;let i=!1;if((null==e?void 0:e.getMainCamera)&&(i=!0),i){const e=["후면 카메라","背面カメラ","後置鏡頭","后置相机","กล้องด้านหลัง","बैक कैमरा","الكاميرا الخلفية","מצלמה אחורית","камера на задней панели","задня камера","задна камера","артқы камера","πίσω κάμερα","zadní fotoaparát","zadná kamera","tylny aparat","takakamera","stražnja kamera","rückkamera","kamera på baksidan","kamera belakang","kamera bak","hátsó kamera","fotocamera (posteriore)","câmera traseira","câmara traseira","cámara trasera","càmera posterior","caméra arrière","cameră spate","camera mặt sau","camera aan achterzijde","bagsidekamera","back camera","arka kamera"],i=t.find(t=>e.includes(t.label.toLowerCase()));return null==i?void 0:i.deviceId}{const e=["후면","背面","後置","后置","านหลัง","बैक","خلفية","אחורית","задняя","задней","задна","πίσω","zadní","zadná","tylny","trasera","traseira","taka","stražnja","spate","sau","rück","posteriore","posterior","hátsó","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"],i=["트리플","三镜头","三鏡頭","トリプル","สาม","ट्रिपल","ثلاثية","משולשת","үштік","тройная","тройна","потроєна","τριπλή","üçlü","trójobiektywowy","trostruka","trojný","trojitá","trippelt","trippel","triplă","triple","tripla","tiga","kolmois","ba camera"],n=["듀얼 와이드","雙廣角","双广角","デュアル広角","คู่ด้านหลังมุมกว้าง","ड्युअल वाइड","مزدوجة عريضة","כפולה רחבה","қос кең бұрышты","здвоєна ширококутна","двойная широкоугольная","двойна широкоъгълна","διπλή ευρεία","çift geniş","laajakulmainen kaksois","kép rộng mặt sau","kettős, széles látószögű","grande angular dupla","ganda","dwuobiektywowy","dwikamera","dvostruka široka","duální širokoúhlý","duálna širokouhlá","dupla grande-angular","dublă","dubbel vidvinkel","dual-weitwinkel","dual wide","dual con gran angular","dual","double","doppia con grandangolo","doble","dobbelt vidvinkelkamera"],r=t.filter(t=>{const i=t.label.toLowerCase();return e.some(t=>i.includes(t))});if(!r.length)return null;const s=r.find(t=>{const e=t.label.toLowerCase();return i.some(t=>e.includes(t))});if(s)return s.deviceId;const a=r.find(t=>{const e=t.label.toLowerCase();return n.some(t=>e.includes(t))});return a?a.deviceId:r[0].deviceId}}static findBestRearCamera(t,e){if(!t||!t.length)return null;if(["iPhone","iPad","Mac"].includes(ai.OS))return Yr.findBestRearCameraInIOS(t,{getMainCamera:null==e?void 0:e.getMainCameraInIOS});const i=["후","背面","背置","後面","後置","后面","后置","านหลัง","หลัง","बैक","خلفية","אחורית","задняя","задня","задней","задна","πίσω","zadní","zadná","tylny","trás","trasera","traseira","taka","stražnja","spate","sau","rück","rear","posteriore","posterior","hátsó","darrere","belakang","baksidan","bakre","bak","bagside","back","aртқы","arrière","arka","achterzijde"];for(let e of t){const t=e.label.toLowerCase();if(t&&i.some(e=>t.includes(e))&&/\b0(\b)?/.test(t))return e.deviceId}return["Android","HarmonyOS"].includes(ai.OS)?t[t.length-1].deviceId:null}static findBestCamera(t,e,i){return t&&t.length?"environment"===e?this.findBestRearCamera(t,i):"user"===e?null:e?void 0:null:null}static async playVideo(t,e,i){if(!t)throw new Error("Invalid 'videoEl'.");if(!e)throw new Error("Invalid 'source'.");return new Promise(async(n,r)=>{let s;const a=()=>{t.removeEventListener("loadstart",c),t.removeEventListener("abort",d),t.removeEventListener("play",u),t.removeEventListener("error",f),t.removeEventListener("loadedmetadata",p)};let o=!1;const l=()=>{o=!0,s&&clearTimeout(s),a(),n(t)},h=t=>{s&&clearTimeout(s),a(),r(t)},c=()=>{t.addEventListener("abort",d,{once:!0})},d=()=>{const t=new Error("Video playing was interrupted.");t.name="AbortError",h(t)},u=()=>{l()},f=()=>{h(new Error(`Video error ${t.error.code}: ${t.error.message}.`))};let g;const m=new Promise(t=>{g=t}),p=()=>{g()};if(t.addEventListener("loadstart",c,{once:!0}),t.addEventListener("play",u,{once:!0}),t.addEventListener("error",f,{once:!0}),t.addEventListener("loadedmetadata",p,{once:!0}),"string"==typeof e||e instanceof String?t.src=e:t.srcObject=e,t.autoplay&&await new Promise(t=>{setTimeout(t,1e3)}),!o){i&&(s=setTimeout(()=>{a(),r(new Error("Failed to play video. Timeout."))},i)),await m;try{await t.play(),l()}catch(t){console.warn("1st play error: "+((null==t?void 0:t.message)||t))}if(!o)try{await t.play(),l()}catch(t){console.warn("2rd play error: "+((null==t?void 0:t.message)||t)),h(t)}}})}static async testCameraAccess(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))return{ok:!1,errorName:"InsecureContext",errorMessage:"Insecure context."};let n;try{n=t?await navigator.mediaDevices.getUserMedia(t):await navigator.mediaDevices.getUserMedia({video:!0})}catch(t){return{ok:!1,errorName:t.name,errorMessage:t.message}}finally{null==n||n.getTracks().forEach(t=>{t.stop()})}return{ok:!0}}get state(){if(!oi(this,ar,"f"))return"closed";if("pending"===oi(this,ar,"f"))return"opening";if("fulfilled"===oi(this,ar,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(t){t?Yr.isStorageAvailable("localStorage")?li(this,ir,!0):(li(this,ir,!1),console.warn("Local storage is unavailable")):li(this,ir,!1)}get ifSaveLastUsedCamera(){return oi(this,ir,"f")}get isVideoPlaying(){return!(!oi(this,qn,"f")||oi(this,qn,"f").paused)&&"opened"===this.state}set tapFocusEventBoundEl(t){var e,i,n;if(!(t instanceof HTMLElement)&&null!=t)throw new TypeError("Invalid 'element'.");null===(e=oi(this,ur,"f"))||void 0===e||e.removeEventListener("click",oi(this,dr,"f")),null===(i=oi(this,ur,"f"))||void 0===i||i.removeEventListener("touchend",oi(this,dr,"f")),null===(n=oi(this,ur,"f"))||void 0===n||n.removeEventListener("touchmove",oi(this,cr,"f")),li(this,ur,t),t&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(ai.OS)?(t.addEventListener("touchend",oi(this,dr,"f")),t.addEventListener("touchmove",oi(this,cr,"f"))):t.addEventListener("click",oi(this,dr,"f")))}get tapFocusEventBoundEl(){return oi(this,ur,"f")}get disposed(){return oi(this,Er,"f")}constructor(t){var e,i;Zn.add(this),qn.set(this,null),Kn.set(this,void 0),this._zoomPreSetting=null,Jn.set(this,()=>{"opened"===this.state&&oi(this,pr,"f").fire("resumed",null,{target:this,async:!1})}),$n.set(this,()=>{oi(this,pr,"f").fire("paused",null,{target:this,async:!1})}),Qn.set(this,void 0),tr.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],er.set(this,void 0),ir.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,nr.set(this,void 0),rr.set(this,!0),sr.set(this,void 0),ar.set(this,void 0),or.set(this,!1),this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,focusArea:null,tempBufferContainer:null,defaultTempBufferContainerLenRatio:1/4},lr.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(t,e)=>{let i,n;const r=window.getComputedStyle(oi(this,qn,"f")).objectFit,s=this.getResolution(),a=oi(this,qn,"f").getBoundingClientRect(),o=a.left,l=a.top,{width:h,height:c}=oi(this,qn,"f").getBoundingClientRect();if(h<=0||c<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const d=h/c,u=s.width/s.height;let f=1;if("contain"===r)u>d?(f=h/s.width,i=(t-o)/f,n=(e-l-(c-h/u)/2)/f):(f=c/s.height,n=(e-l)/f,i=(t-o-(h-c*u)/2)/f);else{if("cover"!==r)throw new Error("Unsupported object-fit.");u>d?(f=c/s.height,n=(e-l)/f,i=(t-o+(c*u-h)/2)/f):(f=h/s.width,i=(t-o)/f,n=(e-l+(h/u-c)/2)/f)}return{x:i,y:n}},hr.set(this,!1),cr.set(this,()=>{li(this,hr,!0)}),dr.set(this,async t=>{var e;if(oi(this,hr,"f"))return void li(this,hr,!1);if(!oi(this,lr,"f"))return;if(!this.isVideoPlaying)return;if(!oi(this,Kn,"f"))return;if(!this._focusSupported)return;if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(e=this.getCameraCapabilities())||void 0===e?void 0:e.focusDistance,!this._focusParameters.fds))return void(this._focusSupported=!1);if(null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),1==this._focusParameters.isDoingFocus)return;let i,n;if(this._focusParameters.taskBackToContinous&&(clearTimeout(this._focusParameters.taskBackToContinous),this._focusParameters.taskBackToContinous=null),t instanceof MouseEvent)i=t.clientX,n=t.clientY;else{if(!(t instanceof TouchEvent))throw new Error("Unknown event type.");if(!t.changedTouches.length)return;i=t.changedTouches[0].clientX,n=t.changedTouches[0].clientY}const r=this.getResolution(),s=2*Math.round(Math.min(r.width,r.height)/this._focusParameters.defaultFocusAreaSizeRatio/2);let a;try{a=this.calculateCoordInVideo(i,n)}catch(t){}if(a.x<0||a.x>r.width||a.y<0||a.y>r.height)return;const o={x:a.x+"px",y:a.y+"px"},l=s+"px",h=l;let c;Yr._onLog&&(c=Date.now());try{await oi(this,Zn,"m",Mr).call(this,o,l,h,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance)}catch(t){if(Yr._onLog)throw Yr._onLog(t),t}Yr._onLog&&Yr._onLog(`Tap focus costs: ${Date.now()-c} ms`),this._focusParameters.taskBackToContinous=setTimeout(()=>{var t;Yr._onLog&&Yr._onLog("Back to continuous focus."),null===(t=oi(this,Kn,"f"))||void 0===t||t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})},this._focusParameters.focusBackToContinousTime),oi(this,pr,"f").fire("tapfocus",null,{target:this,async:!1})}),ur.set(this,null),fr.set(this,1),gr.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!oi(this,qn,"f"))return;const t=oi(this,fr,"f");if(t<1)throw new RangeError("Invalid scale value.");if(1===t)oi(this,qn,"f").style.transform="";else{const e=window.getComputedStyle(oi(this,qn,"f")).objectFit,i=oi(this,qn,"f").videoWidth,n=oi(this,qn,"f").videoHeight,{width:r,height:s}=oi(this,qn,"f").getBoundingClientRect();if(r<=0||s<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const a=r/s,o=i/n;let l=1;"contain"===e?l=aa?s/(i/t):r/(n/t));const h=l*(1-1/t)*(i/2-oi(this,gr,"f").x),c=l*(1-1/t)*(n/2-oi(this,gr,"f").y);oi(this,qn,"f").style.transform=`translate(${h}px, ${c}px) scale(${t})`}},mr.set(this,function(){if(!(this.data instanceof Uint8Array||this.data instanceof Uint8ClampedArray))throw new TypeError("Invalid data.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.pixelFormat===wi.GREY){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{var t,e;if("visible"===document.visibilityState){if(Yr._onLog&&Yr._onLog("document visible. video paused: "+(null===(t=oi(this,qn,"f"))||void 0===t?void 0:t.paused)),function(){const t=navigator.userAgent||navigator.vendor||navigator.opera;return!!/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(t)||("ontouchstart"in window||navigator.maxTouchPoints>0)&&window.innerWidth<1024}())"opened"===this.state&&await oi(this,Zn,"m",Rr).call(this);else if("opening"==this.state||"opened"==this.state){let e=!1;if(!this.isVideoPlaying){Yr._onLog&&Yr._onLog("document visible. Not auto resume. 1st resume start.");try{await this.resume(),e=!0}catch(t){Yr._onLog&&Yr._onLog("document visible. 1st resume video failed, try open instead.")}e||await oi(this,Zn,"m",Ir).call(this)}if(await new Promise(t=>setTimeout(t,300)),!this.isVideoPlaying){Yr._onLog&&Yr._onLog("document visible. 1st open failed. 2rd resume start."),e=!1;try{await this.resume(),e=!0}catch(t){Yr._onLog&&Yr._onLog("document visible. 2rd resume video failed, try open instead.")}e||await oi(this,Zn,"m",Ir).call(this)}}}else"hidden"===document.visibilityState&&(Yr._onLog&&Yr._onLog("document hidden. video paused: "+(null===(e=oi(this,qn,"f"))||void 0===e?void 0:e.paused)),"opening"==this.state||"opened"==this.state&&this.isVideoPlaying&&this.pause())}),Er.set(this,!1),(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia)||setTimeout(()=>{Yr.onWarning&&Yr.onWarning("The browser is too old or the page is loaded from an insecure origin.")},0),this.defaultConstraints={video:{facingMode:{ideal:"environment"}}},this.resetMediaStreamConstraints(),t instanceof HTMLVideoElement&&this.setVideoEl(t),li(this,pr,new tn),this.imageDataGetter=new Gr,document.addEventListener("visibilitychange",oi(this,wr,"f"))}setVideoEl(t){if(!(t&&t instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");t.addEventListener("play",oi(this,Jn,"f")),t.addEventListener("pause",oi(this,$n,"f")),li(this,qn,t)}getVideoEl(){return oi(this,qn,"f")}releaseVideoEl(){var t,e;null===(t=oi(this,qn,"f"))||void 0===t||t.removeEventListener("play",oi(this,Jn,"f")),null===(e=oi(this,qn,"f"))||void 0===e||e.removeEventListener("pause",oi(this,$n,"f")),li(this,qn,null)}isVideoLoaded(){return!!oi(this,qn,"f")&&(this.videoSrc?0!==oi(this,qn,"f").readyState:4===oi(this,qn,"f").readyState)}async open(){if(oi(this,sr,"f")&&!oi(this,rr,"f")){if("pending"===oi(this,ar,"f"))return oi(this,sr,"f");if("fulfilled"===oi(this,ar,"f"))return}oi(this,pr,"f").fire("before:open",null,{target:this}),await oi(this,Zn,"m",Rr).call(this),oi(this,pr,"f").fire("played",null,{target:this,async:!1}),oi(this,pr,"f").fire("opened",null,{target:this,async:!1})}async close(){if("closed"===this.state)return;oi(this,pr,"f").fire("before:close",null,{target:this});const t=oi(this,sr,"f");if(oi(this,Zn,"m",Or).call(this),t&&"pending"===oi(this,ar,"f")){try{await t}catch(t){}if(!1===oi(this,rr,"f")){const t=new Error("'close()' was interrupted.");throw t.name="AbortError",t}}li(this,sr,null),li(this,ar,null),oi(this,pr,"f").fire("closed",null,{target:this,async:!1})}pause(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");oi(this,qn,"f").pause()}async resume(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");await oi(this,qn,"f").play()}async setCamera(t){if("string"!=typeof t)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof oi(this,Qn,"f").video&&(oi(this,Qn,"f").video={}),delete oi(this,Qn,"f").video.facingMode,oi(this,Qn,"f").video.deviceId={exact:t},!("closed"===this.state||this.videoSrc||"opening"===this.state&&oi(this,rr,"f"))){oi(this,pr,"f").fire("before:camera:change",[],{target:this,async:!1}),await oi(this,Zn,"m",xr).call(this);try{this.resetSoftwareScale()}catch(t){}return oi(this,tr,"f")}}async switchToFrontCamera(t){if("object"!=typeof oi(this,Qn,"f").video&&(oi(this,Qn,"f").video={}),(null==t?void 0:t.resolution)&&(oi(this,Qn,"f").video.width={ideal:t.resolution.width},oi(this,Qn,"f").video.height={ideal:t.resolution.height}),delete oi(this,Qn,"f").video.deviceId,oi(this,Qn,"f").video.facingMode={exact:"user"},li(this,er,null),!("closed"===this.state||this.videoSrc||"opening"===this.state&&oi(this,rr,"f"))){oi(this,pr,"f").fire("before:camera:change",[],{target:this,async:!1}),oi(this,Zn,"m",xr).call(this);try{this.resetSoftwareScale()}catch(t){}return oi(this,tr,"f")}}getCamera(){var t;if(oi(this,tr,"f"))return oi(this,tr,"f");{let e=(null===(t=oi(this,Qn,"f").video)||void 0===t?void 0:t.deviceId)||"";if(e){e=e.exact||e.ideal||e;for(let t of this._arrCameras)if(t.deviceId===e)return JSON.parse(JSON.stringify(t))}return{deviceId:"",label:"",_checked:!1}}}async _getCameras(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n=[];if(t)try{let t=await navigator.mediaDevices.getUserMedia({video:!0});n=(await navigator.mediaDevices.enumerateDevices()).filter(t=>"videoinput"===t.kind),t.getTracks().forEach(t=>{t.stop()})}catch(t){console.error(t.message||t)}else n=(await navigator.mediaDevices.enumerateDevices()).filter(t=>"videoinput"===t.kind);const r=[],s=[];if(this._arrCameras)for(let t of this._arrCameras)t._checked&&s.push(t);for(let t=0;t"videoinput"===t.kind);return i&&i.length&&!i[0].deviceId?this._getCameras(!0):this._getCameras(!1)}async getAllCameras(){return this.getCameras()}async setResolution(t,e,i){if("number"!=typeof t||t<=0)throw new TypeError("Invalid 'width'.");if("number"!=typeof e||e<=0)throw new TypeError("Invalid 'height'.");if("object"!=typeof oi(this,Qn,"f").video&&(oi(this,Qn,"f").video={}),i?(oi(this,Qn,"f").video.width={exact:t},oi(this,Qn,"f").video.height={exact:e}):(oi(this,Qn,"f").video.width={ideal:t},oi(this,Qn,"f").video.height={ideal:e}),"closed"===this.state||this.videoSrc||"opening"===this.state&&oi(this,rr,"f"))return null;oi(this,pr,"f").fire("before:resolution:change",[],{target:this,async:!1}),await oi(this,Zn,"m",xr).call(this);try{this.resetSoftwareScale()}catch(t){}const n=this.getResolution();return{width:n.width,height:n.height}}getResolution(){if("opened"===this.state&&this.videoSrc&&oi(this,qn,"f"))return{width:oi(this,qn,"f").videoWidth,height:oi(this,qn,"f").videoHeight};if(oi(this,Kn,"f")){const t=oi(this,Kn,"f").getSettings();return{width:t.width,height:t.height}}if(this.isVideoLoaded())return{width:oi(this,qn,"f").videoWidth,height:oi(this,qn,"f").videoHeight};{const t={width:0,height:0};let e=oi(this,Qn,"f").video.width||0,i=oi(this,Qn,"f").video.height||0;return e&&(t.width=e.exact||e.ideal||e),i&&(t.height=i.exact||i.ideal||i),t}}async getResolutions(t){var e,i,n,r,s,a,o,l,h,c,d;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let u="";const f=(t,e)=>{const i=oi(this,vr,"f").get(t);if(!i||!i.length)return!1;for(let t of i)if(t.width===e.width&&t.height===e.height)return!0;return!1};if(this._mediaStream){u=null===(d=oi(this,tr,"f"))||void 0===d?void 0:d.deviceId;let e=oi(this,vr,"f").get(u);if(e&&!t)return JSON.parse(JSON.stringify(e));e=[],oi(this,vr,"f").set(u,e),li(this,or,!0);try{for(let t of this.detectedResolutions){await oi(this,Kn,"f").applyConstraints({width:{ideal:t.width},height:{ideal:t.height}}),oi(this,Zn,"m",Sr).call(this);const i=oi(this,Kn,"f").getSettings(),n={width:i.width,height:i.height};f(u,n)||e.push({width:n.width,height:n.height})}}catch(t){throw oi(this,Zn,"m",Or).call(this),li(this,or,!1),t}try{await oi(this,Zn,"m",Ir).call(this)}catch(t){if("AbortError"===t.name)return e;throw t}finally{li(this,or,!1)}return e}{const e=async(t,e,i)=>{const n={video:{deviceId:{exact:t},width:{ideal:e},height:{ideal:i}}};let r=null;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(t){return null}if(!r)return null;const s=r.getVideoTracks();let a=null;try{const t=s[0].getSettings();a={width:t.width,height:t.height}}catch(t){const e=document.createElement("video");e.srcObject=r,a={width:e.videoWidth,height:e.videoHeight},e.srcObject=null}return s.forEach(t=>{t.stop()}),a};let i=(null===(s=null===(r=null===(n=oi(this,Qn,"f"))||void 0===n?void 0:n.video)||void 0===r?void 0:r.deviceId)||void 0===s?void 0:s.exact)||(null===(l=null===(o=null===(a=oi(this,Qn,"f"))||void 0===a?void 0:a.video)||void 0===o?void 0:o.deviceId)||void 0===l?void 0:l.ideal)||(null===(c=null===(h=oi(this,Qn,"f"))||void 0===h?void 0:h.video)||void 0===c?void 0:c.deviceId);if(!i)return[];let d=oi(this,vr,"f").get(i);if(d&&!t)return JSON.parse(JSON.stringify(d));d=[],oi(this,vr,"f").set(i,d);for(let t of this.detectedResolutions){const n=await e(i,t.width,t.height);n&&!f(i,n)&&d.push({width:n.width,height:n.height})}return d}}async setMediaStreamConstraints(t,e){if(!(t=>{return null!==t&&"[object Object]"===(e=t,Object.prototype.toString.call(e));var e})(t))throw new TypeError("Invalid 'mediaStreamConstraints'.");li(this,Qn,JSON.parse(JSON.stringify(t))),li(this,er,null),e&&await oi(this,Zn,"m",xr).call(this)}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(oi(this,Qn,"f")))}resetMediaStreamConstraints(){li(this,Qn,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null)}getCameraCapabilities(){if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return oi(this,Kn,"f").getCapabilities?oi(this,Kn,"f").getCapabilities():{}}getCameraSettings(){if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return oi(this,Kn,"f").getSettings()}async turnOnTorch(){if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await oi(this,Kn,"f").applyConstraints({advanced:[{torch:!0}]})}async turnOffTorch(){if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const t=this.getCameraCapabilities();if(!(null==t?void 0:t.torch))throw Error("Not supported.");await oi(this,Kn,"f").applyConstraints({advanced:[{torch:!1}]})}async setColorTemperature(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.colorTemperature;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Wr(t,n.min,n.step,n.max)),await oi(this,Kn,"f").applyConstraints({advanced:[{colorTemperature:t,whiteBalanceMode:"manual"}]}),t}getColorTemperature(){return this.getCameraSettings().colorTemperature||0}async setExposureCompensation(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.exposureCompensation;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Wr(t,n.min,n.step,n.max)),await oi(this,Kn,"f").applyConstraints({advanced:[{exposureCompensation:t}]}),t}getExposureCompensation(){return this.getCameraSettings().exposureCompensation||0}async setFrameRate(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");let n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.frameRate;if(!n)throw Error("Not supported.");e&&(tn.max&&(t=n.max));const r=this.getResolution();return await oi(this,Kn,"f").applyConstraints({width:{ideal:Math.max(r.width,r.height)},frameRate:t}),t}getFrameRate(){return this.getCameraSettings().frameRate}async setFocus(t,e){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const i=this.getCameraCapabilities(),n=null==i?void 0:i.focusMode,r=null==i?void 0:i.focusDistance;if(!n)throw Error("Not supported.");if("string"!=typeof t.mode)throw TypeError("Invalid 'mode'.");const s=t.mode.toLowerCase();if(!n.includes(s))throw Error("Unsupported focus mode.");if("manual"===s){if(!r)throw Error("Manual focus unsupported.");if(t.hasOwnProperty("distance")){let i=t.distance;e&&(ir.max&&(i=r.max),i=Wr(i,r.min,r.step,r.max)),this._focusParameters.focusArea=null,await oi(this,Kn,"f").applyConstraints({advanced:[{focusMode:s,focusDistance:i}]})}else{if(!t.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const e=t.area.centerPoint;let i=t.area.width,n=t.area.height;if(!i||!n){const t=this.getResolution();i||(i=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),n||(n=2*Math.round(Math.min(t.width,t.height)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}this._focusParameters.focusArea={centerPoint:{x:e.x,y:e.y},width:i,height:n},await oi(this,Zn,"m",Mr).call(this,e,i,n)}}}else this._focusParameters.focusArea=null,await oi(this,Kn,"f").applyConstraints({advanced:[{focusMode:s}]})}getFocus(){const t=this.getCameraSettings(),e=t.focusMode;return e?"manual"===e?this._focusParameters.focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters.focusArea))}:{mode:"manual",distance:t.focusDistance}:{mode:e}:null}enableTapToFocus(){li(this,lr,!0)}disableTapToFocus(){li(this,lr,!1)}isTapToFocusEnabled(){return oi(this,lr,"f")}async setZoom(t){if("object"!=typeof t||Array.isArray(t)||null==t)throw new TypeError("Invalid 'settings'.");if("number"!=typeof t.factor)throw new TypeError("Illegal type of 'factor'.");if(t.factor<1)throw new RangeError("Invalid 'factor'.");if("opened"===this.state){t.centerPoint?oi(this,Zn,"m",Lr).call(this,t.centerPoint):this.resetScaleCenter();try{if(oi(this,Zn,"m",Fr).call(this,oi(this,gr,"f"))){const e=await this.setHardwareScale(t.factor,!0);let i=this.getHardwareScale();1==i&&1!=e&&(i=e),t.factor>i?this.setSoftwareScale(t.factor/i):this.setSoftwareScale(1)}else await this.setHardwareScale(1),this.setSoftwareScale(t.factor)}catch(e){const i=e.message||e;if("Not supported."!==i&&"Camera is not open."!==i)throw e;this.setSoftwareScale(t.factor)}}else this._zoomPreSetting=t}getZoom(){if("opened"!==this.state)throw new Error("Video is not playing.");let t=1;try{t=this.getHardwareScale()}catch(t){if("Camera is not open."!==(t.message||t))throw t}return{factor:t*oi(this,fr,"f")}}async resetZoom(){await this.setZoom({factor:1})}async setHardwareScale(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if(!oi(this,Kn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");const n=null===(i=this.getCameraCapabilities())||void 0===i?void 0:i.zoom;if(!n)throw Error("Not supported.");return e&&(tn.max&&(t=n.max),t=Wr(t,n.min,n.step,n.max)),await oi(this,Kn,"f").applyConstraints({advanced:[{zoom:t}]}),t}getHardwareScale(){return this.getCameraSettings().zoom||1}setSoftwareScale(t,e){if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(t<1)throw new RangeError("Invalid 'value'.");if("opened"!==this.state)throw new Error("Video is not playing.");e&&oi(this,Zn,"m",Lr).call(this,e),li(this,fr,t),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return oi(this,fr,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const t=this.getResolution();li(this,gr,{x:t.width/2,y:t.height/2})}resetSoftwareScale(){this.setSoftwareScale(1),this.resetScaleCenter()}getFrameData(t){if(this.disposed)throw Error("The 'Camera' instance has been disposed.");if(!this.isVideoLoaded())return null;if(oi(this,or,"f"))return null;const e=Date.now();Yr._onLog&&Yr._onLog("getFrameData() START: "+e);const i=oi(this,qn,"f").videoWidth,n=oi(this,qn,"f").videoHeight;let r={sx:0,sy:0,sWidth:i,sHeight:n,dWidth:i,dHeight:n};(null==t?void 0:t.position)&&(r=JSON.parse(JSON.stringify(t.position)));let s=wi.RGBA;(null==t?void 0:t.pixelFormat)&&(s=t.pixelFormat);let a=oi(this,fr,"f");(null==t?void 0:t.scale)&&(a=t.scale);let o=oi(this,gr,"f");if(null==t?void 0:t.scaleCenter){if("string"!=typeof t.scaleCenter.x||"string"!=typeof t.scaleCenter.y)throw new Error("Invalid scale center.");let e=0,r=0;if(t.scaleCenter.x.endsWith("px"))e=parseFloat(t.scaleCenter.x);else{if(!t.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");e=parseFloat(t.scaleCenter.x)/100*i}if(t.scaleCenter.y.endsWith("px"))r=parseFloat(t.scaleCenter.y);else{if(!t.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");r=parseFloat(t.scaleCenter.y)/100*n}if(isNaN(e)||isNaN(r))throw new Error("Invalid scale center.");o.x=Math.round(e),o.y=Math.round(r)}let l=null;if((null==t?void 0:t.bufferContainer)&&(l=t.bufferContainer),0==i||0==n)return null;1!==a&&(r.sWidth=Math.round(r.sWidth/a),r.sHeight=Math.round(r.sHeight/a),r.sx=Math.round((1-1/a)*o.x+r.sx/a),r.sy=Math.round((1-1/a)*o.y+r.sy/a));const h=this.imageDataGetter.getImageData(oi(this,qn,"f"),r,{pixelFormat:s,bufferContainer:l,isEnableMirroring:null==t?void 0:t.isEnableMirroring});if(!h)return null;const c=Date.now();return Yr._onLog&&Yr._onLog("getFrameData() END: "+c),{data:h.data,width:h.width,height:h.height,pixelFormat:h.pixelFormat,timeSpent:c-e,timeStamp:c,toCanvas:oi(this,mr,"f")}}on(t,e){if(!oi(this,_r,"f").includes(t.toLowerCase()))throw new Error(`Event '${t}' does not exist.`);oi(this,pr,"f").on(t,e)}off(t,e){oi(this,pr,"f").off(t,e)}async dispose(){this.tapFocusEventBoundEl=null,await this.close(),this.releaseVideoEl(),oi(this,pr,"f").dispose(),this.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",oi(this,wr,"f")),li(this,Er,!0)}}var Hr,zr,Xr,Zr,qr,Kr,Jr,$r,Qr,ts,es,is,ns,rs,ss,as,os,ls,hs,cs,ds,us,fs,gs,ms,ps,_s,vs,ys,ws,Es,Cs,Ss,Ts,bs,Is;qn=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,$n=new WeakMap,Qn=new WeakMap,tr=new WeakMap,er=new WeakMap,ir=new WeakMap,nr=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,hr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,fr=new WeakMap,gr=new WeakMap,mr=new WeakMap,pr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,wr=new WeakMap,Er=new WeakMap,Zn=new WeakSet,Cr=async function(){const t=this.getMediaStreamConstraints();if("boolean"==typeof t.video&&(t.video={}),t.video.deviceId);else if(oi(this,er,"f"))delete t.video.facingMode,t.video.deviceId={exact:oi(this,er,"f")};else if(this.ifSaveLastUsedCamera&&Yr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete t.video.facingMode,t.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const e=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),i=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));e&&i&&(t.video.width=e,t.video.height=i)}else if(this.ifSkipCameraInspection);else{const e=async t=>{let e=null;return"environment"===t&&["Android","HarmonyOS","iPhone","iPad"].includes(ai.OS)?(await this._getCameras(!1),oi(this,Zn,"m",Sr).call(this),e=Yr.findBestCamera(this._arrCameras,"environment",{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})):t||["Android","HarmonyOS","iPhone","iPad"].includes(ai.OS)||(await this._getCameras(!1),oi(this,Zn,"m",Sr).call(this),e=Yr.findBestCamera(this._arrCameras,null,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})),e};let i=t.video.facingMode;i instanceof Array&&i.length&&(i=i[0]),"object"==typeof i&&(i=i.exact||i.ideal);const n=await e(i);n&&(delete t.video.facingMode,t.video.deviceId={exact:n})}return t},Sr=function(){if(oi(this,rr,"f")){const t=new Error("The operation was interrupted.");throw t.name="AbortError",t}},Tr=async function(t){var e,i;if(!(null===(i=null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.mediaDevices)||void 0===i?void 0:i.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let n;try{Yr._onLog&&Yr._onLog("======try getUserMedia========");let e=[0,500,1e3,2e3],i=null;const r=async t=>{for(let r of e){r&&(await new Promise(t=>setTimeout(t,r)),oi(this,Zn,"m",Sr).call(this));try{Yr._onLog&&Yr._onLog("ask "+JSON.stringify(t)),n=await navigator.mediaDevices.getUserMedia(t),oi(this,Zn,"m",Sr).call(this);break}catch(t){if("NotFoundError"===t.name||"NotAllowedError"===t.name||"AbortError"===t.name||"OverconstrainedError"===t.name)throw t;i=t,Yr._onLog&&Yr._onLog(t.message||t)}}};if(await r(t),!n&&"object"==typeof t.video&&!n){const e=(await navigator.mediaDevices.enumerateDevices()).filter(t=>"videoinput"===t.kind);for(let i of e)try{n=await navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:i.deviceId}}});break}catch(t){continue}}if(!n)throw i;return n}catch(t){throw null==n||n.getTracks().forEach(t=>{t.stop()}),"NotFoundError"===t.name&&(DOMException?t=new DOMException("No camera available, please use a device with an accessible camera.",t.name):(t=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),t}},br=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach(t=>{t.stop()}),this._mediaStream=null),li(this,Kn,null)},Ir=async function(){li(this,rr,!1);const t=li(this,nr,Symbol());if(oi(this,sr,"f")&&"pending"===oi(this,ar,"f")){try{await oi(this,sr,"f")}catch(t){}oi(this,Zn,"m",Sr).call(this)}if(t!==oi(this,nr,"f"))return;const e=li(this,sr,(async()=>{li(this,ar,"pending");try{if(this.videoSrc){if(!oi(this,qn,"f"))throw new Error("'videoEl' should be set.");await Yr.playVideo(oi(this,qn,"f"),this.videoSrc,this.cameraOpenTimeout),oi(this,Zn,"m",Sr).call(this)}else{let t=await oi(this,Zn,"m",Cr).call(this);oi(this,Zn,"m",br).call(this);let e=await oi(this,Zn,"m",Tr).call(this,t);await this._getCameras(!1),oi(this,Zn,"m",Sr).call(this);const i=()=>{const t=e.getVideoTracks();let i,n;if(t.length&&(i=t[0]),i){const t=i.getSettings();if(t)for(let e of this._arrCameras)if(t.deviceId===e.deviceId){e._checked=!0,e.label=i.label,n=e;break}}return n},n=oi(this,Qn,"f");if("object"==typeof n.video){let r=n.video.facingMode;if(r instanceof Array&&r.length&&(r=r[0]),"object"==typeof r&&(r=r.exact||r.ideal),!(oi(this,er,"f")||this.ifSaveLastUsedCamera&&Yr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||this.ifSkipCameraInspection||n.video.deviceId)){const n=i(),s=Yr.findBestCamera(this._arrCameras,r,{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault});s&&s!=(null==n?void 0:n.deviceId)&&(e.getTracks().forEach(t=>{t.stop()}),t.video.deviceId={exact:s},e=await oi(this,Zn,"m",Tr).call(this,t),oi(this,Zn,"m",Sr).call(this))}}const r=i();(null==r?void 0:r.deviceId)&&(li(this,er,r&&r.deviceId),this.ifSaveLastUsedCamera&&Yr.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",oi(this,er,"f")),"object"==typeof t.video&&t.video.width&&t.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(t.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(t.video.height))))),oi(this,qn,"f")&&(await Yr.playVideo(oi(this,qn,"f"),e,this.cameraOpenTimeout),oi(this,Zn,"m",Sr).call(this)),this._mediaStream=e;const s=e.getVideoTracks();(null==s?void 0:s.length)&&li(this,Kn,s[0]),li(this,tr,r)}}catch(t){throw oi(this,Zn,"m",Or).call(this),li(this,ar,null),t}li(this,ar,"fulfilled")})());return e},xr=async function(){var t;if("closed"===this.state||this.videoSrc)return;const e=null===(t=oi(this,tr,"f"))||void 0===t?void 0:t.deviceId,i=this.getResolution();await oi(this,Zn,"m",Ir).call(this);const n=this.getResolution();e&&e!==oi(this,tr,"f").deviceId&&oi(this,pr,"f").fire("camera:changed",[oi(this,tr,"f").deviceId,e],{target:this,async:!1}),i.width==n.width&&i.height==n.height||oi(this,pr,"f").fire("resolution:changed",[{width:n.width,height:n.height},{width:i.width,height:i.height}],{target:this,async:!1}),oi(this,pr,"f").fire("played",null,{target:this,async:!1})},Rr=async function(){let t=0;for(;Yr._tryToReopenTime>=t++;){try{await oi(this,Zn,"m",Ir).call(this)}catch(t){await new Promise(t=>setTimeout(t,300));continue}break}},Or=function(){oi(this,Zn,"m",br).call(this),li(this,tr,null),oi(this,qn,"f")&&(oi(this,qn,"f").srcObject=null,this.videoSrc&&(oi(this,qn,"f").pause(),oi(this,qn,"f").currentTime=0)),li(this,rr,!0);try{this.resetSoftwareScale()}catch(t){}},Dr=async function t(e,i){const n=t=>{if(!oi(this,Kn,"f")||!this.isVideoPlaying||t.focusTaskId!=this._focusParameters.curFocusTaskId){oi(this,Kn,"f")&&this.isVideoPlaying||(this._focusParameters.isDoingFocus=0);const e=new Error(`Focus task ${t.focusTaskId} canceled.`);throw e.name="DeprecatedTaskError",e}1===this._focusParameters.isDoingFocus&&Date.now()-t.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let r;i=Wr(i,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await oi(this,Kn,"f").applyConstraints({advanced:[{focusMode:"manual",focusDistance:i}]}),n(e),r=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/i),Math.abs(1/this._focusParameters.fds.max-1/i))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/i)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=i,await new Promise(t=>{setTimeout(t,r)}),n(e);let s=e.focusL-e.focusW/2,a=e.focusT-e.focusH/2,o=e.focusW,l=e.focusH;const h=this.getResolution();s=Math.round(s),a=Math.round(a),o=Math.round(o),l=Math.round(l),o>h.width&&(o=h.width),l>h.height&&(l=h.height),s<0?s=0:s+o>h.width&&(s=h.width-o),a<0?a=0:a+l>h.height&&(a=h.height-l);const c=4*h.width*h.height*this._focusParameters.defaultTempBufferContainerLenRatio,d=4*o*l;let u=this._focusParameters.tempBufferContainer;if(u){const t=u.length;c>t&&c>=d?u=new Uint8Array(c):d>t&&d>=c&&(u=new Uint8Array(d))}else u=this._focusParameters.tempBufferContainer=new Uint8Array(Math.max(c,d));if(!this.imageDataGetter.getImageData(oi(this,qn,"f"),{sx:s,sy:a,sWidth:o,sHeight:l,dWidth:o,dHeight:l},{pixelFormat:wi.RGBA,bufferContainer:u}))return oi(this,Zn,"m",t).call(this,e,i);const f=u;let g=0;for(let t=0,e=d-8;to&&od)return await oi(this,Zn,"m",t).call(this,e,a,o,r,s,c,d)}else{let l=await oi(this,Zn,"m",Dr).call(this,e,c);if(o>l)return await oi(this,Zn,"m",t).call(this,e,a,o,r,s,c,l);if(o==l)return await oi(this,Zn,"m",t).call(this,e,a,o,c,l);let d=await oi(this,Zn,"m",Dr).call(this,e,h);if(d>o&&oa.width||l<0||l>a.height)throw new Error("Invalid 'centerPoint'.");let h=0;if(e.endsWith("px"))h=parseFloat(e);else{if(!e.endsWith("%"))throw new Error("Invalid 'width'.");h=parseFloat(e)/100*a.width}if(isNaN(h)||h<0)throw new Error("Invalid 'width'.");let c=0;if(i.endsWith("px"))c=parseFloat(i);else{if(!i.endsWith("%"))throw new Error("Invalid 'height'.");c=parseFloat(i)/100*a.height}if(isNaN(c)||c<0)throw new Error("Invalid 'height'.");if(1!==oi(this,fr,"f")){const t=oi(this,fr,"f"),e=oi(this,gr,"f");h/=t,c/=t,o=(1-1/t)*e.x+o/t,l=(1-1/t)*e.y+l/t}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(s=this.getCameraCapabilities())||void 0===s?void 0:s.focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const d={focusL:o,focusT:l,focusW:h,focusH:c,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},u=async(t,e,i)=>{try{(null==e||ethis._focusParameters.fds.max)&&(i=this._focusParameters.fds.max),this._focusParameters.oldDistance=null;let n=Wr(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=Wr(Math.sqrt((e||this._focusParameters.fds.step)*n),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=Wr(Math.sqrt(n*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),a=await oi(this,Zn,"m",Dr).call(this,t,s),o=await oi(this,Zn,"m",Dr).call(this,t,r),l=await oi(this,Zn,"m",Dr).call(this,t,n);if(o>l&&la&&o>a){let e=await oi(this,Zn,"m",Dr).call(this,t,i);const r=await oi(this,Zn,"m",Ar).call(this,t,n,l,i,e,s,a);return this._focusParameters.isDoingFocus=0,r}if(o==l&&l l){const e=await oi(this,Zn,"m",Ar).call(this,t,n,l,s,a);return this._focusParameters.isDoingFocus=0,e}return u(t,e,i)}catch(t){if("DeprecatedTaskError"!==t.name)throw t}};return u(d,n,r)},Lr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid 'center'.");const e=this.getResolution();let i=0,n=0;if(t.x.endsWith("px"))i=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid scale center.");i=parseFloat(t.x)/100*e.width}if(t.y.endsWith("px"))n=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid scale center.");n=parseFloat(t.y)/100*e.height}if(isNaN(i)||isNaN(n))throw new Error("Invalid scale center.");li(this,gr,{x:i,y:n})},Fr=function(t){if("opened"!==this.state)throw new Error("Video is not playing.");const e=this.getResolution();return t&&t.x==e.width/2&&t.y==e.height/2},Yr.browserInfo=ai,Yr._tryToReopenTime=4,Yr.onWarning=null===(Xn=null===window||void 0===window?void 0:window.console)||void 0===Xn?void 0:Xn.warn;class xs{constructor(t){Hr.add(this),zr.set(this,void 0),Xr.set(this,0),Zr.set(this,void 0),qr.set(this,0),Kr.set(this,!1),li(this,zr,t)}startCharging(){oi(this,Kr,"f")||(xs._onLog&&xs._onLog("start charging."),oi(this,Hr,"m",$r).call(this),li(this,Kr,!0))}stopCharging(){oi(this,Zr,"f")&&clearTimeout(oi(this,Zr,"f")),oi(this,Kr,"f")&&(xs._onLog&&xs._onLog("stop charging."),li(this,Xr,Date.now()-oi(this,qr,"f")),li(this,Kr,!1))}}zr=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,qr=new WeakMap,Kr=new WeakMap,Hr=new WeakSet,Jr=function(){At.cfd(1),xs._onLog&&xs._onLog("charge 1.")},$r=function t(){0==oi(this,Xr,"f")&&oi(this,Hr,"m",Jr).call(this),li(this,qr,Date.now()),oi(this,Zr,"f")&&clearTimeout(oi(this,Zr,"f")),li(this,Zr,setTimeout(()=>{li(this,Xr,0),oi(this,Hr,"m",t).call(this)},oi(this,zr,"f")-oi(this,Xr,"f")))};class Rs{static beep(){if(!this.allowBeep)return;if(!this.beepSoundSource)return;let t,e=Date.now();if(!(e-oi(this,Qr,"f",is)<100)){if(li(this,Qr,e,0,is),oi(this,Qr,"f",ts).size&&(t=oi(this,Qr,"f",ts).values().next().value,this.beepSoundSource==t.src?(oi(this,Qr,"f",ts).delete(t),t.play()):t=null),!t)if(oi(this,Qr,"f",es).size<16){t=new Audio(this.beepSoundSource);let e=null,i=()=>{t.removeEventListener("loadedmetadata",i),t.play(),e=setTimeout(()=>{oi(this,Qr,"f",es).delete(t)},2e3*t.duration)};t.addEventListener("loadedmetadata",i),t.addEventListener("ended",()=>{null!=e&&(clearTimeout(e),e=null),t.pause(),t.currentTime=0,oi(this,Qr,"f",es).delete(t),oi(this,Qr,"f",ts).add(t)})}else oi(this,Qr,"f",ns)||(li(this,Qr,!0,0,ns),console.warn("The requested audio tracks exceed 16 and will not be played."));t&&oi(this,Qr,"f",es).add(t)}}static vibrate(){if(this.allowVibrate){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(Rs.vibrateDuration)}}}Qr=Rs,ts={value:new Set},es={value:new Set},is={value:0},ns={value:!1},Rs.allowBeep=!0,Rs.beepSoundSource="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",Rs.allowVibrate=!0,Rs.vibrateDuration=300;const Os=new Map([[wi.GREY,l.IPF_GRAYSCALED],[wi.RGBA,l.IPF_ABGR_8888]]),Ds="function"==typeof BigInt?t=>BigInt(t):t=>t,As=(Ds("0x00"),Ds("0xFFFFFFFFFFFFFFFF"),Ds("0xFE3BFFFF"),Ds("0x003007FF")),Ms=(Ds("0x0003F800"),Ds("0x1"),Ds("0x2"),Ds("0x4"),Ds("0x8"),Ds("0x10"),Ds("0x20"),Ds("0x40"),Ds("0x80"),Ds("0x100"),Ds("0x200"),Ds("0x400"),Ds("0x800"),Ds("0x1000"),Ds("0x2000"),Ds("0x4000"),Ds("0x8000"),Ds("0x10000"),Ds("0x20000"),Ds("0x00040000"),Ds("0x01000000"),Ds("0x02000000"),Ds("0x04000000")),Ls=Ds("0x08000000");Ds("0x10000000"),Ds("0x20000000"),Ds("0x40000000"),Ds("0x00080000"),Ds("0x80000000"),Ds("0x100000"),Ds("0x200000"),Ds("0x400000"),Ds("0x800000"),Ds("0x1000000000"),Ds("0x3F0000000000000"),Ds("0x100000000"),Ds("0x10000000000000"),Ds("0x20000000000000"),Ds("0x40000000000000"),Ds("0x80000000000000"),Ds("0x100000000000000"),Ds("0x200000000000000"),Ds("0x200000000"),Ds("0x400000000"),Ds("0x800000000"),Ds("0xC00000000"),Ds("0x2000000000"),Ds("0x4000000000");class Fs extends Z{static set _onLog(t){li(Fs,ss,t,0,as),Yr._onLog=t,xs._onLog=t}static get _onLog(){return oi(Fs,ss,"f",as)}static async detectEnvironment(){return await(async()=>({wasm:hi,worker:ci,getUserMedia:di,camera:await ui(),browser:ai.browser,version:ai.version,OS:ai.OS}))()}static async testCameraAccess(){const t=await Yr.testCameraAccess();return t.ok?{ok:!0,message:"Successfully accessed the camera."}:"InsecureContext"===t.errorName?{ok:!1,message:"Insecure context."}:"OverconstrainedError"===t.errorName||"NotFoundError"===t.errorName?{ok:!1,message:"No camera detected."}:"NotAllowedError"===t.errorName?{ok:!1,message:"No permission to access camera."}:"AbortError"===t.errorName?{ok:!1,message:"Some problem occurred which prevented the device from being used."}:"NotReadableError"===t.errorName?{ok:!1,message:"A hardware error occurred."}:"SecurityError"===t.errorName?{ok:!1,message:"User media support is disabled."}:{ok:!1,message:t.errorMessage}}static async createInstance(t){var e,i;if(t&&!(t instanceof Ur))throw new TypeError("Invalid view.");if(!Fs._isRTU&&(null===(e=xt.license)||void 0===e?void 0:e.LicenseManager)){if(!(null===(i=xt.license)||void 0===i?void 0:i.LicenseManager.bCallInitLicense))throw new Error("License is not set.");await At.loadWasm(),await xt.license.dynamsoft()}const n=new Fs(t);return Fs.onWarning&&(location&&"file:"===location.protocol?setTimeout(()=>{Fs.onWarning&&Fs.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})},0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout(()=>{Fs.onWarning&&Fs.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})},0)),n}get isEnableMirroring(){return this._isEnableMirroring}get video(){return this.cameraManager.getVideoEl()}set videoSrc(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraView&&(this.cameraView._hideDefaultSelection=!0),this.cameraManager.videoSrc=t}get videoSrc(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.videoSrc}set ifSaveLastUsedCamera(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSaveLastUsedCamera=t}get ifSaveLastUsedCamera(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSaveLastUsedCamera}set ifSkipCameraInspection(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.ifSkipCameraInspection=t}get ifSkipCameraInspection(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.ifSkipCameraInspection}set cameraOpenTimeout(t){if(!this.cameraManager)throw new Error("Camera manager is null.");this.cameraManager.cameraOpenTimeout=t}get cameraOpenTimeout(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.cameraOpenTimeout}set singleFrameMode(t){if(!["disabled","image","camera"].includes(t))throw new Error("Invalid value.");if(this.isOpen())throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");li(this,cs,t)}get singleFrameMode(){return oi(this,cs,"f")}get _isFetchingStarted(){return oi(this,ps,"f")}get disposed(){return oi(this,Es,"f")}constructor(t){if(super(),rs.add(this),os.set(this,"closed"),ls.set(this,void 0),hs.set(this,void 0),this._isEnableMirroring=!1,this.isTorchOn=void 0,cs.set(this,void 0),this._onCameraSelChange=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&await this.selectCamera(this.cameraView._selCam.value)},this._onResolutionSelChange=async()=>{if(!this.isOpen())return;if(!this.cameraView||this.cameraView.disposed)return;let t,e;if(this.cameraView._selRsl&&-1!=this.cameraView._selRsl.selectedIndex){let i=this.cameraView._selRsl.options[this.cameraView._selRsl.selectedIndex];t=parseInt(i.getAttribute("data-width")),e=parseInt(i.getAttribute("data-height"))}await this.setResolution({width:t,height:e})},this._onCloseBtnClick=async()=>{this.isOpen()&&this.cameraView&&!this.cameraView.disposed&&this.close()},ds.set(this,(t,e,i,n)=>{const r=Date.now(),s={sx:n.x,sy:n.y,sWidth:n.width,sHeight:n.height,dWidth:n.width,dHeight:n.height},a=Math.max(s.dWidth,s.dHeight);if(this.canvasSizeLimit&&a>this.canvasSizeLimit){const t=this.canvasSizeLimit/a;s.dWidth>s.dHeight?(s.dWidth=this.canvasSizeLimit,s.dHeight=Math.round(s.dHeight*t)):(s.dWidth=Math.round(s.dWidth*t),s.dHeight=this.canvasSizeLimit)}const o=this.cameraManager.imageDataGetter.getImageData(t,s,{pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?wi.GREY:wi.RGBA});let h=null;if(o){const t=Date.now();let a;a=o.pixelFormat===wi.GREY?o.width:4*o.width;let l=!0;0===s.sx&&0===s.sy&&s.sWidth===e&&s.sHeight===i&&(l=!1),h={bytes:o.data,width:o.width,height:o.height,stride:a,format:Os.get(o.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:rt.ITT_FILE_IMAGE,isCropped:l,cropRegion:{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height,isMeasuredInPercentage:!1},originalWidth:e,originalHeight:i,currentWidth:o.width,currentHeight:o.height,timeSpent:t-r,timeStamp:t},toCanvas:oi(this,us,"f"),isDCEFrame:!0}}return h}),this._onSingleFrameAcquired=t=>{let e;e=this.cameraView?this.cameraView.getConvertedRegion():Ji.convert(oi(this,gs,"f"),t.width,t.height,this.cameraView),e||(e={x:0,y:0,width:t.width,height:t.height});const i=oi(this,ds,"f").call(this,t,t.width,t.height,e);oi(this,ls,"f").fire("singleFrameAcquired",[i],{async:!1,copy:!1})},us.set(this,function(){if(!(this.bytes instanceof Uint8Array||this.bytes instanceof Uint8ClampedArray))throw new TypeError("Invalid bytes.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,this.format===l.IPF_GRAYSCALED){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{if(!this.video)return;const t=this.cameraManager.getSoftwareScale();if(t<1)throw new RangeError("Invalid scale value.");this.cameraView&&!this.cameraView.disposed?(this.video.style.transform=1===t?"":`scale(${t})`,this.cameraView._updateVideoContainer()):this.video.style.transform=1===t?"":`scale(${t})`},["iPhone","iPad","Android","HarmonyOS"].includes(ai.OS)?this.cameraManager.setResolution(1280,720):this.cameraManager.setResolution(1920,1080),navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?this.singleFrameMode="disabled":this.singleFrameMode="image",t&&(this.setCameraView(t),t.cameraEnhancer=this),this._on("before:camera:change",()=>{oi(this,ws,"f").stopCharging();const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())}),this._on("camera:changed",()=>{this.clearBuffer()}),this._on("before:resolution:change",()=>{const t=this.cameraView;t&&!t.disposed&&(t._startLoading(),t.clearAllInnerDrawingItems())}),this._on("resolution:changed",()=>{this.clearBuffer(),t.eventHandler.fire("content:updated",null,{async:!1})}),this._on("paused",()=>{oi(this,ws,"f").stopCharging();const t=this.cameraView;t&&t.disposed}),this._on("resumed",()=>{const t=this.cameraView;t&&t.disposed}),this._on("tapfocus",()=>{oi(this,vs,"f").tapToFocus&&oi(this,ws,"f").startCharging()}),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=async(t,e)=>{var i,n,r,s;const a=t.intermediateResultUnits;if(oi(this,rs,"m",Cs).call(this)||!this.isOpen()||this.isPaused()||a[0]&&!a[0].originalImageTag)return;Fs._onLog&&(Fs._onLog("intermediateResultUnits:"),Fs._onLog(a));let o=!1,l=!1;for(let t of a){if(t.unitType===lt.IRUT_DECODED_BARCODES&&t.decodedBarcodes.length){o=!0;break}t.unitType===lt.IRUT_LOCALIZED_BARCODES&&t.localizedBarcodes.length&&(l=!0)}if(Fs._onLog&&(Fs._onLog("hasLocalizedBarcodes:"),Fs._onLog(l)),oi(this,vs,"f").autoZoom||oi(this,vs,"f").enhancedFocus)if(o)oi(this,ys,"f").autoZoomInFrameArray.length=0,oi(this,ys,"f").autoZoomOutFrameCount=0,oi(this,ys,"f").frameArrayInIdealZoom.length=0,oi(this,ys,"f").autoFocusFrameArray.length=0;else{const e=async t=>{await this.setZoom(t),oi(this,vs,"f").autoZoom&&oi(this,ws,"f").startCharging()},o=async t=>{await this.setFocus(t),oi(this,vs,"f").enhancedFocus&&oi(this,ws,"f").startCharging()};if(l){const l=a[0].originalImageTag,h=(null===(i=l.cropRegion)||void 0===i?void 0:i.left)||0,c=(null===(n=l.cropRegion)||void 0===n?void 0:n.top)||0,d=(null===(r=l.cropRegion)||void 0===r?void 0:r.right)?l.cropRegion.right-h:l.originalWidth,u=(null===(s=l.cropRegion)||void 0===s?void 0:s.bottom)?l.cropRegion.bottom-c:l.originalHeight,f=l.currentWidth,g=l.currentHeight;let m;{let t,e,i,n,r;{const t=this.video.videoWidth*(1-oi(this,ys,"f").autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+oi(this,ys,"f").autoZoomDetectionArea)/2,i=e,n=t,s=this.video.videoHeight*(1-oi(this,ys,"f").autoZoomDetectionArea)/2,a=s,o=this.video.videoHeight*(1+oi(this,ys,"f").autoZoomDetectionArea)/2;r=[{x:t,y:s},{x:e,y:a},{x:i,y:o},{x:n,y:o}]}Fs._onLog&&(Fs._onLog("detectionArea:"),Fs._onLog(r));const s=[];{const t=(t,e)=>{const i=(t,e)=>{if(!t&&!e)throw new Error("Invalid arguments.");return function(t,e,i){let n=!1;const r=t.length;if(r<=2)return!1;for(let s=0;s0!=nn(o.y-i)>0&&nn(e-(i-a.y)*(a.x-o.x)/(a.y-o.y)-a.x)<0&&(n=!n)}return n}(e,t.x,t.y)},n=(t,e)=>!!(rn([t[0],t[1]],[t[2],t[3]],[e[0].x,e[0].y],[e[1].x,e[1].y])||rn([t[0],t[1]],[t[2],t[3]],[e[1].x,e[1].y],[e[2].x,e[2].y])||rn([t[0],t[1]],[t[2],t[3]],[e[2].x,e[2].y],[e[3].x,e[3].y])||rn([t[0],t[1]],[t[2],t[3]],[e[3].x,e[3].y],[e[0].x,e[0].y]));return!!(i({x:t[0].x,y:t[0].y},e)||i({x:t[1].x,y:t[1].y},e)||i({x:t[2].x,y:t[2].y},e)||i({x:t[3].x,y:t[3].y},e))||!!(i({x:e[0].x,y:e[0].y},t)||i({x:e[1].x,y:e[1].y},t)||i({x:e[2].x,y:e[2].y},t)||i({x:e[3].x,y:e[3].y},t))||!!(n([e[0].x,e[0].y,e[1].x,e[1].y],t)||n([e[1].x,e[1].y,e[2].x,e[2].y],t)||n([e[2].x,e[2].y,e[3].x,e[3].y],t)||n([e[3].x,e[3].y,e[0].x,e[0].y],t))};for(let e of a)if(e.unitType===lt.IRUT_LOCALIZED_BARCODES)for(let i of e.localizedBarcodes){if(!i)continue;const e=i.location.points;e.forEach(t=>{Ur._transformCoordinates(t,h,c,d,u,f,g)}),t(r,e)&&s.push(i)}if(Fs._debug&&this.cameraView){const t=this.__layer||(this.__layer=this.cameraView._createDrawingLayer(99));t.clearDrawingItems();const e=this.__styleId2||(this.__styleId2=Pr.createDrawingStyle({strokeStyle:"red"}));for(let i of a)if(i.unitType===lt.IRUT_LOCALIZED_BARCODES)for(let n of i.localizedBarcodes){if(!n)continue;const i=n.location.points,r=new Ui({points:i},e);t.addDrawingItems([r])}}}if(Fs._onLog&&(Fs._onLog("intersectedResults:"),Fs._onLog(s)),!s.length)return;let o;if(s.length){let t=s.filter(t=>t.possibleFormats==Ms||t.possibleFormats==Ls);if(t.length||(t=s.filter(t=>t.possibleFormats==As),t.length||(t=s)),t.length){const e=t=>{const e=t.location.points,i=(e[0].x+e[1].x+e[2].x+e[3].x)/4,n=(e[0].y+e[1].y+e[2].y+e[3].y)/4;return(i-f/2)*(i-f/2)+(n-g/2)*(n-g/2)};o=t[0];let i=e(o);if(1!=t.length)for(let n=1;n1.1*o.confidence||t[n].confidence>.9*o.confidence&&ri&&s>i&&a>i&&l>i&&m.result.moduleSize{}),oi(this,ys,"f").autoZoomInFrameArray.filter(t=>!0===t).length>=oi(this,ys,"f").autoZoomInFrameLimit[1]){oi(this,ys,"f").autoZoomInFrameArray.length=0;const i=[(.5-n)/(.5-r),(.5-n)/(.5-s),(.5-n)/(.5-a),(.5-n)/(.5-l)].filter(t=>t>0),o=Math.min(...i,oi(this,ys,"f").autoZoomInIdealModuleSize/m.result.moduleSize),h=this.getZoomSettings().factor;let c=Math.max(Math.pow(h*o,1/oi(this,ys,"f").autoZoomInMaxTimes),oi(this,ys,"f").autoZoomInMinStep);c=Math.min(c,o);let d=h*c;d=Math.max(oi(this,ys,"f").minValue,d),d=Math.min(oi(this,ys,"f").maxValue,d);try{await e({factor:d})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else if(oi(this,ys,"f").autoZoomInFrameArray.length=0,oi(this,ys,"f").frameArrayInIdealZoom.push(!0),oi(this,ys,"f").frameArrayInIdealZoom.splice(0,oi(this,ys,"f").frameArrayInIdealZoom.length-oi(this,ys,"f").frameLimitInIdealZoom[0]),oi(this,ys,"f").frameArrayInIdealZoom.filter(t=>!0===t).length>=oi(this,ys,"f").frameLimitInIdealZoom[1]&&(oi(this,ys,"f").frameArrayInIdealZoom.length=0,oi(this,vs,"f").enhancedFocus)){const e=m.points;try{await o({mode:"manual",area:{centerPoint:{x:(e[0].x+e[2].x)/2+"px",y:(e[0].y+e[2].y)/2+"px"},width:e[2].x-e[0].x+"px",height:e[2].y-e[0].y+"px"}})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}if(!oi(this,vs,"f").autoZoom&&oi(this,vs,"f").enhancedFocus&&(oi(this,ys,"f").autoFocusFrameArray.push(!0),oi(this,ys,"f").autoFocusFrameArray.splice(0,oi(this,ys,"f").autoFocusFrameArray.length-oi(this,ys,"f").autoFocusFrameLimit[0]),oi(this,ys,"f").autoFocusFrameArray.filter(t=>!0===t).length>=oi(this,ys,"f").autoFocusFrameLimit[1])){oi(this,ys,"f").autoFocusFrameArray.length=0;try{const t=m.points;await o({mode:"manual",area:{centerPoint:{x:(t[0].x+t[2].x)/2+"px",y:(t[0].y+t[2].y)/2+"px"},width:t[2].x-t[0].x+"px",height:t[2].y-t[0].y+"px"}})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else{if(oi(this,vs,"f").autoZoom){if(oi(this,ys,"f").autoZoomInFrameArray.push(!1),oi(this,ys,"f").autoZoomInFrameArray.splice(0,oi(this,ys,"f").autoZoomInFrameArray.length-oi(this,ys,"f").autoZoomInFrameLimit[0]),oi(this,ys,"f").autoZoomOutFrameCount++,oi(this,ys,"f").frameArrayInIdealZoom.push(!1),oi(this,ys,"f").frameArrayInIdealZoom.splice(0,oi(this,ys,"f").frameArrayInIdealZoom.length-oi(this,ys,"f").frameLimitInIdealZoom[0]),oi(this,ys,"f").autoZoomOutFrameCount>=oi(this,ys,"f").autoZoomOutFrameLimit){oi(this,ys,"f").autoZoomOutFrameCount=0;const i=this.getZoomSettings().factor;let n=i-Math.max((i-1)*oi(this,ys,"f").autoZoomOutStepRate,oi(this,ys,"f").autoZoomOutMinStep);n=Math.max(oi(this,ys,"f").minValue,n),n=Math.min(oi(this,ys,"f").maxValue,n);try{await e({factor:n})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}oi(this,vs,"f").enhancedFocus&&o({mode:"continuous"}).catch(()=>{})}!oi(this,vs,"f").autoZoom&&oi(this,vs,"f").enhancedFocus&&(oi(this,ys,"f").autoFocusFrameArray.length=0,o({mode:"continuous"}).catch(()=>{}))}}},li(this,ws,new xs(1e4)),this.getColourChannelUsageType()===o.CCUT_AUTO&&this.setColourChannelUsageType(o.CCUT_Y_CHANNEL_ONLY),this.setPixelFormat(l.IPF_GRAYSCALED)}setCameraView(t){if(!(t instanceof Ur))throw new TypeError("Invalid view.");if(t.disposed)throw new Error("The camera view has been disposed.");if(this.isOpen())throw new Error("It is not allowed to change camera view when the camera is open.");this.releaseCameraView(),t._singleFrameMode=this.singleFrameMode,t._onSingleFrameAcquired=this._onSingleFrameAcquired,this.videoSrc&&(this.cameraView._hideDefaultSelection=!0),oi(this,rs,"m",Cs).call(this)||this.cameraManager.setVideoEl(t.getVideoElement()),this.cameraView=t,this.addListenerToView()}getCameraView(){return this.cameraView}releaseCameraView(){this.cameraView&&(this.removeListenerFromView(),this.cameraView.disposed||(this.cameraView._singleFrameMode="disabled",this.cameraView._onSingleFrameAcquired=null,this.cameraView._hideDefaultSelection=!1),this.cameraManager.releaseVideoEl(),this.cameraView=null)}addListenerToView(){if(!this.cameraView)return;if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");const t=this.cameraView;oi(this,rs,"m",Cs).call(this)||this.videoSrc||(t._innerComponent&&(this.cameraManager.tapFocusEventBoundEl=t._innerComponent),t._selCam&&t._selCam.addEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.addEventListener("change",this._onResolutionSelChange)),t._btnClose&&t._btnClose.addEventListener("click",this._onCloseBtnClick)}removeListenerFromView(){if(!this.cameraView||this.cameraView.disposed)return;const t=this.cameraView;this.cameraManager.tapFocusEventBoundEl=null,t._selCam&&t._selCam.removeEventListener("change",this._onCameraSelChange),t._selRsl&&t._selRsl.removeEventListener("change",this._onResolutionSelChange),t._btnClose&&t._btnClose.removeEventListener("click",this._onCloseBtnClick)}getCameraState(){return oi(this,rs,"m",Cs).call(this)?oi(this,os,"f"):new Map([["closed","closed"],["opening","opening"],["opened","open"]]).get(this.cameraManager.state)}isOpen(){return"open"===this.getCameraState()}getVideoEl(){return this.video}async open(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");e&&(e._singleFrameMode=this.singleFrameMode,oi(this,rs,"m",Cs).call(this)?e._clickIptSingleFrameMode():(this.cameraManager.setVideoEl(e.getVideoElement()),e._startLoading()));let i={width:0,height:0,deviceId:""};if(oi(this,rs,"m",Cs).call(this));else{try{await this.cameraManager.open(),li(this,hs,this.cameraView.getVisibleRegionOfVideo({inPixels:!0}))}catch(t){throw e&&e._stopLoading(),"NotFoundError"===t.name?new Error("No Camera Found: No camera devices were detected. Please ensure a camera is connected and recognized by your system."):"NotAllowedError"===t.name?new Error("No Camera Access: Camera access is blocked. Please check your browser settings or grant permission to use the camera."):t}const n=!this.cameraManager.videoSrc&&!!(null===(t=this.cameraManager.getCameraCapabilities())||void 0===t?void 0:t.torch);let r,s=e.getUIElement();if(s=s.shadowRoot||s,r=s.querySelector(".dce-macro-use-mobile-native-like-ui")){let t=s.elTorchAuto=s.querySelector(".dce-mn-torch-auto"),e=s.elTorchOn=s.querySelector(".dce-mn-torch-on"),i=s.elTorchOff=s.querySelector(".dce-mn-torch-off");t&&(t.style.display=null==this.isTorchOn?"":"none",n||(t.style.filter="invert(1)",t.style.cursor="not-allowed")),e&&(e.style.display=1==this.isTorchOn?"":"none"),i&&(i.style.display=0==this.isTorchOn?"":"none");let a=s.elBeepOn=s.querySelector(".dce-mn-beep-on"),o=s.elBeepOff=s.querySelector(".dce-mn-beep-off");a&&(a.style.display=Rs.allowBeep?"":"none"),o&&(o.style.display=Rs.allowBeep?"none":"");let l=s.elVibrateOn=s.querySelector(".dce-mn-vibrate-on"),h=s.elVibrateOff=s.querySelector(".dce-mn-vibrate-off");l&&(l.style.display=Rs.allowVibrate?"":"none"),h&&(h.style.display=Rs.allowVibrate?"none":""),s.elResolutionBox=s.querySelector(".dce-mn-resolution-box");let c,d=s.elZoom=s.querySelector(".dce-mn-zoom");d&&(d.style.display="none",c=s.elZoomSpan=d.querySelector("span"));let u=s.elToast=s.querySelector(".dce-mn-toast"),f=s.elCameraClose=s.querySelector(".dce-mn-camera-close"),g=s.elTakePhoto=s.querySelector(".dce-mn-take-photo"),m=s.elCameraSwitch=s.querySelector(".dce-mn-camera-switch"),p=s.elCameraAndResolutionSettings=s.querySelector(".dce-mn-camera-and-resolution-settings");p&&(p.style.display="none");const _=s.dceMnFs={},v=()=>{this.turnOnTorch()};null==t||t.addEventListener("pointerdown",v);const y=()=>{this.turnOffTorch()};null==e||e.addEventListener("pointerdown",y);const w=()=>{this.turnAutoTorch()};null==i||i.addEventListener("pointerdown",w);const E=()=>{Rs.allowBeep=!Rs.allowBeep,a&&(a.style.display=Rs.allowBeep?"":"none"),o&&(o.style.display=Rs.allowBeep?"none":"")};for(let t of[o,a])null==t||t.addEventListener("pointerdown",E);const C=()=>{Rs.allowVibrate=!Rs.allowVibrate,l&&(l.style.display=Rs.allowVibrate?"":"none"),h&&(h.style.display=Rs.allowVibrate?"none":"")};for(let t of[h,l])null==t||t.addEventListener("pointerdown",C);const S=async t=>{let e,i=t.target;if(e=i.closest(".dce-mn-camera-option"))this.selectCamera(e.getAttribute("data-davice-id"));else if(e=i.closest(".dce-mn-resolution-option")){let t,i=parseInt(e.getAttribute("data-width")),n=parseInt(e.getAttribute("data-height")),r=await this.setResolution({width:i,height:n});{let e=Math.max(r.width,r.height),i=Math.min(r.width,r.height);t=i<=1080?i+"P":e<3e3?"2K":Math.round(e/1e3)+"K"}t!=e.textContent&&I(`Fallback to ${t}`)}else i.closest(".dce-mn-camera-and-resolution-settings")||(i.closest(".dce-mn-resolution-box")?p&&(p.style.display=p.style.display?"":"none"):p&&""===p.style.display&&(p.style.display="none"))};s.addEventListener("click",S);let T=null;_.funcInfoZoomChange=(t,e=3e3)=>{d&&c&&(c.textContent=t.toFixed(1),d.style.display="",null!=T&&(clearTimeout(T),T=null),T=setTimeout(()=>{d.style.display="none",T=null},e))};let b=null,I=_.funcShowToast=(t,e=3e3)=>{u&&(u.textContent=t,u.style.display="",null!=b&&(clearTimeout(b),b=null),b=setTimeout(()=>{u.style.display="none",b=null},e))};const x=()=>{this.close()};null==f||f.addEventListener("click",x);const R=()=>{};null==g||g.addEventListener("pointerdown",R);const O=()=>{var t,e;let i,n=this.getVideoSettings(),r=n.video.facingMode,s=null===(e=null===(t=this.cameraManager.getCamera())||void 0===t?void 0:t.label)||void 0===e?void 0:e.toLowerCase(),a=null==s?void 0:s.indexOf("front");-1===a&&(a=null==s?void 0:s.indexOf("前"));let o=null==s?void 0:s.indexOf("back");if(-1===o&&(o=null==s?void 0:s.indexOf("后")),"number"==typeof a&&-1!==a?i=!0:"number"==typeof o&&-1!==o&&(i=!1),void 0===i&&(i="user"===((null==r?void 0:r.ideal)||(null==r?void 0:r.exact)||r)),!i){let t=this.cameraView.getUIElement();t=t.shadowRoot||t,t.elTorchAuto&&(t.elTorchAuto.style.display="none"),t.elTorchOn&&(t.elTorchOn.style.display="none"),t.elTorchOff&&(t.elTorchOff.style.display="")}n.video.facingMode={ideal:i?"environment":"user"},delete n.video.deviceId,this.updateVideoSettings(n)};null==m||m.addEventListener("pointerdown",O);let D=-1/0,A=1;const M=t=>{let e=Date.now();e-D>1e3&&(A=this.getZoomSettings().factor),A-=t.deltaY/200,A>20&&(A=20),A<1&&(A=1),this.setZoom({factor:A}),D=e};r.addEventListener("wheel",M);const L=new Map;let F=!1;const P=async t=>{var e;for(t.touches.length>=2&&"touchmove"==t.type&&t.preventDefault();t.changedTouches.length>1&&2==t.touches.length;){let i=t.touches[0],n=t.touches[1],r=L.get(i.identifier),s=L.get(n.identifier);if(!r||!s)break;let a=Math.pow(Math.pow(r.x-s.x,2)+Math.pow(r.y-s.y,2),.5),o=Math.pow(Math.pow(i.clientX-n.clientX,2)+Math.pow(i.clientY-n.clientY,2),.5),l=Date.now();if(F||l-D<100)return;l-D>1e3&&(A=this.getZoomSettings().factor),A*=o/a,A>20&&(A=20),A<1&&(A=1);let h=!1;"safari"==(null===(e=null==ai?void 0:ai.browser)||void 0===e?void 0:e.toLocaleLowerCase())&&(o/a>1&&A<2?(A=2,h=!0):o/a<1&&A<2&&(A=1,h=!0)),F=!0,h&&I("zooming..."),await this.setZoom({factor:A}),h&&(u.textContent=""),F=!1,D=Date.now();break}L.clear();for(let e of t.touches)L.set(e.identifier,{x:e.clientX,y:e.clientY})};s.addEventListener("touchstart",P),s.addEventListener("touchmove",P),s.addEventListener("touchend",P),s.addEventListener("touchcancel",P),_.unbind=()=>{null==t||t.removeEventListener("pointerdown",v),null==e||e.removeEventListener("pointerdown",y),null==i||i.removeEventListener("pointerdown",w);for(let t of[o,a])null==t||t.removeEventListener("pointerdown",E);for(let t of[h,l])null==t||t.removeEventListener("pointerdown",C);s.removeEventListener("click",S),null==f||f.removeEventListener("click",x),null==g||g.removeEventListener("pointerdown",R),null==m||m.removeEventListener("pointerdown",O),r.removeEventListener("wheel",M),s.removeEventListener("touchstart",P),s.removeEventListener("touchmove",P),s.removeEventListener("touchend",P),s.removeEventListener("touchcancel",P),delete s.dceMnFs,r.style.display="none"},r.style.display="",t&&null==this.isTorchOn&&setTimeout(()=>{this.turnAutoTorch(1e3)},0)}this.isTorchOn&&this.turnOnTorch().catch(()=>{});const a=this.getResolution();i.width=a.width,i.height=a.height,i.deviceId=this.getSelectedCamera().deviceId}return li(this,os,"open"),e&&(e._innerComponent.style.display="",oi(this,rs,"m",Cs).call(this)||(e._stopLoading(),e._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),e._renderResolutionInfo({width:i.width,height:i.height}),e.eventHandler.fire("content:updated",null,{async:!1}),e.eventHandler.fire("videoEl:resized",null,{async:!1}))),this.toggleMirroring(this._isEnableMirroring),oi(this,ls,"f").fire("opened",null,{target:this,async:!1}),this.cameraManager._zoomPreSetting&&(await this.setZoom(this.cameraManager._zoomPreSetting),this.cameraManager._zoomPreSetting=null),i}close(){var t;const e=this.cameraView;if(null==e?void 0:e.disposed)throw new Error("'cameraView' has been disposed.");if(this.stopFetching(),this.clearBuffer(),oi(this,rs,"m",Cs).call(this));else{this.cameraManager.close();let i=e.getUIElement();i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")&&(null===(t=i.dceMnFs)||void 0===t||t.unbind())}li(this,os,"closed"),oi(this,ws,"f").stopCharging(),e&&(e._innerComponent.style.display="none",oi(this,rs,"m",Cs).call(this)&&e._innerComponent.removeElement("content"),e._stopLoading()),oi(this,ls,"f").fire("closed",null,{target:this,async:!1})}pause(){if(oi(this,rs,"m",Cs).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");this.cameraManager.pause()}isPaused(){var t;return!oi(this,rs,"m",Cs).call(this)&&!0===(null===(t=this.video)||void 0===t?void 0:t.paused)}async resume(){if(oi(this,rs,"m",Cs).call(this))throw new Error("'resume()' is invalid in 'singleFrameMode'.");await this.cameraManager.resume()}async selectCamera(t){var e;if(!t)throw new Error("Invalid value.");let i;i="string"==typeof t?t:t.deviceId,await this.cameraManager.setCamera(i),this.isTorchOn=!1;const n=this.getResolution(),r=this.cameraView;if(r&&!r.disposed&&(r._stopLoading(),r._renderCamerasInfo(this.getSelectedCamera(),this.cameraManager._arrCameras),r._renderResolutionInfo({width:n.width,height:n.height})),this.isOpen()){const t=!!(null===(e=this.cameraManager.getCameraCapabilities())||void 0===e?void 0:e.torch);let i=r.getUIElement();if(i=i.shadowRoot||i,i.querySelector(".dce-macro-use-mobile-native-like-ui")){let e=i.elTorchAuto=i.querySelector(".dce-mn-torch-auto");e&&(t?(e.style.filter="none",e.style.cursor="pointer"):(e.style.filter="invert(1)",e.style.cursor="not-allowed"))}}return this.toggleMirroring(this._isEnableMirroring),{width:n.width,height:n.height,deviceId:this.getSelectedCamera().deviceId}}getSelectedCamera(){return this.cameraManager.getCamera()}async getAllCameras(){return this.cameraManager.getCameras()}async setResolution(t){await this.cameraManager.setResolution(t.width,t.height),this.isTorchOn&&this.turnOnTorch().catch(()=>{});const e=this.getResolution(),i=this.cameraView;return i&&!i.disposed&&(i._stopLoading(),i._renderResolutionInfo({width:e.width,height:e.height})),this.toggleMirroring(this._isEnableMirroring),oi(this,gs,"f")&&this.setScanRegion(oi(this,gs,"f")),{width:e.width,height:e.height,deviceId:this.getSelectedCamera().deviceId}}getResolution(){return this.cameraManager.getResolution()}getAvailableResolutions(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getResolutions()}_on(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?oi(this,ls,"f").on(t,e):this.cameraManager.on(t,e)}_off(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?oi(this,ls,"f").off(t,e):this.cameraManager.off(t,e)}on(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._on(n,e)}off(t,e){const i=t.toLowerCase(),n=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(i);if(!n)throw new Error("Invalid event.");this._off(n,e)}getVideoSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getMediaStreamConstraints()}async updateVideoSettings(t){var e;await(null===(e=this.cameraManager)||void 0===e?void 0:e.setMediaStreamConstraints(t,!0))}getCapabilities(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getCameraCapabilities()}getCameraSettings(){return this.cameraManager.getCameraSettings()}async turnOnTorch(){var t,e;if(oi(this,rs,"m",Cs).call(this))throw new Error("'turnOnTorch()' is invalid in 'singleFrameMode'.");try{await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOnTorch())}catch(t){let i=this.cameraView.getUIElement();throw i=i.shadowRoot||i,null===(e=null==i?void 0:i.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"),t}this.isTorchOn=!0;let i=this.cameraView.getUIElement();i=i.shadowRoot||i,i.elTorchAuto&&(i.elTorchAuto.style.display="none"),i.elTorchOn&&(i.elTorchOn.style.display=""),i.elTorchOff&&(i.elTorchOff.style.display="none")}async turnOffTorch(){var t;if(oi(this,rs,"m",Cs).call(this))throw new Error("'turnOffTorch()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.turnOffTorch()),this.isTorchOn=!1;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,e.elTorchAuto&&(e.elTorchAuto.style.display="none"),e.elTorchOn&&(e.elTorchOn.style.display="none"),e.elTorchOff&&(e.elTorchOff.style.display="")}async turnAutoTorch(t=250){var e;const i=this.isOpen()&&!this.cameraManager.videoSrc?this.cameraManager.getCameraCapabilities():{};if(!(null==i?void 0:i.torch)){let t=this.cameraView.getUIElement();return t=t.shadowRoot||t,void(null===(e=null==t?void 0:t.dceMnFs)||void 0===e||e.funcShowToast("Torch Not Supported"))}if(null!=this._taskid4AutoTorch){if(!(t{var t,e,i;if(this.disposed||n||null!=this.isTorchOn||!this.isOpen())return clearInterval(this._taskid4AutoTorch),void(this._taskid4AutoTorch=null);if(this.isPaused())return;if(++s>10&&this._delay4AutoTorch<1e3)return clearInterval(this._taskid4AutoTorch),this._taskid4AutoTorch=null,void this.turnAutoTorch(1e3);let a;try{a=this.fetchImage()}catch(t){}if(!a||!a.width||!a.height)return;let o=0;if(l.IPF_GRAYSCALED===a.format){for(let t=0;t=this.maxDarkCount4AutoTroch){null===(t=Fs._onLog)||void 0===t||t.call(Fs,`darkCount ${r}`);try{await this.turnOnTorch(),this.isTorchOn=!0;let t=this.cameraView.getUIElement();t=t.shadowRoot||t,null===(e=null==t?void 0:t.dceMnFs)||void 0===e||e.funcShowToast("Torch Auto On")}catch(t){console.warn(t),n=!0;let e=this.cameraView.getUIElement();e=e.shadowRoot||e,null===(i=null==e?void 0:e.dceMnFs)||void 0===i||i.funcShowToast("Torch Not Supported")}}}else r=0};this._taskid4AutoTorch=setInterval(a,t),this.isTorchOn=void 0,a();let o=this.cameraView.getUIElement();o=o.shadowRoot||o,o.elTorchAuto&&(o.elTorchAuto.style.display=""),o.elTorchOn&&(o.elTorchOn.style.display="none"),o.elTorchOff&&(o.elTorchOff.style.display="none")}async setColorTemperature(t){if(oi(this,rs,"m",Cs).call(this))throw new Error("'setColorTemperature()' is invalid in 'singleFrameMode'.");await this.cameraManager.setColorTemperature(t,!0)}getColorTemperature(){return this.cameraManager.getColorTemperature()}async setExposureCompensation(t){var e;if(oi(this,rs,"m",Cs).call(this))throw new Error("'setExposureCompensation()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setExposureCompensation(t,!0))}getExposureCompensation(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getExposureCompensation()}async _setZoom(t){var e,i,n;if(oi(this,rs,"m",Cs).call(this))throw new Error("'setZoom()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setZoom(t));{let e=null===(i=this.cameraView)||void 0===i?void 0:i.getUIElement();e=(null==e?void 0:e.shadowRoot)||e,null===(n=null==e?void 0:e.dceMnFs)||void 0===n||n.funcInfoZoomChange(t.factor)}}async setZoom(t){await this._setZoom(t)}getZoomSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getZoom()}async resetZoom(){var t;if(oi(this,rs,"m",Cs).call(this))throw new Error("'resetZoom()' is invalid in 'singleFrameMode'.");await(null===(t=this.cameraManager)||void 0===t?void 0:t.resetZoom())}async setFrameRate(t){var e;if(oi(this,rs,"m",Cs).call(this))throw new Error("'setFrameRate()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFrameRate(t,!0))}getFrameRate(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFrameRate()}async setFocus(t){var e;if(oi(this,rs,"m",Cs).call(this))throw new Error("'setFocus()' is invalid in 'singleFrameMode'.");await(null===(e=this.cameraManager)||void 0===e?void 0:e.setFocus(t,!0))}getFocusSettings(){var t;return null===(t=this.cameraManager)||void 0===t?void 0:t.getFocus()}setAutoZoomRange(t){oi(this,ys,"f").minValue=t.min,oi(this,ys,"f").maxValue=t.max}getAutoZoomRange(){return{min:oi(this,ys,"f").minValue,max:oi(this,ys,"f").maxValue}}enableEnhancedFeatures(t){var e,i;if(!(null===(i=null===(e=xt.license)||void 0===e?void 0:e.LicenseManager)||void 0===i?void 0:i.bPassValidation))throw new Error("License is not verified, or license is invalid.");if(0!==At.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");t&yi.EF_ENHANCED_FOCUS&&(oi(this,vs,"f").enhancedFocus=!0),t&yi.EF_AUTO_ZOOM&&(oi(this,vs,"f").autoZoom=!0),t&yi.EF_TAP_TO_FOCUS&&(oi(this,vs,"f").tapToFocus=!0,this.cameraManager.enableTapToFocus())}disableEnhancedFeatures(t){t&yi.EF_ENHANCED_FOCUS&&(oi(this,vs,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch(()=>{})),t&yi.EF_AUTO_ZOOM&&(oi(this,vs,"f").autoZoom=!1,this.resetZoom().catch(()=>{})),t&yi.EF_TAP_TO_FOCUS&&(oi(this,vs,"f").tapToFocus=!1,this.cameraManager.disableTapToFocus()),oi(this,rs,"m",Ts).call(this)&&oi(this,rs,"m",Ss).call(this)||oi(this,ws,"f").stopCharging()}_setScanRegion(t){if(null!=t&&!y(t)&&!b(t))throw TypeError("Invalid 'region'.");li(this,gs,t?JSON.parse(JSON.stringify(t)):null),this.cameraView&&!this.cameraView.disposed&&this.cameraView.setScanRegion(t)}setScanRegion(t){this._setScanRegion(t),this.cameraView&&!this.cameraView.disposed&&(null===t?this.cameraView.setScanRegionMaskVisible(!1):this.cameraView.setScanRegionMaskVisible(!0))}getScanRegion(){return JSON.parse(JSON.stringify(oi(this,gs,"f")))}setErrorListener(t){if(!t)throw new TypeError("Invalid 'listener'");li(this,fs,t)}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!this.cameraManager.isVideoLoaded()||oi(this,rs,"m",Cs).call(this))}startFetching(){if(oi(this,rs,"m",Cs).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");oi(this,ps,"f")||(li(this,ps,!0),oi(this,rs,"m",bs).call(this))}stopFetching(){oi(this,ps,"f")&&(Fs._onLog&&Fs._onLog("DCE: stop fetching loop: "+Date.now()),oi(this,_s,"f")&&clearTimeout(oi(this,_s,"f")),li(this,ps,!1))}toggleMirroring(t){this.isOpen()&&(this.video.style.transform=`scaleX(${t?"-1":"1"})`),this._isEnableMirroring=t}fetchImage(t=!1){if(oi(this,rs,"m",Cs).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(!this.cameraManager.isVideoLoaded())throw new Error("The video is not loaded.");const e=this.getResolution();if(!(null==e?void 0:e.width)||!(null==e?void 0:e.height))throw new Error("The video is not loaded.");let i,n;if(i=Ji.convert(oi(this,gs,"f"),e.width,e.height,this.cameraView),i||(i={x:0,y:0,width:e.width,height:e.height}),i.x>e.width||i.y>e.height)throw new Error("Invalid scan region.");if(i.x+i.width>e.width&&(i.width=e.width-i.x),i.y+i.height>e.height&&(i.height=e.height-i.y),oi(this,gs,"f")&&!t)n={sx:i.x,sy:i.y,sWidth:i.width,sHeight:i.height,dWidth:i.width,dHeight:i.height};else{const t=this.cameraView.getVisibleRegionOfVideo({inPixels:!0});n={sx:t.x,sy:t.y,sWidth:t.width,sHeight:t.height,dWidth:t.width,dHeight:t.height}}const r=Math.max(n.dWidth,n.dHeight);if(this.canvasSizeLimit&&r>this.canvasSizeLimit){const t=this.canvasSizeLimit/r;n.dWidth>n.dHeight?(n.dWidth=this.canvasSizeLimit,n.dHeight=Math.round(n.dHeight*t)):(n.dWidth=Math.round(n.dWidth*t),n.dHeight=this.canvasSizeLimit)}const s=this.cameraManager.getFrameData({position:n,pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?wi.GREY:wi.RGBA,isEnableMirroring:this._isEnableMirroring});if(!s)return null;let a;a=s.pixelFormat===wi.GREY?s.width:4*s.width;let o=!0;return 0===n.sx&&0===n.sy&&n.sWidth===e.width&&n.sHeight===e.height&&(o=!1),{bytes:s.data,width:s.width,height:s.height,stride:a,format:Os.get(s.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:rt.ITT_VIDEO_FRAME,isCropped:o,cropRegion:{left:n.sx,top:n.sy,right:n.sx+n.sWidth,bottom:n.sy+n.sHeight,isMeasuredInPercentage:!1},originalWidth:e.width,originalHeight:e.height,currentWidth:s.width,currentHeight:s.height,timeSpent:s.timeSpent,timeStamp:s.timeStamp},toCanvas:oi(this,us,"f"),isDCEFrame:!0}}setImageFetchInterval(t){this.fetchInterval=t,oi(this,ps,"f")&&(oi(this,_s,"f")&&clearTimeout(oi(this,_s,"f")),li(this,_s,setTimeout(()=>{this.disposed||oi(this,rs,"m",bs).call(this)},t)))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(t){li(this,ms,t)}getPixelFormat(){return oi(this,ms,"f")}takePhoto(t){if(!this.isOpen())throw new Error("Not open.");if(oi(this,rs,"m",Cs).call(this))throw new Error("'takePhoto()' is unavailable in 'singleFrameMode'.");const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"),e.setAttribute("capture",""),e.style.position="absolute",e.style.top="-9999px",e.style.backgroundColor="transparent",e.style.color="transparent",e.addEventListener("click",()=>{const t=this.isOpen();this.close(),window.addEventListener("focus",()=>{t&&this.open(),e.remove()},{once:!0})}),e.addEventListener("change",async()=>{const i=e.files[0],n=await(async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var n;return e||(i=await(n=t,new Promise((t,e)=>{let i=URL.createObjectURL(n),r=new Image;r.src=i,r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}}))),i})(i),r=n instanceof HTMLImageElement?n.naturalWidth:n.width,s=n instanceof HTMLImageElement?n.naturalHeight:n.height;let a=Ji.convert(oi(this,gs,"f"),r,s,this.cameraView);a||(a={x:0,y:0,width:r,height:s});const o=oi(this,ds,"f").call(this,n,r,s,a);t&&t(o)}),document.body.appendChild(e),e.click()}convertToPageCoordinates(t){const e=this.convertToContainCoordinates(t),i=oi(this,rs,"m",Is).call(this,e);return{x:i.pageX,y:i.pageY}}convertToClientCoordinates(t){const e=this.convertToContainCoordinates(t),i=oi(this,rs,"m",Is).call(this,e);return{x:i.clientX,y:i.clientY}}convertToScanRegionCoordinates(t){if(!oi(this,gs,"f"))return JSON.parse(JSON.stringify(t));const e=this.convertToContainCoordinates(t);if(this.isOpen()){const t=this.cameraView.getVisibleRegionOfVideo({inPixels:!0});li(this,hs,t||oi(this,hs,"f"))}let i,n,r=oi(this,gs,"f").left||oi(this,gs,"f").x||0,s=oi(this,gs,"f").top||oi(this,gs,"f").y||0;if(!oi(this,gs,"f").isMeasuredInPercentage)return{x:e.x-(r+oi(this,hs,"f").x),y:e.y-(s+oi(this,hs,"f").y)};if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!oi(this,rs,"m",Cs).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(oi(this,rs,"m",Cs).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");if(oi(this,rs,"m",Cs).call(this)){const t=this.cameraView._innerComponent.getElement("content");i=t.width,n=t.height}else i=oi(this,hs,"f").width,n=oi(this,hs,"f").height;return{x:e.x-(Math.round(r*i/100)+oi(this,hs,"f").x),y:e.y-(Math.round(s*n/100)+oi(this,hs,"f").y)}}convertToContainCoordinates(t){if("contain"===this.cameraView.getVideoFit())return t;const e=this.cameraView.getVisibleRegionOfVideo({inPixels:!0}),i=JSON.parse(JSON.stringify(t));return y(oi(this,gs,"f"))?oi(this,gs,"f").isMeasuredInPercentage?(i.x=e.width*(oi(this,gs,"f").left/100)+e.x+t.x,i.y=e.height*(oi(this,gs,"f").top/100)+e.y+t.y):(i.x=oi(this,gs,"f").left+e.x+t.x,i.y=oi(this,gs,"f").top+e.y+t.y):oi(this,gs,"f").isMeasuredInPercentage?(i.x=e.width*(oi(this,gs,"f").x/100)+e.x+t.x,i.y=e.height*(oi(this,gs,"f").y/100)+e.y+t.y):(i.x=oi(this,gs,"f").x+e.x+t.x,i.y=oi(this,gs,"f").y+e.y+t.y),i}dispose(){this.close(),this.cameraManager.dispose(),this.releaseCameraView(),li(this,Es,!0)}}var Ps,ks,Ns,Bs,js,Vs,Us,Gs;ss=Fs,os=new WeakMap,ls=new WeakMap,hs=new WeakMap,cs=new WeakMap,ds=new WeakMap,us=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ps=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys=new WeakMap,ws=new WeakMap,Es=new WeakMap,rs=new WeakSet,Cs=function(){return"disabled"!==this.singleFrameMode},Ss=function(){return!this.videoSrc&&"opened"===this.cameraManager.state},Ts=function(){for(let t in oi(this,vs,"f"))if(1==oi(this,vs,"f")[t])return!0;return!1},bs=function t(){if(this.disposed)return;if("open"!==this.getCameraState()||!oi(this,ps,"f"))return oi(this,_s,"f")&&clearTimeout(oi(this,_s,"f")),void li(this,_s,setTimeout(()=>{this.disposed||oi(this,rs,"m",t).call(this)},this.fetchInterval));const e=()=>{var t;let e;Fs._onLog&&Fs._onLog("DCE: start fetching a frame into buffer: "+Date.now());try{e=this.fetchImage()}catch(e){const i=e.message||e;if("The video is not loaded."===i)return;if(null===(t=oi(this,fs,"f"))||void 0===t?void 0:t.onErrorReceived)return void setTimeout(()=>{var t;null===(t=oi(this,fs,"f"))||void 0===t||t.onErrorReceived(et.EC_IMAGE_READ_FAILED,i)},0);console.warn(e)}e?(this.addImageToBuffer(e),Fs._onLog&&Fs._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),oi(this,ls,"f").fire("frameAddedToBuffer",null,{async:!1})):Fs._onLog&&Fs._onLog("DCE: get a invalid frame, abandon it: "+Date.now())};if(this.getImageCount()>=this.getMaxImageCount())switch(this.getBufferOverflowProtectionMode()){case a.BOPM_BLOCK:break;case a.BOPM_UPDATE:e()}else e();oi(this,_s,"f")&&clearTimeout(oi(this,_s,"f")),li(this,_s,setTimeout(()=>{this.disposed||oi(this,rs,"m",t).call(this)},this.fetchInterval))},Is=function(t){if(!this.cameraView)throw new Error("Camera view is not set.");if(this.cameraView.disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!oi(this,rs,"m",Cs).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(oi(this,rs,"m",Cs).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");const e=this.cameraView._innerComponent.getBoundingClientRect(),i=e.left,n=e.top,r=i+window.scrollX,s=n+window.scrollY,{width:a,height:o}=this.cameraView._innerComponent.getBoundingClientRect();if(a<=0||o<=0)throw new Error("Unable to get content dimensions. Camera view may not be rendered on the page.");let l,h,c;if(oi(this,rs,"m",Cs).call(this)){const t=this.cameraView._innerComponent.getElement("content");l=t.width,h=t.height,c="contain"}else{const t=this.getVideoEl();l=t.videoWidth,h=t.videoHeight,c=this.cameraView.getVideoFit()}const d=a/o,u=l/h;let f,g,m,p,_=1;if("contain"===c)d{var e;if(!this.isUseMagnifier)return;if(oi(this,Bs,"f")||li(this,Bs,new Ws),!oi(this,Bs,"f").magnifierCanvas)return;document.body.contains(oi(this,Bs,"f").magnifierCanvas)||(oi(this,Bs,"f").magnifierCanvas.style.position="fixed",oi(this,Bs,"f").magnifierCanvas.style.boxSizing="content-box",oi(this,Bs,"f").magnifierCanvas.style.border="2px solid #FFFFFF",document.body.append(oi(this,Bs,"f").magnifierCanvas));const i=this._innerComponent.getElement("content");if(!i)return;if(t.pointer.x<0||t.pointer.x>i.width||t.pointer.y<0||t.pointer.y>i.height)return void oi(this,Vs,"f").call(this);const n=null===(e=this._drawingLayerManager._getFabricCanvas())||void 0===e?void 0:e.lowerCanvasEl;if(!n)return;const r=Math.max(i.clientWidth/5/1.5,i.clientHeight/4/1.5),s=1.5*r,a=[{image:i,width:i.width,height:i.height},{image:n,width:n.width,height:n.height}];oi(this,Bs,"f").update(s,t.pointer,r,a);{let e=0,i=0;t.e instanceof MouseEvent?(e=t.e.clientX,i=t.e.clientY):t.e instanceof TouchEvent&&t.e.changedTouches.length&&(e=t.e.changedTouches[0].clientX,i=t.e.changedTouches[0].clientY),e<1.5*s&&i<1.5*s?(oi(this,Bs,"f").magnifierCanvas.style.left="auto",oi(this,Bs,"f").magnifierCanvas.style.top="0",oi(this,Bs,"f").magnifierCanvas.style.right="0"):(oi(this,Bs,"f").magnifierCanvas.style.left="0",oi(this,Bs,"f").magnifierCanvas.style.top="0",oi(this,Bs,"f").magnifierCanvas.style.right="auto")}oi(this,Bs,"f").show()}),Vs.set(this,()=>{oi(this,Bs,"f")&&oi(this,Bs,"f").hide()}),Us.set(this,!1)}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await sn(t);e=document.createElement("div"),Object.assign(e.style,{width:"100%",height:"100%"}),e.attachShadow({mode:"open"}).appendChild(i)}else e=t;this._setUIElement(e)}getUIElement(){return this.UIElement}_bindUI(){if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;const t=this.UIElement;let e=t.classList.contains(this.containerClassName)?t:t.querySelector(`.${this.containerClassName}`);e||(e=document.createElement("div"),e.style.width="100%",e.style.height="100%",e.className=this.containerClassName,t.append(e)),this._innerComponent=document.createElement("dce-component"),e.appendChild(this._innerComponent)}_unbindUI(){var t,e,i;null===(t=this._drawingLayerManager)||void 0===t||t.clearDrawingLayers(),null===(e=this._innerComponent)||void 0===e||e.removeElement("drawing-layer"),this._layerBaseCvs=null,null===(i=this._innerComponent)||void 0===i||i.remove(),this._innerComponent=null}setImage(t,e,i){if(!this._innerComponent)throw new Error("Need to set 'UIElement'.");let n=this._innerComponent.getElement("content");n||(n=document.createElement("canvas"),n.style.objectFit="contain",this._innerComponent.setElement("content",n)),n.width===e&&n.height===i||(n.width=e,n.height=i);const r=n.getContext("2d");r.clearRect(0,0,n.width,n.height),t instanceof Uint8Array||t instanceof Uint8ClampedArray?(t instanceof Uint8Array&&(t=new Uint8ClampedArray(t.buffer)),r.putImageData(new ImageData(t,e,i),0,0)):(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement)&&r.drawImage(t,0,0)}getImage(){return this._innerComponent.getElement("content")}clearImage(){if(!this._innerComponent)return;let t=this._innerComponent.getElement("content");t&&t.getContext("2d").clearRect(0,0,t.width,t.height)}removeImage(){this._innerComponent&&this._innerComponent.removeElement("content")}setOriginalImage(t){if(v(t)){li(this,Ns,t);const{width:e,height:i,bytes:n,format:r}=Object.assign({},t);let s;if(r===l.IPF_GRAYSCALED){s=new Uint8ClampedArray(e*i*4);for(let t=0;t{if(!zs){if(!Hs&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),Zs=t=>{if(null==t&&(t="./"),Hs||zs);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};At.engineResourcePaths.dbr={version:"11.2.20-dev-20251029130556",path:Xs,isInternal:!0},Rt.dbr={js:!1,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.dbr={};const qs="2.0.0";"string"!=typeof At.engineResourcePaths.std&&x(At.engineResourcePaths.std.version,qs)<0&&(At.engineResourcePaths.std={version:qs,path:Zs(Xs+`../../dynamsoft-capture-vision-std@${qs}/dist/`),isInternal:!0});const Ks="3.0.10";(!At.engineResourcePaths.dip||"string"!=typeof At.engineResourcePaths.dip&&x(At.engineResourcePaths.dip.version,Ks)<0)&&(At.engineResourcePaths.dip={version:Ks,path:Zs(Xs+`../../dynamsoft-image-processing@${Ks}/dist/`),isInternal:!0});const Js={BF_NULL:BigInt(0),BF_ALL:BigInt("0xFFFFFFFEFFFFFFFF"),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552),BF_TELEPEN:BigInt(137438953472),BF_TELEPEN_NUMERIC:BigInt(274877906944)};var $s,Qs,ta,ea;function ia(t,e,i,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}!function(t){t[t.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",t[t.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",t[t.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT"}($s||($s={})),function(t){t[t.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",t[t.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",t[t.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",t[t.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(Qs||(Qs={})),function(t){t[t.LM_AUTO=1]="LM_AUTO",t[t.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",t[t.LM_STATISTICS=4]="LM_STATISTICS",t[t.LM_LINES=8]="LM_LINES",t[t.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",t[t.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",t[t.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",t[t.LM_CENTRE=128]="LM_CENTRE",t[t.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",t[t.LM_NEURAL_NETWORK=512]="LM_NEURAL_NETWORK",t[t.LM_REV=-2147483648]="LM_REV",t[t.LM_SKIP=0]="LM_SKIP",t[t.LM_END=-1]="LM_END"}(ta||(ta={})),function(t){t[t.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",t[t.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",t[t.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",t[t.DM_SMOOTHING=8]="DM_SMOOTHING",t[t.DM_MORPHING=16]="DM_MORPHING",t[t.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",t[t.DM_SHARPENING=64]="DM_SHARPENING",t[t.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",t[t.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",t[t.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",t[t.DM_REV=-2147483648]="DM_REV",t[t.DM_SKIP=0]="DM_SKIP",t[t.DM_END=-1]="DM_END"}(ea||(ea={})),"function"==typeof SuppressedError&&SuppressedError;const na="undefined"==typeof self,ra=(()=>{if(!na&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"})(),sa=t=>{if(null==t&&(t="./"),na);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var aa,oa;At.engineResourcePaths.dlr={version:"4.2.10-dev-20251029130602",path:ra,isInternal:!0},Rt.dlr={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]};const la="2.0.0";"string"!=typeof At.engineResourcePaths.std&&x(At.engineResourcePaths.std.version,la)<0&&(At.engineResourcePaths.std={version:la,path:sa(ra+`../../dynamsoft-capture-vision-std@${la}/dist/`),isInternal:!0});const ha="3.0.10";(!At.engineResourcePaths.dip||"string"!=typeof At.engineResourcePaths.dip&&x(At.engineResourcePaths.dip.version,ha)<0)&&(At.engineResourcePaths.dip={version:ha,path:sa(ra+`../../dynamsoft-image-processing@${ha}/dist/`),isInternal:!0});let ca=class t{static getVersion(){const t=It.dlr&&It.dlr.wasm;return`4.2.10-dev-20251029130602(Worker: ${It.dlr&&It.dlr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadConfusableCharsData(e,i){return ia(t,aa,"m",oa).call(t,"confusable",e,i)}static async loadOverlappingCharsData(e,i){return ia(t,aa,"m",oa).call(t,"overlapping",e,i)}};aa=ca,oa=async function(t,e,i){return await At.loadWasm(),await new Promise((n,r)=>{let s=wt();Et[s]=async t=>{if(t.success){const e=JSON.parse(t.result);if(0!==e.errorCode){let t=new Error(e.errorString);return t.errorCode=e.errorCode,r(t)}return n(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,r(e)}},i&&!i.endsWith("/")&&(i+="/");const a=R(At.engineResourcePaths);vt.postMessage({type:"dlr_loadData",id:s,body:{type:t,dataName:e,dataPath:i||a.dcvData+"char-resources/"}})})},xt.dlr={loadConfusableCharsData:ca.loadConfusableCharsData,loadOverlappingCharsData:ca.loadOverlappingCharsData};const da={filterVINResult:function(t){let e="";if(18===t.characterResults.length){let e=t.characterResults[9].location.points[0].x-t.characterResults[8].location.points[1].x;e<2&&(e=2);let i=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,n=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,r=2===e?3:e;i-e>=r&&n-e=r&&i-et.characterResults[17].characterHConfidence?t.characterResults.pop():t.characterResults.shift()}else if(19===t.characterResults.length){let e=t.characterResults[10].location.points[0].x-t.characterResults[9].location.points[1].x;e<2&&(e=2);let i,n,r,s=t.characterResults[1].location.points[0].x-t.characterResults[0].location.points[1].x,a=t.characterResults[18].location.points[0].x-t.characterResults[17].location.points[1].x,o=t.characterResults[2].location.points[0].x-t.characterResults[1].location.points[1].x,l=t.characterResults[17].location.points[0].x-t.characterResults[16].location.points[1].x,h=2===e?3:e;if("1"===t.characterResults[1].characterH||"1"===t.characterResults[2].characterH||"1"===t.characterResults[16].characterH||"1"===t.characterResults[17].characterH){for(let e=9;e=(i||h)&&l-e<(n||h))t.characterResults.splice(0,2);else if(l-e>=(n||h)&&o-e<(i||h))t.characterResults.splice(17,2);else if(s>e&&a>e)t.characterResults.pop(),t.characterResults.shift();else{let e=t.characterResults[0].characterHConfidence+t.characterResults[1].characterHConfidence,i=t.characterResults[17].characterHConfidence+t.characterResults[18].characterHConfidence,n=t.characterResults[0].characterHConfidence+t.characterResults[18].characterHConfidence,r=Math.min(e,i,n);r===e?t.characterResults.splice(0,2):r===i?t.characterResults.splice(17,2):r===n&&(t.characterResults.pop(),t.characterResults.shift())}}for(let i of t.characterResults)e+=i.characterH;return e},checkValidVIN:function(t){return!(!t||17!=t.length)&&(t=>{const e=new Map([["A",1],["B",2],["C",3],["D",4],["E",5],["F",6],["G",7],["H",8],["J",1],["K",2],["L",3],["M",4],["N",5],["P",7],["R",9],["S",2],["T",3],["U",4],["V",5],["W",6],["X",7],["Y",8],["Z",9],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9]]),i=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];let n=0;for(let r=0;r{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=t.slice(0,10)+t.slice(13,20)+t.slice(21,43),n=e(t,0,8).toString(),r=e(t,13,18).toString(),s=e(t,21,26).toString(),a=e(t,28,41).toString(),o=e(i,0,i.length).toString();return n===t[9]&&r===t[19]&&s===t[27]&&a===t[42]&&o===t[43]},checkValidMRV:function(t){if(!t||44!=t.length&&36!=t.length)return!1;const e=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10},i=e(t,0,8).toString(),n=e(t,13,18).toString(),r=e(t,21,26).toString();return i===t[9]&&n===t[19]&&r===t[27]},checkValidIDCard:function(t,e){if(!t||30!=t.length&&36!=t.length)return!1;const i=(t,e,i)=>{const n=new Map([["<",0],["0",0],["1",1],["2",2],["3",3],["4",4],["5",5],["6",6],["7",7],["8",8],["9",9],["A",10],["B",11],["C",12],["D",13],["E",14],["F",15],["G",16],["H",17],["I",18],["J",19],["K",20],["L",21],["M",22],["N",23],["O",24],["P",25],["Q",26],["R",27],["S",28],["T",29],["U",30],["V",31],["W",32],["X",33],["Y",34],["Z",35]]),r=[7,3,1];let s=0;for(let a=e,o=0;a<=i;a++){let e=n.get(t[a]);e&&(s+=e*r[o%3]),o++}return s%10};if(30===t.length){if(e&&t===e)return i(t,5,13).toString()===t[14];if(e&&t!==e){const n=`${e.substring(5,30)}${t.substring(0,7)}${t.substring(8,15)}${t.substring(18,29)}`;return i(n,0,n.length-1).toString()===t[29]}}else if(36===t.length){const e=i(t,0,8).toString(),n=i(t,13,18).toString(),r=i(t,21,26).toString(),s=`${t.substring(0,10)}${t.substring(13,20)}${t.substring(21,28)}`,a=i(s,0,s.length-1).toString();return e===t[9]&&n===t[19]&&r===t[27]&&a===t[35]}}};var ua,fa,ga;function ma(t){delete t.moduleId;const e=JSON.parse(t.jsonString).ResultInfo,i=t.fullCodeString;t.getFieldValue=t=>"fullcodestring"===t.toLowerCase()?i:pa(e,t,"map"),t.getFieldRawValue=t=>pa(e,t,"raw"),t.getFieldMappingStatus=t=>_a(e,t),t.getFieldValidationStatus=t=>va(e,t),delete t.fullCodeString}function pa(t,e,i){for(let n of t){if(n.FieldName===e)return"raw"===i&&n.RawValue?n.RawValue:n.Value;if(n.ChildFields&&n.ChildFields.length>0){let t;for(let r of n.ChildFields)t=pa(r,e,i);if(void 0!==t)return t}}}function _a(t,e){for(let i of t){if(i.FieldName===e)return i.MappingStatus?Number(fa[i.MappingStatus]):fa.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=_a(n,e);if(void 0!==t)return t}}}function va(t,e){for(let i of t){if(i.FieldName===e&&i.ValidationStatus)return i.ValidationStatus?Number(ga[i.ValidationStatus]):ga.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=va(n,e);if(void 0!==t)return t}}}function ya(t){if(t.disposed)throw new Error('"CodeParser" instance has been disposed')}!function(t){t[t.RTLS_LOCALIZED=0]="RTLS_LOCALIZED",t[t.RTLS_RECOGNITION_FAILED=1]="RTLS_RECOGNITION_FAILED",t[t.RTLS_RECOGNITION_SUCCEEDED=2]="RTLS_RECOGNITION_SUCCEEDED"}(ua||(ua={})),Et[-1]=async t=>{ca.onDataLoadProgressChanged&&ca.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})},function(t){t[t.MS_NONE=0]="MS_NONE",t[t.MS_SUCCEEDED=1]="MS_SUCCEEDED",t[t.MS_FAILED=2]="MS_FAILED"}(fa||(fa={})),function(t){t[t.VS_NONE=0]="VS_NONE",t[t.VS_SUCCEEDED=1]="VS_SUCCEEDED",t[t.VS_FAILED=2]="VS_FAILED"}(ga||(ga={}));const wa=t=>t&&"object"==typeof t&&"function"==typeof t.then,Ea=(async()=>{})().constructor;let Ca=class extends Ea{get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(t){let e;this._task=t,wa(t)?e=t:"function"==typeof t&&(e=new Ea(t)),e&&(async()=>{try{const i=await e;t===this._task&&this.resolve(i)}catch(e){t===this._task&&this.reject(e)}})()}get isEmpty(){return null==this._task}constructor(t){let e,i;super((t,n)=>{e=t,i=n}),this._s="pending",this.resolve=t=>{this.isPending&&(wa(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};const Sa="undefined"==typeof self,Ta="function"==typeof importScripts,ba=(()=>{if(!Ta){if(!Sa&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})();At.engineResourcePaths.dcp={version:"3.2.20-dev-20251029130614",path:ba,isInternal:!0},Rt.dcp={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE]},xt.dcp={handleParsedResultItem:ma};const Ia="2.0.0";"string"!=typeof At.engineResourcePaths.std&&x(At.engineResourcePaths.std.version,Ia)<0&&(At.engineResourcePaths.std={version:Ia,path:(t=>{if(null==t&&(t="./"),Sa||Ta);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(ba+`../../dynamsoft-capture-vision-std@${Ia}/dist/`),isInternal:!0}),Et[-4]=async t=>{xa.onSpecLoadProgressChanged&&xa.onSpecLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})};let xa=class{static getVersion(){const t=It.dcp&&It.dcp.wasm;return`3.2.20-dev-20251029130614(Worker: ${It.dcp&&It.dcp.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadSpec(t,e){return await At.loadWasm(),await new Promise((i,n)=>{let r=wt();Et[r]=async t=>{if(t.success)return i();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},e&&!e.endsWith("/")&&(e+="/");const s=t instanceof Array?t:[t],a=R(At.engineResourcePaths);vt.postMessage({type:"dcp_appendResourceBuffer",id:r,body:{specificationPath:e||`${"DBR"===At._bundleEnv?a.dbrBundle:a.dcvData}parser-resources/`,specificationNames:s}})})}};const Ra="undefined"==typeof self,Oa="function"==typeof importScripts,Da=(()=>{if(!Oa){if(!Ra&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),Aa=t=>{if(null==t&&(t="./"),Ra||Oa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};At.engineResourcePaths.ddn={version:"4.2.20-dev-20251029130608",path:Da,isInternal:!0},Rt.ddn={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.ddn={handleDeskewedAndEnhancedImageResultItem:function(t){let e=t,i=L(e.imageData);e.toCanvas=()=>D(i),e.toImage=t=>A(t,i),e.toBlob=t=>M(t,i)}};const Ma="2.0.0";"string"!=typeof At.engineResourcePaths.std&&x(At.engineResourcePaths.std.version,Ma)<0&&(At.engineResourcePaths.std={version:Ma,path:Aa(Da+`../../dynamsoft-capture-vision-std@${Ma}/dist/`),isInternal:!0});const La="3.0.10";(!At.engineResourcePaths.dip||"string"!=typeof At.engineResourcePaths.dip&&x(At.engineResourcePaths.dip.version,La)<0)&&(At.engineResourcePaths.dip={version:La,path:Aa(Da+`../../dynamsoft-image-processing@${La}/dist/`),isInternal:!0});var Fa;!function(t){t[t.ICM_COLOUR=0]="ICM_COLOUR",t[t.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",t[t.ICM_BINARY=2]="ICM_BINARY"}(Fa||(Fa={}));const Pa="undefined"==typeof self,ka="function"==typeof importScripts,Na=(()=>{if(!ka){if(!Pa&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),Ba=t=>{if(null==t&&(t="./"),Pa||ka);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};At.engineResourcePaths.utility={version:"2.2.20-dev-20251029130550",path:Na,isInternal:!0},Rt.utility={js:!0,wasm:!0};const ja="2.0.0";"string"!=typeof At.engineResourcePaths.std&&x(At.engineResourcePaths.std.version,ja)<0&&(At.engineResourcePaths.std={version:ja,path:Ba(Na+`../../dynamsoft-capture-vision-std@${ja}/dist/`),isInternal:!0});const Va="3.0.10";(!At.engineResourcePaths.dip||"string"!=typeof At.engineResourcePaths.dip&&x(At.engineResourcePaths.dip.version,Va)<0)&&(At.engineResourcePaths.dip={version:Va,path:Ba(Na+`../../dynamsoft-image-processing@${Va}/dist/`),isInternal:!0});function Ua(t,e,i,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;const Ga="undefined"==typeof self,Wa="function"==typeof importScripts,Ya=(()=>{if(!Wa){if(!Ga&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),Ha=t=>{if(null==t&&(t="./"),Ga||Wa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};At.engineResourcePaths.dbr={version:"11.0.30-dev-20250522174049",path:Ya,isInternal:!0},Rt.dbr={js:!1,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.dbr={};const za="2.0.0";"string"!=typeof At.engineResourcePaths.std&&x(At.engineResourcePaths.std.version,za)<0&&(At.engineResourcePaths.std={version:za,path:Ha(Ya+`../../dynamsoft-capture-vision-std@${za}/dist/`),isInternal:!0});const Xa="3.0.10";(!At.engineResourcePaths.dip||"string"!=typeof At.engineResourcePaths.dip&&x(At.engineResourcePaths.dip.version,Xa)<0)&&(At.engineResourcePaths.dip={version:Xa,path:Ha(Ya+`../../dynamsoft-image-processing@${Xa}/dist/`),isInternal:!0});const Za={BF_NULL:BigInt(0),BF_ALL:BigInt("0xFFFFFFFEFFFFFFFF"),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552),BF_TELEPEN:BigInt(137438953472),BF_TELEPEN_NUMERIC:BigInt(274877906944)};var qa,Ka,Ja,$a,Qa;(Qa=qa||(qa={}))[Qa.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",Qa[Qa.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",Qa[Qa.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT",function(t){t[t.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",t[t.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",t[t.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",t[t.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(Ka||(Ka={})),function(t){t[t.LM_AUTO=1]="LM_AUTO",t[t.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",t[t.LM_STATISTICS=4]="LM_STATISTICS",t[t.LM_LINES=8]="LM_LINES",t[t.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",t[t.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",t[t.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",t[t.LM_CENTRE=128]="LM_CENTRE",t[t.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",t[t.LM_REV=-2147483648]="LM_REV",t[t.LM_SKIP=0]="LM_SKIP",t[t.LM_END=4294967295]="LM_END"}(Ja||(Ja={})),function(t){t[t.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",t[t.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",t[t.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",t[t.DM_SMOOTHING=8]="DM_SMOOTHING",t[t.DM_MORPHING=16]="DM_MORPHING",t[t.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",t[t.DM_SHARPENING=64]="DM_SHARPENING",t[t.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",t[t.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",t[t.DM_NEURAL_NETWORK=512]="DM_NEURAL_NETWORK",t[t.DM_REV=-2147483648]="DM_REV",t[t.DM_SKIP=0]="DM_SKIP",t[t.DM_END=4294967295]="DM_END"}($a||($a={}));const to=async t=>{let e;await new Promise((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)});const i=document.createElement("canvas"),n=i.getContext("2d");return i.width=e.width,i.height=e.height,n.drawImage(e,0,0),{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:l.IPF_ABGR_8888}};function eo(t,e){let i=!0;for(let a=0;a1)return Math.sqrt((l-a)**2+(h-o)**2);{const t=r+d*(a-r),e=s+d*(o-s);return Math.sqrt((l-t)**2+(h-e)**2)}}function ro(t){const e=[];for(let i=0;i=0&&l<=1&&h>=0&&h<=1?{x:t.x+h*r,y:t.y+h*s}:null}function oo(t){let e=0;for(let i=0;i0}function ho(t,e){for(let i=0;i<4;i++)if(!lo(t.points[i],t.points[(i+1)%4],e))return!1;return!0}function co(t,e,i,n){const r=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const o=ro(r)[3],l=ro(r)[1],h=ro(s)[3],c=ro(s)[1];let d,u=0;if(d=Math.max(Math.abs(no(o,e.points[0])),Math.abs(no(o,e.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(no(l,e.points[1])),Math.abs(no(l,e.points[2]))),d>u&&(u=d),d=Math.max(Math.abs(no(h,t.points[0])),Math.abs(no(h,t.points[3]))),d>u&&(u=d),d=Math.max(Math.abs(no(c,t.points[1])),Math.abs(no(c,t.points[2]))),d>u&&(u=d),u>a)return!1;const f=so(ro(r)[0]),g=so(ro(r)[2]),m=so(ro(s)[0]),p=so(ro(s)[2]),_=io(f,p),v=io(m,g),y=_>v,w=Math.min(_,v),E=io(f,g),C=io(m,p);let S=12*i;return S=Math.max(S,5),S=Math.min(S,E),S=Math.min(S,C),!!(w{e.x+=t,e.y+=i}),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let r=new Array(4).fill(0),s=new Array(4).fill(0),a=0,o=0;for(let t=0;t<4;++t)r[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=r[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,o+=s[t];a/=4,o/=4;for(let t=0;t<4;++t){if(Math.abs(r[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-o)>this.strictLimit||Math.abs(o)>.8)return!1}return e.x=a,e.y=o,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(ho(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(ho(this.location,e))return!0}else{for(let e=0;e<4;e++)if(ho(t,this.location.points[e]))return!0;if(ho(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],r=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:r;if(Math.abs(no(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],r=this.location.points[i];if(!(Math.abs(r.x+e.x-n.x)=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return function(t,e){const i=[];for(let n=0;n<4;n++)for(let r=0;r<4;r++){const s=ao(t[n],t[(n+1)%4],e[r],e[(r+1)%4]);s&&i.push(s)}return t.forEach(t=>{eo(e,t)&&i.push(t)}),e.forEach(e=>{eo(t,e)&&i.push(e)}),oo(function(t){if(t.length<=1)return t;t.sort((t,e)=>t.x-e.x||t.y-e.y);const e=t.shift();return t.sort((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x)),[e,...t]}(i))}([...this.location.points],n.points)>this.locationArea*t}return!0}}var fo,go,mo,po,_o;const vo={barcode:2,text_line:4,detected_quad:8,deskewed_image:16,enhanced_image:64},yo=t=>Object.values(vo).includes(t)||vo.hasOwnProperty(t),wo=(t,e)=>"string"==typeof t?e[vo[t]]:e[t],Eo=(t,e,i)=>{"string"==typeof t?e[vo[t]]=i:e[t]=i},Co=(t,e,i)=>{const n=[{type:Q.CRIT_BARCODE,resultName:"decodedBarcodesResult",itemNames:["barcodeResultItems"]},{type:Q.CRIT_TEXT_LINE,resultName:"recognizedTextLinesResult",itemNames:["textLineResultItems"]}],r=e.items;if(t.isResultCrossVerificationEnabled(i)){for(let t=r.length-1;t>=0;t--)r[t].type!==i||r[t].verified||r.splice(t,1);const t=n.filter(t=>t.type===i)[0];e[t.resultName]&&t.itemNames.forEach(n=>{const r=e[t.resultName][n];e[t.resultName][n]=r.filter(t=>t.type===i&&t.verified)})}if(t.isResultDeduplicationEnabled(i)){for(let t=r.length-1;t>=0;t--)r[t].type===i&&r[t].duplicate&&r.splice(t,1);const t=n.filter(t=>t.type===i)[0];e[t.resultName]&&t.itemNames.forEach(n=>{const r=e[t.resultName][n];e[t.resultName][n]=r.filter(t=>t.type===i&&!t.duplicate)})}};class So{constructor(){this.verificationEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!0,[Q.CRIT_DETECTED_QUAD]:!0,[Q.CRIT_DESKEWED_IMAGE]:!1,[Q.CRIT_ENHANCED_IMAGE]:!1},this.duplicateFilterEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1,[Q.CRIT_ENHANCED_IMAGE]:!1},this.duplicateForgetTime={[Q.CRIT_BARCODE]:3e3,[Q.CRIT_TEXT_LINE]:3e3,[Q.CRIT_DETECTED_QUAD]:3e3,[Q.CRIT_DESKEWED_IMAGE]:3e3,[Q.CRIT_ENHANCED_IMAGE]:3e3},fo.set(this,new Map),go.set(this,new Map),mo.set(this,new Map),po.set(this,new Map),_o.set(this,new Map),this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,this.latestOverlappingEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1},this.maxOverlappingFrames={[Q.CRIT_BARCODE]:this.crossVerificationFrames,[Q.CRIT_TEXT_LINE]:this.crossVerificationFrames,[Q.CRIT_DETECTED_QUAD]:this.crossVerificationFrames,[Q.CRIT_DESKEWED_IMAGE]:this.crossVerificationFrames},Object.defineProperties(this,{onOriginalImageResultReceived:{value:t=>{},writable:!1},onDecodedBarcodesReceived:{value:t=>{this.latestOverlappingFilter(t),Co(this,t,Q.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:t=>{Co(this,t,Q.CRIT_TEXT_LINE)},writable:!1},onProcessedDocumentResultReceived:{value:t=>{},writable:!1},onParsedResultsReceived:{value:t=>{},writable:!1}})}_dynamsoft(){Ua(this,fo,"f").forEach((t,e)=>{Eo(e,this.verificationEnabled,t)}),Ua(this,go,"f").forEach((t,e)=>{Eo(e,this.duplicateFilterEnabled,t)}),Ua(this,mo,"f").forEach((t,e)=>{Eo(e,this.duplicateForgetTime,t)}),Ua(this,po,"f").forEach((t,e)=>{Eo(e,this.latestOverlappingEnabled,t)}),Ua(this,_o,"f").forEach((t,e)=>{Eo(e,this.maxOverlappingFrames,t)})}enableResultCrossVerification(t,e){yo(t)&&Ua(this,fo,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!yo(t)&&wo(t,this.verificationEnabled)}enableResultDeduplication(t,e){yo(t)&&(e&&this.enableLatestOverlapping(t,!1),Ua(this,go,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!yo(t)&&wo(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){yo(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),Ua(this,mo,"f").set(t,e))}getDuplicateForgetTime(t){return yo(t)?wo(t,this.duplicateForgetTime):-1}getFilteredResultItemTypes(){let t=0;const e=[Q.CRIT_BARCODE,Q.CRIT_TEXT_LINE,Q.CRIT_DETECTED_QUAD,Q.CRIT_DESKEWED_IMAGE,Q.CRIT_ENHANCED_IMAGE];for(let i=0;i{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Za.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Za.BF_GS1_DATABAR))!=BigInt(0);return new uo(l,e?1:2,e,t)}}).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(h).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e-1!==t).length;r>p&&(p=r,m=n,g.x=i.x,g.y=i.y)}}if(0===p){for(let e=0;e-1!=t).length}let i=this.overlapSet.length<=3?p>=1:p>=2;if(!i&&s&&d>0){let t=0;for(let e=0;e=1:t>=3}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(Za.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Za.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence5||Math.abs(g.y)>5)&&(e=!1):e=!1;for(let i=0;i0){for(let t=0;t!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0))}f.sort((t,e)=>e-t).forEach((e,i)=>{t.items.splice(e,1)}),u.forEach(e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))})}}}var To,bo,Io,xo;fo=new WeakMap,go=new WeakMap,mo=new WeakMap,po=new WeakMap,_o=new WeakMap;class Ro{async readFromFile(t){return await to(t)}async saveToFile(t,e,i){if(!t||!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");const n=L(t);return O(n,e,i)}async readFromMemory(t){if(!Ua(Ro,To,"f",bo).has(t))throw new Error("Image data ID does not exist.");const{ptr:e,length:i}=Ua(Ro,To,"f",bo).get(t);return await new Promise((t,n)=>{let r=wt();Et[r]=async e=>{if(e.success)return 0!==e.imageData.errorCode&&n(new Error(`[${e.imageData.errorCode}] ${e.imageData.errorString}`)),t(e.imageData);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},vt.postMessage({type:"utility_readFromMemory",id:r,body:{ptr:e,length:i}})})}async saveToMemory(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=await to(t);return await new Promise((t,o)=>{let l=wt();Et[l]=async e=>{var i,n;if(e.success)return function(t,e,i,n,r){if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");r?r.value=i:e.set(t,i)}(i=Ro,To,(n=Ua(i,To,"f",Io),++n),0,Io),Ua(Ro,To,"f",bo).set(Ua(Ro,To,"f",Io),JSON.parse(e.memery)),t(Ua(Ro,To,"f",Io));{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_saveToMemory",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,fileFormat:e}})})}async readFromBase64String(t){return await new Promise((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success)return 0!==t.imageData.errorCode&&i(new Error(`[${t.imageData.errorCode}] ${t.imageData.errorString}`)),e(t.imageData);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},vt.postMessage({type:"utility_readFromBase64String",id:n,body:{base64String:t}})})}async saveToBase64String(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=await to(t);return await new Promise((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return 0!==e.base64Data.errorCode&&o(new Error(`[${e.base64Data.errorCode}] ${e.base64Data.errorString}`)),t(e.base64Data.base64String);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_saveToBase64String",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,fileFormat:e}})})}}To=Ro,bo={value:new Map},Io={value:0};!function(t){t[t.FT_HIGH_PASS=0]="FT_HIGH_PASS",t[t.FT_SHARPEN=1]="FT_SHARPEN",t[t.FT_SMOOTH=2]="FT_SMOOTH"}(xo||(xo={})),At.engineResourcePaths.rootDirectory=(t=>{if(null==t&&(t="./"),Mt||Lt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Ft+"../../"),At.engineResourcePaths.dcvBundle={version:"3.2.5000",path:Ft,isInternal:!0},At.engineResourcePaths.dcvData={version:"1.1.0",path:Ft,isInternal:!0};var Oo,Do,Ao,Mo=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const t=It.dbr&&It.dbr.wasm;return`11.2.20-dev-20251029130556(Worker: ${It.dbr&&It.dbr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}},CameraEnhancer:Fs,CameraEnhancerModule:class{static getVersion(){return"4.3.3-dev-20251029130621"}},CameraManager:Yr,CameraView:Ur,CaptureVisionRouter:Re,CaptureVisionRouterModule:$t,CapturedResultReceiver:Oe,CodeParser:class t{constructor(){this._instanceID=void 0,this.bDestroyed=!1}static async createInstance(){if(!xt.license)throw Error("Module `license` is not existed.");await xt.license.dynamsoft(),await At.loadWasm();const e=new t,i=new Ca;let n=wt();return Et[n]=async t=>{if(t.success)e._instanceID=t.instanceID,i.resolve(e);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),i.reject(e)}},vt.postMessage({type:"dcp_createInstance",id:n}),i}async dispose(){ya(this);let t=wt();this.bDestroyed=!0,Et[t]=t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}},vt.postMessage({type:"dcp_dispose",id:t,instanceID:this._instanceID})}get disposed(){return this.bDestroyed}async initSettings(t){if(ya(this),t&&["string","object"].includes(typeof t))return"string"==typeof t?t.trimStart().startsWith("{")||(t=await I(t,"text")):"object"==typeof t&&(t=JSON.stringify(t)),await new Promise((e,i)=>{let n=wt();Et[n]=async t=>{if(t.success){const n=JSON.parse(t.response);if(0!==n.errorCode){let t=new Error(n.errorString?n.errorString:"Init Settings Failed.");return t.errorCode=n.errorCode,i(t)}return e(n)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},vt.postMessage({type:"dcp_initSettings",id:n,instanceID:this._instanceID,body:{settings:t}})});console.error("Invalid settings.")}async resetSettings(){return ya(this),await new Promise((t,e)=>{let i=wt();Et[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},vt.postMessage({type:"dcp_resetSettings",id:i,instanceID:this._instanceID})})}async parse(t,e=""){if(ya(this),!t||!(t instanceof Array||t instanceof Uint8Array||"string"==typeof t))throw new Error("`parse` must pass in an Array or Uint8Array or string");return await new Promise((i,n)=>{let r=wt();t instanceof Array&&(t=Uint8Array.from(t)),"string"==typeof t&&(t=Uint8Array.from(function(t){let e=[];for(let i=0;i{if(t.success){let e=JSON.parse(t.parseResponse);return e.errorCode?n(new Error(e.errorString)):(ma(e),i(e))}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}},vt.postMessage({type:"dcp_parse",id:r,instanceID:this._instanceID,body:{source:t,taskSettingName:e}})})}},CodeParserModule:xa,CoreModule:At,DocumentNormalizerModule:class{static getVersion(){const t=It.ddn&&It.ddn.wasm;return`4.2.20-dev-20251029130608(Worker: ${It.ddn&&It.ddn.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}},DrawingItem:Pi,DrawingStyleManager:Pr,EnumBarcodeFormat:Js,get EnumBufferOverflowProtectionMode(){return a},get EnumCapturedResultItemType(){return Q},get EnumColourChannelUsageType(){return o},get EnumCornerType(){return tt},get EnumCrossVerificationStatus(){return ot},get EnumDeblurMode(){return ea},get EnumDrawingItemMediaType(){return _i},get EnumDrawingItemState(){return vi},get EnumEnhancedFeatures(){return yi},get EnumErrorCode(){return et},get EnumExtendedBarcodeResultType(){return $s},get EnumFilterType(){return xo},get EnumGrayscaleEnhancementMode(){return it},get EnumGrayscaleTransformationMode(){return nt},get EnumImageCaptureDistanceMode(){return ut},get EnumImageColourMode(){return Fa},get EnumImageFileFormat(){return dt},get EnumImagePixelFormat(){return l},get EnumImageSourceState(){return Qt},get EnumImageTagType(){return rt},EnumIntermediateResultUnitType:lt,get EnumLocalizationMode(){return ta},get EnumMappingStatus(){return fa},get EnumModuleName(){return ft},get EnumPDFReadingMode(){return st},get EnumPresetTemplate(){return De},get EnumQRCodeErrorCorrectionLevel(){return Qs},get EnumRasterDataSource(){return at},get EnumRawTextLineStatus(){return ua},get EnumRegionObjectElementType(){return ht},get EnumSectionType(){return ct},get EnumTransformMatrixType(){return gt},get EnumValidationStatus(){return ga},Feedback:Rs,GroupDrawingItem:Xi,ImageDataGetter:Gr,ImageDrawer:class{async drawOnImage(t,e,i,n=4294901760,r=1,s="test.png",a){if(!t)throw new Error("Invalid image.");if(!e)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let o;if(t instanceof Blob)o=await to(t);else if("string"==typeof t){let e=await I(t,"blob");o=await to(e)}else v(t)&&(o=t,"bigint"==typeof o.format&&(o.format=Number(o.format)));return await new Promise((t,l)=>{let h=wt();Et[h]=async e=>{if(e.success)return a&&(new Ro).saveToFile(e.image,s,a),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},vt.postMessage({type:"utility_drawOnImage",id:h,body:{dsImage:o,drawingItem:Array.isArray(e)?e:[e],color:n,thickness:r,type:i}})})}},ImageDrawingItem:class extends Pi{set maintainAspectRatio(t){t&&this.set("scaleY",this.get("scaleX"))}get maintainAspectRatio(){return oi(this,Li,"f")}constructor(t,e,i,n){if(super(null,n),Mi.set(this,void 0),Li.set(this,void 0),!b(e))throw new TypeError("Invalid 'rect'.");if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)this._setFabricObject(new Ei.Image(t,{left:e.x,top:e.y}));else{if(!v(t))throw new TypeError("Invalid 'image'.");{const i=document.createElement("canvas");let n;if(i.width=t.width,i.height=t.height,t.format===l.IPF_GRAYSCALED){n=new Uint8ClampedArray(t.width*t.height*4);for(let e=0;e{let l=wt();Et[l]=async e=>{if(e.success)return t(e.cropImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_cropImage",id:l,body:{type:"Rect",bytes:i,width:n,height:r,stride:s,format:a,roi:e}})})}async adjustBrightness(t,e){if(e>100||e<-100)throw new Error("Invalid brightness, range: [-100, 100].");const{bytes:i,width:n,height:r,stride:s,format:a}=await to(t);return await new Promise((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.adjustBrightness);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_adjustBrightness",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,brightness:e}})})}async adjustContrast(t,e){if(e>100||e<-100)throw new Error("Invalid contrast, range: [-100, 100].");const{bytes:i,width:n,height:r,stride:s,format:a}=await to(t);return await new Promise((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.adjustContrast);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_adjustContrast",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,contrast:e}})})}async filterImage(t,e){if(![0,1,2].includes(e))throw new Error("Invalid filterType.");const{bytes:i,width:n,height:r,stride:s,format:a}=await to(t);return await new Promise((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.filterImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_filterImage",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,filterType:e}})})}async convertToGray(t,e,i,n){const{bytes:r,width:s,height:a,stride:o,format:l}=await to(t);return await new Promise((t,h)=>{let c=wt();Et[c]=async e=>{if(e.success)return t(e.convertToGray);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,h(t)}},vt.postMessage({type:"utility_convertToGray",id:c,body:{bytes:r,width:s,height:a,stride:o,format:l,R:e,G:i,B:n}})})}async convertToBinaryGlobal(t,e=-1,i=!1){const{bytes:n,width:r,height:s,stride:a,format:o}=await to(t);return await new Promise((t,l)=>{let h=wt();Et[h]=async e=>{if(e.success)return t(e.convertToBinaryGlobal);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},vt.postMessage({type:"utility_convertToBinaryGlobal",id:h,body:{bytes:n,width:r,height:s,stride:a,format:o,threshold:e,invert:i}})})}async convertToBinaryLocal(t,e=0,i=0,n=!1){const{bytes:r,width:s,height:a,stride:o,format:l}=await to(t);return await new Promise((t,h)=>{let c=wt();Et[c]=async e=>{if(e.success)return t(e.convertToBinaryLocal);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,h(t)}},vt.postMessage({type:"utility_convertToBinaryLocal",id:c,body:{bytes:r,width:s,height:a,stride:o,format:l,blockSize:e,compensation:i,invert:n}})})}async cropAndDeskewImage(t,e){const{bytes:i,width:n,height:r,stride:s,format:a}=await to(t);return await new Promise((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return t(e.cropAndDeskewImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_cropAndDeskewImage",id:l,body:{bytes:i,width:n,height:r,stride:s,format:a,roi:e}})})}},ImageSourceAdapter:Z,IntermediateResultReceiver:class{constructor(){this._observedResultUnitTypes=lt.IRUT_ALL,this._observedTaskMap=new Map,this._parameters={setObservedResultUnitTypes:t=>{this._observedResultUnitTypes=t},getObservedResultUnitTypes:()=>this._observedResultUnitTypes,isResultUnitTypeObserved:t=>!!(t&this._observedResultUnitTypes),addObservedTask:t=>{this._observedTaskMap.set(t,!0)},removeObservedTask:t=>{this._observedTaskMap.set(t,!1)},isTaskObserved:t=>0===this._observedTaskMap.size||!!this._observedTaskMap.get(t)},this.onTaskResultsReceived=null,this.onPredetectedRegionsReceived=null,this.onColourImageUnitReceived=null,this.onScaledColourImageUnitReceived=null,this.onGrayscaleImageUnitReceived=null,this.onTransformedGrayscaleImageUnitReceived=null,this.onEnhancedGrayscaleImageUnitReceived=null,this.onBinaryImageUnitReceived=null,this.onTextureDetectionResultUnitReceived=null,this.onTextureRemovedGrayscaleImageUnitReceived=null,this.onTextureRemovedBinaryImageUnitReceived=null,this.onContoursUnitReceived=null,this.onLineSegmentsUnitReceived=null,this.onTextZonesUnitReceived=null,this.onTextRemovedBinaryImageUnitReceived=null,this.onShortLinesUnitReceived=null}getObservationParameters(){return this._parameters}},LabelRecognizerModule:ca,LicenseManager:Je,LicenseModule:class{static getVersion(){return`4.2.20-dev-20251029130543(Worker: ${It.license&&It.license.worker||"Not Loaded"}, Wasm: ${It.license&&It.license.wasm||"Not Loaded"})`}},LineDrawingItem:class extends Ui{constructor(t,e){if(super({points:[null==t?void 0:t.startPoint,null==t?void 0:t.endPoint]},e),Yi.set(this,void 0),!E(t))throw new TypeError("Invalid 'line'.");li(this,Yi,JSON.parse(JSON.stringify(t))),this._mediaType="line"}extendSet(t,e){if("startPoint"===t||"endPoint"===t){e="startPoint"===t?[e,this.get("endPoint")]:[this.get("startPoint"),e];const i=this._fabricObject;if(i.group){const t=i.group;i.points=e.map(e=>({x:e.x-t.left-t.width/2,y:e.y-t.top-t.height/2})),t.addWithUpdate()}else i.points=e;const n=i.points.length-1;return i.controls=i.points.reduce(function(t,e,i){return t["p"+i]=new Ei.Control({positionHandler:Ni,actionHandler:Vi(i>0?i-1:n,ji),actionName:"modifyPolygon",pointIndex:i}),t},{}),i._setPositionDimensions({}),!0}}extendGet(t){if("startPoint"===t||"endPoint"===t){const e=[],i=this._fabricObject;if(i.selectable&&!i.group)for(let t in i.oCoords)e.push({x:i.oCoords[t].x,y:i.oCoords[t].y});else for(let t of i.points){let n=t.x-i.pathOffset.x,r=t.y-i.pathOffset.y;const s=Ei.util.transformPoint({x:n,y:r},i.calcTransformMatrix());e.push({x:s.x,y:s.y})}return"startPoint"===t?e[0]:e[1]}}updateCoordinateBaseFromImageToView(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromViewToImage(t.x),y:this.convertPropFromViewToImage(t.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(e.x),y:this.convertPropFromViewToImage(e.y)})}updateCoordinateBaseFromViewToImage(){const t=this.get("startPoint"),e=this.get("endPoint");this.set("startPoint",{x:this.convertPropFromImageToView(t.x),y:this.convertPropFromImageToView(t.y)}),this.set("endPoint",{x:this.convertPropFromImageToView(e.x),y:this.convertPropFromImageToView(e.y)})}setPosition(t){this.setLine(t)}getPosition(){return this.getLine()}updatePosition(){oi(this,Yi,"f")&&this.setLine(oi(this,Yi,"f"))}setPolygon(){}getPolygon(){return null}setLine(t){if(!E(t))throw new TypeError("Invalid 'line'.");if(this._drawingLayer){if("view"===this.coordinateBase)this.set("startPoint",{x:this.convertPropFromViewToImage(t.startPoint.x),y:this.convertPropFromViewToImage(t.startPoint.y)}),this.set("endPoint",{x:this.convertPropFromViewToImage(t.endPoint.x),y:this.convertPropFromViewToImage(t.endPoint.y)});else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("startPoint",t.startPoint),this.set("endPoint",t.endPoint)}this._drawingLayer.renderAll()}else li(this,Yi,JSON.parse(JSON.stringify(t)))}getLine(){if(this._drawingLayer){if("view"===this.coordinateBase)return{startPoint:{x:this.convertPropFromImageToView(this.get("startPoint").x),y:this.convertPropFromImageToView(this.get("startPoint").y)},endPoint:{x:this.convertPropFromImageToView(this.get("endPoint").x),y:this.convertPropFromImageToView(this.get("endPoint").y)}};if("image"===this.coordinateBase)return{startPoint:this.get("startPoint"),endPoint:this.get("endPoint")};throw new Error("Invalid 'coordinateBase'.")}return oi(this,Yi,"f")?JSON.parse(JSON.stringify(oi(this,Yi,"f"))):null}},MultiFrameResultCrossFilter:So,QuadDrawingItem:zi,RectDrawingItem:ki,TextDrawingItem:Wi,UtilityModule:class{static getVersion(){return`2.2.20-dev-20251029130550(Worker: ${It.utility&&It.utility.worker||"Not Loaded"}, Wasm: ${It.utility&&It.utility.wasm||"Not Loaded"})`}},_getNorImageData:L,_saveToFile:O,_toBlob:M,_toCanvas:D,_toImage:A,get bDebug(){return Tt},checkIsLink:t=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(t),compareVersion:x,doOrWaitAsyncDependency:_t,getNextTaskID:wt,handleEngineResourcePaths:R,innerVersions:It,isArc:t=>!(!p(t)||!m(t.x)||!m(t.y)||!m(t.radius)||t.radius<0||!m(t.startAngle)||!m(t.endAngle)),isContour:t=>!!p(t)&&!!g(t.points)&&0!=t.points.length&&!t.points.some(t=>!C(t)),isDSImageData:v,isDSRect:y,isImageTag:w,isLineSegment:E,isObject:p,isOriginalDsImageData:t=>!(!_(t)||!m(t.bytes.length)&&!m(t.bytes.ptr)),isPoint:C,isPolygon:S,isQuad:T,isRect:b,isSimdSupported:async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),mapAsyncDependency:mt,mapPackageRegister:xt,mapTaskCallBack:Et,get onLog(){return Ct},productNameMap:F,requestResource:I,setBDebug:bt,setOnLog:St,utilsFuncs:da,waitAsyncDependency:pt,get worker(){return vt},workerAutoResources:Rt});t.EnumMRZScanMode=void 0,(Oo=t.EnumMRZScanMode||(t.EnumMRZScanMode={})).Passport="passport",Oo.TD1="td1",Oo.TD2="td2",Oo.PassportAndTD1="passportAndTd1",Oo.PassportAndTD2="passportAndTd2",Oo.TD1AndTD2="td1AndTd2",Oo.All="all",t.EnumMRZDocumentType=void 0,(Do=t.EnumMRZDocumentType||(t.EnumMRZDocumentType={})).Passport="passport",Do.TD1="td1",Do.TD2="td2",t.EnumMRZScannerViews=void 0,(Ao=t.EnumMRZScannerViews||(t.EnumMRZScannerViews={})).Scanner="scanner",Ao.Result="scan-result";const Lo={[t.EnumMRZScanMode.Passport]:"ReadPassport",[t.EnumMRZScanMode.TD1]:"ReadId-TD1",[t.EnumMRZScanMode.TD2]:"ReadId-TD2",[t.EnumMRZScanMode.PassportAndTD1]:"ReadPassportAndId-TD1",[t.EnumMRZScanMode.PassportAndTD2]:"ReadPassportAndId-TD2",[t.EnumMRZScanMode.TD1AndTD2]:"ReadId",[t.EnumMRZScanMode.All]:"ReadPassportAndId"};var Fo;function Po(t){if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error("Element not found");return e}return t instanceof HTMLElement?t:null}t.EnumResultStatus=void 0,(Fo=t.EnumResultStatus||(t.EnumResultStatus={}))[Fo.RS_SUCCESS=0]="RS_SUCCESS",Fo[Fo.RS_CANCELLED=1]="RS_CANCELLED",Fo[Fo.RS_FAILED=2]="RS_FAILED";function ko(t,e){if(!document.getElementById(t)){const i=document.createElement("style");i.id=t,i.textContent=e,document.head.appendChild(i)}}const No=t=>!t||0===Object.keys(t).length;function Bo(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}const jo={"4k":{width:3840,height:2160},"2k":{width:2560,height:1440},"1080p":{width:1920,height:1080},"720p":{width:1280,height:720},"480p":{width:640,height:480}};function Vo(t,e={}){const{message:i,spinnerSize:n=32}=e,r=document.createElement("div");r.className="dynamsoft-mrz-loading-screen";const s=document.createElement("div");s.className="dynamsoft-mrz-loading";const a=document.createElement("div");a.className="dynamsoft-mrz-loading-content";const o=`\n \n \n \n `;if(a.innerHTML=o,i){const t=document.createElement("div");t.className="dynamsoft-mrz-loading-message",t.textContent=i,a.appendChild(t)}return s.appendChild(a),r.appendChild(s),t.appendChild(r),{element:r,updateMessage:t=>{let e=s.querySelector(".dynamsoft-mrz-loading-message");null!==t?e?e.textContent=t:(e=document.createElement("div"),e.className="dynamsoft-mrz-loading-message",e.textContent=t,a.appendChild(e)):null==e||e.remove()},hide:()=>{r&&r.parentNode&&(r.classList.add("fade-out"),setTimeout(()=>{var t;null===(t=r.parentNode)||void 0===t||t.removeChild(r)},200))}}}const Uo='\n .dynamsoft-mrz-loading-screen {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #323234;\n z-index: 998;\n opacity: 1;\n transition: opacity 0.2s ease-out;\n }\n\n .dynamsoft-mrz-loading-screen.fade-out {\n opacity: 0;\n }\n\n .dynamsoft-mrz-loading {\n position: absolute;\n left: 50%;\n top: 50%;\n color: white;\n z-index: 999;\n transform: translate(-50%, -50%);\n }\n\n .dynamsoft-mrz-loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n }\n\n .dynamsoft-mrz-loading svg {\n animation: spin 1s linear infinite;\n }\n\n .dynamsoft-mrz-loading-message {\n color: white;\n font-family: "Verdana";\n font-size: 14px;\n text-align: center;\n max-width: 200px;\n line-height: 1.4;\n opacity: 0.9;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n';var Go;t.EnumMRZData=void 0,(Go=t.EnumMRZData||(t.EnumMRZData={})).InvalidFields="invalidFields",Go.DocumentType="documentType",Go.DocumentNumber="documentNumber",Go.MRZText="mrzText",Go.FirstName="firstName",Go.LastName="lastName",Go.Age="age",Go.Sex="sex",Go.IssuingState="issuingState",Go.IssuingStateRaw="issuingStateRaw",Go.Nationality="nationality",Go.NationalityRaw="nationalityRaw",Go.DateOfBirth="dateOfBirth",Go.DateOfExpiry="dateOfExpiry";const Wo={[t.EnumMRZData.InvalidFields]:"Invalid Fields",[t.EnumMRZData.DocumentType]:"Document Type",[t.EnumMRZData.DocumentNumber]:"Document Number",[t.EnumMRZData.MRZText]:"MRZ Text",[t.EnumMRZData.FirstName]:"Given Name(s)",[t.EnumMRZData.LastName]:"Surname",[t.EnumMRZData.Age]:"Age",[t.EnumMRZData.Sex]:"Sex",[t.EnumMRZData.IssuingState]:"Issuing State",[t.EnumMRZData.IssuingStateRaw]:"Issuing State (Raw Value)",[t.EnumMRZData.Nationality]:"Nationality",[t.EnumMRZData.NationalityRaw]:"Nationality State (Raw Value)",[t.EnumMRZData.DateOfBirth]:"Date Of Birth (YYYY-MM-DD)",[t.EnumMRZData.DateOfExpiry]:"Date Of Expiry (YYYY-MM-DD)"};function Yo(t,e,i,n=!1){const r=parseInt(t,10);let s;if(n)s=r>=60?1900+r:2e3+r;else{s=r>(new Date).getFullYear()%100?1900+r:2e3+r}return{year:s,month:parseInt(e,10),day:parseInt(i,10)}}function Ho(t){const e=t=>{var e;return 1===(null===(e=`${t}`)||void 0===e?void 0:e.length)?`0${t}`:t};return`${null==t?void 0:t.year}-${e(null==t?void 0:t.month)}${(null==t?void 0:t.day)&&`-${e(null==t?void 0:t.day)}`}`}function zo(t){return"D<<"===t?"D":t}function Xo(e,i){const n=[],r=t=>i.getFieldValidationStatus(t)===ga.VS_FAILED,s=i.codeType,a=function(e){switch(e){case"MRTD_TD1_ID":return t.EnumMRZDocumentType.TD1;case"MRTD_TD2_ID":case"MRTD_TD2_VISA":case"MRTD_TD2_FRENCH_ID":return t.EnumMRZDocumentType.TD2;case"MRTD_TD3_PASSPORT":case"MRTD_TD3_VISA":return t.EnumMRZDocumentType.Passport;default:throw new Error(`Unknown document type: ${e}`)}}(s),o=function(t){switch(t){case"MRTD_TD1_ID":return"ID (TD1)";case"MRTD_TD2_ID":return"ID (TD2)";case"MRTD_TD2_VISA":return"ID (VISA)";case"MRTD_TD2_FRENCH_ID":return"French ID (TD2)";case"MRTD_TD3_PASSPORT":return"Passport (TD3)";case"MRTD_TD3_VISA":return"Visa (TD3)";default:throw new Error(`Unknown document type: ${t}`)}}(s),l=a===t.EnumMRZDocumentType.Passport&&"MRTD_TD3_PASSPORT"===s?"passportNumber":"documentNumber",h=Yo(i.getFieldValue("birthYear"),i.getFieldValue("birthMonth"),i.getFieldValue("birthDay")),c=Yo(i.getFieldValue("expiryYear"),i.getFieldValue("expiryMonth"),i.getFieldValue("expiryDay"),!0);["birthYear","birthMonth","birthDay"].forEach(e=>{r(e)&&n.push(t.EnumMRZData.DateOfBirth)}),["expiryYear","expiryMonth","expiryDay"].forEach(e=>{r(e)&&n.push(t.EnumMRZData.DateOfExpiry)});const d={[t.EnumMRZData.LastName]:i.getFieldValue("primaryIdentifier"),[t.EnumMRZData.FirstName]:i.getFieldValue("secondaryIdentifier"),[t.EnumMRZData.Nationality]:i.getFieldValue("nationality"),[t.EnumMRZData.NationalityRaw]:zo(i.getFieldRawValue("nationality")),[t.EnumMRZData.DocumentNumber]:i.getFieldValue(l)||i.getFieldValue("longDocumentNumber"),[t.EnumMRZData.IssuingState]:i.getFieldValue("issuingState"),[t.EnumMRZData.IssuingStateRaw]:zo(i.getFieldRawValue("issuingState")),[t.EnumMRZData.Sex]:Bo(i.getFieldValue("sex"))};Object.keys(d).forEach(e=>{let i=!1;switch(e){case t.EnumMRZData.FirstName:i=r("secondaryIdentifier");break;case t.EnumMRZData.LastName:i=r("primaryIdentifier");break;case t.EnumMRZData.DocumentNumber:i=r(l)||r("longDocumentNumber");break;default:i=r(e)}i&&n.push(e)});const u=function(t){const e=new Date,i=e.getMonth()+1>t.month||e.getMonth()+1===t.month&&e.getDate()>=t.day;return e.getFullYear()-t.year-(i?0:1)}(h);u<1&&n.push(t.EnumMRZData.Age);return{[t.EnumMRZData.InvalidFields]:n,[t.EnumMRZData.FirstName]:d[t.EnumMRZData.FirstName],[t.EnumMRZData.LastName]:d[t.EnumMRZData.LastName],[t.EnumMRZData.Age]:u,[t.EnumMRZData.DateOfBirth]:h,[t.EnumMRZData.Sex]:d[t.EnumMRZData.Sex],[t.EnumMRZData.Nationality]:d[t.EnumMRZData.Nationality],[t.EnumMRZData.NationalityRaw]:d[t.EnumMRZData.NationalityRaw],[t.EnumMRZData.DocumentNumber]:d[t.EnumMRZData.DocumentNumber],[t.EnumMRZData.DateOfExpiry]:c,[t.EnumMRZData.IssuingState]:d[t.EnumMRZData.IssuingState],[t.EnumMRZData.IssuingStateRaw]:d[t.EnumMRZData.IssuingStateRaw],[t.EnumMRZData.DocumentType]:Bo(o),[t.EnumMRZData.MRZText]:e}}const Zo={[t.EnumMRZDocumentType.TD1]:{width:85.6,height:53.98},[t.EnumMRZDocumentType.TD2]:{width:105,height:74},[t.EnumMRZDocumentType.Passport]:{width:125,height:88}};class qo{showScannerLoadingOverlay(t){const e=Po(this.config.container);this.loadingScreen=Vo(e,{message:t}),e.style.display="block",e.style.position="relative"}hideScannerLoadingOverlay(t=!1){this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,t&&(Po(this.config.container).style.display="none"))}constructor(e,i){this.resources=e,this.config=i,this.isSoundFeedbackOn=!1,this.scanModeManager={[t.EnumMRZDocumentType.Passport]:!0,[t.EnumMRZDocumentType.TD1]:!0,[t.EnumMRZDocumentType.TD2]:!0},this.currentScanMode=t.EnumMRZScanMode.All,this.resizeTimer=null,this.capturedResultItems=[],this.originalImageData=null,this.initialized=!1,this.initializedDCE=!1,this.DCE_ELEMENTS={selectCameraBtn:null,uploadImageBtn:null,soundFeedbackBtn:null,closeScannerBtn:null,scanModeSelectContainer:null,passportModeOption:null,td1ModeOption:null,td2ModeOption:null,toast:null},this.loadingScreen=null,this.handleResize=()=>{this.toggleScanGuide(!1),this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>{this.toggleScanGuide(!0)},500)},this.firstFrame=!0}async initialize(){if(!this.initialized){this.initializeScanModeManager(),this.currentScanMode=this.getScanMode(),ko("dynamsoft-mrz-loading-screen-style",Uo);try{const{cameraView:t,cameraEnhancer:e,cvRouter:i}=this.resources;if(t.setScanRegionMaskStyle({strokeStyle:"transparent",fillStyle:"transparent",lineWidth:0}),t.setVideoFit("cover"),i.setInput(e),!0===this.config.enableMultiFrameCrossFilter){const t=new So;t.enableResultCrossVerification(Q.CRIT_TEXT_LINE,!0),await i.addResultFilter(t)}const n=new Oe;n.onCapturedResultReceived=t=>this.handleMRZResult(t),await i.addResultReceiver(n),this.toggleSoundFeedback(!1),!1===this.config.showScanGuide&&this.toggleScanGuide(!1),this.initialized=!0}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"Dynamsoft MRZ Scanner initialize error"}};this.currentScanResolver(n)}}}initializeElements(){var t;const e=Po(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))throw new Error("Shadow root not found");if(this.DCE_ELEMENTS={selectCameraBtn:i.shadowRoot.querySelector(".dce-mn-select-camera-icon"),uploadImageBtn:i.shadowRoot.querySelector(".dce-mn-upload-image-icon"),soundFeedbackBtn:i.shadowRoot.querySelector(".dce-mn-sound-feedback"),closeScannerBtn:i.shadowRoot.querySelector(".dce-mn-close"),scanModeSelectContainer:i.shadowRoot.querySelector(".dce-mn-scan-mode-select"),passportModeOption:i.shadowRoot.querySelector(".scan-mode-option-passport"),td1ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td1"),td2ModeOption:i.shadowRoot.querySelector(".scan-mode-option-td2"),toast:i.shadowRoot.querySelector(".dce-mn-toast")},this.setupScanModeSelector(),this.assignDCEClickEvents(),this.DCE_ELEMENTS.toast.style.display="none",!1===this.config.showUploadImage&&(this.DCE_ELEMENTS.uploadImageBtn.style.visibility="hidden"),!1===this.config.showSoundToggle&&(this.DCE_ELEMENTS.soundFeedbackBtn.style.visibility="hidden"),!1===(null===(t=this.config)||void 0===t?void 0:t.showPoweredByDynamsoft)){i.shadowRoot.querySelector(".dce-mn-msg-poweredby").style.display="none"}this.initializedDCE=!0}setupScanModeSelector(){if(!1!==this.config.showFormatSelector)switch(this.currentScanMode){case t.EnumMRZScanMode.PassportAndTD1:this.DCE_ELEMENTS.td2ModeOption.style.display="none";break;case t.EnumMRZScanMode.PassportAndTD2:this.DCE_ELEMENTS.td1ModeOption.style.display="none";break;case t.EnumMRZScanMode.TD1AndTD2:this.DCE_ELEMENTS.passportModeOption.style.display="none";break;case t.EnumMRZScanMode.All:break;default:this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}else this.DCE_ELEMENTS.scanModeSelectContainer.style.display="none"}assignDCEClickEvents(){if(!Object.values(this.DCE_ELEMENTS).every(Boolean))throw new Error("Camera control elements not found");this.closeCamera=this.closeCamera.bind(this),this.DCE_ELEMENTS.uploadImageBtn.onclick=()=>this.uploadFile(),this.DCE_ELEMENTS.soundFeedbackBtn.onclick=()=>this.toggleSoundFeedback(),this.DCE_ELEMENTS.closeScannerBtn.onclick=()=>this.handleCloseBtn(),this.DCE_ELEMENTS.selectCameraBtn.onclick=t=>{t.stopPropagation(),this.toggleSelectCameraBox()},this.DCE_ELEMENTS.passportModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.passportModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.Passport)},this.DCE_ELEMENTS.td1ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td1ModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.TD1)},this.DCE_ELEMENTS.td2ModeOption.onclick=async()=>{"none"!==this.DCE_ELEMENTS.td2ModeOption.style.display&&await this.toggleScanDocType(t.EnumMRZDocumentType.TD2)}}handleCloseBtn(){this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:t.EnumResultStatus.RS_CANCELLED,message:"Cancelled"}})}attachOptionClickListeners(){const t=Po(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings");[...e.shadowRoot.querySelectorAll(".dce-mn-camera-option"),...e.shadowRoot.querySelectorAll(".dce-mn-resolution-option")].forEach(t=>{t.addEventListener("click",async e=>{const n=t.getAttribute("data-davice-id"),r=t.getAttribute("data-height"),s=t.getAttribute("data-width");n?this.resources.cameraEnhancer.selectCamera(n).then(()=>{this.toggleScanGuide()}):r&&s&&this.resources.cameraEnhancer.setResolution({width:parseInt(s),height:parseInt(r)}).then(()=>{this.toggleScanGuide()}),"none"!==i.style.display&&this.toggleSelectCameraBox()})})}highlightCameraAndResolutionOption(){const t=Po(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-camera-and-resolution-settings"),n=i.querySelectorAll(".dce-mn-camera-option"),r=i.querySelectorAll(".dce-mn-resolution-option"),s=this.resources.cameraEnhancer.getSelectedCamera(),a=this.resources.cameraEnhancer.getResolution();n.forEach(t=>{const e=t;e.getAttribute("data-davice-id")===(null==s?void 0:s.deviceId)?e.style.border="2px solid #fe814a":e.style.border="none"});const o={"480p":"480","720p":"720","1080p":"1080","2k":"1440","4k":"2160"},l=function(t){const e=t.width*t.height,i=t.width/t.height;let n="480p",r=Number.MAX_VALUE;for(const[t,s]of Object.entries(jo)){const a=s.width*s.height,o=s.width/s.height,l=.7*Math.abs(a-e)+Math.abs(o-i)*a*.3;l{const e=t,i=e.getAttribute("data-height");e.style.border=i===o[l]?"2px solid #fe814a":"none"})}toggleSelectCameraBox(){const t=Po(this.config.container),e=t.children[t.children.length-1];if(!(null==e?void 0:e.shadowRoot))return;const i=e.shadowRoot.querySelector(".dce-mn-resolution-box");this.highlightCameraAndResolutionOption(),this.attachOptionClickListeners(),i.click()}async relaunch(){}async uploadFile(){var e,i,n,r,s,a;const{cvRouter:o}=this.resources,l=document.createElement("input");l.type="file",l.accept=null!==(e=this.config.uploadAcceptedTypes)&&void 0!==e?e:"image/*",l.style.display="none",document.body.appendChild(l);try{this.showScannerLoadingOverlay("Processing file..."),await this.closeCamera(!1);const e=await new Promise((t,e)=>{l.onchange=i=>{var n;const r=null===(n=i.target.files)||void 0===n?void 0:n[0];r?t(r):e(new Error("No file selected"))},l.addEventListener("cancel",async()=>{this.hideScannerLoadingOverlay(!1),this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()}),l.click()});if(!e)return;let h;if(this.config.uploadFileConverter&&!e.type.startsWith("image/"))try{h=await this.config.uploadFileConverter(e)}catch(t){throw new Error(`Error converting file: ${t.message}`)}else{if(!e.type.startsWith("image/"))throw new Error("Unsupported file type. Please provide a converter function for this file type.");h=e}const c=this.config.utilizedTemplateNames[this.currentScanMode];if(!1!==this.config.showScanGuide){const t=await o.getSimplifiedSettings(c);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await o.updateSettings(c,t)}const d=await o.capture(h,c);this.capturedResultItems=d.items;const u=this.capturedResultItems.filter(t=>t.type===Q.CRIT_ORIGINAL_IMAGE);if(0===u.length)throw new Error("No image data found in the captured result");const f=u[0].imageData;f.toCanvas=()=>D(f),f.toBlob=async()=>await M("image/png",f),this.originalImageData=f;const g=null===(i=null==d?void 0:d.parsedResult)||void 0===i?void 0:i.parsedResultItems;let m={};if(null==g?void 0:g.length){const t=(null===(r=null===(n=g[0])||void 0===n?void 0:n.referenceItem)||void 0===r?void 0:r.text)||"";m=Xo(t,g[0])}const p={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:m,imageData:!0,_imageData:this.originalImageData};null===(a=(s=this.resources).onResultUpdated)||void 0===a||a.call(s,p),this.currentScanResolver(p)}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:`Error processing file: ${i}`}};this.currentScanResolver(n)}finally{this.hideScannerLoadingOverlay(!0),document.body.removeChild(l)}}toggleSoundFeedback(t){this.isSoundFeedbackOn=void 0!==t?t:!this.isSoundFeedbackOn;const e=Po(this.config.container),i=e.children[e.children.length-1];if(!(null==i?void 0:i.shadowRoot))return;const n=i.shadowRoot.querySelector(".dce-mn-sound-feedback"),r=n.querySelector(".dce-mn-sound-feedback-on");n.querySelector(".dce-mn-sound-feedback-off").style.display=this.isSoundFeedbackOn?"none":"block",r.style.display=this.isSoundFeedbackOn?"block":"none"}calculateScanRegion(t){const{cameraEnhancer:e,cameraView:i}=this.resources;if(!e||!e.isOpen())return;const n=Zo[t].width/Zo[t].height;let r;const s=i.getVisibleRegionOfVideo({inPixels:!0}),{width:a,height:o}=s;if(s){if(s.width>s.height){const t=.5*o*n,e=Math.round(t/a*100),i=(100-e)/2;r={left:i,right:i+e,top:25,bottom:75,isMeasuredInPercentage:!0}}else{const t=.9*a/n,e=Math.round(t/o*100),i=(100-e)/2;r={left:5,right:95,top:i,bottom:i+e,isMeasuredInPercentage:!0}}null==i||i.setScanRegionMaskVisible(!0),e.setScanRegion(r)}}toggleScanGuide(e){const i=Po(this.config.container),n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))return;const r=n.shadowRoot.querySelector(".dce-scanguide-passport"),s=n.shadowRoot.querySelector(".dce-scanguide-td1"),a=n.shadowRoot.querySelector(".dce-scanguide-td2");if(!1===e||!1===this.config.showScanGuide)return r.style.display="none",s.style.display="none",void(a.style.display="none");switch(this.currentScanMode){case t.EnumMRZScanMode.All:case t.EnumMRZScanMode.Passport:case t.EnumMRZScanMode.PassportAndTD1:case t.EnumMRZScanMode.PassportAndTD2:r.style.display="block",s.style.display="none",a.style.display="none",this.calculateScanRegion(t.EnumMRZDocumentType.Passport);break;case t.EnumMRZScanMode.TD1:case t.EnumMRZScanMode.TD1AndTD2:r.style.display="none",s.style.display="block",a.style.display="none",this.calculateScanRegion(t.EnumMRZDocumentType.TD1);break;case t.EnumMRZScanMode.TD2:r.style.display="none",s.style.display="none",a.style.display="block",this.calculateScanRegion(t.EnumMRZDocumentType.TD2)}}async openCamera(){try{const{cameraEnhancer:t,cameraView:e}=this.resources,i=Po(this.config.container);if(i.style.display="block",t.isOpen())t.isPaused()&&await t.resume();else{const n=e.getUIElement();n.parentElement||i.append(n),await t.open()}await t.setResolution({width:2560,height:1440}),!this.initializedDCE&&t.isOpen()&&await this.initializeElements(),window.addEventListener("resize",this.handleResize);const n=i.children[i.children.length-1];if(!(null==n?void 0:n.shadowRoot))throw new Error("Shadow root not found");n.shadowRoot.querySelector(".dce-mn-torch-off").style.display="none",n.shadowRoot.querySelector(".dce-mn-torch-on").style.display="none"}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner Open Camera Error"}};this.currentScanResolver(n)}}async closeCamera(t=!0){try{window.removeEventListener("resize",this.handleResize),this.resizeTimer&&(window.clearTimeout(this.resizeTimer),this.resizeTimer=null);const{cameraEnhancer:e,cameraView:i}=this.resources,n=Po(this.config.container);n.style.display=t?"none":"block",(null==i?void 0:i.getUIElement().parentElement)&&n.removeChild(i.getUIElement()),e.close(),this.stopCapturing()}catch(t){let e=(null==t?void 0:t.message)||t;console.error(`Close Camera error: ${e}`)}}pauseCamera(){const{cameraEnhancer:t}=this.resources;t.pause()}stopCapturing(){const{cameraView:t,cvRouter:e}=this.resources;e.stopCapturing(),t.clearAllInnerDrawingItems()}async handleMRZResult(e){var i,n,r;if(this.firstFrame)this.firstFrame=!1;else if(!(e.items.length<=1)){this.capturedResultItems=e.items;try{const{onResultUpdated:s}=this.resources,a=e.items.filter(t=>t.type===Q.CRIT_ORIGINAL_IMAGE)[0].imageData;a.toCanvas=()=>D(a),a.toBlob=async()=>await M("image/png",a),this.originalImageData=a;const o=null===(i=null==e?void 0:e.parsedResult)||void 0===i?void 0:i.parsedResultItems;if(null==o?void 0:o.length){this.isSoundFeedbackOn&&Rs.beep();const e=(null===(r=null===(n=o[0])||void 0===n?void 0:n.referenceItem)||void 0===r?void 0:r.text)||"",i=Xo(e,o[0]);this.closeCamera();const a={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:this.originalImageData,data:i,imageData:!0,_imageData:this.originalImageData};null==s||s(a),this.currentScanResolver(a)}}catch(e){let i=(null==e?void 0:e.message)||e;console.error(i),alert(i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"Error capturing image"}};this.currentScanResolver(n)}}}initializeScanModeManager(){const{mrzFormatType:e}=this.config;if(this.scanModeManager={[t.EnumMRZDocumentType.Passport]:!0,[t.EnumMRZDocumentType.TD1]:!0,[t.EnumMRZDocumentType.TD2]:!0},!e||Array.isArray(e)&&0===e.length)return;Object.keys(this.scanModeManager).forEach(t=>{this.scanModeManager[t]=!1});(Array.isArray(e)?e:[e]).forEach(t=>{this.scanModeManager[t]=!0})}getScanMode(){const e=Object.entries(this.scanModeManager).filter(([t,e])=>e).map(([t])=>t).sort().join(",");return{[t.EnumMRZDocumentType.Passport]:t.EnumMRZScanMode.Passport,[t.EnumMRZDocumentType.TD1]:t.EnumMRZScanMode.TD1,[t.EnumMRZDocumentType.TD2]:t.EnumMRZScanMode.TD2,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD1}`]:t.EnumMRZScanMode.PassportAndTD1,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.PassportAndTD2,[`${t.EnumMRZDocumentType.TD1},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.TD1AndTD2,[`${t.EnumMRZDocumentType.Passport},${t.EnumMRZDocumentType.TD1},${t.EnumMRZDocumentType.TD2}`]:t.EnumMRZScanMode.All,"":t.EnumMRZScanMode.All}[e]}DCEShowToast(t,e=3e3){this.DCE_ELEMENTS.toast&&(this.DCE_ELEMENTS.toast.textContent=t,this.DCE_ELEMENTS.toast.style.display="",setTimeout(()=>{this.DCE_ELEMENTS.toast.style.display="none"},e))}async startCapturing(){const{cvRouter:e,cameraEnhancer:i}=this.resources,n=this.config.utilizedTemplateNames[this.currentScanMode];try{if(!1!==this.config.showScanGuide){const t=await e.getSimplifiedSettings(n);t.roiMeasuredInPercentage=!0,t.roi.points=[{x:0,y:50},{x:100,y:50},{x:100,y:100},{x:0,y:100}],await e.updateSettings(n,t)}this.firstFrame=!0,await e.startCapturing(n),i.setPixelFormat(l.IPF_ABGR_8888)}catch(e){let i=(null==e?void 0:e.message)||e;console.error("Failed to start capturing:",i),this.closeCamera(),this.currentScanResolver&&this.currentScanResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:"Failed to start capturing"}})}}async toggleScanDocType(e){try{if(this.scanModeManager[e]&&0===Object.entries(this.scanModeManager).filter(([t,i])=>i&&t!==e).length)return console.warn("MRZ Scanner - At least one mode must be enabled"),void this.DCEShowToast("At least one mode must be enabled");this.scanModeManager[e]=!this.scanModeManager[e],this.currentScanMode=this.getScanMode(),this.stopCapturing(),this.toggleScanGuide(),await this.startCapturing(),this.DCE_ELEMENTS.td1ModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.TD1]),this.DCE_ELEMENTS.td2ModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.TD2]),this.DCE_ELEMENTS.passportModeOption.classList.toggle("selected",this.scanModeManager[t.EnumMRZDocumentType.Passport])}catch(e){let i=(null==e?void 0:e.message)||e;console.error("MRZ Scanner switch scan mode error: ",i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner switch scan mode error"}};this.currentScanResolver(n)}}async launch(){try{await this.initialize();const{cvRouter:t,cameraEnhancer:e}=this.resources;return new Promise(async t=>{this.currentScanResolver=t,this.showScannerLoadingOverlay("Initializing camera..."),await this.openCamera(),!this.initializedDCE&&e.isOpen()&&await this.initializeElements(),this.toggleScanGuide(),await this.startCapturing(),this.hideScannerLoadingOverlay()})}catch(e){let i=(null==e?void 0:e.message)||e;console.error("MRZ Scanner launch error: ",i),this.closeCamera();const n={status:{code:t.EnumResultStatus.RS_FAILED,message:"MRZ Scanner launch error"}};this.currentScanResolver(n)}}}const Ko={cancel:'\n\n \n \n \n \n \n \n \n \n \n \n ',rescan:'\n\n\n \n \n \n\n \n \n \n \n',complete:'\n\n\n\n \n \n \n\n \n \n \n \n',failed:'\n \n \n \n \n',info:'\n\n \n \n \n \n'};class Jo{constructor(t,e,i){this.resources=t,this.config=e,this.scannerView=i,this.editedFields={}}async launch(){try{return Po(this.config.container).textContent="",await this.initialize(),Po(this.config.container).style.display="flex",new Promise(t=>{this.currentScanResultViewResolver=t})}catch(t){let e=(null==t?void 0:t.message)||t;throw console.error(e),e}}async handleRescan(){var e;try{if(!this.scannerView)return void console.error("Scanner View not initialized");this.hideView();const i=await this.scannerView.launch();if((null===(e=null==i?void 0:i.status)||void 0===e?void 0:e.code)===t.EnumResultStatus.RS_FAILED)return void(this.currentScanResultViewResolver&&this.currentScanResultViewResolver(i));this.resources.onResultUpdated&&((null==i?void 0:i.status.code)===t.EnumResultStatus.RS_CANCELLED?this.resources.onResultUpdated(this.resources.result):(null==i?void 0:i.status.code)===t.EnumResultStatus.RS_SUCCESS&&this.resources.onResultUpdated(i)),this.dispose(!0),await this.initialize(),Po(this.config.container).style.display="flex"}catch(e){throw console.error("Error in rescan handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleCancel(){var e;try{(null===(e=this.config)||void 0===e?void 0:e.onCancel)&&await this.config.onCancel(this.resources.result),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_CANCELLED,message:"Upload file cancelled"}}),this.hideView(),this.dispose()}catch(e){throw console.error("Error in cancel handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}async handleDone(){var e,i;try{(null===(e=this.resources.result)||void 0===e?void 0:e.data)&&!No(this.editedFields)&&(this.resources.result.data=Object.assign(Object.assign({},this.resources.result.data),this.editedFields),this.resources.onResultUpdated&&this.resources.onResultUpdated(this.resources.result)),(null===(i=this.config)||void 0===i?void 0:i.onDone)&&await this.config.onDone(this.resources.result),this.currentScanResultViewResolver&&this.resources.result&&this.currentScanResultViewResolver(this.resources.result),this.hideView(),this.dispose()}catch(e){throw console.error("Error in done handler:",e),this.currentScanResultViewResolver&&this.currentScanResultViewResolver({status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}),e}}createControls(){var t,e,i,n,r,s,a,o,l,h,c,d;const{toolbarButtonsConfig:u}=this.config;return function(t){ko("dynamsoft-mrz-controls-style","\n .dynamsoft-mrz-controls {\n display: flex;\n height: 6rem;\n background-color: #323234;\n align-items: center;\n font-size: 12px;\n font-family: Verdana;\n color: white;\n width: 100%;\n }\n\n .dynamsoft-mrz-control-btn {\n background-color: #323234;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n gap: 0.5rem;\n text-align: center;\n user-select: none;\n }\n\n .dynamsoft-mrz-control-btn.hide {\n display: none;\n }\n\n .dynamsoft-mrz-control-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n cursor: default;\n }\n\n .dynamsoft-mrz-control-icon-wrapper {\n flex: 0.75;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n min-height: 40px;\n }\n\n .dynamsoft-mrz-control-icon img,\n .dynamsoft-mrz-control-icon svg {\n width: 32px;\n height: 32px;\n fill: #fe8e14;\n }\n\n .dynamsoft-mrz-control-text {\n flex: 0.5;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-bottom: 0.5rem;\n }\n\n \n @media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-controls {\n flex-direction: column;\n height: 100%;\n width: 5rem;\n }\n\n .dynamsoft-mrz-control-text {\n padding: 0 0.5rem 0.5rem;\n }\n }\n");const e=document.createElement("div");return e.className="dynamsoft-mrz-controls",t.forEach(t=>{const i=document.createElement("div");i.className=`dynamsoft-mrz-control-btn ${null==t?void 0:t.className}`;const n=document.createElement("div");if(n.className="dynamsoft-mrz-control-icon-wrapper",(r=t.icon).trim().startsWith(""))n.innerHTML=t.icon;else{const e=document.createElement("img");e.src=t.icon,e.alt=t.label,e.width=24,e.height=24,n.appendChild(e)}var r;const s=document.createElement("div");s.className="dynamsoft-mrz-control-text",s.textContent=t.label,t.isDisabled&&i.classList.add("disabled"),t.isHidden&&i.classList.add("hide"),i.appendChild(n),i.appendChild(s),t.onClick&&!t.isDisabled&&i.addEventListener("click",t.onClick),e.appendChild(i)}),e}([this.config._isFileMode?{id:"dynamsoft-mrz-scanResult-cancel",icon:(null===(t=null==u?void 0:u.cancel)||void 0===t?void 0:t.icon)||Ko.cancel,label:(null===(e=null==u?void 0:u.cancel)||void 0===e?void 0:e.label)||"Cancel",onClick:()=>this.handleCancel(),className:`${(null===(i=null==u?void 0:u.cancel)||void 0===i?void 0:i.className)||""}`,isHidden:(null===(n=null==u?void 0:u.cancel)||void 0===n?void 0:n.isHidden)||!1}:{id:"dynamsoft-mrz-scanResult-rescan",icon:(null===(r=null==u?void 0:u.rescan)||void 0===r?void 0:r.icon)||Ko.rescan,label:(null===(s=null==u?void 0:u.rescan)||void 0===s?void 0:s.label)||"Re-scan",onClick:()=>this.handleRescan(),className:`${(null===(a=null==u?void 0:u.rescan)||void 0===a?void 0:a.className)||""}`,isHidden:(null===(o=null==u?void 0:u.rescan)||void 0===o?void 0:o.isHidden)||!1,isDisabled:!this.scannerView},{id:"dynamsoft-mrz-scanResult-done",icon:(null===(l=null==u?void 0:u.done)||void 0===l?void 0:l.icon)||Ko.complete,label:(null===(h=null==u?void 0:u.done)||void 0===h?void 0:h.label)||"Done",className:`${(null===(c=null==u?void 0:u.done)||void 0===c?void 0:c.className)||""}`,isHidden:(null===(d=null==u?void 0:u.done)||void 0===d?void 0:d.isHidden)||!1,onClick:()=>this.handleDone()}])}handleFieldEdit(e,i){if(e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry)try{const[t,n,r]=i.split(/[\/\-\.]/);r&&n&&t&&(this.editedFields[e]={day:parseInt(r,10),month:parseInt(n,10),year:parseInt(t,10)})}catch(t){console.error("Error parsing date",t)}else this.editedFields[e]=i}createMRZDataDisplay(){var e,i,n,r;const s=(null===(e=this.resources.result)||void 0===e?void 0:e.data)||{},a=!!this.config.allowResultEditing,o=s.invalidFields||[],l=[t.EnumMRZData.InvalidFields,t.EnumMRZData.IssuingStateRaw,t.EnumMRZData.NationalityRaw];!1===(null===(i=this.config)||void 0===i?void 0:i.showMRZText)&&l.push(t.EnumMRZData.MRZText);const h=document.createElement("div");if(h.className="dynamsoft-mrz-data-container",No(s)){const t=document.createElement("div");return t.className="dynamsoft-mrz-data-row empty",t.innerText=null!==(r=null===(n=this.config)||void 0===n?void 0:n.emptyResultMessage)&&void 0!==r?r:"The necessary information could not be detected. Please try again.",h.appendChild(t),h}if(o.length>0){const t=document.createElement("div");t.className="dynamsoft-mrz-error-notification",t.innerHTML=`\n ${Ko.failed}
\n \n ${a?"Some fields require correction. Please review highlighted fields.":"Some fields contain invalid information. Please rescan the document."}\n
\n `,h.appendChild(t)}else if(0===o.length&&a){const t=document.createElement("div");t.className="dynamsoft-mrz-info-notification",t.innerHTML=`\n ${Ko.info}
\n \n Please review all fields to ensure the information is correct.\n
\n `,h.appendChild(t)}return Object.entries(s).forEach(([e,i])=>{if(l.includes(e)||!i)return;const n=document.createElement("div");n.className="dynamsoft-mrz-data-row";const r=o.includes(e);r&&n.classList.add("invalid-field");const s=[t.EnumMRZData.MRZText,t.EnumMRZData.DocumentType,t.EnumMRZData.IssuingStateRaw,t.EnumMRZData.NationalityRaw],c=document.createElement("span");if(c.className="dynamsoft-mrz-data-label",c.innerText=Wo[e]||e,r){const t=document.createElement("span");if(t.className="dynamsoft-mrz-error-icon",t.innerHTML=Ko.failed,c.appendChild(t),a){const t=document.createElement("span");t.className="dynamsoft-mrz-error-hint",t.textContent="Please correct this field",c.appendChild(t)}}const d=document.createElement("div");if(d.className="dynamsoft-mrz-data-value",a&&!s.includes(e)){const s=document.createElement("input");s.className="dynamsoft-mrz-data-input",r&&s.classList.add("invalid"),e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry?(s.value=Ho(i),s.setAttribute("placeholder","YYYY-MM-DD")):s.value=i,s.addEventListener("input",t=>{if(this.handleFieldEdit(e,t.target.value),r){s.classList.remove("invalid"),n.classList.remove("invalid-field"),this.editedFields.invalidFields||(this.editedFields.invalidFields=[...o]);const t=this.editedFields.invalidFields.indexOf(e);t>-1&&this.editedFields.invalidFields.splice(t,1)}}),d.appendChild(s)}else e===t.EnumMRZData.MRZText?(d.classList.add("code"),d.innerText=i):e===t.EnumMRZData.DateOfBirth||e===t.EnumMRZData.DateOfExpiry?d.innerText=Ho(i):d.innerText=i,r&&d.classList.add("invalid-value");n.appendChild(c),n.appendChild(d),h.appendChild(n)}),h}async initialize(){try{if(!this.resources.result)throw Error("Captured image is missing. Please capture an image first!");if(!this.config.container)throw new Error("Please create a Scan Result View Container element");ko("dynamsoft-mrz-result-view-style",$o);const t=document.createElement("div");if(t.className="dynamsoft-mrz-result-view-container",!1!==this.config.showOriginalImage){const e=this.resources.result.originalImageResult,i=document.createElement("div");let n;i.className="dynamsoft-mrz-result-view-image-container",(null==e?void 0:e.toCanvas)&&(n=null==e?void 0:e.toCanvas()),Object.assign(n.style,{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}),i.appendChild(n),t.appendChild(i)}const e=this.createMRZDataDisplay();t.appendChild(e);const i=this.createControls();t.appendChild(i),Po(this.config.container).appendChild(t)}catch(t){let e=(null==t?void 0:t.message)||t;console.error(e),alert(e)}}hideView(){Po(this.config.container).style.display="none"}dispose(t=!1){Po(this.config.container).textContent="",t||(this.currentScanResultViewResolver=void 0)}}const $o="\n .dynamsoft-mrz-result-view-container {\n display: flex;\n width: 100%;\n height: 100%;\n background-color:#575757;\n font-size: 12px;\n flex-direction: column;\n align-items: center;\n }\n\n .dynamsoft-mrz-result-view-image-container {\n width: 100%;\n height: 200px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: #323234;\n }\n\n \n.dynamsoft-mrz-data-container {\n font-size: 16px;\n font-family: Verdana;\n color: white;\n overflow: auto;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 1rem 0;\n}\n\n.dynamsoft-mrz-data-row {\n padding: 0.5rem 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n transition: background-color 0.3s ease;\n}\n\n.dynamsoft-mrz-data-row.invalid-field {\n background-color: rgba(231, 76, 60, 0.1);\n border-left: 3px solid #e74c3c;\n padding-left: calc(2rem - 3px);\n}\n\n.dynamsoft-mrz-data-label {\n color: #aaa;\n display: flex;\n gap: 0.5rem;\n align-items: end;\n flex-wrap: wrap;\n}\n\n.dynamsoft-mrz-error-notification,\n.dynamsoft-mrz-info-notification {\n color: white;\n padding: 1rem;\n margin: 0.5rem 2rem;\n border-radius: 4px;\n display: flex;\n align-items: center;\n gap: 1rem;\n text-align: start;\n}\n\n.dynamsoft-mrz-error-notification {\n background-color: rgba(231, 76, 60, 0.2);\n}\n\n.dynamsoft-mrz-info-notification {\n background-color: #fe8e14;\n}\n\n.dynamsoft-mrz-edit-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #aaa;\n}\n\n.dynamsoft-mrz-error-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-info-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.dynamsoft-mrz-info-message,\n.dynamsoft-mrz-error-message {\n flex: 1;\n}\n\n.dynamsoft-mrz-error-hint {\n font-size: 0.8rem;\n color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-value {\n word-wrap: break-word;\n text-align: start;\n}\n\n.dynamsoft-mrz-data-value.code {\n font-family: monospace;\n}\n\n.dynamsoft-mrz-data-value.invalid-value {\n color: #e74c3c;\n text-decoration: wavy underline #e74c3c;\n text-decoration-skip-ink: none;\n}\n\n.dynamsoft-mrz-data-input {\n width: 100%;\n padding: 5px;\n background-color: rgba(255, 255, 255, 0.1);\n border: 1px solid rgba(255, 255, 255, 0.3);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n transition: all 0.3s ease;\n}\n\n.dynamsoft-mrz-data-input.invalid {\n background-color: rgba(231, 76, 60, 0.1);\n border-color: #e74c3c;\n}\n\n.dynamsoft-mrz-data-input:focus {\n background-color: rgba(255, 255, 255, 0.2);\n border-color: #fe8e14;\n outline: none;\n}\n\n@media screen and (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {\n .dynamsoft-mrz-result-view-container {\n flex-direction: row;\n }\n\n .dynamsoft-mrz-result-view-image-container{\n flex: 1;\n height: 100%;\n }\n\n .dynamsoft-mrz-data-container{\n flex: 1;\n }\n\n .dynamsoft-mrz-data-row:first-of-type {\n padding-top: 2rem;\n }\n\n .dynamsoft-mrz-data-row:last-of-type {\n padding-bottom: 2rem;\n }\n\n .dynamsoft-mrz-data-row.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding-top: 0;\n padding-bottom: 0;\n }\n}\n",Qo={rootDirectory:"https://cdn.jsdelivr.net/npm/"};class tl{showLoadingOverlay(t){var e,i;const n=Po(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Po(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen=Vo(n,{message:t}),n.style.display="block",n.style.position="relative"}hideLoadingOverlay(t=!1){var e,i,n;const r=Po(null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.container)||Po(null===(i=this.config.resultViewConfig)||void 0===i?void 0:i.container);this.loadingScreen&&(this.loadingScreen.hide(),this.loadingScreen=null,r.style.display="none",t&&(null===(n=this.config)||void 0===n?void 0:n.container)&&(Po(this.config.container).style.display="none"))}constructor(t){this.config=t,this.resources={},this.isInitialized=!1,this.isCapturing=!1,this.loadingScreen=null,this.isDynamsoftResourcesLoaded=!1,this.isFileMode=!1,this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources()}async initialize(){if(this.isInitialized)return{resources:this.resources,components:{scannerView:this.scannerView,resultView:this.resultView}};try{if(!this.initializeMRZScannerConfig())return console.error("Failed to initialize mrz scanner config"),{resources:this.resources,components:{}};ko("dynamsoft-mrz-loading-screen-style",Uo),this.showLoadingOverlay("Loading..."),await this.initializeDCVResources(),this.resources.onResultUpdated=t=>{this.resources.result=t};const t={};return!this.isFileMode&&this.config.scannerViewConfig&&(this.scannerView=new qo(this.resources,this.config.scannerViewConfig),t.scannerView=this.scannerView,await this.scannerView.initialize()),this.config.resultViewConfig&&(this.resultView=new Jo(this.resources,this.config.resultViewConfig,this.scannerView),t.resultView=this.resultView),this.isInitialized=!0,{resources:this.resources,components:t}}catch(t){this.isInitialized=!1;const e=`Initialization Failed: ${(null==t?void 0:t.message)||t}`;throw console.error(e),new Error(e)}finally{this.hideLoadingOverlay(!0)}}initializeDynamsoftResources(){var t;At.engineResourcePaths=No(null===(t=this.config)||void 0===t?void 0:t.engineResourcePaths)?Qo:this.config.engineResourcePaths,At.loadWasm(),xa.loadSpec("MRTD_TD3_PASSPORT"),xa.loadSpec("MRTD_TD3_VISA"),xa.loadSpec("MRTD_TD1_ID"),xa.loadSpec("MRTD_TD2_ID"),xa.loadSpec("MRTD_TD2_VISA"),this.isDynamsoftResourcesLoaded=!0}async initializeDCVResources(){var t,e,i,n;try{this.isDynamsoftResourcesLoaded||this.initializeDynamsoftResources(),Je._onAuthMessage=t=>t.replace("(https://www.dynamsoft.com/customer/license/trialLicense?product=unknown&deploymenttype=unknown)","(https://www.dynamsoft.com/customer/license/trialLicense?product=mrz&deploymenttype=web)"),await Je.initLicense((null===(t=this.config)||void 0===t?void 0:t.license)||"",{executeNow:!0}),this.isFileMode||(this.resources.cameraView=await Ur.createInstance((null===(e=this.config.scannerViewConfig)||void 0===e?void 0:e.uiPath)||(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.cameraEnhancerUIPath)),this.resources.cameraEnhancer=await Fs.createInstance(this.resources.cameraView)),this.resources.cvRouter=await Re.createInstance(),await this.resources.cvRouter.initSettings(this.config.templateFilePath)}catch(t){let e="string"==typeof t?t:null!==(n=null==t?void 0:t.message)&&void 0!==n?n:"object"==typeof t?JSON.stringify(t):String(t);const i=(null==e?void 0:e.toLowerCase().includes("license"))?"The MRZ Scanner license is invalid or has expired. Please contact the site administrator to resolve this issue.":`Resource Initialization Failed: ${e}`;throw console.error(i),new Error(i)}}shouldCreateDefaultContainer(){var t,e;const i=!this.config.container,n=!((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)||(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container));return i&&n}createDefaultMRZScannerContainer(){const t=document.createElement("div");return t.className="mrz-scanner-main-container",Object.assign(t.style,{height:"100dvh",width:"100%",position:"absolute",left:"0",top:"0",zIndex:"999"}),document.body.append(t),t}checkForTemporaryLicense(t){return!(null==t?void 0:t.length)||(null==t?void 0:t.startsWith("A"))||(null==t?void 0:t.startsWith("L"))||(null==t?void 0:t.startsWith("P"))||(null==t?void 0:t.startsWith("Y"))?"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9":t}validateViewConfigs(){var t,e,i,n,r,s,a,o;if(!this.config.container){if((null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container)&&this.config.showResultView&&!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container)){const t="MRZResultView container is required when showResultView is true";return alert(t),console.error(t),!1}if(!(null===(i=this.config.scannerViewConfig)||void 0===i?void 0:i.container)&&(null===(n=this.config.resultViewConfig)||void 0===n?void 0:n.container)&&!this.resources.result){const t="Result is needed to create MRZResultView without a scanner view";return alert(t),console.error(t),!1}}try{if(this.config.container&&!Po(this.config.container)){const t="Invalid main container reference";return alert(t),console.error(t),!1}if((null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.container)&&!Po(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.container)){const t="Invalid scanner view container reference";return alert(t),console.error(t),!1}if((null===(a=this.config.resultViewConfig)||void 0===a?void 0:a.container)&&!Po(null===(o=this.config.resultViewConfig)||void 0===o?void 0:o.container)){const t="Invalid result view container reference";return alert(t),console.error(t),!1}}catch(t){const e=`Error accessing container references: ${t.message}`;return alert(e),console.error(e),!1}return!0}showResultView(){var t,e;return!1!==this.config.showResultView&&(this.config.container?!(void 0!==this.config.showResultView||!(null===(t=this.config.resultViewConfig)||void 0===t?void 0:t.container)&&!this.config.container)||!!this.config.showResultView:this.config.showResultView&&!!(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container))}initializeMRZScannerConfig(){var e,i,n,r,s,a,o,l;this.config=null!==(e=this.config)&&void 0!==e?e:{};if(!this.validateViewConfigs())return!1;this.shouldCreateDefaultContainer()?this.config.container=this.createDefaultMRZScannerContainer():this.config.container&&(this.config.container=Po(this.config.container));const h=this.config.container?this.createViewContainers(Po(this.config.container)):{},c={license:this.checkForTemporaryLicense(this.config.license),utilizedTemplateNames:Object.fromEntries(Object.values(t.EnumMRZScanMode).map(t=>{var e;return[t,(null===(e=this.config.utilizedTemplateNames)||void 0===e?void 0:e[t])||Lo[t]]})),templateFilePath:(null===(i=this.config)||void 0===i?void 0:i.templateFilePath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.5-beta-202601070001/dist/mrz-scanner.template.json"},d=Object.assign(Object.assign({},this.config.scannerViewConfig),{container:h[t.EnumMRZScannerViews.Scanner]||Po(null===(n=this.config.scannerViewConfig)||void 0===n?void 0:n.container)||null,cameraEnhancerUIPath:(null===(r=this.config.scannerViewConfig)||void 0===r?void 0:r.uiPath)||(null===(s=this.config.scannerViewConfig)||void 0===s?void 0:s.cameraEnhancerUIPath)||"https://cdn.jsdelivr.net/npm/dynamsoft-mrz-scanner@3.0.5-beta-202601070001/dist/mrz-scanner.ui.html",templateFilePath:c.templateFilePath,utilizedTemplateNames:c.utilizedTemplateNames,enableMultiFrameCrossFilter:null===(o=null===(a=this.config.scannerViewConfig)||void 0===a?void 0:a.enableMultiFrameCrossFilter)||void 0===o||o,mrzFormatType:this.config.mrzFormatType}),u=this.showResultView()?Object.assign(Object.assign({},this.config.resultViewConfig),{_isFileMode:this.isFileMode,container:h[t.EnumMRZScannerViews.Result]||Po(null===(l=this.config.resultViewConfig)||void 0===l?void 0:l.container)||null}):void 0;return Object.assign(this.config,Object.assign(Object.assign({},c),{scannerViewConfig:d,resultViewConfig:u})),!0}createViewContainers(e){e.textContent="";const i=[t.EnumMRZScannerViews.Scanner];return this.showResultView()&&i.push(t.EnumMRZScannerViews.Result),i.reduce((t,i)=>{const n=document.createElement("div");return n.className=`mrz-scanner-${i}-view-container`,Object.assign(n.style,{height:"100%",width:"100%",display:"none",position:"relative"}),e.append(n),t[i]=n,t},{})}dispose(){var t,e;this.resultView&&(this.resultView.dispose(),this.resultView=null),this.scannerView=null,this.resources.cameraEnhancer&&(this.resources.cameraEnhancer.dispose(),this.resources.cameraEnhancer=null),this.resources.cameraView&&(this.resources.cameraView.dispose(),this.resources.cameraView=null),this.resources.cvRouter&&(this.resources.cvRouter.dispose(),this.resources.cvRouter=null),this.resources.result=null,this.resources.onResultUpdated=null;const i=t=>{const e=Po(t);e&&(e.style.display="none",e.textContent="")};i(this.config.container),i(null===(t=this.config.scannerViewConfig)||void 0===t?void 0:t.container),i(null===(e=this.config.resultViewConfig)||void 0===e?void 0:e.container),this.isInitialized=!1}async processUploadedFile(e){var i,n,r,s,a,o;try{this.showLoadingOverlay("Processing File...");const{cvRouter:l}=this.resources,h=null===(i=this.config.utilizedTemplateNames)||void 0===i?void 0:i.all,c=await l.getSimplifiedSettings(h);c.roiMeasuredInPercentage=!0,c.roi.points=[{x:0,y:0},{x:100,y:0},{x:100,y:100},{x:0,y:100}],await l.updateSettings(h,c);const d=await l.capture(e,h),u=d.items,f=u.filter(t=>t.type===Q.CRIT_ORIGINAL_IMAGE)[0].imageData;f.toCanvas=()=>D(f),f.toBlob=async()=>await M("image/png",f);const g=null===(n=null==d?void 0:d.parsedResult)||void 0===n?void 0:n.parsedResultItems;let m={};if(null==g?void 0:g.length){const t=(null===(s=null===(r=g[0])||void 0===r?void 0:r.referenceItem)||void 0===s?void 0:s.text)||"";m=Xo(t,g[0])}const p={status:{code:t.EnumResultStatus.RS_SUCCESS,message:"Success"},originalImageResult:f,data:m,imageData:!0,_imageData:f};null===(o=(a=this.resources).onResultUpdated)||void 0===o||o.call(a,p)}catch(e){return console.error("Failed to process uploaded file:",e),{status:{code:t.EnumResultStatus.RS_FAILED,message:`Failed to process image: ${e.message||e}`}}}finally{this.hideLoadingOverlay(!1)}}async launch(e){if(this.isCapturing)throw new Error("Capture session already in progress");try{this.isCapturing=!0,this.isFileMode=!!e;const{components:i}=await this.initialize();if(this.config.container&&(Po(this.config.container).style.display="block"),this.isFileMode)return await this.processUploadedFile(e),i.resultView?await i.resultView.launch():this.resources.result;if(!i.scannerView&&this.resources.result)return i.resultView?await i.resultView.launch():this.resources.result;if(!i.scannerView)throw new Error("Scanner view is required when no previous result exists");const n=await i.scannerView.launch();return(null==n?void 0:n.status.code)!==t.EnumResultStatus.RS_SUCCESS?{status:{code:null==n?void 0:n.status.code,message:(null==n?void 0:n.status.message)||"Failed to capture image"}}:i.resultView?await i.resultView.launch():this.resources.result}catch(e){return alert((null==e?void 0:e.message)||e),console.error((null==e?void 0:e.message)||e),{status:{code:t.EnumResultStatus.RS_FAILED,message:(null==e?void 0:e.message)||e}}}finally{this.isCapturing=!1,this.dispose()}}}const el={MRZScanner:tl,MRZScannerView:qo,MRZResultView:Jo};t.DEFAULT_TEMPLATE_NAMES=Lo,t.Dynamsoft=Mo,t.DynamsoftMRZScanner=el,t.MRZDataLabel=Wo,t.MRZResultView=Jo,t.MRZScanner=tl,t.MRZScannerView=qo,t.displayMRZDate=Ho});
diff --git a/dist/mrz-scanner.bundle.mjs b/dist/mrz-scanner.bundle.mjs
index eec5a9c..0a694e3 100644
--- a/dist/mrz-scanner.bundle.mjs
+++ b/dist/mrz-scanner.bundle.mjs
@@ -1 +1 @@
-const t=t=>t&&"object"==typeof t&&"function"==typeof t.then,e=(async()=>{})().constructor;let i=class extends e{get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(i){let n;this._task=i,t(i)?n=i:"function"==typeof i&&(n=new e(i)),n&&(async()=>{try{const t=await n;i===this._task&&this.resolve(t)}catch(t){i===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}constructor(e){let i,n;super((t,e)=>{i=t,n=e}),this._s="pending",this.resolve=e=>{this.isPending&&(t(e)?this.task=e:(this._s="fulfilled",i(e)))},this.reject=t=>{this.isPending&&(this._s="rejected",n(t))},this.task=e}};function n(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function r(t,e,i,n,r){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}var s,a,o;"function"==typeof SuppressedError&&SuppressedError,function(t){t[t.BOPM_BLOCK=0]="BOPM_BLOCK",t[t.BOPM_UPDATE=1]="BOPM_UPDATE"}(s||(s={})),function(t){t[t.CCUT_AUTO=0]="CCUT_AUTO",t[t.CCUT_FULL_CHANNEL=1]="CCUT_FULL_CHANNEL",t[t.CCUT_Y_CHANNEL_ONLY=2]="CCUT_Y_CHANNEL_ONLY",t[t.CCUT_RGB_R_CHANNEL_ONLY=3]="CCUT_RGB_R_CHANNEL_ONLY",t[t.CCUT_RGB_G_CHANNEL_ONLY=4]="CCUT_RGB_G_CHANNEL_ONLY",t[t.CCUT_RGB_B_CHANNEL_ONLY=5]="CCUT_RGB_B_CHANNEL_ONLY"}(a||(a={})),function(t){t[t.IPF_BINARY=0]="IPF_BINARY",t[t.IPF_BINARYINVERTED=1]="IPF_BINARYINVERTED",t[t.IPF_GRAYSCALED=2]="IPF_GRAYSCALED",t[t.IPF_NV21=3]="IPF_NV21",t[t.IPF_RGB_565=4]="IPF_RGB_565",t[t.IPF_RGB_555=5]="IPF_RGB_555",t[t.IPF_RGB_888=6]="IPF_RGB_888",t[t.IPF_ARGB_8888=7]="IPF_ARGB_8888",t[t.IPF_RGB_161616=8]="IPF_RGB_161616",t[t.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",t[t.IPF_ABGR_8888=10]="IPF_ABGR_8888",t[t.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",t[t.IPF_BGR_888=12]="IPF_BGR_888",t[t.IPF_BINARY_8=13]="IPF_BINARY_8",t[t.IPF_NV12=14]="IPF_NV12",t[t.IPF_BINARY_8_INVERTED=15]="IPF_BINARY_8_INVERTED"}(o||(o={}));const l="undefined"==typeof self,h="function"==typeof importScripts,c=(()=>{if(!h){if(!l&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),d=t=>{if(null==t&&(t="./"),l||h);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t},u=t=>Object.prototype.toString.call(t),f=t=>Array.isArray?Array.isArray(t):"[object Array]"===u(t),g=t=>"number"==typeof t&&!Number.isNaN(t),m=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),p=t=>!(!m(t)||!g(t.x)||!g(t.y)||!g(t.radius)||t.radius<0||!g(t.startAngle)||!g(t.endAngle)),_=t=>!!m(t)&&!!f(t.points)&&0!=t.points.length&&!t.points.some(t=>!T(t)),v=t=>!(!m(t)||!g(t.width)||t.width<=0||!g(t.height)||t.height<=0||!g(t.stride)||t.stride<=0||!("format"in t)||"tag"in t&&!E(t.tag)),y=t=>!(!v(t)||!g(t.bytes.length)&&!g(t.bytes.ptr)),w=t=>!!v(t)&&t.bytes instanceof Uint8Array,C=t=>!(!m(t)||!g(t.left)||t.left<0||!g(t.top)||t.top<0||!g(t.right)||t.right<0||!g(t.bottom)||t.bottom<0||t.left>=t.right||t.top>=t.bottom),E=t=>null===t||!!m(t)&&!!g(t.imageId)&&"type"in t,S=t=>!(!m(t)||!T(t.startPoint)||!T(t.endPoint)||t.startPoint.x==t.endPoint.x&&t.startPoint.y==t.endPoint.y),T=t=>!!m(t)&&!!g(t.x)&&!!g(t.y),b=t=>!!m(t)&&!!f(t.points)&&0!=t.points.length&&!t.points.some(t=>!T(t)),I=t=>!!m(t)&&!!f(t.points)&&0!=t.points.length&&4==t.points.length&&!t.points.some(t=>!T(t)),x=t=>!(!m(t)||!g(t.x)||!g(t.y)||!g(t.width)||t.width<0||!g(t.height)||t.height<0),R=async(t,e)=>await new Promise((i,n)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,r.send(),r.onloadend=async()=>{r.status<200||r.status>=300?n(new Error(t+" "+r.status)):i(r.response)},r.onerror=()=>{n(new Error("Network Error: "+r.statusText))}}),O=t=>/^(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)|^[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})(\.[a-zA-Z0-9]{2,})?/.test(t),A=(t,e)=>{let i=t.split("."),n=e.split(".");for(let t=0;t{const e={};for(let i in t){if("rootDirectory"===i)continue;let n=i,r=t[n],s=r&&"object"==typeof r&&r.path?r.path:r,a=t.rootDirectory;if(a&&!a.endsWith("/")&&(a+="/"),"object"==typeof r&&r.isInternal)a&&(s=t[n].version?`${a}${B[n]}@${t[n].version}/${"dcvData"===n?"":"dist/"}${"ddv"===n?"engine":""}`:`${a}${B[n]}/${"dcvData"===n?"":"dist/"}${"ddv"===n?"engine":""}`);else{const i=/^@engineRootDirectory(\/?)/;if("string"==typeof s&&(s=s.replace(i,a||"")),"object"==typeof s&&"dwt"===n){const r=t[n].resourcesPath,s=t[n].serviceInstallerLocation;e[n]={resourcesPath:r.replace(i,a||""),serviceInstallerLocation:s.replace(i,a||"")};continue}}e[n]=d(s)}return e},M=async(t,e,i)=>await new Promise(async(n,r)=>{try{const r=e.split(".");let s=r[r.length-1];const a=await P(`image/${s}`,t);r.length<=1&&(s="png");const o=new File([a],e,{type:`image/${s}`});if(i){const t=URL.createObjectURL(o),i=document.createElement("a");i.href=t,i.download=e,i.click()}return n(o)}catch(t){return r()}}),L=t=>{w(t)&&(t=k(t));const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d",{willReadFrequently:!0}).putImageData(t,0,0),e},F=(t,e)=>{w(e)&&(e=k(e));const i=L(e);let n=new Image,r=i.toDataURL(t);return n.src=r,n},P=async(t,e)=>{w(e)&&(e=k(e));const i=L(e);return new Promise((e,n)=>{i.toBlob(t=>e(t),t)})},k=t=>{let e,i=t.bytes;if(!(i&&i instanceof Uint8Array))throw Error("Parameter type error");if(Number(t.format)===o.IPF_BGR_888){const t=i.length/3;e=new Uint8ClampedArray(4*t);for(let n=0;n=r)break;e[a]=e[a+1]=e[a+2]=(128&n)/128*255,e[a+3]=255,n<<=1}}}else if(Number(t.format)===o.IPF_ABGR_8888){const t=i.length/4;e=new Uint8ClampedArray(i.length);for(let n=0;n=r)break;e[a]=e[a+1]=e[a+2]=128&n?0:255,e[a+3]=255,n<<=1}}}return new ImageData(e,t.width,t.height)},N=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),B={std:"dynamsoft-capture-vision-std",dip:"dynamsoft-image-processing",core:"dynamsoft-core",dnn:"dynamsoft-capture-vision-dnn",license:"dynamsoft-license",utility:"dynamsoft-utility",cvr:"dynamsoft-capture-vision-router",dbr:"dynamsoft-barcode-reader",dlr:"dynamsoft-label-recognizer",ddn:"dynamsoft-document-normalizer",dcp:"dynamsoft-code-parser",dcvData:"dynamsoft-capture-vision-data",dce:"dynamsoft-camera-enhancer",ddv:"dynamsoft-document-viewer",dwt:"dwt",dbrBundle:"dynamsoft-barcode-reader-bundle",dcvBundle:"dynamsoft-capture-vision-bundle"};var j,V,U,G,W,Y,H,z;let X,q,Z,K,J,$=class t{get _isFetchingStarted(){return n(this,W,"f")}constructor(){j.add(this),V.set(this,[]),U.set(this,1),G.set(this,s.BOPM_BLOCK),W.set(this,!1),Y.set(this,void 0),H.set(this,a.CCUT_AUTO)}setErrorListener(t){}addImageToBuffer(t){var e;if(!w(t))throw new TypeError("Invalid 'image'.");if((null===(e=t.tag)||void 0===e?void 0:e.hasOwnProperty("imageId"))&&"number"==typeof t.tag.imageId&&this.hasImage(t.tag.imageId))throw new Error("Existed imageId.");if(n(this,V,"f").length>=n(this,U,"f"))switch(n(this,G,"f")){case s.BOPM_BLOCK:break;case s.BOPM_UPDATE:if(n(this,V,"f").push(t),m(n(this,Y,"f"))&&g(n(this,Y,"f").imageId)&&1==n(this,Y,"f").keepInBuffer)for(;n(this,V,"f").length>n(this,U,"f");){const t=n(this,V,"f").findIndex(t=>{var e;return(null===(e=t.tag)||void 0===e?void 0:e.imageId)!==n(this,Y,"f").imageId});n(this,V,"f").splice(t,1)}else n(this,V,"f").splice(0,n(this,V,"f").length-n(this,U,"f"))}else n(this,V,"f").push(t)}getImage(){if(0===n(this,V,"f").length)return null;let e;if(n(this,Y,"f")&&g(n(this,Y,"f").imageId)){const t=n(this,j,"m",z).call(this,n(this,Y,"f").imageId);if(t<0)throw new Error(`Image with id ${n(this,Y,"f").imageId} doesn't exist.`);e=n(this,V,"f").slice(t,t+1)[0]}else e=n(this,V,"f").pop();if([o.IPF_RGB_565,o.IPF_RGB_555,o.IPF_RGB_888,o.IPF_ARGB_8888,o.IPF_RGB_161616,o.IPF_ARGB_16161616,o.IPF_ABGR_8888,o.IPF_ABGR_16161616,o.IPF_BGR_888].includes(e.format)){if(n(this,H,"f")===a.CCUT_RGB_R_CHANNEL_ONLY){t._onLog&&t._onLog("only get R channel data.");const i=new Uint8Array(e.width*e.height);for(let t=0;t0!==t.length&&t.every(t=>g(t)))(t))throw new TypeError("Invalid 'imageId'.");if(void 0!==e&&"[object Boolean]"!==u(e))throw new TypeError("Invalid 'keepInBuffer'.");r(this,Y,{imageId:t,keepInBuffer:e})}_resetNextReturnedImage(){r(this,Y,null)}hasImage(t){return n(this,j,"m",z).call(this,t)>=0}startFetching(){r(this,W,!0)}stopFetching(){r(this,W,!1)}setMaxImageCount(t){if("number"!=typeof t)throw new TypeError("Invalid 'count'.");if(t<1||Math.round(t)!==t)throw new Error("Invalid 'count'.");for(r(this,U,t);n(this,V,"f")&&n(this,V,"f").length>t;)n(this,V,"f").shift()}getMaxImageCount(){return n(this,U,"f")}getImageCount(){return n(this,V,"f").length}clearBuffer(){n(this,V,"f").length=0}isBufferEmpty(){return 0===n(this,V,"f").length}setBufferOverflowProtectionMode(t){r(this,G,t)}getBufferOverflowProtectionMode(){return n(this,G,"f")}setColourChannelUsageType(t){r(this,H,t)}getColourChannelUsageType(){return n(this,H,"f")}};V=new WeakMap,U=new WeakMap,G=new WeakMap,W=new WeakMap,Y=new WeakMap,H=new WeakMap,j=new WeakSet,z=function(t){if("number"!=typeof t)throw new TypeError("Invalid 'imageId'.");return n(this,V,"f").findIndex(e=>{var i;return(null===(i=e.tag)||void 0===i?void 0:i.imageId)===t})},"undefined"!=typeof navigator&&(X=navigator,q=X.userAgent,Z=X.platform,K=X.mediaDevices),function(){if(!l){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:X.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},e={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:Z,search:"Win"},Mac:{str:Z},Linux:{str:Z}};let i="unknownBrowser",n=0,r="unknownOS";for(let e in t){const r=t[e]||{};let s=r.str||q,a=r.search||e,o=r.verStr||q,l=r.verSearch||e;if(l instanceof Array||(l=[l]),-1!=s.indexOf(a)){i=e;for(let t of l){let e=o.indexOf(t);if(-1!=e){n=parseFloat(o.substring(e+t.length+1));break}}break}}for(let t in e){const i=e[t]||{};let n=i.str||q,s=i.search||t;if(-1!=n.indexOf(s)){r=t;break}}"Linux"==r&&-1!=q.indexOf("Windows NT")&&(r="HarmonyOS"),J={browser:i,version:n,OS:r}}l&&(J={browser:"ssr",version:0,OS:"ssr"})}();const Q="undefined"!=typeof WebAssembly&&q&&!(/Safari/.test(q)&&!/Chrome/.test(q)&&/\(.+\s11_2_([2-6]).*\)/.test(q)),tt=!("undefined"==typeof Worker),et=!(!K||!K.getUserMedia),it=async()=>{let t=!1;if(et)try{(await K.getUserMedia({video:!0})).getTracks().forEach(t=>{t.stop()}),t=!0}catch(t){}return t};var nt,rt,st,at,ot,lt,ht,ct,dt;"Chrome"===J.browser&&J.version>66||"Safari"===J.browser&&J.version>13||"OPR"===J.browser&&J.version>43||"Edge"===J.browser&&J.version,function(t){t[t.CRIT_ORIGINAL_IMAGE=1]="CRIT_ORIGINAL_IMAGE",t[t.CRIT_BARCODE=2]="CRIT_BARCODE",t[t.CRIT_TEXT_LINE=4]="CRIT_TEXT_LINE",t[t.CRIT_DETECTED_QUAD=8]="CRIT_DETECTED_QUAD",t[t.CRIT_DESKEWED_IMAGE=16]="CRIT_DESKEWED_IMAGE",t[t.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT",t[t.CRIT_ENHANCED_IMAGE=64]="CRIT_ENHANCED_IMAGE"}(nt||(nt={})),function(t){t[t.CT_NORMAL_INTERSECTED=0]="CT_NORMAL_INTERSECTED",t[t.CT_T_INTERSECTED=1]="CT_T_INTERSECTED",t[t.CT_CROSS_INTERSECTED=2]="CT_CROSS_INTERSECTED",t[t.CT_NOT_INTERSECTED=3]="CT_NOT_INTERSECTED"}(rt||(rt={})),function(t){t[t.EC_OK=0]="EC_OK",t[t.EC_UNKNOWN=-1e4]="EC_UNKNOWN",t[t.EC_NO_MEMORY=-10001]="EC_NO_MEMORY",t[t.EC_NULL_POINTER=-10002]="EC_NULL_POINTER",t[t.EC_LICENSE_INVALID=-10003]="EC_LICENSE_INVALID",t[t.EC_LICENSE_EXPIRED=-10004]="EC_LICENSE_EXPIRED",t[t.EC_FILE_NOT_FOUND=-10005]="EC_FILE_NOT_FOUND",t[t.EC_FILE_TYPE_NOT_SUPPORTED=-10006]="EC_FILE_TYPE_NOT_SUPPORTED",t[t.EC_BPP_NOT_SUPPORTED=-10007]="EC_BPP_NOT_SUPPORTED",t[t.EC_INDEX_INVALID=-10008]="EC_INDEX_INVALID",t[t.EC_CUSTOM_REGION_INVALID=-10010]="EC_CUSTOM_REGION_INVALID",t[t.EC_IMAGE_READ_FAILED=-10012]="EC_IMAGE_READ_FAILED",t[t.EC_TIFF_READ_FAILED=-10013]="EC_TIFF_READ_FAILED",t[t.EC_DIB_BUFFER_INVALID=-10018]="EC_DIB_BUFFER_INVALID",t[t.EC_PDF_READ_FAILED=-10021]="EC_PDF_READ_FAILED",t[t.EC_PDF_DLL_MISSING=-10022]="EC_PDF_DLL_MISSING",t[t.EC_PAGE_NUMBER_INVALID=-10023]="EC_PAGE_NUMBER_INVALID",t[t.EC_CUSTOM_SIZE_INVALID=-10024]="EC_CUSTOM_SIZE_INVALID",t[t.EC_TIMEOUT=-10026]="EC_TIMEOUT",t[t.EC_JSON_PARSE_FAILED=-10030]="EC_JSON_PARSE_FAILED",t[t.EC_JSON_TYPE_INVALID=-10031]="EC_JSON_TYPE_INVALID",t[t.EC_JSON_KEY_INVALID=-10032]="EC_JSON_KEY_INVALID",t[t.EC_JSON_VALUE_INVALID=-10033]="EC_JSON_VALUE_INVALID",t[t.EC_JSON_NAME_KEY_MISSING=-10034]="EC_JSON_NAME_KEY_MISSING",t[t.EC_JSON_NAME_VALUE_DUPLICATED=-10035]="EC_JSON_NAME_VALUE_DUPLICATED",t[t.EC_TEMPLATE_NAME_INVALID=-10036]="EC_TEMPLATE_NAME_INVALID",t[t.EC_JSON_NAME_REFERENCE_INVALID=-10037]="EC_JSON_NAME_REFERENCE_INVALID",t[t.EC_PARAMETER_VALUE_INVALID=-10038]="EC_PARAMETER_VALUE_INVALID",t[t.EC_DOMAIN_NOT_MATCH=-10039]="EC_DOMAIN_NOT_MATCH",t[t.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",t[t.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",t[t.EC_GET_MODE_ARGUMENT_ERROR=-10055]="EC_GET_MODE_ARGUMENT_ERROR",t[t.EC_IRT_LICENSE_INVALID=-10056]="EC_IRT_LICENSE_INVALID",t[t.EC_FILE_SAVE_FAILED=-10058]="EC_FILE_SAVE_FAILED",t[t.EC_STAGE_TYPE_INVALID=-10059]="EC_STAGE_TYPE_INVALID",t[t.EC_IMAGE_ORIENTATION_INVALID=-10060]="EC_IMAGE_ORIENTATION_INVALID",t[t.EC_CONVERT_COMPLEX_TEMPLATE_ERROR=-10061]="EC_CONVERT_COMPLEX_TEMPLATE_ERROR",t[t.EC_CALL_REJECTED_WHEN_CAPTURING=-10062]="EC_CALL_REJECTED_WHEN_CAPTURING",t[t.EC_NO_IMAGE_SOURCE=-10063]="EC_NO_IMAGE_SOURCE",t[t.EC_READ_DIRECTORY_FAILED=-10064]="EC_READ_DIRECTORY_FAILED",t[t.EC_MODULE_NOT_FOUND=-10065]="EC_MODULE_NOT_FOUND",t[t.EC_MULTI_PAGES_NOT_SUPPORTED=-10066]="EC_MULTI_PAGES_NOT_SUPPORTED",t[t.EC_FILE_ALREADY_EXISTS=-10067]="EC_FILE_ALREADY_EXISTS",t[t.EC_CREATE_FILE_FAILED=-10068]="EC_CREATE_FILE_FAILED",t[t.EC_IMGAE_DATA_INVALID=-10069]="EC_IMGAE_DATA_INVALID",t[t.EC_IMAGE_SIZE_NOT_MATCH=-10070]="EC_IMAGE_SIZE_NOT_MATCH",t[t.EC_IMAGE_PIXEL_FORMAT_NOT_MATCH=-10071]="EC_IMAGE_PIXEL_FORMAT_NOT_MATCH",t[t.EC_SECTION_LEVEL_RESULT_IRREPLACEABLE=-10072]="EC_SECTION_LEVEL_RESULT_IRREPLACEABLE",t[t.EC_AXIS_DEFINITION_INCORRECT=-10073]="EC_AXIS_DEFINITION_INCORRECT",t[t.EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE=-10074]="EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE",t[t.EC_PDF_LIBRARY_LOAD_FAILED=-10075]="EC_PDF_LIBRARY_LOAD_FAILED",t[t.EC_UNSUPPORTED_JSON_KEY_WARNING=-10077]="EC_UNSUPPORTED_JSON_KEY_WARNING",t[t.EC_MODEL_FILE_NOT_FOUND=-10078]="EC_MODEL_FILE_NOT_FOUND",t[t.EC_PDF_LICENSE_NOT_FOUND=-10079]="EC_PDF_LICENSE_NOT_FOUND",t[t.EC_RECT_INVALID=-10080]="EC_RECT_INVALID",t[t.EC_TEMPLATE_VERSION_INCOMPATIBLE=-10081]="EC_TEMPLATE_VERSION_INCOMPATIBLE",t[t.EC_NO_LICENSE=-2e4]="EC_NO_LICENSE",t[t.EC_LICENSE_BUFFER_FAILED=-20002]="EC_LICENSE_BUFFER_FAILED",t[t.EC_LICENSE_SYNC_FAILED=-20003]="EC_LICENSE_SYNC_FAILED",t[t.EC_DEVICE_NOT_MATCH=-20004]="EC_DEVICE_NOT_MATCH",t[t.EC_BIND_DEVICE_FAILED=-20005]="EC_BIND_DEVICE_FAILED",t[t.EC_INSTANCE_COUNT_OVER_LIMIT=-20008]="EC_INSTANCE_COUNT_OVER_LIMIT",t[t.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",t[t.EC_LICENSE_VERSION_NOT_MATCH=-20011]="EC_LICENSE_VERSION_NOT_MATCH",t[t.EC_LICENSE_CACHE_USED=-20012]="EC_LICENSE_CACHE_USED",t[t.EC_LICENSE_AUTH_QUOTA_EXCEEDED=-20013]="EC_LICENSE_AUTH_QUOTA_EXCEEDED",t[t.EC_LICENSE_RESULTS_LIMIT_EXCEEDED=-20014]="EC_LICENSE_RESULTS_LIMIT_EXCEEDED",t[t.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",t[t.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",t[t.EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT=-40101]="EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT",t[t.EC_TEXT_LINE_GROUP_REGEX_CONFLICT=-40102]="EC_TEXT_LINE_GROUP_REGEX_CONFLICT",t[t.EC_QUADRILATERAL_INVALID=-50057]="EC_QUADRILATERAL_INVALID",t[t.EC_PANORAMA_LICENSE_INVALID=-70060]="EC_PANORAMA_LICENSE_INVALID",t[t.EC_RESOURCE_PATH_NOT_EXIST=-90001]="EC_RESOURCE_PATH_NOT_EXIST",t[t.EC_RESOURCE_LOAD_FAILED=-90002]="EC_RESOURCE_LOAD_FAILED",t[t.EC_CODE_SPECIFICATION_NOT_FOUND=-90003]="EC_CODE_SPECIFICATION_NOT_FOUND",t[t.EC_FULL_CODE_EMPTY=-90004]="EC_FULL_CODE_EMPTY",t[t.EC_FULL_CODE_PREPROCESS_FAILED=-90005]="EC_FULL_CODE_PREPROCESS_FAILED",t[t.EC_LICENSE_WARNING=-10076]="EC_LICENSE_WARNING",t[t.EC_BARCODE_READER_LICENSE_NOT_FOUND=-30063]="EC_BARCODE_READER_LICENSE_NOT_FOUND",t[t.EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND=-40103]="EC_LABEL_RECOGNIZER_LICENSE_NOT_FOUND",t[t.EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND=-50058]="EC_DOCUMENT_NORMALIZER_LICENSE_NOT_FOUND",t[t.EC_CODE_PARSER_LICENSE_NOT_FOUND=-90012]="EC_CODE_PARSER_LICENSE_NOT_FOUND"}(st||(st={})),function(t){t[t.GEM_SKIP=0]="GEM_SKIP",t[t.GEM_AUTO=1]="GEM_AUTO",t[t.GEM_GENERAL=2]="GEM_GENERAL",t[t.GEM_GRAY_EQUALIZE=4]="GEM_GRAY_EQUALIZE",t[t.GEM_GRAY_SMOOTH=8]="GEM_GRAY_SMOOTH",t[t.GEM_SHARPEN_SMOOTH=16]="GEM_SHARPEN_SMOOTH",t[t.GEM_REV=-2147483648]="GEM_REV",t[t.GEM_END=-1]="GEM_END"}(at||(at={})),function(t){t[t.GTM_SKIP=0]="GTM_SKIP",t[t.GTM_INVERTED=1]="GTM_INVERTED",t[t.GTM_ORIGINAL=2]="GTM_ORIGINAL",t[t.GTM_AUTO=4]="GTM_AUTO",t[t.GTM_REV=-2147483648]="GTM_REV",t[t.GTM_END=-1]="GTM_END"}(ot||(ot={})),function(t){t[t.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",t[t.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(lt||(lt={})),function(t){t[t.PDFRM_VECTOR=1]="PDFRM_VECTOR",t[t.PDFRM_RASTER=2]="PDFRM_RASTER",t[t.PDFRM_REV=-2147483648]="PDFRM_REV"}(ht||(ht={})),function(t){t[t.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",t[t.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(ct||(ct={})),function(t){t[t.CVS_NOT_VERIFIED=0]="CVS_NOT_VERIFIED",t[t.CVS_PASSED=1]="CVS_PASSED",t[t.CVS_FAILED=2]="CVS_FAILED"}(dt||(dt={}));const ut={IRUT_NULL:BigInt(0),IRUT_COLOUR_IMAGE:BigInt(1),IRUT_SCALED_COLOUR_IMAGE:BigInt(2),IRUT_GRAYSCALE_IMAGE:BigInt(4),IRUT_TRANSOFORMED_GRAYSCALE_IMAGE:BigInt(8),IRUT_ENHANCED_GRAYSCALE_IMAGE:BigInt(16),IRUT_PREDETECTED_REGIONS:BigInt(32),IRUT_BINARY_IMAGE:BigInt(64),IRUT_TEXTURE_DETECTION_RESULT:BigInt(128),IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE:BigInt(256),IRUT_TEXTURE_REMOVED_BINARY_IMAGE:BigInt(512),IRUT_CONTOURS:BigInt(1024),IRUT_LINE_SEGMENTS:BigInt(2048),IRUT_TEXT_ZONES:BigInt(4096),IRUT_TEXT_REMOVED_BINARY_IMAGE:BigInt(8192),IRUT_CANDIDATE_BARCODE_ZONES:BigInt(16384),IRUT_LOCALIZED_BARCODES:BigInt(32768),IRUT_SCALED_BARCODE_IMAGE:BigInt(65536),IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE:BigInt(1<<17),IRUT_COMPLEMENTED_BARCODE_IMAGE:BigInt(1<<18),IRUT_DECODED_BARCODES:BigInt(1<<19),IRUT_LONG_LINES:BigInt(1<<20),IRUT_CORNERS:BigInt(1<<21),IRUT_CANDIDATE_QUAD_EDGES:BigInt(1<<22),IRUT_DETECTED_QUADS:BigInt(1<<23),IRUT_LOCALIZED_TEXT_LINES:BigInt(1<<24),IRUT_RECOGNIZED_TEXT_LINES:BigInt(1<<25),IRUT_DESKEWED_IMAGE:BigInt(1<<26),IRUT_SHORT_LINES:BigInt(1<<27),IRUT_RAW_TEXT_LINES:BigInt(1<<28),IRUT_LOGIC_LINES:BigInt(1<<29),IRUT_ENHANCED_IMAGE:BigInt(Math.pow(2,30)),IRUT_ALL:BigInt("0xFFFFFFFFFFFFFFFF")};var ft,gt,mt,pt,_t,vt;!function(t){t[t.ROET_PREDETECTED_REGION=0]="ROET_PREDETECTED_REGION",t[t.ROET_LOCALIZED_BARCODE=1]="ROET_LOCALIZED_BARCODE",t[t.ROET_DECODED_BARCODE=2]="ROET_DECODED_BARCODE",t[t.ROET_LOCALIZED_TEXT_LINE=3]="ROET_LOCALIZED_TEXT_LINE",t[t.ROET_RECOGNIZED_TEXT_LINE=4]="ROET_RECOGNIZED_TEXT_LINE",t[t.ROET_DETECTED_QUAD=5]="ROET_DETECTED_QUAD",t[t.ROET_DESKEWED_IMAGE=6]="ROET_DESKEWED_IMAGE",t[t.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",t[t.ROET_TARGET_ROI=8]="ROET_TARGET_ROI",t[t.ROET_ENHANCED_IMAGE=9]="ROET_ENHANCED_IMAGE"}(ft||(ft={})),function(t){t[t.ST_NULL=0]="ST_NULL",t[t.ST_REGION_PREDETECTION=1]="ST_REGION_PREDETECTION",t[t.ST_BARCODE_LOCALIZATION=2]="ST_BARCODE_LOCALIZATION",t[t.ST_BARCODE_DECODING=3]="ST_BARCODE_DECODING",t[t.ST_TEXT_LINE_LOCALIZATION=4]="ST_TEXT_LINE_LOCALIZATION",t[t.ST_TEXT_LINE_RECOGNITION=5]="ST_TEXT_LINE_RECOGNITION",t[t.ST_DOCUMENT_DETECTION=6]="ST_DOCUMENT_DETECTION",t[t.ST_DOCUMENT_DESKEWING=7]="ST_DOCUMENT_DESKEWING",t[t.ST_IMAGE_ENHANCEMENT=8]="ST_IMAGE_ENHANCEMENT"}(gt||(gt={})),function(t){t[t.IFF_JPEG=0]="IFF_JPEG",t[t.IFF_PNG=1]="IFF_PNG",t[t.IFF_BMP=2]="IFF_BMP",t[t.IFF_PDF=3]="IFF_PDF"}(mt||(mt={})),function(t){t[t.ICDM_NEAR=0]="ICDM_NEAR",t[t.ICDM_FAR=1]="ICDM_FAR"}(pt||(pt={})),function(t){t.MN_DYNAMSOFT_CAPTURE_VISION_ROUTER="cvr",t.MN_DYNAMSOFT_CORE="core",t.MN_DYNAMSOFT_LICENSE="license",t.MN_DYNAMSOFT_IMAGE_PROCESSING="dip",t.MN_DYNAMSOFT_UTILITY="utility",t.MN_DYNAMSOFT_BARCODE_READER="dbr",t.MN_DYNAMSOFT_DOCUMENT_NORMALIZER="ddn",t.MN_DYNAMSOFT_LABEL_RECOGNIZER="dlr",t.MN_DYNAMSOFT_CAPTURE_VISION_DATA="dcvData",t.MN_DYNAMSOFT_NEURAL_NETWORK="dnn",t.MN_DYNAMSOFT_CODE_PARSER="dcp",t.MN_DYNAMSOFT_CAMERA_ENHANCER="dce",t.MN_DYNAMSOFT_CAPTURE_VISION_STD="std"}(_t||(_t={})),function(t){t[t.TMT_LOCAL_TO_ORIGINAL_IMAGE=0]="TMT_LOCAL_TO_ORIGINAL_IMAGE",t[t.TMT_ORIGINAL_TO_LOCAL_IMAGE=1]="TMT_ORIGINAL_TO_LOCAL_IMAGE",t[t.TMT_LOCAL_TO_SECTION_IMAGE=2]="TMT_LOCAL_TO_SECTION_IMAGE",t[t.TMT_SECTION_TO_LOCAL_IMAGE=3]="TMT_SECTION_TO_LOCAL_IMAGE"}(vt||(vt={}));const yt={},wt=async t=>{let e="string"==typeof t?[t]:t,n=[];for(let t of e)n.push(yt[t]=yt[t]||new i);await Promise.all(n)},Ct=async(t,e)=>{let n,r="string"==typeof t?[t]:t,s=[];for(let t of r){let r;s.push(r=yt[t]=yt[t]||new i(n=n||e())),r.isEmpty&&(r.task=n=n||e())}await Promise.all(s)};let Et,St=0;const Tt=()=>St++,bt={};let It;const xt=t=>{It=t,Et&&Et.postMessage({type:"setBLog",body:{value:!!t}})};let Rt=!1;const Ot=t=>{Rt=t,Et&&Et.postMessage({type:"setBDebug",body:{value:!!t}})},At={},Dt={},Mt={dip:{wasm:!0}},Lt={std:{version:"2.0.0",path:d(c+"../../dynamsoft-capture-vision-std@2.0.0/dist/"),isInternal:!0},core:{version:"4.0.60-dev-20250812165815",path:c,isInternal:!0}};class Ft{static get engineResourcePaths(){return Lt}static set engineResourcePaths(t){Object.assign(Lt,t)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return It}static set _onLog(t){xt(t)}static get _bDebug(){return Rt}static set _bDebug(t){Ot(t)}static get _workerName(){return`${Ft._bundleEnv.toLowerCase()}.bundle.worker.js`}static isModuleLoaded(t){return t=(t=t||"core").toLowerCase(),!!yt[t]&&yt[t].isFulfilled}static async loadWasm(){return await(async()=>{let t,e;t instanceof Array||(t=t?[t]:[]);let n=yt.core;e=!n||n.isEmpty,e||await wt("core");let r=new Map;const s=t=>{if(t=t.toLowerCase(),_t.MN_DYNAMSOFT_CAPTURE_VISION_STD==t||_t.MN_DYNAMSOFT_CORE==t)return;let e=Mt[t].deps;if(null==e?void 0:e.length)for(let t of e)s(t);let i=yt[t];r.has(t)||r.set(t,!i||i.isEmpty)};for(let e of t)s(e);let a=[];e&&a.push("core"),a.push(...r.keys());const o=[...r.entries()].filter(t=>!t[1]).map(t=>t[0]);await Ct(a,async()=>{const t=[...r.entries()].filter(t=>t[1]).map(t=>t[0]);await wt(o);const n=D(Lt),s={};for(let e of t)s[e]=Mt[e];const a={engineResourcePaths:n,autoResources:s,names:t,_bundleEnv:Ft._bundleEnv,_useSimd:Ft._useSimd,_useMLBackend:Ft._useMLBackend};let l=new i;if(e){a.needLoadCore=!0;let t=n[`${Ft._bundleEnv.toLowerCase()}Bundle`]+Ft._workerName;t.startsWith(location.origin)||(t=await fetch(t).then(t=>t.blob()).then(t=>URL.createObjectURL(t))),Et=new Worker(t),Et.onerror=t=>{let e=new Error(t.message);l.reject(e)},Et.addEventListener("message",t=>{let e=t.data?t.data:t,i=e.type,n=e.id,r=e.body;switch(i){case"log":It&&It(e.message);break;case"task":try{bt[n](r),delete bt[n]}catch(t){throw delete bt[n],t}break;case"event":try{bt[n](r)}catch(t){throw t}break;default:console.log(t)}}),a.bLog=!!It,a.bd=Rt,a.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else await wt("core");let h=St++;bt[h]=t=>{if(t.success)Object.assign(At,t.versions),"{}"!==JSON.stringify(t.versions)&&(Ft._versions=t.versions),l.resolve(void 0);else{const e=Error(t.message);t.stack&&(e.stack=t.stack),l.reject(e)}},Et.postMessage({type:"loadWasm",id:h,body:a}),await l})})()}static async detectEnvironment(){return await(async()=>({wasm:Q,worker:tt,getUserMedia:et,camera:await it(),browser:J.browser,version:J.version,OS:J.OS}))()}static async getModuleVersion(){return await new Promise((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success)return t(i.versions);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},Et.postMessage({type:"getModuleVersion",id:i})})}static getVersion(){return`4.0.60-dev-20250812165815(Worker: ${At.core&&At.core.worker||"Not Loaded"}, Wasm: ${At.core&&At.core.wasm||"Not Loaded"})`}static enableLogging(){$._onLog=console.log,Ft._onLog=console.log}static disableLogging(){$._onLog=null,Ft._onLog=null}static async cfd(t){return await new Promise((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},Et.postMessage({type:"cfd",id:n,body:{count:t}})})}}Ft._bSupportDce4Module=-1,Ft._bSupportIRTModule=-1,Ft._versions=null,Ft._bundleEnv="DCV",Ft._useMLBackend=!1,Ft._useSimd=!0,Ft.browserInfo=J;const Pt="undefined"==typeof self,kt="function"==typeof importScripts,Nt=(()=>{if(!kt){if(!Pt&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})();function Bt(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function jt(t,e,i,n,r){if("function"==typeof e||!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;const Vt=t=>t&&"object"==typeof t&&"function"==typeof t.then,Ut=(async()=>{})().constructor;let Gt=class extends Ut{get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(t){let e;this._task=t,Vt(t)?e=t:"function"==typeof t&&(e=new Ut(t)),e&&(async()=>{try{const i=await e;t===this._task&&this.resolve(i)}catch(e){t===this._task&&this.reject(e)}})()}get isEmpty(){return null==this._task}constructor(t){let e,i;super((t,n)=>{e=t,i=n}),this._s="pending",this.resolve=t=>{this.isPending&&(Vt(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}},Wt=class{constructor(t){this._cvr=t}async getMaxBufferedItems(){return await new Promise((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success)return t(i.count);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},Et.postMessage({type:"cvr_getMaxBufferedItems",id:i,instanceID:this._cvr._instanceID})})}async setMaxBufferedItems(t){return await new Promise((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}},Et.postMessage({type:"cvr_setMaxBufferedItems",id:n,instanceID:this._cvr._instanceID,body:{count:t}})})}async getBufferedCharacterItemSet(){return await new Promise((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success)return t(i.itemSet);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},Et.postMessage({type:"cvr_getBufferedCharacterItemSet",id:i,instanceID:this._cvr._instanceID})})}};var Yt={onTaskResultsReceived:!1,onTargetROIResultsReceived:!1,onTaskResultsReceivedForDce:!1,onPredetectedRegionsReceived:!1,onLocalizedBarcodesReceived:!1,onDecodedBarcodesReceived:!1,onLocalizedTextLinesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onDeskewedImageReceived:!1,onEnhancedImageReceived:!1,onColourImageUnitReceived:!1,onScaledColourImageUnitReceived:!1,onGrayscaleImageUnitReceived:!1,onTransformedGrayscaleImageUnitReceived:!1,onEnhancedGrayscaleImageUnitReceived:!1,onBinaryImageUnitReceived:!1,onTextureDetectionResultUnitReceived:!1,onTextureRemovedGrayscaleImageUnitReceived:!1,onTextureRemovedBinaryImageUnitReceived:!1,onContoursUnitReceived:!1,onLineSegmentsUnitReceived:!1,onTextZonesUnitReceived:!1,onTextRemovedBinaryImageUnitReceived:!1,onRawTextLinesUnitReceived:!1,onLongLinesUnitReceived:!1,onCornersUnitReceived:!1,onCandidateQuadEdgesUnitReceived:!1,onCandidateBarcodeZonesUnitReceived:!1,onScaledBarcodeImageUnitReceived:!1,onDeformationResistedBarcodeImageUnitReceived:!1,onComplementedBarcodeImageUnitReceived:!1,onShortLinesUnitReceived:!1,onLogicLinesUnitReceived:!1,onProcessedDocumentResultReceived:!1};const Ht=t=>{for(let e in t._irrRegistryState)t._irrRegistryState[e]=!1;for(let e of t._intermediateResultReceiverSet)if(e.isDce||e.isFilter)t._irrRegistryState.onTaskResultsReceivedForDce=!0;else for(let i in e)t._irrRegistryState[i]||(t._irrRegistryState[i]=!!e[i])};let zt=class{constructor(t){this._irrRegistryState=Yt,this._intermediateResultReceiverSet=new Set,this._cvr=t}async addResultReceiver(t){if("object"!=typeof t)throw new Error("Invalid receiver.");this._intermediateResultReceiverSet.add(t),Ht(this);let e=-1,i={};if(!t.isDce&&!t.isFilter){if(!t._observedResultUnitTypes||!t._observedTaskMap)throw new Error("Invalid Intermediate Result Receiver.");e=t._observedResultUnitTypes,t._observedTaskMap.forEach((t,e)=>{i[e]=t}),t._observedTaskMap.clear()}return await new Promise((t,n)=>{let r=Tt();bt[r]=async e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,n(t)}},Et.postMessage({type:"cvr_setIrrRegistry",id:r,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState,observedResultUnitTypes:e.toString(),observedTaskMap:i}})})}async removeResultReceiver(t){return this._intermediateResultReceiverSet.delete(t),Ht(this),await new Promise((t,e)=>{let i=Tt();bt[i]=async i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}},Et.postMessage({type:"cvr_setIrrRegistry",id:i,instanceID:this._cvr._instanceID,body:{receiverObj:this._irrRegistryState}})})}getOriginalImage(){return this._cvr._dsImage}};const Xt="undefined"==typeof self,qt="function"==typeof importScripts,Zt=(()=>{if(!qt){if(!Xt&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),Kt=t=>{if(null==t&&(t="./"),Xt||qt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var Jt;Ft.engineResourcePaths.cvr={version:"3.0.60-dev-20250812165839",path:Zt,isInternal:!0},Mt.cvr={js:!0,wasm:!0,deps:[_t.MN_DYNAMSOFT_LICENSE,_t.MN_DYNAMSOFT_IMAGE_PROCESSING,_t.MN_DYNAMSOFT_NEURAL_NETWORK]},Mt.dnn={wasm:!0,deps:[_t.MN_DYNAMSOFT_IMAGE_PROCESSING]},Dt.cvr={};const $t="2.0.0";"string"!=typeof Ft.engineResourcePaths.std&&A(Ft.engineResourcePaths.std.version,$t)<0&&(Ft.engineResourcePaths.std={version:$t,path:Kt(Zt+`../../dynamsoft-capture-vision-std@${$t}/dist/`),isInternal:!0});const Qt="3.0.10";(!Ft.engineResourcePaths.dip||"string"!=typeof Ft.engineResourcePaths.dip&&A(Ft.engineResourcePaths.dip.version,Qt)<0)&&(Ft.engineResourcePaths.dip={version:Qt,path:Kt(Zt+`../../dynamsoft-image-processing@${Qt}/dist/`),isInternal:!0});const te="2.0.10";(!Ft.engineResourcePaths.dnn||"string"!=typeof Ft.engineResourcePaths.dnn&&A(Ft.engineResourcePaths.dnn.version,te)<0)&&(Ft.engineResourcePaths.dnn={version:te,path:Kt(Zt+`../../dynamsoft-capture-vision-dnn@${te}/dist/`),isInternal:!0});let ee=class{static getVersion(){return this._version}};var ie,ne,re,se,ae,oe,le,he,ce,de,ue,fe,ge,me,pe,_e,ve,ye,we,Ce,Ee,Se,Te,be;function Ie(t,e){if(t&&t.sourceLocation){const i=t.sourceLocation.points;for(let t of i)t.x=t.x/e,t.y=t.y/e;Ie(t.referencedItem,e)}}function xe(t){if(t.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}function Re(t){const e=[st.EC_UNSUPPORTED_JSON_KEY_WARNING,st.EC_LICENSE_AUTH_QUOTA_EXCEEDED,st.EC_LICENSE_RESULTS_LIMIT_EXCEEDED];if(t.errorCode&&e.includes(t.errorCode))return void console.warn(t.message);let i=new Error(t.errorCode?`[${t.functionName}] [${t.errorCode}] ${t.message}`:`[${t.functionName}] ${t.message}`);if(i.stack&&(i.stack=t.stack),t.isShouleThrow)throw i;return t.rj&&t.rj(i),!0}ee._version=`3.0.60-dev-20250812165839(Worker: ${null===(Jt=At.cvr)||void 0===Jt?void 0:Jt.worker}, Wasm: loading...`,function(t){t[t.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",t[t.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(ie||(ie={}));const Oe={onTaskResultsReceived:()=>{},isFilter:!0};bt[-2]=async t=>{Ae.onDataLoadProgressChanged&&Ae.onDataLoadProgressChanged(t.resourcesPath,t.tag,{loaded:t.loaded,total:t.total})};let Ae=class t{constructor(){ne.add(this),this.maxImageSideLength=["iPhone","Android","HarmonyOS"].includes(Ft.browserInfo.OS)?2048:4096,this.onCaptureError=null,this._instanceID=void 0,this._dsImage=null,this._isPauseScan=!0,this._isOutputOriginalImage=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1,this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._minImageCaptureInterval=0,this._averageProcessintTimeArray=[],this._averageFetchImageTimeArray=[],this._currentSettings=null,this._averageTime=999,this._dynamsoft=!0,re.set(this,null),se.set(this,null),ae.set(this,null),oe.set(this,null),le.set(this,null),he.set(this,new Set),ce.set(this,new Set),de.set(this,new Set),ue.set(this,500),fe.set(this,0),ge.set(this,0),me.set(this,!1),pe.set(this,!1),_e.set(this,!1),ve.set(this,null),ye.set(this,null),this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this)}get disposed(){return Bt(this,_e,"f")}static async createInstance(e=!0){if(!Dt.license)throw Error("The `license` module cannot be found.");await Dt.license.dynamsoft(),await Ft.loadWasm();const i=new t,n=new Gt;let r=Tt();return bt[r]=async t=>{t.success?(i._instanceID=t.instanceID,i._currentSettings=JSON.parse(JSON.parse(t.outputSettings).data),ee._version=`3.0.60-dev-20250812165839(Worker: ${At.cvr.worker}, Wasm: ${t.version})`,jt(i,pe,!0),jt(i,oe,i.getIntermediateResultManager()),jt(i,pe,!1),n.resolve(i)):Re({message:t.message,rj:n.reject,stack:t.stack,functionName:"createInstance"})},Et.postMessage({type:"cvr_createInstance",id:r,body:{loadPresetTemplates:e,itemCountRecord:localStorage.getItem("dynamsoft")}}),n}static async appendModelBuffer(t,e){return await Ft.loadWasm(),await new Promise((i,n)=>{let r=Tt();const s=D(Ft.engineResourcePaths);let a;bt[r]=async t=>{if(t.success){const e=JSON.parse(t.response);return 0!==e.errorCode&&Re({message:e.errorString?e.errorString:"Append Model Buffer Failed.",rj:n,errorCode:e.errorCode,functionName:"appendModelBuffer"}),i(e)}Re({message:t.message,rj:n,stack:t.stack,functionName:"appendModelBuffer"})},e?a=e:"DCV"===Ft._bundleEnv?a=s.dcvData+"models/":"DBR"===Ft._bundleEnv&&(a=s.dbrBundle+"models/"),Et.postMessage({type:"cvr_appendModelBuffer",id:r,body:{modelName:t,path:a}})})}async _singleFrameModeCallback(t){for(let e of Bt(this,he,"f"))this._isOutputOriginalImage&&e.onOriginalImageResultReceived&&e.onOriginalImageResultReceived({imageData:t});const e={bytes:new Uint8Array(t.bytes),width:t.width,height:t.height,stride:t.stride,format:t.format,tag:t.tag};this._templateName||(this._templateName=this._currentSettings.CaptureVisionTemplates[0].Name);const i=await this.capture(e,this._templateName);i.originalImageTag=t.tag;for(let t of Bt(this,he,"f"))t.isDce?t.onCapturedResultReceived(i,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1}):Bt(this,ne,"m",Ce).call(this,t,i)}setInput(t){if(xe(this),!t)return Bt(this,ve,"f")&&(Bt(this,oe,"f").removeResultReceiver(Bt(this,ve,"f")),jt(this,ve,null)),Bt(this,ye,"f")&&(Bt(this,he,"f").delete(Bt(this,ye,"f")),jt(this,ye,null)),void jt(this,re,null);if(jt(this,re,t),t.isCameraEnhancer){Bt(this,oe,"f")&&(Bt(this,re,"f")._intermediateResultReceiver.isDce=!0,Bt(this,oe,"f").addResultReceiver(Bt(this,re,"f")._intermediateResultReceiver),jt(this,ve,Bt(this,re,"f")._intermediateResultReceiver));const t=Bt(this,re,"f").getCameraView();if(t){const e=t._capturedResultReceiver;e.isDce=!0,Bt(this,he,"f").add(e),jt(this,ye,e)}}}getInput(){return Bt(this,re,"f")}addImageSourceStateListener(t){if(xe(this),"object"!=typeof t)return console.warn("Invalid ISA state listener.");t&&Object.keys(t)&&Bt(this,ce,"f").add(t)}removeImageSourceStateListener(t){return xe(this),Bt(this,ce,"f").delete(t)}addResultReceiver(t){if(xe(this),"object"!=typeof t)throw new Error("Invalid receiver.");t&&Object.keys(t).length&&(Bt(this,he,"f").add(t),this._setCrrRegistry())}removeResultReceiver(t){xe(this),Bt(this,he,"f").delete(t),this._setCrrRegistry()}async _setCrrRegistry(){const t={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onProcessedDocumentResultReceived:!1,onParsedResultsReceived:!1};for(let e of Bt(this,he,"f"))e.isDce||(t.onCapturedResultReceived=!!e.onCapturedResultReceived,t.onDecodedBarcodesReceived=!!e.onDecodedBarcodesReceived,t.onRecognizedTextLinesReceived=!!e.onRecognizedTextLinesReceived,t.onProcessedDocumentResultReceived=!!e.onProcessedDocumentResultReceived,t.onParsedResultsReceived=!!e.onParsedResultsReceived);const e=new Gt;let i=Tt();return bt[i]=async t=>{t.success?e.resolve():Re({message:t.message,rj:e.reject,stack:t.stack,functionName:"addResultReceiver"})},Et.postMessage({type:"cvr_setCrrRegistry",id:i,instanceID:this._instanceID,body:{receiver:JSON.stringify(t)}}),e}async addResultFilter(t){if(xe(this),!t||"object"!=typeof t||!Object.keys(t).length)return console.warn("Invalid filter.");Bt(this,de,"f").add(t),t._dynamsoft(),await this._handleFilterUpdate()}async removeResultFilter(t){xe(this),Bt(this,de,"f").delete(t),await this._handleFilterUpdate()}async _handleFilterUpdate(){if(Bt(this,oe,"f").removeResultReceiver(Oe),0===Bt(this,de,"f").size){this._isOpenBarcodeVerify=!1,this._isOpenLabelVerify=!1,this._isOpenDetectVerify=!1,this._isOpenNormalizeVerify=!1;const t={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!1,[nt.CRIT_DETECTED_QUAD]:!1,[nt.CRIT_DESKEWED_IMAGE]:!1},e={[nt.CRIT_BARCODE]:!1,[nt.CRIT_TEXT_LINE]:!1,[nt.CRIT_DETECTED_QUAD]:!1,[nt.CRIT_DESKEWED_IMAGE]:!1};return await Bt(this,ne,"m",Ee).call(this,t),void await Bt(this,ne,"m",Se).call(this,e)}for(let t of Bt(this,de,"f"))this._isOpenBarcodeVerify=t.isResultCrossVerificationEnabled(nt.CRIT_BARCODE),this._isOpenLabelVerify=t.isResultCrossVerificationEnabled(nt.CRIT_TEXT_LINE),this._isOpenDetectVerify=t.isResultCrossVerificationEnabled(nt.CRIT_DETECTED_QUAD),this._isOpenNormalizeVerify=t.isResultCrossVerificationEnabled(nt.CRIT_DESKEWED_IMAGE),t.isLatestOverlappingEnabled(nt.CRIT_BARCODE)&&([...Bt(this,oe,"f")._intermediateResultReceiverSet.values()].find(t=>t.isFilter)||Bt(this,oe,"f").addResultReceiver(Oe)),await Bt(this,ne,"m",Ee).call(this,t.verificationEnabled),await Bt(this,ne,"m",Se).call(this,t.duplicateFilterEnabled),await Bt(this,ne,"m",Te).call(this,t.duplicateForgetTime)}async startCapturing(e){if(xe(this),!this._isPauseScan)return;if(!Bt(this,re,"f"))throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");e||(e=t._defaultTemplate);const i=await this.containsTask(e);for(let t of Bt(this,de,"f"))await this.addResultFilter(t);const n=D(Ft.engineResourcePaths);return Bt(this,re,"f").isCameraEnhancer&&(i.includes("ddn")?Bt(this,re,"f").setPixelFormat(o.IPF_ABGR_8888):Bt(this,re,"f").setPixelFormat(o.IPF_GRAYSCALED)),void 0!==Bt(this,re,"f").singleFrameMode&&"disabled"!==Bt(this,re,"f").singleFrameMode?(this._templateName=e,void Bt(this,re,"f").on("singleFrameAcquired",this._singleFrameModeCallbackBind)):(Bt(this,re,"f").getColourChannelUsageType()===a.CCUT_AUTO&&Bt(this,re,"f").setColourChannelUsageType(i.includes("ddn")?a.CCUT_FULL_CHANNEL:a.CCUT_Y_CHANNEL_ONLY),Bt(this,ae,"f")&&Bt(this,ae,"f").isPending?Bt(this,ae,"f"):(jt(this,ae,new Gt((t,i)=>{if(this.disposed)return;let r=Tt();bt[r]=async n=>{Bt(this,ae,"f")&&!Bt(this,ae,"f").isFulfilled&&(n.success?(this._isPauseScan=!1,this._isOutputOriginalImage=n.isOutputOriginalImage,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(async()=>{-1!==this._minImageCaptureInterval&&Bt(this,re,"f").startFetching(),this._loopReadVideo(e),t()},0)):Re({message:n.message,rj:i,stack:n.stack,functionName:"startCapturing"}))},Et.postMessage({type:"cvr_startCapturing",id:r,instanceID:this._instanceID,body:{templateName:e,engineResourcePaths:n}})})),await Bt(this,ae,"f")))}stopCapturing(){xe(this),Bt(this,re,"f")&&(Bt(this,re,"f").isCameraEnhancer&&void 0!==Bt(this,re,"f").singleFrameMode&&"disabled"!==Bt(this,re,"f").singleFrameMode?Bt(this,re,"f").off("singleFrameAcquired",this._singleFrameModeCallbackBind):(Bt(this,ne,"m",be).call(this),Bt(this,re,"f").stopFetching(),this._averageProcessintTimeArray=[],this._averageTime=999,this._isPauseScan=!0,jt(this,ae,null),Bt(this,re,"f").setColourChannelUsageType(a.CCUT_AUTO)))}async containsTask(t){return xe(this),await new Promise((e,i)=>{let n=Tt();bt[n]=async t=>{if(t.success)return e(JSON.parse(t.tasks));Re({message:t.message,rj:i,stack:t.stack,functionName:"containsTask"})},Et.postMessage({type:"cvr_containsTask",id:n,instanceID:this._instanceID,body:{templateName:t}})})}async _loopReadVideo(e){if(this.disposed||this._isPauseScan)return;if(jt(this,me,!0),Bt(this,re,"f").isBufferEmpty())if(Bt(this,re,"f").hasNextImageToFetch())for(let t of Bt(this,ce,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(ie.ISS_BUFFER_EMPTY);else if(!Bt(this,re,"f").hasNextImageToFetch())for(let t of Bt(this,ce,"f"))t.onImageSourceStateReceived&&t.onImageSourceStateReceived(ie.ISS_EXHAUSTED);if(-1===this._minImageCaptureInterval||Bt(this,re,"f").isBufferEmpty()&&Bt(this,re,"f").isCameraEnhancer)try{Bt(this,re,"f").isBufferEmpty()&&t._onLog&&t._onLog("buffer is empty so fetch image"),t._onLog&&t._onLog(`DCE: start fetching a frame: ${Date.now()}`),this._dsImage=Bt(this,re,"f").fetchImage(),t._onLog&&t._onLog(`DCE: finish fetching a frame: ${Date.now()}`),Bt(this,re,"f").setImageFetchInterval(this._averageTime)}catch(i){return void this._reRunCurrnetFunc(e)}else if(Bt(this,re,"f").isCameraEnhancer&&Bt(this,re,"f").setImageFetchInterval(this._averageTime-(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0)),this._dsImage=Bt(this,re,"f").getImage(),this._dsImage&&this._dsImage.tag&&Date.now()-this._dsImage.tag.timeStamp>200)return void this._reRunCurrnetFunc(e);if(!this._dsImage)return void this._reRunCurrnetFunc(e);for(let t of Bt(this,he,"f"))this._isOutputOriginalImage&&t.onOriginalImageResultReceived&&t.onOriginalImageResultReceived({imageData:this._dsImage});const i=Date.now();this._captureDsimage(this._dsImage,e).then(async n=>{if(t._onLog&&t._onLog("no js handle time: "+(Date.now()-i)),this._isPauseScan)return void this._reRunCurrnetFunc(e);n.originalImageTag=this._dsImage.tag?this._dsImage.tag:null;for(let e of Bt(this,he,"f"))if(e.isDce){const i=Date.now();if(e.onCapturedResultReceived(n,{isDetectVerifyOpen:this._isOpenDetectVerify,isNormalizeVerifyOpen:this._isOpenNormalizeVerify,isBarcodeVerifyOpen:this._isOpenBarcodeVerify,isLabelVerifyOpen:this._isOpenLabelVerify}),t._onLog){const e=Date.now()-i;e>10&&t._onLog(`draw result time: ${e}`)}}else{for(let t of Bt(this,de,"f"))t.onDecodedBarcodesReceived(n),t.onRecognizedTextLinesReceived(n),t.onProcessedDocumentResultReceived(n);Bt(this,ne,"m",Ce).call(this,e,n)}const r=Date.now();if(this._minImageCaptureInterval>-1&&(5===this._averageProcessintTimeArray.length&&this._averageProcessintTimeArray.shift(),5===this._averageFetchImageTimeArray.length&&this._averageFetchImageTimeArray.shift(),this._averageProcessintTimeArray.push(Date.now()-i),this._averageFetchImageTimeArray.push(this._dsImage&&this._dsImage.tag?this._dsImage.tag.timeSpent:0),this._averageTime=Math.min(...this._averageProcessintTimeArray)-Math.max(...this._averageFetchImageTimeArray),this._averageTime=this._averageTime>0?this._averageTime:0,t._onLog&&(t._onLog(`minImageCaptureInterval: ${this._minImageCaptureInterval}`),t._onLog(`averageProcessintTimeArray: ${this._averageProcessintTimeArray}`),t._onLog(`averageFetchImageTimeArray: ${this._averageFetchImageTimeArray}`),t._onLog(`averageTime: ${this._averageTime}`))),t._onLog){const e=Date.now()-r;e>10&&t._onLog(`fetch image calculate time: ${e}`)}t._onLog&&t._onLog(`time finish decode: ${Date.now()}`),t._onLog&&t._onLog("main time: "+(Date.now()-i)),t._onLog&&t._onLog("===================================================="),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._minImageCaptureInterval>0&&this._minImageCaptureInterval>=this._averageTime?this._loopReadVideoTimeoutId=setTimeout(()=>{this._loopReadVideo(e)},this._minImageCaptureInterval-this._averageTime):this._loopReadVideoTimeoutId=setTimeout(()=>{this._loopReadVideo(e)},Math.max(this._minImageCaptureInterval,0))}).catch(t=>{Bt(this,re,"f").stopFetching(),"platform error"!==t.message&&(t.errorCode&&0===t.errorCode&&(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{Bt(this,re,"f").startFetching(),this._loopReadVideo(e)},Math.max(this._minImageCaptureInterval,1e3))),setTimeout(()=>{if(!this.onCaptureError)throw t;this.onCaptureError(t)},0))})}_reRunCurrnetFunc(t){this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{this._loopReadVideo(t)},0)}async capture(e,i){let n;if(xe(this),i||(i=t._defaultTemplate),jt(this,me,!1),w(e))n=await this._captureDsimage(e,i);else if("string"==typeof e)n="data:image/"==e.substring(0,11)?await this._captureBase64(e,i):await this._captureUrl(e,i);else if(e instanceof Blob)n=await this._captureBlob(e,i);else if(e instanceof HTMLImageElement)n=await this._captureImage(e,i);else if(e instanceof HTMLCanvasElement)n=await this._captureCanvas(e,i);else{if(!(e instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");n=await this._captureVideo(e,i)}return n}async _captureDsimage(t,e){return await this._captureInWorker(t,e)}async _captureUrl(t,e){let i=await R(t,"blob");return await this._captureBlob(i,e)}async _captureBase64(t,e){t=t.substring(t.indexOf(",")+1);let i=atob(t),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return await this._captureBlob(new Blob([r]),e)}async _captureBlob(t,e){let i=null,n=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(t)}catch(t){}i||(n=await async function(e){return await new Promise((i,n)=>{let r=URL.createObjectURL(e),s=new Image;s.src=r,s.onload=()=>{URL.revokeObjectURL(s.dbrObjUrl),i(s)},s.onerror=()=>{let e="Unsupported image format. Please upload files in one of the following formats: .jpg,.jpeg,.ico,.gif,.svg,.webp,.png,.bmp";"image/svg+xml"===t.type&&(e="Invalid SVG file. The file appears to be malformed or contains invalid XML."),n(new Error(e))}})}(t));let r=await this._captureImage(i||n,e);return i&&i.close(),r}async _captureImage(t,e){let i,n,r=t instanceof HTMLImageElement?t.naturalWidth:t.width,s=t instanceof HTMLImageElement?t.naturalHeight:t.height,a=Math.max(r,s);a>this.maxImageSideLength?(jt(this,ge,this.maxImageSideLength/a),i=Math.round(r*Bt(this,ge,"f")),n=Math.round(s*Bt(this,ge,"f"))):(i=r,n=s),Bt(this,se,"f")||jt(this,se,document.createElement("canvas"));const o=Bt(this,se,"f");return o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0})),o.ctx2d.drawImage(t,0,0,r,s,0,0,i,n),t.dbrObjUrl&&URL.revokeObjectURL(t.dbrObjUrl),await this._captureCanvas(o,e)}async _captureCanvas(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";if([t.width,t.height].includes(0))throw Error("The width or height of the 'canvas' is 0.");const i=t.ctx2d||t.getContext("2d",{willReadFrequently:!0}),n={bytes:Uint8Array.from(i.getImageData(0,0,t.width,t.height).data),width:t.width,height:t.height,stride:4*t.width,format:10};return await this._captureInWorker(n,e)}async _captureVideo(t,e){if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";let i,n,r=t.videoWidth,s=t.videoHeight,a=Math.max(r,s);a>this.maxImageSideLength?(jt(this,ge,this.maxImageSideLength/a),i=Math.round(r*Bt(this,ge,"f")),n=Math.round(s*Bt(this,ge,"f"))):(i=r,n=s),Bt(this,se,"f")||jt(this,se,document.createElement("canvas"));const o=Bt(this,se,"f");return o.width===i&&o.height===n||(o.width=i,o.height=n),o.ctx2d||(o.ctx2d=o.getContext("2d",{willReadFrequently:!0})),o.ctx2d.drawImage(t,0,0,r,s,0,0,i,n),await this._captureCanvas(o,e)}async _captureInWorker(e,i){const{bytes:n,width:r,height:s,stride:a,format:o}=e;let l=Tt();D(Ft.engineResourcePaths);const h=new Gt;return bt[l]=async i=>{if(i.success){const n=Date.now();t._onLog&&(t._onLog(`get result time from worker: ${n}`),t._onLog("worker to main time consume: "+(n-i.workerReturnMsgTime)));try{const t=i.captureResult;t.hasOwnProperty("_needContinueProcess")&&delete t._needContinueProcess,e.bytes=i.bytes;for(let i of t.items)0!==Bt(this,ge,"f")&&Ie(i,Bt(this,ge,"f")),i.type===nt.CRIT_ORIGINAL_IMAGE?i.imageData=e:[nt.CRIT_DESKEWED_IMAGE,nt.CRIT_ENHANCED_IMAGE].includes(i.type)?Dt.ddn&&Dt.ddn.handleDeskewedAndEnhancedImageResultItem(i):i.type===nt.CRIT_PARSED_RESULT&&Dt.dcp&&Dt.dcp.handleParsedResultItem(i);const n=t.processedDocumentResult;if(n){if(n.deskewedImageResultItems)for(let t=0;t