@mcp-use/inspector 0.13.1-canary.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{browser-DzMnlhBk.js → browser-w6I2DwYe.js} +3 -3
- package/dist/client/assets/{display-A5IEINAP-CxJrDFxL.js → display-A5IEINAP-CR1mJNtZ.js} +2 -2
- package/dist/client/assets/{embeddings-Dhc0WFm_.js → embeddings-B8aKgKJK.js} +1 -1
- package/dist/client/assets/{index-DHishBTL.js → index-Bdi5EzVT.js} +1 -1
- package/dist/client/assets/{index-CyA4ELug.js → index-Bwxjf5mc.js} +1 -1
- package/dist/client/assets/{index-BDx3HgIR.js → index-CTPvdefa.js} +6 -6
- package/dist/client/assets/{index-1rKB6Ory.js → index-Ct4b1Obu.js} +1 -1
- package/dist/client/assets/{index-BxtpoonK.js → index-D364PFZX.js} +1 -1
- package/dist/client/assets/{index-Csl-S2aO.js → index-DGjFeGIT.js} +1 -1
- package/dist/client/assets/{index-B18K1oi4.js → index-Dnlk3cN0.js} +1 -1
- package/dist/client/assets/{index-B9h0wA_l.js → index-JNCLaBht.js} +1 -1
- package/dist/client/assets/{index-DFQl8vXM.js → index-tIZ5IdOV.js} +1 -1
- package/dist/client/assets/{llms-CAvL3UTt.js → llms-BLW_VGg4.js} +1 -1
- package/dist/client/assets/{path-CFPMDnJe.js → path-BvecqUiL.js} +1 -1
- package/dist/client/assets/{winston-C46EKxi0.js → winston-C17O0O46.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/display-A5IEINAP-
|
|
2
|
-
import{_ as A,g as Ml,c as Al,J as Pl,E as Ol,F as $i,T as Nl,G as m,M as Il,H as $l,I as Ri,a as Jt,K as Rl,L as Io,N as jl,o as we,s as Or,O as Ee,Z as Ur,j as Vr,e as Ll,n as Fl,d as Dl,P as Ul,Q as Vl,S as Bl,p as ji,U as Br,V as $o,k as Hn}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/display-A5IEINAP-CR1mJNtZ.js","assets/index-CTPvdefa.js","assets/index-DQ7i0BFM.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as A,g as Ml,c as Al,J as Pl,E as Ol,F as $i,T as Nl,G as m,M as Il,H as $l,I as Ri,a as Jt,K as Rl,L as Io,N as jl,o as we,s as Or,O as Ee,Z as Ur,j as Vr,e as Ll,n as Fl,d as Dl,P as Ul,Q as Vl,S as Bl,p as ji,U as Br,V as $o,k as Hn}from"./index-CTPvdefa.js";import{W as Jy,X as Yy,Y as Xy,a0 as Zy,a1 as Qy,a2 as ew,a2 as tw}from"./index-CTPvdefa.js";import{a as zr,r as zl}from"./fs-u42MReIY.js";import{a as Hl}from"./path-MNZaYwxc.js";import{r as Li,a as Fi}from"./path-BvecqUiL.js";import{D as Wn,S as Nr,t as Wl,a as Di,T as ql,b as Kl}from"./index-DGjFeGIT.js";import{h as Nn,s as Gl,k as Jl,I as Yl,C as Xl,g as Ui,d as Zl,l as Ql,m as eu,t as tu,n as nu,o as ru,p as su,q as ou,r as iu,u as au,v as cu,w as lu,x as uu,y as hu,R as du,z as fu,e as pu}from"./index-JNCLaBht.js";import{aT as mu,aU as Xs,aV as gu,aw as Oe,e as dn,aW as yu,aX as _n,a4 as fe,y as xe,aY as Vi,i as wu,aZ as vs,g as J,aj as an,ah as pe,B as N,S as Q,p as vu,C as _u,a_ as bu,aE as Bi,a$ as be,al as bn,b0 as gn,F as zi,z as je,b1 as Zs,u as Ro,D as _s,E as Yt,ap as Xt,b2 as Su,b3 as Cu,b4 as Eu,b5 as Tu,b6 as xu,b7 as ku,b8 as Mu,b9 as Au,ba as Pu,bb as Ou,bc as Nu,bd as Iu,be as $u,bf as Ru,bg as ju,bh as Lu,bi as Fu,L as Du,bj as Uu,bk as Vu,bl as Bu,A as Ve,k as yn,m as De,M as rt,at as Zt,bm as zu,H as Hu,aF as jo,au as Wu,bn as Lo,bo as Fo,af as Qs,ae as Do,ad as bs,ag as qu,V as Ku,a9 as eo,ac as Xe,bp as hr,o as z,bq as ce,br as Gu,bs as Ie,bt as xt,bu as Ju,bv as to,f as U,aa as Yu,r as Xu,T as Zu,bw as dr,bx as He,by as V,bz as Hi,s as ne,ab as Qu,bA as qn,bB as Wi,bC as Qt,bD as Sn,bE as fr,bF as pr,bG as eh,aP as th,aN as nh,aM as rh,bH as sh}from"./index-Dnlk3cN0.js";import{E as qi,c as oh,e as ih}from"./embeddings-B8aKgKJK.js";import{L as Ki,o as ah,l as ch}from"./llms-BLW_VGg4.js";import"./index-DRz5BQNA.js";var Hr,Ln,Wr=0,qr=0;function lh(t,e,n){var r=0,s=e||new Array(16);t=t||{};var o=t.node,i=t.clockseq;if(t._v6||(o||(o=Hr),i==null&&(i=Ln)),o==null||i==null){var a=t.random||(t.rng||mu)();o==null&&(o=[a[0],a[1],a[2],a[3],a[4],a[5]],!Hr&&!t._v6&&(o[0]|=1,Hr=o)),i==null&&(i=(a[6]<<8|a[7])&16383,Ln===void 0&&!t._v6&&(Ln=i))}var c=t.msecs!==void 0?t.msecs:Date.now(),l=t.nsecs!==void 0?t.nsecs:qr+1,u=c-Wr+(l-qr)/1e4;if(u<0&&t.clockseq===void 0&&(i=i+1&16383),(u<0||c>Wr)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Wr=c,qr=l,Ln=i,c+=122192928e5;var h=((c&268435455)*1e4+l)%4294967296;s[r++]=h>>>24&255,s[r++]=h>>>16&255,s[r++]=h>>>8&255,s[r++]=h&255;var d=c/4294967296*1e4&268435455;s[r++]=d>>>8&255,s[r++]=d&255,s[r++]=d>>>24&15|16,s[r++]=d>>>16&255,s[r++]=i>>>8|128,s[r++]=i&255;for(var f=0;f<6;++f)s[r+f]=o[f];return e||Xs(s)}function uh(t){var e=typeof t=="string"?gu(t):t,n=hh(e);return typeof t=="string"?Xs(n):n}function hh(t,e=!1){return Uint8Array.of((t[6]&15)<<4|t[7]>>4&15,(t[7]&15)<<4|(t[4]&240)>>4,(t[4]&15)<<4|(t[5]&240)>>4,(t[5]&15)<<4|(t[0]&240)>>4,(t[0]&15)<<4|(t[1]&240)>>4,(t[1]&15)<<4|(t[2]&240)>>4,96|t[2]&15,t[3],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}function Uo(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Vo(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Uo(Object(n),!0).forEach(function(r){dh(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Uo(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dh(t,e,n){return(e=fh(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fh(t){var e=ph(t,"string");return typeof e=="symbol"?e:e+""}function ph(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mh(t={},e,n=0){var r=lh(Vo(Vo({},t),{},{_v6:!0}),new Uint8Array(16));return r=uh(r),Xs(r)}async function*gh(t){for await(const e of t)if(e.event==="on_chat_model_stream"&&e.data?.chunk?.text){const n=e.data.chunk.text;typeof n=="string"&&n.length>0&&(yield n)}}A(gh,"streamEventsToAISDK");function yh(t){return new ReadableStream({async start(e){try{for await(const n of t)e.enqueue(n);e.close()}catch(n){e.error(n)}}})}A(yh,"createReadableStreamFromGenerator");async function*wh(t){for await(const e of t)switch(e.event){case"on_chat_model_stream":if(e.data?.chunk?.text){const n=e.data.chunk.text;typeof n=="string"&&n.length>0&&(yield n)}break;case"on_tool_start":yield`
|
|
3
3
|
🔧 Using tool: ${e.name}
|
|
4
4
|
`;break;case"on_tool_end":yield`
|
|
5
5
|
✅ Tool completed: ${e.name}
|
|
@@ -465,7 +465,7 @@ You can then use these server-specific tools in subsequent steps.
|
|
|
465
465
|
Here are the tools *currently* available to you (this list includes server management tools and will
|
|
466
466
|
change when you connect to a server):
|
|
467
467
|
{tool_descriptions}
|
|
468
|
-
`;function ur(t,e,n,r,s){if(typeof t=="object"&&t!==null){const o=t;return{query:o.prompt,maxSteps:o.maxSteps,manageConnector:o.manageConnector,externalHistory:o.externalHistory,outputSchema:o.schema}}return{query:t,maxSteps:e,manageConnector:n,externalHistory:r,outputSchema:s}}A(ur,"normalizeRunOptions");var Gt,qy=(Gt=class{static getPackageVersion(){return $i()}llm;client;connectors;maxSteps;autoInitialize;memoryEnabled;disallowedTools;additionalTools;toolsUsedNames=[];useServerManager;verbose;observe;systemPrompt;systemPromptTemplateOverride;additionalInstructions;_initialized=!1;conversationHistory=[];_agentExecutor=null;sessions={};systemMessage=null;_tools=[];adapter;serverManager=null;telemetry;modelProvider;modelName;observabilityManager;callbacks=[];metadata={};tags=[];isRemote=!1;remoteAgent=null;isSimplifiedMode=!1;llmString;llmConfig;mcpServersConfig;clientOwnedByAgent=!1;constructor(e){if(e.agentId){this.isRemote=!0,this.remoteAgent=new xy({agentId:e.agentId,apiKey:e.apiKey,baseUrl:e.baseUrl}),this.maxSteps=e.maxSteps??5,this.memoryEnabled=e.memoryEnabled??!0,this.autoInitialize=e.autoInitialize??!1,this.verbose=e.verbose??!1,this.observe=e.observe??!0,this.connectors=[],this.disallowedTools=[],this.additionalTools=[],this.useServerManager=!1,this.adapter=new vt,this.telemetry=Br.getInstance(),this.modelProvider="remote",this.modelName="remote-agent",this.observabilityManager=new Ni({customCallbacks:e.callbacks,agentId:e.agentId}),this.callbacks=[];return}if(!e.llm)throw new Error("llm is required for local execution. For remote execution, provide agentId instead.");if(typeof e.llm=="string"){if(this.isSimplifiedMode=!0,this.llmString=e.llm,this.llmConfig=e.llmConfig,this.mcpServersConfig=e.mcpServers,!this.mcpServersConfig||Object.keys(this.mcpServersConfig).length===0)throw new Error("Simplified mode requires 'mcpServers' configuration. Provide an object with server configurations, e.g., { filesystem: { command: 'npx', args: [...] } }");this.llm=void 0,this.client=void 0,this.clientOwnedByAgent=!0,this.connectors=[],m.info(`🎯 Simplified mode enabled: LLM will be created from '${this.llmString}'`)}else if(this.isSimplifiedMode=!1,this.llm=e.llm,this.client=e.client,this.connectors=e.connectors??[],this.clientOwnedByAgent=!1,!this.client&&this.connectors.length===0)throw new Error("Explicit mode requires either 'client' or at least one 'connector'. Alternatively, use simplified mode with 'llm' as a string and 'mcpServers' config.");if(this.maxSteps=e.maxSteps??5,this.autoInitialize=e.autoInitialize??!1,this.memoryEnabled=e.memoryEnabled??!0,this.systemPrompt=e.systemPrompt??null,this.systemPromptTemplateOverride=e.systemPromptTemplate??null,this.additionalInstructions=e.additionalInstructions??null,this.disallowedTools=e.disallowedTools??[],this.additionalTools=e.additionalTools??[],this.toolsUsedNames=e.toolsUsedNames??[],this.useServerManager=e.useServerManager??!1,this.verbose=e.verbose??!1,this.observe=e.observe??!0,this.isSimplifiedMode)this.adapter=e.adapter??new vt(this.disallowedTools),this.telemetry=Br.getInstance(),this.modelProvider="unknown",this.modelName="unknown";else{if(this.useServerManager){if(!this.client)throw new Error("'client' must be provided when 'useServerManager' is true.");this.adapter=e.adapter??new vt(this.disallowedTools),this.serverManager=e.serverManagerFactory?.(this.client)??new Oi(this.client,this.adapter)}else this.adapter=e.adapter??new vt(this.disallowedTools);if(this.telemetry=Br.getInstance(),this.llm){const[r,s]=$o(this.llm);this.modelProvider=r,this.modelName=s}else this.modelProvider="unknown",this.modelName="unknown"}this.observabilityManager=new Ni({customCallbacks:e.callbacks,verbose:this.verbose,observe:this.observe,agentId:e.agentId,metadataProvider:A(()=>this.getMetadata(),"metadataProvider"),tagsProvider:A(()=>this.getTags(),"tagsProvider")}),Object.defineProperty(this,"agentExecutor",{get:A(()=>this._agentExecutor,"get"),configurable:!0}),Object.defineProperty(this,"tools",{get:A(()=>this._tools,"get"),configurable:!0}),Object.defineProperty(this,"initialized",{get:A(()=>this._initialized,"get"),configurable:!0})}async initialize(){if(this.isRemote){this._initialized=!0;return}if(m.info("🚀 Initializing MCP agent and connecting to services..."),this.isSimplifiedMode){if(m.info("🎯 Simplified mode: Creating client and LLM from configuration..."),this.mcpServersConfig&&(m.info(`Creating MCPClient with ${Object.keys(this.mcpServersConfig).length} server(s)...`),this.client=new Zh({mcpServers:this.mcpServersConfig}),m.info("✅ MCPClient created successfully")),this.llmString){m.info(`Creating LLM from string: ${this.llmString}...`);try{this.llm=await El(this.llmString,this.llmConfig),m.info("✅ LLM created successfully");const[r,s]=$o(this.llm);this.modelProvider=r,this.modelName=s}catch(r){throw new Error(`Failed to create LLM from string '${this.llmString}': ${r?.message||r}`)}}if(this.useServerManager){if(!this.client)throw new Error("'client' must be available when 'useServerManager' is true.");this.serverManager=new Oi(this.client,this.adapter)}}this.callbacks=await this.observabilityManager.getCallbacks();const e=await this.observabilityManager.getHandlerNames();if(e.length>0&&m.info(`📊 Observability enabled with: ${e.join(", ")}`),this.useServerManager&&this.serverManager){await this.serverManager.initialize();const r=this.serverManager.tools;this._tools=r,this._tools.push(...this.additionalTools),m.info(`🔧 Server manager mode active with ${r.length} management tools`),await this.createSystemMessageFromTools(this._tools)}else{if(this.client){if(this.sessions=this.client.getAllActiveSessions(),m.info(`🔌 Found ${Object.keys(this.sessions).length} existing sessions`),Object.keys(this.sessions).filter(s=>s!=="code_mode").length===0&&(m.info("🔄 No active sessions found, creating new ones..."),this.sessions=await this.client.createAllSessions(),m.info(`✅ Created ${Object.keys(this.sessions).length} new sessions`)),this.client.codeMode){const s=this.sessions.code_mode;if(s)this._tools=await this.adapter.createToolsFromConnectors([s.connector]),m.info(`🛠️ Created ${this._tools.length} code mode tools`);else throw new Error("Code mode enabled but code_mode session not found")}else{const s=await this.adapter.createToolsFromConnectors(Object.values(this.sessions).map(a=>a.connector)),o=await this.adapter.createResourcesFromConnectors(Object.values(this.sessions).map(a=>a.connector)),i=await this.adapter.createPromptsFromConnectors(Object.values(this.sessions).map(a=>a.connector));this._tools=[...s,...o,...i],m.info(`🛠️ Created ${this._tools.length} LangChain items from client: ${s.length} tools, ${o.length} resources, ${i.length} prompts`)}this._tools.push(...this.additionalTools)}else{m.info(`🔗 Connecting to ${this.connectors.length} direct connectors...`);for(const i of this.connectors)i.isClientConnected||await i.connect();const r=await this.adapter.createToolsFromConnectors(this.connectors),s=await this.adapter.createResourcesFromConnectors(this.connectors),o=await this.adapter.createPromptsFromConnectors(this.connectors);this._tools=[...r,...s,...o],this._tools.push(...this.additionalTools),m.info(`🛠️ Created ${this._tools.length} LangChain items from connectors: ${r.length} tools, ${s.length} resources, ${o.length} prompts`)}m.info(`🧰 Found ${this._tools.length} tools across all connectors`),await this.createSystemMessageFromTools(this._tools)}this._agentExecutor=this.createAgent(),this._initialized=!0;const n=this.getMCPServerInfo();Object.keys(n).length>0&&(this.setMetadata(n),m.debug(`MCP server info added to metadata: ${JSON.stringify(n)}`)),m.info("✨ Agent initialization complete")}async createSystemMessageFromTools(e){const n=this.systemPromptTemplateOverride??Ay;this.systemMessage=kl(e,n,Py,this.useServerManager,this.disallowedTools,this.systemPrompt??void 0,this.additionalInstructions??void 0),this.memoryEnabled&&(this.conversationHistory=[this.systemMessage,...this.conversationHistory.filter(r=>!(r instanceof be))])}createAgent(){if(!this.llm)throw new Error("LLM is required to create agent");const e=this.systemMessage?.content??"You are a helpful assistant.",n=this._tools.map(o=>o.name);m.info(`🧠 Agent ready with tools: ${n.join(", ")}`);const r=[_l({runLimit:this.maxSteps})],s=ll({model:this.llm,tools:this._tools,systemPrompt:e,middleware:r});return m.debug(`Created agent with max_steps=${this.maxSteps} (via ModelCallLimitMiddleware) and ${this.callbacks.length} callbacks`),s}getConversationHistory(){return[...this.conversationHistory]}clearConversationHistory(){this.conversationHistory=this.memoryEnabled&&this.systemMessage?[this.systemMessage]:[]}addToHistory(e){this.memoryEnabled&&this.conversationHistory.push(e)}getSystemMessage(){return this.systemMessage}setSystemMessage(e){this.systemMessage=new be(e),this.memoryEnabled&&(this.conversationHistory=this.conversationHistory.filter(n=>!(n instanceof be)),this.conversationHistory.unshift(this.systemMessage)),this._initialized&&this._tools.length&&(this._agentExecutor=this.createAgent(),m.debug("Agent recreated with new system message"))}setDisallowedTools(e){this.disallowedTools=e,this.adapter=new vt(this.disallowedTools),this._initialized&&m.debug("Agent already initialized. Changes will take effect on next initialization.")}getDisallowedTools(){return this.disallowedTools}setMetadata(e){const n=this.sanitizeMetadata(e);this.metadata={...this.metadata,...n},m.debug(`Metadata set: ${JSON.stringify(this.metadata)}`)}getMetadata(){return{...this.metadata}}setTags(e){const n=this.sanitizeTags(e);this.tags=[...new Set([...this.tags,...n])],m.debug(`Tags set: ${JSON.stringify(this.tags)}`)}getTags(){return[...this.tags]}sanitizeMetadata(e){const n={};for(const[r,s]of Object.entries(e)){if(typeof r!="string"||r.length===0){m.warn(`Invalid metadata key: ${r}. Skipping.`);continue}const o=r.replace(/[^\w-]/g,"_");if(s==null)n[o]=s;else if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")n[o]=s;else if(Array.isArray(s)){const i=s.filter(a=>typeof a=="string"||typeof a=="number"||typeof a=="boolean");i.length>0&&(n[o]=i)}else if(typeof s=="object")try{const i=JSON.stringify(s);i.length>1e3?(m.warn(`Metadata value for key '${o}' is too large. Truncating.`),n[o]=`${i.substring(0,1e3)}...`):n[o]=s}catch(i){m.warn(`Failed to serialize metadata value for key '${o}': ${i}. Skipping.`)}else m.warn(`Unsupported metadata value type for key '${o}': ${typeof s}. Skipping.`)}return n}sanitizeTags(e){return e.filter(n=>typeof n=="string"&&n.length>0).map(n=>n.replace(/[^\w:-]/g,"_")).filter(n=>n.length<=50)}getMCPServerInfo(){const e={};try{if(this.client){const n=this.client.getServerNames();e.mcp_servers_count=n.length,e.mcp_server_names=n;const r={};for(const s of n)try{const o=this.client.getServerConfig(s);if(o){let i="unknown";o.command?i="command":o.url?i="http":o.ws_url&&(i="websocket"),r[s]={type:i,has_args:!!o.args,has_env:!!o.env,has_headers:!!o.headers,url:o.url||null,command:o.command||null}}}catch(o){m.warn(`Failed to get config for server '${s}': ${o}`),r[s]={type:"error",error:"config_unavailable"}}e.mcp_server_configs=r}else this.connectors&&this.connectors.length>0&&(e.mcp_servers_count=this.connectors.length,e.mcp_server_names=this.connectors.map(n=>n.publicIdentifier),e.mcp_server_types=this.connectors.map(n=>n.constructor.name))}catch(n){m.warn(`Failed to collect MCP server info: ${n}`),e.error="collection_failed"}return e}_normalizeOutput(e){try{if(typeof e=="string")return e;if(e&&typeof e=="object"&&"content"in e)return this._normalizeOutput(e.content);if(Array.isArray(e)){const n=[];for(const r of e)if(typeof r=="object"&&r!==null)"text"in r&&typeof r.text=="string"?n.push(r.text):"content"in r?n.push(this._normalizeOutput(r.content)):n.push(String(r));else{const s=r&&typeof r=="object"&&"text"in r?r.text:null;if(typeof s=="string")n.push(s);else{const o=r&&typeof r=="object"&&"content"in r?r.content:r;n.push(this._normalizeOutput(o))}}return n.join("")}return String(e)}catch{return String(e)}}_isAIMessageLike(e){if(e instanceof N)return!0;if(typeof e!="object"||e===null)return!1;const n=e;if(typeof n.getType=="function")try{const r=n.getType();if(r==="ai"||r==="assistant")return!0}catch{}if(typeof n._getType=="function")try{const r=n._getType();if(r==="ai"||r==="assistant")return!0}catch{}return"type"in n?n.type==="ai"||n.type==="assistant":"role"in n?n.role==="ai"||n.role==="assistant":!1}_messageHasToolCalls(e){return typeof e=="object"&&e!==null&&"tool_calls"in e&&Array.isArray(e.tool_calls)?e.tool_calls.length>0:!1}_isHumanMessageLike(e){if(e instanceof pe)return!0;if(typeof e!="object"||e===null)return!1;const n=e;if(typeof n.getType=="function")try{const r=n.getType();if(r==="human"||r==="user")return!0}catch{}return"type"in n&&(n.type==="human"||n.type==="user")||"role"in n&&(n.role==="human"||n.role==="user")}_isToolMessageLike(e){if(e instanceof U)return!0;if(typeof e!="object"||e===null)return!1;const n=e;if(typeof n.getType=="function")try{if(n.getType()==="tool")return!0}catch{}return"type"in n&&n.type==="tool"}_getMessageContent(e){if(e instanceof N||e&&typeof e=="object"&&"content"in e)return e.content}async _consumeAndReturn(e){for(;;){const{done:n,value:r}=await e.next();if(n)return r}}async run(e,n,r,s,o){const{query:i,maxSteps:a,manageConnector:c,externalHistory:l,outputSchema:u}=ur(e,n,r,s,o);if(this.isRemote&&this.remoteAgent)return this.remoteAgent.run(i,a,c,l,u);const h=this.stream(i,a,c,l,u);return this._consumeAndReturn(h)}async*stream(e,n,r=!0,s,o){const{query:i,maxSteps:a,manageConnector:c,externalHistory:l,outputSchema:u}=ur(e,n,r,s,o);if(this.isRemote&&this.remoteAgent)return await this.remoteAgent.run(i,a,c,l,u);let h=!1;const d=Date.now();let f=!1,g=null,p=0;try{if(c&&!this._initialized?(await this.initialize(),h=!0):!this._initialized&&this.autoInitialize&&(await this.initialize(),h=!0),!this._agentExecutor)throw new Error("MCP agent failed to initialize");if(this.useServerManager&&this.serverManager){const T=this.serverManager.tools,v=new Set(T.map(x=>x.name)),S=new Set(this._tools.map(x=>x.name));(v.size!==S.size||[...v].some(x=>!S.has(x)))&&(m.info(`🔄 Tools changed before execution, updating agent. New tools: ${[...v].join(", ")}`),this._tools=T,this._tools.push(...this.additionalTools),await this.createSystemMessageFromTools(this._tools),this._agentExecutor=this.createAgent())}const b=l??this.conversationHistory,C=[];for(const T of b)(this._isHumanMessageLike(T)||this._isAIMessageLike(T)||this._isToolMessageLike(T))&&C.push(T);const y=i.length>50?`${i.slice(0,50).replace(/\n/g," ")}...`:i.replace(/\n/g," ");m.info(`💬 Received query: '${y}'`),m.info("🏁 Starting agent execution");const _=3;let w=0;const E=[...C,new pe(i)];for(;w<=_;){const T={messages:E};let v=!1;const S=await this._agentExecutor.stream(T,{streamMode:"updates",callbacks:this.callbacks,metadata:this.getMetadata(),tags:this.getTags(),runName:this.metadata.trace_name||"mcp-use-agent",recursionLimit:this.maxSteps*3,...this.metadata.session_id&&{sessionId:this.metadata.session_id}});for await(const x of S){for(const[M,P]of Object.entries(x))if(m.debug(`📦 Node '${M}' output: ${JSON.stringify(P)}`),P&&typeof P=="object"&&"messages"in P){let I=P.messages;Array.isArray(I)||(I=[I]);for(const j of I)E.includes(j)||E.push(j);for(const j of I){if("tool_calls"in j&&Array.isArray(j.tool_calls)&&j.tool_calls.length>0)for(const ee of j.tool_calls){const re=ee.name||"unknown",Se=ee.args||{};this.toolsUsedNames.push(re),p++;let Me=JSON.stringify(Se);Me.length>100&&(Me=`${Me.slice(0,97)}...`),m.info(`🔧 Tool call: ${re} with input: ${Me}`),yield{action:{tool:re,toolInput:Se,log:`Calling tool ${re}`},observation:""}}if(this._isToolMessageLike(j)){const ee=j.content;let re=String(ee);if(re.length>100&&(re=`${re.slice(0,97)}...`),re=re.replace(/\n/g," "),m.info(`📄 Tool result: ${re}`),this.useServerManager&&this.serverManager){const Se=this.serverManager.tools,Me=new Set(Se.map(un=>un.name)),jn=new Set(this._tools.map(un=>un.name));if(Me.size!==jn.size||[...Me].some(un=>!jn.has(un))){m.info(`🔄 Tools changed during execution. New tools: ${[...Me].join(", ")}`),this._tools=Se,this._tools.push(...this.additionalTools),await this.createSystemMessageFromTools(this._tools),this._agentExecutor=this.createAgent(),v=!0,w++,m.info(`🔃 Restarting execution with updated tools (restart ${w}/${_})`);break}}}this._isAIMessageLike(j)&&!this._messageHasToolCalls(j)&&(g=this._normalizeOutput(this._getMessageContent(j)),m.info("✅ Agent finished with output"))}if(v)break}if(v)break}if(!v)break;if(w>_){m.warn(`⚠️ Max restarts (${_}) reached. Continuing with current tools.`);break}}if(this.memoryEnabled){const T=E.slice(C.length);for(const v of T)this.addToHistory(v)}if(u&&g)try{m.info("🔧 Attempting structured output...");const T=await this._attemptStructuredOutput(g,this.llm,u);return this.memoryEnabled&&this.addToHistory(new N(`Structured result: ${JSON.stringify(T)}`)),m.info("✅ Structured output successful"),f=!0,T}catch(T){throw m.error(`❌ Structured output failed: ${T}`),new Error(`Failed to generate structured output: ${T instanceof Error?T.message:String(T)}`)}return m.info(`🎉 Agent execution complete in ${((Date.now()-d)/1e3).toFixed(2)} seconds`),f=!0,g||"No output generated"}catch(b){throw m.error(`❌ Error running query: ${b}`),h&&c&&(m.info("🧹 Cleaning up resources after error"),await this.close()),b}finally{const b=Date.now()-d;let C=0;this.client?C=Object.keys(this.client.getAllActiveSessions()).length:this.connectors&&(C=this.connectors.length);const y=this.memoryEnabled?this.conversationHistory.length:0,_=this._tools||[];await this.telemetry.trackAgentExecution({executionMethod:"stream",query:i,success:f,modelProvider:this.modelProvider,modelName:this.modelName,serverCount:C,serverIdentifiers:this.connectors.map(w=>w.publicIdentifier),totalToolsAvailable:_.length,toolsAvailableNames:_.map(w=>w.name),maxStepsConfigured:this.maxSteps,memoryEnabled:this.memoryEnabled,useServerManager:this.useServerManager,maxStepsUsed:a??null,manageConnector:c??!0,externalHistoryUsed:l!==void 0,stepsTaken:p,toolsUsedCount:this.toolsUsedNames.length,toolsUsedNames:this.toolsUsedNames,response:g||"",executionTimeMs:b,errorType:f?null:"execution_error",conversationHistoryLength:y}),c&&!this.client&&h&&(m.info("🧹 Closing agent after stream completion"),await this.close())}}async flush(){this.isRemote&&this.remoteAgent||(m.debug("Flushing observability traces..."),await this.observabilityManager.flush())}async close(){if(this.isRemote&&this.remoteAgent){await this.remoteAgent.close();return}m.info("🔌 Closing MCPAgent resources…"),await this.observabilityManager.shutdown();try{if(this._agentExecutor=null,this._tools=[],this.client)this.clientOwnedByAgent?(m.info("🔄 Closing internally-created client (simplified mode) and cleaning up resources"),await this.client.close(),this.sessions={},this.client=void 0):(m.info("🔄 Closing client and cleaning up resources"),await this.client.close(),this.sessions={});else for(const e of this.connectors)m.info("🔄 Disconnecting connector"),await e.disconnect();this.isSimplifiedMode&&this.llm&&(m.debug("🔄 Clearing LLM reference (simplified mode)"),this.llm=void 0),"connectorToolMap"in this.adapter&&(this.adapter=new vt)}finally{this._initialized=!1,m.info("👋 Agent closed successfully")}}async*prettyStreamEvents(e,n,r=!0,s,o){const{prettyStreamEvents:i}=await Jt(async()=>{const{prettyStreamEvents:c}=await import("./display-A5IEINAP-CxJrDFxL.js");return{prettyStreamEvents:c}},__vite__mapDeps([0,1,2])),a="";for await(const c of i(this.streamEvents(e,n,r,s,o)))yield;return a}async*streamEvents(e,n,r=!0,s,o){const i=ur(e,n,r,s,o);let{query:a}=i;const{maxSteps:c,manageConnector:l,externalHistory:u,outputSchema:h}=i;let d=!1;const f=Date.now();let g=!1,p=0,b=0,C="";h&&(a=this._enhanceQueryWithSchema(a,h));try{l&&!this._initialized?(await this.initialize(),d=!0):!this._initialized&&this.autoInitialize&&(await this.initialize(),d=!0);const y=this._agentExecutor;if(!y)throw new Error("MCP agent failed to initialize");this.maxSteps=c??this.maxSteps;const _=typeof a=="string"&&a.length>50?`${a.slice(0,50).replace(/\n/g," ")}...`:typeof a=="string"?a.replace(/\n/g," "):String(a);m.info(`💬 Received query for streamEvents: '${_}'`),this.memoryEnabled&&(m.info(`🔄 Adding user message to history: ${_}`),this.addToHistory(new pe({content:a})));const w=u??this.conversationHistory,E=[];for(const S of w)this._isHumanMessageLike(S)||this._isAIMessageLike(S)||this._isToolMessageLike(S)?E.push(S):m.info(`⚠️ Skipped message of type: ${S.constructor?.name||typeof S}`);const T=[...E,new pe(a)];m.info("callbacks",this.callbacks);const v=y.streamEvents({messages:T},{streamMode:"messages",version:"v2",callbacks:this.callbacks,metadata:this.getMetadata(),tags:this.getTags(),runName:this.metadata.trace_name||"mcp-use-agent",recursionLimit:this.maxSteps*3,...this.metadata.session_id&&{sessionId:this.metadata.session_id}});for await(const S of v)if(p++,!(!S||typeof S!="object")){if(S.event==="on_chat_model_stream"&&S.data?.chunk?.content&&(b+=S.data.chunk.content.length),S.event==="on_chat_model_stream"&&S.data?.chunk){const x=S.data.chunk;if(x.content){C||(C="");const M=this._normalizeOutput(x.content);C+=M,m.debug(`📝 Accumulated response length: ${C.length}`)}}if(yield S,S.event==="on_chain_end"&&S.data?.output&&!C){const x=S.data.output;Array.isArray(x)&&x.length>0&&x[0]?.text?C=x[0].text:typeof x=="string"?C=x:x&&typeof x=="object"&&"output"in x&&(C=x.output)}}if(h&&C){m.info("🔧 Attempting structured output conversion...");try{let S=!1,x=null,M=null;this._attemptStructuredOutput(C,this.llm,h).then(I=>(S=!0,x=I,I)).catch(I=>{throw S=!0,M=I,I});let P=0;for(;!S;)await new Promise(I=>setTimeout(I,2e3)),S||(P++,yield{event:"on_structured_output_progress",data:{message:`Converting to structured output... (${P*2}s)`,elapsed:P*2}});if(M)throw M;x&&(yield{event:"on_structured_output",data:{output:x}},this.memoryEnabled&&this.addToHistory(new N(`Structured result: ${JSON.stringify(x)}`)),m.info("✅ Structured output successful"))}catch(S){m.warn(`⚠️ Structured output failed: ${S}`),yield{event:"on_structured_output_error",data:{error:S instanceof Error?S.message:String(S)}}}}else this.memoryEnabled&&C&&this.addToHistory(new N(C));console.log(`
|
|
468
|
+
`;function ur(t,e,n,r,s){if(typeof t=="object"&&t!==null){const o=t;return{query:o.prompt,maxSteps:o.maxSteps,manageConnector:o.manageConnector,externalHistory:o.externalHistory,outputSchema:o.schema}}return{query:t,maxSteps:e,manageConnector:n,externalHistory:r,outputSchema:s}}A(ur,"normalizeRunOptions");var Gt,qy=(Gt=class{static getPackageVersion(){return $i()}llm;client;connectors;maxSteps;autoInitialize;memoryEnabled;disallowedTools;additionalTools;toolsUsedNames=[];useServerManager;verbose;observe;systemPrompt;systemPromptTemplateOverride;additionalInstructions;_initialized=!1;conversationHistory=[];_agentExecutor=null;sessions={};systemMessage=null;_tools=[];adapter;serverManager=null;telemetry;modelProvider;modelName;observabilityManager;callbacks=[];metadata={};tags=[];isRemote=!1;remoteAgent=null;isSimplifiedMode=!1;llmString;llmConfig;mcpServersConfig;clientOwnedByAgent=!1;constructor(e){if(e.agentId){this.isRemote=!0,this.remoteAgent=new xy({agentId:e.agentId,apiKey:e.apiKey,baseUrl:e.baseUrl}),this.maxSteps=e.maxSteps??5,this.memoryEnabled=e.memoryEnabled??!0,this.autoInitialize=e.autoInitialize??!1,this.verbose=e.verbose??!1,this.observe=e.observe??!0,this.connectors=[],this.disallowedTools=[],this.additionalTools=[],this.useServerManager=!1,this.adapter=new vt,this.telemetry=Br.getInstance(),this.modelProvider="remote",this.modelName="remote-agent",this.observabilityManager=new Ni({customCallbacks:e.callbacks,agentId:e.agentId}),this.callbacks=[];return}if(!e.llm)throw new Error("llm is required for local execution. For remote execution, provide agentId instead.");if(typeof e.llm=="string"){if(this.isSimplifiedMode=!0,this.llmString=e.llm,this.llmConfig=e.llmConfig,this.mcpServersConfig=e.mcpServers,!this.mcpServersConfig||Object.keys(this.mcpServersConfig).length===0)throw new Error("Simplified mode requires 'mcpServers' configuration. Provide an object with server configurations, e.g., { filesystem: { command: 'npx', args: [...] } }");this.llm=void 0,this.client=void 0,this.clientOwnedByAgent=!0,this.connectors=[],m.info(`🎯 Simplified mode enabled: LLM will be created from '${this.llmString}'`)}else if(this.isSimplifiedMode=!1,this.llm=e.llm,this.client=e.client,this.connectors=e.connectors??[],this.clientOwnedByAgent=!1,!this.client&&this.connectors.length===0)throw new Error("Explicit mode requires either 'client' or at least one 'connector'. Alternatively, use simplified mode with 'llm' as a string and 'mcpServers' config.");if(this.maxSteps=e.maxSteps??5,this.autoInitialize=e.autoInitialize??!1,this.memoryEnabled=e.memoryEnabled??!0,this.systemPrompt=e.systemPrompt??null,this.systemPromptTemplateOverride=e.systemPromptTemplate??null,this.additionalInstructions=e.additionalInstructions??null,this.disallowedTools=e.disallowedTools??[],this.additionalTools=e.additionalTools??[],this.toolsUsedNames=e.toolsUsedNames??[],this.useServerManager=e.useServerManager??!1,this.verbose=e.verbose??!1,this.observe=e.observe??!0,this.isSimplifiedMode)this.adapter=e.adapter??new vt(this.disallowedTools),this.telemetry=Br.getInstance(),this.modelProvider="unknown",this.modelName="unknown";else{if(this.useServerManager){if(!this.client)throw new Error("'client' must be provided when 'useServerManager' is true.");this.adapter=e.adapter??new vt(this.disallowedTools),this.serverManager=e.serverManagerFactory?.(this.client)??new Oi(this.client,this.adapter)}else this.adapter=e.adapter??new vt(this.disallowedTools);if(this.telemetry=Br.getInstance(),this.llm){const[r,s]=$o(this.llm);this.modelProvider=r,this.modelName=s}else this.modelProvider="unknown",this.modelName="unknown"}this.observabilityManager=new Ni({customCallbacks:e.callbacks,verbose:this.verbose,observe:this.observe,agentId:e.agentId,metadataProvider:A(()=>this.getMetadata(),"metadataProvider"),tagsProvider:A(()=>this.getTags(),"tagsProvider")}),Object.defineProperty(this,"agentExecutor",{get:A(()=>this._agentExecutor,"get"),configurable:!0}),Object.defineProperty(this,"tools",{get:A(()=>this._tools,"get"),configurable:!0}),Object.defineProperty(this,"initialized",{get:A(()=>this._initialized,"get"),configurable:!0})}async initialize(){if(this.isRemote){this._initialized=!0;return}if(m.info("🚀 Initializing MCP agent and connecting to services..."),this.isSimplifiedMode){if(m.info("🎯 Simplified mode: Creating client and LLM from configuration..."),this.mcpServersConfig&&(m.info(`Creating MCPClient with ${Object.keys(this.mcpServersConfig).length} server(s)...`),this.client=new Zh({mcpServers:this.mcpServersConfig}),m.info("✅ MCPClient created successfully")),this.llmString){m.info(`Creating LLM from string: ${this.llmString}...`);try{this.llm=await El(this.llmString,this.llmConfig),m.info("✅ LLM created successfully");const[r,s]=$o(this.llm);this.modelProvider=r,this.modelName=s}catch(r){throw new Error(`Failed to create LLM from string '${this.llmString}': ${r?.message||r}`)}}if(this.useServerManager){if(!this.client)throw new Error("'client' must be available when 'useServerManager' is true.");this.serverManager=new Oi(this.client,this.adapter)}}this.callbacks=await this.observabilityManager.getCallbacks();const e=await this.observabilityManager.getHandlerNames();if(e.length>0&&m.info(`📊 Observability enabled with: ${e.join(", ")}`),this.useServerManager&&this.serverManager){await this.serverManager.initialize();const r=this.serverManager.tools;this._tools=r,this._tools.push(...this.additionalTools),m.info(`🔧 Server manager mode active with ${r.length} management tools`),await this.createSystemMessageFromTools(this._tools)}else{if(this.client){if(this.sessions=this.client.getAllActiveSessions(),m.info(`🔌 Found ${Object.keys(this.sessions).length} existing sessions`),Object.keys(this.sessions).filter(s=>s!=="code_mode").length===0&&(m.info("🔄 No active sessions found, creating new ones..."),this.sessions=await this.client.createAllSessions(),m.info(`✅ Created ${Object.keys(this.sessions).length} new sessions`)),this.client.codeMode){const s=this.sessions.code_mode;if(s)this._tools=await this.adapter.createToolsFromConnectors([s.connector]),m.info(`🛠️ Created ${this._tools.length} code mode tools`);else throw new Error("Code mode enabled but code_mode session not found")}else{const s=await this.adapter.createToolsFromConnectors(Object.values(this.sessions).map(a=>a.connector)),o=await this.adapter.createResourcesFromConnectors(Object.values(this.sessions).map(a=>a.connector)),i=await this.adapter.createPromptsFromConnectors(Object.values(this.sessions).map(a=>a.connector));this._tools=[...s,...o,...i],m.info(`🛠️ Created ${this._tools.length} LangChain items from client: ${s.length} tools, ${o.length} resources, ${i.length} prompts`)}this._tools.push(...this.additionalTools)}else{m.info(`🔗 Connecting to ${this.connectors.length} direct connectors...`);for(const i of this.connectors)i.isClientConnected||await i.connect();const r=await this.adapter.createToolsFromConnectors(this.connectors),s=await this.adapter.createResourcesFromConnectors(this.connectors),o=await this.adapter.createPromptsFromConnectors(this.connectors);this._tools=[...r,...s,...o],this._tools.push(...this.additionalTools),m.info(`🛠️ Created ${this._tools.length} LangChain items from connectors: ${r.length} tools, ${s.length} resources, ${o.length} prompts`)}m.info(`🧰 Found ${this._tools.length} tools across all connectors`),await this.createSystemMessageFromTools(this._tools)}this._agentExecutor=this.createAgent(),this._initialized=!0;const n=this.getMCPServerInfo();Object.keys(n).length>0&&(this.setMetadata(n),m.debug(`MCP server info added to metadata: ${JSON.stringify(n)}`)),m.info("✨ Agent initialization complete")}async createSystemMessageFromTools(e){const n=this.systemPromptTemplateOverride??Ay;this.systemMessage=kl(e,n,Py,this.useServerManager,this.disallowedTools,this.systemPrompt??void 0,this.additionalInstructions??void 0),this.memoryEnabled&&(this.conversationHistory=[this.systemMessage,...this.conversationHistory.filter(r=>!(r instanceof be))])}createAgent(){if(!this.llm)throw new Error("LLM is required to create agent");const e=this.systemMessage?.content??"You are a helpful assistant.",n=this._tools.map(o=>o.name);m.info(`🧠 Agent ready with tools: ${n.join(", ")}`);const r=[_l({runLimit:this.maxSteps})],s=ll({model:this.llm,tools:this._tools,systemPrompt:e,middleware:r});return m.debug(`Created agent with max_steps=${this.maxSteps} (via ModelCallLimitMiddleware) and ${this.callbacks.length} callbacks`),s}getConversationHistory(){return[...this.conversationHistory]}clearConversationHistory(){this.conversationHistory=this.memoryEnabled&&this.systemMessage?[this.systemMessage]:[]}addToHistory(e){this.memoryEnabled&&this.conversationHistory.push(e)}getSystemMessage(){return this.systemMessage}setSystemMessage(e){this.systemMessage=new be(e),this.memoryEnabled&&(this.conversationHistory=this.conversationHistory.filter(n=>!(n instanceof be)),this.conversationHistory.unshift(this.systemMessage)),this._initialized&&this._tools.length&&(this._agentExecutor=this.createAgent(),m.debug("Agent recreated with new system message"))}setDisallowedTools(e){this.disallowedTools=e,this.adapter=new vt(this.disallowedTools),this._initialized&&m.debug("Agent already initialized. Changes will take effect on next initialization.")}getDisallowedTools(){return this.disallowedTools}setMetadata(e){const n=this.sanitizeMetadata(e);this.metadata={...this.metadata,...n},m.debug(`Metadata set: ${JSON.stringify(this.metadata)}`)}getMetadata(){return{...this.metadata}}setTags(e){const n=this.sanitizeTags(e);this.tags=[...new Set([...this.tags,...n])],m.debug(`Tags set: ${JSON.stringify(this.tags)}`)}getTags(){return[...this.tags]}sanitizeMetadata(e){const n={};for(const[r,s]of Object.entries(e)){if(typeof r!="string"||r.length===0){m.warn(`Invalid metadata key: ${r}. Skipping.`);continue}const o=r.replace(/[^\w-]/g,"_");if(s==null)n[o]=s;else if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")n[o]=s;else if(Array.isArray(s)){const i=s.filter(a=>typeof a=="string"||typeof a=="number"||typeof a=="boolean");i.length>0&&(n[o]=i)}else if(typeof s=="object")try{const i=JSON.stringify(s);i.length>1e3?(m.warn(`Metadata value for key '${o}' is too large. Truncating.`),n[o]=`${i.substring(0,1e3)}...`):n[o]=s}catch(i){m.warn(`Failed to serialize metadata value for key '${o}': ${i}. Skipping.`)}else m.warn(`Unsupported metadata value type for key '${o}': ${typeof s}. Skipping.`)}return n}sanitizeTags(e){return e.filter(n=>typeof n=="string"&&n.length>0).map(n=>n.replace(/[^\w:-]/g,"_")).filter(n=>n.length<=50)}getMCPServerInfo(){const e={};try{if(this.client){const n=this.client.getServerNames();e.mcp_servers_count=n.length,e.mcp_server_names=n;const r={};for(const s of n)try{const o=this.client.getServerConfig(s);if(o){let i="unknown";o.command?i="command":o.url?i="http":o.ws_url&&(i="websocket"),r[s]={type:i,has_args:!!o.args,has_env:!!o.env,has_headers:!!o.headers,url:o.url||null,command:o.command||null}}}catch(o){m.warn(`Failed to get config for server '${s}': ${o}`),r[s]={type:"error",error:"config_unavailable"}}e.mcp_server_configs=r}else this.connectors&&this.connectors.length>0&&(e.mcp_servers_count=this.connectors.length,e.mcp_server_names=this.connectors.map(n=>n.publicIdentifier),e.mcp_server_types=this.connectors.map(n=>n.constructor.name))}catch(n){m.warn(`Failed to collect MCP server info: ${n}`),e.error="collection_failed"}return e}_normalizeOutput(e){try{if(typeof e=="string")return e;if(e&&typeof e=="object"&&"content"in e)return this._normalizeOutput(e.content);if(Array.isArray(e)){const n=[];for(const r of e)if(typeof r=="object"&&r!==null)"text"in r&&typeof r.text=="string"?n.push(r.text):"content"in r?n.push(this._normalizeOutput(r.content)):n.push(String(r));else{const s=r&&typeof r=="object"&&"text"in r?r.text:null;if(typeof s=="string")n.push(s);else{const o=r&&typeof r=="object"&&"content"in r?r.content:r;n.push(this._normalizeOutput(o))}}return n.join("")}return String(e)}catch{return String(e)}}_isAIMessageLike(e){if(e instanceof N)return!0;if(typeof e!="object"||e===null)return!1;const n=e;if(typeof n.getType=="function")try{const r=n.getType();if(r==="ai"||r==="assistant")return!0}catch{}if(typeof n._getType=="function")try{const r=n._getType();if(r==="ai"||r==="assistant")return!0}catch{}return"type"in n?n.type==="ai"||n.type==="assistant":"role"in n?n.role==="ai"||n.role==="assistant":!1}_messageHasToolCalls(e){return typeof e=="object"&&e!==null&&"tool_calls"in e&&Array.isArray(e.tool_calls)?e.tool_calls.length>0:!1}_isHumanMessageLike(e){if(e instanceof pe)return!0;if(typeof e!="object"||e===null)return!1;const n=e;if(typeof n.getType=="function")try{const r=n.getType();if(r==="human"||r==="user")return!0}catch{}return"type"in n&&(n.type==="human"||n.type==="user")||"role"in n&&(n.role==="human"||n.role==="user")}_isToolMessageLike(e){if(e instanceof U)return!0;if(typeof e!="object"||e===null)return!1;const n=e;if(typeof n.getType=="function")try{if(n.getType()==="tool")return!0}catch{}return"type"in n&&n.type==="tool"}_getMessageContent(e){if(e instanceof N||e&&typeof e=="object"&&"content"in e)return e.content}async _consumeAndReturn(e){for(;;){const{done:n,value:r}=await e.next();if(n)return r}}async run(e,n,r,s,o){const{query:i,maxSteps:a,manageConnector:c,externalHistory:l,outputSchema:u}=ur(e,n,r,s,o);if(this.isRemote&&this.remoteAgent)return this.remoteAgent.run(i,a,c,l,u);const h=this.stream(i,a,c,l,u);return this._consumeAndReturn(h)}async*stream(e,n,r=!0,s,o){const{query:i,maxSteps:a,manageConnector:c,externalHistory:l,outputSchema:u}=ur(e,n,r,s,o);if(this.isRemote&&this.remoteAgent)return await this.remoteAgent.run(i,a,c,l,u);let h=!1;const d=Date.now();let f=!1,g=null,p=0;try{if(c&&!this._initialized?(await this.initialize(),h=!0):!this._initialized&&this.autoInitialize&&(await this.initialize(),h=!0),!this._agentExecutor)throw new Error("MCP agent failed to initialize");if(this.useServerManager&&this.serverManager){const T=this.serverManager.tools,v=new Set(T.map(x=>x.name)),S=new Set(this._tools.map(x=>x.name));(v.size!==S.size||[...v].some(x=>!S.has(x)))&&(m.info(`🔄 Tools changed before execution, updating agent. New tools: ${[...v].join(", ")}`),this._tools=T,this._tools.push(...this.additionalTools),await this.createSystemMessageFromTools(this._tools),this._agentExecutor=this.createAgent())}const b=l??this.conversationHistory,C=[];for(const T of b)(this._isHumanMessageLike(T)||this._isAIMessageLike(T)||this._isToolMessageLike(T))&&C.push(T);const y=i.length>50?`${i.slice(0,50).replace(/\n/g," ")}...`:i.replace(/\n/g," ");m.info(`💬 Received query: '${y}'`),m.info("🏁 Starting agent execution");const _=3;let w=0;const E=[...C,new pe(i)];for(;w<=_;){const T={messages:E};let v=!1;const S=await this._agentExecutor.stream(T,{streamMode:"updates",callbacks:this.callbacks,metadata:this.getMetadata(),tags:this.getTags(),runName:this.metadata.trace_name||"mcp-use-agent",recursionLimit:this.maxSteps*3,...this.metadata.session_id&&{sessionId:this.metadata.session_id}});for await(const x of S){for(const[M,P]of Object.entries(x))if(m.debug(`📦 Node '${M}' output: ${JSON.stringify(P)}`),P&&typeof P=="object"&&"messages"in P){let I=P.messages;Array.isArray(I)||(I=[I]);for(const j of I)E.includes(j)||E.push(j);for(const j of I){if("tool_calls"in j&&Array.isArray(j.tool_calls)&&j.tool_calls.length>0)for(const ee of j.tool_calls){const re=ee.name||"unknown",Se=ee.args||{};this.toolsUsedNames.push(re),p++;let Me=JSON.stringify(Se);Me.length>100&&(Me=`${Me.slice(0,97)}...`),m.info(`🔧 Tool call: ${re} with input: ${Me}`),yield{action:{tool:re,toolInput:Se,log:`Calling tool ${re}`},observation:""}}if(this._isToolMessageLike(j)){const ee=j.content;let re=String(ee);if(re.length>100&&(re=`${re.slice(0,97)}...`),re=re.replace(/\n/g," "),m.info(`📄 Tool result: ${re}`),this.useServerManager&&this.serverManager){const Se=this.serverManager.tools,Me=new Set(Se.map(un=>un.name)),jn=new Set(this._tools.map(un=>un.name));if(Me.size!==jn.size||[...Me].some(un=>!jn.has(un))){m.info(`🔄 Tools changed during execution. New tools: ${[...Me].join(", ")}`),this._tools=Se,this._tools.push(...this.additionalTools),await this.createSystemMessageFromTools(this._tools),this._agentExecutor=this.createAgent(),v=!0,w++,m.info(`🔃 Restarting execution with updated tools (restart ${w}/${_})`);break}}}this._isAIMessageLike(j)&&!this._messageHasToolCalls(j)&&(g=this._normalizeOutput(this._getMessageContent(j)),m.info("✅ Agent finished with output"))}if(v)break}if(v)break}if(!v)break;if(w>_){m.warn(`⚠️ Max restarts (${_}) reached. Continuing with current tools.`);break}}if(this.memoryEnabled){const T=E.slice(C.length);for(const v of T)this.addToHistory(v)}if(u&&g)try{m.info("🔧 Attempting structured output...");const T=await this._attemptStructuredOutput(g,this.llm,u);return this.memoryEnabled&&this.addToHistory(new N(`Structured result: ${JSON.stringify(T)}`)),m.info("✅ Structured output successful"),f=!0,T}catch(T){throw m.error(`❌ Structured output failed: ${T}`),new Error(`Failed to generate structured output: ${T instanceof Error?T.message:String(T)}`)}return m.info(`🎉 Agent execution complete in ${((Date.now()-d)/1e3).toFixed(2)} seconds`),f=!0,g||"No output generated"}catch(b){throw m.error(`❌ Error running query: ${b}`),h&&c&&(m.info("🧹 Cleaning up resources after error"),await this.close()),b}finally{const b=Date.now()-d;let C=0;this.client?C=Object.keys(this.client.getAllActiveSessions()).length:this.connectors&&(C=this.connectors.length);const y=this.memoryEnabled?this.conversationHistory.length:0,_=this._tools||[];await this.telemetry.trackAgentExecution({executionMethod:"stream",query:i,success:f,modelProvider:this.modelProvider,modelName:this.modelName,serverCount:C,serverIdentifiers:this.connectors.map(w=>w.publicIdentifier),totalToolsAvailable:_.length,toolsAvailableNames:_.map(w=>w.name),maxStepsConfigured:this.maxSteps,memoryEnabled:this.memoryEnabled,useServerManager:this.useServerManager,maxStepsUsed:a??null,manageConnector:c??!0,externalHistoryUsed:l!==void 0,stepsTaken:p,toolsUsedCount:this.toolsUsedNames.length,toolsUsedNames:this.toolsUsedNames,response:g||"",executionTimeMs:b,errorType:f?null:"execution_error",conversationHistoryLength:y}),c&&!this.client&&h&&(m.info("🧹 Closing agent after stream completion"),await this.close())}}async flush(){this.isRemote&&this.remoteAgent||(m.debug("Flushing observability traces..."),await this.observabilityManager.flush())}async close(){if(this.isRemote&&this.remoteAgent){await this.remoteAgent.close();return}m.info("🔌 Closing MCPAgent resources…"),await this.observabilityManager.shutdown();try{if(this._agentExecutor=null,this._tools=[],this.client)this.clientOwnedByAgent?(m.info("🔄 Closing internally-created client (simplified mode) and cleaning up resources"),await this.client.close(),this.sessions={},this.client=void 0):(m.info("🔄 Closing client and cleaning up resources"),await this.client.close(),this.sessions={});else for(const e of this.connectors)m.info("🔄 Disconnecting connector"),await e.disconnect();this.isSimplifiedMode&&this.llm&&(m.debug("🔄 Clearing LLM reference (simplified mode)"),this.llm=void 0),"connectorToolMap"in this.adapter&&(this.adapter=new vt)}finally{this._initialized=!1,m.info("👋 Agent closed successfully")}}async*prettyStreamEvents(e,n,r=!0,s,o){const{prettyStreamEvents:i}=await Jt(async()=>{const{prettyStreamEvents:c}=await import("./display-A5IEINAP-CR1mJNtZ.js");return{prettyStreamEvents:c}},__vite__mapDeps([0,1,2])),a="";for await(const c of i(this.streamEvents(e,n,r,s,o)))yield;return a}async*streamEvents(e,n,r=!0,s,o){const i=ur(e,n,r,s,o);let{query:a}=i;const{maxSteps:c,manageConnector:l,externalHistory:u,outputSchema:h}=i;let d=!1;const f=Date.now();let g=!1,p=0,b=0,C="";h&&(a=this._enhanceQueryWithSchema(a,h));try{l&&!this._initialized?(await this.initialize(),d=!0):!this._initialized&&this.autoInitialize&&(await this.initialize(),d=!0);const y=this._agentExecutor;if(!y)throw new Error("MCP agent failed to initialize");this.maxSteps=c??this.maxSteps;const _=typeof a=="string"&&a.length>50?`${a.slice(0,50).replace(/\n/g," ")}...`:typeof a=="string"?a.replace(/\n/g," "):String(a);m.info(`💬 Received query for streamEvents: '${_}'`),this.memoryEnabled&&(m.info(`🔄 Adding user message to history: ${_}`),this.addToHistory(new pe({content:a})));const w=u??this.conversationHistory,E=[];for(const S of w)this._isHumanMessageLike(S)||this._isAIMessageLike(S)||this._isToolMessageLike(S)?E.push(S):m.info(`⚠️ Skipped message of type: ${S.constructor?.name||typeof S}`);const T=[...E,new pe(a)];m.info("callbacks",this.callbacks);const v=y.streamEvents({messages:T},{streamMode:"messages",version:"v2",callbacks:this.callbacks,metadata:this.getMetadata(),tags:this.getTags(),runName:this.metadata.trace_name||"mcp-use-agent",recursionLimit:this.maxSteps*3,...this.metadata.session_id&&{sessionId:this.metadata.session_id}});for await(const S of v)if(p++,!(!S||typeof S!="object")){if(S.event==="on_chat_model_stream"&&S.data?.chunk?.content&&(b+=S.data.chunk.content.length),S.event==="on_chat_model_stream"&&S.data?.chunk){const x=S.data.chunk;if(x.content){C||(C="");const M=this._normalizeOutput(x.content);C+=M,m.debug(`📝 Accumulated response length: ${C.length}`)}}if(yield S,S.event==="on_chain_end"&&S.data?.output&&!C){const x=S.data.output;Array.isArray(x)&&x.length>0&&x[0]?.text?C=x[0].text:typeof x=="string"?C=x:x&&typeof x=="object"&&"output"in x&&(C=x.output)}}if(h&&C){m.info("🔧 Attempting structured output conversion...");try{let S=!1,x=null,M=null;this._attemptStructuredOutput(C,this.llm,h).then(I=>(S=!0,x=I,I)).catch(I=>{throw S=!0,M=I,I});let P=0;for(;!S;)await new Promise(I=>setTimeout(I,2e3)),S||(P++,yield{event:"on_structured_output_progress",data:{message:`Converting to structured output... (${P*2}s)`,elapsed:P*2}});if(M)throw M;x&&(yield{event:"on_structured_output",data:{output:x}},this.memoryEnabled&&this.addToHistory(new N(`Structured result: ${JSON.stringify(x)}`)),m.info("✅ Structured output successful"))}catch(S){m.warn(`⚠️ Structured output failed: ${S}`),yield{event:"on_structured_output_error",data:{error:S instanceof Error?S.message:String(S)}}}}else this.memoryEnabled&&C&&this.addToHistory(new N(C));console.log(`
|
|
469
469
|
|
|
470
470
|
`),m.info(`🎉 StreamEvents complete - ${p} events emitted`),g=!0}catch(y){throw m.error(`❌ Error during streamEvents: ${y}`),d&&l&&(m.info("🧹 Cleaning up resources after initialization error in streamEvents"),await this.close()),y}finally{const y=Date.now()-f;let _=0;this.client?_=Object.keys(this.client.getAllActiveSessions()).length:this.connectors&&(_=this.connectors.length);const w=this.memoryEnabled?this.conversationHistory.length:0;await this.telemetry.trackAgentExecution({executionMethod:"streamEvents",query:a,success:g,modelProvider:this.modelProvider,modelName:this.modelName,serverCount:_,serverIdentifiers:this.connectors.map(E=>E.publicIdentifier),totalToolsAvailable:this._tools.length,toolsAvailableNames:this._tools.map(E=>E.name),maxStepsConfigured:this.maxSteps,memoryEnabled:this.memoryEnabled,useServerManager:this.useServerManager,maxStepsUsed:c??null,manageConnector:l??!0,externalHistoryUsed:u!==void 0,response:`[STREAMED RESPONSE - ${b} chars]`,executionTimeMs:y,errorType:g?null:"streaming_error",conversationHistoryLength:w}),l&&!this.client&&d&&(m.info("🧹 Closing agent after streamEvents completion"),await this.close())}}async _attemptStructuredOutput(e,n,r){m.info(`🔄 Attempting structured output with schema: ${JSON.stringify(r,null,2)}`),m.info(`🔄 Raw result: ${JSON.stringify(e,null,2)}`);let s=null,o="";if(m.debug(`🔄 Structured output requested, schema: ${JSON.stringify(Hn(r),null,2)}`),n&&"withStructuredOutput"in n&&typeof n.withStructuredOutput=="function")s=n.withStructuredOutput(r);else if(n)s=n;else throw new Error("LLM is required for structured output");const i=Hn(r),{$schema:a,additionalProperties:c,...l}=i;o=JSON.stringify(l,null,2),m.info(`🔄 Schema description: ${o}`);let u="";typeof e=="string"?u=e:e&&typeof e=="object"&&(u=JSON.stringify(e)),m.info("rawResult",e),u||(u=JSON.stringify(e));const h=3;let d="";for(let f=1;f<=h;f++){m.info(`🔄 Structured output attempt ${f}/${h}`);let g=`
|
|
471
471
|
Please format the following information according to the EXACT schema specified below.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{_ as a,a as k}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ct4b1Obu.js","assets/index-CTPvdefa.js","assets/index-DQ7i0BFM.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as a,a as k}from"./index-CTPvdefa.js";var y=null,L=null,O=null,J=!1,V=typeof process<"u"&&process.versions?.node;(async()=>{if(V)try{O=(await k(()=>import("./util-t-trnxQI.js").then(e=>e.u),[])).stripVTControlCharacters}catch{}try{y=(await k(()=>import("./index-JiKw9JSs.js"),[])).default}catch{}try{L=(await k(()=>import("./index-Ct4b1Obu.js").then(e=>e.i),__vite__mapDeps([0,1,2]))).highlight}catch{}V&&(!y||!L)&&(J||(J=!0,console.warn(`
|
|
3
3
|
✨ For enhanced console output with colors and syntax highlighting, install:
|
|
4
4
|
|
|
5
5
|
npm install chalk cli-highlight
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as c,q as d}from"./index-
|
|
1
|
+
import{g as c,q as d}from"./index-Dnlk3cN0.js";var l={};c(l,{chunkArray:()=>u});const u=(r,s)=>r.reduce((a,n,o)=>{const e=Math.floor(o/s),t=a[e]||[];return a[e]=t.concat([n]),a},[]);var h={};c(h,{Embeddings:()=>i});var i=class{caller;constructor(r){this.caller=new d(r??{})}};export{i as E,l as c,h as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,R as ce,b as Ai}from"./index-BDx3HgIR.js";var lt={exports:{}},Na;function $i(){if(Na)return lt.exports;Na=1;var e={decodeValues:!0,map:!1,silent:!1};function t(l){return typeof l!="string"||l in{}}function r(){return Object.create(null)}function a(l){return typeof l=="string"&&!!l.trim()}function n(l,u){var c=l.split(";").filter(a),d=c.shift(),m=o(d),p=m.name,f=m.value;if(u=u?Object.assign({},e,u):e,t(p))return null;try{f=u.decodeValues?decodeURIComponent(f):f}catch(y){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",y)}var g=r();return g.name=p,g.value=f,c.forEach(function(y){var w=y.split("="),R=w.shift().trimLeft().toLowerCase();if(!t(R)){var C=w.join("=");if(R==="expires")g.expires=new Date(C);else if(R==="max-age"){var P=parseInt(C,10);Number.isNaN(P)||(g.maxAge=P)}else R==="secure"?g.secure=!0:R==="httponly"?g.httpOnly=!0:R==="samesite"?g.sameSite=C:R==="partitioned"?g.partitioned=!0:R&&(g[R]=C)}}),g}function o(l){var u="",c="",d=l.split("=");return d.length>1?(u=d.shift(),c=d.join("=")):c=l,{name:u,value:c}}function i(l,u){if(u=u?Object.assign({},e,u):e,!l)return u.map?r():[];if(l.headers)if(typeof l.headers.getSetCookie=="function")l=l.headers.getSetCookie();else if(l.headers["set-cookie"])l=l.headers["set-cookie"];else{var c=l.headers[Object.keys(l.headers).find(function(m){return m.toLowerCase()==="set-cookie"})];!c&&l.headers.cookie&&!u.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),l=c}if(Array.isArray(l)||(l=[l]),u.map){var d=r();return l.filter(a).reduce(function(m,p){var f=n(p,u);return f&&!t(f.name)&&(m[f.name]=f),m},d)}else return l.filter(a).map(function(m){return n(m,u)}).filter(Boolean)}function s(l){if(Array.isArray(l))return l;if(typeof l!="string")return[];var u=[],c=0,d,m,p,f,g;function y(){for(;c<l.length&&/\s/.test(l.charAt(c));)c+=1;return c<l.length}function w(){return m=l.charAt(c),m!=="="&&m!==";"&&m!==","}for(;c<l.length;){for(d=c,g=!1;y();)if(m=l.charAt(c),m===","){for(p=c,c+=1,y(),f=c;c<l.length&&w();)c+=1;c<l.length&&l.charAt(c)==="="?(g=!0,c=f,u.push(l.substring(d,p)),d=c):c=p+1}else c+=1;(!g||c>=l.length)&&u.push(l.substring(d,l.length))}return u}return lt.exports=i,lt.exports.parse=i,lt.exports.parseString=n,lt.exports.splitCookiesString=s,lt.exports}var Ii=$i();var Cn=e=>{throw TypeError(e)},Hi=(e,t,r)=>t.has(e)||Cn("Cannot "+r),Er=(e,t,r)=>(Hi(e,t,"read from private field"),r?r.call(e):t.get(e)),ji=(e,t,r)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ui=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Ui||{}),Aa="popstate";function xn(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((p,f)=>c(p,typeof p=="string"?null:p.state,f===0?"default":void 0));let o=l(r??n.length-1),i="POP",s=null;function l(p){return Math.min(Math.max(p,0),n.length-1)}function u(){return n[o]}function c(p,f=null,g){let y=Ae(n?u().pathname:"/",p,f,g);return K(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function d(p){return typeof p=="string"?p:he(p)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:d,createURL(p){return new URL(d(p),"http://localhost")},encodeLocation(p){let f=typeof p=="string"?xe(p):p;return{pathname:f.pathname||"",search:f.search||"",hash:f.hash||""}},push(p,f){i="PUSH";let g=c(p,f);o+=1,n.splice(o,n.length,g),a&&s&&s({action:i,location:g,delta:1})},replace(p,f){i="REPLACE";let g=c(p,f);n[o]=g,a&&s&&s({action:i,location:g,delta:0})},go(p){i="POP";let f=l(o+p),g=n[f];o=f,s&&s({action:i,location:g,delta:p})},listen(p){return s=p,()=>{s=null}}}}function Pn(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return Ae("",{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:he(n)}return Dn(t,r,null,e)}function Ln(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=xe(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ae("",{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:he(o))}function a(n,o){K(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Dn(t,r,a,e)}function I(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function K(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function zi(){return Math.random().toString(36).substring(2,10)}function $a(e,t){return{usr:e.state,key:e.key,idx:t}}function Ae(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?xe(t):t,state:r,key:t&&t.key||a||zi()}}function he({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 xe(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 Dn(e,t,r,a={}){let{window:n=document.defaultView,v5Compat:o=!1}=a,i=n.history,s="POP",l=null,u=c();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function c(){return(i.state||{idx:null}).idx}function d(){s="POP";let y=c(),w=y==null?null:y-u;u=y,l&&l({action:s,location:g.location,delta:w})}function m(y,w){s="PUSH";let R=Ae(g.location,y,w);r&&r(R,y),u=c()+1;let C=$a(R,u),P=g.createHref(R);try{i.pushState(C,"",P)}catch(x){if(x instanceof DOMException&&x.name==="DataCloneError")throw x;n.location.assign(P)}o&&l&&l({action:s,location:g.location,delta:1})}function p(y,w){s="REPLACE";let R=Ae(g.location,y,w);r&&r(R,y),u=c();let C=$a(R,u),P=g.createHref(R);i.replaceState(C,"",P),o&&l&&l({action:s,location:g.location,delta:0})}function f(y){return Tn(y)}let g={get action(){return s},get location(){return e(n,i)},listen(y){if(l)throw new Error("A history only accepts one active listener");return n.addEventListener(Aa,d),l=y,()=>{n.removeEventListener(Aa,d),l=null}},createHref(y){return t(n,y)},createURL:f,encodeLocation(y){let w=f(y);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:m,replace:p,go(y){return i.go(y)}};return g}function Tn(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),I(r,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:he(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=r+a),new URL(a,r)}function cc(e){return{defaultValue:e}}var xt,Ne=class{constructor(e){if(ji(this,xt,new Map),e)for(let[t,r]of e)this.set(t,r)}get(e){if(Er(this,xt).has(e))return Er(this,xt).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Er(this,xt).set(e,t)}};xt=new WeakMap;var Bi=new Set(["lazy","caseSensitive","path","id","index","children"]);function Wi(e){return Bi.has(e)}var Vi=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Yi(e){return Vi.has(e)}function Ji(e){return e.index===!0}function We(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(I(o.index!==!0||!o.children,"Cannot specify children on an index route"),I(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),Ji(o)){let u={...o,id:l};return a[l]=Ia(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Ia(u,t(u)),o.children&&(u.children=We(o.children,t,s,a,n)),u}})}function Ia(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function ve(e,t,r="/"){return Pt(e,t,r,!1)}function Pt(e,t,r,a){let n=typeof t=="string"?xe(t):t,o=ne(n.pathname||"/",r);if(o==null)return null;let i=kn(e);Ki(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Mn(o);s=al(i[l],u,a)}return s}function _n(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 kn(e,t=[],r=[],a="",n=!1){let o=(i,s,l=n,u)=>{let c={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(c.relativePath.startsWith("/")){if(!c.relativePath.startsWith(a)&&l)return;I(c.relativePath.startsWith(a),`Absolute route path "${c.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(a.length)}let d=_e([a,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(I(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),kn(i.children,t,m,d,l)),!(i.path==null&&!i.index)&&t.push({path:d,score:tl(d,i.index),routesMeta:m})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of On(i.path))o(i,s,!0,l)}),t}function On(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=On(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 Ki(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:rl(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}var Xi=/^:[\w-]+$/,Gi=3,Qi=2,Zi=1,qi=10,el=-2,Ha=e=>e==="*";function tl(e,t){let r=e.split("/"),a=r.length;return r.some(Ha)&&(a+=el),t&&(a+=Qi),r.filter(n=>!Ha(n)).reduce((n,o)=>n+(Xi.test(o)?Gi:o===""?Zi:qi),a)}function rl(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 al(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,c=o==="/"?t:t.slice(o.length)||"/",d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},c),m=l.route;if(!d&&u&&r&&!a[a.length-1].route.index&&(d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},c)),!d)return null;Object.assign(n,d.params),i.push({params:n,pathname:_e([o,d.pathname]),pathnameBase:ll(_e([o,d.pathnameBase])),route:m}),d.pathnameBase!=="/"&&(o=_e([o,d.pathnameBase]))}return i}function dc(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(K(!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(/\*$/,"/*"));const 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["*"]);const c=i.match(/^:([\w-]+)(\??)$/);if(c){const[,d,m]=c;let p=t[d];return I(m==="?"||p!=null,`Missing ":${d}" param`),encodeURIComponent(n(p))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function Lt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=Fn(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:c,isOptional:d},m)=>{if(c==="*"){let f=s[m]||"";i=o.slice(0,o.length-f.length).replace(/(.)\/+$/,"$1")}const p=s[m];return d&&!p?u[c]=void 0:u[c]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Fn(e,t=!1,r=!0){K(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 Mn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return K(!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 ne(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 nl({basename:e,pathname:t}){return t==="/"?e:_e([e,t])}var ol=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nr=e=>ol.test(e);function il(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?xe(e):e,o;if(r)if(nr(r))o=r;else{if(r.includes("//")){let i=r;r=r.replace(/\/\/+/g,"/"),K(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${r}`)}r.startsWith("/")?o=ja(r.substring(1),"/"):o=ja(r,t)}else o=t;return{pathname:o,search:sl(a),hash:ul(n)}}function ja(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 br(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 Nn(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function or(e){let t=Nn(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function ir(e,t,r,a=!1){let n;typeof e=="string"?n=xe(e):(n={...e},I(!n.pathname||!n.pathname.includes("?"),br("?","pathname","search",n)),I(!n.pathname||!n.pathname.includes("#"),br("#","pathname","hash",n)),I(!n.search||!n.search.includes("#"),br("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let d=t.length-1;if(!a&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),d-=1;n.pathname=m.join("/")}s=d>=0?t[d]:"/"}let l=il(n,s),u=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}var _e=e=>e.join("/").replace(/\/\/+/g,"/"),ll=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),sl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ul=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cl=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function dl(e,t){return new cl(e,typeof t=="number"?{status:t}:t)}var lr=(e,t=302)=>{let r=t;typeof r=="number"?r={status:r}:typeof r.status>"u"&&(r.status=302);let a=new Headers(r.headers);return a.set("Location",e),new Response(null,{...r,headers:a})},fl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},hl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Replace","true"),r},me=class{constructor(e,t,r,a=!1){this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function re(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ct(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var je=Symbol("Uninstrumented");function An(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=tt(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=tt(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[je]??o,s=tt(r[n],i,(...l)=>Ua(l[0]));s&&(s[je]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[je]??n,i=tt(r.middleware,o,(...s)=>Ua(s[0]));return i?(i[je]=o,i):n})),a}function ml(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[je]??e.navigate,n=tt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?he(i):".",...za(e,s??{})}});n&&(n[je]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[je]??e.fetch,n=tt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...za(e,l??{})}});n&&(n[je]=a,e.fetch=n)}return e}function pl(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=tt(r.request,e,(...n)=>{let[o,i]=n;return{request:In(o),context:i!=null?Hn(i):i}})),a}function tt(e,t,r){return e.length===0?null:async(...a)=>{let n=await $n(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function $n(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=$n(e,t,r,a-1),o=await i,I(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 Ua(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:In(t),params:{...a},unstable_pattern:n,context:Hn(r)}}function za(e,t){return{currentUrl:he(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 In(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function Hn(e){if(vl(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var yl=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function vl(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===yl}var jn=["POST","PUT","PATCH","DELETE"],gl=new Set(jn),wl=["GET",...jn],Rl=new Set(wl),Un=new Set([301,302,303,307,308]),El=new Set([307,308]),Yt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Kr={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},et={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},zn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Bn="remix-router-transitions",Wn=Symbol("ResetLoaderData");function Xr(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";I(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||zn,o=n;if(e.unstable_instrumentations){let v=e.unstable_instrumentations;o=b=>({...n(b),...An(v.map(S=>S.route).filter(Boolean),b)})}let i={},s=We(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let c=e.dataStrategy||Ll,d={...e.future},m=null,p=new Set,f=null,g=null,y=null,w=e.hydrationData!=null,R=ve(s,e.history.location,u),C=!1,P=null,x;if(R==null&&!e.patchRoutesOnNavigation){let v=te(404,{pathname:e.history.location.pathname}),{matches:b,route:S}=ut(s);x=!0,R=b,P={[S.id]:v}}else if(R&&!e.hydrationData&&At(R,s,e.history.location.pathname).active&&(R=null),R)if(R.some(v=>v.route.lazy))x=!1;else if(!R.some(v=>Gr(v.route)))x=!0;else{let v=e.hydrationData?e.hydrationData.loaderData:null,b=e.hydrationData?e.hydrationData.errors:null;if(b){let S=R.findIndex(D=>b[D.route.id]!==void 0);x=R.slice(0,S+1).every(D=>!Or(D.route,v,b))}else x=R.every(S=>!Or(S.route,v,b))}else{x=!1,R=[];let v=At(null,s,e.history.location.pathname);v.active&&v.matches&&(C=!0,R=v.matches)}let L,E={historyAction:e.history.action,location:e.history.location,matches:R,initialized:x,navigation:Yt,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},O="POP",_=!1,k,M=!1,V=new Map,X=null,z=!1,J=!1,le=new Set,Y=new Map,Ee=0,pe=-1,Pe=new Map,ye=new Set,be=new Map,Le=new Map,De=new Set,Je=new Map,Mt,gt=null;function gi(){if(m=e.history.listen(({action:v,location:b,delta:S})=>{if(Mt){Mt(),Mt=void 0;return}K(Je.size===0||S!=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=_a({currentLocation:E.location,nextLocation:b,historyAction:v});if(D&&S!=null){let T=new Promise(N=>{Mt=N});e.history.go(S*-1),Nt(D,{state:"blocked",location:b,proceed(){Nt(D,{state:"proceeding",proceed:void 0,reset:void 0,location:b}),T.then(()=>e.history.go(S))},reset(){let N=new Map(E.blockers);N.set(D,et),se({blockers:N})}});return}return Ke(v,b)}),r){Ml(t,V);let v=()=>Nl(t,V);t.addEventListener("pagehide",v),X=()=>t.removeEventListener("pagehide",v)}return E.initialized||Ke("POP",E.location,{initialHydration:!0}),L}function wi(){m&&m(),X&&X(),p.clear(),k&&k.abort(),E.fetchers.forEach((v,b)=>gr(b)),E.blockers.forEach((v,b)=>Ta(b))}function Ri(v){return p.add(v),()=>p.delete(v)}function se(v,b={}){v.matches&&(v.matches=v.matches.map(T=>{let N=i[T.route.id],A=T.route;return A.element!==N.element||A.errorElement!==N.errorElement||A.hydrateFallbackElement!==N.hydrateFallbackElement?{...T,route:N}:T})),E={...E,...v};let S=[],D=[];E.fetchers.forEach((T,N)=>{T.state==="idle"&&(De.has(N)?S.push(N):D.push(N))}),De.forEach(T=>{!E.fetchers.has(T)&&!Y.has(T)&&S.push(T)}),[...p].forEach(T=>T(E,{deletedFetchers:S,viewTransitionOpts:b.viewTransitionOpts,flushSync:b.flushSync===!0})),S.forEach(T=>gr(T)),D.forEach(T=>E.fetchers.delete(T))}function ot(v,b,{flushSync:S}={}){let D=E.actionData!=null&&E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&E.navigation.state==="loading"&&v.state?._isRedirect!==!0,T;b.actionData?Object.keys(b.actionData).length>0?T=b.actionData:T=null:D?T=E.actionData:T=null;let N=b.loaderData?en(E.loaderData,b.loaderData,b.matches||[],b.errors):E.loaderData,A=E.blockers;A.size>0&&(A=new Map(A),A.forEach((H,j)=>A.set(j,et)));let F=z?!1:Oa(v,b.matches||E.matches),$=_===!0||E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&v.state?._isRedirect!==!0;l&&(s=l,l=void 0),z||O==="POP"||(O==="PUSH"?e.history.push(v,v.state):O==="REPLACE"&&e.history.replace(v,v.state));let U;if(O==="POP"){let H=V.get(E.location.pathname);H&&H.has(v.pathname)?U={currentLocation:E.location,nextLocation:v}:V.has(v.pathname)&&(U={currentLocation:v,nextLocation:E.location})}else if(M){let H=V.get(E.location.pathname);H?H.add(v.pathname):(H=new Set([v.pathname]),V.set(E.location.pathname,H)),U={currentLocation:E.location,nextLocation:v}}se({...b,actionData:T,loaderData:N,historyAction:O,location:v,initialized:!0,navigation:Yt,revalidation:"idle",restoreScrollPosition:F,preventScrollReset:$,blockers:A},{viewTransitionOpts:U,flushSync:S===!0}),O="POP",_=!1,M=!1,z=!1,J=!1,gt?.resolve(),gt=null}async function ba(v,b){if(typeof v=="number"){e.history.go(v);return}let S=kr(E.location,E.matches,u,v,b?.fromRouteId,b?.relative),{path:D,submission:T,error:N}=Wa(!1,S,b),A=E.location,F=Ae(E.location,D,b&&b.state);F={...F,...e.history.encodeLocation(F)};let $=b&&b.replace!=null?b.replace:void 0,U="PUSH";$===!0?U="REPLACE":$===!1||T!=null&&de(T.formMethod)&&T.formAction===E.location.pathname+E.location.search&&(U="REPLACE");let H=b&&"preventScrollReset"in b?b.preventScrollReset===!0:void 0,j=(b&&b.flushSync)===!0,B=_a({currentLocation:A,nextLocation:F,historyAction:U});if(B){Nt(B,{state:"blocked",location:F,proceed(){Nt(B,{state:"proceeding",proceed:void 0,reset:void 0,location:F}),ba(v,b)},reset(){let Z=new Map(E.blockers);Z.set(B,et),se({blockers:Z})}});return}await Ke(U,F,{submission:T,pendingError:N,preventScrollReset:H,replace:b&&b.replace,enableViewTransition:b&&b.viewTransition,flushSync:j})}function Ei(){gt||(gt=Al()),vr(),se({revalidation:"loading"});let v=gt.promise;return E.navigation.state==="submitting"?v:E.navigation.state==="idle"?(Ke(E.historyAction,E.location,{startUninterruptedRevalidation:!0}),v):(Ke(O||E.historyAction,E.navigation.location,{overrideNavigation:E.navigation,enableViewTransition:M===!0}),v)}async function Ke(v,b,S){k&&k.abort(),k=null,O=v,z=(S&&S.startUninterruptedRevalidation)===!0,Oi(E.location,E.matches),_=(S&&S.preventScrollReset)===!0,M=(S&&S.enableViewTransition)===!0;let D=l||s,T=S&&S.overrideNavigation,N=S?.initialHydration&&E.matches&&E.matches.length>0&&!C?E.matches:ve(D,b,u),A=(S&&S.flushSync)===!0;if(N&&E.initialized&&!J&&Tl(E.location,b)&&!(S&&S.submission&&de(S.submission.formMethod))){ot(b,{matches:N},{flushSync:A});return}let F=At(N,D,b.pathname);if(F.active&&F.matches&&(N=F.matches),!N){let{error:oe,notFoundMatches:G,route:Q}=wr(b.pathname);ot(b,{matches:G,loaderData:{},errors:{[Q.id]:oe}},{flushSync:A});return}k=new AbortController;let $=st(e.history,b,k.signal,S&&S.submission),U=e.getContext?await e.getContext():new Ne,H;if(S&&S.pendingError)H=[Ce(N).route.id,{type:"error",error:S.pendingError}];else if(S&&S.submission&&de(S.submission.formMethod)){let oe=await bi($,b,S.submission,N,U,F.active,S&&S.initialHydration===!0,{replace:S.replace,flushSync:A});if(oe.shortCircuited)return;if(oe.pendingActionResult){let[G,Q]=oe.pendingActionResult;if(ie(Q)&&re(Q.error)&&Q.error.status===404){k=null,ot(b,{matches:oe.matches,loaderData:{},errors:{[G]:Q.error}});return}}N=oe.matches||N,H=oe.pendingActionResult,T=Sr(b,S.submission),A=!1,F.active=!1,$=st(e.history,$.url,$.signal)}let{shortCircuited:j,matches:B,loaderData:Z,errors:ae}=await Si($,b,N,U,F.active,T,S&&S.submission,S&&S.fetcherSubmission,S&&S.replace,S&&S.initialHydration===!0,A,H);j||(k=null,ot(b,{matches:B||N,...tn(H),loaderData:Z,errors:ae}))}async function bi(v,b,S,D,T,N,A,F={}){vr();let $=Ol(b,S);if(se({navigation:$},{flushSync:F.flushSync===!0}),N){let j=await $t(D,b.pathname,v.signal);if(j.type==="aborted")return{shortCircuited:!0};if(j.type==="error"){if(j.partialMatches.length===0){let{matches:Z,route:ae}=ut(s);return{matches:Z,pendingActionResult:[ae.id,{type:"error",error:j.error}]}}let B=Ce(j.partialMatches).route.id;return{matches:j.partialMatches,pendingActionResult:[B,{type:"error",error:j.error}]}}else if(j.matches)D=j.matches;else{let{notFoundMatches:B,error:Z,route:ae}=wr(b.pathname);return{matches:B,pendingActionResult:[ae.id,{type:"error",error:Z}]}}}let U,H=dt(D,b);if(!H.route.action&&!H.route.lazy)U={type:"error",error:te(405,{method:v.method,pathname:b.pathname,routeId:H.route.id})};else{let j=ze(o,i,v,D,H,A?[]:a,T),B=await wt(v,j,T,null);if(U=B[H.route.id],!U){for(let Z of D)if(B[Z.route.id]){U=B[Z.route.id];break}}if(v.signal.aborted)return{shortCircuited:!0}}if(Ue(U)){let j;return F&&F.replace!=null?j=F.replace:j=Qa(U.response.headers.get("Location"),new URL(v.url),u)===E.location.pathname+E.location.search,await Xe(v,U,!0,{submission:S,replace:j}),{shortCircuited:!0}}if(ie(U)){let j=Ce(D,H.route.id);return(F&&F.replace)!==!0&&(O="PUSH"),{matches:D,pendingActionResult:[j.route.id,U,H.route.id]}}return{matches:D,pendingActionResult:[H.route.id,U]}}async function Si(v,b,S,D,T,N,A,F,$,U,H,j){let B=N||Sr(b,A),Z=A||F||rn(B),ae=!z&&!U;if(T){if(ae){let ue=Sa(j);se({navigation:B,...ue!==void 0?{actionData:ue}:{}},{flushSync:H})}let W=await $t(S,b.pathname,v.signal);if(W.type==="aborted")return{shortCircuited:!0};if(W.type==="error"){if(W.partialMatches.length===0){let{matches:it,route:Ze}=ut(s);return{matches:it,loaderData:{},errors:{[Ze.id]:W.error}}}let ue=Ce(W.partialMatches).route.id;return{matches:W.partialMatches,loaderData:{},errors:{[ue]:W.error}}}else if(W.matches)S=W.matches;else{let{error:ue,notFoundMatches:it,route:Ze}=wr(b.pathname);return{matches:it,loaderData:{},errors:{[Ze.id]:ue}}}}let oe=l||s,{dsMatches:G,revalidatingFetchers:Q}=Va(v,D,o,i,e.history,E,S,Z,b,U?[]:a,U===!0,J,le,De,be,ye,oe,u,e.patchRoutesOnNavigation!=null,j);if(pe=++Ee,!e.dataStrategy&&!G.some(W=>W.shouldLoad)&&!G.some(W=>W.route.middleware&&W.route.middleware.length>0)&&Q.length===0){let W=La();return ot(b,{matches:S,loaderData:{},errors:j&&ie(j[1])?{[j[0]]:j[1].error}:null,...tn(j),...W?{fetchers:new Map(E.fetchers)}:{}},{flushSync:H}),{shortCircuited:!0}}if(ae){let W={};if(!T){W.navigation=B;let ue=Sa(j);ue!==void 0&&(W.actionData=ue)}Q.length>0&&(W.fetchers=Ci(Q)),se(W,{flushSync:H})}Q.forEach(W=>{Fe(W.key),W.controller&&Y.set(W.key,W.controller)});let Ge=()=>Q.forEach(W=>Fe(W.key));k&&k.signal.addEventListener("abort",Ge);let{loaderResults:Rt,fetcherResults:He}=await Ca(G,Q,v,D);if(v.signal.aborted)return{shortCircuited:!0};k&&k.signal.removeEventListener("abort",Ge),Q.forEach(W=>Y.delete(W.key));let Te=Ut(Rt);if(Te)return await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};if(Te=Ut(He),Te)return ye.add(Te.key),await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};let{loaderData:Rr,errors:Et}=qa(E,S,Rt,j,Q,He);U&&E.errors&&(Et={...E.errors,...Et});let Qe=La(),It=Da(pe),Ht=Qe||It||Q.length>0;return{matches:S,loaderData:Rr,errors:Et,...Ht?{fetchers:new Map(E.fetchers)}:{}}}function Sa(v){if(v&&!ie(v[1]))return{[v[0]]:v[1].data};if(E.actionData)return Object.keys(E.actionData).length===0?null:E.actionData}function Ci(v){return v.forEach(b=>{let S=E.fetchers.get(b.key),D=bt(void 0,S?S.data:void 0);E.fetchers.set(b.key,D)}),new Map(E.fetchers)}async function xi(v,b,S,D){Fe(v);let T=(D&&D.flushSync)===!0,N=l||s,A=kr(E.location,E.matches,u,S,b,D?.relative),F=ve(N,A,u),$=At(F,N,A);if($.active&&$.matches&&(F=$.matches),!F){Oe(v,b,te(404,{pathname:A}),{flushSync:T});return}let{path:U,submission:H,error:j}=Wa(!0,A,D);if(j){Oe(v,b,j,{flushSync:T});return}let B=e.getContext?await e.getContext():new Ne,Z=(D&&D.preventScrollReset)===!0;if(H&&de(H.formMethod)){await Pi(v,b,U,F,B,$.active,T,Z,H);return}be.set(v,{routeId:b,path:U}),await Li(v,b,U,F,B,$.active,T,Z,H)}async function Pi(v,b,S,D,T,N,A,F,$){vr(),be.delete(v);let U=E.fetchers.get(v);ke(v,Fl($,U),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal,$);if(N){let ee=await $t(D,new URL(j.url).pathname,j.signal,v);if(ee.type==="aborted")return;if(ee.type==="error"){Oe(v,b,ee.error,{flushSync:A});return}else if(ee.matches)D=ee.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);if(!B.route.action&&!B.route.lazy){let ee=te(405,{method:$.formMethod,pathname:S,routeId:b});Oe(v,b,ee,{flushSync:A});return}Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),oe=await wt(j,ae,T,v),G=oe[B.route.id];if(!G){for(let ee of ae)if(oe[ee.route.id]){G=oe[ee.route.id];break}}if(j.signal.aborted){Y.get(v)===H&&Y.delete(v);return}if(De.has(v)){if(Ue(G)||ie(G)){ke(v,Me(void 0));return}}else{if(Ue(G))if(Y.delete(v),pe>Z){ke(v,Me(void 0));return}else return ye.add(v),ke(v,bt($)),Xe(j,G,!1,{fetcherSubmission:$,preventScrollReset:F});if(ie(G)){Oe(v,b,G.error);return}}let Q=E.navigation.location||E.location,Ge=st(e.history,Q,H.signal),Rt=l||s,He=E.navigation.state!=="idle"?ve(Rt,E.navigation.location,u):E.matches;I(He,"Didn't find any matches after fetcher action");let Te=++Ee;Pe.set(v,Te);let Rr=bt($,G.data);E.fetchers.set(v,Rr);let{dsMatches:Et,revalidatingFetchers:Qe}=Va(Ge,T,o,i,e.history,E,He,$,Q,a,!1,J,le,De,be,ye,Rt,u,e.patchRoutesOnNavigation!=null,[B.route.id,G]);Qe.filter(ee=>ee.key!==v).forEach(ee=>{let jt=ee.key,Ma=E.fetchers.get(jt),Ni=bt(void 0,Ma?Ma.data:void 0);E.fetchers.set(jt,Ni),Fe(jt),ee.controller&&Y.set(jt,ee.controller)}),se({fetchers:new Map(E.fetchers)});let It=()=>Qe.forEach(ee=>Fe(ee.key));H.signal.addEventListener("abort",It);let{loaderResults:Ht,fetcherResults:W}=await Ca(Et,Qe,Ge,T);if(H.signal.aborted)return;if(H.signal.removeEventListener("abort",It),Pe.delete(v),Y.delete(v),Qe.forEach(ee=>Y.delete(ee.key)),E.fetchers.has(v)){let ee=Me(G.data);E.fetchers.set(v,ee)}let ue=Ut(Ht);if(ue)return Xe(Ge,ue.result,!1,{preventScrollReset:F});if(ue=Ut(W),ue)return ye.add(ue.key),Xe(Ge,ue.result,!1,{preventScrollReset:F});let{loaderData:it,errors:Ze}=qa(E,He,Ht,void 0,Qe,W);Da(Te),E.navigation.state==="loading"&&Te>pe?(I(O,"Expected pending action"),k&&k.abort(),ot(E.navigation.location,{matches:He,loaderData:it,errors:Ze,fetchers:new Map(E.fetchers)})):(se({errors:Ze,loaderData:en(E.loaderData,it,He,Ze),fetchers:new Map(E.fetchers)}),J=!1)}async function Li(v,b,S,D,T,N,A,F,$){let U=E.fetchers.get(v);ke(v,bt($,U?U.data:void 0),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal);if(N){let Q=await $t(D,new URL(j.url).pathname,j.signal,v);if(Q.type==="aborted")return;if(Q.type==="error"){Oe(v,b,Q.error,{flushSync:A});return}else if(Q.matches)D=Q.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),G=(await wt(j,ae,T,v))[B.route.id];if(Y.get(v)===H&&Y.delete(v),!j.signal.aborted){if(De.has(v)){ke(v,Me(void 0));return}if(Ue(G))if(pe>Z){ke(v,Me(void 0));return}else{ye.add(v),await Xe(j,G,!1,{preventScrollReset:F});return}if(ie(G)){Oe(v,b,G.error);return}ke(v,Me(G.data))}}async function Xe(v,b,S,{submission:D,fetcherSubmission:T,preventScrollReset:N,replace:A}={}){b.response.headers.has("X-Remix-Revalidate")&&(J=!0);let F=b.response.headers.get("Location");I(F,"Expected a Location header on the redirect Response"),F=Qa(F,new URL(v.url),u);let $=Ae(E.location,F,{_isRedirect:!0});if(r){let ae=!1;if(b.response.headers.has("X-Remix-Reload-Document"))ae=!0;else if(nr(F)){const oe=Tn(F,!0);ae=oe.origin!==t.location.origin||ne(oe.pathname,u)==null}if(ae){A?t.location.replace(F):t.location.assign(F);return}}k=null;let U=A===!0||b.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:H,formAction:j,formEncType:B}=E.navigation;!D&&!T&&H&&j&&B&&(D=rn(E.navigation));let Z=D||T;if(El.has(b.response.status)&&Z&&de(Z.formMethod))await Ke(U,$,{submission:{...Z,formAction:F},preventScrollReset:N||_,enableViewTransition:S?M:void 0});else{let ae=Sr($,D);await Ke(U,$,{overrideNavigation:ae,fetcherSubmission:T,preventScrollReset:N||_,enableViewTransition:S?M:void 0})}}async function wt(v,b,S,D){let T,N={};try{T=await Zn(c,v,b,D,S,!1)}catch(A){return b.filter(F=>F.shouldLoad).forEach(F=>{N[F.route.id]={type:"error",error:A}}),N}if(v.signal.aborted)return N;for(let[A,F]of Object.entries(T))if(oo(F)){let $=F.result;N[A]={type:"redirect",response:to($,v,A,b,u)}}else N[A]=await eo(F);return N}async function Ca(v,b,S,D){let T=wt(S,v,D,null),N=Promise.all(b.map(async $=>{if($.matches&&$.match&&$.request&&$.controller){let H=(await wt($.request,$.matches,D,$.key))[$.match.route.id];return{[$.key]:H}}else return Promise.resolve({[$.key]:{type:"error",error:te(404,{pathname:$.path})}})})),A=await T,F=(await N).reduce(($,U)=>Object.assign($,U),{});return{loaderResults:A,fetcherResults:F}}function vr(){J=!0,be.forEach((v,b)=>{Y.has(b)&&le.add(b),Fe(b)})}function ke(v,b,S={}){E.fetchers.set(v,b),se({fetchers:new Map(E.fetchers)},{flushSync:(S&&S.flushSync)===!0})}function Oe(v,b,S,D={}){let T=Ce(E.matches,b);gr(v),se({errors:{[T.route.id]:S},fetchers:new Map(E.fetchers)},{flushSync:(D&&D.flushSync)===!0})}function xa(v){return Le.set(v,(Le.get(v)||0)+1),De.has(v)&&De.delete(v),E.fetchers.get(v)||Kr}function Di(v,b){Fe(v,b?.reason),ke(v,Me(null))}function gr(v){let b=E.fetchers.get(v);Y.has(v)&&!(b&&b.state==="loading"&&Pe.has(v))&&Fe(v),be.delete(v),Pe.delete(v),ye.delete(v),De.delete(v),le.delete(v),E.fetchers.delete(v)}function Ti(v){let b=(Le.get(v)||0)-1;b<=0?(Le.delete(v),De.add(v)):Le.set(v,b),se({fetchers:new Map(E.fetchers)})}function Fe(v,b){let S=Y.get(v);S&&(S.abort(b),Y.delete(v))}function Pa(v){for(let b of v){let S=xa(b),D=Me(S.data);E.fetchers.set(b,D)}}function La(){let v=[],b=!1;for(let S of ye){let D=E.fetchers.get(S);I(D,`Expected fetcher: ${S}`),D.state==="loading"&&(ye.delete(S),v.push(S),b=!0)}return Pa(v),b}function Da(v){let b=[];for(let[S,D]of Pe)if(D<v){let T=E.fetchers.get(S);I(T,`Expected fetcher: ${S}`),T.state==="loading"&&(Fe(S),Pe.delete(S),b.push(S))}return Pa(b),b.length>0}function _i(v,b){let S=E.blockers.get(v)||et;return Je.get(v)!==b&&Je.set(v,b),S}function Ta(v){E.blockers.delete(v),Je.delete(v)}function Nt(v,b){let S=E.blockers.get(v)||et;I(S.state==="unblocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="proceeding"||S.state==="blocked"&&b.state==="unblocked"||S.state==="proceeding"&&b.state==="unblocked",`Invalid blocker state transition: ${S.state} -> ${b.state}`);let D=new Map(E.blockers);D.set(v,b),se({blockers:D})}function _a({currentLocation:v,nextLocation:b,historyAction:S}){if(Je.size===0)return;Je.size>1&&K(!1,"A router only supports one blocker at a time");let D=Array.from(Je.entries()),[T,N]=D[D.length-1],A=E.blockers.get(T);if(!(A&&A.state==="proceeding")&&N({currentLocation:v,nextLocation:b,historyAction:S}))return T}function wr(v){let b=te(404,{pathname:v}),S=l||s,{matches:D,route:T}=ut(S);return{notFoundMatches:D,route:T,error:b}}function ki(v,b,S){if(f=v,y=b,g=S||null,!w&&E.navigation===Yt){w=!0;let D=Oa(E.location,E.matches);D!=null&&se({restoreScrollPosition:D})}return()=>{f=null,y=null,g=null}}function ka(v,b){return g&&g(v,b.map(D=>_n(D,E.loaderData)))||v.key}function Oi(v,b){if(f&&y){let S=ka(v,b);f[S]=y()}}function Oa(v,b){if(f){let S=ka(v,b),D=f[S];if(typeof D=="number")return D}return null}function At(v,b,S){if(e.patchRoutesOnNavigation)if(v){if(Object.keys(v[0].params).length>0)return{active:!0,matches:Pt(b,S,u,!0)}}else return{active:!0,matches:Pt(b,S,u,!0)||[]};return{active:!1,matches:null}}async function $t(v,b,S,D){if(!e.patchRoutesOnNavigation)return{type:"success",matches:v};let T=v;for(;;){let N=l==null,A=l||s,F=i;try{await e.patchRoutesOnNavigation({signal:S,path:b,matches:T,fetcherKey:D,patch:(H,j)=>{S.aborted||Ya(H,j,A,F,o,!1)}})}catch(H){return{type:"error",error:H,partialMatches:T}}finally{N&&!S.aborted&&(s=[...s])}if(S.aborted)return{type:"aborted"};let $=ve(A,b,u),U=null;if($){if(Object.keys($[0].params).length===0)return{type:"success",matches:$};if(U=Pt(A,b,u,!0),!(U&&T.length<U.length&&Fa(T,U.slice(0,T.length))))return{type:"success",matches:$}}if(U||(U=Pt(A,b,u,!0)),!U||Fa(T,U))return{type:"success",matches:null};T=U}}function Fa(v,b){return v.length===b.length&&v.every((S,D)=>S.route.id===b[D].route.id)}function Fi(v){i={},l=We(v,o,void 0,i)}function Mi(v,b,S=!1){let D=l==null;Ya(v,b,l||s,i,o,S),D&&(s=[...s],se({}))}return L={get basename(){return u},get future(){return d},get state(){return E},get routes(){return s},get window(){return t},initialize:gi,subscribe:Ri,enableScrollRestoration:ki,navigate:ba,fetch:xi,revalidate:Ei,createHref:v=>e.history.createHref(v),encodeLocation:v=>e.history.encodeLocation(v),getFetcher:xa,resetFetcher:Di,deleteFetcher:Ti,dispose:wi,getBlocker:_i,deleteBlocker:Ta,patchRoutes:Mi,_internalFetchControllers:Y,_internalSetRoutes:Fi,_internalSetStateDoNotUseOrYouWillBreakYourApp(v){se(v)}},e.unstable_instrumentations&&(L=ml(L,e.unstable_instrumentations.map(v=>v.router).filter(Boolean))),L}function Vn(e,t){I(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||zn,o=n;if(t?.unstable_instrumentations){let p=t.unstable_instrumentations;o=f=>({...n(f),...An(p.map(g=>g.route).filter(Boolean),f)})}let i=We(e,o,void 0,r);async function s(p,{requestContext:f,filterMatchesToLoad:g,skipLoaderErrorBubbling:y,skipRevalidation:w,dataStrategy:R,generateMiddlewareResponse:C}={}){let P=new URL(p.url),x=p.method,L=Ae("",he(P),null,"default"),E=ve(i,L,a);if(f=f??new Ne,!Ar(x)&&x!=="HEAD"){let _=te(405,{method:x}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}else if(!E){let _=te(404,{pathname:L.pathname}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}if(C){I(f instanceof Ne,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Xa(E,r,o);let _,k=await Ga({request:p,unstable_pattern:ct(E.map(M=>M.route.path)),matches:E,params:E[0].params,context:f},async()=>await C(async(V,X={})=>{let z=await u(V,L,E,f,R||null,y===!0,null,"filterMatchesToLoad"in X?X.filterMatchesToLoad??null:g??null,w===!0);return q(z)?z:(_={location:L,basename:a,...z},_)}),async(M,V)=>{if(Zt(M))return M;if(q(M))try{M=new me(M.status,M.statusText,await qn(M))}catch(X){M=X}if(Be(M)&&(M=_l(M)),_){V in _.loaderData&&(_.loaderData[V]=void 0);let X=Yn(i,_,M,y?V:Ce(E,V).route.id);return C(()=>Promise.resolve(X))}else{let X=y?V:Ce(E,E.find(J=>J.route.id===V||J.route.loader)?.route.id||V).route.id,z={matches:E,location:L,basename:a,loaderData:{},actionData:null,errors:{[X]:M},statusCode:re(M)?M.status:500,actionHeaders:{},loaderHeaders:{}};return C(()=>Promise.resolve(z))}});return I(q(k),"Expected a response in query()"),k}catch(_){if(q(_))return _;throw _}}let O=await u(p,L,E,f,R||null,y===!0,null,g||null,w===!0);return q(O)?O:{location:L,basename:a,...O}}async function l(p,{routeId:f,requestContext:g,dataStrategy:y,generateMiddlewareResponse:w}={}){let R=new URL(p.url),C=p.method,P=Ae("",he(R),null,"default"),x=ve(i,P,a);if(g=g??new Ne,!Ar(C)&&C!=="HEAD"&&C!=="OPTIONS")throw te(405,{method:C});if(!x)throw te(404,{pathname:P.pathname});let L=f?x.find(_=>_.route.id===f):dt(x,P);if(f&&!L)throw te(403,{pathname:P.pathname,routeId:f});if(!L)throw te(404,{pathname:P.pathname});if(w)return I(g instanceof Ne,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Xa(x,r,o),await Ga({request:p,unstable_pattern:ct(x.map(k=>k.route.path)),matches:x,params:x[0].params,context:g},async()=>await w(async M=>{let V=await u(M,P,x,g,y||null,!1,L,null,!1),X=O(V);return q(X)?X:typeof X=="string"?new Response(X):Response.json(X)}),k=>{if(Be(k))return Promise.resolve(Nr(k));if(q(k))return Promise.resolve(k);throw k});let E=await u(p,P,x,g,y||null,!1,L,null,!1);return O(E);function O(_){if(q(_))return _;let k=_.errors?Object.values(_.errors)[0]:void 0;if(k!==void 0)throw k;if(_.actionData)return Object.values(_.actionData)[0];if(_.loaderData)return Object.values(_.loaderData)[0]}}async function u(p,f,g,y,w,R,C,P,x){I(p.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(de(p.method))return await c(p,g,C||dt(g,f),y,w,R,C!=null,P,x);let L=await d(p,g,y,w,R,C,P);return q(L)?L:{...L,actionData:null,actionHeaders:{}}}catch(L){if(no(L)&&q(L.result)){if(L.type==="error")throw L.result;return L.result}if(Zt(L))return L;throw L}}async function c(p,f,g,y,w,R,C,P,x){let L;if(!g.route.action&&!g.route.lazy){let _=te(405,{method:p.method,pathname:new URL(p.url).pathname,routeId:g.route.id});if(C)throw _;L={type:"error",error:_}}else{let _=ze(o,r,p,f,g,[],y);L=(await m(p,_,C,y,w))[g.route.id],p.signal.aborted&&Ba(p,C)}if(Ue(L))throw new Response(null,{status:L.response.status,headers:{Location:L.response.headers.get("Location")}});if(C){if(ie(L))throw L.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:L.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(x)if(ie(L)){let _=R?g:Ce(f,g.route.id);return{statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}},matches:f,loaderData:{},errors:{[_.route.id]:L.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:L.data},actionHeaders:L.headers?{[g.route.id]:L.headers}:{},matches:f,loaderData:{},errors:null,statusCode:L.statusCode||200,loaderHeaders:{}};let E=new Request(p.url,{headers:p.headers,redirect:p.redirect,signal:p.signal});if(ie(L)){let _=R?g:Ce(f,g.route.id);return{...await d(E,f,y,w,R,null,P,[_.route.id,L]),statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}}}}return{...await d(E,f,y,w,R,null,P),actionData:{[g.route.id]:L.data},...L.statusCode?{statusCode:L.statusCode}:{},actionHeaders:L.headers?{[g.route.id]:L.headers}:{}}}async function d(p,f,g,y,w,R,C,P){let x=R!=null;if(x&&!R?.route.loader&&!R?.route.lazy)throw te(400,{method:p.method,pathname:new URL(p.url).pathname,routeId:R?.route.id});let L;if(R)L=ze(o,r,p,f,R,[],g);else{let _=P&&ie(P[1])?f.findIndex(M=>M.route.id===P[0])-1:void 0,k=ct(f.map(M=>M.route.path));L=f.map((M,V)=>_!=null&&V>_?Dt(o,r,p,k,M,[],g,!1):Dt(o,r,p,k,M,[],g,(M.route.loader||M.route.lazy)!=null&&(!C||C(M))))}if(!y&&!L.some(_=>_.shouldLoad))return{matches:f,loaderData:{},errors:P&&ie(P[1])?{[P[0]]:P[1].error}:null,statusCode:200,loaderHeaders:{}};let E=await m(p,L,x,g,y);return p.signal.aborted&&Ba(p,x),{...ro(f,E,P,!0,w),matches:f}}async function m(p,f,g,y,w){let R=await Zn(w||Fr,p,f,null,y,!0),C={};return await Promise.all(f.map(async P=>{if(!(P.route.id in R))return;let x=R[P.route.id];if(oo(x)){let L=x.result;throw to(L,p,P.route.id,f,a)}if(g){if(q(x.result))throw x;if(Be(x.result))throw Nr(x.result)}C[P.route.id]=await eo(x)})),C}return{dataRoutes:i,query:s,queryRoute:l}}function Yn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:re(r)?r.status:500,errors:{[n]:r}}}function Ba(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 bl(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function kr(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=ir(a||".",or(i),ne(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=Zr(l.search);if(s.route.index&&!u)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!s.route.index&&u){let c=new URLSearchParams(l.search),d=c.getAll("index");c.delete("index"),d.filter(p=>p).forEach(p=>c.append("index",p));let m=c.toString();l.search=m?`?${m}`:""}}return r!=="/"&&(l.pathname=nl({basename:r,pathname:l.pathname})),he(l)}function Wa(e,t,r){if(!r||!bl(r))return{path:t};if(r.formMethod&&!Ar(r.formMethod))return{path:t,error:te(405,{method:r.formMethod})};let a=()=>({path:t,error:te(400,{type:"invalid-body"})}),o=(r.formMethod||"get").toUpperCase(),i=ao(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!de(o))return a();let d=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,[p,f])=>`${m}${p}=${f}
|
|
1
|
+
import{r as h,R as ce,b as Ai}from"./index-CTPvdefa.js";var lt={exports:{}},Na;function $i(){if(Na)return lt.exports;Na=1;var e={decodeValues:!0,map:!1,silent:!1};function t(l){return typeof l!="string"||l in{}}function r(){return Object.create(null)}function a(l){return typeof l=="string"&&!!l.trim()}function n(l,u){var c=l.split(";").filter(a),d=c.shift(),m=o(d),p=m.name,f=m.value;if(u=u?Object.assign({},e,u):e,t(p))return null;try{f=u.decodeValues?decodeURIComponent(f):f}catch(y){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",y)}var g=r();return g.name=p,g.value=f,c.forEach(function(y){var w=y.split("="),R=w.shift().trimLeft().toLowerCase();if(!t(R)){var C=w.join("=");if(R==="expires")g.expires=new Date(C);else if(R==="max-age"){var P=parseInt(C,10);Number.isNaN(P)||(g.maxAge=P)}else R==="secure"?g.secure=!0:R==="httponly"?g.httpOnly=!0:R==="samesite"?g.sameSite=C:R==="partitioned"?g.partitioned=!0:R&&(g[R]=C)}}),g}function o(l){var u="",c="",d=l.split("=");return d.length>1?(u=d.shift(),c=d.join("=")):c=l,{name:u,value:c}}function i(l,u){if(u=u?Object.assign({},e,u):e,!l)return u.map?r():[];if(l.headers)if(typeof l.headers.getSetCookie=="function")l=l.headers.getSetCookie();else if(l.headers["set-cookie"])l=l.headers["set-cookie"];else{var c=l.headers[Object.keys(l.headers).find(function(m){return m.toLowerCase()==="set-cookie"})];!c&&l.headers.cookie&&!u.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),l=c}if(Array.isArray(l)||(l=[l]),u.map){var d=r();return l.filter(a).reduce(function(m,p){var f=n(p,u);return f&&!t(f.name)&&(m[f.name]=f),m},d)}else return l.filter(a).map(function(m){return n(m,u)}).filter(Boolean)}function s(l){if(Array.isArray(l))return l;if(typeof l!="string")return[];var u=[],c=0,d,m,p,f,g;function y(){for(;c<l.length&&/\s/.test(l.charAt(c));)c+=1;return c<l.length}function w(){return m=l.charAt(c),m!=="="&&m!==";"&&m!==","}for(;c<l.length;){for(d=c,g=!1;y();)if(m=l.charAt(c),m===","){for(p=c,c+=1,y(),f=c;c<l.length&&w();)c+=1;c<l.length&&l.charAt(c)==="="?(g=!0,c=f,u.push(l.substring(d,p)),d=c):c=p+1}else c+=1;(!g||c>=l.length)&&u.push(l.substring(d,l.length))}return u}return lt.exports=i,lt.exports.parse=i,lt.exports.parseString=n,lt.exports.splitCookiesString=s,lt.exports}var Ii=$i();var Cn=e=>{throw TypeError(e)},Hi=(e,t,r)=>t.has(e)||Cn("Cannot "+r),Er=(e,t,r)=>(Hi(e,t,"read from private field"),r?r.call(e):t.get(e)),ji=(e,t,r)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ui=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Ui||{}),Aa="popstate";function xn(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((p,f)=>c(p,typeof p=="string"?null:p.state,f===0?"default":void 0));let o=l(r??n.length-1),i="POP",s=null;function l(p){return Math.min(Math.max(p,0),n.length-1)}function u(){return n[o]}function c(p,f=null,g){let y=Ae(n?u().pathname:"/",p,f,g);return K(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function d(p){return typeof p=="string"?p:he(p)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:d,createURL(p){return new URL(d(p),"http://localhost")},encodeLocation(p){let f=typeof p=="string"?xe(p):p;return{pathname:f.pathname||"",search:f.search||"",hash:f.hash||""}},push(p,f){i="PUSH";let g=c(p,f);o+=1,n.splice(o,n.length,g),a&&s&&s({action:i,location:g,delta:1})},replace(p,f){i="REPLACE";let g=c(p,f);n[o]=g,a&&s&&s({action:i,location:g,delta:0})},go(p){i="POP";let f=l(o+p),g=n[f];o=f,s&&s({action:i,location:g,delta:p})},listen(p){return s=p,()=>{s=null}}}}function Pn(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return Ae("",{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:he(n)}return Dn(t,r,null,e)}function Ln(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=xe(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ae("",{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:he(o))}function a(n,o){K(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Dn(t,r,a,e)}function I(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function K(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function zi(){return Math.random().toString(36).substring(2,10)}function $a(e,t){return{usr:e.state,key:e.key,idx:t}}function Ae(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?xe(t):t,state:r,key:t&&t.key||a||zi()}}function he({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 xe(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 Dn(e,t,r,a={}){let{window:n=document.defaultView,v5Compat:o=!1}=a,i=n.history,s="POP",l=null,u=c();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function c(){return(i.state||{idx:null}).idx}function d(){s="POP";let y=c(),w=y==null?null:y-u;u=y,l&&l({action:s,location:g.location,delta:w})}function m(y,w){s="PUSH";let R=Ae(g.location,y,w);r&&r(R,y),u=c()+1;let C=$a(R,u),P=g.createHref(R);try{i.pushState(C,"",P)}catch(x){if(x instanceof DOMException&&x.name==="DataCloneError")throw x;n.location.assign(P)}o&&l&&l({action:s,location:g.location,delta:1})}function p(y,w){s="REPLACE";let R=Ae(g.location,y,w);r&&r(R,y),u=c();let C=$a(R,u),P=g.createHref(R);i.replaceState(C,"",P),o&&l&&l({action:s,location:g.location,delta:0})}function f(y){return Tn(y)}let g={get action(){return s},get location(){return e(n,i)},listen(y){if(l)throw new Error("A history only accepts one active listener");return n.addEventListener(Aa,d),l=y,()=>{n.removeEventListener(Aa,d),l=null}},createHref(y){return t(n,y)},createURL:f,encodeLocation(y){let w=f(y);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:m,replace:p,go(y){return i.go(y)}};return g}function Tn(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),I(r,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:he(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=r+a),new URL(a,r)}function cc(e){return{defaultValue:e}}var xt,Ne=class{constructor(e){if(ji(this,xt,new Map),e)for(let[t,r]of e)this.set(t,r)}get(e){if(Er(this,xt).has(e))return Er(this,xt).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Er(this,xt).set(e,t)}};xt=new WeakMap;var Bi=new Set(["lazy","caseSensitive","path","id","index","children"]);function Wi(e){return Bi.has(e)}var Vi=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Yi(e){return Vi.has(e)}function Ji(e){return e.index===!0}function We(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(I(o.index!==!0||!o.children,"Cannot specify children on an index route"),I(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),Ji(o)){let u={...o,id:l};return a[l]=Ia(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Ia(u,t(u)),o.children&&(u.children=We(o.children,t,s,a,n)),u}})}function Ia(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function ve(e,t,r="/"){return Pt(e,t,r,!1)}function Pt(e,t,r,a){let n=typeof t=="string"?xe(t):t,o=ne(n.pathname||"/",r);if(o==null)return null;let i=kn(e);Ki(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Mn(o);s=al(i[l],u,a)}return s}function _n(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 kn(e,t=[],r=[],a="",n=!1){let o=(i,s,l=n,u)=>{let c={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(c.relativePath.startsWith("/")){if(!c.relativePath.startsWith(a)&&l)return;I(c.relativePath.startsWith(a),`Absolute route path "${c.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(a.length)}let d=_e([a,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(I(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),kn(i.children,t,m,d,l)),!(i.path==null&&!i.index)&&t.push({path:d,score:tl(d,i.index),routesMeta:m})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of On(i.path))o(i,s,!0,l)}),t}function On(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=On(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 Ki(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:rl(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}var Xi=/^:[\w-]+$/,Gi=3,Qi=2,Zi=1,qi=10,el=-2,Ha=e=>e==="*";function tl(e,t){let r=e.split("/"),a=r.length;return r.some(Ha)&&(a+=el),t&&(a+=Qi),r.filter(n=>!Ha(n)).reduce((n,o)=>n+(Xi.test(o)?Gi:o===""?Zi:qi),a)}function rl(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 al(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,c=o==="/"?t:t.slice(o.length)||"/",d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},c),m=l.route;if(!d&&u&&r&&!a[a.length-1].route.index&&(d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},c)),!d)return null;Object.assign(n,d.params),i.push({params:n,pathname:_e([o,d.pathname]),pathnameBase:ll(_e([o,d.pathnameBase])),route:m}),d.pathnameBase!=="/"&&(o=_e([o,d.pathnameBase]))}return i}function dc(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(K(!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(/\*$/,"/*"));const 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["*"]);const c=i.match(/^:([\w-]+)(\??)$/);if(c){const[,d,m]=c;let p=t[d];return I(m==="?"||p!=null,`Missing ":${d}" param`),encodeURIComponent(n(p))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function Lt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=Fn(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:c,isOptional:d},m)=>{if(c==="*"){let f=s[m]||"";i=o.slice(0,o.length-f.length).replace(/(.)\/+$/,"$1")}const p=s[m];return d&&!p?u[c]=void 0:u[c]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Fn(e,t=!1,r=!0){K(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 Mn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return K(!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 ne(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 nl({basename:e,pathname:t}){return t==="/"?e:_e([e,t])}var ol=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nr=e=>ol.test(e);function il(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?xe(e):e,o;if(r)if(nr(r))o=r;else{if(r.includes("//")){let i=r;r=r.replace(/\/\/+/g,"/"),K(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${r}`)}r.startsWith("/")?o=ja(r.substring(1),"/"):o=ja(r,t)}else o=t;return{pathname:o,search:sl(a),hash:ul(n)}}function ja(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 br(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 Nn(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function or(e){let t=Nn(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function ir(e,t,r,a=!1){let n;typeof e=="string"?n=xe(e):(n={...e},I(!n.pathname||!n.pathname.includes("?"),br("?","pathname","search",n)),I(!n.pathname||!n.pathname.includes("#"),br("#","pathname","hash",n)),I(!n.search||!n.search.includes("#"),br("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let d=t.length-1;if(!a&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),d-=1;n.pathname=m.join("/")}s=d>=0?t[d]:"/"}let l=il(n,s),u=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}var _e=e=>e.join("/").replace(/\/\/+/g,"/"),ll=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),sl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ul=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cl=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function dl(e,t){return new cl(e,typeof t=="number"?{status:t}:t)}var lr=(e,t=302)=>{let r=t;typeof r=="number"?r={status:r}:typeof r.status>"u"&&(r.status=302);let a=new Headers(r.headers);return a.set("Location",e),new Response(null,{...r,headers:a})},fl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},hl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Replace","true"),r},me=class{constructor(e,t,r,a=!1){this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function re(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ct(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var je=Symbol("Uninstrumented");function An(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=tt(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=tt(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[je]??o,s=tt(r[n],i,(...l)=>Ua(l[0]));s&&(s[je]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[je]??n,i=tt(r.middleware,o,(...s)=>Ua(s[0]));return i?(i[je]=o,i):n})),a}function ml(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[je]??e.navigate,n=tt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?he(i):".",...za(e,s??{})}});n&&(n[je]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[je]??e.fetch,n=tt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...za(e,l??{})}});n&&(n[je]=a,e.fetch=n)}return e}function pl(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=tt(r.request,e,(...n)=>{let[o,i]=n;return{request:In(o),context:i!=null?Hn(i):i}})),a}function tt(e,t,r){return e.length===0?null:async(...a)=>{let n=await $n(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function $n(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=$n(e,t,r,a-1),o=await i,I(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 Ua(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:In(t),params:{...a},unstable_pattern:n,context:Hn(r)}}function za(e,t){return{currentUrl:he(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 In(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function Hn(e){if(vl(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var yl=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function vl(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===yl}var jn=["POST","PUT","PATCH","DELETE"],gl=new Set(jn),wl=["GET",...jn],Rl=new Set(wl),Un=new Set([301,302,303,307,308]),El=new Set([307,308]),Yt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Kr={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},et={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},zn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Bn="remix-router-transitions",Wn=Symbol("ResetLoaderData");function Xr(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";I(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||zn,o=n;if(e.unstable_instrumentations){let v=e.unstable_instrumentations;o=b=>({...n(b),...An(v.map(S=>S.route).filter(Boolean),b)})}let i={},s=We(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let c=e.dataStrategy||Ll,d={...e.future},m=null,p=new Set,f=null,g=null,y=null,w=e.hydrationData!=null,R=ve(s,e.history.location,u),C=!1,P=null,x;if(R==null&&!e.patchRoutesOnNavigation){let v=te(404,{pathname:e.history.location.pathname}),{matches:b,route:S}=ut(s);x=!0,R=b,P={[S.id]:v}}else if(R&&!e.hydrationData&&At(R,s,e.history.location.pathname).active&&(R=null),R)if(R.some(v=>v.route.lazy))x=!1;else if(!R.some(v=>Gr(v.route)))x=!0;else{let v=e.hydrationData?e.hydrationData.loaderData:null,b=e.hydrationData?e.hydrationData.errors:null;if(b){let S=R.findIndex(D=>b[D.route.id]!==void 0);x=R.slice(0,S+1).every(D=>!Or(D.route,v,b))}else x=R.every(S=>!Or(S.route,v,b))}else{x=!1,R=[];let v=At(null,s,e.history.location.pathname);v.active&&v.matches&&(C=!0,R=v.matches)}let L,E={historyAction:e.history.action,location:e.history.location,matches:R,initialized:x,navigation:Yt,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},O="POP",_=!1,k,M=!1,V=new Map,X=null,z=!1,J=!1,le=new Set,Y=new Map,Ee=0,pe=-1,Pe=new Map,ye=new Set,be=new Map,Le=new Map,De=new Set,Je=new Map,Mt,gt=null;function gi(){if(m=e.history.listen(({action:v,location:b,delta:S})=>{if(Mt){Mt(),Mt=void 0;return}K(Je.size===0||S!=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=_a({currentLocation:E.location,nextLocation:b,historyAction:v});if(D&&S!=null){let T=new Promise(N=>{Mt=N});e.history.go(S*-1),Nt(D,{state:"blocked",location:b,proceed(){Nt(D,{state:"proceeding",proceed:void 0,reset:void 0,location:b}),T.then(()=>e.history.go(S))},reset(){let N=new Map(E.blockers);N.set(D,et),se({blockers:N})}});return}return Ke(v,b)}),r){Ml(t,V);let v=()=>Nl(t,V);t.addEventListener("pagehide",v),X=()=>t.removeEventListener("pagehide",v)}return E.initialized||Ke("POP",E.location,{initialHydration:!0}),L}function wi(){m&&m(),X&&X(),p.clear(),k&&k.abort(),E.fetchers.forEach((v,b)=>gr(b)),E.blockers.forEach((v,b)=>Ta(b))}function Ri(v){return p.add(v),()=>p.delete(v)}function se(v,b={}){v.matches&&(v.matches=v.matches.map(T=>{let N=i[T.route.id],A=T.route;return A.element!==N.element||A.errorElement!==N.errorElement||A.hydrateFallbackElement!==N.hydrateFallbackElement?{...T,route:N}:T})),E={...E,...v};let S=[],D=[];E.fetchers.forEach((T,N)=>{T.state==="idle"&&(De.has(N)?S.push(N):D.push(N))}),De.forEach(T=>{!E.fetchers.has(T)&&!Y.has(T)&&S.push(T)}),[...p].forEach(T=>T(E,{deletedFetchers:S,viewTransitionOpts:b.viewTransitionOpts,flushSync:b.flushSync===!0})),S.forEach(T=>gr(T)),D.forEach(T=>E.fetchers.delete(T))}function ot(v,b,{flushSync:S}={}){let D=E.actionData!=null&&E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&E.navigation.state==="loading"&&v.state?._isRedirect!==!0,T;b.actionData?Object.keys(b.actionData).length>0?T=b.actionData:T=null:D?T=E.actionData:T=null;let N=b.loaderData?en(E.loaderData,b.loaderData,b.matches||[],b.errors):E.loaderData,A=E.blockers;A.size>0&&(A=new Map(A),A.forEach((H,j)=>A.set(j,et)));let F=z?!1:Oa(v,b.matches||E.matches),$=_===!0||E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&v.state?._isRedirect!==!0;l&&(s=l,l=void 0),z||O==="POP"||(O==="PUSH"?e.history.push(v,v.state):O==="REPLACE"&&e.history.replace(v,v.state));let U;if(O==="POP"){let H=V.get(E.location.pathname);H&&H.has(v.pathname)?U={currentLocation:E.location,nextLocation:v}:V.has(v.pathname)&&(U={currentLocation:v,nextLocation:E.location})}else if(M){let H=V.get(E.location.pathname);H?H.add(v.pathname):(H=new Set([v.pathname]),V.set(E.location.pathname,H)),U={currentLocation:E.location,nextLocation:v}}se({...b,actionData:T,loaderData:N,historyAction:O,location:v,initialized:!0,navigation:Yt,revalidation:"idle",restoreScrollPosition:F,preventScrollReset:$,blockers:A},{viewTransitionOpts:U,flushSync:S===!0}),O="POP",_=!1,M=!1,z=!1,J=!1,gt?.resolve(),gt=null}async function ba(v,b){if(typeof v=="number"){e.history.go(v);return}let S=kr(E.location,E.matches,u,v,b?.fromRouteId,b?.relative),{path:D,submission:T,error:N}=Wa(!1,S,b),A=E.location,F=Ae(E.location,D,b&&b.state);F={...F,...e.history.encodeLocation(F)};let $=b&&b.replace!=null?b.replace:void 0,U="PUSH";$===!0?U="REPLACE":$===!1||T!=null&&de(T.formMethod)&&T.formAction===E.location.pathname+E.location.search&&(U="REPLACE");let H=b&&"preventScrollReset"in b?b.preventScrollReset===!0:void 0,j=(b&&b.flushSync)===!0,B=_a({currentLocation:A,nextLocation:F,historyAction:U});if(B){Nt(B,{state:"blocked",location:F,proceed(){Nt(B,{state:"proceeding",proceed:void 0,reset:void 0,location:F}),ba(v,b)},reset(){let Z=new Map(E.blockers);Z.set(B,et),se({blockers:Z})}});return}await Ke(U,F,{submission:T,pendingError:N,preventScrollReset:H,replace:b&&b.replace,enableViewTransition:b&&b.viewTransition,flushSync:j})}function Ei(){gt||(gt=Al()),vr(),se({revalidation:"loading"});let v=gt.promise;return E.navigation.state==="submitting"?v:E.navigation.state==="idle"?(Ke(E.historyAction,E.location,{startUninterruptedRevalidation:!0}),v):(Ke(O||E.historyAction,E.navigation.location,{overrideNavigation:E.navigation,enableViewTransition:M===!0}),v)}async function Ke(v,b,S){k&&k.abort(),k=null,O=v,z=(S&&S.startUninterruptedRevalidation)===!0,Oi(E.location,E.matches),_=(S&&S.preventScrollReset)===!0,M=(S&&S.enableViewTransition)===!0;let D=l||s,T=S&&S.overrideNavigation,N=S?.initialHydration&&E.matches&&E.matches.length>0&&!C?E.matches:ve(D,b,u),A=(S&&S.flushSync)===!0;if(N&&E.initialized&&!J&&Tl(E.location,b)&&!(S&&S.submission&&de(S.submission.formMethod))){ot(b,{matches:N},{flushSync:A});return}let F=At(N,D,b.pathname);if(F.active&&F.matches&&(N=F.matches),!N){let{error:oe,notFoundMatches:G,route:Q}=wr(b.pathname);ot(b,{matches:G,loaderData:{},errors:{[Q.id]:oe}},{flushSync:A});return}k=new AbortController;let $=st(e.history,b,k.signal,S&&S.submission),U=e.getContext?await e.getContext():new Ne,H;if(S&&S.pendingError)H=[Ce(N).route.id,{type:"error",error:S.pendingError}];else if(S&&S.submission&&de(S.submission.formMethod)){let oe=await bi($,b,S.submission,N,U,F.active,S&&S.initialHydration===!0,{replace:S.replace,flushSync:A});if(oe.shortCircuited)return;if(oe.pendingActionResult){let[G,Q]=oe.pendingActionResult;if(ie(Q)&&re(Q.error)&&Q.error.status===404){k=null,ot(b,{matches:oe.matches,loaderData:{},errors:{[G]:Q.error}});return}}N=oe.matches||N,H=oe.pendingActionResult,T=Sr(b,S.submission),A=!1,F.active=!1,$=st(e.history,$.url,$.signal)}let{shortCircuited:j,matches:B,loaderData:Z,errors:ae}=await Si($,b,N,U,F.active,T,S&&S.submission,S&&S.fetcherSubmission,S&&S.replace,S&&S.initialHydration===!0,A,H);j||(k=null,ot(b,{matches:B||N,...tn(H),loaderData:Z,errors:ae}))}async function bi(v,b,S,D,T,N,A,F={}){vr();let $=Ol(b,S);if(se({navigation:$},{flushSync:F.flushSync===!0}),N){let j=await $t(D,b.pathname,v.signal);if(j.type==="aborted")return{shortCircuited:!0};if(j.type==="error"){if(j.partialMatches.length===0){let{matches:Z,route:ae}=ut(s);return{matches:Z,pendingActionResult:[ae.id,{type:"error",error:j.error}]}}let B=Ce(j.partialMatches).route.id;return{matches:j.partialMatches,pendingActionResult:[B,{type:"error",error:j.error}]}}else if(j.matches)D=j.matches;else{let{notFoundMatches:B,error:Z,route:ae}=wr(b.pathname);return{matches:B,pendingActionResult:[ae.id,{type:"error",error:Z}]}}}let U,H=dt(D,b);if(!H.route.action&&!H.route.lazy)U={type:"error",error:te(405,{method:v.method,pathname:b.pathname,routeId:H.route.id})};else{let j=ze(o,i,v,D,H,A?[]:a,T),B=await wt(v,j,T,null);if(U=B[H.route.id],!U){for(let Z of D)if(B[Z.route.id]){U=B[Z.route.id];break}}if(v.signal.aborted)return{shortCircuited:!0}}if(Ue(U)){let j;return F&&F.replace!=null?j=F.replace:j=Qa(U.response.headers.get("Location"),new URL(v.url),u)===E.location.pathname+E.location.search,await Xe(v,U,!0,{submission:S,replace:j}),{shortCircuited:!0}}if(ie(U)){let j=Ce(D,H.route.id);return(F&&F.replace)!==!0&&(O="PUSH"),{matches:D,pendingActionResult:[j.route.id,U,H.route.id]}}return{matches:D,pendingActionResult:[H.route.id,U]}}async function Si(v,b,S,D,T,N,A,F,$,U,H,j){let B=N||Sr(b,A),Z=A||F||rn(B),ae=!z&&!U;if(T){if(ae){let ue=Sa(j);se({navigation:B,...ue!==void 0?{actionData:ue}:{}},{flushSync:H})}let W=await $t(S,b.pathname,v.signal);if(W.type==="aborted")return{shortCircuited:!0};if(W.type==="error"){if(W.partialMatches.length===0){let{matches:it,route:Ze}=ut(s);return{matches:it,loaderData:{},errors:{[Ze.id]:W.error}}}let ue=Ce(W.partialMatches).route.id;return{matches:W.partialMatches,loaderData:{},errors:{[ue]:W.error}}}else if(W.matches)S=W.matches;else{let{error:ue,notFoundMatches:it,route:Ze}=wr(b.pathname);return{matches:it,loaderData:{},errors:{[Ze.id]:ue}}}}let oe=l||s,{dsMatches:G,revalidatingFetchers:Q}=Va(v,D,o,i,e.history,E,S,Z,b,U?[]:a,U===!0,J,le,De,be,ye,oe,u,e.patchRoutesOnNavigation!=null,j);if(pe=++Ee,!e.dataStrategy&&!G.some(W=>W.shouldLoad)&&!G.some(W=>W.route.middleware&&W.route.middleware.length>0)&&Q.length===0){let W=La();return ot(b,{matches:S,loaderData:{},errors:j&&ie(j[1])?{[j[0]]:j[1].error}:null,...tn(j),...W?{fetchers:new Map(E.fetchers)}:{}},{flushSync:H}),{shortCircuited:!0}}if(ae){let W={};if(!T){W.navigation=B;let ue=Sa(j);ue!==void 0&&(W.actionData=ue)}Q.length>0&&(W.fetchers=Ci(Q)),se(W,{flushSync:H})}Q.forEach(W=>{Fe(W.key),W.controller&&Y.set(W.key,W.controller)});let Ge=()=>Q.forEach(W=>Fe(W.key));k&&k.signal.addEventListener("abort",Ge);let{loaderResults:Rt,fetcherResults:He}=await Ca(G,Q,v,D);if(v.signal.aborted)return{shortCircuited:!0};k&&k.signal.removeEventListener("abort",Ge),Q.forEach(W=>Y.delete(W.key));let Te=Ut(Rt);if(Te)return await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};if(Te=Ut(He),Te)return ye.add(Te.key),await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};let{loaderData:Rr,errors:Et}=qa(E,S,Rt,j,Q,He);U&&E.errors&&(Et={...E.errors,...Et});let Qe=La(),It=Da(pe),Ht=Qe||It||Q.length>0;return{matches:S,loaderData:Rr,errors:Et,...Ht?{fetchers:new Map(E.fetchers)}:{}}}function Sa(v){if(v&&!ie(v[1]))return{[v[0]]:v[1].data};if(E.actionData)return Object.keys(E.actionData).length===0?null:E.actionData}function Ci(v){return v.forEach(b=>{let S=E.fetchers.get(b.key),D=bt(void 0,S?S.data:void 0);E.fetchers.set(b.key,D)}),new Map(E.fetchers)}async function xi(v,b,S,D){Fe(v);let T=(D&&D.flushSync)===!0,N=l||s,A=kr(E.location,E.matches,u,S,b,D?.relative),F=ve(N,A,u),$=At(F,N,A);if($.active&&$.matches&&(F=$.matches),!F){Oe(v,b,te(404,{pathname:A}),{flushSync:T});return}let{path:U,submission:H,error:j}=Wa(!0,A,D);if(j){Oe(v,b,j,{flushSync:T});return}let B=e.getContext?await e.getContext():new Ne,Z=(D&&D.preventScrollReset)===!0;if(H&&de(H.formMethod)){await Pi(v,b,U,F,B,$.active,T,Z,H);return}be.set(v,{routeId:b,path:U}),await Li(v,b,U,F,B,$.active,T,Z,H)}async function Pi(v,b,S,D,T,N,A,F,$){vr(),be.delete(v);let U=E.fetchers.get(v);ke(v,Fl($,U),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal,$);if(N){let ee=await $t(D,new URL(j.url).pathname,j.signal,v);if(ee.type==="aborted")return;if(ee.type==="error"){Oe(v,b,ee.error,{flushSync:A});return}else if(ee.matches)D=ee.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);if(!B.route.action&&!B.route.lazy){let ee=te(405,{method:$.formMethod,pathname:S,routeId:b});Oe(v,b,ee,{flushSync:A});return}Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),oe=await wt(j,ae,T,v),G=oe[B.route.id];if(!G){for(let ee of ae)if(oe[ee.route.id]){G=oe[ee.route.id];break}}if(j.signal.aborted){Y.get(v)===H&&Y.delete(v);return}if(De.has(v)){if(Ue(G)||ie(G)){ke(v,Me(void 0));return}}else{if(Ue(G))if(Y.delete(v),pe>Z){ke(v,Me(void 0));return}else return ye.add(v),ke(v,bt($)),Xe(j,G,!1,{fetcherSubmission:$,preventScrollReset:F});if(ie(G)){Oe(v,b,G.error);return}}let Q=E.navigation.location||E.location,Ge=st(e.history,Q,H.signal),Rt=l||s,He=E.navigation.state!=="idle"?ve(Rt,E.navigation.location,u):E.matches;I(He,"Didn't find any matches after fetcher action");let Te=++Ee;Pe.set(v,Te);let Rr=bt($,G.data);E.fetchers.set(v,Rr);let{dsMatches:Et,revalidatingFetchers:Qe}=Va(Ge,T,o,i,e.history,E,He,$,Q,a,!1,J,le,De,be,ye,Rt,u,e.patchRoutesOnNavigation!=null,[B.route.id,G]);Qe.filter(ee=>ee.key!==v).forEach(ee=>{let jt=ee.key,Ma=E.fetchers.get(jt),Ni=bt(void 0,Ma?Ma.data:void 0);E.fetchers.set(jt,Ni),Fe(jt),ee.controller&&Y.set(jt,ee.controller)}),se({fetchers:new Map(E.fetchers)});let It=()=>Qe.forEach(ee=>Fe(ee.key));H.signal.addEventListener("abort",It);let{loaderResults:Ht,fetcherResults:W}=await Ca(Et,Qe,Ge,T);if(H.signal.aborted)return;if(H.signal.removeEventListener("abort",It),Pe.delete(v),Y.delete(v),Qe.forEach(ee=>Y.delete(ee.key)),E.fetchers.has(v)){let ee=Me(G.data);E.fetchers.set(v,ee)}let ue=Ut(Ht);if(ue)return Xe(Ge,ue.result,!1,{preventScrollReset:F});if(ue=Ut(W),ue)return ye.add(ue.key),Xe(Ge,ue.result,!1,{preventScrollReset:F});let{loaderData:it,errors:Ze}=qa(E,He,Ht,void 0,Qe,W);Da(Te),E.navigation.state==="loading"&&Te>pe?(I(O,"Expected pending action"),k&&k.abort(),ot(E.navigation.location,{matches:He,loaderData:it,errors:Ze,fetchers:new Map(E.fetchers)})):(se({errors:Ze,loaderData:en(E.loaderData,it,He,Ze),fetchers:new Map(E.fetchers)}),J=!1)}async function Li(v,b,S,D,T,N,A,F,$){let U=E.fetchers.get(v);ke(v,bt($,U?U.data:void 0),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal);if(N){let Q=await $t(D,new URL(j.url).pathname,j.signal,v);if(Q.type==="aborted")return;if(Q.type==="error"){Oe(v,b,Q.error,{flushSync:A});return}else if(Q.matches)D=Q.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),G=(await wt(j,ae,T,v))[B.route.id];if(Y.get(v)===H&&Y.delete(v),!j.signal.aborted){if(De.has(v)){ke(v,Me(void 0));return}if(Ue(G))if(pe>Z){ke(v,Me(void 0));return}else{ye.add(v),await Xe(j,G,!1,{preventScrollReset:F});return}if(ie(G)){Oe(v,b,G.error);return}ke(v,Me(G.data))}}async function Xe(v,b,S,{submission:D,fetcherSubmission:T,preventScrollReset:N,replace:A}={}){b.response.headers.has("X-Remix-Revalidate")&&(J=!0);let F=b.response.headers.get("Location");I(F,"Expected a Location header on the redirect Response"),F=Qa(F,new URL(v.url),u);let $=Ae(E.location,F,{_isRedirect:!0});if(r){let ae=!1;if(b.response.headers.has("X-Remix-Reload-Document"))ae=!0;else if(nr(F)){const oe=Tn(F,!0);ae=oe.origin!==t.location.origin||ne(oe.pathname,u)==null}if(ae){A?t.location.replace(F):t.location.assign(F);return}}k=null;let U=A===!0||b.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:H,formAction:j,formEncType:B}=E.navigation;!D&&!T&&H&&j&&B&&(D=rn(E.navigation));let Z=D||T;if(El.has(b.response.status)&&Z&&de(Z.formMethod))await Ke(U,$,{submission:{...Z,formAction:F},preventScrollReset:N||_,enableViewTransition:S?M:void 0});else{let ae=Sr($,D);await Ke(U,$,{overrideNavigation:ae,fetcherSubmission:T,preventScrollReset:N||_,enableViewTransition:S?M:void 0})}}async function wt(v,b,S,D){let T,N={};try{T=await Zn(c,v,b,D,S,!1)}catch(A){return b.filter(F=>F.shouldLoad).forEach(F=>{N[F.route.id]={type:"error",error:A}}),N}if(v.signal.aborted)return N;for(let[A,F]of Object.entries(T))if(oo(F)){let $=F.result;N[A]={type:"redirect",response:to($,v,A,b,u)}}else N[A]=await eo(F);return N}async function Ca(v,b,S,D){let T=wt(S,v,D,null),N=Promise.all(b.map(async $=>{if($.matches&&$.match&&$.request&&$.controller){let H=(await wt($.request,$.matches,D,$.key))[$.match.route.id];return{[$.key]:H}}else return Promise.resolve({[$.key]:{type:"error",error:te(404,{pathname:$.path})}})})),A=await T,F=(await N).reduce(($,U)=>Object.assign($,U),{});return{loaderResults:A,fetcherResults:F}}function vr(){J=!0,be.forEach((v,b)=>{Y.has(b)&&le.add(b),Fe(b)})}function ke(v,b,S={}){E.fetchers.set(v,b),se({fetchers:new Map(E.fetchers)},{flushSync:(S&&S.flushSync)===!0})}function Oe(v,b,S,D={}){let T=Ce(E.matches,b);gr(v),se({errors:{[T.route.id]:S},fetchers:new Map(E.fetchers)},{flushSync:(D&&D.flushSync)===!0})}function xa(v){return Le.set(v,(Le.get(v)||0)+1),De.has(v)&&De.delete(v),E.fetchers.get(v)||Kr}function Di(v,b){Fe(v,b?.reason),ke(v,Me(null))}function gr(v){let b=E.fetchers.get(v);Y.has(v)&&!(b&&b.state==="loading"&&Pe.has(v))&&Fe(v),be.delete(v),Pe.delete(v),ye.delete(v),De.delete(v),le.delete(v),E.fetchers.delete(v)}function Ti(v){let b=(Le.get(v)||0)-1;b<=0?(Le.delete(v),De.add(v)):Le.set(v,b),se({fetchers:new Map(E.fetchers)})}function Fe(v,b){let S=Y.get(v);S&&(S.abort(b),Y.delete(v))}function Pa(v){for(let b of v){let S=xa(b),D=Me(S.data);E.fetchers.set(b,D)}}function La(){let v=[],b=!1;for(let S of ye){let D=E.fetchers.get(S);I(D,`Expected fetcher: ${S}`),D.state==="loading"&&(ye.delete(S),v.push(S),b=!0)}return Pa(v),b}function Da(v){let b=[];for(let[S,D]of Pe)if(D<v){let T=E.fetchers.get(S);I(T,`Expected fetcher: ${S}`),T.state==="loading"&&(Fe(S),Pe.delete(S),b.push(S))}return Pa(b),b.length>0}function _i(v,b){let S=E.blockers.get(v)||et;return Je.get(v)!==b&&Je.set(v,b),S}function Ta(v){E.blockers.delete(v),Je.delete(v)}function Nt(v,b){let S=E.blockers.get(v)||et;I(S.state==="unblocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="proceeding"||S.state==="blocked"&&b.state==="unblocked"||S.state==="proceeding"&&b.state==="unblocked",`Invalid blocker state transition: ${S.state} -> ${b.state}`);let D=new Map(E.blockers);D.set(v,b),se({blockers:D})}function _a({currentLocation:v,nextLocation:b,historyAction:S}){if(Je.size===0)return;Je.size>1&&K(!1,"A router only supports one blocker at a time");let D=Array.from(Je.entries()),[T,N]=D[D.length-1],A=E.blockers.get(T);if(!(A&&A.state==="proceeding")&&N({currentLocation:v,nextLocation:b,historyAction:S}))return T}function wr(v){let b=te(404,{pathname:v}),S=l||s,{matches:D,route:T}=ut(S);return{notFoundMatches:D,route:T,error:b}}function ki(v,b,S){if(f=v,y=b,g=S||null,!w&&E.navigation===Yt){w=!0;let D=Oa(E.location,E.matches);D!=null&&se({restoreScrollPosition:D})}return()=>{f=null,y=null,g=null}}function ka(v,b){return g&&g(v,b.map(D=>_n(D,E.loaderData)))||v.key}function Oi(v,b){if(f&&y){let S=ka(v,b);f[S]=y()}}function Oa(v,b){if(f){let S=ka(v,b),D=f[S];if(typeof D=="number")return D}return null}function At(v,b,S){if(e.patchRoutesOnNavigation)if(v){if(Object.keys(v[0].params).length>0)return{active:!0,matches:Pt(b,S,u,!0)}}else return{active:!0,matches:Pt(b,S,u,!0)||[]};return{active:!1,matches:null}}async function $t(v,b,S,D){if(!e.patchRoutesOnNavigation)return{type:"success",matches:v};let T=v;for(;;){let N=l==null,A=l||s,F=i;try{await e.patchRoutesOnNavigation({signal:S,path:b,matches:T,fetcherKey:D,patch:(H,j)=>{S.aborted||Ya(H,j,A,F,o,!1)}})}catch(H){return{type:"error",error:H,partialMatches:T}}finally{N&&!S.aborted&&(s=[...s])}if(S.aborted)return{type:"aborted"};let $=ve(A,b,u),U=null;if($){if(Object.keys($[0].params).length===0)return{type:"success",matches:$};if(U=Pt(A,b,u,!0),!(U&&T.length<U.length&&Fa(T,U.slice(0,T.length))))return{type:"success",matches:$}}if(U||(U=Pt(A,b,u,!0)),!U||Fa(T,U))return{type:"success",matches:null};T=U}}function Fa(v,b){return v.length===b.length&&v.every((S,D)=>S.route.id===b[D].route.id)}function Fi(v){i={},l=We(v,o,void 0,i)}function Mi(v,b,S=!1){let D=l==null;Ya(v,b,l||s,i,o,S),D&&(s=[...s],se({}))}return L={get basename(){return u},get future(){return d},get state(){return E},get routes(){return s},get window(){return t},initialize:gi,subscribe:Ri,enableScrollRestoration:ki,navigate:ba,fetch:xi,revalidate:Ei,createHref:v=>e.history.createHref(v),encodeLocation:v=>e.history.encodeLocation(v),getFetcher:xa,resetFetcher:Di,deleteFetcher:Ti,dispose:wi,getBlocker:_i,deleteBlocker:Ta,patchRoutes:Mi,_internalFetchControllers:Y,_internalSetRoutes:Fi,_internalSetStateDoNotUseOrYouWillBreakYourApp(v){se(v)}},e.unstable_instrumentations&&(L=ml(L,e.unstable_instrumentations.map(v=>v.router).filter(Boolean))),L}function Vn(e,t){I(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||zn,o=n;if(t?.unstable_instrumentations){let p=t.unstable_instrumentations;o=f=>({...n(f),...An(p.map(g=>g.route).filter(Boolean),f)})}let i=We(e,o,void 0,r);async function s(p,{requestContext:f,filterMatchesToLoad:g,skipLoaderErrorBubbling:y,skipRevalidation:w,dataStrategy:R,generateMiddlewareResponse:C}={}){let P=new URL(p.url),x=p.method,L=Ae("",he(P),null,"default"),E=ve(i,L,a);if(f=f??new Ne,!Ar(x)&&x!=="HEAD"){let _=te(405,{method:x}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}else if(!E){let _=te(404,{pathname:L.pathname}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}if(C){I(f instanceof Ne,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Xa(E,r,o);let _,k=await Ga({request:p,unstable_pattern:ct(E.map(M=>M.route.path)),matches:E,params:E[0].params,context:f},async()=>await C(async(V,X={})=>{let z=await u(V,L,E,f,R||null,y===!0,null,"filterMatchesToLoad"in X?X.filterMatchesToLoad??null:g??null,w===!0);return q(z)?z:(_={location:L,basename:a,...z},_)}),async(M,V)=>{if(Zt(M))return M;if(q(M))try{M=new me(M.status,M.statusText,await qn(M))}catch(X){M=X}if(Be(M)&&(M=_l(M)),_){V in _.loaderData&&(_.loaderData[V]=void 0);let X=Yn(i,_,M,y?V:Ce(E,V).route.id);return C(()=>Promise.resolve(X))}else{let X=y?V:Ce(E,E.find(J=>J.route.id===V||J.route.loader)?.route.id||V).route.id,z={matches:E,location:L,basename:a,loaderData:{},actionData:null,errors:{[X]:M},statusCode:re(M)?M.status:500,actionHeaders:{},loaderHeaders:{}};return C(()=>Promise.resolve(z))}});return I(q(k),"Expected a response in query()"),k}catch(_){if(q(_))return _;throw _}}let O=await u(p,L,E,f,R||null,y===!0,null,g||null,w===!0);return q(O)?O:{location:L,basename:a,...O}}async function l(p,{routeId:f,requestContext:g,dataStrategy:y,generateMiddlewareResponse:w}={}){let R=new URL(p.url),C=p.method,P=Ae("",he(R),null,"default"),x=ve(i,P,a);if(g=g??new Ne,!Ar(C)&&C!=="HEAD"&&C!=="OPTIONS")throw te(405,{method:C});if(!x)throw te(404,{pathname:P.pathname});let L=f?x.find(_=>_.route.id===f):dt(x,P);if(f&&!L)throw te(403,{pathname:P.pathname,routeId:f});if(!L)throw te(404,{pathname:P.pathname});if(w)return I(g instanceof Ne,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Xa(x,r,o),await Ga({request:p,unstable_pattern:ct(x.map(k=>k.route.path)),matches:x,params:x[0].params,context:g},async()=>await w(async M=>{let V=await u(M,P,x,g,y||null,!1,L,null,!1),X=O(V);return q(X)?X:typeof X=="string"?new Response(X):Response.json(X)}),k=>{if(Be(k))return Promise.resolve(Nr(k));if(q(k))return Promise.resolve(k);throw k});let E=await u(p,P,x,g,y||null,!1,L,null,!1);return O(E);function O(_){if(q(_))return _;let k=_.errors?Object.values(_.errors)[0]:void 0;if(k!==void 0)throw k;if(_.actionData)return Object.values(_.actionData)[0];if(_.loaderData)return Object.values(_.loaderData)[0]}}async function u(p,f,g,y,w,R,C,P,x){I(p.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(de(p.method))return await c(p,g,C||dt(g,f),y,w,R,C!=null,P,x);let L=await d(p,g,y,w,R,C,P);return q(L)?L:{...L,actionData:null,actionHeaders:{}}}catch(L){if(no(L)&&q(L.result)){if(L.type==="error")throw L.result;return L.result}if(Zt(L))return L;throw L}}async function c(p,f,g,y,w,R,C,P,x){let L;if(!g.route.action&&!g.route.lazy){let _=te(405,{method:p.method,pathname:new URL(p.url).pathname,routeId:g.route.id});if(C)throw _;L={type:"error",error:_}}else{let _=ze(o,r,p,f,g,[],y);L=(await m(p,_,C,y,w))[g.route.id],p.signal.aborted&&Ba(p,C)}if(Ue(L))throw new Response(null,{status:L.response.status,headers:{Location:L.response.headers.get("Location")}});if(C){if(ie(L))throw L.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:L.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(x)if(ie(L)){let _=R?g:Ce(f,g.route.id);return{statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}},matches:f,loaderData:{},errors:{[_.route.id]:L.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:L.data},actionHeaders:L.headers?{[g.route.id]:L.headers}:{},matches:f,loaderData:{},errors:null,statusCode:L.statusCode||200,loaderHeaders:{}};let E=new Request(p.url,{headers:p.headers,redirect:p.redirect,signal:p.signal});if(ie(L)){let _=R?g:Ce(f,g.route.id);return{...await d(E,f,y,w,R,null,P,[_.route.id,L]),statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}}}}return{...await d(E,f,y,w,R,null,P),actionData:{[g.route.id]:L.data},...L.statusCode?{statusCode:L.statusCode}:{},actionHeaders:L.headers?{[g.route.id]:L.headers}:{}}}async function d(p,f,g,y,w,R,C,P){let x=R!=null;if(x&&!R?.route.loader&&!R?.route.lazy)throw te(400,{method:p.method,pathname:new URL(p.url).pathname,routeId:R?.route.id});let L;if(R)L=ze(o,r,p,f,R,[],g);else{let _=P&&ie(P[1])?f.findIndex(M=>M.route.id===P[0])-1:void 0,k=ct(f.map(M=>M.route.path));L=f.map((M,V)=>_!=null&&V>_?Dt(o,r,p,k,M,[],g,!1):Dt(o,r,p,k,M,[],g,(M.route.loader||M.route.lazy)!=null&&(!C||C(M))))}if(!y&&!L.some(_=>_.shouldLoad))return{matches:f,loaderData:{},errors:P&&ie(P[1])?{[P[0]]:P[1].error}:null,statusCode:200,loaderHeaders:{}};let E=await m(p,L,x,g,y);return p.signal.aborted&&Ba(p,x),{...ro(f,E,P,!0,w),matches:f}}async function m(p,f,g,y,w){let R=await Zn(w||Fr,p,f,null,y,!0),C={};return await Promise.all(f.map(async P=>{if(!(P.route.id in R))return;let x=R[P.route.id];if(oo(x)){let L=x.result;throw to(L,p,P.route.id,f,a)}if(g){if(q(x.result))throw x;if(Be(x.result))throw Nr(x.result)}C[P.route.id]=await eo(x)})),C}return{dataRoutes:i,query:s,queryRoute:l}}function Yn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:re(r)?r.status:500,errors:{[n]:r}}}function Ba(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 bl(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function kr(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=ir(a||".",or(i),ne(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=Zr(l.search);if(s.route.index&&!u)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!s.route.index&&u){let c=new URLSearchParams(l.search),d=c.getAll("index");c.delete("index"),d.filter(p=>p).forEach(p=>c.append("index",p));let m=c.toString();l.search=m?`?${m}`:""}}return r!=="/"&&(l.pathname=nl({basename:r,pathname:l.pathname})),he(l)}function Wa(e,t,r){if(!r||!bl(r))return{path:t};if(r.formMethod&&!Ar(r.formMethod))return{path:t,error:te(405,{method:r.formMethod})};let a=()=>({path:t,error:te(400,{type:"invalid-body"})}),o=(r.formMethod||"get").toUpperCase(),i=ao(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!de(o))return a();let d=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,[p,f])=>`${m}${p}=${f}
|
|
2
2
|
`,""):String(r.body);return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:void 0,text:d}}}else if(r.formEncType==="application/json"){if(!de(o))return a();try{let d=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:d,text:void 0}}}catch{return a()}}}I(typeof FormData=="function","FormData is not available in this environment");let s,l;if(r.formData)s=Mr(r.formData),l=r.formData;else if(r.body instanceof FormData)s=Mr(r.body),l=r.body;else if(r.body instanceof URLSearchParams)s=r.body,l=Za(s);else if(r.body==null)s=new URLSearchParams,l=new FormData;else try{s=new URLSearchParams(r.body),l=Za(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(de(u.formMethod))return{path:t,submission:u};let c=xe(t);return e&&c.search&&Zr(c.search)&&s.append("index",""),c.search=`?${s}`,{path:he(c),submission:u}}function Va(e,t,r,a,n,o,i,s,l,u,c,d,m,p,f,g,y,w,R,C){let P=C?ie(C[1])?C[1].error:C[1].data:void 0,x=n.createURL(o.location),L=n.createURL(l),E;if(c&&o.errors){let z=Object.keys(o.errors)[0];E=i.findIndex(J=>J.route.id===z)}else if(C&&ie(C[1])){let z=C[0];E=i.findIndex(J=>J.route.id===z)-1}let O=C?C[1].statusCode:void 0,_=O&&O>=400,k={currentUrl:x,currentParams:o.matches[0]?.params||{},nextUrl:L,nextParams:i[0].params,...s,actionResult:P,actionStatus:O},M=ct(i.map(z=>z.route.path)),V=i.map((z,J)=>{let{route:le}=z,Y=null;if(E!=null&&J>E?Y=!1:le.lazy?Y=!0:Gr(le)?c?Y=Or(le,o.loaderData,o.errors):Sl(o.loaderData,o.matches[J],z)&&(Y=!0):Y=!1,Y!==null)return Dt(r,a,e,M,z,u,t,Y);let Ee=_?!1:d||x.pathname+x.search===L.pathname+L.search||x.search!==L.search||Cl(o.matches[J],z),pe={...k,defaultShouldRevalidate:Ee},Pe=Qt(z,pe);return Dt(r,a,e,M,z,u,t,Pe,pe)}),X=[];return f.forEach((z,J)=>{if(c||!i.some(Le=>Le.route.id===z.routeId)||p.has(J))return;let le=o.fetchers.get(J),Y=le&&le.state!=="idle"&&le.data===void 0,Ee=ve(y,z.path,w);if(!Ee){if(R&&Y)return;X.push({key:J,routeId:z.routeId,path:z.path,matches:null,match:null,request:null,controller:null});return}if(g.has(J))return;let pe=dt(Ee,z.path),Pe=new AbortController,ye=st(n,z.path,Pe.signal),be=null;if(m.has(J))m.delete(J),be=ze(r,a,ye,Ee,pe,u,t);else if(Y)d&&(be=ze(r,a,ye,Ee,pe,u,t));else{let Le={...k,defaultShouldRevalidate:_?!1:d};Qt(pe,Le)&&(be=ze(r,a,ye,Ee,pe,u,t,Le))}be&&X.push({key:J,routeId:z.routeId,path:z.path,matches:be,match:pe,request:ye,controller:Pe})}),{dsMatches:V,revalidatingFetchers:X}}function Gr(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Or(e,t,r){if(e.lazy)return!0;if(!Gr(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 Sl(e,t,r){let a=!t||r.route.id!==t.route.id,n=!e.hasOwnProperty(r.route.id);return a||n}function Cl(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Qt(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function Ya(e,t,r,a,n,o){let i;if(e){let u=a[e];I(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 c=i.find(d=>Jn(u,d));c?l.push({existingRoute:c,newRoute:u}):s.push(u)}),s.length>0){let u=We(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:c,newRoute:d}=l[u],m=c,[p]=We([d],n,[],{},!0);Object.assign(m,{element:p.element?p.element:m.element,errorElement:p.errorElement?p.errorElement:m.errorElement,hydrateFallbackElement:p.hydrateFallbackElement?p.hydrateFallbackElement:m.hydrateFallbackElement})}}function Jn(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=>Jn(r,n))):!1}var Ja=new WeakMap,Qr=({key:e,route:t,manifest:r,mapRouteProperties:a})=>{let n=r[t.id];if(I(n,"No route found in manifest"),!n.lazy||typeof n.lazy!="object")return;let o=n.lazy[e];if(!o)return;let i=Ja.get(n);i||(i={},Ja.set(n,i));let s=i[e];if(s)return s;let l=(async()=>{let u=Wi(e),d=n[e]!==void 0&&e!=="hasErrorBoundary";if(u)K(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(d)K(!1,`Route "${n.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let m=await o();m!=null&&(Object.assign(n,{[e]:m}),Object.assign(n,a(n)))}typeof n.lazy=="object"&&(n.lazy[e]=void 0,Object.values(n.lazy).every(m=>m===void 0)&&(n.lazy=void 0))})();return i[e]=l,l},Ka=new WeakMap;function xl(e,t,r,a,n){let o=r[e.id];if(I(o,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let c=Ka.get(o);if(c)return{lazyRoutePromise:c,lazyHandlerPromise:c};let d=(async()=>{I(typeof e.lazy=="function","No lazy route function found");let m=await e.lazy(),p={};for(let f in m){let g=m[f];if(g===void 0)continue;let y=Yi(f),R=o[f]!==void 0&&f!=="hasErrorBoundary";y?K(!y,"Route property "+f+" is not a supported property to be returned from a lazy route function. This property will be ignored."):R?K(!R,`Route "${o.id}" has a static property "${f}" defined but its lazy function is also returning a value for this property. The lazy route property "${f}" will be ignored.`):p[f]=g}Object.assign(o,p),Object.assign(o,{...a(o),lazy:void 0})})();return Ka.set(o,d),d.catch(()=>{}),{lazyRoutePromise:d,lazyHandlerPromise:d}}let i=Object.keys(e.lazy),s=[],l;for(let c of i){if(n&&n.includes(c))continue;let d=Qr({key:c,route:e,manifest:r,mapRouteProperties:a});d&&(s.push(d),c===t&&(l=d))}let u=s.length>0?Promise.all(s).then(()=>{}):void 0;return u?.catch(()=>{}),l?.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:l}}function Pl(e){return e!==void 0}function Xa(e,t,r){let a=e.map(({route:n})=>{if(!(typeof n.lazy!="object"||!n.lazy.middleware))return Qr({key:"middleware",route:n,manifest:t,mapRouteProperties:r})}).filter(Pl);return a.length>0?Promise.all(a):void 0}async function Fr(e){let t=e.matches.filter(n=>n.shouldLoad),r={};return(await Promise.all(t.map(n=>n.resolve()))).forEach((n,o)=>{r[t[o].route.id]=n}),r}async function Ll(e){return e.matches.some(t=>t.route.middleware)?Kn(e,()=>Fr(e)):Fr(e)}function Ga(e,t,r){return Xn(e,t,a,q,r);function a(n){return Be(n)?Nr(n):n}}function Kn(e,t){return Xn(e,t,a=>a,kl,r);function r(a,n,o){if(o)return Promise.resolve(Object.assign(o.value,{[n]:{type:"error",result:a}}));{let{matches:i}=e,s=Math.min(Math.max(i.findIndex(u=>u.route.id===n),0),Math.max(i.findIndex(u=>u.unstable_shouldCallHandler()),0)),l=Ce(i,i[s].route.id).route.id;return Promise.resolve({[l]:{type:"error",result:a}})}}}async function Xn(e,t,r,a,n){let{matches:o,request:i,params:s,context:l,unstable_pattern:u}=e,c=o.flatMap(m=>m.route.middleware?m.route.middleware.map(p=>[m.route.id,p]):[]);return await Gn({request:i,params:s,context:l,unstable_pattern:u},c,t,r,a,n)}async function Gn(e,t,r,a,n,o,i=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??new Error(`Request aborted: ${s.method} ${s.url}`);let l=t[i];if(!l)return await r();let[u,c]=l,d,m=async()=>{if(d)throw new Error("You may only call `next()` once per middleware");try{return d={value:await Gn(e,t,r,a,n,o,i+1)},d.value}catch(p){return d={value:await o(p,u,d)},d.value}};try{let p=await c(e,m),f=p!=null?a(p):void 0;return n(f)?f:d?f??d.value:(d={value:await m()},d.value)}catch(p){return await o(p,u,d)}}function Qn(e,t,r,a,n){let o=Qr({key:"middleware",route:a.route,manifest:t,mapRouteProperties:e}),i=xl(a.route,de(r.method)?"action":"loader",t,e,n);return{middleware:o,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function Dt(e,t,r,a,n,o,i,s,l=null){let u=!1,c=Qn(e,t,r,n,o);return{...n,_lazyPromises:c,shouldLoad:s,unstable_shouldRevalidateArgs:l,unstable_shouldCallHandler(d){return u=!0,l?typeof d=="boolean"?Qt(n,{...l,defaultShouldRevalidate:d}):Qt(n,l):s},resolve(d){let{lazy:m,loader:p,middleware:f}=n.route,g=u||s||d&&!de(r.method)&&(m||p),y=f&&f.length>0&&!p&&!m;return g&&(de(r.method)||!y)?Dl({request:r,unstable_pattern:a,match:n,lazyHandlerPromise:c?.handler,lazyRoutePromise:c?.route,handlerOverride:d,scopedContext:i}):Promise.resolve({type:"data",result:void 0})}}}function ze(e,t,r,a,n,o,i,s=null){return a.map(l=>l.route.id!==n.route.id?{...l,shouldLoad:!1,unstable_shouldRevalidateArgs:s,unstable_shouldCallHandler:()=>!1,_lazyPromises:Qn(e,t,r,l,o),resolve:()=>Promise.resolve({type:"data",result:void 0})}:Dt(e,t,r,ct(a.map(u=>u.route.path)),l,o,i,!0,s))}async function Zn(e,t,r,a,n,o){r.some(u=>u._lazyPromises?.middleware)&&await Promise.all(r.map(u=>u._lazyPromises?.middleware));let i={request:t,unstable_pattern:ct(r.map(u=>u.route.path)),params:r[0].params,context:n,matches:r},l=await e({...i,fetcherKey:a,runClientMiddleware:o?()=>{throw new 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`")}:u=>{let c=i;return Kn(c,()=>u({...c,fetcherKey:a,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(r.flatMap(u=>[u._lazyPromises?.handler,u._lazyPromises?.route]))}catch{}return l}async function Dl({request:e,unstable_pattern:t,match:r,lazyHandlerPromise:a,lazyRoutePromise:n,handlerOverride:o,scopedContext:i}){let s,l,u=de(e.method),c=u?"action":"loader",d=m=>{let p,f=new Promise((w,R)=>p=R);l=()=>p(),e.signal.addEventListener("abort",l);let g=w=>typeof m!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${c}" [routeId: ${r.route.id}]`)):m({request:e,unstable_pattern:t,params:r.params,context:i},...w!==void 0?[w]:[]),y=(async()=>{try{return{type:"data",result:await(o?o(R=>g(R)):g())}}catch(w){return{type:"error",result:w}}})();return Promise.race([y,f])};try{let m=u?r.route.action:r.route.loader;if(a||n)if(m){let p,[f]=await Promise.all([d(m).catch(g=>{p=g}),a,n]);if(p!==void 0)throw p;s=f}else{await a;let p=u?r.route.action:r.route.loader;if(p)[s]=await Promise.all([d(p),n]);else if(c==="action"){let f=new URL(e.url),g=f.pathname+f.search;throw te(405,{method:e.method,pathname:g,routeId:r.route.id})}else return{type:"data",result:void 0}}else if(m)s=await d(m);else{let p=new URL(e.url),f=p.pathname+p.search;throw te(404,{pathname:f})}}catch(m){return{type:"error",result:m}}finally{l&&e.signal.removeEventListener("abort",l)}return s}async function qn(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function eo(e){let{result:t,type:r}=e;if(q(t)){let a;try{a=await qn(t)}catch(n){return{type:"error",error:n}}return r==="error"?{type:"error",error:new me(t.status,t.statusText,a),statusCode:t.status,headers:t.headers}:{type:"data",data:a,statusCode:t.status,headers:t.headers}}return r==="error"?Be(t)?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:new me(t.init?.status||500,void 0,t.data),statusCode:re(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:re(t)?t.status:void 0}:Be(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}}function to(e,t,r,a,n){let o=e.headers.get("Location");if(I(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!nr(o)){let i=a.slice(0,a.findIndex(s=>s.route.id===r)+1);o=kr(new URL(t.url),i,n,o),e.headers.set("Location",o)}return e}function Qa(e,t,r){if(nr(e)){let a=e,n=a.startsWith("//")?new URL(t.protocol+a):new URL(a),o=ne(n.pathname,r)!=null;if(n.origin===t.origin&&o)return n.pathname+n.search+n.hash}return e}function st(e,t,r,a){let n=e.createURL(ao(t)).toString(),o={signal:r};if(a&&de(a.formMethod)){let{formMethod:i,formEncType:s}=a;o.method=i.toUpperCase(),s==="application/json"?(o.headers=new Headers({"Content-Type":s}),o.body=JSON.stringify(a.json)):s==="text/plain"?o.body=a.text:s==="application/x-www-form-urlencoded"&&a.formData?o.body=Mr(a.formData):o.body=a.formData}return new Request(n,o)}function Mr(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,typeof a=="string"?a:a.name);return t}function Za(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function ro(e,t,r,a=!1,n=!1){let o={},i=null,s,l=!1,u={},c=r&&ie(r[1])?r[1].error:void 0;return e.forEach(d=>{if(!(d.route.id in t))return;let m=d.route.id,p=t[m];if(I(!Ue(p),"Cannot handle redirect results in processLoaderData"),ie(p)){let f=p.error;if(c!==void 0&&(f=c,c=void 0),i=i||{},n)i[m]=f;else{let g=Ce(e,m);i[g.route.id]==null&&(i[g.route.id]=f)}a||(o[m]=Wn),l||(l=!0,s=re(p.error)?p.error.status:500),p.headers&&(u[m]=p.headers)}else o[m]=p.data,p.statusCode&&p.statusCode!==200&&!l&&(s=p.statusCode),p.headers&&(u[m]=p.headers)}),c!==void 0&&r&&(i={[r[0]]:c},r[2]&&(o[r[2]]=void 0)),{loaderData:o,errors:i,statusCode:s||200,loaderHeaders:u}}function qa(e,t,r,a,n,o){let{loaderData:i,errors:s}=ro(t,r,a);return n.filter(l=>!l.matches||l.matches.some(u=>u.shouldLoad)).forEach(l=>{let{key:u,match:c,controller:d}=l;if(d&&d.signal.aborted)return;let m=o[u];if(I(m,"Did not find corresponding fetcher result"),ie(m)){let p=Ce(e.matches,c?.route.id);s&&s[p.route.id]||(s={...s,[p.route.id]:m.error}),e.fetchers.delete(u)}else if(Ue(m))I(!1,"Unhandled fetcher revalidation redirect");else{let p=Me(m.data);e.fetchers.set(u,p)}}),{loaderData:i,errors:s}}function en(e,t,r,a){let n=Object.entries(t).filter(([,o])=>o!==Wn).reduce((o,[i,s])=>(o[i]=s,o),{});for(let o of r){let i=o.route.id;if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&o.route.loader&&(n[i]=e[i]),a&&a.hasOwnProperty(i))break}return n}function tn(e){return e?ie(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Ce(e,t){return(t?e.slice(0,e.findIndex(a=>a.route.id===t)+1):[...e]).reverse().find(a=>a.route.hasErrorBoundary===!0)||e[0]}function ut(e){let t=e.length===1?e[0]:e.find(r=>r.index||!r.path||r.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function te(e,{pathname:t,routeId:r,method:a,type:n,message:o}={}){let i="Unknown Server Error",s="Unknown @remix-run/router error";return e===400?(i="Bad Request",a&&t&&r?s=`You made a ${a} request to "${t}" but did not provide a \`loader\` for route "${r}", so there is no way to handle the request.`:n==="invalid-body"&&(s="Unable to encode submission body")):e===403?(i="Forbidden",s=`Route "${r}" does not match URL "${t}"`):e===404?(i="Not Found",s=`No route matches URL "${t}"`):e===405&&(i="Method Not Allowed",a&&t&&r?s=`You made a ${a.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${r}", so there is no way to handle the request.`:a&&(s=`Invalid request method "${a.toUpperCase()}"`)),new me(e||500,i,new Error(s),!0)}function Ut(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[a,n]=t[r];if(Ue(n))return{key:a,result:n}}}function ao(e){let t=typeof e=="string"?xe(e):e;return he({...t,hash:""})}function Tl(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function Nr(e){return Response.json(e.data,e.init??void 0)}function _l(e){return new me(e.init?.status??500,e.init?.statusText??"Internal Server Error",e.data)}function kl(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,r])=>typeof t=="string"&&no(r))}function no(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function oo(e){return q(e.result)&&Un.has(e.result.status)}function ie(e){return e.type==="error"}function Ue(e){return(e&&e.type)==="redirect"}function Be(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function q(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function sr(e){return Un.has(e)}function Zt(e){return q(e)&&sr(e.status)&&e.headers.has("Location")}function Ar(e){return Rl.has(e.toUpperCase())}function de(e){return gl.has(e.toUpperCase())}function Zr(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function dt(e,t){let r=typeof t=="string"?xe(t).search:t.search;if(e[e.length-1].route.index&&Zr(r||""))return e[e.length-1];let a=Nn(e);return a[a.length-1]}function rn(e){let{formMethod:t,formAction:r,formEncType:a,text:n,formData:o,json:i}=e;if(!(!t||!r||!a)){if(n!=null)return{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:void 0,text:n};if(o!=null)return{formMethod:t,formAction:r,formEncType:a,formData:o,json:void 0,text:void 0};if(i!==void 0)return{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:i,text:void 0}}}function Sr(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Ol(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function bt(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 Fl(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Me(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 Ml(e,t){try{let r=e.sessionStorage.getItem(Bn);if(r){let a=JSON.parse(r);for(let[n,o]of Object.entries(a||{}))o&&Array.isArray(o)&&t.set(n,new Set(o||[]))}}catch{}}function Nl(e,t){if(t.size>0){let r={};for(let[a,n]of t)r[a]=[...n];try{e.sessionStorage.setItem(Bn,JSON.stringify(r))}catch(a){K(!1,`Failed to save applied view transitions in sessionStorage (${a}).`)}}}function Al(){let e,t,r=new Promise((a,n)=>{e=async o=>{a(o);try{await r}catch{}},t=async o=>{n(o);try{await r}catch{}}});return{promise:r,resolve:e,reject:t}}var $e=h.createContext(null);$e.displayName="DataRouter";var Ye=h.createContext(null);Ye.displayName="DataRouterState";var io=h.createContext(!1);function $l(){return h.useContext(io)}var ur=h.createContext({isTransitioning:!1});ur.displayName="ViewTransition";var cr=h.createContext(new Map);cr.displayName="Fetchers";var mt=h.createContext(null);mt.displayName="Await";var fc=e=>h.createElement(mt.Provider,e),ge=h.createContext(null);ge.displayName="Navigation";var pt=h.createContext(null);pt.displayName="Location";var we=h.createContext({outlet:null,matches:[],isDataRoute:!1});we.displayName="Route";var qr=h.createContext(null);qr.displayName="RouteError";function Il(e,{relative:t}={}){I(rt(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:a}=h.useContext(ge),{hash:n,pathname:o,search:i}=Ot(e,{relative:t}),s=o;return r!=="/"&&(s=o==="/"?r:_e([r,o])),a.createHref({pathname:s,search:i,hash:n})}function rt(){return h.useContext(pt)!=null}function Re(){return I(rt(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(pt).location}function hc(){return h.useContext(pt).navigationType}function mc(e){I(rt(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=Re();return h.useMemo(()=>Lt(e,Mn(t)),[t,e])}var lo="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function so(e){h.useContext(ge).static||h.useLayoutEffect(e)}function ea(){let{isDataRoute:e}=h.useContext(we);return e?Zl():Hl()}function Hl(){I(rt(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext($e),{basename:t,navigator:r}=h.useContext(ge),{matches:a}=h.useContext(we),{pathname:n}=Re(),o=JSON.stringify(or(a)),i=h.useRef(!1);return so(()=>{i.current=!0}),h.useCallback((l,u={})=>{if(K(i.current,lo),!i.current)return;if(typeof l=="number"){r.go(l);return}let c=ir(l,JSON.parse(o),n,u.relative==="path");e==null&&t!=="/"&&(c.pathname=c.pathname==="/"?t:_e([t,c.pathname])),(u.replace?r.replace:r.push)(c,u.state,u)},[t,r,o,n,e])}var uo=h.createContext(null);function pc(){return h.useContext(uo)}function jl(e){let t=h.useContext(we).outlet;return h.useMemo(()=>t&&h.createElement(uo.Provider,{value:e},t),[t,e])}function ta(){let{matches:e}=h.useContext(we),t=e[e.length-1];return t?t.params:{}}function Ot(e,{relative:t}={}){let{matches:r}=h.useContext(we),{pathname:a}=Re(),n=JSON.stringify(or(r));return h.useMemo(()=>ir(e,JSON.parse(n),a,t==="path"),[e,n,a,t])}function Ul(e,t){return ra(e,t)}function ra(e,t,r,a,n){I(rt(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(ge),{matches:i}=h.useContext(we),s=i[i.length-1],l=s?s.params:{},u=s?s.pathname:"/",c=s?s.pathnameBase:"/",d=s&&s.route;{let R=d&&d.path||"";fo(u,!d||R.endsWith("*")||R.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${R}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
3
3
|
|
|
4
4
|
Please change the parent <Route path="${R}"> to <Route path="${R==="/"?"*":`${R}/*`}">.`)}let m=Re(),p;if(t){let R=typeof t=="string"?xe(t):t;I(c==="/"||R.pathname?.startsWith(c),`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 "${c}" but pathname "${R.pathname}" was given in the \`location\` prop.`),p=R}else p=m;let f=p.pathname||"/",g=f;if(c!=="/"){let R=c.replace(/^\//,"").split("/");g="/"+f.replace(/^\//,"").split("/").slice(R.length).join("/")}let y=ve(e,{pathname:g});K(d||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),K(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=co(y&&y.map(R=>Object.assign({},R,{params:Object.assign({},l,R.params),pathname:_e([c,o.encodeLocation?o.encodeLocation(R.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?c:_e([c,o.encodeLocation?o.encodeLocation(R.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),i,r,a,n);return t&&w?h.createElement(pt.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},w):w}function zl(){let e=dr(),t=re(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",n={padding:"0.5rem",backgroundColor:a},o={padding:"2px 4px",backgroundColor:a},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:o},"ErrorBoundary")," or"," ",h.createElement("code",{style:o},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:n},r):null,i)}var Bl=h.createElement(zl,null),Wl=class extends h.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?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(){return this.state.error!==void 0?h.createElement(we.Provider,{value:this.props.routeContext},h.createElement(qr.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Vl({routeContext:e,match:t,children:r}){let a=h.useContext($e);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),h.createElement(we.Provider,{value:e},r)}function co(e,t=[],r=null,a=null,n=null){if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,i=r?.errors;if(i!=null){let c=o.findIndex(d=>d.route.id&&i?.[d.route.id]!==void 0);I(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,l=-1;if(r)for(let c=0;c<o.length;c++){let d=o[c];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(l=c),d.route.id){let{loaderData:m,errors:p}=r,f=d.route.loader&&!m.hasOwnProperty(d.route.id)&&(!p||p[d.route.id]===void 0);if(d.route.lazy||f){s=!0,l>=0?o=o.slice(0,l+1):o=[o[0]];break}}}let u=r&&a?(c,d)=>{a(c,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:d})}:void 0;return o.reduceRight((c,d,m)=>{let p,f=!1,g=null,y=null;r&&(p=i&&d.route.id?i[d.route.id]:void 0,g=d.route.errorElement||Bl,s&&(l<0&&m===0?(fo("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,y=null):l===m&&(f=!0,y=d.route.hydrateFallbackElement||null)));let w=t.concat(o.slice(0,m+1)),R=()=>{let C;return p?C=g:f?C=y:d.route.Component?C=h.createElement(d.route.Component,null):d.route.element?C=d.route.element:C=c,h.createElement(Vl,{match:d,routeContext:{outlet:c,matches:w,isDataRoute:r!=null},children:C})};return r&&(d.route.ErrorBoundary||d.route.errorElement||m===0)?h.createElement(Wl,{location:r.location,revalidation:r.revalidation,component:g,error:p,children:R(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:u}):R()},null)}function aa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function na(e){let t=h.useContext($e);return I(t,aa(e)),t}function Ie(e){let t=h.useContext(Ye);return I(t,aa(e)),t}function Yl(e){let t=h.useContext(we);return I(t,aa(e)),t}function yt(e){let t=Yl(e),r=t.matches[t.matches.length-1];return I(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Jl(){return yt("useRouteId")}function Kl(){return Ie("useNavigation").navigation}function yc(){let e=na("useRevalidator"),t=Ie("useRevalidator"),r=h.useCallback(async()=>{await e.router.revalidate()},[e.router]);return h.useMemo(()=>({revalidate:r,state:t.revalidation}),[r,t.revalidation])}function oa(){let{matches:e,loaderData:t}=Ie("useMatches");return h.useMemo(()=>e.map(r=>_n(r,t)),[e,t])}function ia(){let e=Ie("useLoaderData"),t=yt("useLoaderData");return e.loaderData[t]}function vc(e){return Ie("useRouteLoaderData").loaderData[e]}function la(){let e=Ie("useActionData"),t=yt("useLoaderData");return e.actionData?e.actionData[t]:void 0}function dr(){let e=h.useContext(qr),t=Ie("useRouteError"),r=yt("useRouteError");return e!==void 0?e:t.errors?.[r]}function Xl(){return h.useContext(mt)?._data}function gc(){return h.useContext(mt)?._error}var Gl=0;function Ql(e){let{router:t,basename:r}=na("useBlocker"),a=Ie("useBlocker"),[n,o]=h.useState(""),i=h.useCallback(s=>{if(typeof e!="function")return!!e;if(r==="/")return e(s);let{currentLocation:l,nextLocation:u,historyAction:c}=s;return e({currentLocation:{...l,pathname:ne(l.pathname,r)||l.pathname},nextLocation:{...u,pathname:ne(u.pathname,r)||u.pathname},historyAction:c})},[r,e]);return h.useEffect(()=>{let s=String(++Gl);return o(s),()=>t.deleteBlocker(s)},[t]),h.useEffect(()=>{n!==""&&t.getBlocker(n,i)},[t,n,i]),n&&a.blockers.has(n)?a.blockers.get(n):et}function Zl(){let{router:e}=na("useNavigate"),t=yt("useNavigate"),r=h.useRef(!1);return so(()=>{r.current=!0}),h.useCallback(async(n,o={})=>{K(r.current,lo),r.current&&(typeof n=="number"?e.navigate(n):await e.navigate(n,{fromRouteId:t,...o}))},[e,t])}var an={};function fo(e,t,r){!t&&!an[e]&&(an[e]=!0,K(!1,r))}function wc(...e){const t=yt("useRoute"),r=e[0]??t,a=Ie("useRoute"),n=a.matches.find(({route:o})=>o.id===r);if(n!==void 0)return{handle:n.route.handle,loaderData:a.loaderData[r],actionData:a.actionData?.[r]}}var nn={};function Tt(e,t){!e&&!nn[t]&&(nn[t]=!0,console.warn(t))}function Ft(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&K(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:h.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&K(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:h.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&K(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:h.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var sa=["HydrateFallback","hydrateFallbackElement"];function ql(e,t){return Xr({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:xn({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:e,hydrationRouteProperties:sa,mapRouteProperties:Ft,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,unstable_instrumentations:t?.unstable_instrumentations}).initialize()}var es=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",e(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",t(r))}})}};function ts({router:e,flushSync:t,unstable_onError:r}){let[a,n]=h.useState(e.state),[o,i]=h.useState(),[s,l]=h.useState({isTransitioning:!1}),[u,c]=h.useState(),[d,m]=h.useState(),[p,f]=h.useState(),g=h.useRef(new Map),y=h.useCallback(x=>{n(L=>(x.errors&&r&&Object.entries(x.errors).forEach(([E,O])=>{L.errors?.[E]!==O&&r(O,{location:x.location,params:x.matches[0]?.params??{}})}),x))},[r]),w=h.useCallback((x,{deletedFetchers:L,flushSync:E,viewTransitionOpts:O})=>{x.fetchers.forEach((k,M)=>{k.data!==void 0&&g.current.set(M,k.data)}),L.forEach(k=>g.current.delete(k)),Tt(E===!1||t!=null,'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 _=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(Tt(O==null||_,"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."),!O||!_){t&&E?t(()=>y(x)):h.startTransition(()=>y(x));return}if(t&&E){t(()=>{d&&(u&&u.resolve(),d.skipTransition()),l({isTransitioning:!0,flushSync:!0,currentLocation:O.currentLocation,nextLocation:O.nextLocation})});let k=e.window.document.startViewTransition(()=>{t(()=>y(x))});k.finished.finally(()=>{t(()=>{c(void 0),m(void 0),i(void 0),l({isTransitioning:!1})})}),t(()=>m(k));return}d?(u&&u.resolve(),d.skipTransition(),f({state:x,currentLocation:O.currentLocation,nextLocation:O.nextLocation})):(i(x),l({isTransitioning:!0,flushSync:!1,currentLocation:O.currentLocation,nextLocation:O.nextLocation}))},[e.window,t,d,u,y]);h.useLayoutEffect(()=>e.subscribe(w),[e,w]),h.useEffect(()=>{s.isTransitioning&&!s.flushSync&&c(new es)},[s]),h.useEffect(()=>{if(u&&o&&e.window){let x=o,L=u.promise,E=e.window.document.startViewTransition(async()=>{h.startTransition(()=>y(x)),await L});E.finished.finally(()=>{c(void 0),m(void 0),i(void 0),l({isTransitioning:!1})}),m(E)}},[o,u,e.window,y]),h.useEffect(()=>{u&&o&&a.location.key===o.location.key&&u.resolve()},[u,d,a.location,o]),h.useEffect(()=>{!s.isTransitioning&&p&&(i(p.state),l({isTransitioning:!0,flushSync:!1,currentLocation:p.currentLocation,nextLocation:p.nextLocation}),f(void 0))},[s.isTransitioning,p]);let R=h.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:x=>e.navigate(x),push:(x,L,E)=>e.navigate(x,{state:L,preventScrollReset:E?.preventScrollReset}),replace:(x,L,E)=>e.navigate(x,{replace:!0,state:L,preventScrollReset:E?.preventScrollReset})}),[e]),C=e.basename||"/",P=h.useMemo(()=>({router:e,navigator:R,static:!1,basename:C,unstable_onError:r}),[e,R,C,r]);return h.createElement(h.Fragment,null,h.createElement($e.Provider,{value:P},h.createElement(Ye.Provider,{value:a},h.createElement(cr.Provider,{value:g.current},h.createElement(ur.Provider,{value:s},h.createElement(at,{basename:C,location:a.location,navigationType:a.historyAction,navigator:R},h.createElement(rs,{routes:e.routes,future:e.future,state:a,unstable_onError:r})))))),null)}var rs=h.memo(as);function as({routes:e,future:t,state:r,unstable_onError:a}){return ra(e,void 0,r,a,t)}function Rc({basename:e,children:t,initialEntries:r,initialIndex:a}){let n=h.useRef();n.current==null&&(n.current=xn({initialEntries:r,initialIndex:a,v5Compat:!0}));let o=n.current,[i,s]=h.useState({action:o.action,location:o.location}),l=h.useCallback(u=>{h.startTransition(()=>s(u))},[s]);return h.useLayoutEffect(()=>o.listen(l),[o,l]),h.createElement(at,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o})}function Ec({to:e,replace:t,state:r,relative:a}){I(rt(),"<Navigate> may be used only in the context of a <Router> component.");let{static:n}=h.useContext(ge);K(!n,"<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:o}=h.useContext(we),{pathname:i}=Re(),s=ea(),l=ir(e,or(o),i,a==="path"),u=JSON.stringify(l);return h.useEffect(()=>{s(JSON.parse(u),{replace:t,state:r,relative:a})},[s,u,a,t,r]),null}function ns(e){return jl(e.context)}function os(e){I(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function at({basename:e="/",children:t=null,location:r,navigationType:a="POP",navigator:n,static:o=!1}){I(!rt(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=h.useMemo(()=>({basename:i,navigator:n,static:o,future:{}}),[i,n,o]);typeof r=="string"&&(r=xe(r));let{pathname:l="/",search:u="",hash:c="",state:d=null,key:m="default"}=r,p=h.useMemo(()=>{let f=ne(l,i);return f==null?null:{location:{pathname:f,search:u,hash:c,state:d,key:m},navigationType:a}},[i,l,u,c,d,m,a]);return K(p!=null,`<Router basename="${i}"> is not able to match the URL "${l}${u}${c}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:h.createElement(ge.Provider,{value:s},h.createElement(pt.Provider,{children:t,value:p}))}function bc({children:e,location:t}){return Ul(qt(e),t)}function Sc({children:e,errorElement:t,resolve:r}){let a=h.useContext($e),n=h.useContext(Ye),o=h.useCallback((i,s)=>{a&&a.unstable_onError&&n&&a.unstable_onError(i,{location:n.location,params:n.matches?.[0]?.params||{},errorInfo:s})},[a,n]);return h.createElement(is,{resolve:r,errorElement:t,onError:o},h.createElement(ls,null,e))}var is=class extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:r}=this.props,a=null,n=0;if(!(r instanceof Promise))n=1,a=Promise.resolve(),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_data",{get:()=>r});else if(this.state.error){n=2;let o=this.state.error;a=Promise.reject().catch(()=>{}),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_error",{get:()=>o})}else r._tracked?(a=r,n="_error"in a?2:"_data"in a?1:0):(n=0,Object.defineProperty(r,"_tracked",{get:()=>!0}),a=r.then(o=>Object.defineProperty(r,"_data",{get:()=>o}),o=>{this.props.onError?.(o),Object.defineProperty(r,"_error",{get:()=>o})}));if(n===2&&!t)throw a._error;if(n===2)return h.createElement(mt.Provider,{value:a,children:t});if(n===1)return h.createElement(mt.Provider,{value:a,children:e});throw a}};function ls({children:e}){let t=Xl(),r=typeof e=="function"?e(t):e;return h.createElement(h.Fragment,null,r)}function qt(e,t=[]){let r=[];return h.Children.forEach(e,(a,n)=>{if(!h.isValidElement(a))return;let o=[...t,n];if(a.type===h.Fragment){r.push.apply(r,qt(a.props.children,o));return}I(a.type===os,`[${typeof a.type=="string"?a.type:a.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),I(!a.props.index||!a.props.children,"An index route cannot have child routes.");let i={id:a.props.id||o.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,middleware:a.props.middleware,loader:a.props.loader,action:a.props.action,hydrateFallbackElement:a.props.hydrateFallbackElement,HydrateFallback:a.props.HydrateFallback,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.hasErrorBoundary===!0||a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(i.children=qt(a.props.children,o)),r.push(i)}),r}var Cc=qt;function xc(e){return co(e)}function ho(){return{params:ta(),loaderData:ia(),actionData:la(),matches:oa()}}function Pc({children:e}){const t=ho();return h.cloneElement(e,t)}function ss(e){return function(){const r=ho();return h.createElement(e,r)}}function mo(){return{params:ta(),loaderData:ia(),actionData:la()}}function Lc({children:e}){const t=mo();return h.cloneElement(e,t)}function us(e){return function(){const r=mo();return h.createElement(e,r)}}function po(){return{params:ta(),loaderData:ia(),actionData:la(),error:dr()}}function Dc({children:e}){const t=po();return h.cloneElement(e,t)}function cs(e){return function(){const r=po();return h.createElement(e,r)}}var Jt="get",Kt="application/x-www-form-urlencoded";function fr(e){return e!=null&&typeof e.tagName=="string"}function ds(e){return fr(e)&&e.tagName.toLowerCase()==="button"}function fs(e){return fr(e)&&e.tagName.toLowerCase()==="form"}function hs(e){return fr(e)&&e.tagName.toLowerCase()==="input"}function ms(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ps(e,t){return e.button===0&&(!t||t==="_self")&&!ms(e)}function $r(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let a=e[r];return t.concat(Array.isArray(a)?a.map(n=>[r,n]):[[r,a]])},[]))}function ys(e,t){let r=$r(e);return t&&t.forEach((a,n)=>{r.has(n)||t.getAll(n).forEach(o=>{r.append(n,o)})}),r}var zt=null;function vs(){if(zt===null)try{new FormData(document.createElement("form"),0),zt=!1}catch{zt=!0}return zt}var gs=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Cr(e){return e!=null&&!gs.has(e)?(K(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Kt}"`),null):e}function ws(e,t){let r,a,n,o,i;if(fs(e)){let s=e.getAttribute("action");a=s?ne(s,t):null,r=e.getAttribute("method")||Jt,n=Cr(e.getAttribute("enctype"))||Kt,o=new FormData(e)}else if(ds(e)||hs(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||s.getAttribute("action");if(a=l?ne(l,t):null,r=e.getAttribute("formmethod")||s.getAttribute("method")||Jt,n=Cr(e.getAttribute("formenctype"))||Cr(s.getAttribute("enctype"))||Kt,o=new FormData(s,e),!vs()){let{name:u,type:c,value:d}=e;if(c==="image"){let m=u?`${u}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else u&&o.append(u,d)}}else{if(fr(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Jt,a=null,n=Kt,i=e}return o&&n==="text/plain"&&(i=o,o=void 0),{action:a,method:r.toLowerCase(),encType:n,formData:o,body:i}}var yo=-1,vo=-2,go=-3,wo=-4,ua=-5,Ro=-6,Eo=-7,bo="B",So="D",ft="E",Ir="M",Co="N",ht="P",xo="R",Hr="S",Po="Y",Lo="U",jr="Z",Do=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};function Rs(){const e=new TextDecoder;let t="";return new TransformStream({transform(r,a){const n=e.decode(r,{stream:!0}),o=(t+n).split(`
|