UNPKG

@bonhomie/react-security

Version:

A frontend security layer for React: devtools detection, screenshot blocking, anti-iframe, tamper detection, watermarking, and more.

2 lines 212 kB
var Xu=Object.create;var Nr=Object.defineProperty;var qu=Object.getOwnPropertyDescriptor;var Qu=Object.getOwnPropertyNames;var Zu=Object.getPrototypeOf,ec=Object.prototype.hasOwnProperty;var Ir=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ga=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Jo=(e,t)=>{for(var r in t)Nr(e,r,{get:t[r],enumerable:!0})},Ko=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qu(t))!ec.call(e,n)&&n!==r&&Nr(e,n,{get:()=>t[n],enumerable:!(a=qu(t,n))||a.enumerable});return e};var Xa=(e,t,r)=>(r=e!=null?Xu(Zu(e)):{},Ko(t||!e||!e.__esModule?Nr(r,"default",{value:e,enumerable:!0}):r,e)),Go=e=>Ko(Nr({},"__esModule",{value:!0}),e);import*as be from"react";import*as M from"react";import*as L from"react";import*as Fe from"react";import*as de from"react";import*as $ from"react";import*as qs from"react";import*as ct from"react";import*as pn from"react";import*as k from"react";import*as Ae from"react";function xi(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((h,m)=>d(h,typeof h=="string"?null:h.state,m===0?"default":void 0));let o=l(r??n.length-1),i="POP",s=null;function l(h){return Math.min(Math.max(h,0),n.length-1)}function u(){return n[o]}function d(h,m=null,v){let p=rt(n?u().pathname:"/",h,m,v);return Q(p.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(h)}`),p}function c(h){return typeof h=="string"?h:me(h)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:c,createURL(h){return new URL(c(h),"http://localhost")},encodeLocation(h){let m=typeof h=="string"?_e(h):h;return{pathname:m.pathname||"",search:m.search||"",hash:m.hash||""}},push(h,m){i="PUSH";let v=d(h,m);o+=1,n.splice(o,n.length,v),a&&s&&s({action:i,location:v,delta:1})},replace(h,m){i="REPLACE";let v=d(h,m);n[o]=v,a&&s&&s({action:i,location:v,delta:0})},go(h){i="POP";let m=l(o+h),v=n[m];o=m,s&&s({action:i,location:v,delta:h})},listen(h){return s=h,()=>{s=null}}}}function Pt(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return rt("",{pathname:o,search:i,hash:s},n.state&&n.state.usr||null,n.state&&n.state.key||"default")}function r(a,n){return typeof n=="string"?n:me(n)}return Pi(t,r,null,e)}function Ci(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=_e(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),rt("",{pathname:i,search:s,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function r(n,o){let i=n.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let l=n.location.href,u=l.indexOf("#");s=u===-1?l:l.slice(0,u)}return s+"#"+(typeof o=="string"?o:me(o))}function a(n,o){Q(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Pi(t,r,a,e)}function A(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Q(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function sc(){return Math.random().toString(36).substring(2,10)}function qo(e,t){return{usr:e.state,key:e.key,idx:t}}function rt(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?_e(t):t,state:r,key:t&&t.key||a||sc()}}function me({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 _e(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function Pi(e,t,r,a={}){let{window:n=document.defaultView,v5Compat:o=!1}=a,i=n.history,s="POP",l=null,u=d();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function d(){return(i.state||{idx:null}).idx}function c(){s="POP";let p=d(),R=p==null?null:p-u;u=p,l&&l({action:s,location:v.location,delta:R})}function f(p,R){s="PUSH";let w=rt(v.location,p,R);r&&r(w,p),u=d()+1;let x=qo(w,u),P=v.createHref(w);try{i.pushState(x,"",P)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;n.location.assign(P)}o&&l&&l({action:s,location:v.location,delta:1})}function h(p,R){s="REPLACE";let w=rt(v.location,p,R);r&&r(w,p),u=d();let x=qo(w,u),P=v.createHref(w);i.replaceState(x,"",P),o&&l&&l({action:s,location:v.location,delta:0})}function m(p){return Di(p)}let v={get action(){return s},get location(){return e(n,i)},listen(p){if(l)throw new Error("A history only accepts one active listener");return n.addEventListener(Xo,c),l=p,()=>{n.removeEventListener(Xo,c),l=null}},createHref(p){return t(n,p)},createURL:m,encodeLocation(p){let R=m(p);return{pathname:R.pathname,search:R.search,hash:R.hash}},push:f,replace:h,go(p){return i.go(p)}};return v}function Di(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),A(r,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:me(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=r+a),new URL(a,r)}function Zr(e){return{defaultValue:e}}function uc(e){return lc.has(e)}function dc(e){return cc.has(e)}function fc(e){return e.index===!0}function at(e,t,r=[],a={},n=!1){return e.map((o,i)=>{let s=[...r,String(i)],l=typeof o.id=="string"?o.id:s.join("-");if(A(o.index!==!0||!o.children,"Cannot specify children on an index route"),A(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),fc(o)){let u={...o,id:l};return a[l]=Qo(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Qo(u,t(u)),o.children&&(u.children=at(o.children,t,s,a,n)),u}})}function Qo(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function we(e,t,r="/"){return lr(e,t,r,!1)}function lr(e,t,r,a){let n=typeof t=="string"?_e(t):t,o=le(n.pathname||"/",r);if(o==null)return null;let i=_i(e);hc(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Mi(o);s=bc(i[l],u,a)}return s}function Li(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],loaderData:t[r.id],handle:r.handle}}function _i(e,t=[],r=[],a="",n=!1){let o=(i,s,l=n,u)=>{let d={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(a)&&l)return;A(d.relativePath.startsWith(a),`Absolute route path "${d.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(a.length)}let c=Ye([a,d.relativePath]),f=r.concat(d);i.children&&i.children.length>0&&(A(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),_i(i.children,t,f,c,l)),!(i.path==null&&!i.index)&&t.push({path:c,score:wc(c,i.index),routesMeta:f})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of ki(i.path))o(i,s,!0,l)}),t}function ki(e){let t=e.split("/");if(t.length===0)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(a.length===0)return n?[o,""]:[o];let i=ki(a.join("/")),s=[];return s.push(...i.map(l=>l===""?o:[o,l].join("/"))),n&&s.push(...i),s.map(l=>e.startsWith("/")&&l===""?"/":l)}function hc(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:Ec(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}function wc(e,t){let r=e.split("/"),a=r.length;return r.some(Zo)&&(a+=gc),t&&(a+=yc),r.filter(n=>!Zo(n)).reduce((n,o)=>n+(mc.test(o)?pc:o===""?vc:Rc),a)}function Ec(e,t){return e.length===t.length&&e.slice(0,-1).every((a,n)=>a===t[n])?e[e.length-1]-t[t.length-1]:0}function bc(e,t,r=!1){let{routesMeta:a}=e,n={},o="/",i=[];for(let s=0;s<a.length;++s){let l=a[s],u=s===a.length-1,d=o==="/"?t:t.slice(o.length)||"/",c=Ct({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},d),f=l.route;if(!c&&u&&r&&!a[a.length-1].route.index&&(c=Ct({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!c)return null;Object.assign(n,c.params),i.push({params:n,pathname:Ye([o,c.pathname]),pathnameBase:Cc(Ye([o,c.pathnameBase])),route:f}),c.pathnameBase!=="/"&&(o=Ye([o,c.pathnameBase]))}return i}function Ti(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(Q(!1,`Route path "${r}" will be treated as if it were "${r.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${r.replace(/\*$/,"/*")}".`),r=r.replace(/\*$/,"/*"));let a=r.startsWith("/")?"/":"",n=i=>i==null?"":typeof i=="string"?i:String(i),o=r.split(/\/+/).map((i,s,l)=>{if(s===l.length-1&&i==="*")return n(t["*"]);let d=i.match(/^:([\w-]+)(\??)$/);if(d){let[,c,f]=d,h=t[c];return A(f==="?"||h!=null,`Missing ":${c}" param`),encodeURIComponent(n(h))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function Ct(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=Oi(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce((u,{paramName:d,isOptional:c},f)=>{if(d==="*"){let m=s[f]||"";i=o.slice(0,o.length-m.length).replace(/(.)\/+$/,"$1")}let h=s[f];return c&&!h?u[d]=void 0:u[d]=(h||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Oi(e,t=!1,r=!0){Q(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 a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,l)=>(a.push({paramName:s,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),n+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":e!==""&&e!=="/"&&(n+="(?:(?=\\/|$))"),[new RegExp(n,t?void 0:"i"),a]}function Mi(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Q(!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}}function le(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&a!=="/"?null:e.slice(r)||"/"}function Sc({basename:e,pathname:t}){return t==="/"?e:Ye([e,t])}function wn(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?_e(e):e,o;if(r)if(ea(r))o=r;else{if(r.includes("//")){let i=r;r=r.replace(/\/\/+/g,"/"),Q(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${r}`)}r.startsWith("/")?o=ei(r.substring(1),"/"):o=ei(r,t)}else o=t;return{pathname:o,search:Pc(a),hash:Dc(n)}}function ei(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(n=>{n===".."?r.length>1&&r.pop():n!=="."&&r.push(n)}),r.length>1?r.join("/"):"/"}function Za(e,t,r,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. 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 Ai(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ta(e){let t=Ai(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function ra(e,t,r,a=!1){let n;typeof e=="string"?n=_e(e):(n={...e},A(!n.pathname||!n.pathname.includes("?"),Za("?","pathname","search",n)),A(!n.pathname||!n.pathname.includes("#"),Za("#","pathname","hash",n)),A(!n.search||!n.search.includes("#"),Za("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let c=t.length-1;if(!a&&i.startsWith("..")){let f=i.split("/");for(;f[0]==="..";)f.shift(),c-=1;n.pathname=f.join("/")}s=c>=0?t[c]:"/"}let l=wn(n,s),u=i&&i!=="/"&&i.endsWith("/"),d=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||d)&&(l.pathname+="/"),l}function En(e,t){return new Lc(e,typeof t=="number"?{status:t}:t)}function ne(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function $t(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}function Fi(e,t){let r={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(n=>n({id:t.id,index:t.index,path:t.path,instrument(o){let i=Object.keys(r);for(let s of i)o[s]&&r[s].push(o[s])}}));let a={};if(typeof t.lazy=="function"&&r.lazy.length>0){let n=xt(r.lazy,t.lazy,()=>{});n&&(a.lazy=n)}if(typeof t.lazy=="object"){let n=t.lazy;["middleware","loader","action"].forEach(o=>{let i=n[o],s=r[`lazy.${o}`];if(typeof i=="function"&&s.length>0){let l=xt(s,i,()=>{});l&&(a.lazy=Object.assign(a.lazy||{},{[o]:l}))}})}return["loader","action"].forEach(n=>{let o=t[n];if(typeof o=="function"&&r[n].length>0){let i=o[dt]??o,s=xt(r[n],i,(...l)=>ti(l[0]));s&&(s[dt]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[dt]??n,i=xt(r.middleware,o,(...s)=>ti(s[0]));return i?(i[dt]=o,i):n})),a}function _c(e,t){let r={navigate:[],fetch:[]};if(t.forEach(a=>a({instrument(n){let o=Object.keys(n);for(let i of o)n[i]&&r[i].push(n[i])}})),r.navigate.length>0){let a=e.navigate[dt]??e.navigate,n=xt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?me(i):".",...ri(e,s??{})}});n&&(n[dt]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[dt]??e.fetch,n=xt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...ri(e,l??{})}});n&&(n[dt]=a,e.fetch=n)}return e}function Ni(e,t){let r={request:[]};t.forEach(n=>n({instrument(o){let i=Object.keys(o);for(let s of i)o[s]&&r[s].push(o[s])}}));let a=e;return r.request.length>0&&(a=xt(r.request,e,(...n)=>{let[o,i]=n;return{request:Hi(o),context:i!=null?$i(i):i}})),a}function xt(e,t,r){return e.length===0?null:async(...a)=>{let n=await Ii(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function Ii(e,t,r,a){let n=e[a],o;if(n){let i,s=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=Ii(e,t,r,a-1),o=await i,A(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await n(s,t)}catch(l){console.error("An instrumentation function threw an error:",l)}i||await s(),await i}else try{o={type:"success",value:await r()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function ti(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:Hi(t),params:{...a},unstable_pattern:n,context:$i(r)}}function ri(e,t){return{currentUrl:me(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}:{}}}function Hi(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function $i(e){if(Tc(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}function Tc(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===kc}function mt(e){let t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";A(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||zi,o=n;if(e.unstable_instrumentations){let y=e.unstable_instrumentations;o=E=>({...n(E),...Fi(y.map(b=>b.route).filter(Boolean),E)})}let i={},s=at(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let d=e.dataStrategy||jc,c={...e.future},f=null,h=new Set,m=null,v=null,p=null,R=e.hydrationData!=null,w=we(s,e.history.location,u),x=!1,P=null,C;if(w==null&&!e.patchRoutesOnNavigation){let y=se(404,{pathname:e.history.location.pathname}),{matches:E,route:b}=Ht(s);C=!0,w=E,P={[b.id]:y}}else if(w&&!e.hydrationData&&Tr(w,s,e.history.location.pathname).active&&(w=null),w)if(w.some(y=>y.route.lazy))C=!1;else if(!w.some(y=>xn(y.route)))C=!0;else{let y=e.hydrationData?e.hydrationData.loaderData:null,E=e.hydrationData?e.hydrationData.errors:null;if(E){let b=w.findIndex(D=>E[D.route.id]!==void 0);C=w.slice(0,b+1).every(D=>!on(D.route,y,E))}else C=w.every(b=>!on(b.route,y,E))}else{C=!1,w=[];let y=Tr(null,s,e.history.location.pathname);y.active&&y.matches&&(x=!0,w=y.matches)}let S,g={historyAction:e.history.action,location:e.history.location,matches:w,initialized:C,navigation:Ut,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||P,fetchers:new Map,blockers:new Map},T="POP",O=!1,F,H=!1,G=new Map,Z=null,Y=!1,q=!1,ye=new Set,X=new Map,Te=0,De=-1,$e=new Map,Le=new Set,Oe=new Map,Be=new Map,We=new Set,Rt=new Map,_r,tr=null;function Ou(){if(f=e.history.listen(({action:y,location:E,delta:b})=>{if(_r){_r(),_r=void 0;return}Q(Rt.size===0||b!=null,"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 D=zo({currentLocation:g.location,nextLocation:E,historyAction:y});if(D&&b!=null){let _=new Promise(U=>{_r=U});e.history.go(b*-1),kr(D,{state:"blocked",location:E,proceed(){kr(D,{state:"proceeding",proceed:void 0,reset:void 0,location:E}),_.then(()=>e.history.go(b))},reset(){let U=new Map(g.blockers);U.set(D,et),ve({blockers:U})}});return}return gt(y,E)}),r){Kc(t,G);let y=()=>Gc(t,G);t.addEventListener("pagehide",y),Z=()=>t.removeEventListener("pagehide",y)}return g.initialized||gt("POP",g.location,{initialHydration:!0}),S}function Mu(){f&&f(),Z&&Z(),h.clear(),F&&F.abort(),g.fetchers.forEach((y,E)=>Ya(E)),g.blockers.forEach((y,E)=>jo(E))}function Au(y){return h.add(y),()=>h.delete(y)}function ve(y,E={}){y.matches&&(y.matches=y.matches.map(_=>{let U=i[_.route.id],j=_.route;return j.element!==U.element||j.errorElement!==U.errorElement||j.hydrateFallbackElement!==U.hydrateFallbackElement?{..._,route:U}:_})),g={...g,...y};let b=[],D=[];g.fetchers.forEach((_,U)=>{_.state==="idle"&&(We.has(U)?b.push(U):D.push(U))}),We.forEach(_=>{!g.fetchers.has(_)&&!X.has(_)&&b.push(_)}),[...h].forEach(_=>_(g,{deletedFetchers:b,viewTransitionOpts:E.viewTransitionOpts,flushSync:E.flushSync===!0})),b.forEach(_=>Ya(_)),D.forEach(_=>g.fetchers.delete(_))}function Ft(y,E,{flushSync:b}={}){let D=g.actionData!=null&&g.navigation.formMethod!=null&&he(g.navigation.formMethod)&&g.navigation.state==="loading"&&y.state?._isRedirect!==!0,_;E.actionData?Object.keys(E.actionData).length>0?_=E.actionData:_=null:D?_=g.actionData:_=null;let U=E.loaderData?mi(g.loaderData,E.loaderData,E.matches||[],E.errors):g.loaderData,j=g.blockers;j.size>0&&(j=new Map(j),j.forEach((B,W)=>j.set(W,et)));let I=Y?!1:Wo(y,E.matches||g.matches),z=O===!0||g.navigation.formMethod!=null&&he(g.navigation.formMethod)&&y.state?._isRedirect!==!0;l&&(s=l,l=void 0),Y||T==="POP"||(T==="PUSH"?e.history.push(y,y.state):T==="REPLACE"&&e.history.replace(y,y.state));let V;if(T==="POP"){let B=G.get(g.location.pathname);B&&B.has(y.pathname)?V={currentLocation:g.location,nextLocation:y}:G.has(y.pathname)&&(V={currentLocation:y,nextLocation:g.location})}else if(H){let B=G.get(g.location.pathname);B?B.add(y.pathname):(B=new Set([y.pathname]),G.set(g.location.pathname,B)),V={currentLocation:g.location,nextLocation:y}}ve({...E,actionData:_,loaderData:U,historyAction:T,location:y,initialized:!0,navigation:Ut,revalidation:"idle",restoreScrollPosition:I,preventScrollReset:z,blockers:j},{viewTransitionOpts:V,flushSync:b===!0}),T="POP",O=!1,H=!1,Y=!1,q=!1,tr?.resolve(),tr=null}async function Ao(y,E){if(typeof y=="number"){e.history.go(y);return}let b=nn(g.location,g.matches,u,y,E?.fromRouteId,E?.relative),{path:D,submission:_,error:U}=ni(!1,b,E),j=g.location,I=rt(g.location,D,E&&E.state);I={...I,...e.history.encodeLocation(I)};let z=E&&E.replace!=null?E.replace:void 0,V="PUSH";z===!0?V="REPLACE":z===!1||_!=null&&he(_.formMethod)&&_.formAction===g.location.pathname+g.location.search&&(V="REPLACE");let B=E&&"preventScrollReset"in E?E.preventScrollReset===!0:void 0,W=(E&&E.flushSync)===!0,J=zo({currentLocation:j,nextLocation:I,historyAction:V});if(J){kr(J,{state:"blocked",location:I,proceed(){kr(J,{state:"proceeding",proceed:void 0,reset:void 0,location:I}),Ao(y,E)},reset(){let re=new Map(g.blockers);re.set(J,et),ve({blockers:re})}});return}await gt(V,I,{submission:_,pendingError:U,preventScrollReset:B,replace:E&&E.replace,enableViewTransition:E&&E.viewTransition,flushSync:W})}function Fu(){tr||(tr=Xc()),Va(),ve({revalidation:"loading"});let y=tr.promise;return g.navigation.state==="submitting"?y:g.navigation.state==="idle"?(gt(g.historyAction,g.location,{startUninterruptedRevalidation:!0}),y):(gt(T||g.historyAction,g.navigation.location,{overrideNavigation:g.navigation,enableViewTransition:H===!0}),y)}async function gt(y,E,b){F&&F.abort(),F=null,T=y,Y=(b&&b.startUninterruptedRevalidation)===!0,Yu(g.location,g.matches),O=(b&&b.preventScrollReset)===!0,H=(b&&b.enableViewTransition)===!0;let D=l||s,_=b&&b.overrideNavigation,U=b?.initialHydration&&g.matches&&g.matches.length>0&&!x?g.matches:we(D,E,u),j=(b&&b.flushSync)===!0;if(U&&g.initialized&&!q&&Bc(g.location,E)&&!(b&&b.submission&&he(b.submission.formMethod))){Ft(E,{matches:U},{flushSync:j});return}let I=Tr(U,D,E.pathname);if(I.active&&I.matches&&(U=I.matches),!U){let{error:ce,notFoundMatches:ee,route:te}=Ja(E.pathname);Ft(E,{matches:ee,loaderData:{},errors:{[te.id]:ce}},{flushSync:j});return}F=new AbortController;let z=It(e.history,E,F.signal,b&&b.submission),V=e.getContext?await e.getContext():new Ie,B;if(b&&b.pendingError)B=[Ne(U).route.id,{type:"error",error:b.pendingError}];else if(b&&b.submission&&he(b.submission.formMethod)){let ce=await Nu(z,E,b.submission,U,V,I.active,b&&b.initialHydration===!0,{replace:b.replace,flushSync:j});if(ce.shortCircuited)return;if(ce.pendingActionResult){let[ee,te]=ce.pendingActionResult;if(fe(te)&&ne(te.error)&&te.error.status===404){F=null,Ft(E,{matches:ce.matches,loaderData:{},errors:{[ee]:te.error}});return}}U=ce.matches||U,B=ce.pendingActionResult,_=en(E,b.submission),j=!1,I.active=!1,z=It(e.history,z.url,z.signal)}let{shortCircuited:W,matches:J,loaderData:re,errors:ue}=await Iu(z,E,U,V,I.active,_,b&&b.submission,b&&b.fetcherSubmission,b&&b.replace,b&&b.initialHydration===!0,j,B);W||(F=null,Ft(E,{matches:J||U,...pi(B),loaderData:re,errors:ue}))}async function Nu(y,E,b,D,_,U,j,I={}){Va();let z=Yc(E,b);if(ve({navigation:z},{flushSync:I.flushSync===!0}),U){let W=await Or(D,E.pathname,y.signal);if(W.type==="aborted")return{shortCircuited:!0};if(W.type==="error"){if(W.partialMatches.length===0){let{matches:re,route:ue}=Ht(s);return{matches:re,pendingActionResult:[ue.id,{type:"error",error:W.error}]}}let J=Ne(W.partialMatches).route.id;return{matches:W.partialMatches,pendingActionResult:[J,{type:"error",error:W.error}]}}else if(W.matches)D=W.matches;else{let{notFoundMatches:J,error:re,route:ue}=Ja(E.pathname);return{matches:J,pendingActionResult:[ue.id,{type:"error",error:re}]}}}let V,B=jt(D,E);if(!B.route.action&&!B.route.lazy)V={type:"error",error:se(405,{method:y.method,pathname:E.pathname,routeId:B.route.id})};else{let W=ht(o,i,y,D,B,j?[]:a,_),J=await rr(y,W,_,null);if(V=J[B.route.id],!V){for(let re of D)if(J[re.route.id]){V=J[re.route.id];break}}if(y.signal.aborted)return{shortCircuited:!0}}if(ft(V)){let W;return I&&I.replace!=null?W=I.replace:W=di(V.response.headers.get("Location"),new URL(y.url),u)===g.location.pathname+g.location.search,await wt(y,V,!0,{submission:b,replace:W}),{shortCircuited:!0}}if(fe(V)){let W=Ne(D,B.route.id);return(I&&I.replace)!==!0&&(T="PUSH"),{matches:D,pendingActionResult:[W.route.id,V,B.route.id]}}return{matches:D,pendingActionResult:[B.route.id,V]}}async function Iu(y,E,b,D,_,U,j,I,z,V,B,W){let J=U||en(E,j),re=j||I||yi(J),ue=!Y&&!V;if(_){if(ue){let Re=Fo(W);ve({navigation:J,...Re!==void 0?{actionData:Re}:{}},{flushSync:B})}let K=await Or(b,E.pathname,y.signal);if(K.type==="aborted")return{shortCircuited:!0};if(K.type==="error"){if(K.partialMatches.length===0){let{matches:Nt,route:St}=Ht(s);return{matches:Nt,loaderData:{},errors:{[St.id]:K.error}}}let Re=Ne(K.partialMatches).route.id;return{matches:K.partialMatches,loaderData:{},errors:{[Re]:K.error}}}else if(K.matches)b=K.matches;else{let{error:Re,notFoundMatches:Nt,route:St}=Ja(E.pathname);return{matches:Nt,loaderData:{},errors:{[St.id]:Re}}}}let ce=l||s,{dsMatches:ee,revalidatingFetchers:te}=oi(y,D,o,i,e.history,g,b,re,E,V?[]:a,V===!0,q,ye,We,Oe,Le,ce,u,e.patchRoutesOnNavigation!=null,W);if(De=++Te,!e.dataStrategy&&!ee.some(K=>K.shouldLoad)&&!ee.some(K=>K.route.middleware&&K.route.middleware.length>0)&&te.length===0){let K=$o();return Ft(E,{matches:b,loaderData:{},errors:W&&fe(W[1])?{[W[0]]:W[1].error}:null,...pi(W),...K?{fetchers:new Map(g.fetchers)}:{}},{flushSync:B}),{shortCircuited:!0}}if(ue){let K={};if(!_){K.navigation=J;let Re=Fo(W);Re!==void 0&&(K.actionData=Re)}te.length>0&&(K.fetchers=Hu(te)),ve(K,{flushSync:B})}te.forEach(K=>{Qe(K.key),K.controller&&X.set(K.key,K.controller)});let Et=()=>te.forEach(K=>Qe(K.key));F&&F.signal.addEventListener("abort",Et);let{loaderResults:ar,fetcherResults:ut}=await No(ee,te,y,D);if(y.signal.aborted)return{shortCircuited:!0};F&&F.signal.removeEventListener("abort",Et),te.forEach(K=>X.delete(K.key));let Ve=jr(ar);if(Ve)return await wt(y,Ve.result,!0,{replace:z}),{shortCircuited:!0};if(Ve=jr(ut),Ve)return Le.add(Ve.key),await wt(y,Ve.result,!0,{replace:z}),{shortCircuited:!0};let{loaderData:Ka,errors:nr}=hi(g,b,ar,W,te,ut);V&&g.errors&&(nr={...g.errors,...nr});let bt=$o(),Mr=Uo(De),Ar=bt||Mr||te.length>0;return{matches:b,loaderData:Ka,errors:nr,...Ar?{fetchers:new Map(g.fetchers)}:{}}}function Fo(y){if(y&&!fe(y[1]))return{[y[0]]:y[1].data};if(g.actionData)return Object.keys(g.actionData).length===0?null:g.actionData}function Hu(y){return y.forEach(E=>{let b=g.fetchers.get(E.key),D=or(void 0,b?b.data:void 0);g.fetchers.set(E.key,D)}),new Map(g.fetchers)}async function $u(y,E,b,D){Qe(y);let _=(D&&D.flushSync)===!0,U=l||s,j=nn(g.location,g.matches,u,b,E,D?.relative),I=we(U,j,u),z=Tr(I,U,j);if(z.active&&z.matches&&(I=z.matches),!I){qe(y,E,se(404,{pathname:j}),{flushSync:_});return}let{path:V,submission:B,error:W}=ni(!0,j,D);if(W){qe(y,E,W,{flushSync:_});return}let J=e.getContext?await e.getContext():new Ie,re=(D&&D.preventScrollReset)===!0;if(B&&he(B.formMethod)){await Uu(y,E,V,I,J,z.active,_,re,B);return}Oe.set(y,{routeId:E,path:V}),await ju(y,E,V,I,J,z.active,_,re,B)}async function Uu(y,E,b,D,_,U,j,I,z){Va(),Oe.delete(y);let V=g.fetchers.get(y);Xe(y,Jc(z,V),{flushSync:j});let B=new AbortController,W=It(e.history,b,B.signal,z);if(U){let oe=await Or(D,new URL(W.url).pathname,W.signal,y);if(oe.type==="aborted")return;if(oe.type==="error"){qe(y,E,oe.error,{flushSync:j});return}else if(oe.matches)D=oe.matches;else{qe(y,E,se(404,{pathname:b}),{flushSync:j});return}}let J=jt(D,b);if(!J.route.action&&!J.route.lazy){let oe=se(405,{method:z.formMethod,pathname:b,routeId:E});qe(y,E,oe,{flushSync:j});return}X.set(y,B);let re=Te,ue=ht(o,i,W,D,J,a,_),ce=await rr(W,ue,_,y),ee=ce[J.route.id];if(!ee){for(let oe of ue)if(ce[oe.route.id]){ee=ce[oe.route.id];break}}if(W.signal.aborted){X.get(y)===B&&X.delete(y);return}if(We.has(y)){if(ft(ee)||fe(ee)){Xe(y,Ze(void 0));return}}else{if(ft(ee))if(X.delete(y),De>re){Xe(y,Ze(void 0));return}else return Le.add(y),Xe(y,or(z)),wt(W,ee,!1,{fetcherSubmission:z,preventScrollReset:I});if(fe(ee)){qe(y,E,ee.error);return}}let te=g.navigation.location||g.location,Et=It(e.history,te,B.signal),ar=l||s,ut=g.navigation.state!=="idle"?we(ar,g.navigation.location,u):g.matches;A(ut,"Didn't find any matches after fetcher action");let Ve=++Te;$e.set(y,Ve);let Ka=or(z,ee.data);g.fetchers.set(y,Ka);let{dsMatches:nr,revalidatingFetchers:bt}=oi(Et,_,o,i,e.history,g,ut,z,te,a,!1,q,ye,We,Oe,Le,ar,u,e.patchRoutesOnNavigation!=null,[J.route.id,ee]);bt.filter(oe=>oe.key!==y).forEach(oe=>{let Fr=oe.key,Yo=g.fetchers.get(Fr),Gu=or(void 0,Yo?Yo.data:void 0);g.fetchers.set(Fr,Gu),Qe(Fr),oe.controller&&X.set(Fr,oe.controller)}),ve({fetchers:new Map(g.fetchers)});let Mr=()=>bt.forEach(oe=>Qe(oe.key));B.signal.addEventListener("abort",Mr);let{loaderResults:Ar,fetcherResults:K}=await No(nr,bt,Et,_);if(B.signal.aborted)return;if(B.signal.removeEventListener("abort",Mr),$e.delete(y),X.delete(y),bt.forEach(oe=>X.delete(oe.key)),g.fetchers.has(y)){let oe=Ze(ee.data);g.fetchers.set(y,oe)}let Re=jr(Ar);if(Re)return wt(Et,Re.result,!1,{preventScrollReset:I});if(Re=jr(K),Re)return Le.add(Re.key),wt(Et,Re.result,!1,{preventScrollReset:I});let{loaderData:Nt,errors:St}=hi(g,ut,Ar,void 0,bt,K);Uo(Ve),g.navigation.state==="loading"&&Ve>De?(A(T,"Expected pending action"),F&&F.abort(),Ft(g.navigation.location,{matches:ut,loaderData:Nt,errors:St,fetchers:new Map(g.fetchers)})):(ve({errors:St,loaderData:mi(g.loaderData,Nt,ut,St),fetchers:new Map(g.fetchers)}),q=!1)}async function ju(y,E,b,D,_,U,j,I,z){let V=g.fetchers.get(y);Xe(y,or(z,V?V.data:void 0),{flushSync:j});let B=new AbortController,W=It(e.history,b,B.signal);if(U){let te=await Or(D,new URL(W.url).pathname,W.signal,y);if(te.type==="aborted")return;if(te.type==="error"){qe(y,E,te.error,{flushSync:j});return}else if(te.matches)D=te.matches;else{qe(y,E,se(404,{pathname:b}),{flushSync:j});return}}let J=jt(D,b);X.set(y,B);let re=Te,ue=ht(o,i,W,D,J,a,_),ee=(await rr(W,ue,_,y))[J.route.id];if(X.get(y)===B&&X.delete(y),!W.signal.aborted){if(We.has(y)){Xe(y,Ze(void 0));return}if(ft(ee))if(De>re){Xe(y,Ze(void 0));return}else{Le.add(y),await wt(W,ee,!1,{preventScrollReset:I});return}if(fe(ee)){qe(y,E,ee.error);return}Xe(y,Ze(ee.data))}}async function wt(y,E,b,{submission:D,fetcherSubmission:_,preventScrollReset:U,replace:j}={}){E.response.headers.has("X-Remix-Revalidate")&&(q=!0);let I=E.response.headers.get("Location");A(I,"Expected a Location header on the redirect Response"),I=di(I,new URL(y.url),u);let z=rt(g.location,I,{_isRedirect:!0});if(r){let ue=!1;if(E.response.headers.has("X-Remix-Reload-Document"))ue=!0;else if(ea(I)){let ce=Di(I,!0);ue=ce.origin!==t.location.origin||le(ce.pathname,u)==null}if(ue){j?t.location.replace(I):t.location.assign(I);return}}F=null;let V=j===!0||E.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:B,formAction:W,formEncType:J}=g.navigation;!D&&!_&&B&&W&&J&&(D=yi(g.navigation));let re=D||_;if(Fc.has(E.response.status)&&re&&he(re.formMethod))await gt(V,z,{submission:{...re,formAction:I},preventScrollReset:U||O,enableViewTransition:b?H:void 0});else{let ue=en(z,D);await gt(V,z,{overrideNavigation:ue,fetcherSubmission:_,preventScrollReset:U||O,enableViewTransition:b?H:void 0})}}async function rr(y,E,b,D){let _,U={};try{_=await Xi(d,y,E,D,b,!1)}catch(j){return E.filter(I=>I.shouldLoad).forEach(I=>{U[I.route.id]={type:"error",error:j}}),U}if(y.signal.aborted)return U;for(let[j,I]of Object.entries(_))if(as(I)){let z=I.result;U[j]={type:"redirect",response:Zi(z,y,j,E,u)}}else U[j]=await Qi(I);return U}async function No(y,E,b,D){let _=rr(b,y,D,null),U=Promise.all(E.map(async z=>{if(z.matches&&z.match&&z.request&&z.controller){let B=(await rr(z.request,z.matches,D,z.key))[z.match.route.id];return{[z.key]:B}}else return Promise.resolve({[z.key]:{type:"error",error:se(404,{pathname:z.path})}})})),j=await _,I=(await U).reduce((z,V)=>Object.assign(z,V),{});return{loaderResults:j,fetcherResults:I}}function Va(){q=!0,Oe.forEach((y,E)=>{X.has(E)&&ye.add(E),Qe(E)})}function Xe(y,E,b={}){g.fetchers.set(y,E),ve({fetchers:new Map(g.fetchers)},{flushSync:(b&&b.flushSync)===!0})}function qe(y,E,b,D={}){let _=Ne(g.matches,E);Ya(y),ve({errors:{[_.route.id]:b},fetchers:new Map(g.fetchers)},{flushSync:(D&&D.flushSync)===!0})}function Io(y){return Be.set(y,(Be.get(y)||0)+1),We.has(y)&&We.delete(y),g.fetchers.get(y)||mr}function zu(y,E){Qe(y,E?.reason),Xe(y,Ze(null))}function Ya(y){let E=g.fetchers.get(y);X.has(y)&&!(E&&E.state==="loading"&&$e.has(y))&&Qe(y),Oe.delete(y),$e.delete(y),Le.delete(y),We.delete(y),ye.delete(y),g.fetchers.delete(y)}function Bu(y){let E=(Be.get(y)||0)-1;E<=0?(Be.delete(y),We.add(y)):Be.set(y,E),ve({fetchers:new Map(g.fetchers)})}function Qe(y,E){let b=X.get(y);b&&(b.abort(E),X.delete(y))}function Ho(y){for(let E of y){let b=Io(E),D=Ze(b.data);g.fetchers.set(E,D)}}function $o(){let y=[],E=!1;for(let b of Le){let D=g.fetchers.get(b);A(D,`Expected fetcher: ${b}`),D.state==="loading"&&(Le.delete(b),y.push(b),E=!0)}return Ho(y),E}function Uo(y){let E=[];for(let[b,D]of $e)if(D<y){let _=g.fetchers.get(b);A(_,`Expected fetcher: ${b}`),_.state==="loading"&&(Qe(b),$e.delete(b),E.push(b))}return Ho(E),E.length>0}function Wu(y,E){let b=g.blockers.get(y)||et;return Rt.get(y)!==E&&Rt.set(y,E),b}function jo(y){g.blockers.delete(y),Rt.delete(y)}function kr(y,E){let b=g.blockers.get(y)||et;A(b.state==="unblocked"&&E.state==="blocked"||b.state==="blocked"&&E.state==="blocked"||b.state==="blocked"&&E.state==="proceeding"||b.state==="blocked"&&E.state==="unblocked"||b.state==="proceeding"&&E.state==="unblocked",`Invalid blocker state transition: ${b.state} -> ${E.state}`);let D=new Map(g.blockers);D.set(y,E),ve({blockers:D})}function zo({currentLocation:y,nextLocation:E,historyAction:b}){if(Rt.size===0)return;Rt.size>1&&Q(!1,"A router only supports one blocker at a time");let D=Array.from(Rt.entries()),[_,U]=D[D.length-1],j=g.blockers.get(_);if(!(j&&j.state==="proceeding")&&U({currentLocation:y,nextLocation:E,historyAction:b}))return _}function Ja(y){let E=se(404,{pathname:y}),b=l||s,{matches:D,route:_}=Ht(b);return{notFoundMatches:D,route:_,error:E}}function Vu(y,E,b){if(m=y,p=E,v=b||null,!R&&g.navigation===Ut){R=!0;let D=Wo(g.location,g.matches);D!=null&&ve({restoreScrollPosition:D})}return()=>{m=null,p=null,v=null}}function Bo(y,E){return v&&v(y,E.map(D=>Li(D,g.loaderData)))||y.key}function Yu(y,E){if(m&&p){let b=Bo(y,E);m[b]=p()}}function Wo(y,E){if(m){let b=Bo(y,E),D=m[b];if(typeof D=="number")return D}return null}function Tr(y,E,b){if(e.patchRoutesOnNavigation)if(y){if(Object.keys(y[0].params).length>0)return{active:!0,matches:lr(E,b,u,!0)}}else return{active:!0,matches:lr(E,b,u,!0)||[]};return{active:!1,matches:null}}async function Or(y,E,b,D){if(!e.patchRoutesOnNavigation)return{type:"success",matches:y};let _=y;for(;;){let U=l==null,j=l||s,I=i;try{await e.patchRoutesOnNavigation({signal:b,path:E,matches:_,fetcherKey:D,patch:(B,W)=>{b.aborted||ii(B,W,j,I,o,!1)}})}catch(B){return{type:"error",error:B,partialMatches:_}}finally{U&&!b.aborted&&(s=[...s])}if(b.aborted)return{type:"aborted"};let z=we(j,E,u),V=null;if(z){if(Object.keys(z[0].params).length===0)return{type:"success",matches:z};if(V=lr(j,E,u,!0),!(V&&_.length<V.length&&Vo(_,V.slice(0,_.length))))return{type:"success",matches:z}}if(V||(V=lr(j,E,u,!0)),!V||Vo(_,V))return{type:"success",matches:null};_=V}}function Vo(y,E){return y.length===E.length&&y.every((b,D)=>b.route.id===E[D].route.id)}function Ju(y){i={},l=at(y,o,void 0,i)}function Ku(y,E,b=!1){let D=l==null;ii(y,E,l||s,i,o,b),D&&(s=[...s],ve({}))}return S={get basename(){return u},get future(){return c},get state(){return g},get routes(){return s},get window(){return t},initialize:Ou,subscribe:Au,enableScrollRestoration:Vu,navigate:Ao,fetch:$u,revalidate:Fu,createHref:y=>e.history.createHref(y),encodeLocation:y=>e.history.encodeLocation(y),getFetcher:Io,resetFetcher:zu,deleteFetcher:Bu,dispose:Mu,getBlocker:Wu,deleteBlocker:jo,patchRoutes:Ku,_internalFetchControllers:X,_internalSetRoutes:Ju,_internalSetStateDoNotUseOrYouWillBreakYourApp(y){ve(y)}},e.unstable_instrumentations&&(S=_c(S,e.unstable_instrumentations.map(y=>y.router).filter(Boolean))),S}function bn(e,t){A(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||zi,o=n;if(t?.unstable_instrumentations){let h=t.unstable_instrumentations;o=m=>({...n(m),...Fi(h.map(v=>v.route).filter(Boolean),m)})}let i=at(e,o,void 0,r);async function s(h,{requestContext:m,filterMatchesToLoad:v,skipLoaderErrorBubbling:p,skipRevalidation:R,dataStrategy:w,generateMiddlewareResponse:x}={}){let P=new URL(h.url),C=h.method,S=rt("",me(P),null,"default"),g=we(i,S,a);if(m=m??new Ie,!cn(C)&&C!=="HEAD"){let O=se(405,{method:C}),{matches:F,route:H}=Ht(i),G={basename:a,location:S,matches:F,loaderData:{},actionData:null,errors:{[H.id]:O},statusCode:O.status,loaderHeaders:{},actionHeaders:{}};return x?x(()=>Promise.resolve(G)):G}else if(!g){let O=se(404,{pathname:S.pathname}),{matches:F,route:H}=Ht(i),G={basename:a,location:S,matches:F,loaderData:{},actionData:null,errors:{[H.id]:O},statusCode:O.status,loaderHeaders:{},actionHeaders:{}};return x?x(()=>Promise.resolve(G)):G}if(x){A(m instanceof Ie,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await ui(g,r,o);let O,F=await ci({request:h,unstable_pattern:$t(g.map(H=>H.route.path)),matches:g,params:g[0].params,context:m},async()=>await x(async(G,Z={})=>{let Y=await u(G,S,g,m,w||null,p===!0,null,"filterMatchesToLoad"in Z?Z.filterMatchesToLoad??null:v??null,R===!0);return ae(Y)?Y:(O={location:S,basename:a,...Y},O)}),async(H,G)=>{if(dr(H))return H;if(ae(H))try{H=new ie(H.status,H.statusText,await qi(H))}catch(Z){H=Z}if(tt(H)&&(H=Wc(H)),O){G in O.loaderData&&(O.loaderData[G]=void 0);let Z=Sn(i,O,H,p?G:Ne(g,G).route.id);return x(()=>Promise.resolve(Z))}else{let Z=p?G:Ne(g,g.find(q=>q.route.id===G||q.route.loader)?.route.id||G).route.id,Y={matches:g,location:S,basename:a,loaderData:{},actionData:null,errors:{[Z]:H},statusCode:ne(H)?H.status:500,actionHeaders:{},loaderHeaders:{}};return x(()=>Promise.resolve(Y))}});return A(ae(F),"Expected a response in query()"),F}catch(O){if(ae(O))return O;throw O}}let T=await u(h,S,g,m,w||null,p===!0,null,v||null,R===!0);return ae(T)?T:{location:S,basename:a,...T}}async function l(h,{routeId:m,requestContext:v,dataStrategy:p,generateMiddlewareResponse:R}={}){let w=new URL(h.url),x=h.method,P=rt("",me(w),null,"default"),C=we(i,P,a);if(v=v??new Ie,!cn(x)&&x!=="HEAD"&&x!=="OPTIONS")throw se(405,{method:x});if(!C)throw se(404,{pathname:P.pathname});let S=m?C.find(O=>O.route.id===m):jt(C,P);if(m&&!S)throw se(403,{pathname:P.pathname,routeId:m});if(!S)throw se(404,{pathname:P.pathname});if(R)return A(v instanceof Ie,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await ui(C,r,o),await ci({request:h,unstable_pattern:$t(C.map(F=>F.route.path)),matches:C,params:C[0].params,context:v},async()=>await R(async H=>{let G=await u(H,P,C,v,p||null,!1,S,null,!1),Z=T(G);return ae(Z)?Z:typeof Z=="string"?new Response(Z):Response.json(Z)}),F=>{if(tt(F))return Promise.resolve(un(F));if(ae(F))return Promise.resolve(F);throw F});let g=await u(h,P,C,v,p||null,!1,S,null,!1);return T(g);function T(O){if(ae(O))return O;let F=O.errors?Object.values(O.errors)[0]:void 0;if(F!==void 0)throw F;if(O.actionData)return Object.values(O.actionData)[0];if(O.loaderData)return Object.values(O.loaderData)[0]}}async function u(h,m,v,p,R,w,x,P,C){A(h.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(he(h.method))return await d(h,v,x||jt(v,m),p,R,w,x!=null,P,C);let S=await c(h,v,p,R,w,x,P);return ae(S)?S:{...S,actionData:null,actionHeaders:{}}}catch(S){if(rs(S)&&ae(S.result)){if(S.type==="error")throw S.result;return S.result}if(dr(S))return S;throw S}}async function d(h,m,v,p,R,w,x,P,C){let S;if(!v.route.action&&!v.route.lazy){let O=se(405,{method:h.method,pathname:new URL(h.url).pathname,routeId:v.route.id});if(x)throw O;S={type:"error",error:O}}else{let O=ht(o,r,h,m,v,[],p);S=(await f(h,O,x,p,R))[v.route.id],h.signal.aborted&&ai(h,x)}if(ft(S))throw new Response(null,{status:S.response.status,headers:{Location:S.response.headers.get("Location")}});if(x){if(fe(S))throw S.error;return{matches:[v],loaderData:{},actionData:{[v.route.id]:S.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(C)if(fe(S)){let O=w?v:Ne(m,v.route.id);return{statusCode:ne(S.error)?S.error.status:S.statusCode!=null?S.statusCode:500,actionData:null,actionHeaders:{...S.headers?{[v.route.id]:S.headers}:{}},matches:m,loaderData:{},errors:{[O.route.id]:S.error},loaderHeaders:{}}}else return{actionData:{[v.route.id]:S.data},actionHeaders:S.headers?{[v.route.id]:S.headers}:{},matches:m,loaderData:{},errors:null,statusCode:S.statusCode||200,loaderHeaders:{}};let g=new Request(h.url,{headers:h.headers,redirect:h.redirect,signal:h.signal});if(fe(S)){let O=w?v:Ne(m,v.route.id);return{...await c(g,m,p,R,w,null,P,[O.route.id,S]),statusCode:ne(S.error)?S.error.status:S.statusCode!=null?S.statusCode:500,actionData:null,actionHeaders:{...S.headers?{[v.route.id]:S.headers}:{}}}}return{...await c(g,m,p,R,w,null,P),actionData:{[v.route.id]:S.data},...S.statusCode?{statusCode:S.statusCode}:{},actionHeaders:S.headers?{[v.route.id]:S.headers}:{}}}async function c(h,m,v,p,R,w,x,P){let C=w!=null;if(C&&!w?.route.loader&&!w?.route.lazy)throw se(400,{method:h.method,pathname:new URL(h.url).pathname,routeId:w?.route.id});let S;if(w)S=ht(o,r,h,m,w,[],v);else{let O=P&&fe(P[1])?m.findIndex(H=>H.route.id===P[0])-1:void 0,F=$t(m.map(H=>H.route.path));S=m.map((H,G)=>O!=null&&G>O?cr(o,r,h,F,H,[],v,!1):cr(o,r,h,F,H,[],v,(H.route.loader||H.route.lazy)!=null&&(!x||x(H))))}if(!p&&!S.some(O=>O.shouldLoad))return{matches:m,loaderData:{},errors:P&&fe(P[1])?{[P[0]]:P[1].error}:null,statusCode:200,loaderHeaders:{}};let g=await f(h,S,C,v,p);return h.signal.aborted&&ai(h,C),{...es(m,g,P,!0,R),matches:m}}async function f(h,m,v,p,R){let w=await Xi(R||sn,h,m,null,p,!0),x={};return await Promise.all(m.map(async P=>{if(!(P.route.id in w))return;let C=w[P.route.id];if(as(C)){let S=C.result;throw Zi(S,h,P.route.id,m,a)}if(v){if(ae(C.result))throw C;if(tt(C.result))throw un(C.result)}x[P.route.id]=await Qi(C)})),x}return{dataRoutes:i,query:s,queryRoute:l}}function Sn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:ne(r)?r.status:500,errors:{[n]:r}}}function ai(e,t){if(e.signal.reason!==void 0)throw e.signal.reason;let r=t?"queryRoute":"query";throw new Error(`${r}() call aborted without an \`AbortSignal.reason\`: ${e.method} ${e.url}`)}function Nc(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function nn(e,t,r,a,n,o){let i,s;if(n){i=[];for(let u of t)if(i.push(u),u.route.id===n){s=u;break}}else i=t,s=t[t.length-1];let l=ra(a||".",ta(i),le(e.pathname,r)||e.pathname,o==="path");if(a==null&&(l.search=e.search,l.hash=e.hash),(a==null||a===""||a===".")&&s){let u=Pn(l.search);if(s.route.index&&!u)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!s.route.index&&u){let d=new URLSearchParams(l.search),c=d.getAll("index");d.delete("index"),c.filter(h=>h).forEach(h=>d.append("index",h));let f=d.toString();l.search=f?`?${f}`:""}}return r!=="/"&&(l.pathname=Sc({basename:r,pathname:l.pathname})),me(l)}function ni(e,t,r){if(!r||!Nc(r))return{path:t};if(r.formMethod&&!cn(r.formMethod))return{path:t,error:se(405,{method:r.formMethod})};let a=()=>({path:t,error:se(400,{type:"invalid-body"})}),o=(r.formMethod||"get").toUpperCase(),i=ts(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!he(o))return a();let c=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((f,[h,m])=>`${f}${h}=${m} `,""):String(r.body);return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:void 0,text:c}}}else if(r.formEncType==="application/json"){if(!he(o))return a();try{let c=typeof r.body=="string"?JSON.parse(r.body):r.body;return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:c,text:void 0}}}catch{return a()}}}A(typeof FormData=="function","FormData is not available in this environment");let s,l;if(r.formData)s=ln(r.formData),l=r.formData;else if(r.body instanceof FormData)s=ln(r.body),l=r.body;else if(r.body instanceof URLSearchParams)s=r.body,l=fi(s);else if(r.body==null)s=new URLSearchParams,l=new FormData;else try{s=new URLSearchParams(r.body),l=fi(s)}catch{return a()}let u={formMethod:o,formAction:i,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:l,json:void 0,text:void 0};if(he(u.formMethod))return{path:t,submission:u};let d=_e(t);return e&&d.search&&Pn(d.search)&&s.append("index",""),d.search=`?${s}`,{path:me(d),submission:u}}function oi(e,t,r,a,n,o,i,s,l,u,d,c,f,h,m,v,p,R,w,x){let P=x?fe(x[1])?x[1].error:x[1].data:void 0,C=n.createURL(o.location),S=n.createURL(l),g;if(d&&o.errors){let Y=Object.keys(o.errors)[0];g=i.findIndex(q=>q.route.id===Y)}else if(x&&fe(x[1])){let Y=x[0];g=i.findIndex(q=>q.route.id===Y)-1}let T=x?x[1].statusCode:void 0,O=T&&T>=400,F={currentUrl:C,currentParams:o.matches[0]?.params||{},nextUrl:S,nextParams:i[0].params,...s,actionResult:P,actionStatus:T},H=$t(i.map(Y=>Y.route.path)),G=i.map((Y,q)=>{let{route:ye}=Y,X=null;if(g!=null&&q>g?X=!1:ye.lazy?X=!0:xn(ye)?d?X=on(ye,o.loaderData,o.errors):Ic(o.loaderData,o.matches[q],Y)&&(X=!0):X=!1,X!==null)return cr(r,a,e,H,Y,u,t,X);let Te=O?!1:c||C.pathname+C.search===S.pathname+S.search||C.search!==S.search||Hc(o.matches[q],Y),De={...F,defaultShouldRevalidate:Te},$e=Gr(Y,De);return cr(r,a,e,H,Y,u,t,$e,De)}),Z=[];return m.forEach((Y,q)=>{if(d||!i.some(Be=>Be.route.id===Y.routeId)||h.has(q))return;let ye=o.fetchers.get(q),X=ye&&ye.state!=="idle"&&ye.data===void 0,Te=we(p,Y.path,R);if(!Te){if(w&&X)return;Z.push({key:q,routeId:Y.routeId,path:Y.path,matches:null,match:null,request:null,controller:null});return}if(v.has(q))return;let De=jt(Te,Y.path),$e=new AbortController,Le=It(n,Y.path,$e.signal),Oe=null;if(f.has(q))f.delete(q),Oe=ht(r,a,Le,Te,De,u,t);else if(X)c&&(Oe=ht(r,a,Le,Te,De,u,t));else{let Be={...F,defaultShouldRevalidate:O?!1:c};Gr(De,Be)&&(Oe=ht(r,a,Le,Te,De,u,t,Be))}Oe&&Z.push({key:q,routeId:Y.routeId,path:Y.path,matches:Oe,match:De,request:Le,controller:$e})}),{dsMatches:G,revalidatingFetchers:Z}}function xn(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function on(e,t,r){if(e.lazy)return!0;if(!xn(e))return!1;let a=t!=null&&e.id in t,n=r!=null&&r[e.id]!==void 0;return!a&&n?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!a&&!n}function Ic(e,t,r){let a=!t||r.route.id!==t.route.id,n=!e.hasOwnProperty(r.route.id);return a||n}function Hc(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Gr(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function ii(e,t,r,a,n,o){let i;if(e){let u=a[e];A(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=r;let s=[],l=[];if(t.forEach(u=>{let d=i.find(c=>Vi(u,c));d?l.push({existingRoute:d,newRoute:u}):s.push(u)}),s.length>0){let u=at(s,n,[e||"_","patch",String(i?.length||"0")],a);i.push(...u)}if(o&&l.length>0)for(let u=0;u<l.length;u++){let{existingRoute:d,newRoute:c}=l[u],f=d,[h]=at([c],n,[],{},!0);Object.assign(f,{element:h.element?h.element:f.element,errorElement:h.errorElement?h.errorElement:f.errorElement,hydrateFallbackElement:h.hydrateFallbackElement?h.hydrateFallbackElement:f.hydrateFallbackElement})}}function Vi(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((r,a)=>t.children?.some(n=>Vi(r,n))):!1}function $c(e,t,r,a,n){let o=r[e.id];if(A(o,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let d=li.get(o);if(d)return{lazyRoutePromise:d,lazyHandlerPromise:d};let c=(async()=>{A(typeof e.lazy=="function","No lazy route function found");let f=await e.lazy(),h={};for(let m in f){let v=f[m];if(v===void 0)continue;let p=dc(m),w=o[m]!==void 0&&m!=="hasErrorBoundary";p?Q(!p,"Route property "+m+" is not a supported property to be returned from a lazy route function. This property will be ignored."):w?Q(!w,`Route "${o.id}" has a static property "${m}" defined but its lazy function is also returning a value for this property. The lazy route property "${m}" will be ignored.`):h[m]=v}Object.assign(o,h),Object.assign(o,{...a(o),lazy:void 0})})();return li.set(o,c),c.catch(()=>{}),{lazyRoutePromise:c,lazyHandlerPromise:c}}let i=Object.keys(e.lazy),s=[],l;for(let d of i){if(n&&n.includes(d))continue;let c=Cn({key:d,route:e,manifest:r,mapRouteProperties:a});c&&(s.push(c),d===t&&(l=c))}let u=s.length>0?Promise.all(s).then(()=>{}):void 0;return u?.catch(()=>{}),l?.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:l}}function Uc(e){return e!==void 0}function ui(e,t,r){let a=e.map(({route