@scandit/web-datacapture-core 8.4.0-beta.1 → 8.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/build/electron/common.cjs +1 -1
  2. package/build/electron/constants.cjs +1 -1
  3. package/build/electron/main.cjs +1 -1
  4. package/build/electron/preload.cjs +1 -1
  5. package/build/js/Camera.js +1 -1
  6. package/build/js/DataCaptureContext.js +1 -1
  7. package/build/js/DataCaptureVersion.js +1 -1
  8. package/build/js/DataCaptureView.js +1 -1
  9. package/build/js/Feedback.js +1 -1
  10. package/build/js/ImageFrameSource.js +1 -1
  11. package/build/js/NotificationPresenter/index.js +1 -1
  12. package/build/js/Sound.js +1 -1
  13. package/build/js/Vibration.js +1 -1
  14. package/build/js/browserHelper.d.ts +1 -0
  15. package/build/js/browserHelper.js +1 -1
  16. package/build/js/chunks/{chunk-CERFU73N.js → chunk-3WNU5X5L.js} +1 -1
  17. package/build/js/chunks/{chunk-CGK5V6XZ.js → chunk-56S3BFJ6.js} +1 -1
  18. package/build/js/chunks/{chunk-YUZDO2PC.js → chunk-5GUWY76Q.js} +1 -1
  19. package/build/js/chunks/{chunk-RXDVYEE5.js → chunk-7GQFJDH6.js} +1 -1
  20. package/build/js/chunks/{chunk-L66S4DN2.js → chunk-ASAV77S2.js} +1 -1
  21. package/build/js/chunks/{chunk-P2R7FW6C.js → chunk-ASJCS2FB.js} +1 -1
  22. package/build/js/chunks/{chunk-Y7BTRVB4.js → chunk-AYQTB54E.js} +1 -1
  23. package/build/js/chunks/chunk-AYYKQ7YB.js +2 -0
  24. package/build/js/chunks/{chunk-Y3TODCJD.js → chunk-EPIUNYWM.js} +1 -1
  25. package/build/js/chunks/{chunk-ZP3YIZEC.js → chunk-HLVYMWIK.js} +1 -1
  26. package/build/js/chunks/{chunk-ACCTMSWC.js → chunk-I52JX2MQ.js} +1 -1
  27. package/build/js/chunks/chunk-IGTW3KDT.js +1 -0
  28. package/build/js/chunks/{chunk-2UHUEJA4.js → chunk-JAY44NXK.js} +1 -1
  29. package/build/js/chunks/{chunk-H3J4TP2K.js → chunk-KJXBZMMB.js} +1 -1
  30. package/build/js/chunks/{chunk-AD77NFCP.js → chunk-KW2WZUE3.js} +1 -1
  31. package/build/js/chunks/{chunk-JLTSTUKY.js → chunk-NOEX6HP5.js} +1 -1
  32. package/build/js/chunks/{chunk-76IGNICM.js → chunk-QJZW4BFG.js} +1 -1
  33. package/build/js/chunks/{chunk-GMOTHEWV.js → chunk-QRMHTQBG.js} +1 -1
  34. package/build/js/chunks/{chunk-ZTKCGHYQ.js → chunk-RVJQOD3H.js} +1 -1
  35. package/build/js/chunks/{chunk-YJNJGCAN.js → chunk-RXFEUGTT.js} +1 -1
  36. package/build/js/chunks/{chunk-IASACVTH.js → chunk-SIMTA4TK.js} +1 -1
  37. package/build/js/chunks/chunk-T2JW7GJH.js +1 -0
  38. package/build/js/chunks/{chunk-CA6FHIF6.js → chunk-T6EVGEHJ.js} +1 -1
  39. package/build/js/chunks/{chunk-4F2Q2P2O.js → chunk-TDNR2OSD.js} +1 -1
  40. package/build/js/chunks/{chunk-XUIVDVLK.js → chunk-VUPEBHJF.js} +3 -3
  41. package/build/js/chunks/chunk-WMI56GO3.js +1 -0
  42. package/build/js/controls/CameraFOVSwitchControl.js +1 -1
  43. package/build/js/controls/CameraSwitchControl.js +1 -1
  44. package/build/js/controls/ZoomSwitchControl.js +1 -1
  45. package/build/js/controls/index.js +1 -1
  46. package/build/js/index.js +1 -1
  47. package/build/js/private/CameraAccess.js +1 -1
  48. package/build/js/private/CameraManager.js +1 -1
  49. package/build/js/private/CoreModuleLicenseTextProvider.js +1 -1
  50. package/build/js/private/FrameReaders/FrameReader.js +1 -1
  51. package/build/js/private/FrameReaders/GrayScaleFrameReader.js +1 -1
  52. package/build/js/private/FrameReaders/index.js +1 -1
  53. package/build/js/private/OrientationObserver.js +1 -1
  54. package/build/js/private/SingleImageUploaderView.js +1 -1
  55. package/build/js/private/ViewControls+related.js +1 -1
  56. package/build/js/private/customHowler/Howl.js +1 -1
  57. package/build/js/private/customHowler/WebAudioContextManager.js +1 -1
  58. package/build/js/private/customHowler/index.js +1 -1
  59. package/build/js/private/customHowler/setup.js +1 -1
  60. package/build/js/private/hybridDesktopPlatformHelpers.js +1 -1
  61. package/build/js/private/ui/molecules/CameraFOVSwitchButton.js +1 -1
  62. package/build/js/private/ui/molecules/CameraSwitchButton.js +1 -1
  63. package/build/js/private/utils/polyfillLoader.js +1 -1
  64. package/build/js/private/utils/warnMultithreadingUnavailable.js +1 -1
  65. package/build/js/worker/WorkerMain.js +1 -1
  66. package/build/js/worker/coreCapture.inlineWorker.js +1 -1
  67. package/build/js/worker/dataCaptureEngine.js +1 -1
  68. package/build/js/worker/dataCaptureLoader.js +1 -1
  69. package/build/js/worker/index.js +1 -1
  70. package/package.json +1 -1
  71. package/build/js/chunks/chunk-4LGQ66HW.js +0 -1
  72. package/build/js/chunks/chunk-LPFXHHWJ.js +0 -1
  73. package/build/js/chunks/chunk-P3NPNIWR.js +0 -1
  74. package/build/js/chunks/chunk-YONR3EGV.js +0 -2
