import{cf as e,df as t,sf as n}from"./messages-CNn8r9_i.js";import{t as r}from"./dist-C1FpE_gz.js";import{d as i}from"./button-JhAGlo93.js";import{t as a}from"./dist-CItiEXJ0.js";var o=t(e(),1),s=n(),c=`focusScope.autoFocusOnMount`,l=`focusScope.autoFocusOnUnmount`,u={bubbles:!1,cancelable:!0},d=`FocusScope`,f=o.forwardRef((e,t)=>{let{loop:n=!1,trapped:d=!1,onMountAutoFocus:f,onUnmountAutoFocus:g,..._}=e,[v,x]=o.useState(null),S=a(f),w=a(g),T=o.useRef(null),E=i(t,e=>x(e)),D=o.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;o.useEffect(()=>{if(d){let e=function(e){if(D.paused||!v)return;let t=e.target;v.contains(t)?T.current=t:y(T.current,{select:!0})},t=function(e){if(D.paused||!v)return;let t=e.relatedTarget;t!==null&&(v.contains(t)||y(T.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&y(v)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return v&&r.observe(v,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[d,v,D.paused]),o.useEffect(()=>{if(v){b.add(D);let e=document.activeElement;if(!v.contains(e)){let t=new CustomEvent(c,u);v.addEventListener(c,S),v.dispatchEvent(t),t.defaultPrevented||(p(C(h(v)),{select:!0}),document.activeElement===e&&y(v))}return()=>{v.removeEventListener(c,S),setTimeout(()=>{let t=new CustomEvent(l,u);v.addEventListener(l,w),v.dispatchEvent(t),t.defaultPrevented||y(e??document.body,{select:!0}),v.removeEventListener(l,w),b.remove(D)},0)}}},[v,S,w,D]);let O=o.useCallback(e=>{if(!n&&!d||D.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){let t=e.currentTarget,[i,a]=m(t);i&&a?!e.shiftKey&&r===a?(e.preventDefault(),n&&y(i,{select:!0})):e.shiftKey&&r===i&&(e.preventDefault(),n&&y(a,{select:!0})):r===t&&e.preventDefault()}},[n,d,D.paused]);return(0,s.jsx)(r.div,{tabIndex:-1,..._,ref:E,onKeyDown:O})});f.displayName=d;function p(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(y(r,{select:t}),document.activeElement!==n)return}function m(e){let t=h(e);return[g(t,e),g(t.reverse(),e)]}function h(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function g(e,t){for(let n of e)if(!_(n,{upTo:t}))return n}function _(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function v(e){return e instanceof HTMLInputElement&&`select`in e}function y(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&v(e)&&t&&e.select()}}var b=x();function x(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=S(e,t),e.unshift(t)},remove(t){e=S(e,t),e[0]?.resume()}}}function S(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function C(e){return e.filter(e=>e.tagName!==`A`)}var w=0;function T(){o.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??E()),document.body.insertAdjacentElement(`beforeend`,e[1]??E()),w++,()=>{w===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),w--}},[])}function E(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var D=function(){return D=Object.assign||function(e){for(var t,n=1,r=arguments.length;n`u`)return ge;var t=_e(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ye=R(),B=`data-scroll-locked`,be=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),` .${te} { overflow: hidden ${r}; padding-right: ${s}px ${r}; } body[${B}] { overflow: hidden ${r}; overscroll-behavior: contain; ${[t&&`position: relative ${r};`,n===`margin`&&` padding-left: ${i}px; padding-top: ${a}px; padding-right: ${o}px; margin-left:0; margin-top:0; margin-right: ${s}px ${r}; `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)} } .${k} { right: ${s}px ${r}; } .${A} { margin-right: ${s}px ${r}; } .${k} .${k} { right: 0 ${r}; } .${A} .${A} { margin-right: 0 ${r}; } body[${B}] { ${ne}: ${s}px; } `},V=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},xe=function(){o.useEffect(function(){return document.body.setAttribute(B,(V()+1).toString()),function(){var e=V()-1;e<=0?document.body.removeAttribute(B):document.body.setAttribute(B,e.toString())}},[])},Se=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;xe();var a=o.useMemo(function(){return ve(i)},[i]);return o.createElement(ye,{styles:be(a,!t,i,n?``:`!important`)})},H=!1;if(typeof window<`u`)try{var U=Object.defineProperty({},`passive`,{get:function(){return H=!0,!0}});window.addEventListener(`test`,U,U),window.removeEventListener(`test`,U,U)}catch{H=!1}var W=H?{passive:!1}:!1,Ce=function(e){return e.tagName===`TEXTAREA`},G=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Ce(e)&&n[t]===`visible`)},we=function(e){return G(e,`overflowY`)},Te=function(e){return G(e,`overflowX`)},K=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),q(e,r)){var i=Oe(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ee=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},De=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},q=function(e,t){return e===`v`?we(t):Te(t)},Oe=function(e,t){return e===`v`?Ee(t):De(t)},ke=function(e,t){return e===`h`&&t===`rtl`?-1:1},Ae=function(e,t,n,r,i){var a=ke(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Oe(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&q(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},J=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},je=function(e){return[e.deltaX,e.deltaY]},Me=function(e){return e&&`current`in e?e.current:e},Ne=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pe=function(e){return` .block-interactivity-${e} {pointer-events: none;} .allow-interactivity-${e} {pointer-events: all;} `},Fe=0,Y=[];function Ie(e){var t=o.useRef([]),n=o.useRef([0,0]),r=o.useRef(),i=o.useState(Fe++)[0],a=o.useState(R)[0],s=o.useRef(e);o.useEffect(function(){s.current=e},[e]),o.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ee([e.lockRef.current],(e.shards||[]).map(Me),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var c=o.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!s.current.allowPinchZoom;var i=J(e),a=n.current,o=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(o)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=K(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=K(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(o||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ae(h,t,e,h===`h`?o:c,!0)},[]),l=o.useCallback(function(e){var n=e;if(!(!Y.length||Y[Y.length-1]!==a)){var r=`deltaY`in n?je(n):J(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Ne(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var o=(s.current.shards||[]).map(Me).filter(Boolean).filter(function(e){return e.contains(n.target)});(o.length>0?c(n,o[0]):!s.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=o.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Le(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=o.useCallback(function(e){n.current=J(e),r.current=void 0},[]),f=o.useCallback(function(t){u(t.type,je(t),t.target,c(t,e.lockRef.current))},[]),p=o.useCallback(function(t){u(t.type,J(t),t.target,c(t,e.lockRef.current))},[]);o.useEffect(function(){return Y.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,l,W),document.addEventListener(`touchmove`,l,W),document.addEventListener(`touchstart`,d,W),function(){Y=Y.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,l,W),document.removeEventListener(`touchmove`,l,W),document.removeEventListener(`touchstart`,d,W)}},[]);var m=e.removeScrollBar,h=e.inert;return o.createElement(o.Fragment,null,h?o.createElement(a,{styles:Pe(i)}):null,m?o.createElement(Se,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Le(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Re=le(P,Ie),ze=o.forwardRef(function(e,t){return o.createElement(I,D({},e,{ref:t,sideCar:Re}))});ze.classNames=I.classNames;var Be=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},X=new WeakMap,Z=new WeakMap,Q={},$=0,Ve=function(e){return e&&(e.host||Ve(e.parentNode))},He=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ve(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Ue=function(e,t,n,r){var i=He(t,Array.isArray(e)?e:[e]);Q[n]||(Q[n]=new WeakMap);var a=Q[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(X.get(e)||0)+1,l=(a.get(e)||0)+1;X.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Z.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),$++,function(){o.forEach(function(e){var t=X.get(e)-1,i=a.get(e)-1;X.set(e,t),a.set(e,i),t||(Z.has(e)||e.removeAttribute(r),Z.delete(e)),i||e.removeAttribute(n)}),$--,$||(X=new WeakMap,X=new WeakMap,Z=new WeakMap,Q={})}},We=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Be(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Ue(r,i,n,`aria-hidden`)):function(){return null}};export{f as i,ze as n,T as r,We as t};