import{B as L,a9 as R,u as d,a as T,l as k,C as l,D as o,G as i,U as p,a6 as V,Z as m,Y as _,F as w,V as E,$ as x,H as F,aa as C}from"./vue-DweYBrEc.js";import{S,j as r,A as U,C as N,_ as $,D as j}from"./index-fNs72j9w.js";const I=["id"],Y={key:0,class:"loading"},z={key:1,class:"captcha-img-box"},M=["src","alt"],X=["onClick"],Z={key:2,class:"captcha-prompt"},A={key:3,class:"captcha-prompt"},G={class:"captcha-refresh-box"},H=["title"],P=L({__name:"index",props:{uuid:{default:""},callback:{type:Function,default:()=>{}},class:{default:""},unset:{type:Boolean,default:!1},error:{default:r.global.t("validate.The correct area is not clicked, please try again!")},success:{default:r.global.t("validate.Verification is successful!")},apiBaseURL:{default:""}},emits:["destroy"],setup(h,{emit:u}){R(e=>({"09831d2d":d(S),d491669a:D.value,"2e1ecf29":B.value,"2545ff7a":a.captcha.width,"69aaf5f3":a.captcha.height}));const t=h,a=T({loading:!0,xy:[],tip:"",captcha:{id:"",text:"",base64:"",width:350,height:200}}),f=u,g=()=>{a.loading=!0,U(t.uuid,t.apiBaseURL).then(e=>{a.xy=[],a.tip="",a.loading=!1,a.captcha=e.data})},v=e=>{if(a.xy.length<a.captcha.text.length&&(a.xy.push(e.offsetX+","+e.offsetY),a.xy.length==a.captcha.text.length)){const s=[a.xy.join("-"),e.target.width,e.target.height].join(";");N(t.uuid,s,t.unset,t.apiBaseURL).then(()=>{a.tip=t.success,setTimeout(()=>{var c;(c=t.callback)==null||c.call(t,s),y()},1500)}).catch(()=>{a.tip=t.error,setTimeout(()=>{g()},1500)})}},b=e=>{a.xy.splice(e,1)},y=()=>{f("destroy")},B=k(()=>(a.captcha.height+200)/2+"px"),D=k(()=>(a.captcha.width+24)/2+"px");return g(),(e,s)=>(l(),o("div",{id:e.uuid},[i("div",{class:x(["ba-click-captcha",t.class])},[a.loading?(l(),o("div",Y,p(d(r).global.t("utils.Loading")),1)):(l(),o("div",z,[i("img",{class:"captcha-img",onClick:s[0]||(s[0]=V(c=>v(c),["prevent"])),src:a.captcha.base64,alt:d(r).global.t("validate.Captcha loading failed, please click refresh button")},null,8,M),(l(!0),o(m,null,_(a.xy,(c,n)=>(l(),o("span",{key:n,class:"step",onClick:J=>b(n),style:w(`left:${parseFloat(c.split(",")[0])-13}px;top:${parseFloat(c.split(",")[1])-13}px`)},p(n+1),13,X))),128))])),a.tip?(l(),o("div",Z,p(a.tip),1)):(l(),o("div",A,[E(p(d(r).global.t("validate.Please click"))+" ",1),(l(!0),o(m,null,_(a.captcha.text,(c,n)=>(l(),o("span",{key:n,class:x(a.xy.length>n?"clicaptcha-clicked":"")},p(c),3))),128))])),i("div",G,[s[1]||(s[1]=i("div",{class:"captcha-refresh-line captcha-refresh-line-l"},null,-1)),i("i",{class:"fa fa-refresh captcha-refresh-btn",title:d(r).global.t("Refresh"),onClick:g},null,8,H),s[2]||(s[2]=i("div",{class:"captcha-refresh-line captcha-refresh-line-r"},null,-1))])],2),i("div",{class:"ba-layout-shade",onClick:y})],8,I))}}),q=$(P,[["__scopeId","data-v-c3370b98"]]),Q=(h,u,t={})=>{const a=document.createElement("div"),f=F(q,{uuid:h,callback:u,...t,key:j(),onDestroy:()=>{C(null,a)}});C(f,a),document.body.appendChild(a.firstElementChild)};export{Q as c};
