import{r as s,h as t,e as n}from"./index-DCi8lcS0.js";import{a as l,b as a}from"./align-floating-elements-6A9FkBi8-xyinCPK6.js";import{c as r}from"./clsx-eK3rPvPS-B-dksMZM.js";import{v as p}from"./inline-C2QF3Rdx-DewTFQE3.js";import{a as h}from"./align-zs9k2ruM-Z9QWZaht.js";const v=(e,o)=>{h(e,"_popoverAlign",o)},b=class{constructor(e){s(this,e),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())}async kolFocus(){return this.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:"32a785aba018c6cbd915d91380b28a5e6db05088",class:r("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:"dc421640367e726bc5f6de43065d6fe888375b1c",_accessKey:this._accessKey,"_aria-controls":"popover",_ariaControls:this._ariaControls,_ariaDescription:this._ariaDescription,_ariaExpanded:this.popoverOpen,_ariaHasPopup:"dialog",_ariaSelected:this._ariaSelected,_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,_role:this._role,_shortKey:this._shortKey,_syncValueBySelector:this._syncValueBySelector,_tabIndex:this._tabIndex,_tooltipAlign:this._tooltipAlign,_type:this._type,_value:this._value,_buttonVariant:this._variant,"data-testid":"popover-button",class:"kol-popover-button__button",ref:e=>this.refButton=e,onClick:this.handleButtonClick.bind(this)},t("slot",{key:"1fd63443f543963f56e2646f88320e50f34430b0",name:"expert",slot:"expert"})),t("div",{key:"a1cec965c9b92cbe79ce6b09cf84fd0ae619eb33",ref:e=>this.refPopover=e,"data-testid":"popover-content",popover:"auto",id:"popover",class:"kol-popover-button__popover"},t("slot",{key:"bc9c769a2036a69596497cc3a522b121b885f88b"})))}validateInline(e){p(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-Cs4PA96M.js.map
