UNPKG

flyonui

Version:

The easiest, free and open-source Tailwind CSS component library with semantic classes.

16 lines 23.6 kB
var t={179:(t,e,n)=>{n.d(e,{lP:()=>o});const o={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-start":"top-start","top-end":"top-end",bottom:"bottom","bottom-start":"bottom-start","bottom-end":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"}},392:(t,e,n)=>{n.d(e,{JD:()=>i,gj:()=>o,yd:()=>s}); /* * @version: 3.0.1 * @author: Preline Labs Ltd. * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) * Copyright 2024 Preline Labs Ltd. */ const o=(t,e,n="")=>(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ",""),i=(t,e,n=null)=>{const o=new CustomEvent(t,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(o)},s=(t,e)=>{const n=()=>{e(),t.removeEventListener("transitionend",n,!0)},o=window.getComputedStyle(t),i=o.getPropertyValue("transition-duration");"none"!==o.getPropertyValue("transition-property")&&parseFloat(i)>0?t.addEventListener("transitionend",n,!0):e()}},663:(t,e,n)=>{n.d(e,{ll:()=>st,rD:()=>at,UU:()=>ct,cY:()=>lt,BN:()=>rt});const o=Math.min,i=Math.max,s=Math.round,l=Math.floor,r=t=>({x:t,y:t}),c={left:"right",right:"left",bottom:"top",top:"bottom"},a={start:"end",end:"start"};function u(t,e,n){return i(t,o(e,n))}function h(t,e){return"function"==typeof t?t(e):t}function f(t){return t.split("-")[0]}function d(t){return t.split("-")[1]}function g(t){return"x"===t?"y":"x"}function p(t){return"y"===t?"height":"width"}function m(t){return["top","bottom"].includes(f(t))?"y":"x"}function v(t){return g(m(t))}function y(t){return t.replace(/start|end/g,(t=>a[t]))}function w(t){return t.replace(/left|right|bottom|top/g,(t=>c[t]))}function x(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function b(t,e,n){let{reference:o,floating:i}=t;const s=m(e),l=v(e),r=p(l),c=f(e),a="y"===s,u=o.x+o.width/2-i.width/2,h=o.y+o.height/2-i.height/2,g=o[r]/2-i[r]/2;let y;switch(c){case"top":y={x:u,y:o.y-i.height};break;case"bottom":y={x:u,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:h};break;case"left":y={x:o.x-i.width,y:h};break;default:y={x:o.x,y:o.y}}switch(d(e)){case"start":y[l]-=g*(n&&a?-1:1);break;case"end":y[l]+=g*(n&&a?-1:1)}return y}async function L(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:s,rects:l,elements:r,strategy:c}=t,{boundary:a="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:g=0}=h(e,t),p=function(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}(g),m=r[d?"floating"===f?"reference":"floating":f],v=x(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(m)))||n?m:m.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(r.floating)),boundary:a,rootBoundary:u,strategy:c})),y="floating"===f?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,w=await(null==s.getOffsetParent?void 0:s.getOffsetParent(r.floating)),b=await(null==s.isElement?void 0:s.isElement(w))&&await(null==s.getScale?void 0:s.getScale(w))||{x:1,y:1},L=x(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:y,offsetParent:w,strategy:c}):y);return{top:(v.top-L.top+p.top)/b.y,bottom:(L.bottom-v.bottom+p.bottom)/b.y,left:(v.left-L.left+p.left)/b.x,right:(L.right-v.right+p.right)/b.x}}function T(){return"undefined"!=typeof window}function E(t){return A(t)?(t.nodeName||"").toLowerCase():"#document"}function C(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function R(t){var e;return null==(e=(A(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function A(t){return!!T()&&(t instanceof Node||t instanceof C(t).Node)}function k(t){return!!T()&&(t instanceof Element||t instanceof C(t).Element)}function S(t){return!!T()&&(t instanceof HTMLElement||t instanceof C(t).HTMLElement)}function F(t){return!(!T()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof C(t).ShadowRoot)}function M(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=$(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function P(t){return["table","td","th"].includes(E(t))}function D(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function O(t){const e=H(),n=k(t)?$(t):t;return["transform","translate","scale","rotate","perspective"].some((t=>!!n[t]&&"none"!==n[t]))||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function H(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function U(t){return["html","body","#document"].includes(E(t))}function $(t){return C(t).getComputedStyle(t)}function I(t){return k(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function j(t){if("html"===E(t))return t;const e=t.assignedSlot||t.parentNode||F(t)&&t.host||R(t);return F(e)?e.host:e}function B(t){const e=j(t);return U(e)?t.ownerDocument?t.ownerDocument.body:t.body:S(e)&&M(e)?e:B(e)}function V(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=B(t),s=i===(null==(o=t.ownerDocument)?void 0:o.body),l=C(i);if(s){const t=W(l);return e.concat(l,l.visualViewport||[],M(i)?i:[],t&&n?V(t):[])}return e.concat(i,V(i,[],n))}function W(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function N(t){const e=$(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=S(t),l=i?t.offsetWidth:n,r=i?t.offsetHeight:o,c=s(n)!==l||s(o)!==r;return c&&(n=l,o=r),{width:n,height:o,$:c}}function q(t){return k(t)?t:t.contextElement}function z(t){const e=q(t);if(!S(e))return r(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:l}=N(e);let c=(l?s(n.width):n.width)/o,a=(l?s(n.height):n.height)/i;return c&&Number.isFinite(c)||(c=1),a&&Number.isFinite(a)||(a=1),{x:c,y:a}}const _=r(0);function Y(t){const e=C(t);return H()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:_}function J(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),s=q(t);let l=r(1);e&&(o?k(o)&&(l=z(o)):l=z(t));const c=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==C(t))&&e}(s,n,o)?Y(s):r(0);let a=(i.left+c.x)/l.x,u=(i.top+c.y)/l.y,h=i.width/l.x,f=i.height/l.y;if(s){const t=C(s),e=o&&k(o)?C(o):o;let n=t,i=W(n);for(;i&&o&&e!==n;){const t=z(i),e=i.getBoundingClientRect(),o=$(i),s=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,u*=t.y,h*=t.x,f*=t.y,a+=s,u+=l,n=C(i),i=W(n)}}return x({width:h,height:f,x:a,y:u})}function X(t,e){const n=I(t).scrollLeft;return e?e.left+n:J(R(t)).left+n}function G(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:X(t,o)),y:o.top+e.scrollTop}}function K(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=C(t),o=R(t),i=n.visualViewport;let s=o.clientWidth,l=o.clientHeight,r=0,c=0;if(i){s=i.width,l=i.height;const t=H();(!t||t&&"fixed"===e)&&(r=i.offsetLeft,c=i.offsetTop)}return{width:s,height:l,x:r,y:c}}(t,n);else if("document"===e)o=function(t){const e=R(t),n=I(t),o=t.ownerDocument.body,s=i(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),l=i(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+X(t);const c=-n.scrollTop;return"rtl"===$(o).direction&&(r+=i(e.clientWidth,o.clientWidth)-s),{width:s,height:l,x:r,y:c}}(R(t));else if(k(e))o=function(t,e){const n=J(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,s=S(t)?z(t):r(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:i*s.x,y:o*s.y}}(e,n);else{const n=Y(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return x(o)}function Q(t,e){const n=j(t);return!(n===e||!k(n)||U(n))&&("fixed"===$(n).position||Q(n,e))}function Z(t,e,n){const o=S(e),i=R(e),s="fixed"===n,l=J(t,!0,s,e);let c={scrollLeft:0,scrollTop:0};const a=r(0);function u(){a.x=X(i)}if(o||!o&&!s)if(("body"!==E(e)||M(i))&&(c=I(e)),o){const t=J(e,!0,s,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&u();s&&!o&&i&&u();const h=!i||o||s?r(0):G(i,c);return{x:l.left+c.scrollLeft-a.x-h.x,y:l.top+c.scrollTop-a.y-h.y,width:l.width,height:l.height}}function tt(t){return"static"===$(t).position}function et(t,e){if(!S(t)||"fixed"===$(t).position)return null;if(e)return e(t);let n=t.offsetParent;return R(t)===n&&(n=n.ownerDocument.body),n}function nt(t,e){const n=C(t);if(D(t))return n;if(!S(t)){let e=j(t);for(;e&&!U(e);){if(k(e)&&!tt(e))return e;e=j(e)}return n}let o=et(t,e);for(;o&&P(o)&&tt(o);)o=et(o,e);return o&&U(o)&&tt(o)&&!O(o)?n:o||function(t){let e=j(t);for(;S(e)&&!U(e);){if(O(e))return e;if(D(e))return null;e=j(e)}return null}(t)||n}const ot={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const s="fixed"===i,l=R(o),c=!!e&&D(e.floating);if(o===l||c&&s)return n;let a={scrollLeft:0,scrollTop:0},u=r(1);const h=r(0),f=S(o);if((f||!f&&!s)&&(("body"!==E(o)||M(l))&&(a=I(o)),S(o))){const t=J(o);u=z(o),h.x=t.x+o.clientLeft,h.y=t.y+o.clientTop}const d=!l||f||s?r(0):G(l,a,!0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-a.scrollLeft*u.x+h.x+d.x,y:n.y*u.y-a.scrollTop*u.y+h.y+d.y}},getDocumentElement:R,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:s,strategy:l}=t;const r=[..."clippingAncestors"===n?D(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=V(t,[],!1).filter((t=>k(t)&&"body"!==E(t))),i=null;const s="fixed"===$(t).position;let l=s?j(t):t;for(;k(l)&&!U(l);){const e=$(l),n=O(l);n||"fixed"!==e.position||(i=null),(s?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||M(l)&&!n&&Q(t,l))?o=o.filter((t=>t!==l)):i=e,l=j(l)}return e.set(t,o),o}(e,this._c):[].concat(n),s],c=r[0],a=r.reduce(((t,n)=>{const s=K(e,n,l);return t.top=i(s.top,t.top),t.right=o(s.right,t.right),t.bottom=o(s.bottom,t.bottom),t.left=i(s.left,t.left),t}),K(e,c,l));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:nt,getElementRects:async function(t){const e=this.getOffsetParent||nt,n=this.getDimensions,o=await n(t.floating);return{reference:Z(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=N(t);return{width:e,height:n}},getScale:z,isElement:k,isRTL:function(t){return"rtl"===$(t).direction}};function it(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function st(t,e,n,s){void 0===s&&(s={});const{ancestorScroll:r=!0,ancestorResize:c=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:h=!1}=s,f=q(t),d=r||c?[...f?V(f):[],...V(e)]:[];d.forEach((t=>{r&&t.addEventListener("scroll",n,{passive:!0}),c&&t.addEventListener("resize",n)}));const g=f&&u?function(t,e){let n,s=null;const r=R(t);function c(){var t;clearTimeout(n),null==(t=s)||t.disconnect(),s=null}return function a(u,h){void 0===u&&(u=!1),void 0===h&&(h=1),c();const f=t.getBoundingClientRect(),{left:d,top:g,width:p,height:m}=f;if(u||e(),!p||!m)return;const v={rootMargin:-l(g)+"px "+-l(r.clientWidth-(d+p))+"px "+-l(r.clientHeight-(g+m))+"px "+-l(d)+"px",threshold:i(0,o(1,h))||1};let y=!0;function w(e){const o=e[0].intersectionRatio;if(o!==h){if(!y)return a();o?a(!1,o):n=setTimeout((()=>{a(!1,1e-7)}),1e3)}1!==o||it(f,t.getBoundingClientRect())||a(),y=!1}try{s=new IntersectionObserver(w,{...v,root:r.ownerDocument})}catch(t){s=new IntersectionObserver(w,v)}s.observe(t)}(!0),c}(f,n):null;let p,m=-1,v=null;a&&(v=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&v&&(v.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var t;null==(t=v)||t.observe(e)}))),n()})),f&&!h&&v.observe(f),v.observe(e));let y=h?J(t):null;return h&&function e(){const o=J(t);y&&!it(y,o)&&n();y=o,p=requestAnimationFrame(e)}(),n(),()=>{var t;d.forEach((t=>{r&&t.removeEventListener("scroll",n),c&&t.removeEventListener("resize",n)})),null==g||g(),null==(t=v)||t.disconnect(),v=null,h&&cancelAnimationFrame(p)}}const lt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:s,placement:l,middlewareData:r}=e,c=await async function(t,e){const{placement:n,platform:o,elements:i}=t,s=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=f(n),r=d(n),c="y"===m(n),a=["left","top"].includes(l)?-1:1,u=s&&c?-1:1,g=h(e,t);let{mainAxis:p,crossAxis:v,alignmentAxis:y}="number"==typeof g?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return r&&"number"==typeof y&&(v="end"===r?-1*y:y),c?{x:v*u,y:p*a}:{x:p*a,y:v*u}}(e,t);return l===(null==(n=r.offset)?void 0:n.placement)&&null!=(o=r.arrow)&&o.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:l}}}}},rt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:s=!0,crossAxis:l=!1,limiter:r={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...c}=h(t,e),a={x:n,y:o},d=await L(e,c),p=m(f(i)),v=g(p);let y=a[v],w=a[p];if(s){const t="y"===v?"bottom":"right";y=u(y+d["y"===v?"top":"left"],y,y-d[t])}if(l){const t="y"===p?"bottom":"right";w=u(w+d["y"===p?"top":"left"],w,w-d[t])}const x=r.fn({...e,[v]:y,[p]:w});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[v]:s,[p]:l}}}}}},ct=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:s,rects:l,initialPlacement:r,platform:c,elements:a}=e,{mainAxis:u=!0,crossAxis:g=!0,fallbackPlacements:x,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:T="none",flipAlignment:E=!0,...C}=h(t,e);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const R=f(i),A=m(r),k=f(r)===r,S=await(null==c.isRTL?void 0:c.isRTL(a.floating)),F=x||(k||!E?[w(r)]:function(t){const e=w(t);return[y(t),e,y(e)]}(r)),M="none"!==T;!x&&M&&F.push(...function(t,e,n,o){const i=d(t);let s=function(t,e,n){const o=["left","right"],i=["right","left"],s=["top","bottom"],l=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?s:l;default:return[]}}(f(t),"start"===n,o);return i&&(s=s.map((t=>t+"-"+i)),e&&(s=s.concat(s.map(y)))),s}(r,E,T,S));const P=[r,...F],D=await L(e,C),O=[];let H=(null==(o=s.flip)?void 0:o.overflows)||[];if(u&&O.push(D[R]),g){const t=function(t,e,n){void 0===n&&(n=!1);const o=d(t),i=v(t),s=p(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[s]>e.floating[s]&&(l=w(l)),[l,w(l)]}(i,l,S);O.push(D[t[0]],D[t[1]])}if(H=[...H,{placement:i,overflows:O}],!O.every((t=>t<=0))){var U,$;const t=((null==(U=s.flip)?void 0:U.index)||0)+1,e=P[t];if(e){var I;const n="alignment"===g&&A!==m(e),o=(null==(I=H[0])?void 0:I.overflows[0])>0;if(!n||o)return{data:{index:t,overflows:H},reset:{placement:e}}}let n=null==($=H.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:$.placement;if(!n)switch(b){case"bestFit":{var j;const t=null==(j=H.filter((t=>{if(M){const e=m(t.placement);return e===A||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:j[0];t&&(n=t);break}case"initialPlacement":n=r}if(i!==n)return{reset:{placement:n}}}return{}}}},at=(t,e,n)=>{const o=new Map,i={platform:ot,...n},s={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:l}=n,r=s.filter(Boolean),c=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:h}=b(a,o,c),f=o,d={},g=0;for(let n=0;n<r.length;n++){const{name:s,fn:p}=r[n],{x:m,y:v,data:y,reset:w}=await p({x:u,y:h,initialPlacement:o,placement:f,strategy:i,middlewareData:d,rects:a,platform:l,elements:{reference:t,floating:e}});u=null!=m?m:u,h=null!=v?v:h,d={...d,[s]:{...d[s],...y}},w&&g<=50&&(g++,"object"==typeof w&&(w.placement&&(f=w.placement),w.rects&&(a=!0===w.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):w.rects),({x:u,y:h}=b(a,f,c))),n=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:d}})(t,e,{...i,platform:s})}},709:(t,e,n)=>{n.d(e,{A:()=>o});class o{constructor(t,e,n){this.el=t,this.options=e,this.events=n,this.el=t,this.options=e,this.events={}}createCollection(t,e){var n;t.push({id:(null===(n=null==e?void 0:e.el)||void 0===n?void 0:n.id)||t.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var s=e[o]={exports:{}};return t[o](s,s.exports,n),s.exports}n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};n.d(o,{A:()=>a});var i=n(663),s=n(392),l=n(709),r=n(179); /* * HSTooltip * @version: 3.0.1 * @author: Preline Labs Ltd. * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) * Copyright 2024 Preline Labs Ltd. */ class c extends l.A{constructor(t,e,n){super(t,e,n),this.cleanupAutoUpdate=null,this.el&&(this.toggle=this.el.querySelector(".tooltip-toggle")||this.el,this.content=this.el.querySelector(".tooltip-content"),this.eventMode=(0,s.gj)(this.el,"--trigger")||"hover",this.preventFloatingUI=(0,s.gj)(this.el,"--prevent-popper","false"),this.placement=(0,s.gj)(this.el,"--placement"),this.interaction=(0,s.gj)(this.el,"--interaction","true"),this.strategy=(0,s.gj)(this.el,"--strategy"),this.scope=(0,s.gj)(this.el,"--scope")||"parent"),this.el&&this.toggle&&this.content&&this.init()}toggleClick(){this.click()}toggleFocus(){this.focus()}toggleMouseEnter(){this.enter()}toggleMouseLeave(){this.leave()}toggleHandle(){this.hide(),this.toggle.removeEventListener("click",this.onToggleHandleListener,!0),this.toggle.removeEventListener("blur",this.onToggleHandleListener,!0)}init(){this.createCollection(window.$hsTooltipCollection,this),"click"===this.eventMode?(this.onToggleClickListener=()=>this.toggleClick(),this.toggle.addEventListener("click",this.onToggleClickListener)):"focus"===this.eventMode?(this.onToggleFocusListener=()=>this.toggleFocus(),this.toggle.addEventListener("click",this.onToggleFocusListener)):"hover"===this.eventMode&&(this.onToggleMouseEnterListener=()=>this.toggleMouseEnter(),this.onToggleMouseLeaveListener=()=>this.toggleMouseLeave(),this.toggle.addEventListener("mouseenter",this.onToggleMouseEnterListener),this.toggle.addEventListener("mouseleave",this.onToggleMouseLeaveListener)),this.buildFloatingUI()}enter(){this._show()}leave(){this.hide()}click(){this.el.classList.contains("show")?this.hide():(this._show(),this.onToggleHandleListener=()=>{setTimeout((()=>this.toggleHandle()))},this.toggle.addEventListener("click",this.onToggleHandleListener,!0),this.toggle.addEventListener("blur",this.onToggleHandleListener,!0))}focus(){var t;if(this._show(),"true"===this.interaction){const e=t=>{this.content&&this.content.contains(t.target)&&t.stopPropagation()};null===(t=this.content)||void 0===t||t.addEventListener("click",e);const n=t=>{var e;(null===(e=this.content)||void 0===e?void 0:e.contains(t.target))||this.el.contains(t.target)||this.hide()};document.body.addEventListener("click",n)}else{const t=()=>{this.hide(),this.toggle.removeEventListener("blur",t,!0)};this.toggle.addEventListener("blur",t,!0)}}buildFloatingUI(){var t;"window"===this.scope&&document.body.appendChild(this.content);const e=null!==(t=r.lP[this.placement])&&void 0!==t?t:"top",n=new Set(["top","top-start","top-end","bottom","bottom-start","bottom-end"]).has(e),o="false"===this.preventFloatingUI,s=o&&n,l=o,c=[(0,i.cY)(0),...s?[(0,i.BN)()]:[],...l?[(0,i.UU)()]:[]];(0,i.rD)(this.toggle,this.content,{placement:r.lP[this.placement]||"top",strategy:this.strategy||"fixed",middleware:c}).then((({x:t,y:e})=>{Object.assign(this.content.style,{position:this.strategy||"fixed",left:`${t}px`,top:`${e}px`})})),this.cleanupAutoUpdate=(0,i.ll)(this.toggle,this.content,(()=>{(0,i.rD)(this.toggle,this.content,{placement:r.lP[this.placement]||"top",strategy:this.strategy||"fixed",middleware:c}).then((({x:t,y:e})=>{Object.assign(this.content.style,{left:`${t}px`,top:`${e}px`})}))}))}_show(){this.content.classList.remove("hidden"),"window"===this.scope&&this.content.classList.add("show"),this.cleanupAutoUpdate||this.buildFloatingUI(),setTimeout((()=>{this.el.classList.add("show"),this.fireEvent("show",this.el),(0,s.JD)("show.tooltip",this.el,this.el)}))}show(){switch(this.eventMode){case"click":this.click();break;case"focus":this.focus();break;default:this.enter()}this.toggle.focus(),this.toggle.style.outline="none"}hide(){this.el.classList.remove("show"),"window"===this.scope&&this.content.classList.remove("show"),this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),this.fireEvent("hide",this.el),(0,s.JD)("hide.tooltip",this.el,this.el),(0,s.yd)(this.content,(()=>{if(this.el.classList.contains("show"))return!1;this.content.classList.add("hidden"),this.toggle.style.outline=""}))}destroy(){this.el.classList.remove("show"),this.content.classList.add("hidden"),"click"===this.eventMode?this.toggle.removeEventListener("click",this.onToggleClickListener):"focus"===this.eventMode?this.toggle.removeEventListener("click",this.onToggleFocusListener):"hover"===this.eventMode&&(this.toggle.removeEventListener("mouseenter",this.onToggleMouseEnterListener),this.toggle.removeEventListener("mouseleave",this.onToggleMouseLeaveListener)),this.toggle.removeEventListener("click",this.onToggleHandleListener,!0),this.toggle.removeEventListener("blur",this.onToggleHandleListener,!0),this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),window.$hsTooltipCollection=window.$hsTooltipCollection.filter((({element:t})=>t.el!==this.el))}static findInCollection(t){return window.$hsTooltipCollection.find((e=>t instanceof c?e.element.el===t.el:"string"==typeof t?e.element.el===document.querySelector(t):e.element.el===t))||null}static getInstance(t,e=!1){const n=window.$hsTooltipCollection.find((e=>e.element.el===("string"==typeof t?document.querySelector(t):t)));return n?e?n:n.element.el:null}static autoInit(){window.$hsTooltipCollection||(window.$hsTooltipCollection=[]),window.$hsTooltipCollection&&(window.$hsTooltipCollection=window.$hsTooltipCollection.filter((({element:t})=>document.contains(t.el)))),document.querySelectorAll(".tooltip:not(.--prevent-on-load-init)").forEach((t=>{window.$hsTooltipCollection.find((e=>{var n;return(null===(n=null==e?void 0:e.element)||void 0===n?void 0:n.el)===t}))||new c(t)}))}static show(t){const e=c.findInCollection(t);e&&e.element.show()}static hide(t){const e=c.findInCollection(t);e&&e.element.hide()}static on(t,e,n){const o=c.findInCollection(e);o&&(o.element.events[t]=n)}}window.addEventListener("load",(()=>{c.autoInit()})),"undefined"!=typeof window&&(window.HSTooltip=c);const a=c,u=o.A;export{u as default};