"use client";
import{c as U}from"./chunk-SUBVXXYD.js";import{a as O}from"./chunk-CRUBRFDA.js";import{e as B,i as L,j as M}from"./chunk-CLTGASR6.js";import{a as w,c as H,d as V,m as x,n as C}from"./chunk-3CHPBNY2.js";import{cloneElement as A,forwardRef as at,isValidElement as lt,useState as st}from"react";import it from"clsx";import{cloneElement as D,isValidElement as et}from"react";import y from"clsx";var X=w("EulTooltip",["anchorEl","content","open","panel","placementBottom","placementBottomEnd","placementBottomStart","placementLeft","placementLeftEnd","placementLeftStart","placementRight","placementRightEnd","placementRightStart","placementTop","placementTopEnd","placementTopStart","popper","root","tip"]),b=t=>B("EulTooltip",{anchorEl:["anchorEl"],content:["content"],popper:["popper",t.placement&&`placement${V(H(t.placement))}`,t.placement?.indexOf("bottom")!==-1&&"placementBottom",t.placement?.indexOf("top")!==-1&&"placementTop",t.placement?.indexOf("left")!==-1&&"placementLeft",t.placement?.indexOf("right")!==-1&&"placementRight",t.isPanel&&"panel"],root:["root",t.open&&"open"],tip:["tip"]}),a=X;import{forwardRef as Y}from"react";import{jsx as F,jsxs as _}from"react/jsx-runtime";var G=Y(({className:t},i)=>{let o=C();return _("svg",{className:t,fill:"none",height:"10",ref:i,viewBox:"0 0 34 10",width:"34",xmlns:"http://www.w3.org/2000/svg",children:[F("path",{d:"M0 0H34H26.8873C26.0072 0 25.1715 0.386467 24.6015 1.05705L19.2858 7.3108C18.0878 8.72021 15.9122 8.72021 14.7142 7.3108L9.3985 1.05706C8.8285 0.386469 7.99278 0 7.11268 0H0Z",fill:o.palette.background[500]}),F("path",{d:"M7.11268 1H6V0H7.11268C7.96751 0 8.78047 0.364595 9.34875 1C9.36555 1.01878 9.38213 1.0378 9.3985 1.05706L14.7142 7.3108C15.9122 8.72021 18.0878 8.72021 19.2858 7.3108L24.6015 1.05705C24.6179 1.0378 24.6345 1.01878 24.6513 1C25.2195 0.364594 26.0325 0 26.8873 0H28V1H26.8873C26.3006 1 25.7434 1.25765 25.3634 1.7047L20.0478 7.95845C18.4504 9.83766 15.5496 9.83766 13.9522 7.95845L8.63656 1.7047C8.25656 1.25765 7.69942 1 7.11268 1Z",fill:o.palette.background[600]})]})});G.displayName="Tip";var P=G;import{css as j}from"@emotion/react";var I=x("div")`
  .${a.anchorEl} {
    cursor: pointer;
  }
`,z=x("div")(({theme:t})=>j`
    position: relative;
    display: flex;
    gap: ${t.spacing(4)};
    padding: ${t.spacing(2)} ${t.spacing(3)};
    color: ${t.palette.background[900]};
    font-size: ${t.typography.pxToRem(12)};
    line-height: ${t.typography.pxToRem(16)};
    background: ${t.palette.background[500]};
    border: 1px solid ${t.palette.background[600]};
    border-radius: ${t.spacing(1.5)};

    > svg {
      position: absolute;

      .${a.popper}[data-popper-placement*="top"]  & {
        top: 100%;
      }

      .${a.popper}[data-popper-placement*="bottom"] & {
        bottom: 100%;
        transform: rotate(180deg);
      }

      .${a.popper}[data-popper-placement*="left"] & {
        left: calc(100% - 12px);
        transform: rotate(-90deg);
      }

      .${a.popper}[data-popper-placement*="right"] & {
        right: calc(100% - 12px);
        transform: rotate(90deg);
      }
    }

    .${a.popper}[data-popper-placement*="top"] & {
      margin-bottom: ${t.spacing(3)};
    }

    .${a.popper}[data-popper-placement*="bottom"] & {
      margin-top: ${t.spacing(3)};
    }

    .${a.popper}[data-popper-placement*="left"] & {
      margin-right: ${t.spacing(3)};
    }

    .${a.popper}[data-popper-placement*="right"] & {
      margin-left: ${t.spacing(3)};
    }

    .${a.popper}.${a.panel} & {
      padding: ${t.spacing(3)};
      margin: ${t.spacing(1)} 0 0;
      background: ${t.palette.background[300]};
      border: 1px solid ${t.palette.background[500]};
      border-radius: ${t.spacing(2)};
    }
  `),W=x(U)(({theme:t})=>({zIndex:t.zIndex.tooltip}));import{jsx as R,jsxs as Z}from"react/jsx-runtime";var ot=t=>{let{anchorEl:i,children:o,className:S,content:p,id:h,isPanel:c=!1,open:u=!1,placement:l="bottom"}=t,T=C(),r=b(t),g=n=>{setTimeout(()=>{if(i&&n?.parentElement?.parentElement){let d=i.getBoundingClientRect(),e=n.parentElement.parentElement.getBoundingClientRect(),f=n.getBoundingClientRect(),s;n.style.opacity="0",l.includes("bottom")||l.includes("top")?(s=d.left+d.width/2-(e.left+f.width/2),s=Math.max(8,s),s=Math.min(e.width-f.width-8,s),n.style.left=`${s}px`):(s=d.top+d.height/2-(e.top+f.height/2),s=Math.min(e.height-f.height/2-5,Math.max(s,f.height/2+5)),n.style.top=`${s}px`),n.style.opacity="1"}},100)},E=D(o,{...o.props,className:y(o.props.className,r.anchorEl)}),m=p&&et(p)?D(p,{...p.props,className:y(p.props.className,r.content)}):p;return Z(I,{className:y(r.root),children:[E,R(W,{anchorEl:i,className:y(r.popper,S),open:u,placement:l,transition:!0,children:({TransitionProps:n})=>R(O,{timeout:T.transitions.duration.shorter,...n,children:Z(z,{className:y(r.content),id:h,children:[m,!c&&R(P,{className:y(r.tip),ref:g})]})})})]})},$=ot;import{useCallback as nt,useEffect as pt,useRef as v,useState as rt}from"react";function N({onClose:t,onOpen:i,touchDelay:o,touchEndDelay:S}){let[p,h]=rt(!1),c=v("initial"),u=v(!1),l=v(),T=v(),r=nt(()=>{c.current!=="initial"&&(document.body.style.webkitUserSelect=c.current,c.current="initial"),clearTimeout(T.current)},[]);pt(()=>()=>{clearTimeout(l.current),r()},[r]);let g=e=>{h(!0),i?.(e)},E=e=>{h(!1),u.current=!1,t?.(e)},m=e=>{u.current&&e.type!=="touchstart"||(clearTimeout(l.current),g(e))};return{handleClose:E,handleEnter:m,handleTouchEnd:e=>{r(),clearTimeout(l.current),l.current=setTimeout(()=>{E(e)},S)},handleTouchStart:e=>{u.current=!0,clearTimeout(l.current),r(),c.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",T.current=setTimeout(()=>{document.body.style.webkitUserSelect=c.current,m(e)},o)},open:p}}import{jsx as mt}from"react/jsx-runtime";var k=at((t,i)=>{let{children:o,className:S,content:p,id:h,isPanel:c,open:u,persistOnHover:l,placement:T}=t,r=M(),[g,E]=st(null),{handleClose:m,handleEnter:n,handleTouchEnd:d,handleTouchStart:e,open:f}=N(t),s=L(o.props.ref,E,i),q=b(t),J=l&&lt(p)?A(p,{...p.props,onMouseEnter:n,onMouseLeave:m}):p,K=o&&A(o,{...o.props,className:it(o.props.className,q.anchorEl),key:"tooltip-child",onBlur:m,onFocus:Q=>{r==="keyboard"&&n(Q)},onMouseEnter:n,onMouseLeave:l?d:m,onTouchEnd:d,onTouchStart:e,ref:s});return mt($,{anchorEl:g,className:S,content:J,id:h,isPanel:c,open:u||f&&Boolean(g),placement:T,children:K})});k.displayName="Tooltip";k.defaultProps={placement:"bottom",touchDelay:700,touchEndDelay:1500};var ct=k;export{a,$ as b,ct as c};
