import{b5 as O,aq as W,b4 as R}from"./index.45ec425b.js";import{basicProps as B}from"./props.e292b6c2.js";import{f as V,j as k,r as y,e as p,w as A,v as F,u as a,c as h}from"./vendor-@vue.d54eea3a.js";import{h as j,t as q}from"./vendor-@ant-design.e2d15990.js";var K=V({name:"BaseDargVerify",props:B,emits:["success","update:value","change","start","move","end"],setup(r,{emit:f,slots:T,expose:P}){const n=k({isMoving:!1,isPassing:!1,moveDistance:0,toLeft:!1,startTime:0,endTime:0}),L=y(null),m=y(null),w=y(null),d=y(null);O({el:document,name:"mouseup",listener:()=>{n.isMoving&&g()}});const X=p(()=>{const{height:t,actionStyle:s}=r,i=`${parseInt(t)}px`;return{left:0,width:i,height:i,...s}}),C=p(()=>{const{height:t,width:s,circle:i,wrapStyle:e}=r,o=parseInt(t);return{width:`${parseInt(s)}px`,height:`${o}px`,lineHeight:`${o}px`,borderRadius:i?o/2+"px":0,...e}}),N=p(()=>{const{height:t,circle:s,barStyle:i}=r,e=parseInt(t);return{height:`${e}px`,borderRadius:s?e/2+"px 0 0 "+e/2+"px":0,...i}}),_=p(()=>{const{height:t,width:s,contentStyle:i}=r,e=`${parseInt(t)}px`,o=`${parseInt(s)}px`;return{height:e,width:o,...i}});A(()=>n.isPassing,t=>{if(t){const{startTime:s,endTime:i}=n,e=(i-s)/1e3;f("success",{isPassing:t,time:e.toFixed(1)}),f("update:value",t),f("change",t)}}),F(()=>{n.isPassing=!!r.value});function x(t){return t.pageX||t.touches[0].pageX}function $(t){if(n.isPassing)return;const s=a(d);!s||(f("start",t),n.moveDistance=x(t)-parseInt(s.style.left.replace("px",""),10),n.startTime=new Date().getTime(),n.isMoving=!0)}function D(t){const s=parseInt(t.style.width),{width:i}=r,e=parseInt(i);return{offset:e-s-6,widthNum:e,actionWidth:s}}function M(t){const{isMoving:s,moveDistance:i}=n;if(s){const e=a(d),o=a(m);if(!e||!o)return;const{offset:c,widthNum:u,actionWidth:v}=D(e),l=x(t)-i;f("move",{event:t,moveDistance:i,moveX:l}),l>0&&l<=c?(e.style.left=`${l}px`,o.style.width=`${l+v/2}px`):l>c&&(e.style.left=`${u-v}px`,o.style.width=`${u-v/2}px`,r.isSlot||S())}}function E(t){const{isMoving:s,isPassing:i,moveDistance:e}=n;if(s&&!i){f("end",t);const o=a(d),c=a(m);if(!o||!c)return;const u=x(t)-e,{offset:v,widthNum:l,actionWidth:b}=D(o);u<v?r.isSlot?setTimeout(()=>{if(!r.value)g();else{const I=a(w);I&&(I.style.width=`${parseInt(c.style.width)}px`)}},0):g():(o.style.left=`${l-b}px`,c.style.width=`${l-b/2}px`,S()),n.isMoving=!1}}function S(){if(r.isSlot){g();return}n.endTime=new Date().getTime(),n.isPassing=!0,n.isMoving=!1}function g(){n.isMoving=!1,n.isPassing=!1,n.moveDistance=0,n.toLeft=!1,n.startTime=0,n.endTime=0;const t=a(d),s=a(m),i=a(w);!t||!s||!i||(n.toLeft=!0,W(()=>{n.toLeft=!1,t.style.left="0",s.style.width="0"},300),i.style.width=a(_).width)}return P({resume:g}),()=>{const t=()=>{const e=["darg-verify-bar"];return n.toLeft&&e.push("to-left"),h("div",{class:e,ref:m,style:a(N)},null)},s=()=>{const e=["darg-verify-content"],{isPassing:o}=n,{text:c,successText:u}=r;return o&&e.push("success"),h("div",{class:e,ref:w,style:a(_)},[R(T,"text",o)||(o?u:c)])},i=()=>{const e=["darg-verify-action"],{toLeft:o,isPassing:c}=n;return o&&e.push("to-left"),h("div",{class:e,onMousedown:$,onTouchstart:$,style:a(X),ref:d},[R(T,"actionIcon",c)||(c?h(j,{class:"darg-verify-action__icon"},null):h(q,{class:"darg-verify-action__icon"},null))])};return h("div",{class:"darg-verify",ref:L,style:a(C),onMousemove:M,onTouchmove:M,onMouseleave:E,onMouseup:E,onTouchend:E},[t(),s(),i()])}}});export{K as _};
