@inertiaui/modal-react 0.20.5 → 1.0.0-beta-1
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.
- package/dist/inertiaui-modal.js +1539 -1243
- package/dist/inertiaui-modal.umd.cjs +20 -4
- package/package.json +1 -1
- package/src/Deferred.jsx +23 -0
- package/src/ModalRoot.jsx +50 -16
- package/src/WhenVisible.jsx +100 -0
- package/src/helpers.js +2 -2
- package/src/inertiauiModal.js +12 -8
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
(function(C,o){typeof exports=="object"&&typeof module<"u"?o(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"],o):(C=typeof globalThis<"u"?globalThis:C||self,o(C.InertiaUIModal={},C.React,C.jsxRuntime,C.Axios,C.react,C.core,C.ReactDOM))})(this,function(C,o,$,ye,ne,tn,nn){"use strict";var sl=Object.defineProperty;var al=(C,o,$)=>o in C?sl(C,o,{enumerable:!0,configurable:!0,writable:!0,value:$}):C[o]=$;var B=(C,o,$)=>al(C,typeof o!="symbol"?o+"":o,$);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 ue=rn(o),de={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(de))}put(t,n){if(typeof t=="object"){this.config={type:t.type??de.type,navigate:t.navigate??de.navigate,modal:{...de.modal,...t.modal??{}},slideover:{...de.slideover,...t.slideover??{}}};return}const r=t.split(".");let l=this.config;for(let i=0;i<r.length-1;i++)l=l[r[i]]=l[r[i]]||{};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 $e=new ln,on=()=>$e.reset(),sn=(e,t)=>$e.put(e,t),Me=e=>$e.get(e),re=(e,t)=>$e.get(e?`slideover.${t}`:`modal.${t}`);function an(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 le(e){return typeof e=="string"?e.toLowerCase():e}function un(e,t,n=!1){return n&&(t=t.map(le)),Array.isArray(e)?e.filter(r=>!t.includes(n?le(r):r)):Object.keys(e).reduce((r,l)=>(t.includes(n?le(l):l)||(r[l]=e[l]),r),{})}function ct(e,t,n=!1){return n&&(t=t.map(le)),Array.isArray(e)?e.filter(r=>t.includes(n?le(r):r)):Object.keys(e).reduce((r,l)=>(t.includes(n?le(l):l)&&(r[l]=e[l]),r),{})}function dn(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 cn(e,t=3,n=10){return new Promise((r,l)=>{const i=e();if(i){r(i);return}let a=t*1e3/n;const u=setInterval(()=>{const s=e();s&&(clearInterval(u),r(s)),--a<=0&&(clearInterval(u),l(new Error("Condition not met in time")))},n)})}function ce(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 Ce=o.createContext(null);Ce.displayName="ModalStackContext";let ft=null,mt=null,oe=null,Ve=null,Ye=[],ie={};const pt=({children:e})=>{const[t,n]=o.useState([]),[r,l]=o.useState({}),i=x=>{n(d=>{const m=x([...d]),p=E=>{var y;return m.length<2?!0:((y=m.map(v=>({id:v.id,shouldRender:v.shouldRender})).reverse().find(v=>v.shouldRender))==null?void 0:y.id)===E};return m.forEach((E,y)=>{m[y].onTopOfStack=p(E.id),m[y].getParentModal=()=>y<1?null:m.slice(0,y).reverse().find(v=>v.isOpen),m[y].getChildModal=()=>y===m.length-1?null:m.slice(y+1).find(v=>v.isOpen)}),m})};o.useEffect(()=>{Ye=t},[t]);class a{constructor(d,m,p,E,y){B(this,"show",()=>{i(d=>d.map(m=>(m.id===this.id&&!m.isOpen&&(m.isOpen=!0,m.shouldRender=!0),m)))});B(this,"setOpen",d=>{d?this.show():this.close()});B(this,"close",()=>{i(d=>d.map(m=>{var p;return m.id===this.id&&m.isOpen&&(Object.keys(m.listeners).forEach(E=>{m.off(E)}),m.isOpen=!1,(p=m.onCloseCallback)==null||p.call(m)),m}))});B(this,"afterLeave",()=>{this.isOpen||i(d=>{const m=d.map(p=>{var E;return p.id===this.id&&!p.isOpen&&(p.shouldRender=!1,(E=p.afterLeaveCallback)==null||E.call(p),p.afterLeaveCallback=null),p});return this.index===0?[]:m})});B(this,"on",(d,m)=>{d=ce(d),this.listeners[d]=this.listeners[d]??[],this.listeners[d].push(m)});B(this,"off",(d,m)=>{var p;d=ce(d),m?this.listeners[d]=((p=this.listeners[d])==null?void 0:p.filter(E=>E!==m))??[]:delete this.listeners[d]});B(this,"emit",(d,...m)=>{var p;(p=this.listeners[ce(d)])==null||p.forEach(E=>E(...m))});B(this,"registerEventListenersFromProps",d=>{const m=[];return Object.keys(d).filter(p=>p.startsWith("on")).forEach(p=>{const E=ce(p).replace(/^on-/,"");this.on(E,d[p]),m.push(()=>this.off(E,d[p]))}),()=>m.forEach(p=>p())});B(this,"reload",(d={})=>{var y;let m=Object.keys(this.response.props);if(d.only&&(m=ct(m,d.only)),d.except&&(m=un(m,d.except)),!((y=this.response)!=null&&y.url))return;const p=(d.method??"get").toLowerCase(),E=d.data??{};ye({url:this.response.url,method:p,data:p==="get"?{}:E,params:p==="get"?E:{},headers:{...d.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":m.join(","),"X-InertiaUI-Modal":Xe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":oe}}).then(v=>{this.updateProps(v.data.props)})});B(this,"updateProps",d=>{Object.assign(this.props,d),i(m=>m)});if(this.id=m.id??Xe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=d,this.props=m.props,this.response=m,this.config=p??{},this.onCloseCallback=E,this.afterLeaveCallback=y,ie[this.id]){this.config={...this.config,...ie[this.id].config??{}};const v=ie[this.id].onClose,M=ie[this.id].onAfterLeave;v&&(this.onCloseCallback=E?()=>{E(),v()}:v),M&&(this.afterLeaveCallback=y?()=>{y(),M()}:M),delete ie[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 u=(x,d={},m=null,p=null)=>mt(x.component).then(E=>s(E,x,d,m,p)),s=(x,d,m,p,E)=>{const y=new a(x,d,m,p,E);return y.index=t.length,i(v=>[...v,y]),y.show(),y};function h(x,d,m,p){if(!r[x])throw new Error(`The local modal "${x}" has not been registered.`);const E=s(null,{},d,m,p);return E.name=x,r[x].callback(E),E}const c=(x,d={})=>g(x,d.method??"get",d.data??{},d.headers??{},d.config??{},d.onClose,d.onAfterLeave,d.queryStringArrayFormat??"brackets",d.navigate??Me("navigate")).then(m=>{const p=d.listeners??{};return Object.keys(p).forEach(E=>{const y=ce(E);m.on(y,p[E])}),m}),g=(x,d,m={},p={},E={},y=null,v=null,M="brackets",T=!1)=>{const I=Xe();return new Promise((U,F)=>{if(x.startsWith("#")){U(h(x.substring(1),E,y,v));return}const[A,H]=tn.mergeDataIntoQueryString(d,x||"",m,M);let W=T&&t.length===0;if(t.length===0&&(oe=typeof window<"u"?window.location.href:""),p={...p,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":ft,"X-InertiaUI-Modal":I,"X-InertiaUI-Modal-Use-Router":W?1:0,"X-InertiaUI-Modal-Base-Url":oe},W)return Ve=null,ie[I]={config:E,onClose:y,onAfterLeave:v},ne.router.visit(A,{method:d,data:H,headers:p,preserveScroll:!0,preserveState:!0,onError:F,onFinish:()=>{cn(()=>Ve).then(U)}});ye({url:A,method:d,data:H,headers:p}).then(S=>U(u(S.data,E,y,v))).catch(S=>{F(S)})})},f={stack:t,localModals:r,push:s,pushFromResponseData:u,length:()=>Ye.length,closeAll:()=>{Ye.reverse().forEach(x=>x.close())},reset:()=>i(()=>[]),visit:g,visitModal:c,registerLocalModal:(x,d)=>{l(m=>({...m,[x]:{name:x,callback:d}}))},removeLocalModal:x=>{l(d=>{const m={...d};return delete m[x],m})}};return $.jsx(Ce.Provider,{value:f,children:e})},fe=()=>{const e=o.useContext(Ce);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)},fn=(e,t)=>{vt(t);const n=({Component:r,props:l,key:i})=>{const a=()=>{const u=o.createElement(r,{key:i,...l});return typeof r.layout=="function"?r.layout(u):Array.isArray(r.layout)?r.layout.concat(u).reverse().reduce((h,c)=>o.createElement(c,l,h)):u};return $.jsxs($.Fragment,{children:[a(),$.jsx(gt,{})]})};return $.jsx(pt,{children:$.jsx(e,{...t,children:n})})},gt=({children:e})=>{var s,h;const t=o.useContext(Ce),n=ne.usePage();let r=!1,l=!1,i=!!((s=n.props)!=null&&s._inertiaui_modal);o.useEffect(()=>ne.router.on("start",()=>r=!0),[]),o.useEffect(()=>ne.router.on("finish",()=>r=!1),[]),o.useEffect(()=>ne.router.on("navigate",function(c){const g=c.detail.page.props._inertiaui_modal;if(!g){l&&t.closeAll(),oe=null,i=!1;return}l=g,oe=g.baseUrl,t.pushFromResponseData(g,{},()=>{if(!g.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!r&&window.location.href!==g.baseUrl&&ne.router.visit(g.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(b=>{Ve=b})}),[]);const a=c=>{var g;return c.headers["X-InertiaUI-Modal-Base-Url"]=oe??(i?(g=n.props._inertiaui_modal)==null?void 0:g.baseUrl:null),c};o.useEffect(()=>(ye.interceptors.request.use(a),()=>ye.interceptors.request.eject(a)),[]);const u=o.useRef();return o.useEffect(()=>{var b,w;const c=(b=n.props)==null?void 0:b._inertiaui_modal,g=u.current;u.current=c,c&&g&&c.component===g.component&&an(c.url,g.url)&&((w=t.stack[0])==null||w.updateProps(c.props??{}))},[(h=n.props)==null?void 0:h._inertiaui_modal]),$.jsxs($.Fragment,{children:[e,t.stack.length>0&&$.jsx(wt,{index:0})]})},ze=o.createContext(null);ze.displayName="ModalIndexContext";const Ge=()=>{const e=o.useContext(ze);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},wt=({index:e})=>{const{stack:t}=fe(),n=o.useMemo(()=>t[e],[t,e]);return(n==null?void 0:n.component)&&$.jsx(ze.Provider,{value:e,children:$.jsx(n.component,{...n.props,onModalEvent:(...r)=>n.emit(...r)})})},Ke=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:i=null,...a},u)=>{const s=Ge(),{stack:h,registerLocalModal:c,removeLocalModal:g}=fe(),[b,w]=o.useState(null),f=o.useMemo(()=>e?b:h[s],[e,b,s,h]),x=o.useMemo(()=>{var v;return(v=h.find(M=>M.shouldRender&&M.index>(f==null?void 0:f.index)))==null?void 0:v.index},[s,h]),d=o.useMemo(()=>(f==null?void 0:f.config.slideover)??a.slideover??Me("type")==="slideover",[a.slideover]),m=o.useMemo(()=>({slideover:d,closeButton:a.closeButton??re(d,"closeButton"),closeExplicitly:a.closeExplicitly??re(d,"closeExplicitly"),maxWidth:a.maxWidth??re(d,"maxWidth"),paddingClasses:a.paddingClasses??re(d,"paddingClasses"),panelClasses:a.panelClasses??re(d,"panelClasses"),position:a.position??re(d,"position"),...f==null?void 0:f.config}),[a,f==null?void 0:f.config]);o.useEffect(()=>{if(e){let v=null;return c(e,M=>{v=M.registerEventListenersFromProps(a),w(M)}),()=>{v==null||v(),v=null,g(e)}}return f.registerEventListenersFromProps(a)},[e]);const p=o.useRef(f);o.useEffect(()=>{p.current=f},[f]),o.useEffect(()=>{f!==null&&(f.isOpen?i==null||i():l==null||l())},[f==null?void 0:f.isOpen]);const[E,y]=o.useState(!1);return o.useEffect(()=>{E&&f!==null&&f.isOpen&&(f.onTopOfStack?n==null||n():r==null||r()),y(!0)},[f==null?void 0:f.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var v;return(v=p.current)==null?void 0:v.afterLeave()},close:()=>{var v;return(v=p.current)==null?void 0:v.close()},emit:(...v)=>{var M;return(M=p.current)==null?void 0:M.emit(...v)},getChildModal:()=>{var v;return(v=p.current)==null?void 0:v.getChildModal()},getParentModal:()=>{var v;return(v=p.current)==null?void 0:v.getParentModal()},reload:(...v)=>{var M;return(M=p.current)==null?void 0:M.reload(...v)},setOpen:()=>{var v;return(v=p.current)==null?void 0:v.setOpen()},get id(){var v;return(v=p.current)==null?void 0:v.id},get index(){var v;return(v=p.current)==null?void 0:v.index},get isOpen(){var v;return(v=p.current)==null?void 0:v.isOpen},get config(){var v;return(v=p.current)==null?void 0:v.config},get modalContext(){return p.current},get onTopOfStack(){var v;return(v=p.current)==null?void 0:v.onTopOfStack},get shouldRender(){var v;return(v=p.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:m,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,x&&$.jsx(wt,{index:x})]})});Ke.displayName="HeadlessModal";function Et(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=Et(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=Et(e))&&(r&&(r+=" "),r+=t);return r}var mn=Object.defineProperty,pn=(e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(pn(e,typeof t!="symbol"?t+"":t,n),n);let hn=class{constructor(){Ze(this,"current",this.detect()),Ze(this,"handoffState","pending"),Ze(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 hn;function Oe(e){return J.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function Te(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function z(){let e=[],t={addEventListener(n,r,l,i){return n.addEventListener(r,l,i),t.add(()=>n.removeEventListener(r,l,i))},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 Te(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,l){let i=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:l}),this.add(()=>{Object.assign(n.style,{[r]:i})})},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 Je(){let[e]=o.useState(z);return o.useEffect(()=>()=>e.dispose(),[e]),e}let L=(e,t)=>{J.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function Q(e){let t=o.useRef(e);return L(()=>{t.current=e},[e]),t}let O=function(e){let t=Q(e);return o.useCallback((...n)=>t.current(...n),[t])},vn=o.createContext(void 0);function gn(){return o.useContext(vn)}function Qe(...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 Pe=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Pe||{}),K=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(K||{});function D(){let e=En();return o.useCallback(t=>wn({mergeRefs:e,...t}),[e])}function wn({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:l,visible:i=!0,name:a,mergeRefs:u}){u=u??xn;let s=xt(t,e);if(i)return Fe(s,n,r,a,u);let h=l??0;if(h&2){let{static:c=!1,...g}=s;if(c)return Fe(g,n,r,a,u)}if(h&1){let{unmount:c=!0,...g}=s;return G(c?0:1,{0(){return null},1(){return Fe({...g,hidden:!0,style:{display:"none"}},n,r,a,u)}})}return Fe(s,n,r,a,u)}function Fe(e,t={},n,r,l){let{as:i=n,children:a,refName:u="ref",...s}=Re(e,["unmount","static"]),h=e.ref!==void 0?{[u]:e.ref}:{},c=typeof a=="function"?a(t):a;"className"in s&&s.className&&typeof s.className=="function"&&(s.className=s.className(t)),s["aria-labelledby"]&&s["aria-labelledby"]===s.id&&(s["aria-labelledby"]=void 0);let g={};if(t){let b=!1,w=[];for(let[f,x]of Object.entries(t))typeof x=="boolean"&&(b=!0),x===!0&&w.push(f.replace(/([A-Z])/g,d=>`-${d.toLowerCase()}`));if(b){g["data-headlessui-state"]=w.join(" ");for(let f of w)g[`data-${f}`]=""}}if(i===o.Fragment&&(Object.keys(R(s)).length>0||Object.keys(R(g)).length>0))if(!o.isValidElement(c)||Array.isArray(c)&&c.length>1){if(Object.keys(R(s)).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(s)).concat(Object.keys(R(g))).map(b=>` - ${b}`).join(`
|
|
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(
|
|
1
|
+
(function(M,o){typeof exports=="object"&&typeof module<"u"?o(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"],o):(M=typeof globalThis<"u"?globalThis:M||self,o(M.InertiaUIModal={},M.React,M.jsxRuntime,M.Axios,M.react,M.core,M.ReactDOM))})(this,function(M,o,S,Ce,ie,Pr,Tr){"use strict";var Kl=Object.defineProperty;var Yl=(M,o,S)=>o in M?Kl(M,o,{enumerable:!0,configurable:!0,writable:!0,value:S}):M[o]=S;var V=(M,o,S)=>Yl(M,typeof o!="symbol"?o+"":o,S);function kr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const pe=kr(o),he={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 Fr{constructor(){this.config={},this.reset()}reset(){this.config=JSON.parse(JSON.stringify(he))}put(t,r){if(typeof t=="object"){this.config={type:t.type??he.type,navigate:t.navigate??he.navigate,modal:{...he.modal,...t.modal??{}},slideover:{...he.slideover,...t.slideover??{}}};return}const n=t.split(".");let l=this.config;for(let i=0;i<n.length-1;i++)l=l[n[i]]=l[n[i]]||{};l[n[n.length-1]]=r}get(t){if(typeof t>"u")return this.config;const r=t.split(".");let n=this.config;for(const l of r){if(n[l]===void 0)return null;n=n[l]}return n}}const Pe=new Fr,Lr=()=>Pe.reset(),Ar=(e,t)=>Pe.put(e,t),Te=e=>Pe.get(e),se=(e,t)=>Pe.get(e?`slideover.${t}`:`modal.${t}`);function Ir(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 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 ue(e){return typeof e=="string"?e.toLowerCase():e}function Nr(e,t,r=!1){return r&&(t=t.map(ue)),Array.isArray(e)?e.filter(n=>!t.includes(r?ue(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?ue(l):l)||(n[l]=e[l]),n),{})}function Dr(e,t,r=!1){return r&&(t=t.map(ue)),Array.isArray(e)?e.filter(n=>t.includes(r?ue(n):n)):Object.keys(e).reduce((n,l)=>(t.includes(r?ue(l):l)&&(n[l]=e[l]),n),{})}function jr(e){return Array.isArray(e)?e.filter(t=>t!==null):Object.keys(e).reduce((t,r)=>(r in e&&e[r]!==null&&(t[r]=e[r]),t),{})}function ve(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,r)=>r.toUpperCase()),e=e.replace(/(.)(?=[A-Z])/g,"$1-"),e.toLowerCase()):e):""}const ke=o.createContext(null);ke.displayName="ModalStackContext";let Ot=null,Mt=null,ae=null,Fe={},Re=[],de={};const Ct=({children:e})=>{const[t,r]=o.useState([]),[n,l]=o.useState({}),i=v=>{r(c=>{const f=v([...c]),g=y=>{var p;return f.length<2?!0:((p=f.map(x=>({id:x.id,shouldRender:x.shouldRender})).reverse().find(x=>x.shouldRender))==null?void 0:p.id)===y};return f.forEach((y,p)=>{f[p].onTopOfStack=g(y.id),f[p].getParentModal=()=>p<1?null:f.slice(0,p).reverse().find(x=>x.isOpen),f[p].getChildModal=()=>p===f.length-1?null:f.slice(p+1).find(x=>x.isOpen)}),f})};o.useEffect(()=>{Re=t},[t]);class a{constructor(c,f,g,y,p){V(this,"show",()=>{i(c=>c.map(f=>(f.id===this.id&&!f.isOpen&&(f.isOpen=!0,f.shouldRender=!0),f)))});V(this,"setOpen",c=>{c?this.show():this.close()});V(this,"close",()=>{i(c=>{let f=!1;const g=c.map(y=>{var p;return y.id===this.id&&y.isOpen&&(Object.keys(y.listeners).forEach(x=>{y.off(x)}),y.isOpen=!1,(p=y.onCloseCallback)==null||p.call(y),f=!0),y});return f?g:c})});V(this,"afterLeave",()=>{this.isOpen||i(c=>{const f=c.map(g=>{var y;return g.id===this.id&&!g.isOpen&&(g.shouldRender=!1,(y=g.afterLeaveCallback)==null||y.call(g),g.afterLeaveCallback=null),g});return this.index===0?[]:f})});V(this,"on",(c,f)=>{c=ve(c),this.listeners[c]=this.listeners[c]??[],this.listeners[c].push(f)});V(this,"off",(c,f)=>{var g;c=ve(c),f?this.listeners[c]=((g=this.listeners[c])==null?void 0:g.filter(y=>y!==f))??[]:delete this.listeners[c]});V(this,"emit",(c,...f)=>{var g;(g=this.listeners[ve(c)])==null||g.forEach(y=>y(...f))});V(this,"registerEventListenersFromProps",c=>{const f=[];return Object.keys(c).filter(g=>g.startsWith("on")).forEach(g=>{const y=ve(g).replace(/^on-/,"");this.on(y,c[g]),f.push(()=>this.off(y,c[g]))}),()=>f.forEach(g=>g())});V(this,"reload",(c={})=>{var p,x;let f=Object.keys(this.response.props);if(c.only&&(f=c.only),c.except&&(f=Nr(f,c.except)),!((p=this.response)!=null&&p.url))return;const g=(c.method??"get").toLowerCase(),y=c.data??{};(x=c.onStart)==null||x.call(c),Ce({url:this.response.url,method:g,data:g==="get"?{}:y,params:g==="get"?y:{},headers:{...c.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":f.join(","),"X-InertiaUI-Modal":Qe(),"X-InertiaUI-Modal-Use-Router":0,"X-InertiaUI-Modal-Base-Url":ae}}).then(O=>{var F;this.updateProps(O.data.props),(F=c.onSuccess)==null||F.call(c,O)}).catch(O=>{var F;(F=c.onError)==null||F.call(c,O)}).finally(()=>{var O;(O=c.onFinish)==null||O.call(c)})});V(this,"updateProps",c=>{Object.assign(this.props,c),i(f=>f)});if(this.id=f.id??Qe(),this.isOpen=!1,this.shouldRender=!1,this.listeners={},this.component=c,this.props=f.props,this.response=f,this.config=g??{},this.onCloseCallback=y,this.afterLeaveCallback=p,de[this.id]){this.config={...this.config,...de[this.id].config??{}};const x=de[this.id].onClose,O=de[this.id].onAfterLeave;x&&(this.onCloseCallback=y?()=>{y(),x()}:x),O&&(this.afterLeaveCallback=p?()=>{p(),O()}:O),delete de[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 u=(v,c={},f=null,g=null)=>Mt(v.component).then(y=>d(y,v,c,f,g)),s=v=>{var f,g;const c=(g=(f=v.response)==null?void 0:f.meta)==null?void 0:g.deferredProps;c&&Object.keys(c).forEach(y=>{v.reload({only:c[y]})})},d=(v,c,f,g,y)=>{const p=new a(v,c,f,g,y);return p.index=t.length,i(x=>[...x,p]),s(p),p.show(),p};function h(v,c,f,g){if(!n[v])throw new Error(`The local modal "${v}" has not been registered.`);const y=d(null,{},c,f,g);return y.name=v,n[v].callback(y),y}const b=(v,c={})=>E(v,c.method??"get",c.data??{},c.headers??{},c.config??{},c.onClose,c.onAfterLeave,c.queryStringArrayFormat??"brackets",c.navigate??Te("navigate")).then(f=>{const g=c.listeners??{};return Object.keys(g).forEach(y=>{const p=ve(y);f.on(p,g[y])}),f}),E=(v,c,f={},g={},y={},p=null,x=null,O="brackets",F=!1)=>{const U=Qe();return new Promise((k,D)=>{if(v.startsWith("#")){k(h(v.substring(1),y,p,x));return}const[H,A]=Pr.mergeDataIntoQueryString(c,v||"",f,O);let T=F&&t.length===0;if(t.length===0&&(ae=typeof window<"u"?window.location.href:""),g={...g,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,"X-Inertia-Version":Ot,"X-InertiaUI-Modal":U,"X-InertiaUI-Modal-Use-Router":T?1:0,"X-InertiaUI-Modal-Base-Url":ae},T)return Fe={},de[U]={config:y,onClose:p,onAfterLeave:x},ie.router.visit(H,{method:c,data:A,headers:g,preserveScroll:!0,preserveState:!0,onError:D,onBefore:()=>{Fe[U]=k}});Ce({url:H,method:c,data:A,headers:g}).then(I=>k(u(I.data,y,p,x))).catch(I=>{D(I)})})},$={stack:t,localModals:n,push:d,pushFromResponseData:u,length:()=>Re.length,closeAll:()=>{Re.reverse().forEach(v=>v.close())},reset:()=>i(()=>[]),visit:E,visitModal:b,registerLocalModal:(v,c)=>{l(f=>({...f,[v]:{name:v,callback:c}}))},removeLocalModal:v=>{l(c=>{const f={...c};return delete f[v],f})},onModalOnBase:v=>{const c=Fe[v.id];c&&(c(v),delete Fe[v.id])}};return S.jsx(ke.Provider,{value:$,children:e})},ge=()=>{const e=o.useContext(ke);if(e===null)throw new Error("useModalStack must be used within a ModalStackProvider");return e},Pt=["closeButton","closeExplicitly","maxWidth","paddingClasses","panelClasses","position","slideover"],Tt=e=>{e.initialPage&&(Ot=e.initialPage.version),e.resolveComponent&&(Mt=e.resolveComponent)},_r=(e,t)=>{Tt(t);const r=({Component:n,props:l,key:i})=>{const a=()=>{const u=o.createElement(n,{key:i,...l});return typeof n.layout=="function"?n.layout(u):Array.isArray(n.layout)?n.layout.concat(u).reverse().reduce((d,h)=>o.createElement(h,l,d)):u};return S.jsxs(S.Fragment,{children:[a(),S.jsx(kt,{})]})};return S.jsx(Ct,{children:S.jsx(e,{...t,children:r})})},kt=({children:e})=>{var s,d;const t=o.useContext(ke),r=ie.usePage();let n=!1,l=!1,i=!!((s=r.props)!=null&&s._inertiaui_modal);o.useEffect(()=>ie.router.on("start",()=>n=!0),[]),o.useEffect(()=>ie.router.on("finish",()=>n=!1),[]),o.useEffect(()=>ie.router.on("navigate",function(h){const b=h.detail.page.props._inertiaui_modal;if(!b){l&&t.closeAll(),ae=null,i=!1;return}l=b,ae=b.baseUrl,t.pushFromResponseData(b,{},()=>{if(!b.baseUrl){console.error("No base url in modal response data so cannot navigate back");return}!n&&window.location.href!==b.baseUrl&&ie.router.visit(b.baseUrl,{preserveScroll:!0,preserveState:!0})}).then(t.onModalOnBase)}),[]);const a=h=>{var b;return h.headers["X-InertiaUI-Modal-Base-Url"]=ae??(i?(b=r.props._inertiaui_modal)==null?void 0:b.baseUrl:null),h};o.useEffect(()=>(Ce.interceptors.request.use(a),()=>Ce.interceptors.request.eject(a)),[]);const u=o.useRef();return o.useEffect(()=>{var E,w;const h=(E=r.props)==null?void 0:E._inertiaui_modal,b=u.current;u.current=h,h&&b&&h.component===b.component&&Ir(h.url,b.url)&&((w=t.stack[0])==null||w.updateProps(h.props??{}))},[(d=r.props)==null?void 0:d._inertiaui_modal]),S.jsxs(S.Fragment,{children:[e,t.stack.length>0&&S.jsx(Ft,{index:0})]})},et=o.createContext(null);et.displayName="ModalIndexContext";const tt=()=>{const e=o.useContext(et);if(e===void 0)throw new Error("useModalIndex must be used within a ModalIndexProvider");return e},Ft=({index:e})=>{const{stack:t}=ge(),r=o.useMemo(()=>t[e],[t,e]);return(r==null?void 0:r.component)&&S.jsx(et.Provider,{value:e,children:S.jsx(r.component,{...r.props,onModalEvent:(...n)=>r.emit(...n)})})};function rt(){return ge().stack[tt()]??null}const Lt=({children:e,data:t,fallback:r})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop to be a string or array of strings");const[n,l]=o.useState(!1),i=Array.isArray(t)?t:[t],a=rt().props;return o.useEffect(()=>{l(i.every(u=>a[u]!==void 0))},[a,i]),n?e:r};Lt.displayName="InertiaModalDeferred";const nt=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,...a},u)=>{const s=tt(),{stack:d,registerLocalModal:h,removeLocalModal:b}=ge(),[E,w]=o.useState(null),m=o.useMemo(()=>e?E:d[s],[e,E,s,d]),$=o.useMemo(()=>{var p;return(p=d.find(x=>x.shouldRender&&x.index>(m==null?void 0:m.index)))==null?void 0:p.index},[s,d]),v=o.useMemo(()=>(m==null?void 0:m.config.slideover)??a.slideover??Te("type")==="slideover",[a.slideover]),c=o.useMemo(()=>({slideover:v,closeButton:a.closeButton??se(v,"closeButton"),closeExplicitly:a.closeExplicitly??se(v,"closeExplicitly"),maxWidth:a.maxWidth??se(v,"maxWidth"),paddingClasses:a.paddingClasses??se(v,"paddingClasses"),panelClasses:a.panelClasses??se(v,"panelClasses"),position:a.position??se(v,"position"),...m==null?void 0:m.config}),[a,m==null?void 0:m.config]);o.useEffect(()=>{if(e){let p=null;return h(e,x=>{p=x.registerEventListenersFromProps(a),w(x)}),()=>{p==null||p(),p=null,b(e)}}return m.registerEventListenersFromProps(a)},[e]);const f=o.useRef(m);o.useEffect(()=>{f.current=m},[m]),o.useEffect(()=>{m!==null&&(m.isOpen?i==null||i():l==null||l())},[m==null?void 0:m.isOpen]);const[g,y]=o.useState(!1);return o.useEffect(()=>{g&&m!==null&&m.isOpen&&(m.onTopOfStack?r==null||r():n==null||n()),y(!0)},[m==null?void 0:m.onTopOfStack]),o.useImperativeHandle(u,()=>({afterLeave:()=>{var p;return(p=f.current)==null?void 0:p.afterLeave()},close:()=>{var p;return(p=f.current)==null?void 0:p.close()},emit:(...p)=>{var x;return(x=f.current)==null?void 0:x.emit(...p)},getChildModal:()=>{var p;return(p=f.current)==null?void 0:p.getChildModal()},getParentModal:()=>{var p;return(p=f.current)==null?void 0:p.getParentModal()},reload:(...p)=>{var x;return(x=f.current)==null?void 0:x.reload(...p)},setOpen:()=>{var p;return(p=f.current)==null?void 0:p.setOpen()},get id(){var p;return(p=f.current)==null?void 0:p.id},get index(){var p;return(p=f.current)==null?void 0:p.index},get isOpen(){var p;return(p=f.current)==null?void 0:p.isOpen},get config(){var p;return(p=f.current)==null?void 0:p.config},get modalContext(){return f.current},get onTopOfStack(){var p;return(p=f.current)==null?void 0:p.onTopOfStack},get shouldRender(){var p;return(p=f.current)==null?void 0:p.shouldRender}}),[m]),(m==null?void 0:m.shouldRender)&&S.jsxs(S.Fragment,{children:[typeof t=="function"?t({afterLeave:m.afterLeave,close:m.close,config:c,emit:m.emit,getChildModal:m.getChildModal,getParentModal:m.getParentModal,id:m.id,index:m.index,isOpen:m.isOpen,modalContext:m,onTopOfStack:m.onTopOfStack,reload:m.reload,setOpen:m.setOpen,shouldRender:m.shouldRender}):t,$&&S.jsx(Ft,{index:$})]})});nt.displayName="HeadlessModal";function At(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(r=At(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Le(){for(var e,t,r=0,n="",l=arguments.length;r<l;r++)(e=arguments[r])&&(t=At(e))&&(n&&(n+=" "),n+=t);return n}var Wr=Object.defineProperty,Ur=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lt=(e,t,r)=>(Ur(e,typeof t!="symbol"?t+"":t,r),r);let Hr=class{constructor(){lt(this,"current",this.detect()),lt(this,"handoffState","pending"),lt(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"}},ee=new Hr;function Ae(e){var t,r;return ee.isServer?null:e?"ownerDocument"in e?e.ownerDocument:"current"in e?(r=(t=e.current)==null?void 0:t.ownerDocument)!=null?r:document:null:document}function Ie(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function X(){let e=[],t={addEventListener(r,n,l,i){return r.addEventListener(n,l,i),t.add(()=>r.removeEventListener(n,l,i))},requestAnimationFrame(...r){let n=requestAnimationFrame(...r);return t.add(()=>cancelAnimationFrame(n))},nextFrame(...r){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...r))},setTimeout(...r){let n=setTimeout(...r);return t.add(()=>clearTimeout(n))},microTask(...r){let n={current:!0};return Ie(()=>{n.current&&r[0]()}),t.add(()=>{n.current=!1})},style(r,n,l){let i=r.style.getPropertyValue(n);return Object.assign(r.style,{[n]:l}),this.add(()=>{Object.assign(r.style,{[n]:i})})},group(r){let n=X();return r(n),this.add(()=>n.dispose())},add(r){return e.includes(r)||e.push(r),()=>{let n=e.indexOf(r);if(n>=0)for(let l of e.splice(n,1))l()}},dispose(){for(let r of e.splice(0))r()}};return t}function ot(){let[e]=o.useState(X);return o.useEffect(()=>()=>e.dispose(),[e]),e}let L=(e,t)=>{ee.isServer?o.useEffect(e,t):o.useLayoutEffect(e,t)};function te(e){let t=o.useRef(e);return L(()=>{t.current=e},[e]),t}let P=function(e){let t=te(e);return o.useCallback((...r)=>t.current(...r),[t])},Vr=o.createContext(void 0);function Br(){return o.useContext(Vr)}function it(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function z(e,t,...r){if(e in t){let l=t[e];return typeof l=="function"?l(...r):l}let n=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(n,z),n}var Ne=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(Ne||{}),Y=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Y||{});function j(){let e=Xr();return o.useCallback(t=>qr({mergeRefs:e,...t}),[e])}function qr({ourProps:e,theirProps:t,slot:r,defaultTag:n,features:l,visible:i=!0,name:a,mergeRefs:u}){u=u??zr;let s=It(t,e);if(i)return De(s,r,n,a,u);let d=l??0;if(d&2){let{static:h=!1,...b}=s;if(h)return De(b,r,n,a,u)}if(d&1){let{unmount:h=!0,...b}=s;return z(h?0:1,{0(){return null},1(){return De({...b,hidden:!0,style:{display:"none"}},r,n,a,u)}})}return De(s,r,n,a,u)}function De(e,t={},r,n,l){let{as:i=r,children:a,refName:u="ref",...s}=st(e,["unmount","static"]),d=e.ref!==void 0?{[u]:e.ref}:{},h=typeof a=="function"?a(t):a;"className"in s&&s.className&&typeof s.className=="function"&&(s.className=s.className(t)),s["aria-labelledby"]&&s["aria-labelledby"]===s.id&&(s["aria-labelledby"]=void 0);let b={};if(t){let E=!1,w=[];for(let[m,$]of Object.entries(t))typeof $=="boolean"&&(E=!0),$===!0&&w.push(m.replace(/([A-Z])/g,v=>`-${v.toLowerCase()}`));if(E){b["data-headlessui-state"]=w.join(" ");for(let m of w)b[`data-${m}`]=""}}if(i===o.Fragment&&(Object.keys(re(s)).length>0||Object.keys(re(b)).length>0))if(!o.isValidElement(h)||Array.isArray(h)&&h.length>1){if(Object.keys(re(s)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${n} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(re(s)).concat(Object.keys(re(b))).map(E=>` - ${E}`).join(`
|
|
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(E=>` - ${E}`).join(`
|
|
3
3
|
`)].join(`
|
|
4
|
-
`))}else{let b=c.props,w=b==null?void 0:b.className,f=typeof w=="function"?(...m)=>Qe(w(...m),s.className):Qe(w,s.className),x=f?{className:f}:{},d=xt(c.props,R(Re(s,["ref"])));for(let m in g)m in d&&delete g[m];return o.cloneElement(c,Object.assign({},d,g,h,{ref:l(bn(c),h.ref)},x))}return o.createElement(i,Object.assign({},Re(s,["ref"]),i!==o.Fragment&&h,i!==o.Fragment&&g),c)}function En(){let e=o.useRef([]),t=o.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 xn(...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 i;return(i=l==null?void 0:l.preventDefault)==null?void 0:i.call(l)}]);for(let r in n)Object.assign(t,{[r](l,...i){let a=n[r];for(let u of a){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;u(l,...i)}}});return t}function k(e){var t;return Object.assign(o.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 Re(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function bn(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let yn="span";var Le=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(Le||{});function $n(e,t){var n;let{features:r=1,...l}=e,i={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:i,theirProps:l,slot:{},defaultTag:yn,name:"Hidden"})}let et=k($n),bt=Symbol();function Mn(e,t=!0){return Object.assign(e,{[bt]:t})}function q(...e){let t=o.useRef(e);o.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[bt]))?void 0:n}let tt=o.createContext(null);tt.displayName="DescriptionContext";function yt(){let e=o.useContext(tt);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 Cn(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(n){let r=O(i=>(t(a=>[...a,i]),()=>t(a=>{let u=a.slice(),s=u.indexOf(i);return s!==-1&&u.splice(s,1),u}))),l=o.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 o.createElement(tt.Provider,{value:l},n.children)},[t])]}let Sn="p";function On(e,t){let n=o.useId(),r=gn(),{id:l=`headlessui-description-${n}`,...i}=e,a=yt(),u=q(t);L(()=>a.register(l),[l,a.register]);let s=r||!1,h=o.useMemo(()=>({...a.slot,disabled:s}),[a.slot,s]),c={ref:u,...a.props,id:l};return D()({ourProps:c,theirProps:i,slot:h,defaultTag:Sn,name:a.name||"Description"})}let Tn=k(On),Pn=Object.assign(Tn,{});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 Fn=o.createContext(()=>{});function Ln({value:e,children:t}){return o.createElement(Fn.Provider,{value:e},t)}let kn=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,...i){let a=t[l].call(n,...i);a&&(n=a,r.forEach(u=>u()))}}}function Ct(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let Nn=new kn(()=>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 se(e,t){let n=Nn.get(t),r=o.useId(),l=Ct(n);if(L(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let i=l.indexOf(r),a=l.length;return i===-1&&(i=a,a+=1),i===a-1}let nt=new Map,me=new Map;function St(e){var t;let n=(t=me.get(e))!=null?t:0;return me.set(e,n+1),n!==0?()=>Ot(e):(nt.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=me.get(e))!=null?t:1;if(n===1?me.delete(e):me.set(e,n-1),n!==1)return;let r=nt.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,nt.delete(e))}function In(e,{allowed:t,disallowed:n}={}){let r=se(e,"inert-others");L(()=>{var l,i;if(!r)return;let a=z();for(let s of(l=n==null?void 0:n())!=null?l:[])s&&a.add(St(s));let u=(i=t==null?void 0:t())!=null?i:[];for(let s of u){if(!s)continue;let h=Oe(s);if(!h)continue;let c=s.parentElement;for(;c&&c!==h.body;){for(let g of c.children)u.some(b=>g.contains(b))||a.add(St(g));c=c.parentElement}}return a.dispose},[r,t,n])}function An(e,t,n){let r=Q(l=>{let i=l.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&n()});o.useEffect(()=>{if(!e)return;let l=t===null?null:t instanceof HTMLElement?t:t.current;if(!l)return;let i=z();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>r.current(l));a.observe(l),i.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>r.current(l));a.observe(l),i.add(()=>a.disconnect())}return()=>i.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(","),Dn=["[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||{}),rt=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(rt||{}),jn=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(jn||{});function Un(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 Hn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Dn)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var Tt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Tt||{});function Wn(e,t=0){var n;return e===((n=Oe(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 _n=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(_n||{});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 Bn=["textarea","input"].join(",");function qn(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Bn))!=null?n:!1}function Xn(e,t=n=>n){return e.slice().sort((n,r)=>{let l=t(n),i=t(r);if(l===null||i===null)return 0;let a=l.compareDocumentPosition(i);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function pe(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:l=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?n?Xn(e):e:t&64?Hn(e):Un(e);l.length>0&&a.length>1&&(a=a.filter(w=>!l.some(f=>f!=null&&"current"in f?(f==null?void 0:f.current)===w:f===w))),r=r??i.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,a.indexOf(r))-1;if(t&4)return Math.max(0,a.indexOf(r))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),h=t&32?{preventScroll:!0}:{},c=0,g=a.length,b;do{if(c>=g||c+g<=0)return 0;let w=s+c;if(t&16)w=(w+g)%g;else{if(w<0)return 3;if(w>=g)return 1}b=a[w],b==null||b.focus(h),c+=u}while(b!==i.activeElement);return t&6&&qn(b)&&b.select(),2}function Pt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function Vn(){return/Android/gi.test(window.navigator.userAgent)}function Yn(){return Pt()||Vn()}function he(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return document.addEventListener(t,i,r),()=>document.removeEventListener(t,i,r)},[e,t,r])}function Ft(e,t,n,r){let l=Q(n);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return window.addEventListener(t,i,r),()=>window.removeEventListener(t,i,r)},[e,t,r])}const Lt=30;function zn(e,t,n){let r=se(e,"outside-click"),l=Q(n),i=o.useCallback(function(s,h){if(s.defaultPrevented)return;let c=h(s);if(c===null||!c.getRootNode().contains(c)||!c.isConnected)return;let g=function b(w){return typeof w=="function"?b(w()):Array.isArray(w)||w instanceof Set?w:[w]}(t);for(let b of g)if(b!==null&&(b.contains(c)||s.composed&&s.composedPath().includes(b)))return;return!Wn(c,Tt.Loose)&&c.tabIndex!==-1&&s.preventDefault(),l.current(s,c)},[l,t]),a=o.useRef(null);he(r,"pointerdown",s=>{var h,c;a.current=((c=(h=s.composedPath)==null?void 0:h.call(s))==null?void 0:c[0])||s.target},!0),he(r,"mousedown",s=>{var h,c;a.current=((c=(h=s.composedPath)==null?void 0:h.call(s))==null?void 0:c[0])||s.target},!0),he(r,"click",s=>{Yn()||a.current&&(i(s,()=>a.current),a.current=null)},!0);let u=o.useRef({x:0,y:0});he(r,"touchstart",s=>{u.current.x=s.touches[0].clientX,u.current.y=s.touches[0].clientY},!0),he(r,"touchend",s=>{let h={x:s.changedTouches[0].clientX,y:s.changedTouches[0].clientY};if(!(Math.abs(h.x-u.current.x)>=Lt||Math.abs(h.y-u.current.y)>=Lt))return i(s,()=>s.target instanceof HTMLElement?s.target:null)},!0),Ft(r,"blur",s=>i(s,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function ve(...e){return o.useMemo(()=>Oe(...e),[...e])}function kt(e,t,n,r){let l=Q(n);o.useEffect(()=>{e=e??window;function i(a){l.current(a)}return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},[e,t,r])}function Gn(){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),i=Math.max(0,e-l);n.style(r,"paddingRight",`${i}px`)}}}function Kn(){return Pt()?{before({doc:e,d:t,meta:n}){function r(l){return n.containers.flatMap(i=>i()).some(i=>i.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=z();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let i=(l=window.scrollY)!=null?l:window.pageYOffset,a=null;t.addEventListener(e,"click",u=>{if(u.target instanceof HTMLElement)try{let s=u.target.closest("a");if(!s)return;let{hash:h}=new URL(s.href),c=e.querySelector(h);c&&!r(c)&&(a=c)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(u.target instanceof HTMLElement)if(r(u.target)){let s=u.target;for(;s.parentElement&&r(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(u.target instanceof HTMLElement){if(u.target.tagName==="INPUT")return;if(r(u.target)){let s=u.target;for(;s.parentElement&&s.dataset.headlessuiPortal!==""&&!(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);)s=s.parentElement;s.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let s=(u=window.scrollY)!=null?u:window.pageYOffset;i!==s&&window.scrollTo(0,i),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function Zn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Jn(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let ee=Mt(()=>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:Jn(n)},l=[Kn(),Gn(),Zn()];l.forEach(({before:i})=>i==null?void 0:i(r)),l.forEach(({after:i})=>i==null?void 0:i(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 Qn(e,t,n=()=>({containers:[]})){let r=Ct(ee),l=t?r.get(t):void 0,i=l?l.count>0:!1;return L(()=>{if(!(!t||!e))return ee.dispatch("PUSH",t,n),()=>ee.dispatch("POP",t,n)},[e,t]),i}function Rn(e,t,n=()=>[document.body]){let r=se(e,"scroll-lock");Qn(r,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],n]}})}function er(e=0){let[t,n]=o.useState(e),r=o.useCallback(s=>n(s),[t]),l=o.useCallback(s=>n(h=>h|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),a=o.useCallback(s=>n(h=>h&~s),[n]),u=o.useCallback(s=>n(h=>h^s),[n]);return{flags:t,setFlag:r,addFlag:l,hasFlag:i,removeFlag:a,toggleFlag:u}}var Nt,It;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Nt=process==null?void 0:process.env)==null?void 0:Nt.NODE_ENV)==="test"&&typeof((It=Element==null?void 0:Element.prototype)==null?void 0:It.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 tr=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(tr||{});function nr(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function rr(e,t,n,r){let[l,i]=o.useState(n),{hasFlag:a,addFlag:u,removeFlag:s}=er(e&&l?3:0),h=o.useRef(!1),c=o.useRef(!1),g=Je();return L(()=>{var b;if(e){if(n&&i(!0),!t){n&&u(3);return}return(b=r==null?void 0:r.start)==null||b.call(r,n),lr(t,{inFlight:h,prepare(){c.current?c.current=!1:c.current=h.current,h.current=!0,!c.current&&(n?(u(3),s(4)):(u(4),s(2)))},run(){c.current?n?(s(3),u(4)):(s(4),u(3)):n?s(1):u(1)},done(){var w;c.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(h.current=!1,s(7),n||i(!1),(w=r==null?void 0:r.end)==null||w.call(r,n))}})}},[e,n,t,g]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function lr(e,{prepare:t,run:n,done:r,inFlight:l}){let i=z();return ir(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{n(),i.requestAnimationFrame(()=>{i.add(or(e,r))})}),i.dispose}function or(e,t){var n,r;let l=z();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let a=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(u=>u instanceof CSSTransition))!=null?r:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{i||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 lt(e,t){let n=o.useRef([]),r=O(e);o.useEffect(()=>{let l=[...n.current];for(let[i,a]of t.entries())if(n.current[i]!==a){let u=r(t,l);return n.current=t,u}},[r,...t])}let Ne=o.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 Ie(){return o.useContext(Ne)}function sr({value:e,children:t}){return o.createElement(Ne.Provider,{value:e},t)}function ar({children:e}){return o.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 Z=[];ur(()=>{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 At(e){let t=O(e),n=o.useRef(!1);o.useEffect(()=>(n.current=!1,()=>{n.current=!0,Te(()=>{n.current&&t()})}),[t])}function dr(){let e=typeof document>"u";return"useSyncExternalStore"in ue?(t=>t.useSyncExternalStore)(ue)(()=>()=>{},()=>!1,()=>!e):!1}function ge(){let e=dr(),[t,n]=ue.useState(J.isHandoffComplete);return t&&J.isHandoffComplete===!1&&n(!1),ue.useEffect(()=>{t!==!0&&n(!0)},[t]),ue.useEffect(()=>J.handoff(),[]),e?!1:t}let Dt=o.createContext(!1);function cr(){return o.useContext(Dt)}function jt(e){return o.createElement(Dt.Provider,{value:e.force},e.children)}function fr(e){let t=cr(),n=o.useContext(Ht),r=ve(e),[l,i]=o.useState(()=>{var a;if(!t&&n!==null)return(a=n.current)!=null?a:null;if(J.isServer)return null;let u=r==null?void 0:r.getElementById("headlessui-portal-root");if(u)return u;if(r===null)return null;let s=r.createElement("div");return s.setAttribute("id","headlessui-portal-root"),r.body.appendChild(s)});return o.useEffect(()=>{l!==null&&(r!=null&&r.body.contains(l)||r==null||r.body.appendChild(l))},[l,r]),o.useEffect(()=>{t||n!==null&&i(n.current)},[n,i,t]),l}let Ut=o.Fragment,mr=k(function(e,t){let n=e,r=o.useRef(null),l=q(Mn(g=>{r.current=g}),t),i=ve(r),a=fr(r),[u]=o.useState(()=>{var g;return J.isServer?null:(g=i==null?void 0:i.createElement("div"))!=null?g:null}),s=o.useContext(ot),h=ge();L(()=>{!a||!u||a.contains(u)||(u.setAttribute("data-headlessui-portal",""),a.appendChild(u))},[a,u]),L(()=>{if(u&&s)return s.register(u)},[s,u]),At(()=>{var g;!a||!u||(u instanceof Node&&a.contains(u)&&a.removeChild(u),a.childNodes.length<=0&&((g=a.parentElement)==null||g.removeChild(a)))});let c=D();return h?!a||!u?null:nn.createPortal(c({ourProps:{ref:l},theirProps:n,slot:{},defaultTag:Ut,name:"Portal"}),u):null});function pr(e,t){let n=q(t),{enabled:r=!0,...l}=e,i=D();return r?o.createElement(mr,{...l,ref:n}):i({ourProps:{ref:n},theirProps:l,slot:{},defaultTag:Ut,name:"Portal"})}let hr=o.Fragment,Ht=o.createContext(null);function vr(e,t){let{target:n,...r}=e,l={ref:q(t)},i=D();return o.createElement(Ht.Provider,{value:n},i({ourProps:l,theirProps:r,defaultTag:hr,name:"Popover.Group"}))}let ot=o.createContext(null);function gr(){let e=o.useContext(ot),t=o.useRef([]),n=O(i=>(t.current.push(i),e&&e.register(i),()=>r(i))),r=O(i=>{let a=t.current.indexOf(i);a!==-1&&t.current.splice(a,1),e&&e.unregister(i)}),l=o.useMemo(()=>({register:n,unregister:r,portals:t}),[n,r,t]);return[t,o.useMemo(()=>function({children:i}){return o.createElement(ot.Provider,{value:l},i)},[l])]}let wr=k(pr),Wt=k(vr),Er=Object.assign(wr,{Group:Wt});function xr(e,t=typeof document<"u"?document.defaultView:null,n){let r=se(e,"escape");kt(t,"keydown",l=>{r&&(l.defaultPrevented||l.key===$t.Escape&&n(l))})}function br(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[n,r]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return L(()=>{if(!t)return;function l(i){r(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),n}function yr({defaultContainers:e=[],portals:t,mainTreeNode:n}={}){let r=ve(n),l=O(()=>{var i,a;let u=[];for(let s of e)s!==null&&(s instanceof HTMLElement?u.push(s):"current"in s&&s.current instanceof HTMLElement&&u.push(s.current));if(t!=null&&t.current)for(let s of t.current)u.push(s);for(let s of(i=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?i:[])s!==document.body&&s!==document.head&&s instanceof HTMLElement&&s.id!=="headlessui-portal-root"&&(n&&(s.contains(n)||s.contains((a=n==null?void 0:n.getRootNode())==null?void 0:a.host))||u.some(h=>s.contains(h))||u.push(s));return u});return{resolveContainers:l,contains:O(i=>l().some(a=>a.contains(i)))}}let _t=o.createContext(null);function Bt({children:e,node:t}){let[n,r]=o.useState(null),l=qt(t??n);return o.createElement(_t.Provider,{value:l},e,l===null&&o.createElement(et,{features:Le.Hidden,ref:i=>{var a,u;if(i){for(let s of(u=(a=Oe(i))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(s!==document.body&&s!==document.head&&s instanceof HTMLElement&&s!=null&&s.contains(i)){r(s);break}}}}))}function qt(e=null){var t;return(t=o.useContext(_t))!=null?t:e}function it(){let e=o.useRef(!1);return L(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var we=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(we||{});function $r(){let e=o.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 Mr="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 Cr(e,t){let n=o.useRef(null),r=q(n,t),{initialFocus:l,initialFocusFallback:i,containers:a,features:u=15,...s}=e;ge()||(u=0);let h=ve(n);Pr(u,{ownerDocument:h});let c=Fr(u,{ownerDocument:h,container:n,initialFocus:l,initialFocusFallback:i});Lr(u,{ownerDocument:h,container:n,containers:a,previousActiveElement:c});let g=$r(),b=O(p=>{let E=n.current;E&&(y=>y())(()=>{G(g.current,{[we.Forwards]:()=>{pe(E,V.First,{skipElements:[p.relatedTarget,i]})},[we.Backwards]:()=>{pe(E,V.Last,{skipElements:[p.relatedTarget,i]})}})})}),w=se(!!(u&2),"focus-trap#tab-lock"),f=Je(),x=o.useRef(!1),d={ref:r,onKeyDown(p){p.key=="Tab"&&(x.current=!0,f.requestAnimationFrame(()=>{x.current=!1}))},onBlur(p){if(!(u&4))return;let E=Xt(a);n.current instanceof HTMLElement&&E.add(n.current);let y=p.relatedTarget;y instanceof HTMLElement&&y.dataset.headlessuiFocusGuard!=="true"&&(Vt(E,y)||(x.current?pe(n.current,G(g.current,{[we.Forwards]:()=>V.Next,[we.Backwards]:()=>V.Previous})|V.WrapAround,{relativeTo:p.target}):p.target instanceof HTMLElement&&Y(p.target)))}},m=D();return o.createElement(o.Fragment,null,w&&o.createElement(et,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}),m({ourProps:d,theirProps:s,defaultTag:Mr,name:"FocusTrap"}),w&&o.createElement(et,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:b,features:Le.Focusable}))}let Sr=k(Cr),Or=Object.assign(Sr,{features:te});function Tr(e=!0){let t=o.useRef(Z.slice());return lt(([n],[r])=>{r===!0&&n===!1&&Te(()=>{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 Pr(e,{ownerDocument:t}){let n=!!(e&8),r=Tr(n);lt(()=>{n||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&Y(r())},[n]),At(()=>{n&&Y(r())})}function Fr(e,{ownerDocument:t,container:n,initialFocus:r,initialFocusFallback:l}){let i=o.useRef(null),a=se(!!(e&1),"focus-trap#initial-focus"),u=it();return lt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&Y(l.current);return}let s=n.current;s&&Te(()=>{if(!u.current)return;let h=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===h){i.current=h;return}}else if(s.contains(h)){i.current=h;return}if(r!=null&&r.current)Y(r.current);else{if(e&16){if(pe(s,V.First|V.AutoFocus)!==rt.Error)return}else if(pe(s,V.First)!==rt.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 />")}i.current=t==null?void 0:t.activeElement})},[l,a,e]),i}function Lr(e,{ownerDocument:t,container:n,containers:r,previousActiveElement:l}){let i=it(),a=!!(e&4);kt(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!i.current)return;let s=Xt(r);n.current instanceof HTMLElement&&s.add(n.current);let h=l.current;if(!h)return;let c=u.target;c&&c instanceof HTMLElement?Vt(s,c)?(l.current=c,Y(c)):(u.preventDefault(),u.stopPropagation(),Y(h)):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)!==o.Fragment||o.Children.count(e.children)===1}let Ae=o.createContext(null);Ae.displayName="TransitionContext";var kr=(e=>(e.Visible="visible",e.Hidden="hidden",e))(kr||{});function Nr(){let e=o.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}function Ir(){let e=o.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=o.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=Q(e),r=o.useRef([]),l=it(),i=Je(),a=O((w,f=K.Hidden)=>{let x=r.current.findIndex(({el:d})=>d===w);x!==-1&&(G(f,{[K.Unmount](){r.current.splice(x,1)},[K.Hidden](){r.current[x].state="hidden"}}),i.microTask(()=>{var d;!je(r)&&l.current&&((d=n.current)==null||d.call(n))}))}),u=O(w=>{let f=r.current.find(({el:x})=>x===w);return f?f.state!=="visible"&&(f.state="visible"):r.current.push({el:w,state:"visible"}),()=>a(w,K.Unmount)}),s=o.useRef([]),h=o.useRef(Promise.resolve()),c=o.useRef({enter:[],leave:[]}),g=O((w,f,x)=>{s.current.splice(0),t&&(t.chains.current[f]=t.chains.current[f].filter(([d])=>d!==w)),t==null||t.chains.current[f].push([w,new Promise(d=>{s.current.push(d)})]),t==null||t.chains.current[f].push([w,new Promise(d=>{Promise.all(c.current[f].map(([m,p])=>p)).then(()=>d())})]),f==="enter"?h.current=h.current.then(()=>t==null?void 0:t.wait.current).then(()=>x(f)):x(f)}),b=O((w,f,x)=>{Promise.all(c.current[f].splice(0).map(([d,m])=>m)).then(()=>{var d;(d=s.current.shift())==null||d()}).then(()=>x(f))});return o.useMemo(()=>({children:r,register:u,unregister:a,onStart:g,onStop:b,wait:h,chains:c}),[u,a,r,g,b,c,h])}let Gt=o.Fragment,Kt=Pe.RenderStrategy;function Ar(e,t){var n,r;let{transition:l=!0,beforeEnter:i,afterEnter:a,beforeLeave:u,afterLeave:s,enter:h,enterFrom:c,enterTo:g,entered:b,leave:w,leaveFrom:f,leaveTo:x,...d}=e,[m,p]=o.useState(null),E=o.useRef(null),y=Yt(e),v=q(...y?[E,t,p]:t===null?[]:[t]),M=(n=d.unmount)==null||n?K.Unmount:K.Hidden,{show:T,appear:I,initial:U}=Nr(),[F,A]=o.useState(T?"visible":"hidden"),H=Ir(),{register:W,unregister:S}=H;L(()=>W(E),[W,E]),L(()=>{if(M===K.Hidden&&E.current){if(T&&F!=="visible"){A("visible");return}return G(F,{hidden:()=>S(E),visible:()=>W(E)})}},[F,E,W,S,T,M]);let _=ge();L(()=>{if(y&&_&&F==="visible"&&E.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[E,F,_,y]);let He=U&&!I,We=I&&T&&U,Ee=o.useRef(!1),X=zt(()=>{Ee.current||(A("hidden"),S(E))},H),_e=O(dt=>{Ee.current=!0;let qe=dt?"enter":"leave";X.onStart(E,qe,be=>{be==="enter"?i==null||i():be==="leave"&&(u==null||u())})}),P=O(dt=>{let qe=dt?"enter":"leave";Ee.current=!1,X.onStop(E,qe,be=>{be==="enter"?a==null||a():be==="leave"&&(s==null||s())}),qe==="leave"&&!je(X)&&(A("hidden"),S(E))});o.useEffect(()=>{y&&l||(_e(T),P(T))},[T,y,l]);let Be=!(!l||!y||!_||He),[,N]=rr(Be,m,T,{start:_e,end:P}),ol=R({ref:v,className:((r=Qe(d.className,We&&h,We&&c,N.enter&&h,N.enter&&N.closed&&c,N.enter&&!N.closed&&g,N.leave&&w,N.leave&&!N.closed&&f,N.leave&&N.closed&&x,!N.transition&&T&&b))==null?void 0:r.trim())||void 0,...nr(N)}),xe=0;F==="visible"&&(xe|=j.Open),F==="hidden"&&(xe|=j.Closed),N.enter&&(xe|=j.Opening),N.leave&&(xe|=j.Closing);let il=D();return o.createElement(De.Provider,{value:X},o.createElement(sr,{value:xe},il({ourProps:ol,theirProps:d,defaultTag:Gt,features:Kt,visible:F==="visible",name:"Transition.Child"})))}function Dr(e,t){let{show:n,appear:r=!1,unmount:l=!0,...i}=e,a=o.useRef(null),u=Yt(e),s=q(...u?[a,t]:t===null?[]:[t]);ge();let h=Ie();if(n===void 0&&h!==null&&(n=(h&j.Open)===j.Open),n===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[c,g]=o.useState(n?"visible":"hidden"),b=zt(()=>{n||g("hidden")}),[w,f]=o.useState(!0),x=o.useRef([n]);L(()=>{w!==!1&&x.current[x.current.length-1]!==n&&(x.current.push(n),f(!1))},[x,n]);let d=o.useMemo(()=>({show:n,appear:r,initial:w}),[n,r,w]);L(()=>{n?g("visible"):!je(b)&&a.current!==null&&g("hidden")},[n,b]);let m={unmount:l},p=O(()=>{var v;w&&f(!1),(v=e.beforeEnter)==null||v.call(e)}),E=O(()=>{var v;w&&f(!1),(v=e.beforeLeave)==null||v.call(e)}),y=D();return o.createElement(De.Provider,{value:b},o.createElement(Ae.Provider,{value:d},y({ourProps:{...m,as:o.Fragment,children:o.createElement(Zt,{ref:s,...m,...i,beforeEnter:p,beforeLeave:E})},theirProps:{},defaultTag:o.Fragment,features:Kt,visible:c==="visible",name:"Transition"})))}function jr(e,t){let n=o.useContext(Ae)!==null,r=Ie()!==null;return o.createElement(o.Fragment,null,!n&&r?o.createElement(st,{ref:t,...e}):o.createElement(Zt,{ref:t,...e}))}let st=k(Dr),Zt=k(Ar),ae=k(jr),Jt=Object.assign(st,{Child:ae,Root:st});var Ur=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Ur||{}),Hr=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Hr||{});let Wr={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},at=o.createContext(null);at.displayName="DialogContext";function Ue(e){let t=o.useContext(at);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 _r(e,t){return G(t.type,Wr,e,t)}let Qt=k(function(e,t){let n=o.useId(),{id:r=`headlessui-dialog-${n}`,open:l,onClose:i,initialFocus:a,role:u="dialog",autoFocus:s=!0,__demoMode:h=!1,unmount:c=!1,...g}=e,b=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(b.current||(b.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let w=Ie();l===void 0&&w!==null&&(l=(w&j.Open)===j.Open);let f=o.useRef(null),x=q(f,t),d=ve(f),m=l?0:1,[p,E]=o.useReducer(_r,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=O(()=>i(!1)),v=O(P=>E({type:0,id:P})),M=ge()?m===0:!1,[T,I]=gr(),U={get current(){var P;return(P=p.panelRef.current)!=null?P:f.current}},F=qt(),{resolveContainers:A}=yr({mainTreeNode:F,portals:T,defaultContainers:[U]}),H=w!==null?(w&j.Closing)===j.Closing:!1;In(h||H?!1:M,{allowed:O(()=>{var P,Be;return[(Be=(P=f.current)==null?void 0:P.closest("[data-headlessui-portal]"))!=null?Be:null]}),disallowed:O(()=>{var P;return[(P=F==null?void 0:F.closest("body > *:not(#headlessui-portal-root)"))!=null?P:null]})}),zn(M,A,P=>{P.preventDefault(),y()}),xr(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()}),Rn(h||H?!1:M,d,A),An(M,f,y);let[W,S]=Cn(),_=o.useMemo(()=>[{dialogState:m,close:y,setTitleId:v,unmount:c},p],[m,p,y,v,c]),He=o.useMemo(()=>({open:m===0}),[m]),We={ref:x,id:r,role:u,tabIndex:-1,"aria-modal":h?void 0:m===0?!0:void 0,"aria-labelledby":p.titleId,"aria-describedby":W,unmount:c},Ee=!br(),X=te.None;M&&!h&&(X|=te.RestoreFocus,X|=te.TabLock,s&&(X|=te.AutoFocus),Ee&&(X|=te.InitialFocus));let _e=D();return o.createElement(ar,null,o.createElement(jt,{force:!0},o.createElement(Er,null,o.createElement(at.Provider,{value:_},o.createElement(Wt,{target:f},o.createElement(jt,{force:!1},o.createElement(S,{slot:He},o.createElement(I,null,o.createElement(Or,{initialFocus:a,initialFocusFallback:f,containers:A,features:X},o.createElement(Ln,{value:y},_e({ourProps:We,theirProps:g,slot:He,defaultTag:Br,features:qr,visible:m===0,name:"Dialog"})))))))))))}),Br="div",qr=Pe.RenderStrategy|Pe.Static;function Xr(e,t){let{transition:n=!1,open:r,...l}=e,i=Ie(),a=e.hasOwnProperty("open")||i!==null,u=e.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&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?o.createElement(Bt,null,o.createElement(Jt,{show:r,transition:n,unmount:l.unmount},o.createElement(Qt,{ref:t,...l}))):o.createElement(Bt,null,o.createElement(Qt,{ref:t,open:r,...l}))}let Vr="div";function Yr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-panel-${n}`,transition:l=!1,...i}=e,[{dialogState:a,unmount:u},s]=Ue("Dialog.Panel"),h=q(t,s.panelRef),c=o.useMemo(()=>({open:a===0}),[a]),g=O(d=>{d.stopPropagation()}),b={ref:h,id:r,onClick:g},w=l?ae:o.Fragment,f=l?{unmount:u}:{},x=D();return o.createElement(w,{...f},x({ourProps:b,theirProps:i,slot:c,defaultTag:Vr,name:"Dialog.Panel"}))}let zr="div";function Gr(e,t){let{transition:n=!1,...r}=e,[{dialogState:l,unmount:i}]=Ue("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},s=n?ae:o.Fragment,h=n?{unmount:i}:{},c=D();return o.createElement(s,{...h},c({ourProps:u,theirProps:r,slot:a,defaultTag:zr,name:"Dialog.Backdrop"}))}let Kr="h2";function Zr(e,t){let n=o.useId(),{id:r=`headlessui-dialog-title-${n}`,...l}=e,[{dialogState:i,setTitleId:a}]=Ue("Dialog.Title"),u=q(t);o.useEffect(()=>(a(r),()=>a(null)),[r,a]);let s=o.useMemo(()=>({open:i===0}),[i]),h={ref:u,id:r};return D()({ourProps:h,theirProps:l,slot:s,defaultTag:Kr,name:"Dialog.Title"})}let Jr=k(Xr),ut=k(Yr);k(Gr);let Qr=k(Zr),Rr=Object.assign(Jr,{Panel:ut,Title:Qr,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 el=({modalContext:e,config:t,children:n})=>{const[r,l]=o.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(ae,{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]})})})})},tl=({modalContext:e,config:t,children:n})=>{const[r,l]=o.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(ae,{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=o.forwardRef(({name:e,children:t,onFocus:n=null,onBlur:r=null,onClose:l=null,onSuccess:i=null,onAfterLeave:a=null,...u},s)=>{const h=g=>typeof t=="function"?t(g):t,c=o.useRef(null);return o.useImperativeHandle(s,()=>c.current,[c]),$.jsx(Ke,{ref:c,name:e,onFocus:n,onBlur:r,onClose:l,onSuccess:i,...u,children:({afterLeave:g,close:b,config:w,emit:f,getChildModal:x,getParentModal:d,id:m,index:p,isOpen:E,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})=>$.jsx(Jt,{appear:!0,show:E??!1,afterLeave:a,children:$.jsxs(Rr,{as:"div",className:"im-dialog relative z-20",onClose:()=>w.closeExplicitly?null:b(),"data-inertiaui-modal-id":m,"data-inertiaui-modal-index":p,children:[p===0?$.jsx(ae,{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,p>0&&v?$.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,w.slideover?$.jsx(tl,{modalContext:y,config:w,children:h({afterLeave:g,close:b,config:w,emit:f,getChildModal:x,getParentModal:d,id:m,index:p,isOpen:E,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})}):$.jsx(el,{modalContext:y,config:w,children:h({afterLeave:g,close:b,config:w,emit:f,getChildModal:x,getParentModal:d,id:m,index:p,isOpen:E,modalContext:y,onTopOfStack:v,reload:M,setOpen:T,shouldRender:I})})]})})})});en.displayName="Modal";const nl=({href:e,method:t="get",data:n={},as:r="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:s=null,onError:h=null,onFocus:c=null,onStart:g=null,onSuccess:b=null,navigate:w=null,children:f,...x})=>{const[d,m]=o.useState(!1),[p,E]=o.useState(null),{stack:y,visit:v}=fe(),M=o.useMemo(()=>w??Me("navigate"),[w]),T={},I={};Object.keys(x).forEach(S=>{ht.includes(S)||(S.startsWith("on")&&typeof x[S]=="function"?S.toLowerCase()in window?T[S]=x[S]:I[S]=x[S]:T[S]=x[S])});const[U,F]=o.useState(!1);o.useEffect(()=>{p&&(p.onTopOfStack&&U?c==null||c():!p.onTopOfStack&&!U&&(u==null||u()),F(!p.onTopOfStack))},[y]);const A=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{E(null),a==null||a()},[a]),W=o.useCallback(S=>{S==null||S.preventDefault(),!d&&(e.startsWith("#")||(m(!0),g==null||g()),v(e,t,n,l,dn(ct(x,ht)),()=>A(y.length),H,i,M).then(_=>{E(_),_.registerEventListenersFromProps(I),b==null||b()}).catch(_=>{console.error(_),h==null||h(_)}).finally(()=>m(!1)))},[e,t,n,l,i,x,A,H]);return $.jsx(r,{...T,href:e,onClick:W,children:typeof f=="function"?f({loading:d}):f})};function rl(){return fe().stack[Ge()]??null}const ll=e=>t=>(t.default.layout=n=>o.createElement(e,{},n),t);C.HeadlessModal=Ke,C.Modal=en,C.ModalLink=nl,C.ModalRoot=gt,C.ModalStackProvider=pt,C.getConfig=Me,C.initFromPageProps=vt,C.putConfig=sn,C.renderApp=fn,C.resetConfig=on,C.setPageLayout=ll,C.useModal=rl,C.useModalIndex=Ge,C.useModalStack=fe,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
|
4
|
+
`))}else{let E=h.props,w=E==null?void 0:E.className,m=typeof w=="function"?(...c)=>it(w(...c),s.className):it(w,s.className),$=m?{className:m}:{},v=It(h.props,re(st(s,["ref"])));for(let c in b)c in v&&delete b[c];return o.cloneElement(h,Object.assign({},v,b,d,{ref:l(Gr(h),d.ref)},$))}return o.createElement(i,Object.assign({},st(s,["ref"]),i!==o.Fragment&&d,i!==o.Fragment&&b),h)}function Xr(){let e=o.useRef([]),t=o.useCallback(r=>{for(let n of e.current)n!=null&&(typeof n=="function"?n(r):n.current=r)},[]);return(...r)=>{if(!r.every(n=>n==null))return e.current=r,t}}function zr(...e){return e.every(t=>t==null)?void 0:t=>{for(let r of e)r!=null&&(typeof r=="function"?r(t):r.current=t)}}function It(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},r={};for(let n of e)for(let l in n)l.startsWith("on")&&typeof n[l]=="function"?(r[l]!=null||(r[l]=[]),r[l].push(n[l])):t[l]=n[l];if(t.disabled||t["aria-disabled"])for(let n in r)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(n)&&(r[n]=[l=>{var i;return(i=l==null?void 0:l.preventDefault)==null?void 0:i.call(l)}]);for(let n in r)Object.assign(t,{[n](l,...i){let a=r[n];for(let u of a){if((l instanceof Event||(l==null?void 0:l.nativeEvent)instanceof Event)&&l.defaultPrevented)return;u(l,...i)}}});return t}function N(e){var t;return Object.assign(o.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function re(e){let t=Object.assign({},e);for(let r in t)t[r]===void 0&&delete t[r];return t}function st(e,t=[]){let r=Object.assign({},e);for(let n of t)n in r&&delete r[n];return r}function Gr(e){return o.version.split(".")[0]>="19"?e.props.ref:e.ref}let Kr="span";var je=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(je||{});function Yr(e,t){var r;let{features:n=1,...l}=e,i={ref:t,"aria-hidden":(n&2)===2?!0:(r=l["aria-hidden"])!=null?r:void 0,hidden:(n&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",...(n&4)===4&&(n&2)!==2&&{display:"none"}}};return j()({ourProps:i,theirProps:l,slot:{},defaultTag:Kr,name:"Hidden"})}let ut=N(Yr);function Nt(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Z(e){return Nt(e)&&"tagName"in e}function ne(e){return Z(e)&&"accessKey"in e}function J(e){return Z(e)&&"tabIndex"in e}function Zr(e){return Z(e)&&"style"in e}function Jr(e){return ne(e)&&e.nodeName==="IFRAME"}function Qr(e){return ne(e)&&e.nodeName==="INPUT"}let Dt=Symbol();function Rr(e,t=!0){return Object.assign(e,{[Dt]:t})}function B(...e){let t=o.useRef(e);o.useEffect(()=>{t.current=e},[e]);let r=P(n=>{for(let l of t.current)l!=null&&(typeof l=="function"?l(n):l.current=n)});return e.every(n=>n==null||(n==null?void 0:n[Dt]))?void 0:r}let at=o.createContext(null);at.displayName="DescriptionContext";function jt(){let e=o.useContext(at);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,jt),t}return e}function en(){let[e,t]=o.useState([]);return[e.length>0?e.join(" "):void 0,o.useMemo(()=>function(r){let n=P(i=>(t(a=>[...a,i]),()=>t(a=>{let u=a.slice(),s=u.indexOf(i);return s!==-1&&u.splice(s,1),u}))),l=o.useMemo(()=>({register:n,slot:r.slot,name:r.name,props:r.props,value:r.value}),[n,r.slot,r.name,r.props,r.value]);return o.createElement(at.Provider,{value:l},r.children)},[t])]}let tn="p";function rn(e,t){let r=o.useId(),n=Br(),{id:l=`headlessui-description-${r}`,...i}=e,a=jt(),u=B(t);L(()=>a.register(l),[l,a.register]);let s=n||!1,d=o.useMemo(()=>({...a.slot,disabled:s}),[a.slot,s]),h={ref:u,...a.props,id:l};return j()({ourProps:h,theirProps:i,slot:d,defaultTag:tn,name:a.name||"Description"})}let nn=N(rn),ln=Object.assign(nn,{});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 on=o.createContext(()=>{});function sn({value:e,children:t}){return o.createElement(on.Provider,{value:e},t)}let Wt=class extends Map{constructor(t){super(),this.factory=t}get(t){let r=super.get(t);return r===void 0&&(r=this.factory(t),this.set(t,r)),r}};var un=Object.defineProperty,an=(e,t,r)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dn=(e,t,r)=>(an(e,t+"",r),r),Ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},_=(e,t,r)=>(Ut(e,t,"read from private field"),r?r.call(e):t.get(e)),dt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ht=(e,t,r,n)=>(Ut(e,t,"write to private field"),t.set(e,r),r),q,we,be;let cn=class{constructor(t){dt(this,q,{}),dt(this,we,new Wt(()=>new Set)),dt(this,be,new Set),dn(this,"disposables",X()),Ht(this,q,t)}dispose(){this.disposables.dispose()}get state(){return _(this,q)}subscribe(t,r){let n={selector:t,callback:r,current:t(_(this,q))};return _(this,be).add(n),this.disposables.add(()=>{_(this,be).delete(n)})}on(t,r){return _(this,we).get(t).add(r),this.disposables.add(()=>{_(this,we).get(t).delete(r)})}send(t){let r=this.reduce(_(this,q),t);if(r!==_(this,q)){Ht(this,q,r);for(let n of _(this,be)){let l=n.selector(_(this,q));Vt(n.current,l)||(n.current=l,n.callback(l))}for(let n of _(this,we).get(t.type))n(_(this,q),t)}}};q=new WeakMap,we=new WeakMap,be=new WeakMap;function Vt(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null?!1:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:ct(e[Symbol.iterator](),t[Symbol.iterator]()):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?e.size!==t.size?!1:ct(e.entries(),t.entries()):Bt(e)&&Bt(t)?ct(Object.entries(e)[Symbol.iterator](),Object.entries(t)[Symbol.iterator]()):!1}function ct(e,t){do{let r=e.next(),n=t.next();if(r.done&&n.done)return!0;if(r.done||n.done||!Object.is(r.value,n.value))return!1}while(!0)}function Bt(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}var fn=Object.defineProperty,mn=(e,t,r)=>t in e?fn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qt=(e,t,r)=>(mn(e,typeof t!="symbol"?t+"":t,r),r),pn=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(pn||{});let hn={0(e,t){let r=t.id,n=e.stack,l=e.stack.indexOf(r);if(l!==-1){let i=e.stack.slice();return i.splice(l,1),i.push(r),n=i,{...e,stack:n}}return{...e,stack:[...e.stack,r]}},1(e,t){let r=t.id,n=e.stack.indexOf(r);if(n===-1)return e;let l=e.stack.slice();return l.splice(n,1),{...e,stack:l}}},vn=class Cr extends cn{constructor(){super(...arguments),qt(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})}),qt(this,"selectors",{isTop:(t,r)=>t.stack[t.stack.length-1]===r,inStack:(t,r)=>t.stack.includes(r)})}static new(){return new Cr({stack:[]})}reduce(t,r){return z(r.type,hn,t,r)}};const Xt=new Wt(()=>vn.new());var _e={exports:{}},ft={};/**
|
|
5
|
+
* @license React
|
|
6
|
+
* use-sync-external-store-with-selector.production.js
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/var zt;function gn(){if(zt)return ft;zt=1;var e=o;function t(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,l=e.useRef,i=e.useEffect,a=e.useMemo,u=e.useDebugValue;return ft.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var O=b(p);return E!==void 0&&E(x,O)?(f=p,x):(f=p,g=O)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},ft}var mt={};/**
|
|
13
|
+
* @license React
|
|
14
|
+
* use-sync-external-store-with-selector.development.js
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the MIT license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*/var Gt;function wn(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&function(){function e(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=o,r=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,l=t.useRef,i=t.useEffect,a=t.useMemo,u=t.useDebugValue;mt.useSyncExternalStoreWithSelector=function(s,d,h,b,E){var w=l(null);if(w.current===null){var m={hasValue:!1,value:null};w.current=m}else m=w.current;w=a(function(){function v(p){if(!c){if(c=!0,f=p,p=b(p),E!==void 0&&m.hasValue){var x=m.value;if(E(x,p))return g=x}return g=p}if(x=g,r(f,p))return x;var O=b(p);return E!==void 0&&E(x,O)?(f=p,x):(f=p,g=O)}var c=!1,f,g,y=h===void 0?null:h;return[function(){return v(d())},y===null?void 0:function(){return v(y())}]},[d,h,b,E]);var $=n(s,w[0],w[1]);return i(function(){m.hasValue=!0,m.value=$},[$]),u($),$},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),mt}var Kt;function bn(){return Kt||(Kt=1,process.env.NODE_ENV==="production"?_e.exports=gn():_e.exports=wn()),_e.exports}var yn=bn();function Yt(e,t,r=Vt){return yn.useSyncExternalStoreWithSelector(P(n=>e.subscribe(En,n)),P(()=>e.state),P(()=>e.state),P(t),r)}function En(e){return e}function ye(e,t){let r=o.useId(),n=Xt.get(t),[l,i]=Yt(n,o.useCallback(a=>[n.selectors.isTop(a,r),n.selectors.inStack(a,r)],[n,r]));return L(()=>{if(e)return n.actions.push(r),()=>n.actions.pop(r)},[n,e,r]),e?i?l:!0:!1}let pt=new Map,Ee=new Map;function Zt(e){var t;let r=(t=Ee.get(e))!=null?t:0;return Ee.set(e,r+1),r!==0?()=>Jt(e):(pt.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Jt(e))}function Jt(e){var t;let r=(t=Ee.get(e))!=null?t:1;if(r===1?Ee.delete(e):Ee.set(e,r-1),r!==1)return;let n=pt.get(e);n&&(n["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert,pt.delete(e))}function xn(e,{allowed:t,disallowed:r}={}){let n=ye(e,"inert-others");L(()=>{var l,i;if(!n)return;let a=X();for(let s of(l=r==null?void 0:r())!=null?l:[])s&&a.add(Zt(s));let u=(i=t==null?void 0:t())!=null?i:[];for(let s of u){if(!s)continue;let d=Ae(s);if(!d)continue;let h=s.parentElement;for(;h&&h!==d.body;){for(let b of h.children)u.some(E=>b.contains(E))||a.add(Zt(b));h=h.parentElement}}return a.dispose},[n,t,r])}function $n(e,t,r){let n=te(l=>{let i=l.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&r()});o.useEffect(()=>{if(!e)return;let l=t===null?null:ne(t)?t:t.current;if(!l)return;let i=X();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>n.current(l));a.observe(l),i.add(()=>a.disconnect())}return()=>i.dispose()},[t,n,e])}let We=["[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(","),Sn=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var G=(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))(G||{}),ht=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(ht||{}),On=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(On||{});function Mn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(We)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}function Cn(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(Sn)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}var Qt=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Qt||{});function Pn(e,t=0){var r;return e===((r=Ae(e))==null?void 0:r.body)?!1:z(t,{0(){return e.matches(We)},1(){let n=e;for(;n!==null;){if(n.matches(We))return!0;n=n.parentElement}return!1}})}var Tn=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Tn||{});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 K(e){e==null||e.focus({preventScroll:!0})}let kn=["textarea","input"].join(",");function Fn(e){var t,r;return(r=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,kn))!=null?r:!1}function Ln(e,t=r=>r){return e.slice().sort((r,n)=>{let l=t(r),i=t(n);if(l===null||i===null)return 0;let a=l.compareDocumentPosition(i);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function xe(e,t,{sorted:r=!0,relativeTo:n=null,skipElements:l=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?r?Ln(e):e:t&64?Cn(e):Mn(e);l.length>0&&a.length>1&&(a=a.filter(w=>!l.some(m=>m!=null&&"current"in m?(m==null?void 0:m.current)===w:m===w))),n=n??i.activeElement;let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,a.indexOf(n))-1;if(t&4)return Math.max(0,a.indexOf(n))+1;if(t&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=t&32?{preventScroll:!0}:{},h=0,b=a.length,E;do{if(h>=b||h+b<=0)return 0;let w=s+h;if(t&16)w=(w+b)%b;else{if(w<0)return 3;if(w>=b)return 1}E=a[w],E==null||E.focus(d),h+=u}while(E!==i.activeElement);return t&6&&Fn(E)&&E.select(),2}function Rt(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function An(){return/Android/gi.test(window.navigator.userAgent)}function er(){return Rt()||An()}function Ue(e,t,r,n){let l=te(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return document.addEventListener(t,i,n),()=>document.removeEventListener(t,i,n)},[e,t,n])}function tr(e,t,r,n){let l=te(r);o.useEffect(()=>{if(!e)return;function i(a){l.current(a)}return window.addEventListener(t,i,n),()=>window.removeEventListener(t,i,n)},[e,t,n])}const rr=30;function In(e,t,r){let n=te(r),l=o.useCallback(function(u,s){if(u.defaultPrevented)return;let d=s(u);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let h=function b(E){return typeof E=="function"?b(E()):Array.isArray(E)||E instanceof Set?E:[E]}(t);for(let b of h)if(b!==null&&(b.contains(d)||u.composed&&u.composedPath().includes(b)))return;return!Pn(d,Qt.Loose)&&d.tabIndex!==-1&&u.preventDefault(),n.current(u,d)},[n,t]),i=o.useRef(null);Ue(e,"pointerdown",u=>{var s,d;er()||(i.current=((d=(s=u.composedPath)==null?void 0:s.call(u))==null?void 0:d[0])||u.target)},!0),Ue(e,"pointerup",u=>{if(er()||!i.current)return;let s=i.current;return i.current=null,l(u,()=>s)},!0);let a=o.useRef({x:0,y:0});Ue(e,"touchstart",u=>{a.current.x=u.touches[0].clientX,a.current.y=u.touches[0].clientY},!0),Ue(e,"touchend",u=>{let s={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(s.x-a.current.x)>=rr||Math.abs(s.y-a.current.y)>=rr))return l(u,()=>J(u.target)?u.target:null)},!0),tr(e,"blur",u=>l(u,()=>Jr(window.document.activeElement)?window.document.activeElement:null),!0)}function He(...e){return o.useMemo(()=>Ae(...e),[...e])}function nr(e,t,r,n){let l=te(r);o.useEffect(()=>{e=e??window;function i(a){l.current(a)}return e.addEventListener(t,i,n),()=>e.removeEventListener(t,i,n)},[e,t,n])}function Nn(e){return o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Dn(e,t){let r=e(),n=new Set;return{getSnapshot(){return r},subscribe(l){return n.add(l),()=>n.delete(l)},dispatch(l,...i){let a=t[l].call(r,...i);a&&(r=a,n.forEach(u=>u()))}}}function jn(){let e;return{before({doc:t}){var r;let n=t.documentElement,l=(r=t.defaultView)!=null?r:window;e=Math.max(0,l.innerWidth-n.clientWidth)},after({doc:t,d:r}){let n=t.documentElement,l=Math.max(0,n.clientWidth-n.offsetWidth),i=Math.max(0,e-l);r.style(n,"paddingRight",`${i}px`)}}}function _n(){return Rt()?{before({doc:e,d:t,meta:r}){function n(l){return r.containers.flatMap(i=>i()).some(i=>i.contains(l))}t.microTask(()=>{var l;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=X();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let i=(l=window.scrollY)!=null?l:window.pageYOffset,a=null;t.addEventListener(e,"click",u=>{if(J(u.target))try{let s=u.target.closest("a");if(!s)return;let{hash:d}=new URL(s.href),h=e.querySelector(d);J(h)&&!n(h)&&(a=h)}catch{}},!0),t.addEventListener(e,"touchstart",u=>{if(J(u.target)&&Zr(u.target))if(n(u.target)){let s=u.target;for(;s.parentElement&&n(s.parentElement);)s=s.parentElement;t.style(s,"overscrollBehavior","contain")}else t.style(u.target,"touchAction","none")}),t.addEventListener(e,"touchmove",u=>{if(J(u.target)){if(Qr(u.target))return;if(n(u.target)){let s=u.target;for(;s.parentElement&&s.dataset.headlessuiPortal!==""&&!(s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth);)s=s.parentElement;s.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let s=(u=window.scrollY)!=null?u:window.pageYOffset;i!==s&&window.scrollTo(0,i),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function Wn(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Un(e){let t={};for(let r of e)Object.assign(t,r(t));return t}let le=Dn(()=>new Map,{PUSH(e,t){var r;let n=(r=this.get(e))!=null?r:{doc:e,count:0,d:X(),meta:new Set};return n.count++,n.meta.add(t),this.set(e,n),this},POP(e,t){let r=this.get(e);return r&&(r.count--,r.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:r}){let n={doc:e,d:t,meta:Un(r)},l=[_n(),jn(),Wn()];l.forEach(({before:i})=>i==null?void 0:i(n)),l.forEach(({after:i})=>i==null?void 0:i(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});le.subscribe(()=>{let e=le.getSnapshot(),t=new Map;for(let[r]of e)t.set(r,r.documentElement.style.overflow);for(let r of e.values()){let n=t.get(r.doc)==="hidden",l=r.count!==0;(l&&!n||!l&&n)&&le.dispatch(r.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",r),r.count===0&&le.dispatch("TEARDOWN",r)}});function Hn(e,t,r=()=>({containers:[]})){let n=Nn(le),l=t?n.get(t):void 0,i=l?l.count>0:!1;return L(()=>{if(!(!t||!e))return le.dispatch("PUSH",t,r),()=>le.dispatch("POP",t,r)},[e,t]),i}function Vn(e,t,r=()=>[document.body]){let n=ye(e,"scroll-lock");Hn(n,t,l=>{var i;return{containers:[...(i=l.containers)!=null?i:[],r]}})}function Bn(e=0){let[t,r]=o.useState(e),n=o.useCallback(s=>r(s),[t]),l=o.useCallback(s=>r(d=>d|s),[t]),i=o.useCallback(s=>(t&s)===s,[t]),a=o.useCallback(s=>r(d=>d&~s),[r]),u=o.useCallback(s=>r(d=>d^s),[r]);return{flags:t,setFlag:n,addFlag:l,hasFlag:i,removeFlag:a,toggleFlag:u}}var lr,or;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((lr=process==null?void 0:process.env)==null?void 0:lr.NODE_ENV)==="test"&&typeof((or=Element==null?void 0:Element.prototype)==null?void 0:or.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(`
|
|
21
|
+
`)),[]});var qn=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(qn||{});function Xn(e){let t={};for(let r in e)e[r]===!0&&(t[`data-${r}`]="");return t}function zn(e,t,r,n){let[l,i]=o.useState(r),{hasFlag:a,addFlag:u,removeFlag:s}=Bn(e&&l?3:0),d=o.useRef(!1),h=o.useRef(!1),b=ot();return L(()=>{var E;if(e){if(r&&i(!0),!t){r&&u(3);return}return(E=n==null?void 0:n.start)==null||E.call(n,r),Gn(t,{inFlight:d,prepare(){h.current?h.current=!1:h.current=d.current,d.current=!0,!h.current&&(r?(u(3),s(4)):(u(4),s(2)))},run(){h.current?r?(s(3),u(4)):(s(4),u(3)):r?s(1):u(1)},done(){var w;h.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(d.current=!1,s(7),r||i(!1),(w=n==null?void 0:n.end)==null||w.call(n,r))}})}},[e,r,t,b]),e?[l,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[r,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function Gn(e,{prepare:t,run:r,done:n,inFlight:l}){let i=X();return Yn(e,{prepare:t,inFlight:l}),i.nextFrame(()=>{r(),i.requestAnimationFrame(()=>{i.add(Kn(e,n))})}),i.dispose}function Kn(e,t){var r,n;let l=X();if(!e)return l.dispose;let i=!1;l.add(()=>{i=!0});let a=(n=(r=e.getAnimations)==null?void 0:r.call(e).filter(u=>u instanceof CSSTransition))!=null?n:[];return a.length===0?(t(),l.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{i||t()}),l.dispose)}function Yn(e,{inFlight:t,prepare:r}){if(t!=null&&t.current){r();return}let n=e.style.transition;e.style.transition="none",r(),e.offsetHeight,e.style.transition=n}function vt(e,t){let r=o.useRef([]),n=P(e);o.useEffect(()=>{let l=[...r.current];for(let[i,a]of t.entries())if(r.current[i]!==a){let u=n(t,l);return r.current=t,u}},[n,...t])}let Ve=o.createContext(null);Ve.displayName="OpenClosedContext";var W=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(W||{});function Be(){return o.useContext(Ve)}function Zn({value:e,children:t}){return o.createElement(Ve.Provider,{value:e},t)}function Jn({children:e}){return o.createElement(Ve.Provider,{value:null},e)}function Qn(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Q=[];Qn(()=>{function e(t){if(!J(t.target)||t.target===document.body||Q[0]===t.target)return;let r=t.target;r=r.closest(We),Q.unshift(r??t.target),Q=Q.filter(n=>n!=null&&n.isConnected),Q.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 ir(e){let t=P(e),r=o.useRef(!1);o.useEffect(()=>(r.current=!1,()=>{r.current=!0,Ie(()=>{r.current&&t()})}),[t])}function Rn(){let e=typeof document>"u";return"useSyncExternalStore"in pe?(t=>t.useSyncExternalStore)(pe)(()=>()=>{},()=>!1,()=>!e):!1}function $e(){let e=Rn(),[t,r]=pe.useState(ee.isHandoffComplete);return t&&ee.isHandoffComplete===!1&&r(!1),pe.useEffect(()=>{t!==!0&&r(!0)},[t]),pe.useEffect(()=>ee.handoff(),[]),e?!1:t}let sr=o.createContext(!1);function el(){return o.useContext(sr)}function ur(e){return o.createElement(sr.Provider,{value:e.force},e.children)}function tl(e){let t=el(),r=o.useContext(dr),[n,l]=o.useState(()=>{var i;if(!t&&r!==null)return(i=r.current)!=null?i:null;if(ee.isServer)return null;let a=e==null?void 0:e.getElementById("headlessui-portal-root");if(a)return a;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return o.useEffect(()=>{n!==null&&(e!=null&&e.body.contains(n)||e==null||e.body.appendChild(n))},[n,e]),o.useEffect(()=>{t||r!==null&&l(r.current)},[r,l,t]),n}let ar=o.Fragment,rl=N(function(e,t){let{ownerDocument:r=null,...n}=e,l=o.useRef(null),i=B(Rr(w=>{l.current=w}),t),a=He(l),u=r??a,s=tl(u),[d]=o.useState(()=>{var w;return ee.isServer?null:(w=u==null?void 0:u.createElement("div"))!=null?w:null}),h=o.useContext(gt),b=$e();L(()=>{!s||!d||s.contains(d)||(d.setAttribute("data-headlessui-portal",""),s.appendChild(d))},[s,d]),L(()=>{if(d&&h)return h.register(d)},[h,d]),ir(()=>{var w;!s||!d||(Nt(d)&&s.contains(d)&&s.removeChild(d),s.childNodes.length<=0&&((w=s.parentElement)==null||w.removeChild(s)))});let E=j();return b?!s||!d?null:Tr.createPortal(E({ourProps:{ref:i},theirProps:n,slot:{},defaultTag:ar,name:"Portal"}),d):null});function nl(e,t){let r=B(t),{enabled:n=!0,ownerDocument:l,...i}=e,a=j();return n?o.createElement(rl,{...i,ownerDocument:l,ref:r}):a({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:ar,name:"Portal"})}let ll=o.Fragment,dr=o.createContext(null);function ol(e,t){let{target:r,...n}=e,l={ref:B(t)},i=j();return o.createElement(dr.Provider,{value:r},i({ourProps:l,theirProps:n,defaultTag:ll,name:"Popover.Group"}))}let gt=o.createContext(null);function il(){let e=o.useContext(gt),t=o.useRef([]),r=P(i=>(t.current.push(i),e&&e.register(i),()=>n(i))),n=P(i=>{let a=t.current.indexOf(i);a!==-1&&t.current.splice(a,1),e&&e.unregister(i)}),l=o.useMemo(()=>({register:r,unregister:n,portals:t}),[r,n,t]);return[t,o.useMemo(()=>function({children:i}){return o.createElement(gt.Provider,{value:l},i)},[l])]}let sl=N(nl),cr=N(ol),ul=Object.assign(sl,{Group:cr});function al(e,t=typeof document<"u"?document.defaultView:null,r){let n=ye(e,"escape");nr(t,"keydown",l=>{n&&(l.defaultPrevented||l.key===_t.Escape&&r(l))})}function dl(){var e;let[t]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[r,n]=o.useState((e=t==null?void 0:t.matches)!=null?e:!1);return L(()=>{if(!t)return;function l(i){n(i.matches)}return t.addEventListener("change",l),()=>t.removeEventListener("change",l)},[t]),r}function cl({defaultContainers:e=[],portals:t,mainTreeNode:r}={}){let n=He(r),l=P(()=>{var i,a;let u=[];for(let s of e)s!==null&&(Z(s)?u.push(s):"current"in s&&Z(s.current)&&u.push(s.current));if(t!=null&&t.current)for(let s of t.current)u.push(s);for(let s of(i=n==null?void 0:n.querySelectorAll("html > *, body > *"))!=null?i:[])s!==document.body&&s!==document.head&&Z(s)&&s.id!=="headlessui-portal-root"&&(r&&(s.contains(r)||s.contains((a=r==null?void 0:r.getRootNode())==null?void 0:a.host))||u.some(d=>s.contains(d))||u.push(s));return u});return{resolveContainers:l,contains:P(i=>l().some(a=>a.contains(i)))}}let fr=o.createContext(null);function mr({children:e,node:t}){let[r,n]=o.useState(null),l=pr(t??r);return o.createElement(fr.Provider,{value:l},e,l===null&&o.createElement(ut,{features:je.Hidden,ref:i=>{var a,u;if(i){for(let s of(u=(a=Ae(i))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(s!==document.body&&s!==document.head&&Z(s)&&s!=null&&s.contains(i)){n(s);break}}}}))}function pr(e=null){var t;return(t=o.useContext(fr))!=null?t:e}function wt(){let e=o.useRef(!1);return L(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Se=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Se||{});function fl(){let e=o.useRef(0);return tr(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function hr(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let r of e.current)Z(r.current)&&t.add(r.current);return t}let ml="div";var oe=(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))(oe||{});function pl(e,t){let r=o.useRef(null),n=B(r,t),{initialFocus:l,initialFocusFallback:i,containers:a,features:u=15,...s}=e;$e()||(u=0);let d=He(r);wl(u,{ownerDocument:d});let h=bl(u,{ownerDocument:d,container:r,initialFocus:l,initialFocusFallback:i});yl(u,{ownerDocument:d,container:r,containers:a,previousActiveElement:h});let b=fl(),E=P(f=>{if(!ne(r.current))return;let g=r.current;(y=>y())(()=>{z(b.current,{[Se.Forwards]:()=>{xe(g,G.First,{skipElements:[f.relatedTarget,i]})},[Se.Backwards]:()=>{xe(g,G.Last,{skipElements:[f.relatedTarget,i]})}})})}),w=ye(!!(u&2),"focus-trap#tab-lock"),m=ot(),$=o.useRef(!1),v={ref:n,onKeyDown(f){f.key=="Tab"&&($.current=!0,m.requestAnimationFrame(()=>{$.current=!1}))},onBlur(f){if(!(u&4))return;let g=hr(a);ne(r.current)&&g.add(r.current);let y=f.relatedTarget;J(y)&&y.dataset.headlessuiFocusGuard!=="true"&&(vr(g,y)||($.current?xe(r.current,z(b.current,{[Se.Forwards]:()=>G.Next,[Se.Backwards]:()=>G.Previous})|G.WrapAround,{relativeTo:f.target}):J(f.target)&&K(f.target)))}},c=j();return o.createElement(o.Fragment,null,w&&o.createElement(ut,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:je.Focusable}),c({ourProps:v,theirProps:s,defaultTag:ml,name:"FocusTrap"}),w&&o.createElement(ut,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:E,features:je.Focusable}))}let hl=N(pl),vl=Object.assign(hl,{features:oe});function gl(e=!0){let t=o.useRef(Q.slice());return vt(([r],[n])=>{n===!0&&r===!1&&Ie(()=>{t.current.splice(0)}),n===!1&&r===!0&&(t.current=Q.slice())},[e,Q,t]),P(()=>{var r;return(r=t.current.find(n=>n!=null&&n.isConnected))!=null?r:null})}function wl(e,{ownerDocument:t}){let r=!!(e&8),n=gl(r);vt(()=>{r||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&K(n())},[r]),ir(()=>{r&&K(n())})}function bl(e,{ownerDocument:t,container:r,initialFocus:n,initialFocusFallback:l}){let i=o.useRef(null),a=ye(!!(e&1),"focus-trap#initial-focus"),u=wt();return vt(()=>{if(e===0)return;if(!a){l!=null&&l.current&&K(l.current);return}let s=r.current;s&&Ie(()=>{if(!u.current)return;let d=t==null?void 0:t.activeElement;if(n!=null&&n.current){if((n==null?void 0:n.current)===d){i.current=d;return}}else if(s.contains(d)){i.current=d;return}if(n!=null&&n.current)K(n.current);else{if(e&16){if(xe(s,G.First|G.AutoFocus)!==ht.Error)return}else if(xe(s,G.First)!==ht.Error)return;if(l!=null&&l.current&&(K(l.current),(t==null?void 0:t.activeElement)===l.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=t==null?void 0:t.activeElement})},[l,a,e]),i}function yl(e,{ownerDocument:t,container:r,containers:n,previousActiveElement:l}){let i=wt(),a=!!(e&4);nr(t==null?void 0:t.defaultView,"focus",u=>{if(!a||!i.current)return;let s=hr(n);ne(r.current)&&s.add(r.current);let d=l.current;if(!d)return;let h=u.target;ne(h)?vr(s,h)?(l.current=h,K(h)):(u.preventDefault(),u.stopPropagation(),K(d)):K(l.current)},!0)}function vr(e,t){for(let r of e)if(r.contains(t))return!0;return!1}function gr(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||((t=e.as)!=null?t:br)!==o.Fragment||o.Children.count(e.children)===1}let qe=o.createContext(null);qe.displayName="TransitionContext";var El=(e=>(e.Visible="visible",e.Hidden="hidden",e))(El||{});function xl(){let e=o.useContext(qe);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function $l(){let e=o.useContext(Xe);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Xe=o.createContext(null);Xe.displayName="NestingContext";function ze(e){return"children"in e?ze(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function wr(e,t){let r=te(e),n=o.useRef([]),l=wt(),i=ot(),a=P((w,m=Y.Hidden)=>{let $=n.current.findIndex(({el:v})=>v===w);$!==-1&&(z(m,{[Y.Unmount](){n.current.splice($,1)},[Y.Hidden](){n.current[$].state="hidden"}}),i.microTask(()=>{var v;!ze(n)&&l.current&&((v=r.current)==null||v.call(r))}))}),u=P(w=>{let m=n.current.find(({el:$})=>$===w);return m?m.state!=="visible"&&(m.state="visible"):n.current.push({el:w,state:"visible"}),()=>a(w,Y.Unmount)}),s=o.useRef([]),d=o.useRef(Promise.resolve()),h=o.useRef({enter:[],leave:[]}),b=P((w,m,$)=>{s.current.splice(0),t&&(t.chains.current[m]=t.chains.current[m].filter(([v])=>v!==w)),t==null||t.chains.current[m].push([w,new Promise(v=>{s.current.push(v)})]),t==null||t.chains.current[m].push([w,new Promise(v=>{Promise.all(h.current[m].map(([c,f])=>f)).then(()=>v())})]),m==="enter"?d.current=d.current.then(()=>t==null?void 0:t.wait.current).then(()=>$(m)):$(m)}),E=P((w,m,$)=>{Promise.all(h.current[m].splice(0).map(([v,c])=>c)).then(()=>{var v;(v=s.current.shift())==null||v()}).then(()=>$(m))});return o.useMemo(()=>({children:n,register:u,unregister:a,onStart:b,onStop:E,wait:d,chains:h}),[u,a,n,b,E,h,d])}let br=o.Fragment,yr=Ne.RenderStrategy;function Sl(e,t){var r,n;let{transition:l=!0,beforeEnter:i,afterEnter:a,beforeLeave:u,afterLeave:s,enter:d,enterFrom:h,enterTo:b,entered:E,leave:w,leaveFrom:m,leaveTo:$,...v}=e,[c,f]=o.useState(null),g=o.useRef(null),y=gr(e),p=B(...y?[g,t,f]:t===null?[]:[t]),x=(r=v.unmount)==null||r?Y.Unmount:Y.Hidden,{show:O,appear:F,initial:U}=xl(),[k,D]=o.useState(O?"visible":"hidden"),H=$l(),{register:A,unregister:T}=H;L(()=>A(g),[A,g]),L(()=>{if(x===Y.Hidden&&g.current){if(O&&k!=="visible"){D("visible");return}return z(k,{hidden:()=>T(g),visible:()=>A(g)})}},[k,g,A,T,O,x]);let I=$e();L(()=>{if(y&&I&&k==="visible"&&g.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[g,k,I,y]);let xt=U&&!F,Ke=F&&O&&U,fe=o.useRef(!1),me=wr(()=>{fe.current||(D("hidden"),T(g))},H),Ye=P(St=>{fe.current=!0;let Je=St?"enter":"leave";me.onStart(g,Je,Me=>{Me==="enter"?i==null||i():Me==="leave"&&(u==null||u())})}),R=P(St=>{let Je=St?"enter":"leave";fe.current=!1,me.onStop(g,Je,Me=>{Me==="enter"?a==null||a():Me==="leave"&&(s==null||s())}),Je==="leave"&&!ze(me)&&(D("hidden"),T(g))});o.useEffect(()=>{y&&l||(Ye(O),R(O))},[O,y,l]);let $t=!(!l||!y||!I||xt),[,C]=zn($t,c,O,{start:Ye,end:R}),Ze=re({ref:p,className:((n=it(v.className,Ke&&d,Ke&&h,C.enter&&d,C.enter&&C.closed&&h,C.enter&&!C.closed&&b,C.leave&&w,C.leave&&!C.closed&&m,C.leave&&C.closed&&$,!C.transition&&O&&E))==null?void 0:n.trim())||void 0,...Xn(C)}),Oe=0;k==="visible"&&(Oe|=W.Open),k==="hidden"&&(Oe|=W.Closed),O&&k==="hidden"&&(Oe|=W.Opening),!O&&k==="visible"&&(Oe|=W.Closing);let Gl=j();return o.createElement(Xe.Provider,{value:me},o.createElement(Zn,{value:Oe},Gl({ourProps:Ze,theirProps:v,defaultTag:br,features:yr,visible:k==="visible",name:"Transition.Child"})))}function Ol(e,t){let{show:r,appear:n=!1,unmount:l=!0,...i}=e,a=o.useRef(null),u=gr(e),s=B(...u?[a,t]:t===null?[]:[t]);$e();let d=Be();if(r===void 0&&d!==null&&(r=(d&W.Open)===W.Open),r===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,b]=o.useState(r?"visible":"hidden"),E=wr(()=>{r||b("hidden")}),[w,m]=o.useState(!0),$=o.useRef([r]);L(()=>{w!==!1&&$.current[$.current.length-1]!==r&&($.current.push(r),m(!1))},[$,r]);let v=o.useMemo(()=>({show:r,appear:n,initial:w}),[r,n,w]);L(()=>{r?b("visible"):!ze(E)&&a.current!==null&&b("hidden")},[r,E]);let c={unmount:l},f=P(()=>{var p;w&&m(!1),(p=e.beforeEnter)==null||p.call(e)}),g=P(()=>{var p;w&&m(!1),(p=e.beforeLeave)==null||p.call(e)}),y=j();return o.createElement(Xe.Provider,{value:E},o.createElement(qe.Provider,{value:v},y({ourProps:{...c,as:o.Fragment,children:o.createElement(Er,{ref:s,...c,...i,beforeEnter:f,beforeLeave:g})},theirProps:{},defaultTag:o.Fragment,features:yr,visible:h==="visible",name:"Transition"})))}function Ml(e,t){let r=o.useContext(qe)!==null,n=Be()!==null;return o.createElement(o.Fragment,null,!r&&n?o.createElement(bt,{ref:t,...e}):o.createElement(Er,{ref:t,...e}))}let bt=N(Ol),Er=N(Sl),ce=N(Ml),xr=Object.assign(bt,{Child:ce,Root:bt});var Cl=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Cl||{}),Pl=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(Pl||{});let Tl={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},yt=o.createContext(null);yt.displayName="DialogContext";function Ge(e){let t=o.useContext(yt);if(t===null){let r=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Ge),r}return t}function kl(e,t){return z(t.type,Tl,e,t)}let $r=N(function(e,t){let r=o.useId(),{id:n=`headlessui-dialog-${r}`,open:l,onClose:i,initialFocus:a,role:u="dialog",autoFocus:s=!0,__demoMode:d=!1,unmount:h=!1,...b}=e,E=o.useRef(!1);u=function(){return u==="dialog"||u==="alertdialog"?u:(E.current||(E.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let w=Be();l===void 0&&w!==null&&(l=(w&W.Open)===W.Open);let m=o.useRef(null),$=B(m,t),v=He(m),c=l?0:1,[f,g]=o.useReducer(kl,{titleId:null,descriptionId:null,panelRef:o.createRef()}),y=P(()=>i(!1)),p=P(C=>g({type:0,id:C})),x=$e()?c===0:!1,[O,F]=il(),U={get current(){var C;return(C=f.panelRef.current)!=null?C:m.current}},k=pr(),{resolveContainers:D}=cl({mainTreeNode:k,portals:O,defaultContainers:[U]}),H=w!==null?(w&W.Closing)===W.Closing:!1;xn(d||H?!1:x,{allowed:P(()=>{var C,Ze;return[(Ze=(C=m.current)==null?void 0:C.closest("[data-headlessui-portal]"))!=null?Ze:null]}),disallowed:P(()=>{var C;return[(C=k==null?void 0:k.closest("body > *:not(#headlessui-portal-root)"))!=null?C:null]})});let A=Xt.get(null);L(()=>{if(x)return A.actions.push(n),()=>A.actions.pop(n)},[A,n,x]);let T=Yt(A,o.useCallback(C=>A.selectors.isTop(C,n),[A,n]));In(T,D,C=>{C.preventDefault(),y()}),al(T,v==null?void 0:v.defaultView,C=>{C.preventDefault(),C.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),y()}),Vn(d||H?!1:x,v,D),$n(x,m,y);let[I,xt]=en(),Ke=o.useMemo(()=>[{dialogState:c,close:y,setTitleId:p,unmount:h},f],[c,f,y,p,h]),fe=o.useMemo(()=>({open:c===0}),[c]),me={ref:$,id:n,role:u,tabIndex:-1,"aria-modal":d?void 0:c===0?!0:void 0,"aria-labelledby":f.titleId,"aria-describedby":I,unmount:h},Ye=!dl(),R=oe.None;x&&!d&&(R|=oe.RestoreFocus,R|=oe.TabLock,s&&(R|=oe.AutoFocus),Ye&&(R|=oe.InitialFocus));let $t=j();return o.createElement(Jn,null,o.createElement(ur,{force:!0},o.createElement(ul,null,o.createElement(yt.Provider,{value:Ke},o.createElement(cr,{target:m},o.createElement(ur,{force:!1},o.createElement(xt,{slot:fe},o.createElement(F,null,o.createElement(vl,{initialFocus:a,initialFocusFallback:m,containers:D,features:R},o.createElement(sn,{value:y},$t({ourProps:me,theirProps:b,slot:fe,defaultTag:Fl,features:Ll,visible:c===0,name:"Dialog"})))))))))))}),Fl="div",Ll=Ne.RenderStrategy|Ne.Static;function Al(e,t){let{transition:r=!1,open:n,...l}=e,i=Be(),a=e.hasOwnProperty("open")||i!==null,u=e.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&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(n!==void 0||r)&&!l.static?o.createElement(mr,null,o.createElement(xr,{show:n,transition:r,unmount:l.unmount},o.createElement($r,{ref:t,...l}))):o.createElement(mr,null,o.createElement($r,{ref:t,open:n,...l}))}let Il="div";function Nl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-panel-${r}`,transition:l=!1,...i}=e,[{dialogState:a,unmount:u},s]=Ge("Dialog.Panel"),d=B(t,s.panelRef),h=o.useMemo(()=>({open:a===0}),[a]),b=P(v=>{v.stopPropagation()}),E={ref:d,id:n,onClick:b},w=l?ce:o.Fragment,m=l?{unmount:u}:{},$=j();return o.createElement(w,{...m},$({ourProps:E,theirProps:i,slot:h,defaultTag:Il,name:"Dialog.Panel"}))}let Dl="div";function jl(e,t){let{transition:r=!1,...n}=e,[{dialogState:l,unmount:i}]=Ge("Dialog.Backdrop"),a=o.useMemo(()=>({open:l===0}),[l]),u={ref:t,"aria-hidden":!0},s=r?ce:o.Fragment,d=r?{unmount:i}:{},h=j();return o.createElement(s,{...d},h({ourProps:u,theirProps:n,slot:a,defaultTag:Dl,name:"Dialog.Backdrop"}))}let _l="h2";function Wl(e,t){let r=o.useId(),{id:n=`headlessui-dialog-title-${r}`,...l}=e,[{dialogState:i,setTitleId:a}]=Ge("Dialog.Title"),u=B(t);o.useEffect(()=>(a(n),()=>a(null)),[n,a]);let s=o.useMemo(()=>({open:i===0}),[i]),d={ref:u,id:n};return j()({ourProps:d,theirProps:l,slot:s,defaultTag:_l,name:"Dialog.Title"})}let Ul=N(Al),Et=N(Nl);N(jl);let Hl=N(Wl),Vl=Object.assign(Ul,{Panel:Et,Title:Hl,Description:ln});function Sr({onClick:e}){return S.jsxs("button",{type:"button",className:"im-close-button text-gray-400 hover:text-gray-500",onClick:e,children:[S.jsx("span",{className:"sr-only",children:"Close"}),S.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:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]})}const Bl=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return S.jsx("div",{className:"im-modal-container fixed inset-0 z-40 overflow-y-auto p-4",children:S.jsx("div",{className:Le("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:S.jsx(ce,{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:Le("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:S.jsxs(Et,{className:`im-modal-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&S.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:S.jsx(Sr,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},ql=({modalContext:e,config:t,children:r})=>{const[n,l]=o.useState(!1);return S.jsx("div",{className:"im-slideover-container fixed inset-0 z-40 overflow-y-auto overflow-x-hidden",children:S.jsx("div",{className:Le("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:S.jsx(ce,{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:Le("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:S.jsxs(Et,{className:`im-slideover-content relative ${t.paddingClasses} ${t.panelClasses}`,"data-inertiaui-modal-entered":n,children:[t.closeButton&&S.jsx("div",{className:"absolute right-0 top-0 pr-3 pt-3",children:S.jsx(Sr,{onClick:e.close})}),typeof r=="function"?r({modalContext:e,config:t}):r]})})})})},Or=o.forwardRef(({name:e,children:t,onFocus:r=null,onBlur:n=null,onClose:l=null,onSuccess:i=null,onAfterLeave:a=null,...u},s)=>{const d=b=>typeof t=="function"?t(b):t,h=o.useRef(null);return o.useImperativeHandle(s,()=>h.current,[h]),S.jsx(nt,{ref:h,name:e,onFocus:r,onBlur:n,onClose:l,onSuccess:i,...u,children:({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:O,shouldRender:F})=>S.jsx(xr,{appear:!0,show:g??!1,afterLeave:a,children:S.jsxs(Vl,{as:"div",className:"im-dialog relative z-20",onClose:()=>w.closeExplicitly?null:E(),"data-inertiaui-modal-id":c,"data-inertiaui-modal-index":f,children:[f===0?S.jsx(ce,{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:p?S.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75","aria-hidden":"true"}):S.jsx("div",{})}):null,f>0&&p?S.jsx("div",{className:"im-backdrop fixed inset-0 z-30 bg-black/75"}):null,w.slideover?S.jsx(ql,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:O,shouldRender:F})}):S.jsx(Bl,{modalContext:y,config:w,children:d({afterLeave:b,close:E,config:w,emit:m,getChildModal:$,getParentModal:v,id:c,index:f,isOpen:g,modalContext:y,onTopOfStack:p,reload:x,setOpen:O,shouldRender:F})})]})})})});Or.displayName="Modal";const Xl=({href:e,method:t="get",data:r={},as:n="a",headers:l={},queryStringArrayFormat:i="brackets",onAfterLeave:a=null,onBlur:u=null,onClose:s=null,onError:d=null,onFocus:h=null,onStart:b=null,onSuccess:E=null,navigate:w=null,children:m,...$})=>{const[v,c]=o.useState(!1),[f,g]=o.useState(null),{stack:y,visit:p}=ge(),x=o.useMemo(()=>w??Te("navigate"),[w]),O={},F={};Object.keys($).forEach(T=>{Pt.includes(T)||(T.startsWith("on")&&typeof $[T]=="function"?T.toLowerCase()in window?O[T]=$[T]:F[T]=$[T]:O[T]=$[T])});const[U,k]=o.useState(!1);o.useEffect(()=>{f&&(f.onTopOfStack&&U?h==null||h():!f.onTopOfStack&&!U&&(u==null||u()),k(!f.onTopOfStack))},[y]);const D=o.useCallback(()=>{s==null||s()},[s]),H=o.useCallback(()=>{g(null),a==null||a()},[a]),A=o.useCallback(T=>{T==null||T.preventDefault(),!v&&(e.startsWith("#")||(c(!0),b==null||b()),p(e,t,r,l,jr(Dr($,Pt)),()=>D(y.length),H,i,x).then(I=>{g(I),I.registerEventListenersFromProps(F),E==null||E()}).catch(I=>{console.error(I),d==null||d(I)}).finally(()=>c(!1)))},[e,t,r,l,i,$,D,H]);return S.jsx(n,{...O,href:e,onClick:A,children:typeof m=="function"?m({loading:v}):m})},Mr=({children:e,data:t,params:r,buffer:n,as:l,always:i,fallback:a})=>{i=i??!1,l=l??"div",a=a??null;const[u,s]=o.useState(!1),d=o.useRef(!1),h=o.useRef(!1),b=o.useRef(null),E=rt(),w=o.useCallback(()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!r)throw new Error("You must provide either a `data` or `params` prop.");return r},[r,t]);return o.useEffect(()=>{if(!b.current)return;const m=new IntersectionObserver($=>{if(!$[0].isIntersecting||(!i&&d.current&&m.disconnect(),h.current))return;d.current=!0,h.current=!0;const v=w();E.reload({...v,onStart:c=>{var f;h.current=!0,(f=v.onStart)==null||f.call(v,c)},onFinish:c=>{var f;s(!0),h.current=!1,(f=v.onFinish)==null||f.call(v,c),i||m.disconnect()}})},{rootMargin:`${n||0}px`});return m.observe(b.current),()=>{m.disconnect()}},[b,w,n]),i||!u?o.createElement(l,{props:null,ref:b},u?e:a):u?e:null};Mr.displayName="InertiaWhenVisible";const zl=e=>t=>(t.default.layout=r=>o.createElement(e,{},r),t);M.Deferred=Lt,M.HeadlessModal=nt,M.Modal=Or,M.ModalLink=Xl,M.ModalRoot=kt,M.ModalStackProvider=Ct,M.WhenVisible=Mr,M.getConfig=Te,M.initFromPageProps=Tt,M.putConfig=Ar,M.renderApp=_r,M.resetConfig=Lr,M.setPageLayout=zl,M.useModal=rt,M.useModalIndex=tt,M.useModalStack=ge,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/src/Deferred.jsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// See: https://github.com/inertiajs/inertia/blob/48bcd21fb7daf467d0df1bfde2408f161f94a579/packages/react/src/Deferred.ts
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
import useModal from './useModal'
|
|
4
|
+
|
|
5
|
+
const Deferred = ({ children, data, fallback }) => {
|
|
6
|
+
if (!data) {
|
|
7
|
+
throw new Error('`<Deferred>` requires a `data` prop to be a string or array of strings')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const [loaded, setLoaded] = useState(false)
|
|
11
|
+
const keys = Array.isArray(data) ? data : [data]
|
|
12
|
+
const modalProps = useModal().props
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setLoaded(keys.every((key) => modalProps[key] !== undefined))
|
|
16
|
+
}, [modalProps, keys])
|
|
17
|
+
|
|
18
|
+
return loaded ? children : fallback
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Deferred.displayName = 'InertiaModalDeferred'
|
|
22
|
+
|
|
23
|
+
export default Deferred
|
package/src/ModalRoot.jsx
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createElement, useEffect, useState, useRef } from 'react'
|
|
2
2
|
import { default as Axios } from 'axios'
|
|
3
|
-
import { except,
|
|
3
|
+
import { except, 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'
|
|
7
7
|
import ModalRenderer from './ModalRenderer'
|
|
8
|
-
import { waitFor } from './helpers'
|
|
9
8
|
import { getConfig } from './config'
|
|
10
9
|
|
|
11
10
|
const ModalStackContext = createContext(null)
|
|
@@ -14,7 +13,7 @@ ModalStackContext.displayName = 'ModalStackContext'
|
|
|
14
13
|
let pageVersion = null
|
|
15
14
|
let resolveComponent = null
|
|
16
15
|
let baseUrl = null
|
|
17
|
-
let
|
|
16
|
+
let baseModalsToWaitFor = {}
|
|
18
17
|
let localStackCopy = []
|
|
19
18
|
let pendingModalUpdates = {}
|
|
20
19
|
|
|
@@ -147,8 +146,10 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
close = () => {
|
|
150
|
-
updateStack((
|
|
151
|
-
|
|
149
|
+
updateStack((currentStack) => {
|
|
150
|
+
let modalClosed = false
|
|
151
|
+
|
|
152
|
+
const newStack = currentStack.map((modal) => {
|
|
152
153
|
if (modal.id === this.id && modal.isOpen) {
|
|
153
154
|
Object.keys(modal.listeners).forEach((event) => {
|
|
154
155
|
modal.off(event)
|
|
@@ -156,10 +157,13 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
156
157
|
|
|
157
158
|
modal.isOpen = false
|
|
158
159
|
modal.onCloseCallback?.()
|
|
160
|
+
modalClosed = true
|
|
159
161
|
}
|
|
160
162
|
return modal
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
return modalClosed ? newStack : currentStack
|
|
166
|
+
})
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
afterLeave = () => {
|
|
@@ -219,7 +223,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
219
223
|
let keys = Object.keys(this.response.props)
|
|
220
224
|
|
|
221
225
|
if (options.only) {
|
|
222
|
-
keys =
|
|
226
|
+
keys = options.only
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
if (options.except) {
|
|
@@ -233,6 +237,8 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
233
237
|
const method = (options.method ?? 'get').toLowerCase()
|
|
234
238
|
const data = options.data ?? {}
|
|
235
239
|
|
|
240
|
+
options.onStart?.()
|
|
241
|
+
|
|
236
242
|
Axios({
|
|
237
243
|
url: this.response.url,
|
|
238
244
|
method,
|
|
@@ -249,9 +255,18 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
249
255
|
'X-InertiaUI-Modal-Use-Router': 0,
|
|
250
256
|
'X-InertiaUI-Modal-Base-Url': baseUrl,
|
|
251
257
|
},
|
|
252
|
-
}).then((response) => {
|
|
253
|
-
this.updateProps(response.data.props)
|
|
254
258
|
})
|
|
259
|
+
.then((response) => {
|
|
260
|
+
this.updateProps(response.data.props)
|
|
261
|
+
|
|
262
|
+
options.onSuccess?.(response)
|
|
263
|
+
})
|
|
264
|
+
.catch((error) => {
|
|
265
|
+
options.onError?.(error)
|
|
266
|
+
})
|
|
267
|
+
.finally(() => {
|
|
268
|
+
options.onFinish?.()
|
|
269
|
+
})
|
|
255
270
|
}
|
|
256
271
|
|
|
257
272
|
updateProps = (props) => {
|
|
@@ -264,11 +279,24 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
264
279
|
return resolveComponent(responseData.component).then((component) => push(component, responseData, config, onClose, onAfterLeave))
|
|
265
280
|
}
|
|
266
281
|
|
|
282
|
+
const loadDeferredProps = (modal) => {
|
|
283
|
+
const deferred = modal.response?.meta?.deferredProps
|
|
284
|
+
|
|
285
|
+
if (!deferred) {
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
Object.keys(deferred).forEach((key) => {
|
|
290
|
+
modal.reload({ only: deferred[key] })
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
|
|
267
294
|
const push = (component, response, config, onClose, afterLeave) => {
|
|
268
295
|
const newModal = new Modal(component, response, config, onClose, afterLeave)
|
|
269
296
|
newModal.index = stack.length
|
|
270
297
|
|
|
271
298
|
updateStack((prevStack) => [...prevStack, newModal])
|
|
299
|
+
loadDeferredProps(newModal)
|
|
272
300
|
|
|
273
301
|
newModal.show()
|
|
274
302
|
|
|
@@ -348,7 +376,7 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
348
376
|
}
|
|
349
377
|
|
|
350
378
|
if (useInertiaRouter) {
|
|
351
|
-
|
|
379
|
+
baseModalsToWaitFor = {}
|
|
352
380
|
|
|
353
381
|
pendingModalUpdates[modalId] = {
|
|
354
382
|
config,
|
|
@@ -364,8 +392,8 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
364
392
|
preserveScroll: true,
|
|
365
393
|
preserveState: true,
|
|
366
394
|
onError: reject,
|
|
367
|
-
|
|
368
|
-
|
|
395
|
+
onBefore: () => {
|
|
396
|
+
baseModalsToWaitFor[modalId] = resolve
|
|
369
397
|
},
|
|
370
398
|
})
|
|
371
399
|
}
|
|
@@ -414,6 +442,14 @@ export const ModalStackProvider = ({ children }) => {
|
|
|
414
442
|
visitModal,
|
|
415
443
|
registerLocalModal,
|
|
416
444
|
removeLocalModal,
|
|
445
|
+
onModalOnBase: (modalOnBase) => {
|
|
446
|
+
const resolve = baseModalsToWaitFor[modalOnBase.id]
|
|
447
|
+
|
|
448
|
+
if (resolve) {
|
|
449
|
+
resolve(modalOnBase)
|
|
450
|
+
delete baseModalsToWaitFor[modalOnBase.id]
|
|
451
|
+
}
|
|
452
|
+
},
|
|
417
453
|
}
|
|
418
454
|
|
|
419
455
|
return <ModalStackContext.Provider value={value}>{children}</ModalStackContext.Provider>
|
|
@@ -515,9 +551,7 @@ export const ModalRoot = ({ children }) => {
|
|
|
515
551
|
})
|
|
516
552
|
}
|
|
517
553
|
})
|
|
518
|
-
.then(
|
|
519
|
-
newModalOnBase = newModal
|
|
520
|
-
})
|
|
554
|
+
.then(context.onModalOnBase)
|
|
521
555
|
}),
|
|
522
556
|
[],
|
|
523
557
|
)
|