@dhzh/foundry 1.5.0 → 2.0.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/README.md +2 -253
- package/package.json +8 -95
- package/LICENSE +0 -201
- package/dist/app/favicon.png +0 -0
- package/dist/app/index.html +0 -1
- package/dist/app/static/css/index.f4c40968ed.css +0 -2
- package/dist/app/static/font/inter-cyrillic-ext-wght-normal.460bdf14be.woff2 +0 -0
- package/dist/app/static/font/inter-cyrillic-wght-normal.491cbc05ce.woff2 +0 -0
- package/dist/app/static/font/inter-greek-ext-wght-normal.23aae5683d.woff2 +0 -0
- package/dist/app/static/font/inter-greek-wght-normal.4449bf7aab.woff2 +0 -0
- package/dist/app/static/font/inter-latin-ext-wght-normal.3835a68e46.woff2 +0 -0
- package/dist/app/static/font/inter-latin-wght-normal.6c596dfcdd.woff2 +0 -0
- package/dist/app/static/font/inter-vietnamese-wght-normal.113a630f76.woff2 +0 -0
- package/dist/app/static/js/110.f18ecb6e71.js +0 -2
- package/dist/app/static/js/110.f18ecb6e71.js.LICENSE.txt +0 -19
- package/dist/app/static/js/index.c5443edcce.js +0 -1
- package/dist/app/static/js/lib-react.2d16964d11.js +0 -2
- package/dist/app/static/js/lib-react.2d16964d11.js.LICENSE.txt +0 -49
- package/dist/app/static/js/lib-router.440ec6193a.js +0 -3
- package/dist/app/static/js/lib-router.440ec6193a.js.LICENSE.txt +0 -10
- package/dist/cli.d.mts +0 -2
- package/dist/cli.mjs +0 -26
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -2
- package/dist/migrations/0000_initial-settings.sql +0 -26
- package/dist/migrations/0001_youthful_tigra.sql +0 -28
- package/dist/migrations/0002_brainy_patriot.sql +0 -15
- package/dist/migrations/0003_rename_provider_default_model.sql +0 -21
- package/dist/migrations/0004_neat_vulcan.sql +0 -18
- package/dist/migrations/meta/0000_snapshot.json +0 -103
- package/dist/migrations/meta/0001_snapshot.json +0 -240
- package/dist/migrations/meta/0002_snapshot.json +0 -306
- package/dist/migrations/meta/0004_snapshot.json +0 -402
- package/dist/migrations/meta/_journal.json +0 -41
- package/dist/package-DS5RZ0CH.mjs +0 -2
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! LICENSE: lib-router.440ec6193a.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.rspackChunk_dhzh_foundry_app=self.rspackChunk_dhzh_foundry_app||[]).push([[535],{8071(e,t,r){r.d(t,{C5:()=>y,sv:()=>v,Ix:()=>g,pg:()=>f,jC:()=>d});var n=r(7629),a=r(9932),o=r(7527),i=r(4508),l=r(8189);let s={};function u(e,t){e||s[t]||(s[t]=!0,console.warn(t))}var c=r(6255);let d=["HydrateFallback","hydrateFallbackElement"];var h=class{status="pending";promise;resolve;reject;constructor(){this.promise=new Promise((e,t)=>{this.resolve=t=>{"pending"===this.status&&(this.status="resolved",e(t))},this.reject=e=>{"pending"===this.status&&(this.status="rejected",t(e))}})}};function f({router:e,flushSync:t,onError:r,useTransitions:n}){n=(0,i.OA)()||n;let[o,l]=c.useState(e.state),[s,d]=(0,c.useOptimistic)(o),[y,v]=c.useState(),[w,b]=c.useState({isTransitioning:!1}),[R,E]=c.useState(),[x,S]=c.useState(),[L,P]=c.useState(),k=c.useRef(new Map),C=c.useCallback((o,{deletedFetchers:i,newErrors:s,flushSync:h,viewTransitionOpts:f})=>{s&&r&&Object.values(s).forEach(e=>r(e,{location:o.location,params:o.matches[0]?.params??{},pattern:(0,a.gU)(o.matches)})),o.fetchers.forEach((e,t)=>{void 0!==e.data&&k.current.set(t,e.data)}),i.forEach(e=>k.current.delete(e)),u(!1===h||null!=t,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let m=null!=e.window&&null!=e.window.document&&"function"==typeof e.window.document.startViewTransition;if(u(null==f||m,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!f||!m)return void(t&&h?t(()=>l(o)):!1===n?l(o):c.startTransition(()=>{!0===n&&d(e=>p(e,o)),l(o)}));if(t&&h){t(()=>{x&&(R?.resolve(),x.skipTransition()),b({isTransitioning:!0,flushSync:!0,currentLocation:f.currentLocation,nextLocation:f.nextLocation})});let r=e.window.document.startViewTransition(()=>{t(()=>l(o))});r.finished.finally(()=>{t(()=>{E(void 0),S(void 0),v(void 0),b({isTransitioning:!1})})}),t(()=>S(r));return}x?(R?.resolve(),x.skipTransition(),P({state:o,currentLocation:f.currentLocation,nextLocation:f.nextLocation})):(v(o),b({isTransitioning:!0,flushSync:!1,currentLocation:f.currentLocation,nextLocation:f.nextLocation}))},[e.window,t,x,R,n,d,r]);c.useLayoutEffect(()=>e.subscribe(C),[e,C]),c.useEffect(()=>{w.isTransitioning&&!w.flushSync&&E(new h)},[w]),c.useEffect(()=>{if(R&&y&&e.window){let t=R.promise,r=e.window.document.startViewTransition(async()=>{!1===n?l(y):c.startTransition(()=>{!0===n&&d(e=>p(e,y)),l(y)}),await t});r.finished.finally(()=>{E(void 0),S(void 0),v(void 0),b({isTransitioning:!1})}),S(r)}},[y,R,e.window,n,d]),c.useEffect(()=>{R&&y&&s.location.key===y.location.key&&R.resolve()},[R,x,s.location,y]),c.useEffect(()=>{!w.isTransitioning&&L&&(v(L.state),b({isTransitioning:!0,flushSync:!1,currentLocation:L.currentLocation,nextLocation:L.nextLocation}),P(void 0))},[w.isTransitioning,L]);let D=c.useMemo(()=>({createHref:e.createHref,createURL:e.createURL,encodeLocation:e.encodeLocation,go:t=>e.navigate(t),push:(t,r,n)=>e.navigate(t,{state:r,preventScrollReset:n?.preventScrollReset}),replace:(t,r,n)=>e.navigate(t,{replace:!0,state:r,preventScrollReset:n?.preventScrollReset})}),[e]),M=e.basename||"/",O=c.useMemo(()=>({router:e,navigator:D,static:!1,basename:M,onError:r}),[e,D,M,r]);return c.createElement(c.Fragment,null,c.createElement(i.hf.Provider,{value:O},c.createElement(i.ay.Provider,{value:s},c.createElement(i.QH.Provider,{value:k.current},c.createElement(i.KZ.Provider,{value:w},c.createElement(g,{basename:M,location:s.location,navigationType:s.historyAction,navigator:D,useTransitions:n},c.createElement(m,{routes:e.routes,manifest:e.manifest,future:e.future,state:s,isStatic:!1,onError:r})))))),null)}function p(e,t){return{...e,navigation:"idle"!==t.navigation.state?t.navigation:e.navigation,revalidation:"idle"!==t.revalidation?t.revalidation:e.revalidation,actionData:"submitting"!==t.navigation.state?t.actionData:e.actionData,fetchers:t.fetchers}}let m=c.memo(function({routes:e,manifest:t,future:r,state:n,isStatic:a,onError:o}){return(0,l.uG)(e,void 0,{manifest:t,state:n,isStatic:a,onError:o,future:r})});function y({to:e,replace:t,state:r,relative:s}){(0,n.V1)((0,l.Ri)(),"<Navigate> may be used only in the context of a <Router> component.");let{static:u,navigator:d}=c.useContext(i._3);(0,n.$e)(!u,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:h}=c.useContext(i.Pl),{pathname:f}=(0,l.zy)(),p=(0,l.Zp)(),m=(0,a.Gh)(e,(0,a.PD)(h),f,"path"===s);(0,o.c)("string"==typeof e?e:(0,n.AO)(e),d.createHref(m),(0,o.Y)(d),"reject");let v=JSON.stringify(m);return c.useEffect(()=>{p(JSON.parse(v),{replace:t,state:r,relative:s})},[p,v,s,t,r]),null}function v(e){return(0,l.P1)(e.context)}function g({basename:e="/",children:t=null,location:r,navigationType:o="POP",navigator:s,static:u=!1,useTransitions:d}){(0,n.V1)(!(0,l.Ri)(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=e.replace(/^\/*/,"/"),f=c.useMemo(()=>({basename:h,navigator:s,static:u,useTransitions:d,future:{}}),[h,s,u,d]);"string"==typeof r&&(r=(0,n.Rr)(r));let{pathname:p="/",search:m="",hash:y="",state:v=null,key:w="default",mask:b}=r,R=c.useMemo(()=>{let e=(0,a.pb)(p,h);return null==e?null:{location:{pathname:e,search:m,hash:y,state:v,key:w,mask:b},navigationType:o}},[h,p,m,y,v,w,o,b]);return((0,n.$e)(null!=R,`<Router basename="${h}"> is not able to match the URL "${p}${m}${y}" because it does not start with the basename, so the <Router> won't render anything.`),null==R)?null:c.createElement(i._3.Provider,{value:f},c.createElement(i.di.Provider,{children:t,value:R}))}c.Component},4508(e,t,r){var n=r(6255);let a=n.createContext(null);a.displayName="DataRouter";let o=n.createContext(null);o.displayName="DataRouterState";let i=n.createContext(!1);function l(){return n.useContext(i)}let s=n.createContext({isTransitioning:!1});s.displayName="ViewTransition";let u=n.createContext(new Map);u.displayName="Fetchers";let c=n.createContext(null);c.displayName="Await";let d=n.createContext(null);d.displayName="Navigation";let h=n.createContext(null);h.displayName="Location";let f=n.createContext({outlet:null,matches:[],isDataRoute:!1});f.displayName="Route";let p=n.createContext(null);p.displayName="RouteError",r.d(t,{OA:()=>l},{Bu:i,KZ:s,Pl:f,QH:u,_3:d,ay:o,di:h,hf:a,m4:c,xN:p})},6653(e,t,r){var n=r(6255),a=r(7965),o=r(8071);function i(e){return n.createElement(o.pg,{flushSync:a.flushSync,...e})}r.d(t,{p:()=>i})},6551(e,t,r){r.d(t,{N_:()=>O,k2:()=>T,Ge:()=>M,ok:()=>A});var n=r(2872),a=r(7629),o=r(9932),i=r(9667),l=r(4508),s=r(8189),u=r(8071);let c="application/x-www-form-urlencoded";function d(e){return"u">typeof HTMLElement&&e instanceof HTMLElement}function h(e=""){return new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(e=>[r,e]):[[r,n]])},[]))}let f=null,p=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function m(e){return null==e||p.has(e)?e:((0,a.$e)(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${c}"`),null)}function y(e,t){if(!1===e||null==e)throw Error(t)}async function v(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function g(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"==typeof e.imageSrcSet&&"string"==typeof e.imageSizes:"string"==typeof e.rel&&"string"==typeof e.href)}async function w(e,t,r){var n;let a,o;return n=(await Promise.all(e.map(async e=>{let n=t.routes[e.route.id];if(n){let e=await v(n,r);return e.links?e.links():[]}return[]}))).flat(1).filter(g).filter(e=>"stylesheet"===e.rel||"preload"===e.rel).map(e=>"stylesheet"===e.rel?{...e,rel:"prefetch",as:"style"}:{...e,rel:"prefetch"}),a=new Set,o=new Set(void 0),n.reduce((e,t)=>{!1;let r=JSON.stringify(function(e){let t={};for(let r of Object.keys(e).sort())t[r]=e[r];return t}(t));return a.has(r)||(a.add(r),e.push({key:r,link:t})),e},[])}function b(e,t,r,n,a,o){let i=(e,t)=>!r[t]||e.route.id!==r[t].route.id,l=(e,t)=>r[t].pathname!==e.pathname||r[t].route.path?.endsWith("*")&&r[t].params["*"]!==e.params["*"];return"assets"===o?t.filter((e,t)=>i(e,t)||l(e,t)):"data"===o?t.filter((t,o)=>{let s=n.routes[t.route.id];if(!s||!s.hasLoader)return!1;if(i(t,o)||l(t,o))return!0;if(t.route.shouldRevalidate){let n=t.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"==typeof n)return n}return!0}):[]}var R=r(6255);function E(e,t){let r="string"==typeof e?new URL(e,"u"<typeof window?"server://singlefetch/":window.location.origin):e;return r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${t}`:r.pathname=`${r.pathname}.${t}`,r}Symbol("SingleFetchRedirect");let x=R.createContext(void 0);function S(){let e=R.useContext(x);return y(e,"You must render this element inside a <HydratedRouter> element"),e}function L(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function P({page:e,...t}){let r,n=(0,l.OA)(),{nonce:a}=S(),{router:i}=(y(r=R.useContext(l.hf),"You must render this element inside a <DataRouterContext.Provider> element"),r),s=R.useMemo(()=>(0,o.ue)(i.routes,e,i.basename),[i.routes,e,i.basename]);return s?(null==t.nonce&&a&&(t={...t,nonce:a}),n)?R.createElement(k,{page:e,matches:s,...t}):R.createElement(C,{page:e,matches:s,...t}):null}function k({page:e,matches:t,...r}){let n=(0,s.zy)(),a=R.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let r=E(e,"rsc"),a=!1,o=[];for(let e of t)"function"==typeof e.route.shouldRevalidate?a=!0:o.push(e.route.id);return a&&o.length>0&&r.searchParams.set("_routes",o.join(",")),[r.pathname+r.search]},[e,n,t]);return R.createElement(R.Fragment,null,a.map(e=>R.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...r})))}function C({page:e,matches:t,...r}){let n,a=(0,s.zy)(),{manifest:o,routeModules:i}=S(),{loaderData:u,matches:c}=(y(n=R.useContext(l.ay),"You must render this element inside a <DataRouterStateContext.Provider> element"),n),d=R.useMemo(()=>b(e,t,c,o,a,"data"),[e,t,c,o,a]),h=R.useMemo(()=>b(e,t,c,o,a,"assets"),[e,t,c,o,a]),f=R.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let r=new Set,n=!1;if(t.forEach(e=>{let t=o.routes[e.route.id];t&&t.hasLoader&&(!d.some(t=>t.route.id===e.route.id)&&e.route.id in u&&i[e.route.id]?.shouldRevalidate||t.hasClientLoader?n=!0:r.add(e.route.id))}),0===r.size)return[];let l=E(e,"data");return n&&r.size>0&&l.searchParams.set("_routes",t.filter(e=>r.has(e.route.id)).map(e=>e.route.id).join(",")),[l.pathname+l.search]},[u,a,o,d,t,e,i]),p=R.useMemo(()=>(function(e,t,{includeHydrateFallback:r}={}){return[...new Set(e.map(e=>{let n=t.routes[e.route.id];if(!n)return[];let a=[n.module];return n.clientActionModule&&(a=a.concat(n.clientActionModule)),n.clientLoaderModule&&(a=a.concat(n.clientLoaderModule)),r&&n.hydrateFallbackModule&&(a=a.concat(n.hydrateFallbackModule)),n.imports&&(a=a.concat(n.imports)),a}).flat(1))]})(h,o),[h,o]),m=function(e){let{manifest:t,routeModules:r}=S(),[n,a]=R.useState([]);return R.useEffect(()=>{let n=!1;return w(e,t,r).then(e=>{n||a(e)}),()=>{n=!0}},[e,t,r]),n}(h);return R.createElement(R.Fragment,null,f.map(e=>R.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...r})),p.map(e=>R.createElement("link",{key:e,rel:"modulepreload",href:e,...r})),m.map(({key:e,link:t})=>R.createElement("link",{key:e,nonce:r.nonce,...t,crossOrigin:t.crossOrigin??r.crossOrigin})))}x.displayName="FrameworkContext";let D="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement;try{D&&(window.__reactRouterVersion="8")}catch{}function M(e,t){let r;return(0,i.aE)({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:(0,a.TM)({window:t?.window}),hydrationData:t?.hydrationData||((r=window?.__staticRouterHydrationData)&&r.errors&&(r={...r,errors:function(e){if(!e)return null;let t=Object.entries(e),r={};for(let[e,n]of t)if(n&&"RouteErrorResponse"===n.__type)r[e]=new o.cj(n.status,n.statusText,n.data,!0===n.internal);else if(n&&"Error"===n.__type){if("string"==typeof n.__subType&&o.WF.includes(n.__subType)){let t=window[n.__subType];if("function"==typeof t)try{let a=new t(n.message);a.stack="",r[e]=a}catch{}}if(null==r[e]){let t=Error(n.message);t.stack="",r[e]=t}}else r[e]=n;return r}(r.errors)}),r),routes:e,mapRouteProperties:o.MT,hydrationRouteProperties:u.jC,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,window:t?.window,instrumentations:t?.instrumentations}).initialize()}let O=R.forwardRef(function({onClick:e,discover:t="render",prefetch:r="none",relative:i,reloadDocument:u,replace:c,mask:d,state:h,target:f,to:p,preventScrollReset:m,viewTransition:y,defaultShouldRevalidate:v,...g},w){let{basename:b,navigator:E,useTransitions:S}=R.useContext(l._3),k="string"==typeof p&&n.E6.test(p),C=(0,o.X9)(p,b);p=C.to;let D=(0,s.$P)(p,{relative:i}),M=(0,s.zy)(),O=null;if(d){let e=(0,o.Gh)(d,[],M.mask?M.mask.pathname:"/",!0);"/"!==b&&(e.pathname="/"===e.pathname?b:(0,o.HS)([b,e.pathname])),O=E.createHref(e)}let[T,$,A]=function(e,t){let r=R.useContext(x),[n,a]=R.useState(!1),[o,i]=R.useState(!1),{onFocus:l,onBlur:s,onMouseEnter:u,onMouseLeave:c,onTouchStart:d}=t,h=R.useRef(null);R.useEffect(()=>{if("render"===e&&i(!0),"viewport"===e){let e=new IntersectionObserver(e=>{e.forEach(e=>{i(e.isIntersecting)})},{threshold:.5});return h.current&&e.observe(h.current),()=>{e.disconnect()}}},[e]),R.useEffect(()=>{if(n){let e=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(e)}}},[n]);let f=()=>{a(!0)},p=()=>{a(!1),i(!1)};return r?"intent"!==e?[o,h,{}]:[o,h,{onFocus:L(l,f),onBlur:L(s,p),onMouseEnter:L(u,f),onMouseLeave:L(c,p),onTouchStart:L(d,f)}]:[!1,h,{}]}(r,g),j=function(e,{target:t,replace:r,mask:n,state:o,preventScrollReset:i,relative:l,viewTransition:u,defaultShouldRevalidate:c,useTransitions:d}={}){let h=(0,s.Zp)(),f=(0,s.zy)(),p=(0,s.x$)(e,{relative:l});return R.useCallback(s=>{if(0===s.button&&(!t||"_self"===t)&&!(s.metaKey||s.altKey||s.ctrlKey||s.shiftKey)){s.preventDefault();let t=void 0!==r?r:(0,a.AO)(f)===(0,a.AO)(p),m=()=>h(e,{replace:t,mask:n,state:o,preventScrollReset:i,relative:l,viewTransition:u,defaultShouldRevalidate:c});d?R.startTransition(()=>m()):m()}},[f,h,p,r,n,o,t,e,i,l,u,c,d])}(p,{replace:c,mask:d,state:h,target:f,preventScrollReset:m,relative:i,viewTransition:y,defaultShouldRevalidate:v,useTransitions:S}),U=!(C.isExternal||u),z=R.createElement("a",{...g,...A,href:(U?O:void 0)||C.absoluteURL||D,onClick:U?function(t){e&&e(t),t.defaultPrevented||j(t)}:e,ref:function(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}(w,$),target:f,"data-discover":k||"render"!==t?void 0:"true"});return T&&!k?R.createElement(R.Fragment,null,z,R.createElement(P,{page:D})):z});O.displayName="Link";let T=R.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:r="",end:n=!1,style:i,to:u,viewTransition:c,children:d,...h},f){let p,m=(0,s.x$)(u,{relative:h.relative}),y=(0,s.zy)(),v=R.useContext(l.ay),{navigator:g,basename:w}=R.useContext(l._3),b=null!=v&&function(e,{relative:t}={}){let r=R.useContext(l.KZ);(0,a.V1)(null!=r,"`useViewTransitionState` must be used within `react-router/dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=$("useViewTransitionState"),i=(0,s.x$)(e,{relative:t});if(!r.isTransitioning)return!1;let u=(0,o.pb)(r.currentLocation.pathname,n)||r.currentLocation.pathname,c=(0,o.pb)(r.nextLocation.pathname,n)||r.nextLocation.pathname;return null!=(0,o.B6)(i.pathname,c)||null!=(0,o.B6)(i.pathname,u)}(m)&&!0===c,E=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,x=y.pathname,S=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;t||(x=x.toLowerCase(),S=S?S.toLowerCase():null,E=E.toLowerCase()),S&&w&&(S=(0,o.pb)(S,w)||S);let L="/"!==E&&E.endsWith("/")?E.length-1:E.length,P=x===E||!n&&x.startsWith(E)&&"/"===x.charAt(L),k=null!=S&&(S===E||!n&&S.startsWith(E)&&"/"===S.charAt(L)),C={isActive:P,isPending:k,isTransitioning:b},D=P?e:void 0;p="function"==typeof r?r(C):[r,P?"active":null,k?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let M="function"==typeof i?i(C):i;return R.createElement(O,{...h,"aria-current":D,className:p,ref:f,style:M,to:u,viewTransition:c},"function"==typeof d?d(C):d)});T.displayName="NavLink",R.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:i,replace:u,state:h,method:p="get",action:y,onSubmit:v,relative:g,preventScrollReset:w,viewTransition:b,defaultShouldRevalidate:E,...x},S)=>{let{useTransitions:L}=R.useContext(l._3),P=function(){let{router:e}=$("useSubmit"),{basename:t}=R.useContext(l._3),r=(0,s.Gw)(),n=e.fetch,a=e.navigate;return R.useCallback(async(e,i={})=>{let{action:l,method:s,encType:u,formData:h,body:p}=function(e,t){let r,n,a,i,l;if(d(e)&&"form"===e.tagName.toLowerCase()){let l=e.getAttribute("action");n=l?(0,o.pb)(l,t):null,r=e.getAttribute("method")||"get",a=m(e.getAttribute("enctype"))||c,i=new FormData(e)}else if(d(e)&&"button"===e.tagName.toLowerCase()||d(e)&&"input"===e.tagName.toLowerCase()&&("submit"===e.type||"image"===e.type)){let l=e.form;if(null==l)throw Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||l.getAttribute("action");if(n=s?(0,o.pb)(s,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||"get",a=m(e.getAttribute("formenctype"))||m(l.getAttribute("enctype"))||c,i=new FormData(l,e),!function(){if(null===f)try{new FormData(document.createElement("form"),0),f=!1}catch{f=!0}return f}()){let{name:t,type:r,value:n}=e;if("image"===r){let e=t?`${t}.`:"";i.append(`${e}x`,"0"),i.append(`${e}y`,"0")}else t&&i.append(t,n)}}else if(d(e))throw Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');else r="get",n=null,a=c,l=e;return i&&"text/plain"===a&&(l=i,i=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:i,body:l}}(e,t);!1===i.navigate?await n(i.fetcherKey||`__${String(++j)}__`,r,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,relative:i.relative,formData:h,body:p,formMethod:i.method||s,formEncType:i.encType||u,flushSync:i.flushSync}):await a(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,relative:i.relative,formData:h,body:p,formMethod:i.method||s,formEncType:i.encType||u,replace:i.replace,state:i.state,fromRouteId:r,flushSync:i.flushSync,viewTransition:i.viewTransition})},[n,a,t,r])}(),k=function(e,{relative:t}={}){let{basename:r}=R.useContext(l._3),n=R.useContext(l.Pl);(0,a.V1)(n,"useFormAction must be used inside a RouteContext");let[i]=n.matches.slice(-1),u={...(0,s.x$)(e||".",{relative:t})},c=(0,s.zy)();if(null==e){u.search=c.search;let e=new URLSearchParams(u.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let r=e.toString();u.search=r?`?${r}`:""}}return(!e||"."===e)&&i.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),"/"!==r&&(u.pathname="/"===u.pathname?r:(0,o.HS)([r,u.pathname])),(0,a.AO)(u)}(y,{relative:g}),C="get"===p.toLowerCase()?"get":"post",D="string"==typeof y&&n.E6.test(y);return R.createElement("form",{ref:S,method:C,action:k,onSubmit:i?v:e=>{if(v&&v(e),e.defaultPrevented)return;e.preventDefault();let n=e.nativeEvent.submitter,a=n?.getAttribute("formmethod")||p,o=()=>P(n||e.currentTarget,{fetcherKey:t,method:a,navigate:r,replace:u,state:h,relative:g,preventScrollReset:w,viewTransition:b,defaultShouldRevalidate:E});L&&!1!==r?R.startTransition(()=>o()):o()},...x,"data-discover":D||"render"!==e?void 0:"true"})}).displayName="Form";function $(e){var t;let r=R.useContext(l.hf);return(0,a.V1)(r,(t=e,`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`)),r}function A(e){(0,a.$e)("u">typeof URLSearchParams,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=R.useRef(h(e)),r=R.useRef(!1),n=(0,s.zy)(),o=R.useMemo(()=>{var e,a;let o;return e=n.search,a=r.current?null:t.current,o=h(e),a&&a.forEach((e,t)=>{o.has(t)||a.getAll(t).forEach(e=>{o.append(t,e)})}),o},[n.search]),i=(0,s.Zp)();return[o,R.useCallback((e,t)=>{let n=h("function"==typeof e?e(new URLSearchParams(o)):e);r.current=!0,i("?"+n,t)},[i,o])]}let j=0},8189(e,t,r){r.d(t,{KP:()=>$,$P:()=>c,Ri:()=>d,zy:()=>h,FE:()=>O,Zp:()=>p,cq:()=>M,P1:()=>y,g:()=>v,x$:()=>g,Gw:()=>D,uG:()=>w});var n=r(7629),a=r(9932),o=r(7527),i=r(9667),l=r(4508);let s="REACT_ROUTER_ERROR";var u=r(6255);function c(e,{relative:t}={}){(0,n.V1)(d(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:o}=u.useContext(l._3),{hash:i,pathname:s,search:h}=g(e,{relative:t}),f=s;return"/"!==r&&(f="/"===s?r:(0,a.HS)([r,s])),o.createHref({pathname:f,search:h,hash:i})}function d(){return null!=u.useContext(l.di)}function h(){return(0,n.V1)(d(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(l.di).location}let f="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function p(){let{isDataRoute:e}=u.useContext(l.Pl);return e?function(){let{router:e}=P("useNavigate"),t=C("useNavigate"),r=u.useRef(!1);return u.useLayoutEffect(()=>{r.current=!0}),u.useCallback(async(a,o={})=>{(0,n.$e)(r.current,f),r.current&&("number"==typeof a?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}():function(){(0,n.V1)(d(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(l.hf),{basename:t,navigator:r}=u.useContext(l._3),{matches:i}=u.useContext(l.Pl),{pathname:s}=h(),c=JSON.stringify((0,a.PD)(i)),p=u.useRef(!1);return u.useLayoutEffect(()=>{p.current=!0}),u.useCallback((i,l={})=>{if((0,n.$e)(p.current,f),!p.current)return;if("number"==typeof i)return void r.go(i);let u=(0,a.Gh)(i,JSON.parse(c),s,"path"===l.relative);null==e&&"/"!==t&&(u.pathname="/"===u.pathname?t:(0,a.HS)([t,u.pathname])),(0,o.c)("string"==typeof i?i:(0,n.AO)(i),r.createHref(u),(0,o.Y)(r),"reject"),(l.replace?r.replace:r.push)(u,l.state,l)},[t,r,c,s,e])}()}let m=u.createContext(null);function y(e){let t=u.useContext(l.Pl).outlet;return u.useMemo(()=>t&&u.createElement(m.Provider,{value:e},t),[t,e])}function v(){let{matches:e}=u.useContext(l.Pl);return e[e.length-1]?.params??{}}function g(e,{relative:t}={}){let{matches:r}=u.useContext(l.Pl),{pathname:n}=h(),o=JSON.stringify((0,a.PD)(r));return u.useMemo(()=>(0,a.Gh)(e,JSON.parse(o),n,"path"===t),[e,o,n,t])}function w(e,t,r){let o;(0,n.V1)(d(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=u.useContext(l._3),{matches:s}=u.useContext(l.Pl),c=s[s.length-1],f=c?c.params:{};c&&c.pathname;let p=c?c.pathnameBase:"/";c&&c.route;let m=h();if(t){let e="string"==typeof t?(0,n.Rr)(t):t;(0,n.V1)("/"===p||e.pathname?.startsWith(p),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${e.pathname}" was given in the \`location\` prop.`),o=e}else o=m;let y=o.pathname||"/",v=y;if("/"!==p){let e=p.replace(/^\//,"").split("/");v="/"+y.replace(/^\//,"").split("/").slice(e.length).join("/")}let g=r&&r.state.matches.length?r.state.matches.map(e=>Object.assign(e,{route:r.manifest[e.route.id]||e.route})):(0,a.ue)(e,{pathname:v}),w=function(e,t=[],r){let o=r?.state;if(null==e){if(!o)return null;if(o.errors)e=o.matches;else{if(0!==t.length||o.initialized||!(o.matches.length>0))return null;e=o.matches}}let i=e,l=o?.errors;if(null!=l){let e=i.findIndex(e=>e.route.id&&l?.[e.route.id]!==void 0);(0,n.V1)(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,e+1))}let s=!1,c=-1;if(r&&o){s=o.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:n}=o,a=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!n||void 0===n[t.route.id]);if(t.route.lazy||a){r.isStatic&&(s=!0),i=c>=0?i.slice(0,c+1):[i[0]];break}}}}let d=r?.onError,h=o&&d?(e,t)=>{d(e,{location:o.location,params:o.matches?.[0]?.params??{},pattern:(0,a.gU)(o.matches),errorInfo:t})}:void 0;return i.reduceRight((e,r,a)=>{var d,f;let p,m=!1,y=null,v=null;o&&(p=l&&r.route.id?l[r.route.id]:void 0,y=r.route.errorElement||b,s&&(c<0&&0===a?(d="route-fallback",f="No `HydrateFallback` element provided to render during initial hydration",A[d]||(A[d]=!0,(0,n.$e)(!1,f)),m=!0,v=null):c===a&&(m=!0,v=r.route.hydrateFallbackElement||null)));let g=t.concat(i.slice(0,a+1)),w=()=>{let t;return t=p?y:m?v:r.route.Component?u.createElement(r.route.Component,null):r.route.element?r.route.element:e,u.createElement(S,{match:r,routeContext:{outlet:e,matches:g,isDataRoute:null!=o},children:t})};return o&&(r.route.ErrorBoundary||r.route.errorElement||0===a)?u.createElement(R,{location:o.location,revalidation:o.revalidation,component:y,error:p,children:w(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:h}):w()},null)}(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},f,e.params),pathname:(0,a.HS)([p,i.encodeLocation?i.encodeLocation(e.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?p:(0,a.HS)([p,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathnameBase])})),s,r);return t&&w?u.createElement(l.di.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...o},navigationType:"POP"}},w):w}let b=u.createElement(function(){let e,t,r,n=(e=u.useContext(l.xN),t=k("useRouteError"),r=C("useRouteError"),void 0!==e?e:t.errors?.[r]),o=(0,a.pX)(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null;return u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},o),i?u.createElement("pre",{style:{padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"}},i):null,null)},null);var R=class extends u.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static contextType=l.Bu;static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&"object"==typeof e&&e&&"digest"in e&&"string"==typeof e.digest){let t=function(e){if(e.startsWith(`${s}:ROUTE_ERROR_RESPONSE:{`))try{let t=JSON.parse(e.slice(40));if("object"==typeof t&&t&&"number"==typeof t.status&&"string"==typeof t.statusText)return new a.cj(t.status,t.statusText,t.data)}catch{}}(e.digest);t&&(e=t)}let t=void 0!==e?u.createElement(l.Pl.Provider,{value:this.props.routeContext},u.createElement(l.xN.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(x,{error:e},t):t}};let E=new WeakMap;function x({children:e,error:t}){let{basename:r,navigator:n}=u.useContext(l._3);if("object"==typeof t&&t&&"digest"in t&&"string"==typeof t.digest){let e=function(e){if(e.startsWith(`${s}:REDIRECT:{`))try{let t=JSON.parse(e.slice(28));if("object"==typeof t&&t&&"number"==typeof t.status&&"string"==typeof t.statusText&&"string"==typeof t.location&&"boolean"==typeof t.reloadDocument&&"boolean"==typeof t.replace)return t}catch{}}(t.digest);if(e){let l=E.get(t);if(l)throw l;let s=(0,a.X9)(e.location,r),c=s.absoluteURL||s.to;if((0,o.c)(e.location,c,(0,o.Y)(n),"allow-explicit"),(0,i.yf)(c))throw Error("Invalid redirect location");if(a.Bd&&!E.get(t))if(s.isExternal||e.reloadDocument)window.location.href=c;else{let r=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:e.replace}));throw E.set(t,r),r}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${c}`})}}return e}function S({routeContext:e,match:t,children:r}){let n=u.useContext(l.hf);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(l.Pl.Provider,{value:e},r)}function L(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function P(e){let t=u.useContext(l.hf);return(0,n.V1)(t,L(e)),t}function k(e){let t=u.useContext(l.ay);return(0,n.V1)(t,L(e)),t}function C(e){let t,r=(t=u.useContext(l.Pl),(0,n.V1)(t,L(e)),t),a=r.matches[r.matches.length-1];return(0,n.V1)(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function D(){return C("useRouteId")}function M(){let e=k("useNavigation");return u.useMemo(()=>{let{matches:t,historyAction:r,...n}=e.navigation;return n},[e.navigation])}function O(){let{matches:e,loaderData:t}=k("useMatches");return u.useMemo(()=>e.map(e=>(0,a.wy)(e,t)),[e,t])}let T=0;function $(e){let{router:t,basename:r}=P("useBlocker"),n=k("useBlocker"),[o,l]=u.useState(""),s=u.useCallback(t=>{if("function"!=typeof e)return!!e;if("/"===r)return e(t);let{currentLocation:n,nextLocation:o,historyAction:i}=t;return e({currentLocation:{...n,pathname:(0,a.pb)(n.pathname,r)||n.pathname},nextLocation:{...o,pathname:(0,a.pb)(o.pathname,r)||o.pathname},historyAction:i})},[r,e]);return u.useEffect(()=>{let e=String(++T);return l(e),()=>t.deleteBlocker(e)},[t]),u.useEffect(()=>{""!==o&&t.getBlocker(o,s)},[t,o,s]),o&&n.blockers.has(o)?n.blockers.get(o):i.G3}let A={}},7629(e,t,r){var n=r(2872);let a="popstate";function o(e){return"object"==typeof e&&null!=e&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function i(e={}){return function(e,t,r,n={}){let{window:i=document.defaultView,v5Compat:l=!1}=n,s=i.history,d="POP",h=null,p=m();function m(){return(s.state||{idx:null}).idx}function y(){d="POP";let e=m(),t=null==e?null:e-p;p=e,h&&h({action:d,location:g.location,delta:t})}function v(e){return f(i,e)}null==p&&(p=0,s.replaceState({...s.state,idx:p},""));let g={get action(){return d},get location(){return e(i,s)},listen(e){if(h)throw Error("A history only accepts one active listener");return i.addEventListener(a,y),h=e,()=>{i.removeEventListener(a,y),h=null}},createHref:e=>t(i,e),createURL:v,encodeLocation(e){let t=v(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){d="PUSH";let n=o(e)?e:c(g.location,e,t);r&&r(n,e);let a=u(n,p=m()+1),f=g.createHref(n.mask||n);try{s.pushState(a,"",f)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;i.location.assign(f)}l&&h&&h({action:d,location:g.location,delta:1})},replace:function(e,t){d="REPLACE";let n=o(e)?e:c(g.location,e,t);r&&r(n,e);let a=u(n,p=m()),i=g.createHref(n.mask||n);s.replaceState(a,"",i),l&&h&&h({action:d,location:g.location,delta:0})},go:e=>s.go(e)};return g}(function(e,t){let{pathname:r="/",search:n="",hash:a=""}=h(e.location.hash.substring(1));return r.startsWith("/")||r.startsWith(".")||(r="/"+r),c("",{pathname:r,search:n,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||"default")},function(e,t){let r=e.document.querySelector("base"),n="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");n=-1===r?t:t.slice(0,r)}return n+"#"+("string"==typeof t?t:d(t))},function(e,t){s("/"===e.pathname.charAt(0),`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)},e)}function l(e,t){if(!1===e||null==e)throw Error(t)}function s(e,t){if(!e){"u">typeof console&&console.warn(t);try{throw Error(t)}catch{}}}function u(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function c(e,t,r=null,n,a){return{pathname:"string"==typeof e?e:e.pathname,search:"",hash:"",..."string"==typeof t?h(t):t,state:r,key:t&&t.key||n||Math.random().toString(36).substring(2,10),mask:a}}function d({pathname:e="/",search:t="",hash:r=""}){return t&&"?"!==t&&(e+="?"===t.charAt(0)?t:"?"+t),r&&"#"!==r&&(e+="#"===r.charAt(0)?r:"#"+r),e}function h(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function f(e,t,r=!1){let a="http://localhost";e&&(a="null"!==e.location.origin?e.location.origin:e.location.href),l(a,"No window.location.(origin|href) available to create URL");let o="string"==typeof t?t:d(t);return o=o.replace(/ $/,"%20"),!r&&n.iA.test(o)&&(o=a+o),new URL(o,a)}r.d(t,{$e:()=>s,A4:()=>f,AO:()=>d,Rr:()=>h,TM:()=>i,V1:()=>l,yJ:()=>c})},7527(e,t,r){let n=new URL("http://localhost");function a(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),n)}catch{return n}}function o(e,t){return e.origin===t.origin&&("null"!==e.origin||e.protocol===t.protocol&&e.host===t.host)}function i(e,t,r,n){let a=null;try{a=null==e?null:new URL(e,r)}catch{}let i=new URL(t,r),l=null!=a&&!o(a,r),s=!o(i,r);if("reject"===n){if(l||s)throw Error("External navigation is not allowed")}else if(s&&(null==a||!function(e,t){if(e.startsWith("//"))return!0;let r=t.protocol.toLowerCase();return!!e.toLowerCase().startsWith(r)&&(""===t.host||e.slice(r.length).startsWith("//"))}(e,a)||!o(a,i)))throw Error("External navigation is not allowed")}r.d(t,{Y:()=>a,c:()=>i})},9667(e,t,r){r.d(t,{G3:()=>S,aE:()=>C,yf:()=>Z});var n=r(2872),a=r(7629),o=r(9932);let i=Symbol("Uninstrumented"),l=new WeakMap;function s(e){return e[i]??e}function u(e,t){return l.set(e,t),()=>{l.get(e)===t&&l.delete(e)}}function c(e){let t=l.get(e);return l.delete(e),t}function d(e){if("error"===e.type)throw e.value;return e.value}async function h(e,t,r,n,o={result:null,innerResult:null},i=e.length-1){let l=e[i];if(l){let s,u=async()=>(s?console.error("You cannot call instrumented handlers more than once"):s=h(e,t,r,n,o,i-1),await s,(0,a.V1)(o.innerResult,"Expected an inner result"),o.innerResult);try{await l(u,t)}catch(e){console.error("An instrumentation function threw an error:",e)}s||await u(),await s}else{try{o.result={type:"success",value:await r()}}catch(e){o.result={type:"error",value:e}}o.innerResult=n(o.result,t)}return o.result||(o.result={type:"error",value:Error("No result assigned in instrumentation chain.")},o.innerResult=n(o.result,t)),o.result}function f(e){return"error"===e.type&&e.value instanceof Error?{status:"error",error:e.value}:{status:"success",error:void 0}}function p(e){var t,r;let{request:n,context:a,params:o}=e;return{...e,request:{method:(t=n).method,url:t.url,headers:{get:(...e)=>t.headers.get(...e)}},params:{...o},context:(r=a,{get:e=>r.get(e)})}}function m(e,t){return{currentUrl:(0,a.AO)(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}var y=r(7527);let v=["POST","PUT","PATCH","DELETE"],g=new Set(v),w=new Set(["GET",...v]),b=new Set([301,302,303,307,308]),R=new Set([307,308]),E={state:"idle",location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},x={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},S={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},L="remix-router-transitions",P=Symbol("ResetLoaderData");var k=class{#e;#t;#r;#n;constructor(e){this.#e=e,this.#t=(0,o.oI)(e)}get stableRoutes(){return this.#e}get activeRoutes(){return this.#r??this.#e}get branches(){return this.#n??this.#t}get hasHMRRoutes(){return null!=this.#r}setRoutes(e){this.#e=e,this.#t=(0,o.oI)(e)}setHmrRoutes(e){this.#r=e,this.#n=(0,o.oI)(e)}commitHmrRoutes(){this.#r&&(this.#e=this.#r,this.#t=this.#n,this.#r=void 0,this.#n=void 0)}};function C(e){let t,r,l,v,g,w=e.window?e.window:"u">typeof window?window:void 0,P=void 0!==w&&void 0!==w.document&&void 0!==w.document.createElement;(0,a.V1)(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let C=e.hydrationRouteProperties||[],A=e.mapRouteProperties,U=A||(()=>({}));if(e.instrumentations){let t=e.instrumentations;U=e=>({...A?.(e),...function(e,t){var r,n,a,o;let l=[],u=[],c=[],m=[],y=[],v=[],g=[];e.forEach(e=>e({id:t.id,index:t.index,path:t.path,instrument(e){null!=e.lazy&&l.push(e.lazy),null!=e["lazy.loader"]&&u.push(e["lazy.loader"]),null!=e["lazy.action"]&&c.push(e["lazy.action"]),null!=e["lazy.middleware"]&&m.push(e["lazy.middleware"]),null!=e.middleware&&y.push(e.middleware),null!=e.loader&&v.push(e.loader),null!=e.action&&g.push(e.action)}}));let w={};if("function"==typeof t.lazy&&l.length>0){let e=t.lazy;w.lazy=async(...t)=>d(await h(l,void 0,()=>e(...t),f))}if("object"==typeof t.lazy){let e=t.lazy;if("function"==typeof e.middleware&&m.length>0){let t=e.middleware;w.lazy=Object.assign(w.lazy||{},{middleware:async(...e)=>d(await h(m,void 0,()=>t(...e),f))})}if("function"==typeof e.loader&&u.length>0){let t=e.loader;w.lazy=Object.assign(w.lazy||{},{loader:async(...e)=>d(await h(u,void 0,()=>t(...e),f))})}if("function"==typeof e.action&&c.length>0){let t=e.action;w.lazy=Object.assign(w.lazy||{},{action:async(...e)=>d(await h(c,void 0,()=>t(...e),f))})}}if("function"==typeof t.loader&&v.length>0){let e=s(t.loader),a=async(...t)=>d(await h(v,p(t[0]),()=>e(...t),f));!0===e.hydrate&&(a.hydrate=!0),r=a,n=e,r[i]=n,w.loader=a}if("function"==typeof t.action&&g.length>0){let e=s(t.action),r=async(...t)=>d(await h(g,p(t[0]),()=>e(...t),f));a=r,o=e,a[i]=o,w.action=r}return t.middleware&&t.middleware.length>0&&y.length>0&&(w.middleware=t.middleware.map(e=>{var t,r;let n=s(e),a=async(...e)=>d(await h(y,p(e[0]),()=>n(...e),f));return t=a,r=n,t[i]=r,a})),w}(t.map(e=>e.route).filter(Boolean),e)})}let z={},N=new k((0,o.R_)(e.routes,U,void 0,z)),_=e.basename||"/";_.startsWith("/")||(_=`/${_}`);let H=e.dataStrategy||F,V={...e.future},I=null,B=new Set,W=null,J=null,G=null,K=null,Z=null!=e.hydrationData,et=(0,o.et)(N.activeRoutes,e.history.location,_,!1,N.branches),er=!1,ec=null;if(null!=et||e.patchRoutesOnNavigation)if(et&&!e.hydrationData&&ta(et,N.activeRoutes,e.history.location.pathname).active&&(et=null),et)if(et.some(e=>e.route.lazy))t=!1,r=!0;else if(et.some(e=>T(e.route))){let n=e.hydrationData?e.hydrationData.loaderData:null,a=e.hydrationData?e.hydrationData.errors:null,o=et;if(a){let e=et.findIndex(e=>void 0!==a[e.route.id]);o=o.slice(0,e+1)}r=!1,t=!0,o.forEach(e=>{let o=$(e.route,n,a);r=r||o.renderFallback,t=t&&!o.shouldLoad})}else t=!0,r=!1;else{t=!1,r=!0,et=[];let n=ta(null,N.activeRoutes,e.history.location.pathname);n.active&&n.matches&&(er=!0,et=n.matches)}else{let n=es(404,{pathname:e.history.location.pathname}),{matches:a,route:o}=el(N.activeRoutes);t=!0,r=!1,et=a,ec={[o.id]:n}}let ed={historyAction:e.history.action,location:e.history.location,matches:et,initialized:t,renderFallback:r,navigation:E,restoreScrollPosition:null==e.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||ec,fetchers:new Map,blockers:new Map},ep="POP",ev=null,eL=!1,eP=!1,ek=new Map,eC=null,eD=!1,eM=!1,eO=new Set,eT=new Map,e$=0,eA=-1,ej=new Map,eU=new Set,ez=new Map,eN=new Map,e_=new Set,eF=new Map,eH=null;function eV(e,t={}){e.matches&&(e.matches=e.matches.map(e=>{let t=z[e.route.id],r=e.route;return r.element!==t.element||r.errorElement!==t.errorElement||r.hydrateFallbackElement!==t.hydrateFallbackElement?{...e,route:t}:e}));let r=[],n=[];(ed={...ed,...e}).fetchers.forEach((e,t)=>{"idle"===e.state&&(e_.has(t)?r.push(t):n.push(t))}),e_.forEach(e=>{ed.fetchers.has(e)||eT.has(e)||r.push(e)}),0===B.size&&(W={newErrors:e.errors??null}),[...B].forEach(n=>n(ed,{deletedFetchers:r,newErrors:e.errors??null,viewTransitionOpts:t.viewTransitionOpts,flushSync:!0===t.flushSync})),r.forEach(e=>e5(ed.fetchers,e)),n.forEach(e=>ed.fetchers.delete(e))}function eI(t,r,{flushSync:n}={}){let a,o,i=null!=ed.actionData&&null!=ed.navigation.formMethod&&ey(ed.navigation.formMethod)&&"loading"===ed.navigation.state&&t.state?._isRedirect!==!0;a=r.actionData?Object.keys(r.actionData).length>0?r.actionData:null:i?ed.actionData:null;let l=r.loaderData?ea(ed.loaderData,r.loaderData,r.matches||[],r.errors):ed.loaderData,s=ed.blockers;s.size>0&&!eD&&(s=new Map(s)).forEach((e,t)=>s.set(t,S));let u=!eD&&tn(t,r.matches||ed.matches),c=!0===eL||null!=ed.navigation.formMethod&&ey(ed.navigation.formMethod)&&t.state?._isRedirect!==!0;if(N.commitHmrRoutes(),eD||"POP"===ep||("PUSH"===ep?e.history.push(t,t.state):"REPLACE"===ep&&e.history.replace(t,t.state)),"POP"===ep){let e=ek.get(ed.location.pathname);e&&e.has(t.pathname)?o={currentLocation:ed.location,nextLocation:t}:ek.has(t.pathname)&&(o={currentLocation:t,nextLocation:ed.location})}else if(eP){let e=ek.get(ed.location.pathname);e?e.add(t.pathname):(e=new Set([t.pathname]),ek.set(ed.location.pathname,e)),o={currentLocation:ed.location,nextLocation:t}}eV({...r,actionData:a,loaderData:l,historyAction:ep,location:t,initialized:!0,renderFallback:!1,navigation:E,revalidation:"idle",restoreScrollPosition:u,preventScrollReset:c,blockers:s},{viewTransitionOpts:o,flushSync:!0===n}),ep="POP",eL=!1,eP=!1,eD=!1,eM=!1,ev?.resolve(),ev=null,eH?.resolve(),eH=null}async function eB(t,r){let o;if(ev?.resolve(),ev=null,"number"==typeof t){ev||(ev=eS());let r=ev.promise;return e.history.go(t),r}let i=c(l),{path:s,submission:u,error:d}=M(!1,D(ed.location,ed.matches,_,t,r?.fromRouteId,r?.relative),r);if(r?.mask){let t="string"==typeof r.mask?(0,a.Rr)(r.mask):{...ed.location.mask,...r.mask};if(o={pathname:t.pathname??"",search:t.search??"",hash:t.hash??""},n.iA.test(o.pathname))throw Error("External navigation is not allowed");o.pathname.startsWith("\\")&&(o.pathname=o.pathname.replace(/^\\+/,"/")),(0,y.c)("string"==typeof r.mask?r.mask:(0,a.AO)(r.mask),(0,a.AO)(o),e.history.createURL("/"),"reject")}let h=ed.location,f=(0,a.yJ)(h,s,r&&r.state,void 0,o);f={...f,...e.history.encodeLocation(f)},(0,y.c)(null==t?e.history.createHref(ed.location):"string"==typeof t?t:(0,a.AO)(t),e.history.createHref(f.mask||f),e.history.createURL("/"),"reject");let p=r&&null!=r.replace?r.replace:void 0,m="PUSH";!0===p?m="REPLACE":!1===p||null!=u&&ey(u.formMethod)&&u.formAction===ed.location.pathname+ed.location.search&&(m="REPLACE");let v=r&&"preventScrollReset"in r?!0===r.preventScrollReset:void 0,g=!0===(r&&r.flushSync),w=te({currentLocation:h,nextLocation:f,historyAction:m});w?e8(w,{state:"blocked",location:f,proceed(){e8(w,{state:"proceeding",proceed:void 0,reset:void 0,location:f}),eB(t,r)},reset(){let e=new Map(ed.blockers);e.set(w,S),eV({blockers:e})}}):await eW(m,f,{submission:u,pendingError:d,preventScrollReset:v,replace:r&&r.replace,enableViewTransition:r&&r.viewTransition,flushSync:g,callSiteDefaultShouldRevalidate:r&&r.defaultShouldRevalidate,instrumentationNavigateMetaReceiver:i})}async function eW(t,r,n){var a,i,l,s;let u;v&&v.abort(),v=null,ep=t,eD=!0===(n&&n.startUninterruptedRevalidation),a=ed.location,i=ed.matches,J&&K&&(J[tr(a,i)]=K()),eL=!0===(n&&n.preventScrollReset),eP=!0===(n&&n.enableViewTransition);let c=N.activeRoutes,d=n?.initialHydration&&ed.matches&&ed.matches.length>0&&!er?ed.matches:(0,o.et)(c,r,_,!1,N.branches),h=!0===(n&&n.flushSync);if(d&&ed.initialized&&!eM&&(l=ed.location,s=r,l.pathname===s.pathname&&l.search===s.search&&(""===l.hash?""!==s.hash:l.hash===s.hash||""!==s.hash||!1))&&!(n&&n.submission&&ey(n.submission.formMethod)))return void eI(r,{matches:d},{flushSync:h});let f=ta(d,c,r.pathname);if(f.active&&f.matches&&(d=f.matches),n?.instrumentationNavigateMetaReceiver){let t=ew(e.history,r,d);n.instrumentationNavigateMetaReceiver(t)}if(!d){let{error:e,notFoundMatches:t,route:n}=tt(r.pathname);eI(r,{matches:t,loaderData:{},errors:{[n.id]:e}},{flushSync:h});return}let p=n&&n.overrideNavigation?{...n.overrideNavigation,matches:d,historyAction:t}:void 0;v=new AbortController;let m=ee(e.history,r,v.signal,n&&n.submission),y=e.getContext?await e.getContext():new o.aB;if(n&&n.pendingError)u=[ei(d).route.id,{type:"error",error:n.pendingError}];else if(n&&n.submission&&ey(n.submission.formMethod)){let a=await eY(m,r,n.submission,d,t,y,f.active,n&&!0===n.initialHydration,{replace:n.replace,flushSync:h});if(a.shortCircuited)return;if(a.pendingActionResult){let[e,t]=a.pendingActionResult;if(eh(t)&&(0,o.pX)(t.error)&&404===t.error.status){v=null,eI(r,{matches:a.matches,loaderData:{},errors:{[e]:t.error}});return}}d=a.matches||d,u=a.pendingActionResult,p=eR(r,d,t,n.submission),h=!1,f.active=!1,m=ee(e.history,m.url,m.signal)}let{shortCircuited:g,matches:w,loaderData:b,errors:R,workingFetchers:E}=await eq(m,r,d,t,y,f.active,p,n&&n.submission,n&&n.fetcherSubmission,n&&n.replace,n&&!0===n.initialHydration,h,u,n&&n.callSiteDefaultShouldRevalidate);g||(v=null,eI(r,{matches:w||d,...eo(u),loaderData:b,errors:R,...E?{fetchers:E}:{}}))}async function eY(t,r,n,a,o,i,l,s,u={}){var c,d,h;let f;if(e0(),eV({navigation:(c=r,d=a,{state:"submitting",location:c,matches:d,historyAction:o,formMethod:(h=n).formMethod,formAction:h.formAction,formEncType:h.formEncType,formData:h.formData,json:h.json,text:h.text})},{flushSync:!0===u.flushSync}),l){let e=await to(a,r.pathname,t.signal);if("aborted"===e.type)return{shortCircuited:!0};if("error"===e.type){if(0===e.partialMatches.length){let{matches:t,route:r}=el(N.activeRoutes);return{matches:t,pendingActionResult:[r.id,{type:"error",error:e.error}]}}let t=ei(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:"error",error:e.error}]}}if(e.matches)a=e.matches;else{let{notFoundMatches:e,error:t,route:n}=tt(r.pathname);return{matches:e,pendingActionResult:[n.id,{type:"error",error:t}]}}}let p=eg(a,r);if(p.route.action||p.route.lazy){let e=await eZ(t,r,Y(U,z,t,r,a,p,s?[]:C,i),i,null);if(!(f=e[p.route.id])){for(let t of a)if(e[t.route.id]){f=e[t.route.id];break}}if(t.signal.aborted)return{shortCircuited:!0}}else f={type:"error",error:es(405,{method:t.method,pathname:r.pathname,routeId:p.route.id})};if(ef(f)){let r;return r=u&&null!=u.replace?u.replace:Q(f.response.headers.get("Location"),new URL(t.url),_,e.history)===ed.location.pathname+ed.location.search,await eK(t,f,!0,{submission:n,replace:r}),{shortCircuited:!0}}if(eh(f)){let e=ei(a,p.route.id);return!0!==(u&&u.replace)&&(ep="PUSH"),{matches:a,pendingActionResult:[e.route.id,f,p.route.id]}}return{matches:a,pendingActionResult:[p.route.id,f]}}async function eq(t,r,n,a,o,i,l,s,u,c,d,h,f,p){let m=l||eR(r,n,a,s),y=s||u||eb(m),g=!eD&&!d;if(i){if(g){let e=eJ(f);eV({navigation:m,...void 0!==e?{actionData:e}:{}},{flushSync:h})}let e=await to(n,r.pathname,t.signal);if("aborted"===e.type)return{shortCircuited:!0};if("error"===e.type){if(0===e.partialMatches.length){let{matches:t,route:r}=el(N.activeRoutes);return{matches:t,loaderData:{},errors:{[r.id]:e.error}}}let t=ei(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}if(e.matches)n=e.matches;else{let{error:e,notFoundMatches:t,route:n}=tt(r.pathname);return{matches:t,loaderData:{},errors:{[n.id]:e}}}}let w=N.activeRoutes,{dsMatches:b,revalidatingFetchers:R}=O(t,o,U,z,e.history,ed,n,y,r,d?[]:C,!0===d,eM,eO,e_,ez,eU,w,_,null!=e.patchRoutesOnNavigation,N.branches,f,p);if(eA=++e$,!e.dataStrategy&&!b.some(e=>e.shouldLoad)&&!b.some(e=>e.route.middleware&&e.route.middleware.length>0)&&0===R.length){let e=new Map(ed.fetchers),t=e6(e);return eI(r,{matches:n,loaderData:{},errors:f&&eh(f[1])?{[f[0]]:f[1].error}:null,...eo(f),...t?{fetchers:e}:{}},{flushSync:h}),{shortCircuited:!0}}if(g){var E;let e,t={};if(!i){t.navigation=m;let e=eJ(f);void 0!==e&&(t.actionData=e)}R.length>0&&(E=R,e=new Map(ed.fetchers),E.forEach(t=>{let r=e.get(t.key),n=eE(void 0,r?r.data:void 0);e.set(t.key,n)}),t.fetchers=e),eV(t,{flushSync:h})}R.forEach(e=>{e3(e.key),e.controller&&eT.set(e.key,e.controller)});let x=()=>R.forEach(e=>e3(e.key));v&&v.signal.addEventListener("abort",x);let{loaderResults:S,fetcherResults:L}=await eQ(b,R,t,r,o);if(t.signal.aborted)return{shortCircuited:!0};v&&v.signal.removeEventListener("abort",x),R.forEach(e=>eT.delete(e.key));let P=eu(S);if(P)return await eK(t,P.result,!0,{replace:c}),{shortCircuited:!0};if(P=eu(L))return eU.add(P.key),await eK(t,P.result,!0,{replace:c}),{shortCircuited:!0};let k=new Map(ed.fetchers),{loaderData:D,errors:M}=en(ed,n,S,f,R,L,k);d&&ed.errors&&(M={...ed.errors,...M});let T=e6(k),$=e7(eA,k);return{matches:n,loaderData:D,errors:M,...T||$||R.length>0?{workingFetchers:k}:{}}}function eJ(e){if(e&&!eh(e[1]))return{[e[0]]:e[1].data};if(ed.actionData)if(0===Object.keys(ed.actionData).length)return null;else return ed.actionData}async function eG(t,r,n,i,l,s,u,c,d,h){var f,p;e0(),ez.delete(t),e1(t,(f=d,p=ed.fetchers.get(t),{state:"submitting",formMethod:f.formMethod,formAction:f.formAction,formEncType:f.formEncType,formData:f.formData,json:f.json,text:f.text,data:p?p.data:void 0}),{flushSync:u});let m=new AbortController,y=ee(e.history,n,m.signal,d);if(s){let e=await to(i,new URL(y.url).pathname,y.signal,t);if("aborted"===e.type)return;if("error"===e.type)return void e2(t,r,e.error,{flushSync:u});if(!e.matches)return void e2(t,r,es(404,{pathname:n}),{flushSync:u});i=e.matches}let g=eg(i,n);if(!g.route.action&&!g.route.lazy)return void e2(t,r,es(405,{method:d.formMethod,pathname:n,routeId:r}),{flushSync:u});eT.set(t,m);let w=e$,b=Y(U,z,y,n,i,g,C,l),R=await eZ(y,n,b,l,t),E=R[g.route.id];if(!E){for(let e of b)if(R[e.route.id]){E=R[e.route.id];break}}if(y.signal.aborted){eT.get(t)===m&&eT.delete(t);return}if(e_.has(t)){if(ef(E)||eh(E))return void e1(t,ex(void 0))}else{if(ef(E))return(eT.delete(t),eA>w)?void e1(t,ex(void 0)):(eU.add(t),e1(t,eE(d)),eK(y,E,!1,{fetcherSubmission:d,preventScrollReset:c}));if(eh(E))return void e2(t,r,E.error)}let x=ed.navigation.location||ed.location,S=ee(e.history,x,m.signal),L=N.activeRoutes,P="idle"!==ed.navigation.state?(0,o.et)(L,ed.navigation.location,_,!1,N.branches):ed.matches;(0,a.V1)(P,"Didn't find any matches after fetcher action");let k=++e$;ej.set(t,k);let{dsMatches:D,revalidatingFetchers:M}=O(S,l,U,z,e.history,ed,P,d,x,C,!1,eM,eO,e_,ez,eU,L,_,null!=e.patchRoutesOnNavigation,N.branches,[g.route.id,E],h),T=eE(d,E.data),$=new Map(ed.fetchers);$.set(t,T),M.filter(e=>e.key!==t).forEach(e=>{let t=e.key,r=$.get(t),n=eE(void 0,r?r.data:void 0);$.set(t,n),e3(t),e.controller&&eT.set(t,e.controller)}),eV({fetchers:$});let A=()=>M.forEach(e=>e3(e.key));m.signal.addEventListener("abort",A);let{loaderResults:j,fetcherResults:F}=await eQ(D,M,S,x,l);if(m.signal.aborted){ej.get(t)===k&&ej.delete(t);return}m.signal.removeEventListener("abort",A),ej.delete(t),eT.delete(t),M.forEach(e=>eT.delete(e.key));let H=ed.fetchers.has(t),V=e=>{if(!H)return e;let r=new Map(e.fetchers);return r.set(t,ex(E.data)),{...e,fetchers:r}},I=eu(j);if(I)return ed=V(ed),eK(S,I.result,!1,{preventScrollReset:c});if(I=eu(F))return eU.add(I.key),ed=V(ed),eK(S,I.result,!1,{preventScrollReset:c});let B=new Map(ed.fetchers);H&&B.set(t,ex(E.data));let{loaderData:W,errors:q}=en(ed,P,j,void 0,M,F,B);e7(k,B),"loading"===ed.navigation.state&&k>eA?((0,a.V1)(ep,"Expected pending action"),v&&v.abort(),eI(ed.navigation.location,{matches:P,loaderData:W,errors:q,fetchers:B})):(eV({errors:q,loaderData:ea(ed.loaderData,W,P,q),fetchers:B}),eM=!1)}async function eX(t,r,n,a,o,i,l,s,u){let c=ed.fetchers.get(t);e1(t,eE(u,c?c.data:void 0),{flushSync:l});let d=new AbortController,h=ee(e.history,n,d.signal);if(i){let e=await to(a,new URL(h.url).pathname,h.signal,t);if("aborted"===e.type)return;if("error"===e.type)return void e2(t,r,e.error,{flushSync:l});if(!e.matches)return void e2(t,r,es(404,{pathname:n}),{flushSync:l});a=e.matches}let f=eg(a,n);eT.set(t,d);let p=e$,m=await eZ(h,n,Y(U,z,h,n,a,f,C,o),o,t),y=m[f.route.id];if(!y){for(let e of a)if(m[e.route.id]){y=m[e.route.id];break}}if(eT.get(t)===d&&eT.delete(t),!h.signal.aborted){if(e_.has(t))return void e1(t,ex(void 0));if(ef(y))if(eA>p)return void e1(t,ex(void 0));else{eU.add(t),await eK(h,y,!1,{preventScrollReset:s});return}if(eh(y))return void e2(t,r,y.error);e1(t,ex(y.data))}}async function eK(t,r,n,{submission:i,fetcherSubmission:l,preventScrollReset:s,replace:u}={}){n||(ev?.resolve(),ev=null),r.response.headers.has("X-Remix-Revalidate")&&(eM=!0);let c=r.response.headers.get("Location");(0,a.V1)(c,"Expected a Location header on the redirect Response");let d=c,h=new URL(t.url);c=Q(c,h,_,e.history),(0,y.c)(d,c,h,"allow-explicit");let f=(0,a.yJ)(ed.location,c,{_isRedirect:!0});if(P){let e=!1;if(r.response.headers.has("X-Remix-Reload-Document"))e=!0;else if((0,o.vh)(c)){let t=(0,a.A4)(w,c,!0);e=t.origin!==w.location.origin||null==(0,o.pb)(t.pathname,_)}if(e)return void(u?w.location.replace(c):w.location.assign(c))}v=null;let p=!0===u||r.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:m,formAction:g,formEncType:b}=ed.navigation;!i&&!l&&m&&g&&b&&(i=eb(ed.navigation));let E=i||l;R.has(r.response.status)&&E&&ey(E.formMethod)?await eW(p,f,{submission:{...E,formAction:c},preventScrollReset:s||eL,enableViewTransition:n?eP:void 0}):await eW(p,f,{overrideNavigation:eR(f,[],p,i),fetcherSubmission:l,preventScrollReset:s||eL,enableViewTransition:n?eP:void 0})}async function eZ(e,t,r,n,i){let l,s={};try{l=await q(H,e,t,r,i,n,!1)}catch(e){return r.filter(e=>e.shouldLoad).forEach(t=>{s[t.route.id]={type:"error",error:e}}),s}if(e.signal.aborted)return s;if(!ey(e.method))for(let e of r){if(l[e.route.id]?.type==="error")break;!l.hasOwnProperty(e.route.id)&&!ed.loaderData.hasOwnProperty(e.route.id)&&(!ed.errors||!ed.errors.hasOwnProperty(e.route.id))&&e.shouldCallHandler()&&(l[e.route.id]={type:"error",result:Error(`No result returned from dataStrategy for route ${e.route.id}`)})}for(let[t,n]of Object.entries(l)){var u;if(em((u=n).result)&&b.has(u.result.status)){let i=n.result;s[t]={type:"redirect",response:function(e,t,r,n,i){let l=e.headers.get("Location");if((0,a.V1)(l,"Redirects returned/thrown from loaders/actions must have a Location header"),!(0,o.vh)(l)){let a=n.slice(0,n.findIndex(e=>e.route.id===r)+1);l=D(new URL(t.url),a,i,l),e.headers.set("Location",l)}return e}(i,e,t,r,_)}}else s[t]=await X(n)}return s}async function eQ(e,t,r,n,a){let o=eZ(r,n,e,a,null),i=Promise.all(t.map(async e=>{if(!e.matches||!e.match||!e.request||!e.controller)return Promise.resolve({[e.key]:{type:"error",error:es(404,{pathname:e.path})}});{let t=(await eZ(e.request,e.path,e.matches,a,e.key))[e.match.route.id];return{[e.key]:t}}}));return{loaderResults:await o,fetcherResults:(await i).reduce((e,t)=>Object.assign(e,t),{})}}function e0(){eM=!0,ez.forEach((e,t)=>{eT.has(t)&&eO.add(t),e3(t)})}function e1(e,t,r={}){let n=new Map(ed.fetchers);n.set(e,t),eV({fetchers:n},{flushSync:!0===(r&&r.flushSync)})}function e2(e,t,r,n={}){let a=ei(ed.matches,t),o=new Map(ed.fetchers);e5(o,e),eV({errors:{[a.route.id]:r},fetchers:o},{flushSync:!0===(n&&n.flushSync)})}function e5(e,t){let r=ed.fetchers.get(t);eT.has(t)&&!(r&&"loading"===r.state&&ej.has(t))&&e3(t),ez.delete(t),ej.delete(t),eU.delete(t),e_.delete(t),eO.delete(t),e.delete(t)}function e3(e,t){let r=eT.get(e);r&&(r.abort(t),eT.delete(e))}function e4(e,t){for(let r of e){let e=t.get(r);(0,a.V1)(e,`Expected fetcher: ${r}`);let n=ex(e.data);t.set(r,n)}}function e6(e){let t=[],r=!1;for(let n of eU){let o=e.get(n);(0,a.V1)(o,`Expected fetcher: ${n}`),"loading"===o.state&&(eU.delete(n),t.push(n),r=!0)}return e4(t,e),r}function e7(e,t){let r=[];for(let[n,o]of ej)if(o<e){let e=t.get(n);(0,a.V1)(e,`Expected fetcher: ${n}`),"loading"===e.state&&(e3(n),ej.delete(n),r.push(n))}return e4(r,t),r.length>0}function e9(e){ed.blockers.delete(e),eF.delete(e)}function e8(e,t){let r=ed.blockers.get(e)||S;(0,a.V1)("unblocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"proceeding"===t.state||"blocked"===r.state&&"unblocked"===t.state||"proceeding"===r.state&&"unblocked"===t.state,`Invalid blocker state transition: ${r.state} -> ${t.state}`);let n=new Map(ed.blockers);n.set(e,t),eV({blockers:n})}function te({currentLocation:e,nextLocation:t,historyAction:r}){if(0===eF.size)return;eF.size>1&&(0,a.$e)(!1,"A router only supports one blocker at a time");let n=Array.from(eF.entries()),[o,i]=n[n.length-1],l=ed.blockers.get(o);if((!l||"proceeding"!==l.state)&&i({currentLocation:e,nextLocation:t,historyAction:r}))return o}function tt(e){let t=es(404,{pathname:e}),{matches:r,route:n}=el(N.activeRoutes);return{notFoundMatches:r,route:n,error:t}}function tr(e,t){return G&&G(e,t.map(e=>(0,o.wy)(e,ed.loaderData)))||e.key}function tn(e,t){if(J){let r=J[tr(e,t)];if("number"==typeof r)return r}return null}function ta(t,r,n){if(e.patchRoutesOnNavigation){let e=N.branches;if(!t)return{active:!0,matches:(0,o.et)(r,n,_,!0,e)||[]};if(Object.keys(t[0].params).length>0)return{active:!0,matches:(0,o.et)(r,n,_,!0,e)}}return{active:!1,matches:null}}async function to(t,r,n,a){if(!e.patchRoutesOnNavigation)return{type:"success",matches:t};let i=t;for(;;){let t=z;try{await e.patchRoutesOnNavigation({signal:n,path:r,matches:i,fetcherKey:a,patch:(e,r)=>{n.aborted||j(e,r,N,t,U,!1)}})}catch(e){return{type:"error",error:e,partialMatches:i}}if(n.aborted)return{type:"aborted"};let l=N.branches,s=(0,o.et)(N.activeRoutes,r,_,!1,l),u=null;if(s){if(0===Object.keys(s[0].params).length)return{type:"success",matches:s};else if(!((u=(0,o.et)(N.activeRoutes,r,_,!0,l))&&i.length<u.length&&ti(i,u.slice(0,i.length))))return{type:"success",matches:s}}if(u||(u=(0,o.et)(N.activeRoutes,r,_,!0,l)),!u||ti(i,u))return{type:"success",matches:null};i=u}}function ti(e,t){return e.length===t.length&&e.every((e,r)=>e.route.id===t[r].route.id)}return l={get basename(){return _},get future(){return V},get state(){return ed},get routes(){return N.stableRoutes},get branches(){return N.branches},get manifest(){return z},get window(){return w},initialize:function(){if(I=e.history.listen(({action:t,location:r,delta:n})=>{if(g){g(),g=void 0;return}(0,a.$e)(0===eF.size||null!=n,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let o=te({currentLocation:ed.location,nextLocation:r,historyAction:t});if(o&&null!=n){let t=new Promise(e=>{g=e});e.history.go(-1*n),e8(o,{state:"blocked",location:r,proceed(){e8(o,{state:"proceeding",proceed:void 0,reset:void 0,location:r}),t.then(()=>e.history.go(n))},reset(){let e=new Map(ed.blockers);e.set(o,S),eV({blockers:e})}}),ev?.resolve(),ev=null;return}return eW(t,r)}),P){var t=w,r=ek;try{let e=t.sessionStorage.getItem(L);if(e){let t=JSON.parse(e);for(let[e,n]of Object.entries(t||{}))n&&Array.isArray(n)&&r.set(e,new Set(n||[]))}}catch{}let e=()=>(function(e,t){if(t.size>0){let r={};for(let[e,n]of t)r[e]=[...n];try{e.sessionStorage.setItem(L,JSON.stringify(r))}catch(e){(0,a.$e)(!1,`Failed to save applied view transitions in sessionStorage (${e}).`)}}})(w,ek);w.addEventListener("pagehide",e),eC=()=>w.removeEventListener("pagehide",e)}return ed.initialized||eW("POP",ed.location,{initialHydration:!0}),l},subscribe:function(e){if(B.add(e),W){let{newErrors:t}=W;W=null,e(ed,{deletedFetchers:[],newErrors:t,viewTransitionOpts:void 0,flushSync:!1})}return()=>B.delete(e)},enableScrollRestoration:function(e,t,r){if(J=e,K=t,G=r||null,!Z&&ed.navigation===E){Z=!0;let e=tn(ed.location,ed.matches);null!=e&&eV({restoreScrollPosition:e})}return()=>{J=null,K=null,G=null}},navigate:eB,fetch:async function t(t,r,n,a){e3(t);let i=!0===(a&&a.flushSync),s=c(l),u=N.activeRoutes,d=D(ed.location,ed.matches,_,n,r,a?.relative),h=(0,o.et)(u,d,_,!1,N.branches),f=ta(h,u,d);if(f.active&&f.matches&&(h=f.matches),s&&s(ew(e.history,d,h)),!h)return void e2(t,r,es(404,{pathname:d}),{flushSync:i});let{path:p,submission:m,error:y}=M(!0,d,a);if(y)return void e2(t,r,y,{flushSync:i});let v=e.getContext?await e.getContext():new o.aB,g=!0===(a&&a.preventScrollReset);m&&ey(m.formMethod)?await eG(t,r,p,h,v,f.active,i,g,m,a&&a.defaultShouldRevalidate):(ez.set(t,{routeId:r,path:p}),await eX(t,r,p,h,v,f.active,i,g,m))},revalidate:function(){eH||(eH=eS()),e0(),eV({revalidation:"loading"});let e=eH.promise;return"submitting"===ed.navigation.state||("idle"===ed.navigation.state?eW(ed.historyAction,ed.location,{startUninterruptedRevalidation:!0}):eW(ep||ed.historyAction,ed.navigation.location,{overrideNavigation:ed.navigation,enableViewTransition:!0===eP})),e},createHref:t=>e.history.createHref(t),createURL:t=>e.history.createURL(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:function(e){return eN.set(e,(eN.get(e)||0)+1),e_.has(e)&&e_.delete(e),ed.fetchers.get(e)||x},resetFetcher:function(e,t){e3(e,t?.reason),e1(e,ex(null))},deleteFetcher:function(e){let t=(eN.get(e)||0)-1;t<=0?(eN.delete(e),e_.add(e)):eN.set(e,t),eV({fetchers:new Map(ed.fetchers)})},dispose:function(){I&&I(),eC&&eC(),B.clear(),v&&v.abort(),ed.fetchers.forEach((e,t)=>e5(ed.fetchers,t)),ed.blockers.forEach((e,t)=>e9(t))},getBlocker:function(e,t){let r=ed.blockers.get(e)||S;return eF.get(e)!==t&&eF.set(e,t),r},deleteBlocker:e9,patchRoutes:function(e,t,r=!1){j(e,t,N,z,U,r),N.hasHMRRoutes||eV({})},_internalFetchControllers:eT,_internalSetRoutes:function(e){z={},N.setHmrRoutes((0,o.R_)(e,U,void 0,z))},_internalSetStateDoNotUseOrYouWillBreakYourApp(e){eV(e)}},e.instrumentations&&(l=function(e,t){var r,n,o,l;let c=[],p=[];if(t.forEach(e=>e({instrument(e){null!=e.navigate&&c.push(e.navigate),null!=e.fetch&&p.push(e.fetch)}})),c.length>0){let t=s(e.navigate),o=async(...r)=>{let n,[o,i]=r,l={to:"number"==typeof o||"string"==typeof o?o:o?(0,a.AO)(o):".",...m(e,i??{})};return d(await h(c,l,async()=>{if("number"==typeof o)return await t(...r);let a=u(e,e=>{n=e});try{return await t(...r)}finally{a()}},e=>({...f(e),meta:n})))};r=o,n=t,r[i]=n,e.navigate=o}if(p.length>0){let t=s(e.fetch),r=async(...r)=>{let n,[a,o,i,l]=r;return d(await h(p,{href:i??".",fetcherKey:a,...m(e,l??{})},async()=>{let a=u(e,e=>{n=e});try{return await t(...r)}finally{a()}},e=>({...f(e),meta:n})))};o=r,l=t,o[i]=l,e.fetch=r}return e}(l,e.instrumentations.map(e=>e.router).filter(Boolean))),l}function D(e,t,r,n,i,l){let s,u;if(i){for(let e of(s=[],t))if(s.push(e),e.route.id===i){u=e;break}}else s=t,u=t[t.length-1];let c=(0,o.Gh)(n||".",(0,o.PD)(s),(0,o.pb)(e.pathname,r)||e.pathname,"path"===l);if(null==n&&(c.search=e.search,c.hash=e.hash),(null==n||""===n||"."===n)&&u){let e=ev(c.search);if(u.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index";else if(!u.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll("index");e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let r=e.toString();c.search=r?`?${r}`:""}}return"/"!==r&&(c.pathname=(0,o.RW)({basename:r,pathname:c.pathname})),(0,a.AO)(c)}function M(e,t,r){var n;let o,i;if(!r||!(null!=r&&("formData"in r&&null!=r.formData||"body"in r&&void 0!==r.body)))return{path:t};if(r.formMethod&&(n=r.formMethod,!w.has(n.toUpperCase())))return{path:t,error:es(405,{method:r.formMethod})};let l=()=>({path:t,error:es(400,{type:"invalid-body"})}),s=(r.formMethod||"get").toUpperCase(),u=ec(t);if(void 0!==r.body){if("text/plain"===r.formEncType){if(!ey(s))return l();let e="string"==typeof r.body?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((e,[t,r])=>`${e}${t}=${r}
|
|
3
|
-
`,""):String(r.body);return{path:t,submission:{formMethod:s,formAction:u,formEncType:r.formEncType,formData:void 0,json:void 0,text:e}}}else if("application/json"===r.formEncType){if(!ey(s))return l();try{let e="string"==typeof r.body?JSON.parse(r.body):r.body;return{path:t,submission:{formMethod:s,formAction:u,formEncType:r.formEncType,formData:void 0,json:e,text:void 0}}}catch{return l()}}}if((0,a.V1)("function"==typeof FormData,"FormData is not available in this environment"),r.formData)o=et(r.formData),i=r.formData;else if(r.body instanceof FormData)o=et(r.body),i=r.body;else if(r.body instanceof URLSearchParams)i=er(o=r.body);else if(null==r.body)o=new URLSearchParams,i=new FormData;else try{o=new URLSearchParams(r.body),i=er(o)}catch{return l()}let c={formMethod:s,formAction:u,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:i,json:void 0,text:void 0};if(ey(c.formMethod))return{path:t,submission:c};let d=(0,a.Rr)(t);return e&&d.search&&ev(d.search)&&o.append("index",""),d.search=`?${o}`,{path:(0,a.AO)(d),submission:c}}function O(e,t,r,n,a,i,l,s,u,c,d,h,f,p,m,y,v,g,w,b,R,E){let x,S=R?eh(R[1])?R[1].error:R[1].data:void 0,L=a.createURL(i.location),P=a.createURL(u);if(d&&i.errors){let e=Object.keys(i.errors)[0];x=l.findIndex(t=>t.route.id===e)}else if(R&&eh(R[1])){let e=R[0];x=l.findIndex(t=>t.route.id===e)-1}let k=R?R[1].statusCode:void 0,C=k&&k>=400,D={currentUrl:L,currentParams:i.matches[0]?.params||{},nextUrl:P,nextParams:l[0].params,...s,actionResult:S,actionStatus:k},M=(0,o.gU)(l),O=l.map((a,o)=>{var l,s,f,p,m;let y,{route:v}=a,g=null;if(null!=x&&o>x)g=!1;else if(v.lazy)g=!0;else if(T(v))if(d){let{shouldLoad:e}=$(v,i.loaderData,i.errors);g=e}else{let e,t;l=i.loaderData,s=i.matches[o],f=a,e=!s||f.route.id!==s.route.id,t=!l.hasOwnProperty(f.route.id),(e||t)&&(g=!0)}else g=!1;if(null!==g)return W(r,n,e,u,M,a,c,t,g);let w=!1;"boolean"==typeof E?w=E:C?w=!1:h||L.pathname+L.search===P.pathname+P.search||L.search!==P.search?w=!0:(p=i.matches[o],m=a,y=p.route.path,(p.pathname!==m.pathname||null!=y&&y.endsWith("*")&&p.params["*"]!==m.params["*"])&&(w=!0));let b={...D,defaultShouldRevalidate:w};return W(r,n,e,u,M,a,c,t,A(a,b),b,E)}),j=[];return m.forEach((e,s)=>{if(d||!l.some(t=>t.route.id===e.routeId)||p.has(s))return;let u=i.fetchers.get(s),m=u&&"idle"!==u.state&&void 0===u.data,R=(0,o.et)(v,e.path,g??"/",!1,b);if(!R){if(w&&m)return;j.push({key:s,routeId:e.routeId,path:e.path,matches:null,match:null,request:null,controller:null});return}if(y.has(s))return;let x=eg(R,e.path),S=new AbortController,L=ee(a,e.path,S.signal),P=null;if(f.has(s))f.delete(s),P=Y(r,n,L,e.path,R,x,c,t);else if(m)h&&(P=Y(r,n,L,e.path,R,x,c,t));else{let a={...D,defaultShouldRevalidate:"boolean"==typeof E?E:!C&&h};A(x,a)&&(P=Y(r,n,L,e.path,R,x,c,t,a))}P&&j.push({key:s,routeId:e.routeId,path:e.path,matches:P,match:x,request:L,controller:S})}),{dsMatches:O,revalidatingFetchers:j}}function T(e){return null!=e.loader||null!=e.middleware&&e.middleware.length>0}function $(e,t,r){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!T(e))return{shouldLoad:!1,renderFallback:!1};let n=null!=t&&e.id in t,a=null!=r&&void 0!==r[e.id];if(!n&&a)return{shouldLoad:!1,renderFallback:!1};if("function"==typeof e.loader&&!0===e.loader.hydrate)return{shouldLoad:!0,renderFallback:!n};let o=!n&&!a;return{shouldLoad:o,renderFallback:o}}function A(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}function j(e,t,r,n,i,l){let s;if(e){let t=n[e];(0,a.V1)(t,`No route found to patch children into: routeId = ${e}`),t.children||(t.children=[]),s=t.children}else s=r.activeRoutes;let u=[],c=[];if(t.forEach(e=>{let t=s.find(t=>(function e(t,r){return"id"in t&&"id"in r&&t.id===r.id||t.index===r.index&&t.path===r.path&&t.caseSensitive===r.caseSensitive&&((!t.children||0===t.children.length)&&(!r.children||0===r.children.length)||(t.children?.every((t,n)=>r.children?.some(r=>e(t,r)))??!1))})(e,t));t?c.push({existingRoute:t,newRoute:e}):u.push(e)}),u.length>0){let t=(0,o.R_)(u,i,[e||"_","patch",String(s?.length||"0")],n);s.push(...t)}if(l&&c.length>0)for(let e=0;e<c.length;e++){let{existingRoute:t,newRoute:r}=c[e],[n]=(0,o.R_)([r],i,[],{},!0);Object.assign(t,{element:n.element?n.element:t.element,errorElement:n.errorElement?n.errorElement:t.errorElement,hydrateFallbackElement:n.hydrateFallbackElement?n.hydrateFallbackElement:t.hydrateFallbackElement})}r.hasHMRRoutes||r.setRoutes([...r.activeRoutes])}let U=new WeakMap,z=({key:e,route:t,manifest:r,mapRouteProperties:n})=>{let i=r[t.id];if((0,a.V1)(i,"No route found in manifest"),!i.lazy||"object"!=typeof i.lazy)return;let l=i.lazy[e];if(!l)return;let s=U.get(i);s||(s={},U.set(i,s));let u=s[e];if(u)return u;let c=(async()=>{let t=(0,o.pr)(e),r=void 0!==i[e];if(t)(0,a.$e)(!t,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),s[e]=Promise.resolve();else if(r)(0,a.$e)(!1,`Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let t=await l();null!=t&&(Object.assign(i,{[e]:t}),Object.assign(i,n(i)))}"object"==typeof i.lazy&&(i.lazy[e]=void 0,Object.values(i.lazy).every(e=>void 0===e)&&(i.lazy=void 0))})();return s[e]=c,c},N=new WeakMap;async function _(e){let t=e.matches.filter(e=>e.shouldLoad),r={};return(await Promise.all(t.map(e=>e.resolve()))).forEach((e,n)=>{r[t[n].route.id]=e}),r}async function F(e){return e.matches.some(e=>e.route.middleware)?H(e,()=>_(e)):_(e)}function H(e,t){return V(e,t,e=>{var t,r;if(em(t=e)&&(r=t.status,b.has(r))&&t.headers.has("Location"))throw e;return e},ed,r);async function r(t,r,n){if(n)return Object.assign(n.value,{[r]:{type:"error",result:t}});{let{matches:n}=e,a=Math.min(Math.max(n.findIndex(e=>e.route.id===r),0),Math.max(n.findIndex(e=>e.shouldCallHandler()),0)),o=n[a].route.id;for(let e of n.slice(0,a+1))try{await e._lazyPromises?.route}catch{o=e.route.id;break}return{[ei(n,o).route.id]:{type:"error",result:t}}}}}async function V(e,t,r,n,a){let{matches:o,...i}=e;return await I(i,o.flatMap(e=>e.route.middleware?e.route.middleware.map(t=>[e.route.id,t]):[]),t,r,n,a)}async function I(e,t,r,n,a,o,i=0){let l,{request:s}=e;if(s.signal.aborted)throw s.signal.reason??Error(`Request aborted: ${s.method} ${s.url}`);let u=t[i];if(!u)return await r();let[c,d]=u,h=async()=>{if(l)throw Error("You may only call `next()` once per middleware");try{return(l={value:await I(e,t,r,n,a,o,i+1)}).value}catch(e){return(l={value:await o(e,c,l)}).value}};try{let t=await d(e,h),r=null!=t?n(t):void 0;if(a(r))return r;if(l)return r??l.value;return(l={value:await h()}).value}catch(e){return await o(e,c,l)}}function B(e,t,r,n,i){let l=z({key:"middleware",route:n.route,manifest:t,mapRouteProperties:e}),s=function(e,t,r,n,i){let l,s=r[e.id];if((0,a.V1)(s,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if("function"==typeof e.lazy){let t=N.get(s);if(t)return{lazyRoutePromise:t,lazyHandlerPromise:t};let r=(async()=>{(0,a.V1)("function"==typeof e.lazy,"No lazy route function found");let t=await e.lazy(),r={};for(let e in t){let n=t[e];if(void 0===n)continue;let i=(0,o.ep)(e),l=void 0!==s[e];i?(0,a.$e)(!i,"Route property "+e+" is not a supported property to be returned from a lazy route function. This property will be ignored."):l?(0,a.$e)(!l,`Route "${s.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`):r[e]=n}Object.assign(s,r),Object.assign(s,{...n(s),lazy:void 0})})();return N.set(s,r),r.catch(()=>{}),{lazyRoutePromise:r,lazyHandlerPromise:r}}let u=Object.keys(e.lazy),c=[];for(let a of u){if(i&&i.includes(a))continue;let o=z({key:a,route:e,manifest:r,mapRouteProperties:n});o&&(c.push(o),a===t&&(l=o))}let d=c.length>0?Promise.all(c).then(()=>{}):void 0;return d?.catch(()=>{}),l?.catch(()=>{}),{lazyRoutePromise:d,lazyHandlerPromise:l}}(n.route,ey(r.method)?"action":"loader",t,e,i);return{middleware:l,route:s.lazyRoutePromise,handler:s.lazyHandlerPromise}}function W(e,t,r,n,a,o,i,l,s,u=null,c){let d=!1,h=B(e,t,r,o,i);return{...o,_lazyPromises:h,shouldLoad:s,shouldRevalidateArgs:u,shouldCallHandler:e=>(d=!0,u)?"boolean"==typeof c?A(o,{...u,defaultShouldRevalidate:c}):"boolean"==typeof e?A(o,{...u,defaultShouldRevalidate:e}):A(o,u):s,resolve(e){let{lazy:t,loader:i,middleware:u}=o.route,c=d||s||e&&!ey(r.method)&&(t||i),f=u&&u.length>0&&!i&&!t;return c&&(ey(r.method)||!f)?J({request:r,path:n,pattern:a,match:o,lazyHandlerPromise:h?.handler,lazyRoutePromise:h?.route,handlerOverride:e,scopedContext:l}):Promise.resolve({type:"data",result:void 0})}}}function Y(e,t,r,n,a,i,l,s,u=null){return a.map(c=>c.route.id!==i.route.id?{...c,shouldLoad:!1,shouldRevalidateArgs:u,shouldCallHandler:()=>!1,_lazyPromises:B(e,t,r,c,l),resolve:()=>Promise.resolve({type:"data",result:void 0})}:W(e,t,r,n,(0,o.gU)(a),c,l,s,!0,u))}async function q(e,t,r,n,a,i,l){n.some(e=>e._lazyPromises?.middleware)&&await Promise.all(n.map(e=>e._lazyPromises?.middleware));let s={request:t,url:(0,o.cg)(t,r),pattern:(0,o.gU)(n),params:n[0].params,context:i,matches:n},u=l?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:e=>H(s,()=>e({...s,fetcherKey:a,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}})),c=await e({...s,fetcherKey:a,runClientMiddleware:u});try{await Promise.all(n.flatMap(e=>[e._lazyPromises?.handler,e._lazyPromises?.route]))}catch{}return c}async function J({request:e,path:t,pattern:r,match:n,lazyHandlerPromise:a,lazyRoutePromise:i,handlerOverride:l,scopedContext:s}){let u,c,d=ey(e.method),h=d?"action":"loader",f=a=>{let i,u=new Promise((e,t)=>i=t);c=()=>i(),e.signal.addEventListener("abort",c);let d=i=>"function"!=typeof a?Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${h}" [routeId: ${n.route.id}]`)):a({request:e,url:(0,o.cg)(e,t),pattern:r,params:n.params,context:s},...void 0!==i?[i]:[]);return Promise.race([(async()=>{try{return{type:"data",result:await (l?l(e=>d(e)):d())}}catch(e){return{type:"error",result:e}}})(),u])};try{let t=d?n.route.action:n.route.loader;if(a||i)if(t){let e,[r]=await Promise.all([f(t).catch(t=>{e=t}),a,i]);if(void 0!==e)throw e;u=r}else{await a;let t=d?n.route.action:n.route.loader;if(t)[u]=await Promise.all([f(t),i]);else{if("action"!==h)return{type:"data",result:void 0};let t=new URL(e.url),r=t.pathname+t.search;throw es(405,{method:e.method,pathname:r,routeId:n.route.id})}}else if(t)u=await f(t);else{let t=new URL(e.url);throw es(404,{pathname:t.pathname+t.search})}}catch(e){return{type:"error",result:e}}finally{c&&e.signal.removeEventListener("abort",c)}return u}async function G(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?null==e.body?null:e.json():e.text()}async function X(e){let{result:t,type:r}=e;if(em(t)){let e;try{e=await G(t)}catch(e){return{type:"error",error:e}}return"error"===r?{type:"error",error:new o.cj(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:"data",data:e,statusCode:t.status,headers:t.headers}}if("error"===r){if(ep(t)){var n;return t.data instanceof Error?{type:"error",error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:(n=t,new o.cj(n.init?.status??500,n.init?.statusText??"Internal Server Error",n.data)),statusCode:(0,o.pX)(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}}return{type:"error",error:t,statusCode:(0,o.pX)(t)?t.status:void 0}}return ep(t)?{type:"data",data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}let K=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Z(e){try{return K.includes(new URL(e).protocol)}catch{return!1}}function Q(e,t,r,a){if((0,o.vh)(e)){let a=new URL(n.iA.test(e)?(0,n.lS)(e,t.protocol):e);if(Z(a.toString()))throw Error("Invalid redirect location");let i=null!=(0,o.pb)(a.pathname,r);if(a.origin===t.origin&&i)return(0,o.Hv)(a.pathname)+a.search+a.hash}try{if(Z(a.createURL(e).toString()))throw Error("Invalid redirect location")}catch{}return e}function ee(e,t,r,n){let a=e.createURL(ec(t)).toString(),o={signal:r};if(n&&ey(n.formMethod)){let{formMethod:e,formEncType:t}=n;o.method=e.toUpperCase(),"application/json"===t?(o.headers=new Headers({"Content-Type":t}),o.body=JSON.stringify(n.json)):"text/plain"===t?o.body=n.text:"application/x-www-form-urlencoded"===t&&n.formData?o.body=et(n.formData):o.body=n.formData}return new Request(a,o)}function et(e){let t=new URLSearchParams;for(let[r,n]of e.entries())t.append(r,"string"==typeof n?n:n.name);return t}function er(e){let t=new FormData;for(let[r,n]of e.entries())t.append(r,n);return t}function en(e,t,r,n,i,l,s){let{loaderData:u,errors:c}=function(e,t,r,n=!1,i=!1){let l,s={},u=null,c=!1,d={},h=r&&eh(r[1])?r[1].error:void 0;return e.forEach(r=>{if(!(r.route.id in t))return;let f=r.route.id,p=t[f];if((0,a.V1)(!ef(p),"Cannot handle redirect results in processLoaderData"),eh(p)){let t=p.error;if(void 0!==h&&(t=h,h=void 0),u=u||{},i)u[f]=t;else{let r=ei(e,f);null==u[r.route.id]&&(u[r.route.id]=t)}n||(s[f]=P),c||(c=!0,l=(0,o.pX)(p.error)?p.error.status:500),p.headers&&(d[f]=p.headers)}else s[f]=p.data,p.statusCode&&200!==p.statusCode&&!c&&(l=p.statusCode),p.headers&&(d[f]=p.headers)}),void 0!==h&&r&&(u={[r[0]]:h},r[2]&&(s[r[2]]=void 0)),{loaderData:s,errors:u,statusCode:l||200,loaderHeaders:d}}(t,r,n);return i.filter(e=>!e.matches||e.matches.some(e=>e.shouldLoad)).forEach(t=>{let{key:r,match:n,controller:o}=t;if(o&&o.signal.aborted)return;let i=l[r];if((0,a.V1)(i,"Did not find corresponding fetcher result"),eh(i)){let t=ei(e.matches,n?.route.id);c&&c[t.route.id]||(c={...c,[t.route.id]:i.error}),s.delete(r)}else if(ef(i))(0,a.V1)(!1,"Unhandled fetcher revalidation redirect");else{let e=ex(i.data);s.set(r,e)}}),{loaderData:u,errors:c}}function ea(e,t,r,n){let a=Object.entries(t).filter(([,e])=>e!==P).reduce((e,[t,r])=>(e[t]=r,e),{});for(let o of r){let r=o.route.id;if(!t.hasOwnProperty(r)&&e.hasOwnProperty(r)&&o.route.loader&&(a[r]=e[r]),n&&n.hasOwnProperty(r))break}return a}function eo(e){return e?eh(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function ei(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>null!=e.route.ErrorBoundary||null!=e.route.errorElement)||e[0]}function el(e){let t=1===e.length?e[0]:e.find(e=>e.index||!e.path||"/"===e.path)||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function es(e,{pathname:t,routeId:r,method:n,type:a,message:i}={}){let l="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(l="Bad Request",n&&t&&r?s=`You made a ${n} request to "${t}" but did not provide a \`loader\` for route "${r}", so there is no way to handle the request.`:"invalid-body"===a&&(s="Unable to encode submission body")):403===e?(l="Forbidden",s=`Route "${r}" does not match URL "${t}"`):404===e?(l="Not Found",s=`No route matches URL "${t}"`):405===e&&(l="Method Not Allowed",n&&t&&r?s=`You made a ${n.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${r}", so there is no way to handle the request.`:n&&(s=`Invalid request method "${n.toUpperCase()}"`)),new o.cj(e||500,l,Error(s),!0)}function eu(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[r,n]=t[e];if(ef(n))return{key:r,result:n}}}function ec(e){return(0,a.AO)({..."string"==typeof e?(0,a.Rr)(e):e,hash:""})}function ed(e){return null!=e&&"object"==typeof e&&Object.entries(e).every(([e,t])=>{var r;return"string"==typeof e&&null!=(r=t)&&"object"==typeof r&&"type"in r&&"result"in r&&("data"===r.type||"error"===r.type)})}function eh(e){return"error"===e.type}function ef(e){return"redirect"===(e&&e.type)}function ep(e){return"object"==typeof e&&null!=e&&"type"in e&&"data"in e&&"init"in e&&"DataWithResponseInit"===e.type}function em(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function ey(e){return g.has(e.toUpperCase())}function ev(e){return new URLSearchParams(e).getAll("index").some(e=>""===e)}function eg(e,t){let r="string"==typeof t?(0,a.Rr)(t).search:t.search;if(e[e.length-1].route.index&&ev(r||""))return e[e.length-1];let n=(0,o.nr)(e);return n[n.length-1]}function ew(e,t,r){return{url:(0,o.cg)(e.createURL(t),t),pattern:r?(0,o.gU)(r):"",params:r?.[0]?.params?{...r[0].params}:{}}}function eb(e){let{formMethod:t,formAction:r,formEncType:n,text:a,formData:o,json:i}=e;if(t&&r&&n){if(null!=a)return{formMethod:t,formAction:r,formEncType:n,formData:void 0,json:void 0,text:a};else if(null!=o)return{formMethod:t,formAction:r,formEncType:n,formData:o,json:void 0,text:void 0};else if(void 0!==i)return{formMethod:t,formAction:r,formEncType:n,formData:void 0,json:i,text:void 0}}}function eR(e,t,r,n){return n?{state:"loading",location:e,matches:t,historyAction:r,formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text}:{state:"loading",location:e,matches:t,historyAction:r,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function eE(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function ex(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function eS(){let e,t,r=new Promise((n,a)=>{e=async e=>{n(e);try{await r}catch{}},t=async e=>{a(e);try{await r}catch{}}});return{promise:r,resolve:e,reject:t}}},2872(e,t,r){function n(e,t){return t+e.replace(/\\/g,"/")}r.d(t,{lS:()=>n},{E6:/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,iA:/^[\\/]{2}/})},9932(e,t,r){var n=r(2872),a=r(7629),o=r(6255),i=class{#a=new Map;constructor(e){if(e)for(let[t,r]of e)this.set(t,r)}get(e){if(this.#a.has(e))return this.#a.get(e);if(void 0!==e.defaultValue)return e.defaultValue;throw Error("No value found for context")}set(e,t){this.#a.set(e,t)}};let l=new Set(["lazy","caseSensitive","path","id","index","children"]);function s(e){return l.has(e)}let u=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function c(e){return u.has(e)}function d(e){let t={};return e.Component&&Object.assign(t,{element:o.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:o.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:o.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}function h(e,t){return Object.assign(e,{...t,..."object"==typeof t.lazy&&null!=t.lazy?{lazy:{...e.lazy,...t.lazy}}:{}})}function f(e,t,r="/"){return p(e,t,r,!1)}function p(e,t,r,n,o){let i=x(("string"==typeof t?(0,a.Rr)(t):t).pathname||"/",r);if(null==i)return null;let l=o??y(e),s=null,u=function(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return(0,a.$e)(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}(i);for(let e=0;null==s&&e<l.length;++e)s=function(e,t,r=!1){let{routesMeta:n}=e,a={},o="/",i=[];for(let e=0;e<n.length;++e){let l=n[e],s=e===n.length-1,u="/"===o?t:t.slice(o.length)||"/",c={path:l.relativePath,caseSensitive:l.caseSensitive,end:s},d=l.matcher&&l.compiledParams?R(c,u,l.matcher,l.compiledParams):b(c,u),h=l.route;if(!d&&s&&r&&!n[n.length-1].route.index&&(d=b({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!d)return null;Object.assign(a,d.params),i.push({params:a,pathname:O([o,d.pathname]),pathnameBase:$(O([o,d.pathnameBase])),route:h}),"/"!==d.pathnameBase&&(o=O([o,d.pathnameBase]))}return i}(l[e],u,n);return s}function m(e,t){let{route:r,pathname:n,params:a}=e;return{id:r.id,pathname:n,params:a,loaderData:t[r.id],handle:r.handle}}function y(e){let t=function e(t,r=[],n=[],o="",i=!1){let l=(t,l,s=i,u)=>{var c,d;let h,f,p={relativePath:void 0===u?t.path||"":u,caseSensitive:!0===t.caseSensitive,childrenIndex:l,route:t};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(o)&&s)return;(0,a.V1)(p.relativePath.startsWith(o),`Absolute route path "${p.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(o.length)}let m=O([o,p.relativePath]),y=n.concat(p);t.children&&t.children.length>0&&((0,a.V1)(!0!==t.index,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),e(t.children,r,y,m,s)),(null!=t.path||t.index)&&r.push({path:m,score:(c=m,d=t.index,f=(h=c.split("/")).length,h.some(w)&&(f+=-2),d&&(f+=2),h.filter(e=>!w(e)).reduce((e,t)=>e+(v.test(t)?3:g.test(t)?3.5:""===t?1:10),f)),routesMeta:y.map((e,t)=>{let[r,n]=E(e.relativePath,e.caseSensitive,t===y.length-1);return{...e,matcher:r,compiledParams:n}})})};return t.forEach((e,t)=>{if(""!==e.path&&e.path?.includes("?"))for(let r of function e(t){let r=t.split("/");if(0===r.length)return[];let[n,...a]=r,o=n.endsWith("?"),i=n.replace(/\?$/,"");if(0===a.length)return o?[i,""]:[i];let l=e(a.join("/")),s=[];return s.push(...l.map(e=>""===e?i:[i,e].join("/"))),o&&s.push(...l),s.map(e=>t.startsWith("/")&&""===e?"/":e)}(e.path))l(e,t,!0,r);else l(e,t)}),r}(e);return t.sort((e,t)=>{var r,n;return e.score!==t.score?t.score-e.score:(r=e.routesMeta.map(e=>e.childrenIndex),n=t.routesMeta.map(e=>e.childrenIndex),r.length===n.length&&r.slice(0,-1).every((e,t)=>e===n[t])?r[r.length-1]-n[n.length-1]:0)}),t}let v=/^:[\w-]+$/,g=/^:[\w-]+/,w=e=>"*"===e;function b(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=E(e.path,e.caseSensitive,e.end);return R(e,t,r,n)}function R(e,t,r,n){let a=t.match(r);if(!a)return null;let o=a[0],i=T(o,1),l=a.slice(1);return{params:n.reduce((e,{paramName:t,isOptional:r},n)=>{if("*"===t){let e=l[n]||"";i=T(o.slice(0,o.length-e.length),1)}let a=l[n];return r&&!a?e[t]=void 0:e[t]=(a||"").replace(/%2F/g,"/"),e},{}),pathname:o,pathnameBase:i,pattern:e}}function E(e,t=!1,r=!0){(0,a.$e)("*"===e||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,r,a,o)=>{if(n.push({paramName:t,isOptional:null!=r}),r){let t=o.charAt(a+e.length);return t&&"/"!==t?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(?=\/|$|\()/g,"(?:/$1)?");return e.endsWith("*")?(n.push({paramName:"*"}),o+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?o+="\\/*$":""!==e&&"/"!==e&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),n]}function x(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&"/"!==n?null:e.slice(r)||"/"}function S({basename:e,pathname:t}){return"/"===t?e:O([e,t])}function L(e,t){let r=T(t).split("/");return e.split("/").forEach(e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)}),r.length>1?r.join("/"):"/"}function P(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function k(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}function C(e){let t=k(e);return t.map((e,r)=>r===t.length-1?e.pathname:e.pathnameBase)}function D(e,t,r,n=!1){let o,i;"string"==typeof e?o=(0,a.Rr)(e):(o={...e},(0,a.V1)(!o.pathname||!o.pathname.includes("?"),P("?","pathname","search",o)),(0,a.V1)(!o.pathname||!o.pathname.includes("#"),P("#","pathname","hash",o)),(0,a.V1)(!o.search||!o.search.includes("#"),P("#","search","hash",o)));let l=""===e||""===o.pathname,s=l?"/":o.pathname;if(null==s)i=r;else{let e=t.length-1;if(!n&&s.startsWith("..")){let t=s.split("/");for(;".."===t[0];)t.shift(),e-=1;o.pathname=t.join("/")}i=e>=0?t[e]:"/"}let u=function(e,t="/"){let{pathname:r,search:n="",hash:o=""}="string"==typeof e?(0,a.Rr)(e):e;return{pathname:r?(r=M(r)).startsWith("/")||r.startsWith("\\")?L(r.substring(1),"/"):L(r,t):t,search:A(n),hash:j(o)}}(o,i),c=s&&"/"!==s&&s.endsWith("/"),d=(l||"."===s)&&r.endsWith("/");return!u.pathname.endsWith("/")&&(c||d)&&(u.pathname+="/"),u}let M=e=>e.replace(/[\\/]{2,}/g,"/"),O=e=>M(e.join("/"));function T(e,t=0){let r=e.length;for(;r>t&&47===e.charCodeAt(r-1);)r--;return r===e.length?e:e.slice(0,r)}let $=e=>T(e).replace(/^\/*/,"/"),A=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",j=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";var U=class{status;statusText;data;error;internal;constructor(e,t,r,n=!1){this.status=e,this.statusText=t||"",this.internal=n,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function z(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}function N(e){return O(e.map(e=>e.route.path).filter(Boolean))||"/"}function _(e,t){let r=new URL("string"==typeof e||e instanceof URL?e:e.url),n="string"==typeof t?(0,a.Rr)(t):t;if(r.pathname=n.pathname||"/",n.search){let e=new URLSearchParams(n.search),t=e.getAll("index");for(let r of(e.delete("index"),t.filter(Boolean)))e.append("index",r);let a=e.toString();r.search=a?`?${a}`:""}else r.search="";return r.hash=n.hash||"",r}let F="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function H(e,t){let r=e;if("string"!=typeof r||!n.E6.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let o=r,i=!1;if(F)try{let e=new URL(window.location.href),a=new URL(n.iA.test(r)?(0,n.lS)(r,e.protocol):r),o=x(a.pathname,t);a.origin===e.origin&&null!=o?r=o+a.search+a.hash:i=!0}catch{(0,a.$e)(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:i,to:r}}r.d(t,{B6:()=>b,Gh:()=>D,MT:()=>d,PD:()=>C,RW:()=>S,R_:()=>function e(t,r=d,n=[],o={},i=!1){return t.map((t,l)=>{let s=[...n,String(l)],u="string"==typeof t.id?t.id:s.join("-");if((0,a.V1)(!0!==t.index||!t.children,"Cannot specify children on an index route"),(0,a.V1)(i||!o[u],`Found a route id collision on id "${u}". Route id's must be globally unique within Data Router usages`),!0===t.index){let e={...t,id:u};return o[u]=h(e,r(e)),e}{let n={...t,id:u,children:void 0};return o[u]=h(n,r(n)),t.children&&(n.children=e(t.children,r,s,o,i)),n}})},X9:()=>H,aB:()=>i,cg:()=>_,cj:()=>U,ep:()=>c,et:()=>p,gU:()=>N,nr:()=>k,oI:()=>y,pX:()=>z,pb:()=>x,pr:()=>s,ue:()=>f,wy:()=>m},{Bd:F,HS:O,Hv:M,WF:["EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],vh:e=>n.E6.test(e)})}}]);
|
package/dist/cli.d.mts
DELETED
package/dist/cli.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./package-DS5RZ0CH.mjs";import{defineCommand as t,renderUsage as n,runMain as r}from"citty";import i from"node:process";import a from"open";import{serve as o}from"@hono/node-server";import{serveStatic as s}from"@hono/node-server/serve-static";import{zValidator as c}from"@hono/zod-validator";import{constants as l,existsSync as u}from"node:fs";import d from"node:path";import{Hono as f}from"hono";import{z as p}from"zod";import{Uint8ArrayReader as m,Uint8ArrayWriter as h,ZipReader as ee,ZipWriter as te}from"@zip.js/zip.js";import{createHash as g,randomUUID as ne,randomUUIDv7 as _}from"node:crypto";import{bodyLimit as re}from"hono/body-limit";import{TextDecoder as ie,promisify as ae}from"node:util";import{Buffer as oe}from"node:buffer";import{and as v,desc as se,eq as y,isNull as b,sql as x}from"drizzle-orm";import{blob as ce,check as S,index as le,integer as C,sqliteTable as w,text as T,uniqueIndex as ue}from"drizzle-orm/sqlite-core";import de from"better-sqlite3";import{drizzle as fe}from"drizzle-orm/better-sqlite3";import{access as pe,chmod as me,lstat as he,mkdir as E,readFile as ge,readdir as _e,realpath as ve,rename as ye,rm as D,stat as be,writeFile as xe}from"node:fs/promises";import{readMigrationFiles as Se}from"drizzle-orm/migrator";import Ce from"env-paths";import{homedir as we}from"node:os";import{parse as Te,patch as Ee,stringify as De}from"@decimalturn/toml-patch";import{execFile as Oe}from"node:child_process";var ke=Object.defineProperty,Ae=(e,t)=>{let n={};for(var r in e)ke(n,r,{get:e[r],enumerable:!0});return t||ke(n,Symbol.toStringTag,{value:`Module`}),n};const O={promptNotFound:`PROMPT_NOT_FOUND`,providerConnectionFailed:`PROVIDER_CONNECTION_FAILED`,providerInUse:`PROVIDER_IN_USE`,providerNotFound:`PROVIDER_NOT_FOUND`,runtimeApplyFailed:`RUNTIME_APPLY_FAILED`,runtimeConfigurationChanged:`RUNTIME_CONFIGURATION_CHANGED`,runtimeConfigurationInvalid:`RUNTIME_CONFIGURATION_INVALID`,runtimeNotDetected:`RUNTIME_NOT_DETECTED`,success:`SUCCESS`},k=[`system`,`light`,`dark`],je=`foundry-export-v1`,Me=[`settings`,`providers`,`prompts`],A=[`codex`,`claude-code`],Ne=[`image/png`,`image/jpeg`,`image/webp`,`image/svg+xml`],Pe=[`authorization`,`x-api-key`],Fe=[`effort`,`xhigh_effort`,`max_effort`,`thinking`,`adaptive_thinking`,`interleaved_thinking`],Ie=p.strictObject({});function Le(e,t){e.get(`/api/data/export`,c(`query`,Ie),async()=>{let e=await t.createExport();return new Response(e.content,{headers:{"cache-control":`no-store`,"content-disposition":`attachment; filename="${e.filename}"`,"content-length":String(e.content.byteLength),"content-type":`application/octet-stream`,"x-content-type-options":`nosniff`}})})}const Re=new TextEncoder;function j(e){return String(e).padStart(2,`0`)}function ze(e){let t={avatar:e.avatar,name:e.name,officialWebsite:e.officialWebsite,remark:e.remark};return e.runtime,{...t,configuration:e.configuration,runtime:e.runtime}}function M(e,t,n,r){let i=Re.encode(JSON.stringify(r));return{content:i,manifest:{id:e,mediaType:`application/json`,overwrite:n,path:t,sha256:g(`sha256`).update(i).digest(`hex`),size:i.byteLength}}}function Be(e){return`foundry-export-${[e.getFullYear(),`-`,j(e.getMonth()+1),`-`,j(e.getDate()),`T`,j(e.getHours()),j(e.getMinutes()),j(e.getSeconds())].join(``)}.foundry`}var Ve=class{promptStore;providerStore;settingsStore;now;foundryVersion;constructor(t,n,r,i=()=>new Date,a=e){this.promptStore=t,this.providerStore=n,this.settingsStore=r,this.now=i,this.foundryVersion=a}async createExport(){let e=this.now(),t=this.settingsStore.getApplicationSettings(),n=A.flatMap(e=>this.providerStore.listProviders(e).map(e=>ze(e))),r=this.promptStore.listAllPrompts().map(e=>({content:e.content,description:e.description,title:e.title})),i=[M(`settings`,`modules/settings.json`,!0,t),M(`providers`,`modules/providers.json`,!1,n),M(`prompts`,`modules/prompts.json`,!1,r)],a={createdAt:e.toISOString(),format:je,foundryVersion:this.foundryVersion,modules:i.map(e=>e.manifest)},o=new te(new h),s=JSON.stringify(a),c=Re.encode(s);await o.add(`manifest.json`,new m(c));for(let e of i)await o.add(e.manifest.path,new m(e.content));return{content:await o.close(),filename:Be(e),manifest:a}}};const He=/^[A-Za-z0-9+/]+={0,2}$/u;function Ue(e,t){for(let n of e){let e=n.codePointAt(0)??0,r=t&&[9,10,13].includes(e);if(e===127||!r&&e<32)return!0}return!1}function N(e){return p.string().trim().max(e).refine(e=>!Ue(e,!0),{message:`Control characters are not allowed.`})}function P(e){return N(e).nullable().transform(e=>e===``?null:e)}function We(e,t){try{let n=new URL(e);return[`http:`,`https:`].includes(n.protocol)&&n.username===``&&n.password===``&&(t||n.search===``&&n.hash===``)}catch{return!1}}const Ge=N(2048).min(1).refine(e=>We(e,!1),{message:`Provide an HTTP or HTTPS URL without credentials, a query, or a fragment.`}),Ke=P(2048).refine(e=>e===null||We(e,!0),{message:`Provide an HTTP or HTTPS URL without credentials.`}),qe=N(100).min(1),Je=P(100),Ye=P(2e3),F=N(200).min(1),Xe=P(200),Ze=P(2e3),Qe=p.string().min(1).max(16384).refine(e=>!Ue(e,!1),{message:`Control characters are not allowed.`}),$e=p.union([Qe,p.literal(``),p.null()]).transform(e=>e===``?null:e);function et(e,t){if(e===`image/png`)return[137,80,78,71,13,10,26,10].every((e,n)=>t[n]===e);if(e===`image/jpeg`)return t[0]===255&&t[1]===216&&t[2]===255;if(e===`image/svg+xml`)try{let e=new ie(`utf-8`,{fatal:!0}).decode(t);return/^\s*(?:(?:<\?xml[\s\S]*?\?>|<!--[\s\S]*?-->|<!DOCTYPE[\s\S]*?>)\s*)*<svg(?:\s|>)/u.test(e)}catch{return!1}return t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}const tt=p.strictObject({data:p.string().min(1).max(2796204),mimeType:p.enum(Ne)}).superRefine((e,t)=>{if(!He.test(e.data)){t.addIssue({code:`custom`,message:`Avatar data must be valid Base64.`});return}let n=oe.from(e.data,`base64`);(n.byteLength===0||n.byteLength>2097152||n.toString(`base64`)!==e.data||!et(e.mimeType,n))&&t.addIssue({code:`custom`,message:`Avatar data must be a valid PNG, JPEG, WebP, or SVG image no larger than 2 MB.`})}),nt=p.array(p.enum(Fe)).max(Fe.length).refine(e=>new Set(e).size===e.length,{message:`Model capabilities must be unique.`}),I=p.strictObject({description:Ye,displayName:Je,model:F,supportedCapabilities:nt}),rt=p.union([F,I.transform(e=>e.model)]),it=p.strictObject({apiKey:$e,baseUrl:Ge,defaultModel:F,protocol:p.literal(`responses`),reviewModel:Xe}),at=p.strictObject({apiKey:Qe,apiKeyHeader:p.enum(Pe),baseUrl:Ge,fableModel:I.nullable(),haikuModel:I.nullable(),opusModel:I.nullable(),defaultModel:rt,protocol:p.literal(`messages`),sonnetModel:I.nullable(),subagentModel:Xe,subagentModelForce:p.boolean().default(!1),hideAiAttribution:p.boolean().default(!1),teammatesMode:p.boolean().default(!1),enableToolSearch:p.boolean().default(!1),maxEffortThinking:p.boolean().default(!1),disableAutoUpdater:p.boolean().default(!1)}),ot={avatar:tt.nullable(),name:qe,officialWebsite:Ke,remark:Ze},L=p.discriminatedUnion(`runtime`,[p.strictObject({...ot,configuration:it,runtime:p.literal(`codex`)}),p.strictObject({...ot,configuration:at,runtime:p.literal(`claude-code`)})]),R=p.strictObject({providerId:p.string().min(1)}),st=p.strictObject({runtime:p.enum(A)});function ct(e){return L.parse(e)}function lt(e){return it.parse(e)}function ut(e){return at.parse(e)}function dt(e){return e===null?null:oe.from(tt.parse(e).data,`base64`)}const ft=new TextEncoder,pt=p.string().trim().min(1).max(100),mt=p.string().trim().max(2e3).nullable().transform(e=>e===``?null:e),ht=p.string().refine(e=>e.trim().length>0,{message:`Prompt content is required.`}).refine(e=>ft.encode(e).byteLength<=1048576,{message:`Prompt content must be no larger than 1 MiB.`}),z=p.strictObject({content:ht,description:mt,title:pt}),B=p.strictObject({promptId:p.string().min(1)}),gt=p.strictObject({query:p.string().trim().max(500).optional().default(``)});function _t(e){return e.normalize(`NFKC`).toLocaleLowerCase(`en-US`)}function vt(e){return z.parse(e)}const yt=new ie(`utf-8`,{fatal:!0}),bt=p.string().regex(/^[a-f0-9]{64}$/u),xt=p.strictObject({id:p.string().min(1).max(100).regex(/^[a-z][a-z0-9-]*$/u),mediaType:p.string().min(1).max(100),overwrite:p.boolean(),path:p.string().min(1).max(512),sha256:bt,size:p.number().int().nonnegative().max(2**53-1)}),St=p.strictObject({createdAt:p.string().min(1).max(64).refine(e=>!Number.isNaN(Date.parse(e))),format:p.literal(je),foundryVersion:p.string().min(1).max(100),modules:p.array(xt).max(256)}).superRefine((e,t)=>{let n=new Set,r=new Set;for(let[i,a]of e.modules.entries())n.has(a.id)&&t.addIssue({code:`custom`,message:`Export Module identifiers must be unique.`,path:[`modules`,i,`id`]}),r.has(a.path)&&t.addIssue({code:`custom`,message:`Export Module paths must be unique.`,path:[`modules`,i,`path`]}),n.add(a.id),r.add(a.path)}),Ct=p.strictObject({colorMode:p.enum(k)}),wt=p.array(L),Tt=z.extend({tags:p.array(p.string()).optional()}).transform(e=>({content:e.content,description:e.description,title:e.title})),Et=p.array(Tt),Dt=[`settings`,`providers`];var V=class extends Error{constructor(e){super(`The selected file is not a valid Foundry Export.`,{cause:e}),this.name=`FoundryImportFileError`}};function Ot(e){return Me.includes(e)}function kt(e,t){let n=e.find(e=>e.filename===t);if(!n||n.directory||n.encrypted||n.symlink)throw Error(`The Export Module entry is unavailable.`);return n}async function At(e,t){if(e.uncompressedSize>t)throw Error(`The archive entry is too large.`);let n=await e.getData(new h);if(n.byteLength>t)throw Error(`The archive entry is too large.`);return JSON.parse(yt.decode(n))}async function jt(e){try{let t=St.parse(await At(kt(e,`manifest.json`),1048576)),n=new Set([`manifest.json`,...t.modules.map(e=>e.path)]),r=e.some(e=>!e.directory&&!n.has(e.filename)),i=new Set(t.modules.map(e=>e.id));if(r||Dt.some(e=>!i.has(e)))throw Error(`The Foundry Export package is incomplete.`);return t}catch(e){throw new V(e)}}async function Mt(e,t){if(e.mediaType!==`application/json`||e.size>268435456)throw Error(`The Export Module metadata is invalid.`);let n=kt(t,e.path);if(n.uncompressedSize!==e.size)throw Error(`The Export Module size does not match its manifest.`);let r=await n.getData(new h),i=g(`sha256`).update(r).digest(`hex`);if(r.byteLength!==e.size||i!==e.sha256)throw Error(`The Export Module does not match its manifest.`);return JSON.parse(yt.decode(r))}async function Nt(e,t,n){let r=await Mt(t,n);if(e===`settings`){if(!t.overwrite)throw Error(`Application Settings must use overwrite import behavior.`);return{data:Ct.parse(r),id:e,itemCount:1}}if(e===`providers`){if(t.overwrite)throw Error(`Providers must use append import behavior.`);let n=wt.parse(r);return{data:n,id:e,itemCount:n.length}}if(t.overwrite)throw Error(`Prompts must use append import behavior.`);let i=Et.parse(r);return{data:i,id:e,itemCount:i.length}}function Pt(e){return{id:e.id,itemCount:null,message:`This Export Module is not supported by this Foundry version.`,overwrite:e.overwrite,status:`unsupported`}}function Ft(e){return{id:e.id,itemCount:null,message:`This Export Module is invalid and cannot be imported.`,overwrite:e.overwrite,status:`invalid`}}function It(e){return{id:e,importedItems:0,message:`${{prompts:`Prompts`,providers:`Providers`,settings:`Application Settings`}[e]??e} could not be imported.`,status:`failed`}}async function Lt(e,t){if(e.byteLength===0)throw new V;let n=new ee(new m(e),{checkCrc32:!0,filenameValidation:`strict`,maxAppendedDataSize:0,strictness:`strict`});try{let e;try{e=await n.getEntries()}catch(e){throw new V(e)}if(e.length>256)throw new V;return await t(await jt(e),e)}finally{await n.close()}}var Rt=class{promptStore;providerStore;settingsStore;constructor(e,t,n){this.promptStore=e,this.providerStore=t,this.settingsStore=n}async inspectData(e){return Lt(e,async(e,t)=>{let n=[];for(let r of e.modules){if(!Ot(r.id)){n.push(Pt(r));continue}try{let e=await Nt(r.id,r,t);n.push({id:r.id,itemCount:e.itemCount,overwrite:r.overwrite,status:`available`})}catch{n.push(Ft(r))}}return{createdAt:e.createdAt,foundryVersion:e.foundryVersion,modules:n}})}async importData(e,t){return Lt(e,async(e,n)=>{let r=new Set(t),i=new Set(e.modules.map(e=>e.id));if(r.size===0||[...r].some(e=>!i.has(e)))throw new V;let a=[];for(let t of e.modules)if(!(!Ot(t.id)||!r.has(t.id)))try{let e=await Nt(t.id,t,n);e.id===`settings`?this.settingsStore.updateApplicationSettings(e.data):e.id===`providers`?this.providerStore.createProviders(e.data):this.promptStore.createPrompts(e.data),a.push({id:e.id,importedItems:e.itemCount,status:`imported`})}catch{a.push(It(t.id))}return{modules:a}})}};const zt=268435456,Bt=p.strictObject({}),Vt=p.preprocess(e=>typeof e==`string`?e.split(`,`):e,p.array(p.enum(Me)).min(1).refine(e=>new Set(e).size===e.length)),Ht=p.strictObject({modules:Vt});function Ut(e,t){e.post(`/api/data/import/inspect`,c(`query`,Bt),re({maxSize:zt}),async e=>{try{let n=await t.inspectData(new Uint8Array(await e.req.arrayBuffer()));return e.json({status:O.success,data:n})}catch(t){if(t instanceof V)return e.json({message:t.message},400);throw t}}),e.post(`/api/data/import`,c(`query`,Ht),re({maxSize:zt}),async e=>{try{let n=await t.importData(new Uint8Array(await e.req.arrayBuffer()),e.req.valid(`query`).modules);return e.json({status:O.success,data:n})}catch(t){if(t instanceof V)return e.json({message:t.message},400);throw t}})}var Wt=Ae({prompts:()=>W,providers:()=>U,runtimes:()=>G,settings:()=>H});const H=w(`settings`,{id:T(`id`).primaryKey(),key:T(`key`).notNull(),value:T(`value`,{mode:`json`}).$type().notNull(),createdAt:C(`created_at`).notNull(),updatedAt:C(`updated_at`).notNull(),deletedAt:C(`deleted_at`)},e=>[ue(`settings_key_unique`).on(e.key),S(`settings_id_not_empty`,x`length(${e.id}) > 0`),S(`settings_key_not_empty`,x`length(trim(${e.key})) > 0`),S(`settings_value_json`,x`json_valid(${e.value})`),S(`settings_created_at_nonnegative`,x`${e.createdAt} >= 0`),S(`settings_updated_at_valid`,x`${e.updatedAt} >= ${e.createdAt}`),S(`settings_deleted_at_valid`,x`${e.deletedAt} IS NULL OR ${e.deletedAt} >= ${e.createdAt}`)]),U=w(`providers`,{id:T(`id`).primaryKey(),runtime:T(`runtime`,{enum:[`codex`,`claude-code`]}).notNull(),name:T(`name`).notNull(),officialWebsite:T(`official_website`),remark:T(`remark`),avatarMimeType:T(`avatar_mime_type`,{enum:[`image/png`,`image/jpeg`,`image/webp`,`image/svg+xml`]}),avatarData:ce(`avatar_data`,{mode:`buffer`}),configuration:T(`configuration`,{mode:`json`}).$type().notNull(),createdAt:C(`created_at`).notNull(),updatedAt:C(`updated_at`).notNull(),deletedAt:C(`deleted_at`)},e=>[le(`providers_runtime_created_at_index`).on(e.runtime,e.createdAt),S(`providers_id_not_empty`,x`length(${e.id}) > 0`),S(`providers_runtime_valid`,x`${e.runtime} IN ('codex', 'claude-code')`),S(`providers_name_valid`,x`length(trim(${e.name})) BETWEEN 1 AND 100`),S(`providers_official_website_valid`,x`${e.officialWebsite} IS NULL OR length(${e.officialWebsite}) <= 2048`),S(`providers_remark_valid`,x`${e.remark} IS NULL OR length(${e.remark}) <= 2000`),S(`providers_avatar_valid`,x`(${e.avatarMimeType} IS NULL AND ${e.avatarData} IS NULL) OR (${e.avatarMimeType} IN ('image/png', 'image/jpeg', 'image/webp', 'image/svg+xml') AND ${e.avatarData} IS NOT NULL AND length(${e.avatarData}) BETWEEN 1 AND 2097152)`),S(`providers_configuration_json`,x`json_valid(${e.configuration})`),S(`providers_created_at_nonnegative`,x`${e.createdAt} >= 0`),S(`providers_updated_at_valid`,x`${e.updatedAt} >= ${e.createdAt}`),S(`providers_deleted_at_valid`,x`${e.deletedAt} IS NULL OR ${e.deletedAt} >= ${e.createdAt}`)]),W=w(`prompts`,{id:T(`id`).primaryKey(),title:T(`title`).notNull(),description:T(`description`),content:T(`content`).notNull(),createdAt:C(`created_at`).notNull(),updatedAt:C(`updated_at`).notNull(),deletedAt:C(`deleted_at`)},e=>[le(`prompts_updated_at_index`).on(e.updatedAt),S(`prompts_id_not_empty`,x`length(${e.id}) > 0`),S(`prompts_title_valid`,x`length(trim(${e.title})) BETWEEN 1 AND 100`),S(`prompts_description_valid`,x`${e.description} IS NULL OR length(${e.description}) <= 2000`),S(`prompts_content_valid`,x`length(trim(${e.content})) > 0 AND length(CAST(${e.content} AS BLOB)) <= 1048576`),S(`prompts_created_at_nonnegative`,x`${e.createdAt} >= 0`),S(`prompts_updated_at_valid`,x`${e.updatedAt} >= ${e.createdAt}`),S(`prompts_deleted_at_valid`,x`${e.deletedAt} IS NULL OR ${e.deletedAt} >= ${e.createdAt}`)]),G=w(`runtimes`,{runtime:T(`runtime`,{enum:[`codex`,`claude-code`]}).primaryKey(),managed:C(`managed`,{mode:`boolean`}).notNull().default(!1),providerId:T(`provider_id`).references(()=>U.id,{onDelete:`restrict`}),appliedAt:C(`applied_at`)},e=>[S(`runtimes_runtime_valid`,x`${e.runtime} IN ('codex', 'claude-code')`),S(`runtimes_state_valid`,x`(${e.managed} = 0 AND ${e.providerId} IS NULL AND ${e.appliedAt} IS NULL) OR (${e.managed} = 1 AND ${e.appliedAt} IS NOT NULL)`),S(`runtimes_applied_at_nonnegative`,x`${e.appliedAt} IS NULL OR ${e.appliedAt} >= 0`)]);function Gt(e){return{content:e.content,createdAt:e.createdAt,description:e.description,id:e.id,title:e.title,updatedAt:e.updatedAt}}function K(e){return{createdAt:e.createdAt,description:e.description,excerpt:e.content.replaceAll(/\s+/gu,` `).trim().slice(0,240),id:e.id,title:e.title,updatedAt:e.updatedAt}}function Kt(e,t){let n=_t(t);return n===``||[e.title,e.description??``,e.content].some(e=>_t(e).includes(n))}var qt=class{database;now;createId;constructor(e,t=Date.now,n=_){this.database=e,this.now=t,this.createId=n}createPrompt(e){let t=vt(e),n=this.now(),r=this.createId();return this.database.insert(W).values({...t,createdAt:n,deletedAt:null,id:r,updatedAt:n}).run(),{...t,createdAt:n,id:r,updatedAt:n}}createPrompts(e){return this.database.transaction(()=>e.map(e=>this.createPrompt(e)))}deletePrompt(e){return this.database.update(W).set({deletedAt:this.now()}).where(v(y(W.id,e),b(W.deletedAt))).run().changes>0}getPrompt(e){let t=this.database.select().from(W).where(v(y(W.id,e),b(W.deletedAt))).get();return t?Gt(t):null}listAllPrompts(){return this.database.select().from(W).where(b(W.deletedAt)).all().map(e=>Gt(e))}listPrompts(e){return{items:this.listAllPrompts().filter(t=>Kt(t,e.query)).toSorted((e,t)=>t.updatedAt-e.updatedAt||t.id.localeCompare(e.id)).map(e=>K(e))}}updatePrompt(e,t){if(this.getPrompt(e)===null)return null;let n=vt(t);return this.database.update(W).set({...n,updatedAt:this.now()}).where(v(y(W.id,e),b(W.deletedAt))).run(),this.getPrompt(e)}};function Jt(e,t){e.get(`/api/prompts`,c(`query`,gt),e=>e.json({data:t.listPrompts(e.req.valid(`query`)),status:O.success})),e.post(`/api/prompts`,c(`json`,z),e=>{let n=t.createPrompt(e.req.valid(`json`));return e.json({data:K(n),status:O.success},201)}),e.delete(`/api/prompts/:promptId`,c(`param`,B),e=>t.deletePrompt(e.req.valid(`param`).promptId)?e.json({data:!0,status:O.success}):e.json({data:!1,message:`The selected Prompt is unavailable.`,status:O.promptNotFound})),e.get(`/api/prompts/:promptId`,c(`param`,B),e=>{let n=t.getPrompt(e.req.valid(`param`).promptId);return n===null?e.json({data:null,message:`The selected Prompt is unavailable.`,status:O.promptNotFound}):e.json({data:n,status:O.success})}),e.put(`/api/prompts/:promptId`,c(`param`,B),c(`json`,z),e=>{let n=t.updatePrompt(e.req.valid(`param`).promptId,e.req.valid(`json`));return n===null?e.json({data:null,message:`The selected Prompt is unavailable.`,status:O.promptNotFound}):e.json({data:K(n),status:O.success})})}function q(e){return{avatar:e.avatar,baseUrl:e.configuration.baseUrl,id:e.id,name:e.name,officialWebsite:e.officialWebsite,remark:e.remark,runtime:e.runtime}}function Yt(e,t,n){e.get(`/api/providers`,c(`query`,st),e=>e.json({status:O.success,data:t.listProviders(e.req.valid(`query`).runtime).map(e=>q(e))})),e.delete(`/api/providers/:providerId`,c(`param`,R),e=>{let n=t.deleteProvider(e.req.valid(`param`).providerId);return n===`in-use`?e.json({status:O.providerInUse,data:!1,message:`A Provider in use cannot be deleted.`}):n===`not-found`?e.json({status:O.providerNotFound,data:!1,message:`The selected Provider is unavailable.`}):e.json({status:O.success,data:!0})}),e.post(`/api/providers/:providerId/test-connection`,c(`param`,R),async e=>{let r=t.getProvider(e.req.valid(`param`).providerId);if(r===null)return e.json({status:O.providerNotFound,data:!1,message:`The selected Provider is unavailable.`});let i=await n.testProvider(r);return i.successful?e.json({status:O.success,data:!0}):e.json({status:O.providerConnectionFailed,data:!1,message:i.message})}),e.post(`/api/providers`,c(`json`,L),e=>{let n=e.req.valid(`json`),r=q(t.createProvider(n));return e.json({status:O.success,data:r},201)}),e.get(`/api/providers/:providerId`,c(`param`,R),e=>{let n=t.getProvider(e.req.valid(`param`).providerId);return n===null?e.json({status:O.providerNotFound,data:null,message:`The selected Provider is unavailable.`}):e.json({status:O.success,data:n})}),e.post(`/api/providers/:providerId/copy`,c(`param`,R),c(`json`,L),e=>{let n=e.req.valid(`param`).providerId,r=t.getProvider(n);if(r===null)return e.json({status:O.providerNotFound,data:null,message:`The selected Provider is unavailable.`});let i=e.req.valid(`json`);if(i.runtime!==r.runtime)return e.json({message:`A Provider Runtime cannot be changed.`},400);let a=t.copyProvider(n,i);return a===null?e.json({status:O.providerNotFound,data:null,message:`The selected Provider is unavailable.`}):e.json({status:O.success,data:q(a)},201)}),e.put(`/api/providers/:providerId`,c(`param`,R),c(`json`,L),e=>{let n=e.req.valid(`param`).providerId,r=t.getProvider(n);if(r===null)return e.json({status:O.providerNotFound,data:null,message:`The selected Provider is unavailable.`});let i=e.req.valid(`json`);if(i.runtime!==r.runtime)return e.json({message:`A Provider Runtime cannot be changed.`},400);let a=t.updateProvider(n,i);return e.json({status:O.success,data:a===null?null:q(a)})})}var J=class extends Error{status;constructor(e,t){super(t),this.status=e}};const Xt=p.discriminatedUnion(`kind`,[p.strictObject({kind:p.literal(`official-default`)}),p.strictObject({kind:p.literal(`provider`),providerId:p.string().min(1)})]),Zt=p.strictObject({runtime:p.enum(A)}),Qt=p.strictObject({}),$t=p.strictObject({providerKey:p.string().min(1).max(200).optional(),target:Xt}),en=p.strictObject({expectedFileHash:p.string().regex(/^[0-9a-f]{64}$/),providerKey:p.string().min(1).max(200).optional(),target:Xt});function tn(e,t){e.get(`/api/runtimes`,c(`query`,Qt),async e=>e.json({status:O.success,data:await t.listRuntimes()})),e.post(`/api/runtimes/:runtime/preview`,c(`param`,Zt),c(`json`,$t),async e=>{try{return e.json({status:O.success,data:await t.previewConfiguration(e.req.valid(`param`).runtime,e.req.valid(`json`))})}catch(t){if(t instanceof J)return e.json({status:t.status,data:null,message:t.message});throw t}}),e.post(`/api/runtimes/:runtime/apply`,c(`param`,Zt),c(`json`,en),async e=>{try{return e.json({status:O.success,data:await t.applyConfiguration(e.req.valid(`param`).runtime,e.req.valid(`json`))})}catch(t){if(t instanceof J)return e.json({status:t.status,data:null,message:t.message});throw t}})}const nn=p.strictObject({}),rn=p.strictObject({colorMode:p.enum(k)});function an(e,t){e.get(`/api/settings`,c(`query`,nn),e=>e.json({status:O.success,data:t.getApplicationSettings()})),e.patch(`/api/settings`,c(`json`,rn),e=>e.json({status:O.success,data:t.updateApplicationSettings(e.req.valid(`json`))}))}const on=p.strictObject({});function sn(){return[d.resolve(import.meta.dirname,`app`),d.resolve(import.meta.dirname,`../../dist/app`)].find(e=>u(e))}function cn(e){let t=new f;t.get(`/api/health`,c(`query`,on),e=>e.json({status:O.success,data:!0,message:`Service is healthy.`})),Le(t,new Ve(e.promptStore,e.providerStore,e.settingsStore)),Ut(t,new Rt(e.promptStore,e.providerStore,e.settingsStore)),an(t,e.settingsStore),Jt(t,e.promptStore),Yt(t,e.providerStore,e.providerConnectionTester),tn(t,e.runtimeService);let n=e.webRoot??sn();return n&&t.use(`*`,s({root:n})),t}const Y=`__drizzle_migrations`;function ln(e){return!!e.prepare(`
|
|
3
|
-
SELECT 1
|
|
4
|
-
FROM sqlite_master
|
|
5
|
-
WHERE type = 'table' AND name = ?
|
|
6
|
-
`).pluck().get(Y)}function un(e){return ln(e)?e.prepare(`
|
|
7
|
-
SELECT hash, created_at
|
|
8
|
-
FROM ${Y}
|
|
9
|
-
ORDER BY created_at ASC
|
|
10
|
-
`).all():[]}function dn(e,t){if(e.length>t.length)throw Error(`The Foundry database was migrated by a newer CLI version.`);for(let[n,r]of e.entries()){let e=t[n];if(r.hash!==e.hash||r.created_at!==e.folderMillis)throw Error(`The Foundry database migration history is incompatible.`)}}async function fn(e){let t=(await _e(e)).filter(e=>e.startsWith(`foundry-before-`)&&e.endsWith(`.sqlite`)).toSorted((e,t)=>e.localeCompare(t)).slice(0,-1);await Promise.all(t.map(t=>D(d.join(e,t),{force:!0})))}async function pn(e,t,n){let r=d.join(d.dirname(t),`backups`);await E(r,{recursive:!0});let a=new Date(n()).toISOString().replaceAll(`:`,`-`),o=d.join(r,`foundry-before-${a}-${i.pid}.sqlite`);await e.backup(o),await fn(r)}function mn(e,t){e.exec(`BEGIN IMMEDIATE`);try{e.exec(`
|
|
11
|
-
CREATE TABLE IF NOT EXISTS ${Y} (
|
|
12
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
13
|
-
hash TEXT NOT NULL,
|
|
14
|
-
created_at INTEGER NOT NULL
|
|
15
|
-
)
|
|
16
|
-
`);let n=un(e);dn(n,t);let r=e.prepare(`
|
|
17
|
-
INSERT INTO ${Y} (hash, created_at)
|
|
18
|
-
VALUES (?, ?)
|
|
19
|
-
`);for(let i of t.slice(n.length)){for(let t of i.sql)e.exec(t);r.run(i.hash,i.folderMillis)}e.exec(`COMMIT`)}catch(t){throw e.exec(`ROLLBACK`),t}}async function hn(e,t){let n=Se({migrationsFolder:t.migrationsFolder}),r=un(e);dn(r,n),r.length!==n.length&&(t.isExistingDatabase&&await pn(e,t.databasePath,t.now??Date.now),mn(e,n))}function gn(){return i.platform!==`darwin`&&i.platform!==`win32`&&i.env.XDG_DATA_HOME&&!d.isAbsolute(i.env.XDG_DATA_HOME)?d.join(we(),`.local`,`share`,`foundry`):Ce(`foundry`,{suffix:``}).data}function _n(){return d.join(gn(),`foundry.sqlite`)}function vn(){let e=[d.resolve(import.meta.dirname,`migrations`),d.resolve(import.meta.dirname,`../../../drizzle`)].find(e=>u(e));if(!e)throw Error(`Foundry database migrations could not be found.`);return e}async function yn(e={}){let t=e.databasePath??_n(),n=u(t);await E(d.dirname(t),{recursive:!0});let r=new de(t,{timeout:5e3});try{return r.pragma(`foreign_keys = ON`),r.function(`uuid_v7`,()=>_()),await hn(r,{isExistingDatabase:n,databasePath:t,migrationsFolder:e.migrationsFolder??vn(),now:e.now}),{client:r,db:fe({client:r,schema:Wt})}}catch(e){throw r.close(),e}}function bn(e){if(e.avatarMimeType===null&&e.avatarData===null)return null;if(e.avatarMimeType===null||e.avatarData===null)throw Error(`Stored Provider avatar is invalid.`);return{data:e.avatarData.toString(`base64`),mimeType:e.avatarMimeType}}function X(e){let t={avatar:bn(e),createdAt:e.createdAt,id:e.id,name:e.name,officialWebsite:e.officialWebsite,remark:e.remark,updatedAt:e.updatedAt};return e.runtime===`codex`?{...t,configuration:lt(e.configuration),runtime:e.runtime}:{...t,configuration:ut(e.configuration),runtime:e.runtime}}var xn=class{database;now;createId;constructor(e,t=Date.now,n=_){this.database=e,this.now=t,this.createId=n}createProvider(e){let t=ct(e),n=dt(t.avatar),r=this.now(),i=this.createId();return this.database.insert(U).values({avatarData:n,avatarMimeType:t.avatar?.mimeType??null,configuration:t.configuration,createdAt:r,deletedAt:null,id:i,name:t.name,officialWebsite:t.officialWebsite,remark:t.remark,runtime:t.runtime,updatedAt:r}).run(),X({avatarData:n,avatarMimeType:t.avatar?.mimeType??null,configuration:t.configuration,createdAt:r,deletedAt:null,id:i,name:t.name,officialWebsite:t.officialWebsite,remark:t.remark,runtime:t.runtime,updatedAt:r})}createProviders(e){return this.database.transaction(()=>e.map(e=>this.createProvider(e)))}copyProvider(e,t){let n=this.getProvider(e);if(n===null)return null;let r=ct(t);if(r.runtime!==n.runtime)throw Error(`A Provider Runtime cannot be changed.`);return this.createProvider(r)}deleteProvider(e){return this.database.transaction(()=>this.database.select({id:U.id}).from(U).where(v(y(U.id,e),b(U.deletedAt))).get()?this.database.select({providerId:G.providerId}).from(G).where(y(G.providerId,e)).get()?`in-use`:this.database.update(U).set({deletedAt:this.now()}).where(v(y(U.id,e),b(U.deletedAt))).run().changes===1?`deleted`:`not-found`:`not-found`)}getProvider(e){let t=this.database.select().from(U).where(v(y(U.id,e),b(U.deletedAt))).get();return t?X(t):null}listProviders(e){return this.database.select().from(U).where(v(y(U.runtime,e),b(U.deletedAt))).orderBy(se(U.createdAt),se(U.id)).all().map(e=>X(e))}updateProvider(e,t){let n=this.getProvider(e);if(n===null)return null;let r=ct(t);if(r.runtime!==n.runtime)throw Error(`A Provider Runtime cannot be changed.`);let i=dt(r.avatar),a=this.now();return this.database.update(U).set({avatarData:i,avatarMimeType:r.avatar?.mimeType??null,configuration:r.configuration,name:r.name,officialWebsite:r.officialWebsite,remark:r.remark,updatedAt:a}).where(v(y(U.id,e),b(U.deletedAt))).run(),this.getProvider(e)}};const Sn=new Set([404,405,501]);function Cn(e,t){let n=new URL(e);return n.pathname=`${n.pathname.replace(/\/+$/u,``)}/${t}`,n.href}function wn(e){if(e.runtime===`codex`)return Cn(e.configuration.baseUrl,`models`);let t=new URL(e.configuration.baseUrl).pathname.replace(/\/+$/u,``);return Cn(e.configuration.baseUrl,t.endsWith(`/v1`)?`models`:`v1/models`)}function Tn(e){let t=new Headers({accept:`application/json`});if(e.runtime===`codex`){let{apiKey:n}=e.configuration;return n!==null&&t.set(`authorization`,`Bearer ${n}`),t}let{apiKey:n}=e.configuration;return t.set(`anthropic-version`,`2023-06-01`),t.set(e.configuration.apiKeyHeader,e.configuration.apiKeyHeader===`authorization`?`Bearer ${n}`:n),t}function En(e){return e>=300&&e<400?`The Provider redirected the request. Check the Base URL.`:e===401||e===403?`Authentication failed. Check the API key and its permissions.`:e===402?`The Provider rejected the request because billing is unavailable.`:e===408?`The Provider timed out while handling the request.`:e===429?`The Provider is rate limited or has insufficient quota.`:e>=500?`The Provider is temporarily unavailable.`:`The Provider returned HTTP ${e}.`}async function Dn(e){return await e.body?.cancel(),{message:En(e.status),successful:!1}}function On(e){return e instanceof DOMException&&e.name===`TimeoutError`?{message:`The connection timed out.`,successful:!1}:{message:`The Provider could not be reached${e instanceof Error?`: ${e.message}`:``}.`.slice(0,500),successful:!1}}var kn=class{fetcher;timeoutMs;constructor(e=fetch,t=1e4){this.fetcher=e,this.timeoutMs=t}async request(e,t){try{return{response:await this.fetcher(e,{headers:t,method:`GET`,redirect:`manual`,signal:AbortSignal.timeout(this.timeoutMs)}),type:`response`}}catch(e){return{error:e,type:`error`}}}async testProvider(e){let t=Tn(e),n=await this.request(wn(e),t);if(n.type===`error`)return On(n.error);if(n.response.ok)return await n.response.body?.cancel(),{successful:!0};if(!Sn.has(n.response.status))return Dn(n.response);await n.response.body?.cancel();let r=await this.request(e.configuration.baseUrl,t);return r.type===`error`?On(r.error):(await r.response.body?.cancel(),{successful:!0})}};function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function An(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=JSON.stringify(e);return typeof t==`string`?t:String(e)}function jn(e,t){return e===void 0?{kind:`absent`}:t?{kind:`secret`,value:An(e)}:{kind:`plain`,value:An(e)}}function Q(e,t,n,r=!1){let i;return i=t===void 0&&n===void 0?`unchanged`:t===void 0?`add`:n===void 0?`remove`:t===n?`unchanged`:`update`,{current:jn(t,r),key:e,operation:i,proposed:jn(n,r)}}function Mn(e){return{changes:e.filter(e=>e.operation!==`unchanged`),unchanged:e.filter(e=>e.operation===`unchanged`)}}function Nn(e){return g(`sha256`).update(e===null?`absent\0`:`present\0${e}`).digest(`hex`)}function Pn(e,t){try{let n=e===`codex`?Te(t):JSON.parse(t);if(!Z(n))throw Error(`Configuration root must be an object.`);return n}catch{throw new J(`RUNTIME_CONFIGURATION_INVALID`,`The ${e===`codex`?`Codex`:`Claude Code`} configuration cannot be safely parsed.`)}}async function Fn(e,t){try{let n=await he(t);if(!n.isFile())throw new J(`RUNTIME_CONFIGURATION_INVALID`,`The Runtime configuration path is not a regular file.`);let r=await ge(t,`utf8`);return{content:r,exists:!0,hash:Nn(r),mode:n.mode&511,values:Pn(e,r)}}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return{content:null,exists:!1,hash:Nn(null),mode:384,values:{}};throw e instanceof J?e:new J(`RUNTIME_APPLY_FAILED`,`The Runtime configuration could not be read.`)}}function In(e){return structuredClone(e)}function Ln(e,t,n){n===void 0?delete e[t]:e[t]=n}function Rn(e,t){return e.content===null?De(t):Ee(e.content,t)}function zn(e){let t=/(?:\r\n|\n)([\t ]+)"/.exec(e)?.[1];if(t!==void 0)return t.includes(` `)?` `:t.length}function Bn(e,t){if(e.content===null)return`${JSON.stringify(t,null,2)}\n`;let n=e.content.includes(`\r
|
|
20
|
-
`)?`\r
|
|
21
|
-
`:`
|
|
22
|
-
`,r=e.content.endsWith(`
|
|
23
|
-
`),i=JSON.stringify(t,null,zn(e.content));return n===`\r
|
|
24
|
-
`&&(i=i.replaceAll(`
|
|
25
|
-
`,`\r
|
|
26
|
-
`)),r?`${i}${n}`:i}function Vn(e,t){return d.join(d.dirname(e),`.${d.basename(e)}.foundry-${t}-${ne()}.tmp`)}async function Hn(e,t,n,r){let i=Vn(e,r);try{await xe(i,t,{encoding:`utf8`,flag:`wx`,mode:n}),await me(i,n),await ye(i,e)}catch(e){try{await D(i,{force:!0})}catch{}throw e}}async function Un(e,t,n,r){if(n.source.hash!==r)throw new J(`RUNTIME_CONFIGURATION_CHANGED`,`The Runtime configuration changed after Preview. Refresh and review it again.`);let{source:i}=n,a=d.dirname(t),o=`${t}.foundry-backup`;if(!(!i.exists||n.content!==i.content))return{rollback:async()=>{}};Pn(e,n.content);try{await E(a,{mode:448,recursive:!0}),i.exists&&i.content!==null?await Hn(o,i.content,384,`backup`):await D(o,{force:!0}),await Hn(t,n.content,i.mode,`write`)}catch(e){throw e instanceof J?e:new J(`RUNTIME_APPLY_FAILED`,`The Runtime configuration could not be safely updated.`)}return{rollback:async()=>{try{i.exists&&i.content!==null?await Hn(t,i.content,i.mode,`rollback`):await D(t,{force:!0})}catch{throw new J(`RUNTIME_APPLY_FAILED`,`The previous Runtime configuration could not be restored.`)}}}}const Wn=[`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`],Gn=[``,`_NAME`,`_DESCRIPTION`,`_SUPPORTED_CAPABILITIES`],Kn=Wn.flatMap(e=>Gn.map(t=>`${e}${t}`)),qn=[`CLAUDE_CODE_SUBAGENT_MODEL`,`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`],Jn=[`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`,`ENABLE_TOOL_SEARCH`,`CLAUDE_CODE_EFFORT_LEVEL`,`DISABLE_AUTOUPDATER`],Yn=[`commit`,`pr`,`sessionUrl`],Xn=[`ANTHROPIC_BASE_URL`,`ANTHROPIC_AUTH_TOKEN`,`ANTHROPIC_API_KEY`,`ANTHROPIC_MODEL`,...Kn,...qn,...Jn];function Zn(e){return e===null?[void 0,void 0,void 0,void 0]:[e.model,e.displayName??void 0,e.description??void 0,e.supportedCapabilities.length>0?e.supportedCapabilities.join(`,`):void 0]}function Qn(e){let t=Object.fromEntries(Xn.map(e=>[e,void 0]));if(e===null)return t;t.ANTHROPIC_BASE_URL=e.baseUrl,t.ANTHROPIC_AUTH_TOKEN=e.apiKeyHeader===`authorization`?e.apiKey:void 0,t.ANTHROPIC_API_KEY=e.apiKeyHeader===`x-api-key`?e.apiKey:void 0,t.ANTHROPIC_MODEL=e.defaultModel;let n=[e.opusModel,e.sonnetModel,e.haikuModel,e.fableModel];for(let[e,r]of Wn.entries()){let i=Zn(n[e]);for(let[e,n]of Gn.entries())t[`${r}${n}`]=i[e]}return t.CLAUDE_CODE_SUBAGENT_MODEL=e.subagentModel??void 0,t.CLAUDE_CODE_SUBAGENT_MODEL_FORCE=e.subagentModelForce?`1`:void 0,t.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=e.teammatesMode?`1`:void 0,t.ENABLE_TOOL_SEARCH=e.enableToolSearch?`true`:void 0,t.CLAUDE_CODE_EFFORT_LEVEL=e.maxEffortThinking?`max`:void 0,t.DISABLE_AUTOUPDATER=e.disableAutoUpdater?`1`:void 0,t}function $n(e){let t=e?.hideAiAttribution===!0;return{commit:t?``:void 0,pr:t?``:void 0,sessionUrl:!t&&void 0}}function er(e,t,n,r){let i=e.values.env;if(i!==void 0&&!Z(i))throw new J(`RUNTIME_CONFIGURATION_INVALID`,`Claude Code env must be an object.`);let a=i??{},o=Qn(r?.configuration??null),s=e.values.attribution;if(s!==void 0&&!Z(s))throw new J(`RUNTIME_CONFIGURATION_INVALID`,`Claude Code attribution must be an object.`);let c=s??{},l=$n(r?.configuration??null),u=[...Xn.map(e=>Q(`env.${e}`,a[e],o[e],e===`ANTHROPIC_AUTH_TOKEN`||e===`ANTHROPIC_API_KEY`)),...Yn.map(e=>Q(`attribution.${e}`,c[e],l[e]))],d=In(e.values),f=Z(d.env)?d.env:{};d.env=f;for(let e of Xn)Ln(f,e,o[e]);Object.keys(f).length===0&&delete d.env;let p=Z(d.attribution)?d.attribution:{};d.attribution=p;for(let e of Yn){let t=l[e];t===void 0?delete p[e]:p[e]=t}Object.keys(p).length===0&&delete d.attribution;let m=Mn(u);return{content:Bn(e,d),preview:{...m,file:{exists:e.exists,hash:e.hash,path:t},kind:`ready`,providerKey:null,runtime:`claude-code`,target:n},source:e}}const $=[`model`,`review_model`,`model_provider`],tr=[`name`,`base_url`,`wire_api`,`experimental_bearer_token`];function nr(e){let t=e.model_providers;if(t===void 0)return{};if(!Z(t))throw new J(`RUNTIME_CONFIGURATION_INVALID`,`Codex model_providers must be a table.`);return t}function rr(e){return Object.entries(nr(e)).filter(e=>Z(e[1])).map(([e])=>e)}function ir(e,t){let n=rr(e);if(n.length===0){if(t!==void 0&&t!==`foundry`)throw new J(`RUNTIME_CONFIGURATION_INVALID`,`The selected Codex Provider key is unavailable.`);return{key:`foundry`,keys:n}}if(n.length===1){if(t!==void 0&&t!==n[0])throw new J(`RUNTIME_CONFIGURATION_INVALID`,`The selected Codex Provider key is unavailable.`);return{key:n[0],keys:n}}if(t===void 0)return{key:null,keys:n};if(!n.includes(t))throw new J(`RUNTIME_CONFIGURATION_INVALID`,`The selected Codex Provider key is unavailable.`);return{key:t,keys:n}}function ar(e,t){let n=nr(e)[t];if(n===void 0)return{};if(!Z(n))throw new J(`RUNTIME_CONFIGURATION_INVALID`,`Codex model_providers.${t} must be a table.`);return n}function or(e){let t=Z(e.model_providers)?e.model_providers:{};if(typeof e.model_provider==`string`){let n=t[e.model_provider];return{key:e.model_provider,table:Z(n)?n:{}}}let n=Object.entries(t).filter(e=>Z(e[1]));return n.length===1?{key:n[0][0],table:n[0][1]}:{key:`<key>`,table:{}}}function sr(e,t,n,r,i){if(n.kind===`official-default`){let r=or(e.values),i=[...$.map(t=>Q(t,e.values[t],void 0)),...tr.map(e=>Q(`[model_providers.${r.key}].${e}`,r.table[e],r.table[e],e===`experimental_bearer_token`))],a=In(e.values);for(let e of $)delete a[e];let o=Mn(i);return{content:Rn(e,a),preview:{...o,file:{exists:e.exists,hash:e.hash,path:t},kind:`ready`,providerKey:null,runtime:`codex`,target:n},source:e}}if(r===null)throw new J(`PROVIDER_NOT_FOUND`,`The selected Provider is unavailable.`);let a=ir(e.values,i);if(a.key===null)return{file:{exists:e.exists,hash:e.hash,path:t},kind:`provider-key-selection`,providerKeys:a.keys,runtime:`codex`,target:n};let o=a.key,s=ar(e.values,o),c={model:r.configuration.defaultModel,model_provider:o,review_model:r.configuration.reviewModel??void 0},l={base_url:r.configuration.baseUrl,experimental_bearer_token:r.configuration.apiKey??void 0,name:r.name,wire_api:`responses`},u=[...$.map(t=>Q(t,e.values[t],c[t])),...tr.map(e=>Q(`[model_providers.${o}].${e}`,s[e],l[e],e===`experimental_bearer_token`))],d=In(e.values);for(let e of $)Ln(d,e,c[e]);let f=Z(d.model_providers)?d.model_providers:{};d.model_providers=f;let p=Z(f[o])?f[o]:{};f[o]=p;for(let e of tr)Ln(p,e,l[e]);let m=Mn(u);return{content:Rn(e,d),preview:{...m,file:{exists:e.exists,hash:e.hash,path:t},kind:`ready`,providerKey:o,runtime:`codex`,target:n},source:e}}function cr(e,t,n){if(t.kind===`official-default`)return null;if(n?.id!==t.providerId||n.runtime!==e)throw new J(`PROVIDER_NOT_FOUND`,`The selected Provider is unavailable.`);return n}async function lr(e,t,n,r,i){let a=await Fn(e,t),o=cr(e,n,r);return e===`codex`?sr(a,t,n,o,i):er(a,t,n,o)}function ur(e){return`preview`in e}var dr=class{async preview(e,t,n,r,i){let a=await lr(e,t,n,r,i);return ur(a)?a.preview:a}async apply(e,t,n,r,i,a){let o=await lr(e,t,n,r,a);if(!ur(o))throw new J(`RUNTIME_CONFIGURATION_INVALID`,`Select a Codex Provider key before applying changes.`);return Un(e,t,o,i)}};const fr=ae(Oe),pr={"claude-code":{command:`claude`,configurationDirectory:`.claude`,configurationDirectoryEnvironmentVariable:`CLAUDE_CONFIG_DIR`,configurationFilename:`settings.json`},codex:{command:`codex`,configurationDirectory:`.codex`,configurationDirectoryEnvironmentVariable:`CODEX_HOME`,configurationFilename:`config.toml`}};async function mr(e){try{return await be(e),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code!==`ENOENT`)}}async function hr(e,t){let n=i.platform===`win32`?(i.env.PATHEXT??`.EXE;.CMD;.BAT;.COM`).split(`;`):[``];for(let r of t.split(d.delimiter))if(r)for(let t of n){let n=d.join(r,`${e}${t}`);try{return await pe(n,i.platform===`win32`?l.F_OK:l.X_OK),await ve(n)}catch{}}return null}var gr=class{homeDirectory;environmentPath;runVersion;environment;constructor(e=we(),t=i.env.PATH??``,n=async e=>{let t=await fr(e,[`--version`],{timeout:3e3,windowsHide:!0});return(t.stdout||t.stderr).trim()},r=i.env){this.homeDirectory=e,this.environmentPath=t,this.runVersion=n,this.environment=r}async detect(e){let t=pr[e],n=this.environment[t.configurationDirectoryEnvironmentVariable]?.trim(),r=n?d.resolve(n):d.join(this.homeDirectory,t.configurationDirectory),i=d.join(r,t.configurationFilename),a=await mr(i),o=await hr(t.command,this.environmentPath);if(!o)return{configurationExists:a,configurationPath:i,executablePath:null,message:`${t.command} was not found in PATH.`,status:`not-detected`,version:null};try{return{configurationExists:a,configurationPath:i,executablePath:o,message:null,status:`detected`,version:await this.runVersion(o)}}catch{return{configurationExists:a,configurationPath:i,executablePath:o,message:`${t.command} --version could not be completed.`,status:`failed`,version:null}}}},_r=class{runtimeStore;providerStore;detector;configurationManager;inFlightRuntimes=new Set;constructor(e,t,n,r){this.runtimeStore=e,this.providerStore=t,this.detector=n,this.configurationManager=r}resolveProvider(e,t){if(t.kind===`official-default`)return null;let n=this.providerStore.getProvider(t.providerId);if(n?.runtime!==e)throw new J(`PROVIDER_NOT_FOUND`,`The selected Provider is unavailable.`);return n}async requireDetection(e){let t=await this.detector.detect(e);if(t.status!==`detected`)throw new J(`RUNTIME_NOT_DETECTED`,t.message??`The Runtime could not be detected.`);return t}async listRuntimes(){let e=new Map(this.runtimeStore.listAssignments().map(e=>[e.runtime,e])),t=await Promise.all(A.map(e=>this.detector.detect(e)));return A.map((n,r)=>{let i=e.get(n);if(!i)throw Error(`Runtime assignment ${n} is missing.`);return{...i,detection:t[r]}})}async previewConfiguration(e,t){let n=await this.requireDetection(e),r=this.resolveProvider(e,t.target);return this.configurationManager.preview(e,n.configurationPath,t.target,r,t.providerKey)}async applyConfiguration(e,t){if(this.inFlightRuntimes.has(e))throw new J(`RUNTIME_APPLY_FAILED`,`A configuration update is already running for this Runtime.`);this.inFlightRuntimes.add(e);try{let n=await this.requireDetection(e),r=this.resolveProvider(e,t.target),i=await this.configurationManager.apply(e,n.configurationPath,t.target,r,t.expectedFileHash,t.providerKey);try{return{...this.runtimeStore.recordAssignment(e,t.target),detection:{...n,configurationExists:!0}}}catch(e){throw await i.rollback(),e}}finally{this.inFlightRuntimes.delete(e)}}},vr=class{database;now;constructor(e,t=Date.now){this.database=e,this.now=t}listAssignments(){let e=new Map(this.database.select().from(G).all().map(e=>[e.runtime,{appliedAt:e.appliedAt,managed:e.managed,providerId:e.providerId,runtime:e.runtime}]));return A.map(t=>{let n=e.get(t);if(!n)throw Error(`Runtime assignment ${t} is missing.`);return n})}recordAssignment(e,t){return this.database.transaction(()=>{let n=t.kind===`provider`?t.providerId:null;if(n!==null&&!this.database.select({runtime:U.runtime}).from(U).where(v(y(U.id,n),y(U.runtime,e),b(U.deletedAt))).get())throw new J(`PROVIDER_NOT_FOUND`,`The selected Provider is unavailable.`);let r=this.now();if(this.database.update(G).set({appliedAt:r,managed:!0,providerId:n}).where(y(G.runtime,e)).run().changes!==1)throw Error(`Runtime assignment ${e} could not be saved.`);return{appliedAt:r,managed:!0,providerId:n,runtime:e}})}};const yr=`color_mode`,br=p.enum(k);var xr=class{database;now;constructor(e,t=Date.now){this.database=e,this.now=t}getApplicationSettings(){let e=this.database.select({deletedAt:H.deletedAt,key:H.key,value:H.value}).from(H).all();if(e.length!==1)throw Error(`Stored Application Settings are invalid.`);let[t]=e;if(t.key!==yr||t.deletedAt!==null)throw Error(`Stored Application Settings are invalid.`);return{colorMode:br.parse(t.value)}}updateApplicationSettings(e){if(this.database.update(H).set({updatedAt:this.now(),value:e.colorMode}).where(y(H.key,yr)).run().changes!==1)throw Error(`Stored Application Settings are invalid.`);return this.getApplicationSettings()}};const Sr=`127.0.0.1`;function Cr(e){return new Promise((t,n)=>{e.close(e=>{if(e){n(e);return}t()})})}async function wr(e={}){let t=e.port??54321,n=await yn({databasePath:e.databasePath,migrationsFolder:e.migrationsFolder}),r=new xn(n.db),i=cn({promptStore:new qt(n.db),providerConnectionTester:new kn,providerStore:r,runtimeService:new _r(new vr(n.db),r,new gr,new dr),settingsStore:new xr(n.db)});return new Promise((e,r)=>{let a=e=>{n.client.close(),r(e)},s=o({fetch:i.fetch,hostname:Sr,port:t},t=>{s.off(`error`,a);let r,i=t.port,o=async()=>{try{await Cr(s)}finally{n.client.close()}};e({close:()=>(r??=o(),r),hostname:Sr,port:i,url:`http://${Sr}:${i}`})});s.once(`error`,a)})}function Tr(e,t){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`?`Port ${t} is already in use on 127.0.0.1.`:`Could not start Foundry Server: ${e instanceof Error?e.message:String(e)}`}function Er(e,t=i,n=console.error){let r=!1,a=()=>{r||(r=!0,t.off(`SIGINT`,a),t.off(`SIGTERM`,a),e.close().catch(e=>{n(`Could not stop Foundry Server: ${e instanceof Error?e.message:String(e)}`),t.exitCode=1}))};return t.once(`SIGINT`,a),t.once(`SIGTERM`,a),()=>{t.off(`SIGINT`,a),t.off(`SIGTERM`,a)}}const Dr={error:console.error,log:console.info,openBrowser:a,registerShutdown:e=>{Er(e)},setExitCode:e=>{i.exitCode=e},startServer:wr};function Or(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n===`--port`){if(t+1>=e.length||e[t+1].startsWith(`--`))return`Missing value for option: --port`;t+=1;continue}if(!n.startsWith(`--port=`)&&n!==`--open`&&n!==`--no-open`)return`${n.startsWith(`-`)?`Unknown option`:`Unexpected argument`}: ${n}`}}function kr(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>65535)throw RangeError(`Port must be an integer between 1 and 65535. Received "${e}".`);return t}function Ar(e=Dr){return t({meta:{description:`Start the Local Web UI`,name:`ui`},args:{port:{default:`54321`,description:`Port for the Local Web UI`,type:`string`,valueHint:`port`},open:{default:!0,description:`Open the Local Web UI in the default browser`,negativeDescription:`Do not open the default browser`,type:`boolean`}},async run({args:t,rawArgs:n}){let r=Or(n);if(r){e.error(`${r}\nRun \`foundry ui --help\` for usage.`),e.setExitCode(1);return}let i;try{i=kr(t.port)}catch(t){e.error(`${t instanceof Error?t.message:String(t)}\nRun \`foundry ui --help\` for usage.`),e.setExitCode(1);return}let a;try{a=await e.startServer({port:i})}catch(t){e.error(Tr(t,i)),e.setExitCode(1);return}if(e.registerShutdown(a),e.log(`Foundry Local Web UI: ${a.url}`),t.open)try{await e.openBrowser(a.url)}catch{e.error(`Could not open the default browser. Open ${a.url} manually.`)}}})}const jr=t({meta:{description:`An AI-native local developer runtime`,name:`foundry`,version:e},subCommands:{ui:Ar()}});function Mr(e){if(!e.some(e=>e===`--help`||e===`-h`)&&(e.length!==1||e[0]!==`--version`&&e[0]!==`-v`)&&!(e[0]===`ui`||!e[0]?.startsWith(`-`)))return`Unknown option: ${e[0]}`}async function Nr(e=i.argv.slice(2)){if(e.length===0){console.info(`${await n(jr)}\n`);return}let t=Mr(e);if(t){console.error(`${t}\nRun \`foundry --help\` for usage.`),i.exitCode=1;return}await r(jr,{rawArgs:e})}Nr();export{};
|
package/dist/index.d.mts
DELETED
package/dist/index.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `settings` (
|
|
2
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
-
`key` text NOT NULL,
|
|
4
|
-
`value` text NOT NULL,
|
|
5
|
-
`created_at` integer NOT NULL,
|
|
6
|
-
`updated_at` integer NOT NULL,
|
|
7
|
-
`deleted_at` integer,
|
|
8
|
-
CONSTRAINT "settings_id_not_empty" CHECK(length("settings"."id") > 0),
|
|
9
|
-
CONSTRAINT "settings_key_not_empty" CHECK(length(trim("settings"."key")) > 0),
|
|
10
|
-
CONSTRAINT "settings_value_json" CHECK(json_valid("settings"."value")),
|
|
11
|
-
CONSTRAINT "settings_created_at_nonnegative" CHECK("settings"."created_at" >= 0),
|
|
12
|
-
CONSTRAINT "settings_updated_at_valid" CHECK("settings"."updated_at" >= "settings"."created_at"),
|
|
13
|
-
CONSTRAINT "settings_deleted_at_valid" CHECK("settings"."deleted_at" IS NULL OR "settings"."deleted_at" >= "settings"."created_at")
|
|
14
|
-
);
|
|
15
|
-
--> statement-breakpoint
|
|
16
|
-
CREATE UNIQUE INDEX `settings_key_unique` ON `settings` (`key`);
|
|
17
|
-
--> statement-breakpoint
|
|
18
|
-
INSERT INTO `settings` (`id`, `key`, `value`, `created_at`, `updated_at`, `deleted_at`)
|
|
19
|
-
VALUES (
|
|
20
|
-
uuid_v7(),
|
|
21
|
-
'color_mode',
|
|
22
|
-
'"system"',
|
|
23
|
-
CAST(unixepoch('subsec') * 1000 AS INTEGER),
|
|
24
|
-
CAST(unixepoch('subsec') * 1000 AS INTEGER),
|
|
25
|
-
NULL
|
|
26
|
-
);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `providers` (
|
|
2
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
-
`runtime` text NOT NULL,
|
|
4
|
-
`name` text NOT NULL,
|
|
5
|
-
`official_website` text,
|
|
6
|
-
`remark` text,
|
|
7
|
-
`avatar_mime_type` text,
|
|
8
|
-
`avatar_data` blob,
|
|
9
|
-
`configuration` text NOT NULL,
|
|
10
|
-
`created_at` integer NOT NULL,
|
|
11
|
-
`updated_at` integer NOT NULL,
|
|
12
|
-
`deleted_at` integer,
|
|
13
|
-
CONSTRAINT "providers_id_not_empty" CHECK(length("providers"."id") > 0),
|
|
14
|
-
CONSTRAINT "providers_runtime_valid" CHECK("providers"."runtime" IN ('codex', 'claude-code')),
|
|
15
|
-
CONSTRAINT "providers_name_valid" CHECK(length(trim("providers"."name")) BETWEEN 1 AND 100),
|
|
16
|
-
CONSTRAINT "providers_official_website_valid" CHECK("providers"."official_website" IS NULL OR length("providers"."official_website") <= 2048),
|
|
17
|
-
CONSTRAINT "providers_remark_valid" CHECK("providers"."remark" IS NULL OR length("providers"."remark") <= 2000),
|
|
18
|
-
CONSTRAINT "providers_avatar_valid" CHECK(("providers"."avatar_mime_type" IS NULL AND "providers"."avatar_data" IS NULL)
|
|
19
|
-
OR ("providers"."avatar_mime_type" IN ('image/png', 'image/jpeg', 'image/webp', 'image/svg+xml')
|
|
20
|
-
AND "providers"."avatar_data" IS NOT NULL
|
|
21
|
-
AND length("providers"."avatar_data") BETWEEN 1 AND 2097152)),
|
|
22
|
-
CONSTRAINT "providers_configuration_json" CHECK(json_valid("providers"."configuration")),
|
|
23
|
-
CONSTRAINT "providers_created_at_nonnegative" CHECK("providers"."created_at" >= 0),
|
|
24
|
-
CONSTRAINT "providers_updated_at_valid" CHECK("providers"."updated_at" >= "providers"."created_at"),
|
|
25
|
-
CONSTRAINT "providers_deleted_at_valid" CHECK("providers"."deleted_at" IS NULL OR "providers"."deleted_at" >= "providers"."created_at")
|
|
26
|
-
);
|
|
27
|
-
--> statement-breakpoint
|
|
28
|
-
CREATE INDEX `providers_runtime_created_at_index` ON `providers` (`runtime`,`created_at`);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `runtimes` (
|
|
2
|
-
`runtime` text PRIMARY KEY NOT NULL,
|
|
3
|
-
`managed` integer DEFAULT false NOT NULL,
|
|
4
|
-
`provider_id` text,
|
|
5
|
-
`applied_at` integer,
|
|
6
|
-
FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
7
|
-
CONSTRAINT "runtimes_runtime_valid" CHECK("runtimes"."runtime" IN ('codex', 'claude-code')),
|
|
8
|
-
CONSTRAINT "runtimes_state_valid" CHECK(("runtimes"."managed" = 0 AND "runtimes"."provider_id" IS NULL AND "runtimes"."applied_at" IS NULL) OR ("runtimes"."managed" = 1 AND "runtimes"."applied_at" IS NOT NULL)),
|
|
9
|
-
CONSTRAINT "runtimes_applied_at_nonnegative" CHECK("runtimes"."applied_at" IS NULL OR "runtimes"."applied_at" >= 0)
|
|
10
|
-
);
|
|
11
|
-
--> statement-breakpoint
|
|
12
|
-
INSERT INTO `runtimes` (`runtime`, `managed`, `provider_id`, `applied_at`)
|
|
13
|
-
VALUES
|
|
14
|
-
('codex', false, NULL, NULL),
|
|
15
|
-
('claude-code', false, NULL, NULL);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
UPDATE `providers`
|
|
2
|
-
SET `configuration` = json_set(
|
|
3
|
-
`configuration`,
|
|
4
|
-
'$.defaultModel',
|
|
5
|
-
CASE
|
|
6
|
-
WHEN json_type(`configuration`, '$.primaryModel') = 'text'
|
|
7
|
-
THEN json_extract(`configuration`, '$.primaryModel')
|
|
8
|
-
WHEN json_type(`configuration`, '$.primaryModel.model') = 'text'
|
|
9
|
-
THEN json_extract(`configuration`, '$.primaryModel.model')
|
|
10
|
-
END
|
|
11
|
-
)
|
|
12
|
-
WHERE json_type(`configuration`, '$.defaultModel') IS NULL
|
|
13
|
-
AND (
|
|
14
|
-
json_type(`configuration`, '$.primaryModel') = 'text'
|
|
15
|
-
OR json_type(`configuration`, '$.primaryModel.model') = 'text'
|
|
16
|
-
);
|
|
17
|
-
--> statement-breakpoint
|
|
18
|
-
UPDATE `providers`
|
|
19
|
-
SET `configuration` = json_remove(`configuration`, '$.primaryModel')
|
|
20
|
-
WHERE json_type(`configuration`, '$.defaultModel') = 'text'
|
|
21
|
-
AND json_type(`configuration`, '$.primaryModel') IS NOT NULL;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `prompts` (
|
|
2
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
-
`title` text NOT NULL,
|
|
4
|
-
`description` text,
|
|
5
|
-
`content` text NOT NULL,
|
|
6
|
-
`created_at` integer NOT NULL,
|
|
7
|
-
`updated_at` integer NOT NULL,
|
|
8
|
-
`deleted_at` integer,
|
|
9
|
-
CONSTRAINT "prompts_id_not_empty" CHECK(length("prompts"."id") > 0),
|
|
10
|
-
CONSTRAINT "prompts_title_valid" CHECK(length(trim("prompts"."title")) BETWEEN 1 AND 100),
|
|
11
|
-
CONSTRAINT "prompts_description_valid" CHECK("prompts"."description" IS NULL OR length("prompts"."description") <= 2000),
|
|
12
|
-
CONSTRAINT "prompts_content_valid" CHECK(length(trim("prompts"."content")) > 0 AND length(CAST("prompts"."content" AS BLOB)) <= 1048576),
|
|
13
|
-
CONSTRAINT "prompts_created_at_nonnegative" CHECK("prompts"."created_at" >= 0),
|
|
14
|
-
CONSTRAINT "prompts_updated_at_valid" CHECK("prompts"."updated_at" >= "prompts"."created_at"),
|
|
15
|
-
CONSTRAINT "prompts_deleted_at_valid" CHECK("prompts"."deleted_at" IS NULL OR "prompts"."deleted_at" >= "prompts"."created_at")
|
|
16
|
-
);
|
|
17
|
-
--> statement-breakpoint
|
|
18
|
-
CREATE INDEX `prompts_updated_at_index` ON `prompts` (`updated_at`);
|