var D=Object.defineProperty,F=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var P=(r,l,o)=>l in r?D(r,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[l]=o,C=(r,l)=>{for(var o in l||(l={}))z.call(l,o)&&P(r,o,l[o]);if(O)for(var o of O(l))H.call(l,o)&&P(r,o,l[o]);return r},$=(r,l)=>F(r,x(l));import{b as I,c as j,m as R,d as A,b2 as E,r as _,ab as G,w as K,aq as L,ag as N,b3 as U,ah as Q,f as X,o as J,g as h,h as y,j as Y,n as q,k as V,a5 as Z,a2 as W,q as ee}from"./index-C8qz7c0N.js";import{q as ae,r as se,p as le,c as te}from"./clickoutside.D2lvuuWI.js";import{u as oe}from"./useTouch.r5G7-plf.js";const ue=$(C({},I),{modelValue:R("close"),disabled:j(!1),beforeClose:Function}),ne={name:"wd-swipe-action",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"}},re=A($(C({},ne),{props:ue,emits:["click","update:modelValue"],setup(r,{expose:l,emit:o}){const i=r,p=o,c=E(ae,null),T=_(""),u=_(0),t=_(0),v=_(!1),m=oe(),{proxy:d}=G();K(()=>i.modelValue,(e,a)=>{S(e,a)},{deep:!0}),L(()=>{c&&c.pushToQueue?c.pushToQueue(d):le(d),u.value=0,t.value=0,v.value=!1}),N(()=>{v.value=!0,S(i.modelValue),v.value=!1}),U(()=>{c&&c.removeFromQueue?c.removeFromQueue(d):se(d)});function S(e,a){i.disabled||k().then(([s,f])=>{switch(e){case"close":if(t.value===0)return;b("value",a);break;case"left":n(s);break;case"right":n(-f);break}})}function k(){return Promise.all([Q(".wd-swipe-action__left",!1,d).then(e=>e.width?e.width:0),Q(".wd-swipe-action__right",!1,d).then(e=>e.width?e.width:0)])}function n(e=0){const a=`translate3d(${e}px, 0, 0)`,s=v.value?"none":".6s cubic-bezier(0.18, 0.89, 0.32, 1)";T.value=`
        -webkit-transform: ${a};
        -webkit-transition: ${s};
        transform: ${a};
        transition: ${s};
      `,t.value=e}function g(e){i.disabled||t.value===0||(e=e||"inside",b("click",e),p("click",{value:e}))}function w(e){i.disabled||(u.value=t.value,m.touchStart(e),c&&c.closeOther?c.closeOther(d):te(d))}function B(e){if(i.disabled||(m.touchMove(e),m.direction.value==="vertical"))return;e.preventDefault(),e.stopPropagation(),v.value=!0;const a=u.value+m.deltaX.value;k().then(([s,f])=>{if(s===0&&a>0||f===0&&a<0)return n(0),w(e);if(s!==0&&a>=s)return n(s),w(e);if(f!==0&&-a>=f)return n(-f),w(e);n(a)})}function M(){if(i.disabled)return;const e=.3;v.value=!1,k().then(([a,s])=>{u.value<0&&t.value<0&&t.value-u.value<s*e?(n(-s),p("update:modelValue","right")):u.value>0&&t.value>0&&u.value-t.value<a*e?(n(a),p("update:modelValue","left")):s>0&&u.value>=0&&t.value<0&&Math.abs(t.value)>s*e?(n(-s),p("update:modelValue","right")):a>0&&u.value<=0&&t.value>0&&Math.abs(t.value)>a*e?(n(a),p("update:modelValue","left")):b("swipe")})}function b(e,a){if(e==="swipe"&&u.value===0)return n(0);e==="swipe"&&u.value>0?a="left":e==="swipe"&&u.value<0&&(a="right"),e&&a&&i.beforeClose&&i.beforeClose(e,a),n(0),i.modelValue!=="close"&&p("update:modelValue","close")}return l({close:b}),(e,a)=>{const s=Y;return J(),X(s,{class:W(`wd-swipe-action ${e.customClass}`),style:q(e.customStyle),onClick:a[2]||(a[2]=Z(f=>g(),["stop"])),onTouchstart:w,onTouchmove:B,onTouchend:M,onTouchcancel:M},{default:h(()=>[y(s,{class:"wd-swipe-action__wrapper",style:q(T.value)},{default:h(()=>[y(s,{class:"wd-swipe-action__left",onClick:a[0]||(a[0]=f=>g("left"))},{default:h(()=>[V(e.$slots,"left",{},void 0,!0)]),_:3}),V(e.$slots,"default",{},void 0,!0),y(s,{class:"wd-swipe-action__right",onClick:a[1]||(a[1]=f=>g("right"))},{default:h(()=>[V(e.$slots,"right",{},void 0,!0)]),_:3})]),_:3},8,["style"])]),_:3},8,["class","style"])}}})),pe=ee(re,[["__scopeId","data-v-ec0f42c7"]]);export{pe as _};
