var __awaiter=this&&this.__awaiter||function(t,e,n,i){function o(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,r){function s(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i["throw"](t))}catch(t){r(t)}}function c(t){t.done?n(t.value):o(t.value).then(s,a)}c((i=i.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(t){return function(e){return c([t,e])}}function c(a){if(i)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(i=1,o&&(r=a[0]&2?o["return"]:a[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;if(o=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(t){a=[6,t];o=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,g as getElement}from"./index-aed5ae27.js";import{c as cls}from"./helpers-ea9d01ce.js";import{c as computePosition,f as flip,s as shift,o as offset}from"./floating-ui.dom.esm-6802681c.js";var styleCss="x-dropdown{display:inherit;text-align:inherit}x-dropdown .dropdown-container{display:none;width:-webkit-max-content;width:-moz-max-content;width:max-content;top:0;left:0;position:absolute;z-index:10000}x-dropdown .dropdown-container.dropdown-show{display:block;-webkit-animation:0.3s fadeIn;animation:0.3s fadeIn}";var XDropdownStyle0=styleCss;var XDropdown=function(){function t(t){registerInstance(this,t);this.show=false;this.align="bottom";this.hover=false;this.syncWidth=false;this.offset=0}t.prototype.onAlignWatch=function(){this.updateDropdownContainer()};t.prototype.componentDidLoad=function(){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))};t.prototype.disconectedCallback=function(){if(this.el){this.el.removeEventListener("mouseenter",this.onMouseEnterOnContainer);this.el.removeEventListener("mouseleave",this.onMouseLeaveOnContainer)}};t.prototype.onMouseEnterOnContainer=function(){if(this.hover){this.show=true}};t.prototype.onMouseLeaveOnContainer=function(){if(this.hover){this.show=false}};t.prototype.updateDropdownContainer=function(){var t=this;if(this.syncWidth){this.container.style.maxWidth="".concat(this.el.offsetWidth,"px");this.container.style.width="100%"}else{this.container.style.maxWidth="auto";this.container.style.width="auto"}setTimeout((function(){computePosition(t.el,t.container,{placement:t.align,middleware:[flip(),shift({padding:10}),offset(t.offset)]}).then((function(e){var n=e.x,i=e.y;t.container.style.left="".concat(n,"px");t.container.style.top="".concat(i,"px")}))}),50)};t.prototype.display=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.show=t;return[2]}))}))};t.prototype.render=function(){return h(Host,{key:"71e5bd83345ae6f95e820a7c4bbe477c2593436d"},h("slot",{key:"c68838e07e036ad4196ac0c44d16708c89c67313"}),h("div",{key:"ddb1c6581583632112eccf1a00163e75dbe9b243",class:cls("dropdown-container",{"dropdown-show":this.show,"dropdown-hover":this.hover})},h("slot",{key:"6be924779eae483e258cdb9ade1c9fbe72677fae",name:"dropdown"})))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{align:["onAlignWatch"],show:["onAlignWatch"]}},enumerable:false,configurable:true});return t}();XDropdown.style=XDropdownStyle0;export{XDropdown as x_dropdown};