import{r as l,R as Te,W as s}from"./chunk-LFPYN7LY-BBzdRvLF.js";import{o as Ke,d as Ve}from"./keyboard-YMzSIKlt.js";import{E as Ie}from"./use-event-listener-DVMhAIzP.js";import{I as Ee,u as xe,c as We,b as le,i as D,N as ze,d as Qe,g as Xe,h as Ge,x as qe,S as Ze,e as Je,f as _e,p as et,j as tt,l as Ce,t as nt,X as rt}from"./portal-uZHCK1-a.js";import{n as B,d as me,Y as x,y as K,b as C,f as re,u as G,p as Le,K as j,g as Oe,i as ye,t as lt,A as he,C as M,e as at,h as ot,j as ut,s as it,a as ae}from"./use-sync-refs-BVOyhIhP.js";import{y as st}from"./use-inert-others-Bj2I0D1Z.js";import{u as ct,a as ne,j as Se,x as dt,S as ft,C as pt}from"./use-tab-direction-URJqSVtd.js";import{M as mt,H as vt}from"./description-L7M3MMUj.js";import{f as be}from"./use-is-mounted-88Gak2T3.js";import{m as $e,n as ve}from"./active-element-history-DuKQP1m2.js";import{f as Re,s as Pe}from"./hidden-BBJayvbf.js";import{v as X,T as O,w as I,A as De}from"./focus-management-jyWB_kd_.js";function ht(e,t=typeof document<"u"?document.defaultView:null,n){let r=Ee(e,"escape");Ie(t,"keydown",a=>{r&&(a.defaultPrevented||a.key===Ke.Escape&&n(a))})}function gt(){var e;let[t]=l.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,r]=l.useState((e=t==null?void 0:t.matches)!=null?e:!1);return B(()=>{if(!t)return;function a(c){r(c.matches)}return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[t]),n}function Et(){let e=typeof document>"u";return"useSyncExternalStore"in Te?(t=>t.useSyncExternalStore)(Te)(()=>()=>{},()=>!1,()=>!e):!1}function oe(){let e=Et(),[t,n]=l.useState(me.isHandoffComplete);return t&&me.isHandoffComplete===!1&&n(!1),l.useEffect(()=>{t!==!0&&n(!0)},[t]),l.useEffect(()=>me.handoff(),[]),e?!1:t}function Ae(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)lt(n.current)&&t.add(n.current);return t}let bt="div";var H=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(H||{});function $t(e,t){let n=l.useRef(null),r=K(n,t),{initialFocus:a,initialFocusFallback:c,containers:d,features:o=15,...v}=e;oe()||(o=0);let i=xe(n.current);Ct(o,{ownerDocument:i});let g=yt(o,{ownerDocument:i,container:n,initialFocus:a,initialFocusFallback:c});St(o,{ownerDocument:i,container:n,containers:d,previousActiveElement:g});let T=ct(),w=C($=>{if(!re(n.current))return;let E=n.current;(b=>b())(()=>{G(T.current,{[ne.Forwards]:()=>{X(E,O.First,{skipElements:[$.relatedTarget,c]})},[ne.Backwards]:()=>{X(E,O.Last,{skipElements:[$.relatedTarget,c]})}})})}),p=Ee(!!(o&2),"focus-trap#tab-lock"),u=Le(),h=l.useRef(!1),m={ref:r,onKeyDown($){$.key=="Tab"&&(h.current=!0,u.requestAnimationFrame(()=>{h.current=!1}))},onBlur($){if(!(o&4))return;let E=Ae(d);re(n.current)&&E.add(n.current);let b=$.relatedTarget;ye(b)&&b.dataset.headlessuiFocusGuard!=="true"&&(Ne(E,b)||(h.current?X(n.current,G(T.current,{[ne.Forwards]:()=>O.Next,[ne.Backwards]:()=>O.Previous})|O.WrapAround,{relativeTo:$.target}):ye($.target)&&I($.target)))}},F=j();return s.createElement(s.Fragment,null,p&&s.createElement(Re,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:w,features:Pe.Focusable}),F({ourProps:m,theirProps:v,defaultTag:bt,name:"FocusTrap"}),p&&s.createElement(Re,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:w,features:Pe.Focusable}))}let wt=x($t),Ft=Object.assign(wt,{features:H});function Tt(e=!0){let t=l.useRef(ve.slice());return $e(([n],[r])=>{r===!0&&n===!1&&Oe(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=ve.slice())},[e,ve,t]),C(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function Ct(e,{ownerDocument:t}){let n=!!(e&8),r=Tt(n);$e(()=>{n||Ve(t==null?void 0:t.body)&&I(r())},[n]),We(()=>{n&&I(r())})}function yt(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:a}){let c=l.useRef(null),d=Ee(!!(e&1),"focus-trap#initial-focus"),o=be();return $e(()=>{if(e===0)return;if(!d){a!=null&&a.current&&I(a.current);return}let v=n.current;v&&Oe(()=>{if(!o.current)return;let i=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===i){c.current=i;return}}else if(v.contains(i)){c.current=i;return}if(r!=null&&r.current)I(r.current);else{if(e&16){if(X(v,O.First|O.AutoFocus)!==De.Error)return}else if(X(v,O.First)!==De.Error)return;if(a!=null&&a.current&&(I(a.current),(t==null?void 0:t.activeElement)===a.current))return;console.warn("There are no focusable elements inside the ")}c.current=t==null?void 0:t.activeElement})},[a,d,e]),c}function St(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:a}){let c=be(),d=!!(e&4);Ie(t==null?void 0:t.defaultView,"focus",o=>{if(!d||!c.current)return;let v=Ae(r);re(n.current)&&v.add(n.current);let i=a.current;if(!i)return;let g=o.target;re(g)?Ne(v,g)?(a.current=g,I(g)):(o.preventDefault(),o.stopPropagation(),I(i)):I(a.current)},!0)}function Ne(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function He(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!ut((t=e.as)!=null?t:Be)||s.Children.count(e.children)===1}let ue=l.createContext(null);ue.displayName="TransitionContext";var Rt=(e=>(e.Visible="visible",e.Hidden="hidden",e))(Rt||{});function Pt(){let e=l.useContext(ue);if(e===null)throw new Error("A is used but it is missing a parent or .");return e}function Dt(){let e=l.useContext(ie);if(e===null)throw new Error("A is used but it is missing a parent or .");return e}let ie=l.createContext(null);ie.displayName="NestingContext";function se(e){return"children"in e?se(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function Me(e,t){let n=it(e),r=l.useRef([]),a=be(),c=Le(),d=C((p,u=M.Hidden)=>{let h=r.current.findIndex(({el:m})=>m===p);h!==-1&&(G(u,{[M.Unmount](){r.current.splice(h,1)},[M.Hidden](){r.current[h].state="hidden"}}),c.microTask(()=>{var m;!se(r)&&a.current&&((m=n.current)==null||m.call(n))}))}),o=C(p=>{let u=r.current.find(({el:h})=>h===p);return u?u.state!=="visible"&&(u.state="visible"):r.current.push({el:p,state:"visible"}),()=>d(p,M.Unmount)}),v=l.useRef([]),i=l.useRef(Promise.resolve()),g=l.useRef({enter:[],leave:[]}),T=C((p,u,h)=>{v.current.splice(0),t&&(t.chains.current[u]=t.chains.current[u].filter(([m])=>m!==p)),t==null||t.chains.current[u].push([p,new Promise(m=>{v.current.push(m)})]),t==null||t.chains.current[u].push([p,new Promise(m=>{Promise.all(g.current[u].map(([F,$])=>$)).then(()=>m())})]),u==="enter"?i.current=i.current.then(()=>t==null?void 0:t.wait.current).then(()=>h(u)):h(u)}),w=C((p,u,h)=>{Promise.all(g.current[u].splice(0).map(([m,F])=>F)).then(()=>{var m;(m=v.current.shift())==null||m()}).then(()=>h(u))});return l.useMemo(()=>({children:r,register:o,unregister:d,onStart:T,onStop:w,wait:i,chains:g}),[o,d,r,T,w,g,i])}let Be=l.Fragment,je=he.RenderStrategy;function kt(e,t){var n,r;let{transition:a=!0,beforeEnter:c,afterEnter:d,beforeLeave:o,afterLeave:v,enter:i,enterFrom:g,enterTo:T,entered:w,leave:p,leaveFrom:u,leaveTo:h,...m}=e,[F,$]=l.useState(null),E=l.useRef(null),b=He(e),P=K(...b?[E,t,$]:t===null?[]:[t]),k=(n=m.unmount)==null||n?M.Unmount:M.Hidden,{show:S,appear:q,initial:Z}=Pt(),[y,A]=l.useState(S?"visible":"hidden"),V=Dt(),{register:R,unregister:N}=V;B(()=>R(E),[R,E]),B(()=>{if(k===M.Hidden&&E.current){if(S&&y!=="visible"){A("visible");return}return G(y,{hidden:()=>N(E),visible:()=>R(E)})}},[y,E,R,N,S,k]);let W=oe();B(()=>{if(b&&W&&y==="visible"&&E.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[E,y,W,b]);let de=Z&&!q,J=q&&S&&Z,U=l.useRef(!1),Y=Me(()=>{U.current||(A("hidden"),N(E))},V),_=C(pe=>{U.current=!0;let te=pe?"enter":"leave";Y.onStart(E,te,Q=>{Q==="enter"?c==null||c():Q==="leave"&&(o==null||o())})}),L=C(pe=>{let te=pe?"enter":"leave";U.current=!1,Y.onStop(E,te,Q=>{Q==="enter"?d==null||d():Q==="leave"&&(v==null||v())}),te==="leave"&&!se(Y)&&(A("hidden"),N(E))});l.useEffect(()=>{b&&a||(_(S),L(S))},[S,b,a]);let fe=!(!a||!b||!W||de),[,f]=ze(fe,F,S,{start:_,end:L}),ee=at({ref:P,className:((r=ot(m.className,J&&i,J&&g,f.enter&&i,f.enter&&f.closed&&g,f.enter&&!f.closed&&T,f.leave&&p,f.leave&&!f.closed&&u,f.leave&&f.closed&&h,!f.transition&&S&&w))==null?void 0:r.trim())||void 0,...Qe(f)}),z=0;y==="visible"&&(z|=D.Open),y==="hidden"&&(z|=D.Closed),S&&y==="hidden"&&(z|=D.Opening),!S&&y==="visible"&&(z|=D.Closing);let Ye=j();return s.createElement(ie.Provider,{value:Y},s.createElement(Xe,{value:z},Ye({ourProps:ee,theirProps:m,defaultTag:Be,features:je,visible:y==="visible",name:"Transition.Child"})))}function It(e,t){let{show:n,appear:r=!1,unmount:a=!0,...c}=e,d=l.useRef(null),o=He(e),v=K(...o?[d,t]:t===null?[]:[t]);oe();let i=le();if(n===void 0&&i!==null&&(n=(i&D.Open)===D.Open),n===void 0)throw new Error("A is used but it is missing a `show={true | false}` prop.");let[g,T]=l.useState(n?"visible":"hidden"),w=Me(()=>{n||T("hidden")}),[p,u]=l.useState(!0),h=l.useRef([n]);B(()=>{p!==!1&&h.current[h.current.length-1]!==n&&(h.current.push(n),u(!1))},[h,n]);let m=l.useMemo(()=>({show:n,appear:r,initial:p}),[n,r,p]);B(()=>{n?T("visible"):!se(w)&&d.current!==null&&T("hidden")},[n,w]);let F={unmount:a},$=C(()=>{var P;p&&u(!1),(P=e.beforeEnter)==null||P.call(e)}),E=C(()=>{var P;p&&u(!1),(P=e.beforeLeave)==null||P.call(e)}),b=j();return s.createElement(ie.Provider,{value:w},s.createElement(ue.Provider,{value:m},b({ourProps:{...F,as:l.Fragment,children:s.createElement(Ue,{ref:v,...F,...c,beforeEnter:$,beforeLeave:E})},theirProps:{},defaultTag:l.Fragment,features:je,visible:g==="visible",name:"Transition"})))}function xt(e,t){let n=l.useContext(ue)!==null,r=le()!==null;return s.createElement(s.Fragment,null,!n&&r?s.createElement(ge,{ref:t,...e}):s.createElement(Ue,{ref:t,...e}))}let ge=x(It),Ue=x(kt),we=x(xt),Lt=Object.assign(ge,{Child:we,Root:ge});var Ot=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Ot||{}),At=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(At||{});let Nt={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},Fe=l.createContext(null);Fe.displayName="DialogContext";function ce(e){let t=l.useContext(Fe);if(t===null){let n=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,ce),n}return t}function Ht(e,t){return G(t.type,Nt,e,t)}let ke=x(function(e,t){let n=l.useId(),{id:r=`headlessui-dialog-${n}`,open:a,onClose:c,initialFocus:d,role:o="dialog",autoFocus:v=!0,__demoMode:i=!1,unmount:g=!1,...T}=e,w=l.useRef(!1);o=function(){return o==="dialog"||o==="alertdialog"?o:(w.current||(w.current=!0,console.warn(`Invalid role [${o}] passed to . Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let p=le();a===void 0&&p!==null&&(a=(p&D.Open)===D.Open);let u=l.useRef(null),h=K(u,t),m=xe(u.current),F=a?0:1,[$,E]=l.useReducer(Ht,{titleId:null,descriptionId:null,panelRef:l.createRef()}),b=C(()=>c(!1)),P=C(f=>E({type:0,id:f})),k=oe()?F===0:!1,[S,q]=Ge(),Z={get current(){var f;return(f=$.panelRef.current)!=null?f:u.current}},y=dt(),{resolveContainers:A}=ft({mainTreeNode:y,portals:S,defaultContainers:[Z]}),V=p!==null?(p&D.Closing)===D.Closing:!1;st(i||V?!1:k,{allowed:C(()=>{var f,ee;return[(ee=(f=u.current)==null?void 0:f.closest("[data-headlessui-portal]"))!=null?ee:null]}),disallowed:C(()=>{var f;return[(f=y==null?void 0:y.closest("body > *:not(#headlessui-portal-root)"))!=null?f:null]})});let R=qe.get(null);B(()=>{if(k)return R.actions.push(r),()=>R.actions.pop(r)},[R,r,k]);let N=Ze(R,l.useCallback(f=>R.selectors.isTop(f,r),[R,r]));Je(N,A,f=>{f.preventDefault(),b()}),ht(N,m==null?void 0:m.defaultView,f=>{f.preventDefault(),f.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),b()}),_e(i||V?!1:k,m,A),et(k,u,b);let[W,de]=vt(),J=l.useMemo(()=>[{dialogState:F,close:b,setTitleId:P,unmount:g},$],[F,b,P,g,$]),U=ae({open:F===0}),Y={ref:h,id:r,role:o,tabIndex:-1,"aria-modal":i?void 0:F===0?!0:void 0,"aria-labelledby":$.titleId,"aria-describedby":W,unmount:g},_=!gt(),L=H.None;k&&!i&&(L|=H.RestoreFocus,L|=H.TabLock,v&&(L|=H.AutoFocus),_&&(L|=H.InitialFocus));let fe=j();return s.createElement(tt,null,s.createElement(Ce,{force:!0},s.createElement(nt,null,s.createElement(Fe.Provider,{value:J},s.createElement(rt,{target:u},s.createElement(Ce,{force:!1},s.createElement(de,{slot:U},s.createElement(q,null,s.createElement(Ft,{initialFocus:d,initialFocusFallback:u,containers:A,features:L},s.createElement(pt,{value:b},fe({ourProps:Y,theirProps:T,slot:U,defaultTag:Mt,features:Bt,visible:F===0,name:"Dialog"})))))))))))}),Mt="div",Bt=he.RenderStrategy|he.Static;function jt(e,t){let{transition:n=!1,open:r,...a}=e,c=le(),d=e.hasOwnProperty("open")||c!==null,o=e.hasOwnProperty("onClose");if(!d&&!o)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!d)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!o)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!c&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||n)&&!a.static?s.createElement(Se,null,s.createElement(Lt,{show:r,transition:n,unmount:a.unmount},s.createElement(ke,{ref:t,...a}))):s.createElement(Se,null,s.createElement(ke,{ref:t,open:r,...a}))}let Ut="div";function Yt(e,t){let n=l.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:a=!1,...c}=e,[{dialogState:d,unmount:o},v]=ce("Dialog.Panel"),i=K(t,v.panelRef),g=ae({open:d===0}),T=C(m=>{m.stopPropagation()}),w={ref:i,id:r,onClick:T},p=a?we:l.Fragment,u=a?{unmount:o}:{},h=j();return s.createElement(p,{...u},h({ourProps:w,theirProps:c,slot:g,defaultTag:Ut,name:"Dialog.Panel"}))}let Kt="div";function Vt(e,t){let{transition:n=!1,...r}=e,[{dialogState:a,unmount:c}]=ce("Dialog.Backdrop"),d=ae({open:a===0}),o={ref:t,"aria-hidden":!0},v=n?we:l.Fragment,i=n?{unmount:c}:{},g=j();return s.createElement(v,{...i},g({ourProps:o,theirProps:r,slot:d,defaultTag:Kt,name:"Dialog.Backdrop"}))}let Wt="h2";function zt(e,t){let n=l.useId(),{id:r=`headlessui-dialog-title-${n}`,...a}=e,[{dialogState:c,setTitleId:d}]=ce("Dialog.Title"),o=K(t);l.useEffect(()=>(d(r),()=>d(null)),[r,d]);let v=ae({open:c===0}),i={ref:o,id:r};return j()({ourProps:i,theirProps:a,slot:v,defaultTag:Wt,name:"Dialog.Title"})}let Qt=x(jt),Xt=x(Yt),sn=x(Vt),Gt=x(zt),cn=Object.assign(Qt,{Panel:Xt,Title:Gt,Description:mt});export{Lt as K,sn as L,we as O,Gt as Q,cn as h,Xt as z};