@inertiaui/modal-react 0.19.0 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(C,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core","react-dom"],i):(C=typeof globalThis<"u"?globalThis:C||self,i(C.InertiaUIModal={},C.React,C.jsxRuntime,C.Axios,C.react,C.core,C.ReactDOM))})(this,function(C,i,$,ye,ne,en,tn){"use strict";var il=Object.defineProperty;var ol=(C,i,$)=>i in C?il(C,i,{enumerable:!0,configurable:!0,writable:!0,value:$}):C[i]=$;var B=(C,i,$)=>ol(C,typeof i!="symbol"?i+"":i,$);function nn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const se=nn(i),ue={type:"modal",navigate:!1,modal:{closeButton:!0,closeExplicitly:!1,maxWidth:"2xl",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white rounded",position:"center"},slideover:{closeButton:!0,closeExplicitly:!1,maxWidth:"md",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white min-h-screen",position:"right"}};class rn{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(ue))}put(t,n){if(typeof t=="object"){this.config={type:t.type??ue.type,navigate:t.navigate??ue.navigate,modal:{...ue.modal,...t.modal??{}},slideover:{...ue.slideover,...t.slideover??{}}};return}const r=t.split(".");let l=this.config;for(let s=0;s<r.length-1;s++)l=l[r[s]]=l[r[s]]||{};l[r[r.length-1]]=n}get(t){if(typeof t>"u")return this.config;const n=t.split(".");let r=this.config;for(const l of n){if(r[l]===void 0)return null;r=r[l]}return r}}const be=new rn,ln=()=>be.reset(),on=(e,t)=>be.put(e,t),$e=e=>be.get(e),re=(e,t)=>be.get(e?`slideover.${t}`:`modal.${t}`);function qe(e="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}${crypto.randomUUID()}`:`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function sn(e,t){return Array.isArray(e)?e.filter(n=>!t.includes(n)):Object.keys(e).reduce((n,r)=>(t.includes(r)||(n[r]=e[r]),n),{})}function dt(e,t){return Array.isArray(e)?e.filter(n=>t.includes(n)):t.reduce((n,r)=>(r in e&&(n[r]=e[r]),n),{})}function un(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,n)=>(n in e&&e[n]!==null&&(t[n]=e[n]),t),{})}function an(e,t=3,n=10){return new Promise((r,l)=>{const s=e();if(s){r(s);return}let u=t*1e3/n;const a=setInterval(()=>{const o=e();o&&(clearInterval(a),r(o)),--u<=0&&(clearInterval(a),l(new Error("Condition not met in time")))},n)})}function ae(e){return e?(e=e.replace(/_/g,"-"),e=e.replace(/-+/g,"-"),/[A-Z]/.test(e)?(e=e.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(t,n)=>n.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const Me=i.createContext(null);Me.displayName="ModalStackContext";let ct=null,ft=null,de=null,Xe=null,Ve=[],le={};const mt=({children:e})=>{const[t,n]=i.useState([]),[r,l]=i.useState({}),s=g=>{n(d=>{const p=g([...d]),h=w=>{var y;return p.length<2?!0:((y=p.map(v=>({id:v.id,shouldRender:v.shouldRender})).reverse().find(v=>v.shouldRender))==null?void 0:y.id)===w};return p.forEach((w,y)=>{p[y].onTopOfStack=h(w.id),p[y].getParentModal=()=>y<1?null:p.slice(0,y).reverse().find(v=>v.isOpen),p[y].getChildModal=()=>y===p.length-1?null:p.slice(y+1).find(v=>v.isOpen)}),p})};i.useEffect(()=>{Ve=t},[t]);class u{constructor(d,p,h,w,y){B(this,"show",()=>{s(d=>d.map(p=>(p.id===this.id&&!p.isOpen&&(p.isOpen=!0,p.shouldRender=!0),p)))});B(this,"setOpen",d=>{d?this.show():this.close()});B(this,"close",()=>{s(d=>d.map(p=>{var h;return p.id===this.id&&p.isOpen&&(Object.keys(p.listeners).forEach(w=>{p.off(w)}),p.isOpen=!1,(h=p.onCloseCallback)==null||h.call(p)),p}))});B(this,"afterLeave",()=>{this.isOpen||s(d=>{const p=d.map(h=>{var w;return h.id===this.id&&!h.isOpen&&(h.shouldRender=!1,(w=h.afterLeaveCallback)==null||w.call(h),h.afterLeaveCallback=null),h});return this.index===0?[]:p})});B(this,"on",(d,p)=>{d=ae(d),this.listeners[d]=this.listeners[d]??[],this.listeners[d].push(p)});B(this,"off",(d,p)=>{var h;d=ae(d),p?this.listeners[d]=((h=this.listeners[d])==null?void 0:h.filter(w=>w!==p))??[]:delete this.listeners[d]});B(this,"emit",(d,...p)=>{var h;(h=this.listeners[ae(d)])==null||h.forEach(w=>w(...p))});B(this,"registerEventListenersFromProps",d=>{const p=[];return Object.keys(d).filter(h=>h.startsWith("on")).forEach(h=>{const w=ae(h).replace(/^on-/,"");this.on(w,d[h]),p.push(()=>this.off(w,d[h]))}),()=>p.forEach(h=>h())});B(this,"reload",(d={})=>{var h;let p=Object.keys(this.response.props);d.only&&(p=dt(p,d.only)),d.except&&(p=sn(p,d.except)),(h=this.response)!=null&&h.url&&ye.get(this.response.url,{headers:{Accept:"text/html, application/xhtml+xml","X-Inertia":!0,"X-Inertia-Partial-Component":this.response.component,"X-Inertia-Version":this.response.version,"X-Inertia-Partial-Data":p.join(","),"X-InertiaUI-Modal":qe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":de}}).then(w=>{this.updateProps(w.data.props)})});B(this,"updateProps",d=>{Object.assign(this.props,d),s(p=>p)});if(this.id=p.id??qe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=d,this.props=p.props,this.response=p,this.config=h??{},this.onCloseCallback=w,this.afterLeaveCallback=y,le[this.id]){this.config={...this.config,...le[this.id].config??{}};const v=le[this.id].onClose,M=le[this.id].onAfterLeave;v&&(this.onCloseCallback=w?()=>{w(),v()}:v),M&&(this.afterLeaveCallback=y?()=>{y(),M()}:M),delete le[this.id]}this.index=-1,this.getParentModal=()=>null,this.getChildModal=()=>null,this.onTopOfStack=!0}static generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`inertiaui_modal_${crypto.randomUUID()}`:`inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}}const a=(g,d={},p=null,h=null)=>ft(g.component).then(w=>o(w,g,d,p,h)),o=(g,d,p,h,w)=>{const y=new u(g,d,p,h,w);return y.index=t.length,s(v=>[...v,y]),y.show(),y};function c(g,d,p,h){if(!r[g])throw new Error(`The local modal "${g}" has not been registered.`);const w=o(null,{},d,p,h);return w.name=g,r[g].callback(w),w}const m=(g,d={})=>x(g,d.method??"get",d.data??{},d.headers??{},d.config??{},d.onClose,d.onAfterLeave,d.queryStringArrayFormat??"brackets",d.navigate??$e("navigate")).then(p=>{const h=d.listeners??{};return Object.keys(h).forEach(w=>{const y=ae(w);p.on(y,h[w])}),p}),x=(g,d,p={},h={},w={},y=null,v=null,M="brackets",T=!1)=>{const I=qe();return new Promise((H,F)=>{if(g.startsWith("#")){H(c(g.substring(1),w,y,v));return}const[A,U]=en.mergeDataIntoQueryString(d,g||"",p,M);let W=T&&t.length===0;if(t.length===0&&(de=typeof window<"u"?window.location.href:""),h={...h,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":ct,"X-InertiaUI-Modal":I,"X-InertiaUI-Modal-Use-Router":W?1:0,"X-InertiaUI-Modal-Base-Url":de},W)return Xe=null,le[I]={config:w,onClose:y,onAfterLeave:v},ne.router.visit(A,{method:d,data:U,headers:h,preserveScroll:!0,preserveState:!0,onError:F,onFinish:()=>{an(()=>Xe).then(H)}});ye({url:A,method:d,data:U,headers:h}).then(S=>H(a(S.data,w,y,v))).catch(S=>{F(S)})})},f={stack:t,localModals:r,push:o,pushFromResponseData:a,closeAll:()=>{Ve.reverse().forEach(g=>g.close())},reset:()=>s(()=>[]),visit:x,visitModal:m,registerLocalModal:(g,d)=>{l(p=>({...p,[g]:{name:g,callback:d}}))},removeLocalModal:g=>{l(d=>{const p={...d};return delete p[g],p})}};return $.jsx(Me.Provider,{value:f,children:e})},ce=()=>{const e=i.useContext(Me);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},pt=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],ht=e=>{e.initialPage&&(ct=e.initialPage.version),e.resolveComponent&&(ft=e.resolveComponent)},dn=(e,t)=>{ht(t);const n=({Component:r,props:l,key:s})=>{const u=()=>{const a=i.createElement(r,{key:s,...l});return typeof r.layout=="function"?r.layout(a):Array.isArray(r.layout)?r.layout.concat(a).reverse().reduce((c,m)=>i.createElement(m,l,c)):a};return $.jsxs($.Fragment,{children:[u(),$.jsx(vt,{})]})};return $.jsx(mt,{children:$.jsx(e,{...t,children:n})})},vt=({children:e})=>{var a;const t=i.useContext(Me);let n=!1,r=!1;i.useEffect(()=>ne.router.on("start",()=>n=!0),[]),i.useEffect(()=>ne.router.on("finish",()=>n=!1),[]),i.useEffect(()=>ne.router.on("navigate",function(o){const c=o.detail.page.props._inertiaui_modal;if(!c){r&&t.closeAll();return}r=c,de=c.baseUrl,t.pushFromResponseData(c,{},()=>{if(!c.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==c.baseUrl&&ne.router.visit(c.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(m=>{Xe=m})}),[]);const l=o=>(Ve.length&&(o.headers["X-InertiaUI-Modal-Base-Url"]=de),o);i.useEffect(()=>(ye.interceptors.request.use(l),()=>ye.interceptors.request.eject(l)),[]);const s=ne.usePage(),u=i.useRef();return i.useEffect(()=>{var m,x;const o=(m=s.props)==null?void 0:m._inertiaui_modal,c=u.current;u.current=o,o&&c&&o.component===c.component&&o.url===c.url&&((x=t.stack[0])==null||x.updateProps(o.props??{}))},[(a=s.props)==null?void 0:a._inertiaui_modal]),$.jsxs($.Fragment,{children:[e,t.stack.length>0&&$.jsx(gt,{index:0})]})},Ye=i.createContext(null);Ye.displayName="ModalIndexContext";const ze=()=>{const e=i.useContext(Ye);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},gt=({index:e})=>{const{stack:t}=ce(),n=i.useMemo(()=>t[e],[t,e]);return(n==null?void 0:n.component)&&$.jsx(Ye.Provider,{value:e,children:$.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},Ge=i.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:s=null,...u},a)=>{const o=ze(),{stack:c,registerLocalModal:m,removeLocalModal:x}=ce(),[b,E]=i.useState(null),f=i.useMemo(()=>e?b:c[o],[e,b,o,c]),g=i.useMemo(()=>{var v;return(v=c.find(M=>M.shouldRender&&M.index>(f==null?void 0:f.index)))==null?void 0:v.index},[o,c]),d=i.useMemo(()=>(f==null?void 0:f.config.slideover)??u.slideover??$e("type")==="slideover",[u.slideover]),p=i.useMemo(()=>({slideover:d,closeButton:u.closeButton??re(d,"closeButton"),closeExplicitly:u.closeExplicitly??re(d,"closeExplicitly"),maxWidth:u.maxWidth??re(d,"maxWidth"),paddingClasses:u.paddingClasses??re(d,"paddingClasses"),panelClasses:u.panelClasses??re(d,"panelClasses"),position:u.position??re(d,"position"),...f==null?void 0:f.config}),[u,f==null?void 0:f.config]);i.useEffect(()=>{if(e){let v=null;return m(e,M=>{v=M.registerEventListenersFromProps(u),E(M)}),()=>{v==null||v(),v=null,x(e)}}return f.registerEventListenersFromProps(u)},[e]);const h=i.useRef(f);i.useEffect(()=>{h.current=f},[f]),i.useEffect(()=>{f!==null&&(f.isOpen?s==null||s():l==null||l())},[f==null?void 0:f.isOpen]);const[w,y]=i.useState(!1);return i.useEffect(()=>{w&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),y(!0)},[f==null?void 0:f.onTopOfStack]),i.useImperativeHandle(a,()=>({afterLeave:()=>{var v;return(v=h.current)==null?void 0:v.afterLeave()},close:()=>{var v;return(v=h.current)==null?void 0:v.close()},emit:(...v)=>{var M;return(M=h.current)==null?void 0:M.emit(...v)},getChildModal:()=>{var v;return(v=h.current)==null?void 0:v.getChildModal()},getParentModal:()=>{var v;return(v=h.current)==null?void 0:v.getParentModal()},reload:(...v)=>{var M;return(M=h.current)==null?void 0:M.reload(...v)},setOpen:()=>{var v;return(v=h.current)==null?void 0:v.setOpen()},get id(){var v;return(v=h.current)==null?void 0:v.id},get index(){var v;return(v=h.current)==null?void 0:v.index},get isOpen(){var v;return(v=h.current)==null?void 0:v.isOpen},get config(){var v;return(v=h.current)==null?void 0:v.config},get modalContext(){return h.current},get onTopOfStack(){var v;return(v=h.current)==null?void 0:v.onTopOfStack},get shouldRender(){var v;return(v=h.current)==null?void 0:v.shouldRender}}),[f]),(f==null?void 0:f.shouldRender)&&$.jsxs($.Fragment,{children:[typeof t=="function"?t({afterLeave:f.afterLeave,close:f.close,config:p,emit:f.emit,getChildModal:f.getChildModal,getParentModal:f.getParentModal,id:f.id,index:f.index,isOpen:f.isOpen,modalContext:f,onTopOfStack:f.onTopOfStack,reload:f.reload,setOpen:f.setOpen,shouldRender:f.shouldRender}):t,g&&$.jsx(gt,{index:g})]})});Ge.displayName="HeadlessModal";function wt(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(n=wt(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ce(){for(var e,t,n=0,r="",l=arguments.length;n<l;n++)(e=arguments[n])&&(t=wt(e))&&(r&&(r+=" "),r+=t);return r}var cn=Object.defineProperty,fn=(e,t,n)=>t in e?cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ke=(e,t,n)=>(fn(e,typeof t!="symbol"?t+"":t,n),n);let mn=class{constructor(){Ke(this,"current",this.detect()),Ke(this,"handoffState","pending"),Ke(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},J=new mn;function Se(e){return J.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function Oe(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function z(){let e=[],t={addEventListener(n,r,l,s){return n.addEventListener(r,l,s),t.add(()=>n.removeEventListener(r,l,s))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return Oe(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,l){let s=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:l}),this.add(()=>{Object.assign(n.style,{[r]:s})})},group(n){let r=z();return n(r),this.add(()=>r.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let l of e.splice(r,1))l()}},dispose(){for(let n of e.splice(0))n()}};return t}function Ze(){let[e]=i.useState(z);return i.useEffect(()=>()=>e.dispose(),[e]),e}let k=(e,t)=>{J.isServer?i.useEffect(e,t):i.useLayoutEffect(e,t)};function Q(e){let t=i.useRef(e);return k(()=>{t.current=e},[e]),t}let O=function(e){let t=Q(e);return i.useCallback((...n)=>t.current(...n),[t])},pn=i.createContext(void 0);function hn(){return i.useContext(pn)}function Je(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function G(e,t,...n){if(e in t){let l=t[e];return typeof l=="function"?l(...n):l}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(l=>`"${l}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,G),r}var Te=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Te||{}),K=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(K||{});function D(){let e=gn();return i.useCallback(t=>vn({mergeRefs:e,...t}),[e])}function vn({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:l,visible:s=!0,name:u,mergeRefs:a}){a=a??wn;let o=Et(t,e);if(s)return Pe(o,n,r,u,a);let c=l??0;if(c&2){let{static:m=!1,...x}=o;if(m)return Pe(x,n,r,u,a)}if(c&1){let{unmount:m=!0,...x}=o;return G(m?0:1,{0(){return null},1(){return Pe({...x,hidden:!0,style:{display:"none"}},n,r,u,a)}})}return Pe(o,n,r,u,a)}function Pe(e,t={},n,r,l){let{as:s=n,children:u,refName:a="ref",...o}=Qe(e,["unmount","static"]),c=e.ref!==void 0?{[a]:e.ref}:{},m=typeof u=="function"?u(t):u;"className"in o&&o.className&&typeof o.className=="function"&&(o.className=o.className(t)),o["aria-labelledby"]&&o["aria-labelledby"]===o.id&&(o["aria-labelledby"]=void 0);let x={};if(t){let b=!1,E=[];for(let[f,g]of Object.entries(t))typeof g=="boolean"&&(b=!0),g===!0&&E.push(f.replace(/([A-Z])/g,d=>`-${d.toLowerCase()}`));if(b){x["data-headlessui-state"]=E.join(" ");for(let f of E)x[`data-${f}`]=""}}if(s===i.Fragment&&(Object.keys(R(o)).length>0||Object.keys(R(x)).length>0))if(!i.isValidElement(m)||Array.isArray(m)&&m.length>1){if(Object.keys(R(o)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(R(o)).concat(Object.keys(R(x))).map(b=>` - ${b}`).join(`
1
+ (function(C,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react/jsx-runtime"),require("axios"),require("@inertiajs/react"),require("@inertiajs/core"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","axios","@inertiajs/react","@inertiajs/core","react-dom"],i):(C=typeof globalThis<"u"?globalThis:C||self,i(C.InertiaUIModal={},C.React,C.jsxRuntime,C.Axios,C.react,C.core,C.ReactDOM))})(this,function(C,i,$,Ee,z,tn,nn){"use strict";var ol=Object.defineProperty;var sl=(C,i,$)=>i in C?ol(C,i,{enumerable:!0,configurable:!0,writable:!0,value:$}):C[i]=$;var B=(C,i,$)=>sl(C,typeof i!="symbol"?i+"":i,$);function rn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const se=rn(i),ue={type:"modal",navigate:!1,modal:{closeButton:!0,closeExplicitly:!1,maxWidth:"2xl",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white rounded",position:"center"},slideover:{closeButton:!0,closeExplicitly:!1,maxWidth:"md",paddingClasses:"p-4 sm:p-6",panelClasses:"bg-white min-h-screen",position:"right"}};class ln{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(ue))}put(t,n){if(typeof t=="object"){this.config={type:t.type??ue.type,navigate:t.navigate??ue.navigate,modal:{...ue.modal,...t.modal??{}},slideover:{...ue.slideover,...t.slideover??{}}};return}const r=t.split(".");let l=this.config;for(let s=0;s<r.length-1;s++)l=l[r[s]]=l[r[s]]||{};l[r[r.length-1]]=n}get(t){if(typeof t>"u")return this.config;const n=t.split(".");let r=this.config;for(const l of n){if(r[l]===void 0)return null;r=r[l]}return r}}const be=new ln,on=()=>be.reset(),sn=(e,t)=>be.put(e,t),$e=e=>be.get(e),re=(e,t)=>be.get(e?`slideover.${t}`:`modal.${t}`);function dt(e,t){return e=typeof e=="string"?new URL(e,window.location.origin):e,t=typeof t=="string"?new URL(t,window.location.origin):t,`${e.origin}${e.pathname}`==`${t.origin}${t.pathname}`}function Xe(e="inertiaui_modal_"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}${crypto.randomUUID()}`:`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}function un(e,t){return Array.isArray(e)?e.filter(n=>!t.includes(n)):Object.keys(e).reduce((n,r)=>(t.includes(r)||(n[r]=e[r]),n),{})}function ct(e,t){return Array.isArray(e)?e.filter(n=>t.includes(n)):t.reduce((n,r)=>(r in e&&(n[r]=e[r]),n),{})}function an(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,n)=>(n in e&&e[n]!==null&&(t[n]=e[n]),t),{})}function dn(e,t=3,n=10){return new Promise((r,l)=>{const s=e();if(s){r(s);return}let u=t*1e3/n;const a=setInterval(()=>{const o=e();o&&(clearInterval(a),r(o)),--u<=0&&(clearInterval(a),l(new Error("Condition not met in time")))},n)})}function ae(e){return e?(e=e.replace(/_/g,"-"),e=e.replace(/-+/g,"-"),/[A-Z]/.test(e)?(e=e.replace(/\s+/g,"").replace(/_/g,"").replace(/(?:^|\s|-)+([A-Za-z])/g,(t,n)=>n.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const Me=i.createContext(null);Me.displayName="ModalStackContext";let ft=null,mt=null,de=null,Ve=null,Ce=[],le={};const pt=({children:e})=>{const[t,n]=i.useState([]),[r,l]=i.useState({}),s=g=>{n(d=>{const p=g([...d]),h=w=>{var E;return p.length<2?!0:((E=p.map(v=>({id:v.id,shouldRender:v.shouldRender})).reverse().find(v=>v.shouldRender))==null?void 0:E.id)===w};return p.forEach((w,E)=>{p[E].onTopOfStack=h(w.id),p[E].getParentModal=()=>E<1?null:p.slice(0,E).reverse().find(v=>v.isOpen),p[E].getChildModal=()=>E===p.length-1?null:p.slice(E+1).find(v=>v.isOpen)}),p})};i.useEffect(()=>{Ce=t},[t]);class u{constructor(d,p,h,w,E){B(this,"show",()=>{s(d=>d.map(p=>(p.id===this.id&&!p.isOpen&&(p.isOpen=!0,p.shouldRender=!0),p)))});B(this,"setOpen",d=>{d?this.show():this.close()});B(this,"close",()=>{s(d=>d.map(p=>{var h;return p.id===this.id&&p.isOpen&&(Object.keys(p.listeners).forEach(w=>{p.off(w)}),p.isOpen=!1,(h=p.onCloseCallback)==null||h.call(p)),p}))});B(this,"afterLeave",()=>{this.isOpen||s(d=>{const p=d.map(h=>{var w;return h.id===this.id&&!h.isOpen&&(h.shouldRender=!1,(w=h.afterLeaveCallback)==null||w.call(h),h.afterLeaveCallback=null),h});return this.index===0?[]:p})});B(this,"on",(d,p)=>{d=ae(d),this.listeners[d]=this.listeners[d]??[],this.listeners[d].push(p)});B(this,"off",(d,p)=>{var h;d=ae(d),p?this.listeners[d]=((h=this.listeners[d])==null?void 0:h.filter(w=>w!==p))??[]:delete this.listeners[d]});B(this,"emit",(d,...p)=>{var h;(h=this.listeners[ae(d)])==null||h.forEach(w=>w(...p))});B(this,"registerEventListenersFromProps",d=>{const p=[];return Object.keys(d).filter(h=>h.startsWith("on")).forEach(h=>{const w=ae(h).replace(/^on-/,"");this.on(w,d[h]),p.push(()=>this.off(w,d[h]))}),()=>p.forEach(h=>h())});B(this,"reload",(d={})=>{var h;let p=Object.keys(this.response.props);d.only&&(p=ct(p,d.only)),d.except&&(p=un(p,d.except)),(h=this.response)!=null&&h.url&&Ee.get(this.response.url,{headers:{Accept:"text/html, application/xhtml+xml","X-Inertia":!0,"X-Inertia-Partial-Component":this.response.component,"X-Inertia-Version":this.response.version,"X-Inertia-Partial-Data":p.join(","),"X-InertiaUI-Modal":Xe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":de}}).then(w=>{this.updateProps(w.data.props)})});B(this,"updateProps",d=>{Object.assign(this.props,d),s(p=>p)});if(this.id=p.id??Xe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=d,this.props=p.props,this.response=p,this.config=h??{},this.onCloseCallback=w,this.afterLeaveCallback=E,le[this.id]){this.config={...this.config,...le[this.id].config??{}};const v=le[this.id].onClose,M=le[this.id].onAfterLeave;v&&(this.onCloseCallback=w?()=>{w(),v()}:v),M&&(this.afterLeaveCallback=E?()=>{E(),M()}:M),delete le[this.id]}this.index=-1,this.getParentModal=()=>null,this.getChildModal=()=>null,this.onTopOfStack=!0}static generateId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`inertiaui_modal_${crypto.randomUUID()}`:`inertiaui_modal_${Date.now().toString(36)}_${Math.random().toString(36).substr(2,9)}`}}const a=(g,d={},p=null,h=null)=>mt(g.component).then(w=>o(w,g,d,p,h)),o=(g,d,p,h,w)=>{const E=new u(g,d,p,h,w);return E.index=t.length,s(v=>[...v,E]),E.show(),E};function c(g,d,p,h){if(!r[g])throw new Error(`The local modal "${g}" has not been registered.`);const w=o(null,{},d,p,h);return w.name=g,r[g].callback(w),w}const m=(g,d={})=>x(g,d.method??"get",d.data??{},d.headers??{},d.config??{},d.onClose,d.onAfterLeave,d.queryStringArrayFormat??"brackets",d.navigate??$e("navigate")).then(p=>{const h=d.listeners??{};return Object.keys(h).forEach(w=>{const E=ae(w);p.on(E,h[w])}),p}),x=(g,d,p={},h={},w={},E=null,v=null,M="brackets",P=!1)=>{const A=Xe();return new Promise((U,F)=>{if(g.startsWith("#")){U(c(g.substring(1),w,E,v));return}const[I,H]=tn.mergeDataIntoQueryString(d,g||"",p,M);let W=P&&t.length===0;if(t.length===0&&(de=typeof window<"u"?window.location.href:""),h={...h,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":ft,"X-InertiaUI-Modal":A,"X-InertiaUI-Modal-Use-Router":W?1:0,"X-InertiaUI-Modal-Base-Url":de},W)return Ve=null,le[A]={config:w,onClose:E,onAfterLeave:v},z.router.visit(I,{method:d,data:H,headers:h,preserveScroll:!0,preserveState:!0,onError:F,onFinish:()=>{dn(()=>Ve).then(U)}});Ee({url:I,method:d,data:H,headers:h}).then(S=>U(a(S.data,w,E,v))).catch(S=>{F(S)})})},f={stack:t,localModals:r,push:o,pushFromResponseData:a,length:()=>Ce.length,closeAll:()=>{Ce.reverse().forEach(g=>g.close())},reset:()=>s(()=>[]),visit:x,visitModal:m,registerLocalModal:(g,d)=>{l(p=>({...p,[g]:{name:g,callback:d}}))},removeLocalModal:g=>{l(d=>{const p={...d};return delete p[g],p})}};return $.jsx(Me.Provider,{value:f,children:e})},ce=()=>{const e=i.useContext(Me);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},ht=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],vt=e=>{e.initialPage&&(ft=e.initialPage.version),e.resolveComponent&&(mt=e.resolveComponent)},cn=(e,t)=>{vt(t);const n=({Component:r,props:l,key:s})=>{const u=()=>{const a=i.createElement(r,{key:s,...l});return typeof r.layout=="function"?r.layout(a):Array.isArray(r.layout)?r.layout.concat(a).reverse().reduce((c,m)=>i.createElement(m,l,c)):a};return $.jsxs($.Fragment,{children:[u(),$.jsx(gt,{})]})};return $.jsx(pt,{children:$.jsx(e,{...t,children:n})})},gt=({children:e})=>{var a;const t=i.useContext(Me);let n=!1,r=!1;i.useEffect(()=>z.router.on("before",o=>{if(!dt(window.location.href,o.detail.visit.url)||o.detail.visit.replace||t.length()!==1||!r)return!0;const{method:c,data:m,only:x,except:b,headers:y,errorBag:f,forceFormData:g,queryStringArrayFormat:d,async:p,showProgress:h,prefetch:w,fresh:E,reset:v,preserveUrl:M}=o.detail.visit;return z.router.visit(o.detail.visit.url,{replace:!0,preserveScroll:!0,preserveState:!0,method:c,data:m,only:x,except:b,headers:y,errorBag:f,forceFormData:g,queryStringArrayFormat:d,async:p,showProgress:h,prefetch:w,fresh:E,reset:v,preserveUrl:M}),!1}),[]),i.useEffect(()=>z.router.on("start",()=>n=!0),[]),i.useEffect(()=>z.router.on("finish",()=>n=!1),[]),i.useEffect(()=>z.router.on("navigate",function(o){const c=o.detail.page.props._inertiaui_modal;if(!c){r&&t.closeAll();return}r=c,de=c.baseUrl,t.pushFromResponseData(c,{},()=>{if(!c.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==c.baseUrl&&z.router.visit(c.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(m=>{Ve=m})}),[]);const l=o=>(Ce.length&&(o.headers["X-InertiaUI-Modal-Base-Url"]=de),o);i.useEffect(()=>(Ee.interceptors.request.use(l),()=>Ee.interceptors.request.eject(l)),[]);const s=z.usePage(),u=i.useRef();return i.useEffect(()=>{var m,x;const o=(m=s.props)==null?void 0:m._inertiaui_modal,c=u.current;u.current=o,o&&c&&o.component===c.component&&dt(o.url,c.url)&&((x=t.stack[0])==null||x.updateProps(o.props??{}))},[(a=s.props)==null?void 0:a._inertiaui_modal]),$.jsxs($.Fragment,{children:[e,t.stack.length>0&&$.jsx(wt,{index:0})]})},Ye=i.createContext(null);Ye.displayName="ModalIndexContext";const ze=()=>{const e=i.useContext(Ye);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},wt=({index:e})=>{const{stack:t}=ce(),n=i.useMemo(()=>t[e],[t,e]);return(n==null?void 0:n.component)&&$.jsx(Ye.Provider,{value:e,children:$.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},Ge=i.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:s=null,...u},a)=>{const o=ze(),{stack:c,registerLocalModal:m,removeLocalModal:x}=ce(),[b,y]=i.useState(null),f=i.useMemo(()=>e?b:c[o],[e,b,o,c]),g=i.useMemo(()=>{var v;return(v=c.find(M=>M.shouldRender&&M.index>(f==null?void 0:f.index)))==null?void 0:v.index},[o,c]),d=i.useMemo(()=>(f==null?void 0:f.config.slideover)??u.slideover??$e("type")==="slideover",[u.slideover]),p=i.useMemo(()=>({slideover:d,closeButton:u.closeButton??re(d,"closeButton"),closeExplicitly:u.closeExplicitly??re(d,"closeExplicitly"),maxWidth:u.maxWidth??re(d,"maxWidth"),paddingClasses:u.paddingClasses??re(d,"paddingClasses"),panelClasses:u.panelClasses??re(d,"panelClasses"),position:u.position??re(d,"position"),...f==null?void 0:f.config}),[u,f==null?void 0:f.config]);i.useEffect(()=>{if(e){let v=null;return m(e,M=>{v=M.registerEventListenersFromProps(u),y(M)}),()=>{v==null||v(),v=null,x(e)}}return f.registerEventListenersFromProps(u)},[e]);const h=i.useRef(f);i.useEffect(()=>{h.current=f},[f]),i.useEffect(()=>{f!==null&&(f.isOpen?s==null||s():l==null||l())},[f==null?void 0:f.isOpen]);const[w,E]=i.useState(!1);return i.useEffect(()=>{w&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),E(!0)},[f==null?void 0:f.onTopOfStack]),i.useImperativeHandle(a,()=>({afterLeave:()=>{var v;return(v=h.current)==null?void 0:v.afterLeave()},close:()=>{var v;return(v=h.current)==null?void 0:v.close()},emit:(...v)=>{var M;return(M=h.current)==null?void 0:M.emit(...v)},getChildModal:()=>{var v;return(v=h.current)==null?void 0:v.getChildModal()},getParentModal:()=>{var v;return(v=h.current)==null?void 0:v.getParentModal()},reload:(...v)=>{var M;return(M=h.current)==null?void 0:M.reload(...v)},setOpen:()=>{var v;return(v=h.current)==null?void 0:v.setOpen()},get id(){var v;return(v=h.current)==null?void 0:v.id},get index(){var v;return(v=h.current)==null?void 0:v.index},get isOpen(){var v;return(v=h.current)==null?void 0:v.isOpen},get config(){var v;return(v=h.current)==null?void 0:v.config},get modalContext(){return h.current},get onTopOfStack(){var v;return(v=h.current)==null?void 0:v.onTopOfStack},get shouldRender(){var v;return(v=h.current)==null?void 0:v.shouldRender}}),[f]),(f==null?void 0:f.shouldRender)&&$.jsxs($.Fragment,{children:[typeof t=="function"?t({afterLeave:f.afterLeave,close:f.close,config:p,emit:f.emit,getChildModal:f.getChildModal,getParentModal:f.getParentModal,id:f.id,index:f.index,isOpen:f.isOpen,modalContext:f,onTopOfStack:f.onTopOfStack,reload:f.reload,setOpen:f.setOpen,shouldRender:f.shouldRender}):t,g&&$.jsx(wt,{index:g})]})});Ge.displayName="HeadlessModal";function yt(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(n=yt(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Se(){for(var e,t,n=0,r="",l=arguments.length;n<l;n++)(e=arguments[n])&&(t=yt(e))&&(r&&(r+=" "),r+=t);return r}var fn=Object.defineProperty,mn=(e,t,n)=>t in e?fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ke=(e,t,n)=>(mn(e,typeof t!="symbol"?t+"":t,n),n);let pn=class{constructor(){Ke(this,"current",this.detect()),Ke(this,"handoffState","pending"),Ke(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},Q=new pn;function Oe(e){return Q.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function Pe(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function G(){let e=[],t={addEventListener(n,r,l,s){return n.addEventListener(r,l,s),t.add(()=>n.removeEventListener(r,l,s))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return Pe(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,l){let s=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:l}),this.add(()=>{Object.assign(n.style,{[r]:s})})},group(n){let r=G();return n(r),this.add(()=>r.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let l of e.splice(r,1))l()}},dispose(){for(let n of e.splice(0))n()}};return t}function Ze(){let[e]=i.useState(G);return i.useEffect(()=>()=>e.dispose(),[e]),e}let L=(e,t)=>{Q.isServer?i.useEffect(e,t):i.useLayoutEffect(e,t)};function R(e){let t=i.useRef(e);return L(()=>{t.current=e},[e]),t}let O=function(e){let t=R(e);return i.useCallback((...n)=>t.current(...n),[t])},hn=i.createContext(void 0);function vn(){return i.useContext(hn)}function Je(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function K(e,t,...n){if(e in t){let l=t[e];return typeof l=="function"?l(...n):l}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(l=>`"${l}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,K),r}var Te=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Te||{}),Z=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Z||{});function D(){let e=wn();return i.useCallback(t=>gn({mergeRefs:e,...t}),[e])}function gn({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:l,visible:s=!0,name:u,mergeRefs:a}){a=a??yn;let o=xt(t,e);if(s)return Fe(o,n,r,u,a);let c=l??0;if(c&2){let{static:m=!1,...x}=o;if(m)return Fe(x,n,r,u,a)}if(c&1){let{unmount:m=!0,...x}=o;return K(m?0:1,{0(){return null},1(){return Fe({...x,hidden:!0,style:{display:"none"}},n,r,u,a)}})}return Fe(o,n,r,u,a)}function Fe(e,t={},n,r,l){let{as:s=n,children:u,refName:a="ref",...o}=Qe(e,["unmount","static"]),c=e.ref!==void 0?{[a]:e.ref}:{},m=typeof u=="function"?u(t):u;"className"in o&&o.className&&typeof o.className=="function"&&(o.className=o.className(t)),o["aria-labelledby"]&&o["aria-labelledby"]===o.id&&(o["aria-labelledby"]=void 0);let x={};if(t){let b=!1,y=[];for(let[f,g]of Object.entries(t))typeof g=="boolean"&&(b=!0),g===!0&&y.push(f.replace(/([A-Z])/g,d=>`-${d.toLowerCase()}`));if(b){x["data-headlessui-state"]=y.join(" ");for(let f of y)x[`data-${f}`]=""}}if(s===i.Fragment&&(Object.keys(ee(o)).length>0||Object.keys(ee(x)).length>0))if(!i.isValidElement(m)||Array.isArray(m)&&m.length>1){if(Object.keys(ee(o)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(ee(o)).concat(Object.keys(ee(x))).map(b=>` - ${b}`).join(`
2
2
  `),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(b=>` - ${b}`).join(`
3
3
  `)].join(`
4
- `))}else{let b=m.props,E=b==null?void 0:b.className,f=typeof E=="function"?(...p)=>Je(E(...p),o.className):Je(E,o.className),g=f?{className:f}:{},d=Et(m.props,R(Qe(o,["ref"])));for(let p in x)p in d&&delete x[p];return i.cloneElement(m,Object.assign({},d,x,c,{ref:l(En(m),c.ref)},g))}return i.createElement(s,Object.assign({},Qe(o,["ref"]),s!==i.Fragment&&c,s!==i.Fragment&&x),m)}function gn(){let e=i.useRef([]),t=i.useCallback(n=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return e.current=n,t}}function wn(...e){return e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}function Et(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let l in r)l.startsWith("on")&&typeof r[l]=="function"?(n[l]!=null||(n[l]=[]),n[l].push(r[l])):t[l]=r[l];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[l=>{var s;return(s=l==null?void 0:l.preventDefault)==null?void 0:s.call(l)}]);for(let r in n)Object.assign(t,{[r](l,...s){let u=n[r];for(let a of u){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;a(l,...s)}}});return t}function L(e){var t;return Object.assign(i.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function R(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function Qe(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function En(e){return i.version.split(".")[0]>="19"?e.props.ref:e.ref}let xn="span";var Fe=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Fe||{});function yn(e,t){var n;let{features:r=1,...l}=e,s={ref:t,"aria-hidden":(r&2)===2?!0:(n=l["aria-hidden"])!=null?n:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return D()({ourProps:s,theirProps:l,slot:{},defaultTag:xn,name:"Hidden"})}let Re=L(yn),xt=Symbol();function bn(e,t=!0){return Object.assign(e,{[xt]:t})}function q(...e){let t=i.useRef(e);i.useEffect(()=>{t.current=e},[e]);let n=O(r=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(r):l.current=r)});return e.every(r=>r==null||(r==null?void 0:r[xt]))?void 0:n}let et=i.createContext(null);et.displayName="DescriptionContext";function yt(){let e=i.useContext(et);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,yt),t}return e}function $n(){let[e,t]=i.useState([]);return[e.length>0?e.join(" "):void 0,i.useMemo(()=>function(n){let r=O(s=>(t(u=>[...u,s]),()=>t(u=>{let a=u.slice(),o=a.indexOf(s);return o!==-1&&a.splice(o,1),a}))),l=i.useMemo(()=>({register:r,slot:n.slot,name:n.name,props:n.props,value:n.value}),[r,n.slot,n.name,n.props,n.value]);return i.createElement(et.Provider,{value:l},n.children)},[t])]}let Mn="p";function Cn(e,t){let n=i.useId(),r=hn(),{id:l=`headlessui-description-${n}`,...s}=e,u=yt(),a=q(t);k(()=>u.register(l),[l,u.register]);let o=r||!1,c=i.useMemo(()=>({...u.slot,disabled:o}),[u.slot,o]),m={ref:a,...u.props,id:l};return D()({ourProps:m,theirProps:s,slot:c,defaultTag:Mn,name:u.name||"Description"})}let Sn=L(Cn),On=Object.assign(Sn,{});var bt=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(bt||{});let Tn=i.createContext(()=>{});function Pn({value:e,children:t}){return i.createElement(Tn.Provider,{value:e},t)}let Fn=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function $t(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(l){return r.add(l),()=>r.delete(l)},dispatch(l,...s){let u=t[l].call(n,...s);u&&(n=u,r.forEach(a=>a()))}}}function Mt(e){return i.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let kn=new Fn(()=>$t(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function ie(e,t){let n=kn.get(t),r=i.useId(),l=Mt(n);if(k(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let s=l.indexOf(r),u=l.length;return s===-1&&(s=u,u+=1),s===u-1}let tt=new Map,fe=new Map;function Ct(e){var t;let n=(t=fe.get(e))!=null?t:0;return fe.set(e,n+1),n!==0?()=>St(e):(tt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>St(e))}function St(e){var t;let n=(t=fe.get(e))!=null?t:1;if(n===1?fe.delete(e):fe.set(e,n-1),n!==1)return;let r=tt.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,tt.delete(e))}function Ln(e,{allowed:t,disallowed:n}={}){let r=ie(e,"inert-others");k(()=>{var l,s;if(!r)return;let u=z();for(let o of(l=n==null?void 0:n())!=null?l:[])o&&u.add(Ct(o));let a=(s=t==null?void 0:t())!=null?s:[];for(let o of a){if(!o)continue;let c=Se(o);if(!c)continue;let m=o.parentElement;for(;m&&m!==c.body;){for(let x of m.children)a.some(b=>x.contains(b))||u.add(Ct(x));m=m.parentElement}}return u.dispose},[r,t,n])}function Nn(e,t,n){let r=Q(l=>{let s=l.getBoundingClientRect();s.x===0&&s.y===0&&s.width===0&&s.height===0&&n()});i.useEffect(()=>{if(!e)return;let l=t===null?null:t instanceof HTMLElement?t:t.current;if(!l)return;let s=z();if(typeof ResizeObserver<"u"){let u=new ResizeObserver(()=>r.current(l));u.observe(l),s.add(()=>u.disconnect())}if(typeof IntersectionObserver<"u"){let u=new IntersectionObserver(()=>r.current(l));u.observe(l),s.add(()=>u.disconnect())}return()=>s.dispose()},[t,r,e])}let ke=["[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(","),In=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var V=(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[e.AutoFocus=64]="AutoFocus",e))(V||{}),nt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(nt||{}),An=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(An||{});function Dn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(ke)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function jn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(In)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Ot=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Ot||{});function Hn(e,t=0){var n;return e===((n=Se(e))==null?void 0:n.body)?!1:G(t,{0(){return e.matches(ke)},1(){let r=e;for(;r!==null;){if(r.matches(ke))return!0;r=r.parentElement}return!1}})}var Un=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Un||{});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 Y(e){e==null||e.focus({preventScroll:!0})}let Wn=["textarea","input"].join(",");function _n(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Wn))!=null?n:!1}function Bn(e,t=n=>n){return e.slice().sort((n,r)=>{let l=t(n),s=t(r);if(l===null||s===null)return 0;let u=l.compareDocumentPosition(s);return u&Node.DOCUMENT_POSITION_FOLLOWING?-1:u&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function me(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:l=[]}={}){let s=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,u=Array.isArray(e)?n?Bn(e):e:t&64?jn(e):Dn(e);l.length>0&&u.length>1&&(u=u.filter(E=>!l.some(f=>f!=null&&"current"in f?(f==null?void 0:f.current)===E:f===E))),r=r??s.activeElement;let a=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),o=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,u.indexOf(r))-1;if(t&4)return Math.max(0,u.indexOf(r))+1;if(t&8)return u.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=t&32?{preventScroll:!0}:{},m=0,x=u.length,b;do{if(m>=x||m+x<=0)return 0;let E=o+m;if(t&16)E=(E+x)%x;else{if(E<0)return 3;if(E>=x)return 1}b=u[E],b==null||b.focus(c),m+=a}while(b!==s.activeElement);return t&6&&_n(b)&&b.select(),2}function Tt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function qn(){return/Android/gi.test(window.navigator.userAgent)}function Xn(){return Tt()||qn()}function pe(e,t,n,r){let l=Q(n);i.useEffect(()=>{if(!e)return;function s(u){l.current(u)}return document.addEventListener(t,s,r),()=>document.removeEventListener(t,s,r)},[e,t,r])}function Pt(e,t,n,r){let l=Q(n);i.useEffect(()=>{if(!e)return;function s(u){l.current(u)}return window.addEventListener(t,s,r),()=>window.removeEventListener(t,s,r)},[e,t,r])}const Ft=30;function Vn(e,t,n){let r=ie(e,"outside-click"),l=Q(n),s=i.useCallback(function(o,c){if(o.defaultPrevented)return;let m=c(o);if(m===null||!m.getRootNode().contains(m)||!m.isConnected)return;let x=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of x)if(b!==null&&(b.contains(m)||o.composed&&o.composedPath().includes(b)))return;return!Hn(m,Ot.Loose)&&m.tabIndex!==-1&&o.preventDefault(),l.current(o,m)},[l,t]),u=i.useRef(null);pe(r,"pointerdown",o=>{var c,m;u.current=((m=(c=o.composedPath)==null?void 0:c.call(o))==null?void 0:m[0])||o.target},!0),pe(r,"mousedown",o=>{var c,m;u.current=((m=(c=o.composedPath)==null?void 0:c.call(o))==null?void 0:m[0])||o.target},!0),pe(r,"click",o=>{Xn()||u.current&&(s(o,()=>u.current),u.current=null)},!0);let a=i.useRef({x:0,y:0});pe(r,"touchstart",o=>{a.current.x=o.touches[0].clientX,a.current.y=o.touches[0].clientY},!0),pe(r,"touchend",o=>{let c={x:o.changedTouches[0].clientX,y:o.changedTouches[0].clientY};if(!(Math.abs(c.x-a.current.x)>=Ft||Math.abs(c.y-a.current.y)>=Ft))return s(o,()=>o.target instanceof HTMLElement?o.target:null)},!0),Pt(r,"blur",o=>s(o,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function he(...e){return i.useMemo(()=>Se(...e),[...e])}function kt(e,t,n,r){let l=Q(n);i.useEffect(()=>{e=e??window;function s(u){l.current(u)}return e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)},[e,t,r])}function Yn(){let e;return{before({doc:t}){var n;let r=t.documentElement,l=(n=t.defaultView)!=null?n:window;e=Math.max(0,l.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,l=Math.max(0,r.clientWidth-r.offsetWidth),s=Math.max(0,e-l);n.style(r,"paddingRight",`${s}px`)}}}function zn(){return Tt()?{before({doc:e,d:t,meta:n}){function r(l){return n.containers.flatMap(s=>s()).some(s=>s.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=z();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let s=(l=window.scrollY)!=null?l:window.pageYOffset,u=null;t.addEventListener(e,"click",a=>{if(a.target instanceof HTMLElement)try{let o=a.target.closest("a");if(!o)return;let{hash:c}=new URL(o.href),m=e.querySelector(c);m&&!r(m)&&(u=m)}catch{}},!0),t.addEventListener(e,"touchstart",a=>{if(a.target instanceof HTMLElement)if(r(a.target)){let o=a.target;for(;o.parentElement&&r(o.parentElement);)o=o.parentElement;t.style(o,"overscrollBehavior","contain")}else t.style(a.target,"touchAction","none")}),t.addEventListener(e,"touchmove",a=>{if(a.target instanceof HTMLElement){if(a.target.tagName==="INPUT")return;if(r(a.target)){let o=a.target;for(;o.parentElement&&o.dataset.headlessuiPortal!==""&&!(o.scrollHeight>o.clientHeight||o.scrollWidth>o.clientWidth);)o=o.parentElement;o.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let o=(a=window.scrollY)!=null?a:window.pageYOffset;s!==o&&window.scrollTo(0,s),u&&u.isConnected&&(u.scrollIntoView({block:"nearest"}),u=null)})})}}:{}}function Gn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Kn(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let ee=$t(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:z(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:Kn(n)},l=[zn(),Yn(),Gn()];l.forEach(({before:s})=>s==null?void 0:s(r)),l.forEach(({after:s})=>s==null?void 0:s(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});ee.subscribe(()=>{let e=ee.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",l=n.count!==0;(l&&!r||!l&&r)&&ee.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&ee.dispatch("TEARDOWN",n)}});function Zn(e,t,n=()=>({containers:[]})){let r=Mt(ee),l=t?r.get(t):void 0,s=l?l.count>0:!1;return k(()=>{if(!(!t||!e))return ee.dispatch("PUSH",t,n),()=>ee.dispatch("POP",t,n)},[e,t]),s}function Jn(e,t,n=()=>[document.body]){let r=ie(e,"scroll-lock");Zn(r,t,l=>{var s;return{containers:[...(s=l.containers)!=null?s:[],n]}})}function Qn(e=0){let[t,n]=i.useState(e),r=i.useCallback(o=>n(o),[t]),l=i.useCallback(o=>n(c=>c|o),[t]),s=i.useCallback(o=>(t&o)===o,[t]),u=i.useCallback(o=>n(c=>c&~o),[n]),a=i.useCallback(o=>n(c=>c^o),[n]);return{flags:t,setFlag:r,addFlag:l,hasFlag:s,removeFlag:u,toggleFlag:a}}var Lt,Nt;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Lt=process==null?void 0:process.env)==null?void 0:Lt.NODE_ENV)==="test"&&typeof((Nt=Element==null?void 0:Element.prototype)==null?void 0:Nt.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
5
- `)),[]});var Rn=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(Rn||{});function er(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function tr(e,t,n,r){let[l,s]=i.useState(n),{hasFlag:u,addFlag:a,removeFlag:o}=Qn(e&&l?3:0),c=i.useRef(!1),m=i.useRef(!1),x=Ze();return k(()=>{var b;if(e){if(n&&s(!0),!t){n&&a(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,n),nr(t,{inFlight:c,prepare(){m.current?m.current=!1:m.current=c.current,c.current=!0,!m.current&&(n?(a(3),o(4)):(a(4),o(2)))},run(){m.current?n?(o(3),a(4)):(o(4),a(3)):n?o(1):a(1)},done(){var E;m.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,o(7),n||s(!1),(E=r==null?void 0:r.end)==null||E.call(r,n))}})}},[e,n,t,x]),e?[l,{closed:u(1),enter:u(2),leave:u(4),transition:u(2)||u(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function nr(e,{prepare:t,run:n,done:r,inFlight:l}){let s=z();return lr(e,{prepare:t,inFlight:l}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(rr(e,r))})}),s.dispose}function rr(e,t){var n,r;let l=z();if(!e)return l.dispose;let s=!1;l.add(()=>{s=!0});let u=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return u.length===0?(t(),l.dispose):(Promise.allSettled(u.map(a=>a.finished)).then(()=>{s||t()}),l.dispose)}function lr(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function rt(e,t){let n=i.useRef([]),r=O(e);i.useEffect(()=>{let l=[...n.current];for(let[s,u]of t.entries())if(n.current[s]!==u){let a=r(t,l);return n.current=t,a}},[r,...t])}let Le=i.createContext(null);Le.displayName="OpenClosedContext";var j=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(j||{});function Ne(){return i.useContext(Le)}function ir({value:e,children:t}){return i.createElement(Le.Provider,{value:e},t)}function or({children:e}){return i.createElement(Le.Provider,{value:null},e)}function sr(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Z=[];sr(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Z[0]===t.target)return;let n=t.target;n=n.closest(ke),Z.unshift(n??t.target),Z=Z.filter(r=>r!=null&&r.isConnected),Z.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})});function It(e){let t=O(e),n=i.useRef(!1);i.useEffect(()=>(n.current=!1,()=>{n.current=!0,Oe(()=>{n.current&&t()})}),[t])}function ur(){let e=typeof document>"u";return"useSyncExternalStore"in se?(t=>t.useSyncExternalStore)(se)(()=>()=>{},()=>!1,()=>!e):!1}function ve(){let e=ur(),[t,n]=se.useState(J.isHandoffComplete);return t&&J.isHandoffComplete===!1&&n(!1),se.useEffect(()=>{t!==!0&&n(!0)},[t]),se.useEffect(()=>J.handoff(),[]),e?!1:t}let At=i.createContext(!1);function ar(){return i.useContext(At)}function Dt(e){return i.createElement(At.Provider,{value:e.force},e.children)}function dr(e){let t=ar(),n=i.useContext(Ht),r=he(e),[l,s]=i.useState(()=>{var u;if(!t&&n!==null)return(u=n.current)!=null?u:null;if(J.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let o=r.createElement("div");return o.setAttribute("id","headlessui-portal-root"),r.body.appendChild(o)});return i.useEffect(()=>{l!==null&&(r!=null&&r.body.contains(l)||r==null||r.body.appendChild(l))},[l,r]),i.useEffect(()=>{t||n!==null&&s(n.current)},[n,s,t]),l}let jt=i.Fragment,cr=L(function(e,t){let n=e,r=i.useRef(null),l=q(bn(x=>{r.current=x}),t),s=he(r),u=dr(r),[a]=i.useState(()=>{var x;return J.isServer?null:(x=s==null?void 0:s.createElement("div"))!=null?x:null}),o=i.useContext(lt),c=ve();k(()=>{!u||!a||u.contains(a)||(a.setAttribute("data-headlessui-portal",""),u.appendChild(a))},[u,a]),k(()=>{if(a&&o)return o.register(a)},[o,a]),It(()=>{var x;!u||!a||(a instanceof Node&&u.contains(a)&&u.removeChild(a),u.childNodes.length<=0&&((x=u.parentElement)==null||x.removeChild(u)))});let m=D();return c?!u||!a?null:tn.createPortal(m({ourProps:{ref:l},theirProps:n,slot:{},defaultTag:jt,name:"Portal"}),a):null});function fr(e,t){let n=q(t),{enabled:r=!0,...l}=e,s=D();return r?i.createElement(cr,{...l,ref:n}):s({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:jt,name:"Portal"})}let mr=i.Fragment,Ht=i.createContext(null);function pr(e,t){let{target:n,...r}=e,l={ref:q(t)},s=D();return i.createElement(Ht.Provider,{value:n},s({ourProps:l,theirProps:r,defaultTag:mr,name:"Popover.Group"}))}let lt=i.createContext(null);function hr(){let e=i.useContext(lt),t=i.useRef([]),n=O(s=>(t.current.push(s),e&&e.register(s),()=>r(s))),r=O(s=>{let u=t.current.indexOf(s);u!==-1&&t.current.splice(u,1),e&&e.unregister(s)}),l=i.useMemo(()=>({register:n,unregister:r,portals:t}),[n,r,t]);return[t,i.useMemo(()=>function({children:s}){return i.createElement(lt.Provider,{value:l},s)},[l])]}let vr=L(fr),Ut=L(pr),gr=Object.assign(vr,{Group:Ut});function wr(e,t=typeof document<"u"?document.defaultView:null,n){let r=ie(e,"escape");kt(t,"keydown",l=>{r&&(l.defaultPrevented||l.key===bt.Escape&&n(l))})}function Er(){var e;let[t]=i.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,r]=i.useState((e=t==null?void 0:t.matches)!=null?e:!1);return k(()=>{if(!t)return;function l(s){r(s.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),n}function xr({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=he(n),l=O(()=>{var s,u;let a=[];for(let o of e)o!==null&&(o instanceof HTMLElement?a.push(o):"current"in o&&o.current instanceof HTMLElement&&a.push(o.current));if(t!=null&&t.current)for(let o of t.current)a.push(o);for(let o of(s=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?s:[])o!==document.body&&o!==document.head&&o instanceof HTMLElement&&o.id!=="headlessui-portal-root"&&(n&&(o.contains(n)||o.contains((u=n==null?void 0:n.getRootNode())==null?void 0:u.host))||a.some(c=>o.contains(c))||a.push(o));return a});return{resolveContainers:l,contains:O(s=>l().some(u=>u.contains(s)))}}let Wt=i.createContext(null);function _t({children:e,node:t}){let[n,r]=i.useState(null),l=Bt(t??n);return i.createElement(Wt.Provider,{value:l},e,l===null&&i.createElement(Re,{features:Fe.Hidden,ref:s=>{var u,a;if(s){for(let o of(a=(u=Se(s))==null?void 0:u.querySelectorAll("html > *, body > *"))!=null?a:[])if(o!==document.body&&o!==document.head&&o instanceof HTMLElement&&o!=null&&o.contains(s)){r(o);break}}}}))}function Bt(e=null){var t;return(t=i.useContext(Wt))!=null?t:e}function it(){let e=i.useRef(!1);return k(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var ge=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(ge||{});function yr(){let e=i.useRef(0);return Pt(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function qt(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)n.current instanceof HTMLElement&&t.add(n.current);return t}let br="div";var te=(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))(te||{});function $r(e,t){let n=i.useRef(null),r=q(n,t),{initialFocus:l,initialFocusFallback:s,containers:u,features:a=15,...o}=e;ve()||(a=0);let c=he(n);Or(a,{ownerDocument:c});let m=Tr(a,{ownerDocument:c,container:n,initialFocus:l,initialFocusFallback:s});Pr(a,{ownerDocument:c,container:n,containers:u,previousActiveElement:m});let x=yr(),b=O(h=>{let w=n.current;w&&(y=>y())(()=>{G(x.current,{[ge.Forwards]:()=>{me(w,V.First,{skipElements:[h.relatedTarget,s]})},[ge.Backwards]:()=>{me(w,V.Last,{skipElements:[h.relatedTarget,s]})}})})}),E=ie(!!(a&2),"focus-trap#tab-lock"),f=Ze(),g=i.useRef(!1),d={ref:r,onKeyDown(h){h.key=="Tab"&&(g.current=!0,f.requestAnimationFrame(()=>{g.current=!1}))},onBlur(h){if(!(a&4))return;let w=qt(u);n.current instanceof HTMLElement&&w.add(n.current);let y=h.relatedTarget;y instanceof HTMLElement&&y.dataset.headlessuiFocusGuard!=="true"&&(Xt(w,y)||(g.current?me(n.current,G(x.current,{[ge.Forwards]:()=>V.Next,[ge.Backwards]:()=>V.Previous})|V.WrapAround,{relativeTo:h.target}):h.target instanceof HTMLElement&&Y(h.target)))}},p=D();return i.createElement(i.Fragment,null,E&&i.createElement(Re,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Fe.Focusable}),p({ourProps:d,theirProps:o,defaultTag:br,name:"FocusTrap"}),E&&i.createElement(Re,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Fe.Focusable}))}let Mr=L($r),Cr=Object.assign(Mr,{features:te});function Sr(e=!0){let t=i.useRef(Z.slice());return rt(([n],[r])=>{r===!0&&n===!1&&Oe(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=Z.slice())},[e,Z,t]),O(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function Or(e,{ownerDocument:t}){let n=!!(e&8),r=Sr(n);rt(()=>{n||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(r())},[n]),It(()=>{n&&Y(r())})}function Tr(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:l}){let s=i.useRef(null),u=ie(!!(e&1),"focus-trap#initial-focus"),a=it();return rt(()=>{if(e===0)return;if(!u){l!=null&&l.current&&Y(l.current);return}let o=n.current;o&&Oe(()=>{if(!a.current)return;let c=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===c){s.current=c;return}}else if(o.contains(c)){s.current=c;return}if(r!=null&&r.current)Y(r.current);else{if(e&16){if(me(o,V.First|V.AutoFocus)!==nt.Error)return}else if(me(o,V.First)!==nt.Error)return;if(l!=null&&l.current&&(Y(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}s.current=t==null?void 0:t.activeElement})},[l,u,e]),s}function Pr(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:l}){let s=it(),u=!!(e&4);kt(t==null?void 0:t.defaultView,"focus",a=>{if(!u||!s.current)return;let o=qt(r);n.current instanceof HTMLElement&&o.add(n.current);let c=l.current;if(!c)return;let m=a.target;m&&m instanceof HTMLElement?Xt(o,m)?(l.current=m,Y(m)):(a.preventDefault(),a.stopPropagation(),Y(c)):Y(l.current)},!0)}function Xt(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function Vt(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:zt)!==i.Fragment||i.Children.count(e.children)===1}let Ie=i.createContext(null);Ie.displayName="TransitionContext";var Fr=(e=>(e.Visible="visible",e.Hidden="hidden",e))(Fr||{});function kr(){let e=i.useContext(Ie);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function Lr(){let e=i.useContext(Ae);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Ae=i.createContext(null);Ae.displayName="NestingContext";function De(e){return"children"in e?De(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function Yt(e,t){let n=Q(e),r=i.useRef([]),l=it(),s=Ze(),u=O((E,f=K.Hidden)=>{let g=r.current.findIndex(({el:d})=>d===E);g!==-1&&(G(f,{[K.Unmount](){r.current.splice(g,1)},[K.Hidden](){r.current[g].state="hidden"}}),s.microTask(()=>{var d;!De(r)&&l.current&&((d=n.current)==null||d.call(n))}))}),a=O(E=>{let f=r.current.find(({el:g})=>g===E);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:E,state:"visible"}),()=>u(E,K.Unmount)}),o=i.useRef([]),c=i.useRef(Promise.resolve()),m=i.useRef({enter:[],leave:[]}),x=O((E,f,g)=>{o.current.splice(0),t&&(t.chains.current[f]=t.chains.current[f].filter(([d])=>d!==E)),t==null||t.chains.current[f].push([E,new Promise(d=>{o.current.push(d)})]),t==null||t.chains.current[f].push([E,new Promise(d=>{Promise.all(m.current[f].map(([p,h])=>h)).then(()=>d())})]),f==="enter"?c.current=c.current.then(()=>t==null?void 0:t.wait.current).then(()=>g(f)):g(f)}),b=O((E,f,g)=>{Promise.all(m.current[f].splice(0).map(([d,p])=>p)).then(()=>{var d;(d=o.current.shift())==null||d()}).then(()=>g(f))});return i.useMemo(()=>({children:r,register:a,unregister:u,onStart:x,onStop:b,wait:c,chains:m}),[a,u,r,x,b,m,c])}let zt=i.Fragment,Gt=Te.RenderStrategy;function Nr(e,t){var n,r;let{transition:l=!0,beforeEnter:s,afterEnter:u,beforeLeave:a,afterLeave:o,enter:c,enterFrom:m,enterTo:x,entered:b,leave:E,leaveFrom:f,leaveTo:g,...d}=e,[p,h]=i.useState(null),w=i.useRef(null),y=Vt(e),v=q(...y?[w,t,h]:t===null?[]:[t]),M=(n=d.unmount)==null||n?K.Unmount:K.Hidden,{show:T,appear:I,initial:H}=kr(),[F,A]=i.useState(T?"visible":"hidden"),U=Lr(),{register:W,unregister:S}=U;k(()=>W(w),[W,w]),k(()=>{if(M===K.Hidden&&w.current){if(T&&F!=="visible"){A("visible");return}return G(F,{hidden:()=>S(w),visible:()=>W(w)})}},[F,w,W,S,T,M]);let _=ve();k(()=>{if(y&&_&&F==="visible"&&w.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[w,F,_,y]);let He=H&&!I,Ue=I&&T&&H,we=i.useRef(!1),X=Yt(()=>{we.current||(A("hidden"),S(w))},U),We=O(at=>{we.current=!0;let Be=at?"enter":"leave";X.onStart(w,Be,xe=>{xe==="enter"?s==null||s():xe==="leave"&&(a==null||a())})}),P=O(at=>{let Be=at?"enter":"leave";we.current=!1,X.onStop(w,Be,xe=>{xe==="enter"?u==null||u():xe==="leave"&&(o==null||o())}),Be==="leave"&&!De(X)&&(A("hidden"),S(w))});i.useEffect(()=>{y&&l||(We(T),P(T))},[T,y,l]);let _e=!(!l||!y||!_||He),[,N]=tr(_e,p,T,{start:We,end:P}),rl=R({ref:v,className:((r=Je(d.className,Ue&&c,Ue&&m,N.enter&&c,N.enter&&N.closed&&m,N.enter&&!N.closed&&x,N.leave&&E,N.leave&&!N.closed&&f,N.leave&&N.closed&&g,!N.transition&&T&&b))==null?void 0:r.trim())||void 0,...er(N)}),Ee=0;F==="visible"&&(Ee|=j.Open),F==="hidden"&&(Ee|=j.Closed),N.enter&&(Ee|=j.Opening),N.leave&&(Ee|=j.Closing);let ll=D();return i.createElement(Ae.Provider,{value:X},i.createElement(ir,{value:Ee},ll({ourProps:rl,theirProps:d,defaultTag:zt,features:Gt,visible:F==="visible",name:"Transition.Child"})))}function Ir(e,t){let{show:n,appear:r=!1,unmount:l=!0,...s}=e,u=i.useRef(null),a=Vt(e),o=q(...a?[u,t]:t===null?[]:[t]);ve();let c=Ne();if(n===void 0&&c!==null&&(n=(c&j.Open)===j.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[m,x]=i.useState(n?"visible":"hidden"),b=Yt(()=>{n||x("hidden")}),[E,f]=i.useState(!0),g=i.useRef([n]);k(()=>{E!==!1&&g.current[g.current.length-1]!==n&&(g.current.push(n),f(!1))},[g,n]);let d=i.useMemo(()=>({show:n,appear:r,initial:E}),[n,r,E]);k(()=>{n?x("visible"):!De(b)&&u.current!==null&&x("hidden")},[n,b]);let p={unmount:l},h=O(()=>{var v;E&&f(!1),(v=e.beforeEnter)==null||v.call(e)}),w=O(()=>{var v;E&&f(!1),(v=e.beforeLeave)==null||v.call(e)}),y=D();return i.createElement(Ae.Provider,{value:b},i.createElement(Ie.Provider,{value:d},y({ourProps:{...p,as:i.Fragment,children:i.createElement(Kt,{ref:o,...p,...s,beforeEnter:h,beforeLeave:w})},theirProps:{},defaultTag:i.Fragment,features:Gt,visible:m==="visible",name:"Transition"})))}function Ar(e,t){let n=i.useContext(Ie)!==null,r=Ne()!==null;return i.createElement(i.Fragment,null,!n&&r?i.createElement(ot,{ref:t,...e}):i.createElement(Kt,{ref:t,...e}))}let ot=L(Ir),Kt=L(Nr),oe=L(Ar),Zt=Object.assign(ot,{Child:oe,Root:ot});var Dr=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Dr||{}),jr=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(jr||{});let Hr={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},st=i.createContext(null);st.displayName="DialogContext";function je(e){let t=i.useContext(st);if(t===null){let n=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,je),n}return t}function Ur(e,t){return G(t.type,Hr,e,t)}let Jt=L(function(e,t){let n=i.useId(),{id:r=`headlessui-dialog-${n}`,open:l,onClose:s,initialFocus:u,role:a="dialog",autoFocus:o=!0,__demoMode:c=!1,unmount:m=!1,...x}=e,b=i.useRef(!1);a=function(){return a==="dialog"||a==="alertdialog"?a:(b.current||(b.current=!0,console.warn(`Invalid role [${a}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let E=Ne();l===void 0&&E!==null&&(l=(E&j.Open)===j.Open);let f=i.useRef(null),g=q(f,t),d=he(f),p=l?0:1,[h,w]=i.useReducer(Ur,{titleId:null,descriptionId:null,panelRef:i.createRef()}),y=O(()=>s(!1)),v=O(P=>w({type:0,id:P})),M=ve()?p===0:!1,[T,I]=hr(),H={get current(){var P;return(P=h.panelRef.current)!=null?P:f.current}},F=Bt(),{resolveContainers:A}=xr({mainTreeNode:F,portals:T,defaultContainers:[H]}),U=E!==null?(E&j.Closing)===j.Closing:!1;Ln(c||U?!1:M,{allowed:O(()=>{var P,_e;return[(_e=(P=f.current)==null?void 0:P.closest("[data-headlessui-portal]"))!=null?_e:null]}),disallowed:O(()=>{var P;return[(P=F==null?void 0:F.closest("body > *:not(#headlessui-portal-root)"))!=null?P:null]})}),Vn(M,A,P=>{P.preventDefault(),y()}),wr(M,d==null?void 0:d.defaultView,P=>{P.preventDefault(),P.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Jn(c||U?!1:M,d,A),Nn(M,f,y);let[W,S]=$n(),_=i.useMemo(()=>[{dialogState:p,close:y,setTitleId:v,unmount:m},h],[p,h,y,v,m]),He=i.useMemo(()=>({open:p===0}),[p]),Ue={ref:g,id:r,role:a,tabIndex:-1,"aria-modal":c?void 0:p===0?!0:void 0,"aria-labelledby":h.titleId,"aria-describedby":W,unmount:m},we=!Er(),X=te.None;M&&!c&&(X|=te.RestoreFocus,X|=te.TabLock,o&&(X|=te.AutoFocus),we&&(X|=te.InitialFocus));let We=D();return i.createElement(or,null,i.createElement(Dt,{force:!0},i.createElement(gr,null,i.createElement(st.Provider,{value:_},i.createElement(Ut,{target:f},i.createElement(Dt,{force:!1},i.createElement(S,{slot:He},i.createElement(I,null,i.createElement(Cr,{initialFocus:u,initialFocusFallback:f,containers:A,features:X},i.createElement(Pn,{value:y},We({ourProps:Ue,theirProps:x,slot:He,defaultTag:Wr,features:_r,visible:p===0,name:"Dialog"})))))))))))}),Wr="div",_r=Te.RenderStrategy|Te.Static;function Br(e,t){let{transition:n=!1,open:r,...l}=e,s=Ne(),u=e.hasOwnProperty("open")||s!==null,a=e.hasOwnProperty("onClose");if(!u&&!a)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!u)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!a)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!s&&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)&&!l.static?i.createElement(_t,null,i.createElement(Zt,{show:r,transition:n,unmount:l.unmount},i.createElement(Jt,{ref:t,...l}))):i.createElement(_t,null,i.createElement(Jt,{ref:t,open:r,...l}))}let qr="div";function Xr(e,t){let n=i.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:l=!1,...s}=e,[{dialogState:u,unmount:a},o]=je("Dialog.Panel"),c=q(t,o.panelRef),m=i.useMemo(()=>({open:u===0}),[u]),x=O(d=>{d.stopPropagation()}),b={ref:c,id:r,onClick:x},E=l?oe:i.Fragment,f=l?{unmount:a}:{},g=D();return i.createElement(E,{...f},g({ourProps:b,theirProps:s,slot:m,defaultTag:qr,name:"Dialog.Panel"}))}let Vr="div";function Yr(e,t){let{transition:n=!1,...r}=e,[{dialogState:l,unmount:s}]=je("Dialog.Backdrop"),u=i.useMemo(()=>({open:l===0}),[l]),a={ref:t,"aria-hidden":!0},o=n?oe:i.Fragment,c=n?{unmount:s}:{},m=D();return i.createElement(o,{...c},m({ourProps:a,theirProps:r,slot:u,defaultTag:Vr,name:"Dialog.Backdrop"}))}let zr="h2";function Gr(e,t){let n=i.useId(),{id:r=`headlessui-dialog-title-${n}`,...l}=e,[{dialogState:s,setTitleId:u}]=je("Dialog.Title"),a=q(t);i.useEffect(()=>(u(r),()=>u(null)),[r,u]);let o=i.useMemo(()=>({open:s===0}),[s]),c={ref:a,id:r};return D()({ourProps:c,theirProps:l,slot:o,defaultTag:zr,name:"Dialog.Title"})}let Kr=L(Br),ut=L(Xr);L(Yr);let Zr=L(Gr),Jr=Object.assign(Kr,{Panel:ut,Title:Zr,Description:On});function Qt({onClick:e}){return $.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[$.jsx("span",{className:"sr-only",children:"Close"}),$.jsx("svg",{className:"size-6",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor","aria-hidden":"true",children:$.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const Qr=({modalContext:e,config:t,children:n})=>{const[r,l]=i.useState(!1);return $.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:$.jsx("div",{className:Ce("im-modal-positioner flex min-h-full justify-center",{"items-start":t.position==="top","items-center":t.position==="center","items-end":t.position==="bottom"}),children:$.jsx(oe,{as:"div",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Ce("im-modal-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Qt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},Rr=({modalContext:e,config:t,children:n})=>{const[r,l]=i.useState(!1);return $.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:$.jsx("div",{className:Ce("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(t==null?void 0:t.position)==="left","justify-end rtl:justify-start":(t==null?void 0:t.position)==="right"}),children:$.jsx(oe,{as:"div",enterFrom:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Ce("im-slideover-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Qt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},Rt=i.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:s=null,onAfterLeave:u=null,...a},o)=>{const c=x=>typeof t=="function"?t(x):t,m=i.useRef(null);return i.useImperativeHandle(o,()=>m.current,[m]),$.jsx(Ge,{ref:m,name:e,onFocus:n,onBlur:r,onClose:l,onSuccess:s,...a,children:({afterLeave:x,close:b,config:E,emit:f,getChildModal:g,getParentModal:d,id:p,index:h,isOpen:w,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})=>$.jsx(Zt,{appear:!0,show:w??!1,afterLeave:u,children:$.jsxs(Jr,{as:"div",className:"im-dialog relative z-20",onClose:()=>E.closeExplicitly?null:b(),"data-inertiaui-modal-id":p,"data-inertiaui-modal-index":h,children:[h===0?$.jsx(oe,{enter:"transition transform ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition transform ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):$.jsx("div",{})}):null,h>0&&v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,E.slideover?$.jsx(Rr,{modalContext:y,config:E,children:c({afterLeave:x,close:b,config:E,emit:f,getChildModal:g,getParentModal:d,id:p,index:h,isOpen:w,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})}):$.jsx(Qr,{modalContext:y,config:E,children:c({afterLeave:x,close:b,config:E,emit:f,getChildModal:g,getParentModal:d,id:p,index:h,isOpen:w,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})})]})})})});Rt.displayName="Modal";const el=({href:e,method:t="get",data:n={},as:r="a",headers:l={},queryStringArrayFormat:s="brackets",onAfterLeave:u=null,onBlur:a=null,onClose:o=null,onError:c=null,onFocus:m=null,onStart:x=null,onSuccess:b=null,navigate:E=null,children:f,...g})=>{const[d,p]=i.useState(!1),[h,w]=i.useState(null),{stack:y,visit:v}=ce(),M=i.useMemo(()=>E??$e("navigate"),[E]),T={},I={};Object.keys(g).forEach(S=>{pt.includes(S)||(S.startsWith("on")&&typeof g[S]=="function"?S.toLowerCase()in window?T[S]=g[S]:I[S]=g[S]:T[S]=g[S])});const[H,F]=i.useState(!1);i.useEffect(()=>{h&&(h.onTopOfStack&&H?m==null||m():!h.onTopOfStack&&!H&&(a==null||a()),F(!h.onTopOfStack))},[y]);const A=i.useCallback(()=>{o==null||o()},[o]),U=i.useCallback(()=>{w(null),u==null||u()},[u]),W=i.useCallback(S=>{S==null||S.preventDefault(),!d&&(e.startsWith("#")||(p(!0),x==null||x()),v(e,t,n,l,un(dt(g,pt)),()=>A(y.length),U,s,M).then(_=>{w(_),_.registerEventListenersFromProps(I),b==null||b()}).catch(_=>{console.error(_),c==null||c(_)}).finally(()=>p(!1)))},[e,t,n,l,s,g,A,U]);return $.jsx(r,{...T,href:e,onClick:W,children:typeof f=="function"?f({loading:d}):f})};function tl(){return ce().stack[ze()]??null}const nl=e=>t=>(t.default.layout=n=>i.createElement(e,{},n),t);C.HeadlessModal=Ge,C.Modal=Rt,C.ModalLink=el,C.ModalRoot=vt,C.ModalStackProvider=mt,C.getConfig=$e,C.initFromPageProps=ht,C.putConfig=on,C.renderApp=dn,C.resetConfig=ln,C.setPageLayout=nl,C.useModal=tl,C.useModalIndex=ze,C.useModalStack=ce,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
4
+ `))}else{let b=m.props,y=b==null?void 0:b.className,f=typeof y=="function"?(...p)=>Je(y(...p),o.className):Je(y,o.className),g=f?{className:f}:{},d=xt(m.props,ee(Qe(o,["ref"])));for(let p in x)p in d&&delete x[p];return i.cloneElement(m,Object.assign({},d,x,c,{ref:l(xn(m),c.ref)},g))}return i.createElement(s,Object.assign({},Qe(o,["ref"]),s!==i.Fragment&&c,s!==i.Fragment&&x),m)}function wn(){let e=i.useRef([]),t=i.useCallback(n=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return e.current=n,t}}function yn(...e){return e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}function xt(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let l in r)l.startsWith("on")&&typeof r[l]=="function"?(n[l]!=null||(n[l]=[]),n[l].push(r[l])):t[l]=r[l];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[l=>{var s;return(s=l==null?void 0:l.preventDefault)==null?void 0:s.call(l)}]);for(let r in n)Object.assign(t,{[r](l,...s){let u=n[r];for(let a of u){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;a(l,...s)}}});return t}function k(e){var t;return Object.assign(i.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function ee(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function Qe(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function xn(e){return i.version.split(".")[0]>="19"?e.props.ref:e.ref}let En="span";var Le=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Le||{});function bn(e,t){var n;let{features:r=1,...l}=e,s={ref:t,"aria-hidden":(r&2)===2?!0:(n=l["aria-hidden"])!=null?n:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return D()({ourProps:s,theirProps:l,slot:{},defaultTag:En,name:"Hidden"})}let Re=k(bn),Et=Symbol();function $n(e,t=!0){return Object.assign(e,{[Et]:t})}function q(...e){let t=i.useRef(e);i.useEffect(()=>{t.current=e},[e]);let n=O(r=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(r):l.current=r)});return e.every(r=>r==null||(r==null?void 0:r[Et]))?void 0:n}let et=i.createContext(null);et.displayName="DescriptionContext";function bt(){let e=i.useContext(et);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,bt),t}return e}function Mn(){let[e,t]=i.useState([]);return[e.length>0?e.join(" "):void 0,i.useMemo(()=>function(n){let r=O(s=>(t(u=>[...u,s]),()=>t(u=>{let a=u.slice(),o=a.indexOf(s);return o!==-1&&a.splice(o,1),a}))),l=i.useMemo(()=>({register:r,slot:n.slot,name:n.name,props:n.props,value:n.value}),[r,n.slot,n.name,n.props,n.value]);return i.createElement(et.Provider,{value:l},n.children)},[t])]}let Cn="p";function Sn(e,t){let n=i.useId(),r=vn(),{id:l=`headlessui-description-${n}`,...s}=e,u=bt(),a=q(t);L(()=>u.register(l),[l,u.register]);let o=r||!1,c=i.useMemo(()=>({...u.slot,disabled:o}),[u.slot,o]),m={ref:a,...u.props,id:l};return D()({ourProps:m,theirProps:s,slot:c,defaultTag:Cn,name:u.name||"Description"})}let On=k(Sn),Pn=Object.assign(On,{});var $t=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))($t||{});let Tn=i.createContext(()=>{});function Fn({value:e,children:t}){return i.createElement(Tn.Provider,{value:e},t)}let Ln=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function Mt(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(l){return r.add(l),()=>r.delete(l)},dispatch(l,...s){let u=t[l].call(n,...s);u&&(n=u,r.forEach(a=>a()))}}}function Ct(e){return i.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let kn=new Ln(()=>Mt(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function ie(e,t){let n=kn.get(t),r=i.useId(),l=Ct(n);if(L(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let s=l.indexOf(r),u=l.length;return s===-1&&(s=u,u+=1),s===u-1}let tt=new Map,fe=new Map;function St(e){var t;let n=(t=fe.get(e))!=null?t:0;return fe.set(e,n+1),n!==0?()=>Ot(e):(tt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Ot(e))}function Ot(e){var t;let n=(t=fe.get(e))!=null?t:1;if(n===1?fe.delete(e):fe.set(e,n-1),n!==1)return;let r=tt.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,tt.delete(e))}function Nn(e,{allowed:t,disallowed:n}={}){let r=ie(e,"inert-others");L(()=>{var l,s;if(!r)return;let u=G();for(let o of(l=n==null?void 0:n())!=null?l:[])o&&u.add(St(o));let a=(s=t==null?void 0:t())!=null?s:[];for(let o of a){if(!o)continue;let c=Oe(o);if(!c)continue;let m=o.parentElement;for(;m&&m!==c.body;){for(let x of m.children)a.some(b=>x.contains(b))||u.add(St(x));m=m.parentElement}}return u.dispose},[r,t,n])}function An(e,t,n){let r=R(l=>{let s=l.getBoundingClientRect();s.x===0&&s.y===0&&s.width===0&&s.height===0&&n()});i.useEffect(()=>{if(!e)return;let l=t===null?null:t instanceof HTMLElement?t:t.current;if(!l)return;let s=G();if(typeof ResizeObserver<"u"){let u=new ResizeObserver(()=>r.current(l));u.observe(l),s.add(()=>u.disconnect())}if(typeof IntersectionObserver<"u"){let u=new IntersectionObserver(()=>r.current(l));u.observe(l),s.add(()=>u.disconnect())}return()=>s.dispose()},[t,r,e])}let ke=["[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(","),In=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var V=(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[e.AutoFocus=64]="AutoFocus",e))(V||{}),nt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(nt||{}),Dn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(Dn||{});function jn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(ke)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function Un(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(In)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Pt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Pt||{});function Hn(e,t=0){var n;return e===((n=Oe(e))==null?void 0:n.body)?!1:K(t,{0(){return e.matches(ke)},1(){let r=e;for(;r!==null;){if(r.matches(ke))return!0;r=r.parentElement}return!1}})}var Wn=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Wn||{});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 Y(e){e==null||e.focus({preventScroll:!0})}let _n=["textarea","input"].join(",");function Bn(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,_n))!=null?n:!1}function qn(e,t=n=>n){return e.slice().sort((n,r)=>{let l=t(n),s=t(r);if(l===null||s===null)return 0;let u=l.compareDocumentPosition(s);return u&Node.DOCUMENT_POSITION_FOLLOWING?-1:u&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function me(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:l=[]}={}){let s=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,u=Array.isArray(e)?n?qn(e):e:t&64?Un(e):jn(e);l.length>0&&u.length>1&&(u=u.filter(y=>!l.some(f=>f!=null&&"current"in f?(f==null?void 0:f.current)===y:f===y))),r=r??s.activeElement;let a=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),o=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,u.indexOf(r))-1;if(t&4)return Math.max(0,u.indexOf(r))+1;if(t&8)return u.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=t&32?{preventScroll:!0}:{},m=0,x=u.length,b;do{if(m>=x||m+x<=0)return 0;let y=o+m;if(t&16)y=(y+x)%x;else{if(y<0)return 3;if(y>=x)return 1}b=u[y],b==null||b.focus(c),m+=a}while(b!==s.activeElement);return t&6&&Bn(b)&&b.select(),2}function Tt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function Xn(){return/Android/gi.test(window.navigator.userAgent)}function Vn(){return Tt()||Xn()}function pe(e,t,n,r){let l=R(n);i.useEffect(()=>{if(!e)return;function s(u){l.current(u)}return document.addEventListener(t,s,r),()=>document.removeEventListener(t,s,r)},[e,t,r])}function Ft(e,t,n,r){let l=R(n);i.useEffect(()=>{if(!e)return;function s(u){l.current(u)}return window.addEventListener(t,s,r),()=>window.removeEventListener(t,s,r)},[e,t,r])}const Lt=30;function Yn(e,t,n){let r=ie(e,"outside-click"),l=R(n),s=i.useCallback(function(o,c){if(o.defaultPrevented)return;let m=c(o);if(m===null||!m.getRootNode().contains(m)||!m.isConnected)return;let x=function b(y){return typeof y=="function"?b(y()):Array.isArray(y)||y instanceof Set?y:[y]}(t);for(let b of x)if(b!==null&&(b.contains(m)||o.composed&&o.composedPath().includes(b)))return;return!Hn(m,Pt.Loose)&&m.tabIndex!==-1&&o.preventDefault(),l.current(o,m)},[l,t]),u=i.useRef(null);pe(r,"pointerdown",o=>{var c,m;u.current=((m=(c=o.composedPath)==null?void 0:c.call(o))==null?void 0:m[0])||o.target},!0),pe(r,"mousedown",o=>{var c,m;u.current=((m=(c=o.composedPath)==null?void 0:c.call(o))==null?void 0:m[0])||o.target},!0),pe(r,"click",o=>{Vn()||u.current&&(s(o,()=>u.current),u.current=null)},!0);let a=i.useRef({x:0,y:0});pe(r,"touchstart",o=>{a.current.x=o.touches[0].clientX,a.current.y=o.touches[0].clientY},!0),pe(r,"touchend",o=>{let c={x:o.changedTouches[0].clientX,y:o.changedTouches[0].clientY};if(!(Math.abs(c.x-a.current.x)>=Lt||Math.abs(c.y-a.current.y)>=Lt))return s(o,()=>o.target instanceof HTMLElement?o.target:null)},!0),Ft(r,"blur",o=>s(o,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function he(...e){return i.useMemo(()=>Oe(...e),[...e])}function kt(e,t,n,r){let l=R(n);i.useEffect(()=>{e=e??window;function s(u){l.current(u)}return e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)},[e,t,r])}function zn(){let e;return{before({doc:t}){var n;let r=t.documentElement,l=(n=t.defaultView)!=null?n:window;e=Math.max(0,l.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,l=Math.max(0,r.clientWidth-r.offsetWidth),s=Math.max(0,e-l);n.style(r,"paddingRight",`${s}px`)}}}function Gn(){return Tt()?{before({doc:e,d:t,meta:n}){function r(l){return n.containers.flatMap(s=>s()).some(s=>s.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=G();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let s=(l=window.scrollY)!=null?l:window.pageYOffset,u=null;t.addEventListener(e,"click",a=>{if(a.target instanceof HTMLElement)try{let o=a.target.closest("a");if(!o)return;let{hash:c}=new URL(o.href),m=e.querySelector(c);m&&!r(m)&&(u=m)}catch{}},!0),t.addEventListener(e,"touchstart",a=>{if(a.target instanceof HTMLElement)if(r(a.target)){let o=a.target;for(;o.parentElement&&r(o.parentElement);)o=o.parentElement;t.style(o,"overscrollBehavior","contain")}else t.style(a.target,"touchAction","none")}),t.addEventListener(e,"touchmove",a=>{if(a.target instanceof HTMLElement){if(a.target.tagName==="INPUT")return;if(r(a.target)){let o=a.target;for(;o.parentElement&&o.dataset.headlessuiPortal!==""&&!(o.scrollHeight>o.clientHeight||o.scrollWidth>o.clientWidth);)o=o.parentElement;o.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let o=(a=window.scrollY)!=null?a:window.pageYOffset;s!==o&&window.scrollTo(0,s),u&&u.isConnected&&(u.scrollIntoView({block:"nearest"}),u=null)})})}}:{}}function Kn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Zn(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let te=Mt(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:G(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:Zn(n)},l=[Gn(),zn(),Kn()];l.forEach(({before:s})=>s==null?void 0:s(r)),l.forEach(({after:s})=>s==null?void 0:s(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});te.subscribe(()=>{let e=te.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",l=n.count!==0;(l&&!r||!l&&r)&&te.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&te.dispatch("TEARDOWN",n)}});function Jn(e,t,n=()=>({containers:[]})){let r=Ct(te),l=t?r.get(t):void 0,s=l?l.count>0:!1;return L(()=>{if(!(!t||!e))return te.dispatch("PUSH",t,n),()=>te.dispatch("POP",t,n)},[e,t]),s}function Qn(e,t,n=()=>[document.body]){let r=ie(e,"scroll-lock");Jn(r,t,l=>{var s;return{containers:[...(s=l.containers)!=null?s:[],n]}})}function Rn(e=0){let[t,n]=i.useState(e),r=i.useCallback(o=>n(o),[t]),l=i.useCallback(o=>n(c=>c|o),[t]),s=i.useCallback(o=>(t&o)===o,[t]),u=i.useCallback(o=>n(c=>c&~o),[n]),a=i.useCallback(o=>n(c=>c^o),[n]);return{flags:t,setFlag:r,addFlag:l,hasFlag:s,removeFlag:u,toggleFlag:a}}var Nt,At;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Nt=process==null?void 0:process.env)==null?void 0:Nt.NODE_ENV)==="test"&&typeof((At=Element==null?void 0:Element.prototype)==null?void 0:At.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
5
+ `)),[]});var er=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(er||{});function tr(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function nr(e,t,n,r){let[l,s]=i.useState(n),{hasFlag:u,addFlag:a,removeFlag:o}=Rn(e&&l?3:0),c=i.useRef(!1),m=i.useRef(!1),x=Ze();return L(()=>{var b;if(e){if(n&&s(!0),!t){n&&a(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,n),rr(t,{inFlight:c,prepare(){m.current?m.current=!1:m.current=c.current,c.current=!0,!m.current&&(n?(a(3),o(4)):(a(4),o(2)))},run(){m.current?n?(o(3),a(4)):(o(4),a(3)):n?o(1):a(1)},done(){var y;m.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,o(7),n||s(!1),(y=r==null?void 0:r.end)==null||y.call(r,n))}})}},[e,n,t,x]),e?[l,{closed:u(1),enter:u(2),leave:u(4),transition:u(2)||u(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function rr(e,{prepare:t,run:n,done:r,inFlight:l}){let s=G();return ir(e,{prepare:t,inFlight:l}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(lr(e,r))})}),s.dispose}function lr(e,t){var n,r;let l=G();if(!e)return l.dispose;let s=!1;l.add(()=>{s=!0});let u=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return u.length===0?(t(),l.dispose):(Promise.allSettled(u.map(a=>a.finished)).then(()=>{s||t()}),l.dispose)}function ir(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function rt(e,t){let n=i.useRef([]),r=O(e);i.useEffect(()=>{let l=[...n.current];for(let[s,u]of t.entries())if(n.current[s]!==u){let a=r(t,l);return n.current=t,a}},[r,...t])}let Ne=i.createContext(null);Ne.displayName="OpenClosedContext";var j=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(j||{});function Ae(){return i.useContext(Ne)}function or({value:e,children:t}){return i.createElement(Ne.Provider,{value:e},t)}function sr({children:e}){return i.createElement(Ne.Provider,{value:null},e)}function ur(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let J=[];ur(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||J[0]===t.target)return;let n=t.target;n=n.closest(ke),J.unshift(n??t.target),J=J.filter(r=>r!=null&&r.isConnected),J.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})});function It(e){let t=O(e),n=i.useRef(!1);i.useEffect(()=>(n.current=!1,()=>{n.current=!0,Pe(()=>{n.current&&t()})}),[t])}function ar(){let e=typeof document>"u";return"useSyncExternalStore"in se?(t=>t.useSyncExternalStore)(se)(()=>()=>{},()=>!1,()=>!e):!1}function ve(){let e=ar(),[t,n]=se.useState(Q.isHandoffComplete);return t&&Q.isHandoffComplete===!1&&n(!1),se.useEffect(()=>{t!==!0&&n(!0)},[t]),se.useEffect(()=>Q.handoff(),[]),e?!1:t}let Dt=i.createContext(!1);function dr(){return i.useContext(Dt)}function jt(e){return i.createElement(Dt.Provider,{value:e.force},e.children)}function cr(e){let t=dr(),n=i.useContext(Ht),r=he(e),[l,s]=i.useState(()=>{var u;if(!t&&n!==null)return(u=n.current)!=null?u:null;if(Q.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let o=r.createElement("div");return o.setAttribute("id","headlessui-portal-root"),r.body.appendChild(o)});return i.useEffect(()=>{l!==null&&(r!=null&&r.body.contains(l)||r==null||r.body.appendChild(l))},[l,r]),i.useEffect(()=>{t||n!==null&&s(n.current)},[n,s,t]),l}let Ut=i.Fragment,fr=k(function(e,t){let n=e,r=i.useRef(null),l=q($n(x=>{r.current=x}),t),s=he(r),u=cr(r),[a]=i.useState(()=>{var x;return Q.isServer?null:(x=s==null?void 0:s.createElement("div"))!=null?x:null}),o=i.useContext(lt),c=ve();L(()=>{!u||!a||u.contains(a)||(a.setAttribute("data-headlessui-portal",""),u.appendChild(a))},[u,a]),L(()=>{if(a&&o)return o.register(a)},[o,a]),It(()=>{var x;!u||!a||(a instanceof Node&&u.contains(a)&&u.removeChild(a),u.childNodes.length<=0&&((x=u.parentElement)==null||x.removeChild(u)))});let m=D();return c?!u||!a?null:nn.createPortal(m({ourProps:{ref:l},theirProps:n,slot:{},defaultTag:Ut,name:"Portal"}),a):null});function mr(e,t){let n=q(t),{enabled:r=!0,...l}=e,s=D();return r?i.createElement(fr,{...l,ref:n}):s({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:Ut,name:"Portal"})}let pr=i.Fragment,Ht=i.createContext(null);function hr(e,t){let{target:n,...r}=e,l={ref:q(t)},s=D();return i.createElement(Ht.Provider,{value:n},s({ourProps:l,theirProps:r,defaultTag:pr,name:"Popover.Group"}))}let lt=i.createContext(null);function vr(){let e=i.useContext(lt),t=i.useRef([]),n=O(s=>(t.current.push(s),e&&e.register(s),()=>r(s))),r=O(s=>{let u=t.current.indexOf(s);u!==-1&&t.current.splice(u,1),e&&e.unregister(s)}),l=i.useMemo(()=>({register:n,unregister:r,portals:t}),[n,r,t]);return[t,i.useMemo(()=>function({children:s}){return i.createElement(lt.Provider,{value:l},s)},[l])]}let gr=k(mr),Wt=k(hr),wr=Object.assign(gr,{Group:Wt});function yr(e,t=typeof document<"u"?document.defaultView:null,n){let r=ie(e,"escape");kt(t,"keydown",l=>{r&&(l.defaultPrevented||l.key===$t.Escape&&n(l))})}function xr(){var e;let[t]=i.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,r]=i.useState((e=t==null?void 0:t.matches)!=null?e:!1);return L(()=>{if(!t)return;function l(s){r(s.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),n}function Er({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=he(n),l=O(()=>{var s,u;let a=[];for(let o of e)o!==null&&(o instanceof HTMLElement?a.push(o):"current"in o&&o.current instanceof HTMLElement&&a.push(o.current));if(t!=null&&t.current)for(let o of t.current)a.push(o);for(let o of(s=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?s:[])o!==document.body&&o!==document.head&&o instanceof HTMLElement&&o.id!=="headlessui-portal-root"&&(n&&(o.contains(n)||o.contains((u=n==null?void 0:n.getRootNode())==null?void 0:u.host))||a.some(c=>o.contains(c))||a.push(o));return a});return{resolveContainers:l,contains:O(s=>l().some(u=>u.contains(s)))}}let _t=i.createContext(null);function Bt({children:e,node:t}){let[n,r]=i.useState(null),l=qt(t??n);return i.createElement(_t.Provider,{value:l},e,l===null&&i.createElement(Re,{features:Le.Hidden,ref:s=>{var u,a;if(s){for(let o of(a=(u=Oe(s))==null?void 0:u.querySelectorAll("html > *, body > *"))!=null?a:[])if(o!==document.body&&o!==document.head&&o instanceof HTMLElement&&o!=null&&o.contains(s)){r(o);break}}}}))}function qt(e=null){var t;return(t=i.useContext(_t))!=null?t:e}function it(){let e=i.useRef(!1);return L(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var ge=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(ge||{});function br(){let e=i.useRef(0);return Ft(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function Xt(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let n of e.current)n.current instanceof HTMLElement&&t.add(n.current);return t}let $r="div";var ne=(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))(ne||{});function Mr(e,t){let n=i.useRef(null),r=q(n,t),{initialFocus:l,initialFocusFallback:s,containers:u,features:a=15,...o}=e;ve()||(a=0);let c=he(n);Pr(a,{ownerDocument:c});let m=Tr(a,{ownerDocument:c,container:n,initialFocus:l,initialFocusFallback:s});Fr(a,{ownerDocument:c,container:n,containers:u,previousActiveElement:m});let x=br(),b=O(h=>{let w=n.current;w&&(E=>E())(()=>{K(x.current,{[ge.Forwards]:()=>{me(w,V.First,{skipElements:[h.relatedTarget,s]})},[ge.Backwards]:()=>{me(w,V.Last,{skipElements:[h.relatedTarget,s]})}})})}),y=ie(!!(a&2),"focus-trap#tab-lock"),f=Ze(),g=i.useRef(!1),d={ref:r,onKeyDown(h){h.key=="Tab"&&(g.current=!0,f.requestAnimationFrame(()=>{g.current=!1}))},onBlur(h){if(!(a&4))return;let w=Xt(u);n.current instanceof HTMLElement&&w.add(n.current);let E=h.relatedTarget;E instanceof HTMLElement&&E.dataset.headlessuiFocusGuard!=="true"&&(Vt(w,E)||(g.current?me(n.current,K(x.current,{[ge.Forwards]:()=>V.Next,[ge.Backwards]:()=>V.Previous})|V.WrapAround,{relativeTo:h.target}):h.target instanceof HTMLElement&&Y(h.target)))}},p=D();return i.createElement(i.Fragment,null,y&&i.createElement(Re,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}),p({ourProps:d,theirProps:o,defaultTag:$r,name:"FocusTrap"}),y&&i.createElement(Re,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}))}let Cr=k(Mr),Sr=Object.assign(Cr,{features:ne});function Or(e=!0){let t=i.useRef(J.slice());return rt(([n],[r])=>{r===!0&&n===!1&&Pe(()=>{t.current.splice(0)}),r===!1&&n===!0&&(t.current=J.slice())},[e,J,t]),O(()=>{var n;return(n=t.current.find(r=>r!=null&&r.isConnected))!=null?n:null})}function Pr(e,{ownerDocument:t}){let n=!!(e&8),r=Or(n);rt(()=>{n||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(r())},[n]),It(()=>{n&&Y(r())})}function Tr(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:l}){let s=i.useRef(null),u=ie(!!(e&1),"focus-trap#initial-focus"),a=it();return rt(()=>{if(e===0)return;if(!u){l!=null&&l.current&&Y(l.current);return}let o=n.current;o&&Pe(()=>{if(!a.current)return;let c=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===c){s.current=c;return}}else if(o.contains(c)){s.current=c;return}if(r!=null&&r.current)Y(r.current);else{if(e&16){if(me(o,V.First|V.AutoFocus)!==nt.Error)return}else if(me(o,V.First)!==nt.Error)return;if(l!=null&&l.current&&(Y(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}s.current=t==null?void 0:t.activeElement})},[l,u,e]),s}function Fr(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:l}){let s=it(),u=!!(e&4);kt(t==null?void 0:t.defaultView,"focus",a=>{if(!u||!s.current)return;let o=Xt(r);n.current instanceof HTMLElement&&o.add(n.current);let c=l.current;if(!c)return;let m=a.target;m&&m instanceof HTMLElement?Vt(o,m)?(l.current=m,Y(m)):(a.preventDefault(),a.stopPropagation(),Y(c)):Y(l.current)},!0)}function Vt(e,t){for(let n of e)if(n.contains(t))return!0;return!1}function Yt(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:Gt)!==i.Fragment||i.Children.count(e.children)===1}let Ie=i.createContext(null);Ie.displayName="TransitionContext";var Lr=(e=>(e.Visible="visible",e.Hidden="hidden",e))(Lr||{});function kr(){let e=i.useContext(Ie);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function Nr(){let e=i.useContext(De);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let De=i.createContext(null);De.displayName="NestingContext";function je(e){return"children"in e?je(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function zt(e,t){let n=R(e),r=i.useRef([]),l=it(),s=Ze(),u=O((y,f=Z.Hidden)=>{let g=r.current.findIndex(({el:d})=>d===y);g!==-1&&(K(f,{[Z.Unmount](){r.current.splice(g,1)},[Z.Hidden](){r.current[g].state="hidden"}}),s.microTask(()=>{var d;!je(r)&&l.current&&((d=n.current)==null||d.call(n))}))}),a=O(y=>{let f=r.current.find(({el:g})=>g===y);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:y,state:"visible"}),()=>u(y,Z.Unmount)}),o=i.useRef([]),c=i.useRef(Promise.resolve()),m=i.useRef({enter:[],leave:[]}),x=O((y,f,g)=>{o.current.splice(0),t&&(t.chains.current[f]=t.chains.current[f].filter(([d])=>d!==y)),t==null||t.chains.current[f].push([y,new Promise(d=>{o.current.push(d)})]),t==null||t.chains.current[f].push([y,new Promise(d=>{Promise.all(m.current[f].map(([p,h])=>h)).then(()=>d())})]),f==="enter"?c.current=c.current.then(()=>t==null?void 0:t.wait.current).then(()=>g(f)):g(f)}),b=O((y,f,g)=>{Promise.all(m.current[f].splice(0).map(([d,p])=>p)).then(()=>{var d;(d=o.current.shift())==null||d()}).then(()=>g(f))});return i.useMemo(()=>({children:r,register:a,unregister:u,onStart:x,onStop:b,wait:c,chains:m}),[a,u,r,x,b,m,c])}let Gt=i.Fragment,Kt=Te.RenderStrategy;function Ar(e,t){var n,r;let{transition:l=!0,beforeEnter:s,afterEnter:u,beforeLeave:a,afterLeave:o,enter:c,enterFrom:m,enterTo:x,entered:b,leave:y,leaveFrom:f,leaveTo:g,...d}=e,[p,h]=i.useState(null),w=i.useRef(null),E=Yt(e),v=q(...E?[w,t,h]:t===null?[]:[t]),M=(n=d.unmount)==null||n?Z.Unmount:Z.Hidden,{show:P,appear:A,initial:U}=kr(),[F,I]=i.useState(P?"visible":"hidden"),H=Nr(),{register:W,unregister:S}=H;L(()=>W(w),[W,w]),L(()=>{if(M===Z.Hidden&&w.current){if(P&&F!=="visible"){I("visible");return}return K(F,{hidden:()=>S(w),visible:()=>W(w)})}},[F,w,W,S,P,M]);let _=ve();L(()=>{if(E&&_&&F==="visible"&&w.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[w,F,_,E]);let He=U&&!A,We=A&&P&&U,we=i.useRef(!1),X=zt(()=>{we.current||(I("hidden"),S(w))},H),_e=O(at=>{we.current=!0;let qe=at?"enter":"leave";X.onStart(w,qe,xe=>{xe==="enter"?s==null||s():xe==="leave"&&(a==null||a())})}),T=O(at=>{let qe=at?"enter":"leave";we.current=!1,X.onStop(w,qe,xe=>{xe==="enter"?u==null||u():xe==="leave"&&(o==null||o())}),qe==="leave"&&!je(X)&&(I("hidden"),S(w))});i.useEffect(()=>{E&&l||(_e(P),T(P))},[P,E,l]);let Be=!(!l||!E||!_||He),[,N]=nr(Be,p,P,{start:_e,end:T}),ll=ee({ref:v,className:((r=Je(d.className,We&&c,We&&m,N.enter&&c,N.enter&&N.closed&&m,N.enter&&!N.closed&&x,N.leave&&y,N.leave&&!N.closed&&f,N.leave&&N.closed&&g,!N.transition&&P&&b))==null?void 0:r.trim())||void 0,...tr(N)}),ye=0;F==="visible"&&(ye|=j.Open),F==="hidden"&&(ye|=j.Closed),N.enter&&(ye|=j.Opening),N.leave&&(ye|=j.Closing);let il=D();return i.createElement(De.Provider,{value:X},i.createElement(or,{value:ye},il({ourProps:ll,theirProps:d,defaultTag:Gt,features:Kt,visible:F==="visible",name:"Transition.Child"})))}function Ir(e,t){let{show:n,appear:r=!1,unmount:l=!0,...s}=e,u=i.useRef(null),a=Yt(e),o=q(...a?[u,t]:t===null?[]:[t]);ve();let c=Ae();if(n===void 0&&c!==null&&(n=(c&j.Open)===j.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[m,x]=i.useState(n?"visible":"hidden"),b=zt(()=>{n||x("hidden")}),[y,f]=i.useState(!0),g=i.useRef([n]);L(()=>{y!==!1&&g.current[g.current.length-1]!==n&&(g.current.push(n),f(!1))},[g,n]);let d=i.useMemo(()=>({show:n,appear:r,initial:y}),[n,r,y]);L(()=>{n?x("visible"):!je(b)&&u.current!==null&&x("hidden")},[n,b]);let p={unmount:l},h=O(()=>{var v;y&&f(!1),(v=e.beforeEnter)==null||v.call(e)}),w=O(()=>{var v;y&&f(!1),(v=e.beforeLeave)==null||v.call(e)}),E=D();return i.createElement(De.Provider,{value:b},i.createElement(Ie.Provider,{value:d},E({ourProps:{...p,as:i.Fragment,children:i.createElement(Zt,{ref:o,...p,...s,beforeEnter:h,beforeLeave:w})},theirProps:{},defaultTag:i.Fragment,features:Kt,visible:m==="visible",name:"Transition"})))}function Dr(e,t){let n=i.useContext(Ie)!==null,r=Ae()!==null;return i.createElement(i.Fragment,null,!n&&r?i.createElement(ot,{ref:t,...e}):i.createElement(Zt,{ref:t,...e}))}let ot=k(Ir),Zt=k(Ar),oe=k(Dr),Jt=Object.assign(ot,{Child:oe,Root:ot});var jr=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(jr||{}),Ur=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Ur||{});let Hr={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},st=i.createContext(null);st.displayName="DialogContext";function Ue(e){let t=i.useContext(st);if(t===null){let n=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ue),n}return t}function Wr(e,t){return K(t.type,Hr,e,t)}let Qt=k(function(e,t){let n=i.useId(),{id:r=`headlessui-dialog-${n}`,open:l,onClose:s,initialFocus:u,role:a="dialog",autoFocus:o=!0,__demoMode:c=!1,unmount:m=!1,...x}=e,b=i.useRef(!1);a=function(){return a==="dialog"||a==="alertdialog"?a:(b.current||(b.current=!0,console.warn(`Invalid role [${a}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let y=Ae();l===void 0&&y!==null&&(l=(y&j.Open)===j.Open);let f=i.useRef(null),g=q(f,t),d=he(f),p=l?0:1,[h,w]=i.useReducer(Wr,{titleId:null,descriptionId:null,panelRef:i.createRef()}),E=O(()=>s(!1)),v=O(T=>w({type:0,id:T})),M=ve()?p===0:!1,[P,A]=vr(),U={get current(){var T;return(T=h.panelRef.current)!=null?T:f.current}},F=qt(),{resolveContainers:I}=Er({mainTreeNode:F,portals:P,defaultContainers:[U]}),H=y!==null?(y&j.Closing)===j.Closing:!1;Nn(c||H?!1:M,{allowed:O(()=>{var T,Be;return[(Be=(T=f.current)==null?void 0:T.closest("[data-headlessui-portal]"))!=null?Be:null]}),disallowed:O(()=>{var T;return[(T=F==null?void 0:F.closest("body > *:not(#headlessui-portal-root)"))!=null?T:null]})}),Yn(M,I,T=>{T.preventDefault(),E()}),yr(M,d==null?void 0:d.defaultView,T=>{T.preventDefault(),T.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),E()}),Qn(c||H?!1:M,d,I),An(M,f,E);let[W,S]=Mn(),_=i.useMemo(()=>[{dialogState:p,close:E,setTitleId:v,unmount:m},h],[p,h,E,v,m]),He=i.useMemo(()=>({open:p===0}),[p]),We={ref:g,id:r,role:a,tabIndex:-1,"aria-modal":c?void 0:p===0?!0:void 0,"aria-labelledby":h.titleId,"aria-describedby":W,unmount:m},we=!xr(),X=ne.None;M&&!c&&(X|=ne.RestoreFocus,X|=ne.TabLock,o&&(X|=ne.AutoFocus),we&&(X|=ne.InitialFocus));let _e=D();return i.createElement(sr,null,i.createElement(jt,{force:!0},i.createElement(wr,null,i.createElement(st.Provider,{value:_},i.createElement(Wt,{target:f},i.createElement(jt,{force:!1},i.createElement(S,{slot:He},i.createElement(A,null,i.createElement(Sr,{initialFocus:u,initialFocusFallback:f,containers:I,features:X},i.createElement(Fn,{value:E},_e({ourProps:We,theirProps:x,slot:He,defaultTag:_r,features:Br,visible:p===0,name:"Dialog"})))))))))))}),_r="div",Br=Te.RenderStrategy|Te.Static;function qr(e,t){let{transition:n=!1,open:r,...l}=e,s=Ae(),u=e.hasOwnProperty("open")||s!==null,a=e.hasOwnProperty("onClose");if(!u&&!a)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!u)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!a)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!s&&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)&&!l.static?i.createElement(Bt,null,i.createElement(Jt,{show:r,transition:n,unmount:l.unmount},i.createElement(Qt,{ref:t,...l}))):i.createElement(Bt,null,i.createElement(Qt,{ref:t,open:r,...l}))}let Xr="div";function Vr(e,t){let n=i.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:l=!1,...s}=e,[{dialogState:u,unmount:a},o]=Ue("Dialog.Panel"),c=q(t,o.panelRef),m=i.useMemo(()=>({open:u===0}),[u]),x=O(d=>{d.stopPropagation()}),b={ref:c,id:r,onClick:x},y=l?oe:i.Fragment,f=l?{unmount:a}:{},g=D();return i.createElement(y,{...f},g({ourProps:b,theirProps:s,slot:m,defaultTag:Xr,name:"Dialog.Panel"}))}let Yr="div";function zr(e,t){let{transition:n=!1,...r}=e,[{dialogState:l,unmount:s}]=Ue("Dialog.Backdrop"),u=i.useMemo(()=>({open:l===0}),[l]),a={ref:t,"aria-hidden":!0},o=n?oe:i.Fragment,c=n?{unmount:s}:{},m=D();return i.createElement(o,{...c},m({ourProps:a,theirProps:r,slot:u,defaultTag:Yr,name:"Dialog.Backdrop"}))}let Gr="h2";function Kr(e,t){let n=i.useId(),{id:r=`headlessui-dialog-title-${n}`,...l}=e,[{dialogState:s,setTitleId:u}]=Ue("Dialog.Title"),a=q(t);i.useEffect(()=>(u(r),()=>u(null)),[r,u]);let o=i.useMemo(()=>({open:s===0}),[s]),c={ref:a,id:r};return D()({ourProps:c,theirProps:l,slot:o,defaultTag:Gr,name:"Dialog.Title"})}let Zr=k(qr),ut=k(Vr);k(zr);let Jr=k(Kr),Qr=Object.assign(Zr,{Panel:ut,Title:Jr,Description:Pn});function Rt({onClick:e}){return $.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[$.jsx("span",{className:"sr-only",children:"Close"}),$.jsx("svg",{className:"size-6",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor","aria-hidden":"true",children:$.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const Rr=({modalContext:e,config:t,children:n})=>{const[r,l]=i.useState(!1);return $.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:$.jsx("div",{className:Se("im-modal-positioner flex min-h-full justify-center",{"items-start":t.position==="top","items-center":t.position==="center","items-end":t.position==="bottom"}),children:$.jsx(oe,{as:"div",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Se("im-modal-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Rt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},el=({modalContext:e,config:t,children:n})=>{const[r,l]=i.useState(!1);return $.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:$.jsx("div",{className:Se("im-slideover-positioner flex min-h-full items-center",{"justify-start rtl:justify-end":(t==null?void 0:t.position)==="left","justify-end rtl:justify-start":(t==null?void 0:t.position)==="right"}),children:$.jsx(oe,{as:"div",enterFrom:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,enterTo:"opacity-100 translate-x-0",leaveFrom:"opacity-100 translate-x-0",leaveTo:`opacity-0 ${t.position==="left"?"-translate-x-full":"translate-x-full"}`,afterEnter:()=>l(!0),afterLeave:e.afterLeave,className:Se("im-slideover-wrapper w-full transition duration-300 ease-in-out",e.onTopOfStack?"":"blur-sm",{"sm:max-w-sm":t.maxWidth==="sm","sm:max-w-md":t.maxWidth==="md","sm:max-w-md md:max-w-lg":t.maxWidth==="lg","sm:max-w-md md:max-w-xl":t.maxWidth==="xl","sm:max-w-md md:max-w-xl lg:max-w-2xl":t.maxWidth==="2xl","sm:max-w-md md:max-w-xl lg:max-w-3xl":t.maxWidth==="3xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-4xl":t.maxWidth==="4xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl":t.maxWidth==="5xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl":t.maxWidth==="6xl","sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl":t.maxWidth==="7xl"}),children:$.jsxs(ut,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":r,children:[t.closeButton&&$.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:$.jsx(Rt,{onClick:e.close})}),typeof n=="function"?n({modalContext:e,config:t}):n]})})})})},en=i.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:s=null,onAfterLeave:u=null,...a},o)=>{const c=x=>typeof t=="function"?t(x):t,m=i.useRef(null);return i.useImperativeHandle(o,()=>m.current,[m]),$.jsx(Ge,{ref:m,name:e,onFocus:n,onBlur:r,onClose:l,onSuccess:s,...a,children:({afterLeave:x,close:b,config:y,emit:f,getChildModal:g,getParentModal:d,id:p,index:h,isOpen:w,modalContext:E,onTopOfStack:v,reload:M,setOpen:P,shouldRender:A})=>$.jsx(Jt,{appear:!0,show:w??!1,afterLeave:u,children:$.jsxs(Qr,{as:"div",className:"im-dialog relative z-20",onClose:()=>y.closeExplicitly?null:b(),"data-inertiaui-modal-id":p,"data-inertiaui-modal-index":h,children:[h===0?$.jsx(oe,{enter:"transition transform ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition transform ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):$.jsx("div",{})}):null,h>0&&v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,y.slideover?$.jsx(el,{modalContext:E,config:y,children:c({afterLeave:x,close:b,config:y,emit:f,getChildModal:g,getParentModal:d,id:p,index:h,isOpen:w,modalContext:E,onTopOfStack:v,reload:M,setOpen:P,shouldRender:A})}):$.jsx(Rr,{modalContext:E,config:y,children:c({afterLeave:x,close:b,config:y,emit:f,getChildModal:g,getParentModal:d,id:p,index:h,isOpen:w,modalContext:E,onTopOfStack:v,reload:M,setOpen:P,shouldRender:A})})]})})})});en.displayName="Modal";const tl=({href:e,method:t="get",data:n={},as:r="a",headers:l={},queryStringArrayFormat:s="brackets",onAfterLeave:u=null,onBlur:a=null,onClose:o=null,onError:c=null,onFocus:m=null,onStart:x=null,onSuccess:b=null,navigate:y=null,children:f,...g})=>{const[d,p]=i.useState(!1),[h,w]=i.useState(null),{stack:E,visit:v}=ce(),M=i.useMemo(()=>y??$e("navigate"),[y]),P={},A={};Object.keys(g).forEach(S=>{ht.includes(S)||(S.startsWith("on")&&typeof g[S]=="function"?S.toLowerCase()in window?P[S]=g[S]:A[S]=g[S]:P[S]=g[S])});const[U,F]=i.useState(!1);i.useEffect(()=>{h&&(h.onTopOfStack&&U?m==null||m():!h.onTopOfStack&&!U&&(a==null||a()),F(!h.onTopOfStack))},[E]);const I=i.useCallback(()=>{o==null||o()},[o]),H=i.useCallback(()=>{w(null),u==null||u()},[u]),W=i.useCallback(S=>{S==null||S.preventDefault(),!d&&(e.startsWith("#")||(p(!0),x==null||x()),v(e,t,n,l,an(ct(g,ht)),()=>I(E.length),H,s,M).then(_=>{w(_),_.registerEventListenersFromProps(A),b==null||b()}).catch(_=>{console.error(_),c==null||c(_)}).finally(()=>p(!1)))},[e,t,n,l,s,g,I,H]);return $.jsx(r,{...P,href:e,onClick:W,children:typeof f=="function"?f({loading:d}):f})};function nl(){return ce().stack[ze()]??null}const rl=e=>t=>(t.default.layout=n=>i.createElement(e,{},n),t);C.HeadlessModal=Ge,C.Modal=en,C.ModalLink=tl,C.ModalRoot=gt,C.ModalStackProvider=pt,C.getConfig=$e,C.initFromPageProps=vt,C.putConfig=sn,C.renderApp=cn,C.resetConfig=on,C.setPageLayout=rl,C.useModal=nl,C.useModalIndex=ze,C.useModalStack=ce,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inertiaui/modal-react",
3
3
  "author": "Pascal Baljet <pascal@protone.media>",
4
- "version": "0.19.0",
4
+ "version": "0.19.2",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "type": "module",
package/src/ModalRoot.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createElement, useEffect, useState, useRef } from 'react'
2
2
  import { default as Axios } from 'axios'
3
- import { except, only, kebabCase, generateId } from './helpers'
3
+ import { except, only, kebabCase, generateId, sameUrlPath } from './helpers'
4
4
  import { router, usePage } from '@inertiajs/react'
5
5
  import { mergeDataIntoQueryString } from '@inertiajs/core'
6
6
  import { createContext, useContext } from 'react'
@@ -397,6 +397,7 @@ export const ModalStackProvider = ({ children }) => {
397
397
  localModals,
398
398
  push,
399
399
  pushFromResponseData,
400
+ length: () => localStackCopy.length,
400
401
  closeAll: () => {
401
402
  localStackCopy.reverse().forEach((modal) => modal.close())
402
403
  },
@@ -474,6 +475,70 @@ export const ModalRoot = ({ children }) => {
474
475
  let isNavigating = false
475
476
  let previousModalOnBase = false
476
477
 
478
+ useEffect(
479
+ () =>
480
+ router.on('before', ($event) => {
481
+ if (!sameUrlPath(window.location.href, $event.detail.visit.url)) {
482
+ // Not navigating to the same base url
483
+ return true
484
+ }
485
+
486
+ if ($event.detail.visit.replace) {
487
+ // Prevent replacing again if we are already replacing
488
+ return true
489
+ }
490
+
491
+ if (context.length() !== 1) {
492
+ // Only replace the first modal
493
+ return true
494
+ }
495
+
496
+ if (!previousModalOnBase) {
497
+ // No modal on base
498
+ return true
499
+ }
500
+
501
+ const {
502
+ method,
503
+ data,
504
+ only,
505
+ except,
506
+ headers,
507
+ errorBag,
508
+ forceFormData,
509
+ queryStringArrayFormat,
510
+ async,
511
+ showProgress,
512
+ prefetch,
513
+ fresh,
514
+ reset,
515
+ preserveUrl,
516
+ } = $event.detail.visit
517
+
518
+ router.visit($event.detail.visit.url, {
519
+ replace: true,
520
+ preserveScroll: true,
521
+ preserveState: true,
522
+ method,
523
+ data,
524
+ only,
525
+ except,
526
+ headers,
527
+ errorBag,
528
+ forceFormData,
529
+ queryStringArrayFormat,
530
+ async,
531
+ showProgress,
532
+ prefetch,
533
+ fresh,
534
+ reset,
535
+ preserveUrl,
536
+ })
537
+
538
+ return false
539
+ }),
540
+ [],
541
+ )
477
542
  useEffect(() => router.on('start', () => (isNavigating = true)), [])
478
543
  useEffect(() => router.on('finish', () => (isNavigating = false)), [])
479
544
  useEffect(
@@ -533,7 +598,7 @@ export const ModalRoot = ({ children }) => {
533
598
  // Store the current value for the next render
534
599
  previousModalRef.current = newModal
535
600
 
536
- if (newModal && previousModal && newModal.component === previousModal.component && newModal.url === previousModal.url) {
601
+ if (newModal && previousModal && newModal.component === previousModal.component && sameUrlPath(newModal.url, previousModal.url)) {
537
602
  context.stack[0]?.updateProps(newModal.props ?? {})
538
603
  }
539
604
  }, [$page.props?._inertiaui_modal])
package/src/helpers.js CHANGED
@@ -1,2 +1,2 @@
1
- import { generateId, except, only, rejectNullValues, waitFor, kebabCase } from './../../vue/src/helpers.js'
2
- export { generateId, except, only, rejectNullValues, waitFor, kebabCase }
1
+ import { generateId, sameUrlPath, except, only, rejectNullValues, waitFor, kebabCase } from './../../vue/src/helpers.js'
2
+ export { generateId, sameUrlPath, except, only, rejectNullValues, waitFor, kebabCase }