import{wasK}from"./index-DYrB6zKT.js";import{gasP}from"./index-CoCSl5nl.js";constX=K(void0);functionG(n,t){const{computePosition:E,autoUpdate:j,offset:h,shift:y,flip:b,arrow:L,size:$,autoPlacement:k,hide:x,inline:A}=P(X),r={open:!1,autoUpdateCleanup:()=>{}},m=':is(a[href], button, input, textarea, select, details, [tabindex]):not([tabindex="-1"])';letf;constu="https://www.skeleton.dev/utilities/popups";lete,c;functionU(){e=document.querySelector(`[data-popup="${t.target}"]`)??document.createElement("div"),c=e.querySelector(".arrow")??document.createElement("div")}U();functionp(){vari,s,w,F,D,C,q,I;if(!e)thrownewError(`The data-popup="${t.target}" element was not found. ${u}`);if(!E)thrownewError(`Floating UI 'computePosition' not found for data-popup="${t.target}". ${u}`);if(!h)thrownewError(`Floating UI 'offset' not found for data-popup="${t.target}". ${u}`);if(!y)thrownewError(`Floating UI 'shift' not found for data-popup="${t.target}". ${u}`);if(!b)thrownewError(`Floating UI 'flip' not found for data-popup="${t.target}". ${u}`);if(!L)thrownewError(`Floating UI 'arrow' not found for data-popup="${t.target}". ${u}`);consto=[];$&&o.push($((i=t.middleware)==null?void0:i.size)),k&&o.push(k((s=t.middleware)==null?void0:s.autoPlacement)),x&&o.push(x((w=t.middleware)==null?void0:w.hide)),A&&o.push(A((F=t.middleware)==null?void0:F.inline)),E(n,e,{placement:t.placement??"bottom",middleware:[h(((D=t.middleware)==null?void0:D.offset)??8),y(((C=t.middleware)==null?void0:C.shift)??{padding:8}),b((q=t.middleware)==null?void0:q.flip),L(((I=t.middleware)==null?void0:I.arrow)??{element:c||null}),...o]}).then(({x:z,y:M,placement:O,middlewareData:W})=>{if(Object.assign(e.style,{left:`${z}px`,top:`${M}px`}),c){const{x:T,y:Q}=W.arrow,_={top:"bottom",right:"left",bottom:"top",left:"right"}[O.split("-")[0]];Object.assign(c.style,{left:T!=null?`${T}px`:"",top:Q!=null?`${Q}px`:"",right:"",bottom:"",[_]:"-4px"})}})}functionl(){e&&(r.open=!0,t.state&&t.state({state:r.open}),p(),e.style.display="block",e.style.opacity="1",e.style.pointerEvents="auto",e.removeAttribute("inert"),r.autoUpdateCleanup=j(n,e,p),f=Array.from(e==null?void0:e.querySelectorAll(m)))}functiona(o){if(!e)return;consti=parseFloat(window.getComputedStyle(e).transitionDuration.replace("s",""))*1e3;setTimeout(()=>{r.open=!1,t.state&&t.state({state:r.open}),e.style.opacity="0",e.setAttribute("inert",""),r.autoUpdateCleanup&&r.autoUpdateCleanup(),o&&o()},i)}functiond(){r.open===!1?l():a()}functionv(o){if(r.open===!1||n.contains(o.target))return;if(e&&e.contains(o.target)===!1){a();return}consti=t.closeQuery===void0?"a[href], button":t.closeQuery;if(i==="")return;consts=e==null?void0:e.querySelectorAll(i);s==null||s.forEach(w=>{w.contains(o.target)&&a()})}constS=o=>{if(r.open===!1)return;consti=o.key;if(i==="Escape"){o.preventDefault(),n.focus(),a();return}f=Array.from(e==null?void0:e.querySelectorAll(m)),r.open&&document.activeElement===n&&(i==="ArrowDown"||i==="Tab")&&m.length>0&&f.length>0&&(o.preventDefault(),f[0].focus())};switch(t.event){case"click":n.addEventListener("click",d,!0),window.addEventListener("click",v,!0);break;case"hover":n.addEventListener("mouseover",l,!0),n.addEventListener("mouseleave",()=>a(),!0);break;case"focus-blur":n.addEventListener("focus",d,!0),n.addEventListener("blur",()=>a(),!0);break;case"focus-click":n.addEventListener("focus",l,!0),window.addEventListener("click",v,!0);break;default:thrownewError(`Event value of '${t.event}' is not supported. ${u}`)}returnwindow.addEventListener("keydown",S,!0),p(),{update(o){a(()=>{t=o,p(),U()})},destroy(){n.removeEventListener("click",d,!0),n.removeEventListener("mouseover",l,!0),n.removeEventListener("mouseleave",()=>a(),!0),n.removeEventListener("focus",d,!0),n.removeEventListener("focus",l,!0),n.removeEventListener("blur",()=>a(),!0),window.removeEventListener("click",v,!0),window.removeEventListener("keydown",S,!0)}}}export{Gasp,Xass};