"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react/jsx-runtime");require("../primitives/button.js"),require("../primitives/checkbox.js"),require("../primitives/dropdown-selector.js"),require("../primitives/popover.js"),require("../primitives/radio.js"),require("../primitives/segmented-control.js"),require("../primitives/switch.js");var M=require("../primitives/text.js"),b=require("../../hooks/useClickAway.js"),k=require("../../hooks/useToggleState.js"),B=require("../../recipes/tooltip.js"),u=require("@styled/jsx"),t=require("react"),x=require("react-aria");const g=t.forwardRef((o,q)=>{const m="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.maxTouchPoints>0,{children:v,content:f,width:h=288,closeDelay:O=2500,defaultOpen:T,placement:c="top",expand:j=!1,...w}=o,[s,n]=t.useState(!1),{isSelected:p,setSelected:r}=k.useToggleState({isOpen:o.isOpen,defaultSelected:T,onChange(l){l||n(!1)},...o}),e=t.useMemo(()=>({isOpen:p,open:()=>{r(!0)},close:l=>{if(l){r(!1);return}m?r(!1):(s&&setTimeout(()=>{r(!1),n(!1)},O),s||r(!1))}}),[p,s]),y=t.useRef(null),{triggerProps:d,tooltipProps:P}=x.useTooltipTrigger(o,e,y);d.onClick=()=>{e.open(),n(!0)};const S=b.useClickAway(()=>{e.close(!0)}),C=c.split(" ")[0],a=B.tooltip({expand:j,isOpen:e.isOpen,placement:c,position:C});return i.jsxs(u.Box,{ref:S,className:a.trigger,onMouseLeave:()=>{e.close()},onFocus:()=>{e.open()},onBlur:()=>{e.close()},children:[t.cloneElement(v,{...d,tabIndex:0}),i.jsxs(u.Box,{ref:q,"aria-describedby":"tooltip",role:"tooltip",className:a.content,style:{width:h},onMouseEnter:()=>{e.open()},...x.mergeProps(P,w),children:[i.jsx(M.default,{size:"sm",children:f}),e.isOpen&&i.jsx(u.Box,{onMouseEnter:()=>{e.open()},className:a.spacer})]})]})});g.displayName="Tooltip",exports.default=g;
//# sourceMappingURL=tooltip.js.map
