UNPKG

@microblink/blinkid-in-browser-sdk

Version:

A simple ID scanning library for WebAssembly-enabled browsers.

38 lines (33 loc) 59.7 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. ***************************************************************************** */ /*! ***************************************************************************** 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,i,n){return new(i||(i=Promise))((function(o,a){function s(e){try{A(n.next(e))}catch(e){a(e)}}function r(e){try{A(n.throw(e))}catch(e){a(e)}}function A(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,r)}A((n=n.apply(e,t||[])).next())}))}let t=0;class i{constructor(e){this.action=e,this.messageID=function(){const e=t;return t+=1,e}()}}class n extends i{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 o,a,s,r,A;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"}(o||(o={}));class c extends i{constructor(e,t){super(c.action),this.className=e,this.params=t}}c.action="createNewNativeObject";class I extends i{constructor(e,t,i){super(I.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}I.action="createRecognizerRunner";class l extends i{constructor(e,t){super(l.action),this.recognizerHandles=e,this.allowMultipleResults=t}}l.action="reconfigureRecognizerRunner";class N extends i{constructor(){super(N.action)}}N.action="deleteRecognizerRunner";class d extends i{constructor(e,t,i){super(d.action),this.objectHandle=e,this.methodName=t,this.params=i}}d.action="invokeObject";class R extends i{constructor(e){super(R.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}R.action="processImage";class E extends i{constructor(e){super(E.action),this.hardReset=e}}E.action="resetRecognizers";class u{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1,this.onGlare=!1}}class S extends i{constructor(e){super(S.action),this.registeredMetadataCallbacks=e}}S.action="registerMetadataCallbacks";class O extends i{constructor(e){super(O.action),this.detectionOnlyMode=e}}O.action="setDetectionOnly";class D extends i{constructor(e){super(D.action),this.callbackNonEmpty=e}}D.action="setClearTimeoutCallback";class C extends i{constructor(e){super(C.action),this.cameraPreviewMirrored=e}}function T(e,t){return i=>{const n=i;n.success?e():t(n.error)}}function m(e,t){return i=>{const n=i;n.success?e(i):t(n.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"}(a||(a={}));class h{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 d(this.objectHandle,"currentSettings",[]),n=m(t=>{e(t.result)},t);this.wasmSDKWorker.postMessage(i,n)})}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const n of t){const t=e[n];if("function"==typeof t){this.callbacks.set(n,t);e[n]={parameter:{recognizerHandle:this.objectHandle,callbackName:n},type:o.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 n=new d(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:o.RecognizerSettings}]),a=T(t,i);this.wasmSDKWorker.postMessage(n,a)})}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 d(this.objectHandle,"getResult",[]),n=m(t=>{e(t.result)},t);this.wasmSDKWorker.postMessage(i,n)})}delete(){return new Promise((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);this.clearAllCallbacks();const i=new d(this.objectHandle,"delete",[]),n=T(()=>{this.objectHandle=-1,e()},t);this.wasmSDKWorker.postMessage(i,n)})}}function _(e){const t=new u;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 g{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 n=new R(e),o=m(e=>{t(e.recognitionState)},i);this.wasmSDKWorker.postTransferrableMessage(n,o)})}reconfigureRecognizers(e,t){return new Promise((i,n)=>{if(this.deleted)return void n("Recognizer runner is deleted. It cannot be used anymore!");const o=L(e),a=new l(o,t),s=T(i,n);this.wasmSDKWorker.postMessage(a,s)})}setMetadataCallbacks(e){return new Promise((t,i)=>{const n=new S(_(e)),o=T(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(n,e,o)})}resetRecognizers(e){return new Promise((t,i)=>{const n=new E(e),o=T(t,i);this.wasmSDKWorker.postMessage(n,o)})}setDetectionOnlyMode(e){return new Promise((t,i)=>{const n=new O(e),o=T(t,i);this.wasmSDKWorker.postMessage(n,o)})}setClearTimeoutCallback(e){return new Promise((t,i)=>{const n=new D(null!==e),o=T(t,i);this.wasmSDKWorker.registerClearTimeoutCallback(e),this.wasmSDKWorker.postMessage(n,o)})}setCameraPreviewMirrored(e){return new Promise((t,i)=>{const n=new C(e),o=T(t,i);this.wasmSDKWorker.postMessage(n,o)})}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise((e,t)=>{const i=new N,n=T(()=>{this.deleted=!0,e()},t);this.wasmSDKWorker.postMessage(i,n)})}}function L(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class M{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise((n,o)=>{const a=L(e),s=new I(a,t,_(i)),r=T(()=>{n(new g(this.wasmSDKWorker))},o);this.wasmSDKWorker.postMessageAndRegisterCallbacks(s,i,r)})}newRecognizer(e,...t){return new Promise((i,n)=>{const a=new c(e,function(e){const t=[];for(let i of e){let e=o.Any;i instanceof h&&(e=o.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),s=m(t=>{const n=new h(this.wasmSDKWorker,e,t.objectHandle);i(n)},n);this.wasmSDKWorker.postMessage(a,s)})}}class U{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 M(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 a.onDebugText:"function"==typeof this.metadataCallbacks.onDebugText&&this.metadataCallbacks.onDebugText(t.callbackParameters[0]);break;case a.onDetectionFailed:"function"==typeof this.metadataCallbacks.onDetectionFailed&&this.metadataCallbacks.onDetectionFailed();break;case a.onPointsDetection:"function"==typeof this.metadataCallbacks.onPointsDetection&&this.metadataCallbacks.onPointsDetection(t.callbackParameters[0]);break;case a.onQuadDetection:"function"==typeof this.metadataCallbacks.onQuadDetection&&this.metadataCallbacks.onQuadDetection(t.callbackParameters[0]);break;case a.onFirstSideResult:"function"==typeof this.metadataCallbacks.onFirstSideResult&&this.metadataCallbacks.onFirstSideResult();break;case a.clearTimeoutCallback:this.clearTimeoutCallback&&"function"==typeof this.clearTimeoutCallback.onClearTimeout&&this.clearTimeoutCallback.onClearTimeout();break;case a.onGlare:"function"==typeof this.metadataCallbacks.onGlare&&this.metadataCallbacks.onGlare(t.callbackParameters[0]);break;case a.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: "+a[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(t,i,o){return e(this,void 0,void 0,(function*(){return new Promise((e,a)=>{const s=new U(t,i.loadProgressCallback,a),r=new n(i,o),A=m(t=>{s.showOverlay=t.showOverlay,e(s)},a);s.postMessage(r,A)})}))}}let b;!function(e){e[e.RotatedLeft90=0]="RotatedLeft90",e[e.NoRotation=1]="NoRotation",e[e.RotatedRight90=2]="RotatedRight90",e[e.Rotated180=3]="Rotated180"}(s||(s={})),function(e){e[e.Empty=0]="Empty",e[e.Uncertain=1]="Uncertain",e[e.Valid=2]="Valid",e[e.StageValid=3]="StageValid"}(r||(r={})),function(e){e[e.Fail=0]="Fail",e[e.Success=1]="Success",e[e.CameraTooHigh=2]="CameraTooHigh",e[e.FallbackSuccess=3]="FallbackSuccess",e[e.Partial=4]="Partial",e[e.CameraAtAngle=5]="CameraAtAngle",e[e.CameraTooNear=6]="CameraTooNear",e[e.DocumentTooCloseToEdge=7]="DocumentTooCloseToEdge"}(A||(A={}));class f{constructor(e,t,i){this.imageData=e,this.orientation=t,this.videoFrame=i}}function P(e){let t,i,n=!1;if(e instanceof HTMLVideoElement)t=e.videoWidth,i=e.videoHeight,n=!0;else if(e instanceof HTMLImageElement)t=e.naturalWidth,i=e.naturalHeight;else{if(e instanceof SVGImageElement)throw Error("Recognition of SVG elements not supported!");t=e.width,i=e.height}b=b||document.createElement("canvas"),b.width=t,b.height=i;const o=b.getContext("2d");if(!o)throw Error("Could not get canvas 2d context!");o.drawImage(e,0,0,b.width,b.height);const a=o.getImageData(0,0,b.width,b.height);return new f(a,s.NoRotation,n)}var p,F,H;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(p||(p={})),function(e){e.MediaDevicesNotSupported="MediaDevicesNotSupported",e.CameraNotFound="CameraNotFound",e.CameraNotAllowed="CameraNotAllowed",e.CameraInUse="CameraInUse",e.CameraNotAvailable="CameraNotAvailable",e.VideoElementNotProvided="VideoElementNotProvided"}(F||(F={}));class v extends Error{constructor(e,...t){super(...t),this.reason=e,this.name="VideoRecognizerError"}}!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(H||(H={}));class B{constructor(e,t,i=!1,n=!1){this.videoFeed=null,this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.recognitionTimeoutMs=15e3,this.timeoutID=0,this.videoRecognitionMode=H.Recognition,this.onScanningDone=null,this.allowManualVideoPlayout=!1,this.cameraFlipped=!1,this.videoFeed=e,this.recognizerRunner=t,this.cameraFlipped=i,n&&(this.allowManualVideoPlayout=n)}static createVideoRecognizerFromCameraStream(t,i,n=null,o=p.BackFacingCamera){return e(this,void 0,void 0,(function*(){return new Promise((a,s)=>e(this,void 0,void 0,(function*(){if(t&&t instanceof Element)if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)try{const r=yield function(t,i){return e(this,void 0,void 0,(function*(){const e=[],n=[];{let t=yield navigator.mediaDevices.enumerateDevices();if(t.filter(e=>"videoinput"===e.kind).every(e=>""===e.label)){const e=yield navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});t=yield navigator.mediaDevices.enumerateDevices(),e.getTracks().forEach(e=>e.stop())}const i=t.filter(e=>"videoinput"===e.kind);for(const t of i)w(t.label)?n.push(new G(t,p.BackFacingCamera)):e.push(new G(t,p.FrontFacingCamera))}if(e.length>0||n.length>0){let o=n.length>0?n:e;i===p.BackFacingCamera&&n.length>0&&(o=n),i===p.FrontFacingCamera&&e.length>0&&(o=e),o=o.sort((e,t)=>e.label.localeCompare(t.label));{let i=0;const a=o.map(e=>{const t=/\b([0-9]+)MP?\b/i.exec(e.label);return null!==t?parseInt(t[1],10):NaN});if(a.some(e=>isNaN(e))||(i=a.lastIndexOf(Math.max(...a))),t){let i=null;return i=e.filter(e=>e.deviceId===t)[0],i||(i=n.filter(e=>e.deviceId===t)[0]),i||null}return o[i]}}return null}))}(n,o);if(null===r)return void s(new v(F.CameraNotFound));const A={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};if(""===r.deviceId){A.video.facingMode={ideal:o===p.BackFacingCamera?"environment":"user"}}else A.video.deviceId={exact:r.deviceId};const c=yield navigator.mediaDevices.getUserMedia(A);t.controls=!1,t.srcObject=c;let I=!1;r.facing===p.FrontFacingCamera&&(t.style.transform="scaleX(-1)",I=!0),yield i.setCameraPreviewMirrored(I),a(new B(t,i,I))}catch(e){let t=F.CameraInUse;switch(e.name){case"NotFoundError":case"OverconstrainedError":t=F.CameraNotFound;break;case"NotAllowedError":case"SecurityError":t=F.CameraNotAllowed;break;case"AbortError":case"NotReadableError":t=F.CameraNotAvailable;break;case"TypeError":throw e}s(new v(t,e.message))}else s(new v(F.MediaDevicesNotSupported));else{s(new v(F.VideoElementNotProvided,"Video element, i.e. camera feed is not provided!"))}})))}))}static createVideoRecognizerFromVideoPath(t,i,n){return e(this,void 0,void 0,(function*(){return new Promise(e=>{i.src=t,i.currentTime=0,i.onended=()=>{o.cancelRecognition()};const o=new B(i,n);e(o)})}))}flipCamera(){return e(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(t){return e(this,void 0,void 0,(function*(){this.videoRecognitionMode=t;const e=this.videoRecognitionMode===H.DetectionTest;yield this.recognizerRunner.setDetectionOnlyMode(e)}))}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(t=15e3){return e(this,void 0,void 0,(function*(){return new Promise((e,i)=>{try{this.startRecognition(t=>{this.pauseVideoFeed(),e(t)},t)}catch(e){i(e)}})}))}cancelRecognition(){this.cancelled=!0}pauseVideoFeed(){this.pauseRecognition(),this.videoFeed&&this.videoFeed.pause()}pauseRecognition(){this.recognitionPaused=!0}resetRecognizers(t){return e(this,void 0,void 0,(function*(){yield this.recognizerRunner.resetRecognizers(t)}))}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 e(this,void 0,void 0,(function*(){if(!this.videoFeed)throw Error("Missing video feed!");const e=P(this.videoFeed),t=yield this.recognizerRunner.processImage(e);t===r.Valid||this.cancelled||this.timedOut?this.videoRecognitionMode===H.Recognition||this.cancelled?(this.clearTimeout(),this.onScanningDone&&this.onScanningDone(t)):(yield this.recognizerRunner.resetRecognizers(!0),this.clearTimeout()):t===r.Uncertain?0===this.timeoutID&&(this.timeoutID=window.setTimeout(()=>{this.timedOut=!0},this.recognitionTimeoutMs)):t===r.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}}class W{constructor(e){if(this.allowHelloMessage=!0,this.engineLocation="",this.loadProgressCallback=null,this.wasmModuleName="BlinkIDWasmSDK",!e)throw Error("Missing license key!");this.licenseKey=e}}function y(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}function K(){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}function V(t){return e(this,void 0,void 0,(function*(){return new Promise((e,i)=>{if(!t||"object"!=typeof t)return void i("Missing WASM load settings!");if("string"!=typeof t.licenseKey)return void i("Missing license key!");if(!t.wasmModuleName)return void i("Missing WASM module name!");if("string"!=typeof t.engineLocation)return void i("Setting property 'engineLocation' must be a string!");const n=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=y(),localStorage.setItem("mb-user-id",e)),e}catch(e){return y()}}();try{const o=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.setCameraPreviewMirrored(t);break;case p.action:this.registerMetadataCallbacks(t);break;case b.action:this.registerClearTimeoutCallback(t);break;default:throw Error("Unknown message action: "+JSON.stringify(t.action))}}}getNextObjectHandle(){const e=this.nextObjectHandle;return this.nextObjectHandle=this.nextObjectHandle+1,e}notifyError(e,t){this.context.postMessage(new y(e.messageID,!1,t))}notifySuccess(e){this.context.postMessage(new y(e.messageID,!0,null))}notifyInitSuccess(e,t){this.context.postMessage(new w(e.messageID,!0,t))}unwrapParameters(e){const t=[];for(const s of e.params){let r=s.parameter;s.type===n.Recognizer?(r=this.objects[r],void 0===r&&this.notifyError(e,"Cannot find object with handle: undefined")):s.type===n.RecognizerSettings&&(r=this.restoreFunctions(r)),t.push(r)}return t}restoreFunctions(e){const t=Object.keys(e);for(const s of t){const t=e[s];"object"==typeof t&&null!==t&&"parameter"in t&&"type"in t&&t.type===n.Callback&&(e[s]=(...e)=>{const s=new M(i.recognizerCallback,[t.parameter].concat(e));this.context.postMessage(s)})}return e}scanForTransferrables(e){if("object"==typeof e){const t=Object.keys(e),s=[];for(const r of t){const t=e[r];t instanceof ImageData?s.push(t.data.buffer):t instanceof Uint8Array?s.push(t.buffer):null!==t&&"object"==typeof t&&s.push(...this.scanForTransferrables(t))}return s}return[]}registerHeartBeat(e){this.unregisterHeartBeat(),this.lease=e;let t=e-Math.floor(Date.now()/1e3);t>120?t-=120:t/=2,this.inFlightHeartBeatTimeoutId=setTimeout(()=>{this.obtainNewServerPermission(!0)},1e3*t)}unregisterHeartBeat(){this.lease&&delete this.lease,this.inFlightHeartBeatTimeoutId&&(clearTimeout(this.inFlightHeartBeatTimeoutId),delete this.inFlightHeartBeatTimeoutId)}obtainNewServerPermission(t){return e(this,void 0,void 0,(function*(){if(this.wasmModule){const e=this.wasmModule.getActiveLicenseTokenInfo(),s=yield P(e,this.wasmModule);switch(s.status){case T.Ok:case T.RemoteLock:this.registerHeartBeat(s.lease);break;case T.NetworkError:case T.PayloadSignatureVerificationFailed:case T.PayloadCorrupted:t?(console.warn("Problem with obtaining server permission. Will attempt in 10 seconds "+T[s.status]),this.inFlightHeartBeatTimeoutId=setTimeout(()=>{this.obtainNewServerPermission(!1)},1e4)):console.error("Problem with obtaining server permission. "+T[s.status]);break;case T.IncorrectTokenState:case T.PermissionExpired:console.error("Internal error: "+T[s.status])}return s.status}return console.error("Internal inconsistency! Wasm module not initialized where it's expected to be!"),T.IncorrectTokenState}))}willSoonExpire(){if(this.lease){if(this.wasmModule.getActiveLicenseTokenInfo().unlockResult===o.Valid){const e=Math.floor(Date.now()/1e3);return 30>this.lease-e}return!0}return!1}processInitMessage(t){let s={locateFile:e=>I(""===t.engineLocation?self.location.origin:t.engineLocation,e)};t.registerLoadCallback&&(s=Object.assign(s,{setStatus:e=>{const t=new E(function(e){if("Running..."===e)return 100;if(0===e.length)return 0;const t=/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/.exec(e);if(t){return 100*parseInt(t[2])/parseInt(t[4])}return NaN}(e));this.context.postMessage(t)}}));try{const r=""===t.engineLocation?self.location.origin:t.engineLocation,n=I(r,t.wasmModuleName+".js");importScripts(n);(0,self[t.wasmModuleName])(s).then(s=>e(this,void 0,void 0,(function*(){const r=yield function(t,s,r,n){return e(this,void 0,void 0,(function*(){const e=n.initializeWithLicenseKey(t,r,s);switch(e.unlockResult){case o.Invalid:return{error:new S(a.LicenseTokenStateInvalid,e.licenseError)};case o.Valid:return{error:null,showOverlay:(i=e.isTrial,c=e.allowRemoveDemoOverlay,l=e.allowRemoveProductionOverlay,!(i&&c||!i&&l))};case o.RequiresServerPermission:{const t=yield P(e,n);switch(t.status){case T.Ok:return{error:null,lease:t.lease};case T.NetworkError:{let e="";return t.networkErrorDescription&&(e=" "+t.networkErrorDescription),{error:new S(a.NetworkError,"There has been a network error while obtaining the server permission!"+e)}}case T.RemoteLock:return{error:new S(a.RemoteLock,"Provided license key has been remotely locked.Please contact support for more information!"),lease:t.lease};case T.PermissionExpired:return{error:new S(a.PermissionExpired,"Internal error (server permission expired)"),lease:t.lease};case T.PayloadCorrupted:return{error:new S(a.PayloadCorrupted,"Server permission payload is corrupted!"),lease:t.lease};case T.PayloadSignatureVerificationFailed:return{error:new S(a.PayloadSignatureVerificationFailed,"Failed to verify server permission's digital signature!"),lease:t.lease};case T.IncorrectTokenState:return{error:new S(a.IncorrectTokenState,"Internal error (Incorrect token state)"),lease:t.lease}}}}var i,c,l}))}(t.licenseKey,t.allowHelloMessage,t.userId,s);null===r.error?(this.wasmModule=s,r.lease?this.registerHeartBeat(r.lease):this.unregisterHeartBeat(),this.notifyInitSuccess(t,!!r.showOverlay)):this.notifyError(t,r.error)})),e=>{this.notifyError(t,e)})}catch(e){this.notifyError(t,e)}}processInvokeFunction(e){if(null===this.wasmModule)return void this.notifyError(e,"WASM module is not initialized!");const t=e.funcName,s=this.unwrapParameters(e);try{const r=this.wasmModule[t](...s);this.context.postMessage(new v(e.messageID,r))}catch(t){this.notifyError(e,t)}}processCreateNewRecognizer(e){if(null===this.wasmModule)return void this.notifyError(e,"WASM module is not initialized!");const t=e.className,s=this.unwrapParameters(e);try{const r=new this.wasmModule[t](...s),n=this.getNextObjectHandle();this.objects[n]=r,this.context.postMessage(new C(e.messageID,n))}catch(t){this.notifyError(e,t)}}getRecognizers(e){const t=[];for(const s of e){t.push(this.objects[s])}return t}processCreateRecognizerRunner(t){return e(this,void 0,void 0,(function*(){if(null===this.wasmModule)this.notifyError(t,"WASM module is not initialized!");else if(null!==this.nativeRecognizerRunner)this.notifyError(t,"Recognizer runner is already created! Multiple instances are not allowed!");else{this.setupMetadataCallbacks(t.registeredMetadataCallbacks);try{if(this.willSoonExpire()){const e=yield this.obtainNewServerPermission(!1);if(e!==T.Ok){const s=T[e];return void this.notifyError(t,new S(a[s],"Cannot initialize recognizers because of invalid server permission: "+s))}}const e=this.getRecognizers(t.recognizerHandles);this.nativeRecognizerRunner=new this.wasmModule.RecognizerRunner(e,t.allowMultipleResults,this.metadataCallbacks),this.notifySuccess(t)}catch(e){this.notifyError(t,e)}}}))}processReconfigureRecognizerRunner(e){if(null===this.wasmModule)this.notifyError(e,"WASM module is not initialized!");else if(null===this.nativeRecognizerRunner)this.notifyError(e,"Recognizer runner is not created! There is nothing to reconfigure!");else try{const t=this.getRecognizers(e.recognizerHandles);this.nativeRecognizerRunner.reconfigureRecognizers(t,e.allowMultipleResults),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}}processDeleteRecognizerRunner(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.delete(),this.nativeRecognizerRunner=null,this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is already deleted!")}processInvokeObject(e){try{const t=e.objectHandle,s=e.methodName,r=this.unwrapParameters(e),n=this.objects[t];if(void 0===n)this.notifyError(e,"Cannot find object with handle: "+t);else{const i=n[s](...r),o=this.scanForTransferrables(i);"delete"===s&&delete this.objects[t],this.context.postMessage(new v(e.messageID,i),o)}}catch(t){this.notifyError(e,t)}}processImage(e){if(null!==this.nativeRecognizerRunner)try{const t=this.nativeRecognizerRunner.processImage(e.frame);this.context.postMessage(new z(e.messageID,t))}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}resetRecognizers(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.resetRecognizers(e.hardReset),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}setDetectionOnly(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.setDetectionOnlyMode(e.detectionOnlyMode),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}setCameraPreviewMirrored(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.setCameraPreviewMirrored(e.cameraPreviewMirrored),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}setupMetadataCallbacks(e){e.onDebugText?this.metadataCallbacks.onDebugText=e=>{const t=new M(i.onDebugText,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onDebugText,e.onDetectionFailed?this.metadataCallbacks.onDetectionFailed=()=>{const e=new M(i.onDetectionFailed,[]);this.context.postMessage(e)}:delete this.metadataCallbacks.onDetectionFailed,e.onPointsDetection?this.metadataCallbacks.onPointsDetection=e=>{const t=new M(i.onPointsDetection,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onPointsDetection,e.onQuadDetection?this.metadataCallbacks.onQuadDetection=e=>{const t=new M(i.onQuadDetection,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onQuadDetection,e.onFirstSideResult?this.metadataCallbacks.onFirstSideResult=()=>{const e=new M(i.onFirstSideResult,[]);this.context.postMessage(e)}:delete this.metadataCallbacks.onFirstSideResult,e.onGlare?this.metadataCallbacks.onGlare=e=>{const t=new M(i.onGlare,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onGlare}registerMetadataCallbacks(e){if(null!==this.nativeRecognizerRunner){this.setupMetadataCallbacks(e.registeredMetadataCallbacks);try{this.nativeRecognizerRunner.setJSDelegate(this.metadataCallbacks),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}registerClearTimeoutCallback(e){if(null!==this.nativeRecognizerRunner){this.clearTimeoutCallback=e.callbackNonEmpty?{onClearTimeout:()=>{const e=new M(i.clearTimeoutCallback,[]);this.context.postMessage(e)}}:null;try{this.nativeRecognizerRunner.setClearTimeoutCallback(this.clearTimeoutCallback),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}}}(); `],{type:"application/javascript"}),a=URL.createObjectURL(o),s=new Worker(a);U.createWasmWorker(s,t,n).then(t=>{e(t)},i)}catch(e){i(e)}})}))}function Y(t,i,n=!1,o={}){return e(this,void 0,void 0,(function*(){if("object"!=typeof t)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 t.mbWasmModule.createRecognizerRunner(i,n,o)}))}function z(t,i){return e(this,void 0,void 0,(function*(){const e=yield t.mbWasmModule.newRecognizer("SuccessFrameGrabberRecognizer",i);return e.wrappedRecognizer=i,e}))}var x,J,j,Z,Q,X,q,$,ee,te,ie;!function(e){e[e.NONE=0]="NONE",e[e.QR_CODE=1]="QR_CODE",e[e.DATA_MATRIX=2]="DATA_MATRIX",e[e.UPC_E=3]="UPC_E",e[e.UPC_A=4]="UPC_A",e[e.EAN_8=5]="EAN_8",e[e.EAN_13=6]="EAN_13",e[e.CODE_128=7]="CODE_128",e[e.CODE_39=8]="CODE_39",e[e.ITF=9]="ITF",e[e.AZTEC_BARCODE=10]="AZTEC_BARCODE",e[e.PDF417_BARCODE=11]="PDF417_BARCODE"}(x||(x={})),function(e){e[e.None=0]="None",e[e.ImageOnly=1]="ImageOnly",e[e.ResultFieldsOnly=2]="ResultFieldsOnly",e[e.FullResult=3]="FullResult"}(J||(J={}));class ne{constructor(e=0,t=0,i=0,n=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(n),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=n}checkExtensionFactor(e){if(e>1||-1>e)throw Error("Extension factor must be in range [-1.0, 1.0]")}}function oe(e){if(100>e||e>400)throw Error("DPI must be from interval [100, 400]")}!function(e){e[e.DocumentType=0]="DocumentType",e[e.StandardVersionNumber=1]="StandardVersionNumber",e[e.CustomerFamilyName=2]="CustomerFamilyName",e[e.CustomerFirstName=3]="CustomerFirstName",e[e.CustomerFullName=4]="CustomerFullName",e[e.DateOfBirth=5]="DateOfBirth",e[e.Sex=6]="Sex",e[e.EyeColor=7]="EyeColor",e[e.AddressStreet=8]="AddressStreet",e[e.AddressCity=9]="AddressCity",e[e.AddressJurisdictionCode=10]="AddressJurisdictionCode",e[e.AddressPostalCode=11]="AddressPostalCode",e[e.FullAddress=12]="FullAddress",e[e.Height=13]="Height",e[e.HeightIn=14]="HeightIn",e[e.HeightCm=15]="HeightCm",e[e.CustomerMiddleName=16]="CustomerMiddleName",e[e.HairColor=17]="HairColor",e[e.NameSuffix=18]="NameSuffix",e[e.AKAFullName=19]="AKAFullName",e[e.AKAFamilyName=20]="AKAFamilyName",e[e.AKAGivenName=21]="AKAGivenName",e[e.AKASuffixName=22]="AKASuffixName",e[e.WeightRange=23]="WeightRange",e[e.WeightPounds=24]="WeightPounds",e[e.WeightKilograms=25]="WeightKilograms",e[e.CustomerIdNumber=26]="CustomerIdNumber",e[e.FamilyNameTruncation=27]="FamilyNameTruncation",e[e.FirstNameTruncation=28]="FirstNameTruncation",e[e.MiddleNameTruncation=29]="MiddleNameTruncation",e[e.PlaceOfBirth=30]="PlaceOfBirth",e[e.AddressStreet2=31]="AddressStreet2",e[e.RaceEthnicity=32]="RaceEthnicity",e[e.NamePrefix=33]="NamePrefix",e[e.CountryIdentification=34]="CountryIdentification",e[e.ResidenceStreetAddress=35]="ResidenceStreetAddress",e[e.ResidenceStreetAddress2=36]="ResidenceStreetAddress2",e[e.ResidenceCity=37]="ResidenceCity",e[e.ResidenceJurisdictionCode=38]="ResidenceJurisdictionCode",e[e.ResidencePostalCode=39]="ResidencePostalCode",e[e.ResidenceFullAddress=40]="ResidenceFullAddress",e[e.Under18=41]="Under18",e[e.Under19=42]="Under19",e[e.Under21=43]="Under21",e[e.SocialSecurityNumber=44]="SocialSecurityNumber",e[e.AKASocialSecurityNumber=45]="AKASocialSecurityNumber",e[e.AKAMiddleName=46]="AKAMiddleName",e[e.AKAPrefixName=47]="AKAPrefixName",e[e.OrganDonor=48]="OrganDonor",e[e.Veteran=49]="Veteran",e[e.AKADateOfBirth=50]="AKADateOfBirth",e[e.IssuerIdentificationNumber=51]="IssuerIdentificationNumber",e[e.DocumentExpirationDate=52]="DocumentExpirationDate",e[e.JurisdictionVersionNumber=53]="JurisdictionVersionNumber",e[e.JurisdictionVehicleClass=54]="JurisdictionVehicleClass",e[e.JurisdictionRestrictionCodes=55]="JurisdictionRestrictionCodes",e[e.JurisdictionEndorsementCodes=56]="JurisdictionEndorsementCodes",e[e.DocumentIssueDate=57]="DocumentIssueDate",e[e.FederalCommercialVehicleCodes=58]="FederalCommercialVehicleCodes",e[e.IssuingJurisdiction=59]="IssuingJurisdiction",e[e.StandardVehicleClassification=60]="StandardVehicleClassification",e[e.IssuingJurisdictionName=61]="IssuingJurisdictionName",e[e.StandardEndorsementCode=62]="StandardEndorsementCode",e[e.StandardRestrictionCode=63]="StandardRestrictionCode",e[e.JurisdictionVehicleClassificationDescription=64]="JurisdictionVehicleClassificationDescription",e[e.JurisdictionEndorsmentCodeDescription=65]="JurisdictionEndorsmentCodeDescription",e[e.JurisdictionRestrictionCodeDescription=66]="JurisdictionRestrictionCodeDescription",e[e.InventoryControlNumber=67]="InventoryControlNumber",e[e.CardRevisionDate=68]="CardRevisionDate",e[e.DocumentDiscriminator=69]="DocumentDiscriminator",e[e.LimitedDurationDocument=70]="LimitedDurationDocument",e[e.AuditInformation=71]="AuditInformation",e[e.ComplianceType=72]="ComplianceType",e[e.IssueTimestamp=73]="IssueTimestamp",e[e.PermitExpirationDate=74]="PermitExpirationDate",e[e.PermitIdentifier=75]="PermitIdentifier",e[e.PermitIssueDate=76]="PermitIssueDate",e[e.NumberOfDuplicates=77]="NumberOfDuplicates",e[e.HAZMATExpirationDate=78]="HAZMATExpirationDate",e[e.MedicalIndicator=79]="MedicalIndicator",e[e.NonResident=80]="NonResident",e[e.UniqueCustomerId=81]="UniqueCustomerId",e[e.DataDiscriminator=82]="DataDiscriminator",e[e.DocumentExpirationMonth=83]="DocumentExpirationMonth",e[e.DocumentNonexpiring=84]="DocumentNonexpiring",e[e.SecurityVersion=85]="SecurityVersion",e[e.Count=86]="Count"}(j||(j={})),function(e){e[e.NONE=0]="NONE",e[e.ALBANIA=1]="ALBANIA",e[e.ALGERIA=2]="ALGERIA",e[e.ARGENTINA=3]="ARGENTINA",e[e.AUSTRALIA=4]="AUSTRALIA",e[e.AUSTRIA=5]="AUSTRIA",e[e.AZERBAIJAN=6]="AZERBAIJAN",e[e.BAHRAIN=7]="BAHRAIN",e[e.BANGLADESH=8]="BANGLADESH",e[e.BELGIUM=9]="BELGIUM",e[e.BOSNIA_AND_HERZEGOVINA=10]="BOSNIA_AND_HERZEGOVINA",e[e.BRUNEI=11]="BRUNEI",e[e.BULGARIA=12]="BULGARIA",e[e.CAMBODIA=13]="CAMBODIA",e[e.CANADA=14]="CANADA",e[e.CHILE=15]="CHILE",e[e.COLOMBIA=16]="COLOMBIA",e[e.COSTA_RICA=17]="COSTA_RICA",e[e.CROATIA=18]="CROATIA",e[e.CYPRUS=19]="CYPRUS",e[e.CZECHIA=20]="CZECHIA",e[e.DENMARK=21]="DENMARK",e[e.DOMINICAN_REPUBLIC=22]="DOMINICAN_REPUBLIC",e[e.EGYPT=23]="EGYPT",e[e.ESTONIA=24]="ESTONIA",e[e.FINLAND=25]="FINLAND",e[e.FRANCE=26]="FRANCE",e[e.GEORGIA=27]="GEORGIA",e[e.GERMANY=28]="GERMANY",e[e.GHANA=29]="GHANA",e[e.GREECE=30]="GREECE",e[e.GUATEMALA=31]="GUATEMALA",e[e.HONG_KONG=32]="HONG_KONG",e[e.HUNGARY=33]="HUNGARY",e[e.INDIA=34]="INDIA",e[e.INDONESIA=35]="INDONESIA",e[e.IRELAND=36]="IRELAND",e[e.ISRAEL=37]="ISRAEL",e[e.ITALY=38]="ITALY",e[e.JORDAN=39]="JORDAN",e[e.KAZAKHSTAN=40]="KAZAKHSTAN",e[e.KENYA=41]="KENYA",e[e.KOSOVO=42]="KOSOVO",e[e.KUWAIT=43]="KUWAIT",e[e.LATVIA=44]="LATVIA",e[e.LITHUANIA=45]="LITHUANIA",e[e.MALAYSIA=46]="MALAYSIA",e[e.MALDIVES=47]="MALDIVES",e[e.MALTA=48]="MALTA",e[e.MAURITIUS=49]="MAURITIUS",e[e.MEXICO=50]="MEXICO",e[e.MOROCCO=51]="MOROCCO",e[e.NETHERLANDS=52]="NETHERLANDS",e[e.NEW_ZEALAND=53]="NEW_ZEALAND",e[e.NIGERIA=54]="NIGERIA",e[e.PAKISTAN=55]="PAKISTAN",e[e.PANAMA=56]="PANAMA",e[e.PARAGUAY=57]="PARAGUAY",e[e.PHILIPPINES=58]="PHILIPPINES",e[e.POLAND=59]="POLAND",e[e.PORTUGAL=60]="PORTUGAL",e[e.PUERTO_RICO=61]="PUERTO_RICO",e[e.QATAR=62]="QATAR",e[e.ROMANIA=63]="ROMANIA",e[e.RUSSIA=64]="RUSSIA",e[e.SAUDI_ARABIA=65]="SAUDI_ARABIA",e[e.SERBIA=66]="SERBIA",e[e.SINGAPORE=67]="SINGAPORE",e[e.SLOVAKIA=68]="SLOVAKIA",e[e.SLOVENIA=69]="SLOVENIA",e[e.SOUTH_AFRICA=70]="SOUTH_AFRICA",e[e.SPAIN=71]="SPAIN",e[e.SWEDEN=72]="SWEDEN",e[e.SWITZERLAND=73]="SWITZERLAND",e[e.TAIWAN=74]="TAIWAN",e[e.THAILAND=75]="THAILAND",e[e.TUNISIA=76]="TUNISIA",e[e.TURKEY=77]="TURKEY",e[e.UAE=78]="UAE",e[e.UGANDA=79]="UGANDA",e[e.UK=80]="UK",e[e.UKRAINE=81]="UKRAINE",e[e.USA=82]="USA",e[e.VIETNAM=83]="VIETNAM",e[e.BRAZIL=84]="BRAZIL",e[e.NORWAY=85]="NORWAY",e[e.OMAN=86]="OMAN",e[e.ECUADOR=87]="ECUADOR",e[e.EL_SALVADOR=88]="EL_SALVADOR",e[e.SRI_LANKA=89]="SRI_LANKA",e[e.PERU=90]="PERU",e[e.URUGUAY=91]="URUGUAY",e[e.BAHAMAS=92]="BAHAMAS",e[e.BERMUDA=93]="BERMUDA",e[e.BOLIVIA=94]="BOLIVIA",e[e.CHINA=95]="CHINA",e[e.EUROPEAN_UNION=96]="EUROPEAN_UNION",e[e.HAITI=97]="HAITI",e[e.HONDURAS=98]="HONDURAS",e[e.ICELAND=99]="ICELAND",e[e.JAPAN=100]="JAPAN",e[e.LUXEMBOURG=101]="LUXEMBOURG",e[e.MONTENEGRO=102]="MONTENEGRO",e[e.NICARAGUA=103]="NICARAGUA",e[e.SOUTH_KOREA=104]="SOUTH_KOREA",e[e.VENEZUELA=105]="VENEZUELA",e[e.AFGHANISTAN=106]="AFGHANISTAN",e[e.ALAND_ISLANDS=107]="ALAND_ISLANDS",e[e.AMERICAN_SAMOA=108]="AMERICAN_SAMOA",e[e.ANDORRA=109]="ANDORRA",e[e.ANGOLA=110]="ANGOLA",e[e.ANGUILLA=111]="ANGUILLA",e[e.ANTARCTICA=112]="ANTARCTICA",e[e.ANTIGUA_AND_BARBUDA=113]="ANTIGUA_AND_BARBUDA",e[e.ARMENIA=114]="ARMENIA",e[e.ARUBA=115]="ARUBA",e[e.BAILIWICK_OF_GUERNSEY=116]="BAILIWICK_OF_GUERNSEY",e[e.BAILIWICK_OF_JERSEY=117]="BAILIWICK_OF_JERSEY",e[e.BARBADOS=118]="BARBADOS",e[e.BELARUS=119]="BELARUS",e[e.BELIZE=120]="BELIZE",e[e.BENIN=121]="BENIN",e[e.BHUTAN=122]="BHUTAN",e[e.BONAIRE_SAINT_EUSTATIUS_AND_SABA=123]="BONAIRE_SAINT_EUSTATIUS_AND_SABA",e[e.BOTSWANA=124]="BOTSWANA",e[e.BOUVET_ISLAND=125]="BOUVET_ISLAND",e[e.BRITISH_INDIAN_OCEAN_TERRITORY=126]="BRITISH_INDIAN_OCEAN_TERRITORY",e[e.BURKINA_FASO=127]="BURKINA_FASO",e[e.BURUNDI=128]="BURUNDI",e[e.CAMEROON=129]="CAMEROON",e[e.CAPE_VERDE=130]="CAPE_VERDE",e[e.CARIBBEAN_NETHERLANDS=131]="CARIBBEAN_NETHERLANDS",e[e.CAYMAN_ISLANDS=132]="CAYMAN_ISLANDS",e[e.CENTRAL_AFRICAN_REPUBLIC=133]="CENTRAL_AFRICAN_REPUBLIC",e[e.CHAD=134]="CHAD",e[e.CHRISTMAS_ISLAND=135]="CHRISTMAS_ISLAND",e[e.COCOS_ISLANDS=136]="COCOS_ISLANDS",e[e.COMOROS=137]="COMOROS",e[e.CONGO=138]="CONGO",e[e.COOK_ISLANDS=139]="COOK_ISLANDS",e[e.CUBA=140]="CUBA",e[e.CURACAO=141]="CURACAO",e[e.DEMOCRATIC_REPUBLIC_OF_THE_CONGO=142]="DEMOCRATIC_REPUBLIC_OF_THE_CONGO",e[e.DJIBOUTI=143]="DJIBOUTI",e[e.DOMINICA=144]="DOMINICA",e[e.EAST_TIMOR=145]="EAST_TIMOR",e[e.EQUATORIAL_GUINEA=146]="EQUATORIAL_GUINEA",e[e.ERITREA=147]="ERITREA",e[e.ETHIOPIA=148]="ETHIOPIA",e[e.FALKLAND_ISLANDS=149]="FALKLAND_ISLANDS",e[e.FAROE_ISLANDS=150]="FAROE_ISLANDS",e[e.FEDERATED_STATES_OF_MICRONESIA=151]="FEDERATED_STATES_OF_MICRONESIA",e[e.FIJI=152]="FIJI",e[e.FRENCH_GUIANA=153]="FRENCH_GUIANA",e[e.FRENCH_POLYNESIA=154]="FRENCH_POLYNESIA",e[e.FRENCH_SOUTHERN_TERRITORIES=155]="FRENCH_SOUTHERN_TERRITORIES",e[e.GABON=156]="GABON",e[e.GAMBIA=157]="GAMBIA",e[e.GIBRALTAR=158]="GIBRALTAR",e[e.GREENLAND=159]="GREENLAND",e[e.GRENADA=160]="GRENADA",e[e.GUADELOUPE=161]="GUADELOUPE",e[e.GUAM=162]="GUAM",e[e.GUINEA=163]="GUINEA",e[e.GUINEA_BISSAU=164]="GUINEA_BISSAU",e[e.GUYANA=165]="GUYANA",e[e.HEARD_ISLAND_AND_MCDONALD_ISLANDS=166]="HEARD_ISLAND_AND_MCDONALD_ISLANDS",e[e.IRAN=167]="IRAN",e[e.IRAQ=168]="IRAQ",e[e.ISLE_OF_MAN=169]="ISLE_OF_MAN",e[e.IVORY_COAST=170]="IVORY_COAST",e[e.JAMAICA=171]="JAMAICA",e[e.KIRIBATI=172]="KIRIBATI",e[e.KYRGYZSTAN=173]="KYRGYZSTAN",e[e.LAOS=174]="LAOS",e[e.LEBANON=175]="LEBANON",e[e.LESOTHO=176]="LESOTHO",e[e.LIBERIA=177]="LIBERIA",e[e.LIBYA=178]="LIBYA",e[e.LIECHTENSTEIN=179]="LIECHTENSTEIN",e[e.MACAU=180]="MACAU",e[e.MADAGASCAR=181]="MADAGASCAR",e[e.MALAWI=182]="MALAWI",e[e.MALI=183]="MALI",e[e.MARSHALL_ISLANDS=184]="MARSHALL_ISLANDS",e[e.MARTINIQUE=185]="MARTINIQUE",e[e.MAURITANIA=186]="MAURITANIA",e[e.MAYOTTE=187]="MAYOTTE",e[e.MOLDOVA=188]="MOLDOVA",e[e.MONACO=189]="MONACO",e[e.MONGOLIA=190]="MONGOLIA",e[e.MONTSERRAT=191]="MONTSERRAT",e[e.MOZAMBIQUE=192]="MOZAMBIQUE",e[e.MYANMAR=193]="MYANMAR",e[e.NAMIBIA=194]="NAMIBIA",e[e.NAURU=195]="NAURU",e[e.NEPAL=196]="NEPAL",e[e.NEW_CALEDONIA=197]="NEW_CALEDONIA",e[e.NIGER=198]="NIGER",e[e.NIUE=199]="NIUE",e[e.NORFOLK_ISLAND=200]="NORFOLK_ISLAND",e[e.NORTHERN_CYPRUS=201]="NORTHERN_CYPRUS",e[e.NORTHERN_MARIANA_ISLANDS=202]="NORTHERN_MARIANA_ISLANDS",e[e.NORTH_KOREA=203]="NORTH_KOREA",e[e.NORTH_MACEDONIA=204]="NORTH_MACEDONIA",e[e.PALAU=205]="PALAU",e[e.PALESTINE=206]="PALESTINE",e[e.PAPUA_NEW_GUINEA=207]="PAPUA_NEW_GUINEA",e[e.PITCAIRN=208]="PITCAIRN",e[e.REUNION=209]="REUNION",e[e.RWANDA=210]="RWANDA",e[e.SAINT_BARTHELEMY=211]="SAINT_BARTHELEMY",e[e.SAINT_HELENA_ASCENSION_AND_TRISTIAN_DA_CUNHA=212]="SAINT_HELENA_ASCENSION_AND_TRISTIAN_DA_CUNHA",e[e.SAINT_KITTS_AND_NEVIS=213]="SAINT_KITTS_AND_NEVIS",e[e.SAINT_