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