/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/capacitor-plugin-dynamsoft-camera-preview@2.1.1/dist/plugin.cjs.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@capacitor/core"),dynamsoftCameraEnhancer=require("dynamsoft-camera-enhancer");exports.EnumResolution=void 0,function(e){e[e.RESOLUTION_AUTO=0]="RESOLUTION_AUTO",e[e.RESOLUTION_480P=1]="RESOLUTION_480P",e[e.RESOLUTION_720P=2]="RESOLUTION_720P",e[e.RESOLUTION_1080P=3]="RESOLUTION_1080P",e[e.RESOLUTION_2K=4]="RESOLUTION_2K",e[e.RESOLUTION_4K=5]="RESOLUTION_4K"}(exports.EnumResolution||(exports.EnumResolution={}));const CameraPreview=core.registerPlugin("CameraPreview",{web:()=>Promise.resolve().then((function(){return web})).then((e=>new e.CameraPreviewWeb))});dynamsoftCameraEnhancer.CameraEnhancer.defaultUIElementURL="https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@3.1.0/dist/dce.ui.html";class CameraPreviewWeb extends core.WebPlugin{async setDefaultUIElementURL(e){dynamsoftCameraEnhancer.CameraEnhancer.defaultUIElementURL=e}async initialize(){this.camera=await dynamsoftCameraEnhancer.CameraEnhancer.createInstance(),this.camera.on("played",(e=>{this.notifyListeners("onPlayed",{resolution:e.width+"x"+e.height})})),await this.camera.setUIElement(dynamsoftCameraEnhancer.CameraEnhancer.defaultUIElementURL),this.camera.getUIElement().getElementsByClassName("dce-btn-close")[0].remove(),this.camera.getUIElement().getElementsByClassName("dce-sel-camera")[0].remove(),this.camera.getUIElement().getElementsByClassName("dce-sel-resolution")[0].remove(),this.camera.getUIElement().getElementsByClassName("dce-msg-poweredby")[0].remove()}async getResolution(){if(this.camera){let e=this.camera.getResolution();return{resolution:e[0]+"x"+e[1]}}throw new Error("DCE not initialized")}async setResolution(e){if(this.camera){let a=e.resolution,t=1280,r=720;return a==exports.EnumResolution.RESOLUTION_480P?(t=640,r=480):a==exports.EnumResolution.RESOLUTION_720P?(t=1280,r=720):a==exports.EnumResolution.RESOLUTION_1080P?(t=1920,r=1080):a==exports.EnumResolution.RESOLUTION_2K?(t=2560,r=1440):a==exports.EnumResolution.RESOLUTION_4K&&(t=3840,r=2160),void await this.camera.setResolution(t,r)}throw new Error("DCE not initialized")}async getAllCameras(){if(this.camera){let e=await this.camera.getAllCameras(),a=[];return e.forEach((e=>{a.push(e.label)})),{cameras:a}}throw new Error("DCE not initialized")}async getSelectedCamera(){if(this.camera){return{selectedCamera:this.camera.getSelectedCamera().label}}throw new Error("DCE not initialized")}async selectCamera(e){if(!this.camera)throw new Error("DCE not initialized");{let a=await this.camera.getAllCameras();for(let t=0;t<a.length;t++){const r=a[t];if(r.label===e.cameraID)return void await this.camera.selectCamera(r)}}}async setScanRegion(e){if(!this.camera)throw new Error("DCE not initialized");this.camera.setScanRegion({regionLeft:e.region.left,regionTop:e.region.top,regionRight:e.region.right,regionBottom:e.region.bottom,regionMeasuredByPercentage:e.region.measuredByPercentage})}async setZoom(e){if(!this.camera)throw new Error("DCE not initialized");await this.camera.setZoom(e.factor)}async setFocus(){throw new Error("Method not implemented.")}async toggleTorch(e){if(this.camera)try{e.on?await this.camera.turnOnTorch():await this.camera.turnOffTorch()}catch(e){throw new Error("Torch unsupported")}}async startCamera(){if(!this.camera)throw new Error("DCE not initialized");await this.camera.open(!0)}async stopCamera(){if(!this.camera)throw new Error("DCE not initialized");this.camera.close(!0)}async pauseCamera(){if(!this.camera)throw new Error("DCE not initialized");this.camera.pause()}async resumeCamera(){if(!this.camera)throw new Error("DCE not initialized");this.camera.resume()}async isOpen(){if(this.camera)return{isOpen:this.camera.isOpen()};throw new Error("DCE not initialized")}async takeSnapshot(e){if(this.camera){let a=85;return e.quality&&(a=e.quality),{base64:this.camera.getFrame().toCanvas().toDataURL("image/jpeg",a).replace("data:image/jpeg;base64,","")}}throw new Error("DCE not initialized")}async takeSnapshot2(){if(this.camera){return{frame:this.camera.getFrame()}}throw new Error("DCE not initialized")}async takePhoto(){if(this.camera){return{base64:this.camera.getFrame().toCanvas().toDataURL()}}throw new Error("DCE not initialized")}async requestCameraPermission(){const e=(await navigator.mediaDevices.getUserMedia({video:!0,audio:!1})).getTracks();for(let a=0;a<e.length;a++){e[a].stop()}}}var web=Object.freeze({__proto__:null,CameraPreviewWeb:CameraPreviewWeb});exports.CameraPreview=CameraPreview;
//# sourceMappingURL=/sm/cdea5cf2223d724e4d0419c1bb6e117f260ede1b8115c71c01502a504e09e6e5.map