sv-bootstrap-tooltip
Version:
Bootstrap 5 tooltip component for Svelte 5
3 lines (2 loc) • 21 kB
JavaScript
import"svelte/internal/disclose-version";import*as e from"svelte/internal/client";var t="top",n="bottom",r="right",o="left",i="auto",a=[t,n,r,o],s="start",f="end",c="viewport",p="popper",u=a.reduce(function(e,t){return e.concat([t+"-"+s,t+"-"+f])},[]),l=[].concat(a,[i]).reduce(function(e,t){return e.concat([t,t+"-"+s,t+"-"+f])},[]),d=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function m(e){return e?(e.nodeName||"").toLowerCase():null}function h(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function v(e){return e instanceof h(e).Element||e instanceof Element}function g(e){return e instanceof h(e).HTMLElement||e instanceof HTMLElement}function y(e){return"undefined"!=typeof ShadowRoot&&(e instanceof h(e).ShadowRoot||e instanceof ShadowRoot)}var b={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},o=t.elements[e];g(o)&&m(o)&&(Object.assign(o.style,n),Object.keys(r).forEach(function(e){var t=r[e];!1===t?o.removeAttribute(e):o.setAttribute(e,!0===t?"":t)}))})},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],o=t.attributes[e]||{},i=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]="",e},{});g(r)&&m(r)&&(Object.assign(r.style,i),Object.keys(o).forEach(function(e){r.removeAttribute(e)}))})}},requires:["computeStyles"]};function w(e){return e.split("-")[0]}var x=Math.max,O=Math.min,j=Math.round;function E(){var e=navigator.userAgentData;return null!=e&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function D(){return!/^((?!chrome|android).)*safari/i.test(E())}function A(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var r=e.getBoundingClientRect(),o=1,i=1;t&&g(e)&&(o=e.offsetWidth>0&&j(r.width)/e.offsetWidth||1,i=e.offsetHeight>0&&j(r.height)/e.offsetHeight||1);var a=(v(e)?h(e):window).visualViewport,s=!D()&&n,f=(r.left+(s&&a?a.offsetLeft:0))/o,c=(r.top+(s&&a?a.offsetTop:0))/i,p=r.width/o,u=r.height/i;return{width:p,height:u,top:c,right:f+p,bottom:c+u,left:f,x:f,y:c}}function k(e){var t=A(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function L(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&y(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function W(e){return h(e).getComputedStyle(e)}function M(e){return["table","td","th"].indexOf(m(e))>=0}function P(e){return((v(e)?e.ownerDocument:e.document)||window.document).documentElement}function B(e){return"html"===m(e)?e:e.assignedSlot||e.parentNode||(y(e)?e.host:null)||P(e)}function H(e){return g(e)&&"fixed"!==W(e).position?e.offsetParent:null}function R(e){for(var t=h(e),n=H(e);n&&M(n)&&"static"===W(n).position;)n=H(n);return n&&("html"===m(n)||"body"===m(n)&&"static"===W(n).position)?t:n||function(e){var t=/firefox/i.test(E());if(/Trident/i.test(E())&&g(e)&&"fixed"===W(e).position)return null;var n=B(e);for(y(n)&&(n=n.host);g(n)&&["html","body"].indexOf(m(n))<0;){var r=W(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||t}function T(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function S(e,t,n){return x(e,O(t,n))}function C(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function V(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var _={name:"arrow",enabled:!0,phase:"main",fn:function(e){var i,s=e.state,f=e.name,c=e.options,p=s.elements.arrow,u=s.modifiersData.popperOffsets,l=w(s.placement),d=T(l),m=[o,r].indexOf(l)>=0?"height":"width";if(p&&u){var h=function(e,t){return C("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:V(e,a))}(c.padding,s),v=k(p),g="y"===d?t:o,y="y"===d?n:r,b=s.rects.reference[m]+s.rects.reference[d]-u[d]-s.rects.popper[m],x=u[d]-s.rects.reference[d],O=R(p),j=O?"y"===d?O.clientHeight||0:O.clientWidth||0:0,E=b/2-x/2,D=h[g],A=j-v[m]-h[y],L=j/2-v[m]/2+E,W=S(D,L,A),M=d;s.modifiersData[f]=((i={})[M]=W,i.centerOffset=W-L,i)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&L(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function q(e){return e.split("-")[1]}var N={top:"auto",right:"auto",bottom:"auto",left:"auto"};function I(e){var i,a=e.popper,s=e.popperRect,c=e.placement,p=e.variation,u=e.offsets,l=e.position,d=e.gpuAcceleration,m=e.adaptive,v=e.roundOffsets,g=e.isFixed,y=u.x,b=void 0===y?0:y,w=u.y,x=void 0===w?0:w,O="function"==typeof v?v({x:b,y:x}):{x:b,y:x};b=O.x,x=O.y;var E=u.hasOwnProperty("x"),D=u.hasOwnProperty("y"),A=o,k=t,L=window;if(m){var M=R(a),B="clientHeight",H="clientWidth";if(M===h(a)&&"static"!==W(M=P(a)).position&&"absolute"===l&&(B="scrollHeight",H="scrollWidth"),c===t||(c===o||c===r)&&p===f)k=n,x-=(g&&M===L&&L.visualViewport?L.visualViewport.height:M[B])-s.height,x*=d?1:-1;if(c===o||(c===t||c===n)&&p===f)A=r,b-=(g&&M===L&&L.visualViewport?L.visualViewport.width:M[H])-s.width,b*=d?1:-1}var T,S=Object.assign({position:l},m&&N),C=!0===v?function(e,t){var n=e.x,r=e.y,o=t.devicePixelRatio||1;return{x:j(n*o)/o||0,y:j(r*o)/o||0}}({x:b,y:x},h(a)):{x:b,y:x};return b=C.x,x=C.y,d?Object.assign({},S,((T={})[k]=D?"0":"",T[A]=E?"0":"",T.transform=(L.devicePixelRatio||1)<=1?"translate("+b+"px, "+x+"px)":"translate3d("+b+"px, "+x+"px, 0)",T)):Object.assign({},S,((i={})[k]=D?x+"px":"",i[A]=E?b+"px":"",i.transform="",i))}var F={passive:!0};var U={left:"right",right:"left",bottom:"top",top:"bottom"};function z(e){return e.replace(/left|right|bottom|top/g,function(e){return U[e]})}var X={start:"end",end:"start"};function Y(e){return e.replace(/start|end/g,function(e){return X[e]})}function $(e){var t=h(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function G(e){return A(P(e)).left+$(e).scrollLeft}function J(e){var t=W(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function K(e){return["html","body","#document"].indexOf(m(e))>=0?e.ownerDocument.body:g(e)&&J(e)?e:K(B(e))}function Q(e,t){var n;void 0===t&&(t=[]);var r=K(e),o=r===(null==(n=e.ownerDocument)?void 0:n.body),i=h(r),a=o?[i].concat(i.visualViewport||[],J(r)?r:[]):r,s=t.concat(a);return o?s:s.concat(Q(B(a)))}function Z(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ee(e,t,n){return t===c?Z(function(e,t){var n=h(e),r=P(e),o=n.visualViewport,i=r.clientWidth,a=r.clientHeight,s=0,f=0;if(o){i=o.width,a=o.height;var c=D();(c||!c&&"fixed"===t)&&(s=o.offsetLeft,f=o.offsetTop)}return{width:i,height:a,x:s+G(e),y:f}}(e,n)):v(t)?function(e,t){var n=A(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):Z(function(e){var t,n=P(e),r=$(e),o=null==(t=e.ownerDocument)?void 0:t.body,i=x(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=x(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),s=-r.scrollLeft+G(e),f=-r.scrollTop;return"rtl"===W(o||n).direction&&(s+=x(n.clientWidth,o?o.clientWidth:0)-i),{width:i,height:a,x:s,y:f}}(P(e)))}function te(e,t,n,r){var o="clippingParents"===t?function(e){var t=Q(B(e)),n=["absolute","fixed"].indexOf(W(e).position)>=0&&g(e)?R(e):e;return v(n)?t.filter(function(e){return v(e)&&L(e,n)&&"body"!==m(e)}):[]}(e):[].concat(t),i=[].concat(o,[n]),a=i[0],s=i.reduce(function(t,n){var o=ee(e,n,r);return t.top=x(o.top,t.top),t.right=O(o.right,t.right),t.bottom=O(o.bottom,t.bottom),t.left=x(o.left,t.left),t},ee(e,a,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function ne(e){var i,a=e.reference,c=e.element,p=e.placement,u=p?w(p):null,l=p?q(p):null,d=a.x+a.width/2-c.width/2,m=a.y+a.height/2-c.height/2;switch(u){case t:i={x:d,y:a.y-c.height};break;case n:i={x:d,y:a.y+a.height};break;case r:i={x:a.x+a.width,y:m};break;case o:i={x:a.x-c.width,y:m};break;default:i={x:a.x,y:a.y}}var h=u?T(u):null;if(null!=h){var v="y"===h?"height":"width";switch(l){case s:i[h]=i[h]-(a[v]/2-c[v]/2);break;case f:i[h]=i[h]+(a[v]/2-c[v]/2)}}return i}function re(e,o){void 0===o&&(o={});var i=o,s=i.placement,f=void 0===s?e.placement:s,u=i.strategy,l=void 0===u?e.strategy:u,d=i.boundary,m=void 0===d?"clippingParents":d,h=i.rootBoundary,g=void 0===h?c:h,y=i.elementContext,b=void 0===y?p:y,w=i.altBoundary,x=void 0!==w&&w,O=i.padding,j=void 0===O?0:O,E=C("number"!=typeof j?j:V(j,a)),D=b===p?"reference":p,k=e.rects.popper,L=e.elements[x?D:b],W=te(v(L)?L:L.contextElement||P(e.elements.popper),m,g,l),M=A(e.elements.reference),B=ne({reference:M,element:k,placement:f}),H=Z(Object.assign({},k,B)),R=b===p?H:M,T={top:W.top-R.top+E.top,bottom:R.bottom-W.bottom+E.bottom,left:W.left-R.left+E.left,right:R.right-W.right+E.right},S=e.modifiersData.offset;if(b===p&&S){var _=S[f];Object.keys(T).forEach(function(e){var o=[r,n].indexOf(e)>=0?1:-1,i=[t,n].indexOf(e)>=0?"y":"x";T[e]+=_[i]*o})}return T}function oe(e,t){void 0===t&&(t={});var n=t,r=n.placement,o=n.boundary,i=n.rootBoundary,s=n.padding,f=n.flipVariations,c=n.allowedAutoPlacements,p=void 0===c?l:c,d=q(r),m=d?f?u:u.filter(function(e){return q(e)===d}):a,h=m.filter(function(e){return p.indexOf(e)>=0});0===h.length&&(h=m);var v=h.reduce(function(t,n){return t[n]=re(e,{placement:n,boundary:o,rootBoundary:i,padding:s})[w(n)],t},{});return Object.keys(v).sort(function(e,t){return v[e]-v[t]})}var ie={name:"flip",enabled:!0,phase:"main",fn:function(e){var a=e.state,f=e.options,c=e.name;if(!a.modifiersData[c]._skip){for(var p=f.mainAxis,u=void 0===p||p,l=f.altAxis,d=void 0===l||l,m=f.fallbackPlacements,h=f.padding,v=f.boundary,g=f.rootBoundary,y=f.altBoundary,b=f.flipVariations,x=void 0===b||b,O=f.allowedAutoPlacements,j=a.options.placement,E=w(j),D=m||(E===j||!x?[z(j)]:function(e){if(w(e)===i)return[];var t=z(e);return[Y(e),t,Y(t)]}(j)),A=[j].concat(D).reduce(function(e,t){return e.concat(w(t)===i?oe(a,{placement:t,boundary:v,rootBoundary:g,padding:h,flipVariations:x,allowedAutoPlacements:O}):t)},[]),k=a.rects.reference,L=a.rects.popper,W=new Map,M=!0,P=A[0],B=0;B<A.length;B++){var H=A[B],R=w(H),T=q(H)===s,S=[t,n].indexOf(R)>=0,C=S?"width":"height",V=re(a,{placement:H,boundary:v,rootBoundary:g,altBoundary:y,padding:h}),_=S?T?r:o:T?n:t;k[C]>L[C]&&(_=z(_));var N=z(_),I=[];if(u&&I.push(V[R]<=0),d&&I.push(V[_]<=0,V[N]<=0),I.every(function(e){return e})){P=H,M=!1;break}W.set(H,I)}if(M)for(var F=function(e){var t=A.find(function(t){var n=W.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return P=t,"break"},U=x?3:1;U>0;U--){if("break"===F(U))break}a.placement!==P&&(a.modifiersData[c]._skip=!0,a.placement=P,a.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ae(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function se(e){return[t,r,n,o].some(function(t){return e[t]>=0})}var fe={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var n=e.state,i=e.options,a=e.name,s=i.offset,f=void 0===s?[0,0]:s,c=l.reduce(function(e,i){return e[i]=function(e,n,i){var a=w(e),s=[o,t].indexOf(a)>=0?-1:1,f="function"==typeof i?i(Object.assign({},n,{placement:e})):i,c=f[0],p=f[1];return c=c||0,p=(p||0)*s,[o,r].indexOf(a)>=0?{x:p,y:c}:{x:c,y:p}}(i,n.rects,f),e},{}),p=c[n.placement],u=p.x,d=p.y;null!=n.modifiersData.popperOffsets&&(n.modifiersData.popperOffsets.x+=u,n.modifiersData.popperOffsets.y+=d),n.modifiersData[a]=c}};var ce={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var i=e.state,a=e.options,f=e.name,c=a.mainAxis,p=void 0===c||c,u=a.altAxis,l=void 0!==u&&u,d=a.boundary,m=a.rootBoundary,h=a.altBoundary,v=a.padding,g=a.tether,y=void 0===g||g,b=a.tetherOffset,j=void 0===b?0:b,E=re(i,{boundary:d,rootBoundary:m,padding:v,altBoundary:h}),D=w(i.placement),A=q(i.placement),L=!A,W=T(D),M="x"===W?"y":"x",P=i.modifiersData.popperOffsets,B=i.rects.reference,H=i.rects.popper,C="function"==typeof j?j(Object.assign({},i.rects,{placement:i.placement})):j,V="number"==typeof C?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),_=i.modifiersData.offset?i.modifiersData.offset[i.placement]:null,N={x:0,y:0};if(P){if(p){var I,F="y"===W?t:o,U="y"===W?n:r,z="y"===W?"height":"width",X=P[W],Y=X+E[F],$=X-E[U],G=y?-H[z]/2:0,J=A===s?B[z]:H[z],K=A===s?-H[z]:-B[z],Q=i.elements.arrow,Z=y&&Q?k(Q):{width:0,height:0},ee=i.modifiersData["arrow#persistent"]?i.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},te=ee[F],ne=ee[U],oe=S(0,B[z],Z[z]),ie=L?B[z]/2-G-oe-te-V.mainAxis:J-oe-te-V.mainAxis,ae=L?-B[z]/2+G+oe+ne+V.mainAxis:K+oe+ne+V.mainAxis,se=i.elements.arrow&&R(i.elements.arrow),fe=se?"y"===W?se.clientTop||0:se.clientLeft||0:0,ce=null!=(I=null==_?void 0:_[W])?I:0,pe=X+ae-ce,ue=S(y?O(Y,X+ie-ce-fe):Y,X,y?x($,pe):$);P[W]=ue,N[W]=ue-X}if(l){var le,de="x"===W?t:o,me="x"===W?n:r,he=P[M],ve="y"===M?"height":"width",ge=he+E[de],ye=he-E[me],be=-1!==[t,o].indexOf(D),we=null!=(le=null==_?void 0:_[M])?le:0,xe=be?ge:he-B[ve]-H[ve]-we+V.altAxis,Oe=be?he+B[ve]+H[ve]-we-V.altAxis:ye,je=y&&be?function(e,t,n){var r=S(e,t,n);return r>n?n:r}(xe,he,Oe):S(y?xe:ge,he,y?Oe:ye);P[M]=je,N[M]=je-he}i.modifiersData[f]=N}},requiresIfExists:["offset"]};function pe(e,t,n){void 0===n&&(n=!1);var r,o,i=g(t),a=g(t)&&function(e){var t=e.getBoundingClientRect(),n=j(t.width)/e.offsetWidth||1,r=j(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(t),s=P(t),f=A(e,a,n),c={scrollLeft:0,scrollTop:0},p={x:0,y:0};return(i||!i&&!n)&&(("body"!==m(t)||J(s))&&(c=(r=t)!==h(r)&&g(r)?{scrollLeft:(o=r).scrollLeft,scrollTop:o.scrollTop}:$(r)),g(t)?((p=A(t,!0)).x+=t.clientLeft,p.y+=t.clientTop):s&&(p.x=G(s))),{x:f.left+c.scrollLeft-p.x,y:f.top+c.scrollTop-p.y,width:f.width,height:f.height}}function ue(e){var t=new Map,n=new Set,r=[];function o(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&o(r)}}),r.push(e)}return e.forEach(function(e){t.set(e.name,e)}),e.forEach(function(e){n.has(e.name)||o(e)}),r}var le={placement:"bottom",modifiers:[],strategy:"absolute"};function de(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(e){return!(e&&"function"==typeof e.getBoundingClientRect)})}function me(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,r=void 0===n?[]:n,o=t.defaultOptions,i=void 0===o?le:o;return function(e,t,n){void 0===n&&(n=i);var o,a,s={placement:"bottom",orderedModifiers:[],options:Object.assign({},le,i),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},f=[],c=!1,p={state:s,setOptions:function(n){var o="function"==typeof n?n(s.options):n;u(),s.options=Object.assign({},i,s.options,o),s.scrollParents={reference:v(e)?Q(e):e.contextElement?Q(e.contextElement):[],popper:Q(t)};var a,c,l=function(e){var t=ue(e);return d.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}((a=[].concat(r,s.options.modifiers),c=a.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{}),Object.keys(c).map(function(e){return c[e]})));return s.orderedModifiers=l.filter(function(e){return e.enabled}),s.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=void 0===n?{}:n,o=e.effect;if("function"==typeof o){var i=o({state:s,name:t,instance:p,options:r}),a=function(){};f.push(i||a)}}),p.update()},forceUpdate:function(){if(!c){var e=s.elements,t=e.reference,n=e.popper;if(de(t,n)){s.rects={reference:pe(t,R(n),"fixed"===s.options.strategy),popper:k(n)},s.reset=!1,s.placement=s.options.placement,s.orderedModifiers.forEach(function(e){return s.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<s.orderedModifiers.length;r++)if(!0!==s.reset){var o=s.orderedModifiers[r],i=o.fn,a=o.options,f=void 0===a?{}:a,u=o.name;"function"==typeof i&&(s=i({state:s,options:f,name:u,instance:p})||s)}else s.reset=!1,r=-1}}},update:(o=function(){return new Promise(function(e){p.forceUpdate(),e(s)})},function(){return a||(a=new Promise(function(e){Promise.resolve().then(function(){a=void 0,e(o())})})),a}),destroy:function(){u(),c=!0}};if(!de(e,t))return p;function u(){f.forEach(function(e){return e()}),f=[]}return p.setOptions(n).then(function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)}),p}}var he=me({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,o=r.scroll,i=void 0===o||o,a=r.resize,s=void 0===a||a,f=h(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&c.forEach(function(e){e.addEventListener("scroll",n.update,F)}),s&&f.addEventListener("resize",n.update,F),function(){i&&c.forEach(function(e){e.removeEventListener("scroll",n.update,F)}),s&&f.removeEventListener("resize",n.update,F)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=ne({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,o=void 0===r||r,i=n.adaptive,a=void 0===i||i,s=n.roundOffsets,f=void 0===s||s,c={placement:w(t.placement),variation:q(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:o,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,I(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:f})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,I(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},b,fe,ie,ce,_,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,i=t.modifiersData.preventOverflow,a=re(t,{elementContext:"reference"}),s=re(t,{altBoundary:!0}),f=ae(a,r),c=ae(s,o,i),p=se(f),u=se(c);t.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}}]}),ve=e.from_html('<div role="tooltip"><div class="tooltip-arrow"></div> <div class="tooltip-inner"><!></div></div>');function ge(t,n){e.push(n,!0);let r=e.prop(n,"open",15,!1),o=e.prop(n,"triggerElement",3,null),i=e.prop(n,"flip",3,!0),a=e.prop(n,"placement",3,"top"),s=e.prop(n,"trigger",3,"hover|focus"),f=e.prop(n,"offset",19,()=>[0,4]),c=e.prop(n,"onOpened",3,()=>{}),p=e.prop(n,"onClosed",3,()=>{}),u=e.state(null),l=e.state(null);function d(e,...t){return e.addEventListener(...t),{remove:()=>e.removeEventListener(...t)}}e.user_effect(()=>{if(!r()||!e.get(u))return;const t=he(o(),e.get(u),{placement:a(),modifiers:[{name:"arrow",options:{element:e.get(l)}},{name:"flip",enabled:i()},{name:"offset",options:{offset:f()}},{name:"preventOverflow",options:{altBoundary:!0}}]});return c()(),()=>{t.destroy(),p()()}}),e.user_effect(()=>{if(!o())return;const e=s().split("|"),t=[];return e.includes("hover")&&(t.push(d(o(),"mouseenter",()=>{r(!0)})),t.push(d(o(),"mouseleave",()=>{r(!1)}))),e.includes("focus")&&(t.push(d(o(),"focus",()=>{r(!0)})),t.push(d(o(),"blur",()=>{r(!1)}))),e.includes("click")&&t.push(d(o(),"click",()=>{r(!r())})),()=>t.forEach(e=>e.remove())});var m=e.comment(),h=e.first_child(m),v=t=>{var r=ve(),o=e.child(r);e.bind_this(o,t=>e.set(l,t),()=>e.get(l));var i=e.sibling(o,2),s=e.child(i);e.snippet(s,()=>n.children??e.noop),e.reset(i),e.reset(r),e.bind_this(r,t=>e.set(u,t),()=>e.get(u)),e.template_effect(()=>e.set_class(r,1,`tooltip bs-tooltip-${a()??""} fade show`)),e.append(t,r)};e.if(h,e=>{r()&&e(v)}),e.append(t,m),e.pop()}export{ge as Tooltip,ge as default};
//# sourceMappingURL=index.mjs.map