const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-dom-CwaHFgt6.js","assets/codemirror-core-vkcnXJgD.js","assets/react-dom-Cfkhaq8h.css"])))=>i.map(i=>d[i]);
import{c as me,m as be,a0 as $e,V as Te,o as ve,f as C,F as he,g as xe,w as ge,_ as Oe,T as ye}from"./index-BfMm4PRv.js";import{h as o,j as a}from"./codemirror-core-vkcnXJgD.js";import{b4 as Ce,b5 as Pe,b6 as Ae,i as w,aP as _e,aO as we,L as Re,m as je,A as De,b7 as G}from"./react-dom-CwaHFgt6.js";import{p as J,b as Q,t as Ie,g as Ee}from"./chunk-WQVQ7P2I-ChwhspC1.js";import{m as Ne}from"./chunk-UX7UMZL5-Dkm9oXhI.js";const Le=1500,X=500;let g={},ke=0,_=!1,m=null,O=null;function Me(e={}){let{delay:$=Le,closeDelay:d=X}=e,{isOpen:n,open:u,close:p}=Ce(e),r=o.useMemo(()=>`${++ke}`,[]),t=o.useRef(null),T=o.useRef(p),y=()=>{g[r]=b},v=()=>{for(let s in g)s!==r&&(g[s](!0),delete g[s])},h=()=>{t.current&&clearTimeout(t.current),t.current=null,v(),y(),_=!0,u(),m&&(clearTimeout(m),m=null),O&&(clearTimeout(O),O=null)},b=s=>{s||d<=0?(t.current&&clearTimeout(t.current),t.current=null,T.current()):t.current||(t.current=setTimeout(()=>{t.current=null,T.current()},d)),m&&(clearTimeout(m),m=null),_&&(O&&clearTimeout(O),O=setTimeout(()=>{delete g[r],O=null,_=!1},Math.max(X,d)))},l=()=>{v(),y(),!n&&!m&&!_?m=setTimeout(()=>{m=null,_=!0,h()},$):n||h()};return o.useEffect(()=>{T.current=p},[p]),o.useEffect(()=>()=>{t.current&&clearTimeout(t.current),g[r]&&delete g[r]},[r]),{isOpen:n,open:s=>{!s&&$>0&&!t.current?l():h()},close:b}}function Ve(e){var $,d;const n=me(),[u,p]=be(e,J.variantKeys),{ref:r,as:t,isOpen:T,content:y,children:v,defaultOpen:h,onOpenChange:b,isDisabled:l,trigger:s,shouldFlip:R=!0,containerPadding:j=12,placement:f="top",delay:M=0,closeDelay:V=500,showArrow:i=!1,offset:F=7,crossOffset:ee=0,isDismissable:te,shouldCloseOnBlur:oe=!0,portalContainer:le,isKeyboardDismissDisabled:se=!1,updatePositionDeps:U=[],shouldCloseOnInteractOutside:ae,className:ne,onClose:W,motionProps:re,classNames:P,...z}=u,ie=t||"div",S=(d=($=e==null?void 0:e.disableAnimation)!=null?$:n==null?void 0:n.disableAnimation)!=null?d:!1,A=Me({delay:M,closeDelay:V,isDisabled:l,defaultOpen:h,isOpen:T,onOpenChange:x=>{b==null||b(x),x||W==null||W()}}),D=o.useRef(null),I=o.useRef(null),E=o.useId(),c=A.isOpen&&!l;o.useImperativeHandle(r,()=>$e(I));const{triggerProps:H,tooltipProps:ce}=Pe({isDisabled:l,trigger:s},A,D),{tooltipProps:K}=Ae({isOpen:c,...w(u,ce)},A),{overlayProps:B,placement:N,updatePosition:de}=_e({isOpen:c,targetRef:D,placement:Ie(f),overlayRef:I,offset:i?F+3:F,crossOffset:ee,shouldFlip:R,containerPadding:j});Te(()=>{U.length&&de()},U);const{overlayProps:Y}=we({isOpen:c,onClose:A.close,isDismissable:te,shouldCloseOnBlur:oe,isKeyboardDismissDisabled:se,shouldCloseOnInteractOutside:ae},I),L=o.useMemo(()=>{var x,k,q;return J({...p,disableAnimation:S,radius:(x=e==null?void 0:e.radius)!=null?x:"md",size:(k=e==null?void 0:e.size)!=null?k:"md",shadow:(q=e==null?void 0:e.shadow)!=null?q:"sm"})},[ve(p),S,e==null?void 0:e.radius,e==null?void 0:e.size,e==null?void 0:e.shadow]),ue=o.useCallback((x={},k=null)=>({...w(H,x),ref:Ne(k,D),"aria-describedby":c?E:void 0}),[H,c,E,A]),pe=o.useCallback(()=>({ref:I,"data-slot":"base","data-open":C(c),"data-arrow":C(i),"data-disabled":C(l),"data-placement":Q(N||"top",f),...w(K,Y,z),style:w(B.style,z.style,u.style),className:L.base({class:P==null?void 0:P.base}),id:E}),[L,c,i,l,N,f,K,Y,z,B,u,E]),fe=o.useCallback(()=>({"data-slot":"content","data-open":C(c),"data-arrow":C(i),"data-disabled":C(l),"data-placement":Q(N||"top",f),className:L.content({class:he(P==null?void 0:P.content,ne)})}),[L,c,i,l,N,f,P]);return{Component:ie,content:y,children:v,isOpen:c,triggerRef:D,showArrow:i,portalContainer:le,placement:f,disableAnimation:S,isDisabled:l,motionProps:re,getTooltipContentProps:fe,getTriggerProps:ue,getTooltipProps:pe}}var ze=()=>Oe(()=>import("./react-dom-CwaHFgt6.js").then(e=>e.bg),__vite__mapDeps([0,1,2])).then(e=>e.default),Z=xe((e,$)=>{const{Component:d,children:n,content:u,isOpen:p,portalContainer:r,placement:t,disableAnimation:T,motionProps:y,getTriggerProps:v,getTooltipProps:h,getTooltipContentProps:b}=Ve({...e,ref:$});let l;try{if(o.Children.count(n)!==1)throw new Error;if(!o.isValidElement(n))l=a.jsx("p",{...v(),children:n});else{const i=n;l=o.cloneElement(i,v(i.props,i.ref))}}catch{l=a.jsx("span",{}),ge("Tooltip must have only one child node. Please, check your code.")}const{ref:s,id:R,style:j,...f}=h(),M=a.jsx("div",{ref:s,id:R,style:j,children:a.jsx(Re,{features:ze,children:a.jsx(je.div,{animate:"enter",exit:"exit",initial:"exit",variants:ye.scaleSpring,...w(y,f),style:{...Ee(t)},children:a.jsx(d,{...b(),children:u})})})});return a.jsxs(a.Fragment,{children:[l,T&&p?a.jsx(G,{portalContainer:r,children:a.jsx("div",{ref:s,id:R,style:j,...f,children:a.jsx(d,{...b(),children:u})})}):a.jsx(De,{children:p?a.jsx(G,{portalContainer:r,children:M}):null})]})});Z.displayName="HeroUI.Tooltip";var Ke=Z;export{Ke as t};
