import{r as e,j as i}from"./index-DCzV2WLr.js";import{S}from"./info_icon-D8fJPANx.js";const V="_container_qq0n4_1",B="_trigger_qq0n4_10",L="_icon_qq0n4_15",N="_infoIcon_qq0n4_21",y="_panel_qq0n4_25",P="_panelVisible_qq0n4_44",o={container:V,trigger:B,icon:L,infoIcon:N,panel:y,panelVisible:P},Z="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_12658_16703)'%3e%3cpath%20d='M10%200C8.02219%200%206.08879%200.58649%204.4443%201.6853C2.79981%202.78412%201.51809%204.3459%200.761209%206.17317C0.00433286%208.00043%20-0.193701%2010.0111%200.192152%2011.9509C0.578004%2013.8907%201.53041%2015.6725%202.92894%2017.0711C4.32746%2018.4696%206.10929%2019.422%208.0491%2019.8079C9.98891%2020.1937%2011.9996%2019.9957%2013.8268%2019.2388C15.6541%2018.4819%2017.2159%2017.2002%2018.3147%2015.5557C19.4135%2013.9112%2020%2011.9778%2020%2010C19.9971%207.34872%2018.9426%204.80684%2017.0679%202.9321C15.1932%201.05736%2012.6513%200.00286757%2010%200ZM10%2018.3333C8.35183%2018.3333%206.74066%2017.8446%205.37025%2016.9289C3.99984%2016.0132%202.93174%2014.7117%202.30101%2013.189C1.67028%2011.6663%201.50525%209.99076%201.82679%208.37425C2.14834%206.75774%202.94201%205.27288%204.10745%204.10744C5.27289%202.94201%206.75774%202.14833%208.37425%201.82679C9.99076%201.50525%2011.6663%201.67027%2013.189%202.301C14.7118%202.93173%2016.0132%203.99984%2016.9289%205.37025C17.8446%206.74066%2018.3333%208.35182%2018.3333%2010C18.3309%2012.2094%2017.4522%2014.3276%2015.8899%2015.8899C14.3276%2017.4522%2012.2094%2018.3309%2010%2018.3333Z'%20fill='%239A9CB0'/%3e%3cpath%20d='M9.99992%208.33337H9.16659C8.94557%208.33337%208.73361%208.42117%208.57733%208.57745C8.42105%208.73373%208.33325%208.94569%208.33325%209.16671C8.33325%209.38772%208.42105%209.59968%208.57733%209.75596C8.73361%209.91224%208.94557%2010%209.16659%2010H9.99992V15C9.99992%2015.2211%2010.0877%2015.433%2010.244%2015.5893C10.4003%2015.7456%2010.6122%2015.8334%2010.8333%2015.8334C11.0543%2015.8334%2011.2662%2015.7456%2011.4225%2015.5893C11.5788%2015.433%2011.6666%2015.2211%2011.6666%2015V10C11.6666%209.55801%2011.491%209.13409%2011.1784%208.82153C10.8659%208.50897%2010.4419%208.33337%209.99992%208.33337Z'%20fill='%239A9CB0'/%3e%3cpath%20d='M10%206.66663C10.6904%206.66663%2011.25%206.10698%2011.25%205.41663C11.25%204.72627%2010.6904%204.16663%2010%204.16663C9.30964%204.16663%208.75%204.72627%208.75%205.41663C8.75%206.10698%209.30964%206.66663%2010%206.66663Z'%20fill='%239A9CB0'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_12658_16703'%3e%3crect%20width='20'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",$=(s=768)=>{const[c,d]=e.useState(window.innerWidth<s);return e.useEffect(()=>{const l=()=>d(window.innerWidth<s);return window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[s]),c},T=({tooltipText:s,position:c="left",className:d="",onClick:l,type:v="accent",gap:w=8})=>{const[t,a]=e.useState(!1),[C,_]=e.useState(!1),[x,M]=e.useState({}),r=$(),h=e.useRef(null),g=e.useRef(null),p=e.useRef(null),m=e.useRef(null);e.useEffect(()=>(t?_(!0):m.current=setTimeout(()=>{_(!1)},200),()=>{m.current&&clearTimeout(m.current)}),[t]);const R=()=>{r&&a(!t)},I=n=>{l&&l(n),R()},b=()=>{r||a(!0)},q=()=>{r||a(!1)};e.useEffect(()=>{const n=f=>{h.current&&!h.current.contains(f.target)&&a(!1)};return t&&r&&document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[t,r]),e.useLayoutEffect(()=>{if(C&&g.current&&p.current){const n=g.current.getBoundingClientRect(),f=p.current.getBoundingClientRect(),j=n.height+w;let u=0;c==="right"?u=n.width-f.width:c==="middle"?u=(n.width-f.width)/2:u=0,M({top:`${j}px`,left:`${u}px`})}},[C,c,s,w]);const E=[o.container,d].filter(Boolean).join(" ");return i.jsxs("div",{ref:h,className:E,onClick:I,onMouseEnter:b,onMouseLeave:q,children:[i.jsx("div",{ref:g,className:o.trigger,role:"button","aria-haspopup":"true","aria-expanded":t,children:v==="accent"?i.jsx(S,{className:o.infoIcon}):i.jsx("img",{src:Z,alt:"Рнформация",className:o.icon})}),C&&i.jsx("div",{ref:p,className:`${o.panel} ${t?o.panelVisible:""}`,style:x,role:"region","aria-label":"Подсказка",children:i.jsx("p",{className:"body-3",children:s})})]})};export{T as I};