import{r as l,P as n,h as o,d as h,H as r,m as d,t as p}from"./index-CJwtOLCA.js";import{b as c,a as u}from"./align-floating-elements-f88f945f-DNJFvZ9i.js";import{v}from"./badge-text-c7f39390-IIMowJK9.js";import{v as m}from"./align-bc8d98ac-DfD8j5LE.js";import{v as f}from"./label-51d66c9d-CT4N_dB0.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const b=(e,t)=>{p(e,"_id",t)},s=new Set;function g(e){s.forEach(t=>{t.style.setProperty("z-index","999")}),s.add(e),e.style.setProperty("z-index","1000")}function E(e){if(s.delete(e),s.size>0){const t=Array.from(s).pop();t&&t.style.setProperty("z-index","1000")}}const I=class{constructor(e){l(this,e),this.hasFocusIn=!1,this.hasMouseIn=!1,this.showTooltip=()=>{if(this.previousSibling&&this.tooltipElement){g(this.tooltipElement),this.tooltipElement.style.setProperty("display","block"),n().addEventListener("keyup",this.hideTooltipByEscape);const t=this.previousSibling,i=this.tooltipElement;this.cleanupAutoPositioning=c(t,i,()=>{this.alignTooltip()})}},this.hideTooltip=()=>{this.tooltipElement&&(E(this.tooltipElement),this.tooltipElement.style.setProperty("display","none"),this.tooltipElement.style.setProperty("visibility","hidden"),this.cleanupAutoPositioning&&(this.cleanupAutoPositioning(),this.cleanupAutoPositioning=void 0)),n().removeEventListener("keyup",this.hideTooltipByEscape)},this.hideTooltipByEscape=t=>{t.key==="Escape"&&this.hideTooltip()},this.addListeners=t=>{t.addEventListener("mouseenter",this.handleMouseEnter.bind(this)),t.addEventListener("mouseleave",this.handleMouseleave.bind(this)),t.addEventListener("focusin",this.handleFocusIn.bind(this)),t.addEventListener("focusout",this.handleFocusout.bind(this))},this.removeListeners=t=>{t.removeEventListener("mouseenter",this.handleMouseEnter.bind(this)),t.removeEventListener("mouseleave",this.handleMouseleave.bind(this)),t.removeEventListener("focusin",this.handleFocusIn.bind(this)),t.removeEventListener("focusout",this.handleFocusout.bind(this))},this.resyncListeners=(t,i,a=!1)=>{t&&this.removeListeners(t),i&&(a&&(this.previousSibling=i),this.addListeners(i))},this.catchTooltipElement=t=>{this.tooltipElement=t},this.catchArrowElement=t=>{this.arrowElement=t},this.showOrHideTooltip=()=>{clearTimeout(this.overFocusTimeout),this.overFocusTimeout=setTimeout(()=>{this.hasMouseIn||this.hasFocusIn?this.showTooltip():this.hideTooltip()},300)},this._badgeText=void 0,this._align="top",this._id=void 0,this._label=void 0,this.state={_align:"top",_label:""}}async alignTooltip(){this.tooltipElement&&this.previousSibling&&await u({align:this._align,referenceElement:this.previousSibling,arrowElement:this.arrowElement,floatingElement:this.tooltipElement})}handleMouseEnter(){this.hasMouseIn=!0,this.showOrHideTooltip()}handleMouseleave(){this.hasMouseIn=!1,this.showOrHideTooltip()}handleFocusIn(){this.hasFocusIn=!0,this.showOrHideTooltip()}handleFocusout(){this.hasFocusIn=!1,this.showOrHideTooltip()}render(){return o(r,{key:"499817b8ce171b101e0aa4a5846bf50cceb853f9",class:"kol-tooltip-wc"},this.state._label!==""&&o("div",{key:"28f89bc33dfd88fbdaa2ea11ff8be12d1c45df42",class:"tooltip-floating",ref:this.catchTooltipElement},o("div",{key:"4b84ee6af63868e84015c1ad2e45b96f04845b41",class:"tooltip-area tooltip-arrow",ref:this.catchArrowElement}),o(h,{key:"159cbc321c5cc5287aaa83aa75310afe0ad9121e",class:"tooltip-area tooltip-content",id:this.state._id,_badgeText:this._badgeText,_label:this.state._label})))}validateBadgeText(e){v(this,e)}validateAlign(e){m(this,e)}validateId(e){b(this,e)}validateLabel(e){f(this,e,{required:!0})}componentWillLoad(){this.validateBadgeText(this._badgeText),this.validateAlign(this._align),this.validateId(this._id),this.validateLabel(this._label)}handleEventListeners(){var e;this.resyncListeners(this.previousSibling,(e=this.host)===null||e===void 0?void 0:e.previousElementSibling,!0),this.resyncListeners(this.tooltipElement,this.tooltipElement)}connectedCallback(){var e;this.previousSibling=(e=this.host)===null||e===void 0?void 0:e.previousElementSibling}componentDidRender(){this.handleEventListeners()}disconnectedCallback(){this.previousSibling&&(this.removeListeners(this.previousSibling),this.previousSibling=void 0),this.tooltipElement&&this.removeListeners(this.tooltipElement),this.cleanupAutoPositioning&&this.cleanupAutoPositioning()}get host(){return d(this)}static get watchers(){return{_badgeText:["validateBadgeText"],_align:["validateAlign"],_id:["validateId"],_label:["validateLabel"]}}};export{I as kol_tooltip_wc};
//# sourceMappingURL=kol-tooltip-wc.entry-L-GeDdIY.js.map
