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{f(i.next(t))}catch(t){r(t)}}function a(t){try{f(i["throw"](t))}catch(t){r(t)}}function f(t){t.done?n(t.value):o(t.value).then(s,a)}f((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 f([t,e])}}function f(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-966f70a5.js";import{c as cls}from"./helpers-e48a05ff.js";import{c as createPopper}from"./popper-0fbeff6d.js";var styleCss="x-dropdown{display:inherit;text-align:inherit}x-dropdown .dropdown-container{position:absolute;visibility:hidden;z-index:-1}x-dropdown .dropdown-container.dropdown-show{z-index:10000;visibility:visible;-webkit-animation:0.4s fadeIn;animation:0.4s fadeIn}";var XDropdownStyle0=styleCss;var popperDefaultConfig={placement:"auto",modifiers:[{name:"offset",options:{offset:[0,0]}}]};var XDropdown=function(){function t(t){registerInstance(this,t);this.show=false;this.align="bottom";this.hover=false;this.syncWidth=false}t.prototype.onAlignWatch=function(){this.updatePopper()};t.prototype.componentDidLoad=function(){var t=this;this.container=this.el.querySelector(".dropdown-container");this.updatePopper();this.el.addEventListener("mouseenter",(function(){if(t.hover){t.show=true}}));this.el.addEventListener("mouseleave",(function(){if(t.hover){t.show=false}}))};t.prototype.disconectedCallback=function(){if(this.popper){this.popper.destroy()}};t.prototype.updatePopper=function(){this.popper=createPopper(this.el,this.container,Object.assign(Object.assign({},popperDefaultConfig),{placement:this.align}));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"}};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:"ecfd7bf191d9fe90c4157e6c05bb4074fb33fc57"},h("slot",{key:"5a720b6b5f9dd78c76945dbbaa148dc19bf1e0fc"}),h("div",{key:"b5205981b09d40a758f83354e82f815d74afa939",class:cls("dropdown-container",{"dropdown-show":this.show,"dropdown-hover":this.hover})},h("slot",{key:"6ab7f3925d9f4a2b6eadc999f7b23254282f2365",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};