Loading
function(e,t,n){n.d(t,{L:()=>d,A:()=>u});var l=n(627968),r=n(64700),i=n(844222),a=n(350535),s=n(642481),o=n(650583);function d(e){let{children:t,targetElementRef:n,estimatedTooltipHeight:d,delay:u=300,onShow:c,title:m,body:g,graphic:p,size:f="md",actions:h,gradientColor:E}=e,_=r.useContext(i.C),[x,v]=r.useState("closed"),R=r.useRef(null),b=r.useRef(!1),j="opening-mouse"===x||"open-mouse"===x,C="opening-keyboard"===x||"open-keyboard"===x,y="open-mouse"===x||"open-keyboard"===x,A=(_.keyboardModeEnabled||C)&&null!=h,[I,O]=r.useState(0),T=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,n=arguments.length>2?arguments[2]:void 0,[l,i]=r.useState("top");return r.useEffect(()=>{if(null==e.current)return void i("top");let n=e.current.getBoundingClientRect(),l=window.innerWidth,r=window.innerHeight,a={top:n.top,bottom:r-n.bottom,left:n.left,right:l-n.right},s=["top","bottom","right","left"];for(let e of s)if(a[e]>=t)return void i(e);i(s.reduce((e,t)=>a[t]>a[e]?t:e,"top"))},[e,t,n]),l}(n,d,x),N=r.useCallback(()=>{null!=R.current&&(clearTimeout(R.current),R.current=null)},[]),S=r.useCallback(e=>{e&&(b.current=!0),N(),v("closing")},[N]);r.useEffect(()=>N,[N]);let U=r.useCallback(()=>{("closed"===x||"closing"===x)&&(N(),v("opening-mouse"))},[N,x]),D=r.useCallback(()=>{j&&S(!1)},[S,j]),k=r.useCallback(()=>{if(b.current||"closed"!==x&&"closing"!==x){b.current=!1;return}N(),v("opening-keyboard")},[N,x]),L=r.useCallback(()=>{A&&"opening-keyboard"!==x||S(!1)},[S,x,A]);r.useEffect(()=>{if("opening-mouse"===x)return R.current=window.setTimeout(()=>{R.current=null,v("open-mouse"),c?.()},u),N},[x,u,c,N]),r.useEffect(()=>{if("opening-keyboard"===x)return R.current=window.setTimeout(()=>{R.current=null,v("open-keyboard"),c?.()},u),N},[x,u,c,N]),r.useEffect(()=>{if("closing"===x)return R.current=window.setTimeout(()=>{R.current=null,v("closed")},200),N},[x,N]),r.useEffect(()=>{if(!y)return;let e=e=>{e.key===o.dh.ESCAPE&&(e.preventDefault(),e.stopPropagation(),S(!0))};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[y,S]);let B=r.useMemo(()=>null==h?h:h.map(e=>({...e,onClick:t=>{e.onClick?.(t),S(!1)}})),[h,S]),P=r.useCallback(e=>{O(e)},[]);return(0,l.jsxs)("div",{onMouseEnter:U,onMouseLeave:D,onFocus:k,onBlur:L,children:[t,(0,l.jsx)(s.j,{targetElementRef:n,shouldShow:y,position:T,align:"center",title:m,body:g,graphic:p,size:f,actions:B,gradientColor:E,showCloseButton:A,shouldTrapFocus:A,returnRef:A?n:void 0,isCaretHoverable:!0,caretConfig:{align:"custom",customOffset:I},onNudgeChange:P,onRequestClose:e=>{S(null!=e&&(0,a.sg)(e))}})]})}let u=d}