import{r as s,h as t,e as n}from"./index-DpEJCboz.js";import{a as l,b as a}from"./align-floating-elements-B53gjKzS-I1gra-2L.js";import{v as r}from"./inline-q8GZVjiZ-Bdc5Iyok.js";import{a as p}from"./align-DDUsWnWP-B5arl-LX.js";import{c as h}from"./clsx-COFh-Vc8-D7cYsJM5.js";const v=(e,o)=>{p(e,"_popoverAlign",o)},b=class{constructor(e){s(this,e),this.on={onClick:this.handleButtonClick.bind(this)},this.state={_label:"",_popoverAlign:"bottom"},this.justClosed=!1,this.popoverOpen=!1,this._disabled=!1,this._hideLabel=!1,this._inline=!1,this._popoverAlign="bottom",this._tooltipAlign="top",this._type="button",this._variant="normal"}async hidePopover(){var e;(e=this.refPopover)===null||e===void 0||e.hidePopover()}async showPopover(){var e;(e=this.refPopover)===null||e===void 0||e.showPopover()}async focus(){var e;return Promise.resolve((e=this.refButton)===null||e===void 0?void 0:e.focus())}handleBeforeToggle(e){e.newState==="closed"?(this.justClosed=!0,setTimeout(()=>{this.justClosed=!1},10)):this.refPopover&&(this.refPopover.style.visibility="hidden")}alignPopover(){this.refPopover&&this.refButton&&l({align:this.state._popoverAlign,floatingElement:this.refPopover,referenceElement:this.refButton})}handleToggle(e){this.popoverOpen=e.newState==="open",this.popoverOpen?this.refPopover&&this.refButton&&(this.cleanupAutoPositioning=a(this.refButton,this.refPopover,()=>{this.alignPopover()})):this.cleanupAutoPositioning&&(this.cleanupAutoPositioning(),this.cleanupAutoPositioning=void 0)}handleButtonClick(){var e;this.justClosed||(e=this.refPopover)===null||e===void 0||e.togglePopover()}componentDidRender(){var e,o;(e=this.refPopover)===null||e===void 0||e.addEventListener("toggle",this.handleToggle.bind(this)),(o=this.refPopover)===null||o===void 0||o.addEventListener("beforetoggle",this.handleBeforeToggle.bind(this))}disconnectedCallback(){var e,o,i;(e=this.refPopover)===null||e===void 0||e.removeEventListener("toggle",this.handleToggle.bind(this)),(o=this.refPopover)===null||o===void 0||o.removeEventListener("beforetoggle",this.handleBeforeToggle.bind(this)),(i=this.cleanupAutoPositioning)===null||i===void 0||i.call(this)}render(){return t("div",{key:"0e7d5b884be9b05c7c94c2e5e7be8c35b0def1d7",class:h("kol-popover-button",{"kol-popover-button--open":this.popoverOpen,"kol-popover-button--inline":this.state._inline===!0,"kol-popover-button--standalone":this.state._inline===!1})},t(n,{key:"94ccc86b0c086381c81138687458bc7f24b8daf0",_accessKey:this._accessKey,"_aria-controls":"popover",_ariaDescription:this._ariaDescription,_ariaExpanded:this.popoverOpen,_ariaHasPopup:"dialog",_customClass:this._customClass,_disabled:this._disabled,_hideLabel:this._hideLabel,_icons:this._icons,_id:this._id,_inline:this._inline,_label:this._label,_name:this._name,_on:this.on,_shortKey:this._shortKey,_syncValueBySelector:this._syncValueBySelector,_tabIndex:this._tabIndex,_tooltipAlign:this._tooltipAlign,_type:this._type,_value:this._value,_variant:this._variant,"data-testid":"popover-button",class:"kol-popover-button__button",ref:e=>this.refButton=e},t("slot",{key:"b0fc81b248083132b185e9f675b26a34f536e8da",name:"expert",slot:"expert"})),t("div",{key:"3d97f41b80556b76628c416f655088f5bef5f73b",ref:e=>this.refPopover=e,"data-testid":"popover-content",popover:"auto",id:"popover",class:"kol-popover-button__popover"},t("slot",{key:"10cf6cdaff42f908b1ed103526d4e92f28493535"})))}validateInline(e){r(this,e,{defaultValue:!1})}validatePopoverAlign(e){v(this,e)}componentWillLoad(){this.validateInline(this._inline),this.validatePopoverAlign(this._popoverAlign)}static get watchers(){return{_inline:["validateInline"],_popoverAlign:["validatePopoverAlign"]}}};export{b as kol_popover_button_wc};
//# sourceMappingURL=kol-popover-button-wc.entry-BTMNA4l-.js.map
