import{r as t,h as i,H as s,g as o}from"./p-444192d7.js";import{c as e}from"./p-ab760d78.js";import{c as n,f as a,s as d,o as h}from"./p-384ed661.js";const r=class{constructor(i){t(this,i),this.show=!1,this.align="bottom",this.hover=!1,this.syncWidth=!1,this.offset=0}watchAlignAndShow(){this.updateDropdownContainer()}componentDidLoad(){this.container=this.el.querySelector(".dropdown-container"),this.updateDropdownContainer(),this.el.addEventListener("mouseenter",this.onMouseEnterOnContainer.bind(this)),this.el.addEventListener("mouseleave",this.onMouseLeaveOnContainer.bind(this))}disconectedCallback(){this.el&&(this.el.removeEventListener("mouseenter",this.onMouseEnterOnContainer),this.el.removeEventListener("mouseleave",this.onMouseLeaveOnContainer))}onMouseEnterOnContainer(){this.hover&&(this.show=!0)}onMouseLeaveOnContainer(){this.hover&&(this.show=!1)}updateDropdownContainer(){this.syncWidth?(this.container.style.maxWidth=`${this.el.offsetWidth}px`,this.container.style.width="100%"):(this.container.style.maxWidth="auto",this.container.style.width="auto"),setTimeout((()=>{n(this.el,this.container,{placement:this.align,middleware:[a(),d({padding:10}),h(this.offset)]}).then((({x:t,y:i})=>{this.container.style.left=`${t}px`,this.container.style.top=`${i}px`}))}),50)}async display(t){this.show=t}render(){return i(s,{key:"48df29d08ae8077798b586c71443872e1894f0bf"},i("slot",{key:"4c623391741dfad19c2e61e20a57327f0ca13c92"}),i("div",{key:"2d058e90c91481f871c41354c964ce87975e7732",class:e("dropdown-container",{"dropdown-show":this.show,"dropdown-hover":this.hover})},i("slot",{key:"71cc31936e0aefa2fd1570ede53838f1278139ff",name:"dropdown"})))}get el(){return o(this)}static get watchers(){return{align:["watchAlignAndShow"],show:["watchAlignAndShow"]}}};r.style="x-dropdown{display:inherit;text-align:inherit}x-dropdown .dropdown-container{display:block;width:-webkit-max-content;width:-moz-max-content;width:max-content;top:0;left:0;position:absolute;z-index:10000;visibility:hidden;opacity:0;-webkit-transition:opacity 0.3s;transition:opacity 0.3s;pointer-events:none}x-dropdown .dropdown-container.dropdown-show{pointer-events:initial;opacity:1;visibility:visible}";export{r as x_dropdown}