import{g as V,bT as g,h as C,d as L,o as $,v as w,U as _,y as G,s as q,aC as y,k,u as J,a as K,i as Q,e as X,x as Y}from"./preload-helper.BAt0wiQU.js";import{w as S,f as Z}from"./motion.DDNFslEg.js";import{u as l}from"./useState.9-uUdCQD.js";const ee=e=>{const{componentCls:t,colorPrimary:o}=e;return{[t]:{position:"absolute",background:"transparent",pointerEvents:"none",boxSizing:"border-box",color:"var(--wave-color, ".concat(o,")"),boxShadow:"0 0 0 0 currentcolor",opacity:.2,"&.wave-motion-appear":{transition:["box-shadow 0.4s ".concat(e.motionEaseOutCirc),"opacity 2s ".concat(e.motionEaseOutCirc)].join(","),"&-active":{boxShadow:"0 0 0 6px currentcolor",opacity:0}}}}},te=V("Wave",e=>[ee(e)]);function oe(e){const t=(e||"").match(/rgba?\((\d*), (\d*), (\d*)(, [\d.]*)?\)/);return t&&t[1]&&t[2]&&t[3]?!(t[1]===t[2]&&t[2]===t[3]):!0}function b(e){return e&&e!=="#fff"&&e!=="#ffffff"&&e!=="rgb(255, 255, 255)"&&e!=="rgba(255, 255, 255, 1)"&&oe(e)&&!/rgba\((?:\d*, ){3}0\)/.test(e)&&e!=="transparent"}function ae(e){const{borderTopColor:t,borderColor:o,backgroundColor:r}=getComputedStyle(e);return b(t)?t:b(o)?o:b(r)?r:null}function h(e){return Number.isNaN(e)?0:e}const ne=L({props:{target:G(),className:String},setup(e){const t=q(null),[o,r]=l(null),[d,i]=l([]),[u,m]=l(0),[c,p]=l(0),[a,v]=l(0),[O,B]=l(0),[I,j]=l(!1);function T(){const{target:n}=e,s=getComputedStyle(n);r(ae(n));const R=s.position==="static",{borderLeftWidth:F,borderTopWidth:A}=s;m(R?n.offsetLeft:h(-parseFloat(F))),p(R?n.offsetTop:h(-parseFloat(A))),v(n.offsetWidth),B(n.offsetHeight);const{borderTopLeftRadius:D,borderTopRightRadius:H,borderBottomLeftRadius:M,borderBottomRightRadius:P}=s;i([D,H,P,M].map(U=>h(parseFloat(U))))}let f,W,x;const E=()=>{clearTimeout(x),S.cancel(W),f==null||f.disconnect()},N=()=>{var n;const s=(n=t.value)===null||n===void 0?void 0:n.parentElement;s&&(g(null,s),s.parentElement&&s.parentElement.removeChild(s))};$(()=>{E(),x=setTimeout(()=>{N()},5e3);const{target:n}=e;n&&(W=S(()=>{T(),j(!0)}),typeof ResizeObserver<"u"&&(f=new ResizeObserver(T),f.observe(n)))}),w(()=>{E()});const z=n=>{n.propertyName==="opacity"&&N()};return()=>{if(!I.value)return null;const n={left:"".concat(u.value,"px"),top:"".concat(c.value,"px"),width:"".concat(a.value,"px"),height:"".concat(O.value,"px"),borderRadius:d.value.map(s=>"".concat(s,"px")).join(" ")};return o&&(n["--wave-color"]=o.value),C(_,{appear:!0,name:"wave-motion",appearFromClass:"wave-motion-appear",appearActiveClass:"wave-motion-appear",appearToClass:"wave-motion-appear wave-motion-appear-active"},{default:()=>[C("div",{ref:t,class:e.className,style:n,onTransitionend:z},null)]})}}});function re(e,t){const o=document.createElement("div");return o.style.position="absolute",o.style.left="0px",o.style.top="0px",e==null||e.insertBefore(o,e==null?void 0:e.firstChild),g(C(ne,{target:e,className:t},null),o),()=>{g(null,o),o.parentElement&&o.parentElement.removeChild(o)}}function se(e,t){const o=k();let r;function d(){var i;const u=y(o);r==null||r(),!(!((i=t==null?void 0:t.value)===null||i===void 0)&&i.disabled||!u)&&(r=re(u,e.value))}return w(()=>{r==null||r()}),d}const ue=L({compatConfig:{MODE:3},name:"Wave",props:{disabled:Boolean},setup(e,t){let{slots:o}=t;const r=k(),{prefixCls:d,wave:i}=J("wave",e),[,u]=te(d),m=se(Q(()=>X(d.value,u.value)),i);let c;const p=()=>{y(r).removeEventListener("click",c,!0)};return $(()=>{K(()=>e.disabled,()=>{p(),Y(()=>{const a=y(r);a==null||a.removeEventListener("click",c,!0),!(!a||a.nodeType!==1||e.disabled)&&(c=v=>{v.target.tagName==="INPUT"||!Z(v.target)||!a.getAttribute||a.getAttribute("disabled")||a.disabled||a.className.includes("disabled")||a.className.includes("-leave")||m()},a.addEventListener("click",c,!0))})},{immediate:!0,flush:"post"})}),w(()=>{p()}),()=>{var a;return(a=o.default)===null||a===void 0?void 0:a.call(o)[0]}}});export{ue as W};