@@ -1 +1 @@
1
- import {a as a$b}from'./chunk-U7ETOWGJ.js';import {b as b$2}from'./chunk-6AZW5IIG.js';import {a as a$c}from'./chunk-DGIQ3GF7.js';import {a as a$l}from'./chunk-AE2LWVIB.js';import {b,a as a$6}from'./chunk-RXDVYEE5.js';import {a as a$j}from'./chunk-ACCTMSWC.js';import {a as a$d}from'./chunk-TPHGDMKG.js';import {a as a$h}from'./chunk-GPPCTFZF.js';import {a as a$n}from'./chunk-Y7V35LNT.js';import {b as b$1}from'./chunk-24MGHMOY.js';import {a as a$g}from'./chunk-WOOPJWJS.js';import {a as a$i}from'./chunk-U4IMOTYL.js';import {a as a$e}from'./chunk-KYNYQBNF.js';import {a}from'./chunk-56OQ5EHO.js';import {a as a$9}from'./chunk-RSQRPDVQ.js';import {a as a$8}from'./chunk-IJQG3OU6.js';import {a as a$a}from'./chunk-I6SWF3FQ.js';import {a as a$3}from'./chunk-MA6UDVDJ.js';import {e,y}from'./chunk-TTGJAMI2.js';import {a as a$r}from'./chunk-ENYHCJGH.js';import {a as a$5}from'./chunk-N5YZEC56.js';import {a as a$2}from'./chunk-VJB527QZ.js';import {a as a$1}from'./chunk-GHTCNOQN.js';import {a as a$q}from'./chunk-Q7JWDX4U.js';import {a as a$f}from'./chunk-UWBNF47P.js';import {g}from'./chunk-CA6FHIF6.js';import {a as a$4}from'./chunk-LFJUGRQV.js';import {a as a$7}from'./chunk-KAFNKP6O.js';import {a as a$p}from'./chunk-E4XJ4GKD.js';import {a as a$m}from'./chunk-QOCHMKNY.js';import {a as a$k}from'./chunk-XR65N6EG.js';import {a as a$o}from'./chunk-WUHKODFA.js';var L="core.camera.recovery",ee;ee=a$4;var V=class V{constructor(){this.focusGesture=a.focusGesture;this.shouldShowZoomNotification=true;this._zoomGestures=a.zoomGestures;this.swipeToZoomGesture=null;this.pinchToZoomGesture=null;this._scanAreaMargins=a.scanAreaMargins;this._pointOfInterest=a.pointOfInterest;this._logoStyle=a.logoStyle;this._logoAnchor=a.logoAnchor;this._logoOffset=a.logoOffset;this._context=null;this.overlays=new Set;this.controlMap=new Map;this.frameSourceListener={didChangeState:this.onFrameSourceChange.bind(this)};this._previewCamera=null;this.isConnected=false;this.controlsElement=void 0;this.frozenFrameCanvas=document.createElement("canvas");this.listeners=[];this.isVideoElementDetached=false;this.orientation="portrait";this.hiddenProperties={stopVideoTracksOnVisibilityChange:true,freezeFrameWhenStoppingFrameSource:true,forceScanAreaMarginsToPixels:false};this.orientationObserver=new b;this.onOrientationChangeListener=this.onOrientationChange.bind(this);this.onHintPresenterUpdateHandler=this.onHintPresenterUpdate.bind(this);this.onViewFinderUpdateRequestedHandler=this.onViewFinderUpdateRequested.bind(this);this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this.htmlElementDidChangeHandler=this.htmlElementDidChange.bind(this);this.htmlElementDisconnectedHandler=this.htmlElementDisconnected.bind(this);this.notificationPresenter=null;this.zoomNotificationDuration=4e3;this.zoomNotificationTimeout=null;this[ee]={attachAdditionalLayer:this.attachAdditionalLayer.bind(this)};this.visibilityListener=this.onVisibilityChange.bind(this),this.cameraRecoveryListener=this.cameraRecovery.bind(this),a$1.getInstance().updateIfMissing(a$2),this.zoomGestures=[...a.zoomGestures];}get zoomGestures(){return this._zoomGestures}set zoomGestures(e){this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),this._zoomGestures=e,this.addSwipeToZoomListener(),this.addPinchToZoomListener();}get videoElement(){return g.instance().getVideoElement()}get scanAreaMargins(){return this._scanAreaMargins}set scanAreaMargins(e){var n,o,a;let t=this.hiddenProperties.forceScanAreaMarginsToPixels?this.marginsToPixels(e):e,i=this._scanAreaMargins;this._scanAreaMargins=t;for(let l of this.listeners)(n=l.willChangeScanAreaMargins)==null||n.call(l,this,i,t);((a=(o=this.privateContext)==null?void 0:o.update())!=null?a:Promise.resolve()).then(()=>{var l;for(let h of this.listeners)(l=h.didChangeScanAreaMargins)==null||l.call(h,this,t);});}marginsToPixels(e){let{width:t,height:i}=this;if(t===0&&i===0)return e;let r=(n,o)=>n.unit==="pixel"?n:new a$r(n.value*o,"pixel");return new a$3(r(e.left,t),r(e.top,i),r(e.right,t),r(e.bottom,i))}get pointOfInterest(){return this._pointOfInterest}set pointOfInterest(e){var t;this._pointOfInterest=e,(t=this.privateContext)==null||t.update();}get logoStyle(){return this._logoStyle}set logoStyle(e){var t;this._logoStyle=e,(t=this.privateContext)==null||t.update();}get logoAnchor(){return this._logoAnchor}set logoAnchor(e){var t;this._logoAnchor=e,(t=this.privateContext)==null||t.update();}get logoOffset(){return this._logoOffset}set logoOffset(e){var t;this._logoOffset=e,(t=this.privateContext)==null||t.update();}get cameraRecoveryText(){return a$1.getInstance().get(L)}get width(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.width)!=null?t:0)}get height(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.height)!=null?t:0)}get canvasDrawer(){return !this._canvasDrawer&&this.canvasElement!=null&&(this._canvasDrawer=new b$1(this.canvasElement),this._canvasDrawer.startObservingCanvasResize()),this._canvasDrawer}get controls(){return this.controlMap.values()}get privateContext(){return this._context}static async forContext(e){let t=new V;return await t.setContext(e),t}showProgressBar(){var e;(e=this.loadingOverlay)==null||e.show();}hideProgressBar(){var e;(e=this.loadingOverlay)==null||e.hide();}setProgressBarPercentage(e){this.loadingOverlay&&(this.loadingOverlay.progress=e);}setProgressBarMessage(e){this.loadingOverlay&&(this.loadingOverlay.message=e);}getContext(){return this._context}async setContext(e){var t,i,r;if(this._context!==e&&(this._context=e,e)){if(this.overlays.size>0&&!((t=this._context)!=null&&t[a$4].hasModes()))throw new Error(["Cannot assign this view to this context. This view has overlays but the context does not have any mode attached matching these overlays.","Remove the overlays first before attaching the view to the context, or add the corresponding mode to the context before attaching this view."].join(" "));await e.setView(this),(i=this.privateContext)==null||i.subscribeToWorkerMessages(this.onWorkerMessageHandler),(r=this._context)!=null&&r.frameSource&&await this.onFrameSourceChange(this._context.frameSource);}}connectToElement(e,t){var i,r,n,o;this.isConnected||(this.orientationObserver.register(),this.setupHtmlElement(e),(i=this.canvasDrawer)==null||i.startObservingCanvasResize(),this.htmlElementDidChange(),a$5.add(this),this.orientation=this.orientationObserver.orientation.value,this.orientationObserver.addEventListener(a$6,this.onOrientationChangeListener),(r=this.hintPresenter)==null||r.addEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(n=this.hintPresenter)==null||n.addEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),this.localizationSubscription=a$1.getInstance().subscribe(a=>{a[L]!=null&&(this.cameraRecoveryElement.textContent=a[L]);}),this._previewCamera=(o=t==null?void 0:t.camera)!=null?o:null,this._previewCamera&&(this._previewCamera.addListener(this.frameSourceListener),this.onFrameSourceChange(this._previewCamera)),this.updateControls(),this.isConnected=true);}detachFromElement(){var e,t,i,r,n,o,a,l;if(this.isConnected){(e=this.htmlElementState)==null||e.removeListeners(),this.removeStyles(),(t=this.canvasDrawer)==null||t.endObservingCanvasResize(),document.removeEventListener("visibilitychange",this.visibilityListener);for(let h of ["touchend","mousedown"])this.cameraRecoveryElement.removeEventListener(h,this.cameraRecoveryListener);(i=this.loadingOverlay)==null||i.remove(),(r=this.customLocationsView)==null||r.unmount(),this.notificationPresenter=null,this.htmlElementDidChange(),this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),(n=this.gestureRecognizer)==null||n.removeListener(this),this.clearHtmlElementContent(),a$5.delete(this),this.orientationObserver.unregister(),this.orientationObserver.removeEventListener(a$6,this.onOrientationChangeListener),(o=this.hintPresenter)==null||o.removeEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(a=this.hintPresenter)==null||a.removeEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),(l=this.localizationSubscription)==null||l.cancel(),g.instance().disconnectedCallback(),this._previewCamera&&(this._previewCamera.removeListener(this.frameSourceListener),this._previewCamera=null);for(let h of this.controls)this.removeControl(h);this.isConnected=false;}}async addOverlay(e){var t;this.overlays.has(e)||(this.overlays.add(e),await((t=this.privateContext)==null?void 0:t.update([{type:"addOverlay",newValue:e,view:this}])));}async removeOverlay(e){var t;this.overlays.has(e)&&(await((t=this.privateContext)==null?void 0:t.update([{type:"removeOverlay",newValue:e,view:this}])),this.overlays.delete(e));}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}viewPointForFramePoint(e){var u,D,T,M,F,R,A,N;let t={width:(D=(u=this.htmlElementState)==null?void 0:u.width)!=null?D:0,height:(M=(T=this.htmlElementState)==null?void 0:T.height)!=null?M:0},i={width:(R=(F=this.videoElement)==null?void 0:F.videoWidth)!=null?R:0,height:(N=(A=this.videoElement)==null?void 0:A.videoHeight)!=null?N:0},r=t.width/t.height,n=i.width/i.height,o=r>n?t.width/i.width:t.height/i.height,a={x:e.x*o,y:e.y*o},l=(i.width*o-t.width)/2,h=(i.height*o-t.height)/2;return new a$7(a.x-l,a.y-h)}viewQuadrilateralForFrameQuadrilateral(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft),n=this.viewPointForFramePoint(e.bottomRight);return new a$8(t,i,n,r)}addControl(e){let t=e.toJSONObject().type;if(!this.controlMap.has(t)&&!(t==="camera-fov"&&this.controlMap.has("zoom"))){if(t==="zoom"){let i=this.controlMap.get("camera-fov");i&&this.removeControl(i);}this.controlMap.set(t,e),e.install(this).then(i=>{var r;i&&((r=this.privateContext)==null||r.update([{type:"addControl",newValue:e}]));});}}removeControl(e){var i;let t=e.toJSONObject().type;this.controlMap.has(t)&&(e.remove(true),this.controlMap.delete(t),(i=this.privateContext)==null||i.update([{type:"removeControl",newValue:e}]));}toJSONObject(){var e;return {scanAreaMargins:this.scanAreaMargins.toJSONObject(),pointOfInterest:this.pointOfInterest.toJSONObject(),logoAnchor:this.logoAnchor,logoOffset:this.logoOffset.toJSONObject(),logoHidden:(e=this.logoHidden)!=null?e:false,logoStyle:this.logoStyle,overlays:[...this.overlays].map(t=>t.toJSONObject()),controls:[...this.controls].map(t=>t.toJSONObject()),focusGesture:this.focusGesture?this.focusGesture.toJSONObject():null,zoomGestures:this._zoomGestures.map(t=>t.toJSONObject())}}isCameraRecoveryVisible(){return !this.cameraRecoveryElement.hidden}setCameraRecoveryVisible(e){this.cameraRecoveryElement.hidden=!e;}async allowPictureInPicture(e){await g.instance().allowPictureInPicture(e);}viewAnchorPositionsForFrameAnchorPositions(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft),n=this.viewPointForFramePoint(e.bottomRight),o=this.viewPointForFramePoint(e.centerLeft),a=this.viewPointForFramePoint(e.centerRight),l=this.viewPointForFramePoint(e.topCenter),h=this.viewPointForFramePoint(e.bottomCenter),u=this.viewPointForFramePoint(e.center);return new a$9(t,i,n,r,o,l,a,h,u)}setDidTapCustomLocationsViewListener(e){this.customLocationsView&&this.customLocationsView.listener===null&&(this.customLocationsView.listener=e);}renderCustomLocationsView(e){this.customLocationsView!=null&&(this.customLocationsView.setMirrored(g.instance().isMirrorImageEnabled()),Object.keys(e).includes("removedIds")?this.customLocationsView.render(e):this.customLocationsView.renderDomView(e));}getNotificationPresenter(){var e;if(!this.notificationPresenter){let t=(e=this.htmlElement)==null?void 0:e.querySelector(b$2.tag);if(!t)throw new Error("Notification presenter cannot be found. Please ensure the DataCaptureView is connected.");this.notificationPresenter=new a$a(t);}return this.notificationPresenter}removeStyles(){for(let e of document.querySelectorAll("style[scandit]"))e.remove();}onHintPresenterUpdate(e){var t;(t=this.privateContext)==null||t.workerCommand("hintPresenterV2update",{});}async onViewFinderUpdateRequested(e){var i;let t=await((i=this.privateContext)==null?void 0:i.workerCommand("getViewfinderInfo",{}));t!=null&&this.updateHintPresenterViewFinderRect(t.rect);}clearHtmlElementContent(){var e;this.htmlElement&&((e=this.canvasDrawer)==null||e.endObservingCanvasResize(),this.htmlElement.innerHTML="",this.cameraPaintboardElement=void 0,this.singleImageUploaderPaintboardElement=void 0,this.htmlElement=void 0);}setupHtmlElement(e){var n,o,a;this.createStyles(),this.htmlElement=e,b$2.register(),a$b.register(),a$c.register();let t=a$f`<div class="${a$d.CONTAINER_CLASS_NAME}" role="main" aria-label="Data capture view"><div class="${a$d.PAINTBOARDS_CONTAINER_CLASS_NAME}"><div data-js-id="loading-overlay"></div><div class="${a$d.PAINTBOARD_CLASS_NAME}" data-js-id="camera-paintboard"><div data-js-id="video-container"></div><img class="${a$d.FROZEN_FRAME}" data-js-id="frozen-frame" alt="Last captured camera frame shown while camera is on standby" hidden /><canvas></canvas><div data-js-id="${a$e.CUSTOM_VIEW_CONTAINER}"></div><${b$2.tag}></${b$2.tag}><${a$b.tag}></${a$b.tag}><div class="${a$d.CAMERA_RECOVERY_CLASS_NAME}" role="alert" aria-live="polite" aria-atomic="true" hidden>${this.cameraRecoveryText}</div><div class="${a$d.ERROR_CLASS_NAME}" role="alert" aria-live="assertive" aria-atomic="true" hidden></div></div><div class="${a$d.PAINTBOARD_CLASS_NAME}" data-js-id="singleimage-paintboard"></div></div></div>`;this.htmlElement.innerHTML=t,g.instance().connectedCallback(this.htmlElement.querySelector('[data-js-id="video-container"]')),this.isVideoElementDetached=false,this.hintPresenter=this.htmlElement.querySelector(b$2.tag),this.notificationPresenter=this.hintPresenter?new a$a(this.hintPresenter):null,this.loadingOverlay&&this.loadingOverlay.remove(),this.loadingOverlay=a$c.create(),this.loadingOverlay.hide(),(n=this.htmlElement.querySelector('[data-js-id="loading-overlay"]'))==null||n.replaceWith(this.loadingOverlay),this.customLocationsView&&this.customLocationsView.unmount(),this.customLocationsView=new a$g,this.customLocationsView.mount(this.htmlElement.querySelector(`[data-js-id="${a$e.CUSTOM_VIEW_CONTAINER}"]`)),this.customLocationsView.mapViewAnchorPositionsForFramePoint=l=>this.viewAnchorPositionsForFrameAnchorPositions(l),this.containerElement=this.htmlElement.querySelector(`.${a$d.CONTAINER_CLASS_NAME}`),this.cameraPaintboardElement=this.containerElement.querySelector('[data-js-id="camera-paintboard"]'),this.singleImageUploaderPaintboardElement=this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]');let i=this.cameraPaintboardElement.querySelector("canvas");this.canvasElement==null?this.canvasElement=i:i.replaceWith(this.canvasElement);let r=this.cameraPaintboardElement.querySelector('[data-js-id="frozen-frame"]');this.frozenFrame==null?this.frozenFrame=r:r.replaceWith(this.frozenFrame),this.controlsElement=this.cameraPaintboardElement.querySelector(a$b.tag),this.cameraRecoveryElement=this.cameraPaintboardElement.querySelector(`.${a$d.CAMERA_RECOVERY_CLASS_NAME}`),this.errorElement=this.cameraPaintboardElement.querySelector(`.${a$d.ERROR_CLASS_NAME}`),this.lastFrameSourceState!=null&&((a=(o=this._context)==null?void 0:o.frameSource)==null||a.switchToDesiredState(this.lastFrameSourceState)),document.addEventListener("visibilitychange",this.visibilityListener);for(let l of ["touchend","mousedown"])this.cameraRecoveryElement.addEventListener(l,this.cameraRecoveryListener);this.htmlElementState&&this.htmlElementState.removeListeners(),this.htmlElementState=new a$h(this.htmlElement),this.htmlElementState.onStateChanged(this.htmlElementDidChangeHandler),this.htmlElementState.onDisconnected(this.htmlElementDisconnectedHandler),this.gestureRecognizer=new a$i(this.htmlElement),this.gestureRecognizer.addListener(this),this.addSwipeToZoomListener(),this.addPinchToZoomListener();}setupHtmlElementSingleImageUploader(e){var i;if(this.singleImageUploaderPaintboardElement==null)return;this.singleImageUploaderView&&this.singleImageUploaderView.unmount(),this.singleImageUploaderView=new a$j(e),this.singleImageUploaderView.mount(this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]'));let t=(i=this._context)==null?void 0:i.frameSource;this.singleImageUploaderView.onInputCheck(r=>{t.getCurrentState()!=="starting"&&r.preventDefault();}),this.singleImageUploaderView.onBeforeFileRead(()=>{t._context&&this.singleImageUploaderView&&(this.singleImageUploaderView.canUploadFile=t._context.hasEnabledMode());}),this.singleImageUploaderView.onImageLoadError(()=>{t.currentState="starting",a$k.log(a$k.Level.Error,"Could not load image from selected file");}),this.singleImageUploaderView.onFileReaderError(r=>{var o,a;let n=r.target;t.currentState="starting",a$k.log(a$k.Level.Error,`Error while reading the file: ${(a=(o=n.error)==null?void 0:o.toString())!=null?a:""}`);}),this.singleImageUploaderView.onCaptureReady(async r=>{await t.processUploadedFileCapture(r);}),this.singleImageUploaderView.setButtonState(t.getCurrentState()==="starting"?"enabled":"disabled"),t.addView(this.singleImageUploaderView);}setupHtmlElementVisibility(e){this.cameraPaintboardElement!=null&&(this.cameraPaintboardElement.hidden=e!=="camera"),this.singleImageUploaderPaintboardElement!=null&&(this.singleImageUploaderPaintboardElement.hidden=e!=="singleImageUploader");}createStyles(){if(document.querySelector("style[scandit]")===null){let e=a$l();for(let[t,i]of Object.entries(e))i.setAttribute("scandit",`data-capture-sdk-${t}`),document.head.append(i);}}async onOrientationChange(e){var t,i;this.orientation=e.detail.value,await((i=this.privateContext)==null?void 0:i.update([{type:"viewChange",newValue:{...(t=this.htmlElementState)==null?void 0:t.toJSONObject(),orientation:this.orientation}}]));}htmlElementDidChange(){var i,r;if(!this.htmlElementState)return;let e=this.htmlElementState,t=e.toJSONObject();if(!a$h.areEquivalentJSONStates(this.lastHtmlElementState,t)){this.orientation=this.orientationObserver.orientation.value,(i=this.privateContext)==null||i.update([{type:"viewChange",newValue:{...e.toJSONObject(),orientation:this.orientation}}]),this.lastHtmlElementState=t,(r=this.canvasDrawer)==null||r.updateCanvasSizeAttributes(this.width,this.height),this.handleVideoDisplay(t.visible);for(let n of this.listeners)typeof n.didChangeSize=="function"&&n.didChangeSize(this,new a$m(t.size.width.value,t.size.height.value),this.orientation);}}async htmlElementDisconnected(){var e,t,i,r,n,o;g.instance().disconnectedCallback(),this.lastFrameSourceState=(t=(e=this._context)==null?void 0:e.frameSource)==null?void 0:t.getCurrentState(),await((r=(i=this._context)==null?void 0:i.frameSource)==null?void 0:r.switchToDesiredState("off")),await((o=this.privateContext)==null?void 0:o.update([{type:"viewChange",newValue:{...(n=this.htmlElementState)==null?void 0:n.toJSONObject(),orientation:this.orientation}}])),this.isConnected=false;}attachAdditionalLayer(e,t){var i;t==="above-controls"&&((i=this.controlsElement)==null||i.insertAdjacentElement("afterend",e));}handleVideoDisplay(e){this.videoElement==null||this.cameraPaintboardElement==null||(!e&&!this.isVideoElementDetached?(this.videoElement.width=0,this.videoElement.height=0,this.videoElement.style.opacity="0",this.videoElement.style.visibility="hidden",document.body.append(this.videoElement),this.isVideoElementDetached=true):e&&this.isVideoElementDetached&&(this.cameraPaintboardElement.insertAdjacentElement("afterbegin",this.videoElement),this.isVideoElementDetached=false,this.videoElement.style.removeProperty("visibility"),this.videoElement.removeAttribute("width"),this.videoElement.removeAttribute("height"),this.videoElement.style.removeProperty("opacity")));}isCanvasDrawerWithMetrics(e){return e instanceof a$n}onWorkerMessage(e){var t,i;switch(e.type){case "draw":{this.drawEngineCommands(e.payload);break}case "performanceMetricsReport":{let r=this._canvasDrawer;r!=null&&this.isCanvasDrawerWithMetrics(r)&&r.setPerformanceMetrics(e.payload);break}case "contextDidChangeStatus":{let r=a$o.fromJSON(e.payload);(t=this.loadingOverlay)==null||t.hide(),r.isValid?(this.clearError(),this.setVideoElementOpacity("1")):this.displayError(r);break}case "viewSizeChanged":{let r=e.payload;if(r==null)return;this.onSDCViewSizeChangedCallback(r);break}default:{(i=this.hintPresenter)==null||i.handleMessage(e);break}}}onSDCViewSizeChangedCallback(e){this.updateHintPresenterViewFinderRect(e.viewFinderRect);}updateHintPresenterViewFinderRect(e){var t;(t=this.hintPresenter)==null||t.setViewFinderRect(new a$p(new a$7(e.origin.x,e.origin.y),new a$m(e.size.width,e.size.height)));}drawEngineCommands(e){var t;(t=this.canvasDrawer)==null||t.draw(e);}displayError(e){this.errorElement.textContent=`Error ${e.code}: ${e.message}`,this.errorElement.hidden=false;}clearError(){this.errorElement.textContent="",this.errorElement.hidden=true;}updateControls(){var e;for(let t of this.controls)(e=t.update)==null||e.call(t,this);}async onFrameSourceChange(e){let t=e==null?void 0:e.type;if(this.setupHtmlElementVisibility(t),t==="camera"){let i=e==null?void 0:e.getCurrentState();i!=null&&await this.onCameraStateChanged(i);}else t==="singleImageUploader"&&this.setupHtmlElementSingleImageUploader(e.settings);}async onCameraStateChanged(e){var t;switch((t=this.cameraPaintboardElement)==null||t.classList.toggle(a$d.PAINTBOARD_CLASS_NAME_STATE_ON,e==="on"),e){case "stopping":{this.hiddenProperties.freezeFrameWhenStoppingFrameSource&&this.freezeFrame(),this.setVideoElementOpacity("0");return}case "starting":case "bootingUp":case "wakingUp":{if(!this.htmlElement){a$k.error("cannot set frame source stream before connecting view to an HTML element");return}this.videoElement&&(g.instance().gui.isCameraRecoveryVisible=this.isCameraRecoveryVisible.bind(this),g.instance().gui.setCameraRecoveryVisible=this.setCameraRecoveryVisible.bind(this),this.setVideoElementOpacity("0"));return}case "off":{this.setVideoElementOpacity("0"),this.updateControls();return}case "on":{await g.instance().waitForCapabilities(),this.updateControls(),this.unfreezeFrame(),this.setVideoElementOpacity("1");break}case "goingToSleep":{this.freezeFrame();break}}}setVideoElementOpacity(e){this.videoElement&&(this.videoElement.style.opacity=e),this.canvasElement&&(this.canvasElement.style.opacity=e);}onSingleImageUploaderSettingsChange(e){this.setupHtmlElementSingleImageUploader(e);}setHiddenProperty(e,t){this.hiddenProperties[e]=t;}async onVisibilityChange(){var t,i;let e=(t=this.videoElement)==null?void 0:t.srcObject;if(this.hiddenProperties.stopVideoTracksOnVisibilityChange&&(document.visibilityState==="hidden"&&g.instance().stopVideoTracks(),document.visibilityState==="visible"&&g.instance().activeCamera!=null&&e!=null))if(!e.active||(i=e.getVideoTracks()[0])!=null&&i.muted)try{a$k.debug('Detected visibility change ("visible") event with inactive video source, try to reinitialize camera'),await g.instance().reinitializeCamera();}catch{}else a$k.debug('Detected visibility change ("visible") event with active video source, replay video'),g.instance().playVideo();}async cameraRecovery(e){e.preventDefault(),g.instance().activeCamera=g.instance().selectedCamera,await g.instance().reinitializeCamera();}freezeFrame(){var i;if(!this.frozenFrame)return;let e=g.instance().getCurrentFrame();if(!e)return;let t=new ImageData(e.data,e.width,e.height);this.frozenFrameCanvas.width=t.width,this.frozenFrameCanvas.height=t.height,this.frozenFrame.width=t.width,this.frozenFrame.height=t.height,(i=this.frozenFrameCanvas.getContext("2d"))==null||i.putImageData(t,0,0),this.frozenFrame.src=this.frozenFrameCanvas.toDataURL("image/jpeg",.4),this.frozenFrame.classList.toggle(a$d.MIRRORED_CLASS_NAME,g.instance().isMirrorImageEnabled()),this.frozenFrame.hidden=false;}unfreezeFrame(){this.frozenFrame&&(this.frozenFrame.src="",this.frozenFrame.hidden=true);}onTap(e){var t;(t=this.privateContext)==null||t.workerCommand("onTap",{point:e.toJSONObject()});}onSwipeUp(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomIn();}onSwipeDown(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomOut();}onPinchIn(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomIn();}onPinchOut(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomOut();}didZoomInGesture(){this.performZoomIn();}didZoomOutGesture(){this.performZoomOut();}addSwipeToZoomListener(){let e=this._zoomGestures.find(t=>t.toJSONObject().type==="swipeToZoom");e&&(this.swipeToZoomGesture=e,e.addListener(this));}removeSwipeToZoomListener(){var e;(e=this.swipeToZoomGesture)==null||e.removeListener(this),this.swipeToZoomGesture=null;}addPinchToZoomListener(){let e=this._zoomGestures.find(t=>t.toJSONObject().type==="pinchToZoom");e&&(this.pinchToZoomGesture=e,e.addListener(this));}removePinchToZoomListener(){var e;(e=this.pinchToZoomGesture)==null||e.removeListener(this),this.pinchToZoomGesture=null;}async performZoomIn(){var n;let e=(n=this._context)==null?void 0:n.frameSource;if(!(e!=null&&e.settings))return;let t=e.settings.zoomFactor,r=[...e.settings.zoomLevels].sort((o,a)=>o-a).find(o=>o>t);r!=null&&(await e.setZoomFactor(r),this.showZoomNotification(r));}async performZoomOut(){var n;let e=(n=this._context)==null?void 0:n.frameSource;if(!(e!=null&&e.settings))return;let t=e.settings.zoomFactor,r=[...[...e.settings.zoomLevels].sort((o,a)=>o-a)].reverse().find(o=>o<t);r!=null&&(await e.setZoomFactor(r),this.showZoomNotification(r));}async showZoomNotification(e$1){var r,n;if(!this.shouldShowZoomNotification)return;let t=e.toJSON(),i={tag:"zoomNotification",text:this.formatZoomFactor(e$1),hintStyle:{textColor:t,backgroundColor:y.neutralWhite.withAlpha(.8).toJSON(),textAlignment:"center",hintIcon:"none",iconColor:t,isAnimatedToView:true,hintAnchor:"top",hintAnchorOffset:16,horizontalMargin:16,maxWidthFraction:1,textSize:14,textWeight:700,lineHeight:24,maxLines:3,cornerRadius:4,fitToText:true}};(r=this.zoomNotificationTimeout)==null||r.stop(),this.zoomNotificationTimeout=new a$q(this.zoomNotificationDuration,()=>{var o;(o=this.hintPresenter)==null||o.hideToast(i);}),await((n=this.hintPresenter)==null?void 0:n.showToast(i)),this.zoomNotificationTimeout.start();}formatZoomFactor(e){let t=Math.ceil(e*100)/100;return parseFloat(t.toPrecision(3))+"x"}},X=V;export{X as a};
1
+ import {a as a$b}from'./chunk-U7ETOWGJ.js';import {b as b$2}from'./chunk-6AZW5IIG.js';import {a as a$c}from'./chunk-DGIQ3GF7.js';import {a as a$j}from'./chunk-I52JX2MQ.js';import {a as a$l}from'./chunk-AE2LWVIB.js';import {a as a$d}from'./chunk-TPHGDMKG.js';import {a as a$h}from'./chunk-GPPCTFZF.js';import {b,a as a$6}from'./chunk-7GQFJDH6.js';import {a as a$n}from'./chunk-Y7V35LNT.js';import {a as a$g}from'./chunk-WOOPJWJS.js';import {a as a$i}from'./chunk-U4IMOTYL.js';import {a as a$e}from'./chunk-KYNYQBNF.js';import {a as a$9}from'./chunk-RSQRPDVQ.js';import {b as b$1}from'./chunk-24MGHMOY.js';import {a}from'./chunk-56OQ5EHO.js';import {a as a$8}from'./chunk-IJQG3OU6.js';import {a as a$3}from'./chunk-MA6UDVDJ.js';import {a as a$a}from'./chunk-I6SWF3FQ.js';import {e,y}from'./chunk-TTGJAMI2.js';import {a as a$r}from'./chunk-ENYHCJGH.js';import {a as a$5}from'./chunk-N5YZEC56.js';import {a as a$2}from'./chunk-VJB527QZ.js';import {a as a$1}from'./chunk-GHTCNOQN.js';import {a as a$q}from'./chunk-Q7JWDX4U.js';import {a as a$f}from'./chunk-UWBNF47P.js';import {g}from'./chunk-T6EVGEHJ.js';import {a as a$4}from'./chunk-LFJUGRQV.js';import {a as a$7}from'./chunk-KAFNKP6O.js';import {a as a$p}from'./chunk-E4XJ4GKD.js';import {a as a$m}from'./chunk-QOCHMKNY.js';import {a as a$k}from'./chunk-XR65N6EG.js';import {a as a$o}from'./chunk-WUHKODFA.js';var L="core.camera.recovery",ee;ee=a$4;var V=class V{constructor(){this.focusGesture=a.focusGesture;this.shouldShowZoomNotification=true;this._zoomGestures=a.zoomGestures;this.swipeToZoomGesture=null;this.pinchToZoomGesture=null;this._scanAreaMargins=a.scanAreaMargins;this._pointOfInterest=a.pointOfInterest;this._logoStyle=a.logoStyle;this._logoAnchor=a.logoAnchor;this._logoOffset=a.logoOffset;this._context=null;this.overlays=new Set;this.controlMap=new Map;this.frameSourceListener={didChangeState:this.onFrameSourceChange.bind(this)};this._previewCamera=null;this.isConnected=false;this.controlsElement=void 0;this.frozenFrameCanvas=document.createElement("canvas");this.listeners=[];this.isVideoElementDetached=false;this.orientation="portrait";this.hiddenProperties={stopVideoTracksOnVisibilityChange:true,freezeFrameWhenStoppingFrameSource:true,forceScanAreaMarginsToPixels:false};this.orientationObserver=new b;this.onOrientationChangeListener=this.onOrientationChange.bind(this);this.onHintPresenterUpdateHandler=this.onHintPresenterUpdate.bind(this);this.onViewFinderUpdateRequestedHandler=this.onViewFinderUpdateRequested.bind(this);this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this.htmlElementDidChangeHandler=this.htmlElementDidChange.bind(this);this.htmlElementDisconnectedHandler=this.htmlElementDisconnected.bind(this);this.notificationPresenter=null;this.zoomNotificationDuration=4e3;this.zoomNotificationTimeout=null;this[ee]={attachAdditionalLayer:this.attachAdditionalLayer.bind(this)};this.visibilityListener=this.onVisibilityChange.bind(this),this.cameraRecoveryListener=this.cameraRecovery.bind(this),a$1.getInstance().updateIfMissing(a$2),this.zoomGestures=[...a.zoomGestures];}get zoomGestures(){return this._zoomGestures}set zoomGestures(e){this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),this._zoomGestures=e,this.addSwipeToZoomListener(),this.addPinchToZoomListener();}get videoElement(){return g.instance().getVideoElement()}get scanAreaMargins(){return this._scanAreaMargins}set scanAreaMargins(e){var n,o,a;let t=this.hiddenProperties.forceScanAreaMarginsToPixels?this.marginsToPixels(e):e,i=this._scanAreaMargins;this._scanAreaMargins=t;for(let l of this.listeners)(n=l.willChangeScanAreaMargins)==null||n.call(l,this,i,t);((a=(o=this.privateContext)==null?void 0:o.update())!=null?a:Promise.resolve()).then(()=>{var l;for(let h of this.listeners)(l=h.didChangeScanAreaMargins)==null||l.call(h,this,t);});}marginsToPixels(e){let{width:t,height:i}=this;if(t===0&&i===0)return e;let r=(n,o)=>n.unit==="pixel"?n:new a$r(n.value*o,"pixel");return new a$3(r(e.left,t),r(e.top,i),r(e.right,t),r(e.bottom,i))}get pointOfInterest(){return this._pointOfInterest}set pointOfInterest(e){var t;this._pointOfInterest=e,(t=this.privateContext)==null||t.update();}get logoStyle(){return this._logoStyle}set logoStyle(e){var t;this._logoStyle=e,(t=this.privateContext)==null||t.update();}get logoAnchor(){return this._logoAnchor}set logoAnchor(e){var t;this._logoAnchor=e,(t=this.privateContext)==null||t.update();}get logoOffset(){return this._logoOffset}set logoOffset(e){var t;this._logoOffset=e,(t=this.privateContext)==null||t.update();}get cameraRecoveryText(){return a$1.getInstance().get(L)}get width(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.width)!=null?t:0)}get height(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.height)!=null?t:0)}get canvasDrawer(){return !this._canvasDrawer&&this.canvasElement!=null&&(this._canvasDrawer=new b$1(this.canvasElement),this._canvasDrawer.startObservingCanvasResize()),this._canvasDrawer}get controls(){return this.controlMap.values()}get privateContext(){return this._context}static async forContext(e){let t=new V;return await t.setContext(e),t}showProgressBar(){var e;(e=this.loadingOverlay)==null||e.show();}hideProgressBar(){var e;(e=this.loadingOverlay)==null||e.hide();}setProgressBarPercentage(e){this.loadingOverlay&&(this.loadingOverlay.progress=e);}setProgressBarMessage(e){this.loadingOverlay&&(this.loadingOverlay.message=e);}getContext(){return this._context}async setContext(e){var t,i,r;if(this._context!==e&&(this._context=e,e)){if(this.overlays.size>0&&!((t=this._context)!=null&&t[a$4].hasModes()))throw new Error(["Cannot assign this view to this context. This view has overlays but the context does not have any mode attached matching these overlays.","Remove the overlays first before attaching the view to the context, or add the corresponding mode to the context before attaching this view."].join(" "));await e.setView(this),(i=this.privateContext)==null||i.subscribeToWorkerMessages(this.onWorkerMessageHandler),(r=this._context)!=null&&r.frameSource&&await this.onFrameSourceChange(this._context.frameSource);}}connectToElement(e,t){var i,r,n,o;this.isConnected||(this.orientationObserver.register(),this.setupHtmlElement(e),(i=this.canvasDrawer)==null||i.startObservingCanvasResize(),this.htmlElementDidChange(),a$5.add(this),this.orientation=this.orientationObserver.orientation.value,this.orientationObserver.addEventListener(a$6,this.onOrientationChangeListener),(r=this.hintPresenter)==null||r.addEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(n=this.hintPresenter)==null||n.addEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),this.localizationSubscription=a$1.getInstance().subscribe(a=>{a[L]!=null&&(this.cameraRecoveryElement.textContent=a[L]);}),this._previewCamera=(o=t==null?void 0:t.camera)!=null?o:null,this._previewCamera&&(this._previewCamera.addListener(this.frameSourceListener),this.onFrameSourceChange(this._previewCamera)),this.updateControls(),this.isConnected=true);}detachFromElement(){var e,t,i,r,n,o,a,l;if(this.isConnected){(e=this.htmlElementState)==null||e.removeListeners(),this.removeStyles(),(t=this.canvasDrawer)==null||t.endObservingCanvasResize(),document.removeEventListener("visibilitychange",this.visibilityListener);for(let h of ["touchend","mousedown"])this.cameraRecoveryElement.removeEventListener(h,this.cameraRecoveryListener);(i=this.loadingOverlay)==null||i.remove(),(r=this.customLocationsView)==null||r.unmount(),this.notificationPresenter=null,this.htmlElementDidChange(),this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),(n=this.gestureRecognizer)==null||n.removeListener(this),this.clearHtmlElementContent(),a$5.delete(this),this.orientationObserver.unregister(),this.orientationObserver.removeEventListener(a$6,this.onOrientationChangeListener),(o=this.hintPresenter)==null||o.removeEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(a=this.hintPresenter)==null||a.removeEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),(l=this.localizationSubscription)==null||l.cancel(),g.instance().disconnectedCallback(),this._previewCamera&&(this._previewCamera.removeListener(this.frameSourceListener),this._previewCamera=null);for(let h of this.controls)this.removeControl(h);this.isConnected=false;}}async addOverlay(e){var t;this.overlays.has(e)||(this.overlays.add(e),await((t=this.privateContext)==null?void 0:t.update([{type:"addOverlay",newValue:e,view:this}])));}async removeOverlay(e){var t;this.overlays.has(e)&&(await((t=this.privateContext)==null?void 0:t.update([{type:"removeOverlay",newValue:e,view:this}])),this.overlays.delete(e));}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}viewPointForFramePoint(e){var u,D,T,M,F,R,A,N;let t={width:(D=(u=this.htmlElementState)==null?void 0:u.width)!=null?D:0,height:(M=(T=this.htmlElementState)==null?void 0:T.height)!=null?M:0},i={width:(R=(F=this.videoElement)==null?void 0:F.videoWidth)!=null?R:0,height:(N=(A=this.videoElement)==null?void 0:A.videoHeight)!=null?N:0},r=t.width/t.height,n=i.width/i.height,o=r>n?t.width/i.width:t.height/i.height,a={x:e.x*o,y:e.y*o},l=(i.width*o-t.width)/2,h=(i.height*o-t.height)/2;return new a$7(a.x-l,a.y-h)}viewQuadrilateralForFrameQuadrilateral(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft),n=this.viewPointForFramePoint(e.bottomRight);return new a$8(t,i,n,r)}addControl(e){let t=e.toJSONObject().type;if(!this.controlMap.has(t)&&!(t==="camera-fov"&&this.controlMap.has("zoom"))){if(t==="zoom"){let i=this.controlMap.get("camera-fov");i&&this.removeControl(i);}this.controlMap.set(t,e),e.install(this).then(i=>{var r;i&&((r=this.privateContext)==null||r.update([{type:"addControl",newValue:e}]));});}}removeControl(e){var i;let t=e.toJSONObject().type;this.controlMap.has(t)&&(e.remove(true),this.controlMap.delete(t),(i=this.privateContext)==null||i.update([{type:"removeControl",newValue:e}]));}toJSONObject(){var e;return {scanAreaMargins:this.scanAreaMargins.toJSONObject(),pointOfInterest:this.pointOfInterest.toJSONObject(),logoAnchor:this.logoAnchor,logoOffset:this.logoOffset.toJSONObject(),logoHidden:(e=this.logoHidden)!=null?e:false,logoStyle:this.logoStyle,overlays:[...this.overlays].map(t=>t.toJSONObject()),controls:[...this.controls].map(t=>t.toJSONObject()),focusGesture:this.focusGesture?this.focusGesture.toJSONObject():null,zoomGestures:this._zoomGestures.map(t=>t.toJSONObject())}}isCameraRecoveryVisible(){return !this.cameraRecoveryElement.hidden}setCameraRecoveryVisible(e){this.cameraRecoveryElement.hidden=!e;}async allowPictureInPicture(e){await g.instance().allowPictureInPicture(e);}viewAnchorPositionsForFrameAnchorPositions(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft),n=this.viewPointForFramePoint(e.bottomRight),o=this.viewPointForFramePoint(e.centerLeft),a=this.viewPointForFramePoint(e.centerRight),l=this.viewPointForFramePoint(e.topCenter),h=this.viewPointForFramePoint(e.bottomCenter),u=this.viewPointForFramePoint(e.center);return new a$9(t,i,n,r,o,l,a,h,u)}setDidTapCustomLocationsViewListener(e){this.customLocationsView&&this.customLocationsView.listener===null&&(this.customLocationsView.listener=e);}renderCustomLocationsView(e){this.customLocationsView!=null&&(this.customLocationsView.setMirrored(g.instance().isMirrorImageEnabled()),Object.keys(e).includes("removedIds")?this.customLocationsView.render(e):this.customLocationsView.renderDomView(e));}getNotificationPresenter(){var e;if(!this.notificationPresenter){let t=(e=this.htmlElement)==null?void 0:e.querySelector(b$2.tag);if(!t)throw new Error("Notification presenter cannot be found. Please ensure the DataCaptureView is connected.");this.notificationPresenter=new a$a(t);}return this.notificationPresenter}removeStyles(){for(let e of document.querySelectorAll("style[scandit]"))e.remove();}onHintPresenterUpdate(e){var t;(t=this.privateContext)==null||t.workerCommand("hintPresenterV2update",{});}async onViewFinderUpdateRequested(e){var i;let t=await((i=this.privateContext)==null?void 0:i.workerCommand("getViewfinderInfo",{}));t!=null&&this.updateHintPresenterViewFinderRect(t.rect);}clearHtmlElementContent(){var e;this.htmlElement&&((e=this.canvasDrawer)==null||e.endObservingCanvasResize(),this.htmlElement.innerHTML="",this.cameraPaintboardElement=void 0,this.singleImageUploaderPaintboardElement=void 0,this.htmlElement=void 0);}setupHtmlElement(e){var n,o,a;this.createStyles(),this.htmlElement=e,b$2.register(),a$b.register(),a$c.register();let t=a$f`<div class="${a$d.CONTAINER_CLASS_NAME}" role="main" aria-label="Data capture view"><div class="${a$d.PAINTBOARDS_CONTAINER_CLASS_NAME}"><div data-js-id="loading-overlay"></div><div class="${a$d.PAINTBOARD_CLASS_NAME}" data-js-id="camera-paintboard"><div data-js-id="video-container"></div><img class="${a$d.FROZEN_FRAME}" data-js-id="frozen-frame" alt="Last captured camera frame shown while camera is on standby" hidden /><canvas></canvas><div data-js-id="${a$e.CUSTOM_VIEW_CONTAINER}"></div><${b$2.tag}></${b$2.tag}><${a$b.tag}></${a$b.tag}><div class="${a$d.CAMERA_RECOVERY_CLASS_NAME}" role="alert" aria-live="polite" aria-atomic="true" hidden>${this.cameraRecoveryText}</div><div class="${a$d.ERROR_CLASS_NAME}" role="alert" aria-live="assertive" aria-atomic="true" hidden></div></div><div class="${a$d.PAINTBOARD_CLASS_NAME}" data-js-id="singleimage-paintboard"></div></div></div>`;this.htmlElement.innerHTML=t,g.instance().connectedCallback(this.htmlElement.querySelector('[data-js-id="video-container"]')),this.isVideoElementDetached=false,this.hintPresenter=this.htmlElement.querySelector(b$2.tag),this.notificationPresenter=this.hintPresenter?new a$a(this.hintPresenter):null,this.loadingOverlay&&this.loadingOverlay.remove(),this.loadingOverlay=a$c.create(),this.loadingOverlay.hide(),(n=this.htmlElement.querySelector('[data-js-id="loading-overlay"]'))==null||n.replaceWith(this.loadingOverlay),this.customLocationsView&&this.customLocationsView.unmount(),this.customLocationsView=new a$g,this.customLocationsView.mount(this.htmlElement.querySelector(`[data-js-id="${a$e.CUSTOM_VIEW_CONTAINER}"]`)),this.customLocationsView.mapViewAnchorPositionsForFramePoint=l=>this.viewAnchorPositionsForFrameAnchorPositions(l),this.containerElement=this.htmlElement.querySelector(`.${a$d.CONTAINER_CLASS_NAME}`),this.cameraPaintboardElement=this.containerElement.querySelector('[data-js-id="camera-paintboard"]'),this.singleImageUploaderPaintboardElement=this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]');let i=this.cameraPaintboardElement.querySelector("canvas");this.canvasElement==null?this.canvasElement=i:i.replaceWith(this.canvasElement);let r=this.cameraPaintboardElement.querySelector('[data-js-id="frozen-frame"]');this.frozenFrame==null?this.frozenFrame=r:r.replaceWith(this.frozenFrame),this.controlsElement=this.cameraPaintboardElement.querySelector(a$b.tag),this.cameraRecoveryElement=this.cameraPaintboardElement.querySelector(`.${a$d.CAMERA_RECOVERY_CLASS_NAME}`),this.errorElement=this.cameraPaintboardElement.querySelector(`.${a$d.ERROR_CLASS_NAME}`),this.lastFrameSourceState!=null&&((a=(o=this._context)==null?void 0:o.frameSource)==null||a.switchToDesiredState(this.lastFrameSourceState)),document.addEventListener("visibilitychange",this.visibilityListener);for(let l of ["touchend","mousedown"])this.cameraRecoveryElement.addEventListener(l,this.cameraRecoveryListener);this.htmlElementState&&this.htmlElementState.removeListeners(),this.htmlElementState=new a$h(this.htmlElement),this.htmlElementState.onStateChanged(this.htmlElementDidChangeHandler),this.htmlElementState.onDisconnected(this.htmlElementDisconnectedHandler),this.gestureRecognizer=new a$i(this.htmlElement),this.gestureRecognizer.addListener(this),this.addSwipeToZoomListener(),this.addPinchToZoomListener();}setupHtmlElementSingleImageUploader(e){var i;if(this.singleImageUploaderPaintboardElement==null)return;this.singleImageUploaderView&&this.singleImageUploaderView.unmount(),this.singleImageUploaderView=new a$j(e),this.singleImageUploaderView.mount(this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]'));let t=(i=this._context)==null?void 0:i.frameSource;this.singleImageUploaderView.onInputCheck(r=>{t.getCurrentState()!=="starting"&&r.preventDefault();}),this.singleImageUploaderView.onBeforeFileRead(()=>{t._context&&this.singleImageUploaderView&&(this.singleImageUploaderView.canUploadFile=t._context.hasEnabledMode());}),this.singleImageUploaderView.onImageLoadError(()=>{t.currentState="starting",a$k.log(a$k.Level.Error,"Could not load image from selected file");}),this.singleImageUploaderView.onFileReaderError(r=>{var o,a;let n=r.target;t.currentState="starting",a$k.log(a$k.Level.Error,`Error while reading the file: ${(a=(o=n.error)==null?void 0:o.toString())!=null?a:""}`);}),this.singleImageUploaderView.onCaptureReady(async r=>{await t.processUploadedFileCapture(r);}),this.singleImageUploaderView.setButtonState(t.getCurrentState()==="starting"?"enabled":"disabled"),t.addView(this.singleImageUploaderView);}setupHtmlElementVisibility(e){this.cameraPaintboardElement!=null&&(this.cameraPaintboardElement.hidden=e!=="camera"),this.singleImageUploaderPaintboardElement!=null&&(this.singleImageUploaderPaintboardElement.hidden=e!=="singleImageUploader");}createStyles(){if(document.querySelector("style[scandit]")===null){let e=a$l();for(let[t,i]of Object.entries(e))i.setAttribute("scandit",`data-capture-sdk-${t}`),document.head.append(i);}}async onOrientationChange(e){var t,i;this.orientation=e.detail.value,await((i=this.privateContext)==null?void 0:i.update([{type:"viewChange",newValue:{...(t=this.htmlElementState)==null?void 0:t.toJSONObject(),orientation:this.orientation}}]));}htmlElementDidChange(){var i,r;if(!this.htmlElementState)return;let e=this.htmlElementState,t=e.toJSONObject();if(!a$h.areEquivalentJSONStates(this.lastHtmlElementState,t)){this.orientation=this.orientationObserver.orientation.value,(i=this.privateContext)==null||i.update([{type:"viewChange",newValue:{...e.toJSONObject(),orientation:this.orientation}}]),this.lastHtmlElementState=t,(r=this.canvasDrawer)==null||r.updateCanvasSizeAttributes(this.width,this.height),this.handleVideoDisplay(t.visible);for(let n of this.listeners)typeof n.didChangeSize=="function"&&n.didChangeSize(this,new a$m(t.size.width.value,t.size.height.value),this.orientation);}}async htmlElementDisconnected(){var e,t,i,r,n,o;g.instance().disconnectedCallback(),this.lastFrameSourceState=(t=(e=this._context)==null?void 0:e.frameSource)==null?void 0:t.getCurrentState(),await((r=(i=this._context)==null?void 0:i.frameSource)==null?void 0:r.switchToDesiredState("off")),await((o=this.privateContext)==null?void 0:o.update([{type:"viewChange",newValue:{...(n=this.htmlElementState)==null?void 0:n.toJSONObject(),orientation:this.orientation}}])),this.isConnected=false;}attachAdditionalLayer(e,t){var i;t==="above-controls"&&((i=this.controlsElement)==null||i.insertAdjacentElement("afterend",e));}handleVideoDisplay(e){this.videoElement==null||this.cameraPaintboardElement==null||(!e&&!this.isVideoElementDetached?(this.videoElement.width=0,this.videoElement.height=0,this.videoElement.style.opacity="0",this.videoElement.style.visibility="hidden",document.body.append(this.videoElement),this.isVideoElementDetached=true):e&&this.isVideoElementDetached&&(this.cameraPaintboardElement.insertAdjacentElement("afterbegin",this.videoElement),this.isVideoElementDetached=false,this.videoElement.style.removeProperty("visibility"),this.videoElement.removeAttribute("width"),this.videoElement.removeAttribute("height"),this.videoElement.style.removeProperty("opacity")));}isCanvasDrawerWithMetrics(e){return e instanceof a$n}onWorkerMessage(e){var t,i;switch(e.type){case "draw":{this.drawEngineCommands(e.payload);break}case "performanceMetricsReport":{let r=this._canvasDrawer;r!=null&&this.isCanvasDrawerWithMetrics(r)&&r.setPerformanceMetrics(e.payload);break}case "contextDidChangeStatus":{let r=a$o.fromJSON(e.payload);(t=this.loadingOverlay)==null||t.hide(),r.isValid?(this.clearError(),this.setVideoElementOpacity("1")):this.displayError(r);break}case "viewSizeChanged":{let r=e.payload;if(r==null)return;this.onSDCViewSizeChangedCallback(r);break}default:{(i=this.hintPresenter)==null||i.handleMessage(e);break}}}onSDCViewSizeChangedCallback(e){this.updateHintPresenterViewFinderRect(e.viewFinderRect);}updateHintPresenterViewFinderRect(e){var t;(t=this.hintPresenter)==null||t.setViewFinderRect(new a$p(new a$7(e.origin.x,e.origin.y),new a$m(e.size.width,e.size.height)));}drawEngineCommands(e){var t;(t=this.canvasDrawer)==null||t.draw(e);}displayError(e){this.errorElement.textContent=`Error ${e.code}: ${e.message}`,this.errorElement.hidden=false;}clearError(){this.errorElement.textContent="",this.errorElement.hidden=true;}updateControls(){var e;for(let t of this.controls)(e=t.update)==null||e.call(t,this);}async onFrameSourceChange(e){let t=e==null?void 0:e.type;if(this.setupHtmlElementVisibility(t),t==="camera"){let i=e==null?void 0:e.getCurrentState();i!=null&&await this.onCameraStateChanged(i);}else t==="singleImageUploader"&&this.setupHtmlElementSingleImageUploader(e.settings);}async onCameraStateChanged(e){var t;switch((t=this.cameraPaintboardElement)==null||t.classList.toggle(a$d.PAINTBOARD_CLASS_NAME_STATE_ON,e==="on"),e){case "stopping":{this.hiddenProperties.freezeFrameWhenStoppingFrameSource&&this.freezeFrame(),this.setVideoElementOpacity("0");return}case "starting":case "bootingUp":case "wakingUp":{if(!this.htmlElement){a$k.error("cannot set frame source stream before connecting view to an HTML element");return}this.videoElement&&(g.instance().gui.isCameraRecoveryVisible=this.isCameraRecoveryVisible.bind(this),g.instance().gui.setCameraRecoveryVisible=this.setCameraRecoveryVisible.bind(this),this.setVideoElementOpacity("0"));return}case "off":{this.setVideoElementOpacity("0"),this.updateControls();return}case "on":{await g.instance().waitForCapabilities(),this.updateControls(),this.unfreezeFrame(),this.setVideoElementOpacity("1");break}case "goingToSleep":{this.freezeFrame();break}}}setVideoElementOpacity(e){this.videoElement&&(this.videoElement.style.opacity=e),this.canvasElement&&(this.canvasElement.style.opacity=e);}onSingleImageUploaderSettingsChange(e){this.setupHtmlElementSingleImageUploader(e);}setHiddenProperty(e,t){this.hiddenProperties[e]=t;}async onVisibilityChange(){var t,i;let e=(t=this.videoElement)==null?void 0:t.srcObject;if(this.hiddenProperties.stopVideoTracksOnVisibilityChange&&(document.visibilityState==="hidden"&&g.instance().stopVideoTracks(),document.visibilityState==="visible"&&g.instance().activeCamera!=null&&e!=null))if(!e.active||(i=e.getVideoTracks()[0])!=null&&i.muted)try{a$k.debug('Detected visibility change ("visible") event with inactive video source, try to reinitialize camera'),await g.instance().reinitializeCamera();}catch{}else a$k.debug('Detected visibility change ("visible") event with active video source, replay video'),g.instance().playVideo();}async cameraRecovery(e){e.preventDefault(),g.instance().activeCamera=g.instance().selectedCamera,await g.instance().reinitializeCamera();}freezeFrame(){var i;if(!this.frozenFrame)return;let e=g.instance().getCurrentFrame();if(!e)return;let t=new ImageData(e.data,e.width,e.height);this.frozenFrameCanvas.width=t.width,this.frozenFrameCanvas.height=t.height,this.frozenFrame.width=t.width,this.frozenFrame.height=t.height,(i=this.frozenFrameCanvas.getContext("2d"))==null||i.putImageData(t,0,0),this.frozenFrame.src=this.frozenFrameCanvas.toDataURL("image/jpeg",.4),this.frozenFrame.classList.toggle(a$d.MIRRORED_CLASS_NAME,g.instance().isMirrorImageEnabled()),this.frozenFrame.hidden=false;}unfreezeFrame(){this.frozenFrame&&(this.frozenFrame.src="",this.frozenFrame.hidden=true);}onTap(e){var t;(t=this.privateContext)==null||t.workerCommand("onTap",{point:e.toJSONObject()});}onSwipeUp(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomIn();}onSwipeDown(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomOut();}onPinchIn(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomIn();}onPinchOut(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomOut();}didZoomInGesture(){this.performZoomIn();}didZoomOutGesture(){this.performZoomOut();}addSwipeToZoomListener(){let e=this._zoomGestures.find(t=>t.toJSONObject().type==="swipeToZoom");e&&(this.swipeToZoomGesture=e,e.addListener(this));}removeSwipeToZoomListener(){var e;(e=this.swipeToZoomGesture)==null||e.removeListener(this),this.swipeToZoomGesture=null;}addPinchToZoomListener(){let e=this._zoomGestures.find(t=>t.toJSONObject().type==="pinchToZoom");e&&(this.pinchToZoomGesture=e,e.addListener(this));}removePinchToZoomListener(){var e;(e=this.pinchToZoomGesture)==null||e.removeListener(this),this.pinchToZoomGesture=null;}async performZoomIn(){var n;let e=(n=this._context)==null?void 0:n.frameSource;if(!(e!=null&&e.settings))return;let t=e.settings.zoomFactor,r=[...e.settings.zoomLevels].sort((o,a)=>o-a).find(o=>o>t);r!=null&&(await e.setZoomFactor(r),this.showZoomNotification(r));}async performZoomOut(){var n;let e=(n=this._context)==null?void 0:n.frameSource;if(!(e!=null&&e.settings))return;let t=e.settings.zoomFactor,r=[...[...e.settings.zoomLevels].sort((o,a)=>o-a)].reverse().find(o=>o<t);r!=null&&(await e.setZoomFactor(r),this.showZoomNotification(r));}async showZoomNotification(e$1){var r,n;if(!this.shouldShowZoomNotification)return;let t=e.toJSON(),i={tag:"zoomNotification",text:this.formatZoomFactor(e$1),hintStyle:{textColor:t,backgroundColor:y.neutralWhite.withAlpha(.8).toJSON(),textAlignment:"center",hintIcon:"none",iconColor:t,isAnimatedToView:true,hintAnchor:"top",hintAnchorOffset:16,horizontalMargin:16,maxWidthFraction:1,textSize:14,textWeight:700,lineHeight:24,maxLines:3,cornerRadius:4,fitToText:true}};(r=this.zoomNotificationTimeout)==null||r.stop(),this.zoomNotificationTimeout=new a$q(this.zoomNotificationDuration,()=>{var o;(o=this.hintPresenter)==null||o.hideToast(i);}),await((n=this.hintPresenter)==null?void 0:n.showToast(i)),this.zoomNotificationTimeout.start();}formatZoomFactor(e){let t=Math.ceil(e*100)/100;return parseFloat(t.toPrecision(3))+"x"}},X=V;export{X as a};
@@ -1 +1 @@
1
- import {e}from'./chunk-CA6FHIF6.js';import {a as a$1}from'./chunk-XR65N6EG.js';import {a}from'./chunk-QCZSSQAQ.js';var m=class i{constructor(){this.type="imageFrameSource";this._listeners=new Set;this._currentState="off";this._desiredState="off";this._context=null;this._imageData=null;}get desiredState(){return this._desiredState}get context(){return this._context}set context(e){this._context=e;}get currentState(){return this._currentState}static async fromFile(e){let r=URL.createObjectURL(e),t=new Image;t.src=r;try{await t.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted file is not an image"})}finally{URL.revokeObjectURL(r);}return i.fromImage(t)}static async fromImage(e){let r=new i;try{await e.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted image cannot be decoded"})}let t=r.getCanvasAndContext(e.width,e.height);return t.drawImage(e,0,0),r._imageData=t.getImageData(0,0,e.width,e.height,{colorSpace:"srgb"}),r}static async fromImageData(e){let r=new i,t=r.getCanvasAndContext(e.width,e.height);try{t.putImageData(e,0,0);}catch(n){throw new a({name:"InvalidImageError",message:`Submitted image data does not seem valid (details: ${n})`})}return r._imageData=e,r}async switchToDesiredState(e){if(e==="on"){if(this.currentState==="on")return}else if(this.currentState==="off")return;if(this._desiredState=e,e==="off"){await this.setCurrentState("off");return}return this._imageData==null?(a$1.log(a$1.Level.Warn,"No image data to process."),this.processSubmittedImage({data:new Uint8ClampedArray(0),width:0,height:0,colorSpace:"srgb"})):this.processSubmittedImage(this._imageData)}addListener(e){e!=null&&this._listeners.add(e);}removeListener(e){e!=null&&this._listeners.delete(e);}toJSONObject(){return {type:this.type}}getCurrentState(){return this._currentState}getCanvasAndContext(e,r){let t=document.createElement("canvas");t.width=e,t.height=r;let n=t.getContext("2d");if(n==null)throw new a({name:"ImageFrameSourceError",message:"Could not generate a canvas context to get image data"});return n}async setCurrentState(e){if(e!==this._currentState)return this._currentState=e,this.notifyListeners(),this.notifyContext({type:"frameSourceState",newValue:e})}async notifyContext(e){if(this._context)return this._context.update([e])}notifyListeners(){for(let e of this._listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}async processSubmittedImage(e$1){var t;await this.setCurrentState("on");let r={data:e$1.data,width:e$1.width,height:e$1.height,frameId:e()};await((t=this._context)==null?void 0:t.sendFrameToProcessor(r)),await this.setCurrentState("off");}};export{m as a};
1
+ import {e}from'./chunk-T6EVGEHJ.js';import {a as a$1}from'./chunk-XR65N6EG.js';import {a}from'./chunk-QCZSSQAQ.js';var m=class i{constructor(){this.type="imageFrameSource";this._listeners=new Set;this._currentState="off";this._desiredState="off";this._context=null;this._imageData=null;}get desiredState(){return this._desiredState}get context(){return this._context}set context(e){this._context=e;}get currentState(){return this._currentState}static async fromFile(e){let r=URL.createObjectURL(e),t=new Image;t.src=r;try{await t.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted file is not an image"})}finally{URL.revokeObjectURL(r);}return i.fromImage(t)}static async fromImage(e){let r=new i;try{await e.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted image cannot be decoded"})}let t=r.getCanvasAndContext(e.width,e.height);return t.drawImage(e,0,0),r._imageData=t.getImageData(0,0,e.width,e.height,{colorSpace:"srgb"}),r}static async fromImageData(e){let r=new i,t=r.getCanvasAndContext(e.width,e.height);try{t.putImageData(e,0,0);}catch(n){throw new a({name:"InvalidImageError",message:`Submitted image data does not seem valid (details: ${n})`})}return r._imageData=e,r}async switchToDesiredState(e){if(e==="on"){if(this.currentState==="on")return}else if(this.currentState==="off")return;if(this._desiredState=e,e==="off"){await this.setCurrentState("off");return}return this._imageData==null?(a$1.log(a$1.Level.Warn,"No image data to process."),this.processSubmittedImage({data:new Uint8ClampedArray(0),width:0,height:0,colorSpace:"srgb"})):this.processSubmittedImage(this._imageData)}addListener(e){e!=null&&this._listeners.add(e);}removeListener(e){e!=null&&this._listeners.delete(e);}toJSONObject(){return {type:this.type}}getCurrentState(){return this._currentState}getCanvasAndContext(e,r){let t=document.createElement("canvas");t.width=e,t.height=r;let n=t.getContext("2d");if(n==null)throw new a({name:"ImageFrameSourceError",message:"Could not generate a canvas context to get image data"});return n}async setCurrentState(e){if(e!==this._currentState)return this._currentState=e,this.notifyListeners(),this.notifyContext({type:"frameSourceState",newValue:e})}async notifyContext(e){if(this._context)return this._context.update([e])}notifyListeners(){for(let e of this._listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}async processSubmittedImage(e$1){var t;await this.setCurrentState("on");let r={data:e$1.data,width:e$1.width,height:e$1.height,frameId:e()};await((t=this._context)==null?void 0:t.sendFrameToProcessor(r)),await this.setCurrentState("off");}};export{m as a};
@@ -1 +1 @@
1
- import {a as a$2}from'./chunk-SEAVQZN6.js';import {a}from'./chunk-2UHUEJA4.js';import {a as a$5}from'./chunk-AIRWHLJH.js';import {a as a$4}from'./chunk-FGO2SSRS.js';import {a as a$1}from'./chunk-QCRFVRSS.js';import {b}from'./chunk-FTD535WI.js';import {a as a$3}from'./chunk-XR65N6EG.js';var h=class{constructor(a$3,e){this.onMessageListener=this.onMessage.bind(this);this.workerSelf=a$3,this.dataCaptureInstance=new a(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),a$1(a$3)&&(a$2(a$3),this.listenToMessages());}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",a=>{a$3.log(a$3.Level.Error,a);}),this.workerSelf.addEventListener("messageerror",a=>{a$3.log(a$3.Level.Error,a);});}postMessage(a,e){this.workerSelf.postMessage(a,e!=null?e:[]);}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas=="function"}hasPayload(a){return a$4(a)&&"payload"in a}hasTransferables(a){return a$4(a)&&Array.isArray(a.transferables)}async respondWith(a,e,l){let r=null,t;try{t=l(),t instanceof Promise&&(t=await t);}catch(m){t=void 0,r=a$5(m);}let i={type:"workerTaskId",command:a,id:e,payload:this.hasPayload(t)?t.payload:void 0};r!=null&&(i.error=r),this.postMessage(i,this.hasTransferables(t)?t.transferables:[]);}onMessage(a){switch(a.data.command){case "loadLibrary":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:e.libraryLocation,locationPath:e.locationPath,referredOrigin:e.referredOrigin,writableDataPathOverride:e.writableDataPathOverride,threadsSupport:e.threadsSupport,simdSupport:e.simdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory,indexedDBTimeoutMs:e.indexedDBTimeoutMs}));}break}case "onTap":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.onTap(e.point);});}break}case "hintPresenterV2update":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update();});}break}case "createContext":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.createContext({context:e.context,deviceId:e.deviceId,delayedRegistration:e.delayedRegistration,highEndBlurryRecognition:e.highEndBlurryRecognition,appName:e.appName,parentDomain:e.parentDomain,isTablet:e.isTablet,batteryInfo:e.batteryInfo}));}break}case "setFrameSource":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.setFrameSource(e.mirrorAxis,e.isCameraFrameSource));}break}case "processFrame":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.processFrame({data:e.data,frameId:e.frameId,width:e.width,height:e.height,colorType:e.colorType}));}break}case "requestFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.requestFrameData(e.frameId));}break}case "deleteFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.deleteFrameData(e.frameId);});}break}case "updateContext":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.updateContext(e));}break}case "dispose":{this.respondWith(a.data.command,a.data.id,()=>this.dataCaptureInstance.dispose());break}case "flushAnalytics":{this.respondWith(a.data.command,a.data.id,()=>{this.dataCaptureInstance.flushAnalytics();});break}case "reportCameraProperties":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.reportCameraProperties(e));}break}case "setLogLevel":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{a$3.setLevel(e.level);});}break}case "updateBatteryInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.updateBatteryInfo(e.batteryInfo);});}break}case "extractCentaurusLicense":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.extractCentaurusLicense(e.licenseKey));}break}case "documentVisibility":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(e.state);});}break}case "isFeatureSupported":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.isFeatureSupported(e.feature));}break}case "getViewfinderInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getViewfinderInfo());}break}case "getOpenSourceSoftwareLicenseInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo());}break}case "addNativeOverlay":this.dataCaptureInstance.addNativeOverlay(a);break;case "removeNativeOverlay":this.dataCaptureInstance.removeNativeOverlay(a);break;case "convertToJPEGResult":{{let{data:e}=a;this.dataCaptureInstance.convertToJPEGResult(e.imageId,e.result);}break}default:return b(a.data),false}return true}};export{h as a};
1
+ import {a as a$2}from'./chunk-SEAVQZN6.js';import {a}from'./chunk-JAY44NXK.js';import {a as a$5}from'./chunk-AIRWHLJH.js';import {a as a$4}from'./chunk-FGO2SSRS.js';import {a as a$1}from'./chunk-QCRFVRSS.js';import {b}from'./chunk-FTD535WI.js';import {a as a$3}from'./chunk-XR65N6EG.js';var h=class{constructor(a$3,e){this.onMessageListener=this.onMessage.bind(this);this.workerSelf=a$3,this.dataCaptureInstance=new a(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),a$1(a$3)&&(a$2(a$3),this.listenToMessages());}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",a=>{a$3.log(a$3.Level.Error,a);}),this.workerSelf.addEventListener("messageerror",a=>{a$3.log(a$3.Level.Error,a);});}postMessage(a,e){this.workerSelf.postMessage(a,e!=null?e:[]);}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas=="function"}hasPayload(a){return a$4(a)&&"payload"in a}hasTransferables(a){return a$4(a)&&Array.isArray(a.transferables)}async respondWith(a,e,l){let r=null,t;try{t=l(),t instanceof Promise&&(t=await t);}catch(m){t=void 0,r=a$5(m);}let i={type:"workerTaskId",command:a,id:e,payload:this.hasPayload(t)?t.payload:void 0};r!=null&&(i.error=r),this.postMessage(i,this.hasTransferables(t)?t.transferables:[]);}onMessage(a){switch(a.data.command){case "loadLibrary":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:e.libraryLocation,locationPath:e.locationPath,referredOrigin:e.referredOrigin,writableDataPathOverride:e.writableDataPathOverride,threadsSupport:e.threadsSupport,simdSupport:e.simdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory,indexedDBTimeoutMs:e.indexedDBTimeoutMs}));}break}case "onTap":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.onTap(e.point);});}break}case "hintPresenterV2update":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update();});}break}case "createContext":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.createContext({context:e.context,deviceId:e.deviceId,delayedRegistration:e.delayedRegistration,highEndBlurryRecognition:e.highEndBlurryRecognition,appName:e.appName,parentDomain:e.parentDomain,isTablet:e.isTablet,batteryInfo:e.batteryInfo}));}break}case "setFrameSource":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.setFrameSource(e.mirrorAxis,e.isCameraFrameSource));}break}case "processFrame":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.processFrame({data:e.data,frameId:e.frameId,width:e.width,height:e.height,colorType:e.colorType}));}break}case "requestFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.requestFrameData(e.frameId));}break}case "deleteFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.deleteFrameData(e.frameId);});}break}case "updateContext":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.updateContext(e));}break}case "dispose":{this.respondWith(a.data.command,a.data.id,()=>this.dataCaptureInstance.dispose());break}case "flushAnalytics":{this.respondWith(a.data.command,a.data.id,()=>{this.dataCaptureInstance.flushAnalytics();});break}case "reportCameraProperties":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.reportCameraProperties(e));}break}case "setLogLevel":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{a$3.setLevel(e.level);});}break}case "updateBatteryInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.updateBatteryInfo(e.batteryInfo);});}break}case "extractCentaurusLicense":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.extractCentaurusLicense(e.licenseKey));}break}case "documentVisibility":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(e.state);});}break}case "isFeatureSupported":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.isFeatureSupported(e.feature));}break}case "getViewfinderInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getViewfinderInfo());}break}case "getOpenSourceSoftwareLicenseInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo());}break}case "addNativeOverlay":this.dataCaptureInstance.addNativeOverlay(a);break;case "removeNativeOverlay":this.dataCaptureInstance.removeNativeOverlay(a);break;case "convertToJPEGResult":{{let{data:e}=a;this.dataCaptureInstance.convertToJPEGResult(e.imageId,e.result);}break}default:return b(a.data),false}return true}};export{h as a};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-CGK5V6XZ.js';import {a}from'./chunk-IASACVTH.js';var o=class r{constructor(i,e){this._vibration=null;this._sound=null;this._vibration=i,this._sound=e;}static get defaultFeedback(){return new r(a.defaultVibration,a$1.defaultSound)}get vibration(){return this._vibration}get sound(){return this._sound}emit(){this.sound&&this.sound.play(),this.vibration&&this.vibration.vibrate();}toJSONObject(){let i={};return this.sound!==null&&(i.sound=this.sound.toJSONObject()),this.vibration!==null&&(i.vibration=this.vibration.toJSONObject()),i}};export{o as a};
1
+ import {a as a$1}from'./chunk-56S3BFJ6.js';import {a}from'./chunk-SIMTA4TK.js';var o=class r{constructor(i,e){this._vibration=null;this._sound=null;this._vibration=i,this._sound=e;}static get defaultFeedback(){return new r(a.defaultVibration,a$1.defaultSound)}get vibration(){return this._vibration}get sound(){return this._sound}emit(){this.sound&&this.sound.play(),this.vibration&&this.vibration.vibrate();}toJSONObject(){let i={};return this.sound!==null&&(i.sound=this.sound.toJSONObject()),this.vibration!==null&&(i.vibration=this.vibration.toJSONObject()),i}};export{o as a};
@@ -1 +1 @@
1
- import {a as a$4}from'./chunk-4KLHTKGW.js';import {g as g$1}from'./chunk-CA6FHIF6.js';import {d}from'./chunk-YUZDO2PC.js';import {b}from'./chunk-7LTHFX4E.js';import {a as a$1}from'./chunk-LFJUGRQV.js';import {b as b$1}from'./chunk-YONR3EGV.js';import {a as a$3}from'./chunk-XR65N6EG.js';import {g}from'./chunk-D222MT4V.js';import {a}from'./chunk-U2WQ3WDE.js';import {a as a$2}from'./chunk-QCZSSQAQ.js';d.addVideoDevicesListener(O=>{b.integrateIncomingVideoDevices(O.map(e=>h.fromDeviceCamera(e)));});var F;F=a$1;var s=class s{constructor(e){this._label="";this._deviceId="";this._notFoundOnDevice=false;this._isBestGuess=false;this.type="camera";this._currentState="off";this._settings=new g;this._desiredTorchState="off";this._desiredState="off";this.listeners=[];this.zoomListeners=new Set;this._context=null;this[F]={markAsUnmappedToDeviceCameras:this.markAsUnmappedToDeviceCameras.bind(this),resetUnmappedState:this.resetUnmappedState.bind(this),setDeviceId:this.setDeviceId.bind(this),setLabel:this.setLabel.bind(this),markAsBestGuess:this.markAsBestGuess.bind(this)};this._captureAndSendBound=this.captureAndSend.bind(this);this.stateTransitionStrategyMap={off:{on:this.transitionFromStateOffToOn.bind(this),standby:this.transitionFromStateOffToStandby.bind(this)},on:{off:this.transitionFromStateOnToOff.bind(this),standby:this.transitionFromStateOnToStandby.bind(this)},standby:{off:this.transitionFromStateStandbyToOff.bind(this),on:this.transitionFromStateStandbyToOn.bind(this)}};this.cameraManager=e!=null?e:g$1.instance();}static pickBestGuess(){return s.getOrCreate({position:"worldFacing",bestGuess:true})}static pickBestGuessForPosition(e){if(!a.availablePositions.includes(e))throw new Error(`Invalid camera position: "${e}"`);return s.getOrCreate({position:e})}static forDeviceId(e){return s.getOrCreate({deviceId:e})}static async getAll(e,t){return await d.getCameras(e!=null?e:false,t!=null?t:false),[...b.get()]}static getOrCreate(e){let{deviceId:t,position:a,bestGuess:i}=e,n=new s;return n._deviceId=t!=null?t:"",n.position=a!=null?a:"worldFacing",i&&n[a$1].markAsBestGuess(),b.getOrCreate(n)}static fromDeviceCamera(e){let t=new s;return t.position=e.position,t._deviceId=e.deviceId,t._label=e.label,t}get deviceId(){return this._deviceId}get label(){return this._label}get desiredState(){return this._desiredState}get settings(){return this._settings}get currentResolution(){var e;return (e=this._currentResolution)!=null?e:null}setDeviceId(e){this._deviceId=e;}setLabel(e){this._label=e;}get context(){return this._context}set context(e){this._context=e,this._context&&this.currentState==="on"&&this.startSendingCapturesToWorker();}get currentState(){return this._currentState}async switchToDesiredState(e){var t,a;if(this.currentTransitionStrategyPromise&&await this.currentTransitionStrategyPromise,this._notFoundOnDevice&&(e==="on"||e==="standby"))throw new a$2({message:`Cannot switch state to ${e}. This camera could not be mapped to a detected camera on the device. Please use another camera and delete this one.`,name:"Unmapped Camera"});return this.currentTransitionStrategyPromise=(a=(t=this.stateTransitionStrategyMap[this.currentState])==null?void 0:t[e])==null?void 0:a.call(t).catch(i=>{if(i instanceof DOMException&&i.message==="The associated Track is in an invalid state"){a$3.log(a$3.Level.Warn,i);return}throw i}),this.currentTransitionStrategyPromise}getDesiredTorchState(){return this._desiredTorchState}async setDesiredTorchState(e){this._desiredTorchState=e,await this.cameraManager.setTorchEnabled(this._desiredTorchState==="on"),await this.notifyContext({type:"torchState",newValue:this._desiredTorchState});}async isTorchAvailable(){return this.cameraManager.isTorchAvailable()}addListener(e){e!=null&&(this.listeners.includes(e)||this.listeners.push(e));}removeListener(e){e!=null&&this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}addZoomListener(e){this.zoomListeners.add(e);}removeZoomListener(e){this.zoomListeners.delete(e);}isZoomAvailable(){var e;return ((e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom)!=null}async getZoomRange(){var t,a,i;await this.cameraManager.waitForCapabilities();let e=(t=this.cameraManager.mediaTrackCapabilities)==null?void 0:t.zoom;return e?{min:(a=e.min)!=null?a:null,max:(i=e.max)!=null?i:null}:null}async setZoomFactor(e){let t=this._settings.zoomFactor;this._settings.zoomFactor=e,t!==e&&((this._currentState==="on"||this._currentState==="standby")&&await this.cameraManager.setZoom(e),this.notifyZoomListeners(t,e)),await this.notifyContext({type:"cameraSettings",newValue:this._settings});}async applySettings(e){var n;let t=this._settings.zoomFactor,a=this._settings.zoomLevels;this._settings=new g(e);let i=this.settings.getProperty("grayScaleFrameReader");if(this.cameraManager.setFrameReaderType(i===true?"GRAYSCALE":"RGBA"),this.currentState==="on"||this.currentState==="standby"){let c=this.cameraManager.activeCameraSettings;(c==null?void 0:c.preferredResolution)!==this.settings.preferredResolution&&(await this.cameraManager.applyCameraSettings(this.settings),(n=this.cameraManager.activeCamera)!=null&&n.currentResolution&&(this._currentResolution={width:this.cameraManager.activeCamera.currentResolution.width,height:this.cameraManager.activeCamera.currentResolution.height})),await this.cameraManager.setZoom(this.settings.zoomFactor),t!==this.settings.zoomFactor&&this.notifyZoomListeners(t,this.settings.zoomFactor);let l=this.settings.getProperty("minFrameRate"),p=this.settings.getProperty("maxFrameRate");(l!=null||p!=null)&&await this.cameraManager.setFrameRate({min:l,max:p});let S=this.settings.getProperty("manualLensPosition");S!=null&&await this.cameraManager.setFocus(S);let g=this.settings.getProperty("exposureTargetBias"),f=this.settings.getProperty("exposureDuration");(g!=null||f!=null)&&await this.cameraManager.setExposure({compensation:g,time:f});}return this.notifyListenersOfZoomLevelChange(a,this.settings.zoomLevels),this.notifyContext({type:"cameraSettings",newValue:this.settings})}toJSONObject(){return {type:this.type,position:this.position,settings:this.settings.toJSONObject(),desiredState:this.desiredState,desiredTorchState:this._desiredTorchState}}getMirrorImageEnabled(){var e;return (e=this._desiredMirrorImageEnabled)!=null?e:this.cameraManager.isMirrorImageEnabled()}async setMirrorImageEnabled(e){this._desiredMirrorImageEnabled=e,this.cameraManager.setMirrorImageEnabled(e,true),this.context&&await this.context.setFrameSource(this);}getCurrentState(){return this._currentState}async setClipArea(e){await this.cameraManager.setClipArea(e);}async setCurrentState(e){if(e!==this._currentState){this._currentState=e,this.notifyListeners();try{await this.notifyContext({type:"frameSourceState",newValue:e}),e==="on"&&this.startSendingCapturesToWorker();}catch{a$3.warn("Error while notifying context about new state of Camera");}}}async setupCamera(){if(this.cameraManager.setSelectedCameraSettings(this.settings),this.deviceId==="")this.cameraManager.setSelectedCamera(),this.cameraManager.setInitialCameraPosition(this.position);else {let t=(await d.getCameras()).find(a=>a.deviceId===this.deviceId);t&&(this.cameraManager.setInitialCameraPosition(t.position),this.cameraManager.setSelectedCamera(t));}await this.cameraManager.setupCameras(),typeof this._desiredMirrorImageEnabled=="boolean"?this.cameraManager.setMirrorImageEnabled(this._desiredMirrorImageEnabled,true):this.cameraManager.setMirrorImageEnabled(this.cameraManager.isMirrorImageEnabled(),false),this.context&&await this.context.setFrameSource(this),this.cameraManager.activeCamera&&(b.rebindToDeviceId(this,{deviceId:this.cameraManager.activeCamera.deviceId,label:this.cameraManager.activeCamera.label,position:this.cameraManager.activeCamera.position}),this._currentResolution=this.cameraManager.activeCamera.currentResolution);}markAsUnmappedToDeviceCameras(){this._notFoundOnDevice=true;}resetUnmappedState(){this._notFoundOnDevice=false;}markAsBestGuess(){this._isBestGuess=true;}async notifyContext(e){if(this.context)return this.context.update([e])}notifyListeners(){for(let e of this.listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}updateCanvasVideoImage(){this.currentState==="on"&&this.context&&(this.cameraManager.updateCanvasVideoImage(),this._lastCanvasVideoPreviewAnimationFrame=this.cameraManager.requestVideoFrame(this.updateCanvasVideoImage.bind(this)));}async captureAndSend(){if(this.currentState!=="on"||!this.context)return;if(!this.context.hasEnabledMode()){this._lastCaptureRequestAnimationFrame=this.cameraManager.requestVideoFrame(this._captureAndSendBound);return}let e=null;try{e=this.cameraManager.captureImage();}catch(t){a$3.warn("Camera: error while capturing image.",t);}finally{if(e!=null)if(this.cameraManager.synchronousFrameHandling){let t=await this.context.sendFrameToProcessor(e);this.cameraManager.recycle(t.data);}else this.context.sendFrameToProcessor(e).then(t=>(this.cameraManager.recycle(t.data),null)).catch(t=>{a$3.warn("error while recycling uint8array",t);});this._lastCaptureRequestAnimationFrame=this.cameraManager.requestVideoFrame(this._captureAndSendBound);}}startSendingCapturesToWorker(){this.stopSendingCapturesToWorker(),this.captureAndSend();}stopSendingCapturesToWorker(){this._lastCanvasVideoPreviewAnimationFrame!=null&&this.cameraManager.cancelVideoFrame(this._lastCanvasVideoPreviewAnimationFrame),this._lastCaptureRequestAnimationFrame!=null&&this.cameraManager.cancelVideoFrame(this._lastCaptureRequestAnimationFrame);}async transitionFromStateOffToOn(){if(!(this.currentState==="on"||this.currentState==="starting"||this.currentState==="wakingUp")){this._desiredState="on",await this.setCurrentState("starting");try{await this.setupCamera(),await this.setCurrentState("on");}catch(e){throw a$3.log(a$3.Level.Error,e),await this.setCurrentState("off"),e}}}async transitionFromStateOffToStandby(){if(!(this.currentState==="standby"||this.currentState==="bootingUp"||this.currentState==="goingToSleep")){if(await this.isAndroidWebView()){a$3.log(a$3.Level.Warn,'Warning: "Standby" state does not work inside web views. Falling back to state "On".'),await this.transitionFromStateOffToOn();return}this._desiredState="standby",await this.setCurrentState("bootingUp");try{await this.setupCamera(),this.cameraManager.pauseStream(),await this.setCurrentState("standby");}catch(e){throw a$3.log(a$3.Level.Error,e),await this.setCurrentState("off"),e}await this.setCurrentState("standby"),await this.setDesiredTorchState("off");}}async transitionFromStateOnToOff(){this.currentState==="off"||this.currentState==="stopping"||(this._desiredState="off",await this.setCurrentState("stopping"),await this.cameraManager.stopStream(),await this.setCurrentState("off"),await this.setDesiredTorchState("off"));}async transitionFromStateOnToStandby(){if(!(this.currentState==="standby"||this.currentState==="bootingUp"||this.currentState==="goingToSleep")){if(await this.isAndroidWebView()){a$3.log(a$3.Level.Warn,'Warning: "Standby" state does not work inside web views. Falling back to state "Off".'),await this.transitionFromStateOnToOff();return}this._desiredState="standby",await this.setCurrentState("goingToSleep"),this.cameraManager.pauseStream(),await this.setCurrentState("standby"),await this.setDesiredTorchState("off");}}async transitionFromStateStandbyToOff(){this.currentState==="off"||this.currentState==="stopping"||(this._desiredState="off",await this.setCurrentState("shuttingDown"),await this.cameraManager.stopStream(),await this.setCurrentState("off"),await this.setDesiredTorchState("off"));}async transitionFromStateStandbyToOn(){this.currentState==="on"||this.currentState==="starting"||this.currentState==="wakingUp"||(this._desiredState="on",await this.setCurrentState("wakingUp"),this.cameraManager.resumeStream(),await this.setCurrentState("on"));}async isAndroidWebView(){return this._isAndroidWebView==null&&(this._isAndroidWebView=await b$1.isAndroidWebView()),this._isAndroidWebView}notifyZoomListeners(e,t){for(let a of this.zoomListeners)a.onZoomLevelChanged(this,e,t);}notifyListenersOfZoomLevelChange(e,t){var a;if(!a$4(e,t))for(let i of this.zoomListeners)(a=i.onZoomLevelsChanged)==null||a.call(i,this,t);}},h=s;export{h as a};
1
+ import {a as a$4}from'./chunk-4KLHTKGW.js';import {g as g$1}from'./chunk-T6EVGEHJ.js';import {d}from'./chunk-5GUWY76Q.js';import {b}from'./chunk-7LTHFX4E.js';import {a as a$1}from'./chunk-LFJUGRQV.js';import {b as b$1}from'./chunk-AYYKQ7YB.js';import {a as a$3}from'./chunk-XR65N6EG.js';import {g}from'./chunk-D222MT4V.js';import {a}from'./chunk-U2WQ3WDE.js';import {a as a$2}from'./chunk-QCZSSQAQ.js';d.addVideoDevicesListener(O=>{b.integrateIncomingVideoDevices(O.map(e=>h.fromDeviceCamera(e)));});var F;F=a$1;var s=class s{constructor(e){this._label="";this._deviceId="";this._notFoundOnDevice=false;this._isBestGuess=false;this.type="camera";this._currentState="off";this._settings=new g;this._desiredTorchState="off";this._desiredState="off";this.listeners=[];this.zoomListeners=new Set;this._context=null;this[F]={markAsUnmappedToDeviceCameras:this.markAsUnmappedToDeviceCameras.bind(this),resetUnmappedState:this.resetUnmappedState.bind(this),setDeviceId:this.setDeviceId.bind(this),setLabel:this.setLabel.bind(this),markAsBestGuess:this.markAsBestGuess.bind(this)};this._captureAndSendBound=this.captureAndSend.bind(this);this.stateTransitionStrategyMap={off:{on:this.transitionFromStateOffToOn.bind(this),standby:this.transitionFromStateOffToStandby.bind(this)},on:{off:this.transitionFromStateOnToOff.bind(this),standby:this.transitionFromStateOnToStandby.bind(this)},standby:{off:this.transitionFromStateStandbyToOff.bind(this),on:this.transitionFromStateStandbyToOn.bind(this)}};this.cameraManager=e!=null?e:g$1.instance();}static pickBestGuess(){return s.getOrCreate({position:"worldFacing",bestGuess:true})}static pickBestGuessForPosition(e){if(!a.availablePositions.includes(e))throw new Error(`Invalid camera position: "${e}"`);return s.getOrCreate({position:e})}static forDeviceId(e){return s.getOrCreate({deviceId:e})}static async getAll(e,t){return await d.getCameras(e!=null?e:false,t!=null?t:false),[...b.get()]}static getOrCreate(e){let{deviceId:t,position:a,bestGuess:i}=e,n=new s;return n._deviceId=t!=null?t:"",n.position=a!=null?a:"worldFacing",i&&n[a$1].markAsBestGuess(),b.getOrCreate(n)}static fromDeviceCamera(e){let t=new s;return t.position=e.position,t._deviceId=e.deviceId,t._label=e.label,t}get deviceId(){return this._deviceId}get label(){return this._label}get desiredState(){return this._desiredState}get settings(){return this._settings}get currentResolution(){var e;return (e=this._currentResolution)!=null?e:null}setDeviceId(e){this._deviceId=e;}setLabel(e){this._label=e;}get context(){return this._context}set context(e){this._context=e,this._context&&this.currentState==="on"&&this.startSendingCapturesToWorker();}get currentState(){return this._currentState}async switchToDesiredState(e){var t,a;if(this.currentTransitionStrategyPromise&&await this.currentTransitionStrategyPromise,this._notFoundOnDevice&&(e==="on"||e==="standby"))throw new a$2({message:`Cannot switch state to ${e}. This camera could not be mapped to a detected camera on the device. Please use another camera and delete this one.`,name:"Unmapped Camera"});return this.currentTransitionStrategyPromise=(a=(t=this.stateTransitionStrategyMap[this.currentState])==null?void 0:t[e])==null?void 0:a.call(t).catch(i=>{if(i instanceof DOMException&&i.message==="The associated Track is in an invalid state"){a$3.log(a$3.Level.Warn,i);return}throw i}),this.currentTransitionStrategyPromise}getDesiredTorchState(){return this._desiredTorchState}async setDesiredTorchState(e){this._desiredTorchState=e,await this.cameraManager.setTorchEnabled(this._desiredTorchState==="on"),await this.notifyContext({type:"torchState",newValue:this._desiredTorchState});}async isTorchAvailable(){return this.cameraManager.isTorchAvailable()}addListener(e){e!=null&&(this.listeners.includes(e)||this.listeners.push(e));}removeListener(e){e!=null&&this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}addZoomListener(e){this.zoomListeners.add(e);}removeZoomListener(e){this.zoomListeners.delete(e);}isZoomAvailable(){var e;return ((e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom)!=null}async getZoomRange(){var t,a,i;await this.cameraManager.waitForCapabilities();let e=(t=this.cameraManager.mediaTrackCapabilities)==null?void 0:t.zoom;return e?{min:(a=e.min)!=null?a:null,max:(i=e.max)!=null?i:null}:null}async setZoomFactor(e){let t=this._settings.zoomFactor;this._settings.zoomFactor=e,t!==e&&((this._currentState==="on"||this._currentState==="standby")&&await this.cameraManager.setZoom(e),this.notifyZoomListeners(t,e)),await this.notifyContext({type:"cameraSettings",newValue:this._settings});}async applySettings(e){var n;let t=this._settings.zoomFactor,a=this._settings.zoomLevels;this._settings=new g(e);let i=this.settings.getProperty("grayScaleFrameReader");if(this.cameraManager.setFrameReaderType(i===true?"GRAYSCALE":"RGBA"),this.currentState==="on"||this.currentState==="standby"){let c=this.cameraManager.activeCameraSettings;(c==null?void 0:c.preferredResolution)!==this.settings.preferredResolution&&(await this.cameraManager.applyCameraSettings(this.settings),(n=this.cameraManager.activeCamera)!=null&&n.currentResolution&&(this._currentResolution={width:this.cameraManager.activeCamera.currentResolution.width,height:this.cameraManager.activeCamera.currentResolution.height})),await this.cameraManager.setZoom(this.settings.zoomFactor),t!==this.settings.zoomFactor&&this.notifyZoomListeners(t,this.settings.zoomFactor);let l=this.settings.getProperty("minFrameRate"),p=this.settings.getProperty("maxFrameRate");(l!=null||p!=null)&&await this.cameraManager.setFrameRate({min:l,max:p});let S=this.settings.getProperty("manualLensPosition");S!=null&&await this.cameraManager.setFocus(S);let g=this.settings.getProperty("exposureTargetBias"),f=this.settings.getProperty("exposureDuration");(g!=null||f!=null)&&await this.cameraManager.setExposure({compensation:g,time:f});}return this.notifyListenersOfZoomLevelChange(a,this.settings.zoomLevels),this.notifyContext({type:"cameraSettings",newValue:this.settings})}toJSONObject(){return {type:this.type,position:this.position,settings:this.settings.toJSONObject(),desiredState:this.desiredState,desiredTorchState:this._desiredTorchState}}getMirrorImageEnabled(){var e;return (e=this._desiredMirrorImageEnabled)!=null?e:this.cameraManager.isMirrorImageEnabled()}async setMirrorImageEnabled(e){this._desiredMirrorImageEnabled=e,this.cameraManager.setMirrorImageEnabled(e,true),this.context&&await this.context.setFrameSource(this);}getCurrentState(){return this._currentState}async setClipArea(e){await this.cameraManager.setClipArea(e);}async setCurrentState(e){if(e!==this._currentState){this._currentState=e,this.notifyListeners();try{await this.notifyContext({type:"frameSourceState",newValue:e}),e==="on"&&this.startSendingCapturesToWorker();}catch{a$3.warn("Error while notifying context about new state of Camera");}}}async setupCamera(){if(this.cameraManager.setSelectedCameraSettings(this.settings),this.deviceId==="")this.cameraManager.setSelectedCamera(),this.cameraManager.setInitialCameraPosition(this.position);else {let t=(await d.getCameras()).find(a=>a.deviceId===this.deviceId);t&&(this.cameraManager.setInitialCameraPosition(t.position),this.cameraManager.setSelectedCamera(t));}await this.cameraManager.setupCameras(),typeof this._desiredMirrorImageEnabled=="boolean"?this.cameraManager.setMirrorImageEnabled(this._desiredMirrorImageEnabled,true):this.cameraManager.setMirrorImageEnabled(this.cameraManager.isMirrorImageEnabled(),false),this.context&&await this.context.setFrameSource(this),this.cameraManager.activeCamera&&(b.rebindToDeviceId(this,{deviceId:this.cameraManager.activeCamera.deviceId,label:this.cameraManager.activeCamera.label,position:this.cameraManager.activeCamera.position}),this._currentResolution=this.cameraManager.activeCamera.currentResolution);}markAsUnmappedToDeviceCameras(){this._notFoundOnDevice=true;}resetUnmappedState(){this._notFoundOnDevice=false;}markAsBestGuess(){this._isBestGuess=true;}async notifyContext(e){if(this.context)return this.context.update([e])}notifyListeners(){for(let e of this.listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}updateCanvasVideoImage(){this.currentState==="on"&&this.context&&(this.cameraManager.updateCanvasVideoImage(),this._lastCanvasVideoPreviewAnimationFrame=this.cameraManager.requestVideoFrame(this.updateCanvasVideoImage.bind(this)));}async captureAndSend(){if(this.currentState!=="on"||!this.context)return;if(!this.context.hasEnabledMode()){this._lastCaptureRequestAnimationFrame=this.cameraManager.requestVideoFrame(this._captureAndSendBound);return}let e=null;try{e=this.cameraManager.captureImage();}catch(t){a$3.warn("Camera: error while capturing image.",t);}finally{if(e!=null)if(this.cameraManager.synchronousFrameHandling){let t=await this.context.sendFrameToProcessor(e);this.cameraManager.recycle(t.data);}else this.context.sendFrameToProcessor(e).then(t=>(this.cameraManager.recycle(t.data),null)).catch(t=>{a$3.warn("error while recycling uint8array",t);});this._lastCaptureRequestAnimationFrame=this.cameraManager.requestVideoFrame(this._captureAndSendBound);}}startSendingCapturesToWorker(){this.stopSendingCapturesToWorker(),this.captureAndSend();}stopSendingCapturesToWorker(){this._lastCanvasVideoPreviewAnimationFrame!=null&&this.cameraManager.cancelVideoFrame(this._lastCanvasVideoPreviewAnimationFrame),this._lastCaptureRequestAnimationFrame!=null&&this.cameraManager.cancelVideoFrame(this._lastCaptureRequestAnimationFrame);}async transitionFromStateOffToOn(){if(!(this.currentState==="on"||this.currentState==="starting"||this.currentState==="wakingUp")){this._desiredState="on",await this.setCurrentState("starting");try{await this.setupCamera(),await this.setCurrentState("on");}catch(e){throw a$3.log(a$3.Level.Error,e),await this.setCurrentState("off"),e}}}async transitionFromStateOffToStandby(){if(!(this.currentState==="standby"||this.currentState==="bootingUp"||this.currentState==="goingToSleep")){if(await this.isAndroidWebView()){a$3.log(a$3.Level.Warn,'Warning: "Standby" state does not work inside web views. Falling back to state "On".'),await this.transitionFromStateOffToOn();return}this._desiredState="standby",await this.setCurrentState("bootingUp");try{await this.setupCamera(),this.cameraManager.pauseStream(),await this.setCurrentState("standby");}catch(e){throw a$3.log(a$3.Level.Error,e),await this.setCurrentState("off"),e}await this.setCurrentState("standby"),await this.setDesiredTorchState("off");}}async transitionFromStateOnToOff(){this.currentState==="off"||this.currentState==="stopping"||(this._desiredState="off",await this.setCurrentState("stopping"),await this.cameraManager.stopStream(),await this.setCurrentState("off"),await this.setDesiredTorchState("off"));}async transitionFromStateOnToStandby(){if(!(this.currentState==="standby"||this.currentState==="bootingUp"||this.currentState==="goingToSleep")){if(await this.isAndroidWebView()){a$3.log(a$3.Level.Warn,'Warning: "Standby" state does not work inside web views. Falling back to state "Off".'),await this.transitionFromStateOnToOff();return}this._desiredState="standby",await this.setCurrentState("goingToSleep"),this.cameraManager.pauseStream(),await this.setCurrentState("standby"),await this.setDesiredTorchState("off");}}async transitionFromStateStandbyToOff(){this.currentState==="off"||this.currentState==="stopping"||(this._desiredState="off",await this.setCurrentState("shuttingDown"),await this.cameraManager.stopStream(),await this.setCurrentState("off"),await this.setDesiredTorchState("off"));}async transitionFromStateStandbyToOn(){this.currentState==="on"||this.currentState==="starting"||this.currentState==="wakingUp"||(this._desiredState="on",await this.setCurrentState("wakingUp"),this.cameraManager.resumeStream(),await this.setCurrentState("on"));}async isAndroidWebView(){return this._isAndroidWebView==null&&(this._isAndroidWebView=await b$1.isAndroidWebView()),this._isAndroidWebView}notifyZoomListeners(e,t){for(let a of this.zoomListeners)a.onZoomLevelChanged(this,e,t);}notifyListenersOfZoomLevelChange(e,t){var a;if(!a$4(e,t))for(let i of this.zoomListeners)(a=i.onZoomLevelsChanged)==null||a.call(i,this,t);}},h=s;export{h as a};
@@ -1 +1 @@
1
- import {a}from'./chunk-GMOTHEWV.js';import {d}from'./chunk-YUZDO2PC.js';import {f,g}from'./chunk-D222MT4V.js';var u=class{constructor(){this.type="camera";this.customImages={idle:"",pressed:""};this.cameraSwitchButton=void 0;this.CameraSwitchButtonClass=void 0;this.currentFrameSource=null;this.view=void 0;this.onCameraSwitched=this.handleCameraSwitched.bind(this);this.isTransitioning=false;}get idleImage(){return this.customImages.idle}set idleImage(t){this.customImages.idle=t,this.applyCustomImagesToButton();}get pressedImage(){return this.customImages.pressed}set pressedImage(t){this.customImages.pressed=t,this.applyCustomImagesToButton();}toJSONObject(){return {type:this.type}}async install(t){var i,r,s;this.CameraSwitchButtonClass||(this.CameraSwitchButtonClass=await import('../private/ui/molecules/CameraSwitchButton.js').then(l=>l.CameraSwitchButton),(i=this.CameraSwitchButtonClass)==null||i.register()),this.view=t,this.currentFrameSource=(s=(r=t.getContext())==null?void 0:r.frameSource)!=null?s:null,this.cameraSwitchButton=this.CameraSwitchButtonClass.create(),this.cameraSwitchButton.slot="topRight",this.cameraSwitchButton.hidden=true,this.cameraSwitchButton.addEventListener("camera-switched",this.onCameraSwitched);let e=t.controlsElement;e&&e.append(this.cameraSwitchButton),this.applyCustomImagesToButton();let a=await this.canShow();return this.updateButtonVisibility(a),true}remove(t){t&&this.cameraSwitchButton&&(this.cameraSwitchButton.removeEventListener("camera-switched",this.onCameraSwitched),this.cameraSwitchButton.remove(),this.cameraSwitchButton=null,this.currentFrameSource=null,this.view=void 0);}async update(t){var a,i;this.currentFrameSource=(i=(a=t.getContext())==null?void 0:a.frameSource)!=null?i:null,this.view=t;let e=await this.canShow();this.updateButtonVisibility(e);}updateButtonVisibility(t){this.cameraSwitchButton&&(this.cameraSwitchButton.hidden=!t);}applyCustomImagesToButton(){if(!this.cameraSwitchButton)return;this.customImages.idle||this.customImages.pressed?this.cameraSwitchButton.setCustomImages(this.customImages):this.cameraSwitchButton.useCustomImages=false;}async canShow(){if(!f(this.currentFrameSource)||this.currentFrameSource.getCurrentState()!=="on")return false;try{return (await d.getCameras(false,true)).length>1}catch{return false}}handleCameraSwitched(t){let{currentMode:e}=t.detail,a=e==="back"?"front":"back";this.cameraSwitchButton.mode=a,this.handleCameraSwitch();}async handleCameraSwitch(){if(this.isTransitioning)return;let t=await this.getNextDeviceCamera();t&&await this.switchCameras(t);}async getNextDeviceCamera(){var r;let t=await a.getAll(false,true),e=this.currentFrameSource?this.currentFrameSource:null,a$1=e==null?void 0:e.deviceId,i=t.findIndex(s=>s.deviceId===a$1);return i>-1?(r=t[i+1])!=null?r:t[0]:t.length>0?t[0]:null}async switchCameras(t){var s;this.isTransitioning=true;let e=(s=this.view)==null?void 0:s.getContext(),a=e==null?void 0:e.frameSource,i,r;a!=null&&(i=new g(a.settings),r=a.desiredState),await(a==null?void 0:a.switchToDesiredState("off")),i!=null&&await t.applySettings(i),await(e==null?void 0:e.setFrameSource(t)),await(e==null?void 0:e.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}};export{u as a};
1
+ import {a}from'./chunk-QRMHTQBG.js';import {d}from'./chunk-5GUWY76Q.js';import {f,g}from'./chunk-D222MT4V.js';var u=class{constructor(){this.type="camera";this.customImages={idle:"",pressed:""};this.cameraSwitchButton=void 0;this.CameraSwitchButtonClass=void 0;this.currentFrameSource=null;this.view=void 0;this.onCameraSwitched=this.handleCameraSwitched.bind(this);this.isTransitioning=false;}get idleImage(){return this.customImages.idle}set idleImage(t){this.customImages.idle=t,this.applyCustomImagesToButton();}get pressedImage(){return this.customImages.pressed}set pressedImage(t){this.customImages.pressed=t,this.applyCustomImagesToButton();}toJSONObject(){return {type:this.type}}async install(t){var i,r,s;this.CameraSwitchButtonClass||(this.CameraSwitchButtonClass=await import('../private/ui/molecules/CameraSwitchButton.js').then(l=>l.CameraSwitchButton),(i=this.CameraSwitchButtonClass)==null||i.register()),this.view=t,this.currentFrameSource=(s=(r=t.getContext())==null?void 0:r.frameSource)!=null?s:null,this.cameraSwitchButton=this.CameraSwitchButtonClass.create(),this.cameraSwitchButton.slot="topRight",this.cameraSwitchButton.hidden=true,this.cameraSwitchButton.addEventListener("camera-switched",this.onCameraSwitched);let e=t.controlsElement;e&&e.append(this.cameraSwitchButton),this.applyCustomImagesToButton();let a=await this.canShow();return this.updateButtonVisibility(a),true}remove(t){t&&this.cameraSwitchButton&&(this.cameraSwitchButton.removeEventListener("camera-switched",this.onCameraSwitched),this.cameraSwitchButton.remove(),this.cameraSwitchButton=null,this.currentFrameSource=null,this.view=void 0);}async update(t){var a,i;this.currentFrameSource=(i=(a=t.getContext())==null?void 0:a.frameSource)!=null?i:null,this.view=t;let e=await this.canShow();this.updateButtonVisibility(e);}updateButtonVisibility(t){this.cameraSwitchButton&&(this.cameraSwitchButton.hidden=!t);}applyCustomImagesToButton(){if(!this.cameraSwitchButton)return;this.customImages.idle||this.customImages.pressed?this.cameraSwitchButton.setCustomImages(this.customImages):this.cameraSwitchButton.useCustomImages=false;}async canShow(){if(!f(this.currentFrameSource)||this.currentFrameSource.getCurrentState()!=="on")return false;try{return (await d.getCameras(false,true)).length>1}catch{return false}}handleCameraSwitched(t){let{currentMode:e}=t.detail,a=e==="back"?"front":"back";this.cameraSwitchButton.mode=a,this.handleCameraSwitch();}async handleCameraSwitch(){if(this.isTransitioning)return;let t=await this.getNextDeviceCamera();t&&await this.switchCameras(t);}async getNextDeviceCamera(){var r;let t=await a.getAll(false,true),e=this.currentFrameSource?this.currentFrameSource:null,a$1=e==null?void 0:e.deviceId,i=t.findIndex(s=>s.deviceId===a$1);return i>-1?(r=t[i+1])!=null?r:t[0]:t.length>0?t[0]:null}async switchCameras(t){var s;this.isTransitioning=true;let e=(s=this.view)==null?void 0:s.getContext(),a=e==null?void 0:e.frameSource,i,r;a!=null&&(i=new g(a.settings),r=a.desiredState),await(a==null?void 0:a.switchToDesiredState("off")),i!=null&&await t.applySettings(i),await(e==null?void 0:e.setFrameSource(t)),await(e==null?void 0:e.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}};export{u as a};
@@ -1 +1 @@
1
- import {b}from'./chunk-YONR3EGV.js';import {a as a$1}from'./chunk-KXAJHLEO.js';import {a}from'./chunk-XR65N6EG.js';var p=class u{constructor(e){this.workerCommandId=1;this.workerTasks=new Map;this.workerListeners=[];var r;this.libraryLocation=e.libraryLocation,this.workerMessageListener=this.onWorkerMessage.bind(this),this.dataCaptureWorker.addEventListener("message",this.workerMessageListener),this.verifyResponseHash=e.verifyResponseHash,this.highEndBlurryRecognition=(r=e.highEndBlurryRecognition)!=null?r:false,this.simdSupport=e.simdSupport,this.threadsSupport=e.threadsSupport,typeof e.loadProgressNotifier=="function"&&this.addWorkerListener(t=>{var o;t.type==="loadLibraryProgress"&&((o=e.loadProgressNotifier)==null||o.call(e,t.payload));});}get dataCaptureWorker(){return (this._dataCaptureWorker)!=null||(this._dataCaptureWorker=(void 0)),this._dataCaptureWorker}get name(){return "CoreLoader"}get fixedWasmMemory(){return this.threadsSupport&&b.isFixedMemoryRequired()?300:null}static async create(e){var t;let r=new u(e);return await r.workerCommand("setLogLevel",{level:(t=e.logLevel)!=null?t:a.Level.Debug}),await r.load(),r}getIndexedDBTimeoutMs(){var t;let e=a$1.getInstanceFor("localStorage"),r=Number.parseInt((t=e.getItem("IndexedDBBlockedTimeoutMs"))!=null?t:"1500",10);return Number.isNaN(r)&&(r=1500),r}async load(){var e;try{await this.workerCommand("loadLibrary",{libraryLocation:this.libraryLocation,locationPath:window.location.pathname,referredOrigin:window.location.origin,writableDataPathOverride:(e=a$1.getInstanceFor("localStorage").getItem("scanditWritableDataPathOverride"))!=null?e:void 0,indexedDBTimeoutMs:this.getIndexedDBTimeoutMs(),verifyResponseHash:this.verifyResponseHash,fixedWasmMemory:this.fixedWasmMemory,simdSupport:this.simdSupport,threadsSupport:this.threadsSupport});}catch(r){if(r!=null&&typeof r=="object"&&typeof r.error=="string"&&r.error.includes("BlockedIndexedDB"))return await this.terminateDataCaptureWorker(false),this.dataCaptureWorker.addEventListener("message",this.workerMessageListener),a$1.getInstanceFor("localStorage").setItem("scanditWritableDataPathOverride",`/scandit_sync_folder_${[...crypto.getRandomValues(new Uint32Array(2))].map(o=>o.toString(32)).join("")}`),this.load();throw r}}async workerCommand(e,r,t){return new Promise((o,i)=>{let a=this.workerCommandId++;this.workerTasks.set(a,{resolve:o,reject:i,command:e});let l={...r,command:e,id:a};this.dataCaptureWorker.postMessage(l,t);})}async terminateDataCaptureWorker(e=true){var r,t;e&&await this.workerCommand("dispose",{}),(r=this._dataCaptureWorker)==null||r.removeEventListener("message",this.workerMessageListener),(t=this._dataCaptureWorker)==null||t.terminate(),this._dataCaptureWorker=void 0;}addWorkerListener(e){this.workerListeners.push(e);}removeWorkerListener(e){this.workerListeners.includes(e)&&this.workerListeners.splice(this.workerListeners.indexOf(e),1);}getOptions(){return {libraryLocation:this.libraryLocation,simdSupport:this.simdSupport,threadsSupport:this.threadsSupport,verifyResponseHash:this.verifyResponseHash}}onWorkerMessage(e){let r=e.data;if(r.type==="workerTaskId"&&typeof r.id=="number"){let{id:t,error:o,payload:i}=r,a=this.workerTasks.get(t);o==null?a==null||a.resolve(i):a==null||a.reject(r),this.workerTasks.delete(t);}else for(let t of this.workerListeners)t(r);}};export{p as a};
1
+ import {b}from'./chunk-AYYKQ7YB.js';import {a as a$1}from'./chunk-KXAJHLEO.js';import {a}from'./chunk-XR65N6EG.js';var p=class u{constructor(e){this.workerCommandId=1;this.workerTasks=new Map;this.workerListeners=[];var r;this.libraryLocation=e.libraryLocation,this.workerMessageListener=this.onWorkerMessage.bind(this),this.dataCaptureWorker.addEventListener("message",this.workerMessageListener),this.verifyResponseHash=e.verifyResponseHash,this.highEndBlurryRecognition=(r=e.highEndBlurryRecognition)!=null?r:false,this.simdSupport=e.simdSupport,this.threadsSupport=e.threadsSupport,typeof e.loadProgressNotifier=="function"&&this.addWorkerListener(t=>{var o;t.type==="loadLibraryProgress"&&((o=e.loadProgressNotifier)==null||o.call(e,t.payload));});}get dataCaptureWorker(){return (this._dataCaptureWorker)!=null||(this._dataCaptureWorker=(void 0)),this._dataCaptureWorker}get name(){return "CoreLoader"}get fixedWasmMemory(){return this.threadsSupport&&b.isFixedMemoryRequired()?300:null}static async create(e){var t;let r=new u(e);return await r.workerCommand("setLogLevel",{level:(t=e.logLevel)!=null?t:a.Level.Debug}),await r.load(),r}getIndexedDBTimeoutMs(){var t;let e=a$1.getInstanceFor("localStorage"),r=Number.parseInt((t=e.getItem("IndexedDBBlockedTimeoutMs"))!=null?t:"1500",10);return Number.isNaN(r)&&(r=1500),r}async load(){var e;try{await this.workerCommand("loadLibrary",{libraryLocation:this.libraryLocation,locationPath:window.location.pathname,referredOrigin:window.location.origin,writableDataPathOverride:(e=a$1.getInstanceFor("localStorage").getItem("scanditWritableDataPathOverride"))!=null?e:void 0,indexedDBTimeoutMs:this.getIndexedDBTimeoutMs(),verifyResponseHash:this.verifyResponseHash,fixedWasmMemory:this.fixedWasmMemory,simdSupport:this.simdSupport,threadsSupport:this.threadsSupport});}catch(r){if(r!=null&&typeof r=="object"&&typeof r.error=="string"&&r.error.includes("BlockedIndexedDB"))return await this.terminateDataCaptureWorker(false),this.dataCaptureWorker.addEventListener("message",this.workerMessageListener),a$1.getInstanceFor("localStorage").setItem("scanditWritableDataPathOverride",`/scandit_sync_folder_${[...crypto.getRandomValues(new Uint32Array(2))].map(o=>o.toString(32)).join("")}`),this.load();throw r}}async workerCommand(e,r,t){return new Promise((o,i)=>{let a=this.workerCommandId++;this.workerTasks.set(a,{resolve:o,reject:i,command:e});let l={...r,command:e,id:a};this.dataCaptureWorker.postMessage(l,t);})}async terminateDataCaptureWorker(e=true){var r,t;e&&await this.workerCommand("dispose",{}),(r=this._dataCaptureWorker)==null||r.removeEventListener("message",this.workerMessageListener),(t=this._dataCaptureWorker)==null||t.terminate(),this._dataCaptureWorker=void 0;}addWorkerListener(e){this.workerListeners.push(e);}removeWorkerListener(e){this.workerListeners.includes(e)&&this.workerListeners.splice(this.workerListeners.indexOf(e),1);}getOptions(){return {libraryLocation:this.libraryLocation,simdSupport:this.simdSupport,threadsSupport:this.threadsSupport,verifyResponseHash:this.verifyResponseHash}}onWorkerMessage(e){let r=e.data;if(r.type==="workerTaskId"&&typeof r.id=="number"){let{id:t,error:o,payload:i}=r,a=this.workerTasks.get(t);o==null?a==null||a.resolve(i):a==null||a.reject(r),this.workerTasks.delete(t);}else for(let t of this.workerListeners)t(r);}};export{p as a};
@@ -1 +1 @@
1
- import {a}from'./chunk-R6SUMD5F.js';import {b}from'./chunk-YONR3EGV.js';var n=class e{constructor(t,o=a.defaultVibrationPattern){this.type=t,this.pattern=o;let r=b.getSupportedVibrationMethod();r&&(this._vibrate=r.bind(navigator));}static get defaultVibration(){return new e("default")}static withPattern(t){return new e("default",t)}toJSONObject(){return {type:this.type}}vibrate(){var t;return (t=this._vibrate)==null?void 0:t.call(this,this.pattern)}};export{n as a};
1
+ import {a}from'./chunk-R6SUMD5F.js';import {b}from'./chunk-AYYKQ7YB.js';var n=class e{constructor(t,o=a.defaultVibrationPattern){this.type=t,this.pattern=o;let r=b.getSupportedVibrationMethod();r&&(this._vibrate=r.bind(navigator));}static get defaultVibration(){return new e("default")}static withPattern(t){return new e("default",t)}toJSONObject(){return {type:this.type}}vibrate(){var t;return (t=this._vibrate)==null?void 0:t.call(this,this.pattern)}};export{n as a};
@@ -0,0 +1 @@
1
+ var e;(o=>{function i(){let r="8.4.1";return r}o.sdkVersion=i;})(e||(e={}));export{e as a};
@@ -1,4 +1,4 @@
1
- import {a as a$4}from'./chunk-3A7LM5JG.js';import {a as a$2}from'./chunk-QHBIT2WY.js';import {b,a as a$3}from'./chunk-SK6L34IF.js';import {a as a$6}from'./chunk-ZKROZLQ4.js';import {a}from'./chunk-NQF3GUK2.js';import {d}from'./chunk-YUZDO2PC.js';import {b as b$2}from'./chunk-7LTHFX4E.js';import {a as a$a}from'./chunk-KAFNKP6O.js';import {a as a$9}from'./chunk-E4XJ4GKD.js';import {a as a$b}from'./chunk-QOCHMKNY.js';import {b as b$4}from'./chunk-FTD535WI.js';import {a as a$5}from'./chunk-R6E4CT22.js';import {a as a$c}from'./chunk-4BP7D26M.js';import {b as b$1}from'./chunk-YONR3EGV.js';import {a as a$7,b as b$3}from'./chunk-CX2R2XQK.js';import {a as a$1}from'./chunk-XR65N6EG.js';import {a as a$8}from'./chunk-QCZSSQAQ.js';var z=`
1
+ import {a as a$4}from'./chunk-3A7LM5JG.js';import {a as a$2}from'./chunk-QHBIT2WY.js';import {b,a as a$3}from'./chunk-SK6L34IF.js';import {a}from'./chunk-NQF3GUK2.js';import {d}from'./chunk-5GUWY76Q.js';import {b as b$2}from'./chunk-7LTHFX4E.js';import {a as a$a}from'./chunk-KAFNKP6O.js';import {a as a$9}from'./chunk-E4XJ4GKD.js';import {a as a$b}from'./chunk-QOCHMKNY.js';import {a as a$6}from'./chunk-ZKROZLQ4.js';import {b as b$4}from'./chunk-FTD535WI.js';import {a as a$5}from'./chunk-R6E4CT22.js';import {a as a$c}from'./chunk-4BP7D26M.js';import {b as b$1}from'./chunk-AYYKQ7YB.js';import {a as a$7,b as b$3}from'./chunk-CX2R2XQK.js';import {a as a$1}from'./chunk-XR65N6EG.js';import {a as a$8}from'./chunk-QCZSSQAQ.js';var z=`
2
2
  attribute vec2 a_position;
3
3
  varying vec2 v_texcoord;
4
4
 
@@ -1 +1 @@
1
- import {c as c$1}from'./chunk-ZAXZRQYF.js';import {a}from'./chunk-LV6LGCDC.js';import {c,b}from'./chunk-Y3TODCJD.js';import {a as a$1}from'./chunk-SJIN27Q5.js';var i=new a,o=null;function m(){return o||(o=new c),o}function h(){var t,e;let u=c$1();for(let c of u)c.dispose();(t=a$1)==null||t(`\u{1F3B5} Disposed ${u.length} Howl instances`),i.reset(),o&&(o.dispose(),o=null),b().clear(),(e=a$1)==null||e("\u{1F3A7} Audio buffer cache cleared during disposal");}function k(){h();}function w(){var t;if(i.isSetupComplete()||typeof document>"u")return;i.markSetupComplete(),(t=a$1)==null||t("\u{1F3A7} Setting up audio unlock event listeners");let u=e=>{var l,s,r,a,d;(d=a$1)==null||d(`\u{1F446} User ${e.type} detected at (${(s=(l=e.touches)==null?void 0:l[0])==null?void 0:s.clientX}, ${(a=(r=e.touches)==null?void 0:r[0])==null?void 0:a.clientY}), unlocking audio...`),m().unlock(),i.reset();};i.setup(u);}export{m as a,h as b,k as c,w as d};
1
+ import {c as c$1}from'./chunk-ZAXZRQYF.js';import {a}from'./chunk-LV6LGCDC.js';import {c,b}from'./chunk-EPIUNYWM.js';import {a as a$1}from'./chunk-SJIN27Q5.js';var i=new a,o=null;function m(){return o||(o=new c),o}function h(){var t,e;let u=c$1();for(let c of u)c.dispose();(t=a$1)==null||t(`\u{1F3B5} Disposed ${u.length} Howl instances`),i.reset(),o&&(o.dispose(),o=null),b().clear(),(e=a$1)==null||e("\u{1F3A7} Audio buffer cache cleared during disposal");}function k(){h();}function w(){var t;if(i.isSetupComplete()||typeof document>"u")return;i.markSetupComplete(),(t=a$1)==null||t("\u{1F3A7} Setting up audio unlock event listeners");let u=e=>{var l,s,r,a,d;(d=a$1)==null||d(`\u{1F446} User ${e.type} detected at (${(s=(l=e.touches)==null?void 0:l[0])==null?void 0:s.clientX}, ${(a=(r=e.touches)==null?void 0:r[0])==null?void 0:a.clientY}), unlocking audio...`),m().unlock(),i.reset();};i.setup(u);}export{m as a,h as b,k as c,w as d};
@@ -1,6 +1,6 @@
1
- import {a as a$7}from'./chunk-Y7BTRVB4.js';import {a as a$4}from'./chunk-ACFJP5SR.js';import {a as a$a,c as c$3,b as b$3}from'./chunk-L66S4DN2.js';import {a as a$j}from'./chunk-BA3RP6L2.js';import {a as a$8}from'./chunk-AIC4H5KG.js';import {a as a$h}from'./chunk-KSCFPJAW.js';import {a as a$f}from'./chunk-W3X3ZRQZ.js';import {a as a$d}from'./chunk-JS3T7K2Z.js';import {b as b$2}from'./chunk-6H6FKGVE.js';import {a as a$c}from'./chunk-N5YZEC56.js';import {a as a$6}from'./chunk-VJB527QZ.js';import {a as a$5}from'./chunk-GHTCNOQN.js';import {a as a$1}from'./chunk-LXOZUOZU.js';import {a as a$g}from'./chunk-FGO2SSRS.js';import {c as c$1,a as a$e}from'./chunk-4LGQ66HW.js';import {g,e as e$1}from'./chunk-CA6FHIF6.js';import {a as a$9}from'./chunk-GPJEB376.js';import {a as a$k}from'./chunk-LFJUGRQV.js';import {b as b$1}from'./chunk-YONR3EGV.js';import {c as c$2,e}from'./chunk-SBC5K7IT.js';import {a as a$3}from'./chunk-XR65N6EG.js';import {f as f$1}from'./chunk-D222MT4V.js';import {a as a$i}from'./chunk-WUHKODFA.js';import {a as a$2}from'./chunk-7SW2PEHB.js';import {a as a$b}from'./chunk-QCZSSQAQ.js';import {c}from'./chunk-TR3NGINC.js';var Z=[{from:"unconfigured",to:"configuring"},{from:"configuring",to:"configured"},{from:"configuring",to:"unconfigured"},{from:"configured",to:"creating-context"},{from:"creating-context",to:"ready"},{from:"creating-context",to:"unconfigured"},{from:"ready",to:"unconfigured"},{from:"configured",to:"unconfigured"}];function v(C,e,t){let r=t.value;return t.value=function(...n){let i=f.stateMachine;return i.currentState==="ready"&&f.mainDataCaptureLoader!=null?r.apply(this,n):i.isInitializing||i.currentState==="configured"?i.waitForState("ready").then(()=>r.apply(this,n)):Promise.reject(new Error(`Please call DataCaptureContext.forLicenseKey() before calling ${String(e)}`))},t}function q(C){return C[a$j]!=null}function x(C){return "skipSerialization"in C||C[a$j]!=null}var _,Y,Q,X;X=a$k;var a=class a{constructor(){this._asyncImageConverterInstance=void 0;this.framework="web";this.runtimeEnvironment={deviceOS:(_=b$1.getUserAgentInfo().getOS().name)!=null?_:"",browser:(Y=b$1.getUserAgentInfo().getBrowser().name)!=null?Y:"",browserVersion:(Q=b$1.getUserAgentInfo().getBrowser().version)!=null?Q:"",get deviceModelName(){let{model:e,vendor:t}=b$1.getUserAgentInfo().getDevice();return (t==null||t==="")&&(t="Unknown"),(e==null||e==="")&&(e="Unknown"),[t,e].join(" ")}};this.settings=new a$2;this._frameSource=null;this._view=null;this.modes=new Set;this.components=[];this.listeners=[];this.updateListeners=new Set;this.cameraPropertiesReportListener=this.reportCameraProperties.bind(this);this.cameraAccessErrorListener=this.onCameraAccessError.bind(this);this.onWorkerMessageListener=this.onWorkerMessage.bind(this);this.onVisibilityChangeListener=this.onVisibilityChange.bind(this);this.batteryChangeListener=this.onBatteryChange.bind(this);this.pendingWorkerMessageListeners=new Set;this.delayedRegistration=false;this.highEndBlurryRecognition=false;this._frameHandlers=[];this._useSynchronousFrameFlow=false;this[X]={hasModes:this.hasModes.bind(this)};}static get moduleLicenseTextProviders(){return [new b]}static get sharedInstance(){return a._sharedInstance==null&&(a._sharedInstance=new a),a._sharedInstance}static get currentState(){return a.stateMachine.currentState}static get isReady(){return a.stateMachine.currentState==="ready"}static get isInitializing(){return a.stateMachine.isInitializing}static addStateListener(e){a.stateMachine.addListener(e);}static removeStateListener(e){a.stateMachine.removeListener(e);}async initializeWithOptions(e){var t,r,n,i,s,o,u,c,l;a.deviceID===""&&(a.deviceID=await b$1.getDeviceId()),this.licenseKey=(r=(t=e.licenseKey)!=null?t:a.userLicenseKey)!=null?r:"",this.deviceName=(n=e.deviceName)!=null?n:"",this.dataCaptureInstance=(i=e.dataCaptureInstance)!=null?i:a.mainDataCaptureLoader,this.delayedRegistration=(s=e.delayedRegistration)!=null?s:false,e.settings!=null&&(this.settings=e.settings),this.highEndBlurryRecognition=(l=(c=(o=e.dataCaptureInstance)==null?void 0:o.highEndBlurryRecognition)!=null?c:(u=a.mainDataCaptureLoader)==null?void 0:u.highEndBlurryRecognition)!=null?l:false;for(let S of this.pendingWorkerMessageListeners)this.dataCaptureInstance.addWorkerListener(S);this.pendingWorkerMessageListeners.clear(),this.settings!=null&&await this.applySettings(this.settings),await this.createContext();}get frameSource(){return this._frameSource}get workerCommand(){if(this.dataCaptureInstance==null)throw new Error("Cannot call workerCommand before dataCaptureInstance is set");return this.dataCaptureInstance.workerCommand.bind(this.dataCaptureInstance)}static async forLicenseKey(e,t){return a$3.debug(`forLicenseKey called, current state: ${a.stateMachine.currentState}`),a.stateMachine.currentState==="ready"?(a$3.debug("DataCaptureContext is already ready, returning existing instance"),a.sharedInstance):a.stateMachine.isInitializing?(a$3.debug("DataCaptureContext is already initializing, waiting for completion"),await a.stateMachine.waitForState("ready"),a.sharedInstance):(a.stateMachine.currentState==="unconfigured"&&(a$3.debug("Starting initialization from unconfigured state"),await a.stateMachine.executeAsyncTransition({targetState:"configuring",action:async()=>{await a.internalConfigure(e,t);},onSuccess:"configured",onError:"unconfigured"}),await a.stateMachine.executeAsyncTransition({targetState:"creating-context",action:async()=>{await a.sharedInstance.initializeWithOptions({licenseKey:e,deviceName:t.deviceName,settings:t.settings});},onSuccess:"ready",onError:"unconfigured"})),a.sharedInstance)}static async internalConfigure(e$1,t){var S;a$4(),c$1(),a$5.getInstance().updateIfMissing(a$6);let{forceAllPolyfills:r,overrideThreadsSupport:n,overrideSimdSupport:i}=a.getOverridesFromQueryString(),[s,o,u]=await Promise.all([a$7({forceAllPolyfills:r}),c$2(),e()]);n!=="auto"&&(a$3.warn(`Threads support override: was ${u} is now ${n==="on"}`),u=n==="on"),i!=="auto"&&(a$3.warn(`SIMD support override: was ${o} is now ${i==="on"}`),o=i==="on"),a.capabilityInfo={simdSupport:o,threadsSupport:u},a$3.debug(`Capability info detected - SIMD: ${o}, Threads: ${u}`),await a.validateOptions({...t,licenseKey:e$1});let c={licenseKey:e$1,libraryLocation:a$8(t.libraryLocation),moduleLoaders:t.moduleLoaders,logLevel:(S=t.logLevel)!=null?S:a$3.Level.Debug,verifyResponseHash:true,loadProgressNotifier:b$2.notify.bind(b$2),simdSupport:o,threadsSupport:u};a$3.setLevel(c.logLevel),a.userLicenseKey=c.licenseKey,a.libraryLocation=c.libraryLocation,b$2.subscribe(a.updateViewsWithProgress);let l=b$1.checkBrowserCompatibility();if(!l.fullSupport&&!l.scannerSupport)throw new a$9(l);b$1.isSupportedIOSVersion()||a$3.warn(`Warning: Minimum supported iOS version is 14.6.
1
+ import {a as a$7}from'./chunk-AYQTB54E.js';import {a as a$4}from'./chunk-ACFJP5SR.js';import {a as a$j}from'./chunk-BA3RP6L2.js';import {a as a$a,c as c$3,b as b$3}from'./chunk-ASAV77S2.js';import {a as a$8}from'./chunk-AIC4H5KG.js';import {a as a$h}from'./chunk-KSCFPJAW.js';import {a as a$f}from'./chunk-W3X3ZRQZ.js';import {a as a$d}from'./chunk-JS3T7K2Z.js';import {b as b$2}from'./chunk-6H6FKGVE.js';import {a as a$c}from'./chunk-N5YZEC56.js';import {a as a$6}from'./chunk-VJB527QZ.js';import {a as a$5}from'./chunk-GHTCNOQN.js';import {a as a$1}from'./chunk-LXOZUOZU.js';import {a as a$g}from'./chunk-FGO2SSRS.js';import {c as c$1,a as a$e}from'./chunk-IGTW3KDT.js';import {g,e as e$1}from'./chunk-T6EVGEHJ.js';import {a as a$9}from'./chunk-GPJEB376.js';import {a as a$k}from'./chunk-LFJUGRQV.js';import {b as b$1}from'./chunk-AYYKQ7YB.js';import {c as c$2,e}from'./chunk-SBC5K7IT.js';import {a as a$3}from'./chunk-XR65N6EG.js';import {f as f$1}from'./chunk-D222MT4V.js';import {a as a$i}from'./chunk-WUHKODFA.js';import {a as a$2}from'./chunk-7SW2PEHB.js';import {a as a$b}from'./chunk-QCZSSQAQ.js';import {c}from'./chunk-TR3NGINC.js';var Z=[{from:"unconfigured",to:"configuring"},{from:"configuring",to:"configured"},{from:"configuring",to:"unconfigured"},{from:"configured",to:"creating-context"},{from:"creating-context",to:"ready"},{from:"creating-context",to:"unconfigured"},{from:"ready",to:"unconfigured"},{from:"configured",to:"unconfigured"}];function v(C,e,t){let r=t.value;return t.value=function(...n){let i=f.stateMachine;return i.currentState==="ready"&&f.mainDataCaptureLoader!=null?r.apply(this,n):i.isInitializing||i.currentState==="configured"?i.waitForState("ready").then(()=>r.apply(this,n)):Promise.reject(new Error(`Please call DataCaptureContext.forLicenseKey() before calling ${String(e)}`))},t}function q(C){return C[a$j]!=null}function x(C){return "skipSerialization"in C||C[a$j]!=null}var _,Y,Q,X;X=a$k;var a=class a{constructor(){this._asyncImageConverterInstance=void 0;this.framework="web";this.runtimeEnvironment={deviceOS:(_=b$1.getUserAgentInfo().getOS().name)!=null?_:"",browser:(Y=b$1.getUserAgentInfo().getBrowser().name)!=null?Y:"",browserVersion:(Q=b$1.getUserAgentInfo().getBrowser().version)!=null?Q:"",get deviceModelName(){let{model:e,vendor:t}=b$1.getUserAgentInfo().getDevice();return (t==null||t==="")&&(t="Unknown"),(e==null||e==="")&&(e="Unknown"),[t,e].join(" ")}};this.settings=new a$2;this._frameSource=null;this._view=null;this.modes=new Set;this.components=[];this.listeners=[];this.updateListeners=new Set;this.cameraPropertiesReportListener=this.reportCameraProperties.bind(this);this.cameraAccessErrorListener=this.onCameraAccessError.bind(this);this.onWorkerMessageListener=this.onWorkerMessage.bind(this);this.onVisibilityChangeListener=this.onVisibilityChange.bind(this);this.batteryChangeListener=this.onBatteryChange.bind(this);this.pendingWorkerMessageListeners=new Set;this.delayedRegistration=false;this.highEndBlurryRecognition=false;this._frameHandlers=[];this._useSynchronousFrameFlow=false;this[X]={hasModes:this.hasModes.bind(this)};}static get moduleLicenseTextProviders(){return [new b]}static get sharedInstance(){return a._sharedInstance==null&&(a._sharedInstance=new a),a._sharedInstance}static get currentState(){return a.stateMachine.currentState}static get isReady(){return a.stateMachine.currentState==="ready"}static get isInitializing(){return a.stateMachine.isInitializing}static addStateListener(e){a.stateMachine.addListener(e);}static removeStateListener(e){a.stateMachine.removeListener(e);}async initializeWithOptions(e){var t,r,n,i,d,o,u,c,l;a.deviceID===""&&(a.deviceID=await b$1.getDeviceId()),this.licenseKey=(r=(t=e.licenseKey)!=null?t:a.userLicenseKey)!=null?r:"",this.deviceName=(n=e.deviceName)!=null?n:"",this.dataCaptureInstance=(i=e.dataCaptureInstance)!=null?i:a.mainDataCaptureLoader,this.delayedRegistration=(d=e.delayedRegistration)!=null?d:false,e.settings!=null&&(this.settings=e.settings),this.highEndBlurryRecognition=(l=(c=(o=e.dataCaptureInstance)==null?void 0:o.highEndBlurryRecognition)!=null?c:(u=a.mainDataCaptureLoader)==null?void 0:u.highEndBlurryRecognition)!=null?l:false;for(let S of this.pendingWorkerMessageListeners)this.dataCaptureInstance.addWorkerListener(S);this.pendingWorkerMessageListeners.clear(),this.settings!=null&&await this.applySettings(this.settings),await this.createContext();}get frameSource(){return this._frameSource}get workerCommand(){if(this.dataCaptureInstance==null)throw new Error("Cannot call workerCommand before dataCaptureInstance is set");return this.dataCaptureInstance.workerCommand.bind(this.dataCaptureInstance)}static async forLicenseKey(e,t){return a$3.debug(`forLicenseKey called, current state: ${a.stateMachine.currentState}`),a.stateMachine.currentState==="ready"?(a$3.debug("DataCaptureContext is already ready, returning existing instance"),a.sharedInstance):a.stateMachine.isInitializing?(a$3.debug("DataCaptureContext is already initializing, waiting for completion"),await a.stateMachine.waitForState("ready"),a.sharedInstance):(a.stateMachine.currentState==="unconfigured"&&(a$3.debug("Starting initialization from unconfigured state"),await a.stateMachine.executeAsyncTransition({targetState:"configuring",action:async()=>{await a.internalConfigure(e,t);},onSuccess:"configured",onError:"unconfigured"}),await a.stateMachine.executeAsyncTransition({targetState:"creating-context",action:async()=>{await a.sharedInstance.initializeWithOptions({licenseKey:e,deviceName:t.deviceName,settings:t.settings});},onSuccess:"ready",onError:"unconfigured"})),a.sharedInstance)}static async internalConfigure(e$1,t){var S;a$4(),c$1(),a$5.getInstance().updateIfMissing(a$6);let{forceAllPolyfills:r,overrideThreadsSupport:n,overrideSimdSupport:i}=a.getOverridesFromQueryString(),[d,o,u]=await Promise.all([a$7({forceAllPolyfills:r}),c$2(),e()]);n!=="auto"&&(a$3.warn(`Threads support override: was ${u} is now ${n==="on"}`),u=n==="on"),i!=="auto"&&(a$3.warn(`SIMD support override: was ${o} is now ${i==="on"}`),o=i==="on"),o&&b$1.isSIMDBroken()&&(a$3.warn("WebKit 26.x SIMD v128 corruption bug detected \u2014 disabling SIMD, using scalar WASM"),o=false),a.capabilityInfo={simdSupport:o,threadsSupport:u},a$3.debug(`Capability info detected - SIMD: ${o}, Threads: ${u}`),await a.validateOptions({...t,licenseKey:e$1});let c={licenseKey:e$1,libraryLocation:a$8(t.libraryLocation),moduleLoaders:t.moduleLoaders,logLevel:(S=t.logLevel)!=null?S:a$3.Level.Debug,verifyResponseHash:true,loadProgressNotifier:b$2.notify.bind(b$2),simdSupport:o,threadsSupport:u};a$3.setLevel(c.logLevel),a.userLicenseKey=c.licenseKey,a.libraryLocation=c.libraryLocation,b$2.subscribe(a.updateViewsWithProgress);let l=b$1.checkBrowserCompatibility();if(!l.fullSupport&&!l.scannerSupport)throw new a$9(l);b$1.isSupportedIOSVersion()||a$3.warn(`Warning: Minimum supported iOS version is 14.6.
2
2
  Please check the minimum system requirements here:
3
- https://docs.scandit.com/system-requirements#browser-compatibility`),a.dataCaptureLoaders=await a.loadModules(c.moduleLoaders,c),a.mainDataCaptureLoader=[...a.dataCaptureLoaders.entries()][0][1],b$2.unsubscribe(a.updateViewsWithProgress);}static async forLicenseKeyInElectronPath(e,t){if(!a$a())throw new a$b({name:"MisconfigurationError",message:"forLicenseKeyInElectronPath can only be used in Electron applications"});let r=await c$3({licenseDataPath:e});if(r==null)throw new a$b({name:"NoLicenseKeyError",message:`Cannot retrieve license key for Electron app at ${e}`});return a.forLicenseKey(r.licenseKey,{...t})}static updateViewsWithProgress({percentage:e}){for(let t of a$c.values())t.setProgressBarPercentage(e);}static getOverridesFromQueryString(){var s,o,u;function e(c){return ["auto","off","on"].includes(c)}let t=new URLSearchParams(window.location.search),[r="auto",n="auto",i=false]=[(s=t.get("pthreads"))==null?void 0:s.toLowerCase(),(o=t.get("simd"))==null?void 0:o.toLowerCase(),((u=t.get("forceAllPolyfills"))==null?void 0:u.toLowerCase())==="true"];return {overrideThreadsSupport:e(r)?r:"auto",overrideSimdSupport:e(n)?n:"auto",forceAllPolyfills:i}}static async validateOptions(e){if(e.licenseKey==null||e.licenseKey.trim().length<64)throw new a$b({name:"NoLicenseKeyError",message:"No license key provided"});if(typeof e.libraryLocation!="string")throw new a$b({name:"MisconfigurationError",message:'Option "libraryLocation" was not provided'});if(!Array.isArray(e.moduleLoaders)||e.moduleLoaders.length===0)throw new a$b({name:"MisconfigurationError",message:'Option "moduleLoaders" is missing or empty'});let t=e.moduleLoaders.map(r=>r.moduleName);if(!["BarcodeCapture","IdCapture","LabelCapture"].includes(t[0]))throw new a$b({name:"MisconfigurationError",message:'Main modules must be loaded before side modules. For example "BarcodeCapture" must be loaded before "Parser".'})}static async loadModules(e,t){let r=new Map,n=new Map;for(let i of e)n.set(i.moduleName,i.load(t));await Promise.all(n.values());for(let[i,s]of n)r.set(i,await s);return r}static async getOpenSourceSoftwareLicenseInfo(){let e=[];for(let r of a.moduleLicenseTextProviders){let n=await r.getLicenseText();e.push(n);}let t=e.join(`
3
+ https://docs.scandit.com/system-requirements#browser-compatibility`),a.dataCaptureLoaders=await a.loadModules(c.moduleLoaders,c),a.mainDataCaptureLoader=[...a.dataCaptureLoaders.entries()][0][1],b$2.unsubscribe(a.updateViewsWithProgress);}static async forLicenseKeyInElectronPath(e,t){if(!a$a())throw new a$b({name:"MisconfigurationError",message:"forLicenseKeyInElectronPath can only be used in Electron applications"});let r=await c$3({licenseDataPath:e});if(r==null)throw new a$b({name:"NoLicenseKeyError",message:`Cannot retrieve license key for Electron app at ${e}`});return a.forLicenseKey(r.licenseKey,{...t})}static updateViewsWithProgress({percentage:e}){for(let t of a$c.values())t.setProgressBarPercentage(e);}static getOverridesFromQueryString(){var d,o,u;function e(c){return ["auto","off","on"].includes(c)}let t=new URLSearchParams(window.location.search),[r="auto",n="auto",i=false]=[(d=t.get("pthreads"))==null?void 0:d.toLowerCase(),(o=t.get("simd"))==null?void 0:o.toLowerCase(),((u=t.get("forceAllPolyfills"))==null?void 0:u.toLowerCase())==="true"];return {overrideThreadsSupport:e(r)?r:"auto",overrideSimdSupport:e(n)?n:"auto",forceAllPolyfills:i}}static async validateOptions(e){if(e.licenseKey==null||e.licenseKey.trim().length<64)throw new a$b({name:"NoLicenseKeyError",message:"No license key provided"});if(typeof e.libraryLocation!="string")throw new a$b({name:"MisconfigurationError",message:'Option "libraryLocation" was not provided'});if(!Array.isArray(e.moduleLoaders)||e.moduleLoaders.length===0)throw new a$b({name:"MisconfigurationError",message:'Option "moduleLoaders" is missing or empty'});let t=e.moduleLoaders.map(r=>r.moduleName);if(!["BarcodeCapture","IdCapture","LabelCapture"].includes(t[0]))throw new a$b({name:"MisconfigurationError",message:'Main modules must be loaded before side modules. For example "BarcodeCapture" must be loaded before "Parser".'})}static async loadModules(e,t){let r=new Map,n=new Map;for(let i of e)n.set(i.moduleName,i.load(t));await Promise.all(n.values());for(let[i,d]of n)r.set(i,await d);return r}static async getOpenSourceSoftwareLicenseInfo(){let e=[];for(let r of a.moduleLicenseTextProviders){let n=await r.getLicenseText();e.push(n);}let t=e.join(`
4
4
 
5
- `);return new a$d(t)}async setFrameSource(e){let t=e!==this._frameSource;if(this._frameSource!==null&&(this._frameSource.context=null),this._frameSource=e!=null?e:null,e&&(e.context=this,await this.workerCommand("setFrameSource",{mirrorAxis:this.getMirrorAxisForFrameSource(e),isCameraFrameSource:f$1(e)})),await this.update([{type:"frameSourceState",newValue:this.frameSource}]),t)for(let r of this.listeners)r.didChangeFrameSource&&r.didChangeFrameSource(this,this._frameSource);}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}async flushAnalytics(){await this.workerCommand("flushAnalytics",{});}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}async addMode(e){this.modes.add(e),await e.attachedToContext(this),this.updateCameraFrameFlow(),await this.update([],{updateContext:!x(e)});}async removeMode(e){this.modes.delete(e),await e.detachedFromContext(),this.updateCameraFrameFlow(),await this.update([],{updateContext:!x(e)});}async setMode(e){this.modes.has(e)||(this.modes.clear(),this.modes.add(e),await e.attachedToContext(this),this.updateCameraFrameFlow(),await this.update());}async removeCurrentMode(){for(let e of this.modes)await e.detachedFromContext();this.modes.clear(),await this.update();}async removeAllModes(){let e=Array.from(this.modes);for(let t of e)await this.removeMode(t);}hasModes(){return this.modes.size>0}async dispose(){if(a.stateMachine.currentState!=="unconfigured")try{await a.stateMachine.executeAsyncTransition({targetState:"unconfigured",action:async()=>{g.instance().removeListener("cameraProperties",this.cameraPropertiesReportListener),g.instance().removeListener("cameraAccessError",this.cameraAccessErrorListener),this.unsubscribeToVisibilityChange(this.onVisibilityChangeListener);for(let e of this.modes)await e.detachedFromContext();this._view&&(await this._view.setContext(null),this._view=null),this.dataCaptureInstance&&(await this.dataCaptureInstance.terminateDataCaptureWorker(true).catch(()=>{}),this.dataCaptureInstance=void 0),this.webBatteryInterface&&(this.webBatteryInterface.dispose(),this.webBatteryInterface=void 0),a.deviceID="";},onSuccess:"unconfigured",onError:"unconfigured"});}catch(e){if(a.stateMachine.currentState==="unconfigured")return;throw e}finally{this.modes.clear(),this.listeners=[],this.components.length=0,this.updateListeners.clear(),this.pendingWorkerMessageListeners.clear(),this.delayedRegistration=false,this.highEndBlurryRecognition=false,this._frameHandlers.length=0,this.frameSource&&(this.frameSource.context=null,this._frameSource=null),g.instance().dispose(),this.licenseKey="",this.deviceName="",a$e();}}async applySettings(e){this.settings=e,await this.update();}toJSONObject(){var e,t;return {licenseKey:this.licenseKey,framework:this.framework,deviceName:this.deviceName,...this.runtimeEnvironment,modes:[...this.modes].filter(r=>!x(r)).map(r=>r.toJSONObject()),components:this.components.map(r=>r.toJSONObject()),frameSource:this.frameSource?this.frameSource.toJSONObject():null,settings:this.settings.toJSONObject(),view:(t=(e=this._view)==null?void 0:e.toJSONObject())!=null?t:null}}getView(){return this._view}async setView(e){return this._view=e,this.update([{type:"viewSet",newValue:e}])}async getAppName(){let e=null;if(a$a()){let t=await b$3();if((t==null?void 0:t.appName)==null||t.appName==="")throw new Error("Cannot retrieve electron appName. Did you set it up in package.json? https://www.electronjs.org/docs/latest/api/app#appgetname");e=t.appName;}return e}urlToHostname(e){try{return new URL(e!=null?e:"").hostname}catch{return ""}}getParentDomain(){var t;let e="";return parent!==window&&(e||(e=this.urlToHostname((t=location.ancestorOrigins)==null?void 0:t[0])),e||(e=this.urlToHostname(document.referrer)),e||(e="")),e.startsWith("[")&&e.endsWith("]")&&(e=e.slice(1,-1)),e}async createContext(){this.webBatteryInterface=await a$f.create();let e=this.webBatteryInterface.getBatteryInfo();await this.workerCommand("createContext",{context:this.toJSONObject(),deviceId:a.deviceID,delayedRegistration:this.delayedRegistration,highEndBlurryRecognition:this.highEndBlurryRecognition,appName:await this.getAppName(),parentDomain:this.getParentDomain(),isTablet:b$1.isTablet(),batteryInfo:e}),this.webBatteryInterface.addBatteryChangeListener(this.batteryChangeListener),this.subscribeToWorkerMessages(this.onWorkerMessageListener),this.subscribeToCameraManagerEvents(),this.subscribeToVisibilityChange(this.onVisibilityChangeListener),this._view!=null&&await this.setView(this._view),this.frameSource!=null&&await this.setFrameSource(this.frameSource);}subscribeToVisibilityChange(e){document.addEventListener("visibilitychange",e);}unsubscribeToVisibilityChange(e){document.removeEventListener("visibilitychange",e);}async requestFrameData(e){return this.workerCommand("requestFrameData",{frameId:e})}performanceMark(e){a$g(globalThis.performance)&&typeof globalThis.performance.mark=="function"&&performance.mark(e);}async sendFrameToProcessor(e){var n,i;let t=e instanceof ImageData?{data:e.data,width:e.width,height:e.height,frameId:(n=e.frameId)!=null?n:e$1(),colorType:(i=e.colorType)!=null?i:"RGBA"}:e,r=await this.sendFrameToHandlers(t);return t.data=r.capture.data,r.skip?r.capture:(this.performanceMark("processFrameBeforeSDC"),this.sendFrameToSDC(t))}async sendFrameToHandlers(e){for(let t of this._frameHandlers)if((await t(e)).action==="skip")return {skip:true,capture:e};return {skip:false,capture:e}}async sendFrameToSDC(e){return this.workerCommand("processFrame",e,[e.data.buffer])}registerFrameHandler(e){this._frameHandlers.includes(e)||this._frameHandlers.push(e);}unregisterFrameHandler(e){this._frameHandlers.includes(e)&&this._frameHandlers.splice(this._frameHandlers.indexOf(e),1);}onBatteryChange(e){this.workerCommand("updateBatteryInfo",{batteryInfo:e});}onVisibilityChange(){this.workerCommand("documentVisibility",{state:document.visibilityState});}getImageConverterInstance(e){return this._asyncImageConverterInstance==null&&(this._asyncImageConverterInstance=new a$h(e)),this._asyncImageConverterInstance}onWorkerMessage(e){if(e.type==="contextDidChangeStatus"){e.payload.isValid||a$3.error(e.payload);for(let t of this.listeners)t.didChangeStatus&&t.didChangeStatus(this,a$i.fromJSON(e.payload));}if(e.type==="didStartObservingContext")for(let t of this.listeners)t.didStartObservingContext&&t.didStartObservingContext(this);e.type==="onFrameProcessingFinished"&&this.performanceMark("processFrameAfterSDC"),e.type==="convertToJPEG"&&this.convertImageToJPEG(e);}async convertImageToJPEG(e){let{imageId:t,width:r,height:n,data:i,planes:s,orientation:o,quality:u}=e,c={getWidth:()=>r,getHeight:()=>n,getPlanes:()=>s,toBitmap:()=>i,getBitmapRepresentationFromYUV:()=>{throw new Error("Not implemented")},deepCopy:()=>{throw new Error("Not implemented")}},l=await this.getImageConverterInstance({quality:u}).convertToJpeg(c,o);return this.workerCommand("convertToJPEGResult",{imageId:t,result:l})}subscribeToCameraManagerEvents(){g.instance().addListener("cameraProperties",this.cameraPropertiesReportListener),g.instance().addListener("cameraAccessError",this.cameraAccessErrorListener);}async reportCameraProperties(e){return this.workerCommand("reportCameraProperties",e)}onCameraAccessError(e){for(let t of this.listeners)t.didChangeStatus&&t.didChangeStatus(this,a$i.fromJSON({code:33794,isValid:true,message:typeof(e==null?void 0:e.toString)=="function"?e.toString():"Unknown error"}));}async update(e=[],{updateContext:t=true}={}){var r,n;t&&await this.updateContext();for(let i of e){switch(i.type){case "frameSourceState":{await((r=this._view)==null?void 0:r.onFrameSourceChange(this.frameSource));break}case "singleImageModeUploaderSettings":{(n=this._view)==null||n.onSingleImageUploaderSettingsChange(i.newValue);break}case "addOverlay":{await this.addNativeOverlay(i.newValue);break}case "removeOverlay":{await this.removeNativeOverlay(i.newValue);break}}for(let s of this.updateListeners){let o=s(i);o instanceof Promise&&await o;}}}async updateContext(){await this.workerCommand("updateContext",{context:this.toJSONObject(),...this.getViewInfo()}).catch(e=>a$3.warn("Error while updating context:",e,this.toJSONObject()));}getViewInfo(){return this._view!=null?{view:{width:this._view.width,height:this._view.height,visible:this._view.width>0&&this._view.height>0,orientation:this._view.orientation}}:{view:null}}getMirrorAxisForFrameSource(e){let t="None";return f$1(e)&&e.getMirrorImageEnabled()&&(t="Y"),t}async addComponent(e){if(!this.components.includes(e))return this.components.push(e),e._context=this,this.update()}async addNativeOverlay(e){if(q(e))return this.workerCommand("addNativeOverlay",{overlayHandle:e[a$j]})}async removeNativeOverlay(e){if(q(e))return this.workerCommand("removeNativeOverlay",{overlayHandle:e[a$j]})}subscribeToWorkerMessages(e){this.dataCaptureInstance?this.dataCaptureInstance.addWorkerListener(e):this.pendingWorkerMessageListeners.add(e);}unsubscribeToWorkerMessages(e){this.dataCaptureInstance&&this.dataCaptureInstance.removeWorkerListener(e),this.pendingWorkerMessageListeners.delete(e);}hasEnabledMode(){return [...this.modes].some(e=>e.isEnabled())}updateCameraFrameFlow(){let e=[...this.modes].some(t=>t._synchronousFrameFlow===true);g.instance().setFrameHandling(e);}async isFeatureSupported(e){return (await this.workerCommand("isFeatureSupported",{feature:e})).supported}};a.deviceID="",a.stateMachine=new a$1("unconfigured",Z),a.mainDataCaptureLoader=void 0,a.dataCaptureLoaders=new Map,a.libraryLocation=void 0,a.userLicenseKey=null,a.capabilityInfo=void 0,c([v],a.prototype,"setFrameSource",1),c([v],a.prototype,"addMode",1),c([v],a.prototype,"removeMode",1),c([v],a.prototype,"setMode",1),c([v],a.prototype,"removeCurrentMode",1),c([v],a.prototype,"isFeatureSupported",1);var f=a;var b=class{constructor(e=f,t=a$3,r=globalThis.fetch.bind(globalThis)){this.staticContext=f;this.staticContext=e,this.logger=t,this.fetch=r;}get workerCommand(){var e;return (e=this.staticContext.mainDataCaptureLoader)==null?void 0:e.workerCommand.bind(this.staticContext.mainDataCaptureLoader)}async getLicenseText(){var i,s;let e=this.staticContext.stateMachine.currentState;if(e==="unconfigured"||e==="configuring")return this.logger.warn('You must call "DataCaptureContext.forLicenseKey" before retrieving open source license text info.'),"";let t=new URL(`${((i=this.staticContext.libraryLocation)!=null?i:"").replace(/\/$/,"")}/license/web-core-license.txt`),[r,n]=await Promise.all([(s=this.workerCommand)==null?void 0:s.call(this,"getOpenSourceSoftwareLicenseInfo",{}),this.fetchWebLicenseText(t.toString())]);return [r==null?void 0:r.licenseText,n].filter(o=>o!=null).join(`
5
+ `);return new a$d(t)}async setFrameSource(e){let t=e!==this._frameSource;if(this._frameSource!==null&&(this._frameSource.context=null),this._frameSource=e!=null?e:null,e&&(e.context=this,await this.workerCommand("setFrameSource",{mirrorAxis:this.getMirrorAxisForFrameSource(e),isCameraFrameSource:f$1(e)})),await this.update([{type:"frameSourceState",newValue:this.frameSource}]),t)for(let r of this.listeners)r.didChangeFrameSource&&r.didChangeFrameSource(this,this._frameSource);}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}async flushAnalytics(){await this.workerCommand("flushAnalytics",{});}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}async addMode(e){this.modes.add(e),await e.attachedToContext(this),this.updateCameraFrameFlow(),await this.update([],{updateContext:!x(e)});}async removeMode(e){this.modes.delete(e),await e.detachedFromContext(),this.updateCameraFrameFlow(),await this.update([],{updateContext:!x(e)});}async setMode(e){this.modes.has(e)||(this.modes.clear(),this.modes.add(e),await e.attachedToContext(this),this.updateCameraFrameFlow(),await this.update());}async removeCurrentMode(){for(let e of this.modes)await e.detachedFromContext();this.modes.clear(),await this.update();}async removeAllModes(){let e=Array.from(this.modes);for(let t of e)await this.removeMode(t);}hasModes(){return this.modes.size>0}async dispose(){if(a.stateMachine.currentState!=="unconfigured")try{await a.stateMachine.executeAsyncTransition({targetState:"unconfigured",action:async()=>{g.instance().removeListener("cameraProperties",this.cameraPropertiesReportListener),g.instance().removeListener("cameraAccessError",this.cameraAccessErrorListener),this.unsubscribeToVisibilityChange(this.onVisibilityChangeListener);for(let e of this.modes)await e.detachedFromContext();this._view&&(await this._view.setContext(null),this._view=null),this.dataCaptureInstance&&(await this.dataCaptureInstance.terminateDataCaptureWorker(true).catch(()=>{}),this.dataCaptureInstance=void 0),this.webBatteryInterface&&(this.webBatteryInterface.dispose(),this.webBatteryInterface=void 0),a.deviceID="";},onSuccess:"unconfigured",onError:"unconfigured"});}catch(e){if(a.stateMachine.currentState==="unconfigured")return;throw e}finally{this.modes.clear(),this.listeners=[],this.components.length=0,this.updateListeners.clear(),this.pendingWorkerMessageListeners.clear(),this.delayedRegistration=false,this.highEndBlurryRecognition=false,this._frameHandlers.length=0,this.frameSource&&(this.frameSource.context=null,this._frameSource=null),g.instance().dispose(),this.licenseKey="",this.deviceName="",a$e();}}async applySettings(e){this.settings=e,await this.update();}toJSONObject(){var e,t;return {licenseKey:this.licenseKey,framework:this.framework,deviceName:this.deviceName,...this.runtimeEnvironment,modes:[...this.modes].filter(r=>!x(r)).map(r=>r.toJSONObject()),components:this.components.map(r=>r.toJSONObject()),frameSource:this.frameSource?this.frameSource.toJSONObject():null,settings:this.settings.toJSONObject(),view:(t=(e=this._view)==null?void 0:e.toJSONObject())!=null?t:null}}getView(){return this._view}async setView(e){return this._view=e,this.update([{type:"viewSet",newValue:e}])}async getAppName(){let e=null;if(a$a()){let t=await b$3();if((t==null?void 0:t.appName)==null||t.appName==="")throw new Error("Cannot retrieve electron appName. Did you set it up in package.json? https://www.electronjs.org/docs/latest/api/app#appgetname");e=t.appName;}return e}urlToHostname(e){try{return new URL(e!=null?e:"").hostname}catch{return ""}}getParentDomain(){var t;let e="";return parent!==window&&(e||(e=this.urlToHostname((t=location.ancestorOrigins)==null?void 0:t[0])),e||(e=this.urlToHostname(document.referrer)),e||(e="")),e.startsWith("[")&&e.endsWith("]")&&(e=e.slice(1,-1)),e}async createContext(){this.webBatteryInterface=await a$f.create();let e=this.webBatteryInterface.getBatteryInfo();await this.workerCommand("createContext",{context:this.toJSONObject(),deviceId:a.deviceID,delayedRegistration:this.delayedRegistration,highEndBlurryRecognition:this.highEndBlurryRecognition,appName:await this.getAppName(),parentDomain:this.getParentDomain(),isTablet:b$1.isTablet(),batteryInfo:e}),this.webBatteryInterface.addBatteryChangeListener(this.batteryChangeListener),this.subscribeToWorkerMessages(this.onWorkerMessageListener),this.subscribeToCameraManagerEvents(),this.subscribeToVisibilityChange(this.onVisibilityChangeListener),this._view!=null&&await this.setView(this._view),this.frameSource!=null&&await this.setFrameSource(this.frameSource);}subscribeToVisibilityChange(e){document.addEventListener("visibilitychange",e);}unsubscribeToVisibilityChange(e){document.removeEventListener("visibilitychange",e);}async requestFrameData(e){return this.workerCommand("requestFrameData",{frameId:e})}performanceMark(e){a$g(globalThis.performance)&&typeof globalThis.performance.mark=="function"&&performance.mark(e);}async sendFrameToProcessor(e){var n,i;let t=e instanceof ImageData?{data:e.data,width:e.width,height:e.height,frameId:(n=e.frameId)!=null?n:e$1(),colorType:(i=e.colorType)!=null?i:"RGBA"}:e,r=await this.sendFrameToHandlers(t);return t.data=r.capture.data,r.skip?r.capture:(this.performanceMark("processFrameBeforeSDC"),this.sendFrameToSDC(t))}async sendFrameToHandlers(e){for(let t of this._frameHandlers)if((await t(e)).action==="skip")return {skip:true,capture:e};return {skip:false,capture:e}}async sendFrameToSDC(e){return this.workerCommand("processFrame",e,[e.data.buffer])}registerFrameHandler(e){this._frameHandlers.includes(e)||this._frameHandlers.push(e);}unregisterFrameHandler(e){this._frameHandlers.includes(e)&&this._frameHandlers.splice(this._frameHandlers.indexOf(e),1);}onBatteryChange(e){this.workerCommand("updateBatteryInfo",{batteryInfo:e});}onVisibilityChange(){this.workerCommand("documentVisibility",{state:document.visibilityState});}getImageConverterInstance(e){return this._asyncImageConverterInstance==null&&(this._asyncImageConverterInstance=new a$h(e)),this._asyncImageConverterInstance}onWorkerMessage(e){if(e.type==="contextDidChangeStatus"){e.payload.isValid||a$3.error(e.payload);for(let t of this.listeners)t.didChangeStatus&&t.didChangeStatus(this,a$i.fromJSON(e.payload));}if(e.type==="didStartObservingContext")for(let t of this.listeners)t.didStartObservingContext&&t.didStartObservingContext(this);e.type==="onFrameProcessingFinished"&&this.performanceMark("processFrameAfterSDC"),e.type==="convertToJPEG"&&this.convertImageToJPEG(e);}async convertImageToJPEG(e){let{imageId:t,width:r,height:n,data:i,planes:d,orientation:o,quality:u}=e,c={getWidth:()=>r,getHeight:()=>n,getPlanes:()=>d,toBitmap:()=>i,getBitmapRepresentationFromYUV:()=>{throw new Error("Not implemented")},deepCopy:()=>{throw new Error("Not implemented")}},l=await this.getImageConverterInstance({quality:u}).convertToJpeg(c,o);return this.workerCommand("convertToJPEGResult",{imageId:t,result:l})}subscribeToCameraManagerEvents(){g.instance().addListener("cameraProperties",this.cameraPropertiesReportListener),g.instance().addListener("cameraAccessError",this.cameraAccessErrorListener);}async reportCameraProperties(e){return this.workerCommand("reportCameraProperties",e)}onCameraAccessError(e){for(let t of this.listeners)t.didChangeStatus&&t.didChangeStatus(this,a$i.fromJSON({code:33794,isValid:true,message:typeof(e==null?void 0:e.toString)=="function"?e.toString():"Unknown error"}));}async update(e=[],{updateContext:t=true}={}){var r,n;t&&await this.updateContext();for(let i of e){switch(i.type){case "frameSourceState":{await((r=this._view)==null?void 0:r.onFrameSourceChange(this.frameSource));break}case "singleImageModeUploaderSettings":{(n=this._view)==null||n.onSingleImageUploaderSettingsChange(i.newValue);break}case "addOverlay":{await this.addNativeOverlay(i.newValue);break}case "removeOverlay":{await this.removeNativeOverlay(i.newValue);break}}for(let d of this.updateListeners){let o=d(i);o instanceof Promise&&await o;}}}async updateContext(){await this.workerCommand("updateContext",{context:this.toJSONObject(),...this.getViewInfo()}).catch(e=>a$3.warn("Error while updating context:",e,this.toJSONObject()));}getViewInfo(){return this._view!=null?{view:{width:this._view.width,height:this._view.height,visible:this._view.width>0&&this._view.height>0,orientation:this._view.orientation}}:{view:null}}getMirrorAxisForFrameSource(e){let t="None";return f$1(e)&&e.getMirrorImageEnabled()&&(t="Y"),t}async addComponent(e){if(!this.components.includes(e))return this.components.push(e),e._context=this,this.update()}async addNativeOverlay(e){if(q(e))return this.workerCommand("addNativeOverlay",{overlayHandle:e[a$j]})}async removeNativeOverlay(e){if(q(e))return this.workerCommand("removeNativeOverlay",{overlayHandle:e[a$j]})}subscribeToWorkerMessages(e){this.dataCaptureInstance?this.dataCaptureInstance.addWorkerListener(e):this.pendingWorkerMessageListeners.add(e);}unsubscribeToWorkerMessages(e){this.dataCaptureInstance&&this.dataCaptureInstance.removeWorkerListener(e),this.pendingWorkerMessageListeners.delete(e);}hasEnabledMode(){return [...this.modes].some(e=>e.isEnabled())}updateCameraFrameFlow(){let e=[...this.modes].some(t=>t._synchronousFrameFlow===true);g.instance().setFrameHandling(e);}async isFeatureSupported(e){return (await this.workerCommand("isFeatureSupported",{feature:e})).supported}};a.deviceID="",a.stateMachine=new a$1("unconfigured",Z),a.mainDataCaptureLoader=void 0,a.dataCaptureLoaders=new Map,a.libraryLocation=void 0,a.userLicenseKey=null,a.capabilityInfo=void 0,c([v],a.prototype,"setFrameSource",1),c([v],a.prototype,"addMode",1),c([v],a.prototype,"removeMode",1),c([v],a.prototype,"setMode",1),c([v],a.prototype,"removeCurrentMode",1),c([v],a.prototype,"isFeatureSupported",1);var f=a;var b=class{constructor(e=f,t=a$3,r=globalThis.fetch.bind(globalThis)){this.staticContext=f;this.staticContext=e,this.logger=t,this.fetch=r;}get workerCommand(){var e;return (e=this.staticContext.mainDataCaptureLoader)==null?void 0:e.workerCommand.bind(this.staticContext.mainDataCaptureLoader)}async getLicenseText(){var i,d;let e=this.staticContext.stateMachine.currentState;if(e==="unconfigured"||e==="configuring")return this.logger.warn('You must call "DataCaptureContext.forLicenseKey" before retrieving open source license text info.'),"";let t=new URL(`${((i=this.staticContext.libraryLocation)!=null?i:"").replace(/\/$/,"")}/license/web-core-license.txt`),[r,n]=await Promise.all([(d=this.workerCommand)==null?void 0:d.call(this,"getOpenSourceSoftwareLicenseInfo",{}),this.fetchWebLicenseText(t.toString())]);return [r==null?void 0:r.licenseText,n].filter(o=>o!=null).join(`
6
6
  `)}async fetchWebLicenseText(e){return this.fetch(e,{mode:"cors",credentials:"include",headers:{"Content-Type":"text/plain"}}).then(async t=>{if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.text()}).catch(t=>(this.logger.warn(`Failed to fetch license from ${e}: ${t.toString()}`),null))}};export{b as a,f as b};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-NOEX6HP5.js';var t=new a(globalThis,{get:()=>globalThis.Module,set:e=>{globalThis.Module=e;}});function l(e){}export{t as a,l as b};
@@ -1 +1 @@
1
- export{a as CameraFOVSwitchControl}from'../chunks/chunk-ZP3YIZEC.js';
1
+ export{a as CameraFOVSwitchControl}from'../chunks/chunk-HLVYMWIK.js';
@@ -1 +1 @@
1
- export{a as CameraSwitchControl}from'../chunks/chunk-ZTKCGHYQ.js';
1
+ export{a as CameraSwitchControl}from'../chunks/chunk-RVJQOD3H.js';
@@ -1 +1 @@
1
- export{a as ZoomSwitchControl}from'../chunks/chunk-P2R7FW6C.js';
1
+ export{a as ZoomSwitchControl}from'../chunks/chunk-ASJCS2FB.js';
@@ -1 +1 @@
1
- export{a as CameraSwitchControl}from'../chunks/chunk-ZTKCGHYQ.js';export{a as TorchSwitchControl}from'../chunks/chunk-AC4QOIY7.js';export{a as ZoomSwitchControl}from'../chunks/chunk-P2R7FW6C.js';export{a as CameraFOVSwitchControl}from'../chunks/chunk-ZP3YIZEC.js';
1
+ export{a as CameraFOVSwitchControl}from'../chunks/chunk-HLVYMWIK.js';export{a as CameraSwitchControl}from'../chunks/chunk-RVJQOD3H.js';export{a as TorchSwitchControl}from'../chunks/chunk-AC4QOIY7.js';export{a as ZoomSwitchControl}from'../chunks/chunk-ASJCS2FB.js';
package/build/js/index.js CHANGED
@@ -1 +1 @@
1
- export{a as DataCaptureLoader}from'./chunks/chunk-YJNJGCAN.js';export{a as WorkerMain}from'./chunks/chunk-JLTSTUKY.js';export{a as RectWithUnit}from'./chunks/chunk-TKO5JMMS.js';export{a as Direction}from'./chunks/chunk-WARGMW7Z.js';export{a as CameraSwitchControl}from'./chunks/chunk-ZTKCGHYQ.js';export{a as TorchSwitchControl}from'./chunks/chunk-AC4QOIY7.js';export{a as ZoomSwitchControl}from'./chunks/chunk-P2R7FW6C.js';export{a as NotificationBuilder}from'./chunks/chunk-5LXHD7FZ.js';export{a as CameraFOVSwitchControl}from'./chunks/chunk-ZP3YIZEC.js';export{a as NoViewfinder}from'./chunks/chunk-4ZMCJXZS.js';export{a as ZoomSwitchOrientation}from'./chunks/chunk-OLUNDJBC.js';export{a as PrivateNoneLocationSelection,b as RadiusLocationSelection,c as RectangularLocationSelection}from'./chunks/chunk-CAHJ3YOV.js';export{a as RectangularViewfinder}from'./chunks/chunk-GPUTPXQM.js';export{c as ScanditIconBuilder,b as ScanditIconForIconType,a as ScanditIconType}from'./chunks/chunk-WHRRC6V6.js';export{b as ScanditIcon,a as ScanditIconShape}from'./chunks/chunk-O4HDBWKK.js';export{a as SingleImageUploader}from'./chunks/chunk-4WA2PCJE.js';export{a as SingleImageUploaderSettings}from'./chunks/chunk-IMXMNDKM.js';export{a as DataCaptureVersion}from'./chunks/chunk-P3NPNIWR.js';export{a as DataCaptureView}from'./chunks/chunk-H3J4TP2K.js';export{a as AdditionalLayerPosition}from'./chunks/chunk-DZE2EYSZ.js';export{a as AnchorPositions}from'./chunks/chunk-RSQRPDVQ.js';export{a as Orientation}from'./chunks/chunk-5RCWM6NI.js';export{a as PointWithUnit}from'./chunks/chunk-BDGRWHLY.js';export{a as Quadrilateral}from'./chunks/chunk-IJQG3OU6.js';export{a as Anchor}from'./chunks/chunk-Y7ZNLVR2.js';export{a as MarginsWithUnit}from'./chunks/chunk-MA6UDVDJ.js';export{a as NotificationStyle}from'./chunks/chunk-RXT3JWWR.js';export{a as NotificationConfiguration}from'./chunks/chunk-CRUOVJHW.js';export{a as MeasureUnit}from'./chunks/chunk-QQEY536Q.js';export{a as LogoStyle,d as PinchToZoom,c as SwipeToZoom,b as TapToFocus}from'./chunks/chunk-4QJAB4PO.js';export{a as Feedback}from'./chunks/chunk-76IGNICM.js';export{a as Sound}from'./chunks/chunk-CGK5V6XZ.js';export{a as Vibration}from'./chunks/chunk-IASACVTH.js';export{a as convertToPublicFrameData}from'./chunks/chunk-W33RVR5M.js';export{a as ImageFrameSource}from'./chunks/chunk-AD77NFCP.js';export{a as LaserlineViewfinder}from'./chunks/chunk-RXPPTQAB.js';export{a as AimerViewfinder}from'./chunks/chunk-3KKUZY2T.js';export{c as RectangularViewfinderAnimation,b as RectangularViewfinderLineStyle,a as RectangularViewfinderStyle}from'./chunks/chunk-WGLHZXRT.js';export{a as SizeWithUnitAndAspect}from'./chunks/chunk-AZWFNBVA.js';export{a as SizingMode}from'./chunks/chunk-2JIATMSD.js';export{a as SizeWithAspect}from'./chunks/chunk-FR24G4R7.js';export{a as SizeWithUnit}from'./chunks/chunk-F2GMW4LP.js';export{a as NumberWithUnit}from'./chunks/chunk-ENYHCJGH.js';export{a as Brush}from'./chunks/chunk-YOTQPBO6.js';export{a as Color}from'./chunks/chunk-SGL5J2CI.js';export{a as Camera}from'./chunks/chunk-GMOTHEWV.js';export{b as DataCaptureContext}from'./chunks/chunk-XUIVDVLK.js';export{a as OverrideState}from'./chunks/chunk-6W7FX6LD.js';export{b as loadingStatus}from'./chunks/chunk-6H6FKGVE.js';export{a as Localization}from'./chunks/chunk-GHTCNOQN.js';export{a as ScanditHTMLElement}from'./chunks/chunk-EV4OEANA.js';export{a as INTERNAL_ACCESS}from'./chunks/chunk-LFJUGRQV.js';export{a as Point}from'./chunks/chunk-KAFNKP6O.js';export{a as Rect}from'./chunks/chunk-E4XJ4GKD.js';export{a as Size}from'./chunks/chunk-QOCHMKNY.js';export{a as assert,b as assertUnreachable,c as assertUnreachableThrowException}from'./chunks/chunk-FTD535WI.js';export{b as BrowserHelper,a as DisplayMode}from'./chunks/chunk-YONR3EGV.js';export{a as Feature}from'./chunks/chunk-NVK73TNL.js';export{a as Logger}from'./chunks/chunk-XR65N6EG.js';export{c as CameraPosition,g as CameraSettings,e as FocusGestureStrategy,a as FrameSourceState,b as TorchState,d as VideoResolution,f as isCameraFrameSource}from'./chunks/chunk-D222MT4V.js';export{a as ContextStatus,b as PrivateMirrorAxis}from'./chunks/chunk-WUHKODFA.js';export{a as DataCaptureContextSettings}from'./chunks/chunk-7SW2PEHB.js';export{a as DataCaptureError}from'./chunks/chunk-QCZSSQAQ.js';
1
+ export{a as DataCaptureLoader}from'./chunks/chunk-RXFEUGTT.js';export{a as WorkerMain}from'./chunks/chunk-NOEX6HP5.js';export{a as CameraFOVSwitchControl}from'./chunks/chunk-HLVYMWIK.js';export{a as CameraSwitchControl}from'./chunks/chunk-RVJQOD3H.js';export{a as TorchSwitchControl}from'./chunks/chunk-AC4QOIY7.js';export{a as ZoomSwitchControl}from'./chunks/chunk-ASJCS2FB.js';export{a as RectWithUnit}from'./chunks/chunk-TKO5JMMS.js';export{a as Direction}from'./chunks/chunk-WARGMW7Z.js';export{a as NotificationBuilder}from'./chunks/chunk-5LXHD7FZ.js';export{a as NoViewfinder}from'./chunks/chunk-4ZMCJXZS.js';export{a as ZoomSwitchOrientation}from'./chunks/chunk-OLUNDJBC.js';export{a as PrivateNoneLocationSelection,b as RadiusLocationSelection,c as RectangularLocationSelection}from'./chunks/chunk-CAHJ3YOV.js';export{a as RectangularViewfinder}from'./chunks/chunk-GPUTPXQM.js';export{c as ScanditIconBuilder,b as ScanditIconForIconType,a as ScanditIconType}from'./chunks/chunk-WHRRC6V6.js';export{b as ScanditIcon,a as ScanditIconShape}from'./chunks/chunk-O4HDBWKK.js';export{a as SingleImageUploader}from'./chunks/chunk-4WA2PCJE.js';export{a as SingleImageUploaderSettings}from'./chunks/chunk-IMXMNDKM.js';export{a as DataCaptureVersion}from'./chunks/chunk-T2JW7GJH.js';export{a as DataCaptureView}from'./chunks/chunk-KJXBZMMB.js';export{a as AdditionalLayerPosition}from'./chunks/chunk-DZE2EYSZ.js';export{a as AnchorPositions}from'./chunks/chunk-RSQRPDVQ.js';export{a as PointWithUnit}from'./chunks/chunk-BDGRWHLY.js';export{a as Quadrilateral}from'./chunks/chunk-IJQG3OU6.js';export{a as Anchor}from'./chunks/chunk-Y7ZNLVR2.js';export{a as MarginsWithUnit}from'./chunks/chunk-MA6UDVDJ.js';export{a as Orientation}from'./chunks/chunk-5RCWM6NI.js';export{a as NotificationConfiguration}from'./chunks/chunk-CRUOVJHW.js';export{a as NotificationStyle}from'./chunks/chunk-RXT3JWWR.js';export{a as MeasureUnit}from'./chunks/chunk-QQEY536Q.js';export{a as LogoStyle,d as PinchToZoom,c as SwipeToZoom,b as TapToFocus}from'./chunks/chunk-4QJAB4PO.js';export{a as Feedback}from'./chunks/chunk-QJZW4BFG.js';export{a as Sound}from'./chunks/chunk-56S3BFJ6.js';export{a as Vibration}from'./chunks/chunk-SIMTA4TK.js';export{a as convertToPublicFrameData}from'./chunks/chunk-W33RVR5M.js';export{a as ImageFrameSource}from'./chunks/chunk-KW2WZUE3.js';export{a as LaserlineViewfinder}from'./chunks/chunk-RXPPTQAB.js';export{a as AimerViewfinder}from'./chunks/chunk-3KKUZY2T.js';export{c as RectangularViewfinderAnimation,b as RectangularViewfinderLineStyle,a as RectangularViewfinderStyle}from'./chunks/chunk-WGLHZXRT.js';export{a as SizeWithUnitAndAspect}from'./chunks/chunk-AZWFNBVA.js';export{a as SizingMode}from'./chunks/chunk-2JIATMSD.js';export{a as SizeWithAspect}from'./chunks/chunk-FR24G4R7.js';export{a as SizeWithUnit}from'./chunks/chunk-F2GMW4LP.js';export{a as NumberWithUnit}from'./chunks/chunk-ENYHCJGH.js';export{a as Brush}from'./chunks/chunk-YOTQPBO6.js';export{a as Color}from'./chunks/chunk-SGL5J2CI.js';export{a as Camera}from'./chunks/chunk-QRMHTQBG.js';export{b as DataCaptureContext}from'./chunks/chunk-VUPEBHJF.js';export{a as OverrideState}from'./chunks/chunk-6W7FX6LD.js';export{b as loadingStatus}from'./chunks/chunk-6H6FKGVE.js';export{a as Localization}from'./chunks/chunk-GHTCNOQN.js';export{a as ScanditHTMLElement}from'./chunks/chunk-EV4OEANA.js';export{a as INTERNAL_ACCESS}from'./chunks/chunk-LFJUGRQV.js';export{a as Point}from'./chunks/chunk-KAFNKP6O.js';export{a as Rect}from'./chunks/chunk-E4XJ4GKD.js';export{a as Size}from'./chunks/chunk-QOCHMKNY.js';export{a as assert,b as assertUnreachable,c as assertUnreachableThrowException}from'./chunks/chunk-FTD535WI.js';export{b as BrowserHelper,a as DisplayMode}from'./chunks/chunk-AYYKQ7YB.js';export{a as Feature}from'./chunks/chunk-NVK73TNL.js';export{a as Logger}from'./chunks/chunk-XR65N6EG.js';export{c as CameraPosition,g as CameraSettings,e as FocusGestureStrategy,a as FrameSourceState,b as TorchState,d as VideoResolution,f as isCameraFrameSource}from'./chunks/chunk-D222MT4V.js';export{a as ContextStatus,b as PrivateMirrorAxis}from'./chunks/chunk-WUHKODFA.js';export{a as DataCaptureContextSettings}from'./chunks/chunk-7SW2PEHB.js';export{a as DataCaptureError}from'./chunks/chunk-QCZSSQAQ.js';
@@ -1 +1 @@
1
- export{c as AspectRatio,d as CameraAccess,a as CameraPosition,b as CameraResolutionConstraint}from'../chunks/chunk-YUZDO2PC.js';
1
+ export{c as AspectRatio,d as CameraAccess,a as CameraPosition,b as CameraResolutionConstraint}from'../chunks/chunk-5GUWY76Q.js';
@@ -1 +1 @@
1
- export{g as CameraManager,f as CameraManagerEvent,d as CameraResolutionConstraint,c as MeteringMode,e as createFrameId}from'../chunks/chunk-CA6FHIF6.js';
1
+ export{g as CameraManager,f as CameraManagerEvent,d as CameraResolutionConstraint,c as MeteringMode,e as createFrameId}from'../chunks/chunk-T6EVGEHJ.js';
@@ -1 +1 @@
1
- export{a as CoreModuleLicenseTextProvider}from'../chunks/chunk-XUIVDVLK.js';
1
+ export{a as CoreModuleLicenseTextProvider}from'../chunks/chunk-VUPEBHJF.js';
@@ -1 +1 @@
1
- export{a as FrameReader}from'../../chunks/chunk-CA6FHIF6.js';
1
+ export{a as FrameReader}from'../../chunks/chunk-T6EVGEHJ.js';
@@ -1 +1 @@
1
- export{b as GrayScaleFrameReader}from'../../chunks/chunk-CA6FHIF6.js';
1
+ export{b as GrayScaleFrameReader}from'../../chunks/chunk-T6EVGEHJ.js';
@@ -1 +1 @@
1
- export{a as FrameReader,b as GrayScaleFrameReader}from'../../chunks/chunk-CA6FHIF6.js';export{a as FrameReaderType}from'../../chunks/chunk-ORP45GHJ.js';
1
+ export{a as FrameReader,b as GrayScaleFrameReader}from'../../chunks/chunk-T6EVGEHJ.js';export{a as FrameReaderType}from'../../chunks/chunk-ORP45GHJ.js';
@@ -1 +1 @@
1
- export{b as OrientationObserver,a as orientationChangeEvent}from'../chunks/chunk-RXDVYEE5.js';
1
+ export{b as OrientationObserver,a as orientationChangeEvent}from'../chunks/chunk-7GQFJDH6.js';
@@ -1 +1 @@
1
- export{a as SingleImageUploaderView}from'../chunks/chunk-ACCTMSWC.js';
1
+ export{a as SingleImageUploaderView}from'../chunks/chunk-I52JX2MQ.js';
@@ -1 +1 @@
1
- import {a as a$1}from'../chunks/chunk-GMOTHEWV.js';import {d as d$1}from'../chunks/chunk-YUZDO2PC.js';import {b}from'../chunks/chunk-YONR3EGV.js';import {a}from'../chunks/chunk-XR65N6EG.js';import {f as f$1,g}from'../chunks/chunk-D222MT4V.js';var S=(t=>(t.Idle="idle",t.Pressed="pressed",t))(S||{}),d=class{constructor(e,t){this.state="idle";this.isHover=false;this.controlTypeToAriaLabelMap={"camera-fov":"Switch camera field of view",camera:"Switch camera",torch:"Toggle torch"};this.control=e,this.domHost=t,this.onTouchStartListener=this.onTouchStart.bind(this),this.onMouseEnterListener=this.onMouseEnter.bind(this),this.onMouseLeaveListener=this.onMouseLeave.bind(this),this.onClickListener=this.onClick.bind(this),this.setup();}get frameSource(){var e,t;return (t=(e=this.control.view)==null?void 0:e.getContext())==null?void 0:t.frameSource}get context(){var e;return (e=this.control.view)==null?void 0:e.getContext()}async install(){this.button||this.setup();let e=await this.canShow();return e?(this.updateButtonBackground(this.button,this.getImageFromState()),this.show()):this.hide(),e}remove(e=false){e&&this.button?(this.button.removeEventListener("mouseenter",this.onMouseEnterListener),this.button.removeEventListener("mouseleave",this.onMouseLeaveListener),this.button.removeEventListener("touchstart",this.onTouchStartListener),this.button.removeEventListener("click",this.onClickListener),this.button.remove(),this.isHover=false,this.button=void 0):this.hide();}hide(){this.button&&(this.button.style.display="none");}show(){this.button&&(this.button.style.display="block");}setupButton(){let e=document.createElement("button");e.type="button",e.style.display="none",e.className=`scandit-control-widget scandit-control-widget-${this.control.type}`,this.updateButtonBackground(e,this.getImageFromState()),this.domHost.append(e),e.addEventListener("mouseenter",this.onMouseEnterListener),e.addEventListener("mouseleave",this.onMouseLeaveListener),b.isDesktopDevice()||e.addEventListener("touchstart",this.onTouchStartListener),e.addEventListener("click",this.onClickListener),e.setAttribute("aria-pressed",String(this.state==="pressed"));let t=this.control.type,i=this.controlTypeToAriaLabelMap[t];return e.setAttribute("aria-label",i),this.button=e,this.button}setup(){this.setupButton();}onTouchStart(){var e,t;(e=this.button)==null||e.removeEventListener("mouseenter",this.onMouseEnterListener),(t=this.button)==null||t.removeEventListener("mouseleave",this.onMouseLeaveListener);}onMouseEnter(){this.isHover=true,this.updateButtonBackground(this.button,this.getImageFromState());}onMouseLeave(){this.isHover=false,this.updateButtonBackground(this.button,this.getImageFromState());}onClick(){var e;this.state=this.state==="pressed"?"idle":"pressed",this.buttonClicked(),this.updateButtonBackground(this.button,this.getImageFromState()),(e=this.button)==null||e.setAttribute("aria-pressed",String(this.state==="pressed"));}updateButtonBackground(e,t){t!=null&&e!=null&&(e.style.backgroundImage=`url(${JSON.stringify(t)})`);}},v=class extends d{constructor(e,t){super(e,t);}async buttonClicked(){await this.frameSource.setDesiredTorchState(this.retrieveTorchState()==="on"?"off":"on");}async canShow(){return this.isTorchAvailable()}getImageFromState(){return this.retrieveTorchState()==="on"?this.isHover?this.control.torchOnPressedImage:this.control.torchOnImage:this.isHover?this.control.torchOffPressedImage:this.control.torchOffImage}setup(){if(this.control.torchOffImage==null||this.control.torchOnImage==null){a.log(a.Level.Warn,"TorchSwitchControl icon is not set or is empty, the control will not be rendered.");return}super.setup();}async isTorchAvailable(){return f$1(this.frameSource)?this.frameSource.isTorchAvailable():false}retrieveTorchState(){return f$1(this.frameSource)?this.frameSource.getDesiredTorchState():"off"}},f=class extends d{constructor(e,t){super(e,t);}async canShow(){return (await a$1.getAll()).length>1}getImageFromState(){return this.isHover?this.control.pressedImage:this.control.idleImage}async buttonClicked(){if(this.isTransitioning)return;let e=await this.getNextDeviceCamera();e&&await this.switchCameras(e);}setup(){if(this.control.idleImage==null){a.log(a.Level.Warn,"CameraSwitchControl idle icon is not set or is empty, the control will not be rendered.");return}super.setup();}async getNextDeviceCamera(){var a;let e=await a$1.getAll(false,true),t=this.frameSource?this.frameSource:null,i=t==null?void 0:t.deviceId,r=e.findIndex(n=>n.deviceId===i);return r>-1?(a=e[r+1])!=null?a:e[0]:e.length>0?e[0]:null}async switchCameras(e){var a,n,l;this.isTransitioning=true;let t=(a=this.context)==null?void 0:a.frameSource,i,r;t!=null&&(i=new g(t.settings),r=t.desiredState),await(t==null?void 0:t.switchToDesiredState("off")),i!=null&&await e.applySettings(i),await((n=this.context)==null?void 0:n.setFrameSource(e)),await((l=this.context)==null?void 0:l.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}},C=class extends d{constructor(e,t){super(e,t);}async install(){let e=await super.install();return e&&await this.setInitialCamera(),e}async canShow(){return !b.isIOSDeviceWithExtendedCameraAccess()||!f$1(this.frameSource)?false:d$1.isIOSBackDualWideCameraLabel(this.frameSource.label)||d$1.isIOSBackCameraLabel(this.frameSource.label)||d$1.isIOSUltraWideBackCameraLabel(this.frameSource.label)}getImageFromState(){return this.isUltraWideBackCamera()?this.isHover?this.control.cameraFOVUltraWidePressedImage:this.control.cameraFOVUltraWideImage:this.isHover?this.control.cameraFOVWidePressedImage:this.control.cameraFOVWideImage}async buttonClicked(){if(this.isTransitioning)return;let e=await this.getAlternativeCamera();e&&await this.switchCameras(e);}setup(){if(this.control.cameraFOVUltraWideImage==null||this.control.cameraFOVWideImage==null){a.log(a.Level.Warn,"CameraFOVSwitchControl icon is not set or is empty, the control will not be rendered.");return}super.setup();}async setInitialCamera(){var e,t;if(!this.isTransitioning&&!d$1.isIOSBackCameraLabel((t=(e=this.frameSource)==null?void 0:e.label)!=null?t:"")){let r=(await a$1.getAll()).find(a=>d$1.isIOSBackCameraLabel(a.label));r&&await this.switchCameras(r);}}isUltraWideBackCamera(){return f$1(this.frameSource)?d$1.isIOSUltraWideBackCameraLabel(this.frameSource.label):false}async getAlternativeCamera(){return (await a$1.getAll()).find(t=>this.isUltraWideBackCamera()?d$1.isIOSBackCameraLabel(t.label):d$1.isIOSUltraWideBackCameraLabel(t.label))}async switchCameras(e){var a,n,l;this.isTransitioning=true;let t=(a=this.context)==null?void 0:a.frameSource,i,r;t!=null&&(i=new g(t.settings),r=t.desiredState),await(t==null?void 0:t.switchToDesiredState("off")),i!=null&&await e.applySettings(i),await((n=this.context)==null?void 0:n.setFrameSource(e)),await((l=this.context)==null?void 0:l.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}};export{S as ButtonState,f as CameraSwitchControlWidget,C as PrivateCameraFOVSwitchControlWidget,v as PrivateTorchControlWidget};
1
+ import {a as a$1}from'../chunks/chunk-QRMHTQBG.js';import {d as d$1}from'../chunks/chunk-5GUWY76Q.js';import {b}from'../chunks/chunk-AYYKQ7YB.js';import {a}from'../chunks/chunk-XR65N6EG.js';import {f as f$1,g}from'../chunks/chunk-D222MT4V.js';var S=(t=>(t.Idle="idle",t.Pressed="pressed",t))(S||{}),d=class{constructor(e,t){this.state="idle";this.isHover=false;this.controlTypeToAriaLabelMap={"camera-fov":"Switch camera field of view",camera:"Switch camera",torch:"Toggle torch"};this.control=e,this.domHost=t,this.onTouchStartListener=this.onTouchStart.bind(this),this.onMouseEnterListener=this.onMouseEnter.bind(this),this.onMouseLeaveListener=this.onMouseLeave.bind(this),this.onClickListener=this.onClick.bind(this),this.setup();}get frameSource(){var e,t;return (t=(e=this.control.view)==null?void 0:e.getContext())==null?void 0:t.frameSource}get context(){var e;return (e=this.control.view)==null?void 0:e.getContext()}async install(){this.button||this.setup();let e=await this.canShow();return e?(this.updateButtonBackground(this.button,this.getImageFromState()),this.show()):this.hide(),e}remove(e=false){e&&this.button?(this.button.removeEventListener("mouseenter",this.onMouseEnterListener),this.button.removeEventListener("mouseleave",this.onMouseLeaveListener),this.button.removeEventListener("touchstart",this.onTouchStartListener),this.button.removeEventListener("click",this.onClickListener),this.button.remove(),this.isHover=false,this.button=void 0):this.hide();}hide(){this.button&&(this.button.style.display="none");}show(){this.button&&(this.button.style.display="block");}setupButton(){let e=document.createElement("button");e.type="button",e.style.display="none",e.className=`scandit-control-widget scandit-control-widget-${this.control.type}`,this.updateButtonBackground(e,this.getImageFromState()),this.domHost.append(e),e.addEventListener("mouseenter",this.onMouseEnterListener),e.addEventListener("mouseleave",this.onMouseLeaveListener),b.isDesktopDevice()||e.addEventListener("touchstart",this.onTouchStartListener),e.addEventListener("click",this.onClickListener),e.setAttribute("aria-pressed",String(this.state==="pressed"));let t=this.control.type,i=this.controlTypeToAriaLabelMap[t];return e.setAttribute("aria-label",i),this.button=e,this.button}setup(){this.setupButton();}onTouchStart(){var e,t;(e=this.button)==null||e.removeEventListener("mouseenter",this.onMouseEnterListener),(t=this.button)==null||t.removeEventListener("mouseleave",this.onMouseLeaveListener);}onMouseEnter(){this.isHover=true,this.updateButtonBackground(this.button,this.getImageFromState());}onMouseLeave(){this.isHover=false,this.updateButtonBackground(this.button,this.getImageFromState());}onClick(){var e;this.state=this.state==="pressed"?"idle":"pressed",this.buttonClicked(),this.updateButtonBackground(this.button,this.getImageFromState()),(e=this.button)==null||e.setAttribute("aria-pressed",String(this.state==="pressed"));}updateButtonBackground(e,t){t!=null&&e!=null&&(e.style.backgroundImage=`url(${JSON.stringify(t)})`);}},v=class extends d{constructor(e,t){super(e,t);}async buttonClicked(){await this.frameSource.setDesiredTorchState(this.retrieveTorchState()==="on"?"off":"on");}async canShow(){return this.isTorchAvailable()}getImageFromState(){return this.retrieveTorchState()==="on"?this.isHover?this.control.torchOnPressedImage:this.control.torchOnImage:this.isHover?this.control.torchOffPressedImage:this.control.torchOffImage}setup(){if(this.control.torchOffImage==null||this.control.torchOnImage==null){a.log(a.Level.Warn,"TorchSwitchControl icon is not set or is empty, the control will not be rendered.");return}super.setup();}async isTorchAvailable(){return f$1(this.frameSource)?this.frameSource.isTorchAvailable():false}retrieveTorchState(){return f$1(this.frameSource)?this.frameSource.getDesiredTorchState():"off"}},f=class extends d{constructor(e,t){super(e,t);}async canShow(){return (await a$1.getAll()).length>1}getImageFromState(){return this.isHover?this.control.pressedImage:this.control.idleImage}async buttonClicked(){if(this.isTransitioning)return;let e=await this.getNextDeviceCamera();e&&await this.switchCameras(e);}setup(){if(this.control.idleImage==null){a.log(a.Level.Warn,"CameraSwitchControl idle icon is not set or is empty, the control will not be rendered.");return}super.setup();}async getNextDeviceCamera(){var a;let e=await a$1.getAll(false,true),t=this.frameSource?this.frameSource:null,i=t==null?void 0:t.deviceId,r=e.findIndex(n=>n.deviceId===i);return r>-1?(a=e[r+1])!=null?a:e[0]:e.length>0?e[0]:null}async switchCameras(e){var a,n,l;this.isTransitioning=true;let t=(a=this.context)==null?void 0:a.frameSource,i,r;t!=null&&(i=new g(t.settings),r=t.desiredState),await(t==null?void 0:t.switchToDesiredState("off")),i!=null&&await e.applySettings(i),await((n=this.context)==null?void 0:n.setFrameSource(e)),await((l=this.context)==null?void 0:l.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}},C=class extends d{constructor(e,t){super(e,t);}async install(){let e=await super.install();return e&&await this.setInitialCamera(),e}async canShow(){return !b.isIOSDeviceWithExtendedCameraAccess()||!f$1(this.frameSource)?false:d$1.isIOSBackDualWideCameraLabel(this.frameSource.label)||d$1.isIOSBackCameraLabel(this.frameSource.label)||d$1.isIOSUltraWideBackCameraLabel(this.frameSource.label)}getImageFromState(){return this.isUltraWideBackCamera()?this.isHover?this.control.cameraFOVUltraWidePressedImage:this.control.cameraFOVUltraWideImage:this.isHover?this.control.cameraFOVWidePressedImage:this.control.cameraFOVWideImage}async buttonClicked(){if(this.isTransitioning)return;let e=await this.getAlternativeCamera();e&&await this.switchCameras(e);}setup(){if(this.control.cameraFOVUltraWideImage==null||this.control.cameraFOVWideImage==null){a.log(a.Level.Warn,"CameraFOVSwitchControl icon is not set or is empty, the control will not be rendered.");return}super.setup();}async setInitialCamera(){var e,t;if(!this.isTransitioning&&!d$1.isIOSBackCameraLabel((t=(e=this.frameSource)==null?void 0:e.label)!=null?t:"")){let r=(await a$1.getAll()).find(a=>d$1.isIOSBackCameraLabel(a.label));r&&await this.switchCameras(r);}}isUltraWideBackCamera(){return f$1(this.frameSource)?d$1.isIOSUltraWideBackCameraLabel(this.frameSource.label):false}async getAlternativeCamera(){return (await a$1.getAll()).find(t=>this.isUltraWideBackCamera()?d$1.isIOSBackCameraLabel(t.label):d$1.isIOSUltraWideBackCameraLabel(t.label))}async switchCameras(e){var a,n,l;this.isTransitioning=true;let t=(a=this.context)==null?void 0:a.frameSource,i,r;t!=null&&(i=new g(t.settings),r=t.desiredState),await(t==null?void 0:t.switchToDesiredState("off")),i!=null&&await e.applySettings(i),await((n=this.context)==null?void 0:n.setFrameSource(e)),await((l=this.context)==null?void 0:l.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}};export{S as ButtonState,f as CameraSwitchControlWidget,C as PrivateCameraFOVSwitchControlWidget,v as PrivateTorchControlWidget};
@@ -1 +1 @@
1
- export{a as Howl}from'../../chunks/chunk-CERFU73N.js';
1
+ export{a as Howl}from'../../chunks/chunk-3WNU5X5L.js';
@@ -1 +1 @@
1
- export{c as WebAudioContextManager,a as createAudioContext,b as getAudioCacheInstance}from'../../chunks/chunk-Y3TODCJD.js';
1
+ export{c as WebAudioContextManager,a as createAudioContext,b as getAudioCacheInstance}from'../../chunks/chunk-EPIUNYWM.js';
@@ -1 +1 @@
1
- export{a as disposeGlobalAudioContext,c as ensureUnlockSetup,b as resetGlobalAudioContext}from'../../chunks/chunk-4LGQ66HW.js';export{a as Howl}from'../../chunks/chunk-CERFU73N.js';
1
+ export{a as disposeGlobalAudioContext,c as ensureUnlockSetup,b as resetGlobalAudioContext}from'../../chunks/chunk-IGTW3KDT.js';export{a as Howl}from'../../chunks/chunk-3WNU5X5L.js';