import{r,P as l,h as s,H as d,g as p,n as a}from"./index-yJ8X--q8.js";import{b as c,a as u}from"./align-floating-elements-op7c4od4-NN8vwvOo.js";import{v as m}from"./align-tkanisJ7-pF0lTZGz.js";import{v}from"./label-D3d1qqIG-BD7RiEyC.js";import"./Alert-DnD_hO6X-DpaZH47L.js";import{K as E}from"./Span-DMpXIiTW-Bx9h3n4M.js";import"./i18n-H9CUbi---DysS2qV6.js";import"./Heading-D_vnx163-UWSZHCcZ.js";import"./markdown-vxO4XBWP-Z_787KZ6.js";import"./isObject-DvSELytj-B0RigBxT.js";import"./clsx-eK3rPvPS-BT_IL7Fz.js";import"./Icon-XldYcxyr-CesIFDsR.js";import"./InternalUnderlinedBadgeText-Cy3ElU32-BKlO6_-s.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const g=(e,t)=>{a(e,"_badgeText",t)},b=(e,t)=>{a(e,"_id",t)},o=new Set;function T(e){o.forEach(t=>{t.style.setProperty("z-index","999")}),o.add(e),e.style.setProperty("z-index","1000")}function f(e){if(o.delete(e),o.size>0){const t=Array.from(o).pop();t&&t.style.setProperty("z-index","1000")}}const n=300,W=class{constructor(e){r(this,e),this.showTooltip=()=>{if(this.previousSibling&&this.tooltipElement){T(this.tooltipElement),this.tooltipElement.style.setProperty("display","block"),l().addEventListener("keyup",this.hideTooltipByEscape);const t=this.previousSibling,i=this.tooltipElement;this.cleanupAutoPositioning=c(t,i,()=>{this.alignTooltip()})}},this.showTooltipWithDelay=()=>{clearTimeout(this.hideTooltipTimeout),clearTimeout(this.showTooltipTimeout),this.showTooltipTimeout=setTimeout(()=>{this.showTooltip()},n)},this.hideTooltipWithDelay=()=>{clearTimeout(this.hideTooltipTimeout),this.hideTooltipTimeout=setTimeout(()=>{this.hideTooltip()},n)},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,h=!1)=>{t&&this.removeListeners(t),i&&(h&&(this.previousSibling=i),this.addListeners(i))},this.catchTooltipElement=t=>{this.tooltipElement=t},this.catchArrowElement=t=>{this.arrowElement=t},this._align="top",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})}async hideTooltip(){clearTimeout(this.showTooltipTimeout),this.tooltipElement&&(f(this.tooltipElement),this.tooltipElement.style.setProperty("display","none"),this.tooltipElement.style.setProperty("visibility","hidden"),this.cleanupAutoPositioning&&(this.cleanupAutoPositioning(),this.cleanupAutoPositioning=void 0)),l().removeEventListener("keyup",this.hideTooltipByEscape)}handleMouseEnter(){this.showTooltipWithDelay()}handleMouseleave(){this.hideTooltipWithDelay()}handleFocusIn(){this.showTooltipWithDelay()}handleFocusout(){this.hideTooltipWithDelay()}render(){return s(d,{key:"a0b8abd0d04248fd423143784ea3446ce74d5455",class:"kol-tooltip"},this.state._label!==""&&s("div",{key:"e3f3912c333b523115ab170a7034d095ff66eea8",class:"kol-tooltip__floating",ref:this.catchTooltipElement},s("div",{key:"de357980b3f8b686ec462194563cba1b8cc22d09",class:"kol-tooltip__arrow",ref:this.catchArrowElement}),s(E,{key:"102ee0ea200adef3dbee5c134c11af045102e131",class:"kol-tooltip__content",id:this.state._id,badgeText:this._badgeText,label:this.state._label})))}validateBadgeText(e){g(this,e)}validateAlign(e){m(this,e)}validateId(e){b(this,e)}validateLabel(e){v(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 p(this)}static get watchers(){return{_badgeText:["validateBadgeText"],_align:["validateAlign"],_id:["validateId"],_label:["validateLabel"]}}};export{W as kol_tooltip_wc};
//# sourceMappingURL=kol-tooltip-wc.entry-ClBFIghx.js.map
