UNPKG

@microblink/blinkid-in-browser-sdk

Version:

A simple ID scanning library for WebAssembly-enabled browsers.

37 lines (32 loc) 60.8 kB
/*! **************************************************************************** Copyright (c) Microblink. All rights reserved. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. ***************************************************************************** */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BlinkIDSDK={})}(this,(function(e){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function t(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{A(o.next(e))}catch(e){a(e)}}function s(e){try{A(o.throw(e))}catch(e){a(e)}}function A(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,s)}A((o=o.apply(e,t||[])).next())}))}let i=0;class o{constructor(e){this.action=e,this.messageID=function(){const e=i;return i+=1,e}()}}class n extends o{constructor(e,t){super(n.action),this.wasmModuleName=e.wasmModuleName,this.licenseKey=e.licenseKey,this.userId=t,this.registerLoadCallback=null!==e.loadProgressCallback,this.allowHelloMessage=e.allowHelloMessage,this.engineLocation=e.engineLocation}}var a,r,s,A,c;n.action="init",function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback"}(a||(a={}));class I extends o{constructor(e,t){super(I.action),this.className=e,this.params=t}}I.action="createNewNativeObject";class l extends o{constructor(e,t,i){super(l.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}l.action="createRecognizerRunner";class d extends o{constructor(e,t){super(d.action),this.recognizerHandles=e,this.allowMultipleResults=t}}d.action="reconfigureRecognizerRunner";class N extends o{constructor(){super(N.action)}}N.action="deleteRecognizerRunner";class R extends o{constructor(e,t,i){super(R.action),this.objectHandle=e,this.methodName=t,this.params=i}}R.action="invokeObject";class u extends o{constructor(e){super(u.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}u.action="processImage";class E extends o{constructor(e){super(E.action),this.hardReset=e}}E.action="resetRecognizers";class S{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1,this.onGlare=!1}}class D extends o{constructor(e){super(D.action),this.registeredMetadataCallbacks=e}}D.action="registerMetadataCallbacks";class m extends o{constructor(e){super(m.action),this.detectionOnlyMode=e}}m.action="setDetectionOnly";class O extends o{constructor(e){super(O.action),this.callbackNonEmpty=e}}O.action="setClearTimeoutCallback";class C extends o{constructor(e){super(C.action),this.cameraPreviewMirrored=e}}function T(e,t){return i=>{const o=i;o.success?e():t(o.error)}}function h(e,t){return i=>{const o=i;o.success?e(i):t(o.error)}}C.action="setCameraPreviewMirrored",function(e){e[e.onDebugText=0]="onDebugText",e[e.onDetectionFailed=1]="onDetectionFailed",e[e.onQuadDetection=2]="onQuadDetection",e[e.onPointsDetection=3]="onPointsDetection",e[e.onFirstSideResult=4]="onFirstSideResult",e[e.clearTimeoutCallback=5]="clearTimeoutCallback",e[e.onGlare=6]="onGlare",e[e.recognizerCallback=7]="recognizerCallback"}(r||(r={}));class g{constructor(e,t,i){this.wasmSDKWorker=e,this.objectHandle=i,this.recognizerName=t,this.callbacks=new Map}getRemoteObjectHandle(){return this.objectHandle}currentSettings(){return new Promise((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const i=new R(this.objectHandle,"currentSettings",[]),o=h(t=>{e(t.result)},t);this.wasmSDKWorker.postMessage(i,o)})}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const o of t){const t=e[o];if("function"==typeof t){this.callbacks.set(o,t);e[o]={parameter:{recognizerHandle:this.objectHandle,callbackName:o},type:a.Callback},i=!0}}return i&&this.wasmSDKWorker.registerRecognizerCallbacks(this.objectHandle,this),e}updateSettings(e){return new Promise((t,i)=>{if(0>this.objectHandle)return void i("Invalid object handle: "+this.objectHandle);const o=new R(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:a.RecognizerSettings}]),n=T(t,i);this.wasmSDKWorker.postMessage(o,n)})}invokeCallback(e,t){const i=this.callbacks.get(e);void 0!==i?i(...t):console.warn("Cannot find callback",e)}getResult(){return new Promise((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const i=new R(this.objectHandle,"getResult",[]),o=h(t=>{e(t.result)},t);this.wasmSDKWorker.postMessage(i,o)})}delete(){return new Promise((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);this.clearAllCallbacks();const i=new R(this.objectHandle,"delete",[]),o=T(()=>{this.objectHandle=-1,e()},t);this.wasmSDKWorker.postMessage(i,o)})}}function _(e){const t=new S;return t.onDebugText=!!e.onDebugText,t.onDetectionFailed=!!e.onDetectionFailed,t.onPointsDetection=!!e.onPointsDetection,t.onQuadDetection=!!e.onQuadDetection,t.onFirstSideResult=!!e.onFirstSideResult,t.onGlare=!!e.onGlare,t}class M{constructor(e){this.deleted=!1,this.wasmSDKWorker=e}processImage(e){return new Promise((t,i)=>{if(this.deleted)return void i("Recognizer runner is deleted. It cannot be used anymore!");const o=new u(e),n=h(e=>{t(e.recognitionState)},i);this.wasmSDKWorker.postTransferrableMessage(o,n)})}reconfigureRecognizers(e,t){return new Promise((i,o)=>{if(this.deleted)return void o("Recognizer runner is deleted. It cannot be used anymore!");const n=L(e),a=new d(n,t),r=T(i,o);this.wasmSDKWorker.postMessage(a,r)})}setMetadataCallbacks(e){return new Promise((t,i)=>{const o=new D(_(e)),n=T(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(o,e,n)})}resetRecognizers(e){return new Promise((t,i)=>{const o=new E(e),n=T(t,i);this.wasmSDKWorker.postMessage(o,n)})}setDetectionOnlyMode(e){return new Promise((t,i)=>{const o=new m(e),n=T(t,i);this.wasmSDKWorker.postMessage(o,n)})}setClearTimeoutCallback(e){return new Promise((t,i)=>{const o=new O(null!==e),n=T(t,i);this.wasmSDKWorker.registerClearTimeoutCallback(e),this.wasmSDKWorker.postMessage(o,n)})}setCameraPreviewMirrored(e){return new Promise((t,i)=>{const o=new C(e),n=T(t,i);this.wasmSDKWorker.postMessage(o,n)})}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise((e,t)=>{const i=new N,o=T(()=>{this.deleted=!0,e()},t);this.wasmSDKWorker.postMessage(i,o)})}}function L(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class U{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise((o,n)=>{const a=L(e),r=new l(a,t,_(i)),s=T(()=>{o(new M(this.wasmSDKWorker))},n);this.wasmSDKWorker.postMessageAndRegisterCallbacks(r,i,s)})}newRecognizer(e,...t){return new Promise((i,o)=>{const n=new I(e,function(e){const t=[];for(let i of e){let e=a.Any;i instanceof g&&(e=a.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),r=h(t=>{const o=new g(this.wasmSDKWorker,e,t.objectHandle);i(o)},o);this.wasmSDKWorker.postMessage(n,r)})}}class p{constructor(e,t,i){this.eventHandlers={},this.metadataCallbacks={},this.clearTimeoutCallback=null,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{i("Problem during initialization of worker file!")},this.mbWasmModule=new U(this),this.loadCallback=t,this.recognizersWithCallbacks=new Map,this.showOverlay=!1}postMessage(e,t){this.eventHandlers[e.messageID]=t,this.mbWasmWorker.postMessage(e)}postTransferrableMessage(e,t){this.eventHandlers[e.messageID]=t,this.mbWasmWorker.postMessage(e,e.getTransferrables())}postMessageAndRegisterCallbacks(e,t,i){this.eventHandlers[e.messageID]=i,this.metadataCallbacks=t,this.mbWasmWorker.postMessage(e)}registerClearTimeoutCallback(e){this.clearTimeoutCallback=e}registerRecognizerCallbacks(e,t){this.recognizersWithCallbacks.set(e,t)}unregisterRecognizerCallbacks(e){this.recognizersWithCallbacks.delete(e)}handleWorkerEvent(e){if("isCallbackMessage"in e.data){const t=e.data;switch(t.callbackType){case r.onDebugText:"function"==typeof this.metadataCallbacks.onDebugText&&this.metadataCallbacks.onDebugText(t.callbackParameters[0]);break;case r.onDetectionFailed:"function"==typeof this.metadataCallbacks.onDetectionFailed&&this.metadataCallbacks.onDetectionFailed();break;case r.onPointsDetection:"function"==typeof this.metadataCallbacks.onPointsDetection&&this.metadataCallbacks.onPointsDetection(t.callbackParameters[0]);break;case r.onQuadDetection:"function"==typeof this.metadataCallbacks.onQuadDetection&&this.metadataCallbacks.onQuadDetection(t.callbackParameters[0]);break;case r.onFirstSideResult:"function"==typeof this.metadataCallbacks.onFirstSideResult&&this.metadataCallbacks.onFirstSideResult();break;case r.clearTimeoutCallback:this.clearTimeoutCallback&&"function"==typeof this.clearTimeoutCallback.onClearTimeout&&this.clearTimeoutCallback.onClearTimeout();break;case r.onGlare:"function"==typeof this.metadataCallbacks.onGlare&&this.metadataCallbacks.onGlare(t.callbackParameters[0]);break;case r.recognizerCallback:{const e=t.callbackParameters.shift(),i=this.recognizersWithCallbacks.get(e.recognizerHandle);void 0!==i?i.invokeCallback(e.callbackName,t.callbackParameters):console.warn("Cannot find recognizer to deliver callback message. Maybe it's destroyed?",e);break}default:throw Error("Unknown callback type: "+r[t.callbackType])}}else if("isLoadProgressMessage"in e.data){const t=e.data;"function"==typeof this.loadCallback&&this.loadCallback(t.progress)}else{const t=e.data,i=this.eventHandlers[t.messageID];delete this.eventHandlers[t.messageID],i(t)}}static createWasmWorker(e,i,o){return t(this,void 0,void 0,(function*(){return new Promise((t,a)=>{const r=new p(e,i.loadProgressCallback,a),s=new n(i,o),A=h(e=>{r.showOverlay=e.showOverlay,t(r)},a);r.postMessage(s,A)})}))}}let b;e.ImageOrientation=void 0,(s=e.ImageOrientation||(e.ImageOrientation={}))[s.RotatedLeft90=0]="RotatedLeft90",s[s.NoRotation=1]="NoRotation",s[s.RotatedRight90=2]="RotatedRight90",s[s.Rotated180=3]="Rotated180",e.RecognizerResultState=void 0,(A=e.RecognizerResultState||(e.RecognizerResultState={}))[A.Empty=0]="Empty",A[A.Uncertain=1]="Uncertain",A[A.Valid=2]="Valid",A[A.StageValid=3]="StageValid",e.DetectionStatus=void 0,(c=e.DetectionStatus||(e.DetectionStatus={}))[c.Fail=0]="Fail",c[c.Success=1]="Success",c[c.CameraTooHigh=2]="CameraTooHigh",c[c.FallbackSuccess=3]="FallbackSuccess",c[c.Partial=4]="Partial",c[c.CameraAtAngle=5]="CameraAtAngle",c[c.CameraTooNear=6]="CameraTooNear",c[c.DocumentTooCloseToEdge=7]="DocumentTooCloseToEdge";class f{constructor(e,t,i){this.imageData=e,this.orientation=t,this.videoFrame=i}}function P(t){let i,o,n=!1;if(t instanceof HTMLVideoElement)i=t.videoWidth,o=t.videoHeight,n=!0;else if(t instanceof HTMLImageElement)i=t.naturalWidth,o=t.naturalHeight;else{if(t instanceof SVGImageElement)throw Error("Recognition of SVG elements not supported!");i=t.width,o=t.height}b=b||document.createElement("canvas"),b.width=i,b.height=o;const a=b.getContext("2d");if(!a)throw Error("Could not get canvas 2d context!");a.drawImage(t,0,0,b.width,b.height);const r=a.getImageData(0,0,b.width,b.height);return new f(r,e.ImageOrientation.NoRotation,n)}var F,H,v;e.PreferredCameraType=void 0,(F=e.PreferredCameraType||(e.PreferredCameraType={}))[F.BackFacingCamera=0]="BackFacingCamera",F[F.FrontFacingCamera=1]="FrontFacingCamera",e.NotSupportedReason=void 0,(H=e.NotSupportedReason||(e.NotSupportedReason={})).MediaDevicesNotSupported="MediaDevicesNotSupported",H.CameraNotFound="CameraNotFound",H.CameraNotAllowed="CameraNotAllowed",H.CameraInUse="CameraInUse",H.CameraNotAvailable="CameraNotAvailable",H.VideoElementNotProvided="VideoElementNotProvided";class B extends Error{constructor(e,...t){super(...t),this.reason=e,this.name="VideoRecognizerError"}}e.VideoRecognitionMode=void 0,(v=e.VideoRecognitionMode||(e.VideoRecognitionMode={}))[v.Recognition=0]="Recognition",v[v.RecognitionTest=1]="RecognitionTest",v[v.DetectionTest=2]="DetectionTest";class y{constructor(t,i,o=!1,n=!1){this.videoFeed=null,this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.recognitionTimeoutMs=15e3,this.timeoutID=0,this.videoRecognitionMode=e.VideoRecognitionMode.Recognition,this.onScanningDone=null,this.allowManualVideoPlayout=!1,this.cameraFlipped=!1,this.videoFeed=t,this.recognizerRunner=i,this.cameraFlipped=o,n&&(this.allowManualVideoPlayout=n)}static createVideoRecognizerFromCameraStream(i,o,n=null,a=e.PreferredCameraType.BackFacingCamera){return t(this,void 0,void 0,(function*(){return new Promise((r,s)=>t(this,void 0,void 0,(function*(){if(i&&i instanceof Element)if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)try{const A=yield function(i,o){return t(this,void 0,void 0,(function*(){const t=[],n=[];{let i=yield navigator.mediaDevices.enumerateDevices();if(i.filter(e=>"videoinput"===e.kind).every(e=>""===e.label)){const e=yield navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});i=yield navigator.mediaDevices.enumerateDevices(),e.getTracks().forEach(e=>e.stop())}const o=i.filter(e=>"videoinput"===e.kind);for(const i of o)w(i.label)?n.push(new G(i,e.PreferredCameraType.BackFacingCamera)):t.push(new G(i,e.PreferredCameraType.FrontFacingCamera))}if(t.length>0||n.length>0){let a=n.length>0?n:t;o===e.PreferredCameraType.BackFacingCamera&&n.length>0&&(a=n),o===e.PreferredCameraType.FrontFacingCamera&&t.length>0&&(a=t),a=a.sort((e,t)=>e.label.localeCompare(t.label));{let e=0;const o=a.map(e=>{const t=/\b([0-9]+)MP?\b/i.exec(e.label);return null!==t?parseInt(t[1],10):NaN});if(o.some(e=>isNaN(e))||(e=o.lastIndexOf(Math.max(...o))),i){let e=null;return e=t.filter(e=>e.deviceId===i)[0],e||(e=n.filter(e=>e.deviceId===i)[0]),e||null}return a[e]}}return null}))}(n,a);if(null===A)return void s(new B(e.NotSupportedReason.CameraNotFound));const c={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};if(""===A.deviceId){c.video.facingMode={ideal:a===e.PreferredCameraType.BackFacingCamera?"environment":"user"}}else c.video.deviceId={exact:A.deviceId};const I=yield navigator.mediaDevices.getUserMedia(c);i.controls=!1,i.srcObject=I;let l=!1;A.facing===e.PreferredCameraType.FrontFacingCamera&&(i.style.transform="scaleX(-1)",l=!0),yield o.setCameraPreviewMirrored(l),r(new y(i,o,l))}catch(t){let i=e.NotSupportedReason.CameraInUse;switch(t.name){case"NotFoundError":case"OverconstrainedError":i=e.NotSupportedReason.CameraNotFound;break;case"NotAllowedError":case"SecurityError":i=e.NotSupportedReason.CameraNotAllowed;break;case"AbortError":case"NotReadableError":i=e.NotSupportedReason.CameraNotAvailable;break;case"TypeError":throw t}s(new B(i,t.message))}else s(new B(e.NotSupportedReason.MediaDevicesNotSupported));else{s(new B(e.NotSupportedReason.VideoElementNotProvided,"Video element, i.e. camera feed is not provided!"))}})))}))}static createVideoRecognizerFromVideoPath(e,i,o){return t(this,void 0,void 0,(function*(){return new Promise(t=>{i.src=e,i.currentTime=0,i.onended=()=>{n.cancelRecognition()};const n=new y(i,o);t(n)})}))}flipCamera(){return t(this,void 0,void 0,(function*(){this.videoFeed&&(this.cameraFlipped?(this.videoFeed.style.transform="scaleX(1)",this.cameraFlipped=!1):(this.videoFeed.style.transform="scaleX(-1)",this.cameraFlipped=!0),yield this.recognizerRunner.setCameraPreviewMirrored(this.cameraFlipped))}))}setVideoRecognitionMode(i){return t(this,void 0,void 0,(function*(){this.videoRecognitionMode=i;const t=this.videoRecognitionMode===e.VideoRecognitionMode.DetectionTest;yield this.recognizerRunner.setDetectionOnlyMode(t)}))}startRecognition(e,t=15e3){if(null===this.videoFeed)throw Error("The associated video feed has been released!");if(!this.videoFeed.paused)throw Error("The associated video feed is not paused. Use resumeRecognition instead!");this.cancelled=!1,this.recognitionPaused=!1,this.clearTimeout(),this.recognitionTimeoutMs=t,this.onScanningDone=e,this.recognizerRunner.setClearTimeoutCallback({onClearTimeout:()=>this.clearTimeout()}),this.videoFeed.play().then(()=>this.playPauseEvent(),e=>{if(!this.allowManualVideoPlayout)throw console.warn("Native error",e),Error("The play() request was interrupted or prevented by browser security rules!");this.videoFeed&&(this.videoFeed.controls=!0,this.videoFeed.addEventListener("play",()=>this.playPauseEvent()),this.videoFeed.addEventListener("pause",()=>this.playPauseEvent()))})}recognize(e=15e3){return t(this,void 0,void 0,(function*(){return new Promise((t,i)=>{try{this.startRecognition(e=>{this.pauseVideoFeed(),t(e)},e)}catch(e){i(e)}})}))}cancelRecognition(){this.cancelled=!0}pauseVideoFeed(){this.pauseRecognition(),this.videoFeed&&this.videoFeed.pause()}pauseRecognition(){this.recognitionPaused=!0}resetRecognizers(e){return t(this,void 0,void 0,(function*(){yield this.recognizerRunner.resetRecognizers(e)}))}getRecognizerRunner(){return this.recognizerRunner}resumeRecognition(e){if(this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.videoFeed&&this.videoFeed.paused){throw Error("Cannot resume recognition while video feed is paused! Use recognize or startRecognition")}setTimeout(()=>{e?this.resetRecognizers(!0).then(()=>{this.recognitionLoop()}).catch(()=>{throw Error("Could not reset recognizers!")}):this.recognitionLoop()},1)}releaseVideoFeed(){null!==this.videoFeed&&(null!==this.videoFeed.srcObject&&(this.videoFeed.paused||this.cancelRecognition(),this.videoFeed.srcObject.getTracks().forEach(e=>e.stop()),this.videoFeed.srcObject=null),this.videoFeed=null)}playPauseEvent(){this.videoFeed&&this.videoFeed.paused?this.cancelRecognition():this.resumeRecognition(!0)}recognitionLoop(){return t(this,void 0,void 0,(function*(){if(!this.videoFeed)throw Error("Missing video feed!");const t=P(this.videoFeed),i=yield this.recognizerRunner.processImage(t);i===e.RecognizerResultState.Valid||this.cancelled||this.timedOut?this.videoRecognitionMode===e.VideoRecognitionMode.Recognition||this.cancelled?(this.clearTimeout(),this.onScanningDone&&this.onScanningDone(i)):(yield this.recognizerRunner.resetRecognizers(!0),this.clearTimeout()):i===e.RecognizerResultState.Uncertain?0===this.timeoutID&&(this.timeoutID=window.setTimeout(()=>{this.timedOut=!0},this.recognitionTimeoutMs)):i===e.RecognizerResultState.StageValid&&this.clearTimeout(),this.recognitionPaused||setTimeout(()=>{this.recognitionLoop()},1)}))}clearTimeout(){this.timeoutID>0&&(window.clearTimeout(this.timeoutID),this.timeoutID=0)}}const k=["rear","back","rück","arrière","trasera","trás","traseira","posteriore","后面","後面","背面","后置","後置","背置","задней","الخلفية","후","arka","achterzijde","หลัง","baksidan","bagside","sau","bak","tylny","takakamera","belakang","אחורית","πίσω","spate","hátsó","zadní","darrere","zadná","задня","stražnja","belakang","बैक"];function w(e){const t=e.toLowerCase();return k.some(e=>t.includes(e))}class G{constructor(e,t){this.deviceId=e.deviceId,this.facing=t,this.groupId=e.groupId,this.label=e.label}}function W(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}var K,V,z,Y,x,J,j,Z,Q,X,q;e.BarcodeFormat=void 0,(K=e.BarcodeFormat||(e.BarcodeFormat={}))[K.NONE=0]="NONE",K[K.QR_CODE=1]="QR_CODE",K[K.DATA_MATRIX=2]="DATA_MATRIX",K[K.UPC_E=3]="UPC_E",K[K.UPC_A=4]="UPC_A",K[K.EAN_8=5]="EAN_8",K[K.EAN_13=6]="EAN_13",K[K.CODE_128=7]="CODE_128",K[K.CODE_39=8]="CODE_39",K[K.ITF=9]="ITF",K[K.AZTEC_BARCODE=10]="AZTEC_BARCODE",K[K.PDF417_BARCODE=11]="PDF417_BARCODE",e.AnonymizationMode=void 0,(V=e.AnonymizationMode||(e.AnonymizationMode={}))[V.None=0]="None",V[V.ImageOnly=1]="ImageOnly",V[V.ResultFieldsOnly=2]="ResultFieldsOnly",V[V.FullResult=3]="FullResult";class ${constructor(e=0,t=0,i=0,o=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(o),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=o}checkExtensionFactor(e){if(e>1||-1>e)throw Error("Extension factor must be in range [-1.0, 1.0]")}}function ee(e){if(100>e||e>400)throw Error("DPI must be from interval [100, 400]")}e.BarcodeElementKey=void 0,(z=e.BarcodeElementKey||(e.BarcodeElementKey={}))[z.DocumentType=0]="DocumentType",z[z.StandardVersionNumber=1]="StandardVersionNumber",z[z.CustomerFamilyName=2]="CustomerFamilyName",z[z.CustomerFirstName=3]="CustomerFirstName",z[z.CustomerFullName=4]="CustomerFullName",z[z.DateOfBirth=5]="DateOfBirth",z[z.Sex=6]="Sex",z[z.EyeColor=7]="EyeColor",z[z.AddressStreet=8]="AddressStreet",z[z.AddressCity=9]="AddressCity",z[z.AddressJurisdictionCode=10]="AddressJurisdictionCode",z[z.AddressPostalCode=11]="AddressPostalCode",z[z.FullAddress=12]="FullAddress",z[z.Height=13]="Height",z[z.HeightIn=14]="HeightIn",z[z.HeightCm=15]="HeightCm",z[z.CustomerMiddleName=16]="CustomerMiddleName",z[z.HairColor=17]="HairColor",z[z.NameSuffix=18]="NameSuffix",z[z.AKAFullName=19]="AKAFullName",z[z.AKAFamilyName=20]="AKAFamilyName",z[z.AKAGivenName=21]="AKAGivenName",z[z.AKASuffixName=22]="AKASuffixName",z[z.WeightRange=23]="WeightRange",z[z.WeightPounds=24]="WeightPounds",z[z.WeightKilograms=25]="WeightKilograms",z[z.CustomerIdNumber=26]="CustomerIdNumber",z[z.FamilyNameTruncation=27]="FamilyNameTruncation",z[z.FirstNameTruncation=28]="FirstNameTruncation",z[z.MiddleNameTruncation=29]="MiddleNameTruncation",z[z.PlaceOfBirth=30]="PlaceOfBirth",z[z.AddressStreet2=31]="AddressStreet2",z[z.RaceEthnicity=32]="RaceEthnicity",z[z.NamePrefix=33]="NamePrefix",z[z.CountryIdentification=34]="CountryIdentification",z[z.ResidenceStreetAddress=35]="ResidenceStreetAddress",z[z.ResidenceStreetAddress2=36]="ResidenceStreetAddress2",z[z.ResidenceCity=37]="ResidenceCity",z[z.ResidenceJurisdictionCode=38]="ResidenceJurisdictionCode",z[z.ResidencePostalCode=39]="ResidencePostalCode",z[z.ResidenceFullAddress=40]="ResidenceFullAddress",z[z.Under18=41]="Under18",z[z.Under19=42]="Under19",z[z.Under21=43]="Under21",z[z.SocialSecurityNumber=44]="SocialSecurityNumber",z[z.AKASocialSecurityNumber=45]="AKASocialSecurityNumber",z[z.AKAMiddleName=46]="AKAMiddleName",z[z.AKAPrefixName=47]="AKAPrefixName",z[z.OrganDonor=48]="OrganDonor",z[z.Veteran=49]="Veteran",z[z.AKADateOfBirth=50]="AKADateOfBirth",z[z.IssuerIdentificationNumber=51]="IssuerIdentificationNumber",z[z.DocumentExpirationDate=52]="DocumentExpirationDate",z[z.JurisdictionVersionNumber=53]="JurisdictionVersionNumber",z[z.JurisdictionVehicleClass=54]="JurisdictionVehicleClass",z[z.JurisdictionRestrictionCodes=55]="JurisdictionRestrictionCodes",z[z.JurisdictionEndorsementCodes=56]="JurisdictionEndorsementCodes",z[z.DocumentIssueDate=57]="DocumentIssueDate",z[z.FederalCommercialVehicleCodes=58]="FederalCommercialVehicleCodes",z[z.IssuingJurisdiction=59]="IssuingJurisdiction",z[z.StandardVehicleClassification=60]="StandardVehicleClassification",z[z.IssuingJurisdictionName=61]="IssuingJurisdictionName",z[z.StandardEndorsementCode=62]="StandardEndorsementCode",z[z.StandardRestrictionCode=63]="StandardRestrictionCode",z[z.JurisdictionVehicleClassificationDescription=64]="JurisdictionVehicleClassificationDescription",z[z.JurisdictionEndorsmentCodeDescription=65]="JurisdictionEndorsmentCodeDescription",z[z.JurisdictionRestrictionCodeDescription=66]="JurisdictionRestrictionCodeDescription",z[z.InventoryControlNumber=67]="InventoryControlNumber",z[z.CardRevisionDate=68]="CardRevisionDate",z[z.DocumentDiscriminator=69]="DocumentDiscriminator",z[z.LimitedDurationDocument=70]="LimitedDurationDocument",z[z.AuditInformation=71]="AuditInformation",z[z.ComplianceType=72]="ComplianceType",z[z.IssueTimestamp=73]="IssueTimestamp",z[z.PermitExpirationDate=74]="PermitExpirationDate",z[z.PermitIdentifier=75]="PermitIdentifier",z[z.PermitIssueDate=76]="PermitIssueDate",z[z.NumberOfDuplicates=77]="NumberOfDuplicates",z[z.HAZMATExpirationDate=78]="HAZMATExpirationDate",z[z.MedicalIndicator=79]="MedicalIndicator",z[z.NonResident=80]="NonResident",z[z.UniqueCustomerId=81]="UniqueCustomerId",z[z.DataDiscriminator=82]="DataDiscriminator",z[z.DocumentExpirationMonth=83]="DocumentExpirationMonth",z[z.DocumentNonexpiring=84]="DocumentNonexpiring",z[z.SecurityVersion=85]="SecurityVersion",z[z.Count=86]="Count",e.Country=void 0,(Y=e.Country||(e.Country={}))[Y.NONE=0]="NONE",Y[Y.ALBANIA=1]="ALBANIA",Y[Y.ALGERIA=2]="ALGERIA",Y[Y.ARGENTINA=3]="ARGENTINA",Y[Y.AUSTRALIA=4]="AUSTRALIA",Y[Y.AUSTRIA=5]="AUSTRIA",Y[Y.AZERBAIJAN=6]="AZERBAIJAN",Y[Y.BAHRAIN=7]="BAHRAIN",Y[Y.BANGLADESH=8]="BANGLADESH",Y[Y.BELGIUM=9]="BELGIUM",Y[Y.BOSNIA_AND_HERZEGOVINA=10]="BOSNIA_AND_HERZEGOVINA",Y[Y.BRUNEI=11]="BRUNEI",Y[Y.BULGARIA=12]="BULGARIA",Y[Y.CAMBODIA=13]="CAMBODIA",Y[Y.CANADA=14]="CANADA",Y[Y.CHILE=15]="CHILE",Y[Y.COLOMBIA=16]="COLOMBIA",Y[Y.COSTA_RICA=17]="COSTA_RICA",Y[Y.CROATIA=18]="CROATIA",Y[Y.CYPRUS=19]="CYPRUS",Y[Y.CZECHIA=20]="CZECHIA",Y[Y.DENMARK=21]="DENMARK",Y[Y.DOMINICAN_REPUBLIC=22]="DOMINICAN_REPUBLIC",Y[Y.EGYPT=23]="EGYPT",Y[Y.ESTONIA=24]="ESTONIA",Y[Y.FINLAND=25]="FINLAND",Y[Y.FRANCE=26]="FRANCE",Y[Y.GEORGIA=27]="GEORGIA",Y[Y.GERMANY=28]="GERMANY",Y[Y.GHANA=29]="GHANA",Y[Y.GREECE=30]="GREECE",Y[Y.GUATEMALA=31]="GUATEMALA",Y[Y.HONG_KONG=32]="HONG_KONG",Y[Y.HUNGARY=33]="HUNGARY",Y[Y.INDIA=34]="INDIA",Y[Y.INDONESIA=35]="INDONESIA",Y[Y.IRELAND=36]="IRELAND",Y[Y.ISRAEL=37]="ISRAEL",Y[Y.ITALY=38]="ITALY",Y[Y.JORDAN=39]="JORDAN",Y[Y.KAZAKHSTAN=40]="KAZAKHSTAN",Y[Y.KENYA=41]="KENYA",Y[Y.KOSOVO=42]="KOSOVO",Y[Y.KUWAIT=43]="KUWAIT",Y[Y.LATVIA=44]="LATVIA",Y[Y.LITHUANIA=45]="LITHUANIA",Y[Y.MALAYSIA=46]="MALAYSIA",Y[Y.MALDIVES=47]="MALDIVES",Y[Y.MALTA=48]="MALTA",Y[Y.MAURITIUS=49]="MAURITIUS",Y[Y.MEXICO=50]="MEXICO",Y[Y.MOROCCO=51]="MOROCCO",Y[Y.NETHERLANDS=52]="NETHERLANDS",Y[Y.NEW_ZEALAND=53]="NEW_ZEALAND",Y[Y.NIGERIA=54]="NIGERIA",Y[Y.PAKISTAN=55]="PAKISTAN",Y[Y.PANAMA=56]="PANAMA",Y[Y.PARAGUAY=57]="PARAGUAY",Y[Y.PHILIPPINES=58]="PHILIPPINES",Y[Y.POLAND=59]="POLAND",Y[Y.PORTUGAL=60]="PORTUGAL",Y[Y.PUERTO_RICO=61]="PUERTO_RICO",Y[Y.QATAR=62]="QATAR",Y[Y.ROMANIA=63]="ROMANIA",Y[Y.RUSSIA=64]="RUSSIA",Y[Y.SAUDI_ARABIA=65]="SAUDI_ARABIA",Y[Y.SERBIA=66]="SERBIA",Y[Y.SINGAPORE=67]="SINGAPORE",Y[Y.SLOVAKIA=68]="SLOVAKIA",Y[Y.SLOVENIA=69]="SLOVENIA",Y[Y.SOUTH_AFRICA=70]="SOUTH_AFRICA",Y[Y.SPAIN=71]="SPAIN",Y[Y.SWEDEN=72]="SWEDEN",Y[Y.SWITZERLAND=73]="SWITZERLAND",Y[Y.TAIWAN=74]="TAIWAN",Y[Y.THAILAND=75]="THAILAND",Y[Y.TUNISIA=76]="TUNISIA",Y[Y.TURKEY=77]="TURKEY",Y[Y.UAE=78]="UAE",Y[Y.UGANDA=79]="UGANDA",Y[Y.UK=80]="UK",Y[Y.UKRAINE=81]="UKRAINE",Y[Y.USA=82]="USA",Y[Y.VIETNAM=83]="VIETNAM",Y[Y.BRAZIL=84]="BRAZIL",Y[Y.NORWAY=85]="NORWAY",Y[Y.OMAN=86]="OMAN",Y[Y.ECUADOR=87]="ECUADOR",Y[Y.EL_SALVADOR=88]="EL_SALVADOR",Y[Y.SRI_LANKA=89]="SRI_LANKA",Y[Y.PERU=90]="PERU",Y[Y.URUGUAY=91]="URUGUAY",Y[Y.BAHAMAS=92]="BAHAMAS",Y[Y.BERMUDA=93]="BERMUDA",Y[Y.BOLIVIA=94]="BOLIVIA",Y[Y.CHINA=95]="CHINA",Y[Y.EUROPEAN_UNION=96]="EUROPEAN_UNION",Y[Y.HAITI=97]="HAITI",Y[Y.HONDURAS=98]="HONDURAS",Y[Y.ICELAND=99]="ICELAND",Y[Y.JAPAN=100]="JAPAN",Y[Y.LUXEMBOURG=101]="LUXEMBOURG",Y[Y.MONTENEGRO=102]="MONTENEGRO",Y[Y.NICARAGUA=103]="NICARAGUA",Y[Y.SOUTH_KOREA=104]="SOUTH_KOREA",Y[Y.VENEZUELA=105]="VENEZUELA",Y[Y.AFGHANISTAN=106]="AFGHANISTAN",Y[Y.ALAND_ISLANDS=107]="ALAND_ISLANDS",Y[Y.AMERICAN_SAMOA=108]="AMERICAN_SAMOA",Y[Y.ANDORRA=109]="ANDORRA",Y[Y.ANGOLA=110]="ANGOLA",Y[Y.ANGUILLA=111]="ANGUILLA",Y[Y.ANTARCTICA=112]="ANTARCTICA",Y[Y.ANTIGUA_AND_BARBUDA=113]="ANTIGUA_AND_BARBUDA",Y[Y.ARMENIA=114]="ARMENIA",Y[Y.ARUBA=115]="ARUBA",Y[Y.BAILIWICK_OF_GUERNSEY=116]="BAILIWICK_OF_GUERNSEY",Y[Y.BAILIWICK_OF_JERSEY=117]="BAILIWICK_OF_JERSEY",Y[Y.BARBADOS=118]="BARBADOS",Y[Y.BELARUS=119]="BELARUS",Y[Y.BELIZE=120]="BELIZE",Y[Y.BENIN=121]="BENIN",Y[Y.BHUTAN=122]="BHUTAN",Y[Y.BONAIRE_SAINT_EUSTATIUS_AND_SABA=123]="BONAIRE_SAINT_EUSTATIUS_AND_SABA",Y[Y.BOTSWANA=124]="BOTSWANA",Y[Y.BOUVET_ISLAND=125]="BOUVET_ISLAND",Y[Y.BRITISH_INDIAN_OCEAN_TERRITORY=126]="BRITISH_INDIAN_OCEAN_TERRITORY",Y[Y.BURKINA_FASO=127]="BURKINA_FASO",Y[Y.BURUNDI=128]="BURUNDI",Y[Y.CAMEROON=129]="CAMEROON",Y[Y.CAPE_VERDE=130]="CAPE_VERDE",Y[Y.CARIBBEAN_NETHERLANDS=131]="CARIBBEAN_NETHERLANDS",Y[Y.CAYMAN_ISLANDS=132]="CAYMAN_ISLANDS",Y[Y.CENTRAL_AFRICAN_REPUBLIC=133]="CENTRAL_AFRICAN_REPUBLIC",Y[Y.CHAD=134]="CHAD",Y[Y.CHRISTMAS_ISLAND=135]="CHRISTMAS_ISLAND",Y[Y.COCOS_ISLANDS=136]="COCOS_ISLANDS",Y[Y.COMOROS=137]="COMOROS",Y[Y.CONGO=138]="CONGO",Y[Y.COOK_ISLANDS=139]="COOK_ISLANDS",Y[Y.CUBA=140]="CUBA",Y[Y.CURACAO=141]="CURACAO",Y[Y.DEMOCRATIC_REPUBLIC_OF_THE_CONGO=142]="DEMOCRATIC_REPUBLIC_OF_THE_CONGO",Y[Y.DJIBOUTI=143]="DJIBOUTI",Y[Y.DOMINICA=144]="DOMINICA",Y[Y.EAST_TIMOR=145]="EAST_TIMOR",Y[Y.EQUATORIAL_GUINEA=146]="EQUATORIAL_GUINEA",Y[Y.ERITREA=147]="ERITREA",Y[Y.ETHIOPIA=148]="ETHIOPIA",Y[Y.FALKLAND_ISLANDS=149]="FALKLAND_ISLANDS",Y[Y.FAROE_ISLANDS=150]="FAROE_ISLANDS",Y[Y.FEDERATED_STATES_OF_MICRONESIA=151]="FEDERATED_STATES_OF_MICRONESIA",Y[Y.FIJI=152]="FIJI",Y[Y.FRENCH_GUIANA=153]="FRENCH_GUIANA",Y[Y.FRENCH_POLYNESIA=154]="FRENCH_POLYNESIA",Y[Y.FRENCH_SOUTHERN_TERRITORIES=155]="FRENCH_SOUTHERN_TERRITORIES",Y[Y.GABON=156]="GABON",Y[Y.GAMBIA=157]="GAMBIA",Y[Y.GIBRALTAR=158]="GIBRALTAR",Y[Y.GREENLAND=159]="GREENLAND",Y[Y.GRENADA=160]="GRENADA",Y[Y.GUADELOUPE=161]="GUADELOUPE",Y[Y.GUAM=162]="GUAM",Y[Y.GUINEA=163]="GUINEA",Y[Y.GUINEA_BISSAU=164]="GUINEA_BISSAU",Y[Y.GUYANA=165]="GUYANA",Y[Y.HEARD_ISLAND_AND_MCDONALD_ISLANDS=166]="HEARD_ISLAND_AND_MCDONALD_ISLANDS",Y[Y.IRAN=167]="IRAN",Y[Y.IRAQ=168]="IRAQ",Y[Y.ISLE_OF_MAN=169]="ISLE_OF_MAN",Y[Y.IVORY_COAST=170]="IVORY_COAST",Y[Y.JAMAICA=171]="JAMAICA",Y[Y.KIRIBATI=172]="KIRIBATI",Y[Y.KYRGYZSTAN=173]="KYRGYZSTAN",Y[Y.LAOS=174]="LAOS",Y[Y.LEBANON=175]="LEBANON",Y[Y.LESOTHO=176]="LESOTHO",Y[Y.LIBERIA=177]="LIBERIA",Y[Y.LIBYA=178]="LIBYA",Y[Y.LIECHTENSTEIN=179]="LIECHTENSTEIN",Y[Y.MACAU=180]="MACAU",Y[Y.MADAGASCAR=181]="MADAGASCAR",Y[Y.MALAWI=182]="MALAWI",Y[Y.MALI=183]="MALI",Y[Y.MARSHALL_ISLANDS=184]="MARSHALL_ISLANDS",Y[Y.MARTINIQUE=185]="MARTINIQUE",Y[Y.MAURITANIA=186]="MAURITANIA",Y[Y.MAYOTTE=187]="MAYOTTE",Y[Y.MOLDOVA=188]="MOLDOVA",Y[Y.MONACO=189]="MONACO",Y[Y.MONGOLIA=190]="MONGOLIA",Y[Y.MONTSERRAT=191]="MONTSERRAT",Y[Y.MOZAMBIQUE=192]="MOZAMBIQUE",Y[Y.MYANMAR=193]="MYANMAR",Y[Y.NAMIBIA=194]="NAMIBIA",Y[Y.NAURU=195]="NAURU",Y[Y.NEPAL=196]="NEPAL",Y[Y.NEW_CALEDONIA=197]="NEW_CALEDONIA",Y[Y.NIGER=198]="NIGER",Y[Y.NIUE=199]="NIUE",Y[Y.NORFOLK_ISLAND=200]="NORFOLK_ISLAND",Y[Y.NORTHERN_CYPRUS=201]="NORTHERN_CYPRUS",Y[Y.NORTHERN_MARIANA_ISLANDS=202]="NORTHERN_MARIANA_ISLANDS",Y[Y.NORTH_KOREA=203]="NORTH_KOREA",Y[Y.NORTH_MACEDONIA=204]="NORTH_MACEDONIA",Y[Y.PALAU=205]="PALAU",Y[Y.PALESTINE=206]="PALESTINE",Y[Y.PAPUA_NEW_GUINEA=207]="PAPUA_NEW_GUINEA",Y[Y.PITCAIRN=208]="PITCAIRN",Y[Y.REUNION=209]="REUNION",Y[Y.RWANDA=210]="RWANDA",Y[Y.SAINT_BARTHELEMY=211]="SAINT_BARTHELEMY",Y[Y.SAINT_HELENA_ASCENSION_AND_TRISTIAN_DA_CUNHA=212]="SAINT_HELENA_ASCENSION_AND_TRISTIAN_DA_CUNHA",Y[Y.SAINT_KITTS_AND_NEVIS=213]="SAINT_KITTS_AND_NEVIS",Y[Y.SAINT_LUCIA=214]="SAINT_LUCIA",Y[Y.SAINT_MARTIN=215]="SAINT_MARTIN",Y[Y.SAINT_PIERRE_AND_MIQUELON=216]="SAINT_PIERRE_AND_MIQUELON",Y[Y.SAINT_VINCENT_AND_THE_GRENADINES=217]="SAINT_VINCENT_AND_THE_GRENADINES",Y[Y.SAMOA=218]="SAMOA",Y[Y.SAN_MARINO=219]="SAN_MARINO",Y[Y.SAO_TOME_AND_PRINCIPE=220]="SAO_TOME_AND_PRINCIPE",Y[Y.SENEGAL=221]="SENEGAL",Y[Y.SEYCHELLES=222]="SEYCHELLES",Y[Y.SIERRA_LEONE=223]="SIERRA_LEONE",Y[Y.SINT_MAARTEN=224]="SINT_MAARTEN",Y[Y.SOLOMON_ISLANDS=225]="SOLOMON_ISLANDS",Y[Y.SOMALIA=226]="SOMALIA",Y[Y.SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS=227]="SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS",Y[Y.SOUTH_SUDAN=228]="SOUTH_SUDAN",Y[Y.SUDAN=229]="SUDAN",Y[Y.SURINAME=230]="SURINAME",Y[Y.SVALBARD_AND_JAN_MAYEN=231]="SVALBARD_AND_JAN_MAYEN",Y[Y.SWAZILAND=232]="SWAZILAND",Y[Y.SYRIA=233]="SYRIA",Y[Y.TAJIKISTAN=234]="TAJIKISTAN",Y[Y.TANZANIA=235]="TANZANIA",Y[Y.TOGO=236]="TOGO",Y[Y.TOKELAU=237]="TOKELAU",Y[Y.TONGA=238]="TONGA",Y[Y.TRINIDAD_AND_TOBAGO=239]="TRINIDAD_AND_TOBAGO",Y[Y.TURKMENISTAN=240]="TURKMENISTAN",Y[Y.TURKS_AND_CAICOS_ISLANDS=241]="TURKS_AND_CAICOS_ISLANDS",Y[Y.TUVALU=242]="TUVALU",Y[Y.UNITED_STATES_MINOR_OUTLYING_ISLANDS=243]="UNITED_STATES_MINOR_OUTLYING_ISLANDS",Y[Y.UZBEKISTAN=244]="UZBEKISTAN",Y[Y.VANUATU=245]="VANUATU",Y[Y.VATICAN_CITY=246]="VATICAN_CITY",Y[Y.VIRGIN_ISLANDS_BRITISH=247]="VIRGIN_ISLANDS_BRITISH",Y[Y.VIRGIN_ISLANDS_US=248]="VIRGIN_ISLANDS_US",Y[Y.WALLIS_AND_FUTUNA=249]="WALLIS_AND_FUTUNA",Y[Y.WESTERN_SAHARA=250]="WESTERN_SAHARA",Y[Y.YEMEN=251]="YEMEN",Y[Y.YUGOSLAVIA=252]="YUGOSLAVIA",Y[Y.ZAMBIA=253]="ZAMBIA",Y[Y.ZIMBABWE=254]="ZIMBABWE",Y[Y.COUNT=255]="COUNT",e.Region=void 0,(x=e.Region||(e.Region={}))[x.NONE=0]="NONE",x[x.ALABAMA=1]="ALABAMA",x[x.ALASKA=2]="ALASKA",x[x.ALBERTA=3]="ALBERTA",x[x.ARIZONA=4]="ARIZONA",x[x.ARKANSAS=5]="ARKANSAS",x[x.AUSTRALIAN_CAPITAL_TERRITORY=6]="AUSTRALIAN_CAPITAL_TERRITORY",x[x.BRITISH_COLUMBIA=7]="BRITISH_COLUMBIA",x[x.CALIFORNIA=8]="CALIFORNIA",x[x.COLORADO=9]="COLORADO",x[x.CONNECTICUT=10]="CONNECTICUT",x[x.DELAWARE=11]="DELAWARE",x[x.DISTRICT_OF_COLUMBIA=12]="DISTRICT_OF_COLUMBIA",x[x.FLORIDA=13]="FLORIDA",x[x.GEORGIA=14]="GEORGIA",x[x.HAWAII=15]="HAWAII",x[x.IDAHO=16]="IDAHO",x[x.ILLINOIS=17]="ILLINOIS",x[x.INDIANA=18]="INDIANA",x[x.IOWA=19]="IOWA",x[x.KANSAS=20]="KANSAS",x[x.KENTUCKY=21]="KENTUCKY",x[x.LOUISIANA=22]="LOUISIANA",x[x.MAINE=23]="MAINE",x[x.MANITOBA=24]="MANITOBA",x[x.MARYLAND=25]="MARYLAND",x[x.MASSACHUSETTS=26]="MASSACHUSETTS",x[x.MICHIGAN=27]="MICHIGAN",x[x.MINNESOTA=28]="MINNESOTA",x[x.MISSISSIPPI=29]="MISSISSIPPI",x[x.MISSOURI=30]="MISSOURI",x[x.MONTANA=31]="MONTANA",x[x.NEBRASKA=32]="NEBRASKA",x[x.NEVADA=33]="NEVADA",x[x.NEW_BRUNSWICK=34]="NEW_BRUNSWICK",x[x.NEW_HAMPSHIRE=35]="NEW_HAMPSHIRE",x[x.NEW_JERSEY=36]="NEW_JERSEY",x[x.NEW_MEXICO=37]="NEW_MEXICO",x[x.NEW_SOUTH_WALES=38]="NEW_SOUTH_WALES",x[x.NEW_YORK=39]="NEW_YORK",x[x.NORTHERN_TERRITORY=40]="NORTHERN_TERRITORY",x[x.NORTH_CAROLINA=41]="NORTH_CAROLINA",x[x.NORTH_DAKOTA=42]="NORTH_DAKOTA",x[x.NOVA_SCOTIA=43]="NOVA_SCOTIA",x[x.OHIO=44]="OHIO",x[x.OKLAHOMA=45]="OKLAHOMA",x[x.ONTARIO=46]="ONTARIO",x[x.OREGON=47]="OREGON",x[x.PENNSYLVANIA=48]="PENNSYLVANIA",x[x.QUEBEC=49]="QUEBEC",x[x.QUEENSLAND=50]="QUEENSLAND",x[x.RHODE_ISLAND=51]="RHODE_ISLAND",x[x.SASKATCHEWAN=52]="SASKATCHEWAN",x[x.SOUTH_AUSTRALIA=53]="SOUTH_AUSTRALIA",x[x.SOUTH_CAROLINA=54]="SOUTH_CAROLINA",x[x.SOUTH_DAKOTA=55]="SOUTH_DAKOTA",x[x.TASMANIA=56]="TASMANIA",x[x.TENNESSEE=57]="TENNESSEE",x[x.TEXAS=58]="TEXAS",x[x.UTAH=59]="UTAH",x[x.VERMONT=60]="VERMONT",x[x.VICTORIA=61]="VICTORIA",x[x.VIRGINIA=62]="VIRGINIA",x[x.WASHINGTON=63]="WASHINGTON",x[x.WESTERN_AUSTRALIA=64]="WESTERN_AUSTRALIA",x[x.WEST_VIRGINIA=65]="WEST_VIRGINIA",x[x.WISCONSIN=66]="WISCONSIN",x[x.WYOMING=67]="WYOMING",x[x.YUKON=68]="YUKON",x[x.CIUDAD_DE_MEXICO=69]="CIUDAD_DE_MEXICO",x[x.JALISCO=70]="JALISCO",x[x.NEWFOUNDLAND_AND_LABRADOR=71]="NEWFOUNDLAND_AND_LABRADOR",x[x.NUEVO_LEON=72]="NUEVO_LEON",x[x.BAJA_CALIFORNIA=73]="BAJA_CALIFORNIA",x[x.CHIHUAHUA=74]="CHIHUAHUA",x[x.GUANAJUATO=75]="GUANAJUATO",x[x.GUERRERO=76]="GUERRERO",x[x.MEXICO=77]="MEXICO",x[x.MICHOACAN=78]="MICHOACAN",x[x.NEW_YORK_CITY=79]="NEW_YORK_CITY",x[x.TAMAULIPAS=80]="TAMAULIPAS",x[x.VERACRUZ=81]="VERACRUZ",x[x.COUNT=82]="COUNT",e.DocumentType=void 0,(J=e.DocumentType||(e.DocumentType={}))[J.NONE=0]="NONE",J[J.CONSULAR_ID=1]="CONSULAR_ID",J[J.DL=2]="DL",J[J.DL_PUBLIC_SERVICES_CARD=3]="DL_PUBLIC_SERVICES_CARD",J[J.EMPLOYMENT_PASS=4]="EMPLOYMENT_PASS",J[J.FIN_CARD=5]="FIN_CARD",J[J.ID=6]="ID",J[J.MULTIPURPOSE_ID=7]="MULTIPURPOSE_ID",J[J.MyKad=8]="MyKad",J[J.MyKid=9]="MyKid",J[J.MyPR=10]="MyPR",J[J.MyTentera=11]="MyTentera",J[J.PAN_CARD=12]="PAN_CARD",J[J.PROFESSIONAL_ID=13]="PROFESSIONAL_ID",J[J.PUBLIC_SERVICES_CARD=14]="PUBLIC_SERVICES_CARD",J[J.RESIDENCE_PERMIT=15]="RESIDENCE_PERMIT",J[J.RESIDENT_ID=16]="RESIDENT_ID",J[J.TEMPORARY_RESIDENCE_PERMIT=17]="TEMPORARY_RESIDENCE_PERMIT",J[J.VOTER_ID=18]="VOTER_ID",J[J.WORK_PERMIT=19]="WORK_PERMIT",J[J.iKAD=20]="iKAD",J[J.MILITARY_ID=21]="MILITARY_ID",J[J.MyKAS=22]="MyKAS",J[J.SOCIAL_SECURITY_CARD=23]="SOCIAL_SECURITY_CARD",J[J.HEALTH_INSURANCE_CARD=24]="HEALTH_INSURANCE_CARD",J[J.PASSPORT=25]="PASSPORT",J[J.S_PASS=26]="S_PASS",J[J.ADDRESS_CARD=27]="ADDRESS_CARD",J[J.ALIEN_ID=28]="ALIEN_ID",J[J.ALIEN_PASSPORT=29]="ALIEN_PASSPORT",J[J.GREEN_CARD=30]="GREEN_CARD",J[J.MINORS_ID=31]="MINORS_ID",J[J.POSTAL_ID=32]="POSTAL_ID",J[J.PROFESSIONAL_DL=33]="PROFESSIONAL_DL",J[J.TAX_ID=34]="TAX_ID",J[J.WEAPON_PERMIT=35]="WEAPON_PERMIT",J[J.VISA=36]="VISA",J[J.COUNT=37]="COUNT",e.DocumentImageColorStatus=void 0,(j=e.DocumentImageColorStatus||(e.DocumentImageColorStatus={}))[j.NotAvailable=0]="NotAvailable",j[j.BlackAndWhite=1]="BlackAndWhite",j[j.Color=2]="Color",e.ImageAnalysisDetectionStatus=void 0,(Z=e.ImageAnalysisDetectionStatus||(e.ImageAnalysisDetectionStatus={}))[Z.NotAvailable=0]="NotAvailable",Z[Z.NotDetected=1]="NotDetected",Z[Z.Detected=2]="Detected",e.ProcessingStatus=void 0,(Q=e.ProcessingStatus||(e.ProcessingStatus={}))[Q.Success=0]="Success",Q[Q.DetectionFailed=1]="DetectionFailed",Q[Q.ImagePreprocessingFailed=2]="ImagePreprocessingFailed",Q[Q.StabilityTestFailed=3]="StabilityTestFailed",Q[Q.ScanningWrongSide=4]="ScanningWrongSide",Q[Q.FieldIdentificationFailed=5]="FieldIdentificationFailed",Q[Q.MandatoryFieldMissing=6]="MandatoryFieldMissing",Q[Q.InvalidCharactersFound=7]="InvalidCharactersFound",Q[Q.ImageReturnFailed=8]="ImageReturnFailed",Q[Q.BarcodeRecognitionFailed=9]="BarcodeRecognitionFailed",Q[Q.MrzParsingFailed=10]="MrzParsingFailed",Q[Q.ClassFiltered=11]="ClassFiltered",Q[Q.UnsupportedClass=12]="UnsupportedClass",Q[Q.UnsupportedByLicense=13]="UnsupportedByLicense",Q[Q.AwaitingOtherSide=14]="AwaitingOtherSide",Q[Q.Count=15]="Count",e.RecognitionMode=void 0,(X=e.RecognitionMode||(e.RecognitionMode={}))[X.None=0]="None",X[X.MrzId=1]="MrzId",X[X.MrzVisa=2]="MrzVisa",X[X.MrzPassport=3]="MrzPassport",X[X.PhotoId=4]="PhotoId",X[X.FullRecognition=5]="FullRecognition",X[X.Count=6]="Count";class te{constructor(){this.enableMrzId=!0,this.enableMrzPassport=!0,this.enableMrzVisa=!0,this.enablePhotoId=!0,this.enableFullDocumentRecognition=!0}}class ie{constructor(){this.allowBlurFilter=!0,this.allowUnparsedMrzResults=!1,this.allowUnverifiedMrzResults=!0,this.recognitionModeFilter=new te,this.scanCroppedDocumentImage=!1,this.validateResultCharacters=!0,this.anonymizationMode=e.AnonymizationMode.FullResult,this.barcodeScanningStartedCallback=null,this.classifierCallback=null,this.allowedDocumentClasses=null,this.paddingEdge=0,this.returnFullDocumentImage=!1,this.returnEncodedFullDocumentImage=!1,this._fullDocumentImageDpi=250,this.fullDocumentImageExtensionFactors=new $,this.returnFaceImage=!1,this.returnEncodedFaceImage=!1,this._faceImageDpi=250,this.returnSignatureImage=!1,this.returnEncodedSignatureImage=!1,this._signatureImageDpi=250}get fullDocumentImageDpi(){return this._fullDocumentImageDpi}set fullDocumentImageDpi(e){ee(e),this._fullDocumentImageDpi=e}get faceImageDpi(){return this._faceImageDpi}set faceImageDpi(e){ee(e),this._faceImageDpi=e}get signatureImageDpi(){return this._signatureImageDpi}set signatureImageDpi(e){ee(e),this._signatureImageDpi=e}}e.IdBarcodeDocumentType=void 0,(q=e.IdBarcodeDocumentType||(e.IdBarcodeDocumentType={}))[q.None=0]="None",q[q.AAMVACompliant=1]="AAMVACompliant",q[q.ArgentinaID=2]="ArgentinaID",q[q.ArgentinaDL=3]="ArgentinaDL",q[q.ColombiaID=4]="ColombiaID",q[q.ColombiaDL=5]="ColombiaDL",q[q.NigeriaVoterID=6]="NigeriaVoterID",q[q.NigeriaDL=7]="NigeriaDL",q[q.PanamaID=8]="PanamaID",q[q.SouthAfricaID=9]="SouthAfricaID",e.BlinkIdCombinedRecognizerSettings=class extends ie{constructor(){super(...arguments),this.allowSignature=!1}},e.BlinkIdRecognizerSettings=ie,e.CapturedFrame=f,e.ExtensionFactors=$,e.IdBarcodeRecognizerSettings=class{},e.RecognitionModeFilter=te,e.VideoRecognizer=y,e.VideoRecognizerError=B,e.WasmSDKLoadSettings=class{constructor(e){if(this.allowHelloMessage=!0,this.engineLocation="",this.loadProgressCallback=null,this.wasmModuleName="BlinkIDWasmSDK",!e)throw Error("Missing license key!");this.licenseKey=e}},e.captureFrame=P,e.createBlinkIdCombinedRecognizer=function(e){return t(this,void 0,void 0,(function*(){return e.mbWasmModule.newRecognizer("BlinkIdCombinedRecognizer")}))},e.createBlinkIdRecognizer=function(e){return t(this,void 0,void 0,(function*(){return e.mbWasmModule.newRecognizer("BlinkIdRecognizer")}))},e.createIdBarcodeRecognizer=function(e){return t(this,void 0,void 0,(function*(){return e.mbWasmModule.newRecognizer("IdBarcodeRecognizer")}))},e.createRecognizerRunner=function(e,i,o=!1,n={}){return t(this,void 0,void 0,(function*(){if("object"!=typeof e)throw Error("SDK is not provided!");if("object"!=typeof i||1>i.length)throw Error("To create RecognizerRunner at least 1 recognizer is required.");return e.mbWasmModule.createRecognizerRunner(i,o,n)}))},e.createSuccessFrameGrabberRecognizer=function(e,i){return t(this,void 0,void 0,(function*(){const t=yield e.mbWasmModule.newRecognizer("SuccessFrameGrabberRecognizer",i);return t.wrappedRecognizer=i,t}))},e.isBrowserSupported=function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){return!1}return!1},e.loadWasmModule=function(e){return t(this,void 0,void 0,(function*(){return new Promise((t,i)=>{if(!e||"object"!=typeof e)return void i("Missing WASM load settings!");if("string"!=typeof e.licenseKey)return void i("Missing license key!");if(!e.wasmModuleName)return void i("Missing WASM module name!");if("string"!=typeof e.engineLocation)return void i("Setting property 'engineLocation' must be a string!");const o=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=W(),localStorage.setItem("mb-user-id",e)),e}catch(e){return W()}}();try{const n=new Blob([String.raw`!function(){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function e(e,t,s,r){return new(s||(s=Promise))((function(n,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))}let t=0;class s{constructor(e){this.action=e,this.messageID=function(){const e=t;return t+=1,e}()}}class r extends s{constructor(e,t){super(r.action),this.wasmModuleName=e.wasmModuleName,this.licenseKey=e.licenseKey,this.userId=t,this.registerLoadCallback=null!==e.loadProgressCallback,this.allowHelloMessage=e.allowHelloMessage,this.engineLocation=e.engineLocation}}var n,i,o,a;r.action="init",function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback"}(n||(n={}));class c extends s{constructor(e,t){super(c.action),this.funcName=e,this.params=t}}c.action="invokeFunction";class l extends s{constructor(e,t){super(l.action),this.className=e,this.params=t}}l.action="createNewNativeObject";class u extends s{constructor(e,t,s){super(u.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=s}}u.action="createRecognizerRunner";class h extends s{constructor(e,t){super(h.action),this.recognizerHandles=e,this.allowMultipleResults=t}}h.action="reconfigureRecognizerRunner";class d extends s{constructor(){super(d.action)}}d.action="deleteRecognizerRunner";class g extends s{constructor(e,t,s){super(g.action),this.objectHandle=e,this.methodName=t,this.params=s}}g.action="invokeObject";class m extends s{constructor(e){super(m.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}m.action="processImage";class f extends s{constructor(e){super(f.action),this.hardReset=e}}f.action="resetRecognizers";class p extends s{constructor(e){super(p.action),this.registeredMetadataCallbacks=e}}p.action="registerMetadataCallbacks";class R extends s{constructor(e){super(R.action),this.detectionOnlyMode=e}}R.action="setDetectionOnly";class b extends s{constructor(e){super(b.action),this.callbackNonEmpty=e}}b.action="setClearTimeoutCallback";class k extends s{constructor(e){super(k.action),this.cameraPreviewMirrored=e}}k.action="setCameraPreviewMirrored";class y{constructor(e,t,s){this.success=!0,this.error=null,this.messageID=e,this.success=t,this.error=s}}class w{constructor(e,t,s){this.success=!0,this.showOverlay=!0,this.messageID=e,this.showOverlay=s}}class v extends y{constructor(e,t){super(e,!0,null),this.result=t}}class C extends y{constructor(e,t){super(e,!0,null),this.objectHandle=t}}class z extends y{constructor(e,t){super(e,!0,null),this.recognitionState=t}}class E{constructor(e){this.isLoadProgressMessage=!0,this.progress=e}}!function(e){e[e.onDebugText=0]="onDebugText",e[e.onDetectionFailed=1]="onDetectionFailed",e[e.onQuadDetection=2]="onQuadDetection",e[e.onPointsDetection=3]="onPointsDetection",e[e.onFirstSideResult=4]="onFirstSideResult",e[e.clearTimeoutCallback=5]="clearTimeoutCallback",e[e.onGlare=6]="onGlare",e[e.recognizerCallback=7]="recognizerCallback"}(i||(i={}));class M{constructor(e,t){this.isCallbackMessage=!0,this.callbackType=e,this.callbackParameters=t}}function I(e,t){return t=t||"",""===(e=e||"")?t:e.endsWith("/")?t.startsWith("/")?e+t.substring(1):e+t:t.startsWith("/")?e+t:e+"/"+t}!function(e){e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid"}(o||(o={})),function(e){e.LicenseTokenStateInvalid="LICENSE_TOKEN_STATE_INVALID",e.NetworkError="NETWORK_ERROR",e.RemoteLock="REMOTE_LOCK",e.PermissionExpired="PERMISSION_EXPIRED",e.PayloadCorrupted="PAYLOAD_CORRUPTED",e.PayloadSignatureVerificationFailed="PAYLOAD_SIGNATURE_VERIFICATION_FAILED",e.IncorrectTokenState="INCORRECT_TOKEN_STATE"}(a||(a={}));class S{constructor(e,t){this.code="UNLOCK_LICENSE_ERROR",this.message=null,this.type=e,t&&(this.message=t)}}function x(e){return{licenseId:e.licenseId,licensee:e.licensee,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}var T;function P(t,s){return e(this,void 0,void 0,(function*(){try{const e=yield fetch("https://baltazar.microblink.com/api/v1/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(x(t))});if(e.ok){const t=""+(yield e.text());return s.submitServerPermission(t)}return{status:T.NetworkError,lease:0,networkErrorDescription:"Server responded with status "+e.status}}catch(e){return{status:T.NetworkError,lease:0,networkErrorDescription:"Unexpected error: "+JSON.stringify(e)}}}))}!function(e){e[e.Ok=0]="Ok",e[e.NetworkError=1]="NetworkError",e[e.RemoteLock=2]="RemoteLock",e[e.PermissionExpired=3]="PermissionExpired",e[e.PayloadCorrupted=4]="PayloadCorrupted",e[e.PayloadSignatureVerificationFailed=5]="PayloadSignatureVerificationFailed",e[e.IncorrectTokenState=6]="IncorrectTokenState"}(T||(T={}));new class{constructor(){this.context=self,this.wasmModule=null,this.nativeRecognizerRunner=null,this.objects={},this.nextObjectHandle=0,this.metadataCallbacks={},this.clearTimeoutCallback=null,this.context.onmessage=e=>{const t=e.data;switch(t.action){case r.action:this.processInitMessage(t);break;case c.action:this.processInvokeFunction(t);break;case l.action:this.processCreateNewRecognizer(t);break;case g.action:this.processInvokeObject(t);break;case u.action:this.processCreateRecognizerRunner(t);break;case h.action:this.processReconfigureRecognizerRunner(t);break;case d.action:this.processDeleteRecognizerRunner(t);break;case m.action:this.processImage(t);break;case f.action:this.resetRecognizers(t);break;case R.action:this.setDetectionOnly(t);break;case k.action:this