1import{W as r,dr as i,du as a}from"./index-CIhbGVJX.js";import{LensFacing as s,BarcodeValueType as o}from"./index-iomQinYF.js";class l extends r{constructor(){super(...arguments),this._isSupported="BarcodeDetector"in window,this.errorVideoElementMissing="videoElement must be provided.",this.eventBarcodesScanned="barcodesScanned"}async startScan(e){if(!this._isSupported)throw this.createUnimplementedException();if(!e?.videoElement)throw new Error(this.errorVideoElementMissing);this.videoElement=e.videoElement,this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:e?.lensFacing===s.Front?"user":"environment"}},audio:!1}),e.videoElement.srcObject=this.stream,await e.videoElement.play();const n=new BarcodeDetector;this.intervalId=window.setInterval(async()=>{if(!e.videoElement)return;const t=await n.detect(e.videoElement);t.length!==0&&this.handleScannedBarcodes(t)},500)}async stopScan(){if(!this._isSupported)throw this.createUnimplementedException();this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=void 0),this.videoElement&&(this.videoElement.srcObject=null,this.videoElement=void 0)}async readBarcodesFromImage(e){throw this.createUnimplementedException()}async scan(){throw this.createUnimplementedException()}async isSupported(){return{supported:this._isSupported}}async enableTorch(){throw this.createUnimplementedException()}async disableTorch(){throw this.createUnimplementedException()}async toggleTorch(){throw this.createUnimplementedException()}async isTorchEnabled(){throw this.createUnimplementedException()}async isTorchAvailable(){return{available:!1}}async setZoomRatio(e){throw this.createUnimplementedException()}async getZoomRatio(){throw this.createUnimplementedException()}async getMinZoomRatio(){throw this.createUnimplementedException()}async getMaxZoomRatio(){throw this.createUnimplementedException()}async openSettings(){throw this.createUnimplementedException()}async isGoogleBarcodeScannerModuleAvailable(){throw this.createUnimplementedException()}async installGoogleBarcodeScannerModule(){throw this.createUnimplementedException()}async checkPermissions(){try{return{camera:(await navigator.permissions.query({name:"camera"})).state}}catch{return{camera:"prompt"}}}async requestPermissions(){try{return(await navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach(n=>n.stop()),{camera:"granted"}}catch{return{camera:"denied"}}}createUnimplementedException(){return new i("This method is not implemented on web.",a.Unimplemented)}handleScannedBarcodes(e){const n={barcodes:e.map(t=>({cornerPoints:[[t.cornerPoints[0].x,t.cornerPoints[0].y],[t.cornerPoints[1].x,t.cornerPoints[1].y],[t.cornerPoints[2].x,t.cornerPoints[2].y],[t.cornerPoints[3].x,t.cornerPoints[3].y]],displayValue:t.rawValue,rawValue:t.rawValue,format:t.format.toUpperCase(),valueType:o.Unknown}))};this.notifyListeners(this.eventBarcodesScanned,n)}}export{l as BarcodeScannerWeb};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.