import{B as e}from"./vendor-zxing-UoEhqgzi.js";import{S as s}from"./SvgIcon-a1Rg7hQY.js";import{ar as a,U as o,r as n,j as t,ab as c,o as l,b as i,h as r,n as v,q as u,f as d,t as m,u as b}from"./vendor-jA_NIjzi.js";import{_ as p}from"./common-store-kFD1YPwN.js";const h={class:"qrcode-scanner-container"},g={class:"scan-box"},x={key:0,class:"scan-animation"},f={key:1,class:"loading"},I={key:2,class:"error-text"},_=p(a({__name:"index",props:{videoListIndex:{type:Number}},emits:["scaned","update:videoListIndex","close"],setup(a,{expose:p,emit:_}){const{t:w}=o(),j=a,q=_,k=new e,y=n(!1),D=n(""),L=n(""),C=n(""),S=n([]),V=()=>{k.decodeFromVideoDevice(C.value,"qrcode-scanner",(e=>{if(e){const s=e.getText();k.stopContinuousDecode(),L.value=s,q("scaned",L.value)}y.value&&(y.value=!1)})).catch((e=>{z(e)}))},z=e=>{y.value=!1,"Permission denied"===e.message?D.value="授权失败":D.value="初始化异常请重试"};return p({render:k}),t((()=>{y.value=!0,k.listVideoInputDevices().then((e=>{var s,a;e.length?(S.value=e,C.value=null==(s=e[j.videoListIndex])?void 0:s.deviceId,C.value||(C.value=null==(a=e[0])?void 0:a.deviceId),V()):(y.value=!1,D.value="未检测到摄像头")})).catch((e=>{z(e)}))})),c((()=>{k.reset()})),(e,a)=>(l(),i("div",h,[a[2]||(a[2]=r("video",{id:"qrcode-scanner"},null,-1)),r("div",g,[r("div",{class:v(["scan-icon",{"color-white":!L.value,"color-blue":L.value}])},[u(s,{class:"scan-top-left",name:"scanner-subtract"}),u(s,{class:"scan-top-right absolute right-16 top-16 h-42 w-42",name:"scanner-subtract"}),u(s,{class:"scan-bottom-left absolute bottom-16 left-16 h-42 w-42",name:"scanner-subtract"}),u(s,{class:"scan-bottom-right absolute bottom-16 right-16 h-42 w-42",name:"scanner-subtract"})],2),y.value||D.value||L.value?d("",!0):(l(),i("div",x,a[1]||(a[1]=[r("div",{class:"scanning"},null,-1)]))),y.value?(l(),i("div",f,m(b(w)("加载中"))+"...",1)):d("",!0),D.value?(l(),i("div",I,m(D.value),1)):d("",!0)]),r("div",{class:"close-btn",onClick:a[0]||(a[0]=e=>q("close"))},[u(s,{name:"closeIcon",class:"close-svg"})])]))}}),[["__scopeId","data-v-83586e54"],["__file","index.vue"]]);export{_ as Q};
