"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.js"),a=require("react"),S=require("../../node_modules/react-popper/lib/esm/usePopper.js"),U=require("../../icons/Close.js"),A=require("../../hooks/useDelayUnmount.js"),i=require("./styles.js"),V=require("../../utils/index.js"),W=require("../IconButton/index.js");function g({children:x,mode:f="AUTO",width:m,content:l,variant:s="definition",placement:u="top-start",title:j,xOffset:E=0,yOffset:h=4,nonStaticWidth:v=!1,...t}){const[R,b]=a.useState(null),[q,y]=a.useState(null),[c,d]=a.useState(!1),T=A.useDelayUnmount(c,350),k=V.getId(t["data-testid"]),p=v&&s==="definition",n=f==="MANUAL"&&s==="definition",C=p&&!["top","bottom"].includes(u)?"top":u,{styles:I,attributes:M}=S.usePopper(R,q,{placement:C,modifiers:[{name:"offset",options:{offset:[E,h]}}]}),o=()=>{d(!0)},r=()=>{d(!1)},P=()=>n?{onClick:o}:{onMouseEnter:o,onMouseLeave:r};return e.jsxRuntimeExports.jsxs(i.Wrapper,{children:[e.jsxRuntimeExports.jsx("span",{ref:b,onFocus:o,onBlur:r,...P(),tabIndex:0,children:x}),T&&l&&e.jsxRuntimeExports.jsxs(i.PopoverContainer,{ref:y,width:m,style:I.popper,variant:s,isVisible:c,isManual:n,nonStaticWidth:p,...M.props,"data-testid":t["data-testid"],"data-trackid":t["data-trackid"],"aria-label":t["aria-label"],"aria-checked":t["aria-checked"],children:[s==="definition"&&e.jsxRuntimeExports.jsx(i.TooltipTitle,{children:j}),l,n&&e.jsxRuntimeExports.jsx(i.CloseIconContainer,{children:e.jsxRuntimeExports.jsx(W.IconButton,{icon:e.jsxRuntimeExports.jsx(U.default,{}),variant:"ghost",size:"x-small","data-testid":k("close-icon"),onClick:r})})]})]})}exports.Tooltip=g;
