import{o as l,m as H,E as q,u as T,c as se,l as L,F as ie,j as ve,k as pe,H as K,t as A,f as W,b as R,p as ce,N as J,i as B,P as C,e as O,g as V}from"./C8gQjcR0.js";import{a as w,E as U,A as M,d as N,c as F,p as X,f as j,aj as Z,H as _,i as Y,s as fe}from"./DdtSDqGZ.js";import{V as de,p as be,E as Pe,n as ee,d as x}from"./Dbjxx0Ts.js";function Q(a,f){if(a)return a;let p=f??"button";if(typeof p=="string"&&p.toLowerCase()==="button")return"button"}function me(a,f){let p=w(Q(a.value.type,a.value.as));return U(()=>{p.value=Q(a.value.type,a.value.as)}),M(()=>{var $;p.value||l(f)&&l(f)instanceof HTMLButtonElement&&!(($=l(f))!=null&&$.hasAttribute("type"))&&(p.value="button")}),p}var ge=(a=>(a[a.Open=0]="Open",a[a.Closed=1]="Closed",a))(ge||{});let te=Symbol("PopoverContext");function z(a){let f=Y(te,null);if(f===null){let p=new Error(`<${a} /> is missing a parent <${Se.name} /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(p,z),p}return f}let le=Symbol("PopoverGroupContext");function oe(){return Y(le,null)}let ne=Symbol("PopoverPanelContext");function ye(){return Y(ne,null)}let Se=N({name:"Popover",props:{as:{type:[Object,String],default:"div"}},setup(a,{slots:f,attrs:p,expose:$}){var t;let e=w(null);$({el:e,$el:e});let m=w(1),d=w(null),I=w(null),S=w(null),b=w(null),g=F(()=>H(e)),y=F(()=>{var o,u;if(!l(d)||!l(b))return!1;for(let G of document.querySelectorAll("body > *"))if(Number(G==null?void 0:G.contains(l(d)))^Number(G==null?void 0:G.contains(l(b))))return!0;let s=q(),E=s.indexOf(l(d)),D=(E+s.length-1)%s.length,ae=(E+1)%s.length,ue=s[D],re=s[ae];return!((o=l(b))!=null&&o.contains(ue))&&!((u=l(b))!=null&&u.contains(re))}),v={popoverState:m,buttonId:w(null),panelId:w(null),panel:b,button:d,isPortalled:y,beforePanelSentinel:I,afterPanelSentinel:S,togglePopover(){m.value=T(m.value,{0:1,1:0})},closePopover(){m.value!==1&&(m.value=1)},close(o){v.closePopover();let u=o?o instanceof HTMLElement?o:o.value instanceof HTMLElement?l(o):l(v.button):l(v.button);u==null||u.focus()}};X(te,v),se(F(()=>T(m.value,{0:L.Open,1:L.Closed})));let k={buttonId:v.buttonId,panelId:v.panelId,close(){v.closePopover()}},h=oe(),i=h==null?void 0:h.registerPopover,[P,r]=de(),n=be({portals:P,defaultContainers:[d,b]});function c(){var o,u,s,E;return(E=h==null?void 0:h.isFocusWithinPopoverGroup())!=null?E:((o=g.value)==null?void 0:o.activeElement)&&(((u=l(d))==null?void 0:u.contains(g.value.activeElement))||((s=l(b))==null?void 0:s.contains(g.value.activeElement)))}return M(()=>i==null?void 0:i(k)),Pe((t=g.value)==null?void 0:t.defaultView,"focus",o=>{var u,s;o.target!==window&&o.target instanceof HTMLElement&&m.value===0&&(c()||d&&b&&(n.contains(o.target)||(u=l(v.beforePanelSentinel))!=null&&u.contains(o.target)||(s=l(v.afterPanelSentinel))!=null&&s.contains(o.target)||v.closePopover()))},!0),ie(n.resolveContainers,(o,u)=>{var s;v.closePopover(),ve(u,pe.Loose)||(o.preventDefault(),(s=l(d))==null||s.focus())},F(()=>m.value===0)),()=>{let o={open:m.value===0,close:v.close};return j(r,{},()=>K({theirProps:{...a,...p},ourProps:{ref:e},slot:o,slots:f,attrs:p,name:"Popover"}))}}}),$e=N({name:"PopoverButton",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-popover-button-${A()}`}},inheritAttrs:!1,setup(a,{attrs:f,slots:p,expose:$}){let t=z("PopoverButton"),e=F(()=>H(t.button));$({el:t.button,$el:t.button}),U(()=>{t.buttonId.value=a.id}),Z(()=>{t.buttonId.value=null});let m=oe(),d=m==null?void 0:m.closeOthers,I=ye(),S=F(()=>I===null?!1:I.value===t.panelId.value),b=w(null),g=`headlessui-focus-sentinel-${A()}`;S.value||M(()=>{t.button.value=b.value});let y=me(F(()=>({as:a.as,type:f.type})),b);function v(n){var c,o,u,s,E;if(S.value){if(t.popoverState.value===1)return;switch(n.key){case B.Space:case B.Enter:n.preventDefault(),(o=(c=n.target).click)==null||o.call(c),t.closePopover(),(u=l(t.button))==null||u.focus();break}}else switch(n.key){case B.Space:case B.Enter:n.preventDefault(),n.stopPropagation(),t.popoverState.value===1&&(d==null||d(t.buttonId.value)),t.togglePopover();break;case B.Escape:if(t.popoverState.value!==0)return d==null?void 0:d(t.buttonId.value);if(!l(t.button)||(s=e.value)!=null&&s.activeElement&&!((E=l(t.button))!=null&&E.contains(e.value.activeElement)))return;n.preventDefault(),n.stopPropagation(),t.closePopover();break}}function k(n){S.value||n.key===B.Space&&n.preventDefault()}function h(n){var c,o;a.disabled||(S.value?(t.closePopover(),(c=l(t.button))==null||c.focus()):(n.preventDefault(),n.stopPropagation(),t.popoverState.value===1&&(d==null||d(t.buttonId.value)),t.togglePopover(),(o=l(t.button))==null||o.focus()))}function i(n){n.preventDefault(),n.stopPropagation()}let P=ee();function r(){let n=l(t.panel);if(!n)return;function c(){T(P.value,{[x.Forwards]:()=>C(n,O.First),[x.Backwards]:()=>C(n,O.Last)})===V.Error&&C(q().filter(o=>o.dataset.headlessuiFocusGuard!=="true"),T(P.value,{[x.Forwards]:O.Next,[x.Backwards]:O.Previous}),{relativeTo:l(t.button)})}c()}return()=>{let n=t.popoverState.value===0,c={open:n},{id:o,...u}=a,s=S.value?{ref:b,type:y.value,onKeydown:v,onClick:h}:{ref:b,id:o,type:y.value,"aria-expanded":a.disabled?void 0:t.popoverState.value===0,"aria-controls":l(t.panel)?t.panelId.value:void 0,disabled:a.disabled?!0:void 0,onKeydown:v,onKeyup:k,onClick:h,onMousedown:i};return j(_,[K({ourProps:s,theirProps:{...f,...u},slot:c,attrs:f,slots:p,name:"PopoverButton"}),n&&!S.value&&t.isPortalled.value&&j(W,{id:g,features:R.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:r})])}}}),Fe=N({name:"PopoverPanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},focus:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-popover-panel-${A()}`}},inheritAttrs:!1,setup(a,{attrs:f,slots:p,expose:$}){let{focus:t}=a,e=z("PopoverPanel"),m=F(()=>H(e.panel)),d=`headlessui-focus-sentinel-before-${A()}`,I=`headlessui-focus-sentinel-after-${A()}`;$({el:e.panel,$el:e.panel}),U(()=>{e.panelId.value=a.id}),Z(()=>{e.panelId.value=null}),X(ne,e.panelId),M(()=>{var i,P;if(!t||e.popoverState.value!==0||!e.panel)return;let r=(i=m.value)==null?void 0:i.activeElement;(P=l(e.panel))!=null&&P.contains(r)||C(l(e.panel),O.First)});let S=ce(),b=F(()=>S!==null?(S.value&L.Open)===L.Open:e.popoverState.value===0);function g(i){var P,r;switch(i.key){case B.Escape:if(e.popoverState.value!==0||!l(e.panel)||m.value&&!((P=l(e.panel))!=null&&P.contains(m.value.activeElement)))return;i.preventDefault(),i.stopPropagation(),e.closePopover(),(r=l(e.button))==null||r.focus();break}}function y(i){var P,r,n,c,o;let u=i.relatedTarget;u&&l(e.panel)&&((P=l(e.panel))!=null&&P.contains(u)||(e.closePopover(),((n=(r=l(e.beforePanelSentinel))==null?void 0:r.contains)!=null&&n.call(r,u)||(o=(c=l(e.afterPanelSentinel))==null?void 0:c.contains)!=null&&o.call(c,u))&&u.focus({preventScroll:!0})))}let v=ee();function k(){let i=l(e.panel);if(!i)return;function P(){T(v.value,{[x.Forwards]:()=>{var r;C(i,O.First)===V.Error&&((r=l(e.afterPanelSentinel))==null||r.focus())},[x.Backwards]:()=>{var r;(r=l(e.button))==null||r.focus({preventScroll:!0})}})}P()}function h(){let i=l(e.panel);if(!i)return;function P(){T(v.value,{[x.Forwards]:()=>{let r=l(e.button),n=l(e.panel);if(!r)return;let c=q(),o=c.indexOf(r),u=c.slice(0,o+1),s=[...c.slice(o+1),...u];for(let E of s.slice())if(E.dataset.headlessuiFocusGuard==="true"||n!=null&&n.contains(E)){let D=s.indexOf(E);D!==-1&&s.splice(D,1)}C(s,O.First,{sorted:!1})},[x.Backwards]:()=>{var r;C(i,O.Previous)===V.Error&&((r=l(e.button))==null||r.focus())}})}P()}return()=>{let i={open:e.popoverState.value===0,close:e.close},{id:P,focus:r,...n}=a,c={ref:e.panel,id:P,onKeydown:g,onFocusout:t&&e.popoverState.value===0?y:void 0,tabIndex:-1};return K({ourProps:c,theirProps:{...f,...n},attrs:f,slot:i,slots:{...p,default:(...o)=>{var u;return[j(_,[b.value&&e.isPortalled.value&&j(W,{id:d,ref:e.beforePanelSentinel,features:R.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:k}),(u=p.default)==null?void 0:u.call(p,...o),b.value&&e.isPortalled.value&&j(W,{id:I,ref:e.afterPanelSentinel,features:R.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:h})])]}},features:J.RenderStrategy|J.Static,visible:b.value,name:"PopoverPanel"})}}}),Ie=N({name:"PopoverGroup",props:{as:{type:[Object,String],default:"div"}},setup(a,{attrs:f,slots:p,expose:$}){let t=w(null),e=fe([]),m=F(()=>H(t));$({el:t,$el:t});function d(g){let y=e.value.indexOf(g);y!==-1&&e.value.splice(y,1)}function I(g){return e.value.push(g),()=>{d(g)}}function S(){var g;let y=m.value;if(!y)return!1;let v=y.activeElement;return(g=l(t))!=null&&g.contains(v)?!0:e.value.some(k=>{var h,i;return((h=y.getElementById(k.buttonId.value))==null?void 0:h.contains(v))||((i=y.getElementById(k.panelId.value))==null?void 0:i.contains(v))})}function b(g){for(let y of e.value)y.buttonId.value!==g&&y.close()}return X(le,{registerPopover:I,unregisterPopover:d,isFocusWithinPopoverGroup:S,closeOthers:b}),()=>K({ourProps:{ref:t},theirProps:a,slot:{},attrs:f,slots:p,name:"PopoverGroup"})}});export{Ie as A,Fe as W,Se as g,$e as j};