const e=require("../type.js"),t=require("../raf.js"),n=require("../hooks/useState.js"),r=require("./util.js");let i=require("vue");function a(e){return Number.isNaN(e)?0:e}var o=(0,i.defineComponent)({props:{target:e.objectType(),className:String},setup(e){let o=(0,i.shallowRef)(null),[s,c]=n.default(null),[l,u]=n.default([]),[d,f]=n.default(0),[p,m]=n.default(0),[h,g]=n.default(0),[_,v]=n.default(0),[y,b]=n.default(!1);function x(){let{target:t}=e,n=getComputedStyle(t);c(r.getTargetWaveColor(t));let i=n.position===`static`,{borderLeftWidth:o,borderTopWidth:s}=n;f(i?t.offsetLeft:a(-Number.parseFloat(o))),m(i?t.offsetTop:a(-Number.parseFloat(s))),g(t.offsetWidth),v(t.offsetHeight);let{borderTopLeftRadius:l,borderTopRightRadius:d,borderBottomLeftRadius:p,borderBottomRightRadius:h}=n;u([l,d,h,p].map(e=>a(Number.parseFloat(e))))}let S,C,w,T=()=>{clearTimeout(w),t.default.cancel(C),S?.disconnect()},E=()=>{let e=o.value?.parentElement;e&&((0,i.render)(null,e),e.parentElement&&e.parentElement.removeChild(e))};(0,i.onMounted)(()=>{T(),w=setTimeout(()=>{E()},5e3);let{target:n}=e;n&&(C=t.default(()=>{x(),b(!0)}),typeof ResizeObserver<`u`&&(S=new ResizeObserver(x),S.observe(n)))}),(0,i.onBeforeUnmount)(()=>{T()});let D=e=>{e.propertyName===`opacity`&&E()};return()=>{if(!y.value)return null;let t={left:`${d.value}px`,top:`${p.value}px`,width:`${h.value}px`,height:`${_.value}px`,borderRadius:l.value.map(e=>`${e}px`).join(` `)};return s&&(t[`--wave-color`]=s.value),(0,i.createVNode)(i.Transition,{appear:!0,name:`wave-motion`,appearFromClass:`wave-motion-appear`,appearActiveClass:`wave-motion-appear`,appearToClass:`wave-motion-appear wave-motion-appear-active`},{default:()=>[(0,i.createVNode)(`div`,{ref:o,class:e.className,style:t,onTransitionend:D},null)]})}}});function s(e,t){let n=document.createElement(`div`);return n.style.position=`absolute`,n.style.left=`0px`,n.style.top=`0px`,e?.insertBefore(n,e?.firstChild),(0,i.render)((0,i.createVNode)(o,{target:e,className:t},null),n),()=>{(0,i.render)(null,n),n.parentElement&&n.parentElement.removeChild(n)}}exports.default=s;