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