import{aK as F,J as ee,aL as te,az as ne,r as t,A as L,ad as se,w as ve,b as re,o as T,c as B,a as e,aB as w,C as n,P as ie,ae,k as he,B as de,n as G,D as M,h as K,ab as ge,aF as oe,aM as ce,aN as ue,F as fe,i as ye,H as me,aO as be,O as Se,g as xe,aP as we}from"./index-BP6bNRoi.js";function Y(i,f="XwKsGlMcdPMEhR1B"){const l=F.enc.Utf8.parse(f),o=F.enc.Utf8.parse(i);return F.AES.encrypt(o,l,{mode:F.mode.ECB,padding:F.pad.Pkcs7}).toString()}function pe(i){let f,l,o,g;const r=window,c=i.$el.parentNode.offsetWidth||r.offsetWidth,y=i.$el.parentNode.offsetHeight||r.offsetHeight;return f=i.imgSize.width.indexOf("%")!=-1?parseInt(i.imgSize.width)/100*c+"px":i.imgSize.width,l=i.imgSize.height.indexOf("%")!=-1?parseInt(i.imgSize.height)/100*y+"px":i.imgSize.height,o=i.barSize.width.indexOf("%")!=-1?parseInt(i.barSize.width)/100*c+"px":i.barSize.width,g=i.barSize.height.indexOf("%")!=-1?parseInt(i.barSize.height)/100*y+"px":i.barSize.height,{imgWidth:f,imgHeight:l,barWidth:o,barHeight:g}}const ze={style:{position:"relative"}},ke=["src"],We=[n("i",{class:"iconfont icon-refresh"},null,-1)],Te=["textContent"],He=["textContent"],Ie=["src"],Oe={__name:"VerifySlide",props:{captchaType:{type:String},type:{type:String,default:"1"},mode:{type:String,default:"fixed"},vSpace:{type:Number,default:5},explain:{type:String,default:""},imgSize:{type:Object,default:()=>({width:"310px",height:"155px"})},blockSize:{type:Object,default:()=>({width:"50px",height:"50px"})},barSize:{type:Object,default:()=>({width:"310px",height:"30px"})}},setup(i){const f=i,{t:l}=ee(),{mode:o,captchaType:g,type:r,blockSize:c,explain:y}=te(f),{proxy:p}=ne();let u=t(""),z=t(""),P=t(""),_=t(""),H=t(""),m=t(""),j=t(""),b=t(""),k=t(""),D=t(""),v=L({imgHeight:0,imgWidth:0,barHeight:0,barWidth:0}),C=t(void 0),I=t(void 0),O=t(void 0),N=t("#ddd"),$=t(void 0),E=t("icon-right"),J=t(!1),d=t(!1),s=t(!0),S=t(""),x=t(""),X=t(0);const V=se(()=>p.$el.querySelector(".verify-bar-area")),R=()=>{y.value===""?k.value=l("captcha.slide"):k.value=y.value,le(),oe(()=>{let{imgHeight:a,imgWidth:h,barHeight:W,barWidth:Z}=pe(p);v.imgHeight=a,v.imgWidth=h,v.barHeight=W,v.barWidth=Z,p.$parent.$emit("ready",p)}),window.removeEventListener("touchmove",function(a){A(a)}),window.removeEventListener("mousemove",function(a){A(a)}),window.removeEventListener("touchend",function(){U()}),window.removeEventListener("mouseup",function(){U()}),window.addEventListener("touchmove",function(a){A(a)}),window.addEventListener("mousemove",function(a){A(a)}),window.addEventListener("touchend",function(){U()}),window.addEventListener("mouseup",function(){U()})};ve(r,()=>{R()}),re(()=>{R(),p.$el.onselectstart=function(){return!1}});const q=a=>{if((a=a||window.event).touches)h=a.touches[0].pageX;else var h=a.clientX;X.value=Math.floor(h-V.value.getBoundingClientRect().left),m.value=+new Date,d.value==0&&(k.value="",O.value="#337ab7",N.value="#337AB7",$.value="#fff",a.stopPropagation(),J.value=!0)},A=a=>{if(a=a||window.event,J.value&&d.value==0){if(a.touches)h=a.touches[0].pageX;else var h=a.clientX;var W=h-V.value.getBoundingClientRect().left;W>=V.value.offsetWidth-parseInt(parseInt(c.value.width)/2)-2&&(W=V.value.offsetWidth-parseInt(parseInt(c.value.width)/2)-2),W<=0&&(W=parseInt(parseInt(c.value.width)/2)),C.value=W-X.value+"px",I.value=W-X.value+"px"}},U=()=>{if(j.value=+new Date,J.value&&d.value==0){var a=parseInt((C.value||"0").replace("px",""));a=310*a/parseInt(v.imgWidth);let h={captchaType:g.value,pointJson:u.value?Y(JSON.stringify({x:a,y:5}),u.value):JSON.stringify({x:a,y:5}),token:H.value};ce(h).then(W=>{if(W.repCode=="0000"){O.value="#5cb85c",N.value="#5cb85c",$.value="#fff",E.value="icon-check",s.value=!1,d.value=!0,o.value=="pop"&&setTimeout(()=>{p.$parent.clickShow=!1,Q()},1500),z.value=!0,b.value=`${((j.value-m.value)/1e3).toFixed(2)}s ${l("captcha.success")}`;var Z=u.value?Y(H.value+"---"+JSON.stringify({x:a,y:5}),u.value):H.value+"---"+JSON.stringify({x:a,y:5});setTimeout(()=>{b.value="",p.$parent.closeBox(),p.$parent.$emit("success",{captchaVerification:Z})},1e3)}else O.value="#d9534f",N.value="#d9534f",$.value="#fff",E.value="icon-close",z.value=!1,setTimeout(function(){Q()},1e3),p.$parent.$emit("error",p),b.value=l("captcha.fail"),setTimeout(()=>{b.value=""},1e3)}),J.value=!1}},Q=async()=>{s.value=!0,D.value="",S.value="left .3s",C.value=0,I.value=void 0,x.value="width .3s",N.value="#ddd",O.value="#fff",$.value="#000",E.value="icon-right",d.value=!1,await le(),setTimeout(()=>{x.value="",S.value="",k.value=y.value},300)},le=async()=>{let a={captchaType:g.value};const h=await ue(a);h.repCode=="0000"?(P.value=h.repData.originalImageBase64,_.value=h.repData.jigsawImageBase64,H.value=h.repData.token,u.value=h.repData.secretKey):b.value=h.repMsg};return(a,h)=>(T(),B("div",ze,[e(r)==="2"?(T(),B("div",{key:0,style:w({height:parseInt(e(v).imgHeight)+i.vSpace+"px"}),class:"verify-img-out"},[n("div",{style:w({width:e(v).imgWidth,height:e(v).imgHeight}),class:"verify-img-panel"},[n("img",{src:"data:image/png;base64,"+e(P),alt:"",style:{display:"block",width:"100%",height:"100%"}},null,8,ke),ie(n("div",{class:"verify-refresh",onClick:Q},We,512),[[ae,e(s)]]),he(ge,{name:"tips"},{default:de(()=>[e(b)?(T(),B("span",{key:0,class:G([e(z)?"suc-bg":"err-bg","verify-tips"])},M(e(b)),3)):K("",!0)]),_:1})],4)],4)):K("",!0),n("div",{style:w({width:e(v).imgWidth,height:i.barSize.height,"line-height":i.barSize.height}),class:"verify-bar-area"},[n("span",{class:"verify-msg",textContent:M(e(k))},null,8,Te),n("div",{style:w({width:e(I)!==void 0?e(I):i.barSize.height,height:i.barSize.height,"border-color":e(N),transaction:e(x)}),class:"verify-left-bar"},[n("span",{class:"verify-msg",textContent:M(e(D))},null,8,He),n("div",{style:w({width:i.barSize.height,height:i.barSize.height,"background-color":e(O),left:e(C),transition:e(S)}),class:"verify-move-block",onMousedown:q,onTouchstart:q},[n("i",{class:G(["verify-icon iconfont",e(E)]),style:w({color:e($)})},null,6),e(r)==="2"?(T(),B("div",{key:0,style:w({width:Math.floor(47*parseInt(e(v).imgWidth)/310)+"px",height:e(v).imgHeight,top:"-"+(parseInt(e(v).imgHeight)+i.vSpace)+"px","background-size":e(v).imgWidth+" "+e(v).imgHeight}),class:"verify-sub-block"},[n("img",{src:"data:image/png;base64,"+e(_),alt:"",style:{display:"block",width:"100%",height:"100%","-webkit-user-drag":"none"}},null,8,Ie)],4)):K("",!0)],36)],4)],4)]))}},$e={style:{position:"relative"}},Be={class:"verify-img-out"},Ce=[n("i",{class:"iconfont icon-refresh"},null,-1)],Ne=["src"],je={class:"verify-msg"},De={name:"Vue3Verify",components:{VerifySlide:Oe,VerifyPoints:{__name:"VerifyPoints",props:{mode:{type:String,default:"fixed"},captchaType:{type:String},vSpace:{type:Number,default:5},imgSize:{type:Object,default:()=>({width:"310px",height:"155px"})},barSize:{type:Object,default:()=>({width:"310px",height:"40px"})}},setup(i){const f=i,{t:l}=ee(),{mode:o,captchaType:g}=te(f),{proxy:r}=ne();let c=t(""),y=t(3),p=L([]),u=L([]),z=t(1),P=t(""),_=L([]),H=t(""),m=L({imgHeight:0,imgWidth:0,barHeight:0,barWidth:0}),j=L([]),b=t(""),k=t(void 0),D=t(void 0),v=t(!0),C=t(!0);re(()=>{p.splice(0,p.length),u.splice(0,u.length),z.value=1,E(),oe(()=>{let{imgHeight:d,imgWidth:s,barHeight:S,barWidth:x}=pe(r);m.imgHeight=d,m.imgWidth=s,m.barHeight=S,m.barWidth=x,r.$parent.$emit("ready",r)}),r.$el.onselectstart=function(){return!1}});const I=t(null),O=function(d,s){return{x:s.offsetX,y:s.offsetY}},N=function(d){return j.push(Object.assign({},d)),z.value+1},$=async function(){j.splice(0,j.length),k.value="#000",D.value="#ddd",C.value=!0,p.splice(0,p.length),u.splice(0,u.length),z.value=1,await E(),v.value=!0},E=async()=>{let d={captchaType:g.value};const s=await ue(d);s.repCode=="0000"?(P.value=s.repData.originalImageBase64,H.value=s.repData.token,c.value=s.repData.secretKey,_.value=s.repData.wordList,b.value=l("captcha.point")+"\u3010"+_.value.join(",")+"\u3011"):b.value=s.repMsg},J=function(d,s){return d.map(S=>({x:Math.round(310*S.x/parseInt(s.imgWidth)),y:Math.round(155*S.y/parseInt(s.imgHeight))}))};return(d,s)=>(T(),B("div",$e,[n("div",Be,[n("div",{style:w({width:e(m).imgWidth,height:e(m).imgHeight,"background-size":e(m).imgWidth+" "+e(m).imgHeight,"margin-bottom":i.vSpace+"px"}),class:"verify-img-panel"},[ie(n("div",{class:"verify-refresh",style:{"z-index":"3"},onClick:$},Ce,512),[[ae,e(v)]]),n("img",{ref_key:"canvas",ref:I,src:"data:image/png;base64,"+e(P),alt:"",style:{display:"block",width:"100%",height:"100%"},onClick:s[0]||(s[0]=S=>e(C)?(x=>{if(u.push(O(I,x)),z.value==y.value){z.value=N(O(I,x));let X=J(u,m);u.length=0,u.push(...X),setTimeout(()=>{var V=c.value?Y(H.value+"---"+JSON.stringify(u),c.value):H.value+"---"+JSON.stringify(u);let R={captchaType:g.value,pointJson:c.value?Y(JSON.stringify(u),c.value):JSON.stringify(u),token:H.value};ce(R).then(q=>{q.repCode=="0000"?(k.value="#4cae4c",D.value="#5cb85c",b.value=l("captcha.success"),C.value=!1,o.value=="pop"&&setTimeout(()=>{r.$parent.clickShow=!1,$()},1500),r.$parent.$emit("success",{captchaVerification:V})):(r.$parent.$emit("error",r),k.value="#d9534f",D.value="#d9534f",b.value=l("captcha.fail"),setTimeout(()=>{$()},700))})},400)}z.value(T(),B("div",{key:x,style:w({"background-color":"#1abd6c",color:"#fff","z-index":9999,width:"20px",height:"20px","text-align":"center","line-height":"20px","border-radius":"50%",position:"absolute",top:parseInt(S.y-10)+"px",left:parseInt(S.x-10)+"px"}),class:"point-area"},M(x+1),5))),128))],4)]),n("div",{style:w({width:e(m).imgWidth,color:e(k),"border-color":e(D),"line-height":i.barSize.height}),class:"verify-bar-area"},[n("span",je,M(e(b)),1)],4)]))}}},props:{captchaType:{type:String,required:!0},figure:{type:Number},arith:{type:Number},mode:{type:String,default:"pop"},vSpace:{type:Number},explain:{type:String},imgSize:{type:Object,default:()=>({width:"310px",height:"155px"})},blockSize:{type:Object},barSize:{type:Object}},setup(i){const{t:f}=ee(),{captchaType:l,mode:o}=te(i),g=t(!1),r=t(void 0),c=t(void 0),y=t({}),p=se(()=>o.value!="pop"||g.value);return be(()=>{switch(l.value){case"blockPuzzle":r.value="2",c.value="VerifySlide";break;case"clickWord":r.value="",c.value="VerifyPoints"}}),{t:f,clickShow:g,verifyType:r,componentType:c,instance:y,showBox:p,closeBox:()=>{g.value=!1,y.value.refresh&&y.value.refresh()},show:()=>{o.value=="pop"&&(g.value=!0)}}}},Ee={key:0,class:"verifybox-top"},Je=[n("i",{class:"iconfont icon-close"},null,-1)],Ve=me(De,[["render",function(i,f,l,o,g,r){return ie((T(),B("div",{class:G(l.mode=="pop"?"mask":"")},[n("div",{class:G(l.mode=="pop"?"verifybox":""),style:w({"max-width":parseInt(l.imgSize.width)+20+"px"})},[l.mode=="pop"?(T(),B("div",Ee,[Se(M(o.t("captcha.verification"))+" ",1),n("span",{class:"verifybox-close",onClick:f[0]||(f[0]=(...c)=>o.closeBox&&o.closeBox(...c))},Je)])):K("",!0),n("div",{style:w({padding:l.mode=="pop"?"10px":"0"}),class:"verifybox-bottom"},[o.componentType?(T(),xe(we(o.componentType),{key:0,ref:"instance",arith:l.arith,barSize:l.barSize,blockSize:l.blockSize,captchaType:l.captchaType,explain:l.explain,figure:l.figure,imgSize:l.imgSize,mode:l.mode,type:o.verifyType,vSpace:l.vSpace},null,8,["arith","barSize","blockSize","captchaType","explain","figure","imgSize","mode","type","vSpace"])):K("",!0)],4)],6)],2)),[[ae,o.showBox]])}]]);export{Ve as _};