l||e.sy+e.sHeight>h)throw new Error("Invalid position.");null===(n=Nr._onLog)||void 0===n||n.call(Nr,"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)||pi.RGBA,w=null==i?void 0:i.bufferContainer;if(w&&(pi.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 jr{static get version(){return"4.2.12-dev-20250609101854"}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(ii.OS))return jr.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(ii.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(!ni(this,ir,"f"))return"closed";if("pending"===ni(this,ir,"f"))return"opening";if("fulfilled"===ni(this,ir,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(t){t?jr.isStorageAvailable("localStorage")?ri(this,$n,!0):(ri(this,$n,!1),console.warn("Local storage is unavailable")):ri(this,$n,!1)}get ifSaveLastUsedCamera(){return ni(this,$n,"f")}get isVideoPlaying(){return!(!ni(this,Hn,"f")||ni(this,Hn,"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=ni(this,lr,"f"))||void 0===e||e.removeEventListener("click",ni(this,or,"f")),null===(i=ni(this,lr,"f"))||void 0===i||i.removeEventListener("touchend",ni(this,or,"f")),null===(n=ni(this,lr,"f"))||void 0===n||n.removeEventListener("touchmove",ni(this,ar,"f")),ri(this,lr,t),t&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(ii.OS)?(t.addEventListener("touchend",ni(this,or,"f")),t.addEventListener("touchmove",ni(this,ar,"f"))):t.addEventListener("click",ni(this,or,"f")))}get tapFocusEventBoundEl(){return ni(this,lr,"f")}get disposed(){return ni(this,_r,"f")}constructor(t){var e,i;Yn.add(this),Hn.set(this,null),zn.set(this,void 0),this._zoomPreSetting=null,Xn.set(this,(()=>{"opened"===this.state&&ni(this,ur,"f").fire("resumed",null,{target:this,async:!1})})),Zn.set(this,(()=>{ni(this,ur,"f").fire("paused",null,{target:this,async:!1})})),qn.set(this,void 0),Kn.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],Jn.set(this,void 0),$n.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,Qn.set(this,void 0),tr.set(this,!0),er.set(this,void 0),ir.set(this,void 0),nr.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},rr.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(t,e)=>{let i,n;const r=window.getComputedStyle(ni(this,Hn,"f")).objectFit,s=this.getResolution(),a=ni(this,Hn,"f").getBoundingClientRect(),o=a.left,l=a.top,{width:h,height:c}=ni(this,Hn,"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}},sr.set(this,!1),ar.set(this,(()=>{ri(this,sr,!0)})),or.set(this,(async t=>{var e;if(ni(this,sr,"f"))return void ri(this,sr,!1);if(!ni(this,rr,"f"))return;if(!this.isVideoPlaying)return;if(!ni(this,zn,"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;jr._onLog&&(c=Date.now());try{await ni(this,Yn,"m",xr).call(this,o,l,h,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance)}catch(t){if(jr._onLog)throw jr._onLog(t),t}jr._onLog&&jr._onLog(`Tap focus costs: ${Date.now()-c} ms`),this._focusParameters.taskBackToContinous=setTimeout((()=>{var t;jr._onLog&&jr._onLog("Back to continuous focus."),null===(t=ni(this,zn,"f"))||void 0===t||t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch((()=>{}))}),this._focusParameters.focusBackToContinousTime),ni(this,ur,"f").fire("tapfocus",null,{target:this,async:!1})})),lr.set(this,null),hr.set(this,1),cr.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!ni(this,Hn,"f"))return;const t=ni(this,hr,"f");if(t<1)throw new RangeError("Invalid scale value.");if(1===t)ni(this,Hn,"f").style.transform="";else{const e=window.getComputedStyle(ni(this,Hn,"f")).objectFit,i=ni(this,Hn,"f").videoWidth,n=ni(this,Hn,"f").videoHeight,{width:r,height:s}=ni(this,Hn,"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-ni(this,cr,"f").x),c=l*(1-1/t)*(n/2-ni(this,cr,"f").y);ni(this,Hn,"f").style.transform=`translate(${h}px, ${c}px) scale(${t})`}},dr.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===pi.GREY){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t{var t,e;if("visible"===document.visibilityState){if(jr._onLog&&jr._onLog("document visible. video paused: "+(null===(t=ni(this,Hn,"f"))||void 0===t?void 0:t.paused)),"opening"==this.state||"opened"==this.state){let e=!1;if(!this.isVideoPlaying){jr._onLog&&jr._onLog("document visible. Not auto resume. 1st resume start.");try{await this.resume(),e=!0}catch(t){jr._onLog&&jr._onLog("document visible. 1st resume video failed, try open instead.")}e||await ni(this,Yn,"m",Cr).call(this)}if(await new Promise((t=>setTimeout(t,300))),!this.isVideoPlaying){jr._onLog&&jr._onLog("document visible. 1st open failed. 2rd resume start."),e=!1;try{await this.resume(),e=!0}catch(t){jr._onLog&&jr._onLog("document visible. 2rd resume video failed, try open instead.")}e||await ni(this,Yn,"m",Cr).call(this)}}}else"hidden"===document.visibilityState&&(jr._onLog&&jr._onLog("document hidden. video paused: "+(null===(e=ni(this,Hn,"f"))||void 0===e?void 0:e.paused)),"opening"==this.state||"opened"==this.state&&this.isVideoPlaying&&this.pause())})),_r.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((()=>{jr.onWarning&&jr.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),ri(this,ur,new Ki),this.imageDataGetter=new Nr,document.addEventListener("visibilitychange",ni(this,pr,"f"))}setVideoEl(t){if(!(t&&t instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");t.addEventListener("play",ni(this,Xn,"f")),t.addEventListener("pause",ni(this,Zn,"f")),ri(this,Hn,t)}getVideoEl(){return ni(this,Hn,"f")}releaseVideoEl(){var t,e;null===(t=ni(this,Hn,"f"))||void 0===t||t.removeEventListener("play",ni(this,Xn,"f")),null===(e=ni(this,Hn,"f"))||void 0===e||e.removeEventListener("pause",ni(this,Zn,"f")),ri(this,Hn,null)}isVideoLoaded(){return!!ni(this,Hn,"f")&&4==ni(this,Hn,"f").readyState}async open(){if(ni(this,er,"f")&&!ni(this,tr,"f")){if("pending"===ni(this,ir,"f"))return ni(this,er,"f");if("fulfilled"===ni(this,ir,"f"))return}ni(this,ur,"f").fire("before:open",null,{target:this}),await ni(this,Yn,"m",Cr).call(this),ni(this,ur,"f").fire("played",null,{target:this,async:!1}),ni(this,ur,"f").fire("opened",null,{target:this,async:!1})}async close(){if("closed"===this.state)return;ni(this,ur,"f").fire("before:close",null,{target:this});const t=ni(this,er,"f");if(ni(this,Yn,"m",Tr).call(this),t&&"pending"===ni(this,ir,"f")){try{await t}catch(t){}if(!1===ni(this,tr,"f")){const t=new Error("'close()' was interrupted.");throw t.name="AbortError",t}}ri(this,er,null),ri(this,ir,null),ni(this,ur,"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.");ni(this,Hn,"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 ni(this,Hn,"f").play()}async setCamera(t){if("string"!=typeof t)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof ni(this,qn,"f").video&&(ni(this,qn,"f").video={}),delete ni(this,qn,"f").video.facingMode,ni(this,qn,"f").video.deviceId={exact:t},!("closed"===this.state||this.videoSrc||"opening"===this.state&&ni(this,tr,"f"))){ni(this,ur,"f").fire("before:camera:change",[],{target:this,async:!1}),await ni(this,Yn,"m",Sr).call(this);try{this.resetSoftwareScale()}catch(t){}return ni(this,Kn,"f")}}async switchToFrontCamera(t){if("object"!=typeof ni(this,qn,"f").video&&(ni(this,qn,"f").video={}),(null==t?void 0:t.resolution)&&(ni(this,qn,"f").video.width={ideal:t.resolution.width},ni(this,qn,"f").video.height={ideal:t.resolution.height}),delete ni(this,qn,"f").video.deviceId,ni(this,qn,"f").video.facingMode={exact:"user"},ri(this,Jn,null),!("closed"===this.state||this.videoSrc||"opening"===this.state&&ni(this,tr,"f"))){ni(this,ur,"f").fire("before:camera:change",[],{target:this,async:!1}),ni(this,Yn,"m",Sr).call(this);try{this.resetSoftwareScale()}catch(t){}return ni(this,Kn,"f")}}getCamera(){var t;if(ni(this,Kn,"f"))return ni(this,Kn,"f");{let e=(null===(t=ni(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 ni(this,qn,"f").video&&(ni(this,qn,"f").video={}),i?(ni(this,qn,"f").video.width={exact:t},ni(this,qn,"f").video.height={exact:e}):(ni(this,qn,"f").video.width={ideal:t},ni(this,qn,"f").video.height={ideal:e}),"closed"===this.state||this.videoSrc||"opening"===this.state&&ni(this,tr,"f"))return null;ni(this,ur,"f").fire("before:resolution:change",[],{target:this,async:!1}),await ni(this,Yn,"m",Sr).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&&ni(this,Hn,"f"))return{width:ni(this,Hn,"f").videoWidth,height:ni(this,Hn,"f").videoHeight};if(ni(this,zn,"f")){const t=ni(this,zn,"f").getSettings();return{width:t.width,height:t.height}}if(this.isVideoLoaded())return{width:ni(this,Hn,"f").videoWidth,height:ni(this,Hn,"f").videoHeight};{const t={width:0,height:0};let e=ni(this,qn,"f").video.width||0,i=ni(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=ni(this,gr,"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=ni(this,Kn,"f"))||void 0===d?void 0:d.deviceId;let e=ni(this,gr,"f").get(u);if(e&&!t)return JSON.parse(JSON.stringify(e));e=[],ni(this,gr,"f").set(u,e),ri(this,nr,!0);try{for(let t of this.detectedResolutions){await ni(this,zn,"f").applyConstraints({width:{ideal:t.width},height:{ideal:t.height}}),ni(this,Yn,"m",yr).call(this);const i=ni(this,zn,"f").getSettings(),n={width:i.width,height:i.height};f(u,n)||e.push({width:n.width,height:n.height})}}catch(t){throw ni(this,Yn,"m",Tr).call(this),ri(this,nr,!1),t}try{await ni(this,Yn,"m",Cr).call(this)}catch(t){if("AbortError"===t.name)return e;throw t}finally{ri(this,nr,!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=ni(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=ni(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=ni(this,qn,"f"))||void 0===h?void 0:h.video)||void 0===c?void 0:c.deviceId);if(!i)return[];let d=ni(this,gr,"f").get(i);if(d&&!t)return JSON.parse(JSON.stringify(d));d=[],ni(this,gr,"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'.");ri(this,qn,JSON.parse(JSON.stringify(t))),ri(this,Jn,null),e&&ni(this,Yn,"m",Sr).call(this)}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(ni(this,qn,"f")))}resetMediaStreamConstraints(){ri(this,qn,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null)}getCameraCapabilities(){if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return ni(this,zn,"f").getCapabilities?ni(this,zn,"f").getCapabilities():{}}getCameraSettings(){if(!ni(this,zn,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return ni(this,zn,"f").getSettings()}async turnOnTorch(){if(!ni(this,zn,"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 ni(this,zn,"f").applyConstraints({advanced:[{torch:!0}]})}async turnOffTorch(){if(!ni(this,zn,"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 ni(this,zn,"f").applyConstraints({advanced:[{torch:!1}]})}async setColorTemperature(t,e){var i;if("number"!=typeof t)throw new TypeError("Invalid 'value'.");if(!ni(this,zn,"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=Br(t,n.min,n.step,n.max)),await ni(this,zn,"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(!ni(this,zn,"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=Br(t,n.min,n.step,n.max)),await ni(this,zn,"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(!ni(this,zn,"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 ni(this,zn,"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(!ni(this,zn,"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=Br(i,r.min,r.step,r.max)),this._focusParameters.focusArea=null,await ni(this,zn,"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 ni(this,Yn,"m",xr).call(this,e,i,n)}}}else this._focusParameters.focusArea=null,await ni(this,zn,"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(){ri(this,rr,!0)}disableTapToFocus(){ri(this,rr,!1)}isTapToFocusEnabled(){return ni(this,rr,"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?ni(this,Yn,"m",Rr).call(this,t.centerPoint):this.resetScaleCenter();try{if(ni(this,Yn,"m",Or).call(this,ni(this,cr,"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*ni(this,hr,"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(!ni(this,zn,"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=Br(t,n.min,n.step,n.max)),await ni(this,zn,"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&&ni(this,Yn,"m",Rr).call(this,e),ri(this,hr,t),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return ni(this,hr,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const t=this.getResolution();ri(this,cr,{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(ni(this,nr,"f"))return null;const e=Date.now();jr._onLog&&jr._onLog("getFrameData() START: "+e);const i=ni(this,Hn,"f").videoWidth,n=ni(this,Hn,"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=pi.RGBA;(null==t?void 0:t.pixelFormat)&&(s=t.pixelFormat);let a=ni(this,hr,"f");(null==t?void 0:t.scale)&&(a=t.scale);let o=ni(this,cr,"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(ni(this,Hn,"f"),r,{pixelFormat:s,bufferContainer:l,isEnableMirroring:null==t?void 0:t.isEnableMirroring});if(!h)return null;const c=Date.now();return jr._onLog&&jr._onLog("getFrameData() END: "+c),{data:h.data,width:h.width,height:h.height,pixelFormat:h.pixelFormat,timeSpent:c-e,timeStamp:c,toCanvas:ni(this,dr,"f")}}on(t,e){if(!ni(this,fr,"f").includes(t.toLowerCase()))throw new Error(`Event '${t}' does not exist.`);ni(this,ur,"f").on(t,e)}off(t,e){ni(this,ur,"f").off(t,e)}async dispose(){this.tapFocusEventBoundEl=null,await this.close(),this.releaseVideoEl(),ni(this,ur,"f").dispose(),this.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",ni(this,pr,"f")),ri(this,_r,!0)}}var Vr,Ur,Gr,Wr,Yr,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;Hn=new WeakMap,zn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,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,Yn=new WeakSet,vr=async function(){const t=this.getMediaStreamConstraints();if("boolean"==typeof t.video&&(t.video={}),t.video.deviceId);else if(ni(this,Jn,"f"))delete t.video.facingMode,t.video.deviceId={exact:ni(this,Jn,"f")};else if(this.ifSaveLastUsedCamera&&jr.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(ii.OS)?(await this._getCameras(!1),ni(this,Yn,"m",yr).call(this),e=jr.findBestCamera(this._arrCameras,"environment",{getMainCameraInIOS:this.selectIOSRearMainCameraAsDefault})):t||["Android","HarmonyOS","iPhone","iPad"].includes(ii.OS)||(await this._getCameras(!1),ni(this,Yn,"m",yr).call(this),e=jr.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},yr=function(){if(ni(this,tr,"f")){const t=new Error("The operation was interrupted.");throw t.name="AbortError",t}},wr=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{jr._onLog&&jr._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))),ni(this,Yn,"m",yr).call(this));try{jr._onLog&&jr._onLog("ask "+JSON.stringify(t)),n=await navigator.mediaDevices.getUserMedia(t),ni(this,Yn,"m",yr).call(this);break}catch(t){if("NotFoundError"===t.name||"NotAllowedError"===t.name||"AbortError"===t.name||"OverconstrainedError"===t.name)throw t;i=t,jr._onLog&&jr._onLog(t.message||t)}}};if(await r(t),!n&&"object"==typeof t.video&&(t.video.deviceId&&(delete t.video.deviceId,await r(t)),!n&&t.video.facingMode&&(delete t.video.facingMode,await r(t)),n||!t.video.width&&!t.video.height||(delete t.video.width,delete t.video.height,await r(t)),!n)){const t=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));for(let e of t){const t={video:{deviceId:{ideal:e.deviceId},facingMode:{ideal:"environment"},width:{ideal:1920},height:{ideal:1080}}};if(await r(t),n)break}}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}},Er=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach((t=>{t.stop()})),this._mediaStream=null),ri(this,zn,null)},Cr=async function(){ri(this,tr,!1);const t=ri(this,Qn,Symbol());if(ni(this,er,"f")&&"pending"===ni(this,ir,"f")){try{await ni(this,er,"f")}catch(t){}ni(this,Yn,"m",yr).call(this)}if(t!==ni(this,Qn,"f"))return;const e=ri(this,er,(async()=>{ri(this,ir,"pending");try{if(this.videoSrc){if(!ni(this,Hn,"f"))throw new Error("'videoEl' should be set.");await jr.playVideo(ni(this,Hn,"f"),this.videoSrc,this.cameraOpenTimeout),ni(this,Yn,"m",yr).call(this)}else{let t=await ni(this,Yn,"m",vr).call(this);ni(this,Yn,"m",Er).call(this);let e=await ni(this,Yn,"m",wr).call(this,t);await this._getCameras(!1),ni(this,Yn,"m",yr).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=ni(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),!(ni(this,Jn,"f")||this.ifSaveLastUsedCamera&&jr.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||this.ifSkipCameraInspection||n.video.deviceId)){const n=i(),s=jr.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 ni(this,Yn,"m",wr).call(this,t),ni(this,Yn,"m",yr).call(this))}}const r=i();(null==r?void 0:r.deviceId)&&(ri(this,Jn,r&&r.deviceId),this.ifSaveLastUsedCamera&&jr.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",ni(this,Jn,"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))))),ni(this,Hn,"f")&&(await jr.playVideo(ni(this,Hn,"f"),e,this.cameraOpenTimeout),ni(this,Yn,"m",yr).call(this)),this._mediaStream=e;const s=e.getVideoTracks();(null==s?void 0:s.length)&&ri(this,zn,s[0]),ri(this,Kn,r)}}catch(t){throw ni(this,Yn,"m",Tr).call(this),ri(this,ir,null),t}ri(this,ir,"fulfilled")})());return e},Sr=async function(){var t;if("closed"===this.state||this.videoSrc)return;const e=null===(t=ni(this,Kn,"f"))||void 0===t?void 0:t.deviceId,i=this.getResolution();await ni(this,Yn,"m",Cr).call(this);const n=this.getResolution();e&&e!==ni(this,Kn,"f").deviceId&&ni(this,ur,"f").fire("camera:changed",[ni(this,Kn,"f").deviceId,e],{target:this,async:!1}),i.width==n.width&&i.height==n.height||ni(this,ur,"f").fire("resolution:changed",[{width:n.width,height:n.height},{width:i.width,height:i.height}],{target:this,async:!1}),ni(this,ur,"f").fire("played",null,{target:this,async:!1})},Tr=function(){ni(this,Yn,"m",Er).call(this),ri(this,Kn,null),ni(this,Hn,"f")&&(ni(this,Hn,"f").srcObject=null,this.videoSrc&&(ni(this,Hn,"f").pause(),ni(this,Hn,"f").currentTime=0)),ri(this,tr,!0);try{this.resetSoftwareScale()}catch(t){}},br=async function t(e,i){const n=t=>{if(!ni(this,zn,"f")||!this.isVideoPlaying||t.focusTaskId!=this._focusParameters.curFocusTaskId){ni(this,zn,"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=Br(i,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await ni(this,zn,"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(ni(this,Hn,"f"),{sx:s,sy:a,sWidth:o,sHeight:l,dWidth:o,dHeight:l},{pixelFormat:pi.RGBA,bufferContainer:u}))return ni(this,Yn,"m",t).call(this,e,i);const f=u;let g=0;for(let t=0,e=d-8;to&&od)return await ni(this,Yn,"m",t).call(this,e,a,o,r,s,c,d)}else{let l=await ni(this,Yn,"m",br).call(this,e,c);if(o>l)return await ni(this,Yn,"m",t).call(this,e,a,o,r,s,c,l);if(o==l)return await ni(this,Yn,"m",t).call(this,e,a,o,c,l);let d=await ni(this,Yn,"m",br).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!==ni(this,hr,"f")){const t=ni(this,hr,"f"),e=ni(this,cr,"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=Br(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=Br(Math.sqrt((e||this._focusParameters.fds.step)*n),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=Br(Math.sqrt(n*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),a=await ni(this,Yn,"m",br).call(this,t,s),o=await ni(this,Yn,"m",br).call(this,t,r),l=await ni(this,Yn,"m",br).call(this,t,n);if(o>l&&la&&o>a){let e=await ni(this,Yn,"m",br).call(this,t,i);const r=await ni(this,Yn,"m",Ir).call(this,t,n,l,i,e,s,a);return this._focusParameters.isDoingFocus=0,r}if(o==l&&l l){const e=await ni(this,Yn,"m",Ir).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)},Rr=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.");ri(this,cr,{x:i,y:n})},Or=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},jr.browserInfo=ii,jr.onWarning=null===(Wn=null===window||void 0===window?void 0:window.console)||void 0===Wn?void 0:Wn.warn;class Cs{constructor(t){Vr.add(this),Ur.set(this,void 0),Gr.set(this,0),Wr.set(this,void 0),Yr.set(this,0),Hr.set(this,!1),ri(this,Ur,t)}startCharging(){ni(this,Hr,"f")||(Cs._onLog&&Cs._onLog("start charging."),ni(this,Vr,"m",Xr).call(this),ri(this,Hr,!0))}stopCharging(){ni(this,Wr,"f")&&clearTimeout(ni(this,Wr,"f")),ni(this,Hr,"f")&&(Cs._onLog&&Cs._onLog("stop charging."),ri(this,Gr,Date.now()-ni(this,Yr,"f")),ri(this,Hr,!1))}}Ur=new WeakMap,Gr=new WeakMap,Wr=new WeakMap,Yr=new WeakMap,Hr=new WeakMap,Vr=new WeakSet,zr=function(){Dt.cfd(1),Cs._onLog&&Cs._onLog("charge 1.")},Xr=function t(){0==ni(this,Gr,"f")&&ni(this,Vr,"m",zr).call(this),ri(this,Yr,Date.now()),ni(this,Wr,"f")&&clearTimeout(ni(this,Wr,"f")),ri(this,Wr,setTimeout((()=>{ri(this,Gr,0),ni(this,Vr,"m",t).call(this)}),ni(this,Ur,"f")-ni(this,Gr,"f")))};class Ss{static beep(){if(!this.allowBeep)return;if(!this.beepSoundSource)return;let t,e=Date.now();if(!(e-ni(this,Zr,"f",Jr)<100)){if(ri(this,Zr,e,0,Jr),ni(this,Zr,"f",qr).size&&(t=ni(this,Zr,"f",qr).values().next().value,this.beepSoundSource==t.src?(ni(this,Zr,"f",qr).delete(t),t.play()):t=null),!t)if(ni(this,Zr,"f",Kr).size<16){t=new Audio(this.beepSoundSource);let e=null,i=()=>{t.removeEventListener("loadedmetadata",i),t.play(),e=setTimeout((()=>{ni(this,Zr,"f",Kr).delete(t)}),2e3*t.duration)};t.addEventListener("loadedmetadata",i),t.addEventListener("ended",(()=>{null!=e&&(clearTimeout(e),e=null),t.pause(),t.currentTime=0,ni(this,Zr,"f",Kr).delete(t),ni(this,Zr,"f",qr).add(t)}))}else ni(this,Zr,"f",$r)||(ri(this,Zr,!0,0,$r),console.warn("The requested audio tracks exceed 16 and will not be played."));t&&ni(this,Zr,"f",Kr).add(t)}}static vibrate(){if(this.allowVibrate){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(Ss.vibrateDuration)}}}Zr=Ss,qr={value:new Set},Kr={value:new Set},Jr={value:0},$r={value:!1},Ss.allowBeep=!0,Ss.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",Ss.allowVibrate=!0,Ss.vibrateDuration=300;const Ts=new Map([[pi.GREY,l.IPF_GRAYSCALED],[pi.RGBA,l.IPF_ABGR_8888]]),bs="function"==typeof BigInt?t=>BigInt(t):t=>t,Is=(bs("0x00"),bs("0xFFFFFFFFFFFFFFFF"),bs("0xFE3BFFFF"),bs("0x003007FF")),xs=(bs("0x0003F800"),bs("0x1"),bs("0x2"),bs("0x4"),bs("0x8"),bs("0x10"),bs("0x20"),bs("0x40"),bs("0x80"),bs("0x100"),bs("0x200"),bs("0x400"),bs("0x800"),bs("0x1000"),bs("0x2000"),bs("0x4000"),bs("0x8000"),bs("0x10000"),bs("0x20000"),bs("0x00040000"),bs("0x01000000"),bs("0x02000000"),bs("0x04000000")),Rs=bs("0x08000000");bs("0x10000000"),bs("0x20000000"),bs("0x40000000"),bs("0x00080000"),bs("0x80000000"),bs("0x100000"),bs("0x200000"),bs("0x400000"),bs("0x800000"),bs("0x1000000000"),bs("0x3F0000000000000"),bs("0x100000000"),bs("0x10000000000000"),bs("0x20000000000000"),bs("0x40000000000000"),bs("0x80000000000000"),bs("0x100000000000000"),bs("0x200000000000000"),bs("0x200000000"),bs("0x400000000"),bs("0x800000000"),bs("0xC00000000"),bs("0x2000000000"),bs("0x4000000000");class Os extends Z{static set _onLog(t){ri(Os,ts,t,0,es),jr._onLog=t,Cs._onLog=t}static get _onLog(){return ni(Os,ts,"f",es)}static async detectEnvironment(){return await(async()=>({wasm:si,worker:ai,getUserMedia:oi,camera:await li(),browser:ii.browser,version:ii.version,OS:ii.OS}))()}static async testCameraAccess(){const t=await jr.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 kr))throw new TypeError("Invalid view.");if(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 Dt.loadWasm(),await xt.license.dynamsoft()}const n=new Os(t);return Os.onWarning&&(location&&"file:"===location.protocol?setTimeout((()=>{Os.onWarning&&Os.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((()=>{Os.onWarning&&Os.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.");ri(this,ss,t)}get singleFrameMode(){return ni(this,ss,"f")}get _isFetchingStarted(){return ni(this,ds,"f")}get disposed(){return ni(this,ps,"f")}constructor(t){if(super(),Qr.add(this),is.set(this,"closed"),ns.set(this,void 0),rs.set(this,void 0),this._isEnableMirroring=!1,this.isTorchOn=void 0,ss.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()},as.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?pi.GREY:pi.RGBA});let h=null;if(o){const t=Date.now();let a;a=o.pixelFormat===pi.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:Ts.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:ni(this,os,"f"),isDCEFrame:!0}}return h})),this._onSingleFrameAcquired=t=>{let e;e=this.cameraView?this.cameraView.getConvertedRegion():Xi.convert(ni(this,hs,"f"),t.width,t.height,this.cameraView),e||(e={x:0,y:0,width:t.width,height:t.height});const i=ni(this,as,"f").call(this,t,t.width,t.height,e);ni(this,ns,"f").fire("singleFrameAcquired",[i],{async:!1,copy:!1})},os.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(ii.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",(()=>{ni(this,ms,"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",(()=>{ni(this,ms,"f").stopCharging();const t=this.cameraView;t&&t.disposed})),this._on("resumed",(()=>{const t=this.cameraView;t&&t.disposed})),this._on("tapfocus",(()=>{ni(this,fs,"f").tapToFocus&&ni(this,ms,"f").startCharging()})),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=async(t,e)=>{var i,n,r,s;const a=t.intermediateResultUnits;if(ni(this,Qr,"m",_s).call(this)||!this.isOpen()||this.isPaused()||a[0]&&!a[0].originalImageTag)return;Os._onLog&&(Os._onLog("intermediateResultUnits:"),Os._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(Os._onLog&&(Os._onLog("hasLocalizedBarcodes:"),Os._onLog(l)),ni(this,fs,"f").autoZoom||ni(this,fs,"f").enhancedFocus)if(o)ni(this,gs,"f").autoZoomInFrameArray.length=0,ni(this,gs,"f").autoZoomOutFrameCount=0,ni(this,gs,"f").frameArrayInIdealZoom.length=0,ni(this,gs,"f").autoFocusFrameArray.length=0;else{const e=async t=>{await this.setZoom(t),ni(this,fs,"f").autoZoom&&ni(this,ms,"f").startCharging()},o=async t=>{await this.setFocus(t),ni(this,fs,"f").enhancedFocus&&ni(this,ms,"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-ni(this,gs,"f").autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+ni(this,gs,"f").autoZoomDetectionArea)/2,i=e,n=t,s=this.video.videoHeight*(1-ni(this,gs,"f").autoZoomDetectionArea)/2,a=s,o=this.video.videoHeight*(1+ni(this,gs,"f").autoZoomDetectionArea)/2;r=[{x:t,y:s},{x:e,y:a},{x:i,y:o},{x:n,y:o}]}Os._onLog&&(Os._onLog("detectionArea:"),Os._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!=$i(o.y-i)>0&&$i(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)=>!!(Qi([t[0],t[1]],[t[2],t[3]],[e[0].x,e[0].y],[e[1].x,e[1].y])||Qi([t[0],t[1]],[t[2],t[3]],[e[1].x,e[1].y],[e[2].x,e[2].y])||Qi([t[0],t[1]],[t[2],t[3]],[e[2].x,e[2].y],[e[3].x,e[3].y])||Qi([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=>{kr._transformCoordinates(t,h,c,d,u,f,g)})),t(r,e)&&s.push(i)}if(Os._debug&&this.cameraView){const t=this.__layer||(this.__layer=this.cameraView._createDrawingLayer(99));t.clearDrawingItems();const e=this.__styleId2||(this.__styleId2=Dr.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 Ni({points:i},e);t.addDrawingItems([r])}}}if(Os._onLog&&(Os._onLog("intersectedResults:"),Os._onLog(s)),!s.length)return;let o;if(s.length){let t=s.filter((t=>t.possibleFormats==xs||t.possibleFormats==Rs));if(t.length||(t=s.filter((t=>t.possibleFormats==Is)),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{})),ni(this,gs,"f").autoZoomInFrameArray.filter((t=>!0===t)).length>=ni(this,gs,"f").autoZoomInFrameLimit[1]){ni(this,gs,"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,ni(this,gs,"f").autoZoomInIdealModuleSize/m.result.moduleSize),h=this.getZoomSettings().factor;let c=Math.max(Math.pow(h*o,1/ni(this,gs,"f").autoZoomInMaxTimes),ni(this,gs,"f").autoZoomInMinStep);c=Math.min(c,o);let d=h*c;d=Math.max(ni(this,gs,"f").minValue,d),d=Math.min(ni(this,gs,"f").maxValue,d);try{await e({factor:d})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}}else if(ni(this,gs,"f").autoZoomInFrameArray.length=0,ni(this,gs,"f").frameArrayInIdealZoom.push(!0),ni(this,gs,"f").frameArrayInIdealZoom.splice(0,ni(this,gs,"f").frameArrayInIdealZoom.length-ni(this,gs,"f").frameLimitInIdealZoom[0]),ni(this,gs,"f").frameArrayInIdealZoom.filter((t=>!0===t)).length>=ni(this,gs,"f").frameLimitInIdealZoom[1]&&(ni(this,gs,"f").frameArrayInIdealZoom.length=0,ni(this,fs,"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(!ni(this,fs,"f").autoZoom&&ni(this,fs,"f").enhancedFocus&&(ni(this,gs,"f").autoFocusFrameArray.push(!0),ni(this,gs,"f").autoFocusFrameArray.splice(0,ni(this,gs,"f").autoFocusFrameArray.length-ni(this,gs,"f").autoFocusFrameLimit[0]),ni(this,gs,"f").autoFocusFrameArray.filter((t=>!0===t)).length>=ni(this,gs,"f").autoFocusFrameLimit[1])){ni(this,gs,"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(ni(this,fs,"f").autoZoom){if(ni(this,gs,"f").autoZoomInFrameArray.push(!1),ni(this,gs,"f").autoZoomInFrameArray.splice(0,ni(this,gs,"f").autoZoomInFrameArray.length-ni(this,gs,"f").autoZoomInFrameLimit[0]),ni(this,gs,"f").autoZoomOutFrameCount++,ni(this,gs,"f").frameArrayInIdealZoom.push(!1),ni(this,gs,"f").frameArrayInIdealZoom.splice(0,ni(this,gs,"f").frameArrayInIdealZoom.length-ni(this,gs,"f").frameLimitInIdealZoom[0]),ni(this,gs,"f").autoZoomOutFrameCount>=ni(this,gs,"f").autoZoomOutFrameLimit){ni(this,gs,"f").autoZoomOutFrameCount=0;const i=this.getZoomSettings().factor;let n=i-Math.max((i-1)*ni(this,gs,"f").autoZoomOutStepRate,ni(this,gs,"f").autoZoomOutMinStep);n=Math.max(ni(this,gs,"f").minValue,n),n=Math.min(ni(this,gs,"f").maxValue,n);try{await e({factor:n})}catch(t){const e=t.message||t;console.warn(e)}this.clearBuffer()}ni(this,fs,"f").enhancedFocus&&o({mode:"continuous"}).catch((()=>{}))}!ni(this,fs,"f").autoZoom&&ni(this,fs,"f").enhancedFocus&&(ni(this,gs,"f").autoFocusFrameArray.length=0,o({mode:"continuous"}).catch((()=>{})))}}},ri(this,ms,new Cs(1e4))}setCameraView(t){if(!(t instanceof kr))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),ni(this,Qr,"m",_s).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;ni(this,Qr,"m",_s).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 ni(this,Qr,"m",_s).call(this)?ni(this,is,"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,ni(this,Qr,"m",_s).call(this)?e._clickIptSingleFrameMode():(this.cameraManager.setVideoEl(e.getVideoElement()),e._startLoading()));let i={width:0,height:0,deviceId:""};if(ni(this,Qr,"m",_s).call(this));else{try{await this.cameraManager.open(),ri(this,rs,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=Ss.allowBeep?"":"none"),o&&(o.style.display=Ss.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=Ss.allowVibrate?"":"none"),h&&(h.style.display=Ss.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=()=>{Ss.allowBeep=!Ss.allowBeep,a&&(a.style.display=Ss.allowBeep?"":"none"),o&&(o.style.display=Ss.allowBeep?"none":"")};for(let t of[o,a])null==t||t.addEventListener("pointerdown",E);const C=()=>{Ss.allowVibrate=!Ss.allowVibrate,l&&(l.style.display=Ss.allowVibrate?"":"none"),h&&(h.style.display=Ss.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==ii?void 0:ii.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 ri(this,is,"open"),e&&(e._innerComponent.style.display="",ni(this,Qr,"m",_s).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),ni(this,ns,"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(),ni(this,Qr,"m",_s).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())}ri(this,is,"closed"),ni(this,ms,"f").stopCharging(),e&&(e._innerComponent.style.display="none",ni(this,Qr,"m",_s).call(this)&&e._innerComponent.removeElement("content"),e._stopLoading()),ni(this,ns,"f").fire("closed",null,{target:this,async:!1})}pause(){if(ni(this,Qr,"m",_s).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");this.cameraManager.pause()}isPaused(){var t;return!ni(this,Qr,"m",_s).call(this)&&!0===(null===(t=this.video)||void 0===t?void 0:t.paused)}async resume(){if(ni(this,Qr,"m",_s).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),{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())?ni(this,ns,"f").on(t,e):this.cameraManager.on(t,e)}_off(t,e){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(t.toLowerCase())?ni(this,ns,"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(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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.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=Os._onLog)||void 0===t||t.call(Os,`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(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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){ni(this,gs,"f").minValue=t.min,ni(this,gs,"f").maxValue=t.max}getAutoZoomRange(){return{min:ni(this,gs,"f").minValue,max:ni(this,gs,"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!==Dt.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");t&mi.EF_ENHANCED_FOCUS&&(ni(this,fs,"f").enhancedFocus=!0),t&mi.EF_AUTO_ZOOM&&(ni(this,fs,"f").autoZoom=!0),t&mi.EF_TAP_TO_FOCUS&&(ni(this,fs,"f").tapToFocus=!0,this.cameraManager.enableTapToFocus())}disableEnhancedFeatures(t){t&mi.EF_ENHANCED_FOCUS&&(ni(this,fs,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch((()=>{}))),t&mi.EF_AUTO_ZOOM&&(ni(this,fs,"f").autoZoom=!1,this.resetZoom().catch((()=>{}))),t&mi.EF_TAP_TO_FOCUS&&(ni(this,fs,"f").tapToFocus=!1,this.cameraManager.disableTapToFocus()),ni(this,Qr,"m",ys).call(this)&&ni(this,Qr,"m",vs).call(this)||ni(this,ms,"f").stopCharging()}_setScanRegion(t){if(null!=t&&!y(t)&&!b(t))throw TypeError("Invalid 'region'.");ri(this,hs,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(ni(this,hs,"f")))}setErrorListener(t){if(!t)throw new TypeError("Invalid 'listener'");ri(this,ls,t)}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!this.cameraManager.isVideoLoaded()||ni(this,Qr,"m",_s).call(this))}startFetching(){if(ni(this,Qr,"m",_s).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");ni(this,ds,"f")||(ri(this,ds,!0),ni(this,Qr,"m",ws).call(this))}stopFetching(){ni(this,ds,"f")&&(Os._onLog&&Os._onLog("DCE: stop fetching loop: "+Date.now()),ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),ri(this,ds,!1))}toggleMirroring(t){this.isOpen()&&(this.video.style.transform=`scaleX(${t?"-1":"1"})`),this._isEnableMirroring=t}fetchImage(t=!1){if(ni(this,Qr,"m",_s).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(4!==this.video.readyState)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;if(i=Xi.convert(ni(this,hs,"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.");i.x+i.width>e.width&&(i.width=e.width-i.x),i.y+i.height>e.height&&(i.height=e.height-i.y);const n=this.cameraView.regionMaskLineWidth;let r;r=ni(this,hs,"f")&&!t?{sx:i.x+n,sy:i.y+n,sWidth:i.width-2*n,sHeight:i.height-2*n,dWidth:i.width-2*n,dHeight:i.height-2*n}:{sx:i.x,sy:i.y,sWidth:i.width,sHeight:i.height,dWidth:i.width,dHeight:i.height};const s=Math.max(r.dWidth,r.dHeight);if(this.canvasSizeLimit&&s>this.canvasSizeLimit){const t=this.canvasSizeLimit/s;r.dWidth>r.dHeight?(r.dWidth=this.canvasSizeLimit,r.dHeight=Math.round(r.dHeight*t)):(r.dWidth=Math.round(r.dWidth*t),r.dHeight=this.canvasSizeLimit)}const a=this.cameraManager.getFrameData({position:r,pixelFormat:this.getPixelFormat()===l.IPF_GRAYSCALED?pi.GREY:pi.RGBA,isEnableMirroring:this._isEnableMirroring});if(!a)return null;let o;o=a.pixelFormat===pi.GREY?a.width:4*a.width;let h=!0;return 0===r.sx&&0===r.sy&&r.sWidth===e.width&&r.sHeight===e.height&&(h=!1),{bytes:a.data,width:a.width,height:a.height,stride:o,format:Ts.get(a.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:rt.ITT_VIDEO_FRAME,isCropped:h,cropRegion:{left:r.sx,top:r.sy,right:r.sx+r.sWidth,bottom:r.sy+r.sHeight,isMeasuredInPercentage:!1},originalWidth:e.width,originalHeight:e.height,currentWidth:a.width,currentHeight:a.height,timeSpent:a.timeSpent,timeStamp:a.timeStamp},toCanvas:ni(this,os,"f"),isDCEFrame:!0}}setImageFetchInterval(t){this.fetchInterval=t,ni(this,ds,"f")&&(ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),ri(this,us,setTimeout((()=>{this.disposed||ni(this,Qr,"m",ws).call(this)}),t)))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(t){ri(this,cs,t)}getPixelFormat(){return ni(this,cs,"f")}takePhoto(t){if(!this.isOpen())throw new Error("Not open.");if(ni(this,Qr,"m",_s).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=Xi.convert(ni(this,hs,"f"),r,s,this.cameraView);a||(a={x:0,y:0,width:r,height:s});const o=ni(this,as,"f").call(this,n,r,s,a);t&&t(o)})),document.body.appendChild(e),e.click()}convertToPageCoordinates(t){const e=ni(this,Qr,"m",Es).call(this,t);return{x:e.pageX,y:e.pageY}}convertToClientCoordinates(t){const e=ni(this,Qr,"m",Es).call(this,t);return{x:e.clientX,y:e.clientY}}convertToScanRegionCoordinates(t){if(!ni(this,hs,"f"))return JSON.parse(JSON.stringify(t));if(this.isOpen()){const t=this.cameraView.getVisibleRegionOfVideo({inPixels:!0});ri(this,rs,t||ni(this,rs,"f"))}let e,i,n=ni(this,hs,"f").left||ni(this,hs,"f").x||0,r=ni(this,hs,"f").top||ni(this,hs,"f").y||0;if(!ni(this,hs,"f").isMeasuredInPercentage)return{x:t.x-(n+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").x),y:t.y-(r+this.cameraView.regionMaskLineWidth+ni(this,rs,"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(!ni(this,Qr,"m",_s).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(ni(this,Qr,"m",_s).call(this)&&!this.cameraView._cvsSingleFrameMode)throw new Error("No image is selected.");if(ni(this,Qr,"m",_s).call(this)){const t=this.cameraView._innerComponent.getElement("content");e=t.width,i=t.height}else e=ni(this,rs,"f").width,i=ni(this,rs,"f").height;return{x:t.x-(Math.round(n*e/100)+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").x),y:t.y-(Math.round(r*i/100)+this.cameraView.regionMaskLineWidth+ni(this,rs,"f").y)}}dispose(){this.close(),this.cameraManager.dispose(),this.releaseCameraView(),ri(this,ps,!0)}}var Ds,As,Ms,Ls,Fs,Ps,ks,Ns;ts=Os,is=new WeakMap,ns=new WeakMap,rs=new WeakMap,ss=new WeakMap,as=new WeakMap,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,Qr=new WeakSet,_s=function(){return"disabled"!==this.singleFrameMode},vs=function(){return!this.videoSrc&&"opened"===this.cameraManager.state},ys=function(){for(let t in ni(this,fs,"f"))if(1==ni(this,fs,"f")[t])return!0;return!1},ws=function t(){if(this.disposed)return;if("open"!==this.getCameraState()||!ni(this,ds,"f"))return ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),void ri(this,us,setTimeout((()=>{this.disposed||ni(this,Qr,"m",t).call(this)}),this.fetchInterval));const e=()=>{var t;let e;Os._onLog&&Os._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=ni(this,ls,"f"))||void 0===t?void 0:t.onErrorReceived)return void setTimeout((()=>{var t;null===(t=ni(this,ls,"f"))||void 0===t||t.onErrorReceived(et.EC_IMAGE_READ_FAILED,i)}),0);console.warn(e)}e?(this.addImageToBuffer(e),Os._onLog&&Os._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),ni(this,ns,"f").fire("frameAddedToBuffer",null,{async:!1})):Os._onLog&&Os._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();ni(this,us,"f")&&clearTimeout(ni(this,us,"f")),ri(this,us,setTimeout((()=>{this.disposed||ni(this,Qr,"m",t).call(this)}),this.fetchInterval))},Es=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(!ni(this,Qr,"m",_s).call(this)&&!this.cameraManager.isVideoLoaded())throw new Error("Video is not loaded.");if(ni(this,Qr,"m",_s).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(ni(this,Qr,"m",_s).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(ni(this,Ls,"f")||ri(this,Ls,new Bs),!ni(this,Ls,"f").magnifierCanvas)return;document.body.contains(ni(this,Ls,"f").magnifierCanvas)||(ni(this,Ls,"f").magnifierCanvas.style.position="fixed",ni(this,Ls,"f").magnifierCanvas.style.boxSizing="content-box",ni(this,Ls,"f").magnifierCanvas.style.border="2px solid #FFFFFF",document.body.append(ni(this,Ls,"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 ni(this,Ps,"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}];ni(this,Ls,"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?(ni(this,Ls,"f").magnifierCanvas.style.left="auto",ni(this,Ls,"f").magnifierCanvas.style.top="0",ni(this,Ls,"f").magnifierCanvas.style.right="0"):(ni(this,Ls,"f").magnifierCanvas.style.left="0",ni(this,Ls,"f").magnifierCanvas.style.top="0",ni(this,Ls,"f").magnifierCanvas.style.right="auto")}ni(this,Ls,"f").show()})),Ps.set(this,(()=>{ni(this,Ls,"f")&&ni(this,Ls,"f").hide()})),ks.set(this,!1)}_setUIElement(t){this.UIElement=t,this._unbindUI(),this._bindUI()}async setUIElement(t){let e;if("string"==typeof t){let i=await tn(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)){ri(this,Ms,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(!Us){if(!Vs&&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"./"}})(),Ws=t=>{if(null==t&&(t="./"),Vs||Us);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.dbr={version:"11.0.30-dev-20250604160153",path:Gs,isInternal:!0},Rt.dbr={js:!1,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.dbr={};const Ys="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ys)<0&&(Dt.engineResourcePaths.std={version:Ys,path:Ws(Gs+`../../dynamsoft-capture-vision-std@${Ys}/dist/`),isInternal:!0});const Hs="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,Hs)<0)&&(Dt.engineResourcePaths.dip={version:Hs,path:Ws(Gs+`../../dynamsoft-image-processing@${Hs}/dist/`),isInternal:!0});const zs={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 Xs,Zs,qs,Ks;function Js(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(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"}(Xs||(Xs={})),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"}(Zs||(Zs={})),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=-1]="LM_END"}(qs||(qs={})),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"}(Ks||(Ks={})),"function"==typeof SuppressedError&&SuppressedError;const $s="undefined"==typeof self,Qs=(()=>{if(!$s&&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"./"})(),ta=t=>{if(null==t&&(t="./"),$s);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};var ea,ia;Dt.engineResourcePaths.dlr={version:"4.0.30-dev-20250604160409",path:Qs,isInternal:!0},Rt.dlr={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]};const na="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,na)<0&&(Dt.engineResourcePaths.std={version:na,path:ta(Qs+`../../dynamsoft-capture-vision-std@${na}/dist/`),isInternal:!0});const ra="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,ra)<0)&&(Dt.engineResourcePaths.dip={version:ra,path:ta(Qs+`../../dynamsoft-image-processing@${ra}/dist/`),isInternal:!0});let sa=class t{static getVersion(){const t=It.dlr&&It.dlr.wasm;return`4.0.30-dev-20250604160409(Worker: ${It.dlr&&It.dlr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadConfusableCharsData(e,i){return Js(t,ea,"m",ia).call(t,"confusable",e,i)}static async loadOverlappingCharsData(e,i){return Js(t,ea,"m",ia).call(t,"overlapping",e,i)}};ea=sa,ia=async function(t,e,i){return await Dt.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(Dt.engineResourcePaths);vt.postMessage({type:"dlr_loadData",id:s,body:{type:t,dataName:e,dataPath:i||a.dcvData+"char-resources/"}})}))},xt.dlr={loadConfusableCharsData:sa.loadConfusableCharsData,loadOverlappingCharsData:sa.loadOverlappingCharsData};const aa={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 oa,la,ha;function ca(t){delete t.moduleId;const e=JSON.parse(t.jsonString).ResultInfo,i=t.fullCodeString;t.getFieldValue=t=>"fullcodestring"===t.toLowerCase()?i:da(e,t,"map"),t.getFieldRawValue=t=>da(e,t,"raw"),t.getFieldMappingStatus=t=>ua(e,t),t.getFieldValidationStatus=t=>fa(e,t),delete t.fullCodeString}function da(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=da(r,e,i);if(void 0!==t)return t}}}function ua(t,e){for(let i of t){if(i.FieldName===e)return i.MappingStatus?Number(la[i.MappingStatus]):la.MS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=ua(n,e);if(void 0!==t)return t}}}function fa(t,e){for(let i of t){if(i.FieldName===e&&i.ValidationStatus)return i.ValidationStatus?Number(ha[i.ValidationStatus]):ha.VS_NONE;if(i.ChildFields&&i.ChildFields.length>0){let t;for(let n of i.ChildFields)t=fa(n,e);if(void 0!==t)return t}}}function ga(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"}(oa||(oa={})),Et[-1]=async t=>{sa.onDataLoadProgressChanged&&sa.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"}(la||(la={})),function(t){t[t.VS_NONE=0]="VS_NONE",t[t.VS_SUCCEEDED=1]="VS_SUCCEEDED",t[t.VS_FAILED=2]="VS_FAILED"}(ha||(ha={}));const ma=t=>t&&"object"==typeof t&&"function"==typeof t.then,pa=(async()=>{})().constructor;let _a=class extends pa{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,ma(t)?e=t:"function"==typeof t&&(e=new pa(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&&(ma(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}};class va{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 Dt.loadWasm();const t=new va,e=new _a;let i=wt();return Et[i]=async i=>{if(i.success)t._instanceID=i.instanceID,e.resolve(t);else{const t=Error(i.message);i.stack&&(t.stack=i.stack),e.reject(t)}},vt.postMessage({type:"dcp_createInstance",id:i}),e}async dispose(){ga(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){return ga(this),t&&["string","object"].includes(typeof t)?("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 ga(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(ga(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)):(ca(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}})}))}}const ya="undefined"==typeof self,wa="function"==typeof importScripts,Ea=(()=>{if(!wa){if(!ya&&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"./"}})();Dt.engineResourcePaths.dcp={version:"3.0.30-dev-20250604160317",path:Ea,isInternal:!0},Rt.dcp={js:!0,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE]},xt.dcp={handleParsedResultItem:ca};const Ca="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ca)<0&&(Dt.engineResourcePaths.std={version:Ca,path:(t=>{if(null==t&&(t="./"),ya||wa);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Ea+`../../dynamsoft-capture-vision-std@${Ca}/dist/`),isInternal:!0});let Sa=class{static getVersion(){const t=It.dcp&&It.dcp.wasm;return`3.0.30-dev-20250604160317(Worker: ${It.dcp&&It.dcp.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}static async loadSpec(t,e){return await Dt.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(Dt.engineResourcePaths);vt.postMessage({type:"dcp_appendResourceBuffer",id:r,body:{specificationPath:e||a.dcvData+"parser-resources/",specificationNames:s}})}))}};const Ta="undefined"==typeof self,ba="function"==typeof importScripts,Ia=(()=>{if(!ba){if(!Ta&&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"./"}})(),xa=t=>{if(null==t&&(t="./"),Ta||ba);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.ddn={version:"3.0.30-dev-20250604160349",path:Ia,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 Ra="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ra)<0&&(Dt.engineResourcePaths.std={version:Ra,path:xa(Ia+`../../dynamsoft-capture-vision-std@${Ra}/dist/`),isInternal:!0});const Oa="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,Oa)<0)&&(Dt.engineResourcePaths.dip={version:Oa,path:xa(Ia+`../../dynamsoft-image-processing@${Oa}/dist/`),isInternal:!0});var Da;!function(t){t[t.ICM_COLOUR=0]="ICM_COLOUR",t[t.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",t[t.ICM_BINARY=2]="ICM_BINARY"}(Da||(Da={}));const Aa="undefined"==typeof self,Ma="function"==typeof importScripts,La=(()=>{if(!Ma){if(!Aa&&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"./"}})(),Fa=t=>{if(null==t&&(t="./"),Aa||Ma);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.utility={version:"2.0.30-dev-20250604160458",path:La,isInternal:!0},Rt.utility={js:!0,wasm:!0};const Pa="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Pa)<0&&(Dt.engineResourcePaths.std={version:Pa,path:Fa(La+`../../dynamsoft-capture-vision-std@${Pa}/dist/`),isInternal:!0});const ka="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,ka)<0)&&(Dt.engineResourcePaths.dip={version:ka,path:Fa(La+`../../dynamsoft-image-processing@${ka}/dist/`),isInternal:!0});function Na(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"==typeof SuppressedError&&SuppressedError;const Ba="undefined"==typeof self,ja="function"==typeof importScripts,Va=(()=>{if(!ja){if(!Ba&&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"./"}})(),Ua=t=>{if(null==t&&(t="./"),Ba||ja);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};Dt.engineResourcePaths.dbr={version:"11.0.30-dev-20250522174049",path:Va,isInternal:!0},Rt.dbr={js:!1,wasm:!0,deps:[ft.MN_DYNAMSOFT_LICENSE,ft.MN_DYNAMSOFT_IMAGE_PROCESSING]},xt.dbr={};const Ga="2.0.0";"string"!=typeof Dt.engineResourcePaths.std&&x(Dt.engineResourcePaths.std.version,Ga)<0&&(Dt.engineResourcePaths.std={version:Ga,path:Ua(Va+`../../dynamsoft-capture-vision-std@${Ga}/dist/`),isInternal:!0});const Wa="3.0.10";(!Dt.engineResourcePaths.dip||"string"!=typeof Dt.engineResourcePaths.dip&&x(Dt.engineResourcePaths.dip.version,Wa)<0)&&(Dt.engineResourcePaths.dip={version:Wa,path:Ua(Va+`../../dynamsoft-image-processing@${Wa}/dist/`),isInternal:!0});const Ya={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 Ha,za,Xa,Za,qa,Ka,Ja,$a,Qa,to;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}}const fo={barcode:2,text_line:4,detected_quad:8,normalized_image:16},go=t=>Object.values(fo).includes(t)||fo.hasOwnProperty(t),mo=(t,e)=>"string"==typeof t?e[fo[t]]:e[t],po=(t,e,i)=>{"string"==typeof t?e[fo[t]]=i:e[t]=i},_o=(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 vo{constructor(){this.verificationEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!0,[Q.CRIT_DETECTED_QUAD]:!0,[Q.CRIT_DESKEWED_IMAGE]:!1},this.duplicateFilterEnabled={[Q.CRIT_BARCODE]:!1,[Q.CRIT_TEXT_LINE]:!1,[Q.CRIT_DETECTED_QUAD]:!1,[Q.CRIT_DESKEWED_IMAGE]:!1},this.duplicateForgetTime={[Q.CRIT_BARCODE]:3e3,[Q.CRIT_TEXT_LINE]:3e3,[Q.CRIT_DETECTED_QUAD]:3e3,[Q.CRIT_DESKEWED_IMAGE]:3e3},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]:5,[Q.CRIT_TEXT_LINE]:5,[Q.CRIT_DETECTED_QUAD]:5,[Q.CRIT_DESKEWED_IMAGE]:5},this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,Ka.set(this,new Map),Ja.set(this,new Map),$a.set(this,new Map),Qa.set(this,new Map),to.set(this,new Map),Object.defineProperties(this,{onOriginalImageResultReceived:{value:t=>{},writable:!1},onDecodedBarcodesReceived:{value:t=>{this.latestOverlappingFilter(t),_o(this,t,Q.CRIT_BARCODE)},writable:!1},onRecognizedTextLinesReceived:{value:t=>{_o(this,t,Q.CRIT_TEXT_LINE)},writable:!1},onProcessedDocumentResultReceived:{value:t=>{},writable:!1},onParsedResultsReceived:{value:t=>{},writable:!1}})}_dynamsoft(){Na(this,Ka,"f").forEach(((t,e)=>{po(e,this.verificationEnabled,t)})),Na(this,Ja,"f").forEach(((t,e)=>{po(e,this.duplicateFilterEnabled,t)})),Na(this,$a,"f").forEach(((t,e)=>{po(e,this.duplicateForgetTime,t)})),Na(this,Qa,"f").forEach(((t,e)=>{po(e,this.latestOverlappingEnabled,t)})),Na(this,to,"f").forEach(((t,e)=>{po(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){go(t)&&Na(this,Ka,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!go(t)&&mo(t,this.verificationEnabled)}enableResultDeduplication(t,e){go(t)&&(e&&this.enableLatestOverlapping(t,!1),Na(this,Ja,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!go(t)&&mo(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){go(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),Na(this,$a,"f").set(t,e))}getDuplicateForgetTime(t){return go(t)?mo(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){go(t)&&Na(this,to,"f").set(t,e)}getMaxOverlappingFrames(t){return go(t)?mo(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){go(t)&&(e&&this.enableResultDeduplication(t,!1),Na(this,Qa,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!go(t)&&mo(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[Q.CRIT_BARCODE,Q.CRIT_TEXT_LINE,Q.CRIT_DETECTED_QUAD,Q.CRIT_DESKEWED_IMAGE];for(let i=0;i{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Ya.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ya.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(Ya.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Ya.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}))}))}}}Ka=new WeakMap,Ja=new WeakMap,$a=new WeakMap,Qa=new WeakMap,to=new WeakMap;const yo=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}};var wo,Eo,Co,So;class To{async readFromFile(t){return await yo(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(!Na(To,wo,"f",Eo).has(t))throw new Error("Image data ID does not exist.");const{ptr:e,length:i}=Na(To,wo,"f",Eo).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 yo(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=To,wo,(n=Na(i,wo,"f",Co),++n),0,Co),Na(To,wo,"f",Eo).set(Na(To,wo,"f",Co),JSON.parse(e.memery)),t(Na(To,wo,"f",Co));{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}})}))}}wo=To,Eo={value:new Map},Co={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"}(So||(So={})),Dt.engineResourcePaths.rootDirectory=(t=>{if(null==t&&(t="./"),At||Mt);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(Lt+"../../"),Dt.engineResourcePaths.dcvBundle={version:"3.0.3001",path:Lt,isInternal:!0},Dt.engineResourcePaths.dcvData={version:"1.0.1",path:Lt,isInternal:!0};var bo,Io,xo,Ro=Object.freeze({__proto__:null,BarcodeReaderModule:class{static getVersion(){const t=It.dbr&&It.dbr.wasm;return`11.0.30-dev-20250604160153(Worker: ${It.dbr&&It.dbr.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}},CameraEnhancer:Os,CameraEnhancerModule:class{static getVersion(){return"4.2.12-dev-20250609101854"}},CameraManager:jr,CameraView:kr,CaptureVisionRouter:Te,CaptureVisionRouterModule:Jt,CapturedResultReceiver:be,CodeParser:va,CodeParserModule:Sa,CoreModule:Dt,DocumentNormalizerModule:class{static getVersion(){const t=It.ddn&&It.ddn.wasm;return`3.0.30-dev-20250604160349(Worker: ${It.ddn&&It.ddn.worker||"Not Loaded"}, Wasm: ${t||"Not Loaded"})`}async setThresholdValue(t,e,i,n){return await Dt.loadWasm(),await new Promise(((r,s)=>{let a=wt();Et[a]=async t=>{if(t.success)return r();{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}},vt.postMessage({type:"ddn_setThresholdValue",id:a,instanceID:t._instanceID,body:{threshold:e,leftLimit:i,rightLimit:n}})}))}},DrawingItem:Ai,DrawingStyleManager:Dr,EnumBarcodeFormat:zs,get EnumBufferOverflowProtectionMode(){return a},get EnumCapturedResultItemType(){return Q},get EnumColourChannelUsageType(){return o},get EnumCornerType(){return tt},get EnumCrossVerificationStatus(){return ot},get EnumDeblurMode(){return Ks},get EnumDrawingItemMediaType(){return fi},get EnumDrawingItemState(){return gi},get EnumEnhancedFeatures(){return mi},get EnumErrorCode(){return et},get EnumExtendedBarcodeResultType(){return Xs},get EnumFilterType(){return So},get EnumGrayscaleEnhancementMode(){return it},get EnumGrayscaleTransformationMode(){return nt},get EnumImageCaptureDistanceMode(){return ut},get EnumImageColourMode(){return Da},get EnumImageFileFormat(){return dt},get EnumImagePixelFormat(){return l},get EnumImageSourceState(){return $t},get EnumImageTagType(){return rt},EnumIntermediateResultUnitType:lt,get EnumLocalizationMode(){return qs},get EnumMappingStatus(){return la},get EnumModuleName(){return ft},get EnumPDFReadingMode(){return st},get EnumPresetTemplate(){return Ie},get EnumQRCodeErrorCorrectionLevel(){return Zs},get EnumRasterDataSource(){return at},get EnumRawTextLineStatus(){return oa},get EnumRegionObjectElementType(){return ht},get EnumSectionType(){return ct},get EnumTransformMatrixType(){return gt},get EnumValidationStatus(){return ha},Feedback:Ss,GroupDrawingItem:Wi,ImageDataGetter:Nr,ImageDrawer:class{async drawOnImage(t,e,i,n=4294901760,r=1,s){if(!t)throw new Error("Invalid image.");if(!e)throw new Error("Invalid drawingItem.");if(!i)throw new Error("Invalid type.");let a;if(t instanceof Blob)a=await yo(t);else if("string"==typeof t){let e=await I(t,"blob");a=await yo(e)}else v(t)&&(a=t,"bigint"==typeof a.format&&(a.format=Number(a.format)));return await new Promise(((t,o)=>{let l=wt();Et[l]=async e=>{if(e.success)return s&&(new To).saveToFile(e.image,"test.png",s),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,o(t)}},vt.postMessage({type:"utility_drawOnImage",id:l,body:{dsImage:a,drawingItem:Array.isArray(e)?e:[e],color:n,thickness:r,type:i}})}))}},ImageDrawingItem:class extends Ai{set maintainAspectRatio(t){t&&this.set("scaleY",this.get("scaleX"))}get maintainAspectRatio(){return ni(this,Oi,"f")}constructor(t,e,i,n){if(super(null,n),Ri.set(this,void 0),Oi.set(this,void 0),!b(e))throw new TypeError("Invalid 'rect'.");if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)this._setFabricObject(new _i.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 h=wt();Et[h]=async e=>{if(e.success)return t(e.cropImage);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,l(t)}},vt.postMessage({type:"utility_cropImage",id:h,body:{type:i,bytes:n,width:r,height:s,stride:a,format:o,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 yo(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 yo(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 yo(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 yo(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 yo(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 yo(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}})}))}},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:sa,LicenseManager:Xe,LicenseModule:class{static getVersion(){return`4.0.30-dev-20250604160433(Worker: ${It.license&&It.license.worker||"Not Loaded"}, Wasm: ${It.license&&It.license.wasm||"Not Loaded"})`}},LineDrawingItem:class extends Ni{constructor(t,e){if(super({points:[null==t?void 0:t.startPoint,null==t?void 0:t.endPoint]},e),Vi.set(this,void 0),!E(t))throw new TypeError("Invalid 'line'.");ri(this,Vi,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 _i.Control({positionHandler:Li,actionHandler:ki(i>0?i-1:n,Pi),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=_i.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(){ni(this,Vi,"f")&&this.setLine(ni(this,Vi,"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 ri(this,Vi,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 ni(this,Vi,"f")?JSON.parse(JSON.stringify(ni(this,Vi,"f"))):null}},MultiFrameResultCrossFilter:vo,QuadDrawingItem:Gi,RectDrawingItem:Mi,TextDrawingItem:ji,UtilityModule:class{static getVersion(){return`2.0.30-dev-20250604160458(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:aa,waitAsyncDependency:pt,get worker(){return vt},workerAutoResources:Rt});t.EnumMRZScanMode=void 0,(bo=t.EnumMRZScanMode||(t.EnumMRZScanMode={})).Passport="passport",bo.TD1="td1",bo.TD2="td2",bo.PassportAndTD1="passportAndTd1",bo.PassportAndTD2="passportAndTd2",bo.TD1AndTD2="td1AndTd2",bo.All="all",t.EnumMRZDocumentType=void 0,(Io=t.EnumMRZDocumentType||(t.EnumMRZDocumentType={})).Passport="passport",Io.TD1="td1",Io.TD2="td2",t.EnumMRZScannerViews=void 0,(xo=t.EnumMRZScannerViews||(t.EnumMRZScannerViews={})).Scanner="scanner",xo.Result="scan-result";const Oo={[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 Do;function Ao(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,(Do=t.EnumResultStatus||(t.EnumResultStatus={}))[Do.RS_SUCCESS=0]="RS_SUCCESS",Do[Do.RS_CANCELLED=1]="RS_CANCELLED",Do[Do.RS_FAILED=2]="RS_FAILED";function Mo(t,e){if(!document.getElementById(t)){const i=document.createElement("style");i.id=t,i.textContent=e,document.head.appendChild(i)}}const Lo=t=>!t||0===Object.keys(t).length;function Fo(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}const Po={"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 ko(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