import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{t}from"./react-Augu_vA3.js";import{D as n,E as r,k as i,y as a}from"./forms-CL2ODv4X.js";var o=e(t(),1);function s(e){return i.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty(`current`)&&e.current instanceof Node?e.current.ownerDocument:document}var c=[`[contentEditable=true]`,`[tabindex]`,`a[href]`,`area[href]`,`button:not([disabled])`,`iframe`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].map(e=>`${e}:not([tabindex='-1'])`).join(`,`),l=(e=>(e[e.First=1]=`First`,e[e.Previous=2]=`Previous`,e[e.Next=4]=`Next`,e[e.Last=8]=`Last`,e[e.WrapAround=16]=`WrapAround`,e[e.NoScroll=32]=`NoScroll`,e))(l||{}),u=(e=>(e[e.Error=0]=`Error`,e[e.Overflow=1]=`Overflow`,e[e.Success=2]=`Success`,e[e.Underflow=3]=`Underflow`,e))(u||{}),d=(e=>(e[e.Previous=-1]=`Previous`,e[e.Next=1]=`Next`,e))(d||{});function f(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(c)).sort((e,t)=>Math.sign((e.tabIndex||2**53-1)-(t.tabIndex||2**53-1)))}var p=(e=>(e[e.Strict=0]=`Strict`,e[e.Loose=1]=`Loose`,e))(p||{});function m(e,t=0){return e!==s(e)?.body&&a(t,{0(){return e.matches(c)},1(){let t=e;for(;t!==null;){if(t.matches(c))return!0;t=t.parentElement}return!1}})}var h=(e=>(e[e.Keyboard=0]=`Keyboard`,e[e.Mouse=1]=`Mouse`,e))(h||{});typeof window<`u`&&typeof document<`u`&&(document.addEventListener(`keydown`,e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible=``)},!0),document.addEventListener(`click`,e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible=``)},!0));function g(e){e?.focus({preventScroll:!0})}var _=[`textarea`,`input`].join(`,`);function v(e){return(e?.matches)?.call(e,_)??!1}function y(e,t=e=>e){return e.slice().sort((e,n)=>{let r=t(e),i=t(n);if(r===null||i===null)return 0;let a=r.compareDocumentPosition(i);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function b(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:i=[]}={}){let a=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,o=Array.isArray(e)?n?y(e):e:f(e);i.length>0&&o.length>1&&(o=o.filter(e=>!i.includes(e))),r??=a.activeElement;let s=(()=>{if(t&5)return 1;if(t&10)return-1;throw Error(`Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last`)})(),c=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,o.indexOf(r))-1;if(t&4)return Math.max(0,o.indexOf(r))+1;if(t&8)return o.length-1;throw Error(`Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last`)})(),l=t&32?{preventScroll:!0}:{},u=0,d=o.length,p;do{if(u>=d||u+d<=0)return 0;let e=c+u;if(t&16)e=(e+d)%d;else{if(e<0)return 3;if(e>=d)return 1}p=o[e],p?.focus(l),u+=s}while(p!==a.activeElement);return t&6&&v(p)&&p.select(),2}function x(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function S(){return/Android/gi.test(window.navigator.userAgent)}function C(){return x()||S()}function w(e,t,r){let i=n(t);(0,o.useEffect)(()=>{function t(e){i.current(e)}return document.addEventListener(e,t,r),()=>document.removeEventListener(e,t,r)},[e,r])}function T(e,t,r){let i=n(t);(0,o.useEffect)(()=>{function t(e){i.current(e)}return window.addEventListener(e,t,r),()=>window.removeEventListener(e,t,r)},[e,r])}function E(e,t,n=!0){let r=(0,o.useRef)(!1);(0,o.useEffect)(()=>{requestAnimationFrame(()=>{r.current=n})},[n]);function i(n,i){if(!r.current||n.defaultPrevented)return;let a=i(n);if(a===null||!a.getRootNode().contains(a)||!a.isConnected)return;let o=function e(t){return typeof t==`function`?e(t()):Array.isArray(t)||t instanceof Set?t:[t]}(e);for(let e of o){if(e===null)continue;let t=e instanceof HTMLElement?e:e.current;if(t!=null&&t.contains(a)||n.composed&&n.composedPath().includes(t))return}return!m(a,p.Loose)&&a.tabIndex!==-1&&n.preventDefault(),t(n,a)}let a=(0,o.useRef)(null);w(`pointerdown`,e=>{r.current&&(a.current=e.composedPath?.call(e)?.[0]||e.target)},!0),w(`mousedown`,e=>{r.current&&(a.current=e.composedPath?.call(e)?.[0]||e.target)},!0),w(`click`,e=>{C()||(a.current&&=(i(e,()=>a.current),null))},!0),w(`touchend`,e=>i(e,()=>e.target instanceof HTMLElement?e.target:null),!0),T(`blur`,e=>i(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function D(...e){return(0,o.useMemo)(()=>s(...e),[...e])}function O(e,t){let n=(0,o.useRef)([]),i=r(e);(0,o.useEffect)(()=>{let e=[...n.current];for(let[r,a]of t.entries())if(n.current[r]!==a){let r=i(t,e);return n.current=t,r}},[i,...t])}var k=(0,o.createContext)(null);k.displayName=`OpenClosedContext`;var A=(e=>(e[e.Open=1]=`Open`,e[e.Closed=2]=`Closed`,e[e.Closing=4]=`Closing`,e[e.Opening=8]=`Opening`,e))(A||{});function j(){return(0,o.useContext)(k)}function M({value:e,children:t}){return o.createElement(k.Provider,{value:e},t)}function N(e){function t(){document.readyState!==`loading`&&(e(),document.removeEventListener(`DOMContentLoaded`,t))}typeof window<`u`&&typeof document<`u`&&(document.addEventListener(`DOMContentLoaded`,t),t())}var P=[];N(()=>{function e(e){e.target instanceof HTMLElement&&e.target!==document.body&&P[0]!==e.target&&(P.unshift(e.target),P=P.filter(e=>e!=null&&e.isConnected),P.splice(10))}window.addEventListener(`click`,e,{capture:!0}),window.addEventListener(`mousedown`,e,{capture:!0}),window.addEventListener(`focus`,e,{capture:!0}),document.body.addEventListener(`click`,e,{capture:!0}),document.body.addEventListener(`mousedown`,e,{capture:!0}),document.body.addEventListener(`focus`,e,{capture:!0})});export{m as _,O as a,T as c,y as d,l as f,f as g,p as h,j as i,C as l,b as m,A as n,D as o,u as p,M as r,E as s,P as t,x as u,g as v,s as y};