(function(n,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(n=typeof globalThis<"u"?globalThis:n||self,l(n.index={}))})(this,function(n){"use strict";const l="",d={event:"mousedown",transition:200},f={beforeMount:(e,t)=>{var h,v,u;if(t.value===!1)return;const s=((h=t==null?void 0:t.value)==null?void 0:h.color)||"#00000050",c=((v=t==null?void 0:t.value)==null?void 0:v.duration)||200,p=(u=t==null?void 0:t.value)==null?void 0:u.zIndex,m=t!=null&&t.value?.2:.3;d.transition=c;const R=e.getAttribute("ripple-background")||s;C(Object.keys(t.modifiers),d);const T=R||f.background,b=f.zIndex||p;e.addEventListener(d.event,x=>{j({event:x,el:e,background:T,zIndex:b,opacity:m})})},updated(e,t){var c,p;if(!t.value){(c=e==null?void 0:e.clearRipple)==null||c.call(e);return}const s=e.getAttribute("ripple-background");(p=e==null?void 0:e.setBackground)==null||p.call(e,s)}};function j({event:e,el:t,zIndex:s,background:c,opacity:p}){const m=parseInt(getComputedStyle(t).borderWidth.replace("px","")),R=e.clientX||e.touches[0].clientX,T=e.clientY||e.touches[0].clientY,b=t.getBoundingClientRect(),{left:h,top:v}=b,{offsetWidth:u,offsetHeight:x}=t,{transition:B}=d,g=R-h,y=T-v,k=Math.max(g,u-g),$=Math.max(y,x-y),M=window.getComputedStyle(t),E=Math.sqrt(k*k+$*$),N=m>0?m:0,r=document.createElement("div"),i=document.createElement("div");r.className="ripple",Object.assign(r.style??{},{marginTop:"0px",marginLeft:"0px",width:"1px",height:"1px",transition:`all ${B}ms cubic-bezier(0.4, 0, 0.2, 1)`,borderRadius:"50%",pointerEvents:"none",position:"relative",zIndex:s??"9999",backgroundColor:c??"rgba(0, 0, 0, 0.3)",opacity:p}),i.className="ripple-container",Object.assign(i.style??{},{position:"absolute",left:`${0-N}px`,top:`${0-N}px`,height:"0",width:"0",pointerEvents:"none",overflow:"hidden"});const L=t.style.position.length>0?t.style.position:getComputedStyle(t).position;L!=="relative"&&(t.style.position="relative"),i.appendChild(r),t.appendChild(i),Object.assign(r.style,{marginTop:`${y}px`,marginLeft:`${g}px`});const{borderTopLeftRadius:z,borderTopRightRadius:I,borderBottomLeftRadius:S,borderBottomRightRadius:P}=M;Object.assign(i.style,{width:`${u}px`,height:`${x}px`,direction:"ltr",borderTopLeftRadius:z,borderTopRightRadius:I,borderBottomLeftRadius:S,borderBottomRightRadius:P}),setTimeout(()=>{const o=`${E*2}px`;Object.assign(r.style??{},{width:o,height:o,marginLeft:`${g-E}px`,marginTop:`${y-E}px`})},0);function a(){setTimeout(()=>{r.style.backgroundColor="rgba(0, 0, 0, 0)"},250),setTimeout(()=>{var o;(o=i==null?void 0:i.parentNode)==null||o.removeChild(i)},850),t.removeEventListener("mouseup",a,!1),t.removeEventListener("mouseleave",a,!1),t.removeEventListener("dragstart",a,!1),setTimeout(()=>{let o=!0;for(let w=0;w<t.childNodes.length;w++)t.childNodes[w].className==="ripple-container"&&(o=!1);o&&(t.style.position=L!=="static"?L:"")},d.transition+260)}e.type==="mousedown"?(t.addEventListener("mouseup",a,!1),t.addEventListener("mouseleave",a,!1),t.addEventListener("dragstart",a,!1)):a(),t.setBackground=o=>{o&&(r.style.backgroundColor=o)}}function C(e,t){e.forEach(s=>{isNaN(Number(s))?t.event=s:t.transition=s})}const O={title:"Ripple 水波纹",category:"通用",status:"100%",install(e){e.directive("GRipple",f)}};n.RippleDirective=f,n.default=O,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
